[−][src]Enum metrics::Key
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]
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.
#[must_use]pub fn deref(&self) -> &Self::Target
[src]
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]
pub fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Key> for Key
[src]
Auto Trait Implementations
impl RefUnwindSafe for Key
[src]
impl Send for Key
[src]
impl Sync for Key
[src]
impl Unpin for Key
[src]
impl UnwindSafe for Key
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,