netlink_packet_route/link/link_info/
tun.rs1use netlink_packet_core::{
4 DecodeError, DefaultNla, ErrorContext, Nla, NlaBuffer, Parseable,
5};
6
7#[derive(Debug, PartialEq, Eq, Clone)]
8#[non_exhaustive]
9pub enum InfoTun {
10 Other(DefaultNla),
11}
12
13impl Nla for InfoTun {
14 fn value_len(&self) -> usize {
15 match self {
16 Self::Other(nla) => nla.value_len(),
17 }
18 }
19
20 fn emit_value(&self, buffer: &mut [u8]) {
21 match self {
22 Self::Other(nla) => nla.emit_value(buffer),
23 }
24 }
25
26 fn kind(&self) -> u16 {
27 match self {
28 Self::Other(nla) => nla.kind(),
29 }
30 }
31}
32
33impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoTun {
34 fn parse(buf: &NlaBuffer<&'a T>) -> Result<Self, DecodeError> {
35 #[allow(clippy::match_single_binding)]
36 Ok(match buf.kind() {
37 kind => Self::Other(DefaultNla::parse(buf).context(format!(
38 "unknown NLA type {kind} for IFLA_INFO_DATA(vrf)"
39 ))?),
40 })
41 }
42}