Struct mail_core::context::CompositeContext
source · pub struct CompositeContext<R: ResourceLoaderComponent, O: OffloaderComponent, M: MailIdGenComponent> { /* private fields */ }
Expand description
The CompositeContext
is the simplest way to get an Context
implementation.
Any custom Context
implementations should be realized through the CompositeContext
if possible.
This type consists of 3 components it forward all method calls from Context
to.
This allows the library to have a single Context
type but match and mix the
parts about resource loading, offloading and id generation in whichever way
it fits best.
The composite context will store the components inside of an Arc
so that
it can be easily shared through an application, it also means non of the
components have to implement Clone
.
Implementations
sourceimpl<R, O, M> CompositeContext<R, O, M>where
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
impl<R, O, M> CompositeContext<R, O, M>where
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
sourcepub fn new(resource_loader: R, offloader: O, message_id_gen: M) -> Self
pub fn new(resource_loader: R, offloader: O, message_id_gen: M) -> Self
Create a new context from the given components.
sourcepub fn resource_loader(&self) -> &R
pub fn resource_loader(&self) -> &R
Returns a reference to the resource loader component.
Trait Implementations
sourceimpl<R, O, M> Clone for CompositeContext<R, O, M>where
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
impl<R, O, M> Clone for CompositeContext<R, O, M>where
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
sourceimpl<R, O, M> Context for CompositeContext<R, O, M>where
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
impl<R, O, M> Context for CompositeContext<R, O, M>where
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
sourcefn load_resource(
&self,
source: &Source
) -> SendBoxFuture<MaybeEncData, ResourceLoadingError>
fn load_resource(
&self,
source: &Source
) -> SendBoxFuture<MaybeEncData, ResourceLoadingError>
Loads and transfer encodes a
Data
instance. Read moresourcefn load_transfer_encoded_resource(
&self,
resource: &Resource
) -> SendBoxFuture<EncData, ResourceLoadingError>
fn load_transfer_encoded_resource(
&self,
resource: &Resource
) -> SendBoxFuture<EncData, ResourceLoadingError>
Loads and Transfer encodes a
Resource
instance. Read moresourcefn offload<F>(&self, fut: F) -> SendBoxFuture<F::Item, F::Error>where
F: Future + Send + 'static,
F::Item: Send + 'static,
F::Error: Send + 'static,
fn offload<F>(&self, fut: F) -> SendBoxFuture<F::Item, F::Error>where
F: Future + Send + 'static,
F::Item: Send + 'static,
F::Error: Send + 'static,
offloads the execution of the future
fut
to somewhere else e.g. a cpu poolsourcefn generate_content_id(&self) -> ContentId
fn generate_content_id(&self) -> ContentId
generate a unique content id Read more
sourcefn generate_message_id(&self) -> MessageId
fn generate_message_id(&self) -> MessageId
generate a unique content id Read more
sourcefn offload_fn<FN, I>(&self, func: FN) -> SendBoxFuture<I::Item, I::Error>where
FN: FnOnce() -> I + Send + 'static,
I: IntoFuture + 'static,
I::Future: Send + 'static,
I::Item: Send + 'static,
I::Error: Send + 'static,
fn offload_fn<FN, I>(&self, func: FN) -> SendBoxFuture<I::Item, I::Error>where
FN: FnOnce() -> I + Send + 'static,
I: IntoFuture + 'static,
I::Future: Send + 'static,
I::Item: Send + 'static,
I::Error: Send + 'static,
offloads the execution of the function
func
to somewhere else e.g. a cpu poolsourceimpl<R: Debug + ResourceLoaderComponent, O: Debug + OffloaderComponent, M: Debug + MailIdGenComponent> Debug for CompositeContext<R, O, M>
impl<R: Debug + ResourceLoaderComponent, O: Debug + OffloaderComponent, M: Debug + MailIdGenComponent> Debug for CompositeContext<R, O, M>
Auto Trait Implementations
impl<R, O, M> RefUnwindSafe for CompositeContext<R, O, M>where
M: RefUnwindSafe,
O: RefUnwindSafe,
R: RefUnwindSafe,
impl<R, O, M> Send for CompositeContext<R, O, M>
impl<R, O, M> Sync for CompositeContext<R, O, M>
impl<R, O, M> Unpin for CompositeContext<R, O, M>
impl<R, O, M> UnwindSafe for CompositeContext<R, O, M>where
M: RefUnwindSafe,
O: RefUnwindSafe,
R: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> HeaderTryFrom<T> for T
impl<T> HeaderTryFrom<T> for T
fn try_from(val: T) -> Result<T, ComponentCreationError>
sourceimpl<F, T> HeaderTryInto<T> for Fwhere
T: HeaderTryFrom<F>,
impl<F, T> HeaderTryInto<T> for Fwhere
T: HeaderTryFrom<F>,
fn try_into(self) -> Result<T, ComponentCreationError>
sourceimpl<C> MailIdGenComponent for Cwhere
C: Context,
impl<C> MailIdGenComponent for Cwhere
C: Context,
sourcefn generate_message_id(&self) -> MessageId
fn generate_message_id(&self) -> MessageId
Calls to
Context::generate_message_id
will be forwarded to this method.sourcefn generate_content_id(&self) -> MessageId
fn generate_content_id(&self) -> MessageId
Calls to
Context::generate_content_id
will be forwarded to this method.sourceimpl<C> OffloaderComponent for Cwhere
C: Context,
impl<C> OffloaderComponent for Cwhere
C: Context,
sourcefn offload<F>(
&self,
fut: F
) -> Box<dyn Future<Error = <F as Future>::Error, Item = <F as Future>::Item> + Send + 'static, Global>where
F: 'static + Future + Send,
<F as Future>::Item: 'static + Send,
<F as Future>::Error: 'static + Send,
fn offload<F>(
&self,
fut: F
) -> Box<dyn Future<Error = <F as Future>::Error, Item = <F as Future>::Item> + Send + 'static, Global>where
F: 'static + Future + Send,
<F as Future>::Item: 'static + Send,
<F as Future>::Error: 'static + Send,
Calls to
Context::offload
and Context::offload_fn
will be forwarded to this method.sourceimpl<C> ResourceLoaderComponent for Cwhere
C: Context,
impl<C> ResourceLoaderComponent for Cwhere
C: Context,
sourcefn load_resource(
&self,
source: &Source,
_: &impl Context
) -> Box<dyn Future<Error = ResourceLoadingError, Item = MaybeEncData> + Send + 'static, Global>
fn load_resource(
&self,
source: &Source,
_: &impl Context
) -> Box<dyn Future<Error = ResourceLoadingError, Item = MaybeEncData> + Send + 'static, Global>
Calls to
Context::load_resource
will be forwarded to this method. Read more