pub struct ConfigLoader<'a> {
shell: &'a Mutex<Shell>,
current_dir: &'a Path,
cargo_home: &'a Path,
search_stop_path: Option<&'a Path>,
}Expand description
Discovers and loads config files from the filesystem.
Fields§
§shell: &'a Mutex<Shell>§current_dir: &'a Path§cargo_home: &'a Path§search_stop_path: Option<&'a Path>Implementations§
Source§impl<'a> ConfigLoader<'a>
impl<'a> ConfigLoader<'a>
Sourcepub fn new(
shell: &'a Mutex<Shell>,
current_dir: &'a Path,
cargo_home: &'a Path,
) -> Self
pub fn new( shell: &'a Mutex<Shell>, current_dir: &'a Path, cargo_home: &'a Path, ) -> Self
Creates a config loader.
current_diris what--configarguments andincludes are relative to on the command line.cargo_homeis$CARGO_HOME, where the lowest-precedence config file live.
Sourcepub fn search_stop_path(self, path: Option<&'a Path>) -> Self
pub fn search_stop_path(self, path: Option<&'a Path>) -> Self
Sets a path where ancestor config file discovery will stop.
The given path is included.
Sourcepub fn load_layers(&self, path: &Path) -> Result<Vec<ConfigStore>>
pub fn load_layers(&self, path: &Path) -> Result<Vec<ConfigStore>>
Discovers config files from a path without merging config values.
Returns one ConfigStore per config file, from lowest to highest precedence.
Sourcefn load_file_layers(
&self,
path: &Path,
seen: &mut HashSet<PathBuf>,
scope: Scope,
output: &mut Vec<ConfigStore>,
) -> Result<()>
fn load_file_layers( &self, path: &Path, seen: &mut HashSet<PathBuf>, scope: Scope, output: &mut Vec<ConfigStore>, ) -> Result<()>
Loads a config file and its includes recursively without merging config values.
Sourcefn load_include_layers(
&self,
config: &ConfigStore,
seen: &mut HashSet<PathBuf>,
output: &mut Vec<ConfigStore>,
) -> Result<()>
fn load_include_layers( &self, config: &ConfigStore, seen: &mut HashSet<PathBuf>, output: &mut Vec<ConfigStore>, ) -> Result<()>
Loads the includes of config recursively without merging config values.
Sourcefn include_paths(
&self,
config: &ConfigStore,
) -> Result<Vec<DetailedIncludeConfig>>
fn include_paths( &self, config: &ConfigStore, ) -> Result<Vec<DetailedIncludeConfig>>
Reads the include entries of config.
Sourcepub fn load_cli_args_layer(&self, cli_args: &[String]) -> Result<ConfigStore>
pub fn load_cli_args_layer(&self, cli_args: &[String]) -> Result<ConfigStore>
Loads --config arguments and merges them into one ConfigStore.
The --config value can be a path to a config file or a key=value pair.
Later arguments take precedence over earlier ones.
Sourcepub fn get_file_path(
&self,
dir: &Path,
file_stem: &str,
warn: bool,
) -> Result<Option<PathBuf>>
pub fn get_file_path( &self, dir: &Path, file_stem: &str, warn: bool, ) -> Result<Option<PathBuf>>
Finds <file_stem> or <file_stem>.toml in dir.
The file without extension is preferred if both exist.
With warn, a warning is emitted if the legacy <file_stem> config file is used.
fn walk_tree<F>(&self, pwd: &Path, walk: F) -> Result<()>
Sourcepub fn load_credentials(&self) -> Result<ConfigStore>
pub fn load_credentials(&self) -> Result<ConfigStore>
Loads credentials config from the credentials file, if present.
fn shell(&self) -> MutexGuard<'_, Shell>
Trait Implementations§
Source§impl<'a> Clone for ConfigLoader<'a>
impl<'a> Clone for ConfigLoader<'a>
impl<'a> Copy for ConfigLoader<'a>
Auto Trait Implementations§
impl<'a> Forget for ConfigLoader<'a>
impl<'a> Freeze for ConfigLoader<'a>
impl<'a> Move for ConfigLoader<'a>
impl<'a> RefUnwindSafe for ConfigLoader<'a>
impl<'a> Send for ConfigLoader<'a>
impl<'a> Sync for ConfigLoader<'a>
impl<'a> Unpin for ConfigLoader<'a>
impl<'a> UnsafeUnpin for ConfigLoader<'a>
impl<'a> UnwindSafe for ConfigLoader<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 56 bytes