final conf structs and +creds struct to contain refs on existing values

pull/6/head
prplV 2025-02-13 12:31:52 +03:00
parent 8630827118
commit 0fe75be43b
1 changed files with 36 additions and 0 deletions

View File

@ -183,6 +183,42 @@ pub mod v3 {
config : Vec<ConfigEndpoint>, config : Vec<ConfigEndpoint>,
} }
impl Default for Config {
fn default() -> Self {
Self {
config : Vec::new()
}
}
}
impl Config {
pub async fn is_default(&self) -> bool {
self.config.is_empty()
}
}
pub struct Credentials<'a> {
ip : &'a str,
login : &'a str,
password : &'a str,
api_key : &'a str,
period : &'a str,
timeout : &'a str,
}
impl<'a> Credentials<'a> {
pub fn from_config_endpoint(endpoint: &'a ConfigEndpoint) -> Credentials<'a> {
Self {
ip : &endpoint.ip,
login : &endpoint.login,
password : &endpoint.password,
api_key : &endpoint.api_key,
period : &endpoint.period,
timeout : &endpoint.timeout,
}
}
}
// to prometheus and nmns // to prometheus and nmns
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct MetricOutput { pub struct MetricOutput {