config.rs (452B)
1 use crate::errors::ConfigError; 2 use async_std::fs; 3 use serde::{Deserialize, Serialize}; 4 5 #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] 6 pub struct Config { 7 pub model_path: String, 8 pub model_name: String, 9 } 10 11 impl Config { 12 pub async fn load(filepath: String) -> Result<Self, ConfigError> { 13 let contents = fs::read(filepath).await?; 14 let config: Self = serde_yaml::from_slice(&contents)?; 15 Ok(config) 16 } 17 }