pub struct SessionManager<S: StateStorage + 'static, M: MessagesManagerTrait + 'static> {
storage: Arc<S>,
messages_manager: Arc<M>,
pqxdh_handlers: RwLock<BTreeMap<PqxdhInboxProtocol, (Arc<PqxdhProtocolHandler<M>>, JoinHandle<()>)>>,
group_manager: GroupManager,
group_manager_task: JoinHandle<()>,
client_keypair: Arc<KeyPair>,
}Expand description
State synchronization manager that automatically listens to and persists state changes.
This manager follows the persistent messenger pattern:
- External objects register with the manager
- The manager listens to their state changes
- State changes are automatically persisted to storage
- State change events are broadcast to subscribers
The SessionManager is designed to be long-lived and handles the lifecycle of multiple PQXDH protocol handlers and group encryption sessions, automatically managing their state persistence and providing reactive access to state changes.
Fields§
§storage: Arc<S>Underlying state storage
messages_manager: Arc<M>Messages manager for subscription and message handling
pqxdh_handlers: RwLock<BTreeMap<PqxdhInboxProtocol, (Arc<PqxdhProtocolHandler<M>>, JoinHandle<()>)>>PQXDH handlers with their background listener tasks
group_manager: GroupManagerGroup manager instance with background listener task
group_manager_task: JoinHandle<()>§client_keypair: Arc<KeyPair>Implementations§
Source§impl<S: StateStorage + 'static, M: MessagesManagerTrait + 'static> SessionManager<S, M>
impl<S: StateStorage + 'static, M: MessagesManagerTrait + 'static> SessionManager<S, M>
Sourcepub fn builder(
storage: Arc<S>,
messages_manager: Arc<M>,
) -> SessionManagerBuilder<S, M>
pub fn builder( storage: Arc<S>, messages_manager: Arc<M>, ) -> SessionManagerBuilder<S, M>
Sourcepub fn messages_manager(&self) -> &Arc<M>
pub fn messages_manager(&self) -> &Arc<M>
Get a reference to the messages manager
pub async fn pqxdh_handler( &self, protocol: PqxdhInboxProtocol, ) -> SessionManagerResult<Arc<PqxdhProtocolHandler<M>>>
Source§impl<S: StateStorage + 'static, M: MessagesManagerTrait + 'static> SessionManager<S, M>
Group Manager Integration
impl<S: StateStorage + 'static, M: MessagesManagerTrait + 'static> SessionManager<S, M>
Group Manager Integration
Sourceasync fn init_group_manager(
storage: Arc<S>,
client_keypair: Arc<KeyPair>,
) -> SessionManagerResult<(GroupManager, JoinHandle<()>)>
async fn init_group_manager( storage: Arc<S>, client_keypair: Arc<KeyPair>, ) -> SessionManagerResult<(GroupManager, JoinHandle<()>)>
Initialize group manager with listener task
Sourcepub fn group_manager(&self) -> GroupManager
pub fn group_manager(&self) -> GroupManager
Get access to the group manager
Source§impl<S: StateStorage + 'static, M: MessagesManagerTrait + 'static> SessionManager<S, M>
Live Object Access and State Cloning
impl<S: StateStorage + 'static, M: MessagesManagerTrait + 'static> SessionManager<S, M>
Live Object Access and State Cloning
Sourceasync fn load_pqxdh_states(
storage: Arc<S>,
messages_manager: Arc<M>,
client_keypair: Arc<KeyPair>,
namespace: StateNamespace,
) -> SessionManagerResult<Vec<(PqxdhInboxProtocol, (Arc<PqxdhProtocolHandler<M>>, JoinHandle<()>))>>
async fn load_pqxdh_states( storage: Arc<S>, messages_manager: Arc<M>, client_keypair: Arc<KeyPair>, namespace: StateNamespace, ) -> SessionManagerResult<Vec<(PqxdhInboxProtocol, (Arc<PqxdhProtocolHandler<M>>, JoinHandle<()>))>>
Load PQXDH states from storage