netlink_packet_route/route/
preference.rs
1const 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]
10pub enum RoutePreference {
11 Low,
12 Medium,
13 High,
14 Invalid,
15 Other(u8),
16}
17
18impl From<RoutePreference> for u8 {
19 fn from(v: RoutePreference) -> Self {
20 match v {
21 RoutePreference::Low => ICMPV6_ROUTER_PREF_LOW,
22 RoutePreference::Medium => ICMPV6_ROUTER_PREF_MEDIUM,
23 RoutePreference::High => ICMPV6_ROUTER_PREF_HIGH,
24 RoutePreference::Invalid => ICMPV6_ROUTER_PREF_INVALID,
25 RoutePreference::Other(s) => s,
26 }
27 }
28}
29
30impl From<u8> for RoutePreference {
31 fn from(d: u8) -> Self {
32 match d {
33 ICMPV6_ROUTER_PREF_LOW => Self::Low,
34 ICMPV6_ROUTER_PREF_MEDIUM => Self::Medium,
35 ICMPV6_ROUTER_PREF_HIGH => Self::High,
36 ICMPV6_ROUTER_PREF_INVALID => Self::Invalid,
37 _ => Self::Other(d),
38 }
39 }
40}
41
42impl Default for RoutePreference {
43 fn default() -> Self {
44 Self::Invalid
45 }
46}