iris_core/protocols/stream/quic/
header.rs1use serde::Serialize;
4
5use crate::protocols::stream::quic::QuicError;
6
7#[derive(Debug, Serialize, Clone)]
9pub struct QuicLongHeader {
10 pub packet_type: LongHeaderPacketType,
11 pub type_specific: u8,
12 pub version: u32,
13 pub dcid_len: u8, pub dcid: String, pub scid_len: u8, pub scid: String, pub token_len: Option<u64>, pub token: Option<String>, pub retry_tag: Option<String>, }
21
22#[derive(Debug, Serialize, Clone)]
24pub struct QuicShortHeader {
25 pub dcid: Option<String>, }
27
28#[derive(Debug, Clone, Serialize, Copy)]
30pub enum LongHeaderPacketType {
31 Initial,
32 ZeroRTT,
33 Handshake,
34 Retry,
35}
36
37impl LongHeaderPacketType {
38 pub fn from_u8(value: u8) -> Result<LongHeaderPacketType, QuicError> {
39 match value {
40 0x00 => Ok(LongHeaderPacketType::Initial),
41 0x01 => Ok(LongHeaderPacketType::ZeroRTT),
42 0x02 => Ok(LongHeaderPacketType::Handshake),
43 0x03 => Ok(LongHeaderPacketType::Retry),
44 _ => Err(QuicError::UnknowLongHeaderPacketType),
45 }
46 }
47}