pub trait RoomRegistry: Send + Sync {
// Required methods
fn get_or_create(&self, room_id: &str) -> Arc<Room> ⓘ;
fn get(&self, room_id: &str) -> Option<Arc<Room>>;
fn remove(&self, room_id: &str) -> Option<Arc<Room>>;
fn room_count(&self) -> usize;
fn room_ids(&self) -> Vec<String>;
fn total_participants(&self) -> usize;
fn cleanup(&self) -> usize;
fn cleanup_empty(&self) -> usize;
}Expand description
Storage for rooms, abstracted so a room collection can be swapped without changing room/messaging code (0.4.0).
The canonical single-node implementation is RoomManager (in-memory
DashMap). The multi-node implementation is
crate::redis_rooms::RedisRoomRegistry (feature redis), which
delegates to an inner RoomManager for the local node and fans
broadcasts out through Redis pub/sub.
Required Methods§
Sourcefn remove(&self, room_id: &str) -> Option<Arc<Room>>
fn remove(&self, room_id: &str) -> Option<Arc<Room>>
Remove a room by id, returning it if present.
Sourcefn room_count(&self) -> usize
fn room_count(&self) -> usize
Number of rooms.
Sourcefn total_participants(&self) -> usize
fn total_participants(&self) -> usize
Total participants across all rooms.
Sourcefn cleanup(&self) -> usize
fn cleanup(&self) -> usize
Remove all empty rooms (no participants, no receivers). Returns number removed.
Sourcefn cleanup_empty(&self) -> usize
fn cleanup_empty(&self) -> usize
Remove all rooms with zero participants (regardless of receivers). Returns number removed.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl RoomRegistry for RoomManager
impl<C> RoomRegistry for RedisRoomRegistry<C>
Available on crate feature
redis only.