reqrio/packet/h2c/frame/
typo.rs1use crate::error::HlsResult;
2
3#[derive(Clone, Debug, Copy, Eq, PartialEq)]
4pub enum FrameType {
5 Data = 0x00,
6 Headers = 0x01,
7 Priority = 0x02,
8 RstStream = 0x03,
9 Settings = 0x04,
10 PushPromise = 0x05,
11 Ping = 0x06,
12 Goaway = 0x07,
13 WindowUpdate = 0x08,
14 Continuation = 0x09,
15}
16
17
18impl FrameType {
19 pub fn from_u8(byte: u8) -> HlsResult<FrameType> {
20 match byte {
21 0x00 => Ok(FrameType::Data),
22 0x01 => Ok(FrameType::Headers),
23 0x02 => Ok(FrameType::Priority),
24 0x03 => Ok(FrameType::RstStream),
25 0x04 => Ok(FrameType::Settings),
26 0x05 => Ok(FrameType::PushPromise),
27 0x06 => Ok(FrameType::Ping),
28 0x07 => Ok(FrameType::Goaway),
29 0x08 => Ok(FrameType::WindowUpdate),
30 0x09 => Ok(FrameType::Continuation),
31 _ => Err(format!("Unknown frame type: {}", byte).into()),
32 }
33 }
34
35 pub fn to_u8(self) -> u8 {
36 self as u8
37 }
38}
39