borrowed strings without ownership (almost everywhere)

pull/6/head
prplV 2025-03-03 13:49:48 +03:00
parent 442c937e06
commit 83f5dd472c
1 changed files with 7 additions and 4 deletions

View File

@ -1,25 +1,28 @@
// use std::collections::HashMap; // use std::collections::HashMap;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use serde_json::Value; use serde_json::Value;
use std::borrow::Cow;
// use anyhow::Result; // use anyhow::Result;
// use std::sync::Arc; // use std::sync::Arc;
pub mod v3 { pub mod v3 {
pub use super::*; pub use super::*;
// to prometheus and nmns // to prometheus and nmns
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MetricOutput { pub struct MetricOutput<'a> {
pub id : String, pub id : String,
#[serde(rename = "type")] #[serde(rename = "type")]
json_type : String, json_type : String,
addr : String, addr : String,
pub value : Value, pub value : Value,
#[serde(rename = "description")]
pub desc : Option<Cow<'a, String>>,
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct PrometheusMetrics { pub struct PrometheusMetrics<'a> {
pub service_name: String, pub service_name: String,
pub endpoint_name: String, pub endpoint_name: String,
pub metrics: Vec<MetricOutput>, pub metrics: Vec<MetricOutput<'a>>,
} }
} }