[][src]Struct prometrics::label::Label

pub struct Label { /* fields omitted */ }

Metric label.

A label is a key-value pair.

Label names may contain ASCII letters, numbers, as well as underscores. They must match the regex [a-zA-Z_][a-zA-Z0-9_]*. Label names beginning with __ are reserved for internal use.

Label values may contain any Unicode (utf-8) characters.

Methods

impl Label[src]

pub fn new(name: &str, value: &str) -> Result<Self>[src]

Makes a new Label instance.

Errors

If name contains invalid characters, this function returns ErrorKind::InvalidInput error.

Examples

use prometrics::ErrorKind;
use prometrics::label::Label;

let label = Label::new("foo", "bar").unwrap();
assert_eq!(label.name(), "foo");
assert_eq!(label.value(), "bar");
assert_eq!(label.to_string(), r#"foo="bar""#);

// Reserved name
assert_eq!(Label::new("__foo", "bar").err().map(|e| *e.kind()),
           Some(ErrorKind::InvalidInput));
// Invalid name
assert_eq!(Label::new("fo-o", "bar").err().map(|e| *e.kind()),
           Some(ErrorKind::InvalidInput));

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

Returns the name of this label.

pub fn value(&self) -> &str[src]

Returns the value of this label.

Trait Implementations

impl Clone for Label[src]

impl Debug for Label[src]

impl Display for Label[src]

impl Eq for Label[src]

impl Hash for Label[src]

impl Ord for Label[src]

impl PartialEq<Label> for Label[src]

impl PartialOrd<Label> for Label[src]

impl StructuralEq for Label[src]

impl StructuralPartialEq for Label[src]

Auto Trait Implementations

impl RefUnwindSafe for Label

impl Send for Label

impl Sync for Label

impl Unpin for Label

impl UnwindSafe for Label

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.