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