pub struct Line { /* private fields */ }
Expand description
A line in the Influx Line Protocol
Implementations§
Source§impl Line
impl Line
Sourcepub fn new(measurement: impl Into<Measurement>) -> Self
pub fn new(measurement: impl Into<Measurement>) -> Self
Create a new line for a measurement
let line = Line::new("measurement");
assert_eq!(line.measurement(), &"measurement".into());
Sourcepub fn measurement(&self) -> &Measurement
pub fn measurement(&self) -> &Measurement
Return the measurement
let line = Line::new("measurement");
assert_eq!(line.measurement(), &"measurement".into());
Sourcepub fn insert_field(
&mut self,
name: impl Into<FieldName>,
value: impl Into<FieldValue>,
)
pub fn insert_field( &mut self, name: impl Into<FieldName>, value: impl Into<FieldValue>, )
Insert a field in the line
let mut line = Line::new("measurement");
line.insert_field("latitude", FieldValue::Float(55.383333));
line.insert_field("longitude", FieldValue::Float(10.383333));
assert_eq!(line.field("latitude"), Some(&55.383333.into()));
assert_eq!(line.field("longitude"), Some(&10.383333.into()));
Sourcepub fn field(&self, name: impl Into<FieldName>) -> Option<&FieldValue>
pub fn field(&self, name: impl Into<FieldName>) -> Option<&FieldValue>
Return the value of a field
let mut line = Line::new("measurement");
line.insert_field("latitude", 55.383333);
line.insert_field("longitude", 10.383333);
assert_eq!(line.field("latitude"), Some(&55.383333.into()));
assert_eq!(line.field("longitude"), Some(&10.383333.into()));
Sourcepub fn insert_tag(
&mut self,
name: impl Into<TagName>,
value: impl Into<TagValue>,
)
pub fn insert_tag( &mut self, name: impl Into<TagName>, value: impl Into<TagValue>, )
Insert a tag in the line
let mut line = Line::new("measurement");
line.insert_tag("city", "Odense");
assert_eq!(line.tag("city"), Some(&"Odense".into()));
Sourcepub fn tag(&self, name: impl Into<TagName>) -> Option<&TagValue>
pub fn tag(&self, name: impl Into<TagName>) -> Option<&TagValue>
Return the value of a tag
let mut line = Line::new("measurement");
line.insert_tag("city", "Odense");
assert_eq!(line.tag("city"), Some(&"Odense".into()));
Sourcepub fn set_timestamp(&mut self, timestamp: DateTime<Utc>)
pub fn set_timestamp(&mut self, timestamp: DateTime<Utc>)
Set the line timestamp
let mut line = Line::new("measurement");
line.set_timestamp(Utc.ymd(2014, 7, 8).and_hms(9, 10, 11));
assert_eq!(line.timestamp(), Some(&Utc.ymd(2014, 7, 8).and_hms(9, 10, 11)));
Trait Implementations§
impl StructuralPartialEq for Line
Auto Trait Implementations§
impl Freeze for Line
impl RefUnwindSafe for Line
impl Send for Line
impl Sync for Line
impl Unpin for Line
impl UnwindSafe for Line
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more