pub struct Roots {
pub home: PathBuf,
pub os_config: PathBuf,
pub xdg_config: PathBuf,
pub cwd: PathBuf,
}Expand description
Where to look. Everything is derived from injected roots rather than read from the environment, so the whole table is testable against tempdirs.
Two config roots, not one, because the harnesses genuinely disagree. Claude
Desktop and VS Code follow the OS convention (~/Library/Application Support
on macOS, %APPDATA% on Windows, ~/.config on Linux) - that is
Self::os_config. Zed and OpenCode use an XDG-style ~/.config on macOS
as well as Linux - that is Self::xdg_config. Collapsing them would
silently look in the wrong place for half the table on macOS.
Fields§
§home: PathBufThe user’s home directory.
os_config: PathBufThe OS config directory (dirs::config_dir).
xdg_config: PathBufThe XDG-style config directory: $XDG_CONFIG_HOME, else ~/.config.
cwd: PathBufThe current working directory, for project-scoped files.
Implementations§
Source§impl Roots
impl Roots
Sourcepub fn new(home: PathBuf, os_config: PathBuf, cwd: PathBuf) -> Self
pub fn new(home: PathBuf, os_config: PathBuf, cwd: PathBuf) -> Self
Resolve both config roots from a home directory and the OS convention.
$XDG_CONFIG_HOME is honoured when set, since a user who sets it means
it. On Windows there is no ~/.config convention at all, so the XDG
root falls back to the OS one.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Roots
impl RefUnwindSafe for Roots
impl Send for Roots
impl Sync for Roots
impl Unpin for Roots
impl UnsafeUnpin for Roots
impl UnwindSafe for Roots
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more