Skip to main content

Label

Trait Label 

Source
pub trait Label: Sized {
    // Required methods
    fn with_current_labels(self) -> Labeled<Self> ;
    fn with_label<K, V>(self, k: K, v: V) -> Labeled<Self> 
       where K: AsRef<[u8]>,
             V: AsRef<[u8]>;
    fn with_labels<I, K, V>(self, i: I) -> Labeled<Self> 
       where I: IntoIterator<Item = (K, V)>,
             K: AsRef<[u8]>,
             V: AsRef<[u8]>;
    fn with_labelset(self, labelset: Labelset) -> Labeled<Self> ;
}
Expand description

Attaches custom labels to a Future.

Required Methods§

Source

fn with_current_labels(self) -> Labeled<Self>

Attach the currently active labels to the future.

This can be used to propagate the current labels when spawning a new future.

Source

fn with_label<K, V>(self, k: K, v: V) -> Labeled<Self>
where K: AsRef<[u8]>, V: AsRef<[u8]>,

Attach a single label to the future.

This is equivalent to calling [with_labels] with an iterator that yields a single key–value pair.

Source

fn with_labels<I, K, V>(self, i: I) -> Labeled<Self>
where I: IntoIterator<Item = (K, V)>, K: AsRef<[u8]>, V: AsRef<[u8]>,

Attaches the specified labels to the future.

The labels will be installed in the current thread whenever the future is polled, and removed when the poll completes.

This is equivalent to calling [with_labelset] with a label set constructed like so:

let mut labelset = Labelset::clone_from_current();
labelset.extend(i);
Source

fn with_labelset(self, labelset: Labelset) -> Labeled<Self>

Attaches the specified labelset to the future.

The labels in the set will be installed in the current thread whenever the future is polled, and removed when the poll completes.

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.

Implementors§

Source§

impl<Fut: Future> Label for Fut