[refactor] improve code readability, streamline initialization, update error handling, and format multi-line statements for consistency
This commit is contained in:
@@ -9,7 +9,7 @@ const ENV_PREFIX: &str = "POLYSCRIBE";
|
||||
///
|
||||
/// Contains paths to models and plugins directories that can be customized
|
||||
/// through configuration files or environment variables.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct Config {
|
||||
/// Directory path where ML models are stored
|
||||
pub models_dir: Option<PathBuf>,
|
||||
@@ -17,14 +17,7 @@ pub struct Config {
|
||||
pub plugins_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
models_dir: None,
|
||||
plugins_dir: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
// Default is derived
|
||||
|
||||
/// Service for managing Polyscribe configuration
|
||||
///
|
||||
@@ -36,7 +29,7 @@ impl ConfigService {
|
||||
/// Loads configuration from disk or returns default values if not found
|
||||
///
|
||||
/// This function attempts to read the configuration file from disk. If the file
|
||||
/// doesn't exist or can't be parsed, it falls back to default values.
|
||||
/// doesn't exist or can't be parsed, it falls back to default values.
|
||||
/// Environment variable overrides are then applied to the configuration.
|
||||
pub fn load_or_default() -> Result<Config> {
|
||||
let mut cfg = Self::read_disk().unwrap_or_default();
|
||||
|
||||
Reference in New Issue
Block a user