http_box/http2/
parser_state.rs

1// +-----------------------------------------------------------------------------------------------+
2// | Copyright 2016 Sean Kerr                                                                      |
3// |                                                                                               |
4// | Licensed under the Apache License, Version 2.0 (the "License");                               |
5// | you may not use this file except in compliance with the License.                              |
6// | You may obtain a copy of the License at                                                       |
7// |                                                                                               |
8// |  http://www.apache.org/licenses/LICENSE-2.0                                                   |
9// |                                                                                               |
10// | Unless required by applicable law or agreed to in writing, software                           |
11// | distributed under the License is distributed on an "AS IS" BASIS,                             |
12// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.                      |
13// | See the License for the specific language governing permissions and                           |
14// | limitations under the License.                                                                |
15// +-----------------------------------------------------------------------------------------------+
16
17//! HTTP 2.x parser states.
18
19/// Parser states.
20#[derive(Clone,Copy,Debug,PartialEq)]
21#[repr(u8)]
22pub enum ParserState {
23    /// An error was returned from a call to `Parser::parse()`.
24    Dead,
25
26    // ---------------------------------------------------------------------------------------------
27    // FRAME STATES
28    // ---------------------------------------------------------------------------------------------
29
30    /// Parsing frame length first byte.
31    FrameLength1,
32
33    /// Parsing frame length second byte.
34    FrameLength2,
35
36    /// Parsing frame length third byte.
37    FrameLength3,
38
39    /// Parsing frame type.
40    FrameType,
41
42    /// Parsing frame flags.
43    FrameFlags,
44
45    /// Parsing frame stream identifier first byte.
46    FrameStreamId1,
47
48    /// Parsing frame stream identifier second byte.
49    FrameStreamId2,
50
51    /// Parsing frame stream identifier third byte.
52    FrameStreamId3,
53
54    /// Parsing frame stream identifier fourth byte.
55    FrameStreamId4,
56
57    /// Frame format parsing finished.
58    FrameFormatEnd,
59
60    /// Parsing end-of-frame padding.
61    FramePadding,
62
63    // ---------------------------------------------------------------------------------------------
64    // DATA STATES
65    // ---------------------------------------------------------------------------------------------
66
67    /// Parsing data pad length.
68    DataPadLength,
69
70    /// Parsing data.
71    DataData,
72
73    // ---------------------------------------------------------------------------------------------
74    // GO AWAY STATES
75    // ---------------------------------------------------------------------------------------------
76
77    /// Parsing go away stream identifier first byte.
78    GoAwayStreamId1,
79
80    /// Parsing go away stream identifier second byte.
81    GoAwayStreamId2,
82
83    /// Parsing go away stream identifier third byte.
84    GoAwayStreamId3,
85
86    /// Parsing go away stream identifier fourth byte.
87    GoAwayStreamId4,
88
89    /// Parsing go away error code first byte.
90    GoAwayErrorCode1,
91
92    /// Parsing go away error code second byte.
93    GoAwayErrorCode2,
94
95    /// Parsing go away error code third byte.
96    GoAwayErrorCode3,
97
98    /// Parsing go away error code fourth byte.
99    GoAwayErrorCode4,
100
101    /// Executing go away callback.
102    GoAwayCallback,
103
104    /// Parsing go away debug data.
105    GoAwayDebugData,
106
107    // ---------------------------------------------------------------------------------------------
108    // HEADERS STATES
109    // ---------------------------------------------------------------------------------------------
110
111    /// Parsing headers pad length with priority flag.
112    HeadersPadLengthWithPriority,
113
114    /// Parsing headers pad length without priority flag.
115    HeadersPadLengthWithoutPriority,
116
117    /// Parsing headers stream identifier first byte.
118    HeadersStreamId1,
119
120    /// Parsing headers stream identifier second byte.
121    HeadersStreamId2,
122
123    /// Parsing headers stream identifier third byte.
124    HeadersStreamId3,
125
126    /// Parsing headers stream identifier fourth byte.
127    HeadersStreamId4,
128
129    /// Parsing headers weight.
130    HeadersWeight,
131
132    /// Executing headers callback.
133    HeadersCallback,
134
135    /// Parsing headers fragment.
136    HeadersFragment,
137
138    // ---------------------------------------------------------------------------------------------
139    // PING STATES
140    // ---------------------------------------------------------------------------------------------
141
142    /// Parsing ping data.
143    PingData,
144
145    // ---------------------------------------------------------------------------------------------
146    // PRIORITY STATES
147    // ---------------------------------------------------------------------------------------------
148
149    /// Parsing priority stream identifier first byte.
150    PriorityStreamId1,
151
152    /// Parsing priority stream identifier second byte.
153    PriorityStreamId2,
154
155    /// Parsing priority stream identifier third byte.
156    PriorityStreamId3,
157
158    /// Parsing priority stream identifier fourth byte.
159    PriorityStreamId4,
160
161    /// Parsing priority weight.
162    PriorityWeight,
163
164    // ---------------------------------------------------------------------------------------------
165    // PUSH PROMISE STATES
166    // ---------------------------------------------------------------------------------------------
167
168    /// Parsing push promise pad length.
169    PushPromisePadLength,
170
171    /// Parsing push promise stream identifier first byte.
172    PushPromiseStreamId1,
173
174    /// Parsing push promise stream identifier second byte.
175    PushPromiseStreamId2,
176
177    /// Parsing push promise stream identifier third byte.
178    PushPromiseStreamId3,
179
180    /// Parsing push promise stream identifier fourth byte.
181    PushPromiseStreamId4,
182
183    /// Executing the push promise callback.
184    PushPromiseCallback,
185
186    // ---------------------------------------------------------------------------------------------
187    // RST STREAM STATES
188    // ---------------------------------------------------------------------------------------------
189
190    /// Parsing rst stream error code first byte.
191    RstStreamErrorCode1,
192
193    /// Parsing rst stream error code second byte.
194    RstStreamErrorCode2,
195
196    /// Parsing rst stream error code third byte.
197    RstStreamErrorCode3,
198
199    /// Parsing rst stream error code fourth byte.
200    RstStreamErrorCode4,
201
202    /// Executing rst stream callback.
203    RstStreamCallback,
204
205    // ---------------------------------------------------------------------------------------------
206    // SETTINGS STATES
207    // ---------------------------------------------------------------------------------------------
208
209    /// Parsing settings identifier first byte.
210    SettingsId1,
211
212    /// Parsing settings identifier second byte.
213    SettingsId2,
214
215    /// Parsing settings value first byte.
216    SettingsValue1,
217
218    /// Parsing settings value second byte.
219    SettingsValue2,
220
221    /// Parsing settings value third byte.
222    SettingsValue3,
223
224    /// Parsing settings value fourth byte.
225    SettingsValue4,
226
227    /// Executing settings callback.
228    SettingsCallback,
229
230    // ---------------------------------------------------------------------------------------------
231    // UNSUPPORTED STATES
232    // ---------------------------------------------------------------------------------------------
233
234    /// Parsing unsupported pad length.
235    UnsupportedPadLength,
236
237    /// Parsing unsupported data.
238    UnsupportedData,
239
240    // ---------------------------------------------------------------------------------------------
241    // WINDOW UPDATE STATES
242    // ---------------------------------------------------------------------------------------------
243
244    /// Parsing window update increment first byte.
245    WindowUpdateIncrement1,
246
247    /// Parsing window update increment second byte.
248    WindowUpdateIncrement2,
249
250    /// Parsing window update increment third byte.
251    WindowUpdateIncrement3,
252
253    /// Parsing window update increment fourth byte.
254    WindowUpdateIncrement4,
255
256    /// Executing window update callback.
257    WindowUpdateCallback,
258
259    // ---------------------------------------------------------------------------------------------
260    // FINISHED
261    // ---------------------------------------------------------------------------------------------
262
263    /// Parsing entire message has finished.
264    Finished
265}