runecast_protocol/lib.rs
1//! `RuneCast` Protocol Library
2//!
3//! This crate defines the WebSocket protocol for `RuneCast`, including:
4//!
5//! - Client-to-server message types
6//! - Server-to-client message types
7//! - Shared data types (`Grid`, `Position`, `PlayerInfo`, etc.)
8//! - Player identity and context types
9//!
10//! # Usage
11//!
12//! ```rust
13//! use runecast_protocol::protocol::{ClientMessage, ServerMessage};
14//!
15//! // Parse an incoming client message
16//! let json = r#"{"type":"heartbeat"}"#;
17//! let msg: ClientMessage = serde_json::from_str(json).unwrap();
18//!
19//! // Create a server response
20//! let response = ServerMessage::HeartbeatAck {
21//! server_time: 1701234567890,
22//! };
23//!
24//! // Serialize it for the wire
25//! let wire = serde_json::to_string(&response).unwrap();
26//! assert!(wire.contains(r#""type":"heartbeat_ack""#));
27//! ```
28
29pub mod player;
30pub mod protocol;
31
32// Re-export commonly used items at crate root for convenience
33pub use player::{PlayerContext, PlayerIdentity};
34pub use protocol::{
35 client_messages::ClientMessage,
36 server_messages::ServerMessage,
37 types::{
38 default_dictionary, AdminGameInfo, AdventureEventKind, BotDifficulty, BotSpec, BuildInfo,
39 ConnectKind, ConnectParams, CustomMeta, DebugBackendGameState, DebugHandlerGameState,
40 DebugLobbyState, DebugPlayerInfo, DebugWebsocketContext, ErrorCode, EventConfig,
41 GameConfig, GamePlayerInfo, GameSnapshot, GameState, GameSummary, Grid, GridCell,
42 LobbyChange, LobbyGameInfo, LobbyGamePlayerInfo, LobbyPlayerInfo, LobbyType, ModeCap,
43 Multiplier, PlayerInfo, PlayerName, Position, RuneBoxStanding, ScoreInfo, SpectatorInfo,
44 TimerVoteState, TurnPassReason, MAIN_DICTIONARY,
45 },
46 LobbySnapshot,
47};