trillium_channels/
version.rs1use std::{convert::Infallible, str::FromStr};
2
3#[derive(Debug, Clone, Copy)]
5#[non_exhaustive]
6#[derive(Default)]
7pub enum Version {
8 #[default]
10 V1,
11
12 V2,
14}
15
16impl FromStr for Version {
17 type Err = Infallible;
18
19 fn from_str(s: &str) -> Result<Self, Self::Err> {
20 match s.chars().next() {
21 Some('2') => Ok(Self::V2),
22 _ => Ok(Self::V1),
23 }
24 }
25}
26
27impl From<&str> for Version {
28 fn from(s: &str) -> Self {
29 s.parse().unwrap()
30 }
31}