base_http/version.rs
1// Released under the MIT License.
2// Copyright, 2026, by Samuel Williams.
3
4use std::fmt;
5
6/// The negotiated or received HTTP version. Message heads use `None` before
7/// selection; protocol selection policy is separate from this value.
8#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
9pub enum Version {
10 Http10,
11 Http11,
12 Http2,
13 Http3,
14}
15
16impl fmt::Display for Version {
17 fn fmt(&self, output: &mut fmt::Formatter<'_>) -> fmt::Result {
18 output.write_str(match self {
19 Self::Http10 => "HTTP/1.0",
20 Self::Http11 => "HTTP/1.1",
21 Self::Http2 => "HTTP/2",
22 Self::Http3 => "HTTP/3",
23 })
24 }
25}