rwebtransport 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/Cargo.lock +666 -0
  2. package/Cargo.toml +31 -0
  3. package/LICENSE +202 -0
  4. package/NOTICE +41 -0
  5. package/README.md +550 -0
  6. package/crates/echo-server/Cargo.toml +20 -0
  7. package/crates/echo-server/src/main.rs +666 -0
  8. package/crates/native/Cargo.toml +23 -0
  9. package/crates/native/src/config.rs +129 -0
  10. package/crates/native/src/driver.rs +463 -0
  11. package/crates/native/src/lib.rs +821 -0
  12. package/crates/native/src/server.rs +718 -0
  13. package/crates/native/src/session.rs +1191 -0
  14. package/crates/native/src/tls.rs +96 -0
  15. package/crates/wtcore/Cargo.toml +15 -0
  16. package/crates/wtcore/src/h3.rs +226 -0
  17. package/crates/wtcore/src/lib.rs +9 -0
  18. package/dist/datagrams.d.ts +16 -0
  19. package/dist/errors.d.ts +10 -0
  20. package/dist/index.d.ts +7 -0
  21. package/dist/index.js +1512 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/index.mjs +1473 -0
  24. package/dist/index.mjs.map +1 -0
  25. package/dist/loader.d.ts +2 -0
  26. package/dist/native.d.ts +226 -0
  27. package/dist/server.d.ts +44 -0
  28. package/dist/streams.d.ts +14 -0
  29. package/dist/types.d.ts +24 -0
  30. package/dist/webtransport.d.ts +20 -0
  31. package/package.json +79 -0
  32. package/prebuilds/win32-x64/rwebtransport.node +0 -0
  33. package/scripts/bench.mjs +180 -0
  34. package/scripts/build.js +67 -0
  35. package/scripts/postinstall.js +67 -0
  36. package/scripts/setup-unix.sh +129 -0
  37. package/scripts/setup-windows.ps1 +229 -0
  38. package/vendor/quiche/AGENTS.md +75 -0
  39. package/vendor/quiche/COPYING +23 -0
  40. package/vendor/quiche/Cargo.lock +1212 -0
  41. package/vendor/quiche/Cargo.toml +215 -0
  42. package/vendor/quiche/README.md +466 -0
  43. package/vendor/quiche/examples/Makefile +46 -0
  44. package/vendor/quiche/examples/README.md +20 -0
  45. package/vendor/quiche/examples/cert-big.crt +90 -0
  46. package/vendor/quiche/examples/cert.crt +18 -0
  47. package/vendor/quiche/examples/cert.key +28 -0
  48. package/vendor/quiche/examples/client.c +343 -0
  49. package/vendor/quiche/examples/client.rs +281 -0
  50. package/vendor/quiche/examples/gen-certs.sh +15 -0
  51. package/vendor/quiche/examples/http3-client.c +473 -0
  52. package/vendor/quiche/examples/http3-client.rs +349 -0
  53. package/vendor/quiche/examples/http3-server.c +614 -0
  54. package/vendor/quiche/examples/http3-server.rs +680 -0
  55. package/vendor/quiche/examples/qpack-decode.rs +87 -0
  56. package/vendor/quiche/examples/qpack-encode.rs +88 -0
  57. package/vendor/quiche/examples/rootca.crt +21 -0
  58. package/vendor/quiche/examples/server.c +529 -0
  59. package/vendor/quiche/examples/server.rs +529 -0
  60. package/vendor/quiche/include/quiche.h +1282 -0
  61. package/vendor/quiche/quiche.svg +1 -0
  62. package/vendor/quiche/src/buffers.rs +105 -0
  63. package/vendor/quiche/src/build.rs +66 -0
  64. package/vendor/quiche/src/cid.rs +1079 -0
  65. package/vendor/quiche/src/crypto/boringssl.rs +373 -0
  66. package/vendor/quiche/src/crypto/mod.rs +671 -0
  67. package/vendor/quiche/src/dgram.rs +118 -0
  68. package/vendor/quiche/src/error.rs +263 -0
  69. package/vendor/quiche/src/ffi.rs +2290 -0
  70. package/vendor/quiche/src/flowcontrol.rs +246 -0
  71. package/vendor/quiche/src/frame.rs +2172 -0
  72. package/vendor/quiche/src/h3/AGENTS.md +54 -0
  73. package/vendor/quiche/src/h3/ffi.rs +442 -0
  74. package/vendor/quiche/src/h3/frame.rs +1404 -0
  75. package/vendor/quiche/src/h3/mod.rs +8223 -0
  76. package/vendor/quiche/src/h3/qpack/decoder.rs +288 -0
  77. package/vendor/quiche/src/h3/qpack/encoder.rs +235 -0
  78. package/vendor/quiche/src/h3/qpack/mod.rs +202 -0
  79. package/vendor/quiche/src/h3/qpack/static_table.rs +323 -0
  80. package/vendor/quiche/src/h3/stream.rs +1595 -0
  81. package/vendor/quiche/src/lib.rs +9556 -0
  82. package/vendor/quiche/src/minmax.rs +446 -0
  83. package/vendor/quiche/src/packet.rs +2334 -0
  84. package/vendor/quiche/src/path.rs +1374 -0
  85. package/vendor/quiche/src/pmtud.rs +652 -0
  86. package/vendor/quiche/src/rand.rs +64 -0
  87. package/vendor/quiche/src/range_buf.rs +186 -0
  88. package/vendor/quiche/src/ranges.rs +755 -0
  89. package/vendor/quiche/src/recovery/AGENTS.md +80 -0
  90. package/vendor/quiche/src/recovery/bandwidth.rs +565 -0
  91. package/vendor/quiche/src/recovery/bytes_in_flight.rs +179 -0
  92. package/vendor/quiche/src/recovery/congestion/cubic.rs +1038 -0
  93. package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +514 -0
  94. package/vendor/quiche/src/recovery/congestion/hystart.rs +241 -0
  95. package/vendor/quiche/src/recovery/congestion/mod.rs +361 -0
  96. package/vendor/quiche/src/recovery/congestion/prr.rs +238 -0
  97. package/vendor/quiche/src/recovery/congestion/recovery.rs +1170 -0
  98. package/vendor/quiche/src/recovery/congestion/reno.rs +291 -0
  99. package/vendor/quiche/src/recovery/congestion/test_sender.rs +201 -0
  100. package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +1947 -0
  101. package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +158 -0
  102. package/vendor/quiche/src/recovery/gcongestion/bbr.rs +37 -0
  103. package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +120 -0
  104. package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +318 -0
  105. package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +784 -0
  106. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +729 -0
  107. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +175 -0
  108. package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +190 -0
  109. package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +855 -0
  110. package/vendor/quiche/src/recovery/gcongestion/mod.rs +275 -0
  111. package/vendor/quiche/src/recovery/gcongestion/pacer.rs +294 -0
  112. package/vendor/quiche/src/recovery/gcongestion/recovery.rs +1384 -0
  113. package/vendor/quiche/src/recovery/mod.rs +3086 -0
  114. package/vendor/quiche/src/recovery/rtt.rs +152 -0
  115. package/vendor/quiche/src/stream/mod.rs +2210 -0
  116. package/vendor/quiche/src/stream/recv_buf.rs +1236 -0
  117. package/vendor/quiche/src/stream/send_buf.rs +849 -0
  118. package/vendor/quiche/src/test_utils.rs +681 -0
  119. package/vendor/quiche/src/tests.rs +12922 -0
  120. package/vendor/quiche/src/tls/boringssl.rs +375 -0
  121. package/vendor/quiche/src/tls/mod.rs +1245 -0
  122. package/vendor/quiche/src/transport_params.rs +628 -0
