Skip to main content

GroupConfig

Struct GroupConfig 

Source
pub struct GroupConfig {
    pub groups: HashMap<String, Group>,
}
Expand description

The frozen group-to-capability map consumed by CapabilityCheck.

Built at kernel boot from built-ins merged with any operator-provided groups.toml. Treat the resulting value as immutable — hot reload is deferred to Layer 6.

Fields§

§groups: HashMap<String, Group>

Group name → group definition.

Implementations§

Source§

impl GroupConfig

Source

pub fn save(&self, home: &AstridHome) -> GroupConfigResult<()>

Save the config’s custom groups to home’s etc/groups.toml, creating etc/ if needed.

Built-in groups are never serialized — they are baked into GroupConfig::builtin_only and rebuilt on load. The result is idempotent: loading the written file back yields the same in-memory config.

§Errors

See Self::save_to_path.

Source

pub fn save_to_path(&self, path: &Path) -> GroupConfigResult<()>

Save to an explicit path. See Self::save for semantics.

§Errors
  • GroupConfigError::Io on filesystem failure (parent create, tempfile open/write, rename).
  • GroupConfigError::Parse never — serialization is infallible for the shape we produce.
Source§

impl GroupConfig

Source

pub fn path_for(home: &AstridHome) -> PathBuf

Canonical on-disk path for the system-wide groups config.

Source

pub fn builtin_only() -> Self

Return a GroupConfig containing only the built-in groups.

Source

pub fn load(home: &AstridHome) -> GroupConfigResult<Self>

Load the group config from home’s etc/groups.toml, falling back to Self::builtin_only if the file is absent.

§Errors

See GroupConfigError.

Source

pub fn load_from_path(path: &Path) -> GroupConfigResult<Self>

Load the group config from an explicit path.

§Errors

See GroupConfigError.

Source

pub fn from_toml_str(contents: &str) -> GroupConfigResult<Self>

Parse a GroupConfig from raw TOML, merging with the built-ins.

§Errors

See GroupConfigError.

Source

pub fn get(&self, name: &str) -> Option<&Group>

Look up a group by name, if present.

Source

pub fn len(&self) -> usize

Number of groups in the resolved config (built-ins + custom).

Source

pub fn is_empty(&self) -> bool

Whether the config contains no groups. Always false in practice because built-ins are baked in.

Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &Group)>

Iterator over (group_name, &Group).

Source

pub fn is_builtin_name(name: &str) -> bool

Return true if name refers to one of the reserved built-in groups (BUILTIN_ADMIN, BUILTIN_AGENT, BUILTIN_RESTRICTED).

Source

pub fn insert_custom_group( &self, name: String, group: Group, ) -> GroupConfigResult<Self>

Return a new GroupConfig with a custom group inserted.

Validates the group with the same rules the boot loader applies to groups.toml: built-in names are rejected, every capability passes validate_capability, and the universal * pattern requires unsafe_admin = true.

§Errors
Source

pub fn modify_custom_group( &self, name: &str, capabilities: Option<Vec<String>>, description: Option<Option<String>>, unsafe_admin: Option<bool>, ) -> GroupConfigResult<Self>

Return a new GroupConfig with a partial update applied to a custom group. Any field left as None is preserved.

§Errors
Source

pub fn remove_group(&self, name: &str) -> GroupConfigResult<Self>

Return a new GroupConfig with name removed.

Built-in groups cannot be removed and produce GroupConfigError::RedefinedBuiltin. Removing an unknown custom group produces GroupConfigError::DuplicateName (reused as the “not a custom group I know about” sentinel).

§Errors

See above.

Trait Implementations§

Source§

impl Clone for GroupConfig

Source§

fn clone(&self) -> GroupConfig

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 GroupConfig

Source§

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

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

impl Default for GroupConfig

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for GroupConfig

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 GroupConfig

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> 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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