pub struct ExtensionContainer { /* private fields */ }
Expand description
Contains extensions
Implementations§
Source§impl ExtensionContainer
impl ExtensionContainer
Sourcepub fn add<E, S>(&mut self, name: S, value: E) -> Result<(), ExtensionError>
pub fn add<E, S>(&mut self, name: S, value: E) -> Result<(), ExtensionError>
Adds a new extension to this container
§Error
Will return an error if name
is already registered to this container
Sourcepub fn get<S>(
&self,
name: S,
) -> Result<&Box<dyn Any + Sync + Send>, PayloadError<ProjectError>>
pub fn get<S>( &self, name: S, ) -> Result<&Box<dyn Any + Sync + Send>, PayloadError<ProjectError>>
Gets a reference to an extension, if it exists
Sourcepub fn get_mut<S>(
&mut self,
name: S,
) -> Result<&mut Box<dyn Any + Sync + Send>, PayloadError<ProjectError>>
pub fn get_mut<S>( &mut self, name: S, ) -> Result<&mut Box<dyn Any + Sync + Send>, PayloadError<ProjectError>>
Gets a mutable reference to an extension, if it exists
Sourcepub fn get_by_type<E>(&self) -> Result<&E, PayloadError<ProjectError>>where
E: Extension,
pub fn get_by_type<E>(&self) -> Result<&E, PayloadError<ProjectError>>where
E: Extension,
If a single extension is registered with a given type, a reference to that value is returned
as Ok(_)
Sourcepub fn get_by_type_mut<E>(
&mut self,
) -> Result<&mut E, PayloadError<ProjectError>>where
E: Extension,
pub fn get_by_type_mut<E>(
&mut self,
) -> Result<&mut E, PayloadError<ProjectError>>where
E: Extension,
If a single extension is registered with a given type, a mutable reference to that value is returned
as Some(_)
Trait Implementations§
Source§impl Debug for ExtensionContainer
impl Debug for ExtensionContainer
Source§impl Default for ExtensionContainer
impl Default for ExtensionContainer
Source§fn default() -> ExtensionContainer
fn default() -> ExtensionContainer
Returns the “default value” for a type. Read more
Source§impl Index<&str> for ExtensionContainer
impl Index<&str> for ExtensionContainer
Source§impl Index<String> for ExtensionContainer
impl Index<String> for ExtensionContainer
Source§impl IndexMut<&str> for ExtensionContainer
impl IndexMut<&str> for ExtensionContainer
Auto Trait Implementations§
impl Freeze for ExtensionContainer
impl !RefUnwindSafe for ExtensionContainer
impl Send for ExtensionContainer
impl Sync for ExtensionContainer
impl Unpin for ExtensionContainer
impl !UnwindSafe for ExtensionContainer
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> InstanceOf for T
impl<T> InstanceOf for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more