1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! A serializer for Rust structs according to [InfluxDB 3 line protocol](https://docs.influxdata.com/influxdb3/core/reference/line-protocol/).
//!
//! When writing data to InfluxDB 3 Core, we have to use [write_lp API](https://docs.influxdata.com/influxdb3/core/write-data/http-api/v3-write-lp/) whose format differs from JSON.
//! This crate defines a derive macro called `Influx3Lp` to assit write process.
//!
//! ```rust
//! use influx3_lp::Influx3Lp;
//!
//! #[derive(Influx3Lp)]
//! #[influx3_lp(table_name = "home")]
//! struct SensorData {
//! pub temp: f32,
//! pub hum: f64,
//! pub co: Option<i32>,
//! pub weather: String,
//! #[influx3_lp(timestamp)]
//! pub timestamp: i64,
//! #[influx3_lp(tag)]
//! pub room: String,
//! }
//!
//! let data = SensorData {
//! temp: 21.0,
//! hum: 35.9,
//! co: Some(0),
//! weather: String::from("sunny"),
//! timestamp: 1735545600,
//! room: String::from("Kitchen"),
//! };
//!
//! // call `to_lp` function to transform struct to a String
//! let serialized = data.to_lp();
//!
//! assert_eq!(serialized,
//! "home,room=Kitchen temp=21,hum=35.9,co=0i,weather=\"sunny\" 1735545600")
//! ```
//!
//! These are features implemented by `influx3_lp`:
//!
//! * `#[influx3_lp(timestamp)]` attribute is optional
//! * multiple `#[influx3_lp(tag)]` atrributes are supported
//! * empty tag is supported also
//! * tag values and field values are [escaped according to line protocol](https://docs.influxdata.com/influxdb3/core/reference/line-protocol/#special-characters)
//! * field string has a length limit of 64K
//! * `i8`,`i16`,`i32`,`i64` field values are appended with `i`
//! * `u8`,`u16`,`u32`,`u64` field values are appended with `u`
//! * field type of `Option<T>` is supported
////////////////////////////////////////////////////////////////////////////////
pub use *;
/// This is the trait that `Influx3Lp` macro help us implementing.