bornera_rustls/
client_status.rs1use bornera::TransportDiagnostic;
4
5pub(crate) const STATUS_HANDSHAKING: u8 = 1 << 0;
6pub(crate) const STATUS_OPEN: u8 = 1 << 1;
7pub(crate) const STATUS_WANTS_READ: u8 = 1 << 2;
8pub(crate) const STATUS_WANTS_WRITE: u8 = 1 << 3;
9pub(crate) const STATUS_CLOSE_NOTIFY_SENT: u8 = 1 << 4;
10
11#[derive(Clone, Copy, Debug, Eq, PartialEq)]
13pub struct RustlsClientStatus {
14 pub(crate) flags: u8,
15 pub(crate) readable_plaintext_bytes: usize,
16 pub(crate) tls_egress_bytes: usize,
17 pub(crate) peer_closure: crate::RustlsPeerClosure,
18 pub(crate) failure: Option<TransportDiagnostic>,
19}
20
21impl RustlsClientStatus {
22 pub const fn is_handshaking(self) -> bool {
24 self.flags & STATUS_HANDSHAKING != 0
25 }
26
27 pub const fn is_open(self) -> bool {
29 self.flags & STATUS_OPEN != 0
30 }
31
32 pub const fn wants_read(self) -> bool {
34 self.flags & STATUS_WANTS_READ != 0
35 }
36
37 pub const fn wants_write(self) -> bool {
39 self.flags & STATUS_WANTS_WRITE != 0
40 }
41
42 pub const fn readable_plaintext_bytes(self) -> usize {
44 self.readable_plaintext_bytes
45 }
46
47 pub const fn tls_egress_bytes(self) -> usize {
49 self.tls_egress_bytes
50 }
51
52 pub const fn peer_closure(self) -> crate::RustlsPeerClosure {
54 self.peer_closure
55 }
56
57 pub const fn close_notify_sent(self) -> bool {
59 self.flags & STATUS_CLOSE_NOTIFY_SENT != 0
60 }
61
62 pub const fn failure(self) -> Option<TransportDiagnostic> {
64 self.failure
65 }
66}