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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
//! Provides guarantees for message delivery and receiving.
//!
//! Lanes are analogous to channels or streams in other protocols, which allow
//! sending messages across different logical lanes with different guarantees,
//! but over the same connection. Each lane is independent of any other lane, so
//! e.g. one lane does not block the head of another lane (head-of-line
//! blocking).
//!
//! The name "lanes" was chosen in order to reduce ambiguity:
//! * *streams* may be confused with TCP, QUIC, or WebTransport streams
//! * *channels* may be confused with MPSC channels
//!
//! # Guarantees
//!
//! Lanes mainly offer guarantees about:
//! * [reliability](LaneReliability) - ensuring that a message reaches the other
//! side without being lost; and if it is lost, it is resent
//! * [ordering](LaneOrdering) - ensuring that messages are received in the same
//! order that they are sent
//!
//! Although it is not a part of the guarantees laid out by the lane kinds,
//! *head-of-line blocking* is also an important factor to consider when
//! choosing which kind of lane to use. A lane kind with head-of-line
//! blocking may block when it is awaiting a message sent earlier, in order to
//! maintain ordering; others may not.
//!
//! Note that lane kinds provide a *minimum* guarantee of reliability and
//! ordering - a transport may provide some guarantees even if using a less
//! reliable lane kind. If a transport does not support lanes, then it
//! guarantees that all messages are sent with the strictest guarantees
//! (reliable-ordered).
//!
//! | [`LaneKind`] | Reliability | Ordering |
//! |---------------------------|-------------|----------|
//! | [`UnreliableUnordered`] | | (1) |
//! | [`UnreliableSequenced`] | | (1,2) |
//! | [`ReliableUnordered`] | ✅ | |
//! | [`ReliableOrdered`] | ✅ | (3) |
//!
//! 1. If delivery of a single chunk fails, delivery of the whole packet fails.
//! 2. If messages X and Y are sent, and X arrives after Y, then X is discarded.
//! 3. If delivery of a single chunk fails, delivery of all messages halts until
//! that single chunk is received.
//!
//! Note: Although reliable-sequenced is possible in theory, this crate does not
//! support this kind of lane. "Reliable-sequenced" is not actually reliable, as
//! messages *may* be dropped if they are older than the last received message.
//! You should probably use [`UnreliableSequenced`] instead.
//!
//! [`UnreliableUnordered`]: LaneKind::UnreliableUnordered
//! [`UnreliableSequenced`]: LaneKind::UnreliableSequenced
//! [`ReliableUnordered`]: LaneKind::ReliableUnordered
//! [`ReliableOrdered`]: LaneKind::ReliableOrdered
/// Kind of lane which can provide guarantees about the manner of message
/// delivery.
///
/// See [`lane`](crate::lane).
/// Guarantees that a [lane](crate::lane) provides with regards to delivering a
/// sent message to the receiver.
/// Guarantees that a [lane](crate::lane) provides with regards to in what order
/// messages will be received.
/// Index of a lane.
///
/// # Correctness
///
/// When creating a transport, you pass a list of [`LaneKind`]s in to define
/// which lanes are available for it to send and receive on. Functions which
/// work with a transport and a lane index (e.g. [`ClientTransport::send`])
/// expect to be given a [`LaneIndex`] which is valid for that instance of the
/// transport. If this index is for a different instance, then the transport may
/// panic.
///
/// [`ClientTransport::send`]: crate::client::ClientTransport::send
;