Skip to main content

moq_net/ietf/
version.rs

1use std::fmt;
2
3/// An IETF protocol version.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum Version {
6	Draft14,
7	Draft15,
8	Draft16,
9	Draft17,
10	Draft18,
11}
12
13impl fmt::Display for Version {
14	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15		match self {
16			Self::Draft14 => write!(f, "moq-transport-14"),
17			Self::Draft15 => write!(f, "moq-transport-15"),
18			Self::Draft16 => write!(f, "moq-transport-16"),
19			Self::Draft17 => write!(f, "moq-transport-17"),
20			Self::Draft18 => write!(f, "moq-transport-18"),
21		}
22	}
23}
24
25impl From<Version> for crate::Version {
26	fn from(v: Version) -> Self {
27		crate::Version::Ietf(v)
28	}
29}
30
31impl TryFrom<crate::Version> for Version {
32	type Error = ();
33
34	fn try_from(v: crate::Version) -> Result<Self, Self::Error> {
35		match v {
36			crate::Version::Ietf(v) => Ok(v),
37			crate::Version::Lite(_) => Err(()),
38		}
39	}
40}