Struct dipstick::LineTemplate

source ·
pub struct LineTemplate { /* private fields */ }
Expand description

An sequence of print commands, embodying an output strategy for a single metric.

Implementations§

source§

impl LineTemplate

source

pub fn new(ops: Vec<LineOp>) -> Self

Make a new LineTemplate

Examples found in repository?
examples/text_format_label.rs (lines 15-28)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    fn template(&self, name: &MetricName, _kind: InputKind) -> LineTemplate {
        LineTemplate::new(vec![
            LineOp::Literal(format!("{} ", name.join(".")).to_uppercase().into()),
            LineOp::ValueAsText,
            LineOp::Literal(" ".into()),
            LineOp::LabelExists(
                "abc".into(),
                vec![
                    LabelOp::LabelKey,
                    LabelOp::Literal(":".into()),
                    LabelOp::LabelValue,
                ],
            ),
            LineOp::NewLine,
        ])
    }
source

pub fn print<L>( &self, output: &mut dyn Write, value: MetricValue, lookup: L, ) -> Result<()>
where L: Fn(&str) -> Option<Arc<String>>,

Template execution applies commands in turn, writing to the output.

Trait Implementations§

source§

impl From<Vec<LineOp>> for LineTemplate

source§

fn from(ops: Vec<LineOp>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.