Initial commit

This commit is contained in:
VC
2023-09-29 17:16:47 +02:00
commit 65cbb89eb5
7 changed files with 1350 additions and 0 deletions

31
src/config.rs Normal file
View File

@@ -0,0 +1,31 @@
use std::fs::read_to_string;
use serde::Deserialize;
// 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 api_key: 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
}