pub enum ConfigPath {
Default(PathBuf),
Override(PathBuf),
}Expand description
A resolved config-related file path that records whether it came from a
CLI override or from the default location under config_home.
Origin is part of the type so loaders can decide whether missing files should error (override) or be scaffolded (default) without a parallel bool.
§Examples
use nu_config::ConfigPath;
use std::path::PathBuf;
let default = ConfigPath::Default(PathBuf::from("/home/me/.config/nushell/config.nu"));
assert!(!default.is_override());
let r#override = ConfigPath::Override(PathBuf::from("/tmp/custom.nu"));
assert!(r#override.is_override());
assert_eq!(r#override.as_path(), PathBuf::from("/tmp/custom.nu"));Variants§
Default(PathBuf)
Path derived from the resolved config home (e.g. config_home/config.nu).
First-run scaffolding is allowed when the file is missing.
Override(PathBuf)
Path supplied by a CLI flag (--config, --env-config, --plugin-config).
A missing file is an error; do not scaffold.
Implementations§
Source§impl ConfigPath
impl ConfigPath
Sourcepub fn to_path_buf(&self) -> PathBuf
pub fn to_path_buf(&self) -> PathBuf
Owned copy of the concrete filesystem path.
Sourcepub fn into_path_buf(self) -> PathBuf
pub fn into_path_buf(self) -> PathBuf
Consume and return the concrete filesystem path.
Sourcepub fn is_override(&self) -> bool
pub fn is_override(&self) -> bool
Whether this path came from a CLI override.
Sourcepub fn empty_default() -> Self
pub fn empty_default() -> Self
Empty default path — used only for inert pre-resolve state
(NushellConfigDirs::empty).
Trait Implementations§
Source§impl AsRef<Path> for ConfigPath
impl AsRef<Path> for ConfigPath
Source§impl Clone for ConfigPath
impl Clone for ConfigPath
Source§fn clone(&self) -> ConfigPath
fn clone(&self) -> ConfigPath
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConfigPath
impl Debug for ConfigPath
Source§impl Display for ConfigPath
impl Display for ConfigPath
impl Eq for ConfigPath
Source§impl PartialEq for ConfigPath
impl PartialEq for ConfigPath
impl StructuralPartialEq for ConfigPath
Auto Trait Implementations§
impl Freeze for ConfigPath
impl RefUnwindSafe for ConfigPath
impl Send for ConfigPath
impl Sync for ConfigPath
impl Unpin for ConfigPath
impl UnsafeUnpin for ConfigPath
impl UnwindSafe for ConfigPath
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