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
items: Vec<(String, ItemKind)>
Methods
impl Snapshot
[src]
fn push<K: Into<String>>(&mut self, k: K, v: ItemKind)
[src]
fn find_with_separator(&self, path: &str, separator: char) -> Option<&ItemKind>
[src]
Find an item on a path with a given a separator.
Same as find
but with a configurable seperator.
fn find(&self, path: &str) -> Option<&ItemKind>
[src]
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);
fn to_default_json(&self) -> String
[src]
Output JSON with default settings.
fn to_json(&self, config: &JsonConfig) -> String
[src]
Output JSON with the given settings.
Trait Implementations
impl Debug for Snapshot
[src]
impl Clone for Snapshot
[src]
fn clone(&self) -> Snapshot
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq for Snapshot
[src]
fn eq(&self, __arg_0: &Snapshot) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Snapshot) -> bool
[src]
This method tests for !=
.