pub struct Record { /* private fields */ }
Expand description
Coarse unit of recording. It keeps track of the organization, bucket and precision which are inherent to the concept of “schema” in SQL lingo. It gets filled with measurements that provide the “table name” (measurement) as well as “indexed columns” (tags) and values.
Implementations§
Source§impl Record
impl Record
Sourcepub fn new(org: &str, bucket: &str) -> Self
pub fn new(org: &str, bucket: &str) -> Self
Create a new measurement by specifying the owning organization and the bucket
Examples found in repository?
examples/simple.rs (line 25)
16fn main() -> Result<(), InfluxError>
17{
18 let creds = Credentials::from_basic("testuser", "testpasswd");
19 let backlog = FileBacklog::new("./ignore/backlog")?;
20
21 let mut client = Client::build("http://127.0.0.1:8086".into(), creds)
22 .backlog(backlog)
23 .finish()?;
24
25 let mut rec = Record::new("org", "bucket")
26 .precision(Precision::Milliseconds);
27
28 loop
29 {
30 rec.measurement("sensor1")
31 .tag("floor", "second")
32 .tag("exposure", "west")
33 .field("temp", 123)
34 .field("brightness", 500);
35
36 rec.measurement("sensor2")
37 .tag("floor", "second")
38 .tag("exposure", "east")
39 .field("temp", 321)
40 .field("brightness", 999);
41
42 if let Err(e) = client.write(&rec) {
43 eprintln!("{}", e);
44 }
45
46 sleep(Duration::from_secs(1));
47 }
48}
Sourcepub fn precision(self, precision: Precision) -> Self
pub fn precision(self, precision: Precision) -> Self
Set precision. It otherwise defaults to nanoseconds.
Examples found in repository?
examples/simple.rs (line 26)
16fn main() -> Result<(), InfluxError>
17{
18 let creds = Credentials::from_basic("testuser", "testpasswd");
19 let backlog = FileBacklog::new("./ignore/backlog")?;
20
21 let mut client = Client::build("http://127.0.0.1:8086".into(), creds)
22 .backlog(backlog)
23 .finish()?;
24
25 let mut rec = Record::new("org", "bucket")
26 .precision(Precision::Milliseconds);
27
28 loop
29 {
30 rec.measurement("sensor1")
31 .tag("floor", "second")
32 .tag("exposure", "west")
33 .field("temp", 123)
34 .field("brightness", 500);
35
36 rec.measurement("sensor2")
37 .tag("floor", "second")
38 .tag("exposure", "east")
39 .field("temp", 321)
40 .field("brightness", 999);
41
42 if let Err(e) = client.write(&rec) {
43 eprintln!("{}", e);
44 }
45
46 sleep(Duration::from_secs(1));
47 }
48}
Sourcepub fn measurement<'r>(&'r mut self, name: &str) -> &'r mut Measurement
pub fn measurement<'r>(&'r mut self, name: &str) -> &'r mut Measurement
Add and return a measurement for further parametrization.
Examples found in repository?
examples/simple.rs (line 30)
16fn main() -> Result<(), InfluxError>
17{
18 let creds = Credentials::from_basic("testuser", "testpasswd");
19 let backlog = FileBacklog::new("./ignore/backlog")?;
20
21 let mut client = Client::build("http://127.0.0.1:8086".into(), creds)
22 .backlog(backlog)
23 .finish()?;
24
25 let mut rec = Record::new("org", "bucket")
26 .precision(Precision::Milliseconds);
27
28 loop
29 {
30 rec.measurement("sensor1")
31 .tag("floor", "second")
32 .tag("exposure", "west")
33 .field("temp", 123)
34 .field("brightness", 500);
35
36 rec.measurement("sensor2")
37 .tag("floor", "second")
38 .tag("exposure", "east")
39 .field("temp", 321)
40 .field("brightness", 999);
41
42 if let Err(e) = client.write(&rec) {
43 eprintln!("{}", e);
44 }
45
46 sleep(Duration::from_secs(1));
47 }
48}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnwindSafe for Record
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