1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5#[non_exhaustive]
6#[derive(Default)]
7pub enum Version {
8 V1,
10 #[default]
12 V2c,
13 V3,
15}
16
17impl Version {
18 pub const fn as_i32(self) -> i32 {
20 match self {
21 Version::V1 => 0,
22 Version::V2c => 1,
23 Version::V3 => 3,
24 }
25 }
26
27 pub const fn from_i32(value: i32) -> Option<Self> {
29 match value {
30 0 => Some(Version::V1),
31 1 => Some(Version::V2c),
32 3 => Some(Version::V3),
33 _ => None,
34 }
35 }
36}
37
38impl std::fmt::Display for Version {
39 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 match self {
41 Version::V1 => write!(f, "SNMPv1"),
42 Version::V2c => write!(f, "SNMPv2c"),
43 Version::V3 => write!(f, "SNMPv3"),
44 }
45 }
46}