Trait mail::ContainedResourcesAccess
source · pub trait ContainedResourcesAccess {
type Key: ToOwned + ?Sized;
fn visit_resources(&self, visitor: &mut impl FnMut(&Self::Key, &Resource));
fn access_resource_mut<R>(
&mut self,
key: &Self::Key,
modify: impl FnOnce(Option<&mut Resource>) -> R
) -> R;
fn access_resource<R>(
&self,
key: &Self::Key,
modify: impl FnOnce(Option<&Resource>) -> R
) -> R;
}
Required Associated Types
Required Methods
sourcefn visit_resources(&self, visitor: &mut impl FnMut(&Self::Key, &Resource))
fn visit_resources(&self, visitor: &mut impl FnMut(&Self::Key, &Resource))
Visit all resources.
This method is not allowed to be implemented in a way that
it might visit resources, which are not accessable with
[Self.access_resource_mut()
]. This means that without
e.g. a RwLock
this can not visit resources in a Arc
.
sourcefn access_resource_mut<R>(
&mut self,
key: &Self::Key,
modify: impl FnOnce(Option<&mut Resource>) -> R
) -> R
fn access_resource_mut<R>(
&mut self,
key: &Self::Key,
modify: impl FnOnce(Option<&mut Resource>) -> R
) -> R
Return a mut ref for a resource based on given key.
If a resource is visited in a Self.visit_resources()
call
and the state of self was not changes this method has to
be able to return a mut reference to it.
To allow accessing resources in a mutext this does pass the mut ref to a closure instead of returning it.
Implementations on Foreign Types
sourceimpl ContainedResourcesAccess for HashMap<String, Resource, RandomState>
impl ContainedResourcesAccess for HashMap<String, Resource, RandomState>
sourcefn access_resource<R>(
&self,
key: &<HashMap<String, Resource, RandomState> as ContainedResourcesAccess>::Key,
modify: impl FnOnce(Option<&Resource>) -> R
) -> R
fn access_resource<R>(
&self,
key: &<HashMap<String, Resource, RandomState> as ContainedResourcesAccess>::Key,
modify: impl FnOnce(Option<&Resource>) -> R
) -> R
Return a ref for a resource base on given key.
type Key = str
fn visit_resources(
&self,
visitor: &mut impl FnMut(&<HashMap<String, Resource, RandomState> as ContainedResourcesAccess>::Key, &Resource)
)
fn access_resource_mut<R>(
&mut self,
key: &<HashMap<String, Resource, RandomState> as ContainedResourcesAccess>::Key,
modify: impl FnOnce(Option<&mut Resource>) -> R
) -> R
sourceimpl ContainedResourcesAccess for Vec<Resource, Global>
impl ContainedResourcesAccess for Vec<Resource, Global>
sourcefn access_resource<R>(
&self,
key: &<Vec<Resource, Global> as ContainedResourcesAccess>::Key,
modify: impl FnOnce(Option<&Resource>) -> R
) -> R
fn access_resource<R>(
&self,
key: &<Vec<Resource, Global> as ContainedResourcesAccess>::Key,
modify: impl FnOnce(Option<&Resource>) -> R
) -> R
Return a ref for a resource base on given key.