@@ -0,0 +1,118 @@
1
+ // Copyright (C) 2020, Cloudflare, Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright notice,
9
+ // this list of conditions and the following disclaimer.
10
+ //
11
+ // * Redistributions in binary form must reproduce the above copyright
12
+ // notice, this list of conditions and the following disclaimer in the
13
+ // documentation and/or other materials provided with the distribution.
14
+ //
15
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
+ // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17
+ // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
19
+ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
+ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ use crate::BufFactory;
28
+ use crate::Error;
29
+ use crate::Result;
30
+
31
+ use std::collections::VecDeque;
32
+
33
+ /// Keeps track of DATAGRAM frames.
34
+ #[derive(Default)]
35
+ pub struct DatagramQueue<F: BufFactory> {
36
+ queue: VecDeque<F::DgramBuf>,
37
+ queue_max_len: usize,
38
+ queue_bytes_size: usize,
39
+ }
40
+
41
+ impl<F: BufFactory> DatagramQueue<F> {
42
+ pub fn new(queue_max_len: usize) -> Self {
43
+ DatagramQueue {
44
+ queue: VecDeque::new(),
45
+ queue_bytes_size: 0,
46
+ queue_max_len,
47
+ }
48
+ }
49
+
50
+ pub fn push(&mut self, data: F::DgramBuf) -> Result<()> {
51
+ if self.is_full() {
52
+ return Err(Error::Done);
53
+ }
54
+
55
+ self.queue_bytes_size += data.as_ref().len();
56
+ self.queue.push_back(data);
57
+
58
+ Ok(())
59
+ }
60
+
61
+ pub fn peek_front_len(&self) -> Option<usize> {
62
+ self.queue.front().map(|d| d.as_ref().len())
63
+ }
64
+
65
+ pub fn peek_front_bytes(&self, buf: &mut [u8], len: usize) -> Result<usize> {
66
+ match self.queue.front() {
67
+ Some(d) => {
68
+ let len = std::cmp::min(len, d.as_ref().len());
69
+ if buf.len() < len {
70
+ return Err(Error::BufferTooShort);
71
+ }
72
+
73
+ buf[..len].copy_from_slice(&d.as_ref()[..len]);
74
+ Ok(len)
75
+ },
76
+
77
+ None => Err(Error::Done),
78
+ }
79
+ }
80
+
81
+ pub fn pop(&mut self) -> Option<F::DgramBuf> {
82
+ if let Some(d) = self.queue.pop_front() {
83
+ self.queue_bytes_size =
84
+ self.queue_bytes_size.saturating_sub(d.as_ref().len());
85
+ return Some(d);
86
+ }
87
+
88
+ None
89
+ }
90
+
91
+ pub fn has_pending(&self) -> bool {
92
+ !self.queue.is_empty()
93
+ }
94
+
95
+ pub fn purge<FN: Fn(&[u8]) -> bool>(&mut self, f: FN) {
96
+ self.queue.retain(|d| !f(d.as_ref()));
97
+ self.queue_bytes_size = self
98
+ .queue
99
+ .iter()
100
+ .fold(0, |total, d| total + d.as_ref().len());
101
+ }
102
+
103
+ pub fn is_full(&self) -> bool {
104
+ self.len() == self.queue_max_len
105
+ }
106
+
107
+ pub fn is_empty(&self) -> bool {
108
+ self.len() == 0
109
+ }
110
+
111
+ pub fn len(&self) -> usize {
112
+ self.queue.len()
113
+ }
114
+
115
+ pub fn byte_size(&self) -> usize {
116
+ self.queue_bytes_size
117
+ }
118
+ }
@@ -0,0 +1,263 @@
1
+ // Copyright (C) 2018-2019, Cloudflare, Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright notice,
9
+ // this list of conditions and the following disclaimer.
10
+ //
11
+ // * Redistributions in binary form must reproduce the above copyright
12
+ // notice, this list of conditions and the following disclaimer in the
13
+ // documentation and/or other materials provided with the distribution.
14
+ //
15
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
+ // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17
+ // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
19
+ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
+ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ /// A specialized [`Result`] type for quiche operations.
28
+ ///
29
+ /// This type is used throughout quiche's public API for any operation that
30
+ /// can produce an error.
31
+ ///
32
+ /// [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
33
+ pub type Result<T> = std::result::Result<T, Error>;
34
+
35
+ /// A QUIC error.
36
+ #[derive(Clone, Copy, Debug, PartialEq, Eq)]
37
+ pub enum Error {
38
+ /// There is no more work to do.
39
+ Done,
40
+
41
+ /// The provided buffer is too short.
42
+ BufferTooShort,
43
+
44
+ /// The provided packet cannot be parsed because its version is unknown.
45
+ UnknownVersion,
46
+
47
+ /// The provided packet cannot be parsed because it contains an invalid
48
+ /// frame.
49
+ InvalidFrame,
50
+
51
+ /// The provided packet cannot be parsed.
52
+ InvalidPacket,
53
+
54
+ /// The operation cannot be completed because the connection is in an
55
+ /// invalid state.
56
+ InvalidState,
57
+
58
+ /// The operation cannot be completed because the stream is in an
59
+ /// invalid state.
60
+ ///
61
+ /// The stream ID is provided as associated data.
62
+ InvalidStreamState(u64),
63
+
64
+ /// The peer's transport params cannot be parsed.
65
+ InvalidTransportParam,
66
+
67
+ /// A cryptographic operation failed.
68
+ CryptoFail,
69
+
70
+ /// The TLS handshake failed.
71
+ TlsFail,
72
+
73
+ /// The peer violated the local flow control limits.
74
+ FlowControl,
75
+
76
+ /// The peer violated the local stream limits.
77
+ StreamLimit,
78
+
79
+ /// The specified stream was stopped by the peer.
80
+ ///
81
+ /// The error code sent as part of the `STOP_SENDING` frame is provided as
82
+ /// associated data.
83
+ StreamStopped(u64),
84
+
85
+ /// The specified stream was reset by the peer.
86
+ ///
87
+ /// The error code sent as part of the `RESET_STREAM` frame is provided as
88
+ /// associated data.
89
+ StreamReset(u64),
90
+
91
+ /// The received data exceeds the stream's final size.
92
+ FinalSize,
93
+
94
+ /// Error in congestion control.
95
+ CongestionControl,
96
+
97
+ /// Too many identifiers were provided.
98
+ IdLimit,
99
+
100
+ /// Not enough available identifiers.
101
+ OutOfIdentifiers,
102
+
103
+ /// Error in key update.
104
+ KeyUpdate,
105
+
106
+ /// The peer sent more data in CRYPTO frames than we can buffer.
107
+ CryptoBufferExceeded,
108
+
109
+ /// The peer sent an ACK frame with an invalid range.
110
+ InvalidAckRange,
111
+
112
+ /// The peer send an ACK frame for a skipped packet used for Optimistic ACK
113
+ /// mitigation.
114
+ OptimisticAckDetected,
115
+
116
+ /// An invalid DCID was used when connecting to a remote peer.
117
+ InvalidDcidInitialization,
118
+ }
119
+
120
+ /// QUIC error codes sent on the wire.
121
+ ///
122
+ /// As defined in [RFC9000](https://www.rfc-editor.org/rfc/rfc9000.html#name-error-codes).
123
+ #[derive(Copy, Clone, Debug, Eq, PartialEq)]
124
+ pub enum WireErrorCode {
125
+ /// An endpoint uses this with CONNECTION_CLOSE to signal that the
126
+ /// connection is being closed abruptly in the absence of any error.
127
+ NoError = 0x0,
128
+ /// The endpoint encountered an internal error and cannot continue with the
129
+ /// connection.
130
+ InternalError = 0x1,
131
+ /// The server refused to accept a new connection.
132
+ ConnectionRefused = 0x2,
133
+ /// An endpoint received more data than it permitted in its advertised data
134
+ /// limits; see Section 4.
135
+ FlowControlError = 0x3,
136
+ /// An endpoint received a frame for a stream identifier that exceeded its
137
+ /// advertised stream limit for the corresponding stream type.
138
+ StreamLimitError = 0x4,
139
+ /// An endpoint received a frame for a stream that was not in a state that
140
+ /// permitted that frame.
141
+ StreamStateError = 0x5,
142
+ /// (1) An endpoint received a STREAM frame containing data that exceeded
143
+ /// the previously established final size, (2) an endpoint received a
144
+ /// STREAM frame or a RESET_STREAM frame containing a final size that
145
+ /// was lower than the size of stream data that was already received, or
146
+ /// (3) an endpoint received a STREAM frame or a RESET_STREAM frame
147
+ /// containing a different final size to the one already established.
148
+ FinalSizeError = 0x6,
149
+ /// An endpoint received a frame that was badly formatted -- for instance, a
150
+ /// frame of an unknown type or an ACK frame that has more
151
+ /// acknowledgment ranges than the remainder of the packet could carry.
152
+ FrameEncodingError = 0x7,
153
+ /// An endpoint received transport parameters that were badly formatted,
154
+ /// included an invalid value, omitted a mandatory transport parameter,
155
+ /// included a forbidden transport parameter, or were otherwise in
156
+ /// error.
157
+ TransportParameterError = 0x8,
158
+ /// The number of connection IDs provided by the peer exceeds the advertised
159
+ /// active_connection_id_limit.
160
+ ConnectionIdLimitError = 0x9,
161
+ /// An endpoint detected an error with protocol compliance that was not
162
+ /// covered by more specific error codes.
163
+ ProtocolViolation = 0xa,
164
+ /// A server received a client Initial that contained an invalid Token
165
+ /// field.
166
+ InvalidToken = 0xb,
167
+ /// The application or application protocol caused the connection to be
168
+ /// closed.
169
+ ApplicationError = 0xc,
170
+ /// An endpoint has received more data in CRYPTO frames than it can buffer.
171
+ CryptoBufferExceeded = 0xd,
172
+ /// An endpoint detected errors in performing key updates.
173
+ KeyUpdateError = 0xe,
174
+ /// An endpoint has reached the confidentiality or integrity limit for the
175
+ /// AEAD algorithm used by the given connection.
176
+ AeadLimitReached = 0xf,
177
+ /// An endpoint has determined that the network path is incapable of
178
+ /// supporting QUIC. An endpoint is unlikely to receive a
179
+ /// CONNECTION_CLOSE frame carrying this code except when the path does
180
+ /// not support a large enough MTU.
181
+ NoViablePath = 0x10,
182
+ }
183
+
184
+ impl Error {
185
+ pub(crate) fn to_wire(self) -> u64 {
186
+ match self {
187
+ Error::Done => WireErrorCode::NoError as u64,
188
+ Error::InvalidFrame => WireErrorCode::FrameEncodingError as u64,
189
+ Error::InvalidStreamState(..) =>
190
+ WireErrorCode::StreamStateError as u64,
191
+ Error::InvalidTransportParam =>
192
+ WireErrorCode::TransportParameterError as u64,
193
+ Error::FlowControl => WireErrorCode::FlowControlError as u64,
194
+ Error::StreamLimit => WireErrorCode::StreamLimitError as u64,
195
+ Error::IdLimit => WireErrorCode::ConnectionIdLimitError as u64,
196
+ Error::FinalSize => WireErrorCode::FinalSizeError as u64,
197
+ Error::CryptoBufferExceeded =>
198
+ WireErrorCode::CryptoBufferExceeded as u64,
199
+ Error::KeyUpdate => WireErrorCode::KeyUpdateError as u64,
200
+ _ => WireErrorCode::ProtocolViolation as u64,
201
+ }
202
+ }
203
+
204
+ #[cfg(feature = "ffi")]
205
+ pub(crate) fn to_c(self) -> libc::ssize_t {
206
+ match self {
207
+ Error::Done => -1,
208
+ Error::BufferTooShort => -2,
209
+ Error::UnknownVersion => -3,
210
+ Error::InvalidFrame => -4,
211
+ Error::InvalidPacket => -5,
212
+ Error::InvalidState => -6,
213
+ Error::InvalidStreamState(_) => -7,
214
+ Error::InvalidTransportParam => -8,
215
+ Error::CryptoFail => -9,
216
+ Error::TlsFail => -10,
217
+ Error::FlowControl => -11,
218
+ Error::StreamLimit => -12,
219
+ Error::FinalSize => -13,
220
+ Error::CongestionControl => -14,
221
+ Error::StreamStopped { .. } => -15,
222
+ Error::StreamReset { .. } => -16,
223
+ Error::IdLimit => -17,
224
+ Error::OutOfIdentifiers => -18,
225
+ Error::KeyUpdate => -19,
226
+ Error::CryptoBufferExceeded => -20,
227
+ Error::InvalidAckRange => -21,
228
+ Error::OptimisticAckDetected => -22,
229
+ Error::InvalidDcidInitialization => -23,
230
+ }
231
+ }
232
+ }
233
+
234
+ impl std::fmt::Display for Error {
235
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
236
+ write!(f, "{self:?}")
237
+ }
238
+ }
239
+
240
+ impl std::error::Error for Error {
241
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
242
+ None
243
+ }
244
+ }
245
+
246
+ impl From<octets::BufferTooShortError> for Error {
247
+ fn from(_err: octets::BufferTooShortError) -> Self {
248
+ Error::BufferTooShort
249
+ }
250
+ }
251
+
252
+ /// Represents information carried by `CONNECTION_CLOSE` frames.
253
+ #[derive(Clone, Debug, PartialEq, Eq)]
254
+ pub struct ConnectionError {
255
+ /// Whether the error came from the application or the transport layer.
256
+ pub is_app: bool,
257
+
258
+ /// The error code carried by the `CONNECTION_CLOSE` frame.
259
+ pub error_code: u64,
260
+
261
+ /// The reason carried by the `CONNECTION_CLOSE` frame.
262
+ pub reason: Vec<u8>,
263
+ }