pub struct YamlFileAdapter { /* private fields */ }Expand description
Configuration source adapter for YAML files.
This adapter reads configuration values from YAML files. It supports automatic discovery of configuration files in OS-appropriate locations, as well as custom file paths.
§Priority
YAML files have a priority of 1, which means they are overridden by both environment variables (priority 2) and command-line arguments (priority 3).
§Examples
use hexcfg::adapters::YamlFileAdapter;
use hexcfg::ports::ConfigSource;
// Load from a specific file
let adapter = YamlFileAdapter::from_file("/path/to/config.yaml").unwrap();
// Load from default OS location
let adapter = YamlFileAdapter::from_default_location("myapp", "com.example").unwrap();Implementations§
Source§impl YamlFileAdapter
impl YamlFileAdapter
Sourcepub fn from_default_location(app_name: &str, qualifier: &str) -> Result<Self>
pub fn from_default_location(app_name: &str, qualifier: &str) -> Result<Self>
Creates a new YAML file adapter from the default OS-appropriate location.
This method uses the directories crate to determine the appropriate
configuration directory for the current operating system.
§Arguments
app_name- The application name (e.g., “myapp”)qualifier- The organization/qualifier (e.g., “com.example”)
§Examples
use hexcfg::adapters::YamlFileAdapter;
let adapter = YamlFileAdapter::from_default_location("myapp", "com.example").unwrap();Sourcepub fn with_filename(
app_name: &str,
qualifier: &str,
filename: &str,
) -> Result<Self>
pub fn with_filename( app_name: &str, qualifier: &str, filename: &str, ) -> Result<Self>
Creates a new YAML file adapter with a custom file name in the default location.
§Arguments
app_name- The application namequalifier- The organization/qualifierfilename- The configuration file name (e.g., “settings.yaml”)
§Examples
use hexcfg::adapters::YamlFileAdapter;
let adapter = YamlFileAdapter::with_filename("myapp", "com.example", "settings.yaml").unwrap();Trait Implementations§
Source§impl Clone for YamlFileAdapter
impl Clone for YamlFileAdapter
Source§fn clone(&self) -> YamlFileAdapter
fn clone(&self) -> YamlFileAdapter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for YamlFileAdapter
impl RefUnwindSafe for YamlFileAdapter
impl Send for YamlFileAdapter
impl Sync for YamlFileAdapter
impl Unpin for YamlFileAdapter
impl UnwindSafe for YamlFileAdapter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more