use string instead

This commit is contained in:
csehviktor
2025-07-06 02:27:52 +02:00
parent 158369ffb3
commit d2a82e973b

View File

@@ -9,16 +9,16 @@ pub const MQTT_TOPIC: &str = "system/metrics";
pub const MQTT_SEND_INTERVAL: u64 = 5; pub const MQTT_SEND_INTERVAL: u64 = 5;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct StatusMessage<'a> { pub struct StatusMessage {
pub agent: &'a str, pub agent: String,
pub metrics: Metrics, pub metrics: Metrics,
pub timestamp: DateTime<Utc>, pub timestamp: DateTime<Utc>,
} }
impl<'a> StatusMessage<'a> { impl<'a> StatusMessage {
pub fn new(agent: &'a str, metrics: Metrics) -> Self { pub fn new(agent: &'a str, metrics: Metrics) -> Self {
Self { Self {
agent, agent: agent.to_string(),
metrics, metrics,
timestamp: Utc::now(), 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; type Error = serde_json::Error;
fn try_from(value: &'a [u8]) -> Result<Self, Self::Error> { fn try_from(value: &'a [u8]) -> Result<Self, Self::Error> {