pub struct CachedConfig { /* private fields */ }Expand description
A cached project configuration that can be loaded once and reused across
multiple operations. This avoids re-reading .patchloom.toml from disk
on every API call.
§Thread safety
CachedConfig is Send + Sync and can be shared across threads via
Arc<CachedConfig>.
§Example
use patchloom::config::CachedConfig;
use std::path::Path;
let config = CachedConfig::load(Path::new("/my/project"));
// Use config.project_config() in multiple API calls...Implementations§
Source§impl CachedConfig
impl CachedConfig
Sourcepub fn load(start: &Path) -> Self
pub fn load(start: &Path) -> Self
Load configuration from the given directory, searching upward for
.patchloom.toml. Returns a CachedConfig with defaults if no
config file is found.
Sourcepub fn project_config(&self) -> &ProjectConfig
pub fn project_config(&self) -> &ProjectConfig
Access the loaded project configuration.
Sourcepub fn config_dir(&self) -> Option<&Path>
pub fn config_dir(&self) -> Option<&Path>
The directory containing the .patchloom.toml file, if one was found.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CachedConfig
impl RefUnwindSafe for CachedConfig
impl Send for CachedConfig
impl Sync for CachedConfig
impl Unpin for CachedConfig
impl UnsafeUnpin for CachedConfig
impl UnwindSafe for CachedConfig
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
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>
Converts
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>
Converts
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