pub struct Config {
pub recipes: Recipes,
pub paths: Paths,
}Expand description
Top-level configuration for lds.
Deserializes from ~/.config/lds/config.toml. Missing sections fall back
to Default via #[serde(default)].
Fields§
§recipes: RecipesRecipe directory settings.
paths: PathsPath overrides.
Implementations§
Source§impl Config
impl Config
Sourcepub fn load(path: &Path) -> Result<Self, ConfigError>
pub fn load(path: &Path) -> Result<Self, ConfigError>
Sourcepub fn load_or_default() -> Self
pub fn load_or_default() -> Self
Load configuration from the default path (~/.config/lds/config.toml).
If the file does not exist this returns Config::default() silently.
Any other I/O error or parse error is also silently swallowed and the
default is returned — suitable for startup where a missing config is
expected to be common.
§Returns
A Config, falling back to Default on any error.
Sourcepub fn save(path: &Path, dirs: &[PathBuf]) -> Result<(), ConfigError>
pub fn save(path: &Path, dirs: &[PathBuf]) -> Result<(), ConfigError>
Save the recipes.dirs list to path using a patch-safe write.
The file is parsed by toml_edit so that comments and sections not
managed by this function (e.g. [paths]) are preserved verbatim.
Only the recipes.dirs array is replaced.
All paths in dirs must already be absolute (tilde-expanded before
calling this function). Passing a tilde literal is a logic error and
will be written literally — callers are responsible for expanding first.
If the parent directory does not exist it is created with
fs::create_dir_all.
§Arguments
path— Destination file (typically~/.config/lds/config.toml).dirs— Absolute paths to persist inrecipes.dirs.
§Errors
ConfigError::Iofor I/O failures (create dir, read, write).ConfigError::Editif the existing file is not valid TOML.