base for dns manager
This commit is contained in:
7
dns-config/Cargo.toml
Normal file
7
dns-config/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "dns-config"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
toml = "0.9"
|
||||
36
dns-config/src/lib.rs
Normal file
36
dns-config/src/lib.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use std::fs::read_to_string;
|
||||
use toml::Table;
|
||||
|
||||
pub struct KeyData {
|
||||
pub key_name: String,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
pub struct ZoneData {
|
||||
pub root_domain: String,
|
||||
pub conection_str: String,
|
||||
}
|
||||
|
||||
impl KeyData {
|
||||
pub fn get_config(file_name: &String) -> Self {
|
||||
let key_toml = read_to_string(file_name).unwrap().parse::<Table>().unwrap();
|
||||
let name: String = key_toml["key"]["name"].as_str().unwrap().to_string();
|
||||
let value: String = key_toml["key"]["value"].as_str().unwrap().to_string();
|
||||
Self {
|
||||
key_name: name,
|
||||
key: value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ZoneData {
|
||||
pub fn get_config(file_name: &String) -> Self {
|
||||
let key_toml = read_to_string(file_name).unwrap().parse::<Table>().unwrap();
|
||||
let root_domain: String = key_toml["zone"]["root_domain"].as_str().unwrap().to_string();
|
||||
let conection_str: String = key_toml["zone"]["conection_str"].as_str().unwrap().to_string();
|
||||
Self {
|
||||
root_domain,
|
||||
conection_str
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user