Browse Source

Add comments to room module.

main
Titouan Rigoudy 2 years ago
parent
commit
064cc9cbac
3 changed files with 14 additions and 0 deletions
  1. +8
    -0
      client/src/room/event.rs
  2. +3
    -0
      client/src/room/map.rs
  3. +3
    -0
      client/src/room/state.rs

+ 8
- 0
client/src/room/event.rs View File

@ -1,3 +1,5 @@
//! This module defines events affecting the room module and their handling.
use solstice_proto::server::{ use solstice_proto::server::{
RoomJoinResponse, RoomListResponse, RoomMessageResponse, RoomJoinResponse, RoomListResponse, RoomMessageResponse,
}; };
@ -11,6 +13,7 @@ use crate::handlers::{
}; };
use crate::message_handler::MessageHandler; use crate::message_handler::MessageHandler;
/// An event affecting the chat room module.
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum RoomEvent { pub enum RoomEvent {
JoinRequest(String), JoinRequest(String),
@ -21,7 +24,11 @@ pub enum RoomEvent {
MessageResponse(RoomMessageResponse), MessageResponse(RoomMessageResponse),
} }
/// An interface for room event handlers.
///
/// Allows mocking of handlers in tests.
pub trait HandleRoomEvent { pub trait HandleRoomEvent {
/// Handles the given `event` against the given global `context`.
fn handle( fn handle(
&mut self, &mut self,
context: &mut Context, context: &mut Context,
@ -29,6 +36,7 @@ pub trait HandleRoomEvent {
) -> anyhow::Result<()>; ) -> anyhow::Result<()>;
} }
/// The real, default implementation of `HandleRoomEvent`.
#[derive(Default)] #[derive(Default)]
pub struct RoomEventHandler; pub struct RoomEventHandler;


+ 3
- 0
client/src/room/map.rs View File

@ -1,3 +1,6 @@
//! This module defines abstractions for handling the global set of rooms and
//! their state.
use std::collections::HashMap; use std::collections::HashMap;
use std::mem; use std::mem;


+ 3
- 0
client/src/room/state.rs View File

@ -1,3 +1,6 @@
//! This module defines the data structures used for room state storage and
//! serialization.
use std::collections::HashSet; use std::collections::HashSet;
use std::time::SystemTime; use std::time::SystemTime;


Loading…
Cancel
Save