Skip to main content

blueprint_rustls/
position.rs

1//! Tls position
2
3/// Orbit position for Rustls
4#[derive(Debug, Default)]
5pub struct TlsPosition {
6    /// Out discard size
7    pub in_discard: usize,
8    /// Out send size
9    pub out_send: usize,
10    /// Out encoded size
11    pub out_encoded: usize,
12    /// Want to write right side?
13    pub want_write_right: bool,
14    /// Peer closed?
15    pub peer_closed: bool,
16}
17
18// TODO: make builder / typestate
19impl TlsPosition {
20    pub(crate) fn peer_closed(in_discard: usize) -> Self {
21        Self {
22            in_discard,
23            peer_closed: true,
24            ..Default::default()
25        }
26    }
27    pub(crate) fn with_blocked_handshake(in_discard: usize) -> Self {
28        Self {
29            in_discard,
30            ..Default::default()
31        }
32    }
33    pub(crate) fn with_discard_only(in_discard: usize) -> Self {
34        Self {
35            in_discard,
36            ..Default::default()
37        }
38    }
39    /*
40    pub(crate) fn with_encoded(in_discard: usize, out_encoded: usize) -> Self {
41        Self {
42            in_discard,
43            out_encoded,
44            ..Default::default()
45        }
46    } */
47    pub(crate) fn with_send(in_discard: usize, out_send: usize) -> Self {
48        Self {
49            in_discard,
50            out_send,
51            ..Default::default()
52        }
53    }
54    pub(crate) fn want_write_right(in_discard: usize) -> Self {
55        Self {
56            in_discard,
57            want_write_right: true,
58            ..Default::default()
59        }
60    }
61}