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§
sourcefn default_key() -> &'static str
fn default_key() -> &'static str
The default key at which this context resides in Contexts
.
sourcefn from_context(context: Context) -> Option<Self>
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
.
sourcefn cast(context: &Context) -> Option<&Self>
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
.
sourcefn cast_mut(context: &mut Context) -> Option<&mut Self>
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
.
sourcefn into_context(self) -> Context
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.