naia_shared/types.rs
1/// Why a connection was terminated.
2#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3pub enum DisconnectReason {
4 /// The client sent a graceful disconnect packet.
5 ClientDisconnected,
6 /// The remote stopped responding within the configured timeout window.
7 TimedOut,
8 /// The server application explicitly kicked the client.
9 Kicked,
10 /// The client failed to complete authentication within the auth timeout window.
11 AuthTimeout,
12}
13
14/// Sequential 16-bit index assigned to each outgoing packet for acknowledgement tracking.
15pub type PacketIndex = u16;
16/// Server-side tick counter, wrapping at `u16::MAX`.
17pub type Tick = u16;
18/// Per-channel sequence number for reliable message ordering and deduplication.
19pub type MessageIndex = u16;
20/// Compact 8-bit message index used by tick-buffered channels.
21pub type ShortMessageIndex = u8;
22
23/// Whether a given endpoint is a server or a client.
24#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
25pub enum HostType {
26 /// This endpoint is the authoritative server.
27 Server,
28 /// This endpoint is a connecting client.
29 Client,
30}
31
32impl HostType {
33 /// Returns the opposite host type.
34 pub fn invert(self) -> Self {
35 match self {
36 HostType::Server => HostType::Client,
37 HostType::Client => HostType::Server,
38 }
39 }
40}