netlink_packet_route/route/
preference.rs1const ICMPV6_ROUTER_PREF_LOW: u8 = 0x3;
4const ICMPV6_ROUTER_PREF_MEDIUM: u8 = 0x0;
5const ICMPV6_ROUTER_PREF_HIGH: u8 = 0x1;
6const ICMPV6_ROUTER_PREF_INVALID: u8 = 0x2;
7
8#[derive(Debug, PartialEq, Eq, Clone, Copy)]
9#[non_exhaustive]
10#[derive(Default)]
11pub enum RoutePreference {
12 Low,
13 Medium,
14 High,
15 #[default]
16 Invalid,
17 Other(u8),
18}
19
20impl From<RoutePreference> for u8 {
21 fn from(v: RoutePreference) -> Self {
22 match v {
23 RoutePreference::Low => ICMPV6_ROUTER_PREF_LOW,
24 RoutePreference::Medium => ICMPV6_ROUTER_PREF_MEDIUM,
25 RoutePreference::High => ICMPV6_ROUTER_PREF_HIGH,
26 RoutePreference::Invalid => ICMPV6_ROUTER_PREF_INVALID,
27 RoutePreference::Other(s) => s,
28 }
29 }
30}
31
32impl From<u8> for RoutePreference {
33 fn from(d: u8) -> Self {
34 match d {
35 ICMPV6_ROUTER_PREF_LOW => Self::Low,
36 ICMPV6_ROUTER_PREF_MEDIUM => Self::Medium,
37 ICMPV6_ROUTER_PREF_HIGH => Self::High,
38 ICMPV6_ROUTER_PREF_INVALID => Self::Invalid,
39 _ => Self::Other(d),
40 }
41 }
42}