fluvio_async_tls/common/
tls_state.rs

1#[derive(Debug, Copy, Clone)]
2pub(crate) enum TlsState {
3    #[cfg(feature = "early-data")]
4    EarlyData,
5    Stream,
6    ReadShutdown,
7    WriteShutdown,
8    FullyShutdown,
9}
10
11impl TlsState {
12    pub(crate) fn shutdown_read(&mut self) {
13        match *self {
14            TlsState::WriteShutdown | TlsState::FullyShutdown => *self = TlsState::FullyShutdown,
15            _ => *self = TlsState::ReadShutdown,
16        }
17    }
18
19    pub(crate) fn shutdown_write(&mut self) {
20        match *self {
21            TlsState::ReadShutdown | TlsState::FullyShutdown => *self = TlsState::FullyShutdown,
22            _ => *self = TlsState::WriteShutdown,
23        }
24    }
25
26    pub(crate) fn writeable(&self) -> bool {
27        !matches!(*self, TlsState::WriteShutdown | TlsState::FullyShutdown)
28    }
29
30    pub(crate) fn readable(self) -> bool {
31        !matches!(self, TlsState::ReadShutdown | TlsState::FullyShutdown)
32    }
33}