use anyhow::{Context, Result}; use dotenv::dotenv; use std::env; #[derive(Debug, Clone)] pub struct Config { // Synology pub nas_fqdn: String, pub nas_user: String, pub nas_pass: String, pub nas_file: String, // Nexrender pub nexrender_api_url: String, pub output_folder: String, // Templates (all required) pub template_double_src: String, pub template_single_src: String, pub template_composition: String, pub template_output_module: String, pub template_output_ext: String, } impl Config { pub fn from_env() -> Result { dotenv().ok(); Ok(Self { nas_fqdn: env::var("NAS_FQDN").context("NAS_FQDN not set")?, nas_user: env::var("NAS_USER").context("NAS_USER not set")?, nas_pass: env::var("NAS_PASS").context("NAS_PASS not set")?, nas_file: env::var("NAS_FILE").context("NAS_FILE not set")?, nexrender_api_url: env::var("NEXRENDER_API_URL") .context("NEXRENDER_API_URL not set")?, output_folder: env::var("OUTPUT_FOLDER").context("OUTPUT_FOLDER not set")?, template_double_src: env::var("TEMPLATE_DOUBLE_SRC") .context("TEMPLATE_DOUBLE_SRC not set")?, template_single_src: env::var("TEMPLATE_SINGLE_SRC") .context("TEMPLATE_SINGLE_SRC not set")?, template_composition: env::var("TEMPLATE_COMPOSITION") .context("TEMPLATE_COMPOSITION not set")?, template_output_module: env::var("TEMPLATE_OUTPUT_MODULE") .context("TEMPLATE_OUTPUT_MODULE not set")?, template_output_ext: env::var("TEMPLATE_OUTPUT_EXT") .context("TEMPLATE_OUTPUT_EXT not set")?, }) } }