[][src]Struct opentelemetry::api::Baggage

pub struct Baggage { /* fields omitted */ }

A set of name/value pairs describing user-defined properties across systems.

Implementations

impl Baggage[src]

pub fn new() -> Self[src]

Creates an empty Baggage.

pub fn get<T: Into<Key>>(&self, key: T) -> Option<&Value>[src]

Returns a reference to the value associated with a given name

Examples

use opentelemetry::api::{Baggage, Value};

let mut cc = Baggage::new();
let _ = cc.insert("my-name", "my-value");

assert_eq!(cc.get("my-name"), Some(&Value::String("my-value".to_string())))

pub fn insert<K, V>(&mut self, key: K, value: V) -> Option<Value> where
    K: Into<Key>,
    V: Into<Value>, 
[src]

Inserts a name-value pair into the baggage.

If the name was not present, None is returned. If the name was present, the value is updated, and the old value is returned.

Examples

use opentelemetry::api::{Baggage, Value};

let mut cc = Baggage::new();
let _ = cc.insert("my-name", "my-value");

assert_eq!(cc.get("my-name"), Some(&Value::String("my-value".to_string())))

pub fn remove<K: Into<Key>>(&mut self, key: K) -> Option<Value>[src]

Removes a name from the baggage, returning the value corresponding to the name if the pair was previously in the map.

pub fn len(&self) -> usize[src]

Returns the number of attributes for this baggage

pub fn is_empty(&self) -> bool[src]

Returns true if the baggage contains no items.

pub fn iter(&self) -> Iter<'_>[src]

Gets an iterator over the baggage items, sorted by name.

Trait Implementations

impl Debug for Baggage[src]

impl Default for Baggage[src]

impl FromIterator<(Key, Value)> for Baggage[src]

impl FromIterator<KeyValue> for Baggage[src]

impl<'a> IntoIterator for &'a Baggage[src]

type Item = (&'a Key, &'a Value)

The type of the elements being iterated over.

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl RefUnwindSafe for Baggage

impl Send for Baggage

impl Sync for Baggage

impl Unpin for Baggage

impl UnwindSafe for Baggage

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,