pub struct GroupSession {
pub state: GroupState,
pub current_key: EncryptionKey,
pub previous_keys: Vec<EncryptionKey>,
}Expand description
Complete group session state including both group state and encryption keys Since both are stored in the same encrypted database and always used together, combining them reduces complexity and eliminates synchronization issues.
Fields§
§state: GroupStateThe group’s business logic state (members, roles, metadata, etc.)
current_key: EncryptionKeyCurrent encryption key for this group
previous_keys: Vec<EncryptionKey>Previous keys (for decrypting old messages during key rotation)
Implementations§
Source§impl GroupSession
impl GroupSession
Sourcepub fn new(state: GroupState, encryption_key: EncryptionKey) -> Self
pub fn new(state: GroupState, encryption_key: EncryptionKey) -> Self
Create a new group session with initial state and encryption key
Sourcepub fn rotate_key(&mut self, new_key: EncryptionKey)
pub fn rotate_key(&mut self, new_key: EncryptionKey)
Rotate the encryption key, moving the current key to previous keys
Sourcepub fn all_keys(&self) -> impl Iterator<Item = &EncryptionKey>
pub fn all_keys(&self) -> impl Iterator<Item = &EncryptionKey>
Get all keys (current + previous) for decryption attempts
Sourcepub fn encrypt_group_event_content<T>(
&self,
event: &GroupActivityEvent<T>,
) -> Result<ChaCha20Poly1305Content, GroupSessionError>where
T: Serialize,
pub fn encrypt_group_event_content<T>(
&self,
event: &GroupActivityEvent<T>,
) -> Result<ChaCha20Poly1305Content, GroupSessionError>where
T: Serialize,
Encrypt a group event using ChaCha20-Poly1305
Sourcepub fn decrypt_group_event<T>(
&self,
payload: &ChaCha20Poly1305Content,
) -> Result<GroupActivityEvent<T>, GroupSessionError>where
T: for<'de> Deserialize<'de>,
pub fn decrypt_group_event<T>(
&self,
payload: &ChaCha20Poly1305Content,
) -> Result<GroupActivityEvent<T>, GroupSessionError>where
T: for<'de> Deserialize<'de>,
Decrypt a group event using ChaCha20-Poly1305
Trait Implementations§
Source§impl Clone for GroupSession
impl Clone for GroupSession
Source§fn clone(&self) -> GroupSession
fn clone(&self) -> GroupSession
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GroupSession
impl Debug for GroupSession
Source§impl<'de> Deserialize<'de> for GroupSession
impl<'de> Deserialize<'de> for GroupSession
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GroupSession
impl RefUnwindSafe for GroupSession
impl Send for GroupSession
impl Sync for GroupSession
impl Unpin for GroupSession
impl UnwindSafe for GroupSession
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more