mirror of
https://framagit.org/veretcle/tootube.git
synced 2025-07-20 12:31:19 +02:00
34 lines
805 B
Rust
34 lines
805 B
Rust
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 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
|
|
}
|