From 3d4e274cfe167b487b85772269a253b0ccd88894 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Fri, 3 Jan 2025 11:34:46 +0000 Subject: [PATCH] WIP adding lifetimes for new version of influx_db_client. --- homie-influx/src/influx.rs | 6 +++--- mijia-homie/src/mijia-history-influx.rs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/homie-influx/src/influx.rs b/homie-influx/src/influx.rs index 0133489c..4b297724 100644 --- a/homie-influx/src/influx.rs +++ b/homie-influx/src/influx.rs @@ -33,7 +33,7 @@ pub async fn send_property_value( /// Convert the value of the given Homie property to an InfluxDB value of the appropriate type, if /// possible. Returns None if the datatype of the property is unknown, or there was an error parsing /// the value. -fn influx_value_for_homie_property(property: &Property) -> Option { +fn influx_value_for_homie_property(property: &Property) -> Option> { let datatype = property.datatype?; Some(match datatype { Datatype::Integer => Value::Integer(property.value().ok()?), @@ -44,12 +44,12 @@ fn influx_value_for_homie_property(property: &Property) -> Option { } /// Construct an InfluxDB `Point` corresponding to the given Homie property value update. -fn point_for_property_value( +fn point_for_property_value<'a>( device: &Device, node: &Node, property: &Property, timestamp: SystemTime, -) -> Option { +) -> Option> { let datatype = property.datatype?; let value = influx_value_for_homie_property(property)?; diff --git a/mijia-homie/src/mijia-history-influx.rs b/mijia-homie/src/mijia-history-influx.rs index f932917b..0d970d6a 100644 --- a/mijia-homie/src/mijia-history-influx.rs +++ b/mijia-homie/src/mijia-history-influx.rs @@ -92,12 +92,12 @@ async fn write_history( Ok(()) } -fn point_for_record( - measurement: &str, +fn point_for_record<'a>( + measurement: &'a str, mac_address: &MacAddress, - name: &str, + name: &'a str, record: &HistoryRecord, -) -> Point { +) -> Point<'a> { Point::new(measurement) .add_timestamp( record