pub struct PermissionGroupManager {
updates: AsyncMutex<()>,
state: SyncRwLock<PermissionGroupManagerState>,
store: Option<Arc<dyn PermissionGroupStore>>,
}Expand description
Runtime permission groups with serialized, persistence-first updates.
Fields§
§updates: AsyncMutex<()>§state: SyncRwLock<PermissionGroupManagerState>§store: Option<Arc<dyn PermissionGroupStore>>Implementations§
Source§impl PermissionGroupManager
impl PermissionGroupManager
Sourcepub fn new(
config: PermissionGroupsConfig,
store: Option<Arc<dyn PermissionGroupStore>>,
) -> Result<Self, PermissionConfigError>
pub fn new( config: PermissionGroupsConfig, store: Option<Arc<dyn PermissionGroupStore>>, ) -> Result<Self, PermissionConfigError>
Builds a manager from typed config and an optional persistence store.
§Errors
Returns an error when the initial config does not resolve.
Sourcepub fn transient(
config: PermissionGroupsConfig,
) -> Result<Self, PermissionConfigError>
pub fn transient( config: PermissionGroupsConfig, ) -> Result<Self, PermissionConfigError>
Builds a manager without persistence.
§Errors
Returns an error when the initial config does not resolve.
Sourcepub fn config_snapshot(&self) -> PermissionGroupsConfig
pub fn config_snapshot(&self) -> PermissionGroupsConfig
Returns a typed snapshot of the current config.
Sourcepub fn contains_group(&self, group: &str) -> bool
pub fn contains_group(&self, group: &str) -> bool
Returns whether a configured group exists.
Sourcepub fn group_names(&self) -> Vec<String>
pub fn group_names(&self) -> Vec<String>
Returns configured group names sorted by name.
Sourcepub fn effective_permissions(
&self,
assigned_groups: &[String],
subject_permissions: &PermissionSet,
) -> PermissionSet
pub fn effective_permissions( &self, assigned_groups: &[String], subject_permissions: &PermissionSet, ) -> PermissionSet
Builds an effective permission set from the current group snapshot.
Sourcepub fn effective_metadata(
&self,
assigned_groups: &[String],
subject_metadata: &PermissionMetadataSet,
) -> PermissionMetadataSet
pub fn effective_metadata( &self, assigned_groups: &[String], subject_metadata: &PermissionMetadataSet, ) -> PermissionMetadataSet
Builds effective metadata from the current group snapshot.
Sourcepub async fn replace_config(
&self,
config: PermissionGroupsConfig,
) -> Result<(), PermissionGroupManagerError>
pub async fn replace_config( &self, config: PermissionGroupsConfig, ) -> Result<(), PermissionGroupManagerError>
Replaces the complete config after validation and optional persistence.
§Errors
Returns an error when validation or persistence fails.
Sourcepub async fn update_config(
&self,
update: impl FnOnce(&mut PermissionGroupsConfig) + Send,
) -> Result<(), PermissionGroupManagerError>
pub async fn update_config( &self, update: impl FnOnce(&mut PermissionGroupsConfig) + Send, ) -> Result<(), PermissionGroupManagerError>
Updates the latest config under the manager update lock.
§Errors
Returns an error when the updated config is invalid or cannot be persisted.
Sourcepub async fn try_update_config<T, E>(
&self,
update: impl FnOnce(&mut PermissionGroupsConfig) -> Result<T, E> + Send,
) -> Result<T, PermissionGroupUpdateError<E>>
pub async fn try_update_config<T, E>( &self, update: impl FnOnce(&mut PermissionGroupsConfig) -> Result<T, E> + Send, ) -> Result<T, PermissionGroupUpdateError<E>>
Updates the latest config with a fallible caller-owned edit.
§Errors
Returns the edit error, or a validation or persistence error.
async fn replace_config_locked( &self, config: PermissionGroupsConfig, ) -> Result<(), PermissionGroupManagerError>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PermissionGroupManager
impl !RefUnwindSafe for PermissionGroupManager
impl !UnwindSafe for PermissionGroupManager
impl Send for PermissionGroupManager
impl Sync for PermissionGroupManager
impl Unpin for PermissionGroupManager
impl UnsafeUnpin for PermissionGroupManager
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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreArc<SyncMutex<>>