Skip to main content

netlink_bindings/nftables/
mod.rs

1#![doc = "Netfilter nftables configuration over netlink\\."]
2#![allow(clippy::all)]
3#![allow(unused_imports)]
4#![allow(unused_assignments)]
5#![allow(non_snake_case)]
6#![allow(unused_variables)]
7#![allow(irrefutable_let_patterns)]
8#![allow(unreachable_code)]
9#![allow(unreachable_patterns)]
10use crate::builtin::{BuiltinBitfield32, BuiltinNfgenmsg, Nlmsghdr, PushDummy};
11use crate::{
12    consts,
13    traits::{NetlinkRequest, Protocol},
14    utils::*,
15};
16pub const PROTONAME: &str = "nftables";
17pub const PROTONAME_CSTR: &CStr = c"nftables";
18pub const PROTONUM: u16 = 12u16;
19#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
20#[derive(Debug, Clone, Copy)]
21pub enum MetaKeys {
22    Len = 0,
23    Protocol = 1,
24    Priority = 2,
25    Mark = 3,
26    Iif = 4,
27    Oif = 5,
28    Iifname = 6,
29    Oifname = 7,
30    Iftype = 8,
31    Oiftype = 9,
32    Skuid = 10,
33    Skgid = 11,
34    Nftrace = 12,
35    Rtclassid = 13,
36    Secmark = 14,
37    Nfproto = 15,
38    L4Proto = 16,
39    BriIifname = 17,
40    BriOifname = 18,
41    Pkttype = 19,
42    Cpu = 20,
43    Iifgroup = 21,
44    Oifgroup = 22,
45    Cgroup = 23,
46    Prandom = 24,
47    Secpath = 25,
48    Iifkind = 26,
49    Oifkind = 27,
50    BriIifpvid = 28,
51    BriIifvproto = 29,
52    TimeNs = 30,
53    TimeDay = 31,
54    TimeHour = 32,
55    Sdif = 33,
56    Sdifname = 34,
57    BriBroute = 35,
58}
59impl MetaKeys {
60    pub fn from_value(value: u64) -> Option<Self> {
61        Some(match value {
62            0 => Self::Len,
63            1 => Self::Protocol,
64            2 => Self::Priority,
65            3 => Self::Mark,
66            4 => Self::Iif,
67            5 => Self::Oif,
68            6 => Self::Iifname,
69            7 => Self::Oifname,
70            8 => Self::Iftype,
71            9 => Self::Oiftype,
72            10 => Self::Skuid,
73            11 => Self::Skgid,
74            12 => Self::Nftrace,
75            13 => Self::Rtclassid,
76            14 => Self::Secmark,
77            15 => Self::Nfproto,
78            16 => Self::L4Proto,
79            17 => Self::BriIifname,
80            18 => Self::BriOifname,
81            19 => Self::Pkttype,
82            20 => Self::Cpu,
83            21 => Self::Iifgroup,
84            22 => Self::Oifgroup,
85            23 => Self::Cgroup,
86            24 => Self::Prandom,
87            25 => Self::Secpath,
88            26 => Self::Iifkind,
89            27 => Self::Oifkind,
90            28 => Self::BriIifpvid,
91            29 => Self::BriIifvproto,
92            30 => Self::TimeNs,
93            31 => Self::TimeDay,
94            32 => Self::TimeHour,
95            33 => Self::Sdif,
96            34 => Self::Sdifname,
97            35 => Self::BriBroute,
98            _ => return None,
99        })
100    }
101}
102#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
103#[derive(Debug, Clone, Copy)]
104pub enum BitwiseOps {
105    #[doc = "mask\\-and\\-xor operation used to implement NOT, AND, OR and XOR boolean operations"]
106    MaskXor = 0,
107    Lshift = 1,
108    Rshift = 2,
109    And = 3,
110    Or = 4,
111    Xor = 5,
112}
113impl BitwiseOps {
114    pub fn from_value(value: u64) -> Option<Self> {
115        Some(match value {
116            0 => Self::MaskXor,
117            1 => Self::Lshift,
118            2 => Self::Rshift,
119            3 => Self::And,
120            4 => Self::Or,
121            5 => Self::Xor,
122            _ => return None,
123        })
124    }
125}
126#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
127#[derive(Debug, Clone, Copy)]
128pub enum CmpOps {
129    Eq = 0,
130    Neq = 1,
131    Lt = 2,
132    Lte = 3,
133    Gt = 4,
134    Gte = 5,
135}
136impl CmpOps {
137    pub fn from_value(value: u64) -> Option<Self> {
138        Some(match value {
139            0 => Self::Eq,
140            1 => Self::Neq,
141            2 => Self::Lt,
142            3 => Self::Lte,
143            4 => Self::Gt,
144            5 => Self::Gte,
145            _ => return None,
146        })
147    }
148}
149#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
150#[derive(Debug, Clone, Copy)]
151pub enum ObjectType {
152    Unspec = 0,
153    Counter = 1,
154    Quota = 2,
155    CtHelper = 3,
156    Limit = 4,
157    Connlimit = 5,
158    Tunnel = 6,
159    CtTimeout = 7,
160    Secmark = 8,
161    CtExpect = 9,
162    Synproxy = 10,
163}
164impl ObjectType {
165    pub fn from_value(value: u64) -> Option<Self> {
166        Some(match value {
167            0 => Self::Unspec,
168            1 => Self::Counter,
169            2 => Self::Quota,
170            3 => Self::CtHelper,
171            4 => Self::Limit,
172            5 => Self::Connlimit,
173            6 => Self::Tunnel,
174            7 => Self::CtTimeout,
175            8 => Self::Secmark,
176            9 => Self::CtExpect,
177            10 => Self::Synproxy,
178            _ => return None,
179        })
180    }
181}
182#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
183#[derive(Debug, Clone, Copy)]
184pub enum NatRangeFlags {
185    MapIps = 1 << 0,
186    ProtoSpecified = 1 << 1,
187    ProtoRandom = 1 << 2,
188    Persistent = 1 << 3,
189    ProtoRandomFully = 1 << 4,
190    ProtoOffset = 1 << 5,
191    Netmap = 1 << 6,
192}
193impl NatRangeFlags {
194    pub fn from_value(value: u64) -> Option<Self> {
195        Some(match value {
196            n if n == 1 << 0 => Self::MapIps,
197            n if n == 1 << 1 => Self::ProtoSpecified,
198            n if n == 1 << 2 => Self::ProtoRandom,
199            n if n == 1 << 3 => Self::Persistent,
200            n if n == 1 << 4 => Self::ProtoRandomFully,
201            n if n == 1 << 5 => Self::ProtoOffset,
202            n if n == 1 << 6 => Self::Netmap,
203            _ => return None,
204        })
205    }
206}
207#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
208#[derive(Debug, Clone, Copy)]
209pub enum TableFlags {
210    Dormant = 1 << 0,
211    Owner = 1 << 1,
212    Persist = 1 << 2,
213}
214impl TableFlags {
215    pub fn from_value(value: u64) -> Option<Self> {
216        Some(match value {
217            n if n == 1 << 0 => Self::Dormant,
218            n if n == 1 << 1 => Self::Owner,
219            n if n == 1 << 2 => Self::Persist,
220            _ => return None,
221        })
222    }
223}
224#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
225#[derive(Debug, Clone, Copy)]
226pub enum ChainFlags {
227    Base = 1 << 0,
228    HwOffload = 1 << 1,
229    Binding = 1 << 2,
230}
231impl ChainFlags {
232    pub fn from_value(value: u64) -> Option<Self> {
233        Some(match value {
234            n if n == 1 << 0 => Self::Base,
235            n if n == 1 << 1 => Self::HwOffload,
236            n if n == 1 << 2 => Self::Binding,
237            _ => return None,
238        })
239    }
240}
241#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
242#[derive(Debug, Clone, Copy)]
243pub enum SetFlags {
244    Anonymous = 1 << 0,
245    Constant = 1 << 1,
246    Interval = 1 << 2,
247    Map = 1 << 3,
248    Timeout = 1 << 4,
249    Eval = 1 << 5,
250    Object = 1 << 6,
251    Concat = 1 << 7,
252    Expr = 1 << 8,
253}
254impl SetFlags {
255    pub fn from_value(value: u64) -> Option<Self> {
256        Some(match value {
257            n if n == 1 << 0 => Self::Anonymous,
258            n if n == 1 << 1 => Self::Constant,
259            n if n == 1 << 2 => Self::Interval,
260            n if n == 1 << 3 => Self::Map,
261            n if n == 1 << 4 => Self::Timeout,
262            n if n == 1 << 5 => Self::Eval,
263            n if n == 1 << 6 => Self::Object,
264            n if n == 1 << 7 => Self::Concat,
265            n if n == 1 << 8 => Self::Expr,
266            _ => return None,
267        })
268    }
269}
270#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
271#[derive(Debug, Clone, Copy)]
272pub enum SetElemFlags {
273    IntervalEnd = 1 << 0,
274    Catchall = 1 << 1,
275}
276impl SetElemFlags {
277    pub fn from_value(value: u64) -> Option<Self> {
278        Some(match value {
279            n if n == 1 << 0 => Self::IntervalEnd,
280            n if n == 1 << 1 => Self::Catchall,
281            _ => return None,
282        })
283    }
284}
285#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
286#[derive(Debug, Clone, Copy)]
287pub enum LookupFlags {
288    Invert = 1 << 0,
289}
290impl LookupFlags {
291    pub fn from_value(value: u64) -> Option<Self> {
292        Some(match value {
293            n if n == 1 << 0 => Self::Invert,
294            _ => return None,
295        })
296    }
297}
298#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
299#[derive(Debug, Clone, Copy)]
300pub enum CtKeys {
301    State = 0,
302    Direction = 1,
303    Status = 2,
304    Mark = 3,
305    Secmark = 4,
306    Expiration = 5,
307    Helper = 6,
308    L3protocol = 7,
309    Src = 8,
310    Dst = 9,
311    Protocol = 10,
312    ProtoSrc = 11,
313    ProtoDst = 12,
314    Labels = 13,
315    Pkts = 14,
316    Bytes = 15,
317    Avgpkt = 16,
318    Zone = 17,
319    Eventmask = 18,
320    SrcIp = 19,
321    DstIp = 20,
322    SrcIp6 = 21,
323    DstIp6 = 22,
324    CtId = 23,
325}
326impl CtKeys {
327    pub fn from_value(value: u64) -> Option<Self> {
328        Some(match value {
329            0 => Self::State,
330            1 => Self::Direction,
331            2 => Self::Status,
332            3 => Self::Mark,
333            4 => Self::Secmark,
334            5 => Self::Expiration,
335            6 => Self::Helper,
336            7 => Self::L3protocol,
337            8 => Self::Src,
338            9 => Self::Dst,
339            10 => Self::Protocol,
340            11 => Self::ProtoSrc,
341            12 => Self::ProtoDst,
342            13 => Self::Labels,
343            14 => Self::Pkts,
344            15 => Self::Bytes,
345            16 => Self::Avgpkt,
346            17 => Self::Zone,
347            18 => Self::Eventmask,
348            19 => Self::SrcIp,
349            20 => Self::DstIp,
350            21 => Self::SrcIp6,
351            22 => Self::DstIp6,
352            23 => Self::CtId,
353            _ => return None,
354        })
355    }
356}
357#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
358#[derive(Debug, Clone, Copy)]
359pub enum CtDirection {
360    Original = 0,
361    Reply = 1,
362}
363impl CtDirection {
364    pub fn from_value(value: u64) -> Option<Self> {
365        Some(match value {
366            0 => Self::Original,
367            1 => Self::Reply,
368            _ => return None,
369        })
370    }
371}
372#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
373#[derive(Debug, Clone, Copy)]
374pub enum QuotaFlags {
375    Invert = 1 << 0,
376    Depleted = 1 << 1,
377}
378impl QuotaFlags {
379    pub fn from_value(value: u64) -> Option<Self> {
380        Some(match value {
381            n if n == 1 << 0 => Self::Invert,
382            n if n == 1 << 1 => Self::Depleted,
383            _ => return None,
384        })
385    }
386}
387#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
388#[derive(Debug, Clone, Copy)]
389pub enum VerdictCode {
390    Continue = 4294967295,
391    Break = 4294967294,
392    Jump = 4294967293,
393    Goto = 4294967292,
394    Return = 4294967291,
395    Drop = 0,
396    Accept = 1,
397    Stolen = 2,
398    Queue = 3,
399    Repeat = 4,
400}
401impl VerdictCode {
402    pub fn from_value(value: u64) -> Option<Self> {
403        Some(match value {
404            4294967295 => Self::Continue,
405            4294967294 => Self::Break,
406            4294967293 => Self::Jump,
407            4294967292 => Self::Goto,
408            4294967291 => Self::Return,
409            0 => Self::Drop,
410            1 => Self::Accept,
411            2 => Self::Stolen,
412            3 => Self::Queue,
413            4 => Self::Repeat,
414            _ => return None,
415        })
416    }
417}
418#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
419#[derive(Debug, Clone, Copy)]
420pub enum FibResult {
421    Oif = 0,
422    Oifname = 1,
423    Addrtype = 2,
424}
425impl FibResult {
426    pub fn from_value(value: u64) -> Option<Self> {
427        Some(match value {
428            0 => Self::Oif,
429            1 => Self::Oifname,
430            2 => Self::Addrtype,
431            _ => return None,
432        })
433    }
434}
435#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
436#[derive(Debug, Clone, Copy)]
437pub enum FibFlags {
438    Saddr = 1 << 0,
439    Daddr = 1 << 1,
440    Mark = 1 << 2,
441    Iif = 1 << 3,
442    Oif = 1 << 4,
443    Present = 1 << 5,
444}
445impl FibFlags {
446    pub fn from_value(value: u64) -> Option<Self> {
447        Some(match value {
448            n if n == 1 << 0 => Self::Saddr,
449            n if n == 1 << 1 => Self::Daddr,
450            n if n == 1 << 2 => Self::Mark,
451            n if n == 1 << 3 => Self::Iif,
452            n if n == 1 << 4 => Self::Oif,
453            n if n == 1 << 5 => Self::Present,
454            _ => return None,
455        })
456    }
457}
458#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
459#[derive(Debug, Clone, Copy)]
460pub enum RejectTypes {
461    IcmpUnreach = 0,
462    TcpRst = 1,
463    IcmpxUnreach = 2,
464}
465impl RejectTypes {
466    pub fn from_value(value: u64) -> Option<Self> {
467        Some(match value {
468            0 => Self::IcmpUnreach,
469            1 => Self::TcpRst,
470            2 => Self::IcmpxUnreach,
471            _ => return None,
472        })
473    }
474}
475#[doc = "These codes are mapped to real ICMP and ICMPv6 codes\\."]
476#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
477#[derive(Debug, Clone, Copy)]
478pub enum RejectInetCode {
479    IcmpxNoRoute = 0,
480    IcmpxPortUnreach = 1,
481    IcmpxHostUnreach = 2,
482    IcmpxAdminProhibited = 3,
483}
484impl RejectInetCode {
485    pub fn from_value(value: u64) -> Option<Self> {
486        Some(match value {
487            0 => Self::IcmpxNoRoute,
488            1 => Self::IcmpxPortUnreach,
489            2 => Self::IcmpxHostUnreach,
490            3 => Self::IcmpxAdminProhibited,
491            _ => return None,
492        })
493    }
494}
495#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
496#[derive(Debug, Clone, Copy)]
497pub enum PayloadBase {
498    LinkLayerHeader = 0,
499    NetworkHeader = 1,
500    TransportHeader = 2,
501    InnerHeader = 3,
502    TunHeader = 4,
503}
504impl PayloadBase {
505    pub fn from_value(value: u64) -> Option<Self> {
506        Some(match value {
507            0 => Self::LinkLayerHeader,
508            1 => Self::NetworkHeader,
509            2 => Self::TransportHeader,
510            3 => Self::InnerHeader,
511            4 => Self::TunHeader,
512            _ => return None,
513        })
514    }
515}
516#[doc = "Range operator"]
517#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
518#[derive(Debug, Clone, Copy)]
519pub enum RangeOps {
520    Eq = 0,
521    Neq = 1,
522}
523impl RangeOps {
524    pub fn from_value(value: u64) -> Option<Self> {
525        Some(match value {
526            0 => Self::Eq,
527            1 => Self::Neq,
528            _ => return None,
529        })
530    }
531}
532#[doc = "nf\\_tables registers\\.\nnf\\_tables used to have five registers: a verdict register and four data\nregisters of size 16\\. The data registers have been changed to 16 registers\nof size 4\\. For compatibility reasons, the NFT\\_REG\\_\\[1\\-4\\] registers still\nmap to areas of size 16, the 4 byte registers are addressed using\nNFT\\_REG32\\_00 \\- NFT\\_REG32\\_15\\.\n"]
533#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
534#[derive(Debug, Clone, Copy)]
535pub enum Registers {
536    RegVerdict = 0,
537    Reg1 = 1,
538    Reg2 = 2,
539    Reg3 = 3,
540    Reg4 = 4,
541    Reg3200 = 8,
542    Reg3201 = 9,
543    Reg3202 = 10,
544    Reg3203 = 11,
545    Reg3204 = 12,
546    Reg3205 = 13,
547    Reg3206 = 14,
548    Reg3207 = 15,
549    Reg3208 = 16,
550    Reg3209 = 17,
551    Reg3210 = 18,
552    Reg3211 = 19,
553    Reg3212 = 20,
554    Reg3213 = 21,
555    Reg3214 = 22,
556    Reg3215 = 23,
557}
558impl Registers {
559    pub fn from_value(value: u64) -> Option<Self> {
560        Some(match value {
561            0 => Self::RegVerdict,
562            1 => Self::Reg1,
563            2 => Self::Reg2,
564            3 => Self::Reg3,
565            4 => Self::Reg4,
566            8 => Self::Reg3200,
567            9 => Self::Reg3201,
568            10 => Self::Reg3202,
569            11 => Self::Reg3203,
570            12 => Self::Reg3204,
571            13 => Self::Reg3205,
572            14 => Self::Reg3206,
573            15 => Self::Reg3207,
574            16 => Self::Reg3208,
575            17 => Self::Reg3209,
576            18 => Self::Reg3210,
577            19 => Self::Reg3211,
578            20 => Self::Reg3212,
579            21 => Self::Reg3213,
580            22 => Self::Reg3214,
581            23 => Self::Reg3215,
582            _ => return None,
583        })
584    }
585}
586#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
587#[derive(Debug, Clone, Copy)]
588pub enum NumgenTypes {
589    Incremental = 0,
590    Random = 1,
591}
592impl NumgenTypes {
593    pub fn from_value(value: u64) -> Option<Self> {
594        Some(match value {
595            0 => Self::Incremental,
596            1 => Self::Random,
597            _ => return None,
598        })
599    }
600}
601#[doc = "nf\\_tables log levels"]
602#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
603#[derive(Debug, Clone, Copy)]
604pub enum LogLevel {
605    #[doc = "system is unusable"]
606    Emerg = 0,
607    #[doc = "action must be taken immediately"]
608    Alert = 1,
609    #[doc = "critical conditions"]
610    Crit = 2,
611    #[doc = "error conditions"]
612    Err = 3,
613    #[doc = "warning conditions"]
614    Warning = 4,
615    #[doc = "normal but significant condition"]
616    Notice = 5,
617    #[doc = "informational"]
618    Info = 6,
619    #[doc = "debug\\-level messages"]
620    Debug = 7,
621    #[doc = "enabling audit logging"]
622    Audit = 8,
623}
624impl LogLevel {
625    pub fn from_value(value: u64) -> Option<Self> {
626        Some(match value {
627            0 => Self::Emerg,
628            1 => Self::Alert,
629            2 => Self::Crit,
630            3 => Self::Err,
631            4 => Self::Warning,
632            5 => Self::Notice,
633            6 => Self::Info,
634            7 => Self::Debug,
635            8 => Self::Audit,
636            _ => return None,
637        })
638    }
639}
640#[doc = "nf\\_tables log flags"]
641#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
642#[derive(Debug, Clone, Copy)]
643pub enum LogFlags {
644    #[doc = "Log TCP sequence numbers"]
645    Tcpseq = 1 << 0,
646    #[doc = "Log TCP options"]
647    Tcpopt = 1 << 1,
648    #[doc = "Log IP options"]
649    Ipopt = 1 << 2,
650    #[doc = "Log UID owning local socket"]
651    Uid = 1 << 3,
652    #[doc = "Unsupported, don't reuse"]
653    Nflog = 1 << 4,
654    #[doc = "Decode MAC header"]
655    Macdecode = 1 << 5,
656}
657impl LogFlags {
658    pub fn from_value(value: u64) -> Option<Self> {
659        Some(match value {
660            n if n == 1 << 0 => Self::Tcpseq,
661            n if n == 1 << 1 => Self::Tcpopt,
662            n if n == 1 << 2 => Self::Ipopt,
663            n if n == 1 << 3 => Self::Uid,
664            n if n == 1 << 4 => Self::Nflog,
665            n if n == 1 << 5 => Self::Macdecode,
666            _ => return None,
667        })
668    }
669}
670#[repr(C, packed(4))]
671pub struct Nfgenmsg {
672    pub nfgen_family: u8,
673    pub version: u8,
674    pub _res_id_be: u16,
675}
676impl Clone for Nfgenmsg {
677    fn clone(&self) -> Self {
678        Self::new_from_array(*self.as_array())
679    }
680}
681#[doc = "Create zero-initialized struct"]
682impl Default for Nfgenmsg {
683    fn default() -> Self {
684        Self::new()
685    }
686}
687impl Nfgenmsg {
688    #[doc = "Create zero-initialized struct"]
689    pub fn new() -> Self {
690        Self::new_from_array([0u8; Self::len()])
691    }
692    #[doc = "Copy from contents from slice"]
693    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
694        if other.len() != Self::len() {
695            return None;
696        }
697        let mut buf = [0u8; Self::len()];
698        buf.clone_from_slice(other);
699        Some(Self::new_from_array(buf))
700    }
701    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
702    pub fn new_from_zeroed(other: &[u8]) -> Self {
703        let mut buf = [0u8; Self::len()];
704        let len = buf.len().min(other.len());
705        buf[..len].clone_from_slice(&other[..len]);
706        Self::new_from_array(buf)
707    }
708    pub fn new_from_array(buf: [u8; 4usize]) -> Self {
709        unsafe { std::mem::transmute(buf) }
710    }
711    pub fn as_slice(&self) -> &[u8] {
712        unsafe {
713            let ptr: *const u8 = std::mem::transmute(self as *const Self);
714            std::slice::from_raw_parts(ptr, Self::len())
715        }
716    }
717    pub fn from_slice(buf: &[u8]) -> &Self {
718        assert!(buf.len() >= Self::len());
719        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
720        unsafe { std::mem::transmute(buf.as_ptr()) }
721    }
722    pub fn as_array(&self) -> &[u8; 4usize] {
723        unsafe { std::mem::transmute(self) }
724    }
725    pub fn from_array(buf: &[u8; 4usize]) -> &Self {
726        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
727        unsafe { std::mem::transmute(buf) }
728    }
729    pub fn into_array(self) -> [u8; 4usize] {
730        unsafe { std::mem::transmute(self) }
731    }
732    pub const fn len() -> usize {
733        const _: () = assert!(std::mem::size_of::<Nfgenmsg>() == 4usize);
734        4usize
735    }
736    pub fn res_id(&self) -> u16 {
737        u16::from_be(self._res_id_be)
738    }
739    pub fn set_res_id(&mut self, value: u16) {
740        self._res_id_be = value.to_be();
741    }
742}
743impl std::fmt::Debug for Nfgenmsg {
744    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
745        fmt.debug_struct("Nfgenmsg")
746            .field("nfgen_family", &self.nfgen_family)
747            .field("version", &self.version)
748            .field("res_id", &self.res_id())
749            .finish()
750    }
751}
752#[derive(Clone)]
753pub enum LogAttrs<'a> {
754    #[doc = "netlink group to send messages to"]
755    Group(u16),
756    #[doc = "prefix to prepend to log messages"]
757    Prefix(&'a CStr),
758    #[doc = "length of payload to include in netlink message"]
759    Snaplen(u32),
760    #[doc = "queue threshold"]
761    Qthreshold(u16),
762    #[doc = "log level\nAssociated type: [`LogLevel`] (enum)"]
763    Level(u32),
764    #[doc = "logging flags\nAssociated type: [`LogFlags`] (enum)"]
765    Flags(u32),
766}
767impl<'a> IterableLogAttrs<'a> {
768    #[doc = "netlink group to send messages to"]
769    pub fn get_group(&self) -> Result<u16, ErrorContext> {
770        let mut iter = self.clone();
771        iter.pos = 0;
772        for attr in iter {
773            if let LogAttrs::Group(val) = attr? {
774                return Ok(val);
775            }
776        }
777        Err(ErrorContext::new_missing(
778            "LogAttrs",
779            "Group",
780            self.orig_loc,
781            self.buf.as_ptr() as usize,
782        ))
783    }
784    #[doc = "prefix to prepend to log messages"]
785    pub fn get_prefix(&self) -> Result<&'a CStr, ErrorContext> {
786        let mut iter = self.clone();
787        iter.pos = 0;
788        for attr in iter {
789            if let LogAttrs::Prefix(val) = attr? {
790                return Ok(val);
791            }
792        }
793        Err(ErrorContext::new_missing(
794            "LogAttrs",
795            "Prefix",
796            self.orig_loc,
797            self.buf.as_ptr() as usize,
798        ))
799    }
800    #[doc = "length of payload to include in netlink message"]
801    pub fn get_snaplen(&self) -> Result<u32, ErrorContext> {
802        let mut iter = self.clone();
803        iter.pos = 0;
804        for attr in iter {
805            if let LogAttrs::Snaplen(val) = attr? {
806                return Ok(val);
807            }
808        }
809        Err(ErrorContext::new_missing(
810            "LogAttrs",
811            "Snaplen",
812            self.orig_loc,
813            self.buf.as_ptr() as usize,
814        ))
815    }
816    #[doc = "queue threshold"]
817    pub fn get_qthreshold(&self) -> Result<u16, ErrorContext> {
818        let mut iter = self.clone();
819        iter.pos = 0;
820        for attr in iter {
821            if let LogAttrs::Qthreshold(val) = attr? {
822                return Ok(val);
823            }
824        }
825        Err(ErrorContext::new_missing(
826            "LogAttrs",
827            "Qthreshold",
828            self.orig_loc,
829            self.buf.as_ptr() as usize,
830        ))
831    }
832    #[doc = "log level\nAssociated type: [`LogLevel`] (enum)"]
833    pub fn get_level(&self) -> Result<u32, ErrorContext> {
834        let mut iter = self.clone();
835        iter.pos = 0;
836        for attr in iter {
837            if let LogAttrs::Level(val) = attr? {
838                return Ok(val);
839            }
840        }
841        Err(ErrorContext::new_missing(
842            "LogAttrs",
843            "Level",
844            self.orig_loc,
845            self.buf.as_ptr() as usize,
846        ))
847    }
848    #[doc = "logging flags\nAssociated type: [`LogFlags`] (enum)"]
849    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
850        let mut iter = self.clone();
851        iter.pos = 0;
852        for attr in iter {
853            if let LogAttrs::Flags(val) = attr? {
854                return Ok(val);
855            }
856        }
857        Err(ErrorContext::new_missing(
858            "LogAttrs",
859            "Flags",
860            self.orig_loc,
861            self.buf.as_ptr() as usize,
862        ))
863    }
864}
865impl LogAttrs<'_> {
866    pub fn new<'a>(buf: &'a [u8]) -> IterableLogAttrs<'a> {
867        IterableLogAttrs::with_loc(buf, buf.as_ptr() as usize)
868    }
869    fn attr_from_type(r#type: u16) -> Option<&'static str> {
870        let res = match r#type {
871            1u16 => "Group",
872            2u16 => "Prefix",
873            3u16 => "Snaplen",
874            4u16 => "Qthreshold",
875            5u16 => "Level",
876            6u16 => "Flags",
877            _ => return None,
878        };
879        Some(res)
880    }
881}
882#[derive(Clone, Copy, Default)]
883pub struct IterableLogAttrs<'a> {
884    buf: &'a [u8],
885    pos: usize,
886    orig_loc: usize,
887}
888impl<'a> IterableLogAttrs<'a> {
889    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
890        Self {
891            buf,
892            pos: 0,
893            orig_loc,
894        }
895    }
896    pub fn get_buf(&self) -> &'a [u8] {
897        self.buf
898    }
899}
900impl<'a> Iterator for IterableLogAttrs<'a> {
901    type Item = Result<LogAttrs<'a>, ErrorContext>;
902    fn next(&mut self) -> Option<Self::Item> {
903        let pos = self.pos;
904        let mut r#type;
905        loop {
906            r#type = None;
907            if self.buf.len() == self.pos {
908                return None;
909            }
910            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
911                break;
912            };
913            r#type = Some(header.r#type);
914            let res = match header.r#type {
915                1u16 => LogAttrs::Group({
916                    let res = parse_be_u16(next);
917                    let Some(val) = res else { break };
918                    val
919                }),
920                2u16 => LogAttrs::Prefix({
921                    let res = CStr::from_bytes_with_nul(next).ok();
922                    let Some(val) = res else { break };
923                    val
924                }),
925                3u16 => LogAttrs::Snaplen({
926                    let res = parse_be_u32(next);
927                    let Some(val) = res else { break };
928                    val
929                }),
930                4u16 => LogAttrs::Qthreshold({
931                    let res = parse_be_u16(next);
932                    let Some(val) = res else { break };
933                    val
934                }),
935                5u16 => LogAttrs::Level({
936                    let res = parse_be_u32(next);
937                    let Some(val) = res else { break };
938                    val
939                }),
940                6u16 => LogAttrs::Flags({
941                    let res = parse_be_u32(next);
942                    let Some(val) = res else { break };
943                    val
944                }),
945                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
946                n => continue,
947            };
948            return Some(Ok(res));
949        }
950        Some(Err(ErrorContext::new(
951            "LogAttrs",
952            r#type.and_then(|t| LogAttrs::attr_from_type(t)),
953            self.orig_loc,
954            self.buf.as_ptr().wrapping_add(pos) as usize,
955        )))
956    }
957}
958impl<'a> std::fmt::Debug for IterableLogAttrs<'_> {
959    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
960        let mut fmt = f.debug_struct("LogAttrs");
961        for attr in self.clone() {
962            let attr = match attr {
963                Ok(a) => a,
964                Err(err) => {
965                    fmt.finish()?;
966                    f.write_str("Err(")?;
967                    err.fmt(f)?;
968                    return f.write_str(")");
969                }
970            };
971            match attr {
972                LogAttrs::Group(val) => fmt.field("Group", &val),
973                LogAttrs::Prefix(val) => fmt.field("Prefix", &val),
974                LogAttrs::Snaplen(val) => fmt.field("Snaplen", &val),
975                LogAttrs::Qthreshold(val) => fmt.field("Qthreshold", &val),
976                LogAttrs::Level(val) => {
977                    fmt.field("Level", &FormatEnum(val.into(), LogLevel::from_value))
978                }
979                LogAttrs::Flags(val) => {
980                    fmt.field("Flags", &FormatFlags(val.into(), LogFlags::from_value))
981                }
982            };
983        }
984        fmt.finish()
985    }
986}
987impl IterableLogAttrs<'_> {
988    pub fn lookup_attr(
989        &self,
990        offset: usize,
991        missing_type: Option<u16>,
992    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
993        let mut stack = Vec::new();
994        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
995        if missing_type.is_some() && cur == offset {
996            stack.push(("LogAttrs", offset));
997            return (
998                stack,
999                missing_type.and_then(|t| LogAttrs::attr_from_type(t)),
1000            );
1001        }
1002        if cur > offset || cur + self.buf.len() < offset {
1003            return (stack, None);
1004        }
1005        let mut attrs = self.clone();
1006        let mut last_off = cur + attrs.pos;
1007        while let Some(attr) = attrs.next() {
1008            let Ok(attr) = attr else { break };
1009            match attr {
1010                LogAttrs::Group(val) => {
1011                    if last_off == offset {
1012                        stack.push(("Group", last_off));
1013                        break;
1014                    }
1015                }
1016                LogAttrs::Prefix(val) => {
1017                    if last_off == offset {
1018                        stack.push(("Prefix", last_off));
1019                        break;
1020                    }
1021                }
1022                LogAttrs::Snaplen(val) => {
1023                    if last_off == offset {
1024                        stack.push(("Snaplen", last_off));
1025                        break;
1026                    }
1027                }
1028                LogAttrs::Qthreshold(val) => {
1029                    if last_off == offset {
1030                        stack.push(("Qthreshold", last_off));
1031                        break;
1032                    }
1033                }
1034                LogAttrs::Level(val) => {
1035                    if last_off == offset {
1036                        stack.push(("Level", last_off));
1037                        break;
1038                    }
1039                }
1040                LogAttrs::Flags(val) => {
1041                    if last_off == offset {
1042                        stack.push(("Flags", last_off));
1043                        break;
1044                    }
1045                }
1046                _ => {}
1047            };
1048            last_off = cur + attrs.pos;
1049        }
1050        if !stack.is_empty() {
1051            stack.push(("LogAttrs", cur));
1052        }
1053        (stack, None)
1054    }
1055}
1056#[derive(Clone)]
1057pub enum NumgenAttrs {
1058    #[doc = "destination register\nAssociated type: [`Registers`] (enum)"]
1059    Dreg(u32),
1060    #[doc = "maximum counter value"]
1061    Modulus(u32),
1062    #[doc = "operation type\nAssociated type: [`NumgenTypes`] (enum)"]
1063    Type(u32),
1064    #[doc = "offset to be added to the counter"]
1065    Offset(u32),
1066}
1067impl<'a> IterableNumgenAttrs<'a> {
1068    #[doc = "destination register\nAssociated type: [`Registers`] (enum)"]
1069    pub fn get_dreg(&self) -> Result<u32, ErrorContext> {
1070        let mut iter = self.clone();
1071        iter.pos = 0;
1072        for attr in iter {
1073            if let NumgenAttrs::Dreg(val) = attr? {
1074                return Ok(val);
1075            }
1076        }
1077        Err(ErrorContext::new_missing(
1078            "NumgenAttrs",
1079            "Dreg",
1080            self.orig_loc,
1081            self.buf.as_ptr() as usize,
1082        ))
1083    }
1084    #[doc = "maximum counter value"]
1085    pub fn get_modulus(&self) -> Result<u32, ErrorContext> {
1086        let mut iter = self.clone();
1087        iter.pos = 0;
1088        for attr in iter {
1089            if let NumgenAttrs::Modulus(val) = attr? {
1090                return Ok(val);
1091            }
1092        }
1093        Err(ErrorContext::new_missing(
1094            "NumgenAttrs",
1095            "Modulus",
1096            self.orig_loc,
1097            self.buf.as_ptr() as usize,
1098        ))
1099    }
1100    #[doc = "operation type\nAssociated type: [`NumgenTypes`] (enum)"]
1101    pub fn get_type(&self) -> Result<u32, ErrorContext> {
1102        let mut iter = self.clone();
1103        iter.pos = 0;
1104        for attr in iter {
1105            if let NumgenAttrs::Type(val) = attr? {
1106                return Ok(val);
1107            }
1108        }
1109        Err(ErrorContext::new_missing(
1110            "NumgenAttrs",
1111            "Type",
1112            self.orig_loc,
1113            self.buf.as_ptr() as usize,
1114        ))
1115    }
1116    #[doc = "offset to be added to the counter"]
1117    pub fn get_offset(&self) -> Result<u32, ErrorContext> {
1118        let mut iter = self.clone();
1119        iter.pos = 0;
1120        for attr in iter {
1121            if let NumgenAttrs::Offset(val) = attr? {
1122                return Ok(val);
1123            }
1124        }
1125        Err(ErrorContext::new_missing(
1126            "NumgenAttrs",
1127            "Offset",
1128            self.orig_loc,
1129            self.buf.as_ptr() as usize,
1130        ))
1131    }
1132}
1133impl NumgenAttrs {
1134    pub fn new<'a>(buf: &'a [u8]) -> IterableNumgenAttrs<'a> {
1135        IterableNumgenAttrs::with_loc(buf, buf.as_ptr() as usize)
1136    }
1137    fn attr_from_type(r#type: u16) -> Option<&'static str> {
1138        let res = match r#type {
1139            1u16 => "Dreg",
1140            2u16 => "Modulus",
1141            3u16 => "Type",
1142            4u16 => "Offset",
1143            _ => return None,
1144        };
1145        Some(res)
1146    }
1147}
1148#[derive(Clone, Copy, Default)]
1149pub struct IterableNumgenAttrs<'a> {
1150    buf: &'a [u8],
1151    pos: usize,
1152    orig_loc: usize,
1153}
1154impl<'a> IterableNumgenAttrs<'a> {
1155    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1156        Self {
1157            buf,
1158            pos: 0,
1159            orig_loc,
1160        }
1161    }
1162    pub fn get_buf(&self) -> &'a [u8] {
1163        self.buf
1164    }
1165}
1166impl<'a> Iterator for IterableNumgenAttrs<'a> {
1167    type Item = Result<NumgenAttrs, ErrorContext>;
1168    fn next(&mut self) -> Option<Self::Item> {
1169        let pos = self.pos;
1170        let mut r#type;
1171        loop {
1172            r#type = None;
1173            if self.buf.len() == self.pos {
1174                return None;
1175            }
1176            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1177                break;
1178            };
1179            r#type = Some(header.r#type);
1180            let res = match header.r#type {
1181                1u16 => NumgenAttrs::Dreg({
1182                    let res = parse_u32(next);
1183                    let Some(val) = res else { break };
1184                    val
1185                }),
1186                2u16 => NumgenAttrs::Modulus({
1187                    let res = parse_be_u32(next);
1188                    let Some(val) = res else { break };
1189                    val
1190                }),
1191                3u16 => NumgenAttrs::Type({
1192                    let res = parse_be_u32(next);
1193                    let Some(val) = res else { break };
1194                    val
1195                }),
1196                4u16 => NumgenAttrs::Offset({
1197                    let res = parse_be_u32(next);
1198                    let Some(val) = res else { break };
1199                    val
1200                }),
1201                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
1202                n => continue,
1203            };
1204            return Some(Ok(res));
1205        }
1206        Some(Err(ErrorContext::new(
1207            "NumgenAttrs",
1208            r#type.and_then(|t| NumgenAttrs::attr_from_type(t)),
1209            self.orig_loc,
1210            self.buf.as_ptr().wrapping_add(pos) as usize,
1211        )))
1212    }
1213}
1214impl std::fmt::Debug for IterableNumgenAttrs<'_> {
1215    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1216        let mut fmt = f.debug_struct("NumgenAttrs");
1217        for attr in self.clone() {
1218            let attr = match attr {
1219                Ok(a) => a,
1220                Err(err) => {
1221                    fmt.finish()?;
1222                    f.write_str("Err(")?;
1223                    err.fmt(f)?;
1224                    return f.write_str(")");
1225                }
1226            };
1227            match attr {
1228                NumgenAttrs::Dreg(val) => {
1229                    fmt.field("Dreg", &FormatEnum(val.into(), Registers::from_value))
1230                }
1231                NumgenAttrs::Modulus(val) => fmt.field("Modulus", &val),
1232                NumgenAttrs::Type(val) => {
1233                    fmt.field("Type", &FormatEnum(val.into(), NumgenTypes::from_value))
1234                }
1235                NumgenAttrs::Offset(val) => fmt.field("Offset", &val),
1236            };
1237        }
1238        fmt.finish()
1239    }
1240}
1241impl IterableNumgenAttrs<'_> {
1242    pub fn lookup_attr(
1243        &self,
1244        offset: usize,
1245        missing_type: Option<u16>,
1246    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
1247        let mut stack = Vec::new();
1248        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
1249        if missing_type.is_some() && cur == offset {
1250            stack.push(("NumgenAttrs", offset));
1251            return (
1252                stack,
1253                missing_type.and_then(|t| NumgenAttrs::attr_from_type(t)),
1254            );
1255        }
1256        if cur > offset || cur + self.buf.len() < offset {
1257            return (stack, None);
1258        }
1259        let mut attrs = self.clone();
1260        let mut last_off = cur + attrs.pos;
1261        while let Some(attr) = attrs.next() {
1262            let Ok(attr) = attr else { break };
1263            match attr {
1264                NumgenAttrs::Dreg(val) => {
1265                    if last_off == offset {
1266                        stack.push(("Dreg", last_off));
1267                        break;
1268                    }
1269                }
1270                NumgenAttrs::Modulus(val) => {
1271                    if last_off == offset {
1272                        stack.push(("Modulus", last_off));
1273                        break;
1274                    }
1275                }
1276                NumgenAttrs::Type(val) => {
1277                    if last_off == offset {
1278                        stack.push(("Type", last_off));
1279                        break;
1280                    }
1281                }
1282                NumgenAttrs::Offset(val) => {
1283                    if last_off == offset {
1284                        stack.push(("Offset", last_off));
1285                        break;
1286                    }
1287                }
1288                _ => {}
1289            };
1290            last_off = cur + attrs.pos;
1291        }
1292        if !stack.is_empty() {
1293            stack.push(("NumgenAttrs", cur));
1294        }
1295        (stack, None)
1296    }
1297}
1298#[derive(Clone)]
1299pub enum RangeAttrs<'a> {
1300    #[doc = "source register of data to compare\nAssociated type: [`Registers`] (enum)"]
1301    Sreg(u32),
1302    #[doc = "cmp operation\nAssociated type: [`RangeOps`] (enum)"]
1303    Op(u32),
1304    #[doc = "data range from"]
1305    FromData(IterableDataAttrs<'a>),
1306    #[doc = "data range to"]
1307    ToData(IterableDataAttrs<'a>),
1308}
1309impl<'a> IterableRangeAttrs<'a> {
1310    #[doc = "source register of data to compare\nAssociated type: [`Registers`] (enum)"]
1311    pub fn get_sreg(&self) -> Result<u32, ErrorContext> {
1312        let mut iter = self.clone();
1313        iter.pos = 0;
1314        for attr in iter {
1315            if let RangeAttrs::Sreg(val) = attr? {
1316                return Ok(val);
1317            }
1318        }
1319        Err(ErrorContext::new_missing(
1320            "RangeAttrs",
1321            "Sreg",
1322            self.orig_loc,
1323            self.buf.as_ptr() as usize,
1324        ))
1325    }
1326    #[doc = "cmp operation\nAssociated type: [`RangeOps`] (enum)"]
1327    pub fn get_op(&self) -> Result<u32, ErrorContext> {
1328        let mut iter = self.clone();
1329        iter.pos = 0;
1330        for attr in iter {
1331            if let RangeAttrs::Op(val) = attr? {
1332                return Ok(val);
1333            }
1334        }
1335        Err(ErrorContext::new_missing(
1336            "RangeAttrs",
1337            "Op",
1338            self.orig_loc,
1339            self.buf.as_ptr() as usize,
1340        ))
1341    }
1342    #[doc = "data range from"]
1343    pub fn get_from_data(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
1344        let mut iter = self.clone();
1345        iter.pos = 0;
1346        for attr in iter {
1347            if let RangeAttrs::FromData(val) = attr? {
1348                return Ok(val);
1349            }
1350        }
1351        Err(ErrorContext::new_missing(
1352            "RangeAttrs",
1353            "FromData",
1354            self.orig_loc,
1355            self.buf.as_ptr() as usize,
1356        ))
1357    }
1358    #[doc = "data range to"]
1359    pub fn get_to_data(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
1360        let mut iter = self.clone();
1361        iter.pos = 0;
1362        for attr in iter {
1363            if let RangeAttrs::ToData(val) = attr? {
1364                return Ok(val);
1365            }
1366        }
1367        Err(ErrorContext::new_missing(
1368            "RangeAttrs",
1369            "ToData",
1370            self.orig_loc,
1371            self.buf.as_ptr() as usize,
1372        ))
1373    }
1374}
1375impl RangeAttrs<'_> {
1376    pub fn new<'a>(buf: &'a [u8]) -> IterableRangeAttrs<'a> {
1377        IterableRangeAttrs::with_loc(buf, buf.as_ptr() as usize)
1378    }
1379    fn attr_from_type(r#type: u16) -> Option<&'static str> {
1380        let res = match r#type {
1381            1u16 => "Sreg",
1382            2u16 => "Op",
1383            3u16 => "FromData",
1384            4u16 => "ToData",
1385            _ => return None,
1386        };
1387        Some(res)
1388    }
1389}
1390#[derive(Clone, Copy, Default)]
1391pub struct IterableRangeAttrs<'a> {
1392    buf: &'a [u8],
1393    pos: usize,
1394    orig_loc: usize,
1395}
1396impl<'a> IterableRangeAttrs<'a> {
1397    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1398        Self {
1399            buf,
1400            pos: 0,
1401            orig_loc,
1402        }
1403    }
1404    pub fn get_buf(&self) -> &'a [u8] {
1405        self.buf
1406    }
1407}
1408impl<'a> Iterator for IterableRangeAttrs<'a> {
1409    type Item = Result<RangeAttrs<'a>, ErrorContext>;
1410    fn next(&mut self) -> Option<Self::Item> {
1411        let pos = self.pos;
1412        let mut r#type;
1413        loop {
1414            r#type = None;
1415            if self.buf.len() == self.pos {
1416                return None;
1417            }
1418            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1419                break;
1420            };
1421            r#type = Some(header.r#type);
1422            let res = match header.r#type {
1423                1u16 => RangeAttrs::Sreg({
1424                    let res = parse_be_u32(next);
1425                    let Some(val) = res else { break };
1426                    val
1427                }),
1428                2u16 => RangeAttrs::Op({
1429                    let res = parse_be_u32(next);
1430                    let Some(val) = res else { break };
1431                    val
1432                }),
1433                3u16 => RangeAttrs::FromData({
1434                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
1435                    let Some(val) = res else { break };
1436                    val
1437                }),
1438                4u16 => RangeAttrs::ToData({
1439                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
1440                    let Some(val) = res else { break };
1441                    val
1442                }),
1443                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
1444                n => continue,
1445            };
1446            return Some(Ok(res));
1447        }
1448        Some(Err(ErrorContext::new(
1449            "RangeAttrs",
1450            r#type.and_then(|t| RangeAttrs::attr_from_type(t)),
1451            self.orig_loc,
1452            self.buf.as_ptr().wrapping_add(pos) as usize,
1453        )))
1454    }
1455}
1456impl<'a> std::fmt::Debug for IterableRangeAttrs<'_> {
1457    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1458        let mut fmt = f.debug_struct("RangeAttrs");
1459        for attr in self.clone() {
1460            let attr = match attr {
1461                Ok(a) => a,
1462                Err(err) => {
1463                    fmt.finish()?;
1464                    f.write_str("Err(")?;
1465                    err.fmt(f)?;
1466                    return f.write_str(")");
1467                }
1468            };
1469            match attr {
1470                RangeAttrs::Sreg(val) => {
1471                    fmt.field("Sreg", &FormatEnum(val.into(), Registers::from_value))
1472                }
1473                RangeAttrs::Op(val) => {
1474                    fmt.field("Op", &FormatEnum(val.into(), RangeOps::from_value))
1475                }
1476                RangeAttrs::FromData(val) => fmt.field("FromData", &val),
1477                RangeAttrs::ToData(val) => fmt.field("ToData", &val),
1478            };
1479        }
1480        fmt.finish()
1481    }
1482}
1483impl IterableRangeAttrs<'_> {
1484    pub fn lookup_attr(
1485        &self,
1486        offset: usize,
1487        missing_type: Option<u16>,
1488    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
1489        let mut stack = Vec::new();
1490        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
1491        if missing_type.is_some() && cur == offset {
1492            stack.push(("RangeAttrs", offset));
1493            return (
1494                stack,
1495                missing_type.and_then(|t| RangeAttrs::attr_from_type(t)),
1496            );
1497        }
1498        if cur > offset || cur + self.buf.len() < offset {
1499            return (stack, None);
1500        }
1501        let mut attrs = self.clone();
1502        let mut last_off = cur + attrs.pos;
1503        let mut missing = None;
1504        while let Some(attr) = attrs.next() {
1505            let Ok(attr) = attr else { break };
1506            match attr {
1507                RangeAttrs::Sreg(val) => {
1508                    if last_off == offset {
1509                        stack.push(("Sreg", last_off));
1510                        break;
1511                    }
1512                }
1513                RangeAttrs::Op(val) => {
1514                    if last_off == offset {
1515                        stack.push(("Op", last_off));
1516                        break;
1517                    }
1518                }
1519                RangeAttrs::FromData(val) => {
1520                    (stack, missing) = val.lookup_attr(offset, missing_type);
1521                    if !stack.is_empty() {
1522                        break;
1523                    }
1524                }
1525                RangeAttrs::ToData(val) => {
1526                    (stack, missing) = val.lookup_attr(offset, missing_type);
1527                    if !stack.is_empty() {
1528                        break;
1529                    }
1530                }
1531                _ => {}
1532            };
1533            last_off = cur + attrs.pos;
1534        }
1535        if !stack.is_empty() {
1536            stack.push(("RangeAttrs", cur));
1537        }
1538        (stack, missing)
1539    }
1540}
1541#[derive(Clone)]
1542pub enum BatchAttrs {
1543    #[doc = "generation ID for this changeset"]
1544    Genid(u32),
1545}
1546impl<'a> IterableBatchAttrs<'a> {
1547    #[doc = "generation ID for this changeset"]
1548    pub fn get_genid(&self) -> Result<u32, ErrorContext> {
1549        let mut iter = self.clone();
1550        iter.pos = 0;
1551        for attr in iter {
1552            if let BatchAttrs::Genid(val) = attr? {
1553                return Ok(val);
1554            }
1555        }
1556        Err(ErrorContext::new_missing(
1557            "BatchAttrs",
1558            "Genid",
1559            self.orig_loc,
1560            self.buf.as_ptr() as usize,
1561        ))
1562    }
1563}
1564impl BatchAttrs {
1565    pub fn new<'a>(buf: &'a [u8]) -> IterableBatchAttrs<'a> {
1566        IterableBatchAttrs::with_loc(buf, buf.as_ptr() as usize)
1567    }
1568    fn attr_from_type(r#type: u16) -> Option<&'static str> {
1569        let res = match r#type {
1570            1u16 => "Genid",
1571            _ => return None,
1572        };
1573        Some(res)
1574    }
1575}
1576#[derive(Clone, Copy, Default)]
1577pub struct IterableBatchAttrs<'a> {
1578    buf: &'a [u8],
1579    pos: usize,
1580    orig_loc: usize,
1581}
1582impl<'a> IterableBatchAttrs<'a> {
1583    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1584        Self {
1585            buf,
1586            pos: 0,
1587            orig_loc,
1588        }
1589    }
1590    pub fn get_buf(&self) -> &'a [u8] {
1591        self.buf
1592    }
1593}
1594impl<'a> Iterator for IterableBatchAttrs<'a> {
1595    type Item = Result<BatchAttrs, ErrorContext>;
1596    fn next(&mut self) -> Option<Self::Item> {
1597        let pos = self.pos;
1598        let mut r#type;
1599        loop {
1600            r#type = None;
1601            if self.buf.len() == self.pos {
1602                return None;
1603            }
1604            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1605                break;
1606            };
1607            r#type = Some(header.r#type);
1608            let res = match header.r#type {
1609                1u16 => BatchAttrs::Genid({
1610                    let res = parse_be_u32(next);
1611                    let Some(val) = res else { break };
1612                    val
1613                }),
1614                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
1615                n => continue,
1616            };
1617            return Some(Ok(res));
1618        }
1619        Some(Err(ErrorContext::new(
1620            "BatchAttrs",
1621            r#type.and_then(|t| BatchAttrs::attr_from_type(t)),
1622            self.orig_loc,
1623            self.buf.as_ptr().wrapping_add(pos) as usize,
1624        )))
1625    }
1626}
1627impl std::fmt::Debug for IterableBatchAttrs<'_> {
1628    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1629        let mut fmt = f.debug_struct("BatchAttrs");
1630        for attr in self.clone() {
1631            let attr = match attr {
1632                Ok(a) => a,
1633                Err(err) => {
1634                    fmt.finish()?;
1635                    f.write_str("Err(")?;
1636                    err.fmt(f)?;
1637                    return f.write_str(")");
1638                }
1639            };
1640            match attr {
1641                BatchAttrs::Genid(val) => fmt.field("Genid", &val),
1642            };
1643        }
1644        fmt.finish()
1645    }
1646}
1647impl IterableBatchAttrs<'_> {
1648    pub fn lookup_attr(
1649        &self,
1650        offset: usize,
1651        missing_type: Option<u16>,
1652    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
1653        let mut stack = Vec::new();
1654        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
1655        if missing_type.is_some() && cur == offset {
1656            stack.push(("BatchAttrs", offset));
1657            return (
1658                stack,
1659                missing_type.and_then(|t| BatchAttrs::attr_from_type(t)),
1660            );
1661        }
1662        if cur > offset || cur + self.buf.len() < offset {
1663            return (stack, None);
1664        }
1665        let mut attrs = self.clone();
1666        let mut last_off = cur + attrs.pos;
1667        while let Some(attr) = attrs.next() {
1668            let Ok(attr) = attr else { break };
1669            match attr {
1670                BatchAttrs::Genid(val) => {
1671                    if last_off == offset {
1672                        stack.push(("Genid", last_off));
1673                        break;
1674                    }
1675                }
1676                _ => {}
1677            };
1678            last_off = cur + attrs.pos;
1679        }
1680        if !stack.is_empty() {
1681            stack.push(("BatchAttrs", cur));
1682        }
1683        (stack, None)
1684    }
1685}
1686#[derive(Clone)]
1687pub enum TableAttrs<'a> {
1688    #[doc = "name of the table"]
1689    Name(&'a CStr),
1690    #[doc = "bitmask of flags\nAssociated type: [`TableFlags`] (1 bit per enumeration)"]
1691    Flags(u32),
1692    #[doc = "number of chains in this table"]
1693    Use(u32),
1694    #[doc = "numeric handle of the table"]
1695    Handle(u64),
1696    Pad(&'a [u8]),
1697    #[doc = "user data"]
1698    Userdata(&'a [u8]),
1699    #[doc = "owner of this table through netlink portID"]
1700    Owner(u32),
1701}
1702impl<'a> IterableTableAttrs<'a> {
1703    #[doc = "name of the table"]
1704    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
1705        let mut iter = self.clone();
1706        iter.pos = 0;
1707        for attr in iter {
1708            if let TableAttrs::Name(val) = attr? {
1709                return Ok(val);
1710            }
1711        }
1712        Err(ErrorContext::new_missing(
1713            "TableAttrs",
1714            "Name",
1715            self.orig_loc,
1716            self.buf.as_ptr() as usize,
1717        ))
1718    }
1719    #[doc = "bitmask of flags\nAssociated type: [`TableFlags`] (1 bit per enumeration)"]
1720    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
1721        let mut iter = self.clone();
1722        iter.pos = 0;
1723        for attr in iter {
1724            if let TableAttrs::Flags(val) = attr? {
1725                return Ok(val);
1726            }
1727        }
1728        Err(ErrorContext::new_missing(
1729            "TableAttrs",
1730            "Flags",
1731            self.orig_loc,
1732            self.buf.as_ptr() as usize,
1733        ))
1734    }
1735    #[doc = "number of chains in this table"]
1736    pub fn get_use(&self) -> Result<u32, ErrorContext> {
1737        let mut iter = self.clone();
1738        iter.pos = 0;
1739        for attr in iter {
1740            if let TableAttrs::Use(val) = attr? {
1741                return Ok(val);
1742            }
1743        }
1744        Err(ErrorContext::new_missing(
1745            "TableAttrs",
1746            "Use",
1747            self.orig_loc,
1748            self.buf.as_ptr() as usize,
1749        ))
1750    }
1751    #[doc = "numeric handle of the table"]
1752    pub fn get_handle(&self) -> Result<u64, ErrorContext> {
1753        let mut iter = self.clone();
1754        iter.pos = 0;
1755        for attr in iter {
1756            if let TableAttrs::Handle(val) = attr? {
1757                return Ok(val);
1758            }
1759        }
1760        Err(ErrorContext::new_missing(
1761            "TableAttrs",
1762            "Handle",
1763            self.orig_loc,
1764            self.buf.as_ptr() as usize,
1765        ))
1766    }
1767    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
1768        let mut iter = self.clone();
1769        iter.pos = 0;
1770        for attr in iter {
1771            if let TableAttrs::Pad(val) = attr? {
1772                return Ok(val);
1773            }
1774        }
1775        Err(ErrorContext::new_missing(
1776            "TableAttrs",
1777            "Pad",
1778            self.orig_loc,
1779            self.buf.as_ptr() as usize,
1780        ))
1781    }
1782    #[doc = "user data"]
1783    pub fn get_userdata(&self) -> Result<&'a [u8], ErrorContext> {
1784        let mut iter = self.clone();
1785        iter.pos = 0;
1786        for attr in iter {
1787            if let TableAttrs::Userdata(val) = attr? {
1788                return Ok(val);
1789            }
1790        }
1791        Err(ErrorContext::new_missing(
1792            "TableAttrs",
1793            "Userdata",
1794            self.orig_loc,
1795            self.buf.as_ptr() as usize,
1796        ))
1797    }
1798    #[doc = "owner of this table through netlink portID"]
1799    pub fn get_owner(&self) -> Result<u32, ErrorContext> {
1800        let mut iter = self.clone();
1801        iter.pos = 0;
1802        for attr in iter {
1803            if let TableAttrs::Owner(val) = attr? {
1804                return Ok(val);
1805            }
1806        }
1807        Err(ErrorContext::new_missing(
1808            "TableAttrs",
1809            "Owner",
1810            self.orig_loc,
1811            self.buf.as_ptr() as usize,
1812        ))
1813    }
1814}
1815impl TableAttrs<'_> {
1816    pub fn new<'a>(buf: &'a [u8]) -> IterableTableAttrs<'a> {
1817        IterableTableAttrs::with_loc(buf, buf.as_ptr() as usize)
1818    }
1819    fn attr_from_type(r#type: u16) -> Option<&'static str> {
1820        let res = match r#type {
1821            1u16 => "Name",
1822            2u16 => "Flags",
1823            3u16 => "Use",
1824            4u16 => "Handle",
1825            5u16 => "Pad",
1826            6u16 => "Userdata",
1827            7u16 => "Owner",
1828            _ => return None,
1829        };
1830        Some(res)
1831    }
1832}
1833#[derive(Clone, Copy, Default)]
1834pub struct IterableTableAttrs<'a> {
1835    buf: &'a [u8],
1836    pos: usize,
1837    orig_loc: usize,
1838}
1839impl<'a> IterableTableAttrs<'a> {
1840    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1841        Self {
1842            buf,
1843            pos: 0,
1844            orig_loc,
1845        }
1846    }
1847    pub fn get_buf(&self) -> &'a [u8] {
1848        self.buf
1849    }
1850}
1851impl<'a> Iterator for IterableTableAttrs<'a> {
1852    type Item = Result<TableAttrs<'a>, ErrorContext>;
1853    fn next(&mut self) -> Option<Self::Item> {
1854        let pos = self.pos;
1855        let mut r#type;
1856        loop {
1857            r#type = None;
1858            if self.buf.len() == self.pos {
1859                return None;
1860            }
1861            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1862                break;
1863            };
1864            r#type = Some(header.r#type);
1865            let res = match header.r#type {
1866                1u16 => TableAttrs::Name({
1867                    let res = CStr::from_bytes_with_nul(next).ok();
1868                    let Some(val) = res else { break };
1869                    val
1870                }),
1871                2u16 => TableAttrs::Flags({
1872                    let res = parse_be_u32(next);
1873                    let Some(val) = res else { break };
1874                    val
1875                }),
1876                3u16 => TableAttrs::Use({
1877                    let res = parse_be_u32(next);
1878                    let Some(val) = res else { break };
1879                    val
1880                }),
1881                4u16 => TableAttrs::Handle({
1882                    let res = parse_be_u64(next);
1883                    let Some(val) = res else { break };
1884                    val
1885                }),
1886                5u16 => TableAttrs::Pad({
1887                    let res = Some(next);
1888                    let Some(val) = res else { break };
1889                    val
1890                }),
1891                6u16 => TableAttrs::Userdata({
1892                    let res = Some(next);
1893                    let Some(val) = res else { break };
1894                    val
1895                }),
1896                7u16 => TableAttrs::Owner({
1897                    let res = parse_be_u32(next);
1898                    let Some(val) = res else { break };
1899                    val
1900                }),
1901                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
1902                n => continue,
1903            };
1904            return Some(Ok(res));
1905        }
1906        Some(Err(ErrorContext::new(
1907            "TableAttrs",
1908            r#type.and_then(|t| TableAttrs::attr_from_type(t)),
1909            self.orig_loc,
1910            self.buf.as_ptr().wrapping_add(pos) as usize,
1911        )))
1912    }
1913}
1914impl<'a> std::fmt::Debug for IterableTableAttrs<'_> {
1915    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1916        let mut fmt = f.debug_struct("TableAttrs");
1917        for attr in self.clone() {
1918            let attr = match attr {
1919                Ok(a) => a,
1920                Err(err) => {
1921                    fmt.finish()?;
1922                    f.write_str("Err(")?;
1923                    err.fmt(f)?;
1924                    return f.write_str(")");
1925                }
1926            };
1927            match attr {
1928                TableAttrs::Name(val) => fmt.field("Name", &val),
1929                TableAttrs::Flags(val) => {
1930                    fmt.field("Flags", &FormatFlags(val.into(), TableFlags::from_value))
1931                }
1932                TableAttrs::Use(val) => fmt.field("Use", &val),
1933                TableAttrs::Handle(val) => fmt.field("Handle", &val),
1934                TableAttrs::Pad(val) => fmt.field("Pad", &val),
1935                TableAttrs::Userdata(val) => fmt.field("Userdata", &val),
1936                TableAttrs::Owner(val) => fmt.field("Owner", &val),
1937            };
1938        }
1939        fmt.finish()
1940    }
1941}
1942impl IterableTableAttrs<'_> {
1943    pub fn lookup_attr(
1944        &self,
1945        offset: usize,
1946        missing_type: Option<u16>,
1947    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
1948        let mut stack = Vec::new();
1949        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
1950        if missing_type.is_some() && cur == offset {
1951            stack.push(("TableAttrs", offset));
1952            return (
1953                stack,
1954                missing_type.and_then(|t| TableAttrs::attr_from_type(t)),
1955            );
1956        }
1957        if cur > offset || cur + self.buf.len() < offset {
1958            return (stack, None);
1959        }
1960        let mut attrs = self.clone();
1961        let mut last_off = cur + attrs.pos;
1962        while let Some(attr) = attrs.next() {
1963            let Ok(attr) = attr else { break };
1964            match attr {
1965                TableAttrs::Name(val) => {
1966                    if last_off == offset {
1967                        stack.push(("Name", last_off));
1968                        break;
1969                    }
1970                }
1971                TableAttrs::Flags(val) => {
1972                    if last_off == offset {
1973                        stack.push(("Flags", last_off));
1974                        break;
1975                    }
1976                }
1977                TableAttrs::Use(val) => {
1978                    if last_off == offset {
1979                        stack.push(("Use", last_off));
1980                        break;
1981                    }
1982                }
1983                TableAttrs::Handle(val) => {
1984                    if last_off == offset {
1985                        stack.push(("Handle", last_off));
1986                        break;
1987                    }
1988                }
1989                TableAttrs::Pad(val) => {
1990                    if last_off == offset {
1991                        stack.push(("Pad", last_off));
1992                        break;
1993                    }
1994                }
1995                TableAttrs::Userdata(val) => {
1996                    if last_off == offset {
1997                        stack.push(("Userdata", last_off));
1998                        break;
1999                    }
2000                }
2001                TableAttrs::Owner(val) => {
2002                    if last_off == offset {
2003                        stack.push(("Owner", last_off));
2004                        break;
2005                    }
2006                }
2007                _ => {}
2008            };
2009            last_off = cur + attrs.pos;
2010        }
2011        if !stack.is_empty() {
2012            stack.push(("TableAttrs", cur));
2013        }
2014        (stack, None)
2015    }
2016}
2017#[derive(Clone)]
2018pub enum ChainAttrs<'a> {
2019    #[doc = "name of the table containing the chain"]
2020    Table(&'a CStr),
2021    #[doc = "numeric handle of the chain"]
2022    Handle(u64),
2023    #[doc = "name of the chain"]
2024    Name(&'a CStr),
2025    #[doc = "hook specification for basechains"]
2026    Hook(IterableNftHookAttrs<'a>),
2027    #[doc = "numeric policy of the chain"]
2028    Policy(u32),
2029    #[doc = "number of references to this chain"]
2030    Use(u32),
2031    #[doc = "type name of the chain"]
2032    Type(&'a CStr),
2033    #[doc = "counter specification of the chain"]
2034    Counters(IterableNftCounterAttrs<'a>),
2035    #[doc = "chain flags\nAssociated type: [`ChainFlags`] (1 bit per enumeration)"]
2036    Flags(u32),
2037    #[doc = "uniquely identifies a chain in a transaction"]
2038    Id(u32),
2039    #[doc = "user data"]
2040    Userdata(&'a [u8]),
2041}
2042impl<'a> IterableChainAttrs<'a> {
2043    #[doc = "name of the table containing the chain"]
2044    pub fn get_table(&self) -> Result<&'a CStr, ErrorContext> {
2045        let mut iter = self.clone();
2046        iter.pos = 0;
2047        for attr in iter {
2048            if let ChainAttrs::Table(val) = attr? {
2049                return Ok(val);
2050            }
2051        }
2052        Err(ErrorContext::new_missing(
2053            "ChainAttrs",
2054            "Table",
2055            self.orig_loc,
2056            self.buf.as_ptr() as usize,
2057        ))
2058    }
2059    #[doc = "numeric handle of the chain"]
2060    pub fn get_handle(&self) -> Result<u64, ErrorContext> {
2061        let mut iter = self.clone();
2062        iter.pos = 0;
2063        for attr in iter {
2064            if let ChainAttrs::Handle(val) = attr? {
2065                return Ok(val);
2066            }
2067        }
2068        Err(ErrorContext::new_missing(
2069            "ChainAttrs",
2070            "Handle",
2071            self.orig_loc,
2072            self.buf.as_ptr() as usize,
2073        ))
2074    }
2075    #[doc = "name of the chain"]
2076    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
2077        let mut iter = self.clone();
2078        iter.pos = 0;
2079        for attr in iter {
2080            if let ChainAttrs::Name(val) = attr? {
2081                return Ok(val);
2082            }
2083        }
2084        Err(ErrorContext::new_missing(
2085            "ChainAttrs",
2086            "Name",
2087            self.orig_loc,
2088            self.buf.as_ptr() as usize,
2089        ))
2090    }
2091    #[doc = "hook specification for basechains"]
2092    pub fn get_hook(&self) -> Result<IterableNftHookAttrs<'a>, ErrorContext> {
2093        let mut iter = self.clone();
2094        iter.pos = 0;
2095        for attr in iter {
2096            if let ChainAttrs::Hook(val) = attr? {
2097                return Ok(val);
2098            }
2099        }
2100        Err(ErrorContext::new_missing(
2101            "ChainAttrs",
2102            "Hook",
2103            self.orig_loc,
2104            self.buf.as_ptr() as usize,
2105        ))
2106    }
2107    #[doc = "numeric policy of the chain"]
2108    pub fn get_policy(&self) -> Result<u32, ErrorContext> {
2109        let mut iter = self.clone();
2110        iter.pos = 0;
2111        for attr in iter {
2112            if let ChainAttrs::Policy(val) = attr? {
2113                return Ok(val);
2114            }
2115        }
2116        Err(ErrorContext::new_missing(
2117            "ChainAttrs",
2118            "Policy",
2119            self.orig_loc,
2120            self.buf.as_ptr() as usize,
2121        ))
2122    }
2123    #[doc = "number of references to this chain"]
2124    pub fn get_use(&self) -> Result<u32, ErrorContext> {
2125        let mut iter = self.clone();
2126        iter.pos = 0;
2127        for attr in iter {
2128            if let ChainAttrs::Use(val) = attr? {
2129                return Ok(val);
2130            }
2131        }
2132        Err(ErrorContext::new_missing(
2133            "ChainAttrs",
2134            "Use",
2135            self.orig_loc,
2136            self.buf.as_ptr() as usize,
2137        ))
2138    }
2139    #[doc = "type name of the chain"]
2140    pub fn get_type(&self) -> Result<&'a CStr, ErrorContext> {
2141        let mut iter = self.clone();
2142        iter.pos = 0;
2143        for attr in iter {
2144            if let ChainAttrs::Type(val) = attr? {
2145                return Ok(val);
2146            }
2147        }
2148        Err(ErrorContext::new_missing(
2149            "ChainAttrs",
2150            "Type",
2151            self.orig_loc,
2152            self.buf.as_ptr() as usize,
2153        ))
2154    }
2155    #[doc = "counter specification of the chain"]
2156    pub fn get_counters(&self) -> Result<IterableNftCounterAttrs<'a>, ErrorContext> {
2157        let mut iter = self.clone();
2158        iter.pos = 0;
2159        for attr in iter {
2160            if let ChainAttrs::Counters(val) = attr? {
2161                return Ok(val);
2162            }
2163        }
2164        Err(ErrorContext::new_missing(
2165            "ChainAttrs",
2166            "Counters",
2167            self.orig_loc,
2168            self.buf.as_ptr() as usize,
2169        ))
2170    }
2171    #[doc = "chain flags\nAssociated type: [`ChainFlags`] (1 bit per enumeration)"]
2172    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
2173        let mut iter = self.clone();
2174        iter.pos = 0;
2175        for attr in iter {
2176            if let ChainAttrs::Flags(val) = attr? {
2177                return Ok(val);
2178            }
2179        }
2180        Err(ErrorContext::new_missing(
2181            "ChainAttrs",
2182            "Flags",
2183            self.orig_loc,
2184            self.buf.as_ptr() as usize,
2185        ))
2186    }
2187    #[doc = "uniquely identifies a chain in a transaction"]
2188    pub fn get_id(&self) -> Result<u32, ErrorContext> {
2189        let mut iter = self.clone();
2190        iter.pos = 0;
2191        for attr in iter {
2192            if let ChainAttrs::Id(val) = attr? {
2193                return Ok(val);
2194            }
2195        }
2196        Err(ErrorContext::new_missing(
2197            "ChainAttrs",
2198            "Id",
2199            self.orig_loc,
2200            self.buf.as_ptr() as usize,
2201        ))
2202    }
2203    #[doc = "user data"]
2204    pub fn get_userdata(&self) -> Result<&'a [u8], ErrorContext> {
2205        let mut iter = self.clone();
2206        iter.pos = 0;
2207        for attr in iter {
2208            if let ChainAttrs::Userdata(val) = attr? {
2209                return Ok(val);
2210            }
2211        }
2212        Err(ErrorContext::new_missing(
2213            "ChainAttrs",
2214            "Userdata",
2215            self.orig_loc,
2216            self.buf.as_ptr() as usize,
2217        ))
2218    }
2219}
2220impl ChainAttrs<'_> {
2221    pub fn new<'a>(buf: &'a [u8]) -> IterableChainAttrs<'a> {
2222        IterableChainAttrs::with_loc(buf, buf.as_ptr() as usize)
2223    }
2224    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2225        let res = match r#type {
2226            1u16 => "Table",
2227            2u16 => "Handle",
2228            3u16 => "Name",
2229            4u16 => "Hook",
2230            5u16 => "Policy",
2231            6u16 => "Use",
2232            7u16 => "Type",
2233            8u16 => "Counters",
2234            9u16 => "Flags",
2235            10u16 => "Id",
2236            11u16 => "Userdata",
2237            _ => return None,
2238        };
2239        Some(res)
2240    }
2241}
2242#[derive(Clone, Copy, Default)]
2243pub struct IterableChainAttrs<'a> {
2244    buf: &'a [u8],
2245    pos: usize,
2246    orig_loc: usize,
2247}
2248impl<'a> IterableChainAttrs<'a> {
2249    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2250        Self {
2251            buf,
2252            pos: 0,
2253            orig_loc,
2254        }
2255    }
2256    pub fn get_buf(&self) -> &'a [u8] {
2257        self.buf
2258    }
2259}
2260impl<'a> Iterator for IterableChainAttrs<'a> {
2261    type Item = Result<ChainAttrs<'a>, ErrorContext>;
2262    fn next(&mut self) -> Option<Self::Item> {
2263        let pos = self.pos;
2264        let mut r#type;
2265        loop {
2266            r#type = None;
2267            if self.buf.len() == self.pos {
2268                return None;
2269            }
2270            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2271                break;
2272            };
2273            r#type = Some(header.r#type);
2274            let res = match header.r#type {
2275                1u16 => ChainAttrs::Table({
2276                    let res = CStr::from_bytes_with_nul(next).ok();
2277                    let Some(val) = res else { break };
2278                    val
2279                }),
2280                2u16 => ChainAttrs::Handle({
2281                    let res = parse_be_u64(next);
2282                    let Some(val) = res else { break };
2283                    val
2284                }),
2285                3u16 => ChainAttrs::Name({
2286                    let res = CStr::from_bytes_with_nul(next).ok();
2287                    let Some(val) = res else { break };
2288                    val
2289                }),
2290                4u16 => ChainAttrs::Hook({
2291                    let res = Some(IterableNftHookAttrs::with_loc(next, self.orig_loc));
2292                    let Some(val) = res else { break };
2293                    val
2294                }),
2295                5u16 => ChainAttrs::Policy({
2296                    let res = parse_be_u32(next);
2297                    let Some(val) = res else { break };
2298                    val
2299                }),
2300                6u16 => ChainAttrs::Use({
2301                    let res = parse_be_u32(next);
2302                    let Some(val) = res else { break };
2303                    val
2304                }),
2305                7u16 => ChainAttrs::Type({
2306                    let res = CStr::from_bytes_with_nul(next).ok();
2307                    let Some(val) = res else { break };
2308                    val
2309                }),
2310                8u16 => ChainAttrs::Counters({
2311                    let res = Some(IterableNftCounterAttrs::with_loc(next, self.orig_loc));
2312                    let Some(val) = res else { break };
2313                    val
2314                }),
2315                9u16 => ChainAttrs::Flags({
2316                    let res = parse_be_u32(next);
2317                    let Some(val) = res else { break };
2318                    val
2319                }),
2320                10u16 => ChainAttrs::Id({
2321                    let res = parse_be_u32(next);
2322                    let Some(val) = res else { break };
2323                    val
2324                }),
2325                11u16 => ChainAttrs::Userdata({
2326                    let res = Some(next);
2327                    let Some(val) = res else { break };
2328                    val
2329                }),
2330                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2331                n => continue,
2332            };
2333            return Some(Ok(res));
2334        }
2335        Some(Err(ErrorContext::new(
2336            "ChainAttrs",
2337            r#type.and_then(|t| ChainAttrs::attr_from_type(t)),
2338            self.orig_loc,
2339            self.buf.as_ptr().wrapping_add(pos) as usize,
2340        )))
2341    }
2342}
2343impl<'a> std::fmt::Debug for IterableChainAttrs<'_> {
2344    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2345        let mut fmt = f.debug_struct("ChainAttrs");
2346        for attr in self.clone() {
2347            let attr = match attr {
2348                Ok(a) => a,
2349                Err(err) => {
2350                    fmt.finish()?;
2351                    f.write_str("Err(")?;
2352                    err.fmt(f)?;
2353                    return f.write_str(")");
2354                }
2355            };
2356            match attr {
2357                ChainAttrs::Table(val) => fmt.field("Table", &val),
2358                ChainAttrs::Handle(val) => fmt.field("Handle", &val),
2359                ChainAttrs::Name(val) => fmt.field("Name", &val),
2360                ChainAttrs::Hook(val) => fmt.field("Hook", &val),
2361                ChainAttrs::Policy(val) => fmt.field("Policy", &val),
2362                ChainAttrs::Use(val) => fmt.field("Use", &val),
2363                ChainAttrs::Type(val) => fmt.field("Type", &val),
2364                ChainAttrs::Counters(val) => fmt.field("Counters", &val),
2365                ChainAttrs::Flags(val) => {
2366                    fmt.field("Flags", &FormatFlags(val.into(), ChainFlags::from_value))
2367                }
2368                ChainAttrs::Id(val) => fmt.field("Id", &val),
2369                ChainAttrs::Userdata(val) => fmt.field("Userdata", &val),
2370            };
2371        }
2372        fmt.finish()
2373    }
2374}
2375impl IterableChainAttrs<'_> {
2376    pub fn lookup_attr(
2377        &self,
2378        offset: usize,
2379        missing_type: Option<u16>,
2380    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2381        let mut stack = Vec::new();
2382        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2383        if missing_type.is_some() && cur == offset {
2384            stack.push(("ChainAttrs", offset));
2385            return (
2386                stack,
2387                missing_type.and_then(|t| ChainAttrs::attr_from_type(t)),
2388            );
2389        }
2390        if cur > offset || cur + self.buf.len() < offset {
2391            return (stack, None);
2392        }
2393        let mut attrs = self.clone();
2394        let mut last_off = cur + attrs.pos;
2395        let mut missing = None;
2396        while let Some(attr) = attrs.next() {
2397            let Ok(attr) = attr else { break };
2398            match attr {
2399                ChainAttrs::Table(val) => {
2400                    if last_off == offset {
2401                        stack.push(("Table", last_off));
2402                        break;
2403                    }
2404                }
2405                ChainAttrs::Handle(val) => {
2406                    if last_off == offset {
2407                        stack.push(("Handle", last_off));
2408                        break;
2409                    }
2410                }
2411                ChainAttrs::Name(val) => {
2412                    if last_off == offset {
2413                        stack.push(("Name", last_off));
2414                        break;
2415                    }
2416                }
2417                ChainAttrs::Hook(val) => {
2418                    (stack, missing) = val.lookup_attr(offset, missing_type);
2419                    if !stack.is_empty() {
2420                        break;
2421                    }
2422                }
2423                ChainAttrs::Policy(val) => {
2424                    if last_off == offset {
2425                        stack.push(("Policy", last_off));
2426                        break;
2427                    }
2428                }
2429                ChainAttrs::Use(val) => {
2430                    if last_off == offset {
2431                        stack.push(("Use", last_off));
2432                        break;
2433                    }
2434                }
2435                ChainAttrs::Type(val) => {
2436                    if last_off == offset {
2437                        stack.push(("Type", last_off));
2438                        break;
2439                    }
2440                }
2441                ChainAttrs::Counters(val) => {
2442                    (stack, missing) = val.lookup_attr(offset, missing_type);
2443                    if !stack.is_empty() {
2444                        break;
2445                    }
2446                }
2447                ChainAttrs::Flags(val) => {
2448                    if last_off == offset {
2449                        stack.push(("Flags", last_off));
2450                        break;
2451                    }
2452                }
2453                ChainAttrs::Id(val) => {
2454                    if last_off == offset {
2455                        stack.push(("Id", last_off));
2456                        break;
2457                    }
2458                }
2459                ChainAttrs::Userdata(val) => {
2460                    if last_off == offset {
2461                        stack.push(("Userdata", last_off));
2462                        break;
2463                    }
2464                }
2465                _ => {}
2466            };
2467            last_off = cur + attrs.pos;
2468        }
2469        if !stack.is_empty() {
2470            stack.push(("ChainAttrs", cur));
2471        }
2472        (stack, missing)
2473    }
2474}
2475#[derive(Clone)]
2476pub enum CounterAttrs<'a> {
2477    Bytes(u64),
2478    Packets(u64),
2479    Pad(&'a [u8]),
2480}
2481impl<'a> IterableCounterAttrs<'a> {
2482    pub fn get_bytes(&self) -> Result<u64, ErrorContext> {
2483        let mut iter = self.clone();
2484        iter.pos = 0;
2485        for attr in iter {
2486            if let CounterAttrs::Bytes(val) = attr? {
2487                return Ok(val);
2488            }
2489        }
2490        Err(ErrorContext::new_missing(
2491            "CounterAttrs",
2492            "Bytes",
2493            self.orig_loc,
2494            self.buf.as_ptr() as usize,
2495        ))
2496    }
2497    pub fn get_packets(&self) -> Result<u64, ErrorContext> {
2498        let mut iter = self.clone();
2499        iter.pos = 0;
2500        for attr in iter {
2501            if let CounterAttrs::Packets(val) = attr? {
2502                return Ok(val);
2503            }
2504        }
2505        Err(ErrorContext::new_missing(
2506            "CounterAttrs",
2507            "Packets",
2508            self.orig_loc,
2509            self.buf.as_ptr() as usize,
2510        ))
2511    }
2512    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
2513        let mut iter = self.clone();
2514        iter.pos = 0;
2515        for attr in iter {
2516            if let CounterAttrs::Pad(val) = attr? {
2517                return Ok(val);
2518            }
2519        }
2520        Err(ErrorContext::new_missing(
2521            "CounterAttrs",
2522            "Pad",
2523            self.orig_loc,
2524            self.buf.as_ptr() as usize,
2525        ))
2526    }
2527}
2528impl CounterAttrs<'_> {
2529    pub fn new<'a>(buf: &'a [u8]) -> IterableCounterAttrs<'a> {
2530        IterableCounterAttrs::with_loc(buf, buf.as_ptr() as usize)
2531    }
2532    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2533        let res = match r#type {
2534            1u16 => "Bytes",
2535            2u16 => "Packets",
2536            3u16 => "Pad",
2537            _ => return None,
2538        };
2539        Some(res)
2540    }
2541}
2542#[derive(Clone, Copy, Default)]
2543pub struct IterableCounterAttrs<'a> {
2544    buf: &'a [u8],
2545    pos: usize,
2546    orig_loc: usize,
2547}
2548impl<'a> IterableCounterAttrs<'a> {
2549    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2550        Self {
2551            buf,
2552            pos: 0,
2553            orig_loc,
2554        }
2555    }
2556    pub fn get_buf(&self) -> &'a [u8] {
2557        self.buf
2558    }
2559}
2560impl<'a> Iterator for IterableCounterAttrs<'a> {
2561    type Item = Result<CounterAttrs<'a>, ErrorContext>;
2562    fn next(&mut self) -> Option<Self::Item> {
2563        let pos = self.pos;
2564        let mut r#type;
2565        loop {
2566            r#type = None;
2567            if self.buf.len() == self.pos {
2568                return None;
2569            }
2570            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2571                break;
2572            };
2573            r#type = Some(header.r#type);
2574            let res = match header.r#type {
2575                1u16 => CounterAttrs::Bytes({
2576                    let res = parse_be_u64(next);
2577                    let Some(val) = res else { break };
2578                    val
2579                }),
2580                2u16 => CounterAttrs::Packets({
2581                    let res = parse_be_u64(next);
2582                    let Some(val) = res else { break };
2583                    val
2584                }),
2585                3u16 => CounterAttrs::Pad({
2586                    let res = Some(next);
2587                    let Some(val) = res else { break };
2588                    val
2589                }),
2590                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2591                n => continue,
2592            };
2593            return Some(Ok(res));
2594        }
2595        Some(Err(ErrorContext::new(
2596            "CounterAttrs",
2597            r#type.and_then(|t| CounterAttrs::attr_from_type(t)),
2598            self.orig_loc,
2599            self.buf.as_ptr().wrapping_add(pos) as usize,
2600        )))
2601    }
2602}
2603impl<'a> std::fmt::Debug for IterableCounterAttrs<'_> {
2604    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2605        let mut fmt = f.debug_struct("CounterAttrs");
2606        for attr in self.clone() {
2607            let attr = match attr {
2608                Ok(a) => a,
2609                Err(err) => {
2610                    fmt.finish()?;
2611                    f.write_str("Err(")?;
2612                    err.fmt(f)?;
2613                    return f.write_str(")");
2614                }
2615            };
2616            match attr {
2617                CounterAttrs::Bytes(val) => fmt.field("Bytes", &val),
2618                CounterAttrs::Packets(val) => fmt.field("Packets", &val),
2619                CounterAttrs::Pad(val) => fmt.field("Pad", &val),
2620            };
2621        }
2622        fmt.finish()
2623    }
2624}
2625impl IterableCounterAttrs<'_> {
2626    pub fn lookup_attr(
2627        &self,
2628        offset: usize,
2629        missing_type: Option<u16>,
2630    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2631        let mut stack = Vec::new();
2632        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2633        if missing_type.is_some() && cur == offset {
2634            stack.push(("CounterAttrs", offset));
2635            return (
2636                stack,
2637                missing_type.and_then(|t| CounterAttrs::attr_from_type(t)),
2638            );
2639        }
2640        if cur > offset || cur + self.buf.len() < offset {
2641            return (stack, None);
2642        }
2643        let mut attrs = self.clone();
2644        let mut last_off = cur + attrs.pos;
2645        while let Some(attr) = attrs.next() {
2646            let Ok(attr) = attr else { break };
2647            match attr {
2648                CounterAttrs::Bytes(val) => {
2649                    if last_off == offset {
2650                        stack.push(("Bytes", last_off));
2651                        break;
2652                    }
2653                }
2654                CounterAttrs::Packets(val) => {
2655                    if last_off == offset {
2656                        stack.push(("Packets", last_off));
2657                        break;
2658                    }
2659                }
2660                CounterAttrs::Pad(val) => {
2661                    if last_off == offset {
2662                        stack.push(("Pad", last_off));
2663                        break;
2664                    }
2665                }
2666                _ => {}
2667            };
2668            last_off = cur + attrs.pos;
2669        }
2670        if !stack.is_empty() {
2671            stack.push(("CounterAttrs", cur));
2672        }
2673        (stack, None)
2674    }
2675}
2676#[derive(Clone)]
2677pub enum NftHookAttrs<'a> {
2678    Num(u32),
2679    Priority(i32),
2680    #[doc = "net device name"]
2681    Dev(&'a CStr),
2682    #[doc = "list of net devices"]
2683    Devs(IterableHookDevAttrs<'a>),
2684}
2685impl<'a> IterableNftHookAttrs<'a> {
2686    pub fn get_num(&self) -> Result<u32, ErrorContext> {
2687        let mut iter = self.clone();
2688        iter.pos = 0;
2689        for attr in iter {
2690            if let NftHookAttrs::Num(val) = attr? {
2691                return Ok(val);
2692            }
2693        }
2694        Err(ErrorContext::new_missing(
2695            "NftHookAttrs",
2696            "Num",
2697            self.orig_loc,
2698            self.buf.as_ptr() as usize,
2699        ))
2700    }
2701    pub fn get_priority(&self) -> Result<i32, ErrorContext> {
2702        let mut iter = self.clone();
2703        iter.pos = 0;
2704        for attr in iter {
2705            if let NftHookAttrs::Priority(val) = attr? {
2706                return Ok(val);
2707            }
2708        }
2709        Err(ErrorContext::new_missing(
2710            "NftHookAttrs",
2711            "Priority",
2712            self.orig_loc,
2713            self.buf.as_ptr() as usize,
2714        ))
2715    }
2716    #[doc = "net device name"]
2717    pub fn get_dev(&self) -> Result<&'a CStr, ErrorContext> {
2718        let mut iter = self.clone();
2719        iter.pos = 0;
2720        for attr in iter {
2721            if let NftHookAttrs::Dev(val) = attr? {
2722                return Ok(val);
2723            }
2724        }
2725        Err(ErrorContext::new_missing(
2726            "NftHookAttrs",
2727            "Dev",
2728            self.orig_loc,
2729            self.buf.as_ptr() as usize,
2730        ))
2731    }
2732    #[doc = "list of net devices"]
2733    pub fn get_devs(&self) -> Result<IterableHookDevAttrs<'a>, ErrorContext> {
2734        let mut iter = self.clone();
2735        iter.pos = 0;
2736        for attr in iter {
2737            if let NftHookAttrs::Devs(val) = attr? {
2738                return Ok(val);
2739            }
2740        }
2741        Err(ErrorContext::new_missing(
2742            "NftHookAttrs",
2743            "Devs",
2744            self.orig_loc,
2745            self.buf.as_ptr() as usize,
2746        ))
2747    }
2748}
2749impl NftHookAttrs<'_> {
2750    pub fn new<'a>(buf: &'a [u8]) -> IterableNftHookAttrs<'a> {
2751        IterableNftHookAttrs::with_loc(buf, buf.as_ptr() as usize)
2752    }
2753    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2754        let res = match r#type {
2755            1u16 => "Num",
2756            2u16 => "Priority",
2757            3u16 => "Dev",
2758            4u16 => "Devs",
2759            _ => return None,
2760        };
2761        Some(res)
2762    }
2763}
2764#[derive(Clone, Copy, Default)]
2765pub struct IterableNftHookAttrs<'a> {
2766    buf: &'a [u8],
2767    pos: usize,
2768    orig_loc: usize,
2769}
2770impl<'a> IterableNftHookAttrs<'a> {
2771    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2772        Self {
2773            buf,
2774            pos: 0,
2775            orig_loc,
2776        }
2777    }
2778    pub fn get_buf(&self) -> &'a [u8] {
2779        self.buf
2780    }
2781}
2782impl<'a> Iterator for IterableNftHookAttrs<'a> {
2783    type Item = Result<NftHookAttrs<'a>, ErrorContext>;
2784    fn next(&mut self) -> Option<Self::Item> {
2785        let pos = self.pos;
2786        let mut r#type;
2787        loop {
2788            r#type = None;
2789            if self.buf.len() == self.pos {
2790                return None;
2791            }
2792            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2793                break;
2794            };
2795            r#type = Some(header.r#type);
2796            let res = match header.r#type {
2797                1u16 => NftHookAttrs::Num({
2798                    let res = parse_be_u32(next);
2799                    let Some(val) = res else { break };
2800                    val
2801                }),
2802                2u16 => NftHookAttrs::Priority({
2803                    let res = parse_be_i32(next);
2804                    let Some(val) = res else { break };
2805                    val
2806                }),
2807                3u16 => NftHookAttrs::Dev({
2808                    let res = CStr::from_bytes_with_nul(next).ok();
2809                    let Some(val) = res else { break };
2810                    val
2811                }),
2812                4u16 => NftHookAttrs::Devs({
2813                    let res = Some(IterableHookDevAttrs::with_loc(next, self.orig_loc));
2814                    let Some(val) = res else { break };
2815                    val
2816                }),
2817                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2818                n => continue,
2819            };
2820            return Some(Ok(res));
2821        }
2822        Some(Err(ErrorContext::new(
2823            "NftHookAttrs",
2824            r#type.and_then(|t| NftHookAttrs::attr_from_type(t)),
2825            self.orig_loc,
2826            self.buf.as_ptr().wrapping_add(pos) as usize,
2827        )))
2828    }
2829}
2830impl<'a> std::fmt::Debug for IterableNftHookAttrs<'_> {
2831    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2832        let mut fmt = f.debug_struct("NftHookAttrs");
2833        for attr in self.clone() {
2834            let attr = match attr {
2835                Ok(a) => a,
2836                Err(err) => {
2837                    fmt.finish()?;
2838                    f.write_str("Err(")?;
2839                    err.fmt(f)?;
2840                    return f.write_str(")");
2841                }
2842            };
2843            match attr {
2844                NftHookAttrs::Num(val) => fmt.field("Num", &val),
2845                NftHookAttrs::Priority(val) => fmt.field("Priority", &val),
2846                NftHookAttrs::Dev(val) => fmt.field("Dev", &val),
2847                NftHookAttrs::Devs(val) => fmt.field("Devs", &val),
2848            };
2849        }
2850        fmt.finish()
2851    }
2852}
2853impl IterableNftHookAttrs<'_> {
2854    pub fn lookup_attr(
2855        &self,
2856        offset: usize,
2857        missing_type: Option<u16>,
2858    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2859        let mut stack = Vec::new();
2860        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2861        if missing_type.is_some() && cur == offset {
2862            stack.push(("NftHookAttrs", offset));
2863            return (
2864                stack,
2865                missing_type.and_then(|t| NftHookAttrs::attr_from_type(t)),
2866            );
2867        }
2868        if cur > offset || cur + self.buf.len() < offset {
2869            return (stack, None);
2870        }
2871        let mut attrs = self.clone();
2872        let mut last_off = cur + attrs.pos;
2873        let mut missing = None;
2874        while let Some(attr) = attrs.next() {
2875            let Ok(attr) = attr else { break };
2876            match attr {
2877                NftHookAttrs::Num(val) => {
2878                    if last_off == offset {
2879                        stack.push(("Num", last_off));
2880                        break;
2881                    }
2882                }
2883                NftHookAttrs::Priority(val) => {
2884                    if last_off == offset {
2885                        stack.push(("Priority", last_off));
2886                        break;
2887                    }
2888                }
2889                NftHookAttrs::Dev(val) => {
2890                    if last_off == offset {
2891                        stack.push(("Dev", last_off));
2892                        break;
2893                    }
2894                }
2895                NftHookAttrs::Devs(val) => {
2896                    (stack, missing) = val.lookup_attr(offset, missing_type);
2897                    if !stack.is_empty() {
2898                        break;
2899                    }
2900                }
2901                _ => {}
2902            };
2903            last_off = cur + attrs.pos;
2904        }
2905        if !stack.is_empty() {
2906            stack.push(("NftHookAttrs", cur));
2907        }
2908        (stack, missing)
2909    }
2910}
2911#[derive(Clone)]
2912pub enum HookDevAttrs<'a> {
2913    #[doc = "Attribute may repeat multiple times (treat it as array)"]
2914    Name(&'a CStr),
2915}
2916impl<'a> IterableHookDevAttrs<'a> {
2917    #[doc = "Attribute may repeat multiple times (treat it as array)"]
2918    pub fn get_name(&self) -> MultiAttrIterable<Self, HookDevAttrs<'a>, &'a CStr> {
2919        MultiAttrIterable::new(self.clone(), |variant| {
2920            if let HookDevAttrs::Name(val) = variant {
2921                Some(val)
2922            } else {
2923                None
2924            }
2925        })
2926    }
2927}
2928impl HookDevAttrs<'_> {
2929    pub fn new<'a>(buf: &'a [u8]) -> IterableHookDevAttrs<'a> {
2930        IterableHookDevAttrs::with_loc(buf, buf.as_ptr() as usize)
2931    }
2932    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2933        let res = match r#type {
2934            1u16 => "Name",
2935            _ => return None,
2936        };
2937        Some(res)
2938    }
2939}
2940#[derive(Clone, Copy, Default)]
2941pub struct IterableHookDevAttrs<'a> {
2942    buf: &'a [u8],
2943    pos: usize,
2944    orig_loc: usize,
2945}
2946impl<'a> IterableHookDevAttrs<'a> {
2947    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2948        Self {
2949            buf,
2950            pos: 0,
2951            orig_loc,
2952        }
2953    }
2954    pub fn get_buf(&self) -> &'a [u8] {
2955        self.buf
2956    }
2957}
2958impl<'a> Iterator for IterableHookDevAttrs<'a> {
2959    type Item = Result<HookDevAttrs<'a>, ErrorContext>;
2960    fn next(&mut self) -> Option<Self::Item> {
2961        let pos = self.pos;
2962        let mut r#type;
2963        loop {
2964            r#type = None;
2965            if self.buf.len() == self.pos {
2966                return None;
2967            }
2968            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2969                break;
2970            };
2971            r#type = Some(header.r#type);
2972            let res = match header.r#type {
2973                1u16 => HookDevAttrs::Name({
2974                    let res = CStr::from_bytes_with_nul(next).ok();
2975                    let Some(val) = res else { break };
2976                    val
2977                }),
2978                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2979                n => continue,
2980            };
2981            return Some(Ok(res));
2982        }
2983        Some(Err(ErrorContext::new(
2984            "HookDevAttrs",
2985            r#type.and_then(|t| HookDevAttrs::attr_from_type(t)),
2986            self.orig_loc,
2987            self.buf.as_ptr().wrapping_add(pos) as usize,
2988        )))
2989    }
2990}
2991impl<'a> std::fmt::Debug for IterableHookDevAttrs<'_> {
2992    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2993        let mut fmt = f.debug_struct("HookDevAttrs");
2994        for attr in self.clone() {
2995            let attr = match attr {
2996                Ok(a) => a,
2997                Err(err) => {
2998                    fmt.finish()?;
2999                    f.write_str("Err(")?;
3000                    err.fmt(f)?;
3001                    return f.write_str(")");
3002                }
3003            };
3004            match attr {
3005                HookDevAttrs::Name(val) => fmt.field("Name", &val),
3006            };
3007        }
3008        fmt.finish()
3009    }
3010}
3011impl IterableHookDevAttrs<'_> {
3012    pub fn lookup_attr(
3013        &self,
3014        offset: usize,
3015        missing_type: Option<u16>,
3016    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3017        let mut stack = Vec::new();
3018        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3019        if missing_type.is_some() && cur == offset {
3020            stack.push(("HookDevAttrs", offset));
3021            return (
3022                stack,
3023                missing_type.and_then(|t| HookDevAttrs::attr_from_type(t)),
3024            );
3025        }
3026        if cur > offset || cur + self.buf.len() < offset {
3027            return (stack, None);
3028        }
3029        let mut attrs = self.clone();
3030        let mut last_off = cur + attrs.pos;
3031        while let Some(attr) = attrs.next() {
3032            let Ok(attr) = attr else { break };
3033            match attr {
3034                HookDevAttrs::Name(val) => {
3035                    if last_off == offset {
3036                        stack.push(("Name", last_off));
3037                        break;
3038                    }
3039                }
3040                _ => {}
3041            };
3042            last_off = cur + attrs.pos;
3043        }
3044        if !stack.is_empty() {
3045            stack.push(("HookDevAttrs", cur));
3046        }
3047        (stack, None)
3048    }
3049}
3050#[derive(Clone)]
3051pub enum NftCounterAttrs {
3052    Bytes(u64),
3053    Packets(u64),
3054}
3055impl<'a> IterableNftCounterAttrs<'a> {
3056    pub fn get_bytes(&self) -> Result<u64, ErrorContext> {
3057        let mut iter = self.clone();
3058        iter.pos = 0;
3059        for attr in iter {
3060            if let NftCounterAttrs::Bytes(val) = attr? {
3061                return Ok(val);
3062            }
3063        }
3064        Err(ErrorContext::new_missing(
3065            "NftCounterAttrs",
3066            "Bytes",
3067            self.orig_loc,
3068            self.buf.as_ptr() as usize,
3069        ))
3070    }
3071    pub fn get_packets(&self) -> Result<u64, ErrorContext> {
3072        let mut iter = self.clone();
3073        iter.pos = 0;
3074        for attr in iter {
3075            if let NftCounterAttrs::Packets(val) = attr? {
3076                return Ok(val);
3077            }
3078        }
3079        Err(ErrorContext::new_missing(
3080            "NftCounterAttrs",
3081            "Packets",
3082            self.orig_loc,
3083            self.buf.as_ptr() as usize,
3084        ))
3085    }
3086}
3087impl NftCounterAttrs {
3088    pub fn new<'a>(buf: &'a [u8]) -> IterableNftCounterAttrs<'a> {
3089        IterableNftCounterAttrs::with_loc(buf, buf.as_ptr() as usize)
3090    }
3091    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3092        let res = match r#type {
3093            1u16 => "Bytes",
3094            2u16 => "Packets",
3095            _ => return None,
3096        };
3097        Some(res)
3098    }
3099}
3100#[derive(Clone, Copy, Default)]
3101pub struct IterableNftCounterAttrs<'a> {
3102    buf: &'a [u8],
3103    pos: usize,
3104    orig_loc: usize,
3105}
3106impl<'a> IterableNftCounterAttrs<'a> {
3107    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3108        Self {
3109            buf,
3110            pos: 0,
3111            orig_loc,
3112        }
3113    }
3114    pub fn get_buf(&self) -> &'a [u8] {
3115        self.buf
3116    }
3117}
3118impl<'a> Iterator for IterableNftCounterAttrs<'a> {
3119    type Item = Result<NftCounterAttrs, ErrorContext>;
3120    fn next(&mut self) -> Option<Self::Item> {
3121        let pos = self.pos;
3122        let mut r#type;
3123        loop {
3124            r#type = None;
3125            if self.buf.len() == self.pos {
3126                return None;
3127            }
3128            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3129                break;
3130            };
3131            r#type = Some(header.r#type);
3132            let res = match header.r#type {
3133                1u16 => NftCounterAttrs::Bytes({
3134                    let res = parse_be_u64(next);
3135                    let Some(val) = res else { break };
3136                    val
3137                }),
3138                2u16 => NftCounterAttrs::Packets({
3139                    let res = parse_be_u64(next);
3140                    let Some(val) = res else { break };
3141                    val
3142                }),
3143                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3144                n => continue,
3145            };
3146            return Some(Ok(res));
3147        }
3148        Some(Err(ErrorContext::new(
3149            "NftCounterAttrs",
3150            r#type.and_then(|t| NftCounterAttrs::attr_from_type(t)),
3151            self.orig_loc,
3152            self.buf.as_ptr().wrapping_add(pos) as usize,
3153        )))
3154    }
3155}
3156impl std::fmt::Debug for IterableNftCounterAttrs<'_> {
3157    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3158        let mut fmt = f.debug_struct("NftCounterAttrs");
3159        for attr in self.clone() {
3160            let attr = match attr {
3161                Ok(a) => a,
3162                Err(err) => {
3163                    fmt.finish()?;
3164                    f.write_str("Err(")?;
3165                    err.fmt(f)?;
3166                    return f.write_str(")");
3167                }
3168            };
3169            match attr {
3170                NftCounterAttrs::Bytes(val) => fmt.field("Bytes", &val),
3171                NftCounterAttrs::Packets(val) => fmt.field("Packets", &val),
3172            };
3173        }
3174        fmt.finish()
3175    }
3176}
3177impl IterableNftCounterAttrs<'_> {
3178    pub fn lookup_attr(
3179        &self,
3180        offset: usize,
3181        missing_type: Option<u16>,
3182    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3183        let mut stack = Vec::new();
3184        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3185        if missing_type.is_some() && cur == offset {
3186            stack.push(("NftCounterAttrs", offset));
3187            return (
3188                stack,
3189                missing_type.and_then(|t| NftCounterAttrs::attr_from_type(t)),
3190            );
3191        }
3192        if cur > offset || cur + self.buf.len() < offset {
3193            return (stack, None);
3194        }
3195        let mut attrs = self.clone();
3196        let mut last_off = cur + attrs.pos;
3197        while let Some(attr) = attrs.next() {
3198            let Ok(attr) = attr else { break };
3199            match attr {
3200                NftCounterAttrs::Bytes(val) => {
3201                    if last_off == offset {
3202                        stack.push(("Bytes", last_off));
3203                        break;
3204                    }
3205                }
3206                NftCounterAttrs::Packets(val) => {
3207                    if last_off == offset {
3208                        stack.push(("Packets", last_off));
3209                        break;
3210                    }
3211                }
3212                _ => {}
3213            };
3214            last_off = cur + attrs.pos;
3215        }
3216        if !stack.is_empty() {
3217            stack.push(("NftCounterAttrs", cur));
3218        }
3219        (stack, None)
3220    }
3221}
3222#[derive(Clone)]
3223pub enum RuleAttrs<'a> {
3224    #[doc = "name of the table containing the rule"]
3225    Table(&'a CStr),
3226    #[doc = "name of the chain containing the rule"]
3227    Chain(&'a CStr),
3228    #[doc = "numeric handle of the rule"]
3229    Handle(u64),
3230    #[doc = "list of expressions"]
3231    Expressions(IterableExprListAttrs<'a>),
3232    #[doc = "compatibility specifications of the rule"]
3233    Compat(IterableRuleCompatAttrs<'a>),
3234    #[doc = "numeric handle of the previous rule"]
3235    Position(u64),
3236    #[doc = "user data"]
3237    Userdata(&'a [u8]),
3238    #[doc = "uniquely identifies a rule in a transaction"]
3239    Id(u32),
3240    #[doc = "transaction unique identifier of the previous rule"]
3241    PositionId(u32),
3242    #[doc = "add the rule to chain by ID, alternative to chain name"]
3243    ChainId(u32),
3244}
3245impl<'a> IterableRuleAttrs<'a> {
3246    #[doc = "name of the table containing the rule"]
3247    pub fn get_table(&self) -> Result<&'a CStr, ErrorContext> {
3248        let mut iter = self.clone();
3249        iter.pos = 0;
3250        for attr in iter {
3251            if let RuleAttrs::Table(val) = attr? {
3252                return Ok(val);
3253            }
3254        }
3255        Err(ErrorContext::new_missing(
3256            "RuleAttrs",
3257            "Table",
3258            self.orig_loc,
3259            self.buf.as_ptr() as usize,
3260        ))
3261    }
3262    #[doc = "name of the chain containing the rule"]
3263    pub fn get_chain(&self) -> Result<&'a CStr, ErrorContext> {
3264        let mut iter = self.clone();
3265        iter.pos = 0;
3266        for attr in iter {
3267            if let RuleAttrs::Chain(val) = attr? {
3268                return Ok(val);
3269            }
3270        }
3271        Err(ErrorContext::new_missing(
3272            "RuleAttrs",
3273            "Chain",
3274            self.orig_loc,
3275            self.buf.as_ptr() as usize,
3276        ))
3277    }
3278    #[doc = "numeric handle of the rule"]
3279    pub fn get_handle(&self) -> Result<u64, ErrorContext> {
3280        let mut iter = self.clone();
3281        iter.pos = 0;
3282        for attr in iter {
3283            if let RuleAttrs::Handle(val) = attr? {
3284                return Ok(val);
3285            }
3286        }
3287        Err(ErrorContext::new_missing(
3288            "RuleAttrs",
3289            "Handle",
3290            self.orig_loc,
3291            self.buf.as_ptr() as usize,
3292        ))
3293    }
3294    #[doc = "list of expressions"]
3295    pub fn get_expressions(&self) -> Result<IterableExprListAttrs<'a>, ErrorContext> {
3296        let mut iter = self.clone();
3297        iter.pos = 0;
3298        for attr in iter {
3299            if let RuleAttrs::Expressions(val) = attr? {
3300                return Ok(val);
3301            }
3302        }
3303        Err(ErrorContext::new_missing(
3304            "RuleAttrs",
3305            "Expressions",
3306            self.orig_loc,
3307            self.buf.as_ptr() as usize,
3308        ))
3309    }
3310    #[doc = "compatibility specifications of the rule"]
3311    pub fn get_compat(&self) -> Result<IterableRuleCompatAttrs<'a>, ErrorContext> {
3312        let mut iter = self.clone();
3313        iter.pos = 0;
3314        for attr in iter {
3315            if let RuleAttrs::Compat(val) = attr? {
3316                return Ok(val);
3317            }
3318        }
3319        Err(ErrorContext::new_missing(
3320            "RuleAttrs",
3321            "Compat",
3322            self.orig_loc,
3323            self.buf.as_ptr() as usize,
3324        ))
3325    }
3326    #[doc = "numeric handle of the previous rule"]
3327    pub fn get_position(&self) -> Result<u64, ErrorContext> {
3328        let mut iter = self.clone();
3329        iter.pos = 0;
3330        for attr in iter {
3331            if let RuleAttrs::Position(val) = attr? {
3332                return Ok(val);
3333            }
3334        }
3335        Err(ErrorContext::new_missing(
3336            "RuleAttrs",
3337            "Position",
3338            self.orig_loc,
3339            self.buf.as_ptr() as usize,
3340        ))
3341    }
3342    #[doc = "user data"]
3343    pub fn get_userdata(&self) -> Result<&'a [u8], ErrorContext> {
3344        let mut iter = self.clone();
3345        iter.pos = 0;
3346        for attr in iter {
3347            if let RuleAttrs::Userdata(val) = attr? {
3348                return Ok(val);
3349            }
3350        }
3351        Err(ErrorContext::new_missing(
3352            "RuleAttrs",
3353            "Userdata",
3354            self.orig_loc,
3355            self.buf.as_ptr() as usize,
3356        ))
3357    }
3358    #[doc = "uniquely identifies a rule in a transaction"]
3359    pub fn get_id(&self) -> Result<u32, ErrorContext> {
3360        let mut iter = self.clone();
3361        iter.pos = 0;
3362        for attr in iter {
3363            if let RuleAttrs::Id(val) = attr? {
3364                return Ok(val);
3365            }
3366        }
3367        Err(ErrorContext::new_missing(
3368            "RuleAttrs",
3369            "Id",
3370            self.orig_loc,
3371            self.buf.as_ptr() as usize,
3372        ))
3373    }
3374    #[doc = "transaction unique identifier of the previous rule"]
3375    pub fn get_position_id(&self) -> Result<u32, ErrorContext> {
3376        let mut iter = self.clone();
3377        iter.pos = 0;
3378        for attr in iter {
3379            if let RuleAttrs::PositionId(val) = attr? {
3380                return Ok(val);
3381            }
3382        }
3383        Err(ErrorContext::new_missing(
3384            "RuleAttrs",
3385            "PositionId",
3386            self.orig_loc,
3387            self.buf.as_ptr() as usize,
3388        ))
3389    }
3390    #[doc = "add the rule to chain by ID, alternative to chain name"]
3391    pub fn get_chain_id(&self) -> Result<u32, ErrorContext> {
3392        let mut iter = self.clone();
3393        iter.pos = 0;
3394        for attr in iter {
3395            if let RuleAttrs::ChainId(val) = attr? {
3396                return Ok(val);
3397            }
3398        }
3399        Err(ErrorContext::new_missing(
3400            "RuleAttrs",
3401            "ChainId",
3402            self.orig_loc,
3403            self.buf.as_ptr() as usize,
3404        ))
3405    }
3406}
3407impl RuleAttrs<'_> {
3408    pub fn new<'a>(buf: &'a [u8]) -> IterableRuleAttrs<'a> {
3409        IterableRuleAttrs::with_loc(buf, buf.as_ptr() as usize)
3410    }
3411    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3412        let res = match r#type {
3413            1u16 => "Table",
3414            2u16 => "Chain",
3415            3u16 => "Handle",
3416            4u16 => "Expressions",
3417            5u16 => "Compat",
3418            6u16 => "Position",
3419            7u16 => "Userdata",
3420            8u16 => "Id",
3421            9u16 => "PositionId",
3422            10u16 => "ChainId",
3423            _ => return None,
3424        };
3425        Some(res)
3426    }
3427}
3428#[derive(Clone, Copy, Default)]
3429pub struct IterableRuleAttrs<'a> {
3430    buf: &'a [u8],
3431    pos: usize,
3432    orig_loc: usize,
3433}
3434impl<'a> IterableRuleAttrs<'a> {
3435    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3436        Self {
3437            buf,
3438            pos: 0,
3439            orig_loc,
3440        }
3441    }
3442    pub fn get_buf(&self) -> &'a [u8] {
3443        self.buf
3444    }
3445}
3446impl<'a> Iterator for IterableRuleAttrs<'a> {
3447    type Item = Result<RuleAttrs<'a>, ErrorContext>;
3448    fn next(&mut self) -> Option<Self::Item> {
3449        let pos = self.pos;
3450        let mut r#type;
3451        loop {
3452            r#type = None;
3453            if self.buf.len() == self.pos {
3454                return None;
3455            }
3456            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3457                break;
3458            };
3459            r#type = Some(header.r#type);
3460            let res = match header.r#type {
3461                1u16 => RuleAttrs::Table({
3462                    let res = CStr::from_bytes_with_nul(next).ok();
3463                    let Some(val) = res else { break };
3464                    val
3465                }),
3466                2u16 => RuleAttrs::Chain({
3467                    let res = CStr::from_bytes_with_nul(next).ok();
3468                    let Some(val) = res else { break };
3469                    val
3470                }),
3471                3u16 => RuleAttrs::Handle({
3472                    let res = parse_be_u64(next);
3473                    let Some(val) = res else { break };
3474                    val
3475                }),
3476                4u16 => RuleAttrs::Expressions({
3477                    let res = Some(IterableExprListAttrs::with_loc(next, self.orig_loc));
3478                    let Some(val) = res else { break };
3479                    val
3480                }),
3481                5u16 => RuleAttrs::Compat({
3482                    let res = Some(IterableRuleCompatAttrs::with_loc(next, self.orig_loc));
3483                    let Some(val) = res else { break };
3484                    val
3485                }),
3486                6u16 => RuleAttrs::Position({
3487                    let res = parse_be_u64(next);
3488                    let Some(val) = res else { break };
3489                    val
3490                }),
3491                7u16 => RuleAttrs::Userdata({
3492                    let res = Some(next);
3493                    let Some(val) = res else { break };
3494                    val
3495                }),
3496                8u16 => RuleAttrs::Id({
3497                    let res = parse_u32(next);
3498                    let Some(val) = res else { break };
3499                    val
3500                }),
3501                9u16 => RuleAttrs::PositionId({
3502                    let res = parse_u32(next);
3503                    let Some(val) = res else { break };
3504                    val
3505                }),
3506                10u16 => RuleAttrs::ChainId({
3507                    let res = parse_u32(next);
3508                    let Some(val) = res else { break };
3509                    val
3510                }),
3511                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3512                n => continue,
3513            };
3514            return Some(Ok(res));
3515        }
3516        Some(Err(ErrorContext::new(
3517            "RuleAttrs",
3518            r#type.and_then(|t| RuleAttrs::attr_from_type(t)),
3519            self.orig_loc,
3520            self.buf.as_ptr().wrapping_add(pos) as usize,
3521        )))
3522    }
3523}
3524impl<'a> std::fmt::Debug for IterableRuleAttrs<'_> {
3525    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3526        let mut fmt = f.debug_struct("RuleAttrs");
3527        for attr in self.clone() {
3528            let attr = match attr {
3529                Ok(a) => a,
3530                Err(err) => {
3531                    fmt.finish()?;
3532                    f.write_str("Err(")?;
3533                    err.fmt(f)?;
3534                    return f.write_str(")");
3535                }
3536            };
3537            match attr {
3538                RuleAttrs::Table(val) => fmt.field("Table", &val),
3539                RuleAttrs::Chain(val) => fmt.field("Chain", &val),
3540                RuleAttrs::Handle(val) => fmt.field("Handle", &val),
3541                RuleAttrs::Expressions(val) => fmt.field("Expressions", &val),
3542                RuleAttrs::Compat(val) => fmt.field("Compat", &val),
3543                RuleAttrs::Position(val) => fmt.field("Position", &val),
3544                RuleAttrs::Userdata(val) => fmt.field("Userdata", &val),
3545                RuleAttrs::Id(val) => fmt.field("Id", &val),
3546                RuleAttrs::PositionId(val) => fmt.field("PositionId", &val),
3547                RuleAttrs::ChainId(val) => fmt.field("ChainId", &val),
3548            };
3549        }
3550        fmt.finish()
3551    }
3552}
3553impl IterableRuleAttrs<'_> {
3554    pub fn lookup_attr(
3555        &self,
3556        offset: usize,
3557        missing_type: Option<u16>,
3558    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3559        let mut stack = Vec::new();
3560        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3561        if missing_type.is_some() && cur == offset {
3562            stack.push(("RuleAttrs", offset));
3563            return (
3564                stack,
3565                missing_type.and_then(|t| RuleAttrs::attr_from_type(t)),
3566            );
3567        }
3568        if cur > offset || cur + self.buf.len() < offset {
3569            return (stack, None);
3570        }
3571        let mut attrs = self.clone();
3572        let mut last_off = cur + attrs.pos;
3573        let mut missing = None;
3574        while let Some(attr) = attrs.next() {
3575            let Ok(attr) = attr else { break };
3576            match attr {
3577                RuleAttrs::Table(val) => {
3578                    if last_off == offset {
3579                        stack.push(("Table", last_off));
3580                        break;
3581                    }
3582                }
3583                RuleAttrs::Chain(val) => {
3584                    if last_off == offset {
3585                        stack.push(("Chain", last_off));
3586                        break;
3587                    }
3588                }
3589                RuleAttrs::Handle(val) => {
3590                    if last_off == offset {
3591                        stack.push(("Handle", last_off));
3592                        break;
3593                    }
3594                }
3595                RuleAttrs::Expressions(val) => {
3596                    (stack, missing) = val.lookup_attr(offset, missing_type);
3597                    if !stack.is_empty() {
3598                        break;
3599                    }
3600                }
3601                RuleAttrs::Compat(val) => {
3602                    (stack, missing) = val.lookup_attr(offset, missing_type);
3603                    if !stack.is_empty() {
3604                        break;
3605                    }
3606                }
3607                RuleAttrs::Position(val) => {
3608                    if last_off == offset {
3609                        stack.push(("Position", last_off));
3610                        break;
3611                    }
3612                }
3613                RuleAttrs::Userdata(val) => {
3614                    if last_off == offset {
3615                        stack.push(("Userdata", last_off));
3616                        break;
3617                    }
3618                }
3619                RuleAttrs::Id(val) => {
3620                    if last_off == offset {
3621                        stack.push(("Id", last_off));
3622                        break;
3623                    }
3624                }
3625                RuleAttrs::PositionId(val) => {
3626                    if last_off == offset {
3627                        stack.push(("PositionId", last_off));
3628                        break;
3629                    }
3630                }
3631                RuleAttrs::ChainId(val) => {
3632                    if last_off == offset {
3633                        stack.push(("ChainId", last_off));
3634                        break;
3635                    }
3636                }
3637                _ => {}
3638            };
3639            last_off = cur + attrs.pos;
3640        }
3641        if !stack.is_empty() {
3642            stack.push(("RuleAttrs", cur));
3643        }
3644        (stack, missing)
3645    }
3646}
3647#[derive(Clone)]
3648pub enum ExprListAttrs<'a> {
3649    #[doc = "Attribute may repeat multiple times (treat it as array)"]
3650    Elem(IterableExprAttrs<'a>),
3651}
3652impl<'a> IterableExprListAttrs<'a> {
3653    #[doc = "Attribute may repeat multiple times (treat it as array)"]
3654    pub fn get_elem(&self) -> MultiAttrIterable<Self, ExprListAttrs<'a>, IterableExprAttrs<'a>> {
3655        MultiAttrIterable::new(self.clone(), |variant| {
3656            if let ExprListAttrs::Elem(val) = variant {
3657                Some(val)
3658            } else {
3659                None
3660            }
3661        })
3662    }
3663}
3664impl ExprListAttrs<'_> {
3665    pub fn new<'a>(buf: &'a [u8]) -> IterableExprListAttrs<'a> {
3666        IterableExprListAttrs::with_loc(buf, buf.as_ptr() as usize)
3667    }
3668    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3669        let res = match r#type {
3670            1u16 => "Elem",
3671            _ => return None,
3672        };
3673        Some(res)
3674    }
3675}
3676#[derive(Clone, Copy, Default)]
3677pub struct IterableExprListAttrs<'a> {
3678    buf: &'a [u8],
3679    pos: usize,
3680    orig_loc: usize,
3681}
3682impl<'a> IterableExprListAttrs<'a> {
3683    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3684        Self {
3685            buf,
3686            pos: 0,
3687            orig_loc,
3688        }
3689    }
3690    pub fn get_buf(&self) -> &'a [u8] {
3691        self.buf
3692    }
3693}
3694impl<'a> Iterator for IterableExprListAttrs<'a> {
3695    type Item = Result<ExprListAttrs<'a>, ErrorContext>;
3696    fn next(&mut self) -> Option<Self::Item> {
3697        let pos = self.pos;
3698        let mut r#type;
3699        loop {
3700            r#type = None;
3701            if self.buf.len() == self.pos {
3702                return None;
3703            }
3704            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3705                break;
3706            };
3707            r#type = Some(header.r#type);
3708            let res = match header.r#type {
3709                1u16 => ExprListAttrs::Elem({
3710                    let res = Some(IterableExprAttrs::with_loc(next, self.orig_loc));
3711                    let Some(val) = res else { break };
3712                    val
3713                }),
3714                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3715                n => continue,
3716            };
3717            return Some(Ok(res));
3718        }
3719        Some(Err(ErrorContext::new(
3720            "ExprListAttrs",
3721            r#type.and_then(|t| ExprListAttrs::attr_from_type(t)),
3722            self.orig_loc,
3723            self.buf.as_ptr().wrapping_add(pos) as usize,
3724        )))
3725    }
3726}
3727impl<'a> std::fmt::Debug for IterableExprListAttrs<'_> {
3728    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3729        let mut fmt = f.debug_struct("ExprListAttrs");
3730        for attr in self.clone() {
3731            let attr = match attr {
3732                Ok(a) => a,
3733                Err(err) => {
3734                    fmt.finish()?;
3735                    f.write_str("Err(")?;
3736                    err.fmt(f)?;
3737                    return f.write_str(")");
3738                }
3739            };
3740            match attr {
3741                ExprListAttrs::Elem(val) => fmt.field("Elem", &val),
3742            };
3743        }
3744        fmt.finish()
3745    }
3746}
3747impl IterableExprListAttrs<'_> {
3748    pub fn lookup_attr(
3749        &self,
3750        offset: usize,
3751        missing_type: Option<u16>,
3752    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3753        let mut stack = Vec::new();
3754        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3755        if missing_type.is_some() && cur == offset {
3756            stack.push(("ExprListAttrs", offset));
3757            return (
3758                stack,
3759                missing_type.and_then(|t| ExprListAttrs::attr_from_type(t)),
3760            );
3761        }
3762        if cur > offset || cur + self.buf.len() < offset {
3763            return (stack, None);
3764        }
3765        let mut attrs = self.clone();
3766        let mut last_off = cur + attrs.pos;
3767        let mut missing = None;
3768        while let Some(attr) = attrs.next() {
3769            let Ok(attr) = attr else { break };
3770            match attr {
3771                ExprListAttrs::Elem(val) => {
3772                    (stack, missing) = val.lookup_attr(offset, missing_type);
3773                    if !stack.is_empty() {
3774                        break;
3775                    }
3776                }
3777                _ => {}
3778            };
3779            last_off = cur + attrs.pos;
3780        }
3781        if !stack.is_empty() {
3782            stack.push(("ExprListAttrs", cur));
3783        }
3784        (stack, missing)
3785    }
3786}
3787#[derive(Clone)]
3788pub enum ExprAttrs<'a> {
3789    #[doc = "name of the expression type"]
3790    Name(&'a CStr),
3791    #[doc = "type specific data"]
3792    Data(ExprOps<'a>),
3793}
3794impl<'a> IterableExprAttrs<'a> {
3795    #[doc = "name of the expression type"]
3796    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
3797        let mut iter = self.clone();
3798        iter.pos = 0;
3799        for attr in iter {
3800            if let ExprAttrs::Name(val) = attr? {
3801                return Ok(val);
3802            }
3803        }
3804        Err(ErrorContext::new_missing(
3805            "ExprAttrs",
3806            "Name",
3807            self.orig_loc,
3808            self.buf.as_ptr() as usize,
3809        ))
3810    }
3811    #[doc = "type specific data"]
3812    pub fn get_data(&self) -> Result<ExprOps<'a>, ErrorContext> {
3813        let mut iter = self.clone();
3814        iter.pos = 0;
3815        for attr in iter {
3816            if let ExprAttrs::Data(val) = attr? {
3817                return Ok(val);
3818            }
3819        }
3820        Err(ErrorContext::new_missing(
3821            "ExprAttrs",
3822            "Data",
3823            self.orig_loc,
3824            self.buf.as_ptr() as usize,
3825        ))
3826    }
3827}
3828#[derive(Debug, Clone)]
3829pub enum ExprOps<'a> {
3830    Bitwise(IterableExprBitwiseAttrs<'a>),
3831    Cmp(IterableExprCmpAttrs<'a>),
3832    Counter(IterableExprCounterAttrs<'a>),
3833    Ct(IterableExprCtAttrs<'a>),
3834    Fib(IterableExprFibAttrs<'a>),
3835    FlowOffload(IterableExprFlowOffloadAttrs<'a>),
3836    Immediate(IterableExprImmediateAttrs<'a>),
3837    Log(IterableLogAttrs<'a>),
3838    Lookup(IterableExprLookupAttrs<'a>),
3839    Match(IterableCompatMatchAttrs<'a>),
3840    Meta(IterableExprMetaAttrs<'a>),
3841    Nat(IterableExprNatAttrs<'a>),
3842    Numgen(IterableNumgenAttrs<'a>),
3843    Objref(IterableExprObjrefAttrs<'a>),
3844    Payload(IterableExprPayloadAttrs<'a>),
3845    Quota(IterableQuotaAttrs<'a>),
3846    Range(IterableRangeAttrs<'a>),
3847    Reject(IterableExprRejectAttrs<'a>),
3848    Target(IterableExprTargetAttrs<'a>),
3849    Tproxy(IterableExprTproxyAttrs<'a>),
3850}
3851impl<'a> ExprOps<'a> {
3852    fn select_with_loc(selector: &'a CStr, buf: &'a [u8], loc: usize) -> Option<Self> {
3853        match selector.to_bytes() {
3854            b"bitwise" => Some(ExprOps::Bitwise(IterableExprBitwiseAttrs::with_loc(
3855                buf, loc,
3856            ))),
3857            b"cmp" => Some(ExprOps::Cmp(IterableExprCmpAttrs::with_loc(buf, loc))),
3858            b"counter" => Some(ExprOps::Counter(IterableExprCounterAttrs::with_loc(
3859                buf, loc,
3860            ))),
3861            b"ct" => Some(ExprOps::Ct(IterableExprCtAttrs::with_loc(buf, loc))),
3862            b"fib" => Some(ExprOps::Fib(IterableExprFibAttrs::with_loc(buf, loc))),
3863            b"flow_offload" => Some(ExprOps::FlowOffload(
3864                IterableExprFlowOffloadAttrs::with_loc(buf, loc),
3865            )),
3866            b"immediate" => Some(ExprOps::Immediate(IterableExprImmediateAttrs::with_loc(
3867                buf, loc,
3868            ))),
3869            b"log" => Some(ExprOps::Log(IterableLogAttrs::with_loc(buf, loc))),
3870            b"lookup" => Some(ExprOps::Lookup(IterableExprLookupAttrs::with_loc(buf, loc))),
3871            b"match" => Some(ExprOps::Match(IterableCompatMatchAttrs::with_loc(buf, loc))),
3872            b"meta" => Some(ExprOps::Meta(IterableExprMetaAttrs::with_loc(buf, loc))),
3873            b"nat" => Some(ExprOps::Nat(IterableExprNatAttrs::with_loc(buf, loc))),
3874            b"numgen" => Some(ExprOps::Numgen(IterableNumgenAttrs::with_loc(buf, loc))),
3875            b"objref" => Some(ExprOps::Objref(IterableExprObjrefAttrs::with_loc(buf, loc))),
3876            b"payload" => Some(ExprOps::Payload(IterableExprPayloadAttrs::with_loc(
3877                buf, loc,
3878            ))),
3879            b"quota" => Some(ExprOps::Quota(IterableQuotaAttrs::with_loc(buf, loc))),
3880            b"range" => Some(ExprOps::Range(IterableRangeAttrs::with_loc(buf, loc))),
3881            b"reject" => Some(ExprOps::Reject(IterableExprRejectAttrs::with_loc(buf, loc))),
3882            b"target" => Some(ExprOps::Target(IterableExprTargetAttrs::with_loc(buf, loc))),
3883            b"tproxy" => Some(ExprOps::Tproxy(IterableExprTproxyAttrs::with_loc(buf, loc))),
3884            _ => None,
3885        }
3886    }
3887}
3888impl ExprAttrs<'_> {
3889    pub fn new<'a>(buf: &'a [u8]) -> IterableExprAttrs<'a> {
3890        IterableExprAttrs::with_loc(buf, buf.as_ptr() as usize)
3891    }
3892    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3893        let res = match r#type {
3894            1u16 => "Name",
3895            2u16 => "Data",
3896            _ => return None,
3897        };
3898        Some(res)
3899    }
3900}
3901#[derive(Clone, Copy, Default)]
3902pub struct IterableExprAttrs<'a> {
3903    buf: &'a [u8],
3904    pos: usize,
3905    orig_loc: usize,
3906}
3907impl<'a> IterableExprAttrs<'a> {
3908    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3909        Self {
3910            buf,
3911            pos: 0,
3912            orig_loc,
3913        }
3914    }
3915    pub fn get_buf(&self) -> &'a [u8] {
3916        self.buf
3917    }
3918}
3919impl<'a> Iterator for IterableExprAttrs<'a> {
3920    type Item = Result<ExprAttrs<'a>, ErrorContext>;
3921    fn next(&mut self) -> Option<Self::Item> {
3922        let pos = self.pos;
3923        let mut r#type;
3924        loop {
3925            r#type = None;
3926            if self.buf.len() == self.pos {
3927                return None;
3928            }
3929            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3930                break;
3931            };
3932            r#type = Some(header.r#type);
3933            let res = match header.r#type {
3934                1u16 => ExprAttrs::Name({
3935                    let res = CStr::from_bytes_with_nul(next).ok();
3936                    let Some(val) = res else { break };
3937                    val
3938                }),
3939                2u16 => ExprAttrs::Data({
3940                    let res = {
3941                        let Ok(selector) = self.get_name() else { break };
3942                        match ExprOps::select_with_loc(selector, next, self.orig_loc) {
3943                            Some(sub) => Some(sub),
3944                            None if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3945                            None => continue,
3946                        }
3947                    };
3948                    let Some(val) = res else { break };
3949                    val
3950                }),
3951                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3952                n => continue,
3953            };
3954            return Some(Ok(res));
3955        }
3956        Some(Err(ErrorContext::new(
3957            "ExprAttrs",
3958            r#type.and_then(|t| ExprAttrs::attr_from_type(t)),
3959            self.orig_loc,
3960            self.buf.as_ptr().wrapping_add(pos) as usize,
3961        )))
3962    }
3963}
3964impl<'a> std::fmt::Debug for IterableExprAttrs<'_> {
3965    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3966        let mut fmt = f.debug_struct("ExprAttrs");
3967        for attr in self.clone() {
3968            let attr = match attr {
3969                Ok(a) => a,
3970                Err(err) => {
3971                    fmt.finish()?;
3972                    f.write_str("Err(")?;
3973                    err.fmt(f)?;
3974                    return f.write_str(")");
3975                }
3976            };
3977            match attr {
3978                ExprAttrs::Name(val) => fmt.field("Name", &val),
3979                ExprAttrs::Data(val) => fmt.field("Data", &val),
3980            };
3981        }
3982        fmt.finish()
3983    }
3984}
3985impl IterableExprAttrs<'_> {
3986    pub fn lookup_attr(
3987        &self,
3988        offset: usize,
3989        missing_type: Option<u16>,
3990    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3991        let mut stack = Vec::new();
3992        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3993        if missing_type.is_some() && cur == offset {
3994            stack.push(("ExprAttrs", offset));
3995            return (
3996                stack,
3997                missing_type.and_then(|t| ExprAttrs::attr_from_type(t)),
3998            );
3999        }
4000        if cur > offset || cur + self.buf.len() < offset {
4001            return (stack, None);
4002        }
4003        let mut attrs = self.clone();
4004        let mut last_off = cur + attrs.pos;
4005        while let Some(attr) = attrs.next() {
4006            let Ok(attr) = attr else { break };
4007            match attr {
4008                ExprAttrs::Name(val) => {
4009                    if last_off == offset {
4010                        stack.push(("Name", last_off));
4011                        break;
4012                    }
4013                }
4014                ExprAttrs::Data(val) => {
4015                    if last_off == offset {
4016                        stack.push(("Data", last_off));
4017                        break;
4018                    }
4019                }
4020                _ => {}
4021            };
4022            last_off = cur + attrs.pos;
4023        }
4024        if !stack.is_empty() {
4025            stack.push(("ExprAttrs", cur));
4026        }
4027        (stack, None)
4028    }
4029}
4030#[derive(Clone)]
4031pub enum RuleCompatAttrs {
4032    #[doc = "numeric value of the handled protocol"]
4033    Proto(u32),
4034    #[doc = "bitmask of flags"]
4035    Flags(u32),
4036}
4037impl<'a> IterableRuleCompatAttrs<'a> {
4038    #[doc = "numeric value of the handled protocol"]
4039    pub fn get_proto(&self) -> Result<u32, ErrorContext> {
4040        let mut iter = self.clone();
4041        iter.pos = 0;
4042        for attr in iter {
4043            if let RuleCompatAttrs::Proto(val) = attr? {
4044                return Ok(val);
4045            }
4046        }
4047        Err(ErrorContext::new_missing(
4048            "RuleCompatAttrs",
4049            "Proto",
4050            self.orig_loc,
4051            self.buf.as_ptr() as usize,
4052        ))
4053    }
4054    #[doc = "bitmask of flags"]
4055    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
4056        let mut iter = self.clone();
4057        iter.pos = 0;
4058        for attr in iter {
4059            if let RuleCompatAttrs::Flags(val) = attr? {
4060                return Ok(val);
4061            }
4062        }
4063        Err(ErrorContext::new_missing(
4064            "RuleCompatAttrs",
4065            "Flags",
4066            self.orig_loc,
4067            self.buf.as_ptr() as usize,
4068        ))
4069    }
4070}
4071impl RuleCompatAttrs {
4072    pub fn new<'a>(buf: &'a [u8]) -> IterableRuleCompatAttrs<'a> {
4073        IterableRuleCompatAttrs::with_loc(buf, buf.as_ptr() as usize)
4074    }
4075    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4076        let res = match r#type {
4077            1u16 => "Proto",
4078            2u16 => "Flags",
4079            _ => return None,
4080        };
4081        Some(res)
4082    }
4083}
4084#[derive(Clone, Copy, Default)]
4085pub struct IterableRuleCompatAttrs<'a> {
4086    buf: &'a [u8],
4087    pos: usize,
4088    orig_loc: usize,
4089}
4090impl<'a> IterableRuleCompatAttrs<'a> {
4091    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4092        Self {
4093            buf,
4094            pos: 0,
4095            orig_loc,
4096        }
4097    }
4098    pub fn get_buf(&self) -> &'a [u8] {
4099        self.buf
4100    }
4101}
4102impl<'a> Iterator for IterableRuleCompatAttrs<'a> {
4103    type Item = Result<RuleCompatAttrs, ErrorContext>;
4104    fn next(&mut self) -> Option<Self::Item> {
4105        let pos = self.pos;
4106        let mut r#type;
4107        loop {
4108            r#type = None;
4109            if self.buf.len() == self.pos {
4110                return None;
4111            }
4112            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
4113                break;
4114            };
4115            r#type = Some(header.r#type);
4116            let res = match header.r#type {
4117                1u16 => RuleCompatAttrs::Proto({
4118                    let res = parse_be_u32(next);
4119                    let Some(val) = res else { break };
4120                    val
4121                }),
4122                2u16 => RuleCompatAttrs::Flags({
4123                    let res = parse_be_u32(next);
4124                    let Some(val) = res else { break };
4125                    val
4126                }),
4127                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4128                n => continue,
4129            };
4130            return Some(Ok(res));
4131        }
4132        Some(Err(ErrorContext::new(
4133            "RuleCompatAttrs",
4134            r#type.and_then(|t| RuleCompatAttrs::attr_from_type(t)),
4135            self.orig_loc,
4136            self.buf.as_ptr().wrapping_add(pos) as usize,
4137        )))
4138    }
4139}
4140impl std::fmt::Debug for IterableRuleCompatAttrs<'_> {
4141    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4142        let mut fmt = f.debug_struct("RuleCompatAttrs");
4143        for attr in self.clone() {
4144            let attr = match attr {
4145                Ok(a) => a,
4146                Err(err) => {
4147                    fmt.finish()?;
4148                    f.write_str("Err(")?;
4149                    err.fmt(f)?;
4150                    return f.write_str(")");
4151                }
4152            };
4153            match attr {
4154                RuleCompatAttrs::Proto(val) => fmt.field("Proto", &val),
4155                RuleCompatAttrs::Flags(val) => fmt.field("Flags", &val),
4156            };
4157        }
4158        fmt.finish()
4159    }
4160}
4161impl IterableRuleCompatAttrs<'_> {
4162    pub fn lookup_attr(
4163        &self,
4164        offset: usize,
4165        missing_type: Option<u16>,
4166    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4167        let mut stack = Vec::new();
4168        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4169        if missing_type.is_some() && cur == offset {
4170            stack.push(("RuleCompatAttrs", offset));
4171            return (
4172                stack,
4173                missing_type.and_then(|t| RuleCompatAttrs::attr_from_type(t)),
4174            );
4175        }
4176        if cur > offset || cur + self.buf.len() < offset {
4177            return (stack, None);
4178        }
4179        let mut attrs = self.clone();
4180        let mut last_off = cur + attrs.pos;
4181        while let Some(attr) = attrs.next() {
4182            let Ok(attr) = attr else { break };
4183            match attr {
4184                RuleCompatAttrs::Proto(val) => {
4185                    if last_off == offset {
4186                        stack.push(("Proto", last_off));
4187                        break;
4188                    }
4189                }
4190                RuleCompatAttrs::Flags(val) => {
4191                    if last_off == offset {
4192                        stack.push(("Flags", last_off));
4193                        break;
4194                    }
4195                }
4196                _ => {}
4197            };
4198            last_off = cur + attrs.pos;
4199        }
4200        if !stack.is_empty() {
4201            stack.push(("RuleCompatAttrs", cur));
4202        }
4203        (stack, None)
4204    }
4205}
4206#[derive(Clone)]
4207pub enum SetAttrs<'a> {
4208    #[doc = "table name"]
4209    Table(&'a CStr),
4210    #[doc = "set name"]
4211    Name(&'a CStr),
4212    #[doc = "bitmask of enum nft\\_set\\_flags\nAssociated type: [`SetFlags`] (enum)"]
4213    Flags(u32),
4214    #[doc = "key data type, informational purpose only"]
4215    KeyType(u32),
4216    #[doc = "key data length"]
4217    KeyLen(u32),
4218    #[doc = "mapping data type"]
4219    DataType(u32),
4220    #[doc = "mapping data length"]
4221    DataLen(u32),
4222    #[doc = "selection policy"]
4223    Policy(u32),
4224    #[doc = "set description"]
4225    Desc(IterableSetDescAttrs<'a>),
4226    #[doc = "uniquely identifies a set in a transaction"]
4227    Id(u32),
4228    #[doc = "default timeout value"]
4229    Timeout(u64),
4230    #[doc = "garbage collection interval"]
4231    GcInterval(u32),
4232    #[doc = "user data"]
4233    Userdata(&'a [u8]),
4234    Pad(&'a [u8]),
4235    #[doc = "stateful object type"]
4236    ObjType(u32),
4237    #[doc = "set handle"]
4238    Handle(u64),
4239    #[doc = "set expression\nAttribute may repeat multiple times (treat it as array)"]
4240    Expr(IterableExprAttrs<'a>),
4241    #[doc = "list of expressions"]
4242    Expressions(IterableSetListAttrs<'a>),
4243    #[doc = "set backend type"]
4244    Type(&'a CStr),
4245    #[doc = "number of set elements"]
4246    Count(u32),
4247}
4248impl<'a> IterableSetAttrs<'a> {
4249    #[doc = "table name"]
4250    pub fn get_table(&self) -> Result<&'a CStr, ErrorContext> {
4251        let mut iter = self.clone();
4252        iter.pos = 0;
4253        for attr in iter {
4254            if let SetAttrs::Table(val) = attr? {
4255                return Ok(val);
4256            }
4257        }
4258        Err(ErrorContext::new_missing(
4259            "SetAttrs",
4260            "Table",
4261            self.orig_loc,
4262            self.buf.as_ptr() as usize,
4263        ))
4264    }
4265    #[doc = "set name"]
4266    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
4267        let mut iter = self.clone();
4268        iter.pos = 0;
4269        for attr in iter {
4270            if let SetAttrs::Name(val) = attr? {
4271                return Ok(val);
4272            }
4273        }
4274        Err(ErrorContext::new_missing(
4275            "SetAttrs",
4276            "Name",
4277            self.orig_loc,
4278            self.buf.as_ptr() as usize,
4279        ))
4280    }
4281    #[doc = "bitmask of enum nft\\_set\\_flags\nAssociated type: [`SetFlags`] (enum)"]
4282    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
4283        let mut iter = self.clone();
4284        iter.pos = 0;
4285        for attr in iter {
4286            if let SetAttrs::Flags(val) = attr? {
4287                return Ok(val);
4288            }
4289        }
4290        Err(ErrorContext::new_missing(
4291            "SetAttrs",
4292            "Flags",
4293            self.orig_loc,
4294            self.buf.as_ptr() as usize,
4295        ))
4296    }
4297    #[doc = "key data type, informational purpose only"]
4298    pub fn get_key_type(&self) -> Result<u32, ErrorContext> {
4299        let mut iter = self.clone();
4300        iter.pos = 0;
4301        for attr in iter {
4302            if let SetAttrs::KeyType(val) = attr? {
4303                return Ok(val);
4304            }
4305        }
4306        Err(ErrorContext::new_missing(
4307            "SetAttrs",
4308            "KeyType",
4309            self.orig_loc,
4310            self.buf.as_ptr() as usize,
4311        ))
4312    }
4313    #[doc = "key data length"]
4314    pub fn get_key_len(&self) -> Result<u32, ErrorContext> {
4315        let mut iter = self.clone();
4316        iter.pos = 0;
4317        for attr in iter {
4318            if let SetAttrs::KeyLen(val) = attr? {
4319                return Ok(val);
4320            }
4321        }
4322        Err(ErrorContext::new_missing(
4323            "SetAttrs",
4324            "KeyLen",
4325            self.orig_loc,
4326            self.buf.as_ptr() as usize,
4327        ))
4328    }
4329    #[doc = "mapping data type"]
4330    pub fn get_data_type(&self) -> Result<u32, ErrorContext> {
4331        let mut iter = self.clone();
4332        iter.pos = 0;
4333        for attr in iter {
4334            if let SetAttrs::DataType(val) = attr? {
4335                return Ok(val);
4336            }
4337        }
4338        Err(ErrorContext::new_missing(
4339            "SetAttrs",
4340            "DataType",
4341            self.orig_loc,
4342            self.buf.as_ptr() as usize,
4343        ))
4344    }
4345    #[doc = "mapping data length"]
4346    pub fn get_data_len(&self) -> Result<u32, ErrorContext> {
4347        let mut iter = self.clone();
4348        iter.pos = 0;
4349        for attr in iter {
4350            if let SetAttrs::DataLen(val) = attr? {
4351                return Ok(val);
4352            }
4353        }
4354        Err(ErrorContext::new_missing(
4355            "SetAttrs",
4356            "DataLen",
4357            self.orig_loc,
4358            self.buf.as_ptr() as usize,
4359        ))
4360    }
4361    #[doc = "selection policy"]
4362    pub fn get_policy(&self) -> Result<u32, ErrorContext> {
4363        let mut iter = self.clone();
4364        iter.pos = 0;
4365        for attr in iter {
4366            if let SetAttrs::Policy(val) = attr? {
4367                return Ok(val);
4368            }
4369        }
4370        Err(ErrorContext::new_missing(
4371            "SetAttrs",
4372            "Policy",
4373            self.orig_loc,
4374            self.buf.as_ptr() as usize,
4375        ))
4376    }
4377    #[doc = "set description"]
4378    pub fn get_desc(&self) -> Result<IterableSetDescAttrs<'a>, ErrorContext> {
4379        let mut iter = self.clone();
4380        iter.pos = 0;
4381        for attr in iter {
4382            if let SetAttrs::Desc(val) = attr? {
4383                return Ok(val);
4384            }
4385        }
4386        Err(ErrorContext::new_missing(
4387            "SetAttrs",
4388            "Desc",
4389            self.orig_loc,
4390            self.buf.as_ptr() as usize,
4391        ))
4392    }
4393    #[doc = "uniquely identifies a set in a transaction"]
4394    pub fn get_id(&self) -> Result<u32, ErrorContext> {
4395        let mut iter = self.clone();
4396        iter.pos = 0;
4397        for attr in iter {
4398            if let SetAttrs::Id(val) = attr? {
4399                return Ok(val);
4400            }
4401        }
4402        Err(ErrorContext::new_missing(
4403            "SetAttrs",
4404            "Id",
4405            self.orig_loc,
4406            self.buf.as_ptr() as usize,
4407        ))
4408    }
4409    #[doc = "default timeout value"]
4410    pub fn get_timeout(&self) -> Result<u64, ErrorContext> {
4411        let mut iter = self.clone();
4412        iter.pos = 0;
4413        for attr in iter {
4414            if let SetAttrs::Timeout(val) = attr? {
4415                return Ok(val);
4416            }
4417        }
4418        Err(ErrorContext::new_missing(
4419            "SetAttrs",
4420            "Timeout",
4421            self.orig_loc,
4422            self.buf.as_ptr() as usize,
4423        ))
4424    }
4425    #[doc = "garbage collection interval"]
4426    pub fn get_gc_interval(&self) -> Result<u32, ErrorContext> {
4427        let mut iter = self.clone();
4428        iter.pos = 0;
4429        for attr in iter {
4430            if let SetAttrs::GcInterval(val) = attr? {
4431                return Ok(val);
4432            }
4433        }
4434        Err(ErrorContext::new_missing(
4435            "SetAttrs",
4436            "GcInterval",
4437            self.orig_loc,
4438            self.buf.as_ptr() as usize,
4439        ))
4440    }
4441    #[doc = "user data"]
4442    pub fn get_userdata(&self) -> Result<&'a [u8], ErrorContext> {
4443        let mut iter = self.clone();
4444        iter.pos = 0;
4445        for attr in iter {
4446            if let SetAttrs::Userdata(val) = attr? {
4447                return Ok(val);
4448            }
4449        }
4450        Err(ErrorContext::new_missing(
4451            "SetAttrs",
4452            "Userdata",
4453            self.orig_loc,
4454            self.buf.as_ptr() as usize,
4455        ))
4456    }
4457    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
4458        let mut iter = self.clone();
4459        iter.pos = 0;
4460        for attr in iter {
4461            if let SetAttrs::Pad(val) = attr? {
4462                return Ok(val);
4463            }
4464        }
4465        Err(ErrorContext::new_missing(
4466            "SetAttrs",
4467            "Pad",
4468            self.orig_loc,
4469            self.buf.as_ptr() as usize,
4470        ))
4471    }
4472    #[doc = "stateful object type"]
4473    pub fn get_obj_type(&self) -> Result<u32, ErrorContext> {
4474        let mut iter = self.clone();
4475        iter.pos = 0;
4476        for attr in iter {
4477            if let SetAttrs::ObjType(val) = attr? {
4478                return Ok(val);
4479            }
4480        }
4481        Err(ErrorContext::new_missing(
4482            "SetAttrs",
4483            "ObjType",
4484            self.orig_loc,
4485            self.buf.as_ptr() as usize,
4486        ))
4487    }
4488    #[doc = "set handle"]
4489    pub fn get_handle(&self) -> Result<u64, ErrorContext> {
4490        let mut iter = self.clone();
4491        iter.pos = 0;
4492        for attr in iter {
4493            if let SetAttrs::Handle(val) = attr? {
4494                return Ok(val);
4495            }
4496        }
4497        Err(ErrorContext::new_missing(
4498            "SetAttrs",
4499            "Handle",
4500            self.orig_loc,
4501            self.buf.as_ptr() as usize,
4502        ))
4503    }
4504    #[doc = "set expression\nAttribute may repeat multiple times (treat it as array)"]
4505    pub fn get_expr(&self) -> MultiAttrIterable<Self, SetAttrs<'a>, IterableExprAttrs<'a>> {
4506        MultiAttrIterable::new(self.clone(), |variant| {
4507            if let SetAttrs::Expr(val) = variant {
4508                Some(val)
4509            } else {
4510                None
4511            }
4512        })
4513    }
4514    #[doc = "list of expressions"]
4515    pub fn get_expressions(&self) -> Result<IterableSetListAttrs<'a>, ErrorContext> {
4516        let mut iter = self.clone();
4517        iter.pos = 0;
4518        for attr in iter {
4519            if let SetAttrs::Expressions(val) = attr? {
4520                return Ok(val);
4521            }
4522        }
4523        Err(ErrorContext::new_missing(
4524            "SetAttrs",
4525            "Expressions",
4526            self.orig_loc,
4527            self.buf.as_ptr() as usize,
4528        ))
4529    }
4530    #[doc = "set backend type"]
4531    pub fn get_type(&self) -> Result<&'a CStr, ErrorContext> {
4532        let mut iter = self.clone();
4533        iter.pos = 0;
4534        for attr in iter {
4535            if let SetAttrs::Type(val) = attr? {
4536                return Ok(val);
4537            }
4538        }
4539        Err(ErrorContext::new_missing(
4540            "SetAttrs",
4541            "Type",
4542            self.orig_loc,
4543            self.buf.as_ptr() as usize,
4544        ))
4545    }
4546    #[doc = "number of set elements"]
4547    pub fn get_count(&self) -> Result<u32, ErrorContext> {
4548        let mut iter = self.clone();
4549        iter.pos = 0;
4550        for attr in iter {
4551            if let SetAttrs::Count(val) = attr? {
4552                return Ok(val);
4553            }
4554        }
4555        Err(ErrorContext::new_missing(
4556            "SetAttrs",
4557            "Count",
4558            self.orig_loc,
4559            self.buf.as_ptr() as usize,
4560        ))
4561    }
4562}
4563impl SetAttrs<'_> {
4564    pub fn new<'a>(buf: &'a [u8]) -> IterableSetAttrs<'a> {
4565        IterableSetAttrs::with_loc(buf, buf.as_ptr() as usize)
4566    }
4567    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4568        let res = match r#type {
4569            1u16 => "Table",
4570            2u16 => "Name",
4571            3u16 => "Flags",
4572            4u16 => "KeyType",
4573            5u16 => "KeyLen",
4574            6u16 => "DataType",
4575            7u16 => "DataLen",
4576            8u16 => "Policy",
4577            9u16 => "Desc",
4578            10u16 => "Id",
4579            11u16 => "Timeout",
4580            12u16 => "GcInterval",
4581            13u16 => "Userdata",
4582            14u16 => "Pad",
4583            15u16 => "ObjType",
4584            16u16 => "Handle",
4585            17u16 => "Expr",
4586            18u16 => "Expressions",
4587            19u16 => "Type",
4588            20u16 => "Count",
4589            _ => return None,
4590        };
4591        Some(res)
4592    }
4593}
4594#[derive(Clone, Copy, Default)]
4595pub struct IterableSetAttrs<'a> {
4596    buf: &'a [u8],
4597    pos: usize,
4598    orig_loc: usize,
4599}
4600impl<'a> IterableSetAttrs<'a> {
4601    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4602        Self {
4603            buf,
4604            pos: 0,
4605            orig_loc,
4606        }
4607    }
4608    pub fn get_buf(&self) -> &'a [u8] {
4609        self.buf
4610    }
4611}
4612impl<'a> Iterator for IterableSetAttrs<'a> {
4613    type Item = Result<SetAttrs<'a>, ErrorContext>;
4614    fn next(&mut self) -> Option<Self::Item> {
4615        let pos = self.pos;
4616        let mut r#type;
4617        loop {
4618            r#type = None;
4619            if self.buf.len() == self.pos {
4620                return None;
4621            }
4622            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
4623                break;
4624            };
4625            r#type = Some(header.r#type);
4626            let res = match header.r#type {
4627                1u16 => SetAttrs::Table({
4628                    let res = CStr::from_bytes_with_nul(next).ok();
4629                    let Some(val) = res else { break };
4630                    val
4631                }),
4632                2u16 => SetAttrs::Name({
4633                    let res = CStr::from_bytes_with_nul(next).ok();
4634                    let Some(val) = res else { break };
4635                    val
4636                }),
4637                3u16 => SetAttrs::Flags({
4638                    let res = parse_be_u32(next);
4639                    let Some(val) = res else { break };
4640                    val
4641                }),
4642                4u16 => SetAttrs::KeyType({
4643                    let res = parse_be_u32(next);
4644                    let Some(val) = res else { break };
4645                    val
4646                }),
4647                5u16 => SetAttrs::KeyLen({
4648                    let res = parse_be_u32(next);
4649                    let Some(val) = res else { break };
4650                    val
4651                }),
4652                6u16 => SetAttrs::DataType({
4653                    let res = parse_be_u32(next);
4654                    let Some(val) = res else { break };
4655                    val
4656                }),
4657                7u16 => SetAttrs::DataLen({
4658                    let res = parse_be_u32(next);
4659                    let Some(val) = res else { break };
4660                    val
4661                }),
4662                8u16 => SetAttrs::Policy({
4663                    let res = parse_be_u32(next);
4664                    let Some(val) = res else { break };
4665                    val
4666                }),
4667                9u16 => SetAttrs::Desc({
4668                    let res = Some(IterableSetDescAttrs::with_loc(next, self.orig_loc));
4669                    let Some(val) = res else { break };
4670                    val
4671                }),
4672                10u16 => SetAttrs::Id({
4673                    let res = parse_u32(next);
4674                    let Some(val) = res else { break };
4675                    val
4676                }),
4677                11u16 => SetAttrs::Timeout({
4678                    let res = parse_u64(next);
4679                    let Some(val) = res else { break };
4680                    val
4681                }),
4682                12u16 => SetAttrs::GcInterval({
4683                    let res = parse_u32(next);
4684                    let Some(val) = res else { break };
4685                    val
4686                }),
4687                13u16 => SetAttrs::Userdata({
4688                    let res = Some(next);
4689                    let Some(val) = res else { break };
4690                    val
4691                }),
4692                14u16 => SetAttrs::Pad({
4693                    let res = Some(next);
4694                    let Some(val) = res else { break };
4695                    val
4696                }),
4697                15u16 => SetAttrs::ObjType({
4698                    let res = parse_be_u32(next);
4699                    let Some(val) = res else { break };
4700                    val
4701                }),
4702                16u16 => SetAttrs::Handle({
4703                    let res = parse_be_u64(next);
4704                    let Some(val) = res else { break };
4705                    val
4706                }),
4707                17u16 => SetAttrs::Expr({
4708                    let res = Some(IterableExprAttrs::with_loc(next, self.orig_loc));
4709                    let Some(val) = res else { break };
4710                    val
4711                }),
4712                18u16 => SetAttrs::Expressions({
4713                    let res = Some(IterableSetListAttrs::with_loc(next, self.orig_loc));
4714                    let Some(val) = res else { break };
4715                    val
4716                }),
4717                19u16 => SetAttrs::Type({
4718                    let res = CStr::from_bytes_with_nul(next).ok();
4719                    let Some(val) = res else { break };
4720                    val
4721                }),
4722                20u16 => SetAttrs::Count({
4723                    let res = parse_be_u32(next);
4724                    let Some(val) = res else { break };
4725                    val
4726                }),
4727                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4728                n => continue,
4729            };
4730            return Some(Ok(res));
4731        }
4732        Some(Err(ErrorContext::new(
4733            "SetAttrs",
4734            r#type.and_then(|t| SetAttrs::attr_from_type(t)),
4735            self.orig_loc,
4736            self.buf.as_ptr().wrapping_add(pos) as usize,
4737        )))
4738    }
4739}
4740impl<'a> std::fmt::Debug for IterableSetAttrs<'_> {
4741    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4742        let mut fmt = f.debug_struct("SetAttrs");
4743        for attr in self.clone() {
4744            let attr = match attr {
4745                Ok(a) => a,
4746                Err(err) => {
4747                    fmt.finish()?;
4748                    f.write_str("Err(")?;
4749                    err.fmt(f)?;
4750                    return f.write_str(")");
4751                }
4752            };
4753            match attr {
4754                SetAttrs::Table(val) => fmt.field("Table", &val),
4755                SetAttrs::Name(val) => fmt.field("Name", &val),
4756                SetAttrs::Flags(val) => {
4757                    fmt.field("Flags", &FormatFlags(val.into(), SetFlags::from_value))
4758                }
4759                SetAttrs::KeyType(val) => fmt.field("KeyType", &val),
4760                SetAttrs::KeyLen(val) => fmt.field("KeyLen", &val),
4761                SetAttrs::DataType(val) => fmt.field("DataType", &val),
4762                SetAttrs::DataLen(val) => fmt.field("DataLen", &val),
4763                SetAttrs::Policy(val) => fmt.field("Policy", &val),
4764                SetAttrs::Desc(val) => fmt.field("Desc", &val),
4765                SetAttrs::Id(val) => fmt.field("Id", &val),
4766                SetAttrs::Timeout(val) => fmt.field("Timeout", &val),
4767                SetAttrs::GcInterval(val) => fmt.field("GcInterval", &val),
4768                SetAttrs::Userdata(val) => fmt.field("Userdata", &val),
4769                SetAttrs::Pad(val) => fmt.field("Pad", &val),
4770                SetAttrs::ObjType(val) => fmt.field("ObjType", &val),
4771                SetAttrs::Handle(val) => fmt.field("Handle", &val),
4772                SetAttrs::Expr(val) => fmt.field("Expr", &val),
4773                SetAttrs::Expressions(val) => fmt.field("Expressions", &val),
4774                SetAttrs::Type(val) => fmt.field("Type", &val),
4775                SetAttrs::Count(val) => fmt.field("Count", &val),
4776            };
4777        }
4778        fmt.finish()
4779    }
4780}
4781impl IterableSetAttrs<'_> {
4782    pub fn lookup_attr(
4783        &self,
4784        offset: usize,
4785        missing_type: Option<u16>,
4786    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4787        let mut stack = Vec::new();
4788        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4789        if missing_type.is_some() && cur == offset {
4790            stack.push(("SetAttrs", offset));
4791            return (
4792                stack,
4793                missing_type.and_then(|t| SetAttrs::attr_from_type(t)),
4794            );
4795        }
4796        if cur > offset || cur + self.buf.len() < offset {
4797            return (stack, None);
4798        }
4799        let mut attrs = self.clone();
4800        let mut last_off = cur + attrs.pos;
4801        let mut missing = None;
4802        while let Some(attr) = attrs.next() {
4803            let Ok(attr) = attr else { break };
4804            match attr {
4805                SetAttrs::Table(val) => {
4806                    if last_off == offset {
4807                        stack.push(("Table", last_off));
4808                        break;
4809                    }
4810                }
4811                SetAttrs::Name(val) => {
4812                    if last_off == offset {
4813                        stack.push(("Name", last_off));
4814                        break;
4815                    }
4816                }
4817                SetAttrs::Flags(val) => {
4818                    if last_off == offset {
4819                        stack.push(("Flags", last_off));
4820                        break;
4821                    }
4822                }
4823                SetAttrs::KeyType(val) => {
4824                    if last_off == offset {
4825                        stack.push(("KeyType", last_off));
4826                        break;
4827                    }
4828                }
4829                SetAttrs::KeyLen(val) => {
4830                    if last_off == offset {
4831                        stack.push(("KeyLen", last_off));
4832                        break;
4833                    }
4834                }
4835                SetAttrs::DataType(val) => {
4836                    if last_off == offset {
4837                        stack.push(("DataType", last_off));
4838                        break;
4839                    }
4840                }
4841                SetAttrs::DataLen(val) => {
4842                    if last_off == offset {
4843                        stack.push(("DataLen", last_off));
4844                        break;
4845                    }
4846                }
4847                SetAttrs::Policy(val) => {
4848                    if last_off == offset {
4849                        stack.push(("Policy", last_off));
4850                        break;
4851                    }
4852                }
4853                SetAttrs::Desc(val) => {
4854                    (stack, missing) = val.lookup_attr(offset, missing_type);
4855                    if !stack.is_empty() {
4856                        break;
4857                    }
4858                }
4859                SetAttrs::Id(val) => {
4860                    if last_off == offset {
4861                        stack.push(("Id", last_off));
4862                        break;
4863                    }
4864                }
4865                SetAttrs::Timeout(val) => {
4866                    if last_off == offset {
4867                        stack.push(("Timeout", last_off));
4868                        break;
4869                    }
4870                }
4871                SetAttrs::GcInterval(val) => {
4872                    if last_off == offset {
4873                        stack.push(("GcInterval", last_off));
4874                        break;
4875                    }
4876                }
4877                SetAttrs::Userdata(val) => {
4878                    if last_off == offset {
4879                        stack.push(("Userdata", last_off));
4880                        break;
4881                    }
4882                }
4883                SetAttrs::Pad(val) => {
4884                    if last_off == offset {
4885                        stack.push(("Pad", last_off));
4886                        break;
4887                    }
4888                }
4889                SetAttrs::ObjType(val) => {
4890                    if last_off == offset {
4891                        stack.push(("ObjType", last_off));
4892                        break;
4893                    }
4894                }
4895                SetAttrs::Handle(val) => {
4896                    if last_off == offset {
4897                        stack.push(("Handle", last_off));
4898                        break;
4899                    }
4900                }
4901                SetAttrs::Expr(val) => {
4902                    (stack, missing) = val.lookup_attr(offset, missing_type);
4903                    if !stack.is_empty() {
4904                        break;
4905                    }
4906                }
4907                SetAttrs::Expressions(val) => {
4908                    (stack, missing) = val.lookup_attr(offset, missing_type);
4909                    if !stack.is_empty() {
4910                        break;
4911                    }
4912                }
4913                SetAttrs::Type(val) => {
4914                    if last_off == offset {
4915                        stack.push(("Type", last_off));
4916                        break;
4917                    }
4918                }
4919                SetAttrs::Count(val) => {
4920                    if last_off == offset {
4921                        stack.push(("Count", last_off));
4922                        break;
4923                    }
4924                }
4925                _ => {}
4926            };
4927            last_off = cur + attrs.pos;
4928        }
4929        if !stack.is_empty() {
4930            stack.push(("SetAttrs", cur));
4931        }
4932        (stack, missing)
4933    }
4934}
4935#[derive(Clone)]
4936pub enum SetDescAttrs<'a> {
4937    #[doc = "number of elements in set"]
4938    Size(u32),
4939    #[doc = "description of field concatenation\nAttribute may repeat multiple times (treat it as array)"]
4940    Concat(IterableSetDescConcatAttrs<'a>),
4941}
4942impl<'a> IterableSetDescAttrs<'a> {
4943    #[doc = "number of elements in set"]
4944    pub fn get_size(&self) -> Result<u32, ErrorContext> {
4945        let mut iter = self.clone();
4946        iter.pos = 0;
4947        for attr in iter {
4948            if let SetDescAttrs::Size(val) = attr? {
4949                return Ok(val);
4950            }
4951        }
4952        Err(ErrorContext::new_missing(
4953            "SetDescAttrs",
4954            "Size",
4955            self.orig_loc,
4956            self.buf.as_ptr() as usize,
4957        ))
4958    }
4959    #[doc = "description of field concatenation\nAttribute may repeat multiple times (treat it as array)"]
4960    pub fn get_concat(
4961        &self,
4962    ) -> MultiAttrIterable<Self, SetDescAttrs<'a>, IterableSetDescConcatAttrs<'a>> {
4963        MultiAttrIterable::new(self.clone(), |variant| {
4964            if let SetDescAttrs::Concat(val) = variant {
4965                Some(val)
4966            } else {
4967                None
4968            }
4969        })
4970    }
4971}
4972impl SetDescAttrs<'_> {
4973    pub fn new<'a>(buf: &'a [u8]) -> IterableSetDescAttrs<'a> {
4974        IterableSetDescAttrs::with_loc(buf, buf.as_ptr() as usize)
4975    }
4976    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4977        let res = match r#type {
4978            1u16 => "Size",
4979            2u16 => "Concat",
4980            _ => return None,
4981        };
4982        Some(res)
4983    }
4984}
4985#[derive(Clone, Copy, Default)]
4986pub struct IterableSetDescAttrs<'a> {
4987    buf: &'a [u8],
4988    pos: usize,
4989    orig_loc: usize,
4990}
4991impl<'a> IterableSetDescAttrs<'a> {
4992    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4993        Self {
4994            buf,
4995            pos: 0,
4996            orig_loc,
4997        }
4998    }
4999    pub fn get_buf(&self) -> &'a [u8] {
5000        self.buf
5001    }
5002}
5003impl<'a> Iterator for IterableSetDescAttrs<'a> {
5004    type Item = Result<SetDescAttrs<'a>, ErrorContext>;
5005    fn next(&mut self) -> Option<Self::Item> {
5006        let pos = self.pos;
5007        let mut r#type;
5008        loop {
5009            r#type = None;
5010            if self.buf.len() == self.pos {
5011                return None;
5012            }
5013            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
5014                break;
5015            };
5016            r#type = Some(header.r#type);
5017            let res = match header.r#type {
5018                1u16 => SetDescAttrs::Size({
5019                    let res = parse_be_u32(next);
5020                    let Some(val) = res else { break };
5021                    val
5022                }),
5023                2u16 => SetDescAttrs::Concat({
5024                    let res = Some(IterableSetDescConcatAttrs::with_loc(next, self.orig_loc));
5025                    let Some(val) = res else { break };
5026                    val
5027                }),
5028                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5029                n => continue,
5030            };
5031            return Some(Ok(res));
5032        }
5033        Some(Err(ErrorContext::new(
5034            "SetDescAttrs",
5035            r#type.and_then(|t| SetDescAttrs::attr_from_type(t)),
5036            self.orig_loc,
5037            self.buf.as_ptr().wrapping_add(pos) as usize,
5038        )))
5039    }
5040}
5041impl<'a> std::fmt::Debug for IterableSetDescAttrs<'_> {
5042    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5043        let mut fmt = f.debug_struct("SetDescAttrs");
5044        for attr in self.clone() {
5045            let attr = match attr {
5046                Ok(a) => a,
5047                Err(err) => {
5048                    fmt.finish()?;
5049                    f.write_str("Err(")?;
5050                    err.fmt(f)?;
5051                    return f.write_str(")");
5052                }
5053            };
5054            match attr {
5055                SetDescAttrs::Size(val) => fmt.field("Size", &val),
5056                SetDescAttrs::Concat(val) => fmt.field("Concat", &val),
5057            };
5058        }
5059        fmt.finish()
5060    }
5061}
5062impl IterableSetDescAttrs<'_> {
5063    pub fn lookup_attr(
5064        &self,
5065        offset: usize,
5066        missing_type: Option<u16>,
5067    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5068        let mut stack = Vec::new();
5069        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5070        if missing_type.is_some() && cur == offset {
5071            stack.push(("SetDescAttrs", offset));
5072            return (
5073                stack,
5074                missing_type.and_then(|t| SetDescAttrs::attr_from_type(t)),
5075            );
5076        }
5077        if cur > offset || cur + self.buf.len() < offset {
5078            return (stack, None);
5079        }
5080        let mut attrs = self.clone();
5081        let mut last_off = cur + attrs.pos;
5082        let mut missing = None;
5083        while let Some(attr) = attrs.next() {
5084            let Ok(attr) = attr else { break };
5085            match attr {
5086                SetDescAttrs::Size(val) => {
5087                    if last_off == offset {
5088                        stack.push(("Size", last_off));
5089                        break;
5090                    }
5091                }
5092                SetDescAttrs::Concat(val) => {
5093                    (stack, missing) = val.lookup_attr(offset, missing_type);
5094                    if !stack.is_empty() {
5095                        break;
5096                    }
5097                }
5098                _ => {}
5099            };
5100            last_off = cur + attrs.pos;
5101        }
5102        if !stack.is_empty() {
5103            stack.push(("SetDescAttrs", cur));
5104        }
5105        (stack, missing)
5106    }
5107}
5108#[derive(Clone)]
5109pub enum SetDescConcatAttrs<'a> {
5110    Elem(IterableSetFieldAttrs<'a>),
5111}
5112impl<'a> IterableSetDescConcatAttrs<'a> {
5113    pub fn get_elem(&self) -> Result<IterableSetFieldAttrs<'a>, ErrorContext> {
5114        let mut iter = self.clone();
5115        iter.pos = 0;
5116        for attr in iter {
5117            if let SetDescConcatAttrs::Elem(val) = attr? {
5118                return Ok(val);
5119            }
5120        }
5121        Err(ErrorContext::new_missing(
5122            "SetDescConcatAttrs",
5123            "Elem",
5124            self.orig_loc,
5125            self.buf.as_ptr() as usize,
5126        ))
5127    }
5128}
5129impl SetDescConcatAttrs<'_> {
5130    pub fn new<'a>(buf: &'a [u8]) -> IterableSetDescConcatAttrs<'a> {
5131        IterableSetDescConcatAttrs::with_loc(buf, buf.as_ptr() as usize)
5132    }
5133    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5134        let res = match r#type {
5135            1u16 => "Elem",
5136            _ => return None,
5137        };
5138        Some(res)
5139    }
5140}
5141#[derive(Clone, Copy, Default)]
5142pub struct IterableSetDescConcatAttrs<'a> {
5143    buf: &'a [u8],
5144    pos: usize,
5145    orig_loc: usize,
5146}
5147impl<'a> IterableSetDescConcatAttrs<'a> {
5148    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5149        Self {
5150            buf,
5151            pos: 0,
5152            orig_loc,
5153        }
5154    }
5155    pub fn get_buf(&self) -> &'a [u8] {
5156        self.buf
5157    }
5158}
5159impl<'a> Iterator for IterableSetDescConcatAttrs<'a> {
5160    type Item = Result<SetDescConcatAttrs<'a>, ErrorContext>;
5161    fn next(&mut self) -> Option<Self::Item> {
5162        let pos = self.pos;
5163        let mut r#type;
5164        loop {
5165            r#type = None;
5166            if self.buf.len() == self.pos {
5167                return None;
5168            }
5169            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
5170                break;
5171            };
5172            r#type = Some(header.r#type);
5173            let res = match header.r#type {
5174                1u16 => SetDescConcatAttrs::Elem({
5175                    let res = Some(IterableSetFieldAttrs::with_loc(next, self.orig_loc));
5176                    let Some(val) = res else { break };
5177                    val
5178                }),
5179                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5180                n => continue,
5181            };
5182            return Some(Ok(res));
5183        }
5184        Some(Err(ErrorContext::new(
5185            "SetDescConcatAttrs",
5186            r#type.and_then(|t| SetDescConcatAttrs::attr_from_type(t)),
5187            self.orig_loc,
5188            self.buf.as_ptr().wrapping_add(pos) as usize,
5189        )))
5190    }
5191}
5192impl<'a> std::fmt::Debug for IterableSetDescConcatAttrs<'_> {
5193    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5194        let mut fmt = f.debug_struct("SetDescConcatAttrs");
5195        for attr in self.clone() {
5196            let attr = match attr {
5197                Ok(a) => a,
5198                Err(err) => {
5199                    fmt.finish()?;
5200                    f.write_str("Err(")?;
5201                    err.fmt(f)?;
5202                    return f.write_str(")");
5203                }
5204            };
5205            match attr {
5206                SetDescConcatAttrs::Elem(val) => fmt.field("Elem", &val),
5207            };
5208        }
5209        fmt.finish()
5210    }
5211}
5212impl IterableSetDescConcatAttrs<'_> {
5213    pub fn lookup_attr(
5214        &self,
5215        offset: usize,
5216        missing_type: Option<u16>,
5217    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5218        let mut stack = Vec::new();
5219        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5220        if missing_type.is_some() && cur == offset {
5221            stack.push(("SetDescConcatAttrs", offset));
5222            return (
5223                stack,
5224                missing_type.and_then(|t| SetDescConcatAttrs::attr_from_type(t)),
5225            );
5226        }
5227        if cur > offset || cur + self.buf.len() < offset {
5228            return (stack, None);
5229        }
5230        let mut attrs = self.clone();
5231        let mut last_off = cur + attrs.pos;
5232        let mut missing = None;
5233        while let Some(attr) = attrs.next() {
5234            let Ok(attr) = attr else { break };
5235            match attr {
5236                SetDescConcatAttrs::Elem(val) => {
5237                    (stack, missing) = val.lookup_attr(offset, missing_type);
5238                    if !stack.is_empty() {
5239                        break;
5240                    }
5241                }
5242                _ => {}
5243            };
5244            last_off = cur + attrs.pos;
5245        }
5246        if !stack.is_empty() {
5247            stack.push(("SetDescConcatAttrs", cur));
5248        }
5249        (stack, missing)
5250    }
5251}
5252#[derive(Clone)]
5253pub enum SetFieldAttrs {
5254    Len(u32),
5255}
5256impl<'a> IterableSetFieldAttrs<'a> {
5257    pub fn get_len(&self) -> Result<u32, ErrorContext> {
5258        let mut iter = self.clone();
5259        iter.pos = 0;
5260        for attr in iter {
5261            if let SetFieldAttrs::Len(val) = attr? {
5262                return Ok(val);
5263            }
5264        }
5265        Err(ErrorContext::new_missing(
5266            "SetFieldAttrs",
5267            "Len",
5268            self.orig_loc,
5269            self.buf.as_ptr() as usize,
5270        ))
5271    }
5272}
5273impl SetFieldAttrs {
5274    pub fn new<'a>(buf: &'a [u8]) -> IterableSetFieldAttrs<'a> {
5275        IterableSetFieldAttrs::with_loc(buf, buf.as_ptr() as usize)
5276    }
5277    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5278        let res = match r#type {
5279            1u16 => "Len",
5280            _ => return None,
5281        };
5282        Some(res)
5283    }
5284}
5285#[derive(Clone, Copy, Default)]
5286pub struct IterableSetFieldAttrs<'a> {
5287    buf: &'a [u8],
5288    pos: usize,
5289    orig_loc: usize,
5290}
5291impl<'a> IterableSetFieldAttrs<'a> {
5292    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5293        Self {
5294            buf,
5295            pos: 0,
5296            orig_loc,
5297        }
5298    }
5299    pub fn get_buf(&self) -> &'a [u8] {
5300        self.buf
5301    }
5302}
5303impl<'a> Iterator for IterableSetFieldAttrs<'a> {
5304    type Item = Result<SetFieldAttrs, ErrorContext>;
5305    fn next(&mut self) -> Option<Self::Item> {
5306        let pos = self.pos;
5307        let mut r#type;
5308        loop {
5309            r#type = None;
5310            if self.buf.len() == self.pos {
5311                return None;
5312            }
5313            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
5314                break;
5315            };
5316            r#type = Some(header.r#type);
5317            let res = match header.r#type {
5318                1u16 => SetFieldAttrs::Len({
5319                    let res = parse_be_u32(next);
5320                    let Some(val) = res else { break };
5321                    val
5322                }),
5323                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5324                n => continue,
5325            };
5326            return Some(Ok(res));
5327        }
5328        Some(Err(ErrorContext::new(
5329            "SetFieldAttrs",
5330            r#type.and_then(|t| SetFieldAttrs::attr_from_type(t)),
5331            self.orig_loc,
5332            self.buf.as_ptr().wrapping_add(pos) as usize,
5333        )))
5334    }
5335}
5336impl std::fmt::Debug for IterableSetFieldAttrs<'_> {
5337    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5338        let mut fmt = f.debug_struct("SetFieldAttrs");
5339        for attr in self.clone() {
5340            let attr = match attr {
5341                Ok(a) => a,
5342                Err(err) => {
5343                    fmt.finish()?;
5344                    f.write_str("Err(")?;
5345                    err.fmt(f)?;
5346                    return f.write_str(")");
5347                }
5348            };
5349            match attr {
5350                SetFieldAttrs::Len(val) => fmt.field("Len", &val),
5351            };
5352        }
5353        fmt.finish()
5354    }
5355}
5356impl IterableSetFieldAttrs<'_> {
5357    pub fn lookup_attr(
5358        &self,
5359        offset: usize,
5360        missing_type: Option<u16>,
5361    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5362        let mut stack = Vec::new();
5363        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5364        if missing_type.is_some() && cur == offset {
5365            stack.push(("SetFieldAttrs", offset));
5366            return (
5367                stack,
5368                missing_type.and_then(|t| SetFieldAttrs::attr_from_type(t)),
5369            );
5370        }
5371        if cur > offset || cur + self.buf.len() < offset {
5372            return (stack, None);
5373        }
5374        let mut attrs = self.clone();
5375        let mut last_off = cur + attrs.pos;
5376        while let Some(attr) = attrs.next() {
5377            let Ok(attr) = attr else { break };
5378            match attr {
5379                SetFieldAttrs::Len(val) => {
5380                    if last_off == offset {
5381                        stack.push(("Len", last_off));
5382                        break;
5383                    }
5384                }
5385                _ => {}
5386            };
5387            last_off = cur + attrs.pos;
5388        }
5389        if !stack.is_empty() {
5390            stack.push(("SetFieldAttrs", cur));
5391        }
5392        (stack, None)
5393    }
5394}
5395#[derive(Clone)]
5396pub enum SetListAttrs<'a> {
5397    #[doc = "Attribute may repeat multiple times (treat it as array)"]
5398    Elem(IterableExprAttrs<'a>),
5399}
5400impl<'a> IterableSetListAttrs<'a> {
5401    #[doc = "Attribute may repeat multiple times (treat it as array)"]
5402    pub fn get_elem(&self) -> MultiAttrIterable<Self, SetListAttrs<'a>, IterableExprAttrs<'a>> {
5403        MultiAttrIterable::new(self.clone(), |variant| {
5404            if let SetListAttrs::Elem(val) = variant {
5405                Some(val)
5406            } else {
5407                None
5408            }
5409        })
5410    }
5411}
5412impl SetListAttrs<'_> {
5413    pub fn new<'a>(buf: &'a [u8]) -> IterableSetListAttrs<'a> {
5414        IterableSetListAttrs::with_loc(buf, buf.as_ptr() as usize)
5415    }
5416    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5417        let res = match r#type {
5418            1u16 => "Elem",
5419            _ => return None,
5420        };
5421        Some(res)
5422    }
5423}
5424#[derive(Clone, Copy, Default)]
5425pub struct IterableSetListAttrs<'a> {
5426    buf: &'a [u8],
5427    pos: usize,
5428    orig_loc: usize,
5429}
5430impl<'a> IterableSetListAttrs<'a> {
5431    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5432        Self {
5433            buf,
5434            pos: 0,
5435            orig_loc,
5436        }
5437    }
5438    pub fn get_buf(&self) -> &'a [u8] {
5439        self.buf
5440    }
5441}
5442impl<'a> Iterator for IterableSetListAttrs<'a> {
5443    type Item = Result<SetListAttrs<'a>, ErrorContext>;
5444    fn next(&mut self) -> Option<Self::Item> {
5445        let pos = self.pos;
5446        let mut r#type;
5447        loop {
5448            r#type = None;
5449            if self.buf.len() == self.pos {
5450                return None;
5451            }
5452            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
5453                break;
5454            };
5455            r#type = Some(header.r#type);
5456            let res = match header.r#type {
5457                1u16 => SetListAttrs::Elem({
5458                    let res = Some(IterableExprAttrs::with_loc(next, self.orig_loc));
5459                    let Some(val) = res else { break };
5460                    val
5461                }),
5462                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5463                n => continue,
5464            };
5465            return Some(Ok(res));
5466        }
5467        Some(Err(ErrorContext::new(
5468            "SetListAttrs",
5469            r#type.and_then(|t| SetListAttrs::attr_from_type(t)),
5470            self.orig_loc,
5471            self.buf.as_ptr().wrapping_add(pos) as usize,
5472        )))
5473    }
5474}
5475impl<'a> std::fmt::Debug for IterableSetListAttrs<'_> {
5476    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5477        let mut fmt = f.debug_struct("SetListAttrs");
5478        for attr in self.clone() {
5479            let attr = match attr {
5480                Ok(a) => a,
5481                Err(err) => {
5482                    fmt.finish()?;
5483                    f.write_str("Err(")?;
5484                    err.fmt(f)?;
5485                    return f.write_str(")");
5486                }
5487            };
5488            match attr {
5489                SetListAttrs::Elem(val) => fmt.field("Elem", &val),
5490            };
5491        }
5492        fmt.finish()
5493    }
5494}
5495impl IterableSetListAttrs<'_> {
5496    pub fn lookup_attr(
5497        &self,
5498        offset: usize,
5499        missing_type: Option<u16>,
5500    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5501        let mut stack = Vec::new();
5502        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5503        if missing_type.is_some() && cur == offset {
5504            stack.push(("SetListAttrs", offset));
5505            return (
5506                stack,
5507                missing_type.and_then(|t| SetListAttrs::attr_from_type(t)),
5508            );
5509        }
5510        if cur > offset || cur + self.buf.len() < offset {
5511            return (stack, None);
5512        }
5513        let mut attrs = self.clone();
5514        let mut last_off = cur + attrs.pos;
5515        let mut missing = None;
5516        while let Some(attr) = attrs.next() {
5517            let Ok(attr) = attr else { break };
5518            match attr {
5519                SetListAttrs::Elem(val) => {
5520                    (stack, missing) = val.lookup_attr(offset, missing_type);
5521                    if !stack.is_empty() {
5522                        break;
5523                    }
5524                }
5525                _ => {}
5526            };
5527            last_off = cur + attrs.pos;
5528        }
5529        if !stack.is_empty() {
5530            stack.push(("SetListAttrs", cur));
5531        }
5532        (stack, missing)
5533    }
5534}
5535#[derive(Clone)]
5536pub enum SetelemAttrs<'a> {
5537    #[doc = "key value"]
5538    Key(IterableDataAttrs<'a>),
5539    #[doc = "data value of mapping"]
5540    Data(IterableDataAttrs<'a>),
5541    #[doc = "bitmask of nft\\_set\\_elem\\_flags"]
5542    Flags(&'a [u8]),
5543    #[doc = "timeout value"]
5544    Timeout(u64),
5545    #[doc = "expiration time"]
5546    Expiration(u64),
5547    #[doc = "user data"]
5548    Userdata(&'a [u8]),
5549    #[doc = "expression"]
5550    Expr(IterableExprAttrs<'a>),
5551    #[doc = "stateful object reference"]
5552    Objref(&'a CStr),
5553    #[doc = "closing key value"]
5554    KeyEnd(IterableDataAttrs<'a>),
5555    #[doc = "list of expressions"]
5556    Expressions(IterableExprListAttrs<'a>),
5557}
5558impl<'a> IterableSetelemAttrs<'a> {
5559    #[doc = "key value"]
5560    pub fn get_key(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
5561        let mut iter = self.clone();
5562        iter.pos = 0;
5563        for attr in iter {
5564            if let SetelemAttrs::Key(val) = attr? {
5565                return Ok(val);
5566            }
5567        }
5568        Err(ErrorContext::new_missing(
5569            "SetelemAttrs",
5570            "Key",
5571            self.orig_loc,
5572            self.buf.as_ptr() as usize,
5573        ))
5574    }
5575    #[doc = "data value of mapping"]
5576    pub fn get_data(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
5577        let mut iter = self.clone();
5578        iter.pos = 0;
5579        for attr in iter {
5580            if let SetelemAttrs::Data(val) = attr? {
5581                return Ok(val);
5582            }
5583        }
5584        Err(ErrorContext::new_missing(
5585            "SetelemAttrs",
5586            "Data",
5587            self.orig_loc,
5588            self.buf.as_ptr() as usize,
5589        ))
5590    }
5591    #[doc = "bitmask of nft\\_set\\_elem\\_flags"]
5592    pub fn get_flags(&self) -> Result<&'a [u8], ErrorContext> {
5593        let mut iter = self.clone();
5594        iter.pos = 0;
5595        for attr in iter {
5596            if let SetelemAttrs::Flags(val) = attr? {
5597                return Ok(val);
5598            }
5599        }
5600        Err(ErrorContext::new_missing(
5601            "SetelemAttrs",
5602            "Flags",
5603            self.orig_loc,
5604            self.buf.as_ptr() as usize,
5605        ))
5606    }
5607    #[doc = "timeout value"]
5608    pub fn get_timeout(&self) -> Result<u64, ErrorContext> {
5609        let mut iter = self.clone();
5610        iter.pos = 0;
5611        for attr in iter {
5612            if let SetelemAttrs::Timeout(val) = attr? {
5613                return Ok(val);
5614            }
5615        }
5616        Err(ErrorContext::new_missing(
5617            "SetelemAttrs",
5618            "Timeout",
5619            self.orig_loc,
5620            self.buf.as_ptr() as usize,
5621        ))
5622    }
5623    #[doc = "expiration time"]
5624    pub fn get_expiration(&self) -> Result<u64, ErrorContext> {
5625        let mut iter = self.clone();
5626        iter.pos = 0;
5627        for attr in iter {
5628            if let SetelemAttrs::Expiration(val) = attr? {
5629                return Ok(val);
5630            }
5631        }
5632        Err(ErrorContext::new_missing(
5633            "SetelemAttrs",
5634            "Expiration",
5635            self.orig_loc,
5636            self.buf.as_ptr() as usize,
5637        ))
5638    }
5639    #[doc = "user data"]
5640    pub fn get_userdata(&self) -> Result<&'a [u8], ErrorContext> {
5641        let mut iter = self.clone();
5642        iter.pos = 0;
5643        for attr in iter {
5644            if let SetelemAttrs::Userdata(val) = attr? {
5645                return Ok(val);
5646            }
5647        }
5648        Err(ErrorContext::new_missing(
5649            "SetelemAttrs",
5650            "Userdata",
5651            self.orig_loc,
5652            self.buf.as_ptr() as usize,
5653        ))
5654    }
5655    #[doc = "expression"]
5656    pub fn get_expr(&self) -> Result<IterableExprAttrs<'a>, ErrorContext> {
5657        let mut iter = self.clone();
5658        iter.pos = 0;
5659        for attr in iter {
5660            if let SetelemAttrs::Expr(val) = attr? {
5661                return Ok(val);
5662            }
5663        }
5664        Err(ErrorContext::new_missing(
5665            "SetelemAttrs",
5666            "Expr",
5667            self.orig_loc,
5668            self.buf.as_ptr() as usize,
5669        ))
5670    }
5671    #[doc = "stateful object reference"]
5672    pub fn get_objref(&self) -> Result<&'a CStr, ErrorContext> {
5673        let mut iter = self.clone();
5674        iter.pos = 0;
5675        for attr in iter {
5676            if let SetelemAttrs::Objref(val) = attr? {
5677                return Ok(val);
5678            }
5679        }
5680        Err(ErrorContext::new_missing(
5681            "SetelemAttrs",
5682            "Objref",
5683            self.orig_loc,
5684            self.buf.as_ptr() as usize,
5685        ))
5686    }
5687    #[doc = "closing key value"]
5688    pub fn get_key_end(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
5689        let mut iter = self.clone();
5690        iter.pos = 0;
5691        for attr in iter {
5692            if let SetelemAttrs::KeyEnd(val) = attr? {
5693                return Ok(val);
5694            }
5695        }
5696        Err(ErrorContext::new_missing(
5697            "SetelemAttrs",
5698            "KeyEnd",
5699            self.orig_loc,
5700            self.buf.as_ptr() as usize,
5701        ))
5702    }
5703    #[doc = "list of expressions"]
5704    pub fn get_expressions(&self) -> Result<IterableExprListAttrs<'a>, ErrorContext> {
5705        let mut iter = self.clone();
5706        iter.pos = 0;
5707        for attr in iter {
5708            if let SetelemAttrs::Expressions(val) = attr? {
5709                return Ok(val);
5710            }
5711        }
5712        Err(ErrorContext::new_missing(
5713            "SetelemAttrs",
5714            "Expressions",
5715            self.orig_loc,
5716            self.buf.as_ptr() as usize,
5717        ))
5718    }
5719}
5720impl SetelemAttrs<'_> {
5721    pub fn new<'a>(buf: &'a [u8]) -> IterableSetelemAttrs<'a> {
5722        IterableSetelemAttrs::with_loc(buf, buf.as_ptr() as usize)
5723    }
5724    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5725        let res = match r#type {
5726            1u16 => "Key",
5727            2u16 => "Data",
5728            3u16 => "Flags",
5729            4u16 => "Timeout",
5730            5u16 => "Expiration",
5731            6u16 => "Userdata",
5732            7u16 => "Expr",
5733            8u16 => "Objref",
5734            9u16 => "KeyEnd",
5735            10u16 => "Expressions",
5736            _ => return None,
5737        };
5738        Some(res)
5739    }
5740}
5741#[derive(Clone, Copy, Default)]
5742pub struct IterableSetelemAttrs<'a> {
5743    buf: &'a [u8],
5744    pos: usize,
5745    orig_loc: usize,
5746}
5747impl<'a> IterableSetelemAttrs<'a> {
5748    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5749        Self {
5750            buf,
5751            pos: 0,
5752            orig_loc,
5753        }
5754    }
5755    pub fn get_buf(&self) -> &'a [u8] {
5756        self.buf
5757    }
5758}
5759impl<'a> Iterator for IterableSetelemAttrs<'a> {
5760    type Item = Result<SetelemAttrs<'a>, ErrorContext>;
5761    fn next(&mut self) -> Option<Self::Item> {
5762        let pos = self.pos;
5763        let mut r#type;
5764        loop {
5765            r#type = None;
5766            if self.buf.len() == self.pos {
5767                return None;
5768            }
5769            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
5770                break;
5771            };
5772            r#type = Some(header.r#type);
5773            let res = match header.r#type {
5774                1u16 => SetelemAttrs::Key({
5775                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
5776                    let Some(val) = res else { break };
5777                    val
5778                }),
5779                2u16 => SetelemAttrs::Data({
5780                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
5781                    let Some(val) = res else { break };
5782                    val
5783                }),
5784                3u16 => SetelemAttrs::Flags({
5785                    let res = Some(next);
5786                    let Some(val) = res else { break };
5787                    val
5788                }),
5789                4u16 => SetelemAttrs::Timeout({
5790                    let res = parse_u64(next);
5791                    let Some(val) = res else { break };
5792                    val
5793                }),
5794                5u16 => SetelemAttrs::Expiration({
5795                    let res = parse_u64(next);
5796                    let Some(val) = res else { break };
5797                    val
5798                }),
5799                6u16 => SetelemAttrs::Userdata({
5800                    let res = Some(next);
5801                    let Some(val) = res else { break };
5802                    val
5803                }),
5804                7u16 => SetelemAttrs::Expr({
5805                    let res = Some(IterableExprAttrs::with_loc(next, self.orig_loc));
5806                    let Some(val) = res else { break };
5807                    val
5808                }),
5809                8u16 => SetelemAttrs::Objref({
5810                    let res = CStr::from_bytes_with_nul(next).ok();
5811                    let Some(val) = res else { break };
5812                    val
5813                }),
5814                9u16 => SetelemAttrs::KeyEnd({
5815                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
5816                    let Some(val) = res else { break };
5817                    val
5818                }),
5819                10u16 => SetelemAttrs::Expressions({
5820                    let res = Some(IterableExprListAttrs::with_loc(next, self.orig_loc));
5821                    let Some(val) = res else { break };
5822                    val
5823                }),
5824                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5825                n => continue,
5826            };
5827            return Some(Ok(res));
5828        }
5829        Some(Err(ErrorContext::new(
5830            "SetelemAttrs",
5831            r#type.and_then(|t| SetelemAttrs::attr_from_type(t)),
5832            self.orig_loc,
5833            self.buf.as_ptr().wrapping_add(pos) as usize,
5834        )))
5835    }
5836}
5837impl<'a> std::fmt::Debug for IterableSetelemAttrs<'_> {
5838    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5839        let mut fmt = f.debug_struct("SetelemAttrs");
5840        for attr in self.clone() {
5841            let attr = match attr {
5842                Ok(a) => a,
5843                Err(err) => {
5844                    fmt.finish()?;
5845                    f.write_str("Err(")?;
5846                    err.fmt(f)?;
5847                    return f.write_str(")");
5848                }
5849            };
5850            match attr {
5851                SetelemAttrs::Key(val) => fmt.field("Key", &val),
5852                SetelemAttrs::Data(val) => fmt.field("Data", &val),
5853                SetelemAttrs::Flags(val) => fmt.field("Flags", &val),
5854                SetelemAttrs::Timeout(val) => fmt.field("Timeout", &val),
5855                SetelemAttrs::Expiration(val) => fmt.field("Expiration", &val),
5856                SetelemAttrs::Userdata(val) => fmt.field("Userdata", &val),
5857                SetelemAttrs::Expr(val) => fmt.field("Expr", &val),
5858                SetelemAttrs::Objref(val) => fmt.field("Objref", &val),
5859                SetelemAttrs::KeyEnd(val) => fmt.field("KeyEnd", &val),
5860                SetelemAttrs::Expressions(val) => fmt.field("Expressions", &val),
5861            };
5862        }
5863        fmt.finish()
5864    }
5865}
5866impl IterableSetelemAttrs<'_> {
5867    pub fn lookup_attr(
5868        &self,
5869        offset: usize,
5870        missing_type: Option<u16>,
5871    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5872        let mut stack = Vec::new();
5873        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5874        if missing_type.is_some() && cur == offset {
5875            stack.push(("SetelemAttrs", offset));
5876            return (
5877                stack,
5878                missing_type.and_then(|t| SetelemAttrs::attr_from_type(t)),
5879            );
5880        }
5881        if cur > offset || cur + self.buf.len() < offset {
5882            return (stack, None);
5883        }
5884        let mut attrs = self.clone();
5885        let mut last_off = cur + attrs.pos;
5886        let mut missing = None;
5887        while let Some(attr) = attrs.next() {
5888            let Ok(attr) = attr else { break };
5889            match attr {
5890                SetelemAttrs::Key(val) => {
5891                    (stack, missing) = val.lookup_attr(offset, missing_type);
5892                    if !stack.is_empty() {
5893                        break;
5894                    }
5895                }
5896                SetelemAttrs::Data(val) => {
5897                    (stack, missing) = val.lookup_attr(offset, missing_type);
5898                    if !stack.is_empty() {
5899                        break;
5900                    }
5901                }
5902                SetelemAttrs::Flags(val) => {
5903                    if last_off == offset {
5904                        stack.push(("Flags", last_off));
5905                        break;
5906                    }
5907                }
5908                SetelemAttrs::Timeout(val) => {
5909                    if last_off == offset {
5910                        stack.push(("Timeout", last_off));
5911                        break;
5912                    }
5913                }
5914                SetelemAttrs::Expiration(val) => {
5915                    if last_off == offset {
5916                        stack.push(("Expiration", last_off));
5917                        break;
5918                    }
5919                }
5920                SetelemAttrs::Userdata(val) => {
5921                    if last_off == offset {
5922                        stack.push(("Userdata", last_off));
5923                        break;
5924                    }
5925                }
5926                SetelemAttrs::Expr(val) => {
5927                    (stack, missing) = val.lookup_attr(offset, missing_type);
5928                    if !stack.is_empty() {
5929                        break;
5930                    }
5931                }
5932                SetelemAttrs::Objref(val) => {
5933                    if last_off == offset {
5934                        stack.push(("Objref", last_off));
5935                        break;
5936                    }
5937                }
5938                SetelemAttrs::KeyEnd(val) => {
5939                    (stack, missing) = val.lookup_attr(offset, missing_type);
5940                    if !stack.is_empty() {
5941                        break;
5942                    }
5943                }
5944                SetelemAttrs::Expressions(val) => {
5945                    (stack, missing) = val.lookup_attr(offset, missing_type);
5946                    if !stack.is_empty() {
5947                        break;
5948                    }
5949                }
5950                _ => {}
5951            };
5952            last_off = cur + attrs.pos;
5953        }
5954        if !stack.is_empty() {
5955            stack.push(("SetelemAttrs", cur));
5956        }
5957        (stack, missing)
5958    }
5959}
5960#[derive(Clone)]
5961pub enum SetelemListElemAttrs<'a> {
5962    #[doc = "Attribute may repeat multiple times (treat it as array)"]
5963    Elem(IterableSetelemAttrs<'a>),
5964}
5965impl<'a> IterableSetelemListElemAttrs<'a> {
5966    #[doc = "Attribute may repeat multiple times (treat it as array)"]
5967    pub fn get_elem(
5968        &self,
5969    ) -> MultiAttrIterable<Self, SetelemListElemAttrs<'a>, IterableSetelemAttrs<'a>> {
5970        MultiAttrIterable::new(self.clone(), |variant| {
5971            if let SetelemListElemAttrs::Elem(val) = variant {
5972                Some(val)
5973            } else {
5974                None
5975            }
5976        })
5977    }
5978}
5979impl SetelemListElemAttrs<'_> {
5980    pub fn new<'a>(buf: &'a [u8]) -> IterableSetelemListElemAttrs<'a> {
5981        IterableSetelemListElemAttrs::with_loc(buf, buf.as_ptr() as usize)
5982    }
5983    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5984        let res = match r#type {
5985            1u16 => "Elem",
5986            _ => return None,
5987        };
5988        Some(res)
5989    }
5990}
5991#[derive(Clone, Copy, Default)]
5992pub struct IterableSetelemListElemAttrs<'a> {
5993    buf: &'a [u8],
5994    pos: usize,
5995    orig_loc: usize,
5996}
5997impl<'a> IterableSetelemListElemAttrs<'a> {
5998    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5999        Self {
6000            buf,
6001            pos: 0,
6002            orig_loc,
6003        }
6004    }
6005    pub fn get_buf(&self) -> &'a [u8] {
6006        self.buf
6007    }
6008}
6009impl<'a> Iterator for IterableSetelemListElemAttrs<'a> {
6010    type Item = Result<SetelemListElemAttrs<'a>, ErrorContext>;
6011    fn next(&mut self) -> Option<Self::Item> {
6012        let pos = self.pos;
6013        let mut r#type;
6014        loop {
6015            r#type = None;
6016            if self.buf.len() == self.pos {
6017                return None;
6018            }
6019            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
6020                break;
6021            };
6022            r#type = Some(header.r#type);
6023            let res = match header.r#type {
6024                1u16 => SetelemListElemAttrs::Elem({
6025                    let res = Some(IterableSetelemAttrs::with_loc(next, self.orig_loc));
6026                    let Some(val) = res else { break };
6027                    val
6028                }),
6029                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
6030                n => continue,
6031            };
6032            return Some(Ok(res));
6033        }
6034        Some(Err(ErrorContext::new(
6035            "SetelemListElemAttrs",
6036            r#type.and_then(|t| SetelemListElemAttrs::attr_from_type(t)),
6037            self.orig_loc,
6038            self.buf.as_ptr().wrapping_add(pos) as usize,
6039        )))
6040    }
6041}
6042impl<'a> std::fmt::Debug for IterableSetelemListElemAttrs<'_> {
6043    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6044        let mut fmt = f.debug_struct("SetelemListElemAttrs");
6045        for attr in self.clone() {
6046            let attr = match attr {
6047                Ok(a) => a,
6048                Err(err) => {
6049                    fmt.finish()?;
6050                    f.write_str("Err(")?;
6051                    err.fmt(f)?;
6052                    return f.write_str(")");
6053                }
6054            };
6055            match attr {
6056                SetelemListElemAttrs::Elem(val) => fmt.field("Elem", &val),
6057            };
6058        }
6059        fmt.finish()
6060    }
6061}
6062impl IterableSetelemListElemAttrs<'_> {
6063    pub fn lookup_attr(
6064        &self,
6065        offset: usize,
6066        missing_type: Option<u16>,
6067    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
6068        let mut stack = Vec::new();
6069        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
6070        if missing_type.is_some() && cur == offset {
6071            stack.push(("SetelemListElemAttrs", offset));
6072            return (
6073                stack,
6074                missing_type.and_then(|t| SetelemListElemAttrs::attr_from_type(t)),
6075            );
6076        }
6077        if cur > offset || cur + self.buf.len() < offset {
6078            return (stack, None);
6079        }
6080        let mut attrs = self.clone();
6081        let mut last_off = cur + attrs.pos;
6082        let mut missing = None;
6083        while let Some(attr) = attrs.next() {
6084            let Ok(attr) = attr else { break };
6085            match attr {
6086                SetelemListElemAttrs::Elem(val) => {
6087                    (stack, missing) = val.lookup_attr(offset, missing_type);
6088                    if !stack.is_empty() {
6089                        break;
6090                    }
6091                }
6092                _ => {}
6093            };
6094            last_off = cur + attrs.pos;
6095        }
6096        if !stack.is_empty() {
6097            stack.push(("SetelemListElemAttrs", cur));
6098        }
6099        (stack, missing)
6100    }
6101}
6102#[derive(Clone)]
6103pub enum SetelemListAttrs<'a> {
6104    Table(&'a CStr),
6105    Set(&'a CStr),
6106    Elements(IterableSetelemListElemAttrs<'a>),
6107    SetId(u32),
6108}
6109impl<'a> IterableSetelemListAttrs<'a> {
6110    pub fn get_table(&self) -> Result<&'a CStr, ErrorContext> {
6111        let mut iter = self.clone();
6112        iter.pos = 0;
6113        for attr in iter {
6114            if let SetelemListAttrs::Table(val) = attr? {
6115                return Ok(val);
6116            }
6117        }
6118        Err(ErrorContext::new_missing(
6119            "SetelemListAttrs",
6120            "Table",
6121            self.orig_loc,
6122            self.buf.as_ptr() as usize,
6123        ))
6124    }
6125    pub fn get_set(&self) -> Result<&'a CStr, ErrorContext> {
6126        let mut iter = self.clone();
6127        iter.pos = 0;
6128        for attr in iter {
6129            if let SetelemListAttrs::Set(val) = attr? {
6130                return Ok(val);
6131            }
6132        }
6133        Err(ErrorContext::new_missing(
6134            "SetelemListAttrs",
6135            "Set",
6136            self.orig_loc,
6137            self.buf.as_ptr() as usize,
6138        ))
6139    }
6140    pub fn get_elements(&self) -> Result<IterableSetelemListElemAttrs<'a>, ErrorContext> {
6141        let mut iter = self.clone();
6142        iter.pos = 0;
6143        for attr in iter {
6144            if let SetelemListAttrs::Elements(val) = attr? {
6145                return Ok(val);
6146            }
6147        }
6148        Err(ErrorContext::new_missing(
6149            "SetelemListAttrs",
6150            "Elements",
6151            self.orig_loc,
6152            self.buf.as_ptr() as usize,
6153        ))
6154    }
6155    pub fn get_set_id(&self) -> Result<u32, ErrorContext> {
6156        let mut iter = self.clone();
6157        iter.pos = 0;
6158        for attr in iter {
6159            if let SetelemListAttrs::SetId(val) = attr? {
6160                return Ok(val);
6161            }
6162        }
6163        Err(ErrorContext::new_missing(
6164            "SetelemListAttrs",
6165            "SetId",
6166            self.orig_loc,
6167            self.buf.as_ptr() as usize,
6168        ))
6169    }
6170}
6171impl SetelemListAttrs<'_> {
6172    pub fn new<'a>(buf: &'a [u8]) -> IterableSetelemListAttrs<'a> {
6173        IterableSetelemListAttrs::with_loc(buf, buf.as_ptr() as usize)
6174    }
6175    fn attr_from_type(r#type: u16) -> Option<&'static str> {
6176        let res = match r#type {
6177            1u16 => "Table",
6178            2u16 => "Set",
6179            3u16 => "Elements",
6180            4u16 => "SetId",
6181            _ => return None,
6182        };
6183        Some(res)
6184    }
6185}
6186#[derive(Clone, Copy, Default)]
6187pub struct IterableSetelemListAttrs<'a> {
6188    buf: &'a [u8],
6189    pos: usize,
6190    orig_loc: usize,
6191}
6192impl<'a> IterableSetelemListAttrs<'a> {
6193    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
6194        Self {
6195            buf,
6196            pos: 0,
6197            orig_loc,
6198        }
6199    }
6200    pub fn get_buf(&self) -> &'a [u8] {
6201        self.buf
6202    }
6203}
6204impl<'a> Iterator for IterableSetelemListAttrs<'a> {
6205    type Item = Result<SetelemListAttrs<'a>, ErrorContext>;
6206    fn next(&mut self) -> Option<Self::Item> {
6207        let pos = self.pos;
6208        let mut r#type;
6209        loop {
6210            r#type = None;
6211            if self.buf.len() == self.pos {
6212                return None;
6213            }
6214            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
6215                break;
6216            };
6217            r#type = Some(header.r#type);
6218            let res = match header.r#type {
6219                1u16 => SetelemListAttrs::Table({
6220                    let res = CStr::from_bytes_with_nul(next).ok();
6221                    let Some(val) = res else { break };
6222                    val
6223                }),
6224                2u16 => SetelemListAttrs::Set({
6225                    let res = CStr::from_bytes_with_nul(next).ok();
6226                    let Some(val) = res else { break };
6227                    val
6228                }),
6229                3u16 => SetelemListAttrs::Elements({
6230                    let res = Some(IterableSetelemListElemAttrs::with_loc(next, self.orig_loc));
6231                    let Some(val) = res else { break };
6232                    val
6233                }),
6234                4u16 => SetelemListAttrs::SetId({
6235                    let res = parse_u32(next);
6236                    let Some(val) = res else { break };
6237                    val
6238                }),
6239                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
6240                n => continue,
6241            };
6242            return Some(Ok(res));
6243        }
6244        Some(Err(ErrorContext::new(
6245            "SetelemListAttrs",
6246            r#type.and_then(|t| SetelemListAttrs::attr_from_type(t)),
6247            self.orig_loc,
6248            self.buf.as_ptr().wrapping_add(pos) as usize,
6249        )))
6250    }
6251}
6252impl<'a> std::fmt::Debug for IterableSetelemListAttrs<'_> {
6253    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6254        let mut fmt = f.debug_struct("SetelemListAttrs");
6255        for attr in self.clone() {
6256            let attr = match attr {
6257                Ok(a) => a,
6258                Err(err) => {
6259                    fmt.finish()?;
6260                    f.write_str("Err(")?;
6261                    err.fmt(f)?;
6262                    return f.write_str(")");
6263                }
6264            };
6265            match attr {
6266                SetelemListAttrs::Table(val) => fmt.field("Table", &val),
6267                SetelemListAttrs::Set(val) => fmt.field("Set", &val),
6268                SetelemListAttrs::Elements(val) => fmt.field("Elements", &val),
6269                SetelemListAttrs::SetId(val) => fmt.field("SetId", &val),
6270            };
6271        }
6272        fmt.finish()
6273    }
6274}
6275impl IterableSetelemListAttrs<'_> {
6276    pub fn lookup_attr(
6277        &self,
6278        offset: usize,
6279        missing_type: Option<u16>,
6280    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
6281        let mut stack = Vec::new();
6282        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
6283        if missing_type.is_some() && cur == offset {
6284            stack.push(("SetelemListAttrs", offset));
6285            return (
6286                stack,
6287                missing_type.and_then(|t| SetelemListAttrs::attr_from_type(t)),
6288            );
6289        }
6290        if cur > offset || cur + self.buf.len() < offset {
6291            return (stack, None);
6292        }
6293        let mut attrs = self.clone();
6294        let mut last_off = cur + attrs.pos;
6295        let mut missing = None;
6296        while let Some(attr) = attrs.next() {
6297            let Ok(attr) = attr else { break };
6298            match attr {
6299                SetelemListAttrs::Table(val) => {
6300                    if last_off == offset {
6301                        stack.push(("Table", last_off));
6302                        break;
6303                    }
6304                }
6305                SetelemListAttrs::Set(val) => {
6306                    if last_off == offset {
6307                        stack.push(("Set", last_off));
6308                        break;
6309                    }
6310                }
6311                SetelemListAttrs::Elements(val) => {
6312                    (stack, missing) = val.lookup_attr(offset, missing_type);
6313                    if !stack.is_empty() {
6314                        break;
6315                    }
6316                }
6317                SetelemListAttrs::SetId(val) => {
6318                    if last_off == offset {
6319                        stack.push(("SetId", last_off));
6320                        break;
6321                    }
6322                }
6323                _ => {}
6324            };
6325            last_off = cur + attrs.pos;
6326        }
6327        if !stack.is_empty() {
6328            stack.push(("SetelemListAttrs", cur));
6329        }
6330        (stack, missing)
6331    }
6332}
6333#[derive(Clone)]
6334pub enum GenAttrs<'a> {
6335    #[doc = "ruleset generation id"]
6336    Id(u32),
6337    ProcPid(u32),
6338    ProcName(&'a CStr),
6339}
6340impl<'a> IterableGenAttrs<'a> {
6341    #[doc = "ruleset generation id"]
6342    pub fn get_id(&self) -> Result<u32, ErrorContext> {
6343        let mut iter = self.clone();
6344        iter.pos = 0;
6345        for attr in iter {
6346            if let GenAttrs::Id(val) = attr? {
6347                return Ok(val);
6348            }
6349        }
6350        Err(ErrorContext::new_missing(
6351            "GenAttrs",
6352            "Id",
6353            self.orig_loc,
6354            self.buf.as_ptr() as usize,
6355        ))
6356    }
6357    pub fn get_proc_pid(&self) -> Result<u32, ErrorContext> {
6358        let mut iter = self.clone();
6359        iter.pos = 0;
6360        for attr in iter {
6361            if let GenAttrs::ProcPid(val) = attr? {
6362                return Ok(val);
6363            }
6364        }
6365        Err(ErrorContext::new_missing(
6366            "GenAttrs",
6367            "ProcPid",
6368            self.orig_loc,
6369            self.buf.as_ptr() as usize,
6370        ))
6371    }
6372    pub fn get_proc_name(&self) -> Result<&'a CStr, ErrorContext> {
6373        let mut iter = self.clone();
6374        iter.pos = 0;
6375        for attr in iter {
6376            if let GenAttrs::ProcName(val) = attr? {
6377                return Ok(val);
6378            }
6379        }
6380        Err(ErrorContext::new_missing(
6381            "GenAttrs",
6382            "ProcName",
6383            self.orig_loc,
6384            self.buf.as_ptr() as usize,
6385        ))
6386    }
6387}
6388impl GenAttrs<'_> {
6389    pub fn new<'a>(buf: &'a [u8]) -> IterableGenAttrs<'a> {
6390        IterableGenAttrs::with_loc(buf, buf.as_ptr() as usize)
6391    }
6392    fn attr_from_type(r#type: u16) -> Option<&'static str> {
6393        let res = match r#type {
6394            1u16 => "Id",
6395            2u16 => "ProcPid",
6396            3u16 => "ProcName",
6397            _ => return None,
6398        };
6399        Some(res)
6400    }
6401}
6402#[derive(Clone, Copy, Default)]
6403pub struct IterableGenAttrs<'a> {
6404    buf: &'a [u8],
6405    pos: usize,
6406    orig_loc: usize,
6407}
6408impl<'a> IterableGenAttrs<'a> {
6409    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
6410        Self {
6411            buf,
6412            pos: 0,
6413            orig_loc,
6414        }
6415    }
6416    pub fn get_buf(&self) -> &'a [u8] {
6417        self.buf
6418    }
6419}
6420impl<'a> Iterator for IterableGenAttrs<'a> {
6421    type Item = Result<GenAttrs<'a>, ErrorContext>;
6422    fn next(&mut self) -> Option<Self::Item> {
6423        let pos = self.pos;
6424        let mut r#type;
6425        loop {
6426            r#type = None;
6427            if self.buf.len() == self.pos {
6428                return None;
6429            }
6430            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
6431                break;
6432            };
6433            r#type = Some(header.r#type);
6434            let res = match header.r#type {
6435                1u16 => GenAttrs::Id({
6436                    let res = parse_be_u32(next);
6437                    let Some(val) = res else { break };
6438                    val
6439                }),
6440                2u16 => GenAttrs::ProcPid({
6441                    let res = parse_be_u32(next);
6442                    let Some(val) = res else { break };
6443                    val
6444                }),
6445                3u16 => GenAttrs::ProcName({
6446                    let res = CStr::from_bytes_with_nul(next).ok();
6447                    let Some(val) = res else { break };
6448                    val
6449                }),
6450                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
6451                n => continue,
6452            };
6453            return Some(Ok(res));
6454        }
6455        Some(Err(ErrorContext::new(
6456            "GenAttrs",
6457            r#type.and_then(|t| GenAttrs::attr_from_type(t)),
6458            self.orig_loc,
6459            self.buf.as_ptr().wrapping_add(pos) as usize,
6460        )))
6461    }
6462}
6463impl<'a> std::fmt::Debug for IterableGenAttrs<'_> {
6464    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6465        let mut fmt = f.debug_struct("GenAttrs");
6466        for attr in self.clone() {
6467            let attr = match attr {
6468                Ok(a) => a,
6469                Err(err) => {
6470                    fmt.finish()?;
6471                    f.write_str("Err(")?;
6472                    err.fmt(f)?;
6473                    return f.write_str(")");
6474                }
6475            };
6476            match attr {
6477                GenAttrs::Id(val) => fmt.field("Id", &val),
6478                GenAttrs::ProcPid(val) => fmt.field("ProcPid", &val),
6479                GenAttrs::ProcName(val) => fmt.field("ProcName", &val),
6480            };
6481        }
6482        fmt.finish()
6483    }
6484}
6485impl IterableGenAttrs<'_> {
6486    pub fn lookup_attr(
6487        &self,
6488        offset: usize,
6489        missing_type: Option<u16>,
6490    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
6491        let mut stack = Vec::new();
6492        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
6493        if missing_type.is_some() && cur == offset {
6494            stack.push(("GenAttrs", offset));
6495            return (
6496                stack,
6497                missing_type.and_then(|t| GenAttrs::attr_from_type(t)),
6498            );
6499        }
6500        if cur > offset || cur + self.buf.len() < offset {
6501            return (stack, None);
6502        }
6503        let mut attrs = self.clone();
6504        let mut last_off = cur + attrs.pos;
6505        while let Some(attr) = attrs.next() {
6506            let Ok(attr) = attr else { break };
6507            match attr {
6508                GenAttrs::Id(val) => {
6509                    if last_off == offset {
6510                        stack.push(("Id", last_off));
6511                        break;
6512                    }
6513                }
6514                GenAttrs::ProcPid(val) => {
6515                    if last_off == offset {
6516                        stack.push(("ProcPid", last_off));
6517                        break;
6518                    }
6519                }
6520                GenAttrs::ProcName(val) => {
6521                    if last_off == offset {
6522                        stack.push(("ProcName", last_off));
6523                        break;
6524                    }
6525                }
6526                _ => {}
6527            };
6528            last_off = cur + attrs.pos;
6529        }
6530        if !stack.is_empty() {
6531            stack.push(("GenAttrs", cur));
6532        }
6533        (stack, None)
6534    }
6535}
6536#[derive(Clone)]
6537pub enum ObjAttrs<'a> {
6538    #[doc = "name of the table containing the expression"]
6539    Table(&'a CStr),
6540    #[doc = "name of this expression type"]
6541    Name(&'a CStr),
6542    #[doc = "stateful object type\nAssociated type: [`ObjectType`] (enum)"]
6543    Type(u32),
6544    #[doc = "stateful object data"]
6545    Data(ObjData<'a>),
6546    #[doc = "number of references to this expression"]
6547    Use(u32),
6548    #[doc = "object handle"]
6549    Handle(u64),
6550    Pad(&'a [u8]),
6551    #[doc = "user data"]
6552    Userdata(&'a [u8]),
6553}
6554impl<'a> IterableObjAttrs<'a> {
6555    #[doc = "name of the table containing the expression"]
6556    pub fn get_table(&self) -> Result<&'a CStr, ErrorContext> {
6557        let mut iter = self.clone();
6558        iter.pos = 0;
6559        for attr in iter {
6560            if let ObjAttrs::Table(val) = attr? {
6561                return Ok(val);
6562            }
6563        }
6564        Err(ErrorContext::new_missing(
6565            "ObjAttrs",
6566            "Table",
6567            self.orig_loc,
6568            self.buf.as_ptr() as usize,
6569        ))
6570    }
6571    #[doc = "name of this expression type"]
6572    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
6573        let mut iter = self.clone();
6574        iter.pos = 0;
6575        for attr in iter {
6576            if let ObjAttrs::Name(val) = attr? {
6577                return Ok(val);
6578            }
6579        }
6580        Err(ErrorContext::new_missing(
6581            "ObjAttrs",
6582            "Name",
6583            self.orig_loc,
6584            self.buf.as_ptr() as usize,
6585        ))
6586    }
6587    #[doc = "stateful object type\nAssociated type: [`ObjectType`] (enum)"]
6588    pub fn get_type(&self) -> Result<u32, ErrorContext> {
6589        let mut iter = self.clone();
6590        iter.pos = 0;
6591        for attr in iter {
6592            if let ObjAttrs::Type(val) = attr? {
6593                return Ok(val);
6594            }
6595        }
6596        Err(ErrorContext::new_missing(
6597            "ObjAttrs",
6598            "Type",
6599            self.orig_loc,
6600            self.buf.as_ptr() as usize,
6601        ))
6602    }
6603    #[doc = "stateful object data"]
6604    pub fn get_data(&self) -> Result<ObjData<'a>, ErrorContext> {
6605        let mut iter = self.clone();
6606        iter.pos = 0;
6607        for attr in iter {
6608            if let ObjAttrs::Data(val) = attr? {
6609                return Ok(val);
6610            }
6611        }
6612        Err(ErrorContext::new_missing(
6613            "ObjAttrs",
6614            "Data",
6615            self.orig_loc,
6616            self.buf.as_ptr() as usize,
6617        ))
6618    }
6619    #[doc = "number of references to this expression"]
6620    pub fn get_use(&self) -> Result<u32, ErrorContext> {
6621        let mut iter = self.clone();
6622        iter.pos = 0;
6623        for attr in iter {
6624            if let ObjAttrs::Use(val) = attr? {
6625                return Ok(val);
6626            }
6627        }
6628        Err(ErrorContext::new_missing(
6629            "ObjAttrs",
6630            "Use",
6631            self.orig_loc,
6632            self.buf.as_ptr() as usize,
6633        ))
6634    }
6635    #[doc = "object handle"]
6636    pub fn get_handle(&self) -> Result<u64, ErrorContext> {
6637        let mut iter = self.clone();
6638        iter.pos = 0;
6639        for attr in iter {
6640            if let ObjAttrs::Handle(val) = attr? {
6641                return Ok(val);
6642            }
6643        }
6644        Err(ErrorContext::new_missing(
6645            "ObjAttrs",
6646            "Handle",
6647            self.orig_loc,
6648            self.buf.as_ptr() as usize,
6649        ))
6650    }
6651    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
6652        let mut iter = self.clone();
6653        iter.pos = 0;
6654        for attr in iter {
6655            if let ObjAttrs::Pad(val) = attr? {
6656                return Ok(val);
6657            }
6658        }
6659        Err(ErrorContext::new_missing(
6660            "ObjAttrs",
6661            "Pad",
6662            self.orig_loc,
6663            self.buf.as_ptr() as usize,
6664        ))
6665    }
6666    #[doc = "user data"]
6667    pub fn get_userdata(&self) -> Result<&'a [u8], ErrorContext> {
6668        let mut iter = self.clone();
6669        iter.pos = 0;
6670        for attr in iter {
6671            if let ObjAttrs::Userdata(val) = attr? {
6672                return Ok(val);
6673            }
6674        }
6675        Err(ErrorContext::new_missing(
6676            "ObjAttrs",
6677            "Userdata",
6678            self.orig_loc,
6679            self.buf.as_ptr() as usize,
6680        ))
6681    }
6682}
6683#[derive(Debug, Clone)]
6684pub enum ObjData<'a> {
6685    Counter(IterableCounterAttrs<'a>),
6686    Quota(IterableQuotaAttrs<'a>),
6687}
6688impl<'a> ObjData<'a> {
6689    fn select_with_loc(selector: u32, buf: &'a [u8], loc: usize) -> Option<Self> {
6690        match selector {
6691            val if val == ObjectType::Counter as u32 => {
6692                Some(ObjData::Counter(IterableCounterAttrs::with_loc(buf, loc)))
6693            }
6694            val if val == ObjectType::Quota as u32 => {
6695                Some(ObjData::Quota(IterableQuotaAttrs::with_loc(buf, loc)))
6696            }
6697            _ => None,
6698        }
6699    }
6700}
6701impl ObjAttrs<'_> {
6702    pub fn new<'a>(buf: &'a [u8]) -> IterableObjAttrs<'a> {
6703        IterableObjAttrs::with_loc(buf, buf.as_ptr() as usize)
6704    }
6705    fn attr_from_type(r#type: u16) -> Option<&'static str> {
6706        let res = match r#type {
6707            1u16 => "Table",
6708            2u16 => "Name",
6709            3u16 => "Type",
6710            4u16 => "Data",
6711            5u16 => "Use",
6712            6u16 => "Handle",
6713            7u16 => "Pad",
6714            8u16 => "Userdata",
6715            _ => return None,
6716        };
6717        Some(res)
6718    }
6719}
6720#[derive(Clone, Copy, Default)]
6721pub struct IterableObjAttrs<'a> {
6722    buf: &'a [u8],
6723    pos: usize,
6724    orig_loc: usize,
6725}
6726impl<'a> IterableObjAttrs<'a> {
6727    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
6728        Self {
6729            buf,
6730            pos: 0,
6731            orig_loc,
6732        }
6733    }
6734    pub fn get_buf(&self) -> &'a [u8] {
6735        self.buf
6736    }
6737}
6738impl<'a> Iterator for IterableObjAttrs<'a> {
6739    type Item = Result<ObjAttrs<'a>, ErrorContext>;
6740    fn next(&mut self) -> Option<Self::Item> {
6741        let pos = self.pos;
6742        let mut r#type;
6743        loop {
6744            r#type = None;
6745            if self.buf.len() == self.pos {
6746                return None;
6747            }
6748            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
6749                break;
6750            };
6751            r#type = Some(header.r#type);
6752            let res = match header.r#type {
6753                1u16 => ObjAttrs::Table({
6754                    let res = CStr::from_bytes_with_nul(next).ok();
6755                    let Some(val) = res else { break };
6756                    val
6757                }),
6758                2u16 => ObjAttrs::Name({
6759                    let res = CStr::from_bytes_with_nul(next).ok();
6760                    let Some(val) = res else { break };
6761                    val
6762                }),
6763                3u16 => ObjAttrs::Type({
6764                    let res = parse_be_u32(next);
6765                    let Some(val) = res else { break };
6766                    val
6767                }),
6768                4u16 => ObjAttrs::Data({
6769                    let res = {
6770                        let Ok(selector) = self.get_type() else { break };
6771                        match ObjData::select_with_loc(selector, next, self.orig_loc) {
6772                            Some(sub) => Some(sub),
6773                            None if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
6774                            None => continue,
6775                        }
6776                    };
6777                    let Some(val) = res else { break };
6778                    val
6779                }),
6780                5u16 => ObjAttrs::Use({
6781                    let res = parse_be_u32(next);
6782                    let Some(val) = res else { break };
6783                    val
6784                }),
6785                6u16 => ObjAttrs::Handle({
6786                    let res = parse_be_u64(next);
6787                    let Some(val) = res else { break };
6788                    val
6789                }),
6790                7u16 => ObjAttrs::Pad({
6791                    let res = Some(next);
6792                    let Some(val) = res else { break };
6793                    val
6794                }),
6795                8u16 => ObjAttrs::Userdata({
6796                    let res = Some(next);
6797                    let Some(val) = res else { break };
6798                    val
6799                }),
6800                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
6801                n => continue,
6802            };
6803            return Some(Ok(res));
6804        }
6805        Some(Err(ErrorContext::new(
6806            "ObjAttrs",
6807            r#type.and_then(|t| ObjAttrs::attr_from_type(t)),
6808            self.orig_loc,
6809            self.buf.as_ptr().wrapping_add(pos) as usize,
6810        )))
6811    }
6812}
6813impl<'a> std::fmt::Debug for IterableObjAttrs<'_> {
6814    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6815        let mut fmt = f.debug_struct("ObjAttrs");
6816        for attr in self.clone() {
6817            let attr = match attr {
6818                Ok(a) => a,
6819                Err(err) => {
6820                    fmt.finish()?;
6821                    f.write_str("Err(")?;
6822                    err.fmt(f)?;
6823                    return f.write_str(")");
6824                }
6825            };
6826            match attr {
6827                ObjAttrs::Table(val) => fmt.field("Table", &val),
6828                ObjAttrs::Name(val) => fmt.field("Name", &val),
6829                ObjAttrs::Type(val) => {
6830                    fmt.field("Type", &FormatEnum(val.into(), ObjectType::from_value))
6831                }
6832                ObjAttrs::Data(val) => fmt.field("Data", &val),
6833                ObjAttrs::Use(val) => fmt.field("Use", &val),
6834                ObjAttrs::Handle(val) => fmt.field("Handle", &val),
6835                ObjAttrs::Pad(val) => fmt.field("Pad", &val),
6836                ObjAttrs::Userdata(val) => fmt.field("Userdata", &val),
6837            };
6838        }
6839        fmt.finish()
6840    }
6841}
6842impl IterableObjAttrs<'_> {
6843    pub fn lookup_attr(
6844        &self,
6845        offset: usize,
6846        missing_type: Option<u16>,
6847    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
6848        let mut stack = Vec::new();
6849        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
6850        if missing_type.is_some() && cur == offset {
6851            stack.push(("ObjAttrs", offset));
6852            return (
6853                stack,
6854                missing_type.and_then(|t| ObjAttrs::attr_from_type(t)),
6855            );
6856        }
6857        if cur > offset || cur + self.buf.len() < offset {
6858            return (stack, None);
6859        }
6860        let mut attrs = self.clone();
6861        let mut last_off = cur + attrs.pos;
6862        while let Some(attr) = attrs.next() {
6863            let Ok(attr) = attr else { break };
6864            match attr {
6865                ObjAttrs::Table(val) => {
6866                    if last_off == offset {
6867                        stack.push(("Table", last_off));
6868                        break;
6869                    }
6870                }
6871                ObjAttrs::Name(val) => {
6872                    if last_off == offset {
6873                        stack.push(("Name", last_off));
6874                        break;
6875                    }
6876                }
6877                ObjAttrs::Type(val) => {
6878                    if last_off == offset {
6879                        stack.push(("Type", last_off));
6880                        break;
6881                    }
6882                }
6883                ObjAttrs::Data(val) => {
6884                    if last_off == offset {
6885                        stack.push(("Data", last_off));
6886                        break;
6887                    }
6888                }
6889                ObjAttrs::Use(val) => {
6890                    if last_off == offset {
6891                        stack.push(("Use", last_off));
6892                        break;
6893                    }
6894                }
6895                ObjAttrs::Handle(val) => {
6896                    if last_off == offset {
6897                        stack.push(("Handle", last_off));
6898                        break;
6899                    }
6900                }
6901                ObjAttrs::Pad(val) => {
6902                    if last_off == offset {
6903                        stack.push(("Pad", last_off));
6904                        break;
6905                    }
6906                }
6907                ObjAttrs::Userdata(val) => {
6908                    if last_off == offset {
6909                        stack.push(("Userdata", last_off));
6910                        break;
6911                    }
6912                }
6913                _ => {}
6914            };
6915            last_off = cur + attrs.pos;
6916        }
6917        if !stack.is_empty() {
6918            stack.push(("ObjAttrs", cur));
6919        }
6920        (stack, None)
6921    }
6922}
6923#[derive(Clone)]
6924pub enum QuotaAttrs<'a> {
6925    Bytes(u64),
6926    #[doc = "Associated type: [`QuotaFlags`] (enum)"]
6927    Flags(u32),
6928    Pad(&'a [u8]),
6929    Consumed(u64),
6930}
6931impl<'a> IterableQuotaAttrs<'a> {
6932    pub fn get_bytes(&self) -> Result<u64, ErrorContext> {
6933        let mut iter = self.clone();
6934        iter.pos = 0;
6935        for attr in iter {
6936            if let QuotaAttrs::Bytes(val) = attr? {
6937                return Ok(val);
6938            }
6939        }
6940        Err(ErrorContext::new_missing(
6941            "QuotaAttrs",
6942            "Bytes",
6943            self.orig_loc,
6944            self.buf.as_ptr() as usize,
6945        ))
6946    }
6947    #[doc = "Associated type: [`QuotaFlags`] (enum)"]
6948    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
6949        let mut iter = self.clone();
6950        iter.pos = 0;
6951        for attr in iter {
6952            if let QuotaAttrs::Flags(val) = attr? {
6953                return Ok(val);
6954            }
6955        }
6956        Err(ErrorContext::new_missing(
6957            "QuotaAttrs",
6958            "Flags",
6959            self.orig_loc,
6960            self.buf.as_ptr() as usize,
6961        ))
6962    }
6963    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
6964        let mut iter = self.clone();
6965        iter.pos = 0;
6966        for attr in iter {
6967            if let QuotaAttrs::Pad(val) = attr? {
6968                return Ok(val);
6969            }
6970        }
6971        Err(ErrorContext::new_missing(
6972            "QuotaAttrs",
6973            "Pad",
6974            self.orig_loc,
6975            self.buf.as_ptr() as usize,
6976        ))
6977    }
6978    pub fn get_consumed(&self) -> Result<u64, ErrorContext> {
6979        let mut iter = self.clone();
6980        iter.pos = 0;
6981        for attr in iter {
6982            if let QuotaAttrs::Consumed(val) = attr? {
6983                return Ok(val);
6984            }
6985        }
6986        Err(ErrorContext::new_missing(
6987            "QuotaAttrs",
6988            "Consumed",
6989            self.orig_loc,
6990            self.buf.as_ptr() as usize,
6991        ))
6992    }
6993}
6994impl QuotaAttrs<'_> {
6995    pub fn new<'a>(buf: &'a [u8]) -> IterableQuotaAttrs<'a> {
6996        IterableQuotaAttrs::with_loc(buf, buf.as_ptr() as usize)
6997    }
6998    fn attr_from_type(r#type: u16) -> Option<&'static str> {
6999        let res = match r#type {
7000            1u16 => "Bytes",
7001            2u16 => "Flags",
7002            3u16 => "Pad",
7003            4u16 => "Consumed",
7004            _ => return None,
7005        };
7006        Some(res)
7007    }
7008}
7009#[derive(Clone, Copy, Default)]
7010pub struct IterableQuotaAttrs<'a> {
7011    buf: &'a [u8],
7012    pos: usize,
7013    orig_loc: usize,
7014}
7015impl<'a> IterableQuotaAttrs<'a> {
7016    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
7017        Self {
7018            buf,
7019            pos: 0,
7020            orig_loc,
7021        }
7022    }
7023    pub fn get_buf(&self) -> &'a [u8] {
7024        self.buf
7025    }
7026}
7027impl<'a> Iterator for IterableQuotaAttrs<'a> {
7028    type Item = Result<QuotaAttrs<'a>, ErrorContext>;
7029    fn next(&mut self) -> Option<Self::Item> {
7030        let pos = self.pos;
7031        let mut r#type;
7032        loop {
7033            r#type = None;
7034            if self.buf.len() == self.pos {
7035                return None;
7036            }
7037            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
7038                break;
7039            };
7040            r#type = Some(header.r#type);
7041            let res = match header.r#type {
7042                1u16 => QuotaAttrs::Bytes({
7043                    let res = parse_be_u64(next);
7044                    let Some(val) = res else { break };
7045                    val
7046                }),
7047                2u16 => QuotaAttrs::Flags({
7048                    let res = parse_be_u32(next);
7049                    let Some(val) = res else { break };
7050                    val
7051                }),
7052                3u16 => QuotaAttrs::Pad({
7053                    let res = Some(next);
7054                    let Some(val) = res else { break };
7055                    val
7056                }),
7057                4u16 => QuotaAttrs::Consumed({
7058                    let res = parse_be_u64(next);
7059                    let Some(val) = res else { break };
7060                    val
7061                }),
7062                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
7063                n => continue,
7064            };
7065            return Some(Ok(res));
7066        }
7067        Some(Err(ErrorContext::new(
7068            "QuotaAttrs",
7069            r#type.and_then(|t| QuotaAttrs::attr_from_type(t)),
7070            self.orig_loc,
7071            self.buf.as_ptr().wrapping_add(pos) as usize,
7072        )))
7073    }
7074}
7075impl<'a> std::fmt::Debug for IterableQuotaAttrs<'_> {
7076    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7077        let mut fmt = f.debug_struct("QuotaAttrs");
7078        for attr in self.clone() {
7079            let attr = match attr {
7080                Ok(a) => a,
7081                Err(err) => {
7082                    fmt.finish()?;
7083                    f.write_str("Err(")?;
7084                    err.fmt(f)?;
7085                    return f.write_str(")");
7086                }
7087            };
7088            match attr {
7089                QuotaAttrs::Bytes(val) => fmt.field("Bytes", &val),
7090                QuotaAttrs::Flags(val) => {
7091                    fmt.field("Flags", &FormatFlags(val.into(), QuotaFlags::from_value))
7092                }
7093                QuotaAttrs::Pad(val) => fmt.field("Pad", &val),
7094                QuotaAttrs::Consumed(val) => fmt.field("Consumed", &val),
7095            };
7096        }
7097        fmt.finish()
7098    }
7099}
7100impl IterableQuotaAttrs<'_> {
7101    pub fn lookup_attr(
7102        &self,
7103        offset: usize,
7104        missing_type: Option<u16>,
7105    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
7106        let mut stack = Vec::new();
7107        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
7108        if missing_type.is_some() && cur == offset {
7109            stack.push(("QuotaAttrs", offset));
7110            return (
7111                stack,
7112                missing_type.and_then(|t| QuotaAttrs::attr_from_type(t)),
7113            );
7114        }
7115        if cur > offset || cur + self.buf.len() < offset {
7116            return (stack, None);
7117        }
7118        let mut attrs = self.clone();
7119        let mut last_off = cur + attrs.pos;
7120        while let Some(attr) = attrs.next() {
7121            let Ok(attr) = attr else { break };
7122            match attr {
7123                QuotaAttrs::Bytes(val) => {
7124                    if last_off == offset {
7125                        stack.push(("Bytes", last_off));
7126                        break;
7127                    }
7128                }
7129                QuotaAttrs::Flags(val) => {
7130                    if last_off == offset {
7131                        stack.push(("Flags", last_off));
7132                        break;
7133                    }
7134                }
7135                QuotaAttrs::Pad(val) => {
7136                    if last_off == offset {
7137                        stack.push(("Pad", last_off));
7138                        break;
7139                    }
7140                }
7141                QuotaAttrs::Consumed(val) => {
7142                    if last_off == offset {
7143                        stack.push(("Consumed", last_off));
7144                        break;
7145                    }
7146                }
7147                _ => {}
7148            };
7149            last_off = cur + attrs.pos;
7150        }
7151        if !stack.is_empty() {
7152            stack.push(("QuotaAttrs", cur));
7153        }
7154        (stack, None)
7155    }
7156}
7157#[derive(Clone)]
7158pub enum FlowtableAttrs<'a> {
7159    Table(&'a CStr),
7160    Name(&'a CStr),
7161    Hook(IterableFlowtableHookAttrs<'a>),
7162    Use(u32),
7163    Handle(u64),
7164    Pad(&'a [u8]),
7165    Flags(u32),
7166}
7167impl<'a> IterableFlowtableAttrs<'a> {
7168    pub fn get_table(&self) -> Result<&'a CStr, ErrorContext> {
7169        let mut iter = self.clone();
7170        iter.pos = 0;
7171        for attr in iter {
7172            if let FlowtableAttrs::Table(val) = attr? {
7173                return Ok(val);
7174            }
7175        }
7176        Err(ErrorContext::new_missing(
7177            "FlowtableAttrs",
7178            "Table",
7179            self.orig_loc,
7180            self.buf.as_ptr() as usize,
7181        ))
7182    }
7183    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
7184        let mut iter = self.clone();
7185        iter.pos = 0;
7186        for attr in iter {
7187            if let FlowtableAttrs::Name(val) = attr? {
7188                return Ok(val);
7189            }
7190        }
7191        Err(ErrorContext::new_missing(
7192            "FlowtableAttrs",
7193            "Name",
7194            self.orig_loc,
7195            self.buf.as_ptr() as usize,
7196        ))
7197    }
7198    pub fn get_hook(&self) -> Result<IterableFlowtableHookAttrs<'a>, ErrorContext> {
7199        let mut iter = self.clone();
7200        iter.pos = 0;
7201        for attr in iter {
7202            if let FlowtableAttrs::Hook(val) = attr? {
7203                return Ok(val);
7204            }
7205        }
7206        Err(ErrorContext::new_missing(
7207            "FlowtableAttrs",
7208            "Hook",
7209            self.orig_loc,
7210            self.buf.as_ptr() as usize,
7211        ))
7212    }
7213    pub fn get_use(&self) -> Result<u32, ErrorContext> {
7214        let mut iter = self.clone();
7215        iter.pos = 0;
7216        for attr in iter {
7217            if let FlowtableAttrs::Use(val) = attr? {
7218                return Ok(val);
7219            }
7220        }
7221        Err(ErrorContext::new_missing(
7222            "FlowtableAttrs",
7223            "Use",
7224            self.orig_loc,
7225            self.buf.as_ptr() as usize,
7226        ))
7227    }
7228    pub fn get_handle(&self) -> Result<u64, ErrorContext> {
7229        let mut iter = self.clone();
7230        iter.pos = 0;
7231        for attr in iter {
7232            if let FlowtableAttrs::Handle(val) = attr? {
7233                return Ok(val);
7234            }
7235        }
7236        Err(ErrorContext::new_missing(
7237            "FlowtableAttrs",
7238            "Handle",
7239            self.orig_loc,
7240            self.buf.as_ptr() as usize,
7241        ))
7242    }
7243    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
7244        let mut iter = self.clone();
7245        iter.pos = 0;
7246        for attr in iter {
7247            if let FlowtableAttrs::Pad(val) = attr? {
7248                return Ok(val);
7249            }
7250        }
7251        Err(ErrorContext::new_missing(
7252            "FlowtableAttrs",
7253            "Pad",
7254            self.orig_loc,
7255            self.buf.as_ptr() as usize,
7256        ))
7257    }
7258    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
7259        let mut iter = self.clone();
7260        iter.pos = 0;
7261        for attr in iter {
7262            if let FlowtableAttrs::Flags(val) = attr? {
7263                return Ok(val);
7264            }
7265        }
7266        Err(ErrorContext::new_missing(
7267            "FlowtableAttrs",
7268            "Flags",
7269            self.orig_loc,
7270            self.buf.as_ptr() as usize,
7271        ))
7272    }
7273}
7274impl FlowtableAttrs<'_> {
7275    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowtableAttrs<'a> {
7276        IterableFlowtableAttrs::with_loc(buf, buf.as_ptr() as usize)
7277    }
7278    fn attr_from_type(r#type: u16) -> Option<&'static str> {
7279        let res = match r#type {
7280            1u16 => "Table",
7281            2u16 => "Name",
7282            3u16 => "Hook",
7283            4u16 => "Use",
7284            5u16 => "Handle",
7285            6u16 => "Pad",
7286            7u16 => "Flags",
7287            _ => return None,
7288        };
7289        Some(res)
7290    }
7291}
7292#[derive(Clone, Copy, Default)]
7293pub struct IterableFlowtableAttrs<'a> {
7294    buf: &'a [u8],
7295    pos: usize,
7296    orig_loc: usize,
7297}
7298impl<'a> IterableFlowtableAttrs<'a> {
7299    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
7300        Self {
7301            buf,
7302            pos: 0,
7303            orig_loc,
7304        }
7305    }
7306    pub fn get_buf(&self) -> &'a [u8] {
7307        self.buf
7308    }
7309}
7310impl<'a> Iterator for IterableFlowtableAttrs<'a> {
7311    type Item = Result<FlowtableAttrs<'a>, ErrorContext>;
7312    fn next(&mut self) -> Option<Self::Item> {
7313        let pos = self.pos;
7314        let mut r#type;
7315        loop {
7316            r#type = None;
7317            if self.buf.len() == self.pos {
7318                return None;
7319            }
7320            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
7321                break;
7322            };
7323            r#type = Some(header.r#type);
7324            let res = match header.r#type {
7325                1u16 => FlowtableAttrs::Table({
7326                    let res = CStr::from_bytes_with_nul(next).ok();
7327                    let Some(val) = res else { break };
7328                    val
7329                }),
7330                2u16 => FlowtableAttrs::Name({
7331                    let res = CStr::from_bytes_with_nul(next).ok();
7332                    let Some(val) = res else { break };
7333                    val
7334                }),
7335                3u16 => FlowtableAttrs::Hook({
7336                    let res = Some(IterableFlowtableHookAttrs::with_loc(next, self.orig_loc));
7337                    let Some(val) = res else { break };
7338                    val
7339                }),
7340                4u16 => FlowtableAttrs::Use({
7341                    let res = parse_be_u32(next);
7342                    let Some(val) = res else { break };
7343                    val
7344                }),
7345                5u16 => FlowtableAttrs::Handle({
7346                    let res = parse_be_u64(next);
7347                    let Some(val) = res else { break };
7348                    val
7349                }),
7350                6u16 => FlowtableAttrs::Pad({
7351                    let res = Some(next);
7352                    let Some(val) = res else { break };
7353                    val
7354                }),
7355                7u16 => FlowtableAttrs::Flags({
7356                    let res = parse_be_u32(next);
7357                    let Some(val) = res else { break };
7358                    val
7359                }),
7360                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
7361                n => continue,
7362            };
7363            return Some(Ok(res));
7364        }
7365        Some(Err(ErrorContext::new(
7366            "FlowtableAttrs",
7367            r#type.and_then(|t| FlowtableAttrs::attr_from_type(t)),
7368            self.orig_loc,
7369            self.buf.as_ptr().wrapping_add(pos) as usize,
7370        )))
7371    }
7372}
7373impl<'a> std::fmt::Debug for IterableFlowtableAttrs<'_> {
7374    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7375        let mut fmt = f.debug_struct("FlowtableAttrs");
7376        for attr in self.clone() {
7377            let attr = match attr {
7378                Ok(a) => a,
7379                Err(err) => {
7380                    fmt.finish()?;
7381                    f.write_str("Err(")?;
7382                    err.fmt(f)?;
7383                    return f.write_str(")");
7384                }
7385            };
7386            match attr {
7387                FlowtableAttrs::Table(val) => fmt.field("Table", &val),
7388                FlowtableAttrs::Name(val) => fmt.field("Name", &val),
7389                FlowtableAttrs::Hook(val) => fmt.field("Hook", &val),
7390                FlowtableAttrs::Use(val) => fmt.field("Use", &val),
7391                FlowtableAttrs::Handle(val) => fmt.field("Handle", &val),
7392                FlowtableAttrs::Pad(val) => fmt.field("Pad", &val),
7393                FlowtableAttrs::Flags(val) => fmt.field("Flags", &val),
7394            };
7395        }
7396        fmt.finish()
7397    }
7398}
7399impl IterableFlowtableAttrs<'_> {
7400    pub fn lookup_attr(
7401        &self,
7402        offset: usize,
7403        missing_type: Option<u16>,
7404    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
7405        let mut stack = Vec::new();
7406        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
7407        if missing_type.is_some() && cur == offset {
7408            stack.push(("FlowtableAttrs", offset));
7409            return (
7410                stack,
7411                missing_type.and_then(|t| FlowtableAttrs::attr_from_type(t)),
7412            );
7413        }
7414        if cur > offset || cur + self.buf.len() < offset {
7415            return (stack, None);
7416        }
7417        let mut attrs = self.clone();
7418        let mut last_off = cur + attrs.pos;
7419        let mut missing = None;
7420        while let Some(attr) = attrs.next() {
7421            let Ok(attr) = attr else { break };
7422            match attr {
7423                FlowtableAttrs::Table(val) => {
7424                    if last_off == offset {
7425                        stack.push(("Table", last_off));
7426                        break;
7427                    }
7428                }
7429                FlowtableAttrs::Name(val) => {
7430                    if last_off == offset {
7431                        stack.push(("Name", last_off));
7432                        break;
7433                    }
7434                }
7435                FlowtableAttrs::Hook(val) => {
7436                    (stack, missing) = val.lookup_attr(offset, missing_type);
7437                    if !stack.is_empty() {
7438                        break;
7439                    }
7440                }
7441                FlowtableAttrs::Use(val) => {
7442                    if last_off == offset {
7443                        stack.push(("Use", last_off));
7444                        break;
7445                    }
7446                }
7447                FlowtableAttrs::Handle(val) => {
7448                    if last_off == offset {
7449                        stack.push(("Handle", last_off));
7450                        break;
7451                    }
7452                }
7453                FlowtableAttrs::Pad(val) => {
7454                    if last_off == offset {
7455                        stack.push(("Pad", last_off));
7456                        break;
7457                    }
7458                }
7459                FlowtableAttrs::Flags(val) => {
7460                    if last_off == offset {
7461                        stack.push(("Flags", last_off));
7462                        break;
7463                    }
7464                }
7465                _ => {}
7466            };
7467            last_off = cur + attrs.pos;
7468        }
7469        if !stack.is_empty() {
7470            stack.push(("FlowtableAttrs", cur));
7471        }
7472        (stack, missing)
7473    }
7474}
7475#[derive(Clone)]
7476pub enum FlowtableHookAttrs<'a> {
7477    Num(u32),
7478    Priority(u32),
7479    Devs(IterableHookDevAttrs<'a>),
7480}
7481impl<'a> IterableFlowtableHookAttrs<'a> {
7482    pub fn get_num(&self) -> Result<u32, ErrorContext> {
7483        let mut iter = self.clone();
7484        iter.pos = 0;
7485        for attr in iter {
7486            if let FlowtableHookAttrs::Num(val) = attr? {
7487                return Ok(val);
7488            }
7489        }
7490        Err(ErrorContext::new_missing(
7491            "FlowtableHookAttrs",
7492            "Num",
7493            self.orig_loc,
7494            self.buf.as_ptr() as usize,
7495        ))
7496    }
7497    pub fn get_priority(&self) -> Result<u32, ErrorContext> {
7498        let mut iter = self.clone();
7499        iter.pos = 0;
7500        for attr in iter {
7501            if let FlowtableHookAttrs::Priority(val) = attr? {
7502                return Ok(val);
7503            }
7504        }
7505        Err(ErrorContext::new_missing(
7506            "FlowtableHookAttrs",
7507            "Priority",
7508            self.orig_loc,
7509            self.buf.as_ptr() as usize,
7510        ))
7511    }
7512    pub fn get_devs(&self) -> Result<IterableHookDevAttrs<'a>, ErrorContext> {
7513        let mut iter = self.clone();
7514        iter.pos = 0;
7515        for attr in iter {
7516            if let FlowtableHookAttrs::Devs(val) = attr? {
7517                return Ok(val);
7518            }
7519        }
7520        Err(ErrorContext::new_missing(
7521            "FlowtableHookAttrs",
7522            "Devs",
7523            self.orig_loc,
7524            self.buf.as_ptr() as usize,
7525        ))
7526    }
7527}
7528impl FlowtableHookAttrs<'_> {
7529    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowtableHookAttrs<'a> {
7530        IterableFlowtableHookAttrs::with_loc(buf, buf.as_ptr() as usize)
7531    }
7532    fn attr_from_type(r#type: u16) -> Option<&'static str> {
7533        let res = match r#type {
7534            1u16 => "Num",
7535            2u16 => "Priority",
7536            3u16 => "Devs",
7537            _ => return None,
7538        };
7539        Some(res)
7540    }
7541}
7542#[derive(Clone, Copy, Default)]
7543pub struct IterableFlowtableHookAttrs<'a> {
7544    buf: &'a [u8],
7545    pos: usize,
7546    orig_loc: usize,
7547}
7548impl<'a> IterableFlowtableHookAttrs<'a> {
7549    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
7550        Self {
7551            buf,
7552            pos: 0,
7553            orig_loc,
7554        }
7555    }
7556    pub fn get_buf(&self) -> &'a [u8] {
7557        self.buf
7558    }
7559}
7560impl<'a> Iterator for IterableFlowtableHookAttrs<'a> {
7561    type Item = Result<FlowtableHookAttrs<'a>, ErrorContext>;
7562    fn next(&mut self) -> Option<Self::Item> {
7563        let pos = self.pos;
7564        let mut r#type;
7565        loop {
7566            r#type = None;
7567            if self.buf.len() == self.pos {
7568                return None;
7569            }
7570            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
7571                break;
7572            };
7573            r#type = Some(header.r#type);
7574            let res = match header.r#type {
7575                1u16 => FlowtableHookAttrs::Num({
7576                    let res = parse_be_u32(next);
7577                    let Some(val) = res else { break };
7578                    val
7579                }),
7580                2u16 => FlowtableHookAttrs::Priority({
7581                    let res = parse_be_u32(next);
7582                    let Some(val) = res else { break };
7583                    val
7584                }),
7585                3u16 => FlowtableHookAttrs::Devs({
7586                    let res = Some(IterableHookDevAttrs::with_loc(next, self.orig_loc));
7587                    let Some(val) = res else { break };
7588                    val
7589                }),
7590                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
7591                n => continue,
7592            };
7593            return Some(Ok(res));
7594        }
7595        Some(Err(ErrorContext::new(
7596            "FlowtableHookAttrs",
7597            r#type.and_then(|t| FlowtableHookAttrs::attr_from_type(t)),
7598            self.orig_loc,
7599            self.buf.as_ptr().wrapping_add(pos) as usize,
7600        )))
7601    }
7602}
7603impl<'a> std::fmt::Debug for IterableFlowtableHookAttrs<'_> {
7604    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7605        let mut fmt = f.debug_struct("FlowtableHookAttrs");
7606        for attr in self.clone() {
7607            let attr = match attr {
7608                Ok(a) => a,
7609                Err(err) => {
7610                    fmt.finish()?;
7611                    f.write_str("Err(")?;
7612                    err.fmt(f)?;
7613                    return f.write_str(")");
7614                }
7615            };
7616            match attr {
7617                FlowtableHookAttrs::Num(val) => fmt.field("Num", &val),
7618                FlowtableHookAttrs::Priority(val) => fmt.field("Priority", &val),
7619                FlowtableHookAttrs::Devs(val) => fmt.field("Devs", &val),
7620            };
7621        }
7622        fmt.finish()
7623    }
7624}
7625impl IterableFlowtableHookAttrs<'_> {
7626    pub fn lookup_attr(
7627        &self,
7628        offset: usize,
7629        missing_type: Option<u16>,
7630    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
7631        let mut stack = Vec::new();
7632        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
7633        if missing_type.is_some() && cur == offset {
7634            stack.push(("FlowtableHookAttrs", offset));
7635            return (
7636                stack,
7637                missing_type.and_then(|t| FlowtableHookAttrs::attr_from_type(t)),
7638            );
7639        }
7640        if cur > offset || cur + self.buf.len() < offset {
7641            return (stack, None);
7642        }
7643        let mut attrs = self.clone();
7644        let mut last_off = cur + attrs.pos;
7645        let mut missing = None;
7646        while let Some(attr) = attrs.next() {
7647            let Ok(attr) = attr else { break };
7648            match attr {
7649                FlowtableHookAttrs::Num(val) => {
7650                    if last_off == offset {
7651                        stack.push(("Num", last_off));
7652                        break;
7653                    }
7654                }
7655                FlowtableHookAttrs::Priority(val) => {
7656                    if last_off == offset {
7657                        stack.push(("Priority", last_off));
7658                        break;
7659                    }
7660                }
7661                FlowtableHookAttrs::Devs(val) => {
7662                    (stack, missing) = val.lookup_attr(offset, missing_type);
7663                    if !stack.is_empty() {
7664                        break;
7665                    }
7666                }
7667                _ => {}
7668            };
7669            last_off = cur + attrs.pos;
7670        }
7671        if !stack.is_empty() {
7672            stack.push(("FlowtableHookAttrs", cur));
7673        }
7674        (stack, missing)
7675    }
7676}
7677#[derive(Clone)]
7678pub enum ExprBitwiseAttrs<'a> {
7679    Sreg(u32),
7680    Dreg(u32),
7681    Len(u32),
7682    Mask(IterableDataAttrs<'a>),
7683    Xor(IterableDataAttrs<'a>),
7684    #[doc = "Associated type: [`BitwiseOps`] (enum)"]
7685    Op(u32),
7686    Data(IterableDataAttrs<'a>),
7687}
7688impl<'a> IterableExprBitwiseAttrs<'a> {
7689    pub fn get_sreg(&self) -> Result<u32, ErrorContext> {
7690        let mut iter = self.clone();
7691        iter.pos = 0;
7692        for attr in iter {
7693            if let ExprBitwiseAttrs::Sreg(val) = attr? {
7694                return Ok(val);
7695            }
7696        }
7697        Err(ErrorContext::new_missing(
7698            "ExprBitwiseAttrs",
7699            "Sreg",
7700            self.orig_loc,
7701            self.buf.as_ptr() as usize,
7702        ))
7703    }
7704    pub fn get_dreg(&self) -> Result<u32, ErrorContext> {
7705        let mut iter = self.clone();
7706        iter.pos = 0;
7707        for attr in iter {
7708            if let ExprBitwiseAttrs::Dreg(val) = attr? {
7709                return Ok(val);
7710            }
7711        }
7712        Err(ErrorContext::new_missing(
7713            "ExprBitwiseAttrs",
7714            "Dreg",
7715            self.orig_loc,
7716            self.buf.as_ptr() as usize,
7717        ))
7718    }
7719    pub fn get_len(&self) -> Result<u32, ErrorContext> {
7720        let mut iter = self.clone();
7721        iter.pos = 0;
7722        for attr in iter {
7723            if let ExprBitwiseAttrs::Len(val) = attr? {
7724                return Ok(val);
7725            }
7726        }
7727        Err(ErrorContext::new_missing(
7728            "ExprBitwiseAttrs",
7729            "Len",
7730            self.orig_loc,
7731            self.buf.as_ptr() as usize,
7732        ))
7733    }
7734    pub fn get_mask(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
7735        let mut iter = self.clone();
7736        iter.pos = 0;
7737        for attr in iter {
7738            if let ExprBitwiseAttrs::Mask(val) = attr? {
7739                return Ok(val);
7740            }
7741        }
7742        Err(ErrorContext::new_missing(
7743            "ExprBitwiseAttrs",
7744            "Mask",
7745            self.orig_loc,
7746            self.buf.as_ptr() as usize,
7747        ))
7748    }
7749    pub fn get_xor(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
7750        let mut iter = self.clone();
7751        iter.pos = 0;
7752        for attr in iter {
7753            if let ExprBitwiseAttrs::Xor(val) = attr? {
7754                return Ok(val);
7755            }
7756        }
7757        Err(ErrorContext::new_missing(
7758            "ExprBitwiseAttrs",
7759            "Xor",
7760            self.orig_loc,
7761            self.buf.as_ptr() as usize,
7762        ))
7763    }
7764    #[doc = "Associated type: [`BitwiseOps`] (enum)"]
7765    pub fn get_op(&self) -> Result<u32, ErrorContext> {
7766        let mut iter = self.clone();
7767        iter.pos = 0;
7768        for attr in iter {
7769            if let ExprBitwiseAttrs::Op(val) = attr? {
7770                return Ok(val);
7771            }
7772        }
7773        Err(ErrorContext::new_missing(
7774            "ExprBitwiseAttrs",
7775            "Op",
7776            self.orig_loc,
7777            self.buf.as_ptr() as usize,
7778        ))
7779    }
7780    pub fn get_data(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
7781        let mut iter = self.clone();
7782        iter.pos = 0;
7783        for attr in iter {
7784            if let ExprBitwiseAttrs::Data(val) = attr? {
7785                return Ok(val);
7786            }
7787        }
7788        Err(ErrorContext::new_missing(
7789            "ExprBitwiseAttrs",
7790            "Data",
7791            self.orig_loc,
7792            self.buf.as_ptr() as usize,
7793        ))
7794    }
7795}
7796impl ExprBitwiseAttrs<'_> {
7797    pub fn new<'a>(buf: &'a [u8]) -> IterableExprBitwiseAttrs<'a> {
7798        IterableExprBitwiseAttrs::with_loc(buf, buf.as_ptr() as usize)
7799    }
7800    fn attr_from_type(r#type: u16) -> Option<&'static str> {
7801        let res = match r#type {
7802            1u16 => "Sreg",
7803            2u16 => "Dreg",
7804            3u16 => "Len",
7805            4u16 => "Mask",
7806            5u16 => "Xor",
7807            6u16 => "Op",
7808            7u16 => "Data",
7809            _ => return None,
7810        };
7811        Some(res)
7812    }
7813}
7814#[derive(Clone, Copy, Default)]
7815pub struct IterableExprBitwiseAttrs<'a> {
7816    buf: &'a [u8],
7817    pos: usize,
7818    orig_loc: usize,
7819}
7820impl<'a> IterableExprBitwiseAttrs<'a> {
7821    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
7822        Self {
7823            buf,
7824            pos: 0,
7825            orig_loc,
7826        }
7827    }
7828    pub fn get_buf(&self) -> &'a [u8] {
7829        self.buf
7830    }
7831}
7832impl<'a> Iterator for IterableExprBitwiseAttrs<'a> {
7833    type Item = Result<ExprBitwiseAttrs<'a>, ErrorContext>;
7834    fn next(&mut self) -> Option<Self::Item> {
7835        let pos = self.pos;
7836        let mut r#type;
7837        loop {
7838            r#type = None;
7839            if self.buf.len() == self.pos {
7840                return None;
7841            }
7842            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
7843                break;
7844            };
7845            r#type = Some(header.r#type);
7846            let res = match header.r#type {
7847                1u16 => ExprBitwiseAttrs::Sreg({
7848                    let res = parse_be_u32(next);
7849                    let Some(val) = res else { break };
7850                    val
7851                }),
7852                2u16 => ExprBitwiseAttrs::Dreg({
7853                    let res = parse_be_u32(next);
7854                    let Some(val) = res else { break };
7855                    val
7856                }),
7857                3u16 => ExprBitwiseAttrs::Len({
7858                    let res = parse_be_u32(next);
7859                    let Some(val) = res else { break };
7860                    val
7861                }),
7862                4u16 => ExprBitwiseAttrs::Mask({
7863                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
7864                    let Some(val) = res else { break };
7865                    val
7866                }),
7867                5u16 => ExprBitwiseAttrs::Xor({
7868                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
7869                    let Some(val) = res else { break };
7870                    val
7871                }),
7872                6u16 => ExprBitwiseAttrs::Op({
7873                    let res = parse_be_u32(next);
7874                    let Some(val) = res else { break };
7875                    val
7876                }),
7877                7u16 => ExprBitwiseAttrs::Data({
7878                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
7879                    let Some(val) = res else { break };
7880                    val
7881                }),
7882                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
7883                n => continue,
7884            };
7885            return Some(Ok(res));
7886        }
7887        Some(Err(ErrorContext::new(
7888            "ExprBitwiseAttrs",
7889            r#type.and_then(|t| ExprBitwiseAttrs::attr_from_type(t)),
7890            self.orig_loc,
7891            self.buf.as_ptr().wrapping_add(pos) as usize,
7892        )))
7893    }
7894}
7895impl<'a> std::fmt::Debug for IterableExprBitwiseAttrs<'_> {
7896    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7897        let mut fmt = f.debug_struct("ExprBitwiseAttrs");
7898        for attr in self.clone() {
7899            let attr = match attr {
7900                Ok(a) => a,
7901                Err(err) => {
7902                    fmt.finish()?;
7903                    f.write_str("Err(")?;
7904                    err.fmt(f)?;
7905                    return f.write_str(")");
7906                }
7907            };
7908            match attr {
7909                ExprBitwiseAttrs::Sreg(val) => fmt.field("Sreg", &val),
7910                ExprBitwiseAttrs::Dreg(val) => fmt.field("Dreg", &val),
7911                ExprBitwiseAttrs::Len(val) => fmt.field("Len", &val),
7912                ExprBitwiseAttrs::Mask(val) => fmt.field("Mask", &val),
7913                ExprBitwiseAttrs::Xor(val) => fmt.field("Xor", &val),
7914                ExprBitwiseAttrs::Op(val) => {
7915                    fmt.field("Op", &FormatEnum(val.into(), BitwiseOps::from_value))
7916                }
7917                ExprBitwiseAttrs::Data(val) => fmt.field("Data", &val),
7918            };
7919        }
7920        fmt.finish()
7921    }
7922}
7923impl IterableExprBitwiseAttrs<'_> {
7924    pub fn lookup_attr(
7925        &self,
7926        offset: usize,
7927        missing_type: Option<u16>,
7928    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
7929        let mut stack = Vec::new();
7930        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
7931        if missing_type.is_some() && cur == offset {
7932            stack.push(("ExprBitwiseAttrs", offset));
7933            return (
7934                stack,
7935                missing_type.and_then(|t| ExprBitwiseAttrs::attr_from_type(t)),
7936            );
7937        }
7938        if cur > offset || cur + self.buf.len() < offset {
7939            return (stack, None);
7940        }
7941        let mut attrs = self.clone();
7942        let mut last_off = cur + attrs.pos;
7943        let mut missing = None;
7944        while let Some(attr) = attrs.next() {
7945            let Ok(attr) = attr else { break };
7946            match attr {
7947                ExprBitwiseAttrs::Sreg(val) => {
7948                    if last_off == offset {
7949                        stack.push(("Sreg", last_off));
7950                        break;
7951                    }
7952                }
7953                ExprBitwiseAttrs::Dreg(val) => {
7954                    if last_off == offset {
7955                        stack.push(("Dreg", last_off));
7956                        break;
7957                    }
7958                }
7959                ExprBitwiseAttrs::Len(val) => {
7960                    if last_off == offset {
7961                        stack.push(("Len", last_off));
7962                        break;
7963                    }
7964                }
7965                ExprBitwiseAttrs::Mask(val) => {
7966                    (stack, missing) = val.lookup_attr(offset, missing_type);
7967                    if !stack.is_empty() {
7968                        break;
7969                    }
7970                }
7971                ExprBitwiseAttrs::Xor(val) => {
7972                    (stack, missing) = val.lookup_attr(offset, missing_type);
7973                    if !stack.is_empty() {
7974                        break;
7975                    }
7976                }
7977                ExprBitwiseAttrs::Op(val) => {
7978                    if last_off == offset {
7979                        stack.push(("Op", last_off));
7980                        break;
7981                    }
7982                }
7983                ExprBitwiseAttrs::Data(val) => {
7984                    (stack, missing) = val.lookup_attr(offset, missing_type);
7985                    if !stack.is_empty() {
7986                        break;
7987                    }
7988                }
7989                _ => {}
7990            };
7991            last_off = cur + attrs.pos;
7992        }
7993        if !stack.is_empty() {
7994            stack.push(("ExprBitwiseAttrs", cur));
7995        }
7996        (stack, missing)
7997    }
7998}
7999#[derive(Clone)]
8000pub enum ExprCmpAttrs<'a> {
8001    Sreg(u32),
8002    #[doc = "Associated type: [`CmpOps`] (enum)"]
8003    Op(u32),
8004    Data(IterableDataAttrs<'a>),
8005}
8006impl<'a> IterableExprCmpAttrs<'a> {
8007    pub fn get_sreg(&self) -> Result<u32, ErrorContext> {
8008        let mut iter = self.clone();
8009        iter.pos = 0;
8010        for attr in iter {
8011            if let ExprCmpAttrs::Sreg(val) = attr? {
8012                return Ok(val);
8013            }
8014        }
8015        Err(ErrorContext::new_missing(
8016            "ExprCmpAttrs",
8017            "Sreg",
8018            self.orig_loc,
8019            self.buf.as_ptr() as usize,
8020        ))
8021    }
8022    #[doc = "Associated type: [`CmpOps`] (enum)"]
8023    pub fn get_op(&self) -> Result<u32, ErrorContext> {
8024        let mut iter = self.clone();
8025        iter.pos = 0;
8026        for attr in iter {
8027            if let ExprCmpAttrs::Op(val) = attr? {
8028                return Ok(val);
8029            }
8030        }
8031        Err(ErrorContext::new_missing(
8032            "ExprCmpAttrs",
8033            "Op",
8034            self.orig_loc,
8035            self.buf.as_ptr() as usize,
8036        ))
8037    }
8038    pub fn get_data(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
8039        let mut iter = self.clone();
8040        iter.pos = 0;
8041        for attr in iter {
8042            if let ExprCmpAttrs::Data(val) = attr? {
8043                return Ok(val);
8044            }
8045        }
8046        Err(ErrorContext::new_missing(
8047            "ExprCmpAttrs",
8048            "Data",
8049            self.orig_loc,
8050            self.buf.as_ptr() as usize,
8051        ))
8052    }
8053}
8054impl ExprCmpAttrs<'_> {
8055    pub fn new<'a>(buf: &'a [u8]) -> IterableExprCmpAttrs<'a> {
8056        IterableExprCmpAttrs::with_loc(buf, buf.as_ptr() as usize)
8057    }
8058    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8059        let res = match r#type {
8060            1u16 => "Sreg",
8061            2u16 => "Op",
8062            3u16 => "Data",
8063            _ => return None,
8064        };
8065        Some(res)
8066    }
8067}
8068#[derive(Clone, Copy, Default)]
8069pub struct IterableExprCmpAttrs<'a> {
8070    buf: &'a [u8],
8071    pos: usize,
8072    orig_loc: usize,
8073}
8074impl<'a> IterableExprCmpAttrs<'a> {
8075    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8076        Self {
8077            buf,
8078            pos: 0,
8079            orig_loc,
8080        }
8081    }
8082    pub fn get_buf(&self) -> &'a [u8] {
8083        self.buf
8084    }
8085}
8086impl<'a> Iterator for IterableExprCmpAttrs<'a> {
8087    type Item = Result<ExprCmpAttrs<'a>, ErrorContext>;
8088    fn next(&mut self) -> Option<Self::Item> {
8089        let pos = self.pos;
8090        let mut r#type;
8091        loop {
8092            r#type = None;
8093            if self.buf.len() == self.pos {
8094                return None;
8095            }
8096            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8097                break;
8098            };
8099            r#type = Some(header.r#type);
8100            let res = match header.r#type {
8101                1u16 => ExprCmpAttrs::Sreg({
8102                    let res = parse_be_u32(next);
8103                    let Some(val) = res else { break };
8104                    val
8105                }),
8106                2u16 => ExprCmpAttrs::Op({
8107                    let res = parse_be_u32(next);
8108                    let Some(val) = res else { break };
8109                    val
8110                }),
8111                3u16 => ExprCmpAttrs::Data({
8112                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
8113                    let Some(val) = res else { break };
8114                    val
8115                }),
8116                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
8117                n => continue,
8118            };
8119            return Some(Ok(res));
8120        }
8121        Some(Err(ErrorContext::new(
8122            "ExprCmpAttrs",
8123            r#type.and_then(|t| ExprCmpAttrs::attr_from_type(t)),
8124            self.orig_loc,
8125            self.buf.as_ptr().wrapping_add(pos) as usize,
8126        )))
8127    }
8128}
8129impl<'a> std::fmt::Debug for IterableExprCmpAttrs<'_> {
8130    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8131        let mut fmt = f.debug_struct("ExprCmpAttrs");
8132        for attr in self.clone() {
8133            let attr = match attr {
8134                Ok(a) => a,
8135                Err(err) => {
8136                    fmt.finish()?;
8137                    f.write_str("Err(")?;
8138                    err.fmt(f)?;
8139                    return f.write_str(")");
8140                }
8141            };
8142            match attr {
8143                ExprCmpAttrs::Sreg(val) => fmt.field("Sreg", &val),
8144                ExprCmpAttrs::Op(val) => {
8145                    fmt.field("Op", &FormatEnum(val.into(), CmpOps::from_value))
8146                }
8147                ExprCmpAttrs::Data(val) => fmt.field("Data", &val),
8148            };
8149        }
8150        fmt.finish()
8151    }
8152}
8153impl IterableExprCmpAttrs<'_> {
8154    pub fn lookup_attr(
8155        &self,
8156        offset: usize,
8157        missing_type: Option<u16>,
8158    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8159        let mut stack = Vec::new();
8160        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8161        if missing_type.is_some() && cur == offset {
8162            stack.push(("ExprCmpAttrs", offset));
8163            return (
8164                stack,
8165                missing_type.and_then(|t| ExprCmpAttrs::attr_from_type(t)),
8166            );
8167        }
8168        if cur > offset || cur + self.buf.len() < offset {
8169            return (stack, None);
8170        }
8171        let mut attrs = self.clone();
8172        let mut last_off = cur + attrs.pos;
8173        let mut missing = None;
8174        while let Some(attr) = attrs.next() {
8175            let Ok(attr) = attr else { break };
8176            match attr {
8177                ExprCmpAttrs::Sreg(val) => {
8178                    if last_off == offset {
8179                        stack.push(("Sreg", last_off));
8180                        break;
8181                    }
8182                }
8183                ExprCmpAttrs::Op(val) => {
8184                    if last_off == offset {
8185                        stack.push(("Op", last_off));
8186                        break;
8187                    }
8188                }
8189                ExprCmpAttrs::Data(val) => {
8190                    (stack, missing) = val.lookup_attr(offset, missing_type);
8191                    if !stack.is_empty() {
8192                        break;
8193                    }
8194                }
8195                _ => {}
8196            };
8197            last_off = cur + attrs.pos;
8198        }
8199        if !stack.is_empty() {
8200            stack.push(("ExprCmpAttrs", cur));
8201        }
8202        (stack, missing)
8203    }
8204}
8205#[derive(Clone)]
8206pub enum DataAttrs<'a> {
8207    Value(&'a [u8]),
8208    Verdict(IterableVerdictAttrs<'a>),
8209}
8210impl<'a> IterableDataAttrs<'a> {
8211    pub fn get_value(&self) -> Result<&'a [u8], ErrorContext> {
8212        let mut iter = self.clone();
8213        iter.pos = 0;
8214        for attr in iter {
8215            if let DataAttrs::Value(val) = attr? {
8216                return Ok(val);
8217            }
8218        }
8219        Err(ErrorContext::new_missing(
8220            "DataAttrs",
8221            "Value",
8222            self.orig_loc,
8223            self.buf.as_ptr() as usize,
8224        ))
8225    }
8226    pub fn get_verdict(&self) -> Result<IterableVerdictAttrs<'a>, ErrorContext> {
8227        let mut iter = self.clone();
8228        iter.pos = 0;
8229        for attr in iter {
8230            if let DataAttrs::Verdict(val) = attr? {
8231                return Ok(val);
8232            }
8233        }
8234        Err(ErrorContext::new_missing(
8235            "DataAttrs",
8236            "Verdict",
8237            self.orig_loc,
8238            self.buf.as_ptr() as usize,
8239        ))
8240    }
8241}
8242impl DataAttrs<'_> {
8243    pub fn new<'a>(buf: &'a [u8]) -> IterableDataAttrs<'a> {
8244        IterableDataAttrs::with_loc(buf, buf.as_ptr() as usize)
8245    }
8246    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8247        let res = match r#type {
8248            1u16 => "Value",
8249            2u16 => "Verdict",
8250            _ => return None,
8251        };
8252        Some(res)
8253    }
8254}
8255#[derive(Clone, Copy, Default)]
8256pub struct IterableDataAttrs<'a> {
8257    buf: &'a [u8],
8258    pos: usize,
8259    orig_loc: usize,
8260}
8261impl<'a> IterableDataAttrs<'a> {
8262    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8263        Self {
8264            buf,
8265            pos: 0,
8266            orig_loc,
8267        }
8268    }
8269    pub fn get_buf(&self) -> &'a [u8] {
8270        self.buf
8271    }
8272}
8273impl<'a> Iterator for IterableDataAttrs<'a> {
8274    type Item = Result<DataAttrs<'a>, ErrorContext>;
8275    fn next(&mut self) -> Option<Self::Item> {
8276        let pos = self.pos;
8277        let mut r#type;
8278        loop {
8279            r#type = None;
8280            if self.buf.len() == self.pos {
8281                return None;
8282            }
8283            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8284                break;
8285            };
8286            r#type = Some(header.r#type);
8287            let res = match header.r#type {
8288                1u16 => DataAttrs::Value({
8289                    let res = Some(next);
8290                    let Some(val) = res else { break };
8291                    val
8292                }),
8293                2u16 => DataAttrs::Verdict({
8294                    let res = Some(IterableVerdictAttrs::with_loc(next, self.orig_loc));
8295                    let Some(val) = res else { break };
8296                    val
8297                }),
8298                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
8299                n => continue,
8300            };
8301            return Some(Ok(res));
8302        }
8303        Some(Err(ErrorContext::new(
8304            "DataAttrs",
8305            r#type.and_then(|t| DataAttrs::attr_from_type(t)),
8306            self.orig_loc,
8307            self.buf.as_ptr().wrapping_add(pos) as usize,
8308        )))
8309    }
8310}
8311impl<'a> std::fmt::Debug for IterableDataAttrs<'_> {
8312    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8313        let mut fmt = f.debug_struct("DataAttrs");
8314        for attr in self.clone() {
8315            let attr = match attr {
8316                Ok(a) => a,
8317                Err(err) => {
8318                    fmt.finish()?;
8319                    f.write_str("Err(")?;
8320                    err.fmt(f)?;
8321                    return f.write_str(")");
8322                }
8323            };
8324            match attr {
8325                DataAttrs::Value(val) => fmt.field("Value", &val),
8326                DataAttrs::Verdict(val) => fmt.field("Verdict", &val),
8327            };
8328        }
8329        fmt.finish()
8330    }
8331}
8332impl IterableDataAttrs<'_> {
8333    pub fn lookup_attr(
8334        &self,
8335        offset: usize,
8336        missing_type: Option<u16>,
8337    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8338        let mut stack = Vec::new();
8339        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8340        if missing_type.is_some() && cur == offset {
8341            stack.push(("DataAttrs", offset));
8342            return (
8343                stack,
8344                missing_type.and_then(|t| DataAttrs::attr_from_type(t)),
8345            );
8346        }
8347        if cur > offset || cur + self.buf.len() < offset {
8348            return (stack, None);
8349        }
8350        let mut attrs = self.clone();
8351        let mut last_off = cur + attrs.pos;
8352        let mut missing = None;
8353        while let Some(attr) = attrs.next() {
8354            let Ok(attr) = attr else { break };
8355            match attr {
8356                DataAttrs::Value(val) => {
8357                    if last_off == offset {
8358                        stack.push(("Value", last_off));
8359                        break;
8360                    }
8361                }
8362                DataAttrs::Verdict(val) => {
8363                    (stack, missing) = val.lookup_attr(offset, missing_type);
8364                    if !stack.is_empty() {
8365                        break;
8366                    }
8367                }
8368                _ => {}
8369            };
8370            last_off = cur + attrs.pos;
8371        }
8372        if !stack.is_empty() {
8373            stack.push(("DataAttrs", cur));
8374        }
8375        (stack, missing)
8376    }
8377}
8378#[derive(Clone)]
8379pub enum VerdictAttrs<'a> {
8380    #[doc = "nf\\_tables verdict\nAssociated type: [`VerdictCode`] (enum)"]
8381    Code(u32),
8382    #[doc = "jump target chain name"]
8383    Chain(&'a CStr),
8384    #[doc = "jump target chain ID"]
8385    ChainId(u32),
8386}
8387impl<'a> IterableVerdictAttrs<'a> {
8388    #[doc = "nf\\_tables verdict\nAssociated type: [`VerdictCode`] (enum)"]
8389    pub fn get_code(&self) -> Result<u32, ErrorContext> {
8390        let mut iter = self.clone();
8391        iter.pos = 0;
8392        for attr in iter {
8393            if let VerdictAttrs::Code(val) = attr? {
8394                return Ok(val);
8395            }
8396        }
8397        Err(ErrorContext::new_missing(
8398            "VerdictAttrs",
8399            "Code",
8400            self.orig_loc,
8401            self.buf.as_ptr() as usize,
8402        ))
8403    }
8404    #[doc = "jump target chain name"]
8405    pub fn get_chain(&self) -> Result<&'a CStr, ErrorContext> {
8406        let mut iter = self.clone();
8407        iter.pos = 0;
8408        for attr in iter {
8409            if let VerdictAttrs::Chain(val) = attr? {
8410                return Ok(val);
8411            }
8412        }
8413        Err(ErrorContext::new_missing(
8414            "VerdictAttrs",
8415            "Chain",
8416            self.orig_loc,
8417            self.buf.as_ptr() as usize,
8418        ))
8419    }
8420    #[doc = "jump target chain ID"]
8421    pub fn get_chain_id(&self) -> Result<u32, ErrorContext> {
8422        let mut iter = self.clone();
8423        iter.pos = 0;
8424        for attr in iter {
8425            if let VerdictAttrs::ChainId(val) = attr? {
8426                return Ok(val);
8427            }
8428        }
8429        Err(ErrorContext::new_missing(
8430            "VerdictAttrs",
8431            "ChainId",
8432            self.orig_loc,
8433            self.buf.as_ptr() as usize,
8434        ))
8435    }
8436}
8437impl VerdictAttrs<'_> {
8438    pub fn new<'a>(buf: &'a [u8]) -> IterableVerdictAttrs<'a> {
8439        IterableVerdictAttrs::with_loc(buf, buf.as_ptr() as usize)
8440    }
8441    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8442        let res = match r#type {
8443            1u16 => "Code",
8444            2u16 => "Chain",
8445            3u16 => "ChainId",
8446            _ => return None,
8447        };
8448        Some(res)
8449    }
8450}
8451#[derive(Clone, Copy, Default)]
8452pub struct IterableVerdictAttrs<'a> {
8453    buf: &'a [u8],
8454    pos: usize,
8455    orig_loc: usize,
8456}
8457impl<'a> IterableVerdictAttrs<'a> {
8458    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8459        Self {
8460            buf,
8461            pos: 0,
8462            orig_loc,
8463        }
8464    }
8465    pub fn get_buf(&self) -> &'a [u8] {
8466        self.buf
8467    }
8468}
8469impl<'a> Iterator for IterableVerdictAttrs<'a> {
8470    type Item = Result<VerdictAttrs<'a>, ErrorContext>;
8471    fn next(&mut self) -> Option<Self::Item> {
8472        let pos = self.pos;
8473        let mut r#type;
8474        loop {
8475            r#type = None;
8476            if self.buf.len() == self.pos {
8477                return None;
8478            }
8479            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8480                break;
8481            };
8482            r#type = Some(header.r#type);
8483            let res = match header.r#type {
8484                1u16 => VerdictAttrs::Code({
8485                    let res = parse_be_u32(next);
8486                    let Some(val) = res else { break };
8487                    val
8488                }),
8489                2u16 => VerdictAttrs::Chain({
8490                    let res = CStr::from_bytes_with_nul(next).ok();
8491                    let Some(val) = res else { break };
8492                    val
8493                }),
8494                3u16 => VerdictAttrs::ChainId({
8495                    let res = parse_be_u32(next);
8496                    let Some(val) = res else { break };
8497                    val
8498                }),
8499                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
8500                n => continue,
8501            };
8502            return Some(Ok(res));
8503        }
8504        Some(Err(ErrorContext::new(
8505            "VerdictAttrs",
8506            r#type.and_then(|t| VerdictAttrs::attr_from_type(t)),
8507            self.orig_loc,
8508            self.buf.as_ptr().wrapping_add(pos) as usize,
8509        )))
8510    }
8511}
8512impl<'a> std::fmt::Debug for IterableVerdictAttrs<'_> {
8513    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8514        let mut fmt = f.debug_struct("VerdictAttrs");
8515        for attr in self.clone() {
8516            let attr = match attr {
8517                Ok(a) => a,
8518                Err(err) => {
8519                    fmt.finish()?;
8520                    f.write_str("Err(")?;
8521                    err.fmt(f)?;
8522                    return f.write_str(")");
8523                }
8524            };
8525            match attr {
8526                VerdictAttrs::Code(val) => {
8527                    fmt.field("Code", &FormatEnum(val.into(), VerdictCode::from_value))
8528                }
8529                VerdictAttrs::Chain(val) => fmt.field("Chain", &val),
8530                VerdictAttrs::ChainId(val) => fmt.field("ChainId", &val),
8531            };
8532        }
8533        fmt.finish()
8534    }
8535}
8536impl IterableVerdictAttrs<'_> {
8537    pub fn lookup_attr(
8538        &self,
8539        offset: usize,
8540        missing_type: Option<u16>,
8541    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8542        let mut stack = Vec::new();
8543        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8544        if missing_type.is_some() && cur == offset {
8545            stack.push(("VerdictAttrs", offset));
8546            return (
8547                stack,
8548                missing_type.and_then(|t| VerdictAttrs::attr_from_type(t)),
8549            );
8550        }
8551        if cur > offset || cur + self.buf.len() < offset {
8552            return (stack, None);
8553        }
8554        let mut attrs = self.clone();
8555        let mut last_off = cur + attrs.pos;
8556        while let Some(attr) = attrs.next() {
8557            let Ok(attr) = attr else { break };
8558            match attr {
8559                VerdictAttrs::Code(val) => {
8560                    if last_off == offset {
8561                        stack.push(("Code", last_off));
8562                        break;
8563                    }
8564                }
8565                VerdictAttrs::Chain(val) => {
8566                    if last_off == offset {
8567                        stack.push(("Chain", last_off));
8568                        break;
8569                    }
8570                }
8571                VerdictAttrs::ChainId(val) => {
8572                    if last_off == offset {
8573                        stack.push(("ChainId", last_off));
8574                        break;
8575                    }
8576                }
8577                _ => {}
8578            };
8579            last_off = cur + attrs.pos;
8580        }
8581        if !stack.is_empty() {
8582            stack.push(("VerdictAttrs", cur));
8583        }
8584        (stack, None)
8585    }
8586}
8587#[derive(Clone)]
8588pub enum ExprCounterAttrs<'a> {
8589    #[doc = "Number of bytes"]
8590    Bytes(u64),
8591    #[doc = "Number of packets"]
8592    Packets(u64),
8593    Pad(&'a [u8]),
8594}
8595impl<'a> IterableExprCounterAttrs<'a> {
8596    #[doc = "Number of bytes"]
8597    pub fn get_bytes(&self) -> Result<u64, ErrorContext> {
8598        let mut iter = self.clone();
8599        iter.pos = 0;
8600        for attr in iter {
8601            if let ExprCounterAttrs::Bytes(val) = attr? {
8602                return Ok(val);
8603            }
8604        }
8605        Err(ErrorContext::new_missing(
8606            "ExprCounterAttrs",
8607            "Bytes",
8608            self.orig_loc,
8609            self.buf.as_ptr() as usize,
8610        ))
8611    }
8612    #[doc = "Number of packets"]
8613    pub fn get_packets(&self) -> Result<u64, ErrorContext> {
8614        let mut iter = self.clone();
8615        iter.pos = 0;
8616        for attr in iter {
8617            if let ExprCounterAttrs::Packets(val) = attr? {
8618                return Ok(val);
8619            }
8620        }
8621        Err(ErrorContext::new_missing(
8622            "ExprCounterAttrs",
8623            "Packets",
8624            self.orig_loc,
8625            self.buf.as_ptr() as usize,
8626        ))
8627    }
8628    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
8629        let mut iter = self.clone();
8630        iter.pos = 0;
8631        for attr in iter {
8632            if let ExprCounterAttrs::Pad(val) = attr? {
8633                return Ok(val);
8634            }
8635        }
8636        Err(ErrorContext::new_missing(
8637            "ExprCounterAttrs",
8638            "Pad",
8639            self.orig_loc,
8640            self.buf.as_ptr() as usize,
8641        ))
8642    }
8643}
8644impl ExprCounterAttrs<'_> {
8645    pub fn new<'a>(buf: &'a [u8]) -> IterableExprCounterAttrs<'a> {
8646        IterableExprCounterAttrs::with_loc(buf, buf.as_ptr() as usize)
8647    }
8648    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8649        let res = match r#type {
8650            1u16 => "Bytes",
8651            2u16 => "Packets",
8652            3u16 => "Pad",
8653            _ => return None,
8654        };
8655        Some(res)
8656    }
8657}
8658#[derive(Clone, Copy, Default)]
8659pub struct IterableExprCounterAttrs<'a> {
8660    buf: &'a [u8],
8661    pos: usize,
8662    orig_loc: usize,
8663}
8664impl<'a> IterableExprCounterAttrs<'a> {
8665    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8666        Self {
8667            buf,
8668            pos: 0,
8669            orig_loc,
8670        }
8671    }
8672    pub fn get_buf(&self) -> &'a [u8] {
8673        self.buf
8674    }
8675}
8676impl<'a> Iterator for IterableExprCounterAttrs<'a> {
8677    type Item = Result<ExprCounterAttrs<'a>, ErrorContext>;
8678    fn next(&mut self) -> Option<Self::Item> {
8679        let pos = self.pos;
8680        let mut r#type;
8681        loop {
8682            r#type = None;
8683            if self.buf.len() == self.pos {
8684                return None;
8685            }
8686            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8687                break;
8688            };
8689            r#type = Some(header.r#type);
8690            let res = match header.r#type {
8691                1u16 => ExprCounterAttrs::Bytes({
8692                    let res = parse_be_u64(next);
8693                    let Some(val) = res else { break };
8694                    val
8695                }),
8696                2u16 => ExprCounterAttrs::Packets({
8697                    let res = parse_be_u64(next);
8698                    let Some(val) = res else { break };
8699                    val
8700                }),
8701                3u16 => ExprCounterAttrs::Pad({
8702                    let res = Some(next);
8703                    let Some(val) = res else { break };
8704                    val
8705                }),
8706                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
8707                n => continue,
8708            };
8709            return Some(Ok(res));
8710        }
8711        Some(Err(ErrorContext::new(
8712            "ExprCounterAttrs",
8713            r#type.and_then(|t| ExprCounterAttrs::attr_from_type(t)),
8714            self.orig_loc,
8715            self.buf.as_ptr().wrapping_add(pos) as usize,
8716        )))
8717    }
8718}
8719impl<'a> std::fmt::Debug for IterableExprCounterAttrs<'_> {
8720    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8721        let mut fmt = f.debug_struct("ExprCounterAttrs");
8722        for attr in self.clone() {
8723            let attr = match attr {
8724                Ok(a) => a,
8725                Err(err) => {
8726                    fmt.finish()?;
8727                    f.write_str("Err(")?;
8728                    err.fmt(f)?;
8729                    return f.write_str(")");
8730                }
8731            };
8732            match attr {
8733                ExprCounterAttrs::Bytes(val) => fmt.field("Bytes", &val),
8734                ExprCounterAttrs::Packets(val) => fmt.field("Packets", &val),
8735                ExprCounterAttrs::Pad(val) => fmt.field("Pad", &val),
8736            };
8737        }
8738        fmt.finish()
8739    }
8740}
8741impl IterableExprCounterAttrs<'_> {
8742    pub fn lookup_attr(
8743        &self,
8744        offset: usize,
8745        missing_type: Option<u16>,
8746    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8747        let mut stack = Vec::new();
8748        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8749        if missing_type.is_some() && cur == offset {
8750            stack.push(("ExprCounterAttrs", offset));
8751            return (
8752                stack,
8753                missing_type.and_then(|t| ExprCounterAttrs::attr_from_type(t)),
8754            );
8755        }
8756        if cur > offset || cur + self.buf.len() < offset {
8757            return (stack, None);
8758        }
8759        let mut attrs = self.clone();
8760        let mut last_off = cur + attrs.pos;
8761        while let Some(attr) = attrs.next() {
8762            let Ok(attr) = attr else { break };
8763            match attr {
8764                ExprCounterAttrs::Bytes(val) => {
8765                    if last_off == offset {
8766                        stack.push(("Bytes", last_off));
8767                        break;
8768                    }
8769                }
8770                ExprCounterAttrs::Packets(val) => {
8771                    if last_off == offset {
8772                        stack.push(("Packets", last_off));
8773                        break;
8774                    }
8775                }
8776                ExprCounterAttrs::Pad(val) => {
8777                    if last_off == offset {
8778                        stack.push(("Pad", last_off));
8779                        break;
8780                    }
8781                }
8782                _ => {}
8783            };
8784            last_off = cur + attrs.pos;
8785        }
8786        if !stack.is_empty() {
8787            stack.push(("ExprCounterAttrs", cur));
8788        }
8789        (stack, None)
8790    }
8791}
8792#[derive(Clone)]
8793pub enum ExprFibAttrs {
8794    Dreg(u32),
8795    #[doc = "Associated type: [`FibResult`] (enum)"]
8796    Result(u32),
8797    #[doc = "Associated type: [`FibFlags`] (enum)"]
8798    Flags(u32),
8799}
8800impl<'a> IterableExprFibAttrs<'a> {
8801    pub fn get_dreg(&self) -> Result<u32, ErrorContext> {
8802        let mut iter = self.clone();
8803        iter.pos = 0;
8804        for attr in iter {
8805            if let ExprFibAttrs::Dreg(val) = attr? {
8806                return Ok(val);
8807            }
8808        }
8809        Err(ErrorContext::new_missing(
8810            "ExprFibAttrs",
8811            "Dreg",
8812            self.orig_loc,
8813            self.buf.as_ptr() as usize,
8814        ))
8815    }
8816    #[doc = "Associated type: [`FibResult`] (enum)"]
8817    pub fn get_result(&self) -> Result<u32, ErrorContext> {
8818        let mut iter = self.clone();
8819        iter.pos = 0;
8820        for attr in iter {
8821            if let ExprFibAttrs::Result(val) = attr? {
8822                return Ok(val);
8823            }
8824        }
8825        Err(ErrorContext::new_missing(
8826            "ExprFibAttrs",
8827            "Result",
8828            self.orig_loc,
8829            self.buf.as_ptr() as usize,
8830        ))
8831    }
8832    #[doc = "Associated type: [`FibFlags`] (enum)"]
8833    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
8834        let mut iter = self.clone();
8835        iter.pos = 0;
8836        for attr in iter {
8837            if let ExprFibAttrs::Flags(val) = attr? {
8838                return Ok(val);
8839            }
8840        }
8841        Err(ErrorContext::new_missing(
8842            "ExprFibAttrs",
8843            "Flags",
8844            self.orig_loc,
8845            self.buf.as_ptr() as usize,
8846        ))
8847    }
8848}
8849impl ExprFibAttrs {
8850    pub fn new<'a>(buf: &'a [u8]) -> IterableExprFibAttrs<'a> {
8851        IterableExprFibAttrs::with_loc(buf, buf.as_ptr() as usize)
8852    }
8853    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8854        let res = match r#type {
8855            1u16 => "Dreg",
8856            2u16 => "Result",
8857            3u16 => "Flags",
8858            _ => return None,
8859        };
8860        Some(res)
8861    }
8862}
8863#[derive(Clone, Copy, Default)]
8864pub struct IterableExprFibAttrs<'a> {
8865    buf: &'a [u8],
8866    pos: usize,
8867    orig_loc: usize,
8868}
8869impl<'a> IterableExprFibAttrs<'a> {
8870    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8871        Self {
8872            buf,
8873            pos: 0,
8874            orig_loc,
8875        }
8876    }
8877    pub fn get_buf(&self) -> &'a [u8] {
8878        self.buf
8879    }
8880}
8881impl<'a> Iterator for IterableExprFibAttrs<'a> {
8882    type Item = Result<ExprFibAttrs, ErrorContext>;
8883    fn next(&mut self) -> Option<Self::Item> {
8884        let pos = self.pos;
8885        let mut r#type;
8886        loop {
8887            r#type = None;
8888            if self.buf.len() == self.pos {
8889                return None;
8890            }
8891            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8892                break;
8893            };
8894            r#type = Some(header.r#type);
8895            let res = match header.r#type {
8896                1u16 => ExprFibAttrs::Dreg({
8897                    let res = parse_be_u32(next);
8898                    let Some(val) = res else { break };
8899                    val
8900                }),
8901                2u16 => ExprFibAttrs::Result({
8902                    let res = parse_be_u32(next);
8903                    let Some(val) = res else { break };
8904                    val
8905                }),
8906                3u16 => ExprFibAttrs::Flags({
8907                    let res = parse_be_u32(next);
8908                    let Some(val) = res else { break };
8909                    val
8910                }),
8911                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
8912                n => continue,
8913            };
8914            return Some(Ok(res));
8915        }
8916        Some(Err(ErrorContext::new(
8917            "ExprFibAttrs",
8918            r#type.and_then(|t| ExprFibAttrs::attr_from_type(t)),
8919            self.orig_loc,
8920            self.buf.as_ptr().wrapping_add(pos) as usize,
8921        )))
8922    }
8923}
8924impl std::fmt::Debug for IterableExprFibAttrs<'_> {
8925    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8926        let mut fmt = f.debug_struct("ExprFibAttrs");
8927        for attr in self.clone() {
8928            let attr = match attr {
8929                Ok(a) => a,
8930                Err(err) => {
8931                    fmt.finish()?;
8932                    f.write_str("Err(")?;
8933                    err.fmt(f)?;
8934                    return f.write_str(")");
8935                }
8936            };
8937            match attr {
8938                ExprFibAttrs::Dreg(val) => fmt.field("Dreg", &val),
8939                ExprFibAttrs::Result(val) => {
8940                    fmt.field("Result", &FormatEnum(val.into(), FibResult::from_value))
8941                }
8942                ExprFibAttrs::Flags(val) => {
8943                    fmt.field("Flags", &FormatFlags(val.into(), FibFlags::from_value))
8944                }
8945            };
8946        }
8947        fmt.finish()
8948    }
8949}
8950impl IterableExprFibAttrs<'_> {
8951    pub fn lookup_attr(
8952        &self,
8953        offset: usize,
8954        missing_type: Option<u16>,
8955    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8956        let mut stack = Vec::new();
8957        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8958        if missing_type.is_some() && cur == offset {
8959            stack.push(("ExprFibAttrs", offset));
8960            return (
8961                stack,
8962                missing_type.and_then(|t| ExprFibAttrs::attr_from_type(t)),
8963            );
8964        }
8965        if cur > offset || cur + self.buf.len() < offset {
8966            return (stack, None);
8967        }
8968        let mut attrs = self.clone();
8969        let mut last_off = cur + attrs.pos;
8970        while let Some(attr) = attrs.next() {
8971            let Ok(attr) = attr else { break };
8972            match attr {
8973                ExprFibAttrs::Dreg(val) => {
8974                    if last_off == offset {
8975                        stack.push(("Dreg", last_off));
8976                        break;
8977                    }
8978                }
8979                ExprFibAttrs::Result(val) => {
8980                    if last_off == offset {
8981                        stack.push(("Result", last_off));
8982                        break;
8983                    }
8984                }
8985                ExprFibAttrs::Flags(val) => {
8986                    if last_off == offset {
8987                        stack.push(("Flags", last_off));
8988                        break;
8989                    }
8990                }
8991                _ => {}
8992            };
8993            last_off = cur + attrs.pos;
8994        }
8995        if !stack.is_empty() {
8996            stack.push(("ExprFibAttrs", cur));
8997        }
8998        (stack, None)
8999    }
9000}
9001#[derive(Clone)]
9002pub enum ExprCtAttrs {
9003    Dreg(u32),
9004    #[doc = "Associated type: [`CtKeys`] (enum)"]
9005    Key(u32),
9006    #[doc = "Associated type: [`CtDirection`] (enum)"]
9007    Direction(u8),
9008    Sreg(u32),
9009}
9010impl<'a> IterableExprCtAttrs<'a> {
9011    pub fn get_dreg(&self) -> Result<u32, ErrorContext> {
9012        let mut iter = self.clone();
9013        iter.pos = 0;
9014        for attr in iter {
9015            if let ExprCtAttrs::Dreg(val) = attr? {
9016                return Ok(val);
9017            }
9018        }
9019        Err(ErrorContext::new_missing(
9020            "ExprCtAttrs",
9021            "Dreg",
9022            self.orig_loc,
9023            self.buf.as_ptr() as usize,
9024        ))
9025    }
9026    #[doc = "Associated type: [`CtKeys`] (enum)"]
9027    pub fn get_key(&self) -> Result<u32, ErrorContext> {
9028        let mut iter = self.clone();
9029        iter.pos = 0;
9030        for attr in iter {
9031            if let ExprCtAttrs::Key(val) = attr? {
9032                return Ok(val);
9033            }
9034        }
9035        Err(ErrorContext::new_missing(
9036            "ExprCtAttrs",
9037            "Key",
9038            self.orig_loc,
9039            self.buf.as_ptr() as usize,
9040        ))
9041    }
9042    #[doc = "Associated type: [`CtDirection`] (enum)"]
9043    pub fn get_direction(&self) -> Result<u8, ErrorContext> {
9044        let mut iter = self.clone();
9045        iter.pos = 0;
9046        for attr in iter {
9047            if let ExprCtAttrs::Direction(val) = attr? {
9048                return Ok(val);
9049            }
9050        }
9051        Err(ErrorContext::new_missing(
9052            "ExprCtAttrs",
9053            "Direction",
9054            self.orig_loc,
9055            self.buf.as_ptr() as usize,
9056        ))
9057    }
9058    pub fn get_sreg(&self) -> Result<u32, ErrorContext> {
9059        let mut iter = self.clone();
9060        iter.pos = 0;
9061        for attr in iter {
9062            if let ExprCtAttrs::Sreg(val) = attr? {
9063                return Ok(val);
9064            }
9065        }
9066        Err(ErrorContext::new_missing(
9067            "ExprCtAttrs",
9068            "Sreg",
9069            self.orig_loc,
9070            self.buf.as_ptr() as usize,
9071        ))
9072    }
9073}
9074impl ExprCtAttrs {
9075    pub fn new<'a>(buf: &'a [u8]) -> IterableExprCtAttrs<'a> {
9076        IterableExprCtAttrs::with_loc(buf, buf.as_ptr() as usize)
9077    }
9078    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9079        let res = match r#type {
9080            1u16 => "Dreg",
9081            2u16 => "Key",
9082            3u16 => "Direction",
9083            4u16 => "Sreg",
9084            _ => return None,
9085        };
9086        Some(res)
9087    }
9088}
9089#[derive(Clone, Copy, Default)]
9090pub struct IterableExprCtAttrs<'a> {
9091    buf: &'a [u8],
9092    pos: usize,
9093    orig_loc: usize,
9094}
9095impl<'a> IterableExprCtAttrs<'a> {
9096    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9097        Self {
9098            buf,
9099            pos: 0,
9100            orig_loc,
9101        }
9102    }
9103    pub fn get_buf(&self) -> &'a [u8] {
9104        self.buf
9105    }
9106}
9107impl<'a> Iterator for IterableExprCtAttrs<'a> {
9108    type Item = Result<ExprCtAttrs, ErrorContext>;
9109    fn next(&mut self) -> Option<Self::Item> {
9110        let pos = self.pos;
9111        let mut r#type;
9112        loop {
9113            r#type = None;
9114            if self.buf.len() == self.pos {
9115                return None;
9116            }
9117            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
9118                break;
9119            };
9120            r#type = Some(header.r#type);
9121            let res = match header.r#type {
9122                1u16 => ExprCtAttrs::Dreg({
9123                    let res = parse_be_u32(next);
9124                    let Some(val) = res else { break };
9125                    val
9126                }),
9127                2u16 => ExprCtAttrs::Key({
9128                    let res = parse_be_u32(next);
9129                    let Some(val) = res else { break };
9130                    val
9131                }),
9132                3u16 => ExprCtAttrs::Direction({
9133                    let res = parse_u8(next);
9134                    let Some(val) = res else { break };
9135                    val
9136                }),
9137                4u16 => ExprCtAttrs::Sreg({
9138                    let res = parse_be_u32(next);
9139                    let Some(val) = res else { break };
9140                    val
9141                }),
9142                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9143                n => continue,
9144            };
9145            return Some(Ok(res));
9146        }
9147        Some(Err(ErrorContext::new(
9148            "ExprCtAttrs",
9149            r#type.and_then(|t| ExprCtAttrs::attr_from_type(t)),
9150            self.orig_loc,
9151            self.buf.as_ptr().wrapping_add(pos) as usize,
9152        )))
9153    }
9154}
9155impl std::fmt::Debug for IterableExprCtAttrs<'_> {
9156    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9157        let mut fmt = f.debug_struct("ExprCtAttrs");
9158        for attr in self.clone() {
9159            let attr = match attr {
9160                Ok(a) => a,
9161                Err(err) => {
9162                    fmt.finish()?;
9163                    f.write_str("Err(")?;
9164                    err.fmt(f)?;
9165                    return f.write_str(")");
9166                }
9167            };
9168            match attr {
9169                ExprCtAttrs::Dreg(val) => fmt.field("Dreg", &val),
9170                ExprCtAttrs::Key(val) => {
9171                    fmt.field("Key", &FormatEnum(val.into(), CtKeys::from_value))
9172                }
9173                ExprCtAttrs::Direction(val) => fmt.field(
9174                    "Direction",
9175                    &FormatEnum(val.into(), CtDirection::from_value),
9176                ),
9177                ExprCtAttrs::Sreg(val) => fmt.field("Sreg", &val),
9178            };
9179        }
9180        fmt.finish()
9181    }
9182}
9183impl IterableExprCtAttrs<'_> {
9184    pub fn lookup_attr(
9185        &self,
9186        offset: usize,
9187        missing_type: Option<u16>,
9188    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9189        let mut stack = Vec::new();
9190        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9191        if missing_type.is_some() && cur == offset {
9192            stack.push(("ExprCtAttrs", offset));
9193            return (
9194                stack,
9195                missing_type.and_then(|t| ExprCtAttrs::attr_from_type(t)),
9196            );
9197        }
9198        if cur > offset || cur + self.buf.len() < offset {
9199            return (stack, None);
9200        }
9201        let mut attrs = self.clone();
9202        let mut last_off = cur + attrs.pos;
9203        while let Some(attr) = attrs.next() {
9204            let Ok(attr) = attr else { break };
9205            match attr {
9206                ExprCtAttrs::Dreg(val) => {
9207                    if last_off == offset {
9208                        stack.push(("Dreg", last_off));
9209                        break;
9210                    }
9211                }
9212                ExprCtAttrs::Key(val) => {
9213                    if last_off == offset {
9214                        stack.push(("Key", last_off));
9215                        break;
9216                    }
9217                }
9218                ExprCtAttrs::Direction(val) => {
9219                    if last_off == offset {
9220                        stack.push(("Direction", last_off));
9221                        break;
9222                    }
9223                }
9224                ExprCtAttrs::Sreg(val) => {
9225                    if last_off == offset {
9226                        stack.push(("Sreg", last_off));
9227                        break;
9228                    }
9229                }
9230                _ => {}
9231            };
9232            last_off = cur + attrs.pos;
9233        }
9234        if !stack.is_empty() {
9235            stack.push(("ExprCtAttrs", cur));
9236        }
9237        (stack, None)
9238    }
9239}
9240#[derive(Clone)]
9241pub enum ExprFlowOffloadAttrs<'a> {
9242    #[doc = "Flow offload table name"]
9243    Name(&'a CStr),
9244}
9245impl<'a> IterableExprFlowOffloadAttrs<'a> {
9246    #[doc = "Flow offload table name"]
9247    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
9248        let mut iter = self.clone();
9249        iter.pos = 0;
9250        for attr in iter {
9251            if let ExprFlowOffloadAttrs::Name(val) = attr? {
9252                return Ok(val);
9253            }
9254        }
9255        Err(ErrorContext::new_missing(
9256            "ExprFlowOffloadAttrs",
9257            "Name",
9258            self.orig_loc,
9259            self.buf.as_ptr() as usize,
9260        ))
9261    }
9262}
9263impl ExprFlowOffloadAttrs<'_> {
9264    pub fn new<'a>(buf: &'a [u8]) -> IterableExprFlowOffloadAttrs<'a> {
9265        IterableExprFlowOffloadAttrs::with_loc(buf, buf.as_ptr() as usize)
9266    }
9267    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9268        let res = match r#type {
9269            1u16 => "Name",
9270            _ => return None,
9271        };
9272        Some(res)
9273    }
9274}
9275#[derive(Clone, Copy, Default)]
9276pub struct IterableExprFlowOffloadAttrs<'a> {
9277    buf: &'a [u8],
9278    pos: usize,
9279    orig_loc: usize,
9280}
9281impl<'a> IterableExprFlowOffloadAttrs<'a> {
9282    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9283        Self {
9284            buf,
9285            pos: 0,
9286            orig_loc,
9287        }
9288    }
9289    pub fn get_buf(&self) -> &'a [u8] {
9290        self.buf
9291    }
9292}
9293impl<'a> Iterator for IterableExprFlowOffloadAttrs<'a> {
9294    type Item = Result<ExprFlowOffloadAttrs<'a>, ErrorContext>;
9295    fn next(&mut self) -> Option<Self::Item> {
9296        let pos = self.pos;
9297        let mut r#type;
9298        loop {
9299            r#type = None;
9300            if self.buf.len() == self.pos {
9301                return None;
9302            }
9303            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
9304                break;
9305            };
9306            r#type = Some(header.r#type);
9307            let res = match header.r#type {
9308                1u16 => ExprFlowOffloadAttrs::Name({
9309                    let res = CStr::from_bytes_with_nul(next).ok();
9310                    let Some(val) = res else { break };
9311                    val
9312                }),
9313                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9314                n => continue,
9315            };
9316            return Some(Ok(res));
9317        }
9318        Some(Err(ErrorContext::new(
9319            "ExprFlowOffloadAttrs",
9320            r#type.and_then(|t| ExprFlowOffloadAttrs::attr_from_type(t)),
9321            self.orig_loc,
9322            self.buf.as_ptr().wrapping_add(pos) as usize,
9323        )))
9324    }
9325}
9326impl<'a> std::fmt::Debug for IterableExprFlowOffloadAttrs<'_> {
9327    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9328        let mut fmt = f.debug_struct("ExprFlowOffloadAttrs");
9329        for attr in self.clone() {
9330            let attr = match attr {
9331                Ok(a) => a,
9332                Err(err) => {
9333                    fmt.finish()?;
9334                    f.write_str("Err(")?;
9335                    err.fmt(f)?;
9336                    return f.write_str(")");
9337                }
9338            };
9339            match attr {
9340                ExprFlowOffloadAttrs::Name(val) => fmt.field("Name", &val),
9341            };
9342        }
9343        fmt.finish()
9344    }
9345}
9346impl IterableExprFlowOffloadAttrs<'_> {
9347    pub fn lookup_attr(
9348        &self,
9349        offset: usize,
9350        missing_type: Option<u16>,
9351    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9352        let mut stack = Vec::new();
9353        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9354        if missing_type.is_some() && cur == offset {
9355            stack.push(("ExprFlowOffloadAttrs", offset));
9356            return (
9357                stack,
9358                missing_type.and_then(|t| ExprFlowOffloadAttrs::attr_from_type(t)),
9359            );
9360        }
9361        if cur > offset || cur + self.buf.len() < offset {
9362            return (stack, None);
9363        }
9364        let mut attrs = self.clone();
9365        let mut last_off = cur + attrs.pos;
9366        while let Some(attr) = attrs.next() {
9367            let Ok(attr) = attr else { break };
9368            match attr {
9369                ExprFlowOffloadAttrs::Name(val) => {
9370                    if last_off == offset {
9371                        stack.push(("Name", last_off));
9372                        break;
9373                    }
9374                }
9375                _ => {}
9376            };
9377            last_off = cur + attrs.pos;
9378        }
9379        if !stack.is_empty() {
9380            stack.push(("ExprFlowOffloadAttrs", cur));
9381        }
9382        (stack, None)
9383    }
9384}
9385#[derive(Clone)]
9386pub enum ExprImmediateAttrs<'a> {
9387    Dreg(u32),
9388    Data(IterableDataAttrs<'a>),
9389}
9390impl<'a> IterableExprImmediateAttrs<'a> {
9391    pub fn get_dreg(&self) -> Result<u32, ErrorContext> {
9392        let mut iter = self.clone();
9393        iter.pos = 0;
9394        for attr in iter {
9395            if let ExprImmediateAttrs::Dreg(val) = attr? {
9396                return Ok(val);
9397            }
9398        }
9399        Err(ErrorContext::new_missing(
9400            "ExprImmediateAttrs",
9401            "Dreg",
9402            self.orig_loc,
9403            self.buf.as_ptr() as usize,
9404        ))
9405    }
9406    pub fn get_data(&self) -> Result<IterableDataAttrs<'a>, ErrorContext> {
9407        let mut iter = self.clone();
9408        iter.pos = 0;
9409        for attr in iter {
9410            if let ExprImmediateAttrs::Data(val) = attr? {
9411                return Ok(val);
9412            }
9413        }
9414        Err(ErrorContext::new_missing(
9415            "ExprImmediateAttrs",
9416            "Data",
9417            self.orig_loc,
9418            self.buf.as_ptr() as usize,
9419        ))
9420    }
9421}
9422impl ExprImmediateAttrs<'_> {
9423    pub fn new<'a>(buf: &'a [u8]) -> IterableExprImmediateAttrs<'a> {
9424        IterableExprImmediateAttrs::with_loc(buf, buf.as_ptr() as usize)
9425    }
9426    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9427        let res = match r#type {
9428            1u16 => "Dreg",
9429            2u16 => "Data",
9430            _ => return None,
9431        };
9432        Some(res)
9433    }
9434}
9435#[derive(Clone, Copy, Default)]
9436pub struct IterableExprImmediateAttrs<'a> {
9437    buf: &'a [u8],
9438    pos: usize,
9439    orig_loc: usize,
9440}
9441impl<'a> IterableExprImmediateAttrs<'a> {
9442    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9443        Self {
9444            buf,
9445            pos: 0,
9446            orig_loc,
9447        }
9448    }
9449    pub fn get_buf(&self) -> &'a [u8] {
9450        self.buf
9451    }
9452}
9453impl<'a> Iterator for IterableExprImmediateAttrs<'a> {
9454    type Item = Result<ExprImmediateAttrs<'a>, ErrorContext>;
9455    fn next(&mut self) -> Option<Self::Item> {
9456        let pos = self.pos;
9457        let mut r#type;
9458        loop {
9459            r#type = None;
9460            if self.buf.len() == self.pos {
9461                return None;
9462            }
9463            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
9464                break;
9465            };
9466            r#type = Some(header.r#type);
9467            let res = match header.r#type {
9468                1u16 => ExprImmediateAttrs::Dreg({
9469                    let res = parse_be_u32(next);
9470                    let Some(val) = res else { break };
9471                    val
9472                }),
9473                2u16 => ExprImmediateAttrs::Data({
9474                    let res = Some(IterableDataAttrs::with_loc(next, self.orig_loc));
9475                    let Some(val) = res else { break };
9476                    val
9477                }),
9478                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9479                n => continue,
9480            };
9481            return Some(Ok(res));
9482        }
9483        Some(Err(ErrorContext::new(
9484            "ExprImmediateAttrs",
9485            r#type.and_then(|t| ExprImmediateAttrs::attr_from_type(t)),
9486            self.orig_loc,
9487            self.buf.as_ptr().wrapping_add(pos) as usize,
9488        )))
9489    }
9490}
9491impl<'a> std::fmt::Debug for IterableExprImmediateAttrs<'_> {
9492    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9493        let mut fmt = f.debug_struct("ExprImmediateAttrs");
9494        for attr in self.clone() {
9495            let attr = match attr {
9496                Ok(a) => a,
9497                Err(err) => {
9498                    fmt.finish()?;
9499                    f.write_str("Err(")?;
9500                    err.fmt(f)?;
9501                    return f.write_str(")");
9502                }
9503            };
9504            match attr {
9505                ExprImmediateAttrs::Dreg(val) => fmt.field("Dreg", &val),
9506                ExprImmediateAttrs::Data(val) => fmt.field("Data", &val),
9507            };
9508        }
9509        fmt.finish()
9510    }
9511}
9512impl IterableExprImmediateAttrs<'_> {
9513    pub fn lookup_attr(
9514        &self,
9515        offset: usize,
9516        missing_type: Option<u16>,
9517    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9518        let mut stack = Vec::new();
9519        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9520        if missing_type.is_some() && cur == offset {
9521            stack.push(("ExprImmediateAttrs", offset));
9522            return (
9523                stack,
9524                missing_type.and_then(|t| ExprImmediateAttrs::attr_from_type(t)),
9525            );
9526        }
9527        if cur > offset || cur + self.buf.len() < offset {
9528            return (stack, None);
9529        }
9530        let mut attrs = self.clone();
9531        let mut last_off = cur + attrs.pos;
9532        let mut missing = None;
9533        while let Some(attr) = attrs.next() {
9534            let Ok(attr) = attr else { break };
9535            match attr {
9536                ExprImmediateAttrs::Dreg(val) => {
9537                    if last_off == offset {
9538                        stack.push(("Dreg", last_off));
9539                        break;
9540                    }
9541                }
9542                ExprImmediateAttrs::Data(val) => {
9543                    (stack, missing) = val.lookup_attr(offset, missing_type);
9544                    if !stack.is_empty() {
9545                        break;
9546                    }
9547                }
9548                _ => {}
9549            };
9550            last_off = cur + attrs.pos;
9551        }
9552        if !stack.is_empty() {
9553            stack.push(("ExprImmediateAttrs", cur));
9554        }
9555        (stack, missing)
9556    }
9557}
9558#[derive(Clone)]
9559pub enum ExprLookupAttrs<'a> {
9560    #[doc = "Name of set to use"]
9561    Set(&'a CStr),
9562    #[doc = "ID of set to use"]
9563    SetId(u32),
9564    Sreg(u32),
9565    Dreg(u32),
9566    #[doc = "Associated type: [`LookupFlags`] (enum)"]
9567    Flags(u32),
9568}
9569impl<'a> IterableExprLookupAttrs<'a> {
9570    #[doc = "Name of set to use"]
9571    pub fn get_set(&self) -> Result<&'a CStr, ErrorContext> {
9572        let mut iter = self.clone();
9573        iter.pos = 0;
9574        for attr in iter {
9575            if let ExprLookupAttrs::Set(val) = attr? {
9576                return Ok(val);
9577            }
9578        }
9579        Err(ErrorContext::new_missing(
9580            "ExprLookupAttrs",
9581            "Set",
9582            self.orig_loc,
9583            self.buf.as_ptr() as usize,
9584        ))
9585    }
9586    #[doc = "ID of set to use"]
9587    pub fn get_set_id(&self) -> Result<u32, ErrorContext> {
9588        let mut iter = self.clone();
9589        iter.pos = 0;
9590        for attr in iter {
9591            if let ExprLookupAttrs::SetId(val) = attr? {
9592                return Ok(val);
9593            }
9594        }
9595        Err(ErrorContext::new_missing(
9596            "ExprLookupAttrs",
9597            "SetId",
9598            self.orig_loc,
9599            self.buf.as_ptr() as usize,
9600        ))
9601    }
9602    pub fn get_sreg(&self) -> Result<u32, ErrorContext> {
9603        let mut iter = self.clone();
9604        iter.pos = 0;
9605        for attr in iter {
9606            if let ExprLookupAttrs::Sreg(val) = attr? {
9607                return Ok(val);
9608            }
9609        }
9610        Err(ErrorContext::new_missing(
9611            "ExprLookupAttrs",
9612            "Sreg",
9613            self.orig_loc,
9614            self.buf.as_ptr() as usize,
9615        ))
9616    }
9617    pub fn get_dreg(&self) -> Result<u32, ErrorContext> {
9618        let mut iter = self.clone();
9619        iter.pos = 0;
9620        for attr in iter {
9621            if let ExprLookupAttrs::Dreg(val) = attr? {
9622                return Ok(val);
9623            }
9624        }
9625        Err(ErrorContext::new_missing(
9626            "ExprLookupAttrs",
9627            "Dreg",
9628            self.orig_loc,
9629            self.buf.as_ptr() as usize,
9630        ))
9631    }
9632    #[doc = "Associated type: [`LookupFlags`] (enum)"]
9633    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
9634        let mut iter = self.clone();
9635        iter.pos = 0;
9636        for attr in iter {
9637            if let ExprLookupAttrs::Flags(val) = attr? {
9638                return Ok(val);
9639            }
9640        }
9641        Err(ErrorContext::new_missing(
9642            "ExprLookupAttrs",
9643            "Flags",
9644            self.orig_loc,
9645            self.buf.as_ptr() as usize,
9646        ))
9647    }
9648}
9649impl ExprLookupAttrs<'_> {
9650    pub fn new<'a>(buf: &'a [u8]) -> IterableExprLookupAttrs<'a> {
9651        IterableExprLookupAttrs::with_loc(buf, buf.as_ptr() as usize)
9652    }
9653    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9654        let res = match r#type {
9655            1u16 => "Set",
9656            2u16 => "SetId",
9657            3u16 => "Sreg",
9658            4u16 => "Dreg",
9659            5u16 => "Flags",
9660            _ => return None,
9661        };
9662        Some(res)
9663    }
9664}
9665#[derive(Clone, Copy, Default)]
9666pub struct IterableExprLookupAttrs<'a> {
9667    buf: &'a [u8],
9668    pos: usize,
9669    orig_loc: usize,
9670}
9671impl<'a> IterableExprLookupAttrs<'a> {
9672    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9673        Self {
9674            buf,
9675            pos: 0,
9676            orig_loc,
9677        }
9678    }
9679    pub fn get_buf(&self) -> &'a [u8] {
9680        self.buf
9681    }
9682}
9683impl<'a> Iterator for IterableExprLookupAttrs<'a> {
9684    type Item = Result<ExprLookupAttrs<'a>, ErrorContext>;
9685    fn next(&mut self) -> Option<Self::Item> {
9686        let pos = self.pos;
9687        let mut r#type;
9688        loop {
9689            r#type = None;
9690            if self.buf.len() == self.pos {
9691                return None;
9692            }
9693            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
9694                break;
9695            };
9696            r#type = Some(header.r#type);
9697            let res = match header.r#type {
9698                1u16 => ExprLookupAttrs::Set({
9699                    let res = CStr::from_bytes_with_nul(next).ok();
9700                    let Some(val) = res else { break };
9701                    val
9702                }),
9703                2u16 => ExprLookupAttrs::SetId({
9704                    let res = parse_be_u32(next);
9705                    let Some(val) = res else { break };
9706                    val
9707                }),
9708                3u16 => ExprLookupAttrs::Sreg({
9709                    let res = parse_be_u32(next);
9710                    let Some(val) = res else { break };
9711                    val
9712                }),
9713                4u16 => ExprLookupAttrs::Dreg({
9714                    let res = parse_be_u32(next);
9715                    let Some(val) = res else { break };
9716                    val
9717                }),
9718                5u16 => ExprLookupAttrs::Flags({
9719                    let res = parse_be_u32(next);
9720                    let Some(val) = res else { break };
9721                    val
9722                }),
9723                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9724                n => continue,
9725            };
9726            return Some(Ok(res));
9727        }
9728        Some(Err(ErrorContext::new(
9729            "ExprLookupAttrs",
9730            r#type.and_then(|t| ExprLookupAttrs::attr_from_type(t)),
9731            self.orig_loc,
9732            self.buf.as_ptr().wrapping_add(pos) as usize,
9733        )))
9734    }
9735}
9736impl<'a> std::fmt::Debug for IterableExprLookupAttrs<'_> {
9737    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9738        let mut fmt = f.debug_struct("ExprLookupAttrs");
9739        for attr in self.clone() {
9740            let attr = match attr {
9741                Ok(a) => a,
9742                Err(err) => {
9743                    fmt.finish()?;
9744                    f.write_str("Err(")?;
9745                    err.fmt(f)?;
9746                    return f.write_str(")");
9747                }
9748            };
9749            match attr {
9750                ExprLookupAttrs::Set(val) => fmt.field("Set", &val),
9751                ExprLookupAttrs::SetId(val) => fmt.field("SetId", &val),
9752                ExprLookupAttrs::Sreg(val) => fmt.field("Sreg", &val),
9753                ExprLookupAttrs::Dreg(val) => fmt.field("Dreg", &val),
9754                ExprLookupAttrs::Flags(val) => {
9755                    fmt.field("Flags", &FormatFlags(val.into(), LookupFlags::from_value))
9756                }
9757            };
9758        }
9759        fmt.finish()
9760    }
9761}
9762impl IterableExprLookupAttrs<'_> {
9763    pub fn lookup_attr(
9764        &self,
9765        offset: usize,
9766        missing_type: Option<u16>,
9767    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9768        let mut stack = Vec::new();
9769        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9770        if missing_type.is_some() && cur == offset {
9771            stack.push(("ExprLookupAttrs", offset));
9772            return (
9773                stack,
9774                missing_type.and_then(|t| ExprLookupAttrs::attr_from_type(t)),
9775            );
9776        }
9777        if cur > offset || cur + self.buf.len() < offset {
9778            return (stack, None);
9779        }
9780        let mut attrs = self.clone();
9781        let mut last_off = cur + attrs.pos;
9782        while let Some(attr) = attrs.next() {
9783            let Ok(attr) = attr else { break };
9784            match attr {
9785                ExprLookupAttrs::Set(val) => {
9786                    if last_off == offset {
9787                        stack.push(("Set", last_off));
9788                        break;
9789                    }
9790                }
9791                ExprLookupAttrs::SetId(val) => {
9792                    if last_off == offset {
9793                        stack.push(("SetId", last_off));
9794                        break;
9795                    }
9796                }
9797                ExprLookupAttrs::Sreg(val) => {
9798                    if last_off == offset {
9799                        stack.push(("Sreg", last_off));
9800                        break;
9801                    }
9802                }
9803                ExprLookupAttrs::Dreg(val) => {
9804                    if last_off == offset {
9805                        stack.push(("Dreg", last_off));
9806                        break;
9807                    }
9808                }
9809                ExprLookupAttrs::Flags(val) => {
9810                    if last_off == offset {
9811                        stack.push(("Flags", last_off));
9812                        break;
9813                    }
9814                }
9815                _ => {}
9816            };
9817            last_off = cur + attrs.pos;
9818        }
9819        if !stack.is_empty() {
9820            stack.push(("ExprLookupAttrs", cur));
9821        }
9822        (stack, None)
9823    }
9824}
9825#[derive(Clone)]
9826pub enum ExprMasqAttrs {
9827    #[doc = "Associated type: [`NatRangeFlags`] (1 bit per enumeration)"]
9828    Flags(u32),
9829    #[doc = "Associated type: [`Registers`] (enum)"]
9830    RegProtoMin(u32),
9831    #[doc = "Associated type: [`Registers`] (enum)"]
9832    RegProtoMax(u32),
9833}
9834impl<'a> IterableExprMasqAttrs<'a> {
9835    #[doc = "Associated type: [`NatRangeFlags`] (1 bit per enumeration)"]
9836    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
9837        let mut iter = self.clone();
9838        iter.pos = 0;
9839        for attr in iter {
9840            if let ExprMasqAttrs::Flags(val) = attr? {
9841                return Ok(val);
9842            }
9843        }
9844        Err(ErrorContext::new_missing(
9845            "ExprMasqAttrs",
9846            "Flags",
9847            self.orig_loc,
9848            self.buf.as_ptr() as usize,
9849        ))
9850    }
9851    #[doc = "Associated type: [`Registers`] (enum)"]
9852    pub fn get_reg_proto_min(&self) -> Result<u32, ErrorContext> {
9853        let mut iter = self.clone();
9854        iter.pos = 0;
9855        for attr in iter {
9856            if let ExprMasqAttrs::RegProtoMin(val) = attr? {
9857                return Ok(val);
9858            }
9859        }
9860        Err(ErrorContext::new_missing(
9861            "ExprMasqAttrs",
9862            "RegProtoMin",
9863            self.orig_loc,
9864            self.buf.as_ptr() as usize,
9865        ))
9866    }
9867    #[doc = "Associated type: [`Registers`] (enum)"]
9868    pub fn get_reg_proto_max(&self) -> Result<u32, ErrorContext> {
9869        let mut iter = self.clone();
9870        iter.pos = 0;
9871        for attr in iter {
9872            if let ExprMasqAttrs::RegProtoMax(val) = attr? {
9873                return Ok(val);
9874            }
9875        }
9876        Err(ErrorContext::new_missing(
9877            "ExprMasqAttrs",
9878            "RegProtoMax",
9879            self.orig_loc,
9880            self.buf.as_ptr() as usize,
9881        ))
9882    }
9883}
9884impl ExprMasqAttrs {
9885    pub fn new<'a>(buf: &'a [u8]) -> IterableExprMasqAttrs<'a> {
9886        IterableExprMasqAttrs::with_loc(buf, buf.as_ptr() as usize)
9887    }
9888    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9889        let res = match r#type {
9890            1u16 => "Flags",
9891            2u16 => "RegProtoMin",
9892            3u16 => "RegProtoMax",
9893            _ => return None,
9894        };
9895        Some(res)
9896    }
9897}
9898#[derive(Clone, Copy, Default)]
9899pub struct IterableExprMasqAttrs<'a> {
9900    buf: &'a [u8],
9901    pos: usize,
9902    orig_loc: usize,
9903}
9904impl<'a> IterableExprMasqAttrs<'a> {
9905    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9906        Self {
9907            buf,
9908            pos: 0,
9909            orig_loc,
9910        }
9911    }
9912    pub fn get_buf(&self) -> &'a [u8] {
9913        self.buf
9914    }
9915}
9916impl<'a> Iterator for IterableExprMasqAttrs<'a> {
9917    type Item = Result<ExprMasqAttrs, ErrorContext>;
9918    fn next(&mut self) -> Option<Self::Item> {
9919        let pos = self.pos;
9920        let mut r#type;
9921        loop {
9922            r#type = None;
9923            if self.buf.len() == self.pos {
9924                return None;
9925            }
9926            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
9927                break;
9928            };
9929            r#type = Some(header.r#type);
9930            let res = match header.r#type {
9931                1u16 => ExprMasqAttrs::Flags({
9932                    let res = parse_be_u32(next);
9933                    let Some(val) = res else { break };
9934                    val
9935                }),
9936                2u16 => ExprMasqAttrs::RegProtoMin({
9937                    let res = parse_be_u32(next);
9938                    let Some(val) = res else { break };
9939                    val
9940                }),
9941                3u16 => ExprMasqAttrs::RegProtoMax({
9942                    let res = parse_be_u32(next);
9943                    let Some(val) = res else { break };
9944                    val
9945                }),
9946                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9947                n => continue,
9948            };
9949            return Some(Ok(res));
9950        }
9951        Some(Err(ErrorContext::new(
9952            "ExprMasqAttrs",
9953            r#type.and_then(|t| ExprMasqAttrs::attr_from_type(t)),
9954            self.orig_loc,
9955            self.buf.as_ptr().wrapping_add(pos) as usize,
9956        )))
9957    }
9958}
9959impl std::fmt::Debug for IterableExprMasqAttrs<'_> {
9960    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9961        let mut fmt = f.debug_struct("ExprMasqAttrs");
9962        for attr in self.clone() {
9963            let attr = match attr {
9964                Ok(a) => a,
9965                Err(err) => {
9966                    fmt.finish()?;
9967                    f.write_str("Err(")?;
9968                    err.fmt(f)?;
9969                    return f.write_str(")");
9970                }
9971            };
9972            match attr {
9973                ExprMasqAttrs::Flags(val) => {
9974                    fmt.field("Flags", &FormatFlags(val.into(), NatRangeFlags::from_value))
9975                }
9976                ExprMasqAttrs::RegProtoMin(val) => fmt.field(
9977                    "RegProtoMin",
9978                    &FormatEnum(val.into(), Registers::from_value),
9979                ),
9980                ExprMasqAttrs::RegProtoMax(val) => fmt.field(
9981                    "RegProtoMax",
9982                    &FormatEnum(val.into(), Registers::from_value),
9983                ),
9984            };
9985        }
9986        fmt.finish()
9987    }
9988}
9989impl IterableExprMasqAttrs<'_> {
9990    pub fn lookup_attr(
9991        &self,
9992        offset: usize,
9993        missing_type: Option<u16>,
9994    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9995        let mut stack = Vec::new();
9996        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9997        if missing_type.is_some() && cur == offset {
9998            stack.push(("ExprMasqAttrs", offset));
9999            return (
10000                stack,
10001                missing_type.and_then(|t| ExprMasqAttrs::attr_from_type(t)),
10002            );
10003        }
10004        if cur > offset || cur + self.buf.len() < offset {
10005            return (stack, None);
10006        }
10007        let mut attrs = self.clone();
10008        let mut last_off = cur + attrs.pos;
10009        while let Some(attr) = attrs.next() {
10010            let Ok(attr) = attr else { break };
10011            match attr {
10012                ExprMasqAttrs::Flags(val) => {
10013                    if last_off == offset {
10014                        stack.push(("Flags", last_off));
10015                        break;
10016                    }
10017                }
10018                ExprMasqAttrs::RegProtoMin(val) => {
10019                    if last_off == offset {
10020                        stack.push(("RegProtoMin", last_off));
10021                        break;
10022                    }
10023                }
10024                ExprMasqAttrs::RegProtoMax(val) => {
10025                    if last_off == offset {
10026                        stack.push(("RegProtoMax", last_off));
10027                        break;
10028                    }
10029                }
10030                _ => {}
10031            };
10032            last_off = cur + attrs.pos;
10033        }
10034        if !stack.is_empty() {
10035            stack.push(("ExprMasqAttrs", cur));
10036        }
10037        (stack, None)
10038    }
10039}
10040#[derive(Clone)]
10041pub enum ExprMetaAttrs {
10042    Dreg(u32),
10043    #[doc = "Associated type: [`MetaKeys`] (enum)"]
10044    Key(u32),
10045    Sreg(u32),
10046}
10047impl<'a> IterableExprMetaAttrs<'a> {
10048    pub fn get_dreg(&self) -> Result<u32, ErrorContext> {
10049        let mut iter = self.clone();
10050        iter.pos = 0;
10051        for attr in iter {
10052            if let ExprMetaAttrs::Dreg(val) = attr? {
10053                return Ok(val);
10054            }
10055        }
10056        Err(ErrorContext::new_missing(
10057            "ExprMetaAttrs",
10058            "Dreg",
10059            self.orig_loc,
10060            self.buf.as_ptr() as usize,
10061        ))
10062    }
10063    #[doc = "Associated type: [`MetaKeys`] (enum)"]
10064    pub fn get_key(&self) -> Result<u32, ErrorContext> {
10065        let mut iter = self.clone();
10066        iter.pos = 0;
10067        for attr in iter {
10068            if let ExprMetaAttrs::Key(val) = attr? {
10069                return Ok(val);
10070            }
10071        }
10072        Err(ErrorContext::new_missing(
10073            "ExprMetaAttrs",
10074            "Key",
10075            self.orig_loc,
10076            self.buf.as_ptr() as usize,
10077        ))
10078    }
10079    pub fn get_sreg(&self) -> Result<u32, ErrorContext> {
10080        let mut iter = self.clone();
10081        iter.pos = 0;
10082        for attr in iter {
10083            if let ExprMetaAttrs::Sreg(val) = attr? {
10084                return Ok(val);
10085            }
10086        }
10087        Err(ErrorContext::new_missing(
10088            "ExprMetaAttrs",
10089            "Sreg",
10090            self.orig_loc,
10091            self.buf.as_ptr() as usize,
10092        ))
10093    }
10094}
10095impl ExprMetaAttrs {
10096    pub fn new<'a>(buf: &'a [u8]) -> IterableExprMetaAttrs<'a> {
10097        IterableExprMetaAttrs::with_loc(buf, buf.as_ptr() as usize)
10098    }
10099    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10100        let res = match r#type {
10101            1u16 => "Dreg",
10102            2u16 => "Key",
10103            3u16 => "Sreg",
10104            _ => return None,
10105        };
10106        Some(res)
10107    }
10108}
10109#[derive(Clone, Copy, Default)]
10110pub struct IterableExprMetaAttrs<'a> {
10111    buf: &'a [u8],
10112    pos: usize,
10113    orig_loc: usize,
10114}
10115impl<'a> IterableExprMetaAttrs<'a> {
10116    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10117        Self {
10118            buf,
10119            pos: 0,
10120            orig_loc,
10121        }
10122    }
10123    pub fn get_buf(&self) -> &'a [u8] {
10124        self.buf
10125    }
10126}
10127impl<'a> Iterator for IterableExprMetaAttrs<'a> {
10128    type Item = Result<ExprMetaAttrs, ErrorContext>;
10129    fn next(&mut self) -> Option<Self::Item> {
10130        let pos = self.pos;
10131        let mut r#type;
10132        loop {
10133            r#type = None;
10134            if self.buf.len() == self.pos {
10135                return None;
10136            }
10137            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
10138                break;
10139            };
10140            r#type = Some(header.r#type);
10141            let res = match header.r#type {
10142                1u16 => ExprMetaAttrs::Dreg({
10143                    let res = parse_be_u32(next);
10144                    let Some(val) = res else { break };
10145                    val
10146                }),
10147                2u16 => ExprMetaAttrs::Key({
10148                    let res = parse_be_u32(next);
10149                    let Some(val) = res else { break };
10150                    val
10151                }),
10152                3u16 => ExprMetaAttrs::Sreg({
10153                    let res = parse_be_u32(next);
10154                    let Some(val) = res else { break };
10155                    val
10156                }),
10157                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
10158                n => continue,
10159            };
10160            return Some(Ok(res));
10161        }
10162        Some(Err(ErrorContext::new(
10163            "ExprMetaAttrs",
10164            r#type.and_then(|t| ExprMetaAttrs::attr_from_type(t)),
10165            self.orig_loc,
10166            self.buf.as_ptr().wrapping_add(pos) as usize,
10167        )))
10168    }
10169}
10170impl std::fmt::Debug for IterableExprMetaAttrs<'_> {
10171    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10172        let mut fmt = f.debug_struct("ExprMetaAttrs");
10173        for attr in self.clone() {
10174            let attr = match attr {
10175                Ok(a) => a,
10176                Err(err) => {
10177                    fmt.finish()?;
10178                    f.write_str("Err(")?;
10179                    err.fmt(f)?;
10180                    return f.write_str(")");
10181                }
10182            };
10183            match attr {
10184                ExprMetaAttrs::Dreg(val) => fmt.field("Dreg", &val),
10185                ExprMetaAttrs::Key(val) => {
10186                    fmt.field("Key", &FormatEnum(val.into(), MetaKeys::from_value))
10187                }
10188                ExprMetaAttrs::Sreg(val) => fmt.field("Sreg", &val),
10189            };
10190        }
10191        fmt.finish()
10192    }
10193}
10194impl IterableExprMetaAttrs<'_> {
10195    pub fn lookup_attr(
10196        &self,
10197        offset: usize,
10198        missing_type: Option<u16>,
10199    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
10200        let mut stack = Vec::new();
10201        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
10202        if missing_type.is_some() && cur == offset {
10203            stack.push(("ExprMetaAttrs", offset));
10204            return (
10205                stack,
10206                missing_type.and_then(|t| ExprMetaAttrs::attr_from_type(t)),
10207            );
10208        }
10209        if cur > offset || cur + self.buf.len() < offset {
10210            return (stack, None);
10211        }
10212        let mut attrs = self.clone();
10213        let mut last_off = cur + attrs.pos;
10214        while let Some(attr) = attrs.next() {
10215            let Ok(attr) = attr else { break };
10216            match attr {
10217                ExprMetaAttrs::Dreg(val) => {
10218                    if last_off == offset {
10219                        stack.push(("Dreg", last_off));
10220                        break;
10221                    }
10222                }
10223                ExprMetaAttrs::Key(val) => {
10224                    if last_off == offset {
10225                        stack.push(("Key", last_off));
10226                        break;
10227                    }
10228                }
10229                ExprMetaAttrs::Sreg(val) => {
10230                    if last_off == offset {
10231                        stack.push(("Sreg", last_off));
10232                        break;
10233                    }
10234                }
10235                _ => {}
10236            };
10237            last_off = cur + attrs.pos;
10238        }
10239        if !stack.is_empty() {
10240            stack.push(("ExprMetaAttrs", cur));
10241        }
10242        (stack, None)
10243    }
10244}
10245#[derive(Clone)]
10246pub enum ExprNatAttrs {
10247    Type(u32),
10248    Family(u32),
10249    RegAddrMin(u32),
10250    RegAddrMax(u32),
10251    RegProtoMin(u32),
10252    RegProtoMax(u32),
10253    #[doc = "Associated type: [`NatRangeFlags`] (1 bit per enumeration)"]
10254    Flags(u32),
10255}
10256impl<'a> IterableExprNatAttrs<'a> {
10257    pub fn get_type(&self) -> Result<u32, ErrorContext> {
10258        let mut iter = self.clone();
10259        iter.pos = 0;
10260        for attr in iter {
10261            if let ExprNatAttrs::Type(val) = attr? {
10262                return Ok(val);
10263            }
10264        }
10265        Err(ErrorContext::new_missing(
10266            "ExprNatAttrs",
10267            "Type",
10268            self.orig_loc,
10269            self.buf.as_ptr() as usize,
10270        ))
10271    }
10272    pub fn get_family(&self) -> Result<u32, ErrorContext> {
10273        let mut iter = self.clone();
10274        iter.pos = 0;
10275        for attr in iter {
10276            if let ExprNatAttrs::Family(val) = attr? {
10277                return Ok(val);
10278            }
10279        }
10280        Err(ErrorContext::new_missing(
10281            "ExprNatAttrs",
10282            "Family",
10283            self.orig_loc,
10284            self.buf.as_ptr() as usize,
10285        ))
10286    }
10287    pub fn get_reg_addr_min(&self) -> Result<u32, ErrorContext> {
10288        let mut iter = self.clone();
10289        iter.pos = 0;
10290        for attr in iter {
10291            if let ExprNatAttrs::RegAddrMin(val) = attr? {
10292                return Ok(val);
10293            }
10294        }
10295        Err(ErrorContext::new_missing(
10296            "ExprNatAttrs",
10297            "RegAddrMin",
10298            self.orig_loc,
10299            self.buf.as_ptr() as usize,
10300        ))
10301    }
10302    pub fn get_reg_addr_max(&self) -> Result<u32, ErrorContext> {
10303        let mut iter = self.clone();
10304        iter.pos = 0;
10305        for attr in iter {
10306            if let ExprNatAttrs::RegAddrMax(val) = attr? {
10307                return Ok(val);
10308            }
10309        }
10310        Err(ErrorContext::new_missing(
10311            "ExprNatAttrs",
10312            "RegAddrMax",
10313            self.orig_loc,
10314            self.buf.as_ptr() as usize,
10315        ))
10316    }
10317    pub fn get_reg_proto_min(&self) -> Result<u32, ErrorContext> {
10318        let mut iter = self.clone();
10319        iter.pos = 0;
10320        for attr in iter {
10321            if let ExprNatAttrs::RegProtoMin(val) = attr? {
10322                return Ok(val);
10323            }
10324        }
10325        Err(ErrorContext::new_missing(
10326            "ExprNatAttrs",
10327            "RegProtoMin",
10328            self.orig_loc,
10329            self.buf.as_ptr() as usize,
10330        ))
10331    }
10332    pub fn get_reg_proto_max(&self) -> Result<u32, ErrorContext> {
10333        let mut iter = self.clone();
10334        iter.pos = 0;
10335        for attr in iter {
10336            if let ExprNatAttrs::RegProtoMax(val) = attr? {
10337                return Ok(val);
10338            }
10339        }
10340        Err(ErrorContext::new_missing(
10341            "ExprNatAttrs",
10342            "RegProtoMax",
10343            self.orig_loc,
10344            self.buf.as_ptr() as usize,
10345        ))
10346    }
10347    #[doc = "Associated type: [`NatRangeFlags`] (1 bit per enumeration)"]
10348    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
10349        let mut iter = self.clone();
10350        iter.pos = 0;
10351        for attr in iter {
10352            if let ExprNatAttrs::Flags(val) = attr? {
10353                return Ok(val);
10354            }
10355        }
10356        Err(ErrorContext::new_missing(
10357            "ExprNatAttrs",
10358            "Flags",
10359            self.orig_loc,
10360            self.buf.as_ptr() as usize,
10361        ))
10362    }
10363}
10364impl ExprNatAttrs {
10365    pub fn new<'a>(buf: &'a [u8]) -> IterableExprNatAttrs<'a> {
10366        IterableExprNatAttrs::with_loc(buf, buf.as_ptr() as usize)
10367    }
10368    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10369        let res = match r#type {
10370            1u16 => "Type",
10371            2u16 => "Family",
10372            3u16 => "RegAddrMin",
10373            4u16 => "RegAddrMax",
10374            5u16 => "RegProtoMin",
10375            6u16 => "RegProtoMax",
10376            7u16 => "Flags",
10377            _ => return None,
10378        };
10379        Some(res)
10380    }
10381}
10382#[derive(Clone, Copy, Default)]
10383pub struct IterableExprNatAttrs<'a> {
10384    buf: &'a [u8],
10385    pos: usize,
10386    orig_loc: usize,
10387}
10388impl<'a> IterableExprNatAttrs<'a> {
10389    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10390        Self {
10391            buf,
10392            pos: 0,
10393            orig_loc,
10394        }
10395    }
10396    pub fn get_buf(&self) -> &'a [u8] {
10397        self.buf
10398    }
10399}
10400impl<'a> Iterator for IterableExprNatAttrs<'a> {
10401    type Item = Result<ExprNatAttrs, ErrorContext>;
10402    fn next(&mut self) -> Option<Self::Item> {
10403        let pos = self.pos;
10404        let mut r#type;
10405        loop {
10406            r#type = None;
10407            if self.buf.len() == self.pos {
10408                return None;
10409            }
10410            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
10411                break;
10412            };
10413            r#type = Some(header.r#type);
10414            let res = match header.r#type {
10415                1u16 => ExprNatAttrs::Type({
10416                    let res = parse_be_u32(next);
10417                    let Some(val) = res else { break };
10418                    val
10419                }),
10420                2u16 => ExprNatAttrs::Family({
10421                    let res = parse_be_u32(next);
10422                    let Some(val) = res else { break };
10423                    val
10424                }),
10425                3u16 => ExprNatAttrs::RegAddrMin({
10426                    let res = parse_be_u32(next);
10427                    let Some(val) = res else { break };
10428                    val
10429                }),
10430                4u16 => ExprNatAttrs::RegAddrMax({
10431                    let res = parse_be_u32(next);
10432                    let Some(val) = res else { break };
10433                    val
10434                }),
10435                5u16 => ExprNatAttrs::RegProtoMin({
10436                    let res = parse_be_u32(next);
10437                    let Some(val) = res else { break };
10438                    val
10439                }),
10440                6u16 => ExprNatAttrs::RegProtoMax({
10441                    let res = parse_be_u32(next);
10442                    let Some(val) = res else { break };
10443                    val
10444                }),
10445                7u16 => ExprNatAttrs::Flags({
10446                    let res = parse_be_u32(next);
10447                    let Some(val) = res else { break };
10448                    val
10449                }),
10450                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
10451                n => continue,
10452            };
10453            return Some(Ok(res));
10454        }
10455        Some(Err(ErrorContext::new(
10456            "ExprNatAttrs",
10457            r#type.and_then(|t| ExprNatAttrs::attr_from_type(t)),
10458            self.orig_loc,
10459            self.buf.as_ptr().wrapping_add(pos) as usize,
10460        )))
10461    }
10462}
10463impl std::fmt::Debug for IterableExprNatAttrs<'_> {
10464    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10465        let mut fmt = f.debug_struct("ExprNatAttrs");
10466        for attr in self.clone() {
10467            let attr = match attr {
10468                Ok(a) => a,
10469                Err(err) => {
10470                    fmt.finish()?;
10471                    f.write_str("Err(")?;
10472                    err.fmt(f)?;
10473                    return f.write_str(")");
10474                }
10475            };
10476            match attr {
10477                ExprNatAttrs::Type(val) => fmt.field("Type", &val),
10478                ExprNatAttrs::Family(val) => fmt.field("Family", &val),
10479                ExprNatAttrs::RegAddrMin(val) => fmt.field("RegAddrMin", &val),
10480                ExprNatAttrs::RegAddrMax(val) => fmt.field("RegAddrMax", &val),
10481                ExprNatAttrs::RegProtoMin(val) => fmt.field("RegProtoMin", &val),
10482                ExprNatAttrs::RegProtoMax(val) => fmt.field("RegProtoMax", &val),
10483                ExprNatAttrs::Flags(val) => {
10484                    fmt.field("Flags", &FormatFlags(val.into(), NatRangeFlags::from_value))
10485                }
10486            };
10487        }
10488        fmt.finish()
10489    }
10490}
10491impl IterableExprNatAttrs<'_> {
10492    pub fn lookup_attr(
10493        &self,
10494        offset: usize,
10495        missing_type: Option<u16>,
10496    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
10497        let mut stack = Vec::new();
10498        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
10499        if missing_type.is_some() && cur == offset {
10500            stack.push(("ExprNatAttrs", offset));
10501            return (
10502                stack,
10503                missing_type.and_then(|t| ExprNatAttrs::attr_from_type(t)),
10504            );
10505        }
10506        if cur > offset || cur + self.buf.len() < offset {
10507            return (stack, None);
10508        }
10509        let mut attrs = self.clone();
10510        let mut last_off = cur + attrs.pos;
10511        while let Some(attr) = attrs.next() {
10512            let Ok(attr) = attr else { break };
10513            match attr {
10514                ExprNatAttrs::Type(val) => {
10515                    if last_off == offset {
10516                        stack.push(("Type", last_off));
10517                        break;
10518                    }
10519                }
10520                ExprNatAttrs::Family(val) => {
10521                    if last_off == offset {
10522                        stack.push(("Family", last_off));
10523                        break;
10524                    }
10525                }
10526                ExprNatAttrs::RegAddrMin(val) => {
10527                    if last_off == offset {
10528                        stack.push(("RegAddrMin", last_off));
10529                        break;
10530                    }
10531                }
10532                ExprNatAttrs::RegAddrMax(val) => {
10533                    if last_off == offset {
10534                        stack.push(("RegAddrMax", last_off));
10535                        break;
10536                    }
10537                }
10538                ExprNatAttrs::RegProtoMin(val) => {
10539                    if last_off == offset {
10540                        stack.push(("RegProtoMin", last_off));
10541                        break;
10542                    }
10543                }
10544                ExprNatAttrs::RegProtoMax(val) => {
10545                    if last_off == offset {
10546                        stack.push(("RegProtoMax", last_off));
10547                        break;
10548                    }
10549                }
10550                ExprNatAttrs::Flags(val) => {
10551                    if last_off == offset {
10552                        stack.push(("Flags", last_off));
10553                        break;
10554                    }
10555                }
10556                _ => {}
10557            };
10558            last_off = cur + attrs.pos;
10559        }
10560        if !stack.is_empty() {
10561            stack.push(("ExprNatAttrs", cur));
10562        }
10563        (stack, None)
10564    }
10565}
10566#[derive(Clone)]
10567pub enum ExprPayloadAttrs {
10568    #[doc = "destination register to load data into\nAssociated type: [`Registers`] (enum)"]
10569    Dreg(u32),
10570    #[doc = "payload base\nAssociated type: [`PayloadBase`] (enum)"]
10571    Base(u32),
10572    #[doc = "payload offset relative to base"]
10573    Offset(u32),
10574    #[doc = "payload length"]
10575    Len(u32),
10576    #[doc = "source register to load data from\nAssociated type: [`Registers`] (enum)"]
10577    Sreg(u32),
10578    #[doc = "checksum type"]
10579    CsumType(u32),
10580    #[doc = "checksum offset relative to base"]
10581    CsumOffset(u32),
10582    #[doc = "checksum flags"]
10583    CsumFlags(u32),
10584}
10585impl<'a> IterableExprPayloadAttrs<'a> {
10586    #[doc = "destination register to load data into\nAssociated type: [`Registers`] (enum)"]
10587    pub fn get_dreg(&self) -> Result<u32, ErrorContext> {
10588        let mut iter = self.clone();
10589        iter.pos = 0;
10590        for attr in iter {
10591            if let ExprPayloadAttrs::Dreg(val) = attr? {
10592                return Ok(val);
10593            }
10594        }
10595        Err(ErrorContext::new_missing(
10596            "ExprPayloadAttrs",
10597            "Dreg",
10598            self.orig_loc,
10599            self.buf.as_ptr() as usize,
10600        ))
10601    }
10602    #[doc = "payload base\nAssociated type: [`PayloadBase`] (enum)"]
10603    pub fn get_base(&self) -> Result<u32, ErrorContext> {
10604        let mut iter = self.clone();
10605        iter.pos = 0;
10606        for attr in iter {
10607            if let ExprPayloadAttrs::Base(val) = attr? {
10608                return Ok(val);
10609            }
10610        }
10611        Err(ErrorContext::new_missing(
10612            "ExprPayloadAttrs",
10613            "Base",
10614            self.orig_loc,
10615            self.buf.as_ptr() as usize,
10616        ))
10617    }
10618    #[doc = "payload offset relative to base"]
10619    pub fn get_offset(&self) -> Result<u32, ErrorContext> {
10620        let mut iter = self.clone();
10621        iter.pos = 0;
10622        for attr in iter {
10623            if let ExprPayloadAttrs::Offset(val) = attr? {
10624                return Ok(val);
10625            }
10626        }
10627        Err(ErrorContext::new_missing(
10628            "ExprPayloadAttrs",
10629            "Offset",
10630            self.orig_loc,
10631            self.buf.as_ptr() as usize,
10632        ))
10633    }
10634    #[doc = "payload length"]
10635    pub fn get_len(&self) -> Result<u32, ErrorContext> {
10636        let mut iter = self.clone();
10637        iter.pos = 0;
10638        for attr in iter {
10639            if let ExprPayloadAttrs::Len(val) = attr? {
10640                return Ok(val);
10641            }
10642        }
10643        Err(ErrorContext::new_missing(
10644            "ExprPayloadAttrs",
10645            "Len",
10646            self.orig_loc,
10647            self.buf.as_ptr() as usize,
10648        ))
10649    }
10650    #[doc = "source register to load data from\nAssociated type: [`Registers`] (enum)"]
10651    pub fn get_sreg(&self) -> Result<u32, ErrorContext> {
10652        let mut iter = self.clone();
10653        iter.pos = 0;
10654        for attr in iter {
10655            if let ExprPayloadAttrs::Sreg(val) = attr? {
10656                return Ok(val);
10657            }
10658        }
10659        Err(ErrorContext::new_missing(
10660            "ExprPayloadAttrs",
10661            "Sreg",
10662            self.orig_loc,
10663            self.buf.as_ptr() as usize,
10664        ))
10665    }
10666    #[doc = "checksum type"]
10667    pub fn get_csum_type(&self) -> Result<u32, ErrorContext> {
10668        let mut iter = self.clone();
10669        iter.pos = 0;
10670        for attr in iter {
10671            if let ExprPayloadAttrs::CsumType(val) = attr? {
10672                return Ok(val);
10673            }
10674        }
10675        Err(ErrorContext::new_missing(
10676            "ExprPayloadAttrs",
10677            "CsumType",
10678            self.orig_loc,
10679            self.buf.as_ptr() as usize,
10680        ))
10681    }
10682    #[doc = "checksum offset relative to base"]
10683    pub fn get_csum_offset(&self) -> Result<u32, ErrorContext> {
10684        let mut iter = self.clone();
10685        iter.pos = 0;
10686        for attr in iter {
10687            if let ExprPayloadAttrs::CsumOffset(val) = attr? {
10688                return Ok(val);
10689            }
10690        }
10691        Err(ErrorContext::new_missing(
10692            "ExprPayloadAttrs",
10693            "CsumOffset",
10694            self.orig_loc,
10695            self.buf.as_ptr() as usize,
10696        ))
10697    }
10698    #[doc = "checksum flags"]
10699    pub fn get_csum_flags(&self) -> Result<u32, ErrorContext> {
10700        let mut iter = self.clone();
10701        iter.pos = 0;
10702        for attr in iter {
10703            if let ExprPayloadAttrs::CsumFlags(val) = attr? {
10704                return Ok(val);
10705            }
10706        }
10707        Err(ErrorContext::new_missing(
10708            "ExprPayloadAttrs",
10709            "CsumFlags",
10710            self.orig_loc,
10711            self.buf.as_ptr() as usize,
10712        ))
10713    }
10714}
10715impl ExprPayloadAttrs {
10716    pub fn new<'a>(buf: &'a [u8]) -> IterableExprPayloadAttrs<'a> {
10717        IterableExprPayloadAttrs::with_loc(buf, buf.as_ptr() as usize)
10718    }
10719    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10720        let res = match r#type {
10721            1u16 => "Dreg",
10722            2u16 => "Base",
10723            3u16 => "Offset",
10724            4u16 => "Len",
10725            5u16 => "Sreg",
10726            6u16 => "CsumType",
10727            7u16 => "CsumOffset",
10728            8u16 => "CsumFlags",
10729            _ => return None,
10730        };
10731        Some(res)
10732    }
10733}
10734#[derive(Clone, Copy, Default)]
10735pub struct IterableExprPayloadAttrs<'a> {
10736    buf: &'a [u8],
10737    pos: usize,
10738    orig_loc: usize,
10739}
10740impl<'a> IterableExprPayloadAttrs<'a> {
10741    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10742        Self {
10743            buf,
10744            pos: 0,
10745            orig_loc,
10746        }
10747    }
10748    pub fn get_buf(&self) -> &'a [u8] {
10749        self.buf
10750    }
10751}
10752impl<'a> Iterator for IterableExprPayloadAttrs<'a> {
10753    type Item = Result<ExprPayloadAttrs, ErrorContext>;
10754    fn next(&mut self) -> Option<Self::Item> {
10755        let pos = self.pos;
10756        let mut r#type;
10757        loop {
10758            r#type = None;
10759            if self.buf.len() == self.pos {
10760                return None;
10761            }
10762            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
10763                break;
10764            };
10765            r#type = Some(header.r#type);
10766            let res = match header.r#type {
10767                1u16 => ExprPayloadAttrs::Dreg({
10768                    let res = parse_be_u32(next);
10769                    let Some(val) = res else { break };
10770                    val
10771                }),
10772                2u16 => ExprPayloadAttrs::Base({
10773                    let res = parse_be_u32(next);
10774                    let Some(val) = res else { break };
10775                    val
10776                }),
10777                3u16 => ExprPayloadAttrs::Offset({
10778                    let res = parse_be_u32(next);
10779                    let Some(val) = res else { break };
10780                    val
10781                }),
10782                4u16 => ExprPayloadAttrs::Len({
10783                    let res = parse_be_u32(next);
10784                    let Some(val) = res else { break };
10785                    val
10786                }),
10787                5u16 => ExprPayloadAttrs::Sreg({
10788                    let res = parse_be_u32(next);
10789                    let Some(val) = res else { break };
10790                    val
10791                }),
10792                6u16 => ExprPayloadAttrs::CsumType({
10793                    let res = parse_be_u32(next);
10794                    let Some(val) = res else { break };
10795                    val
10796                }),
10797                7u16 => ExprPayloadAttrs::CsumOffset({
10798                    let res = parse_be_u32(next);
10799                    let Some(val) = res else { break };
10800                    val
10801                }),
10802                8u16 => ExprPayloadAttrs::CsumFlags({
10803                    let res = parse_be_u32(next);
10804                    let Some(val) = res else { break };
10805                    val
10806                }),
10807                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
10808                n => continue,
10809            };
10810            return Some(Ok(res));
10811        }
10812        Some(Err(ErrorContext::new(
10813            "ExprPayloadAttrs",
10814            r#type.and_then(|t| ExprPayloadAttrs::attr_from_type(t)),
10815            self.orig_loc,
10816            self.buf.as_ptr().wrapping_add(pos) as usize,
10817        )))
10818    }
10819}
10820impl std::fmt::Debug for IterableExprPayloadAttrs<'_> {
10821    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10822        let mut fmt = f.debug_struct("ExprPayloadAttrs");
10823        for attr in self.clone() {
10824            let attr = match attr {
10825                Ok(a) => a,
10826                Err(err) => {
10827                    fmt.finish()?;
10828                    f.write_str("Err(")?;
10829                    err.fmt(f)?;
10830                    return f.write_str(")");
10831                }
10832            };
10833            match attr {
10834                ExprPayloadAttrs::Dreg(val) => {
10835                    fmt.field("Dreg", &FormatEnum(val.into(), Registers::from_value))
10836                }
10837                ExprPayloadAttrs::Base(val) => {
10838                    fmt.field("Base", &FormatEnum(val.into(), PayloadBase::from_value))
10839                }
10840                ExprPayloadAttrs::Offset(val) => fmt.field("Offset", &val),
10841                ExprPayloadAttrs::Len(val) => fmt.field("Len", &val),
10842                ExprPayloadAttrs::Sreg(val) => {
10843                    fmt.field("Sreg", &FormatEnum(val.into(), Registers::from_value))
10844                }
10845                ExprPayloadAttrs::CsumType(val) => fmt.field("CsumType", &val),
10846                ExprPayloadAttrs::CsumOffset(val) => fmt.field("CsumOffset", &val),
10847                ExprPayloadAttrs::CsumFlags(val) => fmt.field("CsumFlags", &val),
10848            };
10849        }
10850        fmt.finish()
10851    }
10852}
10853impl IterableExprPayloadAttrs<'_> {
10854    pub fn lookup_attr(
10855        &self,
10856        offset: usize,
10857        missing_type: Option<u16>,
10858    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
10859        let mut stack = Vec::new();
10860        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
10861        if missing_type.is_some() && cur == offset {
10862            stack.push(("ExprPayloadAttrs", offset));
10863            return (
10864                stack,
10865                missing_type.and_then(|t| ExprPayloadAttrs::attr_from_type(t)),
10866            );
10867        }
10868        if cur > offset || cur + self.buf.len() < offset {
10869            return (stack, None);
10870        }
10871        let mut attrs = self.clone();
10872        let mut last_off = cur + attrs.pos;
10873        while let Some(attr) = attrs.next() {
10874            let Ok(attr) = attr else { break };
10875            match attr {
10876                ExprPayloadAttrs::Dreg(val) => {
10877                    if last_off == offset {
10878                        stack.push(("Dreg", last_off));
10879                        break;
10880                    }
10881                }
10882                ExprPayloadAttrs::Base(val) => {
10883                    if last_off == offset {
10884                        stack.push(("Base", last_off));
10885                        break;
10886                    }
10887                }
10888                ExprPayloadAttrs::Offset(val) => {
10889                    if last_off == offset {
10890                        stack.push(("Offset", last_off));
10891                        break;
10892                    }
10893                }
10894                ExprPayloadAttrs::Len(val) => {
10895                    if last_off == offset {
10896                        stack.push(("Len", last_off));
10897                        break;
10898                    }
10899                }
10900                ExprPayloadAttrs::Sreg(val) => {
10901                    if last_off == offset {
10902                        stack.push(("Sreg", last_off));
10903                        break;
10904                    }
10905                }
10906                ExprPayloadAttrs::CsumType(val) => {
10907                    if last_off == offset {
10908                        stack.push(("CsumType", last_off));
10909                        break;
10910                    }
10911                }
10912                ExprPayloadAttrs::CsumOffset(val) => {
10913                    if last_off == offset {
10914                        stack.push(("CsumOffset", last_off));
10915                        break;
10916                    }
10917                }
10918                ExprPayloadAttrs::CsumFlags(val) => {
10919                    if last_off == offset {
10920                        stack.push(("CsumFlags", last_off));
10921                        break;
10922                    }
10923                }
10924                _ => {}
10925            };
10926            last_off = cur + attrs.pos;
10927        }
10928        if !stack.is_empty() {
10929            stack.push(("ExprPayloadAttrs", cur));
10930        }
10931        (stack, None)
10932    }
10933}
10934#[derive(Clone)]
10935pub enum ExprRejectAttrs {
10936    #[doc = "Associated type: [`RejectTypes`] (enum)"]
10937    Type(u32),
10938    IcmpCode(u8),
10939}
10940impl<'a> IterableExprRejectAttrs<'a> {
10941    #[doc = "Associated type: [`RejectTypes`] (enum)"]
10942    pub fn get_type(&self) -> Result<u32, ErrorContext> {
10943        let mut iter = self.clone();
10944        iter.pos = 0;
10945        for attr in iter {
10946            if let ExprRejectAttrs::Type(val) = attr? {
10947                return Ok(val);
10948            }
10949        }
10950        Err(ErrorContext::new_missing(
10951            "ExprRejectAttrs",
10952            "Type",
10953            self.orig_loc,
10954            self.buf.as_ptr() as usize,
10955        ))
10956    }
10957    pub fn get_icmp_code(&self) -> Result<u8, ErrorContext> {
10958        let mut iter = self.clone();
10959        iter.pos = 0;
10960        for attr in iter {
10961            if let ExprRejectAttrs::IcmpCode(val) = attr? {
10962                return Ok(val);
10963            }
10964        }
10965        Err(ErrorContext::new_missing(
10966            "ExprRejectAttrs",
10967            "IcmpCode",
10968            self.orig_loc,
10969            self.buf.as_ptr() as usize,
10970        ))
10971    }
10972}
10973impl ExprRejectAttrs {
10974    pub fn new<'a>(buf: &'a [u8]) -> IterableExprRejectAttrs<'a> {
10975        IterableExprRejectAttrs::with_loc(buf, buf.as_ptr() as usize)
10976    }
10977    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10978        let res = match r#type {
10979            1u16 => "Type",
10980            2u16 => "IcmpCode",
10981            _ => return None,
10982        };
10983        Some(res)
10984    }
10985}
10986#[derive(Clone, Copy, Default)]
10987pub struct IterableExprRejectAttrs<'a> {
10988    buf: &'a [u8],
10989    pos: usize,
10990    orig_loc: usize,
10991}
10992impl<'a> IterableExprRejectAttrs<'a> {
10993    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10994        Self {
10995            buf,
10996            pos: 0,
10997            orig_loc,
10998        }
10999    }
11000    pub fn get_buf(&self) -> &'a [u8] {
11001        self.buf
11002    }
11003}
11004impl<'a> Iterator for IterableExprRejectAttrs<'a> {
11005    type Item = Result<ExprRejectAttrs, ErrorContext>;
11006    fn next(&mut self) -> Option<Self::Item> {
11007        let pos = self.pos;
11008        let mut r#type;
11009        loop {
11010            r#type = None;
11011            if self.buf.len() == self.pos {
11012                return None;
11013            }
11014            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
11015                break;
11016            };
11017            r#type = Some(header.r#type);
11018            let res = match header.r#type {
11019                1u16 => ExprRejectAttrs::Type({
11020                    let res = parse_be_u32(next);
11021                    let Some(val) = res else { break };
11022                    val
11023                }),
11024                2u16 => ExprRejectAttrs::IcmpCode({
11025                    let res = parse_u8(next);
11026                    let Some(val) = res else { break };
11027                    val
11028                }),
11029                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
11030                n => continue,
11031            };
11032            return Some(Ok(res));
11033        }
11034        Some(Err(ErrorContext::new(
11035            "ExprRejectAttrs",
11036            r#type.and_then(|t| ExprRejectAttrs::attr_from_type(t)),
11037            self.orig_loc,
11038            self.buf.as_ptr().wrapping_add(pos) as usize,
11039        )))
11040    }
11041}
11042impl std::fmt::Debug for IterableExprRejectAttrs<'_> {
11043    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11044        let mut fmt = f.debug_struct("ExprRejectAttrs");
11045        for attr in self.clone() {
11046            let attr = match attr {
11047                Ok(a) => a,
11048                Err(err) => {
11049                    fmt.finish()?;
11050                    f.write_str("Err(")?;
11051                    err.fmt(f)?;
11052                    return f.write_str(")");
11053                }
11054            };
11055            match attr {
11056                ExprRejectAttrs::Type(val) => {
11057                    fmt.field("Type", &FormatEnum(val.into(), RejectTypes::from_value))
11058                }
11059                ExprRejectAttrs::IcmpCode(val) => fmt.field("IcmpCode", &val),
11060            };
11061        }
11062        fmt.finish()
11063    }
11064}
11065impl IterableExprRejectAttrs<'_> {
11066    pub fn lookup_attr(
11067        &self,
11068        offset: usize,
11069        missing_type: Option<u16>,
11070    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11071        let mut stack = Vec::new();
11072        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11073        if missing_type.is_some() && cur == offset {
11074            stack.push(("ExprRejectAttrs", offset));
11075            return (
11076                stack,
11077                missing_type.and_then(|t| ExprRejectAttrs::attr_from_type(t)),
11078            );
11079        }
11080        if cur > offset || cur + self.buf.len() < offset {
11081            return (stack, None);
11082        }
11083        let mut attrs = self.clone();
11084        let mut last_off = cur + attrs.pos;
11085        while let Some(attr) = attrs.next() {
11086            let Ok(attr) = attr else { break };
11087            match attr {
11088                ExprRejectAttrs::Type(val) => {
11089                    if last_off == offset {
11090                        stack.push(("Type", last_off));
11091                        break;
11092                    }
11093                }
11094                ExprRejectAttrs::IcmpCode(val) => {
11095                    if last_off == offset {
11096                        stack.push(("IcmpCode", last_off));
11097                        break;
11098                    }
11099                }
11100                _ => {}
11101            };
11102            last_off = cur + attrs.pos;
11103        }
11104        if !stack.is_empty() {
11105            stack.push(("ExprRejectAttrs", cur));
11106        }
11107        (stack, None)
11108    }
11109}
11110#[derive(Clone)]
11111pub enum ExprTargetAttrs<'a> {
11112    Name(&'a CStr),
11113    Rev(u32),
11114    Info(&'a [u8]),
11115}
11116impl<'a> IterableExprTargetAttrs<'a> {
11117    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
11118        let mut iter = self.clone();
11119        iter.pos = 0;
11120        for attr in iter {
11121            if let ExprTargetAttrs::Name(val) = attr? {
11122                return Ok(val);
11123            }
11124        }
11125        Err(ErrorContext::new_missing(
11126            "ExprTargetAttrs",
11127            "Name",
11128            self.orig_loc,
11129            self.buf.as_ptr() as usize,
11130        ))
11131    }
11132    pub fn get_rev(&self) -> Result<u32, ErrorContext> {
11133        let mut iter = self.clone();
11134        iter.pos = 0;
11135        for attr in iter {
11136            if let ExprTargetAttrs::Rev(val) = attr? {
11137                return Ok(val);
11138            }
11139        }
11140        Err(ErrorContext::new_missing(
11141            "ExprTargetAttrs",
11142            "Rev",
11143            self.orig_loc,
11144            self.buf.as_ptr() as usize,
11145        ))
11146    }
11147    pub fn get_info(&self) -> Result<&'a [u8], ErrorContext> {
11148        let mut iter = self.clone();
11149        iter.pos = 0;
11150        for attr in iter {
11151            if let ExprTargetAttrs::Info(val) = attr? {
11152                return Ok(val);
11153            }
11154        }
11155        Err(ErrorContext::new_missing(
11156            "ExprTargetAttrs",
11157            "Info",
11158            self.orig_loc,
11159            self.buf.as_ptr() as usize,
11160        ))
11161    }
11162}
11163impl ExprTargetAttrs<'_> {
11164    pub fn new<'a>(buf: &'a [u8]) -> IterableExprTargetAttrs<'a> {
11165        IterableExprTargetAttrs::with_loc(buf, buf.as_ptr() as usize)
11166    }
11167    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11168        let res = match r#type {
11169            1u16 => "Name",
11170            2u16 => "Rev",
11171            3u16 => "Info",
11172            _ => return None,
11173        };
11174        Some(res)
11175    }
11176}
11177#[derive(Clone, Copy, Default)]
11178pub struct IterableExprTargetAttrs<'a> {
11179    buf: &'a [u8],
11180    pos: usize,
11181    orig_loc: usize,
11182}
11183impl<'a> IterableExprTargetAttrs<'a> {
11184    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11185        Self {
11186            buf,
11187            pos: 0,
11188            orig_loc,
11189        }
11190    }
11191    pub fn get_buf(&self) -> &'a [u8] {
11192        self.buf
11193    }
11194}
11195impl<'a> Iterator for IterableExprTargetAttrs<'a> {
11196    type Item = Result<ExprTargetAttrs<'a>, ErrorContext>;
11197    fn next(&mut self) -> Option<Self::Item> {
11198        let pos = self.pos;
11199        let mut r#type;
11200        loop {
11201            r#type = None;
11202            if self.buf.len() == self.pos {
11203                return None;
11204            }
11205            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
11206                break;
11207            };
11208            r#type = Some(header.r#type);
11209            let res = match header.r#type {
11210                1u16 => ExprTargetAttrs::Name({
11211                    let res = CStr::from_bytes_with_nul(next).ok();
11212                    let Some(val) = res else { break };
11213                    val
11214                }),
11215                2u16 => ExprTargetAttrs::Rev({
11216                    let res = parse_be_u32(next);
11217                    let Some(val) = res else { break };
11218                    val
11219                }),
11220                3u16 => ExprTargetAttrs::Info({
11221                    let res = Some(next);
11222                    let Some(val) = res else { break };
11223                    val
11224                }),
11225                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
11226                n => continue,
11227            };
11228            return Some(Ok(res));
11229        }
11230        Some(Err(ErrorContext::new(
11231            "ExprTargetAttrs",
11232            r#type.and_then(|t| ExprTargetAttrs::attr_from_type(t)),
11233            self.orig_loc,
11234            self.buf.as_ptr().wrapping_add(pos) as usize,
11235        )))
11236    }
11237}
11238impl<'a> std::fmt::Debug for IterableExprTargetAttrs<'_> {
11239    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11240        let mut fmt = f.debug_struct("ExprTargetAttrs");
11241        for attr in self.clone() {
11242            let attr = match attr {
11243                Ok(a) => a,
11244                Err(err) => {
11245                    fmt.finish()?;
11246                    f.write_str("Err(")?;
11247                    err.fmt(f)?;
11248                    return f.write_str(")");
11249                }
11250            };
11251            match attr {
11252                ExprTargetAttrs::Name(val) => fmt.field("Name", &val),
11253                ExprTargetAttrs::Rev(val) => fmt.field("Rev", &val),
11254                ExprTargetAttrs::Info(val) => fmt.field("Info", &val),
11255            };
11256        }
11257        fmt.finish()
11258    }
11259}
11260impl IterableExprTargetAttrs<'_> {
11261    pub fn lookup_attr(
11262        &self,
11263        offset: usize,
11264        missing_type: Option<u16>,
11265    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11266        let mut stack = Vec::new();
11267        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11268        if missing_type.is_some() && cur == offset {
11269            stack.push(("ExprTargetAttrs", offset));
11270            return (
11271                stack,
11272                missing_type.and_then(|t| ExprTargetAttrs::attr_from_type(t)),
11273            );
11274        }
11275        if cur > offset || cur + self.buf.len() < offset {
11276            return (stack, None);
11277        }
11278        let mut attrs = self.clone();
11279        let mut last_off = cur + attrs.pos;
11280        while let Some(attr) = attrs.next() {
11281            let Ok(attr) = attr else { break };
11282            match attr {
11283                ExprTargetAttrs::Name(val) => {
11284                    if last_off == offset {
11285                        stack.push(("Name", last_off));
11286                        break;
11287                    }
11288                }
11289                ExprTargetAttrs::Rev(val) => {
11290                    if last_off == offset {
11291                        stack.push(("Rev", last_off));
11292                        break;
11293                    }
11294                }
11295                ExprTargetAttrs::Info(val) => {
11296                    if last_off == offset {
11297                        stack.push(("Info", last_off));
11298                        break;
11299                    }
11300                }
11301                _ => {}
11302            };
11303            last_off = cur + attrs.pos;
11304        }
11305        if !stack.is_empty() {
11306            stack.push(("ExprTargetAttrs", cur));
11307        }
11308        (stack, None)
11309    }
11310}
11311#[derive(Clone)]
11312pub enum ExprTproxyAttrs {
11313    Family(u32),
11314    RegAddr(u32),
11315    RegPort(u32),
11316}
11317impl<'a> IterableExprTproxyAttrs<'a> {
11318    pub fn get_family(&self) -> Result<u32, ErrorContext> {
11319        let mut iter = self.clone();
11320        iter.pos = 0;
11321        for attr in iter {
11322            if let ExprTproxyAttrs::Family(val) = attr? {
11323                return Ok(val);
11324            }
11325        }
11326        Err(ErrorContext::new_missing(
11327            "ExprTproxyAttrs",
11328            "Family",
11329            self.orig_loc,
11330            self.buf.as_ptr() as usize,
11331        ))
11332    }
11333    pub fn get_reg_addr(&self) -> Result<u32, ErrorContext> {
11334        let mut iter = self.clone();
11335        iter.pos = 0;
11336        for attr in iter {
11337            if let ExprTproxyAttrs::RegAddr(val) = attr? {
11338                return Ok(val);
11339            }
11340        }
11341        Err(ErrorContext::new_missing(
11342            "ExprTproxyAttrs",
11343            "RegAddr",
11344            self.orig_loc,
11345            self.buf.as_ptr() as usize,
11346        ))
11347    }
11348    pub fn get_reg_port(&self) -> Result<u32, ErrorContext> {
11349        let mut iter = self.clone();
11350        iter.pos = 0;
11351        for attr in iter {
11352            if let ExprTproxyAttrs::RegPort(val) = attr? {
11353                return Ok(val);
11354            }
11355        }
11356        Err(ErrorContext::new_missing(
11357            "ExprTproxyAttrs",
11358            "RegPort",
11359            self.orig_loc,
11360            self.buf.as_ptr() as usize,
11361        ))
11362    }
11363}
11364impl ExprTproxyAttrs {
11365    pub fn new<'a>(buf: &'a [u8]) -> IterableExprTproxyAttrs<'a> {
11366        IterableExprTproxyAttrs::with_loc(buf, buf.as_ptr() as usize)
11367    }
11368    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11369        let res = match r#type {
11370            1u16 => "Family",
11371            2u16 => "RegAddr",
11372            3u16 => "RegPort",
11373            _ => return None,
11374        };
11375        Some(res)
11376    }
11377}
11378#[derive(Clone, Copy, Default)]
11379pub struct IterableExprTproxyAttrs<'a> {
11380    buf: &'a [u8],
11381    pos: usize,
11382    orig_loc: usize,
11383}
11384impl<'a> IterableExprTproxyAttrs<'a> {
11385    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11386        Self {
11387            buf,
11388            pos: 0,
11389            orig_loc,
11390        }
11391    }
11392    pub fn get_buf(&self) -> &'a [u8] {
11393        self.buf
11394    }
11395}
11396impl<'a> Iterator for IterableExprTproxyAttrs<'a> {
11397    type Item = Result<ExprTproxyAttrs, ErrorContext>;
11398    fn next(&mut self) -> Option<Self::Item> {
11399        let pos = self.pos;
11400        let mut r#type;
11401        loop {
11402            r#type = None;
11403            if self.buf.len() == self.pos {
11404                return None;
11405            }
11406            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
11407                break;
11408            };
11409            r#type = Some(header.r#type);
11410            let res = match header.r#type {
11411                1u16 => ExprTproxyAttrs::Family({
11412                    let res = parse_be_u32(next);
11413                    let Some(val) = res else { break };
11414                    val
11415                }),
11416                2u16 => ExprTproxyAttrs::RegAddr({
11417                    let res = parse_be_u32(next);
11418                    let Some(val) = res else { break };
11419                    val
11420                }),
11421                3u16 => ExprTproxyAttrs::RegPort({
11422                    let res = parse_be_u32(next);
11423                    let Some(val) = res else { break };
11424                    val
11425                }),
11426                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
11427                n => continue,
11428            };
11429            return Some(Ok(res));
11430        }
11431        Some(Err(ErrorContext::new(
11432            "ExprTproxyAttrs",
11433            r#type.and_then(|t| ExprTproxyAttrs::attr_from_type(t)),
11434            self.orig_loc,
11435            self.buf.as_ptr().wrapping_add(pos) as usize,
11436        )))
11437    }
11438}
11439impl std::fmt::Debug for IterableExprTproxyAttrs<'_> {
11440    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11441        let mut fmt = f.debug_struct("ExprTproxyAttrs");
11442        for attr in self.clone() {
11443            let attr = match attr {
11444                Ok(a) => a,
11445                Err(err) => {
11446                    fmt.finish()?;
11447                    f.write_str("Err(")?;
11448                    err.fmt(f)?;
11449                    return f.write_str(")");
11450                }
11451            };
11452            match attr {
11453                ExprTproxyAttrs::Family(val) => fmt.field("Family", &val),
11454                ExprTproxyAttrs::RegAddr(val) => fmt.field("RegAddr", &val),
11455                ExprTproxyAttrs::RegPort(val) => fmt.field("RegPort", &val),
11456            };
11457        }
11458        fmt.finish()
11459    }
11460}
11461impl IterableExprTproxyAttrs<'_> {
11462    pub fn lookup_attr(
11463        &self,
11464        offset: usize,
11465        missing_type: Option<u16>,
11466    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11467        let mut stack = Vec::new();
11468        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11469        if missing_type.is_some() && cur == offset {
11470            stack.push(("ExprTproxyAttrs", offset));
11471            return (
11472                stack,
11473                missing_type.and_then(|t| ExprTproxyAttrs::attr_from_type(t)),
11474            );
11475        }
11476        if cur > offset || cur + self.buf.len() < offset {
11477            return (stack, None);
11478        }
11479        let mut attrs = self.clone();
11480        let mut last_off = cur + attrs.pos;
11481        while let Some(attr) = attrs.next() {
11482            let Ok(attr) = attr else { break };
11483            match attr {
11484                ExprTproxyAttrs::Family(val) => {
11485                    if last_off == offset {
11486                        stack.push(("Family", last_off));
11487                        break;
11488                    }
11489                }
11490                ExprTproxyAttrs::RegAddr(val) => {
11491                    if last_off == offset {
11492                        stack.push(("RegAddr", last_off));
11493                        break;
11494                    }
11495                }
11496                ExprTproxyAttrs::RegPort(val) => {
11497                    if last_off == offset {
11498                        stack.push(("RegPort", last_off));
11499                        break;
11500                    }
11501                }
11502                _ => {}
11503            };
11504            last_off = cur + attrs.pos;
11505        }
11506        if !stack.is_empty() {
11507            stack.push(("ExprTproxyAttrs", cur));
11508        }
11509        (stack, None)
11510    }
11511}
11512#[derive(Clone)]
11513pub enum ExprObjrefAttrs<'a> {
11514    ImmType(u32),
11515    #[doc = "object name"]
11516    ImmName(&'a CStr),
11517    SetSreg(u32),
11518    #[doc = "name of object map"]
11519    SetName(&'a CStr),
11520    #[doc = "id of object map"]
11521    SetId(u32),
11522}
11523impl<'a> IterableExprObjrefAttrs<'a> {
11524    pub fn get_imm_type(&self) -> Result<u32, ErrorContext> {
11525        let mut iter = self.clone();
11526        iter.pos = 0;
11527        for attr in iter {
11528            if let ExprObjrefAttrs::ImmType(val) = attr? {
11529                return Ok(val);
11530            }
11531        }
11532        Err(ErrorContext::new_missing(
11533            "ExprObjrefAttrs",
11534            "ImmType",
11535            self.orig_loc,
11536            self.buf.as_ptr() as usize,
11537        ))
11538    }
11539    #[doc = "object name"]
11540    pub fn get_imm_name(&self) -> Result<&'a CStr, ErrorContext> {
11541        let mut iter = self.clone();
11542        iter.pos = 0;
11543        for attr in iter {
11544            if let ExprObjrefAttrs::ImmName(val) = attr? {
11545                return Ok(val);
11546            }
11547        }
11548        Err(ErrorContext::new_missing(
11549            "ExprObjrefAttrs",
11550            "ImmName",
11551            self.orig_loc,
11552            self.buf.as_ptr() as usize,
11553        ))
11554    }
11555    pub fn get_set_sreg(&self) -> Result<u32, ErrorContext> {
11556        let mut iter = self.clone();
11557        iter.pos = 0;
11558        for attr in iter {
11559            if let ExprObjrefAttrs::SetSreg(val) = attr? {
11560                return Ok(val);
11561            }
11562        }
11563        Err(ErrorContext::new_missing(
11564            "ExprObjrefAttrs",
11565            "SetSreg",
11566            self.orig_loc,
11567            self.buf.as_ptr() as usize,
11568        ))
11569    }
11570    #[doc = "name of object map"]
11571    pub fn get_set_name(&self) -> Result<&'a CStr, ErrorContext> {
11572        let mut iter = self.clone();
11573        iter.pos = 0;
11574        for attr in iter {
11575            if let ExprObjrefAttrs::SetName(val) = attr? {
11576                return Ok(val);
11577            }
11578        }
11579        Err(ErrorContext::new_missing(
11580            "ExprObjrefAttrs",
11581            "SetName",
11582            self.orig_loc,
11583            self.buf.as_ptr() as usize,
11584        ))
11585    }
11586    #[doc = "id of object map"]
11587    pub fn get_set_id(&self) -> Result<u32, ErrorContext> {
11588        let mut iter = self.clone();
11589        iter.pos = 0;
11590        for attr in iter {
11591            if let ExprObjrefAttrs::SetId(val) = attr? {
11592                return Ok(val);
11593            }
11594        }
11595        Err(ErrorContext::new_missing(
11596            "ExprObjrefAttrs",
11597            "SetId",
11598            self.orig_loc,
11599            self.buf.as_ptr() as usize,
11600        ))
11601    }
11602}
11603impl ExprObjrefAttrs<'_> {
11604    pub fn new<'a>(buf: &'a [u8]) -> IterableExprObjrefAttrs<'a> {
11605        IterableExprObjrefAttrs::with_loc(buf, buf.as_ptr() as usize)
11606    }
11607    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11608        let res = match r#type {
11609            1u16 => "ImmType",
11610            2u16 => "ImmName",
11611            3u16 => "SetSreg",
11612            4u16 => "SetName",
11613            5u16 => "SetId",
11614            _ => return None,
11615        };
11616        Some(res)
11617    }
11618}
11619#[derive(Clone, Copy, Default)]
11620pub struct IterableExprObjrefAttrs<'a> {
11621    buf: &'a [u8],
11622    pos: usize,
11623    orig_loc: usize,
11624}
11625impl<'a> IterableExprObjrefAttrs<'a> {
11626    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11627        Self {
11628            buf,
11629            pos: 0,
11630            orig_loc,
11631        }
11632    }
11633    pub fn get_buf(&self) -> &'a [u8] {
11634        self.buf
11635    }
11636}
11637impl<'a> Iterator for IterableExprObjrefAttrs<'a> {
11638    type Item = Result<ExprObjrefAttrs<'a>, ErrorContext>;
11639    fn next(&mut self) -> Option<Self::Item> {
11640        let pos = self.pos;
11641        let mut r#type;
11642        loop {
11643            r#type = None;
11644            if self.buf.len() == self.pos {
11645                return None;
11646            }
11647            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
11648                break;
11649            };
11650            r#type = Some(header.r#type);
11651            let res = match header.r#type {
11652                1u16 => ExprObjrefAttrs::ImmType({
11653                    let res = parse_be_u32(next);
11654                    let Some(val) = res else { break };
11655                    val
11656                }),
11657                2u16 => ExprObjrefAttrs::ImmName({
11658                    let res = CStr::from_bytes_with_nul(next).ok();
11659                    let Some(val) = res else { break };
11660                    val
11661                }),
11662                3u16 => ExprObjrefAttrs::SetSreg({
11663                    let res = parse_be_u32(next);
11664                    let Some(val) = res else { break };
11665                    val
11666                }),
11667                4u16 => ExprObjrefAttrs::SetName({
11668                    let res = CStr::from_bytes_with_nul(next).ok();
11669                    let Some(val) = res else { break };
11670                    val
11671                }),
11672                5u16 => ExprObjrefAttrs::SetId({
11673                    let res = parse_be_u32(next);
11674                    let Some(val) = res else { break };
11675                    val
11676                }),
11677                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
11678                n => continue,
11679            };
11680            return Some(Ok(res));
11681        }
11682        Some(Err(ErrorContext::new(
11683            "ExprObjrefAttrs",
11684            r#type.and_then(|t| ExprObjrefAttrs::attr_from_type(t)),
11685            self.orig_loc,
11686            self.buf.as_ptr().wrapping_add(pos) as usize,
11687        )))
11688    }
11689}
11690impl<'a> std::fmt::Debug for IterableExprObjrefAttrs<'_> {
11691    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11692        let mut fmt = f.debug_struct("ExprObjrefAttrs");
11693        for attr in self.clone() {
11694            let attr = match attr {
11695                Ok(a) => a,
11696                Err(err) => {
11697                    fmt.finish()?;
11698                    f.write_str("Err(")?;
11699                    err.fmt(f)?;
11700                    return f.write_str(")");
11701                }
11702            };
11703            match attr {
11704                ExprObjrefAttrs::ImmType(val) => fmt.field("ImmType", &val),
11705                ExprObjrefAttrs::ImmName(val) => fmt.field("ImmName", &val),
11706                ExprObjrefAttrs::SetSreg(val) => fmt.field("SetSreg", &val),
11707                ExprObjrefAttrs::SetName(val) => fmt.field("SetName", &val),
11708                ExprObjrefAttrs::SetId(val) => fmt.field("SetId", &val),
11709            };
11710        }
11711        fmt.finish()
11712    }
11713}
11714impl IterableExprObjrefAttrs<'_> {
11715    pub fn lookup_attr(
11716        &self,
11717        offset: usize,
11718        missing_type: Option<u16>,
11719    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11720        let mut stack = Vec::new();
11721        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11722        if missing_type.is_some() && cur == offset {
11723            stack.push(("ExprObjrefAttrs", offset));
11724            return (
11725                stack,
11726                missing_type.and_then(|t| ExprObjrefAttrs::attr_from_type(t)),
11727            );
11728        }
11729        if cur > offset || cur + self.buf.len() < offset {
11730            return (stack, None);
11731        }
11732        let mut attrs = self.clone();
11733        let mut last_off = cur + attrs.pos;
11734        while let Some(attr) = attrs.next() {
11735            let Ok(attr) = attr else { break };
11736            match attr {
11737                ExprObjrefAttrs::ImmType(val) => {
11738                    if last_off == offset {
11739                        stack.push(("ImmType", last_off));
11740                        break;
11741                    }
11742                }
11743                ExprObjrefAttrs::ImmName(val) => {
11744                    if last_off == offset {
11745                        stack.push(("ImmName", last_off));
11746                        break;
11747                    }
11748                }
11749                ExprObjrefAttrs::SetSreg(val) => {
11750                    if last_off == offset {
11751                        stack.push(("SetSreg", last_off));
11752                        break;
11753                    }
11754                }
11755                ExprObjrefAttrs::SetName(val) => {
11756                    if last_off == offset {
11757                        stack.push(("SetName", last_off));
11758                        break;
11759                    }
11760                }
11761                ExprObjrefAttrs::SetId(val) => {
11762                    if last_off == offset {
11763                        stack.push(("SetId", last_off));
11764                        break;
11765                    }
11766                }
11767                _ => {}
11768            };
11769            last_off = cur + attrs.pos;
11770        }
11771        if !stack.is_empty() {
11772            stack.push(("ExprObjrefAttrs", cur));
11773        }
11774        (stack, None)
11775    }
11776}
11777#[derive(Clone)]
11778pub enum CompatTargetAttrs<'a> {
11779    Name(&'a CStr),
11780    Rev(u32),
11781    Info(&'a [u8]),
11782}
11783impl<'a> IterableCompatTargetAttrs<'a> {
11784    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
11785        let mut iter = self.clone();
11786        iter.pos = 0;
11787        for attr in iter {
11788            if let CompatTargetAttrs::Name(val) = attr? {
11789                return Ok(val);
11790            }
11791        }
11792        Err(ErrorContext::new_missing(
11793            "CompatTargetAttrs",
11794            "Name",
11795            self.orig_loc,
11796            self.buf.as_ptr() as usize,
11797        ))
11798    }
11799    pub fn get_rev(&self) -> Result<u32, ErrorContext> {
11800        let mut iter = self.clone();
11801        iter.pos = 0;
11802        for attr in iter {
11803            if let CompatTargetAttrs::Rev(val) = attr? {
11804                return Ok(val);
11805            }
11806        }
11807        Err(ErrorContext::new_missing(
11808            "CompatTargetAttrs",
11809            "Rev",
11810            self.orig_loc,
11811            self.buf.as_ptr() as usize,
11812        ))
11813    }
11814    pub fn get_info(&self) -> Result<&'a [u8], ErrorContext> {
11815        let mut iter = self.clone();
11816        iter.pos = 0;
11817        for attr in iter {
11818            if let CompatTargetAttrs::Info(val) = attr? {
11819                return Ok(val);
11820            }
11821        }
11822        Err(ErrorContext::new_missing(
11823            "CompatTargetAttrs",
11824            "Info",
11825            self.orig_loc,
11826            self.buf.as_ptr() as usize,
11827        ))
11828    }
11829}
11830impl CompatTargetAttrs<'_> {
11831    pub fn new<'a>(buf: &'a [u8]) -> IterableCompatTargetAttrs<'a> {
11832        IterableCompatTargetAttrs::with_loc(buf, buf.as_ptr() as usize)
11833    }
11834    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11835        let res = match r#type {
11836            1u16 => "Name",
11837            2u16 => "Rev",
11838            3u16 => "Info",
11839            _ => return None,
11840        };
11841        Some(res)
11842    }
11843}
11844#[derive(Clone, Copy, Default)]
11845pub struct IterableCompatTargetAttrs<'a> {
11846    buf: &'a [u8],
11847    pos: usize,
11848    orig_loc: usize,
11849}
11850impl<'a> IterableCompatTargetAttrs<'a> {
11851    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11852        Self {
11853            buf,
11854            pos: 0,
11855            orig_loc,
11856        }
11857    }
11858    pub fn get_buf(&self) -> &'a [u8] {
11859        self.buf
11860    }
11861}
11862impl<'a> Iterator for IterableCompatTargetAttrs<'a> {
11863    type Item = Result<CompatTargetAttrs<'a>, ErrorContext>;
11864    fn next(&mut self) -> Option<Self::Item> {
11865        let pos = self.pos;
11866        let mut r#type;
11867        loop {
11868            r#type = None;
11869            if self.buf.len() == self.pos {
11870                return None;
11871            }
11872            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
11873                break;
11874            };
11875            r#type = Some(header.r#type);
11876            let res = match header.r#type {
11877                1u16 => CompatTargetAttrs::Name({
11878                    let res = CStr::from_bytes_with_nul(next).ok();
11879                    let Some(val) = res else { break };
11880                    val
11881                }),
11882                2u16 => CompatTargetAttrs::Rev({
11883                    let res = parse_be_u32(next);
11884                    let Some(val) = res else { break };
11885                    val
11886                }),
11887                3u16 => CompatTargetAttrs::Info({
11888                    let res = Some(next);
11889                    let Some(val) = res else { break };
11890                    val
11891                }),
11892                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
11893                n => continue,
11894            };
11895            return Some(Ok(res));
11896        }
11897        Some(Err(ErrorContext::new(
11898            "CompatTargetAttrs",
11899            r#type.and_then(|t| CompatTargetAttrs::attr_from_type(t)),
11900            self.orig_loc,
11901            self.buf.as_ptr().wrapping_add(pos) as usize,
11902        )))
11903    }
11904}
11905impl<'a> std::fmt::Debug for IterableCompatTargetAttrs<'_> {
11906    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11907        let mut fmt = f.debug_struct("CompatTargetAttrs");
11908        for attr in self.clone() {
11909            let attr = match attr {
11910                Ok(a) => a,
11911                Err(err) => {
11912                    fmt.finish()?;
11913                    f.write_str("Err(")?;
11914                    err.fmt(f)?;
11915                    return f.write_str(")");
11916                }
11917            };
11918            match attr {
11919                CompatTargetAttrs::Name(val) => fmt.field("Name", &val),
11920                CompatTargetAttrs::Rev(val) => fmt.field("Rev", &val),
11921                CompatTargetAttrs::Info(val) => fmt.field("Info", &val),
11922            };
11923        }
11924        fmt.finish()
11925    }
11926}
11927impl IterableCompatTargetAttrs<'_> {
11928    pub fn lookup_attr(
11929        &self,
11930        offset: usize,
11931        missing_type: Option<u16>,
11932    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11933        let mut stack = Vec::new();
11934        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11935        if missing_type.is_some() && cur == offset {
11936            stack.push(("CompatTargetAttrs", offset));
11937            return (
11938                stack,
11939                missing_type.and_then(|t| CompatTargetAttrs::attr_from_type(t)),
11940            );
11941        }
11942        if cur > offset || cur + self.buf.len() < offset {
11943            return (stack, None);
11944        }
11945        let mut attrs = self.clone();
11946        let mut last_off = cur + attrs.pos;
11947        while let Some(attr) = attrs.next() {
11948            let Ok(attr) = attr else { break };
11949            match attr {
11950                CompatTargetAttrs::Name(val) => {
11951                    if last_off == offset {
11952                        stack.push(("Name", last_off));
11953                        break;
11954                    }
11955                }
11956                CompatTargetAttrs::Rev(val) => {
11957                    if last_off == offset {
11958                        stack.push(("Rev", last_off));
11959                        break;
11960                    }
11961                }
11962                CompatTargetAttrs::Info(val) => {
11963                    if last_off == offset {
11964                        stack.push(("Info", last_off));
11965                        break;
11966                    }
11967                }
11968                _ => {}
11969            };
11970            last_off = cur + attrs.pos;
11971        }
11972        if !stack.is_empty() {
11973            stack.push(("CompatTargetAttrs", cur));
11974        }
11975        (stack, None)
11976    }
11977}
11978#[derive(Clone)]
11979pub enum CompatMatchAttrs<'a> {
11980    Name(&'a CStr),
11981    Rev(u32),
11982    Info(&'a [u8]),
11983}
11984impl<'a> IterableCompatMatchAttrs<'a> {
11985    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
11986        let mut iter = self.clone();
11987        iter.pos = 0;
11988        for attr in iter {
11989            if let CompatMatchAttrs::Name(val) = attr? {
11990                return Ok(val);
11991            }
11992        }
11993        Err(ErrorContext::new_missing(
11994            "CompatMatchAttrs",
11995            "Name",
11996            self.orig_loc,
11997            self.buf.as_ptr() as usize,
11998        ))
11999    }
12000    pub fn get_rev(&self) -> Result<u32, ErrorContext> {
12001        let mut iter = self.clone();
12002        iter.pos = 0;
12003        for attr in iter {
12004            if let CompatMatchAttrs::Rev(val) = attr? {
12005                return Ok(val);
12006            }
12007        }
12008        Err(ErrorContext::new_missing(
12009            "CompatMatchAttrs",
12010            "Rev",
12011            self.orig_loc,
12012            self.buf.as_ptr() as usize,
12013        ))
12014    }
12015    pub fn get_info(&self) -> Result<&'a [u8], ErrorContext> {
12016        let mut iter = self.clone();
12017        iter.pos = 0;
12018        for attr in iter {
12019            if let CompatMatchAttrs::Info(val) = attr? {
12020                return Ok(val);
12021            }
12022        }
12023        Err(ErrorContext::new_missing(
12024            "CompatMatchAttrs",
12025            "Info",
12026            self.orig_loc,
12027            self.buf.as_ptr() as usize,
12028        ))
12029    }
12030}
12031impl CompatMatchAttrs<'_> {
12032    pub fn new<'a>(buf: &'a [u8]) -> IterableCompatMatchAttrs<'a> {
12033        IterableCompatMatchAttrs::with_loc(buf, buf.as_ptr() as usize)
12034    }
12035    fn attr_from_type(r#type: u16) -> Option<&'static str> {
12036        let res = match r#type {
12037            1u16 => "Name",
12038            2u16 => "Rev",
12039            3u16 => "Info",
12040            _ => return None,
12041        };
12042        Some(res)
12043    }
12044}
12045#[derive(Clone, Copy, Default)]
12046pub struct IterableCompatMatchAttrs<'a> {
12047    buf: &'a [u8],
12048    pos: usize,
12049    orig_loc: usize,
12050}
12051impl<'a> IterableCompatMatchAttrs<'a> {
12052    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
12053        Self {
12054            buf,
12055            pos: 0,
12056            orig_loc,
12057        }
12058    }
12059    pub fn get_buf(&self) -> &'a [u8] {
12060        self.buf
12061    }
12062}
12063impl<'a> Iterator for IterableCompatMatchAttrs<'a> {
12064    type Item = Result<CompatMatchAttrs<'a>, ErrorContext>;
12065    fn next(&mut self) -> Option<Self::Item> {
12066        let pos = self.pos;
12067        let mut r#type;
12068        loop {
12069            r#type = None;
12070            if self.buf.len() == self.pos {
12071                return None;
12072            }
12073            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
12074                break;
12075            };
12076            r#type = Some(header.r#type);
12077            let res = match header.r#type {
12078                1u16 => CompatMatchAttrs::Name({
12079                    let res = CStr::from_bytes_with_nul(next).ok();
12080                    let Some(val) = res else { break };
12081                    val
12082                }),
12083                2u16 => CompatMatchAttrs::Rev({
12084                    let res = parse_be_u32(next);
12085                    let Some(val) = res else { break };
12086                    val
12087                }),
12088                3u16 => CompatMatchAttrs::Info({
12089                    let res = Some(next);
12090                    let Some(val) = res else { break };
12091                    val
12092                }),
12093                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
12094                n => continue,
12095            };
12096            return Some(Ok(res));
12097        }
12098        Some(Err(ErrorContext::new(
12099            "CompatMatchAttrs",
12100            r#type.and_then(|t| CompatMatchAttrs::attr_from_type(t)),
12101            self.orig_loc,
12102            self.buf.as_ptr().wrapping_add(pos) as usize,
12103        )))
12104    }
12105}
12106impl<'a> std::fmt::Debug for IterableCompatMatchAttrs<'_> {
12107    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12108        let mut fmt = f.debug_struct("CompatMatchAttrs");
12109        for attr in self.clone() {
12110            let attr = match attr {
12111                Ok(a) => a,
12112                Err(err) => {
12113                    fmt.finish()?;
12114                    f.write_str("Err(")?;
12115                    err.fmt(f)?;
12116                    return f.write_str(")");
12117                }
12118            };
12119            match attr {
12120                CompatMatchAttrs::Name(val) => fmt.field("Name", &val),
12121                CompatMatchAttrs::Rev(val) => fmt.field("Rev", &val),
12122                CompatMatchAttrs::Info(val) => fmt.field("Info", &val),
12123            };
12124        }
12125        fmt.finish()
12126    }
12127}
12128impl IterableCompatMatchAttrs<'_> {
12129    pub fn lookup_attr(
12130        &self,
12131        offset: usize,
12132        missing_type: Option<u16>,
12133    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
12134        let mut stack = Vec::new();
12135        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
12136        if missing_type.is_some() && cur == offset {
12137            stack.push(("CompatMatchAttrs", offset));
12138            return (
12139                stack,
12140                missing_type.and_then(|t| CompatMatchAttrs::attr_from_type(t)),
12141            );
12142        }
12143        if cur > offset || cur + self.buf.len() < offset {
12144            return (stack, None);
12145        }
12146        let mut attrs = self.clone();
12147        let mut last_off = cur + attrs.pos;
12148        while let Some(attr) = attrs.next() {
12149            let Ok(attr) = attr else { break };
12150            match attr {
12151                CompatMatchAttrs::Name(val) => {
12152                    if last_off == offset {
12153                        stack.push(("Name", last_off));
12154                        break;
12155                    }
12156                }
12157                CompatMatchAttrs::Rev(val) => {
12158                    if last_off == offset {
12159                        stack.push(("Rev", last_off));
12160                        break;
12161                    }
12162                }
12163                CompatMatchAttrs::Info(val) => {
12164                    if last_off == offset {
12165                        stack.push(("Info", last_off));
12166                        break;
12167                    }
12168                }
12169                _ => {}
12170            };
12171            last_off = cur + attrs.pos;
12172        }
12173        if !stack.is_empty() {
12174            stack.push(("CompatMatchAttrs", cur));
12175        }
12176        (stack, None)
12177    }
12178}
12179#[derive(Clone)]
12180pub enum CompatAttrs<'a> {
12181    Name(&'a CStr),
12182    Rev(u32),
12183    Type(u32),
12184}
12185impl<'a> IterableCompatAttrs<'a> {
12186    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
12187        let mut iter = self.clone();
12188        iter.pos = 0;
12189        for attr in iter {
12190            if let CompatAttrs::Name(val) = attr? {
12191                return Ok(val);
12192            }
12193        }
12194        Err(ErrorContext::new_missing(
12195            "CompatAttrs",
12196            "Name",
12197            self.orig_loc,
12198            self.buf.as_ptr() as usize,
12199        ))
12200    }
12201    pub fn get_rev(&self) -> Result<u32, ErrorContext> {
12202        let mut iter = self.clone();
12203        iter.pos = 0;
12204        for attr in iter {
12205            if let CompatAttrs::Rev(val) = attr? {
12206                return Ok(val);
12207            }
12208        }
12209        Err(ErrorContext::new_missing(
12210            "CompatAttrs",
12211            "Rev",
12212            self.orig_loc,
12213            self.buf.as_ptr() as usize,
12214        ))
12215    }
12216    pub fn get_type(&self) -> Result<u32, ErrorContext> {
12217        let mut iter = self.clone();
12218        iter.pos = 0;
12219        for attr in iter {
12220            if let CompatAttrs::Type(val) = attr? {
12221                return Ok(val);
12222            }
12223        }
12224        Err(ErrorContext::new_missing(
12225            "CompatAttrs",
12226            "Type",
12227            self.orig_loc,
12228            self.buf.as_ptr() as usize,
12229        ))
12230    }
12231}
12232impl CompatAttrs<'_> {
12233    pub fn new<'a>(buf: &'a [u8]) -> IterableCompatAttrs<'a> {
12234        IterableCompatAttrs::with_loc(buf, buf.as_ptr() as usize)
12235    }
12236    fn attr_from_type(r#type: u16) -> Option<&'static str> {
12237        let res = match r#type {
12238            1u16 => "Name",
12239            2u16 => "Rev",
12240            3u16 => "Type",
12241            _ => return None,
12242        };
12243        Some(res)
12244    }
12245}
12246#[derive(Clone, Copy, Default)]
12247pub struct IterableCompatAttrs<'a> {
12248    buf: &'a [u8],
12249    pos: usize,
12250    orig_loc: usize,
12251}
12252impl<'a> IterableCompatAttrs<'a> {
12253    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
12254        Self {
12255            buf,
12256            pos: 0,
12257            orig_loc,
12258        }
12259    }
12260    pub fn get_buf(&self) -> &'a [u8] {
12261        self.buf
12262    }
12263}
12264impl<'a> Iterator for IterableCompatAttrs<'a> {
12265    type Item = Result<CompatAttrs<'a>, ErrorContext>;
12266    fn next(&mut self) -> Option<Self::Item> {
12267        let pos = self.pos;
12268        let mut r#type;
12269        loop {
12270            r#type = None;
12271            if self.buf.len() == self.pos {
12272                return None;
12273            }
12274            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
12275                break;
12276            };
12277            r#type = Some(header.r#type);
12278            let res = match header.r#type {
12279                1u16 => CompatAttrs::Name({
12280                    let res = CStr::from_bytes_with_nul(next).ok();
12281                    let Some(val) = res else { break };
12282                    val
12283                }),
12284                2u16 => CompatAttrs::Rev({
12285                    let res = parse_be_u32(next);
12286                    let Some(val) = res else { break };
12287                    val
12288                }),
12289                3u16 => CompatAttrs::Type({
12290                    let res = parse_be_u32(next);
12291                    let Some(val) = res else { break };
12292                    val
12293                }),
12294                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
12295                n => continue,
12296            };
12297            return Some(Ok(res));
12298        }
12299        Some(Err(ErrorContext::new(
12300            "CompatAttrs",
12301            r#type.and_then(|t| CompatAttrs::attr_from_type(t)),
12302            self.orig_loc,
12303            self.buf.as_ptr().wrapping_add(pos) as usize,
12304        )))
12305    }
12306}
12307impl<'a> std::fmt::Debug for IterableCompatAttrs<'_> {
12308    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12309        let mut fmt = f.debug_struct("CompatAttrs");
12310        for attr in self.clone() {
12311            let attr = match attr {
12312                Ok(a) => a,
12313                Err(err) => {
12314                    fmt.finish()?;
12315                    f.write_str("Err(")?;
12316                    err.fmt(f)?;
12317                    return f.write_str(")");
12318                }
12319            };
12320            match attr {
12321                CompatAttrs::Name(val) => fmt.field("Name", &val),
12322                CompatAttrs::Rev(val) => fmt.field("Rev", &val),
12323                CompatAttrs::Type(val) => fmt.field("Type", &val),
12324            };
12325        }
12326        fmt.finish()
12327    }
12328}
12329impl IterableCompatAttrs<'_> {
12330    pub fn lookup_attr(
12331        &self,
12332        offset: usize,
12333        missing_type: Option<u16>,
12334    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
12335        let mut stack = Vec::new();
12336        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
12337        if missing_type.is_some() && cur == offset {
12338            stack.push(("CompatAttrs", offset));
12339            return (
12340                stack,
12341                missing_type.and_then(|t| CompatAttrs::attr_from_type(t)),
12342            );
12343        }
12344        if cur > offset || cur + self.buf.len() < offset {
12345            return (stack, None);
12346        }
12347        let mut attrs = self.clone();
12348        let mut last_off = cur + attrs.pos;
12349        while let Some(attr) = attrs.next() {
12350            let Ok(attr) = attr else { break };
12351            match attr {
12352                CompatAttrs::Name(val) => {
12353                    if last_off == offset {
12354                        stack.push(("Name", last_off));
12355                        break;
12356                    }
12357                }
12358                CompatAttrs::Rev(val) => {
12359                    if last_off == offset {
12360                        stack.push(("Rev", last_off));
12361                        break;
12362                    }
12363                }
12364                CompatAttrs::Type(val) => {
12365                    if last_off == offset {
12366                        stack.push(("Type", last_off));
12367                        break;
12368                    }
12369                }
12370                _ => {}
12371            };
12372            last_off = cur + attrs.pos;
12373        }
12374        if !stack.is_empty() {
12375            stack.push(("CompatAttrs", cur));
12376        }
12377        (stack, None)
12378    }
12379}
12380pub struct PushLogAttrs<Prev: Rec> {
12381    pub(crate) prev: Option<Prev>,
12382    pub(crate) header_offset: Option<usize>,
12383}
12384impl<Prev: Rec> Rec for PushLogAttrs<Prev> {
12385    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
12386        self.prev.as_mut().unwrap().as_rec_mut()
12387    }
12388    fn as_rec(&self) -> &Vec<u8> {
12389        self.prev.as_ref().unwrap().as_rec()
12390    }
12391}
12392impl<Prev: Rec> PushLogAttrs<Prev> {
12393    pub fn new(prev: Prev) -> Self {
12394        Self {
12395            prev: Some(prev),
12396            header_offset: None,
12397        }
12398    }
12399    pub fn end_nested(mut self) -> Prev {
12400        let mut prev = self.prev.take().unwrap();
12401        if let Some(header_offset) = &self.header_offset {
12402            finalize_nested_header(prev.as_rec_mut(), *header_offset);
12403        }
12404        prev
12405    }
12406    #[doc = "netlink group to send messages to"]
12407    pub fn push_group(mut self, value: u16) -> Self {
12408        push_header(self.as_rec_mut(), 1u16, 2 as u16);
12409        self.as_rec_mut().extend(value.to_be_bytes());
12410        self
12411    }
12412    #[doc = "prefix to prepend to log messages"]
12413    pub fn push_prefix(mut self, value: &CStr) -> Self {
12414        push_header(
12415            self.as_rec_mut(),
12416            2u16,
12417            value.to_bytes_with_nul().len() as u16,
12418        );
12419        self.as_rec_mut().extend(value.to_bytes_with_nul());
12420        self
12421    }
12422    #[doc = "prefix to prepend to log messages"]
12423    pub fn push_prefix_bytes(mut self, value: &[u8]) -> Self {
12424        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
12425        self.as_rec_mut().extend(value);
12426        self.as_rec_mut().push(0);
12427        self
12428    }
12429    #[doc = "length of payload to include in netlink message"]
12430    pub fn push_snaplen(mut self, value: u32) -> Self {
12431        push_header(self.as_rec_mut(), 3u16, 4 as u16);
12432        self.as_rec_mut().extend(value.to_be_bytes());
12433        self
12434    }
12435    #[doc = "queue threshold"]
12436    pub fn push_qthreshold(mut self, value: u16) -> Self {
12437        push_header(self.as_rec_mut(), 4u16, 2 as u16);
12438        self.as_rec_mut().extend(value.to_be_bytes());
12439        self
12440    }
12441    #[doc = "log level\nAssociated type: [`LogLevel`] (enum)"]
12442    pub fn push_level(mut self, value: u32) -> Self {
12443        push_header(self.as_rec_mut(), 5u16, 4 as u16);
12444        self.as_rec_mut().extend(value.to_be_bytes());
12445        self
12446    }
12447    #[doc = "logging flags\nAssociated type: [`LogFlags`] (enum)"]
12448    pub fn push_flags(mut self, value: u32) -> Self {
12449        push_header(self.as_rec_mut(), 6u16, 4 as u16);
12450        self.as_rec_mut().extend(value.to_be_bytes());
12451        self
12452    }
12453}
12454impl<Prev: Rec> Drop for PushLogAttrs<Prev> {
12455    fn drop(&mut self) {
12456        if let Some(prev) = &mut self.prev {
12457            if let Some(header_offset) = &self.header_offset {
12458                finalize_nested_header(prev.as_rec_mut(), *header_offset);
12459            }
12460        }
12461    }
12462}
12463pub struct PushNumgenAttrs<Prev: Rec> {
12464    pub(crate) prev: Option<Prev>,
12465    pub(crate) header_offset: Option<usize>,
12466}
12467impl<Prev: Rec> Rec for PushNumgenAttrs<Prev> {
12468    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
12469        self.prev.as_mut().unwrap().as_rec_mut()
12470    }
12471    fn as_rec(&self) -> &Vec<u8> {
12472        self.prev.as_ref().unwrap().as_rec()
12473    }
12474}
12475impl<Prev: Rec> PushNumgenAttrs<Prev> {
12476    pub fn new(prev: Prev) -> Self {
12477        Self {
12478            prev: Some(prev),
12479            header_offset: None,
12480        }
12481    }
12482    pub fn end_nested(mut self) -> Prev {
12483        let mut prev = self.prev.take().unwrap();
12484        if let Some(header_offset) = &self.header_offset {
12485            finalize_nested_header(prev.as_rec_mut(), *header_offset);
12486        }
12487        prev
12488    }
12489    #[doc = "destination register\nAssociated type: [`Registers`] (enum)"]
12490    pub fn push_dreg(mut self, value: u32) -> Self {
12491        push_header(self.as_rec_mut(), 1u16, 4 as u16);
12492        self.as_rec_mut().extend(value.to_ne_bytes());
12493        self
12494    }
12495    #[doc = "maximum counter value"]
12496    pub fn push_modulus(mut self, value: u32) -> Self {
12497        push_header(self.as_rec_mut(), 2u16, 4 as u16);
12498        self.as_rec_mut().extend(value.to_be_bytes());
12499        self
12500    }
12501    #[doc = "operation type\nAssociated type: [`NumgenTypes`] (enum)"]
12502    pub fn push_type(mut self, value: u32) -> Self {
12503        push_header(self.as_rec_mut(), 3u16, 4 as u16);
12504        self.as_rec_mut().extend(value.to_be_bytes());
12505        self
12506    }
12507    #[doc = "offset to be added to the counter"]
12508    pub fn push_offset(mut self, value: u32) -> Self {
12509        push_header(self.as_rec_mut(), 4u16, 4 as u16);
12510        self.as_rec_mut().extend(value.to_be_bytes());
12511        self
12512    }
12513}
12514impl<Prev: Rec> Drop for PushNumgenAttrs<Prev> {
12515    fn drop(&mut self) {
12516        if let Some(prev) = &mut self.prev {
12517            if let Some(header_offset) = &self.header_offset {
12518                finalize_nested_header(prev.as_rec_mut(), *header_offset);
12519            }
12520        }
12521    }
12522}
12523pub struct PushRangeAttrs<Prev: Rec> {
12524    pub(crate) prev: Option<Prev>,
12525    pub(crate) header_offset: Option<usize>,
12526}
12527impl<Prev: Rec> Rec for PushRangeAttrs<Prev> {
12528    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
12529        self.prev.as_mut().unwrap().as_rec_mut()
12530    }
12531    fn as_rec(&self) -> &Vec<u8> {
12532        self.prev.as_ref().unwrap().as_rec()
12533    }
12534}
12535impl<Prev: Rec> PushRangeAttrs<Prev> {
12536    pub fn new(prev: Prev) -> Self {
12537        Self {
12538            prev: Some(prev),
12539            header_offset: None,
12540        }
12541    }
12542    pub fn end_nested(mut self) -> Prev {
12543        let mut prev = self.prev.take().unwrap();
12544        if let Some(header_offset) = &self.header_offset {
12545            finalize_nested_header(prev.as_rec_mut(), *header_offset);
12546        }
12547        prev
12548    }
12549    #[doc = "source register of data to compare\nAssociated type: [`Registers`] (enum)"]
12550    pub fn push_sreg(mut self, value: u32) -> Self {
12551        push_header(self.as_rec_mut(), 1u16, 4 as u16);
12552        self.as_rec_mut().extend(value.to_be_bytes());
12553        self
12554    }
12555    #[doc = "cmp operation\nAssociated type: [`RangeOps`] (enum)"]
12556    pub fn push_op(mut self, value: u32) -> Self {
12557        push_header(self.as_rec_mut(), 2u16, 4 as u16);
12558        self.as_rec_mut().extend(value.to_be_bytes());
12559        self
12560    }
12561    #[doc = "data range from"]
12562    pub fn nested_from_data(mut self) -> PushDataAttrs<Self> {
12563        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
12564        PushDataAttrs {
12565            prev: Some(self),
12566            header_offset: Some(header_offset),
12567        }
12568    }
12569    #[doc = "data range to"]
12570    pub fn nested_to_data(mut self) -> PushDataAttrs<Self> {
12571        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
12572        PushDataAttrs {
12573            prev: Some(self),
12574            header_offset: Some(header_offset),
12575        }
12576    }
12577}
12578impl<Prev: Rec> Drop for PushRangeAttrs<Prev> {
12579    fn drop(&mut self) {
12580        if let Some(prev) = &mut self.prev {
12581            if let Some(header_offset) = &self.header_offset {
12582                finalize_nested_header(prev.as_rec_mut(), *header_offset);
12583            }
12584        }
12585    }
12586}
12587pub struct PushBatchAttrs<Prev: Rec> {
12588    pub(crate) prev: Option<Prev>,
12589    pub(crate) header_offset: Option<usize>,
12590}
12591impl<Prev: Rec> Rec for PushBatchAttrs<Prev> {
12592    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
12593        self.prev.as_mut().unwrap().as_rec_mut()
12594    }
12595    fn as_rec(&self) -> &Vec<u8> {
12596        self.prev.as_ref().unwrap().as_rec()
12597    }
12598}
12599impl<Prev: Rec> PushBatchAttrs<Prev> {
12600    pub fn new(prev: Prev) -> Self {
12601        Self {
12602            prev: Some(prev),
12603            header_offset: None,
12604        }
12605    }
12606    pub fn end_nested(mut self) -> Prev {
12607        let mut prev = self.prev.take().unwrap();
12608        if let Some(header_offset) = &self.header_offset {
12609            finalize_nested_header(prev.as_rec_mut(), *header_offset);
12610        }
12611        prev
12612    }
12613    #[doc = "generation ID for this changeset"]
12614    pub fn push_genid(mut self, value: u32) -> Self {
12615        push_header(self.as_rec_mut(), 1u16, 4 as u16);
12616        self.as_rec_mut().extend(value.to_be_bytes());
12617        self
12618    }
12619}
12620impl<Prev: Rec> Drop for PushBatchAttrs<Prev> {
12621    fn drop(&mut self) {
12622        if let Some(prev) = &mut self.prev {
12623            if let Some(header_offset) = &self.header_offset {
12624                finalize_nested_header(prev.as_rec_mut(), *header_offset);
12625            }
12626        }
12627    }
12628}
12629pub struct PushTableAttrs<Prev: Rec> {
12630    pub(crate) prev: Option<Prev>,
12631    pub(crate) header_offset: Option<usize>,
12632}
12633impl<Prev: Rec> Rec for PushTableAttrs<Prev> {
12634    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
12635        self.prev.as_mut().unwrap().as_rec_mut()
12636    }
12637    fn as_rec(&self) -> &Vec<u8> {
12638        self.prev.as_ref().unwrap().as_rec()
12639    }
12640}
12641impl<Prev: Rec> PushTableAttrs<Prev> {
12642    pub fn new(prev: Prev) -> Self {
12643        Self {
12644            prev: Some(prev),
12645            header_offset: None,
12646        }
12647    }
12648    pub fn end_nested(mut self) -> Prev {
12649        let mut prev = self.prev.take().unwrap();
12650        if let Some(header_offset) = &self.header_offset {
12651            finalize_nested_header(prev.as_rec_mut(), *header_offset);
12652        }
12653        prev
12654    }
12655    #[doc = "name of the table"]
12656    pub fn push_name(mut self, value: &CStr) -> Self {
12657        push_header(
12658            self.as_rec_mut(),
12659            1u16,
12660            value.to_bytes_with_nul().len() as u16,
12661        );
12662        self.as_rec_mut().extend(value.to_bytes_with_nul());
12663        self
12664    }
12665    #[doc = "name of the table"]
12666    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
12667        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
12668        self.as_rec_mut().extend(value);
12669        self.as_rec_mut().push(0);
12670        self
12671    }
12672    #[doc = "bitmask of flags\nAssociated type: [`TableFlags`] (1 bit per enumeration)"]
12673    pub fn push_flags(mut self, value: u32) -> Self {
12674        push_header(self.as_rec_mut(), 2u16, 4 as u16);
12675        self.as_rec_mut().extend(value.to_be_bytes());
12676        self
12677    }
12678    #[doc = "number of chains in this table"]
12679    pub fn push_use(mut self, value: u32) -> Self {
12680        push_header(self.as_rec_mut(), 3u16, 4 as u16);
12681        self.as_rec_mut().extend(value.to_be_bytes());
12682        self
12683    }
12684    #[doc = "numeric handle of the table"]
12685    pub fn push_handle(mut self, value: u64) -> Self {
12686        push_header(self.as_rec_mut(), 4u16, 8 as u16);
12687        self.as_rec_mut().extend(value.to_be_bytes());
12688        self
12689    }
12690    pub fn push_pad(mut self, value: &[u8]) -> Self {
12691        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
12692        self.as_rec_mut().extend(value);
12693        self
12694    }
12695    #[doc = "user data"]
12696    pub fn push_userdata(mut self, value: &[u8]) -> Self {
12697        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
12698        self.as_rec_mut().extend(value);
12699        self
12700    }
12701    #[doc = "owner of this table through netlink portID"]
12702    pub fn push_owner(mut self, value: u32) -> Self {
12703        push_header(self.as_rec_mut(), 7u16, 4 as u16);
12704        self.as_rec_mut().extend(value.to_be_bytes());
12705        self
12706    }
12707}
12708impl<Prev: Rec> Drop for PushTableAttrs<Prev> {
12709    fn drop(&mut self) {
12710        if let Some(prev) = &mut self.prev {
12711            if let Some(header_offset) = &self.header_offset {
12712                finalize_nested_header(prev.as_rec_mut(), *header_offset);
12713            }
12714        }
12715    }
12716}
12717pub struct PushChainAttrs<Prev: Rec> {
12718    pub(crate) prev: Option<Prev>,
12719    pub(crate) header_offset: Option<usize>,
12720}
12721impl<Prev: Rec> Rec for PushChainAttrs<Prev> {
12722    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
12723        self.prev.as_mut().unwrap().as_rec_mut()
12724    }
12725    fn as_rec(&self) -> &Vec<u8> {
12726        self.prev.as_ref().unwrap().as_rec()
12727    }
12728}
12729impl<Prev: Rec> PushChainAttrs<Prev> {
12730    pub fn new(prev: Prev) -> Self {
12731        Self {
12732            prev: Some(prev),
12733            header_offset: None,
12734        }
12735    }
12736    pub fn end_nested(mut self) -> Prev {
12737        let mut prev = self.prev.take().unwrap();
12738        if let Some(header_offset) = &self.header_offset {
12739            finalize_nested_header(prev.as_rec_mut(), *header_offset);
12740        }
12741        prev
12742    }
12743    #[doc = "name of the table containing the chain"]
12744    pub fn push_table(mut self, value: &CStr) -> Self {
12745        push_header(
12746            self.as_rec_mut(),
12747            1u16,
12748            value.to_bytes_with_nul().len() as u16,
12749        );
12750        self.as_rec_mut().extend(value.to_bytes_with_nul());
12751        self
12752    }
12753    #[doc = "name of the table containing the chain"]
12754    pub fn push_table_bytes(mut self, value: &[u8]) -> Self {
12755        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
12756        self.as_rec_mut().extend(value);
12757        self.as_rec_mut().push(0);
12758        self
12759    }
12760    #[doc = "numeric handle of the chain"]
12761    pub fn push_handle(mut self, value: u64) -> Self {
12762        push_header(self.as_rec_mut(), 2u16, 8 as u16);
12763        self.as_rec_mut().extend(value.to_be_bytes());
12764        self
12765    }
12766    #[doc = "name of the chain"]
12767    pub fn push_name(mut self, value: &CStr) -> Self {
12768        push_header(
12769            self.as_rec_mut(),
12770            3u16,
12771            value.to_bytes_with_nul().len() as u16,
12772        );
12773        self.as_rec_mut().extend(value.to_bytes_with_nul());
12774        self
12775    }
12776    #[doc = "name of the chain"]
12777    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
12778        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
12779        self.as_rec_mut().extend(value);
12780        self.as_rec_mut().push(0);
12781        self
12782    }
12783    #[doc = "hook specification for basechains"]
12784    pub fn nested_hook(mut self) -> PushNftHookAttrs<Self> {
12785        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
12786        PushNftHookAttrs {
12787            prev: Some(self),
12788            header_offset: Some(header_offset),
12789        }
12790    }
12791    #[doc = "numeric policy of the chain"]
12792    pub fn push_policy(mut self, value: u32) -> Self {
12793        push_header(self.as_rec_mut(), 5u16, 4 as u16);
12794        self.as_rec_mut().extend(value.to_be_bytes());
12795        self
12796    }
12797    #[doc = "number of references to this chain"]
12798    pub fn push_use(mut self, value: u32) -> Self {
12799        push_header(self.as_rec_mut(), 6u16, 4 as u16);
12800        self.as_rec_mut().extend(value.to_be_bytes());
12801        self
12802    }
12803    #[doc = "type name of the chain"]
12804    pub fn push_type(mut self, value: &CStr) -> Self {
12805        push_header(
12806            self.as_rec_mut(),
12807            7u16,
12808            value.to_bytes_with_nul().len() as u16,
12809        );
12810        self.as_rec_mut().extend(value.to_bytes_with_nul());
12811        self
12812    }
12813    #[doc = "type name of the chain"]
12814    pub fn push_type_bytes(mut self, value: &[u8]) -> Self {
12815        push_header(self.as_rec_mut(), 7u16, (value.len() + 1) as u16);
12816        self.as_rec_mut().extend(value);
12817        self.as_rec_mut().push(0);
12818        self
12819    }
12820    #[doc = "counter specification of the chain"]
12821    pub fn nested_counters(mut self) -> PushNftCounterAttrs<Self> {
12822        let header_offset = push_nested_header(self.as_rec_mut(), 8u16);
12823        PushNftCounterAttrs {
12824            prev: Some(self),
12825            header_offset: Some(header_offset),
12826        }
12827    }
12828    #[doc = "chain flags\nAssociated type: [`ChainFlags`] (1 bit per enumeration)"]
12829    pub fn push_flags(mut self, value: u32) -> Self {
12830        push_header(self.as_rec_mut(), 9u16, 4 as u16);
12831        self.as_rec_mut().extend(value.to_be_bytes());
12832        self
12833    }
12834    #[doc = "uniquely identifies a chain in a transaction"]
12835    pub fn push_id(mut self, value: u32) -> Self {
12836        push_header(self.as_rec_mut(), 10u16, 4 as u16);
12837        self.as_rec_mut().extend(value.to_be_bytes());
12838        self
12839    }
12840    #[doc = "user data"]
12841    pub fn push_userdata(mut self, value: &[u8]) -> Self {
12842        push_header(self.as_rec_mut(), 11u16, value.len() as u16);
12843        self.as_rec_mut().extend(value);
12844        self
12845    }
12846}
12847impl<Prev: Rec> Drop for PushChainAttrs<Prev> {
12848    fn drop(&mut self) {
12849        if let Some(prev) = &mut self.prev {
12850            if let Some(header_offset) = &self.header_offset {
12851                finalize_nested_header(prev.as_rec_mut(), *header_offset);
12852            }
12853        }
12854    }
12855}
12856pub struct PushCounterAttrs<Prev: Rec> {
12857    pub(crate) prev: Option<Prev>,
12858    pub(crate) header_offset: Option<usize>,
12859}
12860impl<Prev: Rec> Rec for PushCounterAttrs<Prev> {
12861    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
12862        self.prev.as_mut().unwrap().as_rec_mut()
12863    }
12864    fn as_rec(&self) -> &Vec<u8> {
12865        self.prev.as_ref().unwrap().as_rec()
12866    }
12867}
12868impl<Prev: Rec> PushCounterAttrs<Prev> {
12869    pub fn new(prev: Prev) -> Self {
12870        Self {
12871            prev: Some(prev),
12872            header_offset: None,
12873        }
12874    }
12875    pub fn end_nested(mut self) -> Prev {
12876        let mut prev = self.prev.take().unwrap();
12877        if let Some(header_offset) = &self.header_offset {
12878            finalize_nested_header(prev.as_rec_mut(), *header_offset);
12879        }
12880        prev
12881    }
12882    pub fn push_bytes(mut self, value: u64) -> Self {
12883        push_header(self.as_rec_mut(), 1u16, 8 as u16);
12884        self.as_rec_mut().extend(value.to_be_bytes());
12885        self
12886    }
12887    pub fn push_packets(mut self, value: u64) -> Self {
12888        push_header(self.as_rec_mut(), 2u16, 8 as u16);
12889        self.as_rec_mut().extend(value.to_be_bytes());
12890        self
12891    }
12892    pub fn push_pad(mut self, value: &[u8]) -> Self {
12893        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
12894        self.as_rec_mut().extend(value);
12895        self
12896    }
12897}
12898impl<Prev: Rec> Drop for PushCounterAttrs<Prev> {
12899    fn drop(&mut self) {
12900        if let Some(prev) = &mut self.prev {
12901            if let Some(header_offset) = &self.header_offset {
12902                finalize_nested_header(prev.as_rec_mut(), *header_offset);
12903            }
12904        }
12905    }
12906}
12907pub struct PushNftHookAttrs<Prev: Rec> {
12908    pub(crate) prev: Option<Prev>,
12909    pub(crate) header_offset: Option<usize>,
12910}
12911impl<Prev: Rec> Rec for PushNftHookAttrs<Prev> {
12912    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
12913        self.prev.as_mut().unwrap().as_rec_mut()
12914    }
12915    fn as_rec(&self) -> &Vec<u8> {
12916        self.prev.as_ref().unwrap().as_rec()
12917    }
12918}
12919impl<Prev: Rec> PushNftHookAttrs<Prev> {
12920    pub fn new(prev: Prev) -> Self {
12921        Self {
12922            prev: Some(prev),
12923            header_offset: None,
12924        }
12925    }
12926    pub fn end_nested(mut self) -> Prev {
12927        let mut prev = self.prev.take().unwrap();
12928        if let Some(header_offset) = &self.header_offset {
12929            finalize_nested_header(prev.as_rec_mut(), *header_offset);
12930        }
12931        prev
12932    }
12933    pub fn push_num(mut self, value: u32) -> Self {
12934        push_header(self.as_rec_mut(), 1u16, 4 as u16);
12935        self.as_rec_mut().extend(value.to_be_bytes());
12936        self
12937    }
12938    pub fn push_priority(mut self, value: i32) -> Self {
12939        push_header(self.as_rec_mut(), 2u16, 4 as u16);
12940        self.as_rec_mut().extend(value.to_be_bytes());
12941        self
12942    }
12943    #[doc = "net device name"]
12944    pub fn push_dev(mut self, value: &CStr) -> Self {
12945        push_header(
12946            self.as_rec_mut(),
12947            3u16,
12948            value.to_bytes_with_nul().len() as u16,
12949        );
12950        self.as_rec_mut().extend(value.to_bytes_with_nul());
12951        self
12952    }
12953    #[doc = "net device name"]
12954    pub fn push_dev_bytes(mut self, value: &[u8]) -> Self {
12955        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
12956        self.as_rec_mut().extend(value);
12957        self.as_rec_mut().push(0);
12958        self
12959    }
12960    #[doc = "list of net devices"]
12961    pub fn nested_devs(mut self) -> PushHookDevAttrs<Self> {
12962        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
12963        PushHookDevAttrs {
12964            prev: Some(self),
12965            header_offset: Some(header_offset),
12966        }
12967    }
12968}
12969impl<Prev: Rec> Drop for PushNftHookAttrs<Prev> {
12970    fn drop(&mut self) {
12971        if let Some(prev) = &mut self.prev {
12972            if let Some(header_offset) = &self.header_offset {
12973                finalize_nested_header(prev.as_rec_mut(), *header_offset);
12974            }
12975        }
12976    }
12977}
12978pub struct PushHookDevAttrs<Prev: Rec> {
12979    pub(crate) prev: Option<Prev>,
12980    pub(crate) header_offset: Option<usize>,
12981}
12982impl<Prev: Rec> Rec for PushHookDevAttrs<Prev> {
12983    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
12984        self.prev.as_mut().unwrap().as_rec_mut()
12985    }
12986    fn as_rec(&self) -> &Vec<u8> {
12987        self.prev.as_ref().unwrap().as_rec()
12988    }
12989}
12990impl<Prev: Rec> PushHookDevAttrs<Prev> {
12991    pub fn new(prev: Prev) -> Self {
12992        Self {
12993            prev: Some(prev),
12994            header_offset: None,
12995        }
12996    }
12997    pub fn end_nested(mut self) -> Prev {
12998        let mut prev = self.prev.take().unwrap();
12999        if let Some(header_offset) = &self.header_offset {
13000            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13001        }
13002        prev
13003    }
13004    #[doc = "Attribute may repeat multiple times (treat it as array)"]
13005    pub fn push_name(mut self, value: &CStr) -> Self {
13006        push_header(
13007            self.as_rec_mut(),
13008            1u16,
13009            value.to_bytes_with_nul().len() as u16,
13010        );
13011        self.as_rec_mut().extend(value.to_bytes_with_nul());
13012        self
13013    }
13014    #[doc = "Attribute may repeat multiple times (treat it as array)"]
13015    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
13016        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
13017        self.as_rec_mut().extend(value);
13018        self.as_rec_mut().push(0);
13019        self
13020    }
13021}
13022impl<Prev: Rec> Drop for PushHookDevAttrs<Prev> {
13023    fn drop(&mut self) {
13024        if let Some(prev) = &mut self.prev {
13025            if let Some(header_offset) = &self.header_offset {
13026                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13027            }
13028        }
13029    }
13030}
13031pub struct PushNftCounterAttrs<Prev: Rec> {
13032    pub(crate) prev: Option<Prev>,
13033    pub(crate) header_offset: Option<usize>,
13034}
13035impl<Prev: Rec> Rec for PushNftCounterAttrs<Prev> {
13036    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13037        self.prev.as_mut().unwrap().as_rec_mut()
13038    }
13039    fn as_rec(&self) -> &Vec<u8> {
13040        self.prev.as_ref().unwrap().as_rec()
13041    }
13042}
13043impl<Prev: Rec> PushNftCounterAttrs<Prev> {
13044    pub fn new(prev: Prev) -> Self {
13045        Self {
13046            prev: Some(prev),
13047            header_offset: None,
13048        }
13049    }
13050    pub fn end_nested(mut self) -> Prev {
13051        let mut prev = self.prev.take().unwrap();
13052        if let Some(header_offset) = &self.header_offset {
13053            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13054        }
13055        prev
13056    }
13057    pub fn push_bytes(mut self, value: u64) -> Self {
13058        push_header(self.as_rec_mut(), 1u16, 8 as u16);
13059        self.as_rec_mut().extend(value.to_be_bytes());
13060        self
13061    }
13062    pub fn push_packets(mut self, value: u64) -> Self {
13063        push_header(self.as_rec_mut(), 2u16, 8 as u16);
13064        self.as_rec_mut().extend(value.to_be_bytes());
13065        self
13066    }
13067}
13068impl<Prev: Rec> Drop for PushNftCounterAttrs<Prev> {
13069    fn drop(&mut self) {
13070        if let Some(prev) = &mut self.prev {
13071            if let Some(header_offset) = &self.header_offset {
13072                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13073            }
13074        }
13075    }
13076}
13077pub struct PushRuleAttrs<Prev: Rec> {
13078    pub(crate) prev: Option<Prev>,
13079    pub(crate) header_offset: Option<usize>,
13080}
13081impl<Prev: Rec> Rec for PushRuleAttrs<Prev> {
13082    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13083        self.prev.as_mut().unwrap().as_rec_mut()
13084    }
13085    fn as_rec(&self) -> &Vec<u8> {
13086        self.prev.as_ref().unwrap().as_rec()
13087    }
13088}
13089impl<Prev: Rec> PushRuleAttrs<Prev> {
13090    pub fn new(prev: Prev) -> Self {
13091        Self {
13092            prev: Some(prev),
13093            header_offset: None,
13094        }
13095    }
13096    pub fn end_nested(mut self) -> Prev {
13097        let mut prev = self.prev.take().unwrap();
13098        if let Some(header_offset) = &self.header_offset {
13099            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13100        }
13101        prev
13102    }
13103    #[doc = "name of the table containing the rule"]
13104    pub fn push_table(mut self, value: &CStr) -> Self {
13105        push_header(
13106            self.as_rec_mut(),
13107            1u16,
13108            value.to_bytes_with_nul().len() as u16,
13109        );
13110        self.as_rec_mut().extend(value.to_bytes_with_nul());
13111        self
13112    }
13113    #[doc = "name of the table containing the rule"]
13114    pub fn push_table_bytes(mut self, value: &[u8]) -> Self {
13115        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
13116        self.as_rec_mut().extend(value);
13117        self.as_rec_mut().push(0);
13118        self
13119    }
13120    #[doc = "name of the chain containing the rule"]
13121    pub fn push_chain(mut self, value: &CStr) -> Self {
13122        push_header(
13123            self.as_rec_mut(),
13124            2u16,
13125            value.to_bytes_with_nul().len() as u16,
13126        );
13127        self.as_rec_mut().extend(value.to_bytes_with_nul());
13128        self
13129    }
13130    #[doc = "name of the chain containing the rule"]
13131    pub fn push_chain_bytes(mut self, value: &[u8]) -> Self {
13132        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
13133        self.as_rec_mut().extend(value);
13134        self.as_rec_mut().push(0);
13135        self
13136    }
13137    #[doc = "numeric handle of the rule"]
13138    pub fn push_handle(mut self, value: u64) -> Self {
13139        push_header(self.as_rec_mut(), 3u16, 8 as u16);
13140        self.as_rec_mut().extend(value.to_be_bytes());
13141        self
13142    }
13143    #[doc = "list of expressions"]
13144    pub fn nested_expressions(mut self) -> PushExprListAttrs<Self> {
13145        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
13146        PushExprListAttrs {
13147            prev: Some(self),
13148            header_offset: Some(header_offset),
13149        }
13150    }
13151    #[doc = "compatibility specifications of the rule"]
13152    pub fn nested_compat(mut self) -> PushRuleCompatAttrs<Self> {
13153        let header_offset = push_nested_header(self.as_rec_mut(), 5u16);
13154        PushRuleCompatAttrs {
13155            prev: Some(self),
13156            header_offset: Some(header_offset),
13157        }
13158    }
13159    #[doc = "numeric handle of the previous rule"]
13160    pub fn push_position(mut self, value: u64) -> Self {
13161        push_header(self.as_rec_mut(), 6u16, 8 as u16);
13162        self.as_rec_mut().extend(value.to_be_bytes());
13163        self
13164    }
13165    #[doc = "user data"]
13166    pub fn push_userdata(mut self, value: &[u8]) -> Self {
13167        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
13168        self.as_rec_mut().extend(value);
13169        self
13170    }
13171    #[doc = "uniquely identifies a rule in a transaction"]
13172    pub fn push_id(mut self, value: u32) -> Self {
13173        push_header(self.as_rec_mut(), 8u16, 4 as u16);
13174        self.as_rec_mut().extend(value.to_ne_bytes());
13175        self
13176    }
13177    #[doc = "transaction unique identifier of the previous rule"]
13178    pub fn push_position_id(mut self, value: u32) -> Self {
13179        push_header(self.as_rec_mut(), 9u16, 4 as u16);
13180        self.as_rec_mut().extend(value.to_ne_bytes());
13181        self
13182    }
13183    #[doc = "add the rule to chain by ID, alternative to chain name"]
13184    pub fn push_chain_id(mut self, value: u32) -> Self {
13185        push_header(self.as_rec_mut(), 10u16, 4 as u16);
13186        self.as_rec_mut().extend(value.to_ne_bytes());
13187        self
13188    }
13189}
13190impl<Prev: Rec> Drop for PushRuleAttrs<Prev> {
13191    fn drop(&mut self) {
13192        if let Some(prev) = &mut self.prev {
13193            if let Some(header_offset) = &self.header_offset {
13194                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13195            }
13196        }
13197    }
13198}
13199pub struct PushExprListAttrs<Prev: Rec> {
13200    pub(crate) prev: Option<Prev>,
13201    pub(crate) header_offset: Option<usize>,
13202}
13203impl<Prev: Rec> Rec for PushExprListAttrs<Prev> {
13204    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13205        self.prev.as_mut().unwrap().as_rec_mut()
13206    }
13207    fn as_rec(&self) -> &Vec<u8> {
13208        self.prev.as_ref().unwrap().as_rec()
13209    }
13210}
13211impl<Prev: Rec> PushExprListAttrs<Prev> {
13212    pub fn new(prev: Prev) -> Self {
13213        Self {
13214            prev: Some(prev),
13215            header_offset: None,
13216        }
13217    }
13218    pub fn end_nested(mut self) -> Prev {
13219        let mut prev = self.prev.take().unwrap();
13220        if let Some(header_offset) = &self.header_offset {
13221            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13222        }
13223        prev
13224    }
13225    #[doc = "Attribute may repeat multiple times (treat it as array)"]
13226    pub fn nested_elem(mut self) -> PushExprAttrs<Self> {
13227        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
13228        PushExprAttrs {
13229            prev: Some(self),
13230            header_offset: Some(header_offset),
13231        }
13232    }
13233}
13234impl<Prev: Rec> Drop for PushExprListAttrs<Prev> {
13235    fn drop(&mut self) {
13236        if let Some(prev) = &mut self.prev {
13237            if let Some(header_offset) = &self.header_offset {
13238                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13239            }
13240        }
13241    }
13242}
13243pub struct PushExprAttrs<Prev: Rec> {
13244    pub(crate) prev: Option<Prev>,
13245    pub(crate) header_offset: Option<usize>,
13246}
13247impl<Prev: Rec> Rec for PushExprAttrs<Prev> {
13248    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13249        self.prev.as_mut().unwrap().as_rec_mut()
13250    }
13251    fn as_rec(&self) -> &Vec<u8> {
13252        self.prev.as_ref().unwrap().as_rec()
13253    }
13254}
13255impl<Prev: Rec> PushExprAttrs<Prev> {
13256    pub fn new(prev: Prev) -> Self {
13257        Self {
13258            prev: Some(prev),
13259            header_offset: None,
13260        }
13261    }
13262    pub fn end_nested(mut self) -> Prev {
13263        let mut prev = self.prev.take().unwrap();
13264        if let Some(header_offset) = &self.header_offset {
13265            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13266        }
13267        prev
13268    }
13269    #[doc = "name of the expression type"]
13270    pub fn push_name(mut self, value: &CStr) -> Self {
13271        push_header(
13272            self.as_rec_mut(),
13273            1u16,
13274            value.to_bytes_with_nul().len() as u16,
13275        );
13276        self.as_rec_mut().extend(value.to_bytes_with_nul());
13277        self
13278    }
13279    #[doc = "name of the expression type"]
13280    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
13281        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
13282        self.as_rec_mut().extend(value);
13283        self.as_rec_mut().push(0);
13284        self
13285    }
13286    #[doc = "type specific data"]
13287    #[doc = "Selector attribute is inserted automatically."]
13288    #[doc = "At most one sub-message attribute is expected per attribute set."]
13289    pub fn nested_data_bitwise(mut self) -> PushExprBitwiseAttrs<PushDummy<Prev>> {
13290        self = self.push_name(c"bitwise");
13291        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13292        let dummy = PushDummy {
13293            prev: self.prev.take(),
13294            header_offset: self.header_offset.take(),
13295        };
13296        PushExprBitwiseAttrs {
13297            prev: Some(dummy),
13298            header_offset: Some(new_header_offset),
13299        }
13300    }
13301    #[doc = "Selector attribute is inserted automatically."]
13302    #[doc = "At most one sub-message attribute is expected per attribute set."]
13303    pub fn nested_data_cmp(mut self) -> PushExprCmpAttrs<PushDummy<Prev>> {
13304        self = self.push_name(c"cmp");
13305        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13306        let dummy = PushDummy {
13307            prev: self.prev.take(),
13308            header_offset: self.header_offset.take(),
13309        };
13310        PushExprCmpAttrs {
13311            prev: Some(dummy),
13312            header_offset: Some(new_header_offset),
13313        }
13314    }
13315    #[doc = "Selector attribute is inserted automatically."]
13316    #[doc = "At most one sub-message attribute is expected per attribute set."]
13317    pub fn nested_data_counter(mut self) -> PushExprCounterAttrs<PushDummy<Prev>> {
13318        self = self.push_name(c"counter");
13319        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13320        let dummy = PushDummy {
13321            prev: self.prev.take(),
13322            header_offset: self.header_offset.take(),
13323        };
13324        PushExprCounterAttrs {
13325            prev: Some(dummy),
13326            header_offset: Some(new_header_offset),
13327        }
13328    }
13329    #[doc = "Selector attribute is inserted automatically."]
13330    #[doc = "At most one sub-message attribute is expected per attribute set."]
13331    pub fn nested_data_ct(mut self) -> PushExprCtAttrs<PushDummy<Prev>> {
13332        self = self.push_name(c"ct");
13333        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13334        let dummy = PushDummy {
13335            prev: self.prev.take(),
13336            header_offset: self.header_offset.take(),
13337        };
13338        PushExprCtAttrs {
13339            prev: Some(dummy),
13340            header_offset: Some(new_header_offset),
13341        }
13342    }
13343    #[doc = "Selector attribute is inserted automatically."]
13344    #[doc = "At most one sub-message attribute is expected per attribute set."]
13345    pub fn nested_data_fib(mut self) -> PushExprFibAttrs<PushDummy<Prev>> {
13346        self = self.push_name(c"fib");
13347        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13348        let dummy = PushDummy {
13349            prev: self.prev.take(),
13350            header_offset: self.header_offset.take(),
13351        };
13352        PushExprFibAttrs {
13353            prev: Some(dummy),
13354            header_offset: Some(new_header_offset),
13355        }
13356    }
13357    #[doc = "Selector attribute is inserted automatically."]
13358    #[doc = "At most one sub-message attribute is expected per attribute set."]
13359    pub fn nested_data_flow_offload(mut self) -> PushExprFlowOffloadAttrs<PushDummy<Prev>> {
13360        self = self.push_name(c"flow_offload");
13361        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13362        let dummy = PushDummy {
13363            prev: self.prev.take(),
13364            header_offset: self.header_offset.take(),
13365        };
13366        PushExprFlowOffloadAttrs {
13367            prev: Some(dummy),
13368            header_offset: Some(new_header_offset),
13369        }
13370    }
13371    #[doc = "Selector attribute is inserted automatically."]
13372    #[doc = "At most one sub-message attribute is expected per attribute set."]
13373    pub fn nested_data_immediate(mut self) -> PushExprImmediateAttrs<PushDummy<Prev>> {
13374        self = self.push_name(c"immediate");
13375        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13376        let dummy = PushDummy {
13377            prev: self.prev.take(),
13378            header_offset: self.header_offset.take(),
13379        };
13380        PushExprImmediateAttrs {
13381            prev: Some(dummy),
13382            header_offset: Some(new_header_offset),
13383        }
13384    }
13385    #[doc = "Selector attribute is inserted automatically."]
13386    #[doc = "At most one sub-message attribute is expected per attribute set."]
13387    pub fn nested_data_log(mut self) -> PushLogAttrs<PushDummy<Prev>> {
13388        self = self.push_name(c"log");
13389        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13390        let dummy = PushDummy {
13391            prev: self.prev.take(),
13392            header_offset: self.header_offset.take(),
13393        };
13394        PushLogAttrs {
13395            prev: Some(dummy),
13396            header_offset: Some(new_header_offset),
13397        }
13398    }
13399    #[doc = "Selector attribute is inserted automatically."]
13400    #[doc = "At most one sub-message attribute is expected per attribute set."]
13401    pub fn nested_data_lookup(mut self) -> PushExprLookupAttrs<PushDummy<Prev>> {
13402        self = self.push_name(c"lookup");
13403        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13404        let dummy = PushDummy {
13405            prev: self.prev.take(),
13406            header_offset: self.header_offset.take(),
13407        };
13408        PushExprLookupAttrs {
13409            prev: Some(dummy),
13410            header_offset: Some(new_header_offset),
13411        }
13412    }
13413    #[doc = "Selector attribute is inserted automatically."]
13414    #[doc = "At most one sub-message attribute is expected per attribute set."]
13415    pub fn nested_data_match(mut self) -> PushCompatMatchAttrs<PushDummy<Prev>> {
13416        self = self.push_name(c"match");
13417        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13418        let dummy = PushDummy {
13419            prev: self.prev.take(),
13420            header_offset: self.header_offset.take(),
13421        };
13422        PushCompatMatchAttrs {
13423            prev: Some(dummy),
13424            header_offset: Some(new_header_offset),
13425        }
13426    }
13427    #[doc = "Selector attribute is inserted automatically."]
13428    #[doc = "At most one sub-message attribute is expected per attribute set."]
13429    pub fn nested_data_meta(mut self) -> PushExprMetaAttrs<PushDummy<Prev>> {
13430        self = self.push_name(c"meta");
13431        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13432        let dummy = PushDummy {
13433            prev: self.prev.take(),
13434            header_offset: self.header_offset.take(),
13435        };
13436        PushExprMetaAttrs {
13437            prev: Some(dummy),
13438            header_offset: Some(new_header_offset),
13439        }
13440    }
13441    #[doc = "Selector attribute is inserted automatically."]
13442    #[doc = "At most one sub-message attribute is expected per attribute set."]
13443    pub fn nested_data_nat(mut self) -> PushExprNatAttrs<PushDummy<Prev>> {
13444        self = self.push_name(c"nat");
13445        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13446        let dummy = PushDummy {
13447            prev: self.prev.take(),
13448            header_offset: self.header_offset.take(),
13449        };
13450        PushExprNatAttrs {
13451            prev: Some(dummy),
13452            header_offset: Some(new_header_offset),
13453        }
13454    }
13455    #[doc = "Selector attribute is inserted automatically."]
13456    #[doc = "At most one sub-message attribute is expected per attribute set."]
13457    pub fn nested_data_numgen(mut self) -> PushNumgenAttrs<PushDummy<Prev>> {
13458        self = self.push_name(c"numgen");
13459        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13460        let dummy = PushDummy {
13461            prev: self.prev.take(),
13462            header_offset: self.header_offset.take(),
13463        };
13464        PushNumgenAttrs {
13465            prev: Some(dummy),
13466            header_offset: Some(new_header_offset),
13467        }
13468    }
13469    #[doc = "Selector attribute is inserted automatically."]
13470    #[doc = "At most one sub-message attribute is expected per attribute set."]
13471    pub fn nested_data_objref(mut self) -> PushExprObjrefAttrs<PushDummy<Prev>> {
13472        self = self.push_name(c"objref");
13473        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13474        let dummy = PushDummy {
13475            prev: self.prev.take(),
13476            header_offset: self.header_offset.take(),
13477        };
13478        PushExprObjrefAttrs {
13479            prev: Some(dummy),
13480            header_offset: Some(new_header_offset),
13481        }
13482    }
13483    #[doc = "Selector attribute is inserted automatically."]
13484    #[doc = "At most one sub-message attribute is expected per attribute set."]
13485    pub fn nested_data_payload(mut self) -> PushExprPayloadAttrs<PushDummy<Prev>> {
13486        self = self.push_name(c"payload");
13487        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13488        let dummy = PushDummy {
13489            prev: self.prev.take(),
13490            header_offset: self.header_offset.take(),
13491        };
13492        PushExprPayloadAttrs {
13493            prev: Some(dummy),
13494            header_offset: Some(new_header_offset),
13495        }
13496    }
13497    #[doc = "Selector attribute is inserted automatically."]
13498    #[doc = "At most one sub-message attribute is expected per attribute set."]
13499    pub fn nested_data_quota(mut self) -> PushQuotaAttrs<PushDummy<Prev>> {
13500        self = self.push_name(c"quota");
13501        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13502        let dummy = PushDummy {
13503            prev: self.prev.take(),
13504            header_offset: self.header_offset.take(),
13505        };
13506        PushQuotaAttrs {
13507            prev: Some(dummy),
13508            header_offset: Some(new_header_offset),
13509        }
13510    }
13511    #[doc = "Selector attribute is inserted automatically."]
13512    #[doc = "At most one sub-message attribute is expected per attribute set."]
13513    pub fn nested_data_range(mut self) -> PushRangeAttrs<PushDummy<Prev>> {
13514        self = self.push_name(c"range");
13515        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13516        let dummy = PushDummy {
13517            prev: self.prev.take(),
13518            header_offset: self.header_offset.take(),
13519        };
13520        PushRangeAttrs {
13521            prev: Some(dummy),
13522            header_offset: Some(new_header_offset),
13523        }
13524    }
13525    #[doc = "Selector attribute is inserted automatically."]
13526    #[doc = "At most one sub-message attribute is expected per attribute set."]
13527    pub fn nested_data_reject(mut self) -> PushExprRejectAttrs<PushDummy<Prev>> {
13528        self = self.push_name(c"reject");
13529        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13530        let dummy = PushDummy {
13531            prev: self.prev.take(),
13532            header_offset: self.header_offset.take(),
13533        };
13534        PushExprRejectAttrs {
13535            prev: Some(dummy),
13536            header_offset: Some(new_header_offset),
13537        }
13538    }
13539    #[doc = "Selector attribute is inserted automatically."]
13540    #[doc = "At most one sub-message attribute is expected per attribute set."]
13541    pub fn nested_data_target(mut self) -> PushExprTargetAttrs<PushDummy<Prev>> {
13542        self = self.push_name(c"target");
13543        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13544        let dummy = PushDummy {
13545            prev: self.prev.take(),
13546            header_offset: self.header_offset.take(),
13547        };
13548        PushExprTargetAttrs {
13549            prev: Some(dummy),
13550            header_offset: Some(new_header_offset),
13551        }
13552    }
13553    #[doc = "Selector attribute is inserted automatically."]
13554    #[doc = "At most one sub-message attribute is expected per attribute set."]
13555    pub fn nested_data_tproxy(mut self) -> PushExprTproxyAttrs<PushDummy<Prev>> {
13556        self = self.push_name(c"tproxy");
13557        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13558        let dummy = PushDummy {
13559            prev: self.prev.take(),
13560            header_offset: self.header_offset.take(),
13561        };
13562        PushExprTproxyAttrs {
13563            prev: Some(dummy),
13564            header_offset: Some(new_header_offset),
13565        }
13566    }
13567}
13568impl<Prev: Rec> Drop for PushExprAttrs<Prev> {
13569    fn drop(&mut self) {
13570        if let Some(prev) = &mut self.prev {
13571            if let Some(header_offset) = &self.header_offset {
13572                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13573            }
13574        }
13575    }
13576}
13577pub struct PushRuleCompatAttrs<Prev: Rec> {
13578    pub(crate) prev: Option<Prev>,
13579    pub(crate) header_offset: Option<usize>,
13580}
13581impl<Prev: Rec> Rec for PushRuleCompatAttrs<Prev> {
13582    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13583        self.prev.as_mut().unwrap().as_rec_mut()
13584    }
13585    fn as_rec(&self) -> &Vec<u8> {
13586        self.prev.as_ref().unwrap().as_rec()
13587    }
13588}
13589impl<Prev: Rec> PushRuleCompatAttrs<Prev> {
13590    pub fn new(prev: Prev) -> Self {
13591        Self {
13592            prev: Some(prev),
13593            header_offset: None,
13594        }
13595    }
13596    pub fn end_nested(mut self) -> Prev {
13597        let mut prev = self.prev.take().unwrap();
13598        if let Some(header_offset) = &self.header_offset {
13599            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13600        }
13601        prev
13602    }
13603    #[doc = "numeric value of the handled protocol"]
13604    pub fn push_proto(mut self, value: u32) -> Self {
13605        push_header(self.as_rec_mut(), 1u16, 4 as u16);
13606        self.as_rec_mut().extend(value.to_be_bytes());
13607        self
13608    }
13609    #[doc = "bitmask of flags"]
13610    pub fn push_flags(mut self, value: u32) -> Self {
13611        push_header(self.as_rec_mut(), 2u16, 4 as u16);
13612        self.as_rec_mut().extend(value.to_be_bytes());
13613        self
13614    }
13615}
13616impl<Prev: Rec> Drop for PushRuleCompatAttrs<Prev> {
13617    fn drop(&mut self) {
13618        if let Some(prev) = &mut self.prev {
13619            if let Some(header_offset) = &self.header_offset {
13620                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13621            }
13622        }
13623    }
13624}
13625pub struct PushSetAttrs<Prev: Rec> {
13626    pub(crate) prev: Option<Prev>,
13627    pub(crate) header_offset: Option<usize>,
13628}
13629impl<Prev: Rec> Rec for PushSetAttrs<Prev> {
13630    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13631        self.prev.as_mut().unwrap().as_rec_mut()
13632    }
13633    fn as_rec(&self) -> &Vec<u8> {
13634        self.prev.as_ref().unwrap().as_rec()
13635    }
13636}
13637impl<Prev: Rec> PushSetAttrs<Prev> {
13638    pub fn new(prev: Prev) -> Self {
13639        Self {
13640            prev: Some(prev),
13641            header_offset: None,
13642        }
13643    }
13644    pub fn end_nested(mut self) -> Prev {
13645        let mut prev = self.prev.take().unwrap();
13646        if let Some(header_offset) = &self.header_offset {
13647            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13648        }
13649        prev
13650    }
13651    #[doc = "table name"]
13652    pub fn push_table(mut self, value: &CStr) -> Self {
13653        push_header(
13654            self.as_rec_mut(),
13655            1u16,
13656            value.to_bytes_with_nul().len() as u16,
13657        );
13658        self.as_rec_mut().extend(value.to_bytes_with_nul());
13659        self
13660    }
13661    #[doc = "table name"]
13662    pub fn push_table_bytes(mut self, value: &[u8]) -> Self {
13663        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
13664        self.as_rec_mut().extend(value);
13665        self.as_rec_mut().push(0);
13666        self
13667    }
13668    #[doc = "set name"]
13669    pub fn push_name(mut self, value: &CStr) -> Self {
13670        push_header(
13671            self.as_rec_mut(),
13672            2u16,
13673            value.to_bytes_with_nul().len() as u16,
13674        );
13675        self.as_rec_mut().extend(value.to_bytes_with_nul());
13676        self
13677    }
13678    #[doc = "set name"]
13679    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
13680        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
13681        self.as_rec_mut().extend(value);
13682        self.as_rec_mut().push(0);
13683        self
13684    }
13685    #[doc = "bitmask of enum nft\\_set\\_flags\nAssociated type: [`SetFlags`] (enum)"]
13686    pub fn push_flags(mut self, value: u32) -> Self {
13687        push_header(self.as_rec_mut(), 3u16, 4 as u16);
13688        self.as_rec_mut().extend(value.to_be_bytes());
13689        self
13690    }
13691    #[doc = "key data type, informational purpose only"]
13692    pub fn push_key_type(mut self, value: u32) -> Self {
13693        push_header(self.as_rec_mut(), 4u16, 4 as u16);
13694        self.as_rec_mut().extend(value.to_be_bytes());
13695        self
13696    }
13697    #[doc = "key data length"]
13698    pub fn push_key_len(mut self, value: u32) -> Self {
13699        push_header(self.as_rec_mut(), 5u16, 4 as u16);
13700        self.as_rec_mut().extend(value.to_be_bytes());
13701        self
13702    }
13703    #[doc = "mapping data type"]
13704    pub fn push_data_type(mut self, value: u32) -> Self {
13705        push_header(self.as_rec_mut(), 6u16, 4 as u16);
13706        self.as_rec_mut().extend(value.to_be_bytes());
13707        self
13708    }
13709    #[doc = "mapping data length"]
13710    pub fn push_data_len(mut self, value: u32) -> Self {
13711        push_header(self.as_rec_mut(), 7u16, 4 as u16);
13712        self.as_rec_mut().extend(value.to_be_bytes());
13713        self
13714    }
13715    #[doc = "selection policy"]
13716    pub fn push_policy(mut self, value: u32) -> Self {
13717        push_header(self.as_rec_mut(), 8u16, 4 as u16);
13718        self.as_rec_mut().extend(value.to_be_bytes());
13719        self
13720    }
13721    #[doc = "set description"]
13722    pub fn nested_desc(mut self) -> PushSetDescAttrs<Self> {
13723        let header_offset = push_nested_header(self.as_rec_mut(), 9u16);
13724        PushSetDescAttrs {
13725            prev: Some(self),
13726            header_offset: Some(header_offset),
13727        }
13728    }
13729    #[doc = "uniquely identifies a set in a transaction"]
13730    pub fn push_id(mut self, value: u32) -> Self {
13731        push_header(self.as_rec_mut(), 10u16, 4 as u16);
13732        self.as_rec_mut().extend(value.to_ne_bytes());
13733        self
13734    }
13735    #[doc = "default timeout value"]
13736    pub fn push_timeout(mut self, value: u64) -> Self {
13737        push_header(self.as_rec_mut(), 11u16, 8 as u16);
13738        self.as_rec_mut().extend(value.to_ne_bytes());
13739        self
13740    }
13741    #[doc = "garbage collection interval"]
13742    pub fn push_gc_interval(mut self, value: u32) -> Self {
13743        push_header(self.as_rec_mut(), 12u16, 4 as u16);
13744        self.as_rec_mut().extend(value.to_ne_bytes());
13745        self
13746    }
13747    #[doc = "user data"]
13748    pub fn push_userdata(mut self, value: &[u8]) -> Self {
13749        push_header(self.as_rec_mut(), 13u16, value.len() as u16);
13750        self.as_rec_mut().extend(value);
13751        self
13752    }
13753    pub fn push_pad(mut self, value: &[u8]) -> Self {
13754        push_header(self.as_rec_mut(), 14u16, value.len() as u16);
13755        self.as_rec_mut().extend(value);
13756        self
13757    }
13758    #[doc = "stateful object type"]
13759    pub fn push_obj_type(mut self, value: u32) -> Self {
13760        push_header(self.as_rec_mut(), 15u16, 4 as u16);
13761        self.as_rec_mut().extend(value.to_be_bytes());
13762        self
13763    }
13764    #[doc = "set handle"]
13765    pub fn push_handle(mut self, value: u64) -> Self {
13766        push_header(self.as_rec_mut(), 16u16, 8 as u16);
13767        self.as_rec_mut().extend(value.to_be_bytes());
13768        self
13769    }
13770    #[doc = "set expression\nAttribute may repeat multiple times (treat it as array)"]
13771    pub fn nested_expr(mut self) -> PushExprAttrs<Self> {
13772        let header_offset = push_nested_header(self.as_rec_mut(), 17u16);
13773        PushExprAttrs {
13774            prev: Some(self),
13775            header_offset: Some(header_offset),
13776        }
13777    }
13778    #[doc = "list of expressions"]
13779    pub fn nested_expressions(mut self) -> PushSetListAttrs<Self> {
13780        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
13781        PushSetListAttrs {
13782            prev: Some(self),
13783            header_offset: Some(header_offset),
13784        }
13785    }
13786    #[doc = "set backend type"]
13787    pub fn push_type(mut self, value: &CStr) -> Self {
13788        push_header(
13789            self.as_rec_mut(),
13790            19u16,
13791            value.to_bytes_with_nul().len() as u16,
13792        );
13793        self.as_rec_mut().extend(value.to_bytes_with_nul());
13794        self
13795    }
13796    #[doc = "set backend type"]
13797    pub fn push_type_bytes(mut self, value: &[u8]) -> Self {
13798        push_header(self.as_rec_mut(), 19u16, (value.len() + 1) as u16);
13799        self.as_rec_mut().extend(value);
13800        self.as_rec_mut().push(0);
13801        self
13802    }
13803    #[doc = "number of set elements"]
13804    pub fn push_count(mut self, value: u32) -> Self {
13805        push_header(self.as_rec_mut(), 20u16, 4 as u16);
13806        self.as_rec_mut().extend(value.to_be_bytes());
13807        self
13808    }
13809}
13810impl<Prev: Rec> Drop for PushSetAttrs<Prev> {
13811    fn drop(&mut self) {
13812        if let Some(prev) = &mut self.prev {
13813            if let Some(header_offset) = &self.header_offset {
13814                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13815            }
13816        }
13817    }
13818}
13819pub struct PushSetDescAttrs<Prev: Rec> {
13820    pub(crate) prev: Option<Prev>,
13821    pub(crate) header_offset: Option<usize>,
13822}
13823impl<Prev: Rec> Rec for PushSetDescAttrs<Prev> {
13824    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13825        self.prev.as_mut().unwrap().as_rec_mut()
13826    }
13827    fn as_rec(&self) -> &Vec<u8> {
13828        self.prev.as_ref().unwrap().as_rec()
13829    }
13830}
13831impl<Prev: Rec> PushSetDescAttrs<Prev> {
13832    pub fn new(prev: Prev) -> Self {
13833        Self {
13834            prev: Some(prev),
13835            header_offset: None,
13836        }
13837    }
13838    pub fn end_nested(mut self) -> Prev {
13839        let mut prev = self.prev.take().unwrap();
13840        if let Some(header_offset) = &self.header_offset {
13841            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13842        }
13843        prev
13844    }
13845    #[doc = "number of elements in set"]
13846    pub fn push_size(mut self, value: u32) -> Self {
13847        push_header(self.as_rec_mut(), 1u16, 4 as u16);
13848        self.as_rec_mut().extend(value.to_be_bytes());
13849        self
13850    }
13851    #[doc = "description of field concatenation\nAttribute may repeat multiple times (treat it as array)"]
13852    pub fn nested_concat(mut self) -> PushSetDescConcatAttrs<Self> {
13853        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
13854        PushSetDescConcatAttrs {
13855            prev: Some(self),
13856            header_offset: Some(header_offset),
13857        }
13858    }
13859}
13860impl<Prev: Rec> Drop for PushSetDescAttrs<Prev> {
13861    fn drop(&mut self) {
13862        if let Some(prev) = &mut self.prev {
13863            if let Some(header_offset) = &self.header_offset {
13864                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13865            }
13866        }
13867    }
13868}
13869pub struct PushSetDescConcatAttrs<Prev: Rec> {
13870    pub(crate) prev: Option<Prev>,
13871    pub(crate) header_offset: Option<usize>,
13872}
13873impl<Prev: Rec> Rec for PushSetDescConcatAttrs<Prev> {
13874    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13875        self.prev.as_mut().unwrap().as_rec_mut()
13876    }
13877    fn as_rec(&self) -> &Vec<u8> {
13878        self.prev.as_ref().unwrap().as_rec()
13879    }
13880}
13881impl<Prev: Rec> PushSetDescConcatAttrs<Prev> {
13882    pub fn new(prev: Prev) -> Self {
13883        Self {
13884            prev: Some(prev),
13885            header_offset: None,
13886        }
13887    }
13888    pub fn end_nested(mut self) -> Prev {
13889        let mut prev = self.prev.take().unwrap();
13890        if let Some(header_offset) = &self.header_offset {
13891            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13892        }
13893        prev
13894    }
13895    pub fn nested_elem(mut self) -> PushSetFieldAttrs<Self> {
13896        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
13897        PushSetFieldAttrs {
13898            prev: Some(self),
13899            header_offset: Some(header_offset),
13900        }
13901    }
13902}
13903impl<Prev: Rec> Drop for PushSetDescConcatAttrs<Prev> {
13904    fn drop(&mut self) {
13905        if let Some(prev) = &mut self.prev {
13906            if let Some(header_offset) = &self.header_offset {
13907                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13908            }
13909        }
13910    }
13911}
13912pub struct PushSetFieldAttrs<Prev: Rec> {
13913    pub(crate) prev: Option<Prev>,
13914    pub(crate) header_offset: Option<usize>,
13915}
13916impl<Prev: Rec> Rec for PushSetFieldAttrs<Prev> {
13917    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13918        self.prev.as_mut().unwrap().as_rec_mut()
13919    }
13920    fn as_rec(&self) -> &Vec<u8> {
13921        self.prev.as_ref().unwrap().as_rec()
13922    }
13923}
13924impl<Prev: Rec> PushSetFieldAttrs<Prev> {
13925    pub fn new(prev: Prev) -> Self {
13926        Self {
13927            prev: Some(prev),
13928            header_offset: None,
13929        }
13930    }
13931    pub fn end_nested(mut self) -> Prev {
13932        let mut prev = self.prev.take().unwrap();
13933        if let Some(header_offset) = &self.header_offset {
13934            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13935        }
13936        prev
13937    }
13938    pub fn push_len(mut self, value: u32) -> Self {
13939        push_header(self.as_rec_mut(), 1u16, 4 as u16);
13940        self.as_rec_mut().extend(value.to_be_bytes());
13941        self
13942    }
13943}
13944impl<Prev: Rec> Drop for PushSetFieldAttrs<Prev> {
13945    fn drop(&mut self) {
13946        if let Some(prev) = &mut self.prev {
13947            if let Some(header_offset) = &self.header_offset {
13948                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13949            }
13950        }
13951    }
13952}
13953pub struct PushSetListAttrs<Prev: Rec> {
13954    pub(crate) prev: Option<Prev>,
13955    pub(crate) header_offset: Option<usize>,
13956}
13957impl<Prev: Rec> Rec for PushSetListAttrs<Prev> {
13958    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
13959        self.prev.as_mut().unwrap().as_rec_mut()
13960    }
13961    fn as_rec(&self) -> &Vec<u8> {
13962        self.prev.as_ref().unwrap().as_rec()
13963    }
13964}
13965impl<Prev: Rec> PushSetListAttrs<Prev> {
13966    pub fn new(prev: Prev) -> Self {
13967        Self {
13968            prev: Some(prev),
13969            header_offset: None,
13970        }
13971    }
13972    pub fn end_nested(mut self) -> Prev {
13973        let mut prev = self.prev.take().unwrap();
13974        if let Some(header_offset) = &self.header_offset {
13975            finalize_nested_header(prev.as_rec_mut(), *header_offset);
13976        }
13977        prev
13978    }
13979    #[doc = "Attribute may repeat multiple times (treat it as array)"]
13980    pub fn nested_elem(mut self) -> PushExprAttrs<Self> {
13981        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
13982        PushExprAttrs {
13983            prev: Some(self),
13984            header_offset: Some(header_offset),
13985        }
13986    }
13987}
13988impl<Prev: Rec> Drop for PushSetListAttrs<Prev> {
13989    fn drop(&mut self) {
13990        if let Some(prev) = &mut self.prev {
13991            if let Some(header_offset) = &self.header_offset {
13992                finalize_nested_header(prev.as_rec_mut(), *header_offset);
13993            }
13994        }
13995    }
13996}
13997pub struct PushSetelemAttrs<Prev: Rec> {
13998    pub(crate) prev: Option<Prev>,
13999    pub(crate) header_offset: Option<usize>,
14000}
14001impl<Prev: Rec> Rec for PushSetelemAttrs<Prev> {
14002    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14003        self.prev.as_mut().unwrap().as_rec_mut()
14004    }
14005    fn as_rec(&self) -> &Vec<u8> {
14006        self.prev.as_ref().unwrap().as_rec()
14007    }
14008}
14009impl<Prev: Rec> PushSetelemAttrs<Prev> {
14010    pub fn new(prev: Prev) -> Self {
14011        Self {
14012            prev: Some(prev),
14013            header_offset: None,
14014        }
14015    }
14016    pub fn end_nested(mut self) -> Prev {
14017        let mut prev = self.prev.take().unwrap();
14018        if let Some(header_offset) = &self.header_offset {
14019            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14020        }
14021        prev
14022    }
14023    #[doc = "key value"]
14024    pub fn nested_key(mut self) -> PushDataAttrs<Self> {
14025        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
14026        PushDataAttrs {
14027            prev: Some(self),
14028            header_offset: Some(header_offset),
14029        }
14030    }
14031    #[doc = "data value of mapping"]
14032    pub fn nested_data(mut self) -> PushDataAttrs<Self> {
14033        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
14034        PushDataAttrs {
14035            prev: Some(self),
14036            header_offset: Some(header_offset),
14037        }
14038    }
14039    #[doc = "bitmask of nft\\_set\\_elem\\_flags"]
14040    pub fn push_flags(mut self, value: &[u8]) -> Self {
14041        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
14042        self.as_rec_mut().extend(value);
14043        self
14044    }
14045    #[doc = "timeout value"]
14046    pub fn push_timeout(mut self, value: u64) -> Self {
14047        push_header(self.as_rec_mut(), 4u16, 8 as u16);
14048        self.as_rec_mut().extend(value.to_ne_bytes());
14049        self
14050    }
14051    #[doc = "expiration time"]
14052    pub fn push_expiration(mut self, value: u64) -> Self {
14053        push_header(self.as_rec_mut(), 5u16, 8 as u16);
14054        self.as_rec_mut().extend(value.to_ne_bytes());
14055        self
14056    }
14057    #[doc = "user data"]
14058    pub fn push_userdata(mut self, value: &[u8]) -> Self {
14059        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
14060        self.as_rec_mut().extend(value);
14061        self
14062    }
14063    #[doc = "expression"]
14064    pub fn nested_expr(mut self) -> PushExprAttrs<Self> {
14065        let header_offset = push_nested_header(self.as_rec_mut(), 7u16);
14066        PushExprAttrs {
14067            prev: Some(self),
14068            header_offset: Some(header_offset),
14069        }
14070    }
14071    #[doc = "stateful object reference"]
14072    pub fn push_objref(mut self, value: &CStr) -> Self {
14073        push_header(
14074            self.as_rec_mut(),
14075            8u16,
14076            value.to_bytes_with_nul().len() as u16,
14077        );
14078        self.as_rec_mut().extend(value.to_bytes_with_nul());
14079        self
14080    }
14081    #[doc = "stateful object reference"]
14082    pub fn push_objref_bytes(mut self, value: &[u8]) -> Self {
14083        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
14084        self.as_rec_mut().extend(value);
14085        self.as_rec_mut().push(0);
14086        self
14087    }
14088    #[doc = "closing key value"]
14089    pub fn nested_key_end(mut self) -> PushDataAttrs<Self> {
14090        let header_offset = push_nested_header(self.as_rec_mut(), 9u16);
14091        PushDataAttrs {
14092            prev: Some(self),
14093            header_offset: Some(header_offset),
14094        }
14095    }
14096    #[doc = "list of expressions"]
14097    pub fn nested_expressions(mut self) -> PushExprListAttrs<Self> {
14098        let header_offset = push_nested_header(self.as_rec_mut(), 10u16);
14099        PushExprListAttrs {
14100            prev: Some(self),
14101            header_offset: Some(header_offset),
14102        }
14103    }
14104}
14105impl<Prev: Rec> Drop for PushSetelemAttrs<Prev> {
14106    fn drop(&mut self) {
14107        if let Some(prev) = &mut self.prev {
14108            if let Some(header_offset) = &self.header_offset {
14109                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14110            }
14111        }
14112    }
14113}
14114pub struct PushSetelemListElemAttrs<Prev: Rec> {
14115    pub(crate) prev: Option<Prev>,
14116    pub(crate) header_offset: Option<usize>,
14117}
14118impl<Prev: Rec> Rec for PushSetelemListElemAttrs<Prev> {
14119    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14120        self.prev.as_mut().unwrap().as_rec_mut()
14121    }
14122    fn as_rec(&self) -> &Vec<u8> {
14123        self.prev.as_ref().unwrap().as_rec()
14124    }
14125}
14126impl<Prev: Rec> PushSetelemListElemAttrs<Prev> {
14127    pub fn new(prev: Prev) -> Self {
14128        Self {
14129            prev: Some(prev),
14130            header_offset: None,
14131        }
14132    }
14133    pub fn end_nested(mut self) -> Prev {
14134        let mut prev = self.prev.take().unwrap();
14135        if let Some(header_offset) = &self.header_offset {
14136            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14137        }
14138        prev
14139    }
14140    #[doc = "Attribute may repeat multiple times (treat it as array)"]
14141    pub fn nested_elem(mut self) -> PushSetelemAttrs<Self> {
14142        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
14143        PushSetelemAttrs {
14144            prev: Some(self),
14145            header_offset: Some(header_offset),
14146        }
14147    }
14148}
14149impl<Prev: Rec> Drop for PushSetelemListElemAttrs<Prev> {
14150    fn drop(&mut self) {
14151        if let Some(prev) = &mut self.prev {
14152            if let Some(header_offset) = &self.header_offset {
14153                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14154            }
14155        }
14156    }
14157}
14158pub struct PushSetelemListAttrs<Prev: Rec> {
14159    pub(crate) prev: Option<Prev>,
14160    pub(crate) header_offset: Option<usize>,
14161}
14162impl<Prev: Rec> Rec for PushSetelemListAttrs<Prev> {
14163    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14164        self.prev.as_mut().unwrap().as_rec_mut()
14165    }
14166    fn as_rec(&self) -> &Vec<u8> {
14167        self.prev.as_ref().unwrap().as_rec()
14168    }
14169}
14170impl<Prev: Rec> PushSetelemListAttrs<Prev> {
14171    pub fn new(prev: Prev) -> Self {
14172        Self {
14173            prev: Some(prev),
14174            header_offset: None,
14175        }
14176    }
14177    pub fn end_nested(mut self) -> Prev {
14178        let mut prev = self.prev.take().unwrap();
14179        if let Some(header_offset) = &self.header_offset {
14180            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14181        }
14182        prev
14183    }
14184    pub fn push_table(mut self, value: &CStr) -> Self {
14185        push_header(
14186            self.as_rec_mut(),
14187            1u16,
14188            value.to_bytes_with_nul().len() as u16,
14189        );
14190        self.as_rec_mut().extend(value.to_bytes_with_nul());
14191        self
14192    }
14193    pub fn push_table_bytes(mut self, value: &[u8]) -> Self {
14194        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
14195        self.as_rec_mut().extend(value);
14196        self.as_rec_mut().push(0);
14197        self
14198    }
14199    pub fn push_set(mut self, value: &CStr) -> Self {
14200        push_header(
14201            self.as_rec_mut(),
14202            2u16,
14203            value.to_bytes_with_nul().len() as u16,
14204        );
14205        self.as_rec_mut().extend(value.to_bytes_with_nul());
14206        self
14207    }
14208    pub fn push_set_bytes(mut self, value: &[u8]) -> Self {
14209        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
14210        self.as_rec_mut().extend(value);
14211        self.as_rec_mut().push(0);
14212        self
14213    }
14214    pub fn nested_elements(mut self) -> PushSetelemListElemAttrs<Self> {
14215        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
14216        PushSetelemListElemAttrs {
14217            prev: Some(self),
14218            header_offset: Some(header_offset),
14219        }
14220    }
14221    pub fn push_set_id(mut self, value: u32) -> Self {
14222        push_header(self.as_rec_mut(), 4u16, 4 as u16);
14223        self.as_rec_mut().extend(value.to_ne_bytes());
14224        self
14225    }
14226}
14227impl<Prev: Rec> Drop for PushSetelemListAttrs<Prev> {
14228    fn drop(&mut self) {
14229        if let Some(prev) = &mut self.prev {
14230            if let Some(header_offset) = &self.header_offset {
14231                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14232            }
14233        }
14234    }
14235}
14236pub struct PushGenAttrs<Prev: Rec> {
14237    pub(crate) prev: Option<Prev>,
14238    pub(crate) header_offset: Option<usize>,
14239}
14240impl<Prev: Rec> Rec for PushGenAttrs<Prev> {
14241    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14242        self.prev.as_mut().unwrap().as_rec_mut()
14243    }
14244    fn as_rec(&self) -> &Vec<u8> {
14245        self.prev.as_ref().unwrap().as_rec()
14246    }
14247}
14248impl<Prev: Rec> PushGenAttrs<Prev> {
14249    pub fn new(prev: Prev) -> Self {
14250        Self {
14251            prev: Some(prev),
14252            header_offset: None,
14253        }
14254    }
14255    pub fn end_nested(mut self) -> Prev {
14256        let mut prev = self.prev.take().unwrap();
14257        if let Some(header_offset) = &self.header_offset {
14258            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14259        }
14260        prev
14261    }
14262    #[doc = "ruleset generation id"]
14263    pub fn push_id(mut self, value: u32) -> Self {
14264        push_header(self.as_rec_mut(), 1u16, 4 as u16);
14265        self.as_rec_mut().extend(value.to_be_bytes());
14266        self
14267    }
14268    pub fn push_proc_pid(mut self, value: u32) -> Self {
14269        push_header(self.as_rec_mut(), 2u16, 4 as u16);
14270        self.as_rec_mut().extend(value.to_be_bytes());
14271        self
14272    }
14273    pub fn push_proc_name(mut self, value: &CStr) -> Self {
14274        push_header(
14275            self.as_rec_mut(),
14276            3u16,
14277            value.to_bytes_with_nul().len() as u16,
14278        );
14279        self.as_rec_mut().extend(value.to_bytes_with_nul());
14280        self
14281    }
14282    pub fn push_proc_name_bytes(mut self, value: &[u8]) -> Self {
14283        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
14284        self.as_rec_mut().extend(value);
14285        self.as_rec_mut().push(0);
14286        self
14287    }
14288}
14289impl<Prev: Rec> Drop for PushGenAttrs<Prev> {
14290    fn drop(&mut self) {
14291        if let Some(prev) = &mut self.prev {
14292            if let Some(header_offset) = &self.header_offset {
14293                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14294            }
14295        }
14296    }
14297}
14298pub struct PushObjAttrs<Prev: Rec> {
14299    pub(crate) prev: Option<Prev>,
14300    pub(crate) header_offset: Option<usize>,
14301}
14302impl<Prev: Rec> Rec for PushObjAttrs<Prev> {
14303    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14304        self.prev.as_mut().unwrap().as_rec_mut()
14305    }
14306    fn as_rec(&self) -> &Vec<u8> {
14307        self.prev.as_ref().unwrap().as_rec()
14308    }
14309}
14310impl<Prev: Rec> PushObjAttrs<Prev> {
14311    pub fn new(prev: Prev) -> Self {
14312        Self {
14313            prev: Some(prev),
14314            header_offset: None,
14315        }
14316    }
14317    pub fn end_nested(mut self) -> Prev {
14318        let mut prev = self.prev.take().unwrap();
14319        if let Some(header_offset) = &self.header_offset {
14320            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14321        }
14322        prev
14323    }
14324    #[doc = "name of the table containing the expression"]
14325    pub fn push_table(mut self, value: &CStr) -> Self {
14326        push_header(
14327            self.as_rec_mut(),
14328            1u16,
14329            value.to_bytes_with_nul().len() as u16,
14330        );
14331        self.as_rec_mut().extend(value.to_bytes_with_nul());
14332        self
14333    }
14334    #[doc = "name of the table containing the expression"]
14335    pub fn push_table_bytes(mut self, value: &[u8]) -> Self {
14336        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
14337        self.as_rec_mut().extend(value);
14338        self.as_rec_mut().push(0);
14339        self
14340    }
14341    #[doc = "name of this expression type"]
14342    pub fn push_name(mut self, value: &CStr) -> Self {
14343        push_header(
14344            self.as_rec_mut(),
14345            2u16,
14346            value.to_bytes_with_nul().len() as u16,
14347        );
14348        self.as_rec_mut().extend(value.to_bytes_with_nul());
14349        self
14350    }
14351    #[doc = "name of this expression type"]
14352    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
14353        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
14354        self.as_rec_mut().extend(value);
14355        self.as_rec_mut().push(0);
14356        self
14357    }
14358    #[doc = "stateful object type\nAssociated type: [`ObjectType`] (enum)"]
14359    pub fn push_type(mut self, value: u32) -> Self {
14360        push_header(self.as_rec_mut(), 3u16, 4 as u16);
14361        self.as_rec_mut().extend(value.to_be_bytes());
14362        self
14363    }
14364    #[doc = "stateful object data"]
14365    #[doc = "Selector attribute is inserted automatically."]
14366    #[doc = "At most one sub-message attribute is expected per attribute set."]
14367    pub fn nested_data_counter(mut self) -> PushCounterAttrs<PushDummy<Prev>> {
14368        self = self.push_type(ObjectType::Counter as u32);
14369        let new_header_offset = push_nested_header(self.as_rec_mut(), 4u16);
14370        let dummy = PushDummy {
14371            prev: self.prev.take(),
14372            header_offset: self.header_offset.take(),
14373        };
14374        PushCounterAttrs {
14375            prev: Some(dummy),
14376            header_offset: Some(new_header_offset),
14377        }
14378    }
14379    #[doc = "Selector attribute is inserted automatically."]
14380    #[doc = "At most one sub-message attribute is expected per attribute set."]
14381    pub fn nested_data_quota(mut self) -> PushQuotaAttrs<PushDummy<Prev>> {
14382        self = self.push_type(ObjectType::Quota as u32);
14383        let new_header_offset = push_nested_header(self.as_rec_mut(), 4u16);
14384        let dummy = PushDummy {
14385            prev: self.prev.take(),
14386            header_offset: self.header_offset.take(),
14387        };
14388        PushQuotaAttrs {
14389            prev: Some(dummy),
14390            header_offset: Some(new_header_offset),
14391        }
14392    }
14393    #[doc = "number of references to this expression"]
14394    pub fn push_use(mut self, value: u32) -> Self {
14395        push_header(self.as_rec_mut(), 5u16, 4 as u16);
14396        self.as_rec_mut().extend(value.to_be_bytes());
14397        self
14398    }
14399    #[doc = "object handle"]
14400    pub fn push_handle(mut self, value: u64) -> Self {
14401        push_header(self.as_rec_mut(), 6u16, 8 as u16);
14402        self.as_rec_mut().extend(value.to_be_bytes());
14403        self
14404    }
14405    pub fn push_pad(mut self, value: &[u8]) -> Self {
14406        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
14407        self.as_rec_mut().extend(value);
14408        self
14409    }
14410    #[doc = "user data"]
14411    pub fn push_userdata(mut self, value: &[u8]) -> Self {
14412        push_header(self.as_rec_mut(), 8u16, value.len() as u16);
14413        self.as_rec_mut().extend(value);
14414        self
14415    }
14416}
14417impl<Prev: Rec> Drop for PushObjAttrs<Prev> {
14418    fn drop(&mut self) {
14419        if let Some(prev) = &mut self.prev {
14420            if let Some(header_offset) = &self.header_offset {
14421                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14422            }
14423        }
14424    }
14425}
14426pub struct PushQuotaAttrs<Prev: Rec> {
14427    pub(crate) prev: Option<Prev>,
14428    pub(crate) header_offset: Option<usize>,
14429}
14430impl<Prev: Rec> Rec for PushQuotaAttrs<Prev> {
14431    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14432        self.prev.as_mut().unwrap().as_rec_mut()
14433    }
14434    fn as_rec(&self) -> &Vec<u8> {
14435        self.prev.as_ref().unwrap().as_rec()
14436    }
14437}
14438impl<Prev: Rec> PushQuotaAttrs<Prev> {
14439    pub fn new(prev: Prev) -> Self {
14440        Self {
14441            prev: Some(prev),
14442            header_offset: None,
14443        }
14444    }
14445    pub fn end_nested(mut self) -> Prev {
14446        let mut prev = self.prev.take().unwrap();
14447        if let Some(header_offset) = &self.header_offset {
14448            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14449        }
14450        prev
14451    }
14452    pub fn push_bytes(mut self, value: u64) -> Self {
14453        push_header(self.as_rec_mut(), 1u16, 8 as u16);
14454        self.as_rec_mut().extend(value.to_be_bytes());
14455        self
14456    }
14457    #[doc = "Associated type: [`QuotaFlags`] (enum)"]
14458    pub fn push_flags(mut self, value: u32) -> Self {
14459        push_header(self.as_rec_mut(), 2u16, 4 as u16);
14460        self.as_rec_mut().extend(value.to_be_bytes());
14461        self
14462    }
14463    pub fn push_pad(mut self, value: &[u8]) -> Self {
14464        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
14465        self.as_rec_mut().extend(value);
14466        self
14467    }
14468    pub fn push_consumed(mut self, value: u64) -> Self {
14469        push_header(self.as_rec_mut(), 4u16, 8 as u16);
14470        self.as_rec_mut().extend(value.to_be_bytes());
14471        self
14472    }
14473}
14474impl<Prev: Rec> Drop for PushQuotaAttrs<Prev> {
14475    fn drop(&mut self) {
14476        if let Some(prev) = &mut self.prev {
14477            if let Some(header_offset) = &self.header_offset {
14478                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14479            }
14480        }
14481    }
14482}
14483pub struct PushFlowtableAttrs<Prev: Rec> {
14484    pub(crate) prev: Option<Prev>,
14485    pub(crate) header_offset: Option<usize>,
14486}
14487impl<Prev: Rec> Rec for PushFlowtableAttrs<Prev> {
14488    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14489        self.prev.as_mut().unwrap().as_rec_mut()
14490    }
14491    fn as_rec(&self) -> &Vec<u8> {
14492        self.prev.as_ref().unwrap().as_rec()
14493    }
14494}
14495impl<Prev: Rec> PushFlowtableAttrs<Prev> {
14496    pub fn new(prev: Prev) -> Self {
14497        Self {
14498            prev: Some(prev),
14499            header_offset: None,
14500        }
14501    }
14502    pub fn end_nested(mut self) -> Prev {
14503        let mut prev = self.prev.take().unwrap();
14504        if let Some(header_offset) = &self.header_offset {
14505            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14506        }
14507        prev
14508    }
14509    pub fn push_table(mut self, value: &CStr) -> Self {
14510        push_header(
14511            self.as_rec_mut(),
14512            1u16,
14513            value.to_bytes_with_nul().len() as u16,
14514        );
14515        self.as_rec_mut().extend(value.to_bytes_with_nul());
14516        self
14517    }
14518    pub fn push_table_bytes(mut self, value: &[u8]) -> Self {
14519        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
14520        self.as_rec_mut().extend(value);
14521        self.as_rec_mut().push(0);
14522        self
14523    }
14524    pub fn push_name(mut self, value: &CStr) -> Self {
14525        push_header(
14526            self.as_rec_mut(),
14527            2u16,
14528            value.to_bytes_with_nul().len() as u16,
14529        );
14530        self.as_rec_mut().extend(value.to_bytes_with_nul());
14531        self
14532    }
14533    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
14534        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
14535        self.as_rec_mut().extend(value);
14536        self.as_rec_mut().push(0);
14537        self
14538    }
14539    pub fn nested_hook(mut self) -> PushFlowtableHookAttrs<Self> {
14540        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
14541        PushFlowtableHookAttrs {
14542            prev: Some(self),
14543            header_offset: Some(header_offset),
14544        }
14545    }
14546    pub fn push_use(mut self, value: u32) -> Self {
14547        push_header(self.as_rec_mut(), 4u16, 4 as u16);
14548        self.as_rec_mut().extend(value.to_be_bytes());
14549        self
14550    }
14551    pub fn push_handle(mut self, value: u64) -> Self {
14552        push_header(self.as_rec_mut(), 5u16, 8 as u16);
14553        self.as_rec_mut().extend(value.to_be_bytes());
14554        self
14555    }
14556    pub fn push_pad(mut self, value: &[u8]) -> Self {
14557        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
14558        self.as_rec_mut().extend(value);
14559        self
14560    }
14561    pub fn push_flags(mut self, value: u32) -> Self {
14562        push_header(self.as_rec_mut(), 7u16, 4 as u16);
14563        self.as_rec_mut().extend(value.to_be_bytes());
14564        self
14565    }
14566}
14567impl<Prev: Rec> Drop for PushFlowtableAttrs<Prev> {
14568    fn drop(&mut self) {
14569        if let Some(prev) = &mut self.prev {
14570            if let Some(header_offset) = &self.header_offset {
14571                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14572            }
14573        }
14574    }
14575}
14576pub struct PushFlowtableHookAttrs<Prev: Rec> {
14577    pub(crate) prev: Option<Prev>,
14578    pub(crate) header_offset: Option<usize>,
14579}
14580impl<Prev: Rec> Rec for PushFlowtableHookAttrs<Prev> {
14581    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14582        self.prev.as_mut().unwrap().as_rec_mut()
14583    }
14584    fn as_rec(&self) -> &Vec<u8> {
14585        self.prev.as_ref().unwrap().as_rec()
14586    }
14587}
14588impl<Prev: Rec> PushFlowtableHookAttrs<Prev> {
14589    pub fn new(prev: Prev) -> Self {
14590        Self {
14591            prev: Some(prev),
14592            header_offset: None,
14593        }
14594    }
14595    pub fn end_nested(mut self) -> Prev {
14596        let mut prev = self.prev.take().unwrap();
14597        if let Some(header_offset) = &self.header_offset {
14598            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14599        }
14600        prev
14601    }
14602    pub fn push_num(mut self, value: u32) -> Self {
14603        push_header(self.as_rec_mut(), 1u16, 4 as u16);
14604        self.as_rec_mut().extend(value.to_be_bytes());
14605        self
14606    }
14607    pub fn push_priority(mut self, value: u32) -> Self {
14608        push_header(self.as_rec_mut(), 2u16, 4 as u16);
14609        self.as_rec_mut().extend(value.to_be_bytes());
14610        self
14611    }
14612    pub fn nested_devs(mut self) -> PushHookDevAttrs<Self> {
14613        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
14614        PushHookDevAttrs {
14615            prev: Some(self),
14616            header_offset: Some(header_offset),
14617        }
14618    }
14619}
14620impl<Prev: Rec> Drop for PushFlowtableHookAttrs<Prev> {
14621    fn drop(&mut self) {
14622        if let Some(prev) = &mut self.prev {
14623            if let Some(header_offset) = &self.header_offset {
14624                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14625            }
14626        }
14627    }
14628}
14629pub struct PushExprBitwiseAttrs<Prev: Rec> {
14630    pub(crate) prev: Option<Prev>,
14631    pub(crate) header_offset: Option<usize>,
14632}
14633impl<Prev: Rec> Rec for PushExprBitwiseAttrs<Prev> {
14634    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14635        self.prev.as_mut().unwrap().as_rec_mut()
14636    }
14637    fn as_rec(&self) -> &Vec<u8> {
14638        self.prev.as_ref().unwrap().as_rec()
14639    }
14640}
14641impl<Prev: Rec> PushExprBitwiseAttrs<Prev> {
14642    pub fn new(prev: Prev) -> Self {
14643        Self {
14644            prev: Some(prev),
14645            header_offset: None,
14646        }
14647    }
14648    pub fn end_nested(mut self) -> Prev {
14649        let mut prev = self.prev.take().unwrap();
14650        if let Some(header_offset) = &self.header_offset {
14651            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14652        }
14653        prev
14654    }
14655    pub fn push_sreg(mut self, value: u32) -> Self {
14656        push_header(self.as_rec_mut(), 1u16, 4 as u16);
14657        self.as_rec_mut().extend(value.to_be_bytes());
14658        self
14659    }
14660    pub fn push_dreg(mut self, value: u32) -> Self {
14661        push_header(self.as_rec_mut(), 2u16, 4 as u16);
14662        self.as_rec_mut().extend(value.to_be_bytes());
14663        self
14664    }
14665    pub fn push_len(mut self, value: u32) -> Self {
14666        push_header(self.as_rec_mut(), 3u16, 4 as u16);
14667        self.as_rec_mut().extend(value.to_be_bytes());
14668        self
14669    }
14670    pub fn nested_mask(mut self) -> PushDataAttrs<Self> {
14671        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
14672        PushDataAttrs {
14673            prev: Some(self),
14674            header_offset: Some(header_offset),
14675        }
14676    }
14677    pub fn nested_xor(mut self) -> PushDataAttrs<Self> {
14678        let header_offset = push_nested_header(self.as_rec_mut(), 5u16);
14679        PushDataAttrs {
14680            prev: Some(self),
14681            header_offset: Some(header_offset),
14682        }
14683    }
14684    #[doc = "Associated type: [`BitwiseOps`] (enum)"]
14685    pub fn push_op(mut self, value: u32) -> Self {
14686        push_header(self.as_rec_mut(), 6u16, 4 as u16);
14687        self.as_rec_mut().extend(value.to_be_bytes());
14688        self
14689    }
14690    pub fn nested_data(mut self) -> PushDataAttrs<Self> {
14691        let header_offset = push_nested_header(self.as_rec_mut(), 7u16);
14692        PushDataAttrs {
14693            prev: Some(self),
14694            header_offset: Some(header_offset),
14695        }
14696    }
14697}
14698impl<Prev: Rec> Drop for PushExprBitwiseAttrs<Prev> {
14699    fn drop(&mut self) {
14700        if let Some(prev) = &mut self.prev {
14701            if let Some(header_offset) = &self.header_offset {
14702                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14703            }
14704        }
14705    }
14706}
14707pub struct PushExprCmpAttrs<Prev: Rec> {
14708    pub(crate) prev: Option<Prev>,
14709    pub(crate) header_offset: Option<usize>,
14710}
14711impl<Prev: Rec> Rec for PushExprCmpAttrs<Prev> {
14712    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14713        self.prev.as_mut().unwrap().as_rec_mut()
14714    }
14715    fn as_rec(&self) -> &Vec<u8> {
14716        self.prev.as_ref().unwrap().as_rec()
14717    }
14718}
14719impl<Prev: Rec> PushExprCmpAttrs<Prev> {
14720    pub fn new(prev: Prev) -> Self {
14721        Self {
14722            prev: Some(prev),
14723            header_offset: None,
14724        }
14725    }
14726    pub fn end_nested(mut self) -> Prev {
14727        let mut prev = self.prev.take().unwrap();
14728        if let Some(header_offset) = &self.header_offset {
14729            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14730        }
14731        prev
14732    }
14733    pub fn push_sreg(mut self, value: u32) -> Self {
14734        push_header(self.as_rec_mut(), 1u16, 4 as u16);
14735        self.as_rec_mut().extend(value.to_be_bytes());
14736        self
14737    }
14738    #[doc = "Associated type: [`CmpOps`] (enum)"]
14739    pub fn push_op(mut self, value: u32) -> Self {
14740        push_header(self.as_rec_mut(), 2u16, 4 as u16);
14741        self.as_rec_mut().extend(value.to_be_bytes());
14742        self
14743    }
14744    pub fn nested_data(mut self) -> PushDataAttrs<Self> {
14745        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
14746        PushDataAttrs {
14747            prev: Some(self),
14748            header_offset: Some(header_offset),
14749        }
14750    }
14751}
14752impl<Prev: Rec> Drop for PushExprCmpAttrs<Prev> {
14753    fn drop(&mut self) {
14754        if let Some(prev) = &mut self.prev {
14755            if let Some(header_offset) = &self.header_offset {
14756                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14757            }
14758        }
14759    }
14760}
14761pub struct PushDataAttrs<Prev: Rec> {
14762    pub(crate) prev: Option<Prev>,
14763    pub(crate) header_offset: Option<usize>,
14764}
14765impl<Prev: Rec> Rec for PushDataAttrs<Prev> {
14766    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14767        self.prev.as_mut().unwrap().as_rec_mut()
14768    }
14769    fn as_rec(&self) -> &Vec<u8> {
14770        self.prev.as_ref().unwrap().as_rec()
14771    }
14772}
14773impl<Prev: Rec> PushDataAttrs<Prev> {
14774    pub fn new(prev: Prev) -> Self {
14775        Self {
14776            prev: Some(prev),
14777            header_offset: None,
14778        }
14779    }
14780    pub fn end_nested(mut self) -> Prev {
14781        let mut prev = self.prev.take().unwrap();
14782        if let Some(header_offset) = &self.header_offset {
14783            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14784        }
14785        prev
14786    }
14787    pub fn push_value(mut self, value: &[u8]) -> Self {
14788        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
14789        self.as_rec_mut().extend(value);
14790        self
14791    }
14792    pub fn nested_verdict(mut self) -> PushVerdictAttrs<Self> {
14793        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
14794        PushVerdictAttrs {
14795            prev: Some(self),
14796            header_offset: Some(header_offset),
14797        }
14798    }
14799}
14800impl<Prev: Rec> Drop for PushDataAttrs<Prev> {
14801    fn drop(&mut self) {
14802        if let Some(prev) = &mut self.prev {
14803            if let Some(header_offset) = &self.header_offset {
14804                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14805            }
14806        }
14807    }
14808}
14809pub struct PushVerdictAttrs<Prev: Rec> {
14810    pub(crate) prev: Option<Prev>,
14811    pub(crate) header_offset: Option<usize>,
14812}
14813impl<Prev: Rec> Rec for PushVerdictAttrs<Prev> {
14814    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14815        self.prev.as_mut().unwrap().as_rec_mut()
14816    }
14817    fn as_rec(&self) -> &Vec<u8> {
14818        self.prev.as_ref().unwrap().as_rec()
14819    }
14820}
14821impl<Prev: Rec> PushVerdictAttrs<Prev> {
14822    pub fn new(prev: Prev) -> Self {
14823        Self {
14824            prev: Some(prev),
14825            header_offset: None,
14826        }
14827    }
14828    pub fn end_nested(mut self) -> Prev {
14829        let mut prev = self.prev.take().unwrap();
14830        if let Some(header_offset) = &self.header_offset {
14831            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14832        }
14833        prev
14834    }
14835    #[doc = "nf\\_tables verdict\nAssociated type: [`VerdictCode`] (enum)"]
14836    pub fn push_code(mut self, value: u32) -> Self {
14837        push_header(self.as_rec_mut(), 1u16, 4 as u16);
14838        self.as_rec_mut().extend(value.to_be_bytes());
14839        self
14840    }
14841    #[doc = "jump target chain name"]
14842    pub fn push_chain(mut self, value: &CStr) -> Self {
14843        push_header(
14844            self.as_rec_mut(),
14845            2u16,
14846            value.to_bytes_with_nul().len() as u16,
14847        );
14848        self.as_rec_mut().extend(value.to_bytes_with_nul());
14849        self
14850    }
14851    #[doc = "jump target chain name"]
14852    pub fn push_chain_bytes(mut self, value: &[u8]) -> Self {
14853        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
14854        self.as_rec_mut().extend(value);
14855        self.as_rec_mut().push(0);
14856        self
14857    }
14858    #[doc = "jump target chain ID"]
14859    pub fn push_chain_id(mut self, value: u32) -> Self {
14860        push_header(self.as_rec_mut(), 3u16, 4 as u16);
14861        self.as_rec_mut().extend(value.to_be_bytes());
14862        self
14863    }
14864}
14865impl<Prev: Rec> Drop for PushVerdictAttrs<Prev> {
14866    fn drop(&mut self) {
14867        if let Some(prev) = &mut self.prev {
14868            if let Some(header_offset) = &self.header_offset {
14869                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14870            }
14871        }
14872    }
14873}
14874pub struct PushExprCounterAttrs<Prev: Rec> {
14875    pub(crate) prev: Option<Prev>,
14876    pub(crate) header_offset: Option<usize>,
14877}
14878impl<Prev: Rec> Rec for PushExprCounterAttrs<Prev> {
14879    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14880        self.prev.as_mut().unwrap().as_rec_mut()
14881    }
14882    fn as_rec(&self) -> &Vec<u8> {
14883        self.prev.as_ref().unwrap().as_rec()
14884    }
14885}
14886impl<Prev: Rec> PushExprCounterAttrs<Prev> {
14887    pub fn new(prev: Prev) -> Self {
14888        Self {
14889            prev: Some(prev),
14890            header_offset: None,
14891        }
14892    }
14893    pub fn end_nested(mut self) -> Prev {
14894        let mut prev = self.prev.take().unwrap();
14895        if let Some(header_offset) = &self.header_offset {
14896            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14897        }
14898        prev
14899    }
14900    #[doc = "Number of bytes"]
14901    pub fn push_bytes(mut self, value: u64) -> Self {
14902        push_header(self.as_rec_mut(), 1u16, 8 as u16);
14903        self.as_rec_mut().extend(value.to_be_bytes());
14904        self
14905    }
14906    #[doc = "Number of packets"]
14907    pub fn push_packets(mut self, value: u64) -> Self {
14908        push_header(self.as_rec_mut(), 2u16, 8 as u16);
14909        self.as_rec_mut().extend(value.to_be_bytes());
14910        self
14911    }
14912    pub fn push_pad(mut self, value: &[u8]) -> Self {
14913        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
14914        self.as_rec_mut().extend(value);
14915        self
14916    }
14917}
14918impl<Prev: Rec> Drop for PushExprCounterAttrs<Prev> {
14919    fn drop(&mut self) {
14920        if let Some(prev) = &mut self.prev {
14921            if let Some(header_offset) = &self.header_offset {
14922                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14923            }
14924        }
14925    }
14926}
14927pub struct PushExprFibAttrs<Prev: Rec> {
14928    pub(crate) prev: Option<Prev>,
14929    pub(crate) header_offset: Option<usize>,
14930}
14931impl<Prev: Rec> Rec for PushExprFibAttrs<Prev> {
14932    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14933        self.prev.as_mut().unwrap().as_rec_mut()
14934    }
14935    fn as_rec(&self) -> &Vec<u8> {
14936        self.prev.as_ref().unwrap().as_rec()
14937    }
14938}
14939impl<Prev: Rec> PushExprFibAttrs<Prev> {
14940    pub fn new(prev: Prev) -> Self {
14941        Self {
14942            prev: Some(prev),
14943            header_offset: None,
14944        }
14945    }
14946    pub fn end_nested(mut self) -> Prev {
14947        let mut prev = self.prev.take().unwrap();
14948        if let Some(header_offset) = &self.header_offset {
14949            finalize_nested_header(prev.as_rec_mut(), *header_offset);
14950        }
14951        prev
14952    }
14953    pub fn push_dreg(mut self, value: u32) -> Self {
14954        push_header(self.as_rec_mut(), 1u16, 4 as u16);
14955        self.as_rec_mut().extend(value.to_be_bytes());
14956        self
14957    }
14958    #[doc = "Associated type: [`FibResult`] (enum)"]
14959    pub fn push_result(mut self, value: u32) -> Self {
14960        push_header(self.as_rec_mut(), 2u16, 4 as u16);
14961        self.as_rec_mut().extend(value.to_be_bytes());
14962        self
14963    }
14964    #[doc = "Associated type: [`FibFlags`] (enum)"]
14965    pub fn push_flags(mut self, value: u32) -> Self {
14966        push_header(self.as_rec_mut(), 3u16, 4 as u16);
14967        self.as_rec_mut().extend(value.to_be_bytes());
14968        self
14969    }
14970}
14971impl<Prev: Rec> Drop for PushExprFibAttrs<Prev> {
14972    fn drop(&mut self) {
14973        if let Some(prev) = &mut self.prev {
14974            if let Some(header_offset) = &self.header_offset {
14975                finalize_nested_header(prev.as_rec_mut(), *header_offset);
14976            }
14977        }
14978    }
14979}
14980pub struct PushExprCtAttrs<Prev: Rec> {
14981    pub(crate) prev: Option<Prev>,
14982    pub(crate) header_offset: Option<usize>,
14983}
14984impl<Prev: Rec> Rec for PushExprCtAttrs<Prev> {
14985    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
14986        self.prev.as_mut().unwrap().as_rec_mut()
14987    }
14988    fn as_rec(&self) -> &Vec<u8> {
14989        self.prev.as_ref().unwrap().as_rec()
14990    }
14991}
14992impl<Prev: Rec> PushExprCtAttrs<Prev> {
14993    pub fn new(prev: Prev) -> Self {
14994        Self {
14995            prev: Some(prev),
14996            header_offset: None,
14997        }
14998    }
14999    pub fn end_nested(mut self) -> Prev {
15000        let mut prev = self.prev.take().unwrap();
15001        if let Some(header_offset) = &self.header_offset {
15002            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15003        }
15004        prev
15005    }
15006    pub fn push_dreg(mut self, value: u32) -> Self {
15007        push_header(self.as_rec_mut(), 1u16, 4 as u16);
15008        self.as_rec_mut().extend(value.to_be_bytes());
15009        self
15010    }
15011    #[doc = "Associated type: [`CtKeys`] (enum)"]
15012    pub fn push_key(mut self, value: u32) -> Self {
15013        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15014        self.as_rec_mut().extend(value.to_be_bytes());
15015        self
15016    }
15017    #[doc = "Associated type: [`CtDirection`] (enum)"]
15018    pub fn push_direction(mut self, value: u8) -> Self {
15019        push_header(self.as_rec_mut(), 3u16, 1 as u16);
15020        self.as_rec_mut().extend(value.to_ne_bytes());
15021        self
15022    }
15023    pub fn push_sreg(mut self, value: u32) -> Self {
15024        push_header(self.as_rec_mut(), 4u16, 4 as u16);
15025        self.as_rec_mut().extend(value.to_be_bytes());
15026        self
15027    }
15028}
15029impl<Prev: Rec> Drop for PushExprCtAttrs<Prev> {
15030    fn drop(&mut self) {
15031        if let Some(prev) = &mut self.prev {
15032            if let Some(header_offset) = &self.header_offset {
15033                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15034            }
15035        }
15036    }
15037}
15038pub struct PushExprFlowOffloadAttrs<Prev: Rec> {
15039    pub(crate) prev: Option<Prev>,
15040    pub(crate) header_offset: Option<usize>,
15041}
15042impl<Prev: Rec> Rec for PushExprFlowOffloadAttrs<Prev> {
15043    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15044        self.prev.as_mut().unwrap().as_rec_mut()
15045    }
15046    fn as_rec(&self) -> &Vec<u8> {
15047        self.prev.as_ref().unwrap().as_rec()
15048    }
15049}
15050impl<Prev: Rec> PushExprFlowOffloadAttrs<Prev> {
15051    pub fn new(prev: Prev) -> Self {
15052        Self {
15053            prev: Some(prev),
15054            header_offset: None,
15055        }
15056    }
15057    pub fn end_nested(mut self) -> Prev {
15058        let mut prev = self.prev.take().unwrap();
15059        if let Some(header_offset) = &self.header_offset {
15060            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15061        }
15062        prev
15063    }
15064    #[doc = "Flow offload table name"]
15065    pub fn push_name(mut self, value: &CStr) -> Self {
15066        push_header(
15067            self.as_rec_mut(),
15068            1u16,
15069            value.to_bytes_with_nul().len() as u16,
15070        );
15071        self.as_rec_mut().extend(value.to_bytes_with_nul());
15072        self
15073    }
15074    #[doc = "Flow offload table name"]
15075    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
15076        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
15077        self.as_rec_mut().extend(value);
15078        self.as_rec_mut().push(0);
15079        self
15080    }
15081}
15082impl<Prev: Rec> Drop for PushExprFlowOffloadAttrs<Prev> {
15083    fn drop(&mut self) {
15084        if let Some(prev) = &mut self.prev {
15085            if let Some(header_offset) = &self.header_offset {
15086                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15087            }
15088        }
15089    }
15090}
15091pub struct PushExprImmediateAttrs<Prev: Rec> {
15092    pub(crate) prev: Option<Prev>,
15093    pub(crate) header_offset: Option<usize>,
15094}
15095impl<Prev: Rec> Rec for PushExprImmediateAttrs<Prev> {
15096    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15097        self.prev.as_mut().unwrap().as_rec_mut()
15098    }
15099    fn as_rec(&self) -> &Vec<u8> {
15100        self.prev.as_ref().unwrap().as_rec()
15101    }
15102}
15103impl<Prev: Rec> PushExprImmediateAttrs<Prev> {
15104    pub fn new(prev: Prev) -> Self {
15105        Self {
15106            prev: Some(prev),
15107            header_offset: None,
15108        }
15109    }
15110    pub fn end_nested(mut self) -> Prev {
15111        let mut prev = self.prev.take().unwrap();
15112        if let Some(header_offset) = &self.header_offset {
15113            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15114        }
15115        prev
15116    }
15117    pub fn push_dreg(mut self, value: u32) -> Self {
15118        push_header(self.as_rec_mut(), 1u16, 4 as u16);
15119        self.as_rec_mut().extend(value.to_be_bytes());
15120        self
15121    }
15122    pub fn nested_data(mut self) -> PushDataAttrs<Self> {
15123        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
15124        PushDataAttrs {
15125            prev: Some(self),
15126            header_offset: Some(header_offset),
15127        }
15128    }
15129}
15130impl<Prev: Rec> Drop for PushExprImmediateAttrs<Prev> {
15131    fn drop(&mut self) {
15132        if let Some(prev) = &mut self.prev {
15133            if let Some(header_offset) = &self.header_offset {
15134                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15135            }
15136        }
15137    }
15138}
15139pub struct PushExprLookupAttrs<Prev: Rec> {
15140    pub(crate) prev: Option<Prev>,
15141    pub(crate) header_offset: Option<usize>,
15142}
15143impl<Prev: Rec> Rec for PushExprLookupAttrs<Prev> {
15144    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15145        self.prev.as_mut().unwrap().as_rec_mut()
15146    }
15147    fn as_rec(&self) -> &Vec<u8> {
15148        self.prev.as_ref().unwrap().as_rec()
15149    }
15150}
15151impl<Prev: Rec> PushExprLookupAttrs<Prev> {
15152    pub fn new(prev: Prev) -> Self {
15153        Self {
15154            prev: Some(prev),
15155            header_offset: None,
15156        }
15157    }
15158    pub fn end_nested(mut self) -> Prev {
15159        let mut prev = self.prev.take().unwrap();
15160        if let Some(header_offset) = &self.header_offset {
15161            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15162        }
15163        prev
15164    }
15165    #[doc = "Name of set to use"]
15166    pub fn push_set(mut self, value: &CStr) -> Self {
15167        push_header(
15168            self.as_rec_mut(),
15169            1u16,
15170            value.to_bytes_with_nul().len() as u16,
15171        );
15172        self.as_rec_mut().extend(value.to_bytes_with_nul());
15173        self
15174    }
15175    #[doc = "Name of set to use"]
15176    pub fn push_set_bytes(mut self, value: &[u8]) -> Self {
15177        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
15178        self.as_rec_mut().extend(value);
15179        self.as_rec_mut().push(0);
15180        self
15181    }
15182    #[doc = "ID of set to use"]
15183    pub fn push_set_id(mut self, value: u32) -> Self {
15184        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15185        self.as_rec_mut().extend(value.to_be_bytes());
15186        self
15187    }
15188    pub fn push_sreg(mut self, value: u32) -> Self {
15189        push_header(self.as_rec_mut(), 3u16, 4 as u16);
15190        self.as_rec_mut().extend(value.to_be_bytes());
15191        self
15192    }
15193    pub fn push_dreg(mut self, value: u32) -> Self {
15194        push_header(self.as_rec_mut(), 4u16, 4 as u16);
15195        self.as_rec_mut().extend(value.to_be_bytes());
15196        self
15197    }
15198    #[doc = "Associated type: [`LookupFlags`] (enum)"]
15199    pub fn push_flags(mut self, value: u32) -> Self {
15200        push_header(self.as_rec_mut(), 5u16, 4 as u16);
15201        self.as_rec_mut().extend(value.to_be_bytes());
15202        self
15203    }
15204}
15205impl<Prev: Rec> Drop for PushExprLookupAttrs<Prev> {
15206    fn drop(&mut self) {
15207        if let Some(prev) = &mut self.prev {
15208            if let Some(header_offset) = &self.header_offset {
15209                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15210            }
15211        }
15212    }
15213}
15214pub struct PushExprMasqAttrs<Prev: Rec> {
15215    pub(crate) prev: Option<Prev>,
15216    pub(crate) header_offset: Option<usize>,
15217}
15218impl<Prev: Rec> Rec for PushExprMasqAttrs<Prev> {
15219    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15220        self.prev.as_mut().unwrap().as_rec_mut()
15221    }
15222    fn as_rec(&self) -> &Vec<u8> {
15223        self.prev.as_ref().unwrap().as_rec()
15224    }
15225}
15226impl<Prev: Rec> PushExprMasqAttrs<Prev> {
15227    pub fn new(prev: Prev) -> Self {
15228        Self {
15229            prev: Some(prev),
15230            header_offset: None,
15231        }
15232    }
15233    pub fn end_nested(mut self) -> Prev {
15234        let mut prev = self.prev.take().unwrap();
15235        if let Some(header_offset) = &self.header_offset {
15236            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15237        }
15238        prev
15239    }
15240    #[doc = "Associated type: [`NatRangeFlags`] (1 bit per enumeration)"]
15241    pub fn push_flags(mut self, value: u32) -> Self {
15242        push_header(self.as_rec_mut(), 1u16, 4 as u16);
15243        self.as_rec_mut().extend(value.to_be_bytes());
15244        self
15245    }
15246    #[doc = "Associated type: [`Registers`] (enum)"]
15247    pub fn push_reg_proto_min(mut self, value: u32) -> Self {
15248        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15249        self.as_rec_mut().extend(value.to_be_bytes());
15250        self
15251    }
15252    #[doc = "Associated type: [`Registers`] (enum)"]
15253    pub fn push_reg_proto_max(mut self, value: u32) -> Self {
15254        push_header(self.as_rec_mut(), 3u16, 4 as u16);
15255        self.as_rec_mut().extend(value.to_be_bytes());
15256        self
15257    }
15258}
15259impl<Prev: Rec> Drop for PushExprMasqAttrs<Prev> {
15260    fn drop(&mut self) {
15261        if let Some(prev) = &mut self.prev {
15262            if let Some(header_offset) = &self.header_offset {
15263                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15264            }
15265        }
15266    }
15267}
15268pub struct PushExprMetaAttrs<Prev: Rec> {
15269    pub(crate) prev: Option<Prev>,
15270    pub(crate) header_offset: Option<usize>,
15271}
15272impl<Prev: Rec> Rec for PushExprMetaAttrs<Prev> {
15273    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15274        self.prev.as_mut().unwrap().as_rec_mut()
15275    }
15276    fn as_rec(&self) -> &Vec<u8> {
15277        self.prev.as_ref().unwrap().as_rec()
15278    }
15279}
15280impl<Prev: Rec> PushExprMetaAttrs<Prev> {
15281    pub fn new(prev: Prev) -> Self {
15282        Self {
15283            prev: Some(prev),
15284            header_offset: None,
15285        }
15286    }
15287    pub fn end_nested(mut self) -> Prev {
15288        let mut prev = self.prev.take().unwrap();
15289        if let Some(header_offset) = &self.header_offset {
15290            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15291        }
15292        prev
15293    }
15294    pub fn push_dreg(mut self, value: u32) -> Self {
15295        push_header(self.as_rec_mut(), 1u16, 4 as u16);
15296        self.as_rec_mut().extend(value.to_be_bytes());
15297        self
15298    }
15299    #[doc = "Associated type: [`MetaKeys`] (enum)"]
15300    pub fn push_key(mut self, value: u32) -> Self {
15301        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15302        self.as_rec_mut().extend(value.to_be_bytes());
15303        self
15304    }
15305    pub fn push_sreg(mut self, value: u32) -> Self {
15306        push_header(self.as_rec_mut(), 3u16, 4 as u16);
15307        self.as_rec_mut().extend(value.to_be_bytes());
15308        self
15309    }
15310}
15311impl<Prev: Rec> Drop for PushExprMetaAttrs<Prev> {
15312    fn drop(&mut self) {
15313        if let Some(prev) = &mut self.prev {
15314            if let Some(header_offset) = &self.header_offset {
15315                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15316            }
15317        }
15318    }
15319}
15320pub struct PushExprNatAttrs<Prev: Rec> {
15321    pub(crate) prev: Option<Prev>,
15322    pub(crate) header_offset: Option<usize>,
15323}
15324impl<Prev: Rec> Rec for PushExprNatAttrs<Prev> {
15325    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15326        self.prev.as_mut().unwrap().as_rec_mut()
15327    }
15328    fn as_rec(&self) -> &Vec<u8> {
15329        self.prev.as_ref().unwrap().as_rec()
15330    }
15331}
15332impl<Prev: Rec> PushExprNatAttrs<Prev> {
15333    pub fn new(prev: Prev) -> Self {
15334        Self {
15335            prev: Some(prev),
15336            header_offset: None,
15337        }
15338    }
15339    pub fn end_nested(mut self) -> Prev {
15340        let mut prev = self.prev.take().unwrap();
15341        if let Some(header_offset) = &self.header_offset {
15342            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15343        }
15344        prev
15345    }
15346    pub fn push_type(mut self, value: u32) -> Self {
15347        push_header(self.as_rec_mut(), 1u16, 4 as u16);
15348        self.as_rec_mut().extend(value.to_be_bytes());
15349        self
15350    }
15351    pub fn push_family(mut self, value: u32) -> Self {
15352        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15353        self.as_rec_mut().extend(value.to_be_bytes());
15354        self
15355    }
15356    pub fn push_reg_addr_min(mut self, value: u32) -> Self {
15357        push_header(self.as_rec_mut(), 3u16, 4 as u16);
15358        self.as_rec_mut().extend(value.to_be_bytes());
15359        self
15360    }
15361    pub fn push_reg_addr_max(mut self, value: u32) -> Self {
15362        push_header(self.as_rec_mut(), 4u16, 4 as u16);
15363        self.as_rec_mut().extend(value.to_be_bytes());
15364        self
15365    }
15366    pub fn push_reg_proto_min(mut self, value: u32) -> Self {
15367        push_header(self.as_rec_mut(), 5u16, 4 as u16);
15368        self.as_rec_mut().extend(value.to_be_bytes());
15369        self
15370    }
15371    pub fn push_reg_proto_max(mut self, value: u32) -> Self {
15372        push_header(self.as_rec_mut(), 6u16, 4 as u16);
15373        self.as_rec_mut().extend(value.to_be_bytes());
15374        self
15375    }
15376    #[doc = "Associated type: [`NatRangeFlags`] (1 bit per enumeration)"]
15377    pub fn push_flags(mut self, value: u32) -> Self {
15378        push_header(self.as_rec_mut(), 7u16, 4 as u16);
15379        self.as_rec_mut().extend(value.to_be_bytes());
15380        self
15381    }
15382}
15383impl<Prev: Rec> Drop for PushExprNatAttrs<Prev> {
15384    fn drop(&mut self) {
15385        if let Some(prev) = &mut self.prev {
15386            if let Some(header_offset) = &self.header_offset {
15387                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15388            }
15389        }
15390    }
15391}
15392pub struct PushExprPayloadAttrs<Prev: Rec> {
15393    pub(crate) prev: Option<Prev>,
15394    pub(crate) header_offset: Option<usize>,
15395}
15396impl<Prev: Rec> Rec for PushExprPayloadAttrs<Prev> {
15397    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15398        self.prev.as_mut().unwrap().as_rec_mut()
15399    }
15400    fn as_rec(&self) -> &Vec<u8> {
15401        self.prev.as_ref().unwrap().as_rec()
15402    }
15403}
15404impl<Prev: Rec> PushExprPayloadAttrs<Prev> {
15405    pub fn new(prev: Prev) -> Self {
15406        Self {
15407            prev: Some(prev),
15408            header_offset: None,
15409        }
15410    }
15411    pub fn end_nested(mut self) -> Prev {
15412        let mut prev = self.prev.take().unwrap();
15413        if let Some(header_offset) = &self.header_offset {
15414            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15415        }
15416        prev
15417    }
15418    #[doc = "destination register to load data into\nAssociated type: [`Registers`] (enum)"]
15419    pub fn push_dreg(mut self, value: u32) -> Self {
15420        push_header(self.as_rec_mut(), 1u16, 4 as u16);
15421        self.as_rec_mut().extend(value.to_be_bytes());
15422        self
15423    }
15424    #[doc = "payload base\nAssociated type: [`PayloadBase`] (enum)"]
15425    pub fn push_base(mut self, value: u32) -> Self {
15426        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15427        self.as_rec_mut().extend(value.to_be_bytes());
15428        self
15429    }
15430    #[doc = "payload offset relative to base"]
15431    pub fn push_offset(mut self, value: u32) -> Self {
15432        push_header(self.as_rec_mut(), 3u16, 4 as u16);
15433        self.as_rec_mut().extend(value.to_be_bytes());
15434        self
15435    }
15436    #[doc = "payload length"]
15437    pub fn push_len(mut self, value: u32) -> Self {
15438        push_header(self.as_rec_mut(), 4u16, 4 as u16);
15439        self.as_rec_mut().extend(value.to_be_bytes());
15440        self
15441    }
15442    #[doc = "source register to load data from\nAssociated type: [`Registers`] (enum)"]
15443    pub fn push_sreg(mut self, value: u32) -> Self {
15444        push_header(self.as_rec_mut(), 5u16, 4 as u16);
15445        self.as_rec_mut().extend(value.to_be_bytes());
15446        self
15447    }
15448    #[doc = "checksum type"]
15449    pub fn push_csum_type(mut self, value: u32) -> Self {
15450        push_header(self.as_rec_mut(), 6u16, 4 as u16);
15451        self.as_rec_mut().extend(value.to_be_bytes());
15452        self
15453    }
15454    #[doc = "checksum offset relative to base"]
15455    pub fn push_csum_offset(mut self, value: u32) -> Self {
15456        push_header(self.as_rec_mut(), 7u16, 4 as u16);
15457        self.as_rec_mut().extend(value.to_be_bytes());
15458        self
15459    }
15460    #[doc = "checksum flags"]
15461    pub fn push_csum_flags(mut self, value: u32) -> Self {
15462        push_header(self.as_rec_mut(), 8u16, 4 as u16);
15463        self.as_rec_mut().extend(value.to_be_bytes());
15464        self
15465    }
15466}
15467impl<Prev: Rec> Drop for PushExprPayloadAttrs<Prev> {
15468    fn drop(&mut self) {
15469        if let Some(prev) = &mut self.prev {
15470            if let Some(header_offset) = &self.header_offset {
15471                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15472            }
15473        }
15474    }
15475}
15476pub struct PushExprRejectAttrs<Prev: Rec> {
15477    pub(crate) prev: Option<Prev>,
15478    pub(crate) header_offset: Option<usize>,
15479}
15480impl<Prev: Rec> Rec for PushExprRejectAttrs<Prev> {
15481    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15482        self.prev.as_mut().unwrap().as_rec_mut()
15483    }
15484    fn as_rec(&self) -> &Vec<u8> {
15485        self.prev.as_ref().unwrap().as_rec()
15486    }
15487}
15488impl<Prev: Rec> PushExprRejectAttrs<Prev> {
15489    pub fn new(prev: Prev) -> Self {
15490        Self {
15491            prev: Some(prev),
15492            header_offset: None,
15493        }
15494    }
15495    pub fn end_nested(mut self) -> Prev {
15496        let mut prev = self.prev.take().unwrap();
15497        if let Some(header_offset) = &self.header_offset {
15498            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15499        }
15500        prev
15501    }
15502    #[doc = "Associated type: [`RejectTypes`] (enum)"]
15503    pub fn push_type(mut self, value: u32) -> Self {
15504        push_header(self.as_rec_mut(), 1u16, 4 as u16);
15505        self.as_rec_mut().extend(value.to_be_bytes());
15506        self
15507    }
15508    pub fn push_icmp_code(mut self, value: u8) -> Self {
15509        push_header(self.as_rec_mut(), 2u16, 1 as u16);
15510        self.as_rec_mut().extend(value.to_ne_bytes());
15511        self
15512    }
15513}
15514impl<Prev: Rec> Drop for PushExprRejectAttrs<Prev> {
15515    fn drop(&mut self) {
15516        if let Some(prev) = &mut self.prev {
15517            if let Some(header_offset) = &self.header_offset {
15518                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15519            }
15520        }
15521    }
15522}
15523pub struct PushExprTargetAttrs<Prev: Rec> {
15524    pub(crate) prev: Option<Prev>,
15525    pub(crate) header_offset: Option<usize>,
15526}
15527impl<Prev: Rec> Rec for PushExprTargetAttrs<Prev> {
15528    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15529        self.prev.as_mut().unwrap().as_rec_mut()
15530    }
15531    fn as_rec(&self) -> &Vec<u8> {
15532        self.prev.as_ref().unwrap().as_rec()
15533    }
15534}
15535impl<Prev: Rec> PushExprTargetAttrs<Prev> {
15536    pub fn new(prev: Prev) -> Self {
15537        Self {
15538            prev: Some(prev),
15539            header_offset: None,
15540        }
15541    }
15542    pub fn end_nested(mut self) -> Prev {
15543        let mut prev = self.prev.take().unwrap();
15544        if let Some(header_offset) = &self.header_offset {
15545            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15546        }
15547        prev
15548    }
15549    pub fn push_name(mut self, value: &CStr) -> Self {
15550        push_header(
15551            self.as_rec_mut(),
15552            1u16,
15553            value.to_bytes_with_nul().len() as u16,
15554        );
15555        self.as_rec_mut().extend(value.to_bytes_with_nul());
15556        self
15557    }
15558    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
15559        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
15560        self.as_rec_mut().extend(value);
15561        self.as_rec_mut().push(0);
15562        self
15563    }
15564    pub fn push_rev(mut self, value: u32) -> Self {
15565        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15566        self.as_rec_mut().extend(value.to_be_bytes());
15567        self
15568    }
15569    pub fn push_info(mut self, value: &[u8]) -> Self {
15570        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
15571        self.as_rec_mut().extend(value);
15572        self
15573    }
15574}
15575impl<Prev: Rec> Drop for PushExprTargetAttrs<Prev> {
15576    fn drop(&mut self) {
15577        if let Some(prev) = &mut self.prev {
15578            if let Some(header_offset) = &self.header_offset {
15579                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15580            }
15581        }
15582    }
15583}
15584pub struct PushExprTproxyAttrs<Prev: Rec> {
15585    pub(crate) prev: Option<Prev>,
15586    pub(crate) header_offset: Option<usize>,
15587}
15588impl<Prev: Rec> Rec for PushExprTproxyAttrs<Prev> {
15589    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15590        self.prev.as_mut().unwrap().as_rec_mut()
15591    }
15592    fn as_rec(&self) -> &Vec<u8> {
15593        self.prev.as_ref().unwrap().as_rec()
15594    }
15595}
15596impl<Prev: Rec> PushExprTproxyAttrs<Prev> {
15597    pub fn new(prev: Prev) -> Self {
15598        Self {
15599            prev: Some(prev),
15600            header_offset: None,
15601        }
15602    }
15603    pub fn end_nested(mut self) -> Prev {
15604        let mut prev = self.prev.take().unwrap();
15605        if let Some(header_offset) = &self.header_offset {
15606            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15607        }
15608        prev
15609    }
15610    pub fn push_family(mut self, value: u32) -> Self {
15611        push_header(self.as_rec_mut(), 1u16, 4 as u16);
15612        self.as_rec_mut().extend(value.to_be_bytes());
15613        self
15614    }
15615    pub fn push_reg_addr(mut self, value: u32) -> Self {
15616        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15617        self.as_rec_mut().extend(value.to_be_bytes());
15618        self
15619    }
15620    pub fn push_reg_port(mut self, value: u32) -> Self {
15621        push_header(self.as_rec_mut(), 3u16, 4 as u16);
15622        self.as_rec_mut().extend(value.to_be_bytes());
15623        self
15624    }
15625}
15626impl<Prev: Rec> Drop for PushExprTproxyAttrs<Prev> {
15627    fn drop(&mut self) {
15628        if let Some(prev) = &mut self.prev {
15629            if let Some(header_offset) = &self.header_offset {
15630                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15631            }
15632        }
15633    }
15634}
15635pub struct PushExprObjrefAttrs<Prev: Rec> {
15636    pub(crate) prev: Option<Prev>,
15637    pub(crate) header_offset: Option<usize>,
15638}
15639impl<Prev: Rec> Rec for PushExprObjrefAttrs<Prev> {
15640    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15641        self.prev.as_mut().unwrap().as_rec_mut()
15642    }
15643    fn as_rec(&self) -> &Vec<u8> {
15644        self.prev.as_ref().unwrap().as_rec()
15645    }
15646}
15647impl<Prev: Rec> PushExprObjrefAttrs<Prev> {
15648    pub fn new(prev: Prev) -> Self {
15649        Self {
15650            prev: Some(prev),
15651            header_offset: None,
15652        }
15653    }
15654    pub fn end_nested(mut self) -> Prev {
15655        let mut prev = self.prev.take().unwrap();
15656        if let Some(header_offset) = &self.header_offset {
15657            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15658        }
15659        prev
15660    }
15661    pub fn push_imm_type(mut self, value: u32) -> Self {
15662        push_header(self.as_rec_mut(), 1u16, 4 as u16);
15663        self.as_rec_mut().extend(value.to_be_bytes());
15664        self
15665    }
15666    #[doc = "object name"]
15667    pub fn push_imm_name(mut self, value: &CStr) -> Self {
15668        push_header(
15669            self.as_rec_mut(),
15670            2u16,
15671            value.to_bytes_with_nul().len() as u16,
15672        );
15673        self.as_rec_mut().extend(value.to_bytes_with_nul());
15674        self
15675    }
15676    #[doc = "object name"]
15677    pub fn push_imm_name_bytes(mut self, value: &[u8]) -> Self {
15678        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
15679        self.as_rec_mut().extend(value);
15680        self.as_rec_mut().push(0);
15681        self
15682    }
15683    pub fn push_set_sreg(mut self, value: u32) -> Self {
15684        push_header(self.as_rec_mut(), 3u16, 4 as u16);
15685        self.as_rec_mut().extend(value.to_be_bytes());
15686        self
15687    }
15688    #[doc = "name of object map"]
15689    pub fn push_set_name(mut self, value: &CStr) -> Self {
15690        push_header(
15691            self.as_rec_mut(),
15692            4u16,
15693            value.to_bytes_with_nul().len() as u16,
15694        );
15695        self.as_rec_mut().extend(value.to_bytes_with_nul());
15696        self
15697    }
15698    #[doc = "name of object map"]
15699    pub fn push_set_name_bytes(mut self, value: &[u8]) -> Self {
15700        push_header(self.as_rec_mut(), 4u16, (value.len() + 1) as u16);
15701        self.as_rec_mut().extend(value);
15702        self.as_rec_mut().push(0);
15703        self
15704    }
15705    #[doc = "id of object map"]
15706    pub fn push_set_id(mut self, value: u32) -> Self {
15707        push_header(self.as_rec_mut(), 5u16, 4 as u16);
15708        self.as_rec_mut().extend(value.to_be_bytes());
15709        self
15710    }
15711}
15712impl<Prev: Rec> Drop for PushExprObjrefAttrs<Prev> {
15713    fn drop(&mut self) {
15714        if let Some(prev) = &mut self.prev {
15715            if let Some(header_offset) = &self.header_offset {
15716                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15717            }
15718        }
15719    }
15720}
15721pub struct PushCompatTargetAttrs<Prev: Rec> {
15722    pub(crate) prev: Option<Prev>,
15723    pub(crate) header_offset: Option<usize>,
15724}
15725impl<Prev: Rec> Rec for PushCompatTargetAttrs<Prev> {
15726    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15727        self.prev.as_mut().unwrap().as_rec_mut()
15728    }
15729    fn as_rec(&self) -> &Vec<u8> {
15730        self.prev.as_ref().unwrap().as_rec()
15731    }
15732}
15733impl<Prev: Rec> PushCompatTargetAttrs<Prev> {
15734    pub fn new(prev: Prev) -> Self {
15735        Self {
15736            prev: Some(prev),
15737            header_offset: None,
15738        }
15739    }
15740    pub fn end_nested(mut self) -> Prev {
15741        let mut prev = self.prev.take().unwrap();
15742        if let Some(header_offset) = &self.header_offset {
15743            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15744        }
15745        prev
15746    }
15747    pub fn push_name(mut self, value: &CStr) -> Self {
15748        push_header(
15749            self.as_rec_mut(),
15750            1u16,
15751            value.to_bytes_with_nul().len() as u16,
15752        );
15753        self.as_rec_mut().extend(value.to_bytes_with_nul());
15754        self
15755    }
15756    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
15757        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
15758        self.as_rec_mut().extend(value);
15759        self.as_rec_mut().push(0);
15760        self
15761    }
15762    pub fn push_rev(mut self, value: u32) -> Self {
15763        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15764        self.as_rec_mut().extend(value.to_be_bytes());
15765        self
15766    }
15767    pub fn push_info(mut self, value: &[u8]) -> Self {
15768        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
15769        self.as_rec_mut().extend(value);
15770        self
15771    }
15772}
15773impl<Prev: Rec> Drop for PushCompatTargetAttrs<Prev> {
15774    fn drop(&mut self) {
15775        if let Some(prev) = &mut self.prev {
15776            if let Some(header_offset) = &self.header_offset {
15777                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15778            }
15779        }
15780    }
15781}
15782pub struct PushCompatMatchAttrs<Prev: Rec> {
15783    pub(crate) prev: Option<Prev>,
15784    pub(crate) header_offset: Option<usize>,
15785}
15786impl<Prev: Rec> Rec for PushCompatMatchAttrs<Prev> {
15787    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15788        self.prev.as_mut().unwrap().as_rec_mut()
15789    }
15790    fn as_rec(&self) -> &Vec<u8> {
15791        self.prev.as_ref().unwrap().as_rec()
15792    }
15793}
15794impl<Prev: Rec> PushCompatMatchAttrs<Prev> {
15795    pub fn new(prev: Prev) -> Self {
15796        Self {
15797            prev: Some(prev),
15798            header_offset: None,
15799        }
15800    }
15801    pub fn end_nested(mut self) -> Prev {
15802        let mut prev = self.prev.take().unwrap();
15803        if let Some(header_offset) = &self.header_offset {
15804            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15805        }
15806        prev
15807    }
15808    pub fn push_name(mut self, value: &CStr) -> Self {
15809        push_header(
15810            self.as_rec_mut(),
15811            1u16,
15812            value.to_bytes_with_nul().len() as u16,
15813        );
15814        self.as_rec_mut().extend(value.to_bytes_with_nul());
15815        self
15816    }
15817    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
15818        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
15819        self.as_rec_mut().extend(value);
15820        self.as_rec_mut().push(0);
15821        self
15822    }
15823    pub fn push_rev(mut self, value: u32) -> Self {
15824        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15825        self.as_rec_mut().extend(value.to_be_bytes());
15826        self
15827    }
15828    pub fn push_info(mut self, value: &[u8]) -> Self {
15829        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
15830        self.as_rec_mut().extend(value);
15831        self
15832    }
15833}
15834impl<Prev: Rec> Drop for PushCompatMatchAttrs<Prev> {
15835    fn drop(&mut self) {
15836        if let Some(prev) = &mut self.prev {
15837            if let Some(header_offset) = &self.header_offset {
15838                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15839            }
15840        }
15841    }
15842}
15843pub struct PushCompatAttrs<Prev: Rec> {
15844    pub(crate) prev: Option<Prev>,
15845    pub(crate) header_offset: Option<usize>,
15846}
15847impl<Prev: Rec> Rec for PushCompatAttrs<Prev> {
15848    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
15849        self.prev.as_mut().unwrap().as_rec_mut()
15850    }
15851    fn as_rec(&self) -> &Vec<u8> {
15852        self.prev.as_ref().unwrap().as_rec()
15853    }
15854}
15855impl<Prev: Rec> PushCompatAttrs<Prev> {
15856    pub fn new(prev: Prev) -> Self {
15857        Self {
15858            prev: Some(prev),
15859            header_offset: None,
15860        }
15861    }
15862    pub fn end_nested(mut self) -> Prev {
15863        let mut prev = self.prev.take().unwrap();
15864        if let Some(header_offset) = &self.header_offset {
15865            finalize_nested_header(prev.as_rec_mut(), *header_offset);
15866        }
15867        prev
15868    }
15869    pub fn push_name(mut self, value: &CStr) -> Self {
15870        push_header(
15871            self.as_rec_mut(),
15872            1u16,
15873            value.to_bytes_with_nul().len() as u16,
15874        );
15875        self.as_rec_mut().extend(value.to_bytes_with_nul());
15876        self
15877    }
15878    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
15879        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
15880        self.as_rec_mut().extend(value);
15881        self.as_rec_mut().push(0);
15882        self
15883    }
15884    pub fn push_rev(mut self, value: u32) -> Self {
15885        push_header(self.as_rec_mut(), 2u16, 4 as u16);
15886        self.as_rec_mut().extend(value.to_be_bytes());
15887        self
15888    }
15889    pub fn push_type(mut self, value: u32) -> Self {
15890        push_header(self.as_rec_mut(), 3u16, 4 as u16);
15891        self.as_rec_mut().extend(value.to_be_bytes());
15892        self
15893    }
15894}
15895impl<Prev: Rec> Drop for PushCompatAttrs<Prev> {
15896    fn drop(&mut self) {
15897        if let Some(prev) = &mut self.prev {
15898            if let Some(header_offset) = &self.header_offset {
15899                finalize_nested_header(prev.as_rec_mut(), *header_offset);
15900            }
15901        }
15902    }
15903}
15904#[doc = "Start a batch of operations\nRequest attributes:\n- [.push_genid()](PushBatchAttrs::push_genid)\n\nReply attributes:\n- [.get_genid()](IterableBatchAttrs::get_genid)\n"]
15905#[derive(Debug)]
15906pub struct OpBatchBeginDo<'r> {
15907    request: Request<'r>,
15908}
15909impl<'r> OpBatchBeginDo<'r> {
15910    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
15911        Self::write_header(request.buf_mut(), header);
15912        Self { request: request }
15913    }
15914    pub fn encode_request<'buf>(
15915        buf: &'buf mut Vec<u8>,
15916        header: &Nfgenmsg,
15917    ) -> PushBatchAttrs<&'buf mut Vec<u8>> {
15918        Self::write_header(buf, header);
15919        PushBatchAttrs::new(buf)
15920    }
15921    pub fn encode(&mut self) -> PushBatchAttrs<&mut Vec<u8>> {
15922        PushBatchAttrs::new(self.request.buf_mut())
15923    }
15924    pub fn into_encoder(self) -> PushBatchAttrs<RequestBuf<'r>> {
15925        PushBatchAttrs::new(self.request.buf)
15926    }
15927    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableBatchAttrs<'a>) {
15928        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
15929        (
15930            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
15931            IterableBatchAttrs::with_loc(attrs, buf.as_ptr() as usize),
15932        )
15933    }
15934    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
15935        prev.as_rec_mut().extend(header.as_slice());
15936    }
15937}
15938impl NetlinkRequest for OpBatchBeginDo<'_> {
15939    fn protocol(&self) -> Protocol {
15940        Protocol::Raw {
15941            protonum: 12u16,
15942            request_type: 16u16,
15943        }
15944    }
15945    fn flags(&self) -> u16 {
15946        self.request.flags
15947    }
15948    fn payload(&self) -> &[u8] {
15949        self.request.buf()
15950    }
15951    type ReplyType<'buf> = (Nfgenmsg, IterableBatchAttrs<'buf>);
15952    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
15953        Self::decode_request(buf)
15954    }
15955    fn lookup(
15956        buf: &[u8],
15957        offset: usize,
15958        missing_type: Option<u16>,
15959    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15960        Self::decode_request(buf)
15961            .1
15962            .lookup_attr(offset, missing_type)
15963    }
15964}
15965#[doc = "Finish a batch of operations\nRequest attributes:\n- [.push_genid()](PushBatchAttrs::push_genid)\n"]
15966#[derive(Debug)]
15967pub struct OpBatchEndDo<'r> {
15968    request: Request<'r>,
15969}
15970impl<'r> OpBatchEndDo<'r> {
15971    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
15972        Self::write_header(request.buf_mut(), header);
15973        Self { request: request }
15974    }
15975    pub fn encode_request<'buf>(
15976        buf: &'buf mut Vec<u8>,
15977        header: &Nfgenmsg,
15978    ) -> PushBatchAttrs<&'buf mut Vec<u8>> {
15979        Self::write_header(buf, header);
15980        PushBatchAttrs::new(buf)
15981    }
15982    pub fn encode(&mut self) -> PushBatchAttrs<&mut Vec<u8>> {
15983        PushBatchAttrs::new(self.request.buf_mut())
15984    }
15985    pub fn into_encoder(self) -> PushBatchAttrs<RequestBuf<'r>> {
15986        PushBatchAttrs::new(self.request.buf)
15987    }
15988    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableBatchAttrs<'a>) {
15989        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
15990        (
15991            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
15992            IterableBatchAttrs::with_loc(attrs, buf.as_ptr() as usize),
15993        )
15994    }
15995    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
15996        prev.as_rec_mut().extend(header.as_slice());
15997    }
15998}
15999impl NetlinkRequest for OpBatchEndDo<'_> {
16000    fn protocol(&self) -> Protocol {
16001        Protocol::Raw {
16002            protonum: 12u16,
16003            request_type: 17u16,
16004        }
16005    }
16006    fn flags(&self) -> u16 {
16007        self.request.flags
16008    }
16009    fn payload(&self) -> &[u8] {
16010        self.request.buf()
16011    }
16012    type ReplyType<'buf> = (Nfgenmsg, IterableBatchAttrs<'buf>);
16013    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16014        Self::decode_request(buf)
16015    }
16016    fn lookup(
16017        buf: &[u8],
16018        offset: usize,
16019        missing_type: Option<u16>,
16020    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16021        Self::decode_request(buf)
16022            .1
16023            .lookup_attr(offset, missing_type)
16024    }
16025}
16026#[doc = "Create a new table\\.\nRequest attributes:\n- [.push_name()](PushTableAttrs::push_name)\n- [.push_flags()](PushTableAttrs::push_flags)\n- [.push_userdata()](PushTableAttrs::push_userdata)\n"]
16027#[derive(Debug)]
16028pub struct OpNewtableDo<'r> {
16029    request: Request<'r>,
16030}
16031impl<'r> OpNewtableDo<'r> {
16032    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16033        Self::write_header(request.buf_mut(), header);
16034        Self { request: request }
16035    }
16036    pub fn encode_request<'buf>(
16037        buf: &'buf mut Vec<u8>,
16038        header: &Nfgenmsg,
16039    ) -> PushTableAttrs<&'buf mut Vec<u8>> {
16040        Self::write_header(buf, header);
16041        PushTableAttrs::new(buf)
16042    }
16043    pub fn encode(&mut self) -> PushTableAttrs<&mut Vec<u8>> {
16044        PushTableAttrs::new(self.request.buf_mut())
16045    }
16046    pub fn into_encoder(self) -> PushTableAttrs<RequestBuf<'r>> {
16047        PushTableAttrs::new(self.request.buf)
16048    }
16049    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableTableAttrs<'a>) {
16050        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16051        (
16052            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16053            IterableTableAttrs::with_loc(attrs, buf.as_ptr() as usize),
16054        )
16055    }
16056    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16057        prev.as_rec_mut().extend(header.as_slice());
16058    }
16059}
16060impl NetlinkRequest for OpNewtableDo<'_> {
16061    fn protocol(&self) -> Protocol {
16062        Protocol::Raw {
16063            protonum: 12u16,
16064            request_type: 2560u16,
16065        }
16066    }
16067    fn flags(&self) -> u16 {
16068        self.request.flags
16069    }
16070    fn payload(&self) -> &[u8] {
16071        self.request.buf()
16072    }
16073    type ReplyType<'buf> = (Nfgenmsg, IterableTableAttrs<'buf>);
16074    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16075        Self::decode_request(buf)
16076    }
16077    fn lookup(
16078        buf: &[u8],
16079        offset: usize,
16080        missing_type: Option<u16>,
16081    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16082        Self::decode_request(buf)
16083            .1
16084            .lookup_attr(offset, missing_type)
16085    }
16086}
16087#[doc = "Get / dump tables\\.\n\nReply attributes:\n- [.get_name()](IterableTableAttrs::get_name)\n- [.get_flags()](IterableTableAttrs::get_flags)\n- [.get_use()](IterableTableAttrs::get_use)\n- [.get_handle()](IterableTableAttrs::get_handle)\n- [.get_userdata()](IterableTableAttrs::get_userdata)\n- [.get_owner()](IterableTableAttrs::get_owner)\n"]
16088#[derive(Debug)]
16089pub struct OpGettableDump<'r> {
16090    request: Request<'r>,
16091}
16092impl<'r> OpGettableDump<'r> {
16093    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16094        Self::write_header(request.buf_mut(), header);
16095        Self {
16096            request: request.set_dump(),
16097        }
16098    }
16099    pub fn encode_request<'buf>(
16100        buf: &'buf mut Vec<u8>,
16101        header: &Nfgenmsg,
16102    ) -> PushTableAttrs<&'buf mut Vec<u8>> {
16103        Self::write_header(buf, header);
16104        PushTableAttrs::new(buf)
16105    }
16106    pub fn encode(&mut self) -> PushTableAttrs<&mut Vec<u8>> {
16107        PushTableAttrs::new(self.request.buf_mut())
16108    }
16109    pub fn into_encoder(self) -> PushTableAttrs<RequestBuf<'r>> {
16110        PushTableAttrs::new(self.request.buf)
16111    }
16112    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableTableAttrs<'a>) {
16113        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16114        (
16115            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16116            IterableTableAttrs::with_loc(attrs, buf.as_ptr() as usize),
16117        )
16118    }
16119    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16120        prev.as_rec_mut().extend(header.as_slice());
16121    }
16122}
16123impl NetlinkRequest for OpGettableDump<'_> {
16124    fn protocol(&self) -> Protocol {
16125        Protocol::Raw {
16126            protonum: 12u16,
16127            request_type: 2561u16,
16128        }
16129    }
16130    fn flags(&self) -> u16 {
16131        self.request.flags
16132    }
16133    fn payload(&self) -> &[u8] {
16134        self.request.buf()
16135    }
16136    type ReplyType<'buf> = (Nfgenmsg, IterableTableAttrs<'buf>);
16137    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16138        Self::decode_request(buf)
16139    }
16140    fn lookup(
16141        buf: &[u8],
16142        offset: usize,
16143        missing_type: Option<u16>,
16144    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16145        Self::decode_request(buf)
16146            .1
16147            .lookup_attr(offset, missing_type)
16148    }
16149}
16150#[doc = "Get / dump tables\\.\nRequest attributes:\n- [.push_name()](PushTableAttrs::push_name)\n\nReply attributes:\n- [.get_name()](IterableTableAttrs::get_name)\n- [.get_flags()](IterableTableAttrs::get_flags)\n- [.get_use()](IterableTableAttrs::get_use)\n- [.get_handle()](IterableTableAttrs::get_handle)\n- [.get_userdata()](IterableTableAttrs::get_userdata)\n- [.get_owner()](IterableTableAttrs::get_owner)\n"]
16151#[derive(Debug)]
16152pub struct OpGettableDo<'r> {
16153    request: Request<'r>,
16154}
16155impl<'r> OpGettableDo<'r> {
16156    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16157        Self::write_header(request.buf_mut(), header);
16158        Self { request: request }
16159    }
16160    pub fn encode_request<'buf>(
16161        buf: &'buf mut Vec<u8>,
16162        header: &Nfgenmsg,
16163    ) -> PushTableAttrs<&'buf mut Vec<u8>> {
16164        Self::write_header(buf, header);
16165        PushTableAttrs::new(buf)
16166    }
16167    pub fn encode(&mut self) -> PushTableAttrs<&mut Vec<u8>> {
16168        PushTableAttrs::new(self.request.buf_mut())
16169    }
16170    pub fn into_encoder(self) -> PushTableAttrs<RequestBuf<'r>> {
16171        PushTableAttrs::new(self.request.buf)
16172    }
16173    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableTableAttrs<'a>) {
16174        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16175        (
16176            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16177            IterableTableAttrs::with_loc(attrs, buf.as_ptr() as usize),
16178        )
16179    }
16180    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16181        prev.as_rec_mut().extend(header.as_slice());
16182    }
16183}
16184impl NetlinkRequest for OpGettableDo<'_> {
16185    fn protocol(&self) -> Protocol {
16186        Protocol::Raw {
16187            protonum: 12u16,
16188            request_type: 2561u16,
16189        }
16190    }
16191    fn flags(&self) -> u16 {
16192        self.request.flags
16193    }
16194    fn payload(&self) -> &[u8] {
16195        self.request.buf()
16196    }
16197    type ReplyType<'buf> = (Nfgenmsg, IterableTableAttrs<'buf>);
16198    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16199        Self::decode_request(buf)
16200    }
16201    fn lookup(
16202        buf: &[u8],
16203        offset: usize,
16204        missing_type: Option<u16>,
16205    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16206        Self::decode_request(buf)
16207            .1
16208            .lookup_attr(offset, missing_type)
16209    }
16210}
16211#[doc = "Delete an existing table\\.\nRequest attributes:\n- [.push_name()](PushTableAttrs::push_name)\n- [.push_handle()](PushTableAttrs::push_handle)\n"]
16212#[derive(Debug)]
16213pub struct OpDeltableDo<'r> {
16214    request: Request<'r>,
16215}
16216impl<'r> OpDeltableDo<'r> {
16217    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16218        Self::write_header(request.buf_mut(), header);
16219        Self { request: request }
16220    }
16221    pub fn encode_request<'buf>(
16222        buf: &'buf mut Vec<u8>,
16223        header: &Nfgenmsg,
16224    ) -> PushTableAttrs<&'buf mut Vec<u8>> {
16225        Self::write_header(buf, header);
16226        PushTableAttrs::new(buf)
16227    }
16228    pub fn encode(&mut self) -> PushTableAttrs<&mut Vec<u8>> {
16229        PushTableAttrs::new(self.request.buf_mut())
16230    }
16231    pub fn into_encoder(self) -> PushTableAttrs<RequestBuf<'r>> {
16232        PushTableAttrs::new(self.request.buf)
16233    }
16234    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableTableAttrs<'a>) {
16235        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16236        (
16237            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16238            IterableTableAttrs::with_loc(attrs, buf.as_ptr() as usize),
16239        )
16240    }
16241    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16242        prev.as_rec_mut().extend(header.as_slice());
16243    }
16244}
16245impl NetlinkRequest for OpDeltableDo<'_> {
16246    fn protocol(&self) -> Protocol {
16247        Protocol::Raw {
16248            protonum: 12u16,
16249            request_type: 2562u16,
16250        }
16251    }
16252    fn flags(&self) -> u16 {
16253        self.request.flags
16254    }
16255    fn payload(&self) -> &[u8] {
16256        self.request.buf()
16257    }
16258    type ReplyType<'buf> = (Nfgenmsg, IterableTableAttrs<'buf>);
16259    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16260        Self::decode_request(buf)
16261    }
16262    fn lookup(
16263        buf: &[u8],
16264        offset: usize,
16265        missing_type: Option<u16>,
16266    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16267        Self::decode_request(buf)
16268            .1
16269            .lookup_attr(offset, missing_type)
16270    }
16271}
16272#[doc = "Delete an existing table with destroy semantics (ignoring ENOENT\nerrors)\\.\n\nRequest attributes:\n- [.push_name()](PushTableAttrs::push_name)\n- [.push_handle()](PushTableAttrs::push_handle)\n"]
16273#[derive(Debug)]
16274pub struct OpDestroytableDo<'r> {
16275    request: Request<'r>,
16276}
16277impl<'r> OpDestroytableDo<'r> {
16278    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16279        Self::write_header(request.buf_mut(), header);
16280        Self { request: request }
16281    }
16282    pub fn encode_request<'buf>(
16283        buf: &'buf mut Vec<u8>,
16284        header: &Nfgenmsg,
16285    ) -> PushTableAttrs<&'buf mut Vec<u8>> {
16286        Self::write_header(buf, header);
16287        PushTableAttrs::new(buf)
16288    }
16289    pub fn encode(&mut self) -> PushTableAttrs<&mut Vec<u8>> {
16290        PushTableAttrs::new(self.request.buf_mut())
16291    }
16292    pub fn into_encoder(self) -> PushTableAttrs<RequestBuf<'r>> {
16293        PushTableAttrs::new(self.request.buf)
16294    }
16295    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableTableAttrs<'a>) {
16296        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16297        (
16298            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16299            IterableTableAttrs::with_loc(attrs, buf.as_ptr() as usize),
16300        )
16301    }
16302    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16303        prev.as_rec_mut().extend(header.as_slice());
16304    }
16305}
16306impl NetlinkRequest for OpDestroytableDo<'_> {
16307    fn protocol(&self) -> Protocol {
16308        Protocol::Raw {
16309            protonum: 12u16,
16310            request_type: 2586u16,
16311        }
16312    }
16313    fn flags(&self) -> u16 {
16314        self.request.flags
16315    }
16316    fn payload(&self) -> &[u8] {
16317        self.request.buf()
16318    }
16319    type ReplyType<'buf> = (Nfgenmsg, IterableTableAttrs<'buf>);
16320    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16321        Self::decode_request(buf)
16322    }
16323    fn lookup(
16324        buf: &[u8],
16325        offset: usize,
16326        missing_type: Option<u16>,
16327    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16328        Self::decode_request(buf)
16329            .1
16330            .lookup_attr(offset, missing_type)
16331    }
16332}
16333#[doc = "Create a new chain\\.\nRequest attributes:\n- [.push_table()](PushChainAttrs::push_table)\n- [.push_handle()](PushChainAttrs::push_handle)\n- [.push_name()](PushChainAttrs::push_name)\n- [.nested_hook()](PushChainAttrs::nested_hook)\n- [.push_policy()](PushChainAttrs::push_policy)\n- [.push_type()](PushChainAttrs::push_type)\n- [.nested_counters()](PushChainAttrs::nested_counters)\n- [.push_flags()](PushChainAttrs::push_flags)\n- [.push_userdata()](PushChainAttrs::push_userdata)\n"]
16334#[derive(Debug)]
16335pub struct OpNewchainDo<'r> {
16336    request: Request<'r>,
16337}
16338impl<'r> OpNewchainDo<'r> {
16339    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16340        Self::write_header(request.buf_mut(), header);
16341        Self { request: request }
16342    }
16343    pub fn encode_request<'buf>(
16344        buf: &'buf mut Vec<u8>,
16345        header: &Nfgenmsg,
16346    ) -> PushChainAttrs<&'buf mut Vec<u8>> {
16347        Self::write_header(buf, header);
16348        PushChainAttrs::new(buf)
16349    }
16350    pub fn encode(&mut self) -> PushChainAttrs<&mut Vec<u8>> {
16351        PushChainAttrs::new(self.request.buf_mut())
16352    }
16353    pub fn into_encoder(self) -> PushChainAttrs<RequestBuf<'r>> {
16354        PushChainAttrs::new(self.request.buf)
16355    }
16356    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableChainAttrs<'a>) {
16357        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16358        (
16359            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16360            IterableChainAttrs::with_loc(attrs, buf.as_ptr() as usize),
16361        )
16362    }
16363    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16364        prev.as_rec_mut().extend(header.as_slice());
16365    }
16366}
16367impl NetlinkRequest for OpNewchainDo<'_> {
16368    fn protocol(&self) -> Protocol {
16369        Protocol::Raw {
16370            protonum: 12u16,
16371            request_type: 2563u16,
16372        }
16373    }
16374    fn flags(&self) -> u16 {
16375        self.request.flags
16376    }
16377    fn payload(&self) -> &[u8] {
16378        self.request.buf()
16379    }
16380    type ReplyType<'buf> = (Nfgenmsg, IterableChainAttrs<'buf>);
16381    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16382        Self::decode_request(buf)
16383    }
16384    fn lookup(
16385        buf: &[u8],
16386        offset: usize,
16387        missing_type: Option<u16>,
16388    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16389        Self::decode_request(buf)
16390            .1
16391            .lookup_attr(offset, missing_type)
16392    }
16393}
16394#[doc = "Get / dump chains\\.\n\nReply attributes:\n- [.get_table()](IterableChainAttrs::get_table)\n- [.get_handle()](IterableChainAttrs::get_handle)\n- [.get_name()](IterableChainAttrs::get_name)\n- [.get_hook()](IterableChainAttrs::get_hook)\n- [.get_policy()](IterableChainAttrs::get_policy)\n- [.get_use()](IterableChainAttrs::get_use)\n- [.get_type()](IterableChainAttrs::get_type)\n- [.get_counters()](IterableChainAttrs::get_counters)\n- [.get_flags()](IterableChainAttrs::get_flags)\n- [.get_id()](IterableChainAttrs::get_id)\n- [.get_userdata()](IterableChainAttrs::get_userdata)\n"]
16395#[derive(Debug)]
16396pub struct OpGetchainDump<'r> {
16397    request: Request<'r>,
16398}
16399impl<'r> OpGetchainDump<'r> {
16400    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16401        Self::write_header(request.buf_mut(), header);
16402        Self {
16403            request: request.set_dump(),
16404        }
16405    }
16406    pub fn encode_request<'buf>(
16407        buf: &'buf mut Vec<u8>,
16408        header: &Nfgenmsg,
16409    ) -> PushChainAttrs<&'buf mut Vec<u8>> {
16410        Self::write_header(buf, header);
16411        PushChainAttrs::new(buf)
16412    }
16413    pub fn encode(&mut self) -> PushChainAttrs<&mut Vec<u8>> {
16414        PushChainAttrs::new(self.request.buf_mut())
16415    }
16416    pub fn into_encoder(self) -> PushChainAttrs<RequestBuf<'r>> {
16417        PushChainAttrs::new(self.request.buf)
16418    }
16419    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableChainAttrs<'a>) {
16420        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16421        (
16422            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16423            IterableChainAttrs::with_loc(attrs, buf.as_ptr() as usize),
16424        )
16425    }
16426    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16427        prev.as_rec_mut().extend(header.as_slice());
16428    }
16429}
16430impl NetlinkRequest for OpGetchainDump<'_> {
16431    fn protocol(&self) -> Protocol {
16432        Protocol::Raw {
16433            protonum: 12u16,
16434            request_type: 2564u16,
16435        }
16436    }
16437    fn flags(&self) -> u16 {
16438        self.request.flags
16439    }
16440    fn payload(&self) -> &[u8] {
16441        self.request.buf()
16442    }
16443    type ReplyType<'buf> = (Nfgenmsg, IterableChainAttrs<'buf>);
16444    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16445        Self::decode_request(buf)
16446    }
16447    fn lookup(
16448        buf: &[u8],
16449        offset: usize,
16450        missing_type: Option<u16>,
16451    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16452        Self::decode_request(buf)
16453            .1
16454            .lookup_attr(offset, missing_type)
16455    }
16456}
16457#[doc = "Get / dump chains\\.\nRequest attributes:\n- [.push_table()](PushChainAttrs::push_table)\n- [.push_name()](PushChainAttrs::push_name)\n\nReply attributes:\n- [.get_table()](IterableChainAttrs::get_table)\n- [.get_handle()](IterableChainAttrs::get_handle)\n- [.get_name()](IterableChainAttrs::get_name)\n- [.get_hook()](IterableChainAttrs::get_hook)\n- [.get_policy()](IterableChainAttrs::get_policy)\n- [.get_use()](IterableChainAttrs::get_use)\n- [.get_type()](IterableChainAttrs::get_type)\n- [.get_counters()](IterableChainAttrs::get_counters)\n- [.get_flags()](IterableChainAttrs::get_flags)\n- [.get_id()](IterableChainAttrs::get_id)\n- [.get_userdata()](IterableChainAttrs::get_userdata)\n"]
16458#[derive(Debug)]
16459pub struct OpGetchainDo<'r> {
16460    request: Request<'r>,
16461}
16462impl<'r> OpGetchainDo<'r> {
16463    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16464        Self::write_header(request.buf_mut(), header);
16465        Self { request: request }
16466    }
16467    pub fn encode_request<'buf>(
16468        buf: &'buf mut Vec<u8>,
16469        header: &Nfgenmsg,
16470    ) -> PushChainAttrs<&'buf mut Vec<u8>> {
16471        Self::write_header(buf, header);
16472        PushChainAttrs::new(buf)
16473    }
16474    pub fn encode(&mut self) -> PushChainAttrs<&mut Vec<u8>> {
16475        PushChainAttrs::new(self.request.buf_mut())
16476    }
16477    pub fn into_encoder(self) -> PushChainAttrs<RequestBuf<'r>> {
16478        PushChainAttrs::new(self.request.buf)
16479    }
16480    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableChainAttrs<'a>) {
16481        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16482        (
16483            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16484            IterableChainAttrs::with_loc(attrs, buf.as_ptr() as usize),
16485        )
16486    }
16487    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16488        prev.as_rec_mut().extend(header.as_slice());
16489    }
16490}
16491impl NetlinkRequest for OpGetchainDo<'_> {
16492    fn protocol(&self) -> Protocol {
16493        Protocol::Raw {
16494            protonum: 12u16,
16495            request_type: 2564u16,
16496        }
16497    }
16498    fn flags(&self) -> u16 {
16499        self.request.flags
16500    }
16501    fn payload(&self) -> &[u8] {
16502        self.request.buf()
16503    }
16504    type ReplyType<'buf> = (Nfgenmsg, IterableChainAttrs<'buf>);
16505    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16506        Self::decode_request(buf)
16507    }
16508    fn lookup(
16509        buf: &[u8],
16510        offset: usize,
16511        missing_type: Option<u16>,
16512    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16513        Self::decode_request(buf)
16514            .1
16515            .lookup_attr(offset, missing_type)
16516    }
16517}
16518#[doc = "Delete an existing chain\\.\nRequest attributes:\n- [.push_table()](PushChainAttrs::push_table)\n- [.push_handle()](PushChainAttrs::push_handle)\n- [.push_name()](PushChainAttrs::push_name)\n- [.nested_hook()](PushChainAttrs::nested_hook)\n"]
16519#[derive(Debug)]
16520pub struct OpDelchainDo<'r> {
16521    request: Request<'r>,
16522}
16523impl<'r> OpDelchainDo<'r> {
16524    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16525        Self::write_header(request.buf_mut(), header);
16526        Self { request: request }
16527    }
16528    pub fn encode_request<'buf>(
16529        buf: &'buf mut Vec<u8>,
16530        header: &Nfgenmsg,
16531    ) -> PushChainAttrs<&'buf mut Vec<u8>> {
16532        Self::write_header(buf, header);
16533        PushChainAttrs::new(buf)
16534    }
16535    pub fn encode(&mut self) -> PushChainAttrs<&mut Vec<u8>> {
16536        PushChainAttrs::new(self.request.buf_mut())
16537    }
16538    pub fn into_encoder(self) -> PushChainAttrs<RequestBuf<'r>> {
16539        PushChainAttrs::new(self.request.buf)
16540    }
16541    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableChainAttrs<'a>) {
16542        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16543        (
16544            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16545            IterableChainAttrs::with_loc(attrs, buf.as_ptr() as usize),
16546        )
16547    }
16548    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16549        prev.as_rec_mut().extend(header.as_slice());
16550    }
16551}
16552impl NetlinkRequest for OpDelchainDo<'_> {
16553    fn protocol(&self) -> Protocol {
16554        Protocol::Raw {
16555            protonum: 12u16,
16556            request_type: 2565u16,
16557        }
16558    }
16559    fn flags(&self) -> u16 {
16560        self.request.flags
16561    }
16562    fn payload(&self) -> &[u8] {
16563        self.request.buf()
16564    }
16565    type ReplyType<'buf> = (Nfgenmsg, IterableChainAttrs<'buf>);
16566    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16567        Self::decode_request(buf)
16568    }
16569    fn lookup(
16570        buf: &[u8],
16571        offset: usize,
16572        missing_type: Option<u16>,
16573    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16574        Self::decode_request(buf)
16575            .1
16576            .lookup_attr(offset, missing_type)
16577    }
16578}
16579#[doc = "Delete an existing chain with destroy semantics (ignoring ENOENT\nerrors)\\.\n\nRequest attributes:\n- [.push_table()](PushChainAttrs::push_table)\n- [.push_handle()](PushChainAttrs::push_handle)\n- [.push_name()](PushChainAttrs::push_name)\n- [.nested_hook()](PushChainAttrs::nested_hook)\n"]
16580#[derive(Debug)]
16581pub struct OpDestroychainDo<'r> {
16582    request: Request<'r>,
16583}
16584impl<'r> OpDestroychainDo<'r> {
16585    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16586        Self::write_header(request.buf_mut(), header);
16587        Self { request: request }
16588    }
16589    pub fn encode_request<'buf>(
16590        buf: &'buf mut Vec<u8>,
16591        header: &Nfgenmsg,
16592    ) -> PushChainAttrs<&'buf mut Vec<u8>> {
16593        Self::write_header(buf, header);
16594        PushChainAttrs::new(buf)
16595    }
16596    pub fn encode(&mut self) -> PushChainAttrs<&mut Vec<u8>> {
16597        PushChainAttrs::new(self.request.buf_mut())
16598    }
16599    pub fn into_encoder(self) -> PushChainAttrs<RequestBuf<'r>> {
16600        PushChainAttrs::new(self.request.buf)
16601    }
16602    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableChainAttrs<'a>) {
16603        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16604        (
16605            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16606            IterableChainAttrs::with_loc(attrs, buf.as_ptr() as usize),
16607        )
16608    }
16609    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16610        prev.as_rec_mut().extend(header.as_slice());
16611    }
16612}
16613impl NetlinkRequest for OpDestroychainDo<'_> {
16614    fn protocol(&self) -> Protocol {
16615        Protocol::Raw {
16616            protonum: 12u16,
16617            request_type: 2587u16,
16618        }
16619    }
16620    fn flags(&self) -> u16 {
16621        self.request.flags
16622    }
16623    fn payload(&self) -> &[u8] {
16624        self.request.buf()
16625    }
16626    type ReplyType<'buf> = (Nfgenmsg, IterableChainAttrs<'buf>);
16627    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16628        Self::decode_request(buf)
16629    }
16630    fn lookup(
16631        buf: &[u8],
16632        offset: usize,
16633        missing_type: Option<u16>,
16634    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16635        Self::decode_request(buf)
16636            .1
16637            .lookup_attr(offset, missing_type)
16638    }
16639}
16640#[doc = "Create a new rule\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n- [.nested_expressions()](PushRuleAttrs::nested_expressions)\n- [.nested_compat()](PushRuleAttrs::nested_compat)\n- [.push_position()](PushRuleAttrs::push_position)\n- [.push_userdata()](PushRuleAttrs::push_userdata)\n- [.push_position_id()](PushRuleAttrs::push_position_id)\n- [.push_chain_id()](PushRuleAttrs::push_chain_id)\n"]
16641#[derive(Debug)]
16642pub struct OpNewruleDo<'r> {
16643    request: Request<'r>,
16644}
16645impl<'r> OpNewruleDo<'r> {
16646    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16647        Self::write_header(request.buf_mut(), header);
16648        Self { request: request }
16649    }
16650    pub fn encode_request<'buf>(
16651        buf: &'buf mut Vec<u8>,
16652        header: &Nfgenmsg,
16653    ) -> PushRuleAttrs<&'buf mut Vec<u8>> {
16654        Self::write_header(buf, header);
16655        PushRuleAttrs::new(buf)
16656    }
16657    pub fn encode(&mut self) -> PushRuleAttrs<&mut Vec<u8>> {
16658        PushRuleAttrs::new(self.request.buf_mut())
16659    }
16660    pub fn into_encoder(self) -> PushRuleAttrs<RequestBuf<'r>> {
16661        PushRuleAttrs::new(self.request.buf)
16662    }
16663    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableRuleAttrs<'a>) {
16664        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16665        (
16666            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16667            IterableRuleAttrs::with_loc(attrs, buf.as_ptr() as usize),
16668        )
16669    }
16670    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16671        prev.as_rec_mut().extend(header.as_slice());
16672    }
16673}
16674impl NetlinkRequest for OpNewruleDo<'_> {
16675    fn protocol(&self) -> Protocol {
16676        Protocol::Raw {
16677            protonum: 12u16,
16678            request_type: 2566u16,
16679        }
16680    }
16681    fn flags(&self) -> u16 {
16682        self.request.flags
16683    }
16684    fn payload(&self) -> &[u8] {
16685        self.request.buf()
16686    }
16687    type ReplyType<'buf> = (Nfgenmsg, IterableRuleAttrs<'buf>);
16688    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16689        Self::decode_request(buf)
16690    }
16691    fn lookup(
16692        buf: &[u8],
16693        offset: usize,
16694        missing_type: Option<u16>,
16695    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16696        Self::decode_request(buf)
16697            .1
16698            .lookup_attr(offset, missing_type)
16699    }
16700}
16701#[doc = "Get / dump rules\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n\nReply attributes:\n- [.get_table()](IterableRuleAttrs::get_table)\n- [.get_chain()](IterableRuleAttrs::get_chain)\n- [.get_handle()](IterableRuleAttrs::get_handle)\n- [.get_expressions()](IterableRuleAttrs::get_expressions)\n- [.get_position()](IterableRuleAttrs::get_position)\n- [.get_userdata()](IterableRuleAttrs::get_userdata)\n"]
16702#[derive(Debug)]
16703pub struct OpGetruleDump<'r> {
16704    request: Request<'r>,
16705}
16706impl<'r> OpGetruleDump<'r> {
16707    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16708        Self::write_header(request.buf_mut(), header);
16709        Self {
16710            request: request.set_dump(),
16711        }
16712    }
16713    pub fn encode_request<'buf>(
16714        buf: &'buf mut Vec<u8>,
16715        header: &Nfgenmsg,
16716    ) -> PushRuleAttrs<&'buf mut Vec<u8>> {
16717        Self::write_header(buf, header);
16718        PushRuleAttrs::new(buf)
16719    }
16720    pub fn encode(&mut self) -> PushRuleAttrs<&mut Vec<u8>> {
16721        PushRuleAttrs::new(self.request.buf_mut())
16722    }
16723    pub fn into_encoder(self) -> PushRuleAttrs<RequestBuf<'r>> {
16724        PushRuleAttrs::new(self.request.buf)
16725    }
16726    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableRuleAttrs<'a>) {
16727        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16728        (
16729            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16730            IterableRuleAttrs::with_loc(attrs, buf.as_ptr() as usize),
16731        )
16732    }
16733    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16734        prev.as_rec_mut().extend(header.as_slice());
16735    }
16736}
16737impl NetlinkRequest for OpGetruleDump<'_> {
16738    fn protocol(&self) -> Protocol {
16739        Protocol::Raw {
16740            protonum: 12u16,
16741            request_type: 2567u16,
16742        }
16743    }
16744    fn flags(&self) -> u16 {
16745        self.request.flags
16746    }
16747    fn payload(&self) -> &[u8] {
16748        self.request.buf()
16749    }
16750    type ReplyType<'buf> = (Nfgenmsg, IterableRuleAttrs<'buf>);
16751    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16752        Self::decode_request(buf)
16753    }
16754    fn lookup(
16755        buf: &[u8],
16756        offset: usize,
16757        missing_type: Option<u16>,
16758    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16759        Self::decode_request(buf)
16760            .1
16761            .lookup_attr(offset, missing_type)
16762    }
16763}
16764#[doc = "Get / dump rules\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n\nReply attributes:\n- [.get_table()](IterableRuleAttrs::get_table)\n- [.get_chain()](IterableRuleAttrs::get_chain)\n- [.get_handle()](IterableRuleAttrs::get_handle)\n- [.get_expressions()](IterableRuleAttrs::get_expressions)\n- [.get_position()](IterableRuleAttrs::get_position)\n- [.get_userdata()](IterableRuleAttrs::get_userdata)\n"]
16765#[derive(Debug)]
16766pub struct OpGetruleDo<'r> {
16767    request: Request<'r>,
16768}
16769impl<'r> OpGetruleDo<'r> {
16770    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16771        Self::write_header(request.buf_mut(), header);
16772        Self { request: request }
16773    }
16774    pub fn encode_request<'buf>(
16775        buf: &'buf mut Vec<u8>,
16776        header: &Nfgenmsg,
16777    ) -> PushRuleAttrs<&'buf mut Vec<u8>> {
16778        Self::write_header(buf, header);
16779        PushRuleAttrs::new(buf)
16780    }
16781    pub fn encode(&mut self) -> PushRuleAttrs<&mut Vec<u8>> {
16782        PushRuleAttrs::new(self.request.buf_mut())
16783    }
16784    pub fn into_encoder(self) -> PushRuleAttrs<RequestBuf<'r>> {
16785        PushRuleAttrs::new(self.request.buf)
16786    }
16787    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableRuleAttrs<'a>) {
16788        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16789        (
16790            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16791            IterableRuleAttrs::with_loc(attrs, buf.as_ptr() as usize),
16792        )
16793    }
16794    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16795        prev.as_rec_mut().extend(header.as_slice());
16796    }
16797}
16798impl NetlinkRequest for OpGetruleDo<'_> {
16799    fn protocol(&self) -> Protocol {
16800        Protocol::Raw {
16801            protonum: 12u16,
16802            request_type: 2567u16,
16803        }
16804    }
16805    fn flags(&self) -> u16 {
16806        self.request.flags
16807    }
16808    fn payload(&self) -> &[u8] {
16809        self.request.buf()
16810    }
16811    type ReplyType<'buf> = (Nfgenmsg, IterableRuleAttrs<'buf>);
16812    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16813        Self::decode_request(buf)
16814    }
16815    fn lookup(
16816        buf: &[u8],
16817        offset: usize,
16818        missing_type: Option<u16>,
16819    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16820        Self::decode_request(buf)
16821            .1
16822            .lookup_attr(offset, missing_type)
16823    }
16824}
16825#[doc = "Get / dump rules and reset stateful expressions\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n\nReply attributes:\n- [.get_table()](IterableRuleAttrs::get_table)\n- [.get_chain()](IterableRuleAttrs::get_chain)\n- [.get_handle()](IterableRuleAttrs::get_handle)\n- [.get_expressions()](IterableRuleAttrs::get_expressions)\n- [.get_position()](IterableRuleAttrs::get_position)\n- [.get_userdata()](IterableRuleAttrs::get_userdata)\n"]
16826#[derive(Debug)]
16827pub struct OpGetruleResetDump<'r> {
16828    request: Request<'r>,
16829}
16830impl<'r> OpGetruleResetDump<'r> {
16831    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16832        Self::write_header(request.buf_mut(), header);
16833        Self {
16834            request: request.set_dump(),
16835        }
16836    }
16837    pub fn encode_request<'buf>(
16838        buf: &'buf mut Vec<u8>,
16839        header: &Nfgenmsg,
16840    ) -> PushRuleAttrs<&'buf mut Vec<u8>> {
16841        Self::write_header(buf, header);
16842        PushRuleAttrs::new(buf)
16843    }
16844    pub fn encode(&mut self) -> PushRuleAttrs<&mut Vec<u8>> {
16845        PushRuleAttrs::new(self.request.buf_mut())
16846    }
16847    pub fn into_encoder(self) -> PushRuleAttrs<RequestBuf<'r>> {
16848        PushRuleAttrs::new(self.request.buf)
16849    }
16850    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableRuleAttrs<'a>) {
16851        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16852        (
16853            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16854            IterableRuleAttrs::with_loc(attrs, buf.as_ptr() as usize),
16855        )
16856    }
16857    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16858        prev.as_rec_mut().extend(header.as_slice());
16859    }
16860}
16861impl NetlinkRequest for OpGetruleResetDump<'_> {
16862    fn protocol(&self) -> Protocol {
16863        Protocol::Raw {
16864            protonum: 12u16,
16865            request_type: 2585u16,
16866        }
16867    }
16868    fn flags(&self) -> u16 {
16869        self.request.flags
16870    }
16871    fn payload(&self) -> &[u8] {
16872        self.request.buf()
16873    }
16874    type ReplyType<'buf> = (Nfgenmsg, IterableRuleAttrs<'buf>);
16875    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16876        Self::decode_request(buf)
16877    }
16878    fn lookup(
16879        buf: &[u8],
16880        offset: usize,
16881        missing_type: Option<u16>,
16882    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16883        Self::decode_request(buf)
16884            .1
16885            .lookup_attr(offset, missing_type)
16886    }
16887}
16888#[doc = "Get / dump rules and reset stateful expressions\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n\nReply attributes:\n- [.get_table()](IterableRuleAttrs::get_table)\n- [.get_chain()](IterableRuleAttrs::get_chain)\n- [.get_handle()](IterableRuleAttrs::get_handle)\n- [.get_expressions()](IterableRuleAttrs::get_expressions)\n- [.get_position()](IterableRuleAttrs::get_position)\n- [.get_userdata()](IterableRuleAttrs::get_userdata)\n"]
16889#[derive(Debug)]
16890pub struct OpGetruleResetDo<'r> {
16891    request: Request<'r>,
16892}
16893impl<'r> OpGetruleResetDo<'r> {
16894    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16895        Self::write_header(request.buf_mut(), header);
16896        Self { request: request }
16897    }
16898    pub fn encode_request<'buf>(
16899        buf: &'buf mut Vec<u8>,
16900        header: &Nfgenmsg,
16901    ) -> PushRuleAttrs<&'buf mut Vec<u8>> {
16902        Self::write_header(buf, header);
16903        PushRuleAttrs::new(buf)
16904    }
16905    pub fn encode(&mut self) -> PushRuleAttrs<&mut Vec<u8>> {
16906        PushRuleAttrs::new(self.request.buf_mut())
16907    }
16908    pub fn into_encoder(self) -> PushRuleAttrs<RequestBuf<'r>> {
16909        PushRuleAttrs::new(self.request.buf)
16910    }
16911    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableRuleAttrs<'a>) {
16912        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16913        (
16914            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16915            IterableRuleAttrs::with_loc(attrs, buf.as_ptr() as usize),
16916        )
16917    }
16918    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16919        prev.as_rec_mut().extend(header.as_slice());
16920    }
16921}
16922impl NetlinkRequest for OpGetruleResetDo<'_> {
16923    fn protocol(&self) -> Protocol {
16924        Protocol::Raw {
16925            protonum: 12u16,
16926            request_type: 2585u16,
16927        }
16928    }
16929    fn flags(&self) -> u16 {
16930        self.request.flags
16931    }
16932    fn payload(&self) -> &[u8] {
16933        self.request.buf()
16934    }
16935    type ReplyType<'buf> = (Nfgenmsg, IterableRuleAttrs<'buf>);
16936    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16937        Self::decode_request(buf)
16938    }
16939    fn lookup(
16940        buf: &[u8],
16941        offset: usize,
16942        missing_type: Option<u16>,
16943    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16944        Self::decode_request(buf)
16945            .1
16946            .lookup_attr(offset, missing_type)
16947    }
16948}
16949#[doc = "Delete an existing rule\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n- [.push_id()](PushRuleAttrs::push_id)\n"]
16950#[derive(Debug)]
16951pub struct OpDelruleDo<'r> {
16952    request: Request<'r>,
16953}
16954impl<'r> OpDelruleDo<'r> {
16955    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
16956        Self::write_header(request.buf_mut(), header);
16957        Self { request: request }
16958    }
16959    pub fn encode_request<'buf>(
16960        buf: &'buf mut Vec<u8>,
16961        header: &Nfgenmsg,
16962    ) -> PushRuleAttrs<&'buf mut Vec<u8>> {
16963        Self::write_header(buf, header);
16964        PushRuleAttrs::new(buf)
16965    }
16966    pub fn encode(&mut self) -> PushRuleAttrs<&mut Vec<u8>> {
16967        PushRuleAttrs::new(self.request.buf_mut())
16968    }
16969    pub fn into_encoder(self) -> PushRuleAttrs<RequestBuf<'r>> {
16970        PushRuleAttrs::new(self.request.buf)
16971    }
16972    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableRuleAttrs<'a>) {
16973        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
16974        (
16975            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
16976            IterableRuleAttrs::with_loc(attrs, buf.as_ptr() as usize),
16977        )
16978    }
16979    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
16980        prev.as_rec_mut().extend(header.as_slice());
16981    }
16982}
16983impl NetlinkRequest for OpDelruleDo<'_> {
16984    fn protocol(&self) -> Protocol {
16985        Protocol::Raw {
16986            protonum: 12u16,
16987            request_type: 2568u16,
16988        }
16989    }
16990    fn flags(&self) -> u16 {
16991        self.request.flags
16992    }
16993    fn payload(&self) -> &[u8] {
16994        self.request.buf()
16995    }
16996    type ReplyType<'buf> = (Nfgenmsg, IterableRuleAttrs<'buf>);
16997    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
16998        Self::decode_request(buf)
16999    }
17000    fn lookup(
17001        buf: &[u8],
17002        offset: usize,
17003        missing_type: Option<u16>,
17004    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17005        Self::decode_request(buf)
17006            .1
17007            .lookup_attr(offset, missing_type)
17008    }
17009}
17010#[doc = "Delete an existing rule with destroy semantics (ignoring ENOENT errors)\\.\n\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n- [.push_id()](PushRuleAttrs::push_id)\n"]
17011#[derive(Debug)]
17012pub struct OpDestroyruleDo<'r> {
17013    request: Request<'r>,
17014}
17015impl<'r> OpDestroyruleDo<'r> {
17016    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17017        Self::write_header(request.buf_mut(), header);
17018        Self { request: request }
17019    }
17020    pub fn encode_request<'buf>(
17021        buf: &'buf mut Vec<u8>,
17022        header: &Nfgenmsg,
17023    ) -> PushRuleAttrs<&'buf mut Vec<u8>> {
17024        Self::write_header(buf, header);
17025        PushRuleAttrs::new(buf)
17026    }
17027    pub fn encode(&mut self) -> PushRuleAttrs<&mut Vec<u8>> {
17028        PushRuleAttrs::new(self.request.buf_mut())
17029    }
17030    pub fn into_encoder(self) -> PushRuleAttrs<RequestBuf<'r>> {
17031        PushRuleAttrs::new(self.request.buf)
17032    }
17033    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableRuleAttrs<'a>) {
17034        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17035        (
17036            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17037            IterableRuleAttrs::with_loc(attrs, buf.as_ptr() as usize),
17038        )
17039    }
17040    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17041        prev.as_rec_mut().extend(header.as_slice());
17042    }
17043}
17044impl NetlinkRequest for OpDestroyruleDo<'_> {
17045    fn protocol(&self) -> Protocol {
17046        Protocol::Raw {
17047            protonum: 12u16,
17048            request_type: 2588u16,
17049        }
17050    }
17051    fn flags(&self) -> u16 {
17052        self.request.flags
17053    }
17054    fn payload(&self) -> &[u8] {
17055        self.request.buf()
17056    }
17057    type ReplyType<'buf> = (Nfgenmsg, IterableRuleAttrs<'buf>);
17058    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17059        Self::decode_request(buf)
17060    }
17061    fn lookup(
17062        buf: &[u8],
17063        offset: usize,
17064        missing_type: Option<u16>,
17065    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17066        Self::decode_request(buf)
17067            .1
17068            .lookup_attr(offset, missing_type)
17069    }
17070}
17071#[doc = "Create a new set\\.\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n- [.push_name()](PushSetAttrs::push_name)\n- [.push_flags()](PushSetAttrs::push_flags)\n- [.push_key_type()](PushSetAttrs::push_key_type)\n- [.push_key_len()](PushSetAttrs::push_key_len)\n- [.push_data_type()](PushSetAttrs::push_data_type)\n- [.push_data_len()](PushSetAttrs::push_data_len)\n- [.push_policy()](PushSetAttrs::push_policy)\n- [.nested_desc()](PushSetAttrs::nested_desc)\n- [.push_id()](PushSetAttrs::push_id)\n- [.push_timeout()](PushSetAttrs::push_timeout)\n- [.push_gc_interval()](PushSetAttrs::push_gc_interval)\n- [.push_userdata()](PushSetAttrs::push_userdata)\n- [.push_obj_type()](PushSetAttrs::push_obj_type)\n"]
17072#[derive(Debug)]
17073pub struct OpNewsetDo<'r> {
17074    request: Request<'r>,
17075}
17076impl<'r> OpNewsetDo<'r> {
17077    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17078        Self::write_header(request.buf_mut(), header);
17079        Self { request: request }
17080    }
17081    pub fn encode_request<'buf>(
17082        buf: &'buf mut Vec<u8>,
17083        header: &Nfgenmsg,
17084    ) -> PushSetAttrs<&'buf mut Vec<u8>> {
17085        Self::write_header(buf, header);
17086        PushSetAttrs::new(buf)
17087    }
17088    pub fn encode(&mut self) -> PushSetAttrs<&mut Vec<u8>> {
17089        PushSetAttrs::new(self.request.buf_mut())
17090    }
17091    pub fn into_encoder(self) -> PushSetAttrs<RequestBuf<'r>> {
17092        PushSetAttrs::new(self.request.buf)
17093    }
17094    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetAttrs<'a>) {
17095        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17096        (
17097            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17098            IterableSetAttrs::with_loc(attrs, buf.as_ptr() as usize),
17099        )
17100    }
17101    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17102        prev.as_rec_mut().extend(header.as_slice());
17103    }
17104}
17105impl NetlinkRequest for OpNewsetDo<'_> {
17106    fn protocol(&self) -> Protocol {
17107        Protocol::Raw {
17108            protonum: 12u16,
17109            request_type: 2569u16,
17110        }
17111    }
17112    fn flags(&self) -> u16 {
17113        self.request.flags
17114    }
17115    fn payload(&self) -> &[u8] {
17116        self.request.buf()
17117    }
17118    type ReplyType<'buf> = (Nfgenmsg, IterableSetAttrs<'buf>);
17119    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17120        Self::decode_request(buf)
17121    }
17122    fn lookup(
17123        buf: &[u8],
17124        offset: usize,
17125        missing_type: Option<u16>,
17126    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17127        Self::decode_request(buf)
17128            .1
17129            .lookup_attr(offset, missing_type)
17130    }
17131}
17132#[doc = "Get / dump sets\\.\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n\nReply attributes:\n- [.get_table()](IterableSetAttrs::get_table)\n- [.get_name()](IterableSetAttrs::get_name)\n- [.get_flags()](IterableSetAttrs::get_flags)\n- [.get_key_type()](IterableSetAttrs::get_key_type)\n- [.get_key_len()](IterableSetAttrs::get_key_len)\n- [.get_data_type()](IterableSetAttrs::get_data_type)\n- [.get_data_len()](IterableSetAttrs::get_data_len)\n- [.get_policy()](IterableSetAttrs::get_policy)\n- [.get_desc()](IterableSetAttrs::get_desc)\n- [.get_gc_interval()](IterableSetAttrs::get_gc_interval)\n- [.get_userdata()](IterableSetAttrs::get_userdata)\n- [.get_obj_type()](IterableSetAttrs::get_obj_type)\n- [.get_handle()](IterableSetAttrs::get_handle)\n- [.get_expr()](IterableSetAttrs::get_expr)\n- [.get_expressions()](IterableSetAttrs::get_expressions)\n"]
17133#[derive(Debug)]
17134pub struct OpGetsetDump<'r> {
17135    request: Request<'r>,
17136}
17137impl<'r> OpGetsetDump<'r> {
17138    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17139        Self::write_header(request.buf_mut(), header);
17140        Self {
17141            request: request.set_dump(),
17142        }
17143    }
17144    pub fn encode_request<'buf>(
17145        buf: &'buf mut Vec<u8>,
17146        header: &Nfgenmsg,
17147    ) -> PushSetAttrs<&'buf mut Vec<u8>> {
17148        Self::write_header(buf, header);
17149        PushSetAttrs::new(buf)
17150    }
17151    pub fn encode(&mut self) -> PushSetAttrs<&mut Vec<u8>> {
17152        PushSetAttrs::new(self.request.buf_mut())
17153    }
17154    pub fn into_encoder(self) -> PushSetAttrs<RequestBuf<'r>> {
17155        PushSetAttrs::new(self.request.buf)
17156    }
17157    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetAttrs<'a>) {
17158        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17159        (
17160            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17161            IterableSetAttrs::with_loc(attrs, buf.as_ptr() as usize),
17162        )
17163    }
17164    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17165        prev.as_rec_mut().extend(header.as_slice());
17166    }
17167}
17168impl NetlinkRequest for OpGetsetDump<'_> {
17169    fn protocol(&self) -> Protocol {
17170        Protocol::Raw {
17171            protonum: 12u16,
17172            request_type: 2570u16,
17173        }
17174    }
17175    fn flags(&self) -> u16 {
17176        self.request.flags
17177    }
17178    fn payload(&self) -> &[u8] {
17179        self.request.buf()
17180    }
17181    type ReplyType<'buf> = (Nfgenmsg, IterableSetAttrs<'buf>);
17182    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17183        Self::decode_request(buf)
17184    }
17185    fn lookup(
17186        buf: &[u8],
17187        offset: usize,
17188        missing_type: Option<u16>,
17189    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17190        Self::decode_request(buf)
17191            .1
17192            .lookup_attr(offset, missing_type)
17193    }
17194}
17195#[doc = "Get / dump sets\\.\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n- [.push_name()](PushSetAttrs::push_name)\n\nReply attributes:\n- [.get_table()](IterableSetAttrs::get_table)\n- [.get_name()](IterableSetAttrs::get_name)\n- [.get_flags()](IterableSetAttrs::get_flags)\n- [.get_key_type()](IterableSetAttrs::get_key_type)\n- [.get_key_len()](IterableSetAttrs::get_key_len)\n- [.get_data_type()](IterableSetAttrs::get_data_type)\n- [.get_data_len()](IterableSetAttrs::get_data_len)\n- [.get_policy()](IterableSetAttrs::get_policy)\n- [.get_desc()](IterableSetAttrs::get_desc)\n- [.get_gc_interval()](IterableSetAttrs::get_gc_interval)\n- [.get_userdata()](IterableSetAttrs::get_userdata)\n- [.get_obj_type()](IterableSetAttrs::get_obj_type)\n- [.get_handle()](IterableSetAttrs::get_handle)\n- [.get_expr()](IterableSetAttrs::get_expr)\n- [.get_expressions()](IterableSetAttrs::get_expressions)\n"]
17196#[derive(Debug)]
17197pub struct OpGetsetDo<'r> {
17198    request: Request<'r>,
17199}
17200impl<'r> OpGetsetDo<'r> {
17201    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17202        Self::write_header(request.buf_mut(), header);
17203        Self { request: request }
17204    }
17205    pub fn encode_request<'buf>(
17206        buf: &'buf mut Vec<u8>,
17207        header: &Nfgenmsg,
17208    ) -> PushSetAttrs<&'buf mut Vec<u8>> {
17209        Self::write_header(buf, header);
17210        PushSetAttrs::new(buf)
17211    }
17212    pub fn encode(&mut self) -> PushSetAttrs<&mut Vec<u8>> {
17213        PushSetAttrs::new(self.request.buf_mut())
17214    }
17215    pub fn into_encoder(self) -> PushSetAttrs<RequestBuf<'r>> {
17216        PushSetAttrs::new(self.request.buf)
17217    }
17218    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetAttrs<'a>) {
17219        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17220        (
17221            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17222            IterableSetAttrs::with_loc(attrs, buf.as_ptr() as usize),
17223        )
17224    }
17225    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17226        prev.as_rec_mut().extend(header.as_slice());
17227    }
17228}
17229impl NetlinkRequest for OpGetsetDo<'_> {
17230    fn protocol(&self) -> Protocol {
17231        Protocol::Raw {
17232            protonum: 12u16,
17233            request_type: 2570u16,
17234        }
17235    }
17236    fn flags(&self) -> u16 {
17237        self.request.flags
17238    }
17239    fn payload(&self) -> &[u8] {
17240        self.request.buf()
17241    }
17242    type ReplyType<'buf> = (Nfgenmsg, IterableSetAttrs<'buf>);
17243    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17244        Self::decode_request(buf)
17245    }
17246    fn lookup(
17247        buf: &[u8],
17248        offset: usize,
17249        missing_type: Option<u16>,
17250    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17251        Self::decode_request(buf)
17252            .1
17253            .lookup_attr(offset, missing_type)
17254    }
17255}
17256#[doc = "Delete an existing set\\.\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n- [.push_name()](PushSetAttrs::push_name)\n- [.push_handle()](PushSetAttrs::push_handle)\n"]
17257#[derive(Debug)]
17258pub struct OpDelsetDo<'r> {
17259    request: Request<'r>,
17260}
17261impl<'r> OpDelsetDo<'r> {
17262    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17263        Self::write_header(request.buf_mut(), header);
17264        Self { request: request }
17265    }
17266    pub fn encode_request<'buf>(
17267        buf: &'buf mut Vec<u8>,
17268        header: &Nfgenmsg,
17269    ) -> PushSetAttrs<&'buf mut Vec<u8>> {
17270        Self::write_header(buf, header);
17271        PushSetAttrs::new(buf)
17272    }
17273    pub fn encode(&mut self) -> PushSetAttrs<&mut Vec<u8>> {
17274        PushSetAttrs::new(self.request.buf_mut())
17275    }
17276    pub fn into_encoder(self) -> PushSetAttrs<RequestBuf<'r>> {
17277        PushSetAttrs::new(self.request.buf)
17278    }
17279    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetAttrs<'a>) {
17280        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17281        (
17282            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17283            IterableSetAttrs::with_loc(attrs, buf.as_ptr() as usize),
17284        )
17285    }
17286    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17287        prev.as_rec_mut().extend(header.as_slice());
17288    }
17289}
17290impl NetlinkRequest for OpDelsetDo<'_> {
17291    fn protocol(&self) -> Protocol {
17292        Protocol::Raw {
17293            protonum: 12u16,
17294            request_type: 2571u16,
17295        }
17296    }
17297    fn flags(&self) -> u16 {
17298        self.request.flags
17299    }
17300    fn payload(&self) -> &[u8] {
17301        self.request.buf()
17302    }
17303    type ReplyType<'buf> = (Nfgenmsg, IterableSetAttrs<'buf>);
17304    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17305        Self::decode_request(buf)
17306    }
17307    fn lookup(
17308        buf: &[u8],
17309        offset: usize,
17310        missing_type: Option<u16>,
17311    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17312        Self::decode_request(buf)
17313            .1
17314            .lookup_attr(offset, missing_type)
17315    }
17316}
17317#[doc = "Delete an existing set with destroy semantics (ignoring ENOENT errors)\\.\n\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n- [.push_name()](PushSetAttrs::push_name)\n- [.push_handle()](PushSetAttrs::push_handle)\n"]
17318#[derive(Debug)]
17319pub struct OpDestroysetDo<'r> {
17320    request: Request<'r>,
17321}
17322impl<'r> OpDestroysetDo<'r> {
17323    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17324        Self::write_header(request.buf_mut(), header);
17325        Self { request: request }
17326    }
17327    pub fn encode_request<'buf>(
17328        buf: &'buf mut Vec<u8>,
17329        header: &Nfgenmsg,
17330    ) -> PushSetAttrs<&'buf mut Vec<u8>> {
17331        Self::write_header(buf, header);
17332        PushSetAttrs::new(buf)
17333    }
17334    pub fn encode(&mut self) -> PushSetAttrs<&mut Vec<u8>> {
17335        PushSetAttrs::new(self.request.buf_mut())
17336    }
17337    pub fn into_encoder(self) -> PushSetAttrs<RequestBuf<'r>> {
17338        PushSetAttrs::new(self.request.buf)
17339    }
17340    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetAttrs<'a>) {
17341        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17342        (
17343            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17344            IterableSetAttrs::with_loc(attrs, buf.as_ptr() as usize),
17345        )
17346    }
17347    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17348        prev.as_rec_mut().extend(header.as_slice());
17349    }
17350}
17351impl NetlinkRequest for OpDestroysetDo<'_> {
17352    fn protocol(&self) -> Protocol {
17353        Protocol::Raw {
17354            protonum: 12u16,
17355            request_type: 2589u16,
17356        }
17357    }
17358    fn flags(&self) -> u16 {
17359        self.request.flags
17360    }
17361    fn payload(&self) -> &[u8] {
17362        self.request.buf()
17363    }
17364    type ReplyType<'buf> = (Nfgenmsg, IterableSetAttrs<'buf>);
17365    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17366        Self::decode_request(buf)
17367    }
17368    fn lookup(
17369        buf: &[u8],
17370        offset: usize,
17371        missing_type: Option<u16>,
17372    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17373        Self::decode_request(buf)
17374            .1
17375            .lookup_attr(offset, missing_type)
17376    }
17377}
17378#[doc = "Create a new set element\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n- [.push_set_id()](PushSetelemListAttrs::push_set_id)\n"]
17379#[derive(Debug)]
17380pub struct OpNewsetelemDo<'r> {
17381    request: Request<'r>,
17382}
17383impl<'r> OpNewsetelemDo<'r> {
17384    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17385        Self::write_header(request.buf_mut(), header);
17386        Self { request: request }
17387    }
17388    pub fn encode_request<'buf>(
17389        buf: &'buf mut Vec<u8>,
17390        header: &Nfgenmsg,
17391    ) -> PushSetelemListAttrs<&'buf mut Vec<u8>> {
17392        Self::write_header(buf, header);
17393        PushSetelemListAttrs::new(buf)
17394    }
17395    pub fn encode(&mut self) -> PushSetelemListAttrs<&mut Vec<u8>> {
17396        PushSetelemListAttrs::new(self.request.buf_mut())
17397    }
17398    pub fn into_encoder(self) -> PushSetelemListAttrs<RequestBuf<'r>> {
17399        PushSetelemListAttrs::new(self.request.buf)
17400    }
17401    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetelemListAttrs<'a>) {
17402        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17403        (
17404            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17405            IterableSetelemListAttrs::with_loc(attrs, buf.as_ptr() as usize),
17406        )
17407    }
17408    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17409        prev.as_rec_mut().extend(header.as_slice());
17410    }
17411}
17412impl NetlinkRequest for OpNewsetelemDo<'_> {
17413    fn protocol(&self) -> Protocol {
17414        Protocol::Raw {
17415            protonum: 12u16,
17416            request_type: 2572u16,
17417        }
17418    }
17419    fn flags(&self) -> u16 {
17420        self.request.flags
17421    }
17422    fn payload(&self) -> &[u8] {
17423        self.request.buf()
17424    }
17425    type ReplyType<'buf> = (Nfgenmsg, IterableSetelemListAttrs<'buf>);
17426    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17427        Self::decode_request(buf)
17428    }
17429    fn lookup(
17430        buf: &[u8],
17431        offset: usize,
17432        missing_type: Option<u16>,
17433    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17434        Self::decode_request(buf)
17435            .1
17436            .lookup_attr(offset, missing_type)
17437    }
17438}
17439#[doc = "Get / dump set elements\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n\nReply attributes:\n- [.get_table()](IterableSetelemListAttrs::get_table)\n- [.get_set()](IterableSetelemListAttrs::get_set)\n- [.get_elements()](IterableSetelemListAttrs::get_elements)\n"]
17440#[derive(Debug)]
17441pub struct OpGetsetelemDump<'r> {
17442    request: Request<'r>,
17443}
17444impl<'r> OpGetsetelemDump<'r> {
17445    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17446        Self::write_header(request.buf_mut(), header);
17447        Self {
17448            request: request.set_dump(),
17449        }
17450    }
17451    pub fn encode_request<'buf>(
17452        buf: &'buf mut Vec<u8>,
17453        header: &Nfgenmsg,
17454    ) -> PushSetelemListAttrs<&'buf mut Vec<u8>> {
17455        Self::write_header(buf, header);
17456        PushSetelemListAttrs::new(buf)
17457    }
17458    pub fn encode(&mut self) -> PushSetelemListAttrs<&mut Vec<u8>> {
17459        PushSetelemListAttrs::new(self.request.buf_mut())
17460    }
17461    pub fn into_encoder(self) -> PushSetelemListAttrs<RequestBuf<'r>> {
17462        PushSetelemListAttrs::new(self.request.buf)
17463    }
17464    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetelemListAttrs<'a>) {
17465        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17466        (
17467            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17468            IterableSetelemListAttrs::with_loc(attrs, buf.as_ptr() as usize),
17469        )
17470    }
17471    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17472        prev.as_rec_mut().extend(header.as_slice());
17473    }
17474}
17475impl NetlinkRequest for OpGetsetelemDump<'_> {
17476    fn protocol(&self) -> Protocol {
17477        Protocol::Raw {
17478            protonum: 12u16,
17479            request_type: 2573u16,
17480        }
17481    }
17482    fn flags(&self) -> u16 {
17483        self.request.flags
17484    }
17485    fn payload(&self) -> &[u8] {
17486        self.request.buf()
17487    }
17488    type ReplyType<'buf> = (Nfgenmsg, IterableSetelemListAttrs<'buf>);
17489    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17490        Self::decode_request(buf)
17491    }
17492    fn lookup(
17493        buf: &[u8],
17494        offset: usize,
17495        missing_type: Option<u16>,
17496    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17497        Self::decode_request(buf)
17498            .1
17499            .lookup_attr(offset, missing_type)
17500    }
17501}
17502#[doc = "Get / dump set elements\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n\nReply attributes:\n- [.get_elements()](IterableSetelemListAttrs::get_elements)\n"]
17503#[derive(Debug)]
17504pub struct OpGetsetelemDo<'r> {
17505    request: Request<'r>,
17506}
17507impl<'r> OpGetsetelemDo<'r> {
17508    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17509        Self::write_header(request.buf_mut(), header);
17510        Self { request: request }
17511    }
17512    pub fn encode_request<'buf>(
17513        buf: &'buf mut Vec<u8>,
17514        header: &Nfgenmsg,
17515    ) -> PushSetelemListAttrs<&'buf mut Vec<u8>> {
17516        Self::write_header(buf, header);
17517        PushSetelemListAttrs::new(buf)
17518    }
17519    pub fn encode(&mut self) -> PushSetelemListAttrs<&mut Vec<u8>> {
17520        PushSetelemListAttrs::new(self.request.buf_mut())
17521    }
17522    pub fn into_encoder(self) -> PushSetelemListAttrs<RequestBuf<'r>> {
17523        PushSetelemListAttrs::new(self.request.buf)
17524    }
17525    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetelemListAttrs<'a>) {
17526        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17527        (
17528            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17529            IterableSetelemListAttrs::with_loc(attrs, buf.as_ptr() as usize),
17530        )
17531    }
17532    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17533        prev.as_rec_mut().extend(header.as_slice());
17534    }
17535}
17536impl NetlinkRequest for OpGetsetelemDo<'_> {
17537    fn protocol(&self) -> Protocol {
17538        Protocol::Raw {
17539            protonum: 12u16,
17540            request_type: 2573u16,
17541        }
17542    }
17543    fn flags(&self) -> u16 {
17544        self.request.flags
17545    }
17546    fn payload(&self) -> &[u8] {
17547        self.request.buf()
17548    }
17549    type ReplyType<'buf> = (Nfgenmsg, IterableSetelemListAttrs<'buf>);
17550    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17551        Self::decode_request(buf)
17552    }
17553    fn lookup(
17554        buf: &[u8],
17555        offset: usize,
17556        missing_type: Option<u16>,
17557    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17558        Self::decode_request(buf)
17559            .1
17560            .lookup_attr(offset, missing_type)
17561    }
17562}
17563#[doc = "Get / dump set elements and reset stateful expressions\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n\nReply attributes:\n- [.get_table()](IterableSetelemListAttrs::get_table)\n- [.get_set()](IterableSetelemListAttrs::get_set)\n- [.get_elements()](IterableSetelemListAttrs::get_elements)\n"]
17564#[derive(Debug)]
17565pub struct OpGetsetelemResetDump<'r> {
17566    request: Request<'r>,
17567}
17568impl<'r> OpGetsetelemResetDump<'r> {
17569    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17570        Self::write_header(request.buf_mut(), header);
17571        Self {
17572            request: request.set_dump(),
17573        }
17574    }
17575    pub fn encode_request<'buf>(
17576        buf: &'buf mut Vec<u8>,
17577        header: &Nfgenmsg,
17578    ) -> PushSetelemListAttrs<&'buf mut Vec<u8>> {
17579        Self::write_header(buf, header);
17580        PushSetelemListAttrs::new(buf)
17581    }
17582    pub fn encode(&mut self) -> PushSetelemListAttrs<&mut Vec<u8>> {
17583        PushSetelemListAttrs::new(self.request.buf_mut())
17584    }
17585    pub fn into_encoder(self) -> PushSetelemListAttrs<RequestBuf<'r>> {
17586        PushSetelemListAttrs::new(self.request.buf)
17587    }
17588    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetelemListAttrs<'a>) {
17589        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17590        (
17591            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17592            IterableSetelemListAttrs::with_loc(attrs, buf.as_ptr() as usize),
17593        )
17594    }
17595    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17596        prev.as_rec_mut().extend(header.as_slice());
17597    }
17598}
17599impl NetlinkRequest for OpGetsetelemResetDump<'_> {
17600    fn protocol(&self) -> Protocol {
17601        Protocol::Raw {
17602            protonum: 12u16,
17603            request_type: 2593u16,
17604        }
17605    }
17606    fn flags(&self) -> u16 {
17607        self.request.flags
17608    }
17609    fn payload(&self) -> &[u8] {
17610        self.request.buf()
17611    }
17612    type ReplyType<'buf> = (Nfgenmsg, IterableSetelemListAttrs<'buf>);
17613    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17614        Self::decode_request(buf)
17615    }
17616    fn lookup(
17617        buf: &[u8],
17618        offset: usize,
17619        missing_type: Option<u16>,
17620    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17621        Self::decode_request(buf)
17622            .1
17623            .lookup_attr(offset, missing_type)
17624    }
17625}
17626#[doc = "Get / dump set elements and reset stateful expressions\\.\nRequest attributes:\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n\nReply attributes:\n- [.get_table()](IterableSetelemListAttrs::get_table)\n- [.get_set()](IterableSetelemListAttrs::get_set)\n- [.get_elements()](IterableSetelemListAttrs::get_elements)\n"]
17627#[derive(Debug)]
17628pub struct OpGetsetelemResetDo<'r> {
17629    request: Request<'r>,
17630}
17631impl<'r> OpGetsetelemResetDo<'r> {
17632    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17633        Self::write_header(request.buf_mut(), header);
17634        Self { request: request }
17635    }
17636    pub fn encode_request<'buf>(
17637        buf: &'buf mut Vec<u8>,
17638        header: &Nfgenmsg,
17639    ) -> PushSetelemListAttrs<&'buf mut Vec<u8>> {
17640        Self::write_header(buf, header);
17641        PushSetelemListAttrs::new(buf)
17642    }
17643    pub fn encode(&mut self) -> PushSetelemListAttrs<&mut Vec<u8>> {
17644        PushSetelemListAttrs::new(self.request.buf_mut())
17645    }
17646    pub fn into_encoder(self) -> PushSetelemListAttrs<RequestBuf<'r>> {
17647        PushSetelemListAttrs::new(self.request.buf)
17648    }
17649    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetelemListAttrs<'a>) {
17650        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17651        (
17652            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17653            IterableSetelemListAttrs::with_loc(attrs, buf.as_ptr() as usize),
17654        )
17655    }
17656    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17657        prev.as_rec_mut().extend(header.as_slice());
17658    }
17659}
17660impl NetlinkRequest for OpGetsetelemResetDo<'_> {
17661    fn protocol(&self) -> Protocol {
17662        Protocol::Raw {
17663            protonum: 12u16,
17664            request_type: 2593u16,
17665        }
17666    }
17667    fn flags(&self) -> u16 {
17668        self.request.flags
17669    }
17670    fn payload(&self) -> &[u8] {
17671        self.request.buf()
17672    }
17673    type ReplyType<'buf> = (Nfgenmsg, IterableSetelemListAttrs<'buf>);
17674    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17675        Self::decode_request(buf)
17676    }
17677    fn lookup(
17678        buf: &[u8],
17679        offset: usize,
17680        missing_type: Option<u16>,
17681    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17682        Self::decode_request(buf)
17683            .1
17684            .lookup_attr(offset, missing_type)
17685    }
17686}
17687#[doc = "Delete an existing set element\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n"]
17688#[derive(Debug)]
17689pub struct OpDelsetelemDo<'r> {
17690    request: Request<'r>,
17691}
17692impl<'r> OpDelsetelemDo<'r> {
17693    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17694        Self::write_header(request.buf_mut(), header);
17695        Self { request: request }
17696    }
17697    pub fn encode_request<'buf>(
17698        buf: &'buf mut Vec<u8>,
17699        header: &Nfgenmsg,
17700    ) -> PushSetelemListAttrs<&'buf mut Vec<u8>> {
17701        Self::write_header(buf, header);
17702        PushSetelemListAttrs::new(buf)
17703    }
17704    pub fn encode(&mut self) -> PushSetelemListAttrs<&mut Vec<u8>> {
17705        PushSetelemListAttrs::new(self.request.buf_mut())
17706    }
17707    pub fn into_encoder(self) -> PushSetelemListAttrs<RequestBuf<'r>> {
17708        PushSetelemListAttrs::new(self.request.buf)
17709    }
17710    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetelemListAttrs<'a>) {
17711        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17712        (
17713            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17714            IterableSetelemListAttrs::with_loc(attrs, buf.as_ptr() as usize),
17715        )
17716    }
17717    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17718        prev.as_rec_mut().extend(header.as_slice());
17719    }
17720}
17721impl NetlinkRequest for OpDelsetelemDo<'_> {
17722    fn protocol(&self) -> Protocol {
17723        Protocol::Raw {
17724            protonum: 12u16,
17725            request_type: 2574u16,
17726        }
17727    }
17728    fn flags(&self) -> u16 {
17729        self.request.flags
17730    }
17731    fn payload(&self) -> &[u8] {
17732        self.request.buf()
17733    }
17734    type ReplyType<'buf> = (Nfgenmsg, IterableSetelemListAttrs<'buf>);
17735    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17736        Self::decode_request(buf)
17737    }
17738    fn lookup(
17739        buf: &[u8],
17740        offset: usize,
17741        missing_type: Option<u16>,
17742    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17743        Self::decode_request(buf)
17744            .1
17745            .lookup_attr(offset, missing_type)
17746    }
17747}
17748#[doc = "Delete an existing set element with destroy semantics\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n"]
17749#[derive(Debug)]
17750pub struct OpDestroysetelemDo<'r> {
17751    request: Request<'r>,
17752}
17753impl<'r> OpDestroysetelemDo<'r> {
17754    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17755        Self::write_header(request.buf_mut(), header);
17756        Self { request: request }
17757    }
17758    pub fn encode_request<'buf>(
17759        buf: &'buf mut Vec<u8>,
17760        header: &Nfgenmsg,
17761    ) -> PushSetelemListAttrs<&'buf mut Vec<u8>> {
17762        Self::write_header(buf, header);
17763        PushSetelemListAttrs::new(buf)
17764    }
17765    pub fn encode(&mut self) -> PushSetelemListAttrs<&mut Vec<u8>> {
17766        PushSetelemListAttrs::new(self.request.buf_mut())
17767    }
17768    pub fn into_encoder(self) -> PushSetelemListAttrs<RequestBuf<'r>> {
17769        PushSetelemListAttrs::new(self.request.buf)
17770    }
17771    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableSetelemListAttrs<'a>) {
17772        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17773        (
17774            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17775            IterableSetelemListAttrs::with_loc(attrs, buf.as_ptr() as usize),
17776        )
17777    }
17778    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17779        prev.as_rec_mut().extend(header.as_slice());
17780    }
17781}
17782impl NetlinkRequest for OpDestroysetelemDo<'_> {
17783    fn protocol(&self) -> Protocol {
17784        Protocol::Raw {
17785            protonum: 12u16,
17786            request_type: 2590u16,
17787        }
17788    }
17789    fn flags(&self) -> u16 {
17790        self.request.flags
17791    }
17792    fn payload(&self) -> &[u8] {
17793        self.request.buf()
17794    }
17795    type ReplyType<'buf> = (Nfgenmsg, IterableSetelemListAttrs<'buf>);
17796    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17797        Self::decode_request(buf)
17798    }
17799    fn lookup(
17800        buf: &[u8],
17801        offset: usize,
17802        missing_type: Option<u16>,
17803    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17804        Self::decode_request(buf)
17805            .1
17806            .lookup_attr(offset, missing_type)
17807    }
17808}
17809#[doc = "Get / dump rule\\-set generation\\.\n\nReply attributes:\n- [.get_id()](IterableGenAttrs::get_id)\n- [.get_proc_pid()](IterableGenAttrs::get_proc_pid)\n- [.get_proc_name()](IterableGenAttrs::get_proc_name)\n"]
17810#[derive(Debug)]
17811pub struct OpGetgenDump<'r> {
17812    request: Request<'r>,
17813}
17814impl<'r> OpGetgenDump<'r> {
17815    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17816        Self::write_header(request.buf_mut(), header);
17817        Self {
17818            request: request.set_dump(),
17819        }
17820    }
17821    pub fn encode_request<'buf>(
17822        buf: &'buf mut Vec<u8>,
17823        header: &Nfgenmsg,
17824    ) -> PushGenAttrs<&'buf mut Vec<u8>> {
17825        Self::write_header(buf, header);
17826        PushGenAttrs::new(buf)
17827    }
17828    pub fn encode(&mut self) -> PushGenAttrs<&mut Vec<u8>> {
17829        PushGenAttrs::new(self.request.buf_mut())
17830    }
17831    pub fn into_encoder(self) -> PushGenAttrs<RequestBuf<'r>> {
17832        PushGenAttrs::new(self.request.buf)
17833    }
17834    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableGenAttrs<'a>) {
17835        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17836        (
17837            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17838            IterableGenAttrs::with_loc(attrs, buf.as_ptr() as usize),
17839        )
17840    }
17841    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17842        prev.as_rec_mut().extend(header.as_slice());
17843    }
17844}
17845impl NetlinkRequest for OpGetgenDump<'_> {
17846    fn protocol(&self) -> Protocol {
17847        Protocol::Raw {
17848            protonum: 12u16,
17849            request_type: 2576u16,
17850        }
17851    }
17852    fn flags(&self) -> u16 {
17853        self.request.flags
17854    }
17855    fn payload(&self) -> &[u8] {
17856        self.request.buf()
17857    }
17858    type ReplyType<'buf> = (Nfgenmsg, IterableGenAttrs<'buf>);
17859    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17860        Self::decode_request(buf)
17861    }
17862    fn lookup(
17863        buf: &[u8],
17864        offset: usize,
17865        missing_type: Option<u16>,
17866    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17867        Self::decode_request(buf)
17868            .1
17869            .lookup_attr(offset, missing_type)
17870    }
17871}
17872#[doc = "Get / dump rule\\-set generation\\.\n\nReply attributes:\n- [.get_id()](IterableGenAttrs::get_id)\n- [.get_proc_pid()](IterableGenAttrs::get_proc_pid)\n- [.get_proc_name()](IterableGenAttrs::get_proc_name)\n"]
17873#[derive(Debug)]
17874pub struct OpGetgenDo<'r> {
17875    request: Request<'r>,
17876}
17877impl<'r> OpGetgenDo<'r> {
17878    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17879        Self::write_header(request.buf_mut(), header);
17880        Self { request: request }
17881    }
17882    pub fn encode_request<'buf>(
17883        buf: &'buf mut Vec<u8>,
17884        header: &Nfgenmsg,
17885    ) -> PushGenAttrs<&'buf mut Vec<u8>> {
17886        Self::write_header(buf, header);
17887        PushGenAttrs::new(buf)
17888    }
17889    pub fn encode(&mut self) -> PushGenAttrs<&mut Vec<u8>> {
17890        PushGenAttrs::new(self.request.buf_mut())
17891    }
17892    pub fn into_encoder(self) -> PushGenAttrs<RequestBuf<'r>> {
17893        PushGenAttrs::new(self.request.buf)
17894    }
17895    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableGenAttrs<'a>) {
17896        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17897        (
17898            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17899            IterableGenAttrs::with_loc(attrs, buf.as_ptr() as usize),
17900        )
17901    }
17902    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17903        prev.as_rec_mut().extend(header.as_slice());
17904    }
17905}
17906impl NetlinkRequest for OpGetgenDo<'_> {
17907    fn protocol(&self) -> Protocol {
17908        Protocol::Raw {
17909            protonum: 12u16,
17910            request_type: 2576u16,
17911        }
17912    }
17913    fn flags(&self) -> u16 {
17914        self.request.flags
17915    }
17916    fn payload(&self) -> &[u8] {
17917        self.request.buf()
17918    }
17919    type ReplyType<'buf> = (Nfgenmsg, IterableGenAttrs<'buf>);
17920    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17921        Self::decode_request(buf)
17922    }
17923    fn lookup(
17924        buf: &[u8],
17925        offset: usize,
17926        missing_type: Option<u16>,
17927    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17928        Self::decode_request(buf)
17929            .1
17930            .lookup_attr(offset, missing_type)
17931    }
17932}
17933#[doc = "Create a new stateful object\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_name()](PushObjAttrs::push_name)\n- [.push_type()](PushObjAttrs::push_type)\n- [.nested_data_counter()](PushObjAttrs::nested_data_counter)\n- [.nested_data_quota()](PushObjAttrs::nested_data_quota)\n- [.push_userdata()](PushObjAttrs::push_userdata)\n"]
17934#[derive(Debug)]
17935pub struct OpNewobjDo<'r> {
17936    request: Request<'r>,
17937}
17938impl<'r> OpNewobjDo<'r> {
17939    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
17940        Self::write_header(request.buf_mut(), header);
17941        Self { request: request }
17942    }
17943    pub fn encode_request<'buf>(
17944        buf: &'buf mut Vec<u8>,
17945        header: &Nfgenmsg,
17946    ) -> PushObjAttrs<&'buf mut Vec<u8>> {
17947        Self::write_header(buf, header);
17948        PushObjAttrs::new(buf)
17949    }
17950    pub fn encode(&mut self) -> PushObjAttrs<&mut Vec<u8>> {
17951        PushObjAttrs::new(self.request.buf_mut())
17952    }
17953    pub fn into_encoder(self) -> PushObjAttrs<RequestBuf<'r>> {
17954        PushObjAttrs::new(self.request.buf)
17955    }
17956    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableObjAttrs<'a>) {
17957        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
17958        (
17959            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
17960            IterableObjAttrs::with_loc(attrs, buf.as_ptr() as usize),
17961        )
17962    }
17963    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
17964        prev.as_rec_mut().extend(header.as_slice());
17965    }
17966}
17967impl NetlinkRequest for OpNewobjDo<'_> {
17968    fn protocol(&self) -> Protocol {
17969        Protocol::Raw {
17970            protonum: 12u16,
17971            request_type: 2578u16,
17972        }
17973    }
17974    fn flags(&self) -> u16 {
17975        self.request.flags
17976    }
17977    fn payload(&self) -> &[u8] {
17978        self.request.buf()
17979    }
17980    type ReplyType<'buf> = (Nfgenmsg, IterableObjAttrs<'buf>);
17981    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
17982        Self::decode_request(buf)
17983    }
17984    fn lookup(
17985        buf: &[u8],
17986        offset: usize,
17987        missing_type: Option<u16>,
17988    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
17989        Self::decode_request(buf)
17990            .1
17991            .lookup_attr(offset, missing_type)
17992    }
17993}
17994#[doc = "Get / dump stateful objects\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_type()](PushObjAttrs::push_type)\n\nReply attributes:\n- [.get_table()](IterableObjAttrs::get_table)\n- [.get_name()](IterableObjAttrs::get_name)\n- [.get_type()](IterableObjAttrs::get_type)\n- [.get_data()](IterableObjAttrs::get_data)\n- [.get_use()](IterableObjAttrs::get_use)\n- [.get_handle()](IterableObjAttrs::get_handle)\n- [.get_userdata()](IterableObjAttrs::get_userdata)\n"]
17995#[derive(Debug)]
17996pub struct OpGetobjDump<'r> {
17997    request: Request<'r>,
17998}
17999impl<'r> OpGetobjDump<'r> {
18000    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18001        Self::write_header(request.buf_mut(), header);
18002        Self {
18003            request: request.set_dump(),
18004        }
18005    }
18006    pub fn encode_request<'buf>(
18007        buf: &'buf mut Vec<u8>,
18008        header: &Nfgenmsg,
18009    ) -> PushObjAttrs<&'buf mut Vec<u8>> {
18010        Self::write_header(buf, header);
18011        PushObjAttrs::new(buf)
18012    }
18013    pub fn encode(&mut self) -> PushObjAttrs<&mut Vec<u8>> {
18014        PushObjAttrs::new(self.request.buf_mut())
18015    }
18016    pub fn into_encoder(self) -> PushObjAttrs<RequestBuf<'r>> {
18017        PushObjAttrs::new(self.request.buf)
18018    }
18019    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableObjAttrs<'a>) {
18020        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18021        (
18022            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18023            IterableObjAttrs::with_loc(attrs, buf.as_ptr() as usize),
18024        )
18025    }
18026    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18027        prev.as_rec_mut().extend(header.as_slice());
18028    }
18029}
18030impl NetlinkRequest for OpGetobjDump<'_> {
18031    fn protocol(&self) -> Protocol {
18032        Protocol::Raw {
18033            protonum: 12u16,
18034            request_type: 2579u16,
18035        }
18036    }
18037    fn flags(&self) -> u16 {
18038        self.request.flags
18039    }
18040    fn payload(&self) -> &[u8] {
18041        self.request.buf()
18042    }
18043    type ReplyType<'buf> = (Nfgenmsg, IterableObjAttrs<'buf>);
18044    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18045        Self::decode_request(buf)
18046    }
18047    fn lookup(
18048        buf: &[u8],
18049        offset: usize,
18050        missing_type: Option<u16>,
18051    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18052        Self::decode_request(buf)
18053            .1
18054            .lookup_attr(offset, missing_type)
18055    }
18056}
18057#[doc = "Get / dump stateful objects\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_name()](PushObjAttrs::push_name)\n- [.push_type()](PushObjAttrs::push_type)\n\nReply attributes:\n- [.get_table()](IterableObjAttrs::get_table)\n- [.get_name()](IterableObjAttrs::get_name)\n- [.get_type()](IterableObjAttrs::get_type)\n- [.get_data()](IterableObjAttrs::get_data)\n- [.get_use()](IterableObjAttrs::get_use)\n- [.get_handle()](IterableObjAttrs::get_handle)\n- [.get_userdata()](IterableObjAttrs::get_userdata)\n"]
18058#[derive(Debug)]
18059pub struct OpGetobjDo<'r> {
18060    request: Request<'r>,
18061}
18062impl<'r> OpGetobjDo<'r> {
18063    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18064        Self::write_header(request.buf_mut(), header);
18065        Self { request: request }
18066    }
18067    pub fn encode_request<'buf>(
18068        buf: &'buf mut Vec<u8>,
18069        header: &Nfgenmsg,
18070    ) -> PushObjAttrs<&'buf mut Vec<u8>> {
18071        Self::write_header(buf, header);
18072        PushObjAttrs::new(buf)
18073    }
18074    pub fn encode(&mut self) -> PushObjAttrs<&mut Vec<u8>> {
18075        PushObjAttrs::new(self.request.buf_mut())
18076    }
18077    pub fn into_encoder(self) -> PushObjAttrs<RequestBuf<'r>> {
18078        PushObjAttrs::new(self.request.buf)
18079    }
18080    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableObjAttrs<'a>) {
18081        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18082        (
18083            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18084            IterableObjAttrs::with_loc(attrs, buf.as_ptr() as usize),
18085        )
18086    }
18087    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18088        prev.as_rec_mut().extend(header.as_slice());
18089    }
18090}
18091impl NetlinkRequest for OpGetobjDo<'_> {
18092    fn protocol(&self) -> Protocol {
18093        Protocol::Raw {
18094            protonum: 12u16,
18095            request_type: 2579u16,
18096        }
18097    }
18098    fn flags(&self) -> u16 {
18099        self.request.flags
18100    }
18101    fn payload(&self) -> &[u8] {
18102        self.request.buf()
18103    }
18104    type ReplyType<'buf> = (Nfgenmsg, IterableObjAttrs<'buf>);
18105    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18106        Self::decode_request(buf)
18107    }
18108    fn lookup(
18109        buf: &[u8],
18110        offset: usize,
18111        missing_type: Option<u16>,
18112    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18113        Self::decode_request(buf)
18114            .1
18115            .lookup_attr(offset, missing_type)
18116    }
18117}
18118#[doc = "Delete an existing stateful object\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_name()](PushObjAttrs::push_name)\n- [.push_type()](PushObjAttrs::push_type)\n- [.push_handle()](PushObjAttrs::push_handle)\n"]
18119#[derive(Debug)]
18120pub struct OpDelobjDo<'r> {
18121    request: Request<'r>,
18122}
18123impl<'r> OpDelobjDo<'r> {
18124    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18125        Self::write_header(request.buf_mut(), header);
18126        Self { request: request }
18127    }
18128    pub fn encode_request<'buf>(
18129        buf: &'buf mut Vec<u8>,
18130        header: &Nfgenmsg,
18131    ) -> PushObjAttrs<&'buf mut Vec<u8>> {
18132        Self::write_header(buf, header);
18133        PushObjAttrs::new(buf)
18134    }
18135    pub fn encode(&mut self) -> PushObjAttrs<&mut Vec<u8>> {
18136        PushObjAttrs::new(self.request.buf_mut())
18137    }
18138    pub fn into_encoder(self) -> PushObjAttrs<RequestBuf<'r>> {
18139        PushObjAttrs::new(self.request.buf)
18140    }
18141    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableObjAttrs<'a>) {
18142        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18143        (
18144            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18145            IterableObjAttrs::with_loc(attrs, buf.as_ptr() as usize),
18146        )
18147    }
18148    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18149        prev.as_rec_mut().extend(header.as_slice());
18150    }
18151}
18152impl NetlinkRequest for OpDelobjDo<'_> {
18153    fn protocol(&self) -> Protocol {
18154        Protocol::Raw {
18155            protonum: 12u16,
18156            request_type: 2580u16,
18157        }
18158    }
18159    fn flags(&self) -> u16 {
18160        self.request.flags
18161    }
18162    fn payload(&self) -> &[u8] {
18163        self.request.buf()
18164    }
18165    type ReplyType<'buf> = (Nfgenmsg, IterableObjAttrs<'buf>);
18166    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18167        Self::decode_request(buf)
18168    }
18169    fn lookup(
18170        buf: &[u8],
18171        offset: usize,
18172        missing_type: Option<u16>,
18173    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18174        Self::decode_request(buf)
18175            .1
18176            .lookup_attr(offset, missing_type)
18177    }
18178}
18179#[doc = "Delete an existing stateful object with destroy semantics\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_name()](PushObjAttrs::push_name)\n- [.push_type()](PushObjAttrs::push_type)\n- [.push_handle()](PushObjAttrs::push_handle)\n"]
18180#[derive(Debug)]
18181pub struct OpDestroyobjDo<'r> {
18182    request: Request<'r>,
18183}
18184impl<'r> OpDestroyobjDo<'r> {
18185    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18186        Self::write_header(request.buf_mut(), header);
18187        Self { request: request }
18188    }
18189    pub fn encode_request<'buf>(
18190        buf: &'buf mut Vec<u8>,
18191        header: &Nfgenmsg,
18192    ) -> PushObjAttrs<&'buf mut Vec<u8>> {
18193        Self::write_header(buf, header);
18194        PushObjAttrs::new(buf)
18195    }
18196    pub fn encode(&mut self) -> PushObjAttrs<&mut Vec<u8>> {
18197        PushObjAttrs::new(self.request.buf_mut())
18198    }
18199    pub fn into_encoder(self) -> PushObjAttrs<RequestBuf<'r>> {
18200        PushObjAttrs::new(self.request.buf)
18201    }
18202    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableObjAttrs<'a>) {
18203        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18204        (
18205            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18206            IterableObjAttrs::with_loc(attrs, buf.as_ptr() as usize),
18207        )
18208    }
18209    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18210        prev.as_rec_mut().extend(header.as_slice());
18211    }
18212}
18213impl NetlinkRequest for OpDestroyobjDo<'_> {
18214    fn protocol(&self) -> Protocol {
18215        Protocol::Raw {
18216            protonum: 12u16,
18217            request_type: 2591u16,
18218        }
18219    }
18220    fn flags(&self) -> u16 {
18221        self.request.flags
18222    }
18223    fn payload(&self) -> &[u8] {
18224        self.request.buf()
18225    }
18226    type ReplyType<'buf> = (Nfgenmsg, IterableObjAttrs<'buf>);
18227    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18228        Self::decode_request(buf)
18229    }
18230    fn lookup(
18231        buf: &[u8],
18232        offset: usize,
18233        missing_type: Option<u16>,
18234    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18235        Self::decode_request(buf)
18236            .1
18237            .lookup_attr(offset, missing_type)
18238    }
18239}
18240#[doc = "Create a new flow table\\.\nRequest attributes:\n- [.push_table()](PushFlowtableAttrs::push_table)\n- [.push_name()](PushFlowtableAttrs::push_name)\n- [.nested_hook()](PushFlowtableAttrs::nested_hook)\n- [.push_flags()](PushFlowtableAttrs::push_flags)\n"]
18241#[derive(Debug)]
18242pub struct OpNewflowtableDo<'r> {
18243    request: Request<'r>,
18244}
18245impl<'r> OpNewflowtableDo<'r> {
18246    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18247        Self::write_header(request.buf_mut(), header);
18248        Self { request: request }
18249    }
18250    pub fn encode_request<'buf>(
18251        buf: &'buf mut Vec<u8>,
18252        header: &Nfgenmsg,
18253    ) -> PushFlowtableAttrs<&'buf mut Vec<u8>> {
18254        Self::write_header(buf, header);
18255        PushFlowtableAttrs::new(buf)
18256    }
18257    pub fn encode(&mut self) -> PushFlowtableAttrs<&mut Vec<u8>> {
18258        PushFlowtableAttrs::new(self.request.buf_mut())
18259    }
18260    pub fn into_encoder(self) -> PushFlowtableAttrs<RequestBuf<'r>> {
18261        PushFlowtableAttrs::new(self.request.buf)
18262    }
18263    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableFlowtableAttrs<'a>) {
18264        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18265        (
18266            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18267            IterableFlowtableAttrs::with_loc(attrs, buf.as_ptr() as usize),
18268        )
18269    }
18270    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18271        prev.as_rec_mut().extend(header.as_slice());
18272    }
18273}
18274impl NetlinkRequest for OpNewflowtableDo<'_> {
18275    fn protocol(&self) -> Protocol {
18276        Protocol::Raw {
18277            protonum: 12u16,
18278            request_type: 2582u16,
18279        }
18280    }
18281    fn flags(&self) -> u16 {
18282        self.request.flags
18283    }
18284    fn payload(&self) -> &[u8] {
18285        self.request.buf()
18286    }
18287    type ReplyType<'buf> = (Nfgenmsg, IterableFlowtableAttrs<'buf>);
18288    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18289        Self::decode_request(buf)
18290    }
18291    fn lookup(
18292        buf: &[u8],
18293        offset: usize,
18294        missing_type: Option<u16>,
18295    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18296        Self::decode_request(buf)
18297            .1
18298            .lookup_attr(offset, missing_type)
18299    }
18300}
18301#[doc = "Get / dump flow tables\\.\n\nReply attributes:\n- [.get_table()](IterableFlowtableAttrs::get_table)\n- [.get_name()](IterableFlowtableAttrs::get_name)\n- [.get_hook()](IterableFlowtableAttrs::get_hook)\n- [.get_use()](IterableFlowtableAttrs::get_use)\n- [.get_handle()](IterableFlowtableAttrs::get_handle)\n- [.get_flags()](IterableFlowtableAttrs::get_flags)\n"]
18302#[derive(Debug)]
18303pub struct OpGetflowtableDump<'r> {
18304    request: Request<'r>,
18305}
18306impl<'r> OpGetflowtableDump<'r> {
18307    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18308        Self::write_header(request.buf_mut(), header);
18309        Self {
18310            request: request.set_dump(),
18311        }
18312    }
18313    pub fn encode_request<'buf>(
18314        buf: &'buf mut Vec<u8>,
18315        header: &Nfgenmsg,
18316    ) -> PushFlowtableAttrs<&'buf mut Vec<u8>> {
18317        Self::write_header(buf, header);
18318        PushFlowtableAttrs::new(buf)
18319    }
18320    pub fn encode(&mut self) -> PushFlowtableAttrs<&mut Vec<u8>> {
18321        PushFlowtableAttrs::new(self.request.buf_mut())
18322    }
18323    pub fn into_encoder(self) -> PushFlowtableAttrs<RequestBuf<'r>> {
18324        PushFlowtableAttrs::new(self.request.buf)
18325    }
18326    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableFlowtableAttrs<'a>) {
18327        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18328        (
18329            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18330            IterableFlowtableAttrs::with_loc(attrs, buf.as_ptr() as usize),
18331        )
18332    }
18333    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18334        prev.as_rec_mut().extend(header.as_slice());
18335    }
18336}
18337impl NetlinkRequest for OpGetflowtableDump<'_> {
18338    fn protocol(&self) -> Protocol {
18339        Protocol::Raw {
18340            protonum: 12u16,
18341            request_type: 2583u16,
18342        }
18343    }
18344    fn flags(&self) -> u16 {
18345        self.request.flags
18346    }
18347    fn payload(&self) -> &[u8] {
18348        self.request.buf()
18349    }
18350    type ReplyType<'buf> = (Nfgenmsg, IterableFlowtableAttrs<'buf>);
18351    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18352        Self::decode_request(buf)
18353    }
18354    fn lookup(
18355        buf: &[u8],
18356        offset: usize,
18357        missing_type: Option<u16>,
18358    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18359        Self::decode_request(buf)
18360            .1
18361            .lookup_attr(offset, missing_type)
18362    }
18363}
18364#[doc = "Get / dump flow tables\\.\nRequest attributes:\n- [.push_table()](PushFlowtableAttrs::push_table)\n- [.push_name()](PushFlowtableAttrs::push_name)\n\nReply attributes:\n- [.get_table()](IterableFlowtableAttrs::get_table)\n- [.get_name()](IterableFlowtableAttrs::get_name)\n- [.get_hook()](IterableFlowtableAttrs::get_hook)\n- [.get_use()](IterableFlowtableAttrs::get_use)\n- [.get_handle()](IterableFlowtableAttrs::get_handle)\n- [.get_flags()](IterableFlowtableAttrs::get_flags)\n"]
18365#[derive(Debug)]
18366pub struct OpGetflowtableDo<'r> {
18367    request: Request<'r>,
18368}
18369impl<'r> OpGetflowtableDo<'r> {
18370    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18371        Self::write_header(request.buf_mut(), header);
18372        Self { request: request }
18373    }
18374    pub fn encode_request<'buf>(
18375        buf: &'buf mut Vec<u8>,
18376        header: &Nfgenmsg,
18377    ) -> PushFlowtableAttrs<&'buf mut Vec<u8>> {
18378        Self::write_header(buf, header);
18379        PushFlowtableAttrs::new(buf)
18380    }
18381    pub fn encode(&mut self) -> PushFlowtableAttrs<&mut Vec<u8>> {
18382        PushFlowtableAttrs::new(self.request.buf_mut())
18383    }
18384    pub fn into_encoder(self) -> PushFlowtableAttrs<RequestBuf<'r>> {
18385        PushFlowtableAttrs::new(self.request.buf)
18386    }
18387    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableFlowtableAttrs<'a>) {
18388        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18389        (
18390            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18391            IterableFlowtableAttrs::with_loc(attrs, buf.as_ptr() as usize),
18392        )
18393    }
18394    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18395        prev.as_rec_mut().extend(header.as_slice());
18396    }
18397}
18398impl NetlinkRequest for OpGetflowtableDo<'_> {
18399    fn protocol(&self) -> Protocol {
18400        Protocol::Raw {
18401            protonum: 12u16,
18402            request_type: 2583u16,
18403        }
18404    }
18405    fn flags(&self) -> u16 {
18406        self.request.flags
18407    }
18408    fn payload(&self) -> &[u8] {
18409        self.request.buf()
18410    }
18411    type ReplyType<'buf> = (Nfgenmsg, IterableFlowtableAttrs<'buf>);
18412    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18413        Self::decode_request(buf)
18414    }
18415    fn lookup(
18416        buf: &[u8],
18417        offset: usize,
18418        missing_type: Option<u16>,
18419    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18420        Self::decode_request(buf)
18421            .1
18422            .lookup_attr(offset, missing_type)
18423    }
18424}
18425#[doc = "Delete an existing flow table\\.\nRequest attributes:\n- [.push_table()](PushFlowtableAttrs::push_table)\n- [.push_name()](PushFlowtableAttrs::push_name)\n- [.nested_hook()](PushFlowtableAttrs::nested_hook)\n- [.push_handle()](PushFlowtableAttrs::push_handle)\n"]
18426#[derive(Debug)]
18427pub struct OpDelflowtableDo<'r> {
18428    request: Request<'r>,
18429}
18430impl<'r> OpDelflowtableDo<'r> {
18431    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18432        Self::write_header(request.buf_mut(), header);
18433        Self { request: request }
18434    }
18435    pub fn encode_request<'buf>(
18436        buf: &'buf mut Vec<u8>,
18437        header: &Nfgenmsg,
18438    ) -> PushFlowtableAttrs<&'buf mut Vec<u8>> {
18439        Self::write_header(buf, header);
18440        PushFlowtableAttrs::new(buf)
18441    }
18442    pub fn encode(&mut self) -> PushFlowtableAttrs<&mut Vec<u8>> {
18443        PushFlowtableAttrs::new(self.request.buf_mut())
18444    }
18445    pub fn into_encoder(self) -> PushFlowtableAttrs<RequestBuf<'r>> {
18446        PushFlowtableAttrs::new(self.request.buf)
18447    }
18448    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableFlowtableAttrs<'a>) {
18449        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18450        (
18451            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18452            IterableFlowtableAttrs::with_loc(attrs, buf.as_ptr() as usize),
18453        )
18454    }
18455    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18456        prev.as_rec_mut().extend(header.as_slice());
18457    }
18458}
18459impl NetlinkRequest for OpDelflowtableDo<'_> {
18460    fn protocol(&self) -> Protocol {
18461        Protocol::Raw {
18462            protonum: 12u16,
18463            request_type: 2584u16,
18464        }
18465    }
18466    fn flags(&self) -> u16 {
18467        self.request.flags
18468    }
18469    fn payload(&self) -> &[u8] {
18470        self.request.buf()
18471    }
18472    type ReplyType<'buf> = (Nfgenmsg, IterableFlowtableAttrs<'buf>);
18473    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18474        Self::decode_request(buf)
18475    }
18476    fn lookup(
18477        buf: &[u8],
18478        offset: usize,
18479        missing_type: Option<u16>,
18480    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18481        Self::decode_request(buf)
18482            .1
18483            .lookup_attr(offset, missing_type)
18484    }
18485}
18486#[doc = "Delete an existing flow table with destroy semantics\\.\nRequest attributes:\n- [.push_table()](PushFlowtableAttrs::push_table)\n- [.push_name()](PushFlowtableAttrs::push_name)\n- [.nested_hook()](PushFlowtableAttrs::nested_hook)\n- [.push_handle()](PushFlowtableAttrs::push_handle)\n"]
18487#[derive(Debug)]
18488pub struct OpDestroyflowtableDo<'r> {
18489    request: Request<'r>,
18490}
18491impl<'r> OpDestroyflowtableDo<'r> {
18492    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18493        Self::write_header(request.buf_mut(), header);
18494        Self { request: request }
18495    }
18496    pub fn encode_request<'buf>(
18497        buf: &'buf mut Vec<u8>,
18498        header: &Nfgenmsg,
18499    ) -> PushFlowtableAttrs<&'buf mut Vec<u8>> {
18500        Self::write_header(buf, header);
18501        PushFlowtableAttrs::new(buf)
18502    }
18503    pub fn encode(&mut self) -> PushFlowtableAttrs<&mut Vec<u8>> {
18504        PushFlowtableAttrs::new(self.request.buf_mut())
18505    }
18506    pub fn into_encoder(self) -> PushFlowtableAttrs<RequestBuf<'r>> {
18507        PushFlowtableAttrs::new(self.request.buf)
18508    }
18509    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableFlowtableAttrs<'a>) {
18510        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18511        (
18512            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18513            IterableFlowtableAttrs::with_loc(attrs, buf.as_ptr() as usize),
18514        )
18515    }
18516    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18517        prev.as_rec_mut().extend(header.as_slice());
18518    }
18519}
18520impl NetlinkRequest for OpDestroyflowtableDo<'_> {
18521    fn protocol(&self) -> Protocol {
18522        Protocol::Raw {
18523            protonum: 12u16,
18524            request_type: 2592u16,
18525        }
18526    }
18527    fn flags(&self) -> u16 {
18528        self.request.flags
18529    }
18530    fn payload(&self) -> &[u8] {
18531        self.request.buf()
18532    }
18533    type ReplyType<'buf> = (Nfgenmsg, IterableFlowtableAttrs<'buf>);
18534    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18535        Self::decode_request(buf)
18536    }
18537    fn lookup(
18538        buf: &[u8],
18539        offset: usize,
18540        missing_type: Option<u16>,
18541    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18542        Self::decode_request(buf)
18543            .1
18544            .lookup_attr(offset, missing_type)
18545    }
18546}
18547#[doc = "Get / dump nft\\_compat info\n\nReply attributes:\n- [.get_name()](IterableCompatAttrs::get_name)\n- [.get_rev()](IterableCompatAttrs::get_rev)\n- [.get_type()](IterableCompatAttrs::get_type)\n"]
18548#[derive(Debug)]
18549pub struct OpGetcompatDump<'r> {
18550    request: Request<'r>,
18551}
18552impl<'r> OpGetcompatDump<'r> {
18553    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18554        Self::write_header(request.buf_mut(), header);
18555        Self {
18556            request: request.set_dump(),
18557        }
18558    }
18559    pub fn encode_request<'buf>(
18560        buf: &'buf mut Vec<u8>,
18561        header: &Nfgenmsg,
18562    ) -> PushCompatAttrs<&'buf mut Vec<u8>> {
18563        Self::write_header(buf, header);
18564        PushCompatAttrs::new(buf)
18565    }
18566    pub fn encode(&mut self) -> PushCompatAttrs<&mut Vec<u8>> {
18567        PushCompatAttrs::new(self.request.buf_mut())
18568    }
18569    pub fn into_encoder(self) -> PushCompatAttrs<RequestBuf<'r>> {
18570        PushCompatAttrs::new(self.request.buf)
18571    }
18572    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableCompatAttrs<'a>) {
18573        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18574        (
18575            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18576            IterableCompatAttrs::with_loc(attrs, buf.as_ptr() as usize),
18577        )
18578    }
18579    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18580        prev.as_rec_mut().extend(header.as_slice());
18581    }
18582}
18583impl NetlinkRequest for OpGetcompatDump<'_> {
18584    fn protocol(&self) -> Protocol {
18585        Protocol::Raw {
18586            protonum: 12u16,
18587            request_type: 2816u16,
18588        }
18589    }
18590    fn flags(&self) -> u16 {
18591        self.request.flags
18592    }
18593    fn payload(&self) -> &[u8] {
18594        self.request.buf()
18595    }
18596    type ReplyType<'buf> = (Nfgenmsg, IterableCompatAttrs<'buf>);
18597    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18598        Self::decode_request(buf)
18599    }
18600    fn lookup(
18601        buf: &[u8],
18602        offset: usize,
18603        missing_type: Option<u16>,
18604    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18605        Self::decode_request(buf)
18606            .1
18607            .lookup_attr(offset, missing_type)
18608    }
18609}
18610#[doc = "Get / dump nft\\_compat info\nRequest attributes:\n- [.push_name()](PushCompatAttrs::push_name)\n- [.push_rev()](PushCompatAttrs::push_rev)\n- [.push_type()](PushCompatAttrs::push_type)\n\nReply attributes:\n- [.get_name()](IterableCompatAttrs::get_name)\n- [.get_rev()](IterableCompatAttrs::get_rev)\n- [.get_type()](IterableCompatAttrs::get_type)\n"]
18611#[derive(Debug)]
18612pub struct OpGetcompatDo<'r> {
18613    request: Request<'r>,
18614}
18615impl<'r> OpGetcompatDo<'r> {
18616    pub fn new(mut request: Request<'r>, header: &Nfgenmsg) -> Self {
18617        Self::write_header(request.buf_mut(), header);
18618        Self { request: request }
18619    }
18620    pub fn encode_request<'buf>(
18621        buf: &'buf mut Vec<u8>,
18622        header: &Nfgenmsg,
18623    ) -> PushCompatAttrs<&'buf mut Vec<u8>> {
18624        Self::write_header(buf, header);
18625        PushCompatAttrs::new(buf)
18626    }
18627    pub fn encode(&mut self) -> PushCompatAttrs<&mut Vec<u8>> {
18628        PushCompatAttrs::new(self.request.buf_mut())
18629    }
18630    pub fn into_encoder(self) -> PushCompatAttrs<RequestBuf<'r>> {
18631        PushCompatAttrs::new(self.request.buf)
18632    }
18633    pub fn decode_request<'a>(buf: &'a [u8]) -> (Nfgenmsg, IterableCompatAttrs<'a>) {
18634        let (header, attrs) = buf.split_at(buf.len().min(Nfgenmsg::len()));
18635        (
18636            Nfgenmsg::new_from_slice(header).unwrap_or_default(),
18637            IterableCompatAttrs::with_loc(attrs, buf.as_ptr() as usize),
18638        )
18639    }
18640    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Nfgenmsg) {
18641        prev.as_rec_mut().extend(header.as_slice());
18642    }
18643}
18644impl NetlinkRequest for OpGetcompatDo<'_> {
18645    fn protocol(&self) -> Protocol {
18646        Protocol::Raw {
18647            protonum: 12u16,
18648            request_type: 2816u16,
18649        }
18650    }
18651    fn flags(&self) -> u16 {
18652        self.request.flags
18653    }
18654    fn payload(&self) -> &[u8] {
18655        self.request.buf()
18656    }
18657    type ReplyType<'buf> = (Nfgenmsg, IterableCompatAttrs<'buf>);
18658    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
18659        Self::decode_request(buf)
18660    }
18661    fn lookup(
18662        buf: &[u8],
18663        offset: usize,
18664        missing_type: Option<u16>,
18665    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
18666        Self::decode_request(buf)
18667            .1
18668            .lookup_attr(offset, missing_type)
18669    }
18670}
18671#[derive(Debug)]
18672pub struct ChainedFinal<'a> {
18673    inner: Chained<'a>,
18674}
18675#[derive(Debug)]
18676pub struct Chained<'a> {
18677    buf: RequestBuf<'a>,
18678    first_seq: u32,
18679    lookups: Vec<(&'static str, LookupFn)>,
18680    last_header_offset: usize,
18681    last_kind: Option<RequestInfo>,
18682}
18683impl<'a> ChainedFinal<'a> {
18684    pub fn into_chained(self) -> Chained<'a> {
18685        self.inner
18686    }
18687    pub fn buf(&self) -> &Vec<u8> {
18688        self.inner.buf()
18689    }
18690    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
18691        self.inner.buf_mut()
18692    }
18693    fn get_index(&self, seq: u32) -> Option<u32> {
18694        let min = self.inner.first_seq;
18695        let max = min.wrapping_add(self.inner.lookups.len() as u32);
18696        return if min <= max {
18697            (min..max).contains(&seq).then(|| seq - min)
18698        } else if min <= seq {
18699            Some(seq - min)
18700        } else if seq < max {
18701            Some(u32::MAX - min + seq)
18702        } else {
18703            None
18704        };
18705    }
18706}
18707impl crate::traits::NetlinkChained for ChainedFinal<'_> {
18708    fn protonum(&self) -> u16 {
18709        PROTONUM
18710    }
18711    fn payload(&self) -> &[u8] {
18712        self.buf()
18713    }
18714    fn chain_len(&self) -> usize {
18715        self.inner.lookups.len()
18716    }
18717    fn get_index(&self, seq: u32) -> Option<usize> {
18718        self.get_index(seq).map(|n| n as usize)
18719    }
18720    fn name(&self, index: usize) -> &'static str {
18721        self.inner.lookups[index].0
18722    }
18723    fn lookup(&self, index: usize) -> LookupFn {
18724        self.inner.lookups[index].1
18725    }
18726    fn supports_ack(&self, index: usize) -> Option<bool> {
18727        Some(match self.inner.lookups.get(index)?.1 as *const LookupFn {
18728            f if f == OpBatchBeginDo::lookup as *const LookupFn => false,
18729            f if f == OpBatchEndDo::lookup as *const LookupFn => false,
18730            _ => true,
18731        })
18732    }
18733}
18734impl Chained<'static> {
18735    pub fn new(first_seq: u32) -> Self {
18736        Self::new_from_buf(Vec::new(), first_seq)
18737    }
18738    pub fn new_from_buf(buf: Vec<u8>, first_seq: u32) -> Self {
18739        Self {
18740            buf: RequestBuf::Own(buf),
18741            first_seq,
18742            lookups: Vec::new(),
18743            last_header_offset: 0,
18744            last_kind: None,
18745        }
18746    }
18747    pub fn into_buf(self) -> Vec<u8> {
18748        match self.buf {
18749            RequestBuf::Own(buf) => buf,
18750            _ => unreachable!(),
18751        }
18752    }
18753}
18754impl<'a> Chained<'a> {
18755    pub fn new_with_buf(buf: &'a mut Vec<u8>, first_seq: u32) -> Self {
18756        Self {
18757            buf: RequestBuf::Ref(buf),
18758            first_seq,
18759            lookups: Vec::new(),
18760            last_header_offset: 0,
18761            last_kind: None,
18762        }
18763    }
18764    pub fn finalize(mut self) -> ChainedFinal<'a> {
18765        self.update_header();
18766        ChainedFinal { inner: self }
18767    }
18768    pub fn request(&mut self) -> Request<'_> {
18769        self.update_header();
18770        self.last_header_offset = self.buf().len();
18771        self.buf_mut().extend_from_slice(Nlmsghdr::new().as_slice());
18772        let mut request = Request::new_extend(self.buf.buf_mut());
18773        self.last_kind = None;
18774        request.writeback = Some(&mut self.last_kind);
18775        request
18776    }
18777    pub fn buf(&self) -> &Vec<u8> {
18778        self.buf.buf()
18779    }
18780    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
18781        self.buf.buf_mut()
18782    }
18783    fn update_header(&mut self) {
18784        let Some(RequestInfo {
18785            protocol,
18786            flags,
18787            name,
18788            lookup,
18789        }) = self.last_kind
18790        else {
18791            if !self.buf().is_empty() {
18792                assert_eq!(self.last_header_offset + Nlmsghdr::len(), self.buf().len());
18793                self.buf.buf_mut().truncate(self.last_header_offset);
18794            }
18795            return;
18796        };
18797        let header_offset = self.last_header_offset;
18798        let request_type = match protocol {
18799            Protocol::Raw { request_type, .. } => request_type,
18800            Protocol::Generic(_) => unreachable!(),
18801        };
18802        let index = self.lookups.len();
18803        let seq = self.first_seq.wrapping_add(index as u32);
18804        self.lookups.push((name, lookup));
18805        let buf = self.buf_mut();
18806        align(buf);
18807        let header = Nlmsghdr {
18808            len: (buf.len() - header_offset) as u32,
18809            r#type: request_type,
18810            flags: flags | consts::NLM_F_REQUEST as u16 | consts::NLM_F_ACK as u16,
18811            seq,
18812            pid: 0,
18813        };
18814        buf[header_offset..(header_offset + 16)].clone_from_slice(header.as_slice());
18815    }
18816}
18817use crate::traits::LookupFn;
18818use crate::utils::RequestBuf;
18819#[derive(Debug)]
18820pub struct Request<'buf> {
18821    buf: RequestBuf<'buf>,
18822    flags: u16,
18823    writeback: Option<&'buf mut Option<RequestInfo>>,
18824}
18825#[allow(unused)]
18826#[derive(Debug, Clone)]
18827pub struct RequestInfo {
18828    protocol: Protocol,
18829    flags: u16,
18830    name: &'static str,
18831    lookup: LookupFn,
18832}
18833impl Request<'static> {
18834    pub fn new() -> Self {
18835        Self::new_from_buf(Vec::new())
18836    }
18837    pub fn new_from_buf(buf: Vec<u8>) -> Self {
18838        Self {
18839            flags: 0,
18840            buf: RequestBuf::Own(buf),
18841            writeback: None,
18842        }
18843    }
18844    pub fn into_buf(self) -> Vec<u8> {
18845        match self.buf {
18846            RequestBuf::Own(buf) => buf,
18847            _ => unreachable!(),
18848        }
18849    }
18850}
18851impl<'buf> Request<'buf> {
18852    pub fn new_with_buf(buf: &'buf mut Vec<u8>) -> Self {
18853        buf.clear();
18854        Self::new_extend(buf)
18855    }
18856    pub fn new_extend(buf: &'buf mut Vec<u8>) -> Self {
18857        Self {
18858            flags: 0,
18859            buf: RequestBuf::Ref(buf),
18860            writeback: None,
18861        }
18862    }
18863    fn do_writeback(&mut self, protocol: Protocol, name: &'static str, lookup: LookupFn) {
18864        let Some(writeback) = &mut self.writeback else {
18865            return;
18866        };
18867        **writeback = Some(RequestInfo {
18868            protocol,
18869            flags: self.flags,
18870            name,
18871            lookup,
18872        })
18873    }
18874    pub fn buf(&self) -> &Vec<u8> {
18875        self.buf.buf()
18876    }
18877    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
18878        self.buf.buf_mut()
18879    }
18880    #[doc = "Set `NLM_F_CREATE` flag"]
18881    pub fn set_create(mut self) -> Self {
18882        self.flags |= consts::NLM_F_CREATE as u16;
18883        self
18884    }
18885    #[doc = "Set `NLM_F_EXCL` flag"]
18886    pub fn set_excl(mut self) -> Self {
18887        self.flags |= consts::NLM_F_EXCL as u16;
18888        self
18889    }
18890    #[doc = "Set `NLM_F_REPLACE` flag"]
18891    pub fn set_replace(mut self) -> Self {
18892        self.flags |= consts::NLM_F_REPLACE as u16;
18893        self
18894    }
18895    #[doc = "Set `NLM_F_CREATE` and `NLM_F_REPLACE` flag"]
18896    pub fn set_change(self) -> Self {
18897        self.set_create().set_replace()
18898    }
18899    #[doc = "Set `NLM_F_APPEND` flag"]
18900    pub fn set_append(mut self) -> Self {
18901        self.flags |= consts::NLM_F_APPEND as u16;
18902        self
18903    }
18904    #[doc = "Set `self.flags |= flags`"]
18905    pub fn set_flags(mut self, flags: u16) -> Self {
18906        self.flags |= flags;
18907        self
18908    }
18909    #[doc = "Set `self.flags ^= self.flags & flags`"]
18910    pub fn unset_flags(mut self, flags: u16) -> Self {
18911        self.flags ^= self.flags & flags;
18912        self
18913    }
18914    #[doc = "Set `NLM_F_DUMP` flag"]
18915    fn set_dump(mut self) -> Self {
18916        self.flags |= consts::NLM_F_DUMP as u16;
18917        self
18918    }
18919    #[doc = "Start a batch of operations\nRequest attributes:\n- [.push_genid()](PushBatchAttrs::push_genid)\n\nReply attributes:\n- [.get_genid()](IterableBatchAttrs::get_genid)\n"]
18920    pub fn op_batch_begin_do(self, header: &Nfgenmsg) -> OpBatchBeginDo<'buf> {
18921        let mut res = OpBatchBeginDo::new(self, header);
18922        res.request
18923            .do_writeback(res.protocol(), "op-batch-begin-do", OpBatchBeginDo::lookup);
18924        res
18925    }
18926    #[doc = "Finish a batch of operations\nRequest attributes:\n- [.push_genid()](PushBatchAttrs::push_genid)\n"]
18927    pub fn op_batch_end_do(self, header: &Nfgenmsg) -> OpBatchEndDo<'buf> {
18928        let mut res = OpBatchEndDo::new(self, header);
18929        res.request
18930            .do_writeback(res.protocol(), "op-batch-end-do", OpBatchEndDo::lookup);
18931        res
18932    }
18933    #[doc = "Create a new table\\.\nRequest attributes:\n- [.push_name()](PushTableAttrs::push_name)\n- [.push_flags()](PushTableAttrs::push_flags)\n- [.push_userdata()](PushTableAttrs::push_userdata)\n"]
18934    pub fn op_newtable_do(self, header: &Nfgenmsg) -> OpNewtableDo<'buf> {
18935        let mut res = OpNewtableDo::new(self, header);
18936        res.request
18937            .do_writeback(res.protocol(), "op-newtable-do", OpNewtableDo::lookup);
18938        res
18939    }
18940    #[doc = "Get / dump tables\\.\n\nReply attributes:\n- [.get_name()](IterableTableAttrs::get_name)\n- [.get_flags()](IterableTableAttrs::get_flags)\n- [.get_use()](IterableTableAttrs::get_use)\n- [.get_handle()](IterableTableAttrs::get_handle)\n- [.get_userdata()](IterableTableAttrs::get_userdata)\n- [.get_owner()](IterableTableAttrs::get_owner)\n"]
18941    pub fn op_gettable_dump(self, header: &Nfgenmsg) -> OpGettableDump<'buf> {
18942        let mut res = OpGettableDump::new(self, header);
18943        res.request
18944            .do_writeback(res.protocol(), "op-gettable-dump", OpGettableDump::lookup);
18945        res
18946    }
18947    #[doc = "Get / dump tables\\.\nRequest attributes:\n- [.push_name()](PushTableAttrs::push_name)\n\nReply attributes:\n- [.get_name()](IterableTableAttrs::get_name)\n- [.get_flags()](IterableTableAttrs::get_flags)\n- [.get_use()](IterableTableAttrs::get_use)\n- [.get_handle()](IterableTableAttrs::get_handle)\n- [.get_userdata()](IterableTableAttrs::get_userdata)\n- [.get_owner()](IterableTableAttrs::get_owner)\n"]
18948    pub fn op_gettable_do(self, header: &Nfgenmsg) -> OpGettableDo<'buf> {
18949        let mut res = OpGettableDo::new(self, header);
18950        res.request
18951            .do_writeback(res.protocol(), "op-gettable-do", OpGettableDo::lookup);
18952        res
18953    }
18954    #[doc = "Delete an existing table\\.\nRequest attributes:\n- [.push_name()](PushTableAttrs::push_name)\n- [.push_handle()](PushTableAttrs::push_handle)\n"]
18955    pub fn op_deltable_do(self, header: &Nfgenmsg) -> OpDeltableDo<'buf> {
18956        let mut res = OpDeltableDo::new(self, header);
18957        res.request
18958            .do_writeback(res.protocol(), "op-deltable-do", OpDeltableDo::lookup);
18959        res
18960    }
18961    #[doc = "Delete an existing table with destroy semantics (ignoring ENOENT\nerrors)\\.\n\nRequest attributes:\n- [.push_name()](PushTableAttrs::push_name)\n- [.push_handle()](PushTableAttrs::push_handle)\n"]
18962    pub fn op_destroytable_do(self, header: &Nfgenmsg) -> OpDestroytableDo<'buf> {
18963        let mut res = OpDestroytableDo::new(self, header);
18964        res.request.do_writeback(
18965            res.protocol(),
18966            "op-destroytable-do",
18967            OpDestroytableDo::lookup,
18968        );
18969        res
18970    }
18971    #[doc = "Create a new chain\\.\nRequest attributes:\n- [.push_table()](PushChainAttrs::push_table)\n- [.push_handle()](PushChainAttrs::push_handle)\n- [.push_name()](PushChainAttrs::push_name)\n- [.nested_hook()](PushChainAttrs::nested_hook)\n- [.push_policy()](PushChainAttrs::push_policy)\n- [.push_type()](PushChainAttrs::push_type)\n- [.nested_counters()](PushChainAttrs::nested_counters)\n- [.push_flags()](PushChainAttrs::push_flags)\n- [.push_userdata()](PushChainAttrs::push_userdata)\n"]
18972    pub fn op_newchain_do(self, header: &Nfgenmsg) -> OpNewchainDo<'buf> {
18973        let mut res = OpNewchainDo::new(self, header);
18974        res.request
18975            .do_writeback(res.protocol(), "op-newchain-do", OpNewchainDo::lookup);
18976        res
18977    }
18978    #[doc = "Get / dump chains\\.\n\nReply attributes:\n- [.get_table()](IterableChainAttrs::get_table)\n- [.get_handle()](IterableChainAttrs::get_handle)\n- [.get_name()](IterableChainAttrs::get_name)\n- [.get_hook()](IterableChainAttrs::get_hook)\n- [.get_policy()](IterableChainAttrs::get_policy)\n- [.get_use()](IterableChainAttrs::get_use)\n- [.get_type()](IterableChainAttrs::get_type)\n- [.get_counters()](IterableChainAttrs::get_counters)\n- [.get_flags()](IterableChainAttrs::get_flags)\n- [.get_id()](IterableChainAttrs::get_id)\n- [.get_userdata()](IterableChainAttrs::get_userdata)\n"]
18979    pub fn op_getchain_dump(self, header: &Nfgenmsg) -> OpGetchainDump<'buf> {
18980        let mut res = OpGetchainDump::new(self, header);
18981        res.request
18982            .do_writeback(res.protocol(), "op-getchain-dump", OpGetchainDump::lookup);
18983        res
18984    }
18985    #[doc = "Get / dump chains\\.\nRequest attributes:\n- [.push_table()](PushChainAttrs::push_table)\n- [.push_name()](PushChainAttrs::push_name)\n\nReply attributes:\n- [.get_table()](IterableChainAttrs::get_table)\n- [.get_handle()](IterableChainAttrs::get_handle)\n- [.get_name()](IterableChainAttrs::get_name)\n- [.get_hook()](IterableChainAttrs::get_hook)\n- [.get_policy()](IterableChainAttrs::get_policy)\n- [.get_use()](IterableChainAttrs::get_use)\n- [.get_type()](IterableChainAttrs::get_type)\n- [.get_counters()](IterableChainAttrs::get_counters)\n- [.get_flags()](IterableChainAttrs::get_flags)\n- [.get_id()](IterableChainAttrs::get_id)\n- [.get_userdata()](IterableChainAttrs::get_userdata)\n"]
18986    pub fn op_getchain_do(self, header: &Nfgenmsg) -> OpGetchainDo<'buf> {
18987        let mut res = OpGetchainDo::new(self, header);
18988        res.request
18989            .do_writeback(res.protocol(), "op-getchain-do", OpGetchainDo::lookup);
18990        res
18991    }
18992    #[doc = "Delete an existing chain\\.\nRequest attributes:\n- [.push_table()](PushChainAttrs::push_table)\n- [.push_handle()](PushChainAttrs::push_handle)\n- [.push_name()](PushChainAttrs::push_name)\n- [.nested_hook()](PushChainAttrs::nested_hook)\n"]
18993    pub fn op_delchain_do(self, header: &Nfgenmsg) -> OpDelchainDo<'buf> {
18994        let mut res = OpDelchainDo::new(self, header);
18995        res.request
18996            .do_writeback(res.protocol(), "op-delchain-do", OpDelchainDo::lookup);
18997        res
18998    }
18999    #[doc = "Delete an existing chain with destroy semantics (ignoring ENOENT\nerrors)\\.\n\nRequest attributes:\n- [.push_table()](PushChainAttrs::push_table)\n- [.push_handle()](PushChainAttrs::push_handle)\n- [.push_name()](PushChainAttrs::push_name)\n- [.nested_hook()](PushChainAttrs::nested_hook)\n"]
19000    pub fn op_destroychain_do(self, header: &Nfgenmsg) -> OpDestroychainDo<'buf> {
19001        let mut res = OpDestroychainDo::new(self, header);
19002        res.request.do_writeback(
19003            res.protocol(),
19004            "op-destroychain-do",
19005            OpDestroychainDo::lookup,
19006        );
19007        res
19008    }
19009    #[doc = "Create a new rule\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n- [.nested_expressions()](PushRuleAttrs::nested_expressions)\n- [.nested_compat()](PushRuleAttrs::nested_compat)\n- [.push_position()](PushRuleAttrs::push_position)\n- [.push_userdata()](PushRuleAttrs::push_userdata)\n- [.push_position_id()](PushRuleAttrs::push_position_id)\n- [.push_chain_id()](PushRuleAttrs::push_chain_id)\n"]
19010    pub fn op_newrule_do(self, header: &Nfgenmsg) -> OpNewruleDo<'buf> {
19011        let mut res = OpNewruleDo::new(self, header);
19012        res.request
19013            .do_writeback(res.protocol(), "op-newrule-do", OpNewruleDo::lookup);
19014        res
19015    }
19016    #[doc = "Get / dump rules\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n\nReply attributes:\n- [.get_table()](IterableRuleAttrs::get_table)\n- [.get_chain()](IterableRuleAttrs::get_chain)\n- [.get_handle()](IterableRuleAttrs::get_handle)\n- [.get_expressions()](IterableRuleAttrs::get_expressions)\n- [.get_position()](IterableRuleAttrs::get_position)\n- [.get_userdata()](IterableRuleAttrs::get_userdata)\n"]
19017    pub fn op_getrule_dump(self, header: &Nfgenmsg) -> OpGetruleDump<'buf> {
19018        let mut res = OpGetruleDump::new(self, header);
19019        res.request
19020            .do_writeback(res.protocol(), "op-getrule-dump", OpGetruleDump::lookup);
19021        res
19022    }
19023    #[doc = "Get / dump rules\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n\nReply attributes:\n- [.get_table()](IterableRuleAttrs::get_table)\n- [.get_chain()](IterableRuleAttrs::get_chain)\n- [.get_handle()](IterableRuleAttrs::get_handle)\n- [.get_expressions()](IterableRuleAttrs::get_expressions)\n- [.get_position()](IterableRuleAttrs::get_position)\n- [.get_userdata()](IterableRuleAttrs::get_userdata)\n"]
19024    pub fn op_getrule_do(self, header: &Nfgenmsg) -> OpGetruleDo<'buf> {
19025        let mut res = OpGetruleDo::new(self, header);
19026        res.request
19027            .do_writeback(res.protocol(), "op-getrule-do", OpGetruleDo::lookup);
19028        res
19029    }
19030    #[doc = "Get / dump rules and reset stateful expressions\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n\nReply attributes:\n- [.get_table()](IterableRuleAttrs::get_table)\n- [.get_chain()](IterableRuleAttrs::get_chain)\n- [.get_handle()](IterableRuleAttrs::get_handle)\n- [.get_expressions()](IterableRuleAttrs::get_expressions)\n- [.get_position()](IterableRuleAttrs::get_position)\n- [.get_userdata()](IterableRuleAttrs::get_userdata)\n"]
19031    pub fn op_getrule_reset_dump(self, header: &Nfgenmsg) -> OpGetruleResetDump<'buf> {
19032        let mut res = OpGetruleResetDump::new(self, header);
19033        res.request.do_writeback(
19034            res.protocol(),
19035            "op-getrule-reset-dump",
19036            OpGetruleResetDump::lookup,
19037        );
19038        res
19039    }
19040    #[doc = "Get / dump rules and reset stateful expressions\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n\nReply attributes:\n- [.get_table()](IterableRuleAttrs::get_table)\n- [.get_chain()](IterableRuleAttrs::get_chain)\n- [.get_handle()](IterableRuleAttrs::get_handle)\n- [.get_expressions()](IterableRuleAttrs::get_expressions)\n- [.get_position()](IterableRuleAttrs::get_position)\n- [.get_userdata()](IterableRuleAttrs::get_userdata)\n"]
19041    pub fn op_getrule_reset_do(self, header: &Nfgenmsg) -> OpGetruleResetDo<'buf> {
19042        let mut res = OpGetruleResetDo::new(self, header);
19043        res.request.do_writeback(
19044            res.protocol(),
19045            "op-getrule-reset-do",
19046            OpGetruleResetDo::lookup,
19047        );
19048        res
19049    }
19050    #[doc = "Delete an existing rule\\.\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n- [.push_id()](PushRuleAttrs::push_id)\n"]
19051    pub fn op_delrule_do(self, header: &Nfgenmsg) -> OpDelruleDo<'buf> {
19052        let mut res = OpDelruleDo::new(self, header);
19053        res.request
19054            .do_writeback(res.protocol(), "op-delrule-do", OpDelruleDo::lookup);
19055        res
19056    }
19057    #[doc = "Delete an existing rule with destroy semantics (ignoring ENOENT errors)\\.\n\nRequest attributes:\n- [.push_table()](PushRuleAttrs::push_table)\n- [.push_chain()](PushRuleAttrs::push_chain)\n- [.push_handle()](PushRuleAttrs::push_handle)\n- [.push_id()](PushRuleAttrs::push_id)\n"]
19058    pub fn op_destroyrule_do(self, header: &Nfgenmsg) -> OpDestroyruleDo<'buf> {
19059        let mut res = OpDestroyruleDo::new(self, header);
19060        res.request
19061            .do_writeback(res.protocol(), "op-destroyrule-do", OpDestroyruleDo::lookup);
19062        res
19063    }
19064    #[doc = "Create a new set\\.\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n- [.push_name()](PushSetAttrs::push_name)\n- [.push_flags()](PushSetAttrs::push_flags)\n- [.push_key_type()](PushSetAttrs::push_key_type)\n- [.push_key_len()](PushSetAttrs::push_key_len)\n- [.push_data_type()](PushSetAttrs::push_data_type)\n- [.push_data_len()](PushSetAttrs::push_data_len)\n- [.push_policy()](PushSetAttrs::push_policy)\n- [.nested_desc()](PushSetAttrs::nested_desc)\n- [.push_id()](PushSetAttrs::push_id)\n- [.push_timeout()](PushSetAttrs::push_timeout)\n- [.push_gc_interval()](PushSetAttrs::push_gc_interval)\n- [.push_userdata()](PushSetAttrs::push_userdata)\n- [.push_obj_type()](PushSetAttrs::push_obj_type)\n"]
19065    pub fn op_newset_do(self, header: &Nfgenmsg) -> OpNewsetDo<'buf> {
19066        let mut res = OpNewsetDo::new(self, header);
19067        res.request
19068            .do_writeback(res.protocol(), "op-newset-do", OpNewsetDo::lookup);
19069        res
19070    }
19071    #[doc = "Get / dump sets\\.\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n\nReply attributes:\n- [.get_table()](IterableSetAttrs::get_table)\n- [.get_name()](IterableSetAttrs::get_name)\n- [.get_flags()](IterableSetAttrs::get_flags)\n- [.get_key_type()](IterableSetAttrs::get_key_type)\n- [.get_key_len()](IterableSetAttrs::get_key_len)\n- [.get_data_type()](IterableSetAttrs::get_data_type)\n- [.get_data_len()](IterableSetAttrs::get_data_len)\n- [.get_policy()](IterableSetAttrs::get_policy)\n- [.get_desc()](IterableSetAttrs::get_desc)\n- [.get_gc_interval()](IterableSetAttrs::get_gc_interval)\n- [.get_userdata()](IterableSetAttrs::get_userdata)\n- [.get_obj_type()](IterableSetAttrs::get_obj_type)\n- [.get_handle()](IterableSetAttrs::get_handle)\n- [.get_expr()](IterableSetAttrs::get_expr)\n- [.get_expressions()](IterableSetAttrs::get_expressions)\n"]
19072    pub fn op_getset_dump(self, header: &Nfgenmsg) -> OpGetsetDump<'buf> {
19073        let mut res = OpGetsetDump::new(self, header);
19074        res.request
19075            .do_writeback(res.protocol(), "op-getset-dump", OpGetsetDump::lookup);
19076        res
19077    }
19078    #[doc = "Get / dump sets\\.\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n- [.push_name()](PushSetAttrs::push_name)\n\nReply attributes:\n- [.get_table()](IterableSetAttrs::get_table)\n- [.get_name()](IterableSetAttrs::get_name)\n- [.get_flags()](IterableSetAttrs::get_flags)\n- [.get_key_type()](IterableSetAttrs::get_key_type)\n- [.get_key_len()](IterableSetAttrs::get_key_len)\n- [.get_data_type()](IterableSetAttrs::get_data_type)\n- [.get_data_len()](IterableSetAttrs::get_data_len)\n- [.get_policy()](IterableSetAttrs::get_policy)\n- [.get_desc()](IterableSetAttrs::get_desc)\n- [.get_gc_interval()](IterableSetAttrs::get_gc_interval)\n- [.get_userdata()](IterableSetAttrs::get_userdata)\n- [.get_obj_type()](IterableSetAttrs::get_obj_type)\n- [.get_handle()](IterableSetAttrs::get_handle)\n- [.get_expr()](IterableSetAttrs::get_expr)\n- [.get_expressions()](IterableSetAttrs::get_expressions)\n"]
19079    pub fn op_getset_do(self, header: &Nfgenmsg) -> OpGetsetDo<'buf> {
19080        let mut res = OpGetsetDo::new(self, header);
19081        res.request
19082            .do_writeback(res.protocol(), "op-getset-do", OpGetsetDo::lookup);
19083        res
19084    }
19085    #[doc = "Delete an existing set\\.\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n- [.push_name()](PushSetAttrs::push_name)\n- [.push_handle()](PushSetAttrs::push_handle)\n"]
19086    pub fn op_delset_do(self, header: &Nfgenmsg) -> OpDelsetDo<'buf> {
19087        let mut res = OpDelsetDo::new(self, header);
19088        res.request
19089            .do_writeback(res.protocol(), "op-delset-do", OpDelsetDo::lookup);
19090        res
19091    }
19092    #[doc = "Delete an existing set with destroy semantics (ignoring ENOENT errors)\\.\n\nRequest attributes:\n- [.push_table()](PushSetAttrs::push_table)\n- [.push_name()](PushSetAttrs::push_name)\n- [.push_handle()](PushSetAttrs::push_handle)\n"]
19093    pub fn op_destroyset_do(self, header: &Nfgenmsg) -> OpDestroysetDo<'buf> {
19094        let mut res = OpDestroysetDo::new(self, header);
19095        res.request
19096            .do_writeback(res.protocol(), "op-destroyset-do", OpDestroysetDo::lookup);
19097        res
19098    }
19099    #[doc = "Create a new set element\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n- [.push_set_id()](PushSetelemListAttrs::push_set_id)\n"]
19100    pub fn op_newsetelem_do(self, header: &Nfgenmsg) -> OpNewsetelemDo<'buf> {
19101        let mut res = OpNewsetelemDo::new(self, header);
19102        res.request
19103            .do_writeback(res.protocol(), "op-newsetelem-do", OpNewsetelemDo::lookup);
19104        res
19105    }
19106    #[doc = "Get / dump set elements\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n\nReply attributes:\n- [.get_table()](IterableSetelemListAttrs::get_table)\n- [.get_set()](IterableSetelemListAttrs::get_set)\n- [.get_elements()](IterableSetelemListAttrs::get_elements)\n"]
19107    pub fn op_getsetelem_dump(self, header: &Nfgenmsg) -> OpGetsetelemDump<'buf> {
19108        let mut res = OpGetsetelemDump::new(self, header);
19109        res.request.do_writeback(
19110            res.protocol(),
19111            "op-getsetelem-dump",
19112            OpGetsetelemDump::lookup,
19113        );
19114        res
19115    }
19116    #[doc = "Get / dump set elements\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n\nReply attributes:\n- [.get_elements()](IterableSetelemListAttrs::get_elements)\n"]
19117    pub fn op_getsetelem_do(self, header: &Nfgenmsg) -> OpGetsetelemDo<'buf> {
19118        let mut res = OpGetsetelemDo::new(self, header);
19119        res.request
19120            .do_writeback(res.protocol(), "op-getsetelem-do", OpGetsetelemDo::lookup);
19121        res
19122    }
19123    #[doc = "Get / dump set elements and reset stateful expressions\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n\nReply attributes:\n- [.get_table()](IterableSetelemListAttrs::get_table)\n- [.get_set()](IterableSetelemListAttrs::get_set)\n- [.get_elements()](IterableSetelemListAttrs::get_elements)\n"]
19124    pub fn op_getsetelem_reset_dump(self, header: &Nfgenmsg) -> OpGetsetelemResetDump<'buf> {
19125        let mut res = OpGetsetelemResetDump::new(self, header);
19126        res.request.do_writeback(
19127            res.protocol(),
19128            "op-getsetelem-reset-dump",
19129            OpGetsetelemResetDump::lookup,
19130        );
19131        res
19132    }
19133    #[doc = "Get / dump set elements and reset stateful expressions\\.\nRequest attributes:\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n\nReply attributes:\n- [.get_table()](IterableSetelemListAttrs::get_table)\n- [.get_set()](IterableSetelemListAttrs::get_set)\n- [.get_elements()](IterableSetelemListAttrs::get_elements)\n"]
19134    pub fn op_getsetelem_reset_do(self, header: &Nfgenmsg) -> OpGetsetelemResetDo<'buf> {
19135        let mut res = OpGetsetelemResetDo::new(self, header);
19136        res.request.do_writeback(
19137            res.protocol(),
19138            "op-getsetelem-reset-do",
19139            OpGetsetelemResetDo::lookup,
19140        );
19141        res
19142    }
19143    #[doc = "Delete an existing set element\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n"]
19144    pub fn op_delsetelem_do(self, header: &Nfgenmsg) -> OpDelsetelemDo<'buf> {
19145        let mut res = OpDelsetelemDo::new(self, header);
19146        res.request
19147            .do_writeback(res.protocol(), "op-delsetelem-do", OpDelsetelemDo::lookup);
19148        res
19149    }
19150    #[doc = "Delete an existing set element with destroy semantics\\.\nRequest attributes:\n- [.push_table()](PushSetelemListAttrs::push_table)\n- [.push_set()](PushSetelemListAttrs::push_set)\n- [.nested_elements()](PushSetelemListAttrs::nested_elements)\n"]
19151    pub fn op_destroysetelem_do(self, header: &Nfgenmsg) -> OpDestroysetelemDo<'buf> {
19152        let mut res = OpDestroysetelemDo::new(self, header);
19153        res.request.do_writeback(
19154            res.protocol(),
19155            "op-destroysetelem-do",
19156            OpDestroysetelemDo::lookup,
19157        );
19158        res
19159    }
19160    #[doc = "Get / dump rule\\-set generation\\.\n\nReply attributes:\n- [.get_id()](IterableGenAttrs::get_id)\n- [.get_proc_pid()](IterableGenAttrs::get_proc_pid)\n- [.get_proc_name()](IterableGenAttrs::get_proc_name)\n"]
19161    pub fn op_getgen_dump(self, header: &Nfgenmsg) -> OpGetgenDump<'buf> {
19162        let mut res = OpGetgenDump::new(self, header);
19163        res.request
19164            .do_writeback(res.protocol(), "op-getgen-dump", OpGetgenDump::lookup);
19165        res
19166    }
19167    #[doc = "Get / dump rule\\-set generation\\.\n\nReply attributes:\n- [.get_id()](IterableGenAttrs::get_id)\n- [.get_proc_pid()](IterableGenAttrs::get_proc_pid)\n- [.get_proc_name()](IterableGenAttrs::get_proc_name)\n"]
19168    pub fn op_getgen_do(self, header: &Nfgenmsg) -> OpGetgenDo<'buf> {
19169        let mut res = OpGetgenDo::new(self, header);
19170        res.request
19171            .do_writeback(res.protocol(), "op-getgen-do", OpGetgenDo::lookup);
19172        res
19173    }
19174    #[doc = "Create a new stateful object\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_name()](PushObjAttrs::push_name)\n- [.push_type()](PushObjAttrs::push_type)\n- [.nested_data_counter()](PushObjAttrs::nested_data_counter)\n- [.nested_data_quota()](PushObjAttrs::nested_data_quota)\n- [.push_userdata()](PushObjAttrs::push_userdata)\n"]
19175    pub fn op_newobj_do(self, header: &Nfgenmsg) -> OpNewobjDo<'buf> {
19176        let mut res = OpNewobjDo::new(self, header);
19177        res.request
19178            .do_writeback(res.protocol(), "op-newobj-do", OpNewobjDo::lookup);
19179        res
19180    }
19181    #[doc = "Get / dump stateful objects\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_type()](PushObjAttrs::push_type)\n\nReply attributes:\n- [.get_table()](IterableObjAttrs::get_table)\n- [.get_name()](IterableObjAttrs::get_name)\n- [.get_type()](IterableObjAttrs::get_type)\n- [.get_data()](IterableObjAttrs::get_data)\n- [.get_use()](IterableObjAttrs::get_use)\n- [.get_handle()](IterableObjAttrs::get_handle)\n- [.get_userdata()](IterableObjAttrs::get_userdata)\n"]
19182    pub fn op_getobj_dump(self, header: &Nfgenmsg) -> OpGetobjDump<'buf> {
19183        let mut res = OpGetobjDump::new(self, header);
19184        res.request
19185            .do_writeback(res.protocol(), "op-getobj-dump", OpGetobjDump::lookup);
19186        res
19187    }
19188    #[doc = "Get / dump stateful objects\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_name()](PushObjAttrs::push_name)\n- [.push_type()](PushObjAttrs::push_type)\n\nReply attributes:\n- [.get_table()](IterableObjAttrs::get_table)\n- [.get_name()](IterableObjAttrs::get_name)\n- [.get_type()](IterableObjAttrs::get_type)\n- [.get_data()](IterableObjAttrs::get_data)\n- [.get_use()](IterableObjAttrs::get_use)\n- [.get_handle()](IterableObjAttrs::get_handle)\n- [.get_userdata()](IterableObjAttrs::get_userdata)\n"]
19189    pub fn op_getobj_do(self, header: &Nfgenmsg) -> OpGetobjDo<'buf> {
19190        let mut res = OpGetobjDo::new(self, header);
19191        res.request
19192            .do_writeback(res.protocol(), "op-getobj-do", OpGetobjDo::lookup);
19193        res
19194    }
19195    #[doc = "Delete an existing stateful object\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_name()](PushObjAttrs::push_name)\n- [.push_type()](PushObjAttrs::push_type)\n- [.push_handle()](PushObjAttrs::push_handle)\n"]
19196    pub fn op_delobj_do(self, header: &Nfgenmsg) -> OpDelobjDo<'buf> {
19197        let mut res = OpDelobjDo::new(self, header);
19198        res.request
19199            .do_writeback(res.protocol(), "op-delobj-do", OpDelobjDo::lookup);
19200        res
19201    }
19202    #[doc = "Delete an existing stateful object with destroy semantics\\.\nRequest attributes:\n- [.push_table()](PushObjAttrs::push_table)\n- [.push_name()](PushObjAttrs::push_name)\n- [.push_type()](PushObjAttrs::push_type)\n- [.push_handle()](PushObjAttrs::push_handle)\n"]
19203    pub fn op_destroyobj_do(self, header: &Nfgenmsg) -> OpDestroyobjDo<'buf> {
19204        let mut res = OpDestroyobjDo::new(self, header);
19205        res.request
19206            .do_writeback(res.protocol(), "op-destroyobj-do", OpDestroyobjDo::lookup);
19207        res
19208    }
19209    #[doc = "Create a new flow table\\.\nRequest attributes:\n- [.push_table()](PushFlowtableAttrs::push_table)\n- [.push_name()](PushFlowtableAttrs::push_name)\n- [.nested_hook()](PushFlowtableAttrs::nested_hook)\n- [.push_flags()](PushFlowtableAttrs::push_flags)\n"]
19210    pub fn op_newflowtable_do(self, header: &Nfgenmsg) -> OpNewflowtableDo<'buf> {
19211        let mut res = OpNewflowtableDo::new(self, header);
19212        res.request.do_writeback(
19213            res.protocol(),
19214            "op-newflowtable-do",
19215            OpNewflowtableDo::lookup,
19216        );
19217        res
19218    }
19219    #[doc = "Get / dump flow tables\\.\n\nReply attributes:\n- [.get_table()](IterableFlowtableAttrs::get_table)\n- [.get_name()](IterableFlowtableAttrs::get_name)\n- [.get_hook()](IterableFlowtableAttrs::get_hook)\n- [.get_use()](IterableFlowtableAttrs::get_use)\n- [.get_handle()](IterableFlowtableAttrs::get_handle)\n- [.get_flags()](IterableFlowtableAttrs::get_flags)\n"]
19220    pub fn op_getflowtable_dump(self, header: &Nfgenmsg) -> OpGetflowtableDump<'buf> {
19221        let mut res = OpGetflowtableDump::new(self, header);
19222        res.request.do_writeback(
19223            res.protocol(),
19224            "op-getflowtable-dump",
19225            OpGetflowtableDump::lookup,
19226        );
19227        res
19228    }
19229    #[doc = "Get / dump flow tables\\.\nRequest attributes:\n- [.push_table()](PushFlowtableAttrs::push_table)\n- [.push_name()](PushFlowtableAttrs::push_name)\n\nReply attributes:\n- [.get_table()](IterableFlowtableAttrs::get_table)\n- [.get_name()](IterableFlowtableAttrs::get_name)\n- [.get_hook()](IterableFlowtableAttrs::get_hook)\n- [.get_use()](IterableFlowtableAttrs::get_use)\n- [.get_handle()](IterableFlowtableAttrs::get_handle)\n- [.get_flags()](IterableFlowtableAttrs::get_flags)\n"]
19230    pub fn op_getflowtable_do(self, header: &Nfgenmsg) -> OpGetflowtableDo<'buf> {
19231        let mut res = OpGetflowtableDo::new(self, header);
19232        res.request.do_writeback(
19233            res.protocol(),
19234            "op-getflowtable-do",
19235            OpGetflowtableDo::lookup,
19236        );
19237        res
19238    }
19239    #[doc = "Delete an existing flow table\\.\nRequest attributes:\n- [.push_table()](PushFlowtableAttrs::push_table)\n- [.push_name()](PushFlowtableAttrs::push_name)\n- [.nested_hook()](PushFlowtableAttrs::nested_hook)\n- [.push_handle()](PushFlowtableAttrs::push_handle)\n"]
19240    pub fn op_delflowtable_do(self, header: &Nfgenmsg) -> OpDelflowtableDo<'buf> {
19241        let mut res = OpDelflowtableDo::new(self, header);
19242        res.request.do_writeback(
19243            res.protocol(),
19244            "op-delflowtable-do",
19245            OpDelflowtableDo::lookup,
19246        );
19247        res
19248    }
19249    #[doc = "Delete an existing flow table with destroy semantics\\.\nRequest attributes:\n- [.push_table()](PushFlowtableAttrs::push_table)\n- [.push_name()](PushFlowtableAttrs::push_name)\n- [.nested_hook()](PushFlowtableAttrs::nested_hook)\n- [.push_handle()](PushFlowtableAttrs::push_handle)\n"]
19250    pub fn op_destroyflowtable_do(self, header: &Nfgenmsg) -> OpDestroyflowtableDo<'buf> {
19251        let mut res = OpDestroyflowtableDo::new(self, header);
19252        res.request.do_writeback(
19253            res.protocol(),
19254            "op-destroyflowtable-do",
19255            OpDestroyflowtableDo::lookup,
19256        );
19257        res
19258    }
19259    #[doc = "Get / dump nft\\_compat info\n\nReply attributes:\n- [.get_name()](IterableCompatAttrs::get_name)\n- [.get_rev()](IterableCompatAttrs::get_rev)\n- [.get_type()](IterableCompatAttrs::get_type)\n"]
19260    pub fn op_getcompat_dump(self, header: &Nfgenmsg) -> OpGetcompatDump<'buf> {
19261        let mut res = OpGetcompatDump::new(self, header);
19262        res.request
19263            .do_writeback(res.protocol(), "op-getcompat-dump", OpGetcompatDump::lookup);
19264        res
19265    }
19266    #[doc = "Get / dump nft\\_compat info\nRequest attributes:\n- [.push_name()](PushCompatAttrs::push_name)\n- [.push_rev()](PushCompatAttrs::push_rev)\n- [.push_type()](PushCompatAttrs::push_type)\n\nReply attributes:\n- [.get_name()](IterableCompatAttrs::get_name)\n- [.get_rev()](IterableCompatAttrs::get_rev)\n- [.get_type()](IterableCompatAttrs::get_type)\n"]
19267    pub fn op_getcompat_do(self, header: &Nfgenmsg) -> OpGetcompatDo<'buf> {
19268        let mut res = OpGetcompatDo::new(self, header);
19269        res.request
19270            .do_writeback(res.protocol(), "op-getcompat-do", OpGetcompatDo::lookup);
19271        res
19272    }
19273}
19274#[cfg(test)]
19275mod generated_tests {
19276    use super::*;
19277    #[test]
19278    fn tests() {
19279        let _ = IterableBatchAttrs::get_genid;
19280        let _ = IterableChainAttrs::get_counters;
19281        let _ = IterableChainAttrs::get_flags;
19282        let _ = IterableChainAttrs::get_handle;
19283        let _ = IterableChainAttrs::get_hook;
19284        let _ = IterableChainAttrs::get_id;
19285        let _ = IterableChainAttrs::get_name;
19286        let _ = IterableChainAttrs::get_policy;
19287        let _ = IterableChainAttrs::get_table;
19288        let _ = IterableChainAttrs::get_type;
19289        let _ = IterableChainAttrs::get_use;
19290        let _ = IterableChainAttrs::get_userdata;
19291        let _ = IterableCompatAttrs::get_name;
19292        let _ = IterableCompatAttrs::get_rev;
19293        let _ = IterableCompatAttrs::get_type;
19294        let _ = IterableFlowtableAttrs::get_flags;
19295        let _ = IterableFlowtableAttrs::get_handle;
19296        let _ = IterableFlowtableAttrs::get_hook;
19297        let _ = IterableFlowtableAttrs::get_name;
19298        let _ = IterableFlowtableAttrs::get_table;
19299        let _ = IterableFlowtableAttrs::get_use;
19300        let _ = IterableGenAttrs::get_id;
19301        let _ = IterableGenAttrs::get_proc_name;
19302        let _ = IterableGenAttrs::get_proc_pid;
19303        let _ = IterableObjAttrs::get_data;
19304        let _ = IterableObjAttrs::get_handle;
19305        let _ = IterableObjAttrs::get_name;
19306        let _ = IterableObjAttrs::get_table;
19307        let _ = IterableObjAttrs::get_type;
19308        let _ = IterableObjAttrs::get_use;
19309        let _ = IterableObjAttrs::get_userdata;
19310        let _ = IterableRuleAttrs::get_chain;
19311        let _ = IterableRuleAttrs::get_expressions;
19312        let _ = IterableRuleAttrs::get_handle;
19313        let _ = IterableRuleAttrs::get_position;
19314        let _ = IterableRuleAttrs::get_table;
19315        let _ = IterableRuleAttrs::get_userdata;
19316        let _ = IterableSetAttrs::get_data_len;
19317        let _ = IterableSetAttrs::get_data_type;
19318        let _ = IterableSetAttrs::get_desc;
19319        let _ = IterableSetAttrs::get_expr;
19320        let _ = IterableSetAttrs::get_expressions;
19321        let _ = IterableSetAttrs::get_flags;
19322        let _ = IterableSetAttrs::get_gc_interval;
19323        let _ = IterableSetAttrs::get_handle;
19324        let _ = IterableSetAttrs::get_key_len;
19325        let _ = IterableSetAttrs::get_key_type;
19326        let _ = IterableSetAttrs::get_name;
19327        let _ = IterableSetAttrs::get_obj_type;
19328        let _ = IterableSetAttrs::get_policy;
19329        let _ = IterableSetAttrs::get_table;
19330        let _ = IterableSetAttrs::get_userdata;
19331        let _ = IterableSetelemListAttrs::get_elements;
19332        let _ = IterableSetelemListAttrs::get_set;
19333        let _ = IterableSetelemListAttrs::get_table;
19334        let _ = IterableTableAttrs::get_flags;
19335        let _ = IterableTableAttrs::get_handle;
19336        let _ = IterableTableAttrs::get_name;
19337        let _ = IterableTableAttrs::get_owner;
19338        let _ = IterableTableAttrs::get_use;
19339        let _ = IterableTableAttrs::get_userdata;
19340        let _ = PushBatchAttrs::<&mut Vec<u8>>::push_genid;
19341        let _ = PushChainAttrs::<&mut Vec<u8>>::nested_counters;
19342        let _ = PushChainAttrs::<&mut Vec<u8>>::nested_hook;
19343        let _ = PushChainAttrs::<&mut Vec<u8>>::push_flags;
19344        let _ = PushChainAttrs::<&mut Vec<u8>>::push_handle;
19345        let _ = PushChainAttrs::<&mut Vec<u8>>::push_name;
19346        let _ = PushChainAttrs::<&mut Vec<u8>>::push_policy;
19347        let _ = PushChainAttrs::<&mut Vec<u8>>::push_table;
19348        let _ = PushChainAttrs::<&mut Vec<u8>>::push_type;
19349        let _ = PushChainAttrs::<&mut Vec<u8>>::push_userdata;
19350        let _ = PushCompatAttrs::<&mut Vec<u8>>::push_name;
19351        let _ = PushCompatAttrs::<&mut Vec<u8>>::push_rev;
19352        let _ = PushCompatAttrs::<&mut Vec<u8>>::push_type;
19353        let _ = PushFlowtableAttrs::<&mut Vec<u8>>::nested_hook;
19354        let _ = PushFlowtableAttrs::<&mut Vec<u8>>::push_flags;
19355        let _ = PushFlowtableAttrs::<&mut Vec<u8>>::push_handle;
19356        let _ = PushFlowtableAttrs::<&mut Vec<u8>>::push_name;
19357        let _ = PushFlowtableAttrs::<&mut Vec<u8>>::push_table;
19358        let _ = PushObjAttrs::<&mut Vec<u8>>::nested_data_counter;
19359        let _ = PushObjAttrs::<&mut Vec<u8>>::nested_data_quota;
19360        let _ = PushObjAttrs::<&mut Vec<u8>>::push_handle;
19361        let _ = PushObjAttrs::<&mut Vec<u8>>::push_name;
19362        let _ = PushObjAttrs::<&mut Vec<u8>>::push_table;
19363        let _ = PushObjAttrs::<&mut Vec<u8>>::push_type;
19364        let _ = PushObjAttrs::<&mut Vec<u8>>::push_userdata;
19365        let _ = PushRuleAttrs::<&mut Vec<u8>>::nested_compat;
19366        let _ = PushRuleAttrs::<&mut Vec<u8>>::nested_expressions;
19367        let _ = PushRuleAttrs::<&mut Vec<u8>>::push_chain;
19368        let _ = PushRuleAttrs::<&mut Vec<u8>>::push_chain_id;
19369        let _ = PushRuleAttrs::<&mut Vec<u8>>::push_handle;
19370        let _ = PushRuleAttrs::<&mut Vec<u8>>::push_id;
19371        let _ = PushRuleAttrs::<&mut Vec<u8>>::push_position;
19372        let _ = PushRuleAttrs::<&mut Vec<u8>>::push_position_id;
19373        let _ = PushRuleAttrs::<&mut Vec<u8>>::push_table;
19374        let _ = PushRuleAttrs::<&mut Vec<u8>>::push_userdata;
19375        let _ = PushSetAttrs::<&mut Vec<u8>>::nested_desc;
19376        let _ = PushSetAttrs::<&mut Vec<u8>>::push_data_len;
19377        let _ = PushSetAttrs::<&mut Vec<u8>>::push_data_type;
19378        let _ = PushSetAttrs::<&mut Vec<u8>>::push_flags;
19379        let _ = PushSetAttrs::<&mut Vec<u8>>::push_gc_interval;
19380        let _ = PushSetAttrs::<&mut Vec<u8>>::push_handle;
19381        let _ = PushSetAttrs::<&mut Vec<u8>>::push_id;
19382        let _ = PushSetAttrs::<&mut Vec<u8>>::push_key_len;
19383        let _ = PushSetAttrs::<&mut Vec<u8>>::push_key_type;
19384        let _ = PushSetAttrs::<&mut Vec<u8>>::push_name;
19385        let _ = PushSetAttrs::<&mut Vec<u8>>::push_obj_type;
19386        let _ = PushSetAttrs::<&mut Vec<u8>>::push_policy;
19387        let _ = PushSetAttrs::<&mut Vec<u8>>::push_table;
19388        let _ = PushSetAttrs::<&mut Vec<u8>>::push_timeout;
19389        let _ = PushSetAttrs::<&mut Vec<u8>>::push_userdata;
19390        let _ = PushSetelemListAttrs::<&mut Vec<u8>>::nested_elements;
19391        let _ = PushSetelemListAttrs::<&mut Vec<u8>>::push_set;
19392        let _ = PushSetelemListAttrs::<&mut Vec<u8>>::push_set_id;
19393        let _ = PushSetelemListAttrs::<&mut Vec<u8>>::push_table;
19394        let _ = PushTableAttrs::<&mut Vec<u8>>::push_flags;
19395        let _ = PushTableAttrs::<&mut Vec<u8>>::push_handle;
19396        let _ = PushTableAttrs::<&mut Vec<u8>>::push_name;
19397        let _ = PushTableAttrs::<&mut Vec<u8>>::push_userdata;
19398    }
19399}