pub struct Config { /* private fields */ }Expand description
Top-level config aggregating all registered repos, workspaces, and the user’s agent selection.
Implementations§
Source§impl Config
impl Config
Sourcepub const fn workspaces(&self) -> &BTreeMap<String, Workspace>
pub const fn workspaces(&self) -> &BTreeMap<String, Workspace>
Read-only view of the registered workspaces.
Sourcepub const fn agents(&self) -> Option<&Agents>
pub const fn agents(&self) -> Option<&Agents>
Read-only view of the user’s agent selection. Returns None when no
[agents] section is present (init has not been run); Some(_) when
init has run, even if selected is empty.
Sourcepub fn set_agents(&mut self, agents: Option<Agents>)
pub fn set_agents(&mut self, agents: Option<Agents>)
Replace the [agents] section with the given selection. Passing
Some(Agents { selected: vec![] }) writes a configured-but-empty
section; passing None removes the section (and signals “not
initialized” to consumers).
Sourcepub const fn settings(&self) -> Option<&Settings>
pub const fn settings(&self) -> Option<&Settings>
Read-only view of the user’s persistent settings (project root,
future preferences). Returns None when no [settings] section is
present.
Sourcepub fn set_settings(&mut self, settings: Option<Settings>)
pub fn set_settings(&mut self, settings: Option<Settings>)
Replace the [settings] section. Pass None to remove the section.
Sourcepub fn default_dir() -> Option<PathBuf>
pub fn default_dir() -> Option<PathBuf>
Platform-default config directory: dirs::config_dir() / "repograph".
Returns None when no platform default exists (e.g. minimal envs); the
binary surfaces this as a usage error guiding the user to --config-dir.
Sourcepub fn load(dir: &Path) -> Result<Self, RepographError>
pub fn load(dir: &Path) -> Result<Self, RepographError>
Load config from dir/config.toml. Missing file → empty Config.
Malformed TOML → RepographError::ConfigParse.
§Errors
Returns RepographError::Io for filesystem failures, or
RepographError::ConfigParse when the file exists but is not valid TOML.
Sourcepub fn save(&self, dir: &Path) -> Result<(), RepographError>
pub fn save(&self, dir: &Path) -> Result<(), RepographError>
Save config atomically to dir/config.toml, creating dir if missing.
Atomicity: we serialize to a sibling temp file, then rename to the
target. A crash mid-write cannot leave the target half-written.
§Errors
Returns RepographError::ConfigWrite when serialization fails,
RepographError::PermissionDenied when the target dir or file is not
writable, or RepographError::Io for other filesystem failures.
Sourcepub fn add_repo(
&mut self,
name: String,
repo: Repo,
) -> Result<(), RepographError>
pub fn add_repo( &mut self, name: String, repo: Repo, ) -> Result<(), RepographError>
Register a repo, enforcing both name and path uniqueness.
§Errors
Returns RepographError::Conflict with kind = "name" when name
is already registered, or kind = "path" when repo.path is already
registered under a different name.
Sourcepub fn remove_repo(&mut self, name: &str) -> Result<Repo, RepographError>
pub fn remove_repo(&mut self, name: &str) -> Result<Repo, RepographError>
Deregister a repo by name.
§Errors
Returns RepographError::NotFound when no repo by that name is registered.
Sourcepub fn edit_repo(
&mut self,
name: &str,
edit: RepoEdit,
) -> Result<(String, Repo), RepographError>
pub fn edit_repo( &mut self, name: &str, edit: RepoEdit, ) -> Result<(String, Repo), RepographError>
Update a registered repo in place, returning the resulting (name, repo).
Unlike a remove-then-add, this preserves workspace memberships: a rename
(edit.new_name) rewrites every workspace.members entry that pointed at
the old name, so groupings survive with no dangling references. All
validation runs before any mutation, so an error leaves the config
untouched.
§Errors
Returns RepographError::NotFound with kind = "repo" when name is
not registered; RepographError::Conflict with kind = "name" when
new_name collides with a different existing repo, or kind = "path"
when edit.path is already registered under a different name.
Sourcepub fn create_workspace(
&mut self,
name: String,
description: Option<String>,
) -> Result<(), RepographError>
pub fn create_workspace( &mut self, name: String, description: Option<String>, ) -> Result<(), RepographError>
Create an empty workspace under name with an optional description.
The name must satisfy validate_workspace_name. The workspace must
not already exist.
§Errors
Returns RepographError::InvalidName when name violates the
naming policy, or RepographError::Conflict with kind = "workspace"
when a workspace by that name already exists.
Sourcepub fn remove_workspace(
&mut self,
name: &str,
) -> Result<Workspace, RepographError>
pub fn remove_workspace( &mut self, name: &str, ) -> Result<Workspace, RepographError>
Delete a workspace by name. Registered repos are untouched.
§Errors
Returns RepographError::NotFound with kind = "workspace" when
no workspace by that name is registered.
Sourcepub fn add_members(
&mut self,
workspace: &str,
repos: &[String],
) -> Result<(), RepographError>
pub fn add_members( &mut self, workspace: &str, repos: &[String], ) -> Result<(), RepographError>
Atomically attach one or more registered repos to a workspace.
All repos must be registered before any mutation occurs; if even one
is missing, the workspace is left unchanged. Already-member repos are
silently ignored. On success the members list is sorted and
deduplicated.
§Errors
Returns RepographError::NotFound with kind = "workspace" when
the workspace does not exist, or kind = "repo" (naming the first
missing repo) when any input repo is not registered.
Sourcepub fn remove_members(
&mut self,
workspace: &str,
repos: &[String],
) -> Result<(), RepographError>
pub fn remove_members( &mut self, workspace: &str, repos: &[String], ) -> Result<(), RepographError>
Detach one or more repos from a workspace. Non-members are silently ignored. The repo registry is not modified.
§Errors
Returns RepographError::NotFound with kind = "workspace" when
the workspace does not exist.
Sourcepub fn resolve_workspace<'a>(
&'a self,
workspace: &str,
) -> Result<WorkspaceResolution<'a>, RepographError>
pub fn resolve_workspace<'a>( &'a self, workspace: &str, ) -> Result<WorkspaceResolution<'a>, RepographError>
Walk a workspace’s members and partition them into live entries
(resolved against the repo registry) and dangling names (tombstoned
references to repos that are no longer registered). The order in each
returned vector matches the workspace’s stored members order
(alphabetical after sort-on-write).
§Errors
Returns RepographError::NotFound with kind = "workspace" when
the workspace does not exist.