use serde::Deserialize; use std::fs::read_to_string; // General configuration Struct #[derive(Debug, Deserialize)] pub struct Config { pub peertube: PeertubeConfig, pub youtube: YoutubeConfig, } #[derive(Debug, Deserialize)] pub struct PeertubeConfig { pub base_url: String, } #[derive(Debug, Deserialize)] pub struct YoutubeConfig { pub refresh_token: String, pub client_id: String, pub client_secret: String, } /// Parses the TOML file into a Config struct pub fn parse_toml(toml_file: &str) -> Config { let toml_config = read_to_string(toml_file).unwrap_or_else(|e| panic!("Cannot open file {toml_file}: {e}")); let config: Config = toml::from_str(&toml_config) .unwrap_or_else(|e| panic!("Cannot parse TOML file {toml_file}: {e}")); config }