pub struct ConfigDiscovery { /* private fields */ }Expand description
Configuration file discovery.
Implementations§
Source§impl ConfigDiscovery
impl ConfigDiscovery
Sourcepub fn new(base_name: impl Into<String>) -> Self
pub fn new(base_name: impl Into<String>) -> Self
Create a new configuration discovery with default settings.
Sourcepub fn search_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn search_dir(self, dir: impl Into<PathBuf>) -> Self
Add a search directory.
Sourcepub fn search_dirs(
self,
dirs: impl IntoIterator<Item = impl Into<PathBuf>>,
) -> Self
pub fn search_dirs( self, dirs: impl IntoIterator<Item = impl Into<PathBuf>>, ) -> Self
Add multiple search directories.
Sourcepub fn formats(self, formats: Vec<ConfigFormat>) -> Self
pub fn formats(self, formats: Vec<ConfigFormat>) -> Self
Set preferred formats.
Sourcepub fn with_standard_dirs(self, app_name: &str) -> Self
pub fn with_standard_dirs(self, app_name: &str) -> Self
Add standard search locations.
Includes:
- Current directory
- ./config/
- ~/.config/{app_name}/
- /etc/{app_name}/
Sourcepub fn candidates(&self) -> Vec<PathBuf>
pub fn candidates(&self) -> Vec<PathBuf>
Find all candidate configuration file paths.
Sourcepub fn load<T: DeserializeOwned>(&self) -> Result<(T, PathBuf)>
pub fn load<T: DeserializeOwned>(&self) -> Result<(T, PathBuf)>
Load configuration from the first found file.
Auto Trait Implementations§
impl Freeze for ConfigDiscovery
impl RefUnwindSafe for ConfigDiscovery
impl Send for ConfigDiscovery
impl Sync for ConfigDiscovery
impl Unpin for ConfigDiscovery
impl UnsafeUnpin for ConfigDiscovery
impl UnwindSafe for ConfigDiscovery
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