Skip to main content

TypedContextExt

Trait TypedContextExt 

Source
pub trait TypedContextExt {
    // Required methods
    fn read_typed<T: DeserializeOwned>(
        &self,
        key: &ContextKey,
    ) -> Result<Option<T>, ContextError>;
    fn write_typed<T: Serialize>(
        &mut self,
        key: ContextKey,
        value: &T,
    ) -> Result<(), ContextError>;
}
Expand description

Typed convenience extension (no default bodies; implementations may blanket-impl internally).

Required Methods§

Source

fn read_typed<T: DeserializeOwned>( &self, key: &ContextKey, ) -> Result<Option<T>, ContextError>

Reads a context value and deserializes it into T.

Source

fn write_typed<T: Serialize>( &mut self, key: ContextKey, value: &T, ) -> Result<(), ContextError>

Serializes value and writes it into context.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§