Update to InfluxDB 2.0 and update all interfaces to work with it. MAC has been deprecated, since current `influxdb2` doesn't support non built-in types for read/write into the DB. Co-authored-by: Felipe Diniello <felipediniello@pm.me> Reviewed-on: #1
32 lines
699 B
Rust
32 lines
699 B
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
use influxdb2_derive::{FromDataPoint, WriteDataPoint};
|
|
|
|
use crate::Point;
|
|
|
|
#[derive(
|
|
Debug, Default, PartialEq, Clone, Serialize, Deserialize, FromDataPoint, WriteDataPoint,
|
|
)]
|
|
#[measurement = "known_positions"]
|
|
pub struct KnownPosition {
|
|
#[influxdb(tag)]
|
|
pub id: String,
|
|
pub x: f64,
|
|
pub y: f64,
|
|
pub z: f64,
|
|
#[influxdb(timestamp)]
|
|
pub time: i64,
|
|
}
|
|
|
|
impl KnownPosition {
|
|
pub fn new(device_id: &str, pos: Point) -> KnownPosition {
|
|
KnownPosition {
|
|
id: device_id.into(),
|
|
time: chrono::Utc::now().timestamp_nanos(),
|
|
x: pos.x,
|
|
y: pos.y,
|
|
z: 0.0,
|
|
}
|
|
}
|
|
}
|