Debian Codegraph @

third_party/rust/qlog/src/events/qpack.rs

raw
1 // Copyright (C) 2021, 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 serde::Deserialize;
28 use serde::Serialize;
29
30 use super::h3::HttpHeader;
31 use super::RawInfo;
32
33 #[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
34 #[serde(rename_all = "snake_case")]
35 pub enum QpackEventType {
36 StateUpdated,
37 StreamStateUpdated,
38 DynamicTableUpdated,
39 HeadersEncoded,
40 HeadersDecoded,
41 InstructionCreated,
42 InstructionParsed,
43 }
44
45 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
46 #[serde(rename_all = "snake_case")]
47 pub enum QpackOwner {
48 Local,
49 Remote,
50 }
51
52 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
53 #[serde(rename_all = "snake_case")]
54 pub enum QpackStreamState {
55 Blocked,
56 Unblocked,
57 }
58
59 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
60 #[serde(rename_all = "snake_case")]
61 pub enum QpackUpdateType {
62 Added,
63 Evicted,
64 }
65
66 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
67 pub struct QpackDynamicTableEntry {
68 pub index: u64,
69 pub name: Option<String>,
70 pub value: Option<String>,
71 }
72
73 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
74 pub struct QpackHeaderBlockPrefix {
75 pub required_insert_count: u64,
76 pub sign_bit: bool,
77 pub delta_base: u64,
78 }
79
80 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
81 #[serde(rename_all = "snake_case")]
82 pub enum QpackInstructionTypeName {
83 SetDynamicTableCapacityInstruction,
84 InsertWithNameReferenceInstruction,
85 InsertWithoutNameReferenceInstruction,
86 DuplicateInstruction,
87 HeaderAcknowledgementInstruction,
88 StreamCancellationInstruction,
89 InsertCountIncrementInstruction,
90 }
91
92 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
93 #[serde(rename_all = "snake_case")]
94 pub enum QpackTableType {
95 Static,
96 Dynamic,
97 }
98
99 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
100 pub enum QPackInstruction {
101 SetDynamicTableCapacityInstruction {
102 instruction_type: QpackInstructionTypeName,
103
104 capacity: u64,
105 },
106
107 InsertWithNameReferenceInstruction {
108 instruction_type: QpackInstructionTypeName,
109
110 table_type: QpackTableType,
111
112 name_index: u64,
113
114 huffman_encoded_value: bool,
115 value_length: u64,
116 value: String,
117 },
118
119 InsertWithoutNameReferenceInstruction {
120 instruction_type: QpackInstructionTypeName,
121
122 huffman_encoded_name: bool,
123 name_length: u64,
124 name: String,
125
126 huffman_encoded_value: bool,
127 value_length: u64,
128 value: String,
129 },
130
131 DuplicateInstruction {
132 instruction_type: QpackInstructionTypeName,
133
134 index: u64,
135 },
136
137 HeaderAcknowledgementInstruction {
138 instruction_type: QpackInstructionTypeName,
139
140 stream_id: String,
141 },
142
143 StreamCancellationInstruction {
144 instruction_type: QpackInstructionTypeName,
145
146 stream_id: String,
147 },
148
149 InsertCountIncrementInstruction {
150 instruction_type: QpackInstructionTypeName,
151
152 increment: u64,
153 },
154 }
155
156 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
157 #[serde(rename_all = "snake_case")]
158 pub enum QpackHeaderBlockRepresentationTypeName {
159 IndexedHeaderField,
160 LiteralHeaderFieldWithName,
161 LiteralHeaderFieldWithoutName,
162 }
163
164 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
165 pub enum QpackHeaderBlockRepresentation {
166 IndexedHeaderField {
167 header_field_type: QpackHeaderBlockRepresentationTypeName,
168
169 table_type: QpackTableType,
170 index: u64,
171
172 is_post_base: Option<bool>,
173 },
174
175 LiteralHeaderFieldWithName {
176 header_field_type: QpackHeaderBlockRepresentationTypeName,
177
178 preserve_literal: bool,
179 table_type: QpackTableType,
180 name_index: u64,
181
182 huffman_encoded_value: bool,
183 value_length: u64,
184 value: String,
185
186 is_post_base: Option<bool>,
187 },
188
189 LiteralHeaderFieldWithoutName {
190 header_field_type: QpackHeaderBlockRepresentationTypeName,
191
192 preserve_literal: bool,
193 table_type: QpackTableType,
194 name_index: u64,
195
196 huffman_encoded_name: bool,
197 name_length: u64,
198 name: String,
199
200 huffman_encoded_value: bool,
201 value_length: u64,
202 value: String,
203
204 is_post_base: Option<bool>,
205 },
206 }
207
208 #[serde_with::skip_serializing_none]
209 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
210 pub struct QpackStateUpdated {
211 pub owner: Option<QpackOwner>,
212
213 pub dynamic_table_capacity: Option<u64>,
214 pub dynamic_table_size: Option<u64>,
215
216 pub known_received_count: Option<u64>,
217 pub current_insert_count: Option<u64>,
218 }
219
220 #[serde_with::skip_serializing_none]
221 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
222 pub struct QpackStreamStateUpdated {
223 pub stream_id: u64,
224
225 pub state: QpackStreamState,
226 }
227
228 #[serde_with::skip_serializing_none]
229 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
230 pub struct QpackDynamicTableUpdated {
231 pub update_type: QpackUpdateType,
232
233 pub entries: Vec<QpackDynamicTableEntry>,
234 }
235
236 #[serde_with::skip_serializing_none]
237 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
238 pub struct QpackHeadersEncoded {
239 pub stream_id: Option<u64>,
240
241 pub headers: Option<HttpHeader>,
242
243 pub block_prefix: QpackHeaderBlockPrefix,
244 pub header_block: Vec<QpackHeaderBlockRepresentation>,
245
246 pub raw: Option<RawInfo>,
247 }
248
249 #[serde_with::skip_serializing_none]
250 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
251 pub struct QpackHeadersDecoded {
252 pub stream_id: Option<u64>,
253
254 pub headers: Option<HttpHeader>,
255
256 pub block_prefix: QpackHeaderBlockPrefix,
257 pub header_block: Vec<QpackHeaderBlockRepresentation>,
258
259 pub raw: Option<RawInfo>,
260 }
261
262 #[serde_with::skip_serializing_none]
263 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
264 pub struct QpackInstructionCreated {
265 pub instruction: QPackInstruction,
266
267 pub raw: Option<RawInfo>,
268 }
269
270 #[serde_with::skip_serializing_none]
271 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
272 pub struct QpackInstructionParsed {
273 pub instruction: QPackInstruction,
274
275 pub raw: Option<RawInfo>,
276 }