1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! # FastNet - Ultra-Low Latency Encrypted Networking
//!
//! FastNet is a high-performance networking library designed for real-time multiplayer games.
//! It provides encrypted UDP communication with latencies as low as **12-15 microseconds**
//! while maintaining strong security through TLS 1.3 and ChaCha20-Poly1305 encryption.
//!
//! ## Features
//!
//! - **Ultra-Low Latency**: ~12-15µs average RTT on localhost
//! - **Zero-Alloc Hot Path**: Fixed buffers in send/recv, no allocations
//! - **Key Rotation**: Automatic key rotation every 1M packets or 1 hour
//! - **Linux Tuning**: SO_BUSY_POLL, sendmmsg/recvmmsg, IP_TOS
//! - **Built-in Encryption**: TLS 1.3 handshake + ChaCha20-Poly1305 AEAD
//! - **Zero Configuration Security**: Encryption is always on
//! - **Game Engine Ready**: C/C++ FFI for Unreal Engine, Unity, Godot
//! - **P2P Support**: Direct peer-to-peer connections with NAT traversal
//! - **TCP Fallback**: Automatic fallback when UDP is blocked
//! - **Asset Distribution**: LZ4 compression, chunking, BLAKE3 verification
//!
//! ## Quick Start
//!
//! ### Server
//!
//! ```rust,no_run
//! use fastnet::net::{SecureSocket, SecureEvent};
//! use std::net::SocketAddr;
//!
//! #[tokio::main]
//! async fn main() -> std::io::Result<()> {
//! let udp_addr: SocketAddr = "0.0.0.0:7777".parse().unwrap();
//! let tcp_addr: SocketAddr = "0.0.0.0:7778".parse().unwrap();
//!
//! // Load your TLS certificates
//! let certs = vec![]; // Load from file
//! let key = todo!(); // Load from file
//!
//! let mut socket = SecureSocket::bind_server(udp_addr, tcp_addr, certs, key).await?;
//!
//! loop {
//! for event in socket.poll().await? {
//! match event {
//! SecureEvent::Connected(peer_id) => {
//! println!("Peer {} connected", peer_id);
//! }
//! SecureEvent::Data(peer_id, channel, data) => {
//! // Echo back
//! socket.send(peer_id, channel, data).await?;
//! }
//! SecureEvent::Disconnected(peer_id) => {
//! println!("Peer {} disconnected", peer_id);
//! }
//! }
//! }
//! }
//! }
//! ```
//!
//! ### Client
//!
//! ```rust,no_run
//! use fastnet::net::{SecureSocket, SecureEvent};
//!
//! #[tokio::main]
//! async fn main() -> std::io::Result<()> {
//! let server_addr = "127.0.0.1:7778".parse().unwrap();
//! let mut socket = SecureSocket::connect(server_addr).await?;
//!
//! // Send data on channel 0
//! socket.send(1, 0, b"Hello!".to_vec()).await?;
//!
//! // Poll for events
//! for event in socket.poll().await? {
//! if let SecureEvent::Data(_, _, data) = event {
//! println!("Received: {:?}", data);
//! }
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────┐
//! │ SecureSocket │
//! │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
//! │ │ TLS 1.3 │ │ ChaCha20 │ │ Channels │ │
//! │ │ Handshake │──│ Poly1305 │──│ (Reliable/etc) │ │
//! │ └─────────────┘ └─────────────┘ └─────────────────┘ │
//! │ │ │
//! │ ┌─────┴─────┐ │
//! │ │ UDP │ │
//! │ └───────────┘ │
//! └─────────────────────────────────────────────────────────┘
//! ```
//!
//! ## C/C++ Integration
//!
//! Build with the `ffi` feature to generate a C-compatible dynamic library:
//!
//! ```bash
//! cargo build --release --features ffi
//! ```
//!
//! See the `include/fastnet.h` header for the C API documentation.
// Re-export main types at crate root for convenience
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;