diff --git a/client/src/room/event.rs b/client/src/room/event.rs index 28e0cc6..aee5845 100644 --- a/client/src/room/event.rs +++ b/client/src/room/event.rs @@ -1,3 +1,5 @@ +//! This module defines events affecting the room module and their handling. + use solstice_proto::server::{ RoomJoinResponse, RoomListResponse, RoomMessageResponse, }; @@ -11,6 +13,7 @@ use crate::handlers::{ }; use crate::message_handler::MessageHandler; +/// An event affecting the chat room module. #[derive(Debug, PartialEq, Eq)] pub enum RoomEvent { JoinRequest(String), @@ -21,7 +24,11 @@ pub enum RoomEvent { MessageResponse(RoomMessageResponse), } +/// An interface for room event handlers. +/// +/// Allows mocking of handlers in tests. pub trait HandleRoomEvent { + /// Handles the given `event` against the given global `context`. fn handle( &mut self, context: &mut Context, @@ -29,6 +36,7 @@ pub trait HandleRoomEvent { ) -> anyhow::Result<()>; } +/// The real, default implementation of `HandleRoomEvent`. #[derive(Default)] pub struct RoomEventHandler; diff --git a/client/src/room/map.rs b/client/src/room/map.rs index 21d3fea..cadb82e 100644 --- a/client/src/room/map.rs +++ b/client/src/room/map.rs @@ -1,3 +1,6 @@ +//! This module defines abstractions for handling the global set of rooms and +//! their state. + use std::collections::HashMap; use std::mem; diff --git a/client/src/room/state.rs b/client/src/room/state.rs index a0599f9..91be6e8 100644 --- a/client/src/room/state.rs +++ b/client/src/room/state.rs @@ -1,3 +1,6 @@ +//! This module defines the data structures used for room state storage and +//! serialization. + use std::collections::HashSet; use std::time::SystemTime;