Trait Props

Source
pub trait Props {
    // Required method
    fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
       where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>;

    // Provided methods
    fn get<'v, K>(&'v self, key: K) -> Option<Value<'v>>
       where K: ToStr { ... }
    fn pull<'kv, V, K>(&'kv self, key: K) -> Option<V>
       where V: FromValue<'kv>,
             K: ToStr { ... }
    fn is_unique(&self) -> bool { ... }
    fn and_props<U>(self, other: U) -> And<Self, U>
       where U: Props,
             Self: Sized { ... }
    fn as_map(&self) -> &AsMap<Self>
       where Self: Sized { ... }
    fn dedup(&self) -> &Dedup<Self>
       where Self: Sized { ... }
}
Expand description

A collection of Str and Value pairs.

The Props::for_each method can be used to enumerate properties.

§Uniqueness

Properties may be duplicated in a set of Props. When a property is duplicated, the first for a given key is the one to use.

§Typed and untyped properties

The Props::get method will return a property as an untyped Value that can be formatted or serialized. If you’re looking for a specific type, you can use Props::pull instead.

Required Methods§

Source

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Enumerate the Str and Value pairs.

The function for_each will be called for each property until all properties are visited, or it returns ControlFlow::Break.

Properties may be repeated, but can be de-duplicated by taking the first seen for a given key.

Provided Methods§

Source

fn get<'v, K>(&'v self, key: K) -> Option<Value<'v>>
where K: ToStr,

Get the value for a given key, if it’s present.

If the key is present then this method will return Some. Otherwise this method will return None.

If the key appears multiple times, the first value seen should be returned.

Implementors are encouraged to override this method with a more efficient implementation.

Source

fn pull<'kv, V, K>(&'kv self, key: K) -> Option<V>
where V: FromValue<'kv>, K: ToStr,

Get the value for a given key, if it’s present as an instance of V.

If the key is present, and the raw value can be converted into V through Value::cast then this method will return Some. Otherwise this method will return None.

If the key appears multiple times, the first value seen should be returned.

Source

fn is_unique(&self) -> bool

Whether the collection is known not to contain any duplicate keys.

If there’s any possibility a key may be duplicated, this method should return false.

Source

fn and_props<U>(self, other: U) -> And<Self, U>
where U: Props, Self: Sized,

Concatenate other to the end of self.

Source

fn as_map(&self) -> &AsMap<Self>
where Self: Sized,

Get an adapter that will serialize properties as a map.

Source

fn dedup(&self) -> &Dedup<Self>
where Self: Sized,

Lazily de-duplicate properties in the collection.

Properties are de-duplicated by taking the first value for a given key.

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<'a, P> Props for &'a P
where P: Props + ?Sized,

Source§

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Source§

fn get<'v, K>(&'v self, key: K) -> Option<Value<'v>>
where K: ToStr,

Source§

fn pull<'kv, V, K>(&'kv self, key: K) -> Option<V>
where V: FromValue<'kv>, K: ToStr,

Source§

fn is_unique(&self) -> bool

Source§

impl<'a, P> Props for Box<P>
where P: Props + 'a + ?Sized,

Source§

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Source§

impl<'a, P> Props for Arc<P>
where P: Props + 'a + ?Sized,

Source§

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Source§

impl<K, V> Props for (K, V)
where K: ToStr, V: ToValue,

Source§

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Source§

fn is_unique(&self) -> bool

Source§

impl<K, V> Props for BTreeMap<K, V>
where K: Ord + ToStr + Borrow<str>, V: ToValue,

Source§

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Source§

fn get<'v, Q>(&'v self, key: Q) -> Option<Value<'v>>
where Q: ToStr,

Source§

fn is_unique(&self) -> bool

Source§

impl<K, V> Props for HashMap<K, V>
where K: Eq + Hash + ToStr + Borrow<str>, V: ToValue,

Source§

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Source§

fn get<'v, Q>(&'v self, key: Q) -> Option<Value<'v>>
where Q: ToStr,

Source§

fn is_unique(&self) -> bool

Source§

impl<P> Props for Option<P>
where P: Props,

Source§

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Source§

impl<P> Props for [P]
where P: Props,

Source§

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Source§

impl<T, const N: usize> Props for [T; N]
where [T]: Props,

Source§

fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>,

Implementors§

Source§

impl Props for ThreadLocalCtxtFrame

Source§

impl Props for SpanCtxt

Source§

impl Props for Empty

Source§

impl Props for Extent

Source§

impl<'a> Props for dyn ErasedProps + 'a

Source§

impl<'a, P: Props> Props for Metric<'a, P>

Source§

impl<'a, P: Props> Props for Span<'a, P>

Source§

impl<A, B> Props for And<A, B>
where A: Props, B: Props,

Source§

impl<P> Props for AsMap<P>
where P: Props + ?Sized,

Source§

impl<P> Props for Dedup<P>
where P: Props + ?Sized,