pub struct Context<T> { /* private fields */ }Expand description
Context passed to watchers containing the value and associated metadata.
Implementations§
Source§impl<T> Context<T>
impl<T> Context<T>
Sourcepub const fn new(value: T, metadata: Metadata) -> Self
pub const fn new(value: T, metadata: Metadata) -> Self
Creates a new context with the given value and metadata.
Sourcepub fn with<V: Clone + 'static>(self, value: V) -> Self
pub fn with<V: Clone + 'static>(self, value: V) -> Self
Adds additional metadata to this context.
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Consumes the context and returns the inner value.
Sourcepub const fn metadata_mut(&mut self) -> &mut Metadata
pub const fn metadata_mut(&mut self) -> &mut Metadata
Returns a mutable reference to the metadata.
Sourcepub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Context<U>
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Context<U>
Maps the inner value to a new value.
Sourcepub fn as_mut(&mut self) -> Context<&mut T>
pub fn as_mut(&mut self) -> Context<&mut T>
Returns a new context with a mutable reference to the inner value.
Sourcepub fn as_deref(&self) -> Context<&T::Target>where
T: Deref,
pub fn as_deref(&self) -> Context<&T::Target>where
T: Deref,
Returns a new context with a reference to the dereferenced inner value.
Sourcepub fn as_deref_mut(&mut self) -> Context<&mut T::Target>where
T: DerefMut,
pub fn as_deref_mut(&mut self) -> Context<&mut T::Target>where
T: DerefMut,
Returns a new context with a mutable reference to the dereferenced inner value.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Context<T>where
T: Freeze,
impl<T> !RefUnwindSafe for Context<T>
impl<T> !Send for Context<T>
impl<T> !Sync for Context<T>
impl<T> Unpin for Context<T>where
T: Unpin,
impl<T> !UnwindSafe for Context<T>
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