netlink_packet_route/link/link_info/
gre_tap6.rs

1// SPDX-License-Identifier: MIT
2
3use anyhow::Context;
4use netlink_packet_utils::nla::{DefaultNla, Nla, NlaBuffer};
5use netlink_packet_utils::{DecodeError, Parseable};
6
7#[derive(Debug, PartialEq, Eq, Clone)]
8#[non_exhaustive]
9pub enum InfoGreTap6 {
10    Other(DefaultNla),
11}
12
13impl Nla for InfoGreTap6 {
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 InfoGreTap6 {
34    type Error = DecodeError;
35
36    fn parse(buf: &NlaBuffer<&'a T>) -> Result<Self, DecodeError> {
37        #[allow(clippy::match_single_binding)]
38        Ok(match buf.kind() {
39            kind => Self::Other(
40                DefaultNla::parse(buf).context(format!("unknown NLA type {kind} for gretap6"))?,
41            ),
42        })
43    }
44}