Skip to main content

net_wire/http3/
codepoints.rs

1//! HTTP/3 protocol codepoints.
2
3/// An HTTP/3 frame type, preserving extension and unknown values.
4#[repr(transparent)]
5#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
6pub struct Http3FrameType(u64);
7
8impl Http3FrameType {
9    /// DATA (`0x00`).
10    pub const DATA: Self = Self(0x00);
11    /// HEADERS (`0x01`).
12    pub const HEADERS: Self = Self(0x01);
13    /// CANCEL_PUSH (`0x03`).
14    pub const CANCEL_PUSH: Self = Self(0x03);
15    /// SETTINGS (`0x04`).
16    pub const SETTINGS: Self = Self(0x04);
17    /// PUSH_PROMISE (`0x05`).
18    pub const PUSH_PROMISE: Self = Self(0x05);
19    /// GOAWAY (`0x07`).
20    pub const GOAWAY: Self = Self(0x07);
21    /// MAX_PUSH_ID (`0x0d`).
22    pub const MAX_PUSH_ID: Self = Self(0x0d);
23
24    /// Creates a raw frame type without restricting extensions.
25    pub const fn new(value: u64) -> Self {
26        Self(value)
27    }
28
29    /// Returns the encoded frame type value.
30    pub const fn value(self) -> u64 {
31        self.0
32    }
33}
34
35/// An HTTP/3 SETTINGS identifier, preserving extension and unknown values.
36#[repr(transparent)]
37#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
38pub struct Http3SettingId(u64);
39
40impl Http3SettingId {
41    /// SETTINGS_QPACK_MAX_TABLE_CAPACITY (`0x01`).
42    pub const QPACK_MAX_TABLE_CAPACITY: Self = Self(0x01);
43    /// SETTINGS_MAX_FIELD_SECTION_SIZE (`0x06`).
44    pub const MAX_FIELD_SECTION_SIZE: Self = Self(0x06);
45    /// SETTINGS_QPACK_BLOCKED_STREAMS (`0x07`).
46    pub const QPACK_BLOCKED_STREAMS: Self = Self(0x07);
47
48    /// Creates a raw setting identifier without restricting extensions.
49    pub const fn new(value: u64) -> Self {
50        Self(value)
51    }
52
53    /// Returns the encoded setting identifier value.
54    pub const fn value(self) -> u64 {
55        self.0
56    }
57}
58
59/// An HTTP/3 unidirectional stream type, preserving extension and unknown values.
60#[repr(transparent)]
61#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
62pub struct Http3StreamType(u64);
63
64impl Http3StreamType {
65    /// Control stream (`0x00`).
66    pub const CONTROL: Self = Self(0x00);
67    /// Push stream (`0x01`).
68    pub const PUSH: Self = Self(0x01);
69    /// QPACK encoder stream (`0x02`).
70    pub const QPACK_ENCODER: Self = Self(0x02);
71    /// QPACK decoder stream (`0x03`).
72    pub const QPACK_DECODER: Self = Self(0x03);
73
74    /// Creates a raw stream type without restricting extensions.
75    pub const fn new(value: u64) -> Self {
76        Self(value)
77    }
78
79    /// Returns the encoded stream type value.
80    pub const fn value(self) -> u64 {
81        self.0
82    }
83}
84
85/// An HTTP/3 application error code, preserving extension and unknown values.
86#[repr(transparent)]
87#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
88pub struct Http3ErrorCode(u64);
89
90impl Http3ErrorCode {
91    /// H3_NO_ERROR (`0x0100`).
92    pub const NO_ERROR: Self = Self(0x0100);
93    /// H3_GENERAL_PROTOCOL_ERROR (`0x0101`).
94    pub const GENERAL_PROTOCOL_ERROR: Self = Self(0x0101);
95    /// H3_INTERNAL_ERROR (`0x0102`).
96    pub const INTERNAL_ERROR: Self = Self(0x0102);
97    /// H3_STREAM_CREATION_ERROR (`0x0103`).
98    pub const STREAM_CREATION_ERROR: Self = Self(0x0103);
99    /// H3_CLOSED_CRITICAL_STREAM (`0x0104`).
100    pub const CLOSED_CRITICAL_STREAM: Self = Self(0x0104);
101    /// H3_FRAME_UNEXPECTED (`0x0105`).
102    pub const FRAME_UNEXPECTED: Self = Self(0x0105);
103    /// H3_FRAME_ERROR (`0x0106`).
104    pub const FRAME_ERROR: Self = Self(0x0106);
105    /// H3_EXCESSIVE_LOAD (`0x0107`).
106    pub const EXCESSIVE_LOAD: Self = Self(0x0107);
107    /// H3_ID_ERROR (`0x0108`).
108    pub const ID_ERROR: Self = Self(0x0108);
109    /// H3_SETTINGS_ERROR (`0x0109`).
110    pub const SETTINGS_ERROR: Self = Self(0x0109);
111    /// H3_MISSING_SETTINGS (`0x010a`).
112    pub const MISSING_SETTINGS: Self = Self(0x010a);
113    /// H3_REQUEST_REJECTED (`0x010b`).
114    pub const REQUEST_REJECTED: Self = Self(0x010b);
115    /// H3_REQUEST_CANCELLED (`0x010c`).
116    pub const REQUEST_CANCELLED: Self = Self(0x010c);
117    /// H3_REQUEST_INCOMPLETE (`0x010d`).
118    pub const REQUEST_INCOMPLETE: Self = Self(0x010d);
119    /// H3_MESSAGE_ERROR (`0x010e`).
120    pub const MESSAGE_ERROR: Self = Self(0x010e);
121    /// H3_CONNECT_ERROR (`0x010f`).
122    pub const CONNECT_ERROR: Self = Self(0x010f);
123    /// H3_VERSION_FALLBACK (`0x0110`).
124    pub const VERSION_FALLBACK: Self = Self(0x0110);
125    /// QPACK_DECOMPRESSION_FAILED (`0x0200`).
126    pub const QPACK_DECOMPRESSION_FAILED: Self = Self(0x0200);
127    /// QPACK_ENCODER_STREAM_ERROR (`0x0201`).
128    pub const QPACK_ENCODER_STREAM_ERROR: Self = Self(0x0201);
129    /// QPACK_DECODER_STREAM_ERROR (`0x0202`).
130    pub const QPACK_DECODER_STREAM_ERROR: Self = Self(0x0202);
131
132    /// Creates a raw error code without restricting extensions.
133    pub const fn new(value: u64) -> Self {
134        Self(value)
135    }
136
137    /// Returns the encoded error code value.
138    pub const fn value(self) -> u64 {
139        self.0
140    }
141}