netlink-packet-netfilter 0.4.0

netlink packet types for the netfilter subprotocol
Documentation
// SPDX-License-Identifier: MIT

use netlink_packet_core::{DecodeError, ErrorContext as _, Parseable};

use crate::nftables::gen::GenAttribute;
use crate::nlas::parse_all_nlas;

#[derive(Debug, PartialEq, Eq, Clone)]
pub struct GenMessage {
    pub attributes: Vec<GenAttribute>,
}

impl Parseable<[u8]> for GenMessage {
    fn parse(buf: &[u8]) -> Result<Self, DecodeError> {
        let attributes = parse_all_nlas(buf, |buf| GenAttribute::parse(&buf))
            .context("failed to parse gen message nla")?;
        Ok(Self { attributes })
    }
}