Struct metrix::snapshot::Snapshot[][src]

pub struct Snapshot {
    pub items: Vec<(String, ItemKind)>,
}

A Snapshot which contains measured values at a point in time.

Fields

Methods

impl Snapshot
[src]

Find an item on a path with a given a separator.

Same as find but with a configurable seperator.

Find an item on a path with a / as a separator.

If the path is empty None is returned.

Since a Snapshot may contain multiple items with the same name only the first found will be returned.

If a prefix of a path leads to a value that value is returned and the rest of the path is discarded.

Empty segments of a path are ignored.

Example

use metrix::snapshot::*;

// a -> 23
// b -> c -> 42

let inner = ItemKind::Snapshot(Snapshot {
    items: vec![("c".to_string(), ItemKind::UInt(42))],
});

let snapshot = Snapshot {
    items: vec![
        ("a".to_string(), ItemKind::UInt(23)),
        ("b".to_string(), inner.clone()),
    ],
};

assert_eq!(snapshot.find("a"), Some(&ItemKind::UInt(23)));
assert_eq!(snapshot.find("a/x"), Some(&ItemKind::UInt(23)));
assert_eq!(snapshot.find("/a/x"), Some(&ItemKind::UInt(23)));

assert_eq!(snapshot.find("b"), Some(&inner));

assert_eq!(snapshot.find("b/c"), Some(&ItemKind::UInt(42)));
assert_eq!(snapshot.find("/b//c"), Some(&ItemKind::UInt(42)));

assert_eq!(snapshot.find("b/c/x"), Some(&ItemKind::UInt(42)));

assert_eq!(snapshot.find(""), None);

assert_eq!(snapshot.find("/"), None);

Output JSON with default settings.

Output JSON with the given settings.

Trait Implementations

impl Debug for Snapshot
[src]

Formats the value using the given formatter. Read more

impl Clone for Snapshot
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Snapshot
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Default for Snapshot
[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl Send for Snapshot

impl Sync for Snapshot