use super::error::Http2StreamIdError;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Http2FrameType(u8);
impl Http2FrameType {
pub const DATA: Self = Self(0x0);
pub const HEADERS: Self = Self(0x1);
pub const PRIORITY: Self = Self(0x2);
pub const RST_STREAM: Self = Self(0x3);
pub const SETTINGS: Self = Self(0x4);
pub const PUSH_PROMISE: Self = Self(0x5);
pub const PING: Self = Self(0x6);
pub const GOAWAY: Self = Self(0x7);
pub const WINDOW_UPDATE: Self = Self(0x8);
pub const CONTINUATION: Self = Self(0x9);
pub const fn new(raw: u8) -> Self {
Self(raw)
}
pub const fn raw(self) -> u8 {
self.0
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Http2StreamId(u32);
impl Http2StreamId {
pub const fn new(raw: u32) -> Self {
Self(raw)
}
pub const fn from_value(value: u32) -> Result<Self, Http2StreamIdError> {
if value & 0x8000_0000 != 0 {
Err(Http2StreamIdError::ReservedBitSet)
} else {
Ok(Self(value))
}
}
pub const fn raw(self) -> u32 {
self.0
}
pub const fn value(self) -> u32 {
self.0 & 0x7fff_ffff
}
pub const fn has_reserved_bit(self) -> bool {
self.0 & 0x8000_0000 != 0
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Http2ErrorCode(u32);
impl Http2ErrorCode {
pub const NO_ERROR: Self = Self(0x0);
pub const PROTOCOL_ERROR: Self = Self(0x1);
pub const INTERNAL_ERROR: Self = Self(0x2);
pub const FLOW_CONTROL_ERROR: Self = Self(0x3);
pub const SETTINGS_TIMEOUT: Self = Self(0x4);
pub const STREAM_CLOSED: Self = Self(0x5);
pub const FRAME_SIZE_ERROR: Self = Self(0x6);
pub const REFUSED_STREAM: Self = Self(0x7);
pub const CANCEL: Self = Self(0x8);
pub const COMPRESSION_ERROR: Self = Self(0x9);
pub const CONNECT_ERROR: Self = Self(0xa);
pub const ENHANCE_YOUR_CALM: Self = Self(0xb);
pub const INADEQUATE_SECURITY: Self = Self(0xc);
pub const HTTP_1_1_REQUIRED: Self = Self(0xd);
pub const fn new(raw: u32) -> Self {
Self(raw)
}
pub const fn raw(self) -> u32 {
self.0
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Http2SettingId(u16);
impl Http2SettingId {
pub const HEADER_TABLE_SIZE: Self = Self(0x1);
pub const ENABLE_PUSH: Self = Self(0x2);
pub const MAX_CONCURRENT_STREAMS: Self = Self(0x3);
pub const INITIAL_WINDOW_SIZE: Self = Self(0x4);
pub const MAX_FRAME_SIZE: Self = Self(0x5);
pub const MAX_HEADER_LIST_SIZE: Self = Self(0x6);
pub const ENABLE_CONNECT_PROTOCOL: Self = Self(0x8);
pub const fn new(raw: u16) -> Self {
Self(raw)
}
pub const fn raw(self) -> u16 {
self.0
}
}