pub trait Resource {
// Required methods
fn resource_id(&self) -> &str;
fn next_resource_id<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
This trait represents a Resource against which we’d like to perform an access control check. Each call to next_resource_id() will produce the identifier of the resource which is being checked, following its child -> parent relationship.
So a hypothetical filesystem path resource of /foo/bar/baz
would return on each successive call:
Some("/foo/bar/baz")
Some("/foo/bar")
Some("/foo")
Some("/")
None
so that the ACL checker knows how to resolve the resources up to their containing root.
This trait is essentially an asynchronous iterator.
Required Methods§
Sourcefn resource_id(&self) -> &str
fn resource_id(&self) -> &str
Returns the resource to which access is desired
Sourcefn next_resource_id<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next_resource_id<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns the next resource in the inheritance hierarchy; starts with the targeted resource_id and walks through its parents.