use serde::{Deserialize, Serialize};
use std::fmt;
pub mod client;
pub mod h3_server;
pub mod payload;
pub mod server;
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum HttpVersion {
HTTP1,
H2C,
HTTP2,
HTTP3,
}
impl HttpVersion {
pub fn is_secure(&self) -> bool {
matches!(self, HttpVersion::HTTP2 | HttpVersion::HTTP3)
}
pub fn scheme(&self) -> &'static str {
if self.is_secure() { "https" } else { "http" }
}
}
impl fmt::Display for HttpVersion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
HttpVersion::HTTP1 => write!(f, "HTTP/1.1"),
HttpVersion::H2C => write!(f, "HTTP/2 Cleartext (h2c)"),
HttpVersion::HTTP2 => write!(f, "HTTP/2 with TLS"),
HttpVersion::HTTP3 => write!(f, "HTTP/3 (QUIC)"),
}
}
}