mirror of
https://github.com/csehviktor/status-monitor.git
synced 2025-08-08 18:06:14 +02:00
formatter + implement status history
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::metrics::Metrics;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Error;
|
||||
use crate::metrics::Metrics;
|
||||
|
||||
pub mod metrics;
|
||||
|
||||
@@ -37,6 +37,14 @@ impl<'a> TryFrom<&'a [u8]> for StatusMessage {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<String> for StatusMessage {
|
||||
type Error = serde_json::Error;
|
||||
|
||||
fn try_from(value: String) -> Result<Self, Self::Error> {
|
||||
serde_json::from_str(&value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StatusMessage> for String {
|
||||
fn from(msg: StatusMessage) -> String {
|
||||
serde_json::to_string(&msg).unwrap_or_else(|_| String::new())
|
||||
|
||||
Reference in New Issue
Block a user