pub struct Config {
pub projects: BTreeMap<String, Project>,
}Fields§
§projects: BTreeMap<String, Project>Implementations§
Source§impl Config
impl Config
pub fn load() -> Result<Self, Error>
Sourcepub fn save(&self) -> Result<(), Error>
pub fn save(&self) -> Result<(), Error>
Write the registry to disk atomically.
Callers that read-modify-write the registry should go through
Config::update instead, so the whole cycle is serialized against
other grove processes.
Sourcepub fn update<T, F>(f: F) -> Result<T, Error>
pub fn update<T, F>(f: F) -> Result<T, Error>
Read-modify-write the registry while holding the exclusive config lock.
f receives the config as it exists on disk right now — not a copy
loaded earlier — so concurrent grove processes queue up instead of
dropping each other’s projects.
pub fn add_project(&mut self, name: String, path: PathBuf) -> Result<(), Error>
Sourcepub fn register_discovered(&mut self, name: &str, project: Project) -> bool
pub fn register_discovered(&mut self, name: &str, project: Project) -> bool
Register a discovered project to the registry, printing a message to stderr.
Returns true if the project was newly registered, false if it was already
present or could not be saved.
Only ever called for write-intent commands (see AutoRegister) — read-only
commands must not mutate the registry, because grove env export runs on
every directory change under the mise integration.
The registry is re-read under the config lock before the insert, so a project registered concurrently by another grove process is never dropped. On failure this prints a warning and leaves both disk and memory untouched; registration is a convenience and must never block the command that triggered it.
Unlike [add_project], this skips VCS validation and path canonicalization
because discover() has already verified and canonicalized the path.
Sourcefn insert_discovered(
name: &str,
project: Project,
) -> Result<(Self, bool), Error>
fn insert_discovered( name: &str, project: Project, ) -> Result<(Self, bool), Error>
Insert project into the on-disk registry under the config lock.
Returns the resulting config and whether this call added the entry.
pub fn remove_project(&mut self, name: &str) -> Result<(), Error>
Sourcepub fn find_project_for_path(
&self,
path: &Path,
) -> Result<Option<ProjectRef>, Error>
pub fn find_project_for_path( &self, path: &Path, ) -> Result<Option<ProjectRef>, Error>
Find which project a path belongs to.
Checks in order:
- Path is a subdirectory of a project’s worktree base (more specific match)
- Path is a subdirectory of a project’s main repo
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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>
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