netlink_packet_route/link/link_info/
gtp.rs
1use 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 InfoGtp {
10 Other(DefaultNla),
11}
12
13impl Nla for InfoGtp {
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 InfoGtp {
34 type Error = DecodeError;
35 fn parse(buf: &NlaBuffer<&'a T>) -> Result<Self, DecodeError> {
36 #[allow(clippy::match_single_binding)]
37 Ok(match buf.kind() {
38 kind => Self::Other(
39 DefaultNla::parse(buf).context(format!("unknown NLA type {kind} for gtp"))?,
40 ),
41 })
42 }
43}