relay_event_schema::protocol

Trait AsPair

Source
pub trait AsPair {
    type Key: AsRef<str>;
    type Value: ProcessValue;

    // Required methods
    fn from_pair(pair: (Annotated<Self::Key>, Annotated<Self::Value>)) -> Self;
    fn into_pair(self) -> (Annotated<Self::Key>, Annotated<Self::Value>);
    fn as_pair(&self) -> (&Annotated<Self::Key>, &Annotated<Self::Value>);
    fn as_pair_mut(
        &mut self,
    ) -> (&mut Annotated<Self::Key>, &mut Annotated<Self::Value>);

    // Provided methods
    fn key(&self) -> Option<&str> { ... }
    fn value(&self) -> Option<&Self::Value> { ... }
}
Expand description

A trait to abstract over pairs.

Required Associated Types§

Required Methods§

Source

fn from_pair(pair: (Annotated<Self::Key>, Annotated<Self::Value>)) -> Self

Constructs this value from a raw tuple.

Source

fn into_pair(self) -> (Annotated<Self::Key>, Annotated<Self::Value>)

Converts this pair into a raw tuple.

Source

fn as_pair(&self) -> (&Annotated<Self::Key>, &Annotated<Self::Value>)

Extracts a key and value pair from the object.

Source

fn as_pair_mut( &mut self, ) -> (&mut Annotated<Self::Key>, &mut Annotated<Self::Value>)

Extracts the mutable key and value pair from the object.

Provided Methods§

Source

fn key(&self) -> Option<&str>

Returns a reference to the string representation of the key.

Source

fn value(&self) -> Option<&Self::Value>

Returns a reference to the value.

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.

Implementations on Foreign Types§

Source§

impl<K, V> AsPair for (Annotated<K>, Annotated<V>)
where K: AsRef<str>, V: ProcessValue,

Source§

type Key = K

Source§

type Value = V

Source§

fn from_pair(pair: (Annotated<Self::Key>, Annotated<Self::Value>)) -> Self

Source§

fn into_pair(self) -> (Annotated<Self::Key>, Annotated<Self::Value>)

Source§

fn as_pair(&self) -> (&Annotated<Self::Key>, &Annotated<Self::Value>)

Source§

fn as_pair_mut( &mut self, ) -> (&mut Annotated<Self::Key>, &mut Annotated<Self::Value>)

Implementors§