pub enum UserContext {
Toggle(bool),
Path(String),
Full {
enable: bool,
path: Option<String>,
},
}Expand description
Cross-repo user context source. Cargo-dependency-style shorthand:
bool toggles enable at the default path; a string is enable + that path.
Variants§
Implementations§
Source§impl UserContext
impl UserContext
Sourcepub fn path(&self) -> PathBuf
pub fn path(&self) -> PathBuf
The file this source points at (configured path or default), regardless
of whether it is enabled. Used by --user editing.
Sourcepub fn path_in(&self, config_root: &Path) -> PathBuf
pub fn path_in(&self, config_root: &Path) -> PathBuf
Like path, but resolves the “no explicit path” default
relative to config_root instead of the process-global
tv_config_root. This matters for the user-level config.toml (and
for tests with an injected root): its unconfigured default is the
context.json colocated with it under config_root, which need not be
the real tv_config_root().
Sourcepub fn resolve(&self) -> Option<PathBuf>
pub fn resolve(&self) -> Option<PathBuf>
Some(path) when enabled (consulted by the hook); None when disabled.
Sourcepub fn resolve_in(&self, config_root: &Path) -> Option<PathBuf>
pub fn resolve_in(&self, config_root: &Path) -> Option<PathBuf>
Like resolve, but resolves the “no explicit path”
default relative to config_root (via path_in)
instead of the process-global tv_config_root. Callers that took an
injected config_root MUST use this — resolve() would leak back to
the real ~/.config for the default-path case.
Sourcepub fn from_init_flags(
no_user_context: bool,
user_context: Option<String>,
) -> Result<Option<UserContext>, String>
pub fn from_init_flags( no_user_context: bool, user_context: Option<String>, ) -> Result<Option<UserContext>, String>
Map init’s --no-user-context / --user-context <path> flags to a
requested user-context override. Ok(None) means neither flag was given
(the caller decides the default/preserve behavior). Rejects an empty/blank
--user-context value.
Trait Implementations§
Source§impl Clone for UserContext
impl Clone for UserContext
Source§fn clone(&self) -> UserContext
fn clone(&self) -> UserContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more