[−][src]Struct metrix::snapshot::Snapshot
A Snapshot
which contains measured values
at a point in time.
Fields
items: Vec<(String, ItemKind)>
Methods
impl Snapshot
[src]
pub fn push<K: Into<String>>(&mut self, k: K, v: ItemKind)
[src]
pub fn find_with_separator(&self, path: &str, separator: char) -> FindItem
[src]
Find an item on a path with a given a separator.
Same as find
but with a configurable separator.
pub fn find(&self, path: &str) -> FindItem
[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::*; use metrix::snapshot::FindItem::*; // 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"), Found(&ItemKind::UInt(23))); assert_eq!(snapshot.find("a/x"), Found(&ItemKind::UInt(23))); assert_eq!(snapshot.find("/a/x"), Found(&ItemKind::UInt(23))); assert_eq!(snapshot.find("b"), Found(&inner)); assert_eq!(snapshot.find("b/c"), Found(&ItemKind::UInt(42))); assert_eq!(snapshot.find("/b//c"), Found(&ItemKind::UInt(42))); assert_eq!(snapshot.find("b/c/x"), Found(&ItemKind::UInt(42))); assert_eq!(snapshot.find(""), NotFound); assert_eq!(snapshot.find("/"), NotFound);
pub fn to_default_json(&self) -> String
[src]
Output JSON with default settings.
pub fn to_json(&self, config: &JsonConfig) -> String
[src]
Output JSON with the given settings.
Trait Implementations
impl Clone for Snapshot
[src]
impl Default for Snapshot
[src]
impl PartialEq<Snapshot> for Snapshot
[src]
impl Debug for Snapshot
[src]
impl StructuralPartialEq for Snapshot
[src]
Auto Trait Implementations
impl Send for Snapshot
impl Sync for Snapshot
impl Unpin for Snapshot
impl UnwindSafe for Snapshot
impl RefUnwindSafe for Snapshot
Blanket Implementations
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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,