[−][src]Struct mail_core::context::CompositeContext
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
.
Methods
impl<R, O, M> CompositeContext<R, O, M> where
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
[src]
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
pub fn new(resource_loader: R, offloader: O, message_id_gen: M) -> Self
[src]
Create a new context from the given components.
pub fn resource_loader(&self) -> &R
[src]
Returns a reference to the resource loader component.
pub fn offloader(&self) -> &O
[src]
Returns a reference to the offloader component.
pub fn id_gen(&self) -> &M
[src]
Returns a reference to the id generation component.
Trait Implementations
impl<R, O, M> Context for CompositeContext<R, O, M> where
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
[src]
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
fn load_resource(
&self,
source: &Source
) -> SendBoxFuture<MaybeEncData, ResourceLoadingError>
[src]
&self,
source: &Source
) -> SendBoxFuture<MaybeEncData, ResourceLoadingError>
fn load_transfer_encoded_resource(
&self,
resource: &Resource
) -> SendBoxFuture<EncData, ResourceLoadingError>
[src]
&self,
resource: &Resource
) -> SendBoxFuture<EncData, ResourceLoadingError>
fn offload<F>(&self, fut: F) -> SendBoxFuture<F::Item, F::Error> where
F: Future + Send + 'static,
F::Item: Send + 'static,
F::Error: Send + 'static,
[src]
F: Future + Send + 'static,
F::Item: Send + 'static,
F::Error: Send + 'static,
fn generate_content_id(&self) -> ContentId
[src]
fn generate_message_id(&self) -> MessageId
[src]
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,
[src]
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 pool
impl<R, O, M> Clone for CompositeContext<R, O, M> where
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
[src]
R: ResourceLoaderComponent,
O: OffloaderComponent,
M: MailIdGenComponent,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<R: Debug + ResourceLoaderComponent, O: Debug + OffloaderComponent, M: Debug + MailIdGenComponent> Debug for CompositeContext<R, O, M>
[src]
Auto Trait Implementations
impl<R, O, M> Send for CompositeContext<R, O, M>
impl<R, O, M> Sync for CompositeContext<R, O, M>
Blanket Implementations
impl<C> ResourceLoaderComponent for C where
C: Context,
[src]
C: Context,
fn load_resource<impl Context>(
&Self,
&Source,
&impl Context
) -> Box<dyn Future<Item = MaybeEncData, Error = ResourceLoadingError> + 'static + Send> where
impl Context: Context,
[src]
&Self,
&Source,
&impl Context
) -> Box<dyn Future<Item = MaybeEncData, Error = ResourceLoadingError> + 'static + Send> where
impl Context: Context,
fn load_transfer_encoded_resource<impl Context>(
&Self,
&Resource,
&impl Context
) -> Box<dyn Future<Item = EncData, Error = ResourceLoadingError> + 'static + Send> where
impl Context: Context,
[src]
&Self,
&Resource,
&impl Context
) -> Box<dyn Future<Item = EncData, Error = ResourceLoadingError> + 'static + Send> where
impl Context: Context,
impl<C> OffloaderComponent for C where
C: Context,
[src]
C: Context,
fn offload<F>(
&Self,
F
) -> Box<dyn Future<Item = <F as Future>::Item, Error = <F as Future>::Error> + 'static + Send> where
F: Future + Send + 'static,
<F as Future>::Item: Send,
<F as Future>::Item: 'static,
<F as Future>::Error: Send,
<F as Future>::Error: 'static,
[src]
&Self,
F
) -> Box<dyn Future<Item = <F as Future>::Item, Error = <F as Future>::Error> + 'static + Send> where
F: Future + Send + 'static,
<F as Future>::Item: Send,
<F as Future>::Item: 'static,
<F as Future>::Error: Send,
<F as Future>::Error: 'static,
impl<C> MailIdGenComponent for C where
C: Context,
[src]
C: Context,
fn generate_message_id(&Self) -> MessageId
[src]
fn generate_content_id(&Self) -> MessageId
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<F, T> HeaderTryInto for F where
T: HeaderTryFrom<F>,
[src]
T: HeaderTryFrom<F>,