pub trait ConfigSource {
// Required methods
fn user_config_dir(&self) -> Option<PathBuf>;
fn read(&self, path: &Path) -> Result<Option<String>, EngineError>;
fn read_required(&self, path: &Path) -> Result<String, EngineError>;
}Expand description
Where configuration comes from.
The engine decides WHICH files to look for, what precedence they have and what their absence means; this port only says where the user’s config directory is and hands back file contents.
Required Methods§
Sourcefn user_config_dir(&self) -> Option<PathBuf>
fn user_config_dir(&self) -> Option<PathBuf>
The user config directory. None when no home directory can be
determined — then the user file simply does not exist.
Sourcefn read(&self, path: &Path) -> Result<Option<String>, EngineError>
fn read(&self, path: &Path) -> Result<Option<String>, EngineError>
Contents, or None when the file does not exist. Any other failure
(permissions, non-UTF-8) is an error.
Sourcefn read_required(&self, path: &Path) -> Result<String, EngineError>
fn read_required(&self, path: &Path) -> Result<String, EngineError>
Contents of a file the caller named explicitly, where absence is a hard error rather than a default.
A separate method rather than the domain synthesising the message from
read’s None, so the error text comes from the same std::fs call
it always did and cannot drift.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".