use bornera::TransportDiagnostic;
pub(crate) const STATUS_HANDSHAKING: u8 = 1 << 0;
pub(crate) const STATUS_OPEN: u8 = 1 << 1;
pub(crate) const STATUS_WANTS_READ: u8 = 1 << 2;
pub(crate) const STATUS_WANTS_WRITE: u8 = 1 << 3;
pub(crate) const STATUS_CLOSE_NOTIFY_SENT: u8 = 1 << 4;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct RustlsClientStatus {
pub(crate) flags: u8,
pub(crate) readable_plaintext_bytes: usize,
pub(crate) tls_egress_bytes: usize,
pub(crate) peer_closure: crate::RustlsPeerClosure,
pub(crate) failure: Option<TransportDiagnostic>,
}
impl RustlsClientStatus {
pub const fn is_handshaking(self) -> bool {
self.flags & STATUS_HANDSHAKING != 0
}
pub const fn is_open(self) -> bool {
self.flags & STATUS_OPEN != 0
}
pub const fn wants_read(self) -> bool {
self.flags & STATUS_WANTS_READ != 0
}
pub const fn wants_write(self) -> bool {
self.flags & STATUS_WANTS_WRITE != 0
}
pub const fn readable_plaintext_bytes(self) -> usize {
self.readable_plaintext_bytes
}
pub const fn tls_egress_bytes(self) -> usize {
self.tls_egress_bytes
}
pub const fn peer_closure(self) -> crate::RustlsPeerClosure {
self.peer_closure
}
pub const fn close_notify_sent(self) -> bool {
self.flags & STATUS_CLOSE_NOTIFY_SENT != 0
}
pub const fn failure(self) -> Option<TransportDiagnostic> {
self.failure
}
}