From d2a82e973b3db83c88aa0a92e9a35b6e624638f9 Mon Sep 17 00:00:00 2001 From: csehviktor Date: Sun, 6 Jul 2025 02:27:52 +0200 Subject: [PATCH] use string instead --- common/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/lib.rs b/common/src/lib.rs index feef517..97a1dc4 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -9,16 +9,16 @@ pub const MQTT_TOPIC: &str = "system/metrics"; pub const MQTT_SEND_INTERVAL: u64 = 5; #[derive(Debug, Serialize, Deserialize)] -pub struct StatusMessage<'a> { - pub agent: &'a str, +pub struct StatusMessage { + pub agent: String, pub metrics: Metrics, pub timestamp: DateTime, } -impl<'a> StatusMessage<'a> { +impl<'a> StatusMessage { pub fn new(agent: &'a str, metrics: Metrics) -> Self { Self { - agent, + agent: agent.to_string(), metrics, timestamp: Utc::now(), } @@ -29,7 +29,7 @@ impl<'a> StatusMessage<'a> { } } -impl<'a> TryFrom<&'a [u8]> for StatusMessage<'a> { +impl<'a> TryFrom<&'a [u8]> for StatusMessage { type Error = serde_json::Error; fn try_from(value: &'a [u8]) -> Result {