rewrite in rust
This commit is contained in:
35 files changed
+1949
-1557
No files matched your search
@@ -0,0 +1,27 @@
|
||||
use serde::Deserialize;
|
||||
use std::{error::Error, fs};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Config {
|
||||
#[serde(flatten)]
|
||||
pub auth: Auth,
|
||||
pub entries: Vec<Entry>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Auth {
|
||||
pub key: String,
|
||||
pub secret_key: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Entry {
|
||||
pub domain: String,
|
||||
pub subdomains: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn load(path: &str) -> Result<Config, Box<dyn Error>> {
|
||||
let raw = fs::read_to_string(&path)?;
|
||||
let config = serde_json::from_str(&raw)?;
|
||||
Ok(config)
|
||||
}
|
||||
Reference in new issue
Block a user