use serde::Serialize;
use crate::protocols::stream::quic::QuicError;
#[derive(Debug, Serialize, Clone)]
pub struct QuicLongHeader {
pub packet_type: LongHeaderPacketType,
pub type_specific: u8,
pub version: u32,
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>, }
#[derive(Debug, Serialize, Clone)]
pub struct QuicShortHeader {
pub dcid: Option<String>, }
#[derive(Debug, Clone, Serialize, Copy)]
pub enum LongHeaderPacketType {
Initial,
ZeroRTT,
Handshake,
Retry,
}
impl LongHeaderPacketType {
pub fn from_u8(value: u8) -> Result<LongHeaderPacketType, QuicError> {
match value {
0x00 => Ok(LongHeaderPacketType::Initial),
0x01 => Ok(LongHeaderPacketType::ZeroRTT),
0x02 => Ok(LongHeaderPacketType::Handshake),
0x03 => Ok(LongHeaderPacketType::Retry),
_ => Err(QuicError::UnknowLongHeaderPacketType),
}
}
}