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§
Source§impl<R, O, M> CompositeContext<R, O, M>
impl<R, O, M> CompositeContext<R, O, M>
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§
Source§impl<R, O, M> Clone for CompositeContext<R, O, M>
impl<R, O, M> Clone for CompositeContext<R, O, M>
Source§impl<R, O, M> Context for CompositeContext<R, O, M>
impl<R, O, M> Context for CompositeContext<R, O, M>
Source§fn 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 moreSource§fn 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 moreSource§fn offload<F>(&self, fut: F) -> SendBoxFuture<F::Item, F::Error>
fn offload<F>(&self, fut: F) -> SendBoxFuture<F::Item, F::Error>
offloads the execution of the future
fut
to somewhere else e.g. a cpu poolSource§fn generate_content_id(&self) -> ContentId
fn generate_content_id(&self) -> ContentId
generate a unique content id Read more
Source§fn generate_message_id(&self) -> MessageId
fn generate_message_id(&self) -> MessageId
generate a unique content id Read more
Source§fn offload_fn<FN, I>(&self, func: FN) -> SendBoxFuture<I::Item, I::Error>
fn offload_fn<FN, I>(&self, func: FN) -> SendBoxFuture<I::Item, I::Error>
offloads the execution of the function
func
to somewhere else e.g. a cpu poolSource§impl<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> Freeze for CompositeContext<R, O, M>
impl<R, O, M> RefUnwindSafe for CompositeContext<R, O, M>
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>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> HeaderTryFrom<T> for T
impl<T> HeaderTryFrom<T> for T
fn try_from(val: T) -> Result<T, ComponentCreationError>
Source§impl<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>
Source§impl<C> MailIdGenComponent for Cwhere
C: Context,
impl<C> MailIdGenComponent for Cwhere
C: Context,
Source§fn generate_message_id(&self) -> MessageId
fn generate_message_id(&self) -> MessageId
Calls to
Context::generate_message_id
will be forwarded to this method.Source§fn generate_content_id(&self) -> MessageId
fn generate_content_id(&self) -> MessageId
Calls to
Context::generate_content_id
will be forwarded to this method.Source§impl<C> OffloaderComponent for Cwhere
C: Context,
impl<C> OffloaderComponent for Cwhere
C: Context,
Source§impl<C> ResourceLoaderComponent for Cwhere
C: Context,
impl<C> ResourceLoaderComponent for Cwhere
C: Context,
Source§fn load_resource(
&self,
source: &Source,
_: &impl Context,
) -> Box<dyn Future<Item = MaybeEncData, Error = ResourceLoadingError> + Send>
fn load_resource( &self, source: &Source, _: &impl Context, ) -> Box<dyn Future<Item = MaybeEncData, Error = ResourceLoadingError> + Send>
Calls to
Context::load_resource
will be forwarded to this method. Read more