relay_event_schema::protocol

Trait DefaultContext

source
pub trait DefaultContext: Default {
    // Required methods
    fn default_key() -> &'static str;
    fn from_context(context: Context) -> Option<Self>;
    fn cast(context: &Context) -> Option<&Self>;
    fn cast_mut(context: &mut Context) -> Option<&mut Self>;
    fn into_context(self) -> Context;
}
Expand description

A well-known context in the Contexts interface.

These contexts have a default key in the contexts map and can be constructed as an empty default value.

Required Methods§

source

fn default_key() -> &'static str

The default key at which this context resides in Contexts.

source

fn from_context(context: Context) -> Option<Self>

Converts this context type from a generic context type.

Returns Some if the context is of this type. Otherwise, returns None.

source

fn cast(context: &Context) -> Option<&Self>

Casts a reference to this context type from a generic context type.

Returns Some if the context is of this type. Otherwise, returns None.

source

fn cast_mut(context: &mut Context) -> Option<&mut Self>

Casts a mutable reference to this context type from a generic context type.

Returns Some if the context is of this type. Otherwise, returns None.

source

fn into_context(self) -> Context

Boxes this context type in the generic context wrapper.

Returns Some if the context is of this type. Otherwise, returns None.

Object Safety§

This trait is not object safe.

Implementors§