pub trait ContainedResourcesAccess {
type Key: ToOwned + ?Sized;
// Required methods
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;
}
Expand description
Re-export of all parts of the mail_core
crate.
Some parts like error
/default_impl
will get overridden.
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.
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.
Implementations on Foreign Types§
Source§impl ContainedResourcesAccess for Vec<Resource>
impl ContainedResourcesAccess for Vec<Resource>
Source§fn access_resource<R>(
&self,
key: &<Vec<Resource> as ContainedResourcesAccess>::Key,
modify: impl FnOnce(Option<&Resource>) -> R,
) -> R
fn access_resource<R>( &self, key: &<Vec<Resource> as ContainedResourcesAccess>::Key, modify: impl FnOnce(Option<&Resource>) -> R, ) -> R
Return a ref for a resource base on given key.
type Key = usize
fn visit_resources( &self, visitor: &mut impl FnMut(&<Vec<Resource> as ContainedResourcesAccess>::Key, &Resource), )
fn access_resource_mut<R>( &mut self, key: &<Vec<Resource> as ContainedResourcesAccess>::Key, modify: impl FnOnce(Option<&mut Resource>) -> R, ) -> R
Source§impl ContainedResourcesAccess for HashMap<String, Resource>
impl ContainedResourcesAccess for HashMap<String, Resource>
Source§fn access_resource<R>(
&self,
key: &<HashMap<String, Resource> as ContainedResourcesAccess>::Key,
modify: impl FnOnce(Option<&Resource>) -> R,
) -> R
fn access_resource<R>( &self, key: &<HashMap<String, Resource> as ContainedResourcesAccess>::Key, modify: impl FnOnce(Option<&Resource>) -> R, ) -> R
Return a ref for a resource base on given key.