1
//! KIST-related parameters.
2

            
3
/// A set of parameters derived from the consensus document,
4
/// controlling the KIST behavior of channels.
5
#[derive(Debug, Clone, Copy, PartialEq, amplify::Getters)]
6
pub struct KistParams {
7
    /// Whether KIST is enabled.
8
    #[getter(as_copy)]
9
    kist_enabled: KistMode,
10
    /// The value to set for the [`TCP_NOTSENT_LOWAT`] socket option
11
    /// (on platforms that support it)
12
    /// if the `KistMode` is [`TcpNotSentLowat`](KistMode::TcpNotSentLowat).
13
    ///
14
    /// [`TCP_NOTSENT_LOWAT`]: https://lwn.net/Articles/560082/
15
    #[getter(as_copy)]
16
    tcp_notsent_lowat: u32,
17
}
18

            
19
impl KistParams {
20
    /// Create a new `KistParams` from the given `KistMode` and options.
21
2350
    pub fn new(kist_enabled: KistMode, tcp_notsent_lowat: u32) -> Self {
22
2350
        Self {
23
2350
            kist_enabled,
24
2350
            tcp_notsent_lowat,
25
2350
        }
26
2350
    }
27
}
28

            
29
/// A set of parameters, derived from the consensus document,
30
/// specifying the desired KIST behavior.
31
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
32
#[non_exhaustive]
33
pub enum KistMode {
34
    /// KIST using TCP_NOTSENT_LOWAT.
35
    TcpNotSentLowat = 1,
36
    /// KIST is disabled.
37
    Disabled = 0,
38
}