Skip to main content

aetheris_protocol/
lib.rs

1//! Core protocol definitions and communication contracts for the Aetheris Engine.
2//!
3//! **Phase:** All Phases - Stable Core
4//! **Constraint:** Minimal dependency footprint.
5//! **Purpose:** Defines the Trait Facade (`GameTransport`, `WorldState`, Encoder) that isolates
6//! the engine logic from concrete implementations.
7
8#![warn(clippy::all, clippy::pedantic)]
9
10pub mod error;
11pub mod events;
12pub mod reassembler;
13pub mod traits;
14pub mod types;
15
16pub use reassembler::Reassembler;
17
18/// Maximum safe payload size for UDP datagrams to avoid fragmentation.
19pub const MAX_SAFE_PAYLOAD_SIZE: usize = 1200;
20
21/// Maximum number of fragments allowed for a single message.
22/// 1024 * 1136 bytes ~= 1.1 MiB.
23pub const MAX_TOTAL_FRAGMENTS: u16 = 1024;
24
25/// Estimated overhead in bytes for a `WireEvent::Fragment` envelope using `rmp-serde`.
26/// This includes the enum tag, `FragmentedEvent` fields, and `Vec<u8>` length prefix.
27pub const FRAGMENT_OVERHEAD: usize = 64;
28
29/// The maximum bytes of game payload that can fit into a single MTU-safe fragment.
30pub const MAX_FRAGMENT_PAYLOAD_SIZE: usize = MAX_SAFE_PAYLOAD_SIZE - FRAGMENT_OVERHEAD;
31
32#[cfg(feature = "grpc")]
33/// gRPC Auth services and types generated from `auth.proto`.
34#[allow(clippy::all, clippy::pedantic)]
35pub mod auth {
36    pub mod v1 {
37        tonic::include_proto!("aetheris.auth.v1");
38    }
39}
40
41#[cfg(feature = "grpc")]
42/// gRPC Matchmaking services and types generated from `matchmaking.proto`.
43#[allow(clippy::all, clippy::pedantic)]
44pub mod matchmaking {
45    pub mod v1 {
46        tonic::include_proto!("aetheris.matchmaking.v1");
47    }
48}
49
50#[cfg(feature = "grpc")]
51/// gRPC Telemetry service and types generated from `telemetry.proto`.
52/// This module is the out-of-band diagnostic channel — independent of WebTransport.
53#[allow(clippy::all, clippy::pedantic)]
54pub mod telemetry {
55    pub mod v1 {
56        tonic::include_proto!("aetheris.telemetry.v1");
57    }
58}
59
60#[cfg(any(test, feature = "test-utils"))]
61pub mod test_doubles;
62
63#[cfg(test)]
64mod tests {
65    #[test]
66    fn test_protocol_foundation() {
67        // Basic assertion to satisfy nextest's requirement for at least one test
68        let synchronized = true;
69        assert!(synchronized);
70    }
71}