[][src]Enum metrics::Key

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

Represents the identifier of a metric.

Key holds either an owned or static reference variant of KeyData.

This allows for flexibility in the ways that KeyData can be passed around and reused, enabling performance improvements in specific situations.

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.

The reference is read-only, so you can't modify the underlying data.

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.

Owned variant returned as is, borrowed variant is cloned.

Methods from Deref<Target = KeyData>

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

Name 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]

Returns a clone of this key with some additional 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]

fn eq(&self, other: &Self) -> bool[src]

We deliberately hide the differences between the containment types.

Auto Trait Implementations

impl RefUnwindSafe for Key

impl Send for Key

impl Sync for Key

impl Unpin for Key

impl UnwindSafe for Key

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.