pub trait DictExt {
// Required methods
fn get_capability(&self, path: &impl IterablePath) -> Option<Capability>;
fn get_router_or_not_found<T>(
&self,
path: &impl IterablePath,
not_found_error: RoutingError,
) -> Router<T>
where T: CapabilityBound,
Router<T>: TryFrom<Capability>;
fn insert_capability(
&self,
path: &impl IterablePath,
capability: Capability,
) -> Result<(), CapabilityStoreError>;
fn remove_capability(&self, path: &impl IterablePath);
fn get_with_request<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
moniker: &'life1 ExtendedMoniker,
path: &'a (impl 'async_trait + IterablePath),
request: Option<Request>,
debug: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<GenericRouterResponse>, RouterError>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Required Methods§
Sourcefn get_capability(&self, path: &impl IterablePath) -> Option<Capability>
fn get_capability(&self, path: &impl IterablePath) -> Option<Capability>
Returns the capability at the path, if it exists. Returns None
if path is empty.
Sourcefn get_router_or_not_found<T>(
&self,
path: &impl IterablePath,
not_found_error: RoutingError,
) -> Router<T>
fn get_router_or_not_found<T>( &self, path: &impl IterablePath, not_found_error: RoutingError, ) -> Router<T>
Looks up a top-level router in this Dict with return type T
. If it’s not found (or it’s
not a router) returns a router that always returns not_found_error
. If path
has one
segment and a router was found, returns that router.
If path
is a multi-segment path, the returned router performs a Dict lookup with the
remaining path relative to the top-level router (see [LazyGet::lazy_get]).
REQUIRES: path
is not empty.
Sourcefn insert_capability(
&self,
path: &impl IterablePath,
capability: Capability,
) -> Result<(), CapabilityStoreError>
fn insert_capability( &self, path: &impl IterablePath, capability: Capability, ) -> Result<(), CapabilityStoreError>
Inserts the capability at the path. Intermediary dictionaries are created as needed.
Sourcefn remove_capability(&self, path: &impl IterablePath)
fn remove_capability(&self, path: &impl IterablePath)
Removes the capability at the path, if it exists.
Sourcefn get_with_request<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
moniker: &'life1 ExtendedMoniker,
path: &'a (impl 'async_trait + IterablePath),
request: Option<Request>,
debug: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<GenericRouterResponse>, RouterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_with_request<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
moniker: &'life1 ExtendedMoniker,
path: &'a (impl 'async_trait + IterablePath),
request: Option<Request>,
debug: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<GenericRouterResponse>, RouterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Looks up the element at path
. When encountering an intermediate router, use request
to
request the underlying capability from it. In contrast, get_capability
will return
None
.
Note that the return value can contain any capability type, instead of a parameterized T
.
This is because some callers work with a generic capability and don’t care about the
specific type. Callers who do care can use TryFrom
to cast to the expected
RouterResponse type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.