moqtap_codec/draft14/error_codes.rs
1//! Error, status and stream-reset code registries defined by
2//! draft-ietf-moq-transport-14.
3//!
4//! One enum per registry in the IANA Considerations section (Section 13.1). The
5//! registry tables list only Name, Code and Specification; the per-code prose in
6//! the variant docs is taken from the section each row cites.
7//!
8//! `from_u64` returns `None` for any value the draft does not assign. A peer may
9//! legitimately send a code from a later draft or a private extension, and an
10//! unrecognized code must not be a decode failure at this layer.
11//!
12//! draft-14 assigns no reserved-for-greasing ranges in these registries; every
13//! row is a single code point.
14
15/// Session termination error codes, from the "Session Termination Error Codes"
16/// registry in draft-ietf-moq-transport-14 Section 13.1.1. Every row cites
17/// Section 3.4 (Termination), the source of the descriptions below.
18///
19/// Carried in the QUIC CONNECTION_CLOSE frame or the WebTransport
20/// CLOSE_WEBTRANSPORT_SESSION capsule. The draft assigns 0x0 through 0x9 and
21/// 0x10 through 0x1A; 0xA through 0xF are unassigned.
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23#[repr(u64)]
24pub enum SessionErrorCode {
25 /// `NO_ERROR` — The session is being terminated without an error.
26 NoError = 0x0,
27 /// `INTERNAL_ERROR` — An implementation specific error occurred.
28 InternalError = 0x1,
29 /// `UNAUTHORIZED` — The client is not authorized to establish a session.
30 Unauthorized = 0x2,
31 /// `PROTOCOL_VIOLATION` — The remote endpoint performed an action that was
32 /// disallowed by the specification.
33 ProtocolViolation = 0x3,
34 /// `INVALID_REQUEST_ID` — The session was closed because the endpoint used a
35 /// Request ID that was smaller than or equal to a previously received
36 /// request ID, or the least-significant bit of the request ID was incorrect
37 /// for the endpoint.
38 ///
39 /// This is a monotonicity and parity rule, not a lookup failure: the code
40 /// does not mean the Request ID was unknown.
41 InvalidRequestId = 0x4,
42 /// `DUPLICATE_TRACK_ALIAS` — The endpoint attempted to use a Track Alias
43 /// that was already in use.
44 DuplicateTrackAlias = 0x5,
45 /// `KEY_VALUE_FORMATTING_ERROR` — The key-value pair has a formatting error.
46 KeyValueFormattingError = 0x6,
47 /// `TOO_MANY_REQUESTS` — The session was closed because the endpoint used a
48 /// Request ID equal to or larger than the current Maximum Request ID.
49 ///
50 /// This is a ceiling on the Request ID value, not a limit on how many
51 /// requests are outstanding at once.
52 TooManyRequests = 0x7,
53 /// `INVALID_PATH` — The PATH parameter was used by a server, on a
54 /// WebTransport session, or the server does not support the path.
55 ///
56 /// Two of those three conditions are about where PATH appeared rather than
57 /// about the path value itself.
58 InvalidPath = 0x8,
59 /// `MALFORMED_PATH` — The PATH parameter does not conform to the rules in
60 /// Section 9.3.2.2.
61 MalformedPath = 0x9,
62 /// `GOAWAY_TIMEOUT` — The session was closed because the peer took too long
63 /// to close the session in response to a GOAWAY (Section 9.4) message. See
64 /// session migration (Section 3.5).
65 GoawayTimeout = 0x10,
66 /// `CONTROL_MESSAGE_TIMEOUT` — The session was closed because the peer took
67 /// too long to respond to a control message.
68 ControlMessageTimeout = 0x11,
69 /// `DATA_STREAM_TIMEOUT` — The session was closed because the peer took too
70 /// long to send data expected on an open Data Stream (see Section 10). This
71 /// includes fields of a stream header or an object header within a data
72 /// stream. If an endpoint times out waiting for a new object header on an
73 /// open subgroup stream, it MAY send a STOP_SENDING on that stream or
74 /// terminate the subscription.
75 DataStreamTimeout = 0x12,
76 /// `AUTH_TOKEN_CACHE_OVERFLOW` — The Session limit Section 9.3.2.4 of the
77 /// size of all registered Authorization tokens has been exceeded.
78 ///
79 /// The limit is on total serialized size, not on the number of tokens. The
80 /// missing parentheses around the cross-reference are as printed in the
81 /// draft.
82 AuthTokenCacheOverflow = 0x13,
83 /// `DUPLICATE_AUTH_TOKEN_ALIAS` — Authorization Token attempted to register
84 /// an Alias that was in use (see Section 9.2.1.1).
85 DuplicateAuthTokenAlias = 0x14,
86 /// `VERSION_NEGOTIATION_FAILED` — The client didn't offer a version
87 /// supported by the server.
88 VersionNegotiationFailed = 0x15,
89 /// `MALFORMED_AUTH_TOKEN` — Invalid Auth Token serialization during
90 /// registration (see Section 9.2.1.1).
91 MalformedAuthToken = 0x16,
92 /// `UNKNOWN_AUTH_TOKEN_ALIAS` — No registered token found for the provided
93 /// Alias (see Section 9.2.1.1).
94 UnknownAuthTokenAlias = 0x17,
95 /// `EXPIRED_AUTH_TOKEN` — Authorization token has expired
96 /// (Section 9.2.1.1).
97 ExpiredAuthToken = 0x18,
98 /// `INVALID_AUTHORITY` — The specified AUTHORITY does not correspond to this
99 /// server or cannot be used in this context.
100 InvalidAuthority = 0x19,
101 /// `MALFORMED_AUTHORITY` — The AUTHORITY value is syntactically invalid.
102 MalformedAuthority = 0x1A,
103}
104
105/// SUBSCRIBE_ERROR codes, from the "SUBSCRIBE_ERROR Codes" registry in
106/// draft-ietf-moq-transport-14 Section 13.1.2. Every row cites Section 9.9
107/// (SUBSCRIBE_ERROR), the source of the descriptions below.
108///
109/// This type decodes SUBSCRIBE_ERROR only. It is not a shared request-level
110/// registry: draft-14 gives each request-scoped message its own registry, and
111/// they disagree at 0x4. Decoding another message's error code with this type
112/// silently produces the wrong variant.
113///
114/// | code | SUBSCRIBE_ERROR | PUBLISH_ERROR | FETCH_ERROR | ANNOUNCE_ERROR | SUBSCRIBE_NAMESPACE_ERROR |
115/// |---|---|---|---|---|---|
116/// | 0x4 | `TRACK_DOES_NOT_EXIST` | `UNINTERESTED` | `TRACK_DOES_NOT_EXIST` | `UNINTERESTED` | `NAMESPACE_PREFIX_UNKNOWN` |
117///
118/// Use [`PublishErrorCode`], [`FetchErrorCode`], [`AnnounceErrorCode`] and
119/// [`SubscribeNamespaceErrorCode`] for those messages.
120///
121/// The name is `RequestErrorCode` for compatibility with existing callers; the
122/// registry it transcribes is SUBSCRIBE_ERROR.
123#[derive(Debug, Clone, Copy, PartialEq, Eq)]
124#[repr(u64)]
125pub enum RequestErrorCode {
126 /// `INTERNAL_ERROR` — An implementation specific or generic error occurred.
127 InternalError = 0x0,
128 /// `UNAUTHORIZED` — The subscriber is not authorized to subscribe to the
129 /// given track.
130 Unauthorized = 0x1,
131 /// `TIMEOUT` — The subscription could not be completed before an
132 /// implementation specific timeout. For example, a relay could not establish
133 /// an upstream subscription within the timeout.
134 Timeout = 0x2,
135 /// `NOT_SUPPORTED` — The endpoint does not support the SUBSCRIBE method.
136 NotSupported = 0x3,
137 /// `TRACK_DOES_NOT_EXIST` — The requested track is not available at the
138 /// publisher.
139 TrackDoesNotExist = 0x4,
140 /// `INVALID_RANGE` — The end of the SUBSCRIBE range is earlier than the
141 /// beginning, or the end of the range has already been published.
142 InvalidRange = 0x5,
143 /// `MALFORMED_AUTH_TOKEN` — Invalid Auth Token serialization during
144 /// registration (see Section 9.2.1.1).
145 MalformedAuthToken = 0x10,
146 /// `EXPIRED_AUTH_TOKEN` — Authorization token has expired
147 /// (Section 9.2.1.1).
148 ExpiredAuthToken = 0x12,
149}
150
151/// PUBLISH_DONE status codes, from the "PUBLISH_DONE Codes" registry in
152/// draft-ietf-moq-transport-14 Section 13.1.3. Every row cites Section 9.12
153/// (PUBLISH_DONE), the source of the descriptions below.
154#[derive(Debug, Clone, Copy, PartialEq, Eq)]
155#[repr(u64)]
156pub enum PublishDoneStatusCode {
157 /// `INTERNAL_ERROR` — An implementation specific or generic error occurred.
158 InternalError = 0x0,
159 /// `UNAUTHORIZED` — The subscriber is no longer authorized to subscribe to
160 /// the given track.
161 Unauthorized = 0x1,
162 /// `TRACK_ENDED` — The track is no longer being published.
163 TrackEnded = 0x2,
164 /// `SUBSCRIPTION_ENDED` — The publisher reached the end of an associated
165 /// Subscribe filter.
166 SubscriptionEnded = 0x3,
167 /// `GOING_AWAY` — The subscriber or publisher issued a GOAWAY message.
168 GoingAway = 0x4,
169 /// `EXPIRED` — The publisher reached the timeout specified in SUBSCRIBE_OK.
170 Expired = 0x5,
171 /// `TOO_FAR_BEHIND` — The publisher's queue of objects to be sent to the
172 /// given subscriber exceeds its implementation defined limit.
173 TooFarBehind = 0x6,
174 /// `MALFORMED_TRACK` — A relay publisher detected the track was malformed
175 /// (see Section 2.5).
176 MalformedTrack = 0x7,
177}
178
179/// PUBLISH_ERROR codes, from the "PUBLISH_ERROR Codes" registry in
180/// draft-ietf-moq-transport-14 Section 13.1.4. Every row cites Section 9.15
181/// (PUBLISH_ERROR), the source of the descriptions below.
182///
183/// Unlike the other request-scoped registries in this draft, PUBLISH_ERROR
184/// assigns no `MALFORMED_AUTH_TOKEN` (0x10) or `EXPIRED_AUTH_TOKEN` (0x12).
185#[derive(Debug, Clone, Copy, PartialEq, Eq)]
186#[repr(u64)]
187pub enum PublishErrorCode {
188 /// `INTERNAL_ERROR` — An implementation specific or generic error occurred.
189 InternalError = 0x0,
190 /// `UNAUTHORIZED` — The publisher is not authorized to publish the given
191 /// namespace or track.
192 Unauthorized = 0x1,
193 /// `TIMEOUT` — The subscription could not be established before an
194 /// implementation specific timeout.
195 Timeout = 0x2,
196 /// `NOT_SUPPORTED` — The endpoint does not support the PUBLISH method.
197 NotSupported = 0x3,
198 /// `UNINTERESTED` — The namespace or track is not of interest to the
199 /// endpoint.
200 Uninterested = 0x4,
201}
202
203/// FETCH_ERROR codes, from the "FETCH_ERROR Codes" registry in
204/// draft-ietf-moq-transport-14 Section 13.1.5. Every row cites Section 9.18
205/// (FETCH_ERROR), the source of the descriptions below.
206///
207/// The draft assigns 0x0 through 0x9, then 0x10 and 0x12; 0x11 is unassigned.
208#[derive(Debug, Clone, Copy, PartialEq, Eq)]
209#[repr(u64)]
210pub enum FetchErrorCode {
211 /// `INTERNAL_ERROR` — An implementation specific or generic error occurred.
212 InternalError = 0x0,
213 /// `UNAUTHORIZED` — The subscriber is not authorized to fetch from the
214 /// given track.
215 Unauthorized = 0x1,
216 /// `TIMEOUT` — The fetch could not be completed before an implementation
217 /// specific timeout. For example, a relay could not FETCH missing objects
218 /// within the timeout.
219 Timeout = 0x2,
220 /// `NOT_SUPPORTED` — The endpoint does not support the FETCH method.
221 NotSupported = 0x3,
222 /// `TRACK_DOES_NOT_EXIST` — The requested track is not available at the
223 /// publisher.
224 TrackDoesNotExist = 0x4,
225 /// `INVALID_RANGE` — The end of the requested range is earlier than the
226 /// beginning, the start of the requested range is beyond the Largest
227 /// Location, or the track has not published any Objects yet.
228 InvalidRange = 0x5,
229 /// `NO_OBJECTS` — No Objects exist between the requested Start and End
230 /// Locations.
231 NoObjects = 0x6,
232 /// `INVALID_JOINING_REQUEST_ID` — The joining Fetch referenced a Request ID
233 /// that did not belong to an active Subscription.
234 InvalidJoiningRequestId = 0x7,
235 /// `UNKNOWN_STATUS_IN_RANGE` — The requested range contains objects with
236 /// unknown status.
237 UnknownStatusInRange = 0x8,
238 /// `MALFORMED_TRACK` — A relay publisher detected the track was malformed
239 /// (see Section 2.5).
240 MalformedTrack = 0x9,
241 /// `MALFORMED_AUTH_TOKEN` — Invalid Auth Token serialization during
242 /// registration (see Section 9.2.1.1).
243 MalformedAuthToken = 0x10,
244 /// `EXPIRED_AUTH_TOKEN` — Authorization token has expired
245 /// (Section 9.2.1.1).
246 ExpiredAuthToken = 0x12,
247}
248
249/// ANNOUNCE_ERROR codes, from the "ANNOUNCE_ERROR Codes" registry in
250/// draft-ietf-moq-transport-14 Section 13.1.6.
251///
252/// The registry is still titled ANNOUNCE_ERROR, but every row cites
253/// Section 9.25, which defines PUBLISH_NAMESPACE_ERROR; draft-14 contains no
254/// message named ANNOUNCE_ERROR. The name here follows the registry title, and
255/// the descriptions below come from Section 9.25.
256#[derive(Debug, Clone, Copy, PartialEq, Eq)]
257#[repr(u64)]
258pub enum AnnounceErrorCode {
259 /// `INTERNAL_ERROR` — An implementation specific or generic error occurred.
260 InternalError = 0x0,
261 /// `UNAUTHORIZED` — The subscriber is not authorized to announce the given
262 /// namespace.
263 Unauthorized = 0x1,
264 /// `TIMEOUT` — The announce could not be completed before an implementation
265 /// specific timeout.
266 Timeout = 0x2,
267 /// `NOT_SUPPORTED` — The endpoint does not support the PUBLISH_NAMESPACE
268 /// method.
269 NotSupported = 0x3,
270 /// `UNINTERESTED` — The namespace is not of interest to the endpoint.
271 Uninterested = 0x4,
272 /// `MALFORMED_AUTH_TOKEN` — Invalid Auth Token serialization during
273 /// registration (see Section 9.2.1.1).
274 MalformedAuthToken = 0x10,
275 /// `EXPIRED_AUTH_TOKEN` — Authorization token has expired
276 /// (Section 9.2.1.1).
277 ExpiredAuthToken = 0x12,
278}
279
280/// SUBSCRIBE_NAMESPACE_ERROR codes, from the "SUBSCRIBE_NAMESPACE_ERROR Codes"
281/// registry in draft-ietf-moq-transport-14 Section 13.1.7. Every row cites
282/// Section 9.30 (SUBSCRIBE_NAMESPACE_ERROR), the source of the descriptions
283/// below.
284#[derive(Debug, Clone, Copy, PartialEq, Eq)]
285#[repr(u64)]
286pub enum SubscribeNamespaceErrorCode {
287 /// `INTERNAL_ERROR` — An implementation specific or generic error occurred.
288 InternalError = 0x0,
289 /// `UNAUTHORIZED` — The subscriber is not authorized to subscribe to the
290 /// given namespace prefix.
291 Unauthorized = 0x1,
292 /// `TIMEOUT` — The operation could not be completed before an
293 /// implementation specific timeout.
294 Timeout = 0x2,
295 /// `NOT_SUPPORTED` — The endpoint does not support the SUBSCRIBE_NAMESPACE
296 /// method.
297 NotSupported = 0x3,
298 /// `NAMESPACE_PREFIX_UNKNOWN` — The namespace prefix is not available for
299 /// subscription.
300 NamespacePrefixUnknown = 0x4,
301 /// `NAMESPACE_PREFIX_OVERLAP` — The namespace prefix overlaps with another
302 /// SUBSCRIBE_NAMESPACE in the same session.
303 NamespacePrefixOverlap = 0x5,
304 /// `MALFORMED_AUTH_TOKEN` — Invalid Auth Token serialization during
305 /// registration (see Section 9.2.1.1).
306 MalformedAuthToken = 0x10,
307 /// `EXPIRED_AUTH_TOKEN` — Authorization token has expired
308 /// (Section 9.2.1.1).
309 ExpiredAuthToken = 0x12,
310}
311
312/// Data stream reset error codes, from the "Data Stream Reset Error Codes"
313/// registry in draft-ietf-moq-transport-14 Section 13.1.8. Every row cites
314/// Section 10.4.3 (Closing Subgroup Streams), the source of the descriptions
315/// below. These are the application error codes carried on RESET_STREAM and
316/// RESET_STREAM_AT, not on the session.
317#[derive(Debug, Clone, Copy, PartialEq, Eq)]
318#[repr(u64)]
319pub enum DataStreamResetErrorCode {
320 /// `INTERNAL_ERROR` — An implementation specific error.
321 InternalError = 0x0,
322 /// `CANCELLED` — The subscriber requested cancellation via UNSUBSCRIBE,
323 /// FETCH_CANCEL or STOP_SENDING, or the publisher ended the subscription,
324 /// in which case PUBLISH_DONE (Section 9.12) will have a more detailed
325 /// status code.
326 Cancelled = 0x1,
327 /// `DELIVERY_TIMEOUT` — The DELIVERY TIMEOUT Section 9.2.1.2 was exceeded
328 /// for this stream.
329 DeliveryTimeout = 0x2,
330 /// `SESSION_CLOSED` — The publisher session is being closed.
331 SessionClosed = 0x3,
332}
333
334impl SessionErrorCode {
335 /// Every session termination code draft-14 assigns, in ascending wire order.
336 ///
337 /// This is the set [`Self::from_u64`] accepts, written out so that it can
338 /// be enumerated: nothing can iterate an enum's variants, so a caller that
339 /// wants the registry has to be handed it. Writing it down is also what
340 /// lets a test state its claims about the registry itself rather than about
341 /// the range some sweep happens to reach.
342 pub const ALL: &[SessionErrorCode] = &[
343 SessionErrorCode::NoError,
344 SessionErrorCode::InternalError,
345 SessionErrorCode::Unauthorized,
346 SessionErrorCode::ProtocolViolation,
347 SessionErrorCode::InvalidRequestId,
348 SessionErrorCode::DuplicateTrackAlias,
349 SessionErrorCode::KeyValueFormattingError,
350 SessionErrorCode::TooManyRequests,
351 SessionErrorCode::InvalidPath,
352 SessionErrorCode::MalformedPath,
353 SessionErrorCode::GoawayTimeout,
354 SessionErrorCode::ControlMessageTimeout,
355 SessionErrorCode::DataStreamTimeout,
356 SessionErrorCode::AuthTokenCacheOverflow,
357 SessionErrorCode::DuplicateAuthTokenAlias,
358 SessionErrorCode::VersionNegotiationFailed,
359 SessionErrorCode::MalformedAuthToken,
360 SessionErrorCode::UnknownAuthTokenAlias,
361 SessionErrorCode::ExpiredAuthToken,
362 SessionErrorCode::InvalidAuthority,
363 SessionErrorCode::MalformedAuthority,
364 ];
365
366 /// Convert a raw u64 to a `SessionErrorCode`, if valid.
367 pub fn from_u64(v: u64) -> Option<Self> {
368 match v {
369 0x0 => Some(SessionErrorCode::NoError),
370 0x1 => Some(SessionErrorCode::InternalError),
371 0x2 => Some(SessionErrorCode::Unauthorized),
372 0x3 => Some(SessionErrorCode::ProtocolViolation),
373 0x4 => Some(SessionErrorCode::InvalidRequestId),
374 0x5 => Some(SessionErrorCode::DuplicateTrackAlias),
375 0x6 => Some(SessionErrorCode::KeyValueFormattingError),
376 0x7 => Some(SessionErrorCode::TooManyRequests),
377 0x8 => Some(SessionErrorCode::InvalidPath),
378 0x9 => Some(SessionErrorCode::MalformedPath),
379 0x10 => Some(SessionErrorCode::GoawayTimeout),
380 0x11 => Some(SessionErrorCode::ControlMessageTimeout),
381 0x12 => Some(SessionErrorCode::DataStreamTimeout),
382 0x13 => Some(SessionErrorCode::AuthTokenCacheOverflow),
383 0x14 => Some(SessionErrorCode::DuplicateAuthTokenAlias),
384 0x15 => Some(SessionErrorCode::VersionNegotiationFailed),
385 0x16 => Some(SessionErrorCode::MalformedAuthToken),
386 0x17 => Some(SessionErrorCode::UnknownAuthTokenAlias),
387 0x18 => Some(SessionErrorCode::ExpiredAuthToken),
388 0x19 => Some(SessionErrorCode::InvalidAuthority),
389 0x1A => Some(SessionErrorCode::MalformedAuthority),
390 _ => None,
391 }
392 }
393
394 /// Return the raw u64 value of this error code.
395 pub fn as_u64(self) -> u64 {
396 self as u64
397 }
398}
399
400impl RequestErrorCode {
401 /// Every SUBSCRIBE_ERROR code draft-14 assigns, in ascending wire order.
402 ///
403 /// This is the set [`Self::from_u64`] accepts, written out so that it can
404 /// be enumerated: nothing can iterate an enum's variants, so a caller that
405 /// wants the registry has to be handed it. Writing it down is also what
406 /// lets a test state its claims about the registry itself rather than about
407 /// the range some sweep happens to reach.
408 pub const ALL: &[RequestErrorCode] = &[
409 RequestErrorCode::InternalError,
410 RequestErrorCode::Unauthorized,
411 RequestErrorCode::Timeout,
412 RequestErrorCode::NotSupported,
413 RequestErrorCode::TrackDoesNotExist,
414 RequestErrorCode::InvalidRange,
415 RequestErrorCode::MalformedAuthToken,
416 RequestErrorCode::ExpiredAuthToken,
417 ];
418
419 /// Convert a raw u64 to a `RequestErrorCode`, if valid.
420 pub fn from_u64(v: u64) -> Option<Self> {
421 match v {
422 0x0 => Some(RequestErrorCode::InternalError),
423 0x1 => Some(RequestErrorCode::Unauthorized),
424 0x2 => Some(RequestErrorCode::Timeout),
425 0x3 => Some(RequestErrorCode::NotSupported),
426 0x4 => Some(RequestErrorCode::TrackDoesNotExist),
427 0x5 => Some(RequestErrorCode::InvalidRange),
428 0x10 => Some(RequestErrorCode::MalformedAuthToken),
429 0x12 => Some(RequestErrorCode::ExpiredAuthToken),
430 _ => None,
431 }
432 }
433
434 /// Return the raw u64 value of this error code.
435 pub fn as_u64(self) -> u64 {
436 self as u64
437 }
438}
439
440impl PublishDoneStatusCode {
441 /// Every PUBLISH_DONE status code draft-14 assigns, in ascending wire order.
442 ///
443 /// This is the set [`Self::from_u64`] accepts, written out so that it can
444 /// be enumerated: nothing can iterate an enum's variants, so a caller that
445 /// wants the registry has to be handed it. Writing it down is also what
446 /// lets a test state its claims about the registry itself rather than about
447 /// the range some sweep happens to reach.
448 pub const ALL: &[PublishDoneStatusCode] = &[
449 PublishDoneStatusCode::InternalError,
450 PublishDoneStatusCode::Unauthorized,
451 PublishDoneStatusCode::TrackEnded,
452 PublishDoneStatusCode::SubscriptionEnded,
453 PublishDoneStatusCode::GoingAway,
454 PublishDoneStatusCode::Expired,
455 PublishDoneStatusCode::TooFarBehind,
456 PublishDoneStatusCode::MalformedTrack,
457 ];
458
459 /// Convert a raw u64 to a `PublishDoneStatusCode`, if valid.
460 pub fn from_u64(v: u64) -> Option<Self> {
461 match v {
462 0x0 => Some(PublishDoneStatusCode::InternalError),
463 0x1 => Some(PublishDoneStatusCode::Unauthorized),
464 0x2 => Some(PublishDoneStatusCode::TrackEnded),
465 0x3 => Some(PublishDoneStatusCode::SubscriptionEnded),
466 0x4 => Some(PublishDoneStatusCode::GoingAway),
467 0x5 => Some(PublishDoneStatusCode::Expired),
468 0x6 => Some(PublishDoneStatusCode::TooFarBehind),
469 0x7 => Some(PublishDoneStatusCode::MalformedTrack),
470 _ => None,
471 }
472 }
473
474 /// Return the raw u64 value of this status code.
475 pub fn as_u64(self) -> u64 {
476 self as u64
477 }
478}
479
480impl PublishErrorCode {
481 /// Every PUBLISH_ERROR code draft-14 assigns, in ascending wire order.
482 ///
483 /// This is the set [`Self::from_u64`] accepts, written out so that it can
484 /// be enumerated: nothing can iterate an enum's variants, so a caller that
485 /// wants the registry has to be handed it. Writing it down is also what
486 /// lets a test state its claims about the registry itself rather than about
487 /// the range some sweep happens to reach.
488 pub const ALL: &[PublishErrorCode] = &[
489 PublishErrorCode::InternalError,
490 PublishErrorCode::Unauthorized,
491 PublishErrorCode::Timeout,
492 PublishErrorCode::NotSupported,
493 PublishErrorCode::Uninterested,
494 ];
495
496 /// Convert a raw u64 to a `PublishErrorCode`, if valid.
497 pub fn from_u64(v: u64) -> Option<Self> {
498 match v {
499 0x0 => Some(PublishErrorCode::InternalError),
500 0x1 => Some(PublishErrorCode::Unauthorized),
501 0x2 => Some(PublishErrorCode::Timeout),
502 0x3 => Some(PublishErrorCode::NotSupported),
503 0x4 => Some(PublishErrorCode::Uninterested),
504 _ => None,
505 }
506 }
507
508 /// Return the raw u64 value of this error code.
509 pub fn as_u64(self) -> u64 {
510 self as u64
511 }
512}
513
514impl FetchErrorCode {
515 /// Every FETCH_ERROR code draft-14 assigns, in ascending wire order.
516 ///
517 /// This is the set [`Self::from_u64`] accepts, written out so that it can
518 /// be enumerated: nothing can iterate an enum's variants, so a caller that
519 /// wants the registry has to be handed it. Writing it down is also what
520 /// lets a test state its claims about the registry itself rather than about
521 /// the range some sweep happens to reach.
522 pub const ALL: &[FetchErrorCode] = &[
523 FetchErrorCode::InternalError,
524 FetchErrorCode::Unauthorized,
525 FetchErrorCode::Timeout,
526 FetchErrorCode::NotSupported,
527 FetchErrorCode::TrackDoesNotExist,
528 FetchErrorCode::InvalidRange,
529 FetchErrorCode::NoObjects,
530 FetchErrorCode::InvalidJoiningRequestId,
531 FetchErrorCode::UnknownStatusInRange,
532 FetchErrorCode::MalformedTrack,
533 FetchErrorCode::MalformedAuthToken,
534 FetchErrorCode::ExpiredAuthToken,
535 ];
536
537 /// Convert a raw u64 to a `FetchErrorCode`, if valid.
538 pub fn from_u64(v: u64) -> Option<Self> {
539 match v {
540 0x0 => Some(FetchErrorCode::InternalError),
541 0x1 => Some(FetchErrorCode::Unauthorized),
542 0x2 => Some(FetchErrorCode::Timeout),
543 0x3 => Some(FetchErrorCode::NotSupported),
544 0x4 => Some(FetchErrorCode::TrackDoesNotExist),
545 0x5 => Some(FetchErrorCode::InvalidRange),
546 0x6 => Some(FetchErrorCode::NoObjects),
547 0x7 => Some(FetchErrorCode::InvalidJoiningRequestId),
548 0x8 => Some(FetchErrorCode::UnknownStatusInRange),
549 0x9 => Some(FetchErrorCode::MalformedTrack),
550 0x10 => Some(FetchErrorCode::MalformedAuthToken),
551 0x12 => Some(FetchErrorCode::ExpiredAuthToken),
552 _ => None,
553 }
554 }
555
556 /// Return the raw u64 value of this error code.
557 pub fn as_u64(self) -> u64 {
558 self as u64
559 }
560}
561
562impl AnnounceErrorCode {
563 /// Every ANNOUNCE_ERROR code draft-14 assigns, in ascending wire order.
564 ///
565 /// This is the set [`Self::from_u64`] accepts, written out so that it can
566 /// be enumerated: nothing can iterate an enum's variants, so a caller that
567 /// wants the registry has to be handed it. Writing it down is also what
568 /// lets a test state its claims about the registry itself rather than about
569 /// the range some sweep happens to reach.
570 pub const ALL: &[AnnounceErrorCode] = &[
571 AnnounceErrorCode::InternalError,
572 AnnounceErrorCode::Unauthorized,
573 AnnounceErrorCode::Timeout,
574 AnnounceErrorCode::NotSupported,
575 AnnounceErrorCode::Uninterested,
576 AnnounceErrorCode::MalformedAuthToken,
577 AnnounceErrorCode::ExpiredAuthToken,
578 ];
579
580 /// Convert a raw u64 to an `AnnounceErrorCode`, if valid.
581 pub fn from_u64(v: u64) -> Option<Self> {
582 match v {
583 0x0 => Some(AnnounceErrorCode::InternalError),
584 0x1 => Some(AnnounceErrorCode::Unauthorized),
585 0x2 => Some(AnnounceErrorCode::Timeout),
586 0x3 => Some(AnnounceErrorCode::NotSupported),
587 0x4 => Some(AnnounceErrorCode::Uninterested),
588 0x10 => Some(AnnounceErrorCode::MalformedAuthToken),
589 0x12 => Some(AnnounceErrorCode::ExpiredAuthToken),
590 _ => None,
591 }
592 }
593
594 /// Return the raw u64 value of this error code.
595 pub fn as_u64(self) -> u64 {
596 self as u64
597 }
598}
599
600impl SubscribeNamespaceErrorCode {
601 /// Every SUBSCRIBE_NAMESPACE_ERROR code draft-14 assigns, in ascending wire order.
602 ///
603 /// This is the set [`Self::from_u64`] accepts, written out so that it can
604 /// be enumerated: nothing can iterate an enum's variants, so a caller that
605 /// wants the registry has to be handed it. Writing it down is also what
606 /// lets a test state its claims about the registry itself rather than about
607 /// the range some sweep happens to reach.
608 pub const ALL: &[SubscribeNamespaceErrorCode] = &[
609 SubscribeNamespaceErrorCode::InternalError,
610 SubscribeNamespaceErrorCode::Unauthorized,
611 SubscribeNamespaceErrorCode::Timeout,
612 SubscribeNamespaceErrorCode::NotSupported,
613 SubscribeNamespaceErrorCode::NamespacePrefixUnknown,
614 SubscribeNamespaceErrorCode::NamespacePrefixOverlap,
615 SubscribeNamespaceErrorCode::MalformedAuthToken,
616 SubscribeNamespaceErrorCode::ExpiredAuthToken,
617 ];
618
619 /// Convert a raw u64 to a `SubscribeNamespaceErrorCode`, if valid.
620 pub fn from_u64(v: u64) -> Option<Self> {
621 match v {
622 0x0 => Some(SubscribeNamespaceErrorCode::InternalError),
623 0x1 => Some(SubscribeNamespaceErrorCode::Unauthorized),
624 0x2 => Some(SubscribeNamespaceErrorCode::Timeout),
625 0x3 => Some(SubscribeNamespaceErrorCode::NotSupported),
626 0x4 => Some(SubscribeNamespaceErrorCode::NamespacePrefixUnknown),
627 0x5 => Some(SubscribeNamespaceErrorCode::NamespacePrefixOverlap),
628 0x10 => Some(SubscribeNamespaceErrorCode::MalformedAuthToken),
629 0x12 => Some(SubscribeNamespaceErrorCode::ExpiredAuthToken),
630 _ => None,
631 }
632 }
633
634 /// Return the raw u64 value of this error code.
635 pub fn as_u64(self) -> u64 {
636 self as u64
637 }
638}
639
640impl DataStreamResetErrorCode {
641 /// Every data stream reset code draft-14 assigns, in ascending wire order.
642 ///
643 /// This is the set [`Self::from_u64`] accepts, written out so that it can
644 /// be enumerated: nothing can iterate an enum's variants, so a caller that
645 /// wants the registry has to be handed it. Writing it down is also what
646 /// lets a test state its claims about the registry itself rather than about
647 /// the range some sweep happens to reach.
648 pub const ALL: &[DataStreamResetErrorCode] = &[
649 DataStreamResetErrorCode::InternalError,
650 DataStreamResetErrorCode::Cancelled,
651 DataStreamResetErrorCode::DeliveryTimeout,
652 DataStreamResetErrorCode::SessionClosed,
653 ];
654
655 /// Convert a raw u64 to a `DataStreamResetErrorCode`, if valid.
656 pub fn from_u64(v: u64) -> Option<Self> {
657 match v {
658 0x0 => Some(DataStreamResetErrorCode::InternalError),
659 0x1 => Some(DataStreamResetErrorCode::Cancelled),
660 0x2 => Some(DataStreamResetErrorCode::DeliveryTimeout),
661 0x3 => Some(DataStreamResetErrorCode::SessionClosed),
662 _ => None,
663 }
664 }
665
666 /// Return the raw u64 value of this error code.
667 pub fn as_u64(self) -> u64 {
668 self as u64
669 }
670}