pub struct LineBuilder { /* private fields */ }
Expand description
Build a record
Implementations§
Source§impl LineBuilder
impl LineBuilder
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 = LineBuilder::new("measurement")
.build();
assert_eq!(line.measurement(), &"measurement".into());
Sourcepub fn insert_field(
self,
name: impl Into<FieldName>,
value: impl Into<FieldValue>,
) -> Self
pub fn insert_field( self, name: impl Into<FieldName>, value: impl Into<FieldValue>, ) -> Self
Insert a field in the line
let line = LineBuilder::new("measurement")
.insert_field("latitude", 55.383333)
.insert_field("longitude", 10.383333)
.build();
assert_eq!(line.field("latitude"), Some(&55.383333.into()));
assert_eq!(line.field("longitude"), Some(&10.383333.into()));
Sourcepub fn insert_tag(
self,
name: impl Into<TagName>,
value: impl Into<TagValue>,
) -> Self
pub fn insert_tag( self, name: impl Into<TagName>, value: impl Into<TagValue>, ) -> Self
Insert a tag in the line
let line = LineBuilder::new("measurement")
.insert_tag("city", "Odense")
.build();
assert_eq!(line.tag("city"), Some(&"Odense".into()));
Sourcepub fn set_timestamp(self, timestamp: DateTime<Utc>) -> Self
pub fn set_timestamp(self, timestamp: DateTime<Utc>) -> Self
Set the line timestamp
let line = LineBuilder::new("measurement")
.set_timestamp(Utc.ymd(2014, 7, 8).and_hms(9, 10, 11))
.build();
assert_eq!(line.timestamp(), Some(&Utc.ymd(2014, 7, 8).and_hms(9, 10, 11)));
Sourcepub fn build(self) -> Line
pub fn build(self) -> Line
Build the line
let line = LineBuilder::new("measurement")
.insert_field("latitude", 55.383333)
.insert_field("longitude", 10.383333)
.insert_tag("city", "Odense")
.set_timestamp(Utc.ymd(2014, 7, 8).and_hms(9, 10, 11))
.build();
assert_eq!(line.measurement(), &"measurement".into());
assert_eq!(line.field("latitude"), Some(&55.383333.into()));
assert_eq!(line.field("longitude"), Some(&10.383333.into()));
assert_eq!(line.tag("city"), Some(&"Odense".into()));
assert_eq!(line.timestamp(), Some(&Utc.ymd(2014, 7, 8).and_hms(9, 10, 11)));
Trait Implementations§
Source§impl Clone for LineBuilder
impl Clone for LineBuilder
Source§fn clone(&self) -> LineBuilder
fn clone(&self) -> LineBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for LineBuilder
impl Debug for LineBuilder
Source§impl PartialEq for LineBuilder
impl PartialEq for LineBuilder
impl StructuralPartialEq for LineBuilder
Auto Trait Implementations§
impl Freeze for LineBuilder
impl RefUnwindSafe for LineBuilder
impl Send for LineBuilder
impl Sync for LineBuilder
impl Unpin for LineBuilder
impl UnwindSafe for LineBuilder
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