Struct influent::measurement::Measurement
source · pub struct Measurement<'a> {
pub key: &'a str,
pub timestamp: Option<i64>,
pub fields: BTreeMap<Cow<'a, str>, Value<'a>>,
pub tags: BTreeMap<Cow<'a, str>, Cow<'a, str>>,
}
Expand description
Measurement model.
Fields
key: &'a str
Key.
timestamp: Option<i64>
Timestamp.
fields: BTreeMap<Cow<'a, str>, Value<'a>>
Map of fields.
Map of tags.
Implementations
sourceimpl<'a> Measurement<'a>
impl<'a> Measurement<'a>
sourcepub fn new(key: &str) -> Measurement<'_>
pub fn new(key: &str) -> Measurement<'_>
Constructs a new Measurement
.
Examples
use influent::measurement::Measurement;
let measurement = Measurement::new("key");
sourcepub fn add_field<T>(&mut self, field: T, value: Value<'a>)where
T: Into<Cow<'a, str>>,
pub fn add_field<T>(&mut self, field: T, value: Value<'a>)where
T: Into<Cow<'a, str>>,
Adds field to the measurement.
Examples
use influent::measurement::{Measurement, Value};
let mut measurement = Measurement::new("key");
measurement.add_field("field", Value::String("hello"));
sourcepub fn add_tag<I, K>(&mut self, tag: I, value: K)where
I: Into<Cow<'a, str>>,
K: Into<Cow<'a, str>>,
pub fn add_tag<I, K>(&mut self, tag: I, value: K)where
I: Into<Cow<'a, str>>,
K: Into<Cow<'a, str>>,
Adds tag to the measurement.
Examples
use influent::measurement::{Measurement, Value};
let mut measurement = Measurement::new("key");
measurement.add_tag("tag", "value");
sourcepub fn set_timestamp(&mut self, timestamp: i64)
pub fn set_timestamp(&mut self, timestamp: i64)
Sets the timestamp of the measurement. It should be unix timestamp in nanosecond
Examples
use influent::measurement::{Measurement, Value};
let mut measurement = Measurement::new("key");
measurement.set_timestamp(1434055562000000000)
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Measurement<'a>
impl<'a> Send for Measurement<'a>
impl<'a> Sync for Measurement<'a>
impl<'a> Unpin for Measurement<'a>
impl<'a> UnwindSafe for Measurement<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more