pub struct GroupManager {
pub(crate) groups: Arc<RwLock<HashMap<MessageId, GroupSession>>>,
broadcast_channel: Arc<Sender<GroupDataUpdate>>,
_broadcast_keeper: Arc<InactiveReceiver<GroupDataUpdate>>,
}Expand description
Digital Group Assistant - manages encrypted groups using the wire protocol
Fields§
§groups: Arc<RwLock<HashMap<MessageId, GroupSession>>>All group states managed by this DGA instance Key is the Blake3 hash of the CreateGroup message (which serves as both group ID and root event ID)
broadcast_channel: Arc<Sender<GroupDataUpdate>>§_broadcast_keeper: Arc<InactiveReceiver<GroupDataUpdate>>Keeper receiver to prevent broadcast channel closure (not actively used) Arc-wrapped to ensure channel stays open even when GroupManager instances are cloned and dropped
Implementations§
Source§impl GroupManager
impl GroupManager
Sourcepub fn generate_group_key(timestamp: u64) -> EncryptionKey
pub fn generate_group_key(timestamp: u64) -> EncryptionKey
Generate a new encryption key for a group (ChaCha20-Poly1305)
Sourcepub async fn group_state(&self, group_id: &MessageId) -> Option<GroupState>
pub async fn group_state(&self, group_id: &MessageId) -> Option<GroupState>
Get a group’s current state
Sourcepub async fn group_session(&self, group_id: &MessageId) -> Option<GroupSession>
pub async fn group_session(&self, group_id: &MessageId) -> Option<GroupSession>
Get a group session (state + encryption)
Sourcepub async fn all_group_sessions(&self) -> HashMap<MessageId, GroupSession>
pub async fn all_group_sessions(&self) -> HashMap<MessageId, GroupSession>
Get all managed group sessions
Sourcepub async fn all_groups(&self) -> HashMap<MessageId, GroupState>
pub async fn all_groups(&self) -> HashMap<MessageId, GroupState>
Get all managed groups (state only, for backward compatibility)
Sourcepub async fn is_member(&self, group_id: &MessageId, user: &VerifyingKey) -> bool
pub async fn is_member(&self, group_id: &MessageId, user: &VerifyingKey) -> bool
Check if a user is a member of a specific group
Sourcepub async fn member_role(
&self,
group_id: &MessageId,
user: &VerifyingKey,
) -> Option<GroupRole>
pub async fn member_role( &self, group_id: &MessageId, user: &VerifyingKey, ) -> Option<GroupRole>
Get a user’s role in a specific group
Source§impl GroupManager
impl GroupManager
Sourcepub fn builder() -> GroupManagerBuilder
pub fn builder() -> GroupManagerBuilder
Create a new DGA instance builder
Sourcepub fn create_key_from_mnemonic(
mnemonic: &MnemonicPhrase,
passphrase: &str,
group_name: &str,
timestamp: u64,
) -> GroupResult<EncryptionKey>
pub fn create_key_from_mnemonic( mnemonic: &MnemonicPhrase, passphrase: &str, group_name: &str, timestamp: u64, ) -> GroupResult<EncryptionKey>
Create a group key from a mnemonic phrase
Sourcepub fn recover_key_from_mnemonic(
mnemonic: &MnemonicPhrase,
passphrase: &str,
group_name: &str,
salt: &[u8; 32],
timestamp: u64,
) -> GroupResult<EncryptionKey>
pub fn recover_key_from_mnemonic( mnemonic: &MnemonicPhrase, passphrase: &str, group_name: &str, salt: &[u8; 32], timestamp: u64, ) -> GroupResult<EncryptionKey>
Recover a group key from a mnemonic phrase with specific salt
Sourcepub async fn create_group(
&self,
create_group: CreateGroup,
encryption_key: Option<EncryptionKey>,
creator: &KeyPair,
timestamp: u64,
) -> GroupResult<CreateGroupResult>
pub async fn create_group( &self, create_group: CreateGroup, encryption_key: Option<EncryptionKey>, creator: &KeyPair, timestamp: u64, ) -> GroupResult<CreateGroupResult>
Create a new encrypted group, returning the root event message to be sent
Sourcepub async fn create_group_event_message<T>(
&self,
group_id: MessageId,
event: GroupActivityEvent<T>,
sender: &KeyPair,
timestamp: u64,
) -> GroupResult<MessageFull>where
T: Serialize,
pub async fn create_group_event_message<T>(
&self,
group_id: MessageId,
event: GroupActivityEvent<T>,
sender: &KeyPair,
timestamp: u64,
) -> GroupResult<MessageFull>where
T: Serialize,
Create an encrypted message for a group activity event The group_id parameter should be the Blake3 hash of the CreateGroup message
Sourcepub async fn process_group_event(
&self,
message_full: &MessageFull,
) -> GroupResult<()>
pub async fn process_group_event( &self, message_full: &MessageFull, ) -> GroupResult<()>
Process an incoming group event message
Sourceasync fn find_group_by_event_tag(&self, tags: &[Tag]) -> GroupResult<MessageId>
async fn find_group_by_event_tag(&self, tags: &[Tag]) -> GroupResult<MessageId>
Find a group by looking for Event tags in the message
Sourcepub async fn user_groups(&self, user: &VerifyingKey) -> Vec<GroupState>
pub async fn user_groups(&self, user: &VerifyingKey) -> Vec<GroupState>
List all groups a user is a member of
Sourcepub async fn add_group_session(
&self,
group_id: MessageId,
session: GroupSession,
)
pub async fn add_group_session( &self, group_id: MessageId, session: GroupSession, )
Add a complete group session
Sourcepub async fn remove_group_session(
&self,
group_id: &MessageId,
) -> Option<GroupSession>
pub async fn remove_group_session( &self, group_id: &MessageId, ) -> Option<GroupSession>
Remove a group session
Sourcepub async fn rotate_group_key(
&self,
group_id: &MessageId,
new_key: EncryptionKey,
) -> GroupResult<()>
pub async fn rotate_group_key( &self, group_id: &MessageId, new_key: EncryptionKey, ) -> GroupResult<()>
Update a group session’s encryption key (for key rotation)
Sourcepub fn subscribe_to_updates(&self) -> Receiver<GroupDataUpdate>
pub fn subscribe_to_updates(&self) -> Receiver<GroupDataUpdate>
Subscribe to group updates
Sourcepub async fn create_group_subscription_filter(
&self,
group_id: &MessageId,
) -> GroupResult<Tag>
pub async fn create_group_subscription_filter( &self, group_id: &MessageId, ) -> GroupResult<Tag>
Create a subscription filter for a specific group This returns the Event tag that should be used to subscribe to group events
Trait Implementations§
Source§impl Clone for GroupManager
impl Clone for GroupManager
Source§fn clone(&self) -> GroupManager
fn clone(&self) -> GroupManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more