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
impl GroupConfig
Sourcepub fn save(&self, home: &AstridHome) -> GroupConfigResult<()>
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.
Sourcepub fn save_to_path(&self, path: &Path) -> GroupConfigResult<()>
pub fn save_to_path(&self, path: &Path) -> GroupConfigResult<()>
Save to an explicit path. See Self::save for semantics.
§Errors
GroupConfigError::Ioon filesystem failure (parent create, tempfile open/write, rename).GroupConfigError::Parsenever — serialization is infallible for the shape we produce.
Source§impl GroupConfig
impl GroupConfig
Sourcepub fn path_for(home: &AstridHome) -> PathBuf
pub fn path_for(home: &AstridHome) -> PathBuf
Canonical on-disk path for the system-wide groups config.
Sourcepub fn builtin_only() -> Self
pub fn builtin_only() -> Self
Return a GroupConfig containing only the built-in groups.
Sourcepub fn load(home: &AstridHome) -> GroupConfigResult<Self>
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.
Sourcepub fn load_from_path(path: &Path) -> GroupConfigResult<Self>
pub fn load_from_path(path: &Path) -> GroupConfigResult<Self>
Sourcepub fn from_toml_str(contents: &str) -> GroupConfigResult<Self>
pub fn from_toml_str(contents: &str) -> GroupConfigResult<Self>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the config contains no groups. Always false in practice
because built-ins are baked in.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &Group)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &Group)>
Iterator over (group_name, &Group).
Sourcepub fn is_builtin_name(name: &str) -> bool
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).
Sourcepub fn insert_custom_group(
&self,
name: String,
group: Group,
) -> GroupConfigResult<Self>
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
GroupConfigError::RedefinedBuiltinifnameis a built-in.GroupConfigError::DuplicateNameifnamealready exists in the custom set (an existing custom group must be removed or modified, not re-inserted).GroupConfigError::InvalidCapabilityon a bad capability string.GroupConfigError::UnsafeUniversalGrantifgroup.capabilitiescontains*withoutunsafe_admin = true.
Sourcepub fn modify_custom_group(
&self,
name: &str,
capabilities: Option<Vec<String>>,
description: Option<Option<String>>,
unsafe_admin: Option<bool>,
) -> GroupConfigResult<Self>
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
GroupConfigError::RedefinedBuiltinifnameis a built-in.GroupConfigError::DuplicateNameifnameis unknown — modify is strictly an update, not an upsert.GroupConfigError::InvalidCapability/GroupConfigError::UnsafeUniversalGrantfrom revalidation.
Sourcepub fn remove_group(&self, name: &str) -> GroupConfigResult<Self>
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
impl Clone for GroupConfig
Source§fn clone(&self) -> GroupConfig
fn clone(&self) -> GroupConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more