naia_shared/connection/
compression_config.rs

1#[derive(Clone)]
2pub struct CompressionConfig {
3    pub server_to_client: Option<CompressionMode>,
4    pub client_to_server: Option<CompressionMode>,
5}
6
7impl CompressionConfig {
8    pub fn new(
9        server_to_client: Option<CompressionMode>,
10        client_to_server: Option<CompressionMode>,
11    ) -> Self {
12        Self {
13            server_to_client,
14            client_to_server,
15        }
16    }
17}
18
19#[derive(Clone, Eq, PartialEq)]
20pub enum CompressionMode {
21    /// Compression mode using default zstd dictionary.
22    /// 1st i32 parameter here is the compression level from -7 (fastest) to 22
23    /// (smallest).
24    Default(i32),
25    /// Compression mode using custom dictionary.
26    /// 1st i32 parameter here is the compression level from -7 (fastest) to 22
27    /// (smallest). 2nd Vec<u8> parameter here is the dictionary itself.
28    Dictionary(i32, Vec<u8>),
29    /// Dictionary training mode.
30    /// 1st usize parameter here describes the desired number of samples
31    /// (packets) to train on. Obviously, the more samples trained on, the
32    /// better theoretical compression.
33    Training(usize),
34}