[][src]Enum metrics::Key

pub enum Key {
    Borrowed(&'static KeyData),
    Owned(KeyData),
}

A metric identifier.

While KeyData holds the actual name and label data for a metric, Key works similar to std::borrow::Cow in that we can either hold an owned version of the key data, or a static reference to key data initialized elsewhere.

This allows for flexibility in the ways that KeyData can be passed around and reused, which allows us to enable performance optimizations in specific circumstances.

Variants

Borrowed(&'static KeyData)

A statically borrowed KeyData.

If you are capable of keeping a static KeyData around, this variant can be used to reduce allocations and improve performance.

Owned(KeyData)

An owned KeyData.

Useful when you need to modify a borrowed KeyData in-flight, or when there's no way to keep around a static KeyData reference.

Implementations

impl Key[src]

pub fn into_owned(self) -> KeyData[src]

Converts any kind of Key into an owned KeyData.

If this key is owned, the value is returned as is, otherwise, the contents are cloned.

Methods from Deref<Target = KeyData>

pub fn name(&self) -> &NameParts[src]

Name parts of this key.

pub fn labels(&self) -> Iter<'_, Label>[src]

Labels of this key, if they exist.

pub fn with_extra_labels(&self, extra_labels: Vec<Label>) -> Self[src]

Clones this Key, and expands the existing set of labels.

Trait Implementations

impl AsRef<KeyData> for Key[src]

impl Clone for Key[src]

impl Debug for Key[src]

impl Deref for Key[src]

type Target = KeyData

The resulting type after dereferencing.

impl Display for Key[src]

impl Eq for Key[src]

impl From<&'static KeyData> for Key[src]

impl From<KeyData> for Key[src]

impl Hash for Key[src]

impl PartialEq<Key> for Key[src]

Auto Trait Implementations

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.