Skip to main content

Config

Struct Config 

Source
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

Source

pub const fn repos(&self) -> &BTreeMap<String, Repo>

Read-only view of the registered repos.

Source

pub const fn workspaces(&self) -> &BTreeMap<String, Workspace>

Read-only view of the registered workspaces.

Source

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.

Source

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).

Source

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.

Source

pub fn set_settings(&mut self, settings: Option<Settings>)

Replace the [settings] section. Pass None to remove the section.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.