Struct relay_event_schema::protocol::Contexts
source · pub struct Contexts(pub Object<ContextInner>);
Expand description
The Contexts interface provides additional context data. Typically, this is data related to the
current user and the environment. For example, the device or application version. Its canonical
name is contexts
.
The contexts
type can be used to define arbitrary contextual data on the event. It accepts an
object of key/value pairs. The key is the “alias” of the context and can be freely chosen.
However, as per policy, it should match the type of the context unless there are two values for
a type. You can omit type
if the key name is the type.
Unknown data for the contexts is rendered as a key/value list.
For more details about sending additional data with your event, see the full documentation on Additional Data.
Tuple Fields§
§0: Object<ContextInner>
Implementations§
source§impl Contexts
impl Contexts
sourcepub fn add<C>(&mut self, context: C)where
C: DefaultContext,
pub fn add<C>(&mut self, context: C)where
C: DefaultContext,
Inserts a context under the default key for the context.
sourcepub fn insert(&mut self, key: String, context: Context)
pub fn insert(&mut self, key: String, context: Context)
Inserts a context under a custom given key.
By convention, every typed context has a default key. Use add
to insert such
contexts, instead.
sourcepub fn contains<C>(&self) -> boolwhere
C: DefaultContext,
pub fn contains<C>(&self) -> boolwhere
C: DefaultContext,
Returns true
if a matching context resides in the map at its default key.
sourcepub fn contains_key<S>(&self, key: S) -> bool
pub fn contains_key<S>(&self, key: S) -> bool
Returns true
if a context with the provided key is present in the map.
By convention, every typed context has a default key. Use contains
to
check such contexts, instead.
sourcepub fn get_or_default<C>(&mut self) -> &mut Cwhere
C: DefaultContext,
pub fn get_or_default<C>(&mut self) -> &mut Cwhere
C: DefaultContext,
Returns the context at its default key or constructs it if not present.
sourcepub fn get_or_insert_with<F, S>(
&mut self,
key: S,
context_builder: F,
) -> &mut Context
pub fn get_or_insert_with<F, S>( &mut self, key: S, context_builder: F, ) -> &mut Context
Returns the context at the specified key or constructs it if not present.
By convention, every typed context has a default key. Use
get_or_default
to insert such contexts, instead.
sourcepub fn get<C>(&self) -> Option<&C>where
C: DefaultContext,
pub fn get<C>(&self) -> Option<&C>where
C: DefaultContext,
Returns a reference to the default context by type.
sourcepub fn get_mut<C>(&mut self) -> Option<&mut C>where
C: DefaultContext,
pub fn get_mut<C>(&mut self) -> Option<&mut C>where
C: DefaultContext,
Returns a mutable reference to the default context by type.
sourcepub fn get_key<S>(&self, key: S) -> Option<&Context>
pub fn get_key<S>(&self, key: S) -> Option<&Context>
Returns a reference to the context specified by key
.
By convention, every typed context has a default key. Use get
to retrieve
such contexts, instead.
sourcepub fn get_key_mut<S>(&mut self, key: S) -> Option<&mut Context>
pub fn get_key_mut<S>(&mut self, key: S) -> Option<&mut Context>
Returns a mutable reference to the context specified by key
.
By convention, every typed context has a default key. Use get_mut
to
retrieve such contexts, instead.
sourcepub fn remove<C>(&mut self) -> Option<C>where
C: DefaultContext,
pub fn remove<C>(&mut self) -> Option<C>where
C: DefaultContext,
Removes a context from the map, returning the context it was previously in the map.
Returns Some
if a matching context was removed from the default key. If the context at the
default key does not have a matching type, it is removed but None
is returned.
Trait Implementations§
source§impl FromValue for Contexts
impl FromValue for Contexts
source§fn from_value(annotated: Annotated<Value>) -> Annotated<Self>
fn from_value(annotated: Annotated<Value>) -> Annotated<Self>
source§impl IntoValue for Contexts
impl IntoValue for Contexts
source§fn into_value(self) -> Value
fn into_value(self) -> Value
source§fn serialize_payload<S>(
&self,
__serializer: S,
__behavior: SkipSerialization,
) -> Result<S::Ok, S::Error>where
Self: Sized,
S: Serializer,
fn serialize_payload<S>(
&self,
__serializer: S,
__behavior: SkipSerialization,
) -> Result<S::Ok, S::Error>where
Self: Sized,
S: Serializer,
source§fn extract_child_meta(&self) -> MetaMapwhere
Self: Sized,
fn extract_child_meta(&self) -> MetaMapwhere
Self: Sized,
§fn extract_meta_tree(value: &Annotated<Self>) -> MetaTreewhere
Self: Sized,
fn extract_meta_tree(value: &Annotated<Self>) -> MetaTreewhere
Self: Sized,
source§impl ProcessValue for Contexts
impl ProcessValue for Contexts
source§fn value_type(&self) -> EnumSet<ValueType>
fn value_type(&self) -> EnumSet<ValueType>
source§fn process_value<P>(
&mut self,
__meta: &mut Meta,
__processor: &mut P,
__state: &ProcessingState<'_>,
) -> ProcessingResultwhere
P: Processor,
fn process_value<P>(
&mut self,
__meta: &mut Meta,
__processor: &mut P,
__state: &ProcessingState<'_>,
) -> ProcessingResultwhere
P: Processor,
source§fn process_child_values<P>(
&mut self,
__processor: &mut P,
__state: &ProcessingState<'_>,
) -> ProcessingResultwhere
P: Processor,
fn process_child_values<P>(
&mut self,
__processor: &mut P,
__state: &ProcessingState<'_>,
) -> ProcessingResultwhere
P: Processor,
impl StructuralPartialEq for Contexts
Auto Trait Implementations§
impl Freeze for Contexts
impl RefUnwindSafe for Contexts
impl Send for Contexts
impl Sync for Contexts
impl Unpin for Contexts
impl UnwindSafe for Contexts
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)