Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions h3/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ impl Protocol {
pub const WEB_TRANSPORT: Protocol = Protocol(ProtocolInner::WebTransport);
/// RFC 9298 protocol
pub const CONNECT_UDP: Protocol = Protocol(ProtocolInner::ConnectUdp);
/// RFC 9220 (WebSocket) protocol
pub const WEBSOCKET: Protocol = Protocol(ProtocolInner::WebSocket);

/// Return a &str representation of the `:protocol` pseudo-header value
#[inline]
pub fn as_str(&self) -> &str {
match self.0 {
ProtocolInner::WebTransport => "webtransport",
ProtocolInner::ConnectUdp => "connect-udp",
ProtocolInner::WebSocket => "websocket",
}
}
}
Expand All @@ -37,6 +40,7 @@ impl Protocol {
enum ProtocolInner {
WebTransport,
ConnectUdp,
WebSocket,
}

/// Error when parsing the protocol
Expand All @@ -49,6 +53,7 @@ impl FromStr for Protocol {
match s {
"webtransport" => Ok(Self(ProtocolInner::WebTransport)),
"connect-udp" => Ok(Self(ProtocolInner::ConnectUdp)),
"websocket" => Ok(Self(ProtocolInner::WebSocket)),
_ => Err(InvalidProtocol),
}
}
Expand Down