feat: create tuono_internal crate (#395)

This commit is contained in:
Valerio Ageno
2025-01-21 19:01:37 +01:00
committed by GitHub
parent 0750037385
commit 3035d2a645
7 changed files with 161 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
use serde::Deserialize;
use std::fs::read_to_string;
use std::io;
use std::path::PathBuf;
#[derive(Deserialize)]
pub struct ServerConfig {
pub host: String,
pub port: u16,
}
#[derive(Deserialize)]
pub struct Config {
pub server: ServerConfig,
}
impl Config {
pub fn get() -> io::Result<Config> {
let config_file = read_to_string(PathBuf::from_iter([".tuono", "config", "config.json"]))?;
serde_json::from_str(&config_file)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
}
}
+1
View File
@@ -0,0 +1 @@
pub mod config;