1use super::error::Http2StreamIdError;
4
5#[repr(transparent)]
7#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
8pub struct Http2FrameType(u8);
9
10impl Http2FrameType {
11 pub const DATA: Self = Self(0x0);
13 pub const HEADERS: Self = Self(0x1);
15 pub const PRIORITY: Self = Self(0x2);
17 pub const RST_STREAM: Self = Self(0x3);
19 pub const SETTINGS: Self = Self(0x4);
21 pub const PUSH_PROMISE: Self = Self(0x5);
23 pub const PING: Self = Self(0x6);
25 pub const GOAWAY: Self = Self(0x7);
27 pub const WINDOW_UPDATE: Self = Self(0x8);
29 pub const CONTINUATION: Self = Self(0x9);
31
32 pub const fn new(raw: u8) -> Self {
34 Self(raw)
35 }
36
37 pub const fn raw(self) -> u8 {
39 self.0
40 }
41}
42
43#[repr(transparent)]
45#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
46pub struct Http2StreamId(u32);
47
48impl Http2StreamId {
49 pub const fn new(raw: u32) -> Self {
51 Self(raw)
52 }
53
54 pub const fn from_value(value: u32) -> Result<Self, Http2StreamIdError> {
56 if value & 0x8000_0000 != 0 {
57 Err(Http2StreamIdError::ReservedBitSet)
58 } else {
59 Ok(Self(value))
60 }
61 }
62
63 pub const fn raw(self) -> u32 {
65 self.0
66 }
67
68 pub const fn value(self) -> u32 {
70 self.0 & 0x7fff_ffff
71 }
72
73 pub const fn has_reserved_bit(self) -> bool {
75 self.0 & 0x8000_0000 != 0
76 }
77}
78
79#[repr(transparent)]
81#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
82pub struct Http2ErrorCode(u32);
83
84impl Http2ErrorCode {
85 pub const NO_ERROR: Self = Self(0x0);
87 pub const PROTOCOL_ERROR: Self = Self(0x1);
89 pub const INTERNAL_ERROR: Self = Self(0x2);
91 pub const FLOW_CONTROL_ERROR: Self = Self(0x3);
93 pub const SETTINGS_TIMEOUT: Self = Self(0x4);
95 pub const STREAM_CLOSED: Self = Self(0x5);
97 pub const FRAME_SIZE_ERROR: Self = Self(0x6);
99 pub const REFUSED_STREAM: Self = Self(0x7);
101 pub const CANCEL: Self = Self(0x8);
103 pub const COMPRESSION_ERROR: Self = Self(0x9);
105 pub const CONNECT_ERROR: Self = Self(0xa);
107 pub const ENHANCE_YOUR_CALM: Self = Self(0xb);
109 pub const INADEQUATE_SECURITY: Self = Self(0xc);
111 pub const HTTP_1_1_REQUIRED: Self = Self(0xd);
113
114 pub const fn new(raw: u32) -> Self {
116 Self(raw)
117 }
118
119 pub const fn raw(self) -> u32 {
121 self.0
122 }
123}
124
125#[repr(transparent)]
127#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
128pub struct Http2SettingId(u16);
129
130impl Http2SettingId {
131 pub const HEADER_TABLE_SIZE: Self = Self(0x1);
133 pub const ENABLE_PUSH: Self = Self(0x2);
135 pub const MAX_CONCURRENT_STREAMS: Self = Self(0x3);
137 pub const INITIAL_WINDOW_SIZE: Self = Self(0x4);
139 pub const MAX_FRAME_SIZE: Self = Self(0x5);
141 pub const MAX_HEADER_LIST_SIZE: Self = Self(0x6);
143 pub const ENABLE_CONNECT_PROTOCOL: Self = Self(0x8);
145
146 pub const fn new(raw: u16) -> Self {
148 Self(raw)
149 }
150
151 pub const fn raw(self) -> u16 {
153 self.0
154 }
155}