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