Skip to main content

Crate influx3_lp_macros

Crate influx3_lp_macros 

Source
Expand description

Macros for serializing a struct to line protocol string.

There is only one derive macro:

  • #[derive(Influx3Lp)]

There are three kind of attribute-like macros defined:

  • #[influx3_lp(table_name = "home")] which must be applied to struct level
  • #[influx3_lp(timestamp)] which must be applied to field level
  • #[influx3_lp(tag)] which must be applied to field level

Combined together, we can write:

#[derive(Influx3Lp)]
#[influx3_lp(table_name = "home")]
struct SensorData {
    pub temp: f32,
    pub hum: Option<f64>,
    #[influx3_lp(tag)]
    pub room: String,
    #[influx3_lp(timestamp)]
    pub timestamp: Option<i64>,
}

Escape is applied according to line protocol.

Derive Macrosยง

Influx3Lp