netlink_packet_route/link/link_info/
xstats.rs
1use netlink_packet_utils::nla::NlaBuffer;
4use netlink_packet_utils::{DecodeError, Emitable, ParseableParametrized};
5
6use crate::link::InfoKind;
7
8#[derive(Debug, PartialEq, Eq, Clone)]
11#[non_exhaustive]
12pub enum LinkXstats {
13 Other(Vec<u8>),
14}
15
16impl Emitable for LinkXstats {
17 fn buffer_len(&self) -> usize {
18 match self {
19 Self::Other(v) => v.len(),
20 }
21 }
22
23 fn emit(&self, buffer: &mut [u8]) {
24 match self {
25 Self::Other(v) => buffer.copy_from_slice(v.as_slice()),
26 }
27 }
28}
29
30impl<'a, T: AsRef<[u8]> + ?Sized> ParseableParametrized<NlaBuffer<&'a T>, &InfoKind>
31 for LinkXstats
32{
33 type Error = DecodeError;
34 fn parse_with_param(buf: &NlaBuffer<&'a T>, _kind: &InfoKind) -> Result<Self, DecodeError> {
35 Ok(Self::Other(buf.value().to_vec()))
36 }
37}