Skip to main content

netlink_bindings/dpll/
mod.rs

1#![doc = "DPLL subsystem.\n"]
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 = "dpll";
17pub const PROTONAME_CSTR: &CStr = c"dpll";
18#[doc = "working modes a dpll can support, differentiates if and how dpll selects\none of its inputs to syntonize with it, valid values for DPLL_A_MODE\nattribute\n"]
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 Mode {
22    #[doc = "input can be only selected by sending a request to dpll\n"]
23    Manual = 1,
24    #[doc = "highest prio input pin auto selected by dpll\n"]
25    Automatic = 2,
26}
27impl Mode {
28    pub fn from_value(value: u64) -> Option<Self> {
29        Some(match value {
30            1 => Self::Manual,
31            2 => Self::Automatic,
32            _ => return None,
33        })
34    }
35}
36#[doc = "provides information of dpll device lock status, valid values for\nDPLL_A_LOCK_STATUS attribute\n"]
37#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
38#[derive(Debug, Clone, Copy)]
39pub enum LockStatus {
40    #[doc = "dpll was not yet locked to any valid input (or forced by setting\nDPLL_A_MODE to DPLL_MODE_DETACHED)\n"]
41    Unlocked = 1,
42    #[doc = "dpll is locked to a valid signal, but no holdover available\n"]
43    Locked = 2,
44    #[doc = "dpll is locked and holdover acquired\n"]
45    LockedHoAcq = 3,
46    #[doc = "dpll is in holdover state - lost a valid lock or was forced by\ndisconnecting all the pins (latter possible only when dpll lock-state\nwas already DPLL_LOCK_STATUS_LOCKED_HO_ACQ, if dpll lock-state was not\nDPLL_LOCK_STATUS_LOCKED_HO_ACQ, the dpll\\'s lock-state shall remain\nDPLL_LOCK_STATUS_UNLOCKED)\n"]
47    Holdover = 4,
48}
49impl LockStatus {
50    pub fn from_value(value: u64) -> Option<Self> {
51        Some(match value {
52            1 => Self::Unlocked,
53            2 => Self::Locked,
54            3 => Self::LockedHoAcq,
55            4 => Self::Holdover,
56            _ => return None,
57        })
58    }
59}
60#[doc = "if previous status change was done due to a failure, this provides\ninformation of dpll device lock status error. Valid values for\nDPLL_A_LOCK_STATUS_ERROR attribute\n"]
61#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
62#[derive(Debug, Clone, Copy)]
63pub enum LockStatusError {
64    #[doc = "dpll device lock status was changed without any error\n"]
65    None = 1,
66    #[doc = "dpll device lock status was changed due to undefined error. Driver fills\nthis value up in case it is not able to obtain suitable exact error\ntype.\n"]
67    Undefined = 2,
68    #[doc = "dpll device lock status was changed because of associated media got\ndown. This may happen for example if dpll device was previously locked\non an input pin of type PIN_TYPE_SYNCE_ETH_PORT.\n"]
69    MediaDown = 3,
70    #[doc = "the FFO (Fractional Frequency Offset) between the RX and TX symbol rate\non the media got too high. This may happen for example if dpll device\nwas previously locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT.\n"]
71    FractionalFrequencyOffsetTooHigh = 4,
72}
73impl LockStatusError {
74    pub fn from_value(value: u64) -> Option<Self> {
75        Some(match value {
76            1 => Self::None,
77            2 => Self::Undefined,
78            3 => Self::MediaDown,
79            4 => Self::FractionalFrequencyOffsetTooHigh,
80            _ => return None,
81        })
82    }
83}
84#[doc = "level of quality of a clock device. This mainly applies when the dpll\nlock-status is DPLL_LOCK_STATUS_HOLDOVER. The current list is defined\naccording to the table 11-7 contained in ITU-T G.8264/Y.1364 document.\nOne may extend this list freely by other ITU-T defined clock qualities,\nor different ones defined by another standardization body (for those,\nplease use different prefix).\n"]
85#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
86#[derive(Debug, Clone, Copy)]
87pub enum ClockQualityLevel {
88    ItuOpt1Prc = 1,
89    ItuOpt1SsuA = 2,
90    ItuOpt1SsuB = 3,
91    ItuOpt1Eec1 = 4,
92    ItuOpt1Prtc = 5,
93    ItuOpt1Eprtc = 6,
94    ItuOpt1Eeec = 7,
95    ItuOpt1Eprc = 8,
96}
97impl ClockQualityLevel {
98    pub fn from_value(value: u64) -> Option<Self> {
99        Some(match value {
100            1 => Self::ItuOpt1Prc,
101            2 => Self::ItuOpt1SsuA,
102            3 => Self::ItuOpt1SsuB,
103            4 => Self::ItuOpt1Eec1,
104            5 => Self::ItuOpt1Prtc,
105            6 => Self::ItuOpt1Eprtc,
106            7 => Self::ItuOpt1Eeec,
107            8 => Self::ItuOpt1Eprc,
108            _ => return None,
109        })
110    }
111}
112#[doc = "temperature divider allowing userspace to calculate the temperature as\nfloat with three digit decimal precision. Value of (DPLL_A_TEMP /\nDPLL_TEMP_DIVIDER) is integer part of temperature value. Value of\n(DPLL_A_TEMP % DPLL_TEMP_DIVIDER) is fractional part of temperature\nvalue.\n"]
113pub const TEMP_DIVIDER: u64 = 1000u64;
114#[doc = "type of dpll, valid values for DPLL_A_TYPE attribute\n"]
115#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
116#[derive(Debug, Clone, Copy)]
117pub enum Type {
118    #[doc = "dpll produces Pulse-Per-Second signal\n"]
119    Pps = 1,
120    #[doc = "dpll drives the Ethernet Equipment Clock\n"]
121    Eec = 2,
122}
123impl Type {
124    pub fn from_value(value: u64) -> Option<Self> {
125        Some(match value {
126            1 => Self::Pps,
127            2 => Self::Eec,
128            _ => return None,
129        })
130    }
131}
132#[doc = "defines possible types of a pin, valid values for DPLL_A_PIN_TYPE\nattribute\n"]
133#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
134#[derive(Debug, Clone, Copy)]
135pub enum PinType {
136    #[doc = "aggregates another layer of selectable pins\n"]
137    Mux = 1,
138    #[doc = "external input\n"]
139    Ext = 2,
140    #[doc = "ethernet port PHY\\'s recovered clock\n"]
141    SynceEthPort = 3,
142    #[doc = "device internal oscillator\n"]
143    IntOscillator = 4,
144    #[doc = "GNSS recovered clock\n"]
145    Gnss = 5,
146}
147impl PinType {
148    pub fn from_value(value: u64) -> Option<Self> {
149        Some(match value {
150            1 => Self::Mux,
151            2 => Self::Ext,
152            3 => Self::SynceEthPort,
153            4 => Self::IntOscillator,
154            5 => Self::Gnss,
155            _ => return None,
156        })
157    }
158}
159#[doc = "defines possible direction of a pin, valid values for\nDPLL_A_PIN_DIRECTION attribute\n"]
160#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
161#[derive(Debug, Clone, Copy)]
162pub enum PinDirection {
163    #[doc = "pin used as a input of a signal\n"]
164    Input = 1,
165    #[doc = "pin used to output the signal\n"]
166    Output = 2,
167}
168impl PinDirection {
169    pub fn from_value(value: u64) -> Option<Self> {
170        Some(match value {
171            1 => Self::Input,
172            2 => Self::Output,
173            _ => return None,
174        })
175    }
176}
177pub const PIN_FREQUENCY_1_HZ: u64 = 1u64;
178pub const PIN_FREQUENCY_10_KHZ: u64 = 10000u64;
179pub const PIN_FREQUENCY_77_5_KHZ: u64 = 77500u64;
180pub const PIN_FREQUENCY_10_MHZ: u64 = 10000000u64;
181#[doc = "defines possible states of a pin, valid values for DPLL_A_PIN_STATE\nattribute\n"]
182#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
183#[derive(Debug, Clone, Copy)]
184pub enum PinState {
185    #[doc = "pin connected, active input of phase locked loop\n"]
186    Connected = 1,
187    #[doc = "pin disconnected, not considered as a valid input\n"]
188    Disconnected = 2,
189    #[doc = "pin enabled for automatic input selection\n"]
190    Selectable = 3,
191}
192impl PinState {
193    pub fn from_value(value: u64) -> Option<Self> {
194        Some(match value {
195            1 => Self::Connected,
196            2 => Self::Disconnected,
197            3 => Self::Selectable,
198            _ => return None,
199        })
200    }
201}
202#[doc = "defines possible operational states of a pin with respect to its parent\nDPLL device, valid values for DPLL_A_PIN_OPERSTATE attribute\n"]
203#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
204#[derive(Debug, Clone, Copy)]
205pub enum PinOperstate {
206    #[doc = "pin is qualified and actively used by the DPLL\n"]
207    Active = 1,
208    #[doc = "pin is qualified but not actively used by the DPLL\n"]
209    Standby = 2,
210    #[doc = "pin does not have a valid signal\n"]
211    NoSignal = 3,
212    #[doc = "pin signal failed qualification (e.g. frequency or phase monitor)\n"]
213    QualFailed = 4,
214}
215impl PinOperstate {
216    pub fn from_value(value: u64) -> Option<Self> {
217        Some(match value {
218            1 => Self::Active,
219            2 => Self::Standby,
220            3 => Self::NoSignal,
221            4 => Self::QualFailed,
222            _ => return None,
223        })
224    }
225}
226#[doc = "defines possible capabilities of a pin, valid flags on\nDPLL_A_PIN_CAPABILITIES attribute\n"]
227#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
228#[derive(Debug, Clone, Copy)]
229pub enum PinCapabilities {
230    #[doc = "pin direction can be changed\n"]
231    DirectionCanChange = 1 << 0,
232    #[doc = "pin priority can be changed\n"]
233    PriorityCanChange = 1 << 1,
234    #[doc = "pin state can be changed\n"]
235    StateCanChange = 1 << 2,
236}
237impl PinCapabilities {
238    pub fn from_value(value: u64) -> Option<Self> {
239        Some(match value {
240            n if n == 1 << 0 => Self::DirectionCanChange,
241            n if n == 1 << 1 => Self::PriorityCanChange,
242            n if n == 1 << 2 => Self::StateCanChange,
243            _ => return None,
244        })
245    }
246}
247#[doc = "phase offset divider allows userspace to calculate a value of measured\nsignal phase difference between a pin and dpll device as a fractional\nvalue with three digit decimal precision. Value of (DPLL_A_PHASE_OFFSET\n/ DPLL_PHASE_OFFSET_DIVIDER) is an integer part of a measured phase\noffset value. Value of (DPLL_A_PHASE_OFFSET % DPLL_PHASE_OFFSET_DIVIDER)\nis a fractional part of a measured phase offset value.\n"]
248pub const PHASE_OFFSET_DIVIDER: u64 = 1000u64;
249#[doc = "pin measured frequency divider allows userspace to calculate a value of\nmeasured input frequency as a fractional value with three digit decimal\nprecision (millihertz). Value of (DPLL_A_PIN_MEASURED_FREQUENCY /\nDPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is an integer part of a measured\nfrequency value. Value of (DPLL_A_PIN_MEASURED_FREQUENCY %\nDPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is a fractional part of a measured\nfrequency value.\n"]
250pub const PIN_MEASURED_FREQUENCY_DIVIDER: u64 = 1000u64;
251#[doc = "Allow control (enable/disable) and status checking over features.\n"]
252#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
253#[derive(Debug, Clone, Copy)]
254pub enum FeatureState {
255    #[doc = "feature shall be disabled\n"]
256    Disable = 0,
257    #[doc = "feature shall be enabled\n"]
258    Enable = 1,
259}
260impl FeatureState {
261    pub fn from_value(value: u64) -> Option<Self> {
262        Some(match value {
263            0 => Self::Disable,
264            1 => Self::Enable,
265            _ => return None,
266        })
267    }
268}
269#[derive(Clone)]
270pub enum Dpll<'a> {
271    Id(u32),
272    ModuleName(&'a CStr),
273    Pad(&'a [u8]),
274    ClockId(u64),
275    #[doc = "Associated type: [`Mode`] (enum)"]
276    Mode(u32),
277    #[doc = "Associated type: [`Mode`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
278    ModeSupported(u32),
279    #[doc = "Associated type: [`LockStatus`] (enum)"]
280    LockStatus(u32),
281    Temp(i32),
282    #[doc = "Associated type: [`Type`] (enum)"]
283    Type(u32),
284    #[doc = "Associated type: [`LockStatusError`] (enum)"]
285    LockStatusError(u32),
286    #[doc = "Level of quality of a clock device. This mainly applies when the dpll\nlock-status is DPLL_LOCK_STATUS_HOLDOVER. This could be put to message\nmultiple times to indicate possible parallel quality levels (e.g. one\nspecified by ITU option 1 and another one specified by option 2).\n\nAssociated type: [`ClockQualityLevel`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
287    ClockQualityLevel(u32),
288    #[doc = "Receive or request state of phase offset monitor feature. If enabled,\ndpll device shall monitor and notify all currently available inputs for\nchanges of their phase offset against the dpll device.\n\nAssociated type: [`FeatureState`] (enum)"]
289    PhaseOffsetMonitor(u32),
290    #[doc = "Averaging factor applied to calculation of reported phase offset.\n"]
291    PhaseOffsetAvgFactor(u32),
292    #[doc = "Current or desired state of the frequency monitor feature. If enabled,\ndpll device shall measure all currently available inputs for their\nactual input frequency.\n\nAssociated type: [`FeatureState`] (enum)"]
293    FrequencyMonitor(u32),
294}
295impl<'a> IterableDpll<'a> {
296    pub fn get_id(&self) -> Result<u32, ErrorContext> {
297        let mut iter = self.clone();
298        iter.pos = 0;
299        for attr in iter {
300            if let Ok(Dpll::Id(val)) = attr {
301                return Ok(val);
302            }
303        }
304        Err(ErrorContext::new_missing(
305            "Dpll",
306            "Id",
307            self.orig_loc,
308            self.buf.as_ptr() as usize,
309        ))
310    }
311    pub fn get_module_name(&self) -> Result<&'a CStr, ErrorContext> {
312        let mut iter = self.clone();
313        iter.pos = 0;
314        for attr in iter {
315            if let Ok(Dpll::ModuleName(val)) = attr {
316                return Ok(val);
317            }
318        }
319        Err(ErrorContext::new_missing(
320            "Dpll",
321            "ModuleName",
322            self.orig_loc,
323            self.buf.as_ptr() as usize,
324        ))
325    }
326    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
327        let mut iter = self.clone();
328        iter.pos = 0;
329        for attr in iter {
330            if let Ok(Dpll::Pad(val)) = attr {
331                return Ok(val);
332            }
333        }
334        Err(ErrorContext::new_missing(
335            "Dpll",
336            "Pad",
337            self.orig_loc,
338            self.buf.as_ptr() as usize,
339        ))
340    }
341    pub fn get_clock_id(&self) -> Result<u64, ErrorContext> {
342        let mut iter = self.clone();
343        iter.pos = 0;
344        for attr in iter {
345            if let Ok(Dpll::ClockId(val)) = attr {
346                return Ok(val);
347            }
348        }
349        Err(ErrorContext::new_missing(
350            "Dpll",
351            "ClockId",
352            self.orig_loc,
353            self.buf.as_ptr() as usize,
354        ))
355    }
356    #[doc = "Associated type: [`Mode`] (enum)"]
357    pub fn get_mode(&self) -> Result<u32, ErrorContext> {
358        let mut iter = self.clone();
359        iter.pos = 0;
360        for attr in iter {
361            if let Ok(Dpll::Mode(val)) = attr {
362                return Ok(val);
363            }
364        }
365        Err(ErrorContext::new_missing(
366            "Dpll",
367            "Mode",
368            self.orig_loc,
369            self.buf.as_ptr() as usize,
370        ))
371    }
372    #[doc = "Associated type: [`Mode`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
373    pub fn get_mode_supported(&self) -> MultiAttrIterable<Self, Dpll<'a>, u32> {
374        MultiAttrIterable::new(self.clone(), |variant| {
375            if let Dpll::ModeSupported(val) = variant {
376                Some(val)
377            } else {
378                None
379            }
380        })
381    }
382    #[doc = "Associated type: [`LockStatus`] (enum)"]
383    pub fn get_lock_status(&self) -> Result<u32, ErrorContext> {
384        let mut iter = self.clone();
385        iter.pos = 0;
386        for attr in iter {
387            if let Ok(Dpll::LockStatus(val)) = attr {
388                return Ok(val);
389            }
390        }
391        Err(ErrorContext::new_missing(
392            "Dpll",
393            "LockStatus",
394            self.orig_loc,
395            self.buf.as_ptr() as usize,
396        ))
397    }
398    pub fn get_temp(&self) -> Result<i32, ErrorContext> {
399        let mut iter = self.clone();
400        iter.pos = 0;
401        for attr in iter {
402            if let Ok(Dpll::Temp(val)) = attr {
403                return Ok(val);
404            }
405        }
406        Err(ErrorContext::new_missing(
407            "Dpll",
408            "Temp",
409            self.orig_loc,
410            self.buf.as_ptr() as usize,
411        ))
412    }
413    #[doc = "Associated type: [`Type`] (enum)"]
414    pub fn get_type(&self) -> Result<u32, ErrorContext> {
415        let mut iter = self.clone();
416        iter.pos = 0;
417        for attr in iter {
418            if let Ok(Dpll::Type(val)) = attr {
419                return Ok(val);
420            }
421        }
422        Err(ErrorContext::new_missing(
423            "Dpll",
424            "Type",
425            self.orig_loc,
426            self.buf.as_ptr() as usize,
427        ))
428    }
429    #[doc = "Associated type: [`LockStatusError`] (enum)"]
430    pub fn get_lock_status_error(&self) -> Result<u32, ErrorContext> {
431        let mut iter = self.clone();
432        iter.pos = 0;
433        for attr in iter {
434            if let Ok(Dpll::LockStatusError(val)) = attr {
435                return Ok(val);
436            }
437        }
438        Err(ErrorContext::new_missing(
439            "Dpll",
440            "LockStatusError",
441            self.orig_loc,
442            self.buf.as_ptr() as usize,
443        ))
444    }
445    #[doc = "Level of quality of a clock device. This mainly applies when the dpll\nlock-status is DPLL_LOCK_STATUS_HOLDOVER. This could be put to message\nmultiple times to indicate possible parallel quality levels (e.g. one\nspecified by ITU option 1 and another one specified by option 2).\n\nAssociated type: [`ClockQualityLevel`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
446    pub fn get_clock_quality_level(&self) -> MultiAttrIterable<Self, Dpll<'a>, u32> {
447        MultiAttrIterable::new(self.clone(), |variant| {
448            if let Dpll::ClockQualityLevel(val) = variant {
449                Some(val)
450            } else {
451                None
452            }
453        })
454    }
455    #[doc = "Receive or request state of phase offset monitor feature. If enabled,\ndpll device shall monitor and notify all currently available inputs for\nchanges of their phase offset against the dpll device.\n\nAssociated type: [`FeatureState`] (enum)"]
456    pub fn get_phase_offset_monitor(&self) -> Result<u32, ErrorContext> {
457        let mut iter = self.clone();
458        iter.pos = 0;
459        for attr in iter {
460            if let Ok(Dpll::PhaseOffsetMonitor(val)) = attr {
461                return Ok(val);
462            }
463        }
464        Err(ErrorContext::new_missing(
465            "Dpll",
466            "PhaseOffsetMonitor",
467            self.orig_loc,
468            self.buf.as_ptr() as usize,
469        ))
470    }
471    #[doc = "Averaging factor applied to calculation of reported phase offset.\n"]
472    pub fn get_phase_offset_avg_factor(&self) -> Result<u32, ErrorContext> {
473        let mut iter = self.clone();
474        iter.pos = 0;
475        for attr in iter {
476            if let Ok(Dpll::PhaseOffsetAvgFactor(val)) = attr {
477                return Ok(val);
478            }
479        }
480        Err(ErrorContext::new_missing(
481            "Dpll",
482            "PhaseOffsetAvgFactor",
483            self.orig_loc,
484            self.buf.as_ptr() as usize,
485        ))
486    }
487    #[doc = "Current or desired state of the frequency monitor feature. If enabled,\ndpll device shall measure all currently available inputs for their\nactual input frequency.\n\nAssociated type: [`FeatureState`] (enum)"]
488    pub fn get_frequency_monitor(&self) -> Result<u32, ErrorContext> {
489        let mut iter = self.clone();
490        iter.pos = 0;
491        for attr in iter {
492            if let Ok(Dpll::FrequencyMonitor(val)) = attr {
493                return Ok(val);
494            }
495        }
496        Err(ErrorContext::new_missing(
497            "Dpll",
498            "FrequencyMonitor",
499            self.orig_loc,
500            self.buf.as_ptr() as usize,
501        ))
502    }
503}
504impl Dpll<'_> {
505    pub fn new<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
506        IterableDpll::with_loc(buf, buf.as_ptr() as usize)
507    }
508    fn attr_from_type(r#type: u16) -> Option<&'static str> {
509        let res = match r#type {
510            1u16 => "Id",
511            2u16 => "ModuleName",
512            3u16 => "Pad",
513            4u16 => "ClockId",
514            5u16 => "Mode",
515            6u16 => "ModeSupported",
516            7u16 => "LockStatus",
517            8u16 => "Temp",
518            9u16 => "Type",
519            10u16 => "LockStatusError",
520            11u16 => "ClockQualityLevel",
521            12u16 => "PhaseOffsetMonitor",
522            13u16 => "PhaseOffsetAvgFactor",
523            14u16 => "FrequencyMonitor",
524            _ => return None,
525        };
526        Some(res)
527    }
528}
529#[derive(Clone, Copy, Default)]
530pub struct IterableDpll<'a> {
531    buf: &'a [u8],
532    pos: usize,
533    orig_loc: usize,
534}
535impl<'a> IterableDpll<'a> {
536    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
537        Self {
538            buf,
539            pos: 0,
540            orig_loc,
541        }
542    }
543    pub fn get_buf(&self) -> &'a [u8] {
544        self.buf
545    }
546}
547impl<'a> Iterator for IterableDpll<'a> {
548    type Item = Result<Dpll<'a>, ErrorContext>;
549    fn next(&mut self) -> Option<Self::Item> {
550        let mut pos;
551        let mut r#type;
552        loop {
553            pos = self.pos;
554            r#type = None;
555            if self.buf.len() == self.pos {
556                return None;
557            }
558            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
559                self.pos = self.buf.len();
560                break;
561            };
562            r#type = Some(header.r#type);
563            let res = match header.r#type {
564                1u16 => Dpll::Id({
565                    let res = parse_u32(next);
566                    let Some(val) = res else { break };
567                    val
568                }),
569                2u16 => Dpll::ModuleName({
570                    let res = CStr::from_bytes_with_nul(next).ok();
571                    let Some(val) = res else { break };
572                    val
573                }),
574                3u16 => Dpll::Pad({
575                    let res = Some(next);
576                    let Some(val) = res else { break };
577                    val
578                }),
579                4u16 => Dpll::ClockId({
580                    let res = parse_u64(next);
581                    let Some(val) = res else { break };
582                    val
583                }),
584                5u16 => Dpll::Mode({
585                    let res = parse_u32(next);
586                    let Some(val) = res else { break };
587                    val
588                }),
589                6u16 => Dpll::ModeSupported({
590                    let res = parse_u32(next);
591                    let Some(val) = res else { break };
592                    val
593                }),
594                7u16 => Dpll::LockStatus({
595                    let res = parse_u32(next);
596                    let Some(val) = res else { break };
597                    val
598                }),
599                8u16 => Dpll::Temp({
600                    let res = parse_i32(next);
601                    let Some(val) = res else { break };
602                    val
603                }),
604                9u16 => Dpll::Type({
605                    let res = parse_u32(next);
606                    let Some(val) = res else { break };
607                    val
608                }),
609                10u16 => Dpll::LockStatusError({
610                    let res = parse_u32(next);
611                    let Some(val) = res else { break };
612                    val
613                }),
614                11u16 => Dpll::ClockQualityLevel({
615                    let res = parse_u32(next);
616                    let Some(val) = res else { break };
617                    val
618                }),
619                12u16 => Dpll::PhaseOffsetMonitor({
620                    let res = parse_u32(next);
621                    let Some(val) = res else { break };
622                    val
623                }),
624                13u16 => Dpll::PhaseOffsetAvgFactor({
625                    let res = parse_u32(next);
626                    let Some(val) = res else { break };
627                    val
628                }),
629                14u16 => Dpll::FrequencyMonitor({
630                    let res = parse_u32(next);
631                    let Some(val) = res else { break };
632                    val
633                }),
634                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
635                n => continue,
636            };
637            return Some(Ok(res));
638        }
639        Some(Err(ErrorContext::new(
640            "Dpll",
641            r#type.and_then(|t| Dpll::attr_from_type(t)),
642            self.orig_loc,
643            self.buf.as_ptr().wrapping_add(pos) as usize,
644        )))
645    }
646}
647impl<'a> std::fmt::Debug for IterableDpll<'_> {
648    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
649        let mut fmt = f.debug_struct("Dpll");
650        for attr in self.clone() {
651            let attr = match attr {
652                Ok(a) => a,
653                Err(err) => {
654                    fmt.finish()?;
655                    f.write_str("Err(")?;
656                    err.fmt(f)?;
657                    return f.write_str(")");
658                }
659            };
660            match attr {
661                Dpll::Id(val) => fmt.field("Id", &val),
662                Dpll::ModuleName(val) => fmt.field("ModuleName", &val),
663                Dpll::Pad(val) => fmt.field("Pad", &val),
664                Dpll::ClockId(val) => fmt.field("ClockId", &val),
665                Dpll::Mode(val) => fmt.field("Mode", &FormatEnum(val.into(), Mode::from_value)),
666                Dpll::ModeSupported(val) => {
667                    fmt.field("ModeSupported", &FormatEnum(val.into(), Mode::from_value))
668                }
669                Dpll::LockStatus(val) => fmt.field(
670                    "LockStatus",
671                    &FormatEnum(val.into(), LockStatus::from_value),
672                ),
673                Dpll::Temp(val) => fmt.field("Temp", &val),
674                Dpll::Type(val) => fmt.field("Type", &FormatEnum(val.into(), Type::from_value)),
675                Dpll::LockStatusError(val) => fmt.field(
676                    "LockStatusError",
677                    &FormatEnum(val.into(), LockStatusError::from_value),
678                ),
679                Dpll::ClockQualityLevel(val) => fmt.field(
680                    "ClockQualityLevel",
681                    &FormatEnum(val.into(), ClockQualityLevel::from_value),
682                ),
683                Dpll::PhaseOffsetMonitor(val) => fmt.field(
684                    "PhaseOffsetMonitor",
685                    &FormatEnum(val.into(), FeatureState::from_value),
686                ),
687                Dpll::PhaseOffsetAvgFactor(val) => fmt.field("PhaseOffsetAvgFactor", &val),
688                Dpll::FrequencyMonitor(val) => fmt.field(
689                    "FrequencyMonitor",
690                    &FormatEnum(val.into(), FeatureState::from_value),
691                ),
692            };
693        }
694        fmt.finish()
695    }
696}
697impl IterableDpll<'_> {
698    pub fn lookup_attr(
699        &self,
700        offset: usize,
701        missing_type: Option<u16>,
702    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
703        let mut stack = Vec::new();
704        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
705        if missing_type.is_some() && cur == offset {
706            stack.push(("Dpll", offset));
707            return (stack, missing_type.and_then(|t| Dpll::attr_from_type(t)));
708        }
709        if cur > offset || cur + self.buf.len() < offset {
710            return (stack, None);
711        }
712        let mut attrs = self.clone();
713        let mut last_off = cur + attrs.pos;
714        while let Some(attr) = attrs.next() {
715            let Ok(attr) = attr else { break };
716            match attr {
717                Dpll::Id(val) => {
718                    if last_off == offset {
719                        stack.push(("Id", last_off));
720                        break;
721                    }
722                }
723                Dpll::ModuleName(val) => {
724                    if last_off == offset {
725                        stack.push(("ModuleName", last_off));
726                        break;
727                    }
728                }
729                Dpll::Pad(val) => {
730                    if last_off == offset {
731                        stack.push(("Pad", last_off));
732                        break;
733                    }
734                }
735                Dpll::ClockId(val) => {
736                    if last_off == offset {
737                        stack.push(("ClockId", last_off));
738                        break;
739                    }
740                }
741                Dpll::Mode(val) => {
742                    if last_off == offset {
743                        stack.push(("Mode", last_off));
744                        break;
745                    }
746                }
747                Dpll::ModeSupported(val) => {
748                    if last_off == offset {
749                        stack.push(("ModeSupported", last_off));
750                        break;
751                    }
752                }
753                Dpll::LockStatus(val) => {
754                    if last_off == offset {
755                        stack.push(("LockStatus", last_off));
756                        break;
757                    }
758                }
759                Dpll::Temp(val) => {
760                    if last_off == offset {
761                        stack.push(("Temp", last_off));
762                        break;
763                    }
764                }
765                Dpll::Type(val) => {
766                    if last_off == offset {
767                        stack.push(("Type", last_off));
768                        break;
769                    }
770                }
771                Dpll::LockStatusError(val) => {
772                    if last_off == offset {
773                        stack.push(("LockStatusError", last_off));
774                        break;
775                    }
776                }
777                Dpll::ClockQualityLevel(val) => {
778                    if last_off == offset {
779                        stack.push(("ClockQualityLevel", last_off));
780                        break;
781                    }
782                }
783                Dpll::PhaseOffsetMonitor(val) => {
784                    if last_off == offset {
785                        stack.push(("PhaseOffsetMonitor", last_off));
786                        break;
787                    }
788                }
789                Dpll::PhaseOffsetAvgFactor(val) => {
790                    if last_off == offset {
791                        stack.push(("PhaseOffsetAvgFactor", last_off));
792                        break;
793                    }
794                }
795                Dpll::FrequencyMonitor(val) => {
796                    if last_off == offset {
797                        stack.push(("FrequencyMonitor", last_off));
798                        break;
799                    }
800                }
801                _ => {}
802            };
803            last_off = cur + attrs.pos;
804        }
805        if !stack.is_empty() {
806            stack.push(("Dpll", cur));
807        }
808        (stack, None)
809    }
810}
811#[derive(Clone)]
812pub enum Pin<'a> {
813    Id(u32),
814    ParentId(u32),
815    ModuleName(&'a CStr),
816    Pad(&'a [u8]),
817    ClockId(u64),
818    BoardLabel(&'a CStr),
819    PanelLabel(&'a CStr),
820    PackageLabel(&'a CStr),
821    #[doc = "Associated type: [`PinType`] (enum)"]
822    Type(u32),
823    #[doc = "Associated type: [`PinDirection`] (enum)"]
824    Direction(u32),
825    Frequency(u64),
826    #[doc = "Attribute may repeat multiple times (treat it as array)"]
827    FrequencySupported(IterableFrequencyRange<'a>),
828    FrequencyMin(u64),
829    FrequencyMax(u64),
830    Prio(u32),
831    #[doc = "Associated type: [`PinState`] (enum)"]
832    State(u32),
833    #[doc = "Associated type: [`PinCapabilities`] (enum)"]
834    Capabilities(u32),
835    #[doc = "Attribute may repeat multiple times (treat it as array)"]
836    ParentDevice(IterablePinParentDevice<'a>),
837    #[doc = "Attribute may repeat multiple times (treat it as array)"]
838    ParentPin(IterablePinParentPin<'a>),
839    PhaseAdjustMin(i32),
840    PhaseAdjustMax(i32),
841    PhaseAdjust(i32),
842    PhaseOffset(i64),
843    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
844    FractionalFrequencyOffset(i32),
845    #[doc = "Frequency of Embedded SYNC signal. If provided, the pin is configured\nwith a SYNC signal embedded into its base clock frequency.\n"]
846    EsyncFrequency(u64),
847    #[doc = "If provided a pin is capable of embedding a SYNC signal (within given\nrange) into its base frequency signal.\n\nAttribute may repeat multiple times (treat it as array)"]
848    EsyncFrequencySupported(IterableFrequencyRange<'a>),
849    #[doc = "A ratio of high to low state of a SYNC signal pulse embedded into base\nclock frequency. Value is in percents.\n"]
850    EsyncPulse(u32),
851    #[doc = "Capable pin provides list of pins that can be bound to create a\nreference-sync pin pair.\n\nAttribute may repeat multiple times (treat it as array)"]
852    ReferenceSync(IterableReferenceSync<'a>),
853    #[doc = "Granularity of phase adjustment, in picoseconds. The value of phase\nadjustment must be a multiple of this granularity.\n"]
854    PhaseAdjustGran(u32),
855    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
856    FractionalFrequencyOffsetPpt(i32),
857    #[doc = "The measured frequency of the input pin in millihertz (mHz). Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY / DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\nan integer part (Hz) of a measured frequency value. Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY % DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\na fractional part of a measured frequency value.\n"]
858    MeasuredFrequency(u64),
859    #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
860    Operstate(u32),
861}
862impl<'a> IterablePin<'a> {
863    pub fn get_id(&self) -> Result<u32, ErrorContext> {
864        let mut iter = self.clone();
865        iter.pos = 0;
866        for attr in iter {
867            if let Ok(Pin::Id(val)) = attr {
868                return Ok(val);
869            }
870        }
871        Err(ErrorContext::new_missing(
872            "Pin",
873            "Id",
874            self.orig_loc,
875            self.buf.as_ptr() as usize,
876        ))
877    }
878    pub fn get_parent_id(&self) -> Result<u32, ErrorContext> {
879        let mut iter = self.clone();
880        iter.pos = 0;
881        for attr in iter {
882            if let Ok(Pin::ParentId(val)) = attr {
883                return Ok(val);
884            }
885        }
886        Err(ErrorContext::new_missing(
887            "Pin",
888            "ParentId",
889            self.orig_loc,
890            self.buf.as_ptr() as usize,
891        ))
892    }
893    pub fn get_module_name(&self) -> Result<&'a CStr, ErrorContext> {
894        let mut iter = self.clone();
895        iter.pos = 0;
896        for attr in iter {
897            if let Ok(Pin::ModuleName(val)) = attr {
898                return Ok(val);
899            }
900        }
901        Err(ErrorContext::new_missing(
902            "Pin",
903            "ModuleName",
904            self.orig_loc,
905            self.buf.as_ptr() as usize,
906        ))
907    }
908    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
909        let mut iter = self.clone();
910        iter.pos = 0;
911        for attr in iter {
912            if let Ok(Pin::Pad(val)) = attr {
913                return Ok(val);
914            }
915        }
916        Err(ErrorContext::new_missing(
917            "Pin",
918            "Pad",
919            self.orig_loc,
920            self.buf.as_ptr() as usize,
921        ))
922    }
923    pub fn get_clock_id(&self) -> Result<u64, ErrorContext> {
924        let mut iter = self.clone();
925        iter.pos = 0;
926        for attr in iter {
927            if let Ok(Pin::ClockId(val)) = attr {
928                return Ok(val);
929            }
930        }
931        Err(ErrorContext::new_missing(
932            "Pin",
933            "ClockId",
934            self.orig_loc,
935            self.buf.as_ptr() as usize,
936        ))
937    }
938    pub fn get_board_label(&self) -> Result<&'a CStr, ErrorContext> {
939        let mut iter = self.clone();
940        iter.pos = 0;
941        for attr in iter {
942            if let Ok(Pin::BoardLabel(val)) = attr {
943                return Ok(val);
944            }
945        }
946        Err(ErrorContext::new_missing(
947            "Pin",
948            "BoardLabel",
949            self.orig_loc,
950            self.buf.as_ptr() as usize,
951        ))
952    }
953    pub fn get_panel_label(&self) -> Result<&'a CStr, ErrorContext> {
954        let mut iter = self.clone();
955        iter.pos = 0;
956        for attr in iter {
957            if let Ok(Pin::PanelLabel(val)) = attr {
958                return Ok(val);
959            }
960        }
961        Err(ErrorContext::new_missing(
962            "Pin",
963            "PanelLabel",
964            self.orig_loc,
965            self.buf.as_ptr() as usize,
966        ))
967    }
968    pub fn get_package_label(&self) -> Result<&'a CStr, ErrorContext> {
969        let mut iter = self.clone();
970        iter.pos = 0;
971        for attr in iter {
972            if let Ok(Pin::PackageLabel(val)) = attr {
973                return Ok(val);
974            }
975        }
976        Err(ErrorContext::new_missing(
977            "Pin",
978            "PackageLabel",
979            self.orig_loc,
980            self.buf.as_ptr() as usize,
981        ))
982    }
983    #[doc = "Associated type: [`PinType`] (enum)"]
984    pub fn get_type(&self) -> Result<u32, ErrorContext> {
985        let mut iter = self.clone();
986        iter.pos = 0;
987        for attr in iter {
988            if let Ok(Pin::Type(val)) = attr {
989                return Ok(val);
990            }
991        }
992        Err(ErrorContext::new_missing(
993            "Pin",
994            "Type",
995            self.orig_loc,
996            self.buf.as_ptr() as usize,
997        ))
998    }
999    #[doc = "Associated type: [`PinDirection`] (enum)"]
1000    pub fn get_direction(&self) -> Result<u32, ErrorContext> {
1001        let mut iter = self.clone();
1002        iter.pos = 0;
1003        for attr in iter {
1004            if let Ok(Pin::Direction(val)) = attr {
1005                return Ok(val);
1006            }
1007        }
1008        Err(ErrorContext::new_missing(
1009            "Pin",
1010            "Direction",
1011            self.orig_loc,
1012            self.buf.as_ptr() as usize,
1013        ))
1014    }
1015    pub fn get_frequency(&self) -> Result<u64, ErrorContext> {
1016        let mut iter = self.clone();
1017        iter.pos = 0;
1018        for attr in iter {
1019            if let Ok(Pin::Frequency(val)) = attr {
1020                return Ok(val);
1021            }
1022        }
1023        Err(ErrorContext::new_missing(
1024            "Pin",
1025            "Frequency",
1026            self.orig_loc,
1027            self.buf.as_ptr() as usize,
1028        ))
1029    }
1030    #[doc = "Attribute may repeat multiple times (treat it as array)"]
1031    pub fn get_frequency_supported(
1032        &self,
1033    ) -> MultiAttrIterable<Self, Pin<'a>, IterableFrequencyRange<'a>> {
1034        MultiAttrIterable::new(self.clone(), |variant| {
1035            if let Pin::FrequencySupported(val) = variant {
1036                Some(val)
1037            } else {
1038                None
1039            }
1040        })
1041    }
1042    pub fn get_frequency_min(&self) -> Result<u64, ErrorContext> {
1043        let mut iter = self.clone();
1044        iter.pos = 0;
1045        for attr in iter {
1046            if let Ok(Pin::FrequencyMin(val)) = attr {
1047                return Ok(val);
1048            }
1049        }
1050        Err(ErrorContext::new_missing(
1051            "Pin",
1052            "FrequencyMin",
1053            self.orig_loc,
1054            self.buf.as_ptr() as usize,
1055        ))
1056    }
1057    pub fn get_frequency_max(&self) -> Result<u64, ErrorContext> {
1058        let mut iter = self.clone();
1059        iter.pos = 0;
1060        for attr in iter {
1061            if let Ok(Pin::FrequencyMax(val)) = attr {
1062                return Ok(val);
1063            }
1064        }
1065        Err(ErrorContext::new_missing(
1066            "Pin",
1067            "FrequencyMax",
1068            self.orig_loc,
1069            self.buf.as_ptr() as usize,
1070        ))
1071    }
1072    pub fn get_prio(&self) -> Result<u32, ErrorContext> {
1073        let mut iter = self.clone();
1074        iter.pos = 0;
1075        for attr in iter {
1076            if let Ok(Pin::Prio(val)) = attr {
1077                return Ok(val);
1078            }
1079        }
1080        Err(ErrorContext::new_missing(
1081            "Pin",
1082            "Prio",
1083            self.orig_loc,
1084            self.buf.as_ptr() as usize,
1085        ))
1086    }
1087    #[doc = "Associated type: [`PinState`] (enum)"]
1088    pub fn get_state(&self) -> Result<u32, ErrorContext> {
1089        let mut iter = self.clone();
1090        iter.pos = 0;
1091        for attr in iter {
1092            if let Ok(Pin::State(val)) = attr {
1093                return Ok(val);
1094            }
1095        }
1096        Err(ErrorContext::new_missing(
1097            "Pin",
1098            "State",
1099            self.orig_loc,
1100            self.buf.as_ptr() as usize,
1101        ))
1102    }
1103    #[doc = "Associated type: [`PinCapabilities`] (enum)"]
1104    pub fn get_capabilities(&self) -> Result<u32, ErrorContext> {
1105        let mut iter = self.clone();
1106        iter.pos = 0;
1107        for attr in iter {
1108            if let Ok(Pin::Capabilities(val)) = attr {
1109                return Ok(val);
1110            }
1111        }
1112        Err(ErrorContext::new_missing(
1113            "Pin",
1114            "Capabilities",
1115            self.orig_loc,
1116            self.buf.as_ptr() as usize,
1117        ))
1118    }
1119    #[doc = "Attribute may repeat multiple times (treat it as array)"]
1120    pub fn get_parent_device(
1121        &self,
1122    ) -> MultiAttrIterable<Self, Pin<'a>, IterablePinParentDevice<'a>> {
1123        MultiAttrIterable::new(self.clone(), |variant| {
1124            if let Pin::ParentDevice(val) = variant {
1125                Some(val)
1126            } else {
1127                None
1128            }
1129        })
1130    }
1131    #[doc = "Attribute may repeat multiple times (treat it as array)"]
1132    pub fn get_parent_pin(&self) -> MultiAttrIterable<Self, Pin<'a>, IterablePinParentPin<'a>> {
1133        MultiAttrIterable::new(self.clone(), |variant| {
1134            if let Pin::ParentPin(val) = variant {
1135                Some(val)
1136            } else {
1137                None
1138            }
1139        })
1140    }
1141    pub fn get_phase_adjust_min(&self) -> Result<i32, ErrorContext> {
1142        let mut iter = self.clone();
1143        iter.pos = 0;
1144        for attr in iter {
1145            if let Ok(Pin::PhaseAdjustMin(val)) = attr {
1146                return Ok(val);
1147            }
1148        }
1149        Err(ErrorContext::new_missing(
1150            "Pin",
1151            "PhaseAdjustMin",
1152            self.orig_loc,
1153            self.buf.as_ptr() as usize,
1154        ))
1155    }
1156    pub fn get_phase_adjust_max(&self) -> Result<i32, ErrorContext> {
1157        let mut iter = self.clone();
1158        iter.pos = 0;
1159        for attr in iter {
1160            if let Ok(Pin::PhaseAdjustMax(val)) = attr {
1161                return Ok(val);
1162            }
1163        }
1164        Err(ErrorContext::new_missing(
1165            "Pin",
1166            "PhaseAdjustMax",
1167            self.orig_loc,
1168            self.buf.as_ptr() as usize,
1169        ))
1170    }
1171    pub fn get_phase_adjust(&self) -> Result<i32, ErrorContext> {
1172        let mut iter = self.clone();
1173        iter.pos = 0;
1174        for attr in iter {
1175            if let Ok(Pin::PhaseAdjust(val)) = attr {
1176                return Ok(val);
1177            }
1178        }
1179        Err(ErrorContext::new_missing(
1180            "Pin",
1181            "PhaseAdjust",
1182            self.orig_loc,
1183            self.buf.as_ptr() as usize,
1184        ))
1185    }
1186    pub fn get_phase_offset(&self) -> Result<i64, ErrorContext> {
1187        let mut iter = self.clone();
1188        iter.pos = 0;
1189        for attr in iter {
1190            if let Ok(Pin::PhaseOffset(val)) = attr {
1191                return Ok(val);
1192            }
1193        }
1194        Err(ErrorContext::new_missing(
1195            "Pin",
1196            "PhaseOffset",
1197            self.orig_loc,
1198            self.buf.as_ptr() as usize,
1199        ))
1200    }
1201    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
1202    pub fn get_fractional_frequency_offset(&self) -> Result<i32, ErrorContext> {
1203        let mut iter = self.clone();
1204        iter.pos = 0;
1205        for attr in iter {
1206            if let Ok(Pin::FractionalFrequencyOffset(val)) = attr {
1207                return Ok(val);
1208            }
1209        }
1210        Err(ErrorContext::new_missing(
1211            "Pin",
1212            "FractionalFrequencyOffset",
1213            self.orig_loc,
1214            self.buf.as_ptr() as usize,
1215        ))
1216    }
1217    #[doc = "Frequency of Embedded SYNC signal. If provided, the pin is configured\nwith a SYNC signal embedded into its base clock frequency.\n"]
1218    pub fn get_esync_frequency(&self) -> Result<u64, ErrorContext> {
1219        let mut iter = self.clone();
1220        iter.pos = 0;
1221        for attr in iter {
1222            if let Ok(Pin::EsyncFrequency(val)) = attr {
1223                return Ok(val);
1224            }
1225        }
1226        Err(ErrorContext::new_missing(
1227            "Pin",
1228            "EsyncFrequency",
1229            self.orig_loc,
1230            self.buf.as_ptr() as usize,
1231        ))
1232    }
1233    #[doc = "If provided a pin is capable of embedding a SYNC signal (within given\nrange) into its base frequency signal.\n\nAttribute may repeat multiple times (treat it as array)"]
1234    pub fn get_esync_frequency_supported(
1235        &self,
1236    ) -> MultiAttrIterable<Self, Pin<'a>, IterableFrequencyRange<'a>> {
1237        MultiAttrIterable::new(self.clone(), |variant| {
1238            if let Pin::EsyncFrequencySupported(val) = variant {
1239                Some(val)
1240            } else {
1241                None
1242            }
1243        })
1244    }
1245    #[doc = "A ratio of high to low state of a SYNC signal pulse embedded into base\nclock frequency. Value is in percents.\n"]
1246    pub fn get_esync_pulse(&self) -> Result<u32, ErrorContext> {
1247        let mut iter = self.clone();
1248        iter.pos = 0;
1249        for attr in iter {
1250            if let Ok(Pin::EsyncPulse(val)) = attr {
1251                return Ok(val);
1252            }
1253        }
1254        Err(ErrorContext::new_missing(
1255            "Pin",
1256            "EsyncPulse",
1257            self.orig_loc,
1258            self.buf.as_ptr() as usize,
1259        ))
1260    }
1261    #[doc = "Capable pin provides list of pins that can be bound to create a\nreference-sync pin pair.\n\nAttribute may repeat multiple times (treat it as array)"]
1262    pub fn get_reference_sync(
1263        &self,
1264    ) -> MultiAttrIterable<Self, Pin<'a>, IterableReferenceSync<'a>> {
1265        MultiAttrIterable::new(self.clone(), |variant| {
1266            if let Pin::ReferenceSync(val) = variant {
1267                Some(val)
1268            } else {
1269                None
1270            }
1271        })
1272    }
1273    #[doc = "Granularity of phase adjustment, in picoseconds. The value of phase\nadjustment must be a multiple of this granularity.\n"]
1274    pub fn get_phase_adjust_gran(&self) -> Result<u32, ErrorContext> {
1275        let mut iter = self.clone();
1276        iter.pos = 0;
1277        for attr in iter {
1278            if let Ok(Pin::PhaseAdjustGran(val)) = attr {
1279                return Ok(val);
1280            }
1281        }
1282        Err(ErrorContext::new_missing(
1283            "Pin",
1284            "PhaseAdjustGran",
1285            self.orig_loc,
1286            self.buf.as_ptr() as usize,
1287        ))
1288    }
1289    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
1290    pub fn get_fractional_frequency_offset_ppt(&self) -> Result<i32, ErrorContext> {
1291        let mut iter = self.clone();
1292        iter.pos = 0;
1293        for attr in iter {
1294            if let Ok(Pin::FractionalFrequencyOffsetPpt(val)) = attr {
1295                return Ok(val);
1296            }
1297        }
1298        Err(ErrorContext::new_missing(
1299            "Pin",
1300            "FractionalFrequencyOffsetPpt",
1301            self.orig_loc,
1302            self.buf.as_ptr() as usize,
1303        ))
1304    }
1305    #[doc = "The measured frequency of the input pin in millihertz (mHz). Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY / DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\nan integer part (Hz) of a measured frequency value. Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY % DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\na fractional part of a measured frequency value.\n"]
1306    pub fn get_measured_frequency(&self) -> Result<u64, ErrorContext> {
1307        let mut iter = self.clone();
1308        iter.pos = 0;
1309        for attr in iter {
1310            if let Ok(Pin::MeasuredFrequency(val)) = attr {
1311                return Ok(val);
1312            }
1313        }
1314        Err(ErrorContext::new_missing(
1315            "Pin",
1316            "MeasuredFrequency",
1317            self.orig_loc,
1318            self.buf.as_ptr() as usize,
1319        ))
1320    }
1321    #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
1322    pub fn get_operstate(&self) -> Result<u32, ErrorContext> {
1323        let mut iter = self.clone();
1324        iter.pos = 0;
1325        for attr in iter {
1326            if let Ok(Pin::Operstate(val)) = attr {
1327                return Ok(val);
1328            }
1329        }
1330        Err(ErrorContext::new_missing(
1331            "Pin",
1332            "Operstate",
1333            self.orig_loc,
1334            self.buf.as_ptr() as usize,
1335        ))
1336    }
1337}
1338impl Pin<'_> {
1339    pub fn new<'a>(buf: &'a [u8]) -> IterablePin<'a> {
1340        IterablePin::with_loc(buf, buf.as_ptr() as usize)
1341    }
1342    fn attr_from_type(r#type: u16) -> Option<&'static str> {
1343        let res = match r#type {
1344            1u16 => "Id",
1345            2u16 => "ParentId",
1346            3u16 => "ModuleName",
1347            4u16 => "Pad",
1348            5u16 => "ClockId",
1349            6u16 => "BoardLabel",
1350            7u16 => "PanelLabel",
1351            8u16 => "PackageLabel",
1352            9u16 => "Type",
1353            10u16 => "Direction",
1354            11u16 => "Frequency",
1355            12u16 => "FrequencySupported",
1356            13u16 => "FrequencyMin",
1357            14u16 => "FrequencyMax",
1358            15u16 => "Prio",
1359            16u16 => "State",
1360            17u16 => "Capabilities",
1361            18u16 => "ParentDevice",
1362            19u16 => "ParentPin",
1363            20u16 => "PhaseAdjustMin",
1364            21u16 => "PhaseAdjustMax",
1365            22u16 => "PhaseAdjust",
1366            23u16 => "PhaseOffset",
1367            24u16 => "FractionalFrequencyOffset",
1368            25u16 => "EsyncFrequency",
1369            26u16 => "EsyncFrequencySupported",
1370            27u16 => "EsyncPulse",
1371            28u16 => "ReferenceSync",
1372            29u16 => "PhaseAdjustGran",
1373            30u16 => "FractionalFrequencyOffsetPpt",
1374            31u16 => "MeasuredFrequency",
1375            32u16 => "Operstate",
1376            _ => return None,
1377        };
1378        Some(res)
1379    }
1380}
1381#[derive(Clone, Copy, Default)]
1382pub struct IterablePin<'a> {
1383    buf: &'a [u8],
1384    pos: usize,
1385    orig_loc: usize,
1386}
1387impl<'a> IterablePin<'a> {
1388    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1389        Self {
1390            buf,
1391            pos: 0,
1392            orig_loc,
1393        }
1394    }
1395    pub fn get_buf(&self) -> &'a [u8] {
1396        self.buf
1397    }
1398}
1399impl<'a> Iterator for IterablePin<'a> {
1400    type Item = Result<Pin<'a>, ErrorContext>;
1401    fn next(&mut self) -> Option<Self::Item> {
1402        let mut pos;
1403        let mut r#type;
1404        loop {
1405            pos = self.pos;
1406            r#type = None;
1407            if self.buf.len() == self.pos {
1408                return None;
1409            }
1410            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1411                self.pos = self.buf.len();
1412                break;
1413            };
1414            r#type = Some(header.r#type);
1415            let res = match header.r#type {
1416                1u16 => Pin::Id({
1417                    let res = parse_u32(next);
1418                    let Some(val) = res else { break };
1419                    val
1420                }),
1421                2u16 => Pin::ParentId({
1422                    let res = parse_u32(next);
1423                    let Some(val) = res else { break };
1424                    val
1425                }),
1426                3u16 => Pin::ModuleName({
1427                    let res = CStr::from_bytes_with_nul(next).ok();
1428                    let Some(val) = res else { break };
1429                    val
1430                }),
1431                4u16 => Pin::Pad({
1432                    let res = Some(next);
1433                    let Some(val) = res else { break };
1434                    val
1435                }),
1436                5u16 => Pin::ClockId({
1437                    let res = parse_u64(next);
1438                    let Some(val) = res else { break };
1439                    val
1440                }),
1441                6u16 => Pin::BoardLabel({
1442                    let res = CStr::from_bytes_with_nul(next).ok();
1443                    let Some(val) = res else { break };
1444                    val
1445                }),
1446                7u16 => Pin::PanelLabel({
1447                    let res = CStr::from_bytes_with_nul(next).ok();
1448                    let Some(val) = res else { break };
1449                    val
1450                }),
1451                8u16 => Pin::PackageLabel({
1452                    let res = CStr::from_bytes_with_nul(next).ok();
1453                    let Some(val) = res else { break };
1454                    val
1455                }),
1456                9u16 => Pin::Type({
1457                    let res = parse_u32(next);
1458                    let Some(val) = res else { break };
1459                    val
1460                }),
1461                10u16 => Pin::Direction({
1462                    let res = parse_u32(next);
1463                    let Some(val) = res else { break };
1464                    val
1465                }),
1466                11u16 => Pin::Frequency({
1467                    let res = parse_u64(next);
1468                    let Some(val) = res else { break };
1469                    val
1470                }),
1471                12u16 => Pin::FrequencySupported({
1472                    let res = Some(IterableFrequencyRange::with_loc(next, self.orig_loc));
1473                    let Some(val) = res else { break };
1474                    val
1475                }),
1476                13u16 => Pin::FrequencyMin({
1477                    let res = parse_u64(next);
1478                    let Some(val) = res else { break };
1479                    val
1480                }),
1481                14u16 => Pin::FrequencyMax({
1482                    let res = parse_u64(next);
1483                    let Some(val) = res else { break };
1484                    val
1485                }),
1486                15u16 => Pin::Prio({
1487                    let res = parse_u32(next);
1488                    let Some(val) = res else { break };
1489                    val
1490                }),
1491                16u16 => Pin::State({
1492                    let res = parse_u32(next);
1493                    let Some(val) = res else { break };
1494                    val
1495                }),
1496                17u16 => Pin::Capabilities({
1497                    let res = parse_u32(next);
1498                    let Some(val) = res else { break };
1499                    val
1500                }),
1501                18u16 => Pin::ParentDevice({
1502                    let res = Some(IterablePinParentDevice::with_loc(next, self.orig_loc));
1503                    let Some(val) = res else { break };
1504                    val
1505                }),
1506                19u16 => Pin::ParentPin({
1507                    let res = Some(IterablePinParentPin::with_loc(next, self.orig_loc));
1508                    let Some(val) = res else { break };
1509                    val
1510                }),
1511                20u16 => Pin::PhaseAdjustMin({
1512                    let res = parse_i32(next);
1513                    let Some(val) = res else { break };
1514                    val
1515                }),
1516                21u16 => Pin::PhaseAdjustMax({
1517                    let res = parse_i32(next);
1518                    let Some(val) = res else { break };
1519                    val
1520                }),
1521                22u16 => Pin::PhaseAdjust({
1522                    let res = parse_i32(next);
1523                    let Some(val) = res else { break };
1524                    val
1525                }),
1526                23u16 => Pin::PhaseOffset({
1527                    let res = parse_i64(next);
1528                    let Some(val) = res else { break };
1529                    val
1530                }),
1531                24u16 => Pin::FractionalFrequencyOffset({
1532                    let res = parse_i32(next);
1533                    let Some(val) = res else { break };
1534                    val
1535                }),
1536                25u16 => Pin::EsyncFrequency({
1537                    let res = parse_u64(next);
1538                    let Some(val) = res else { break };
1539                    val
1540                }),
1541                26u16 => Pin::EsyncFrequencySupported({
1542                    let res = Some(IterableFrequencyRange::with_loc(next, self.orig_loc));
1543                    let Some(val) = res else { break };
1544                    val
1545                }),
1546                27u16 => Pin::EsyncPulse({
1547                    let res = parse_u32(next);
1548                    let Some(val) = res else { break };
1549                    val
1550                }),
1551                28u16 => Pin::ReferenceSync({
1552                    let res = Some(IterableReferenceSync::with_loc(next, self.orig_loc));
1553                    let Some(val) = res else { break };
1554                    val
1555                }),
1556                29u16 => Pin::PhaseAdjustGran({
1557                    let res = parse_u32(next);
1558                    let Some(val) = res else { break };
1559                    val
1560                }),
1561                30u16 => Pin::FractionalFrequencyOffsetPpt({
1562                    let res = parse_i32(next);
1563                    let Some(val) = res else { break };
1564                    val
1565                }),
1566                31u16 => Pin::MeasuredFrequency({
1567                    let res = parse_u64(next);
1568                    let Some(val) = res else { break };
1569                    val
1570                }),
1571                32u16 => Pin::Operstate({
1572                    let res = parse_u32(next);
1573                    let Some(val) = res else { break };
1574                    val
1575                }),
1576                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
1577                n => continue,
1578            };
1579            return Some(Ok(res));
1580        }
1581        Some(Err(ErrorContext::new(
1582            "Pin",
1583            r#type.and_then(|t| Pin::attr_from_type(t)),
1584            self.orig_loc,
1585            self.buf.as_ptr().wrapping_add(pos) as usize,
1586        )))
1587    }
1588}
1589impl<'a> std::fmt::Debug for IterablePin<'_> {
1590    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1591        let mut fmt = f.debug_struct("Pin");
1592        for attr in self.clone() {
1593            let attr = match attr {
1594                Ok(a) => a,
1595                Err(err) => {
1596                    fmt.finish()?;
1597                    f.write_str("Err(")?;
1598                    err.fmt(f)?;
1599                    return f.write_str(")");
1600                }
1601            };
1602            match attr {
1603                Pin::Id(val) => fmt.field("Id", &val),
1604                Pin::ParentId(val) => fmt.field("ParentId", &val),
1605                Pin::ModuleName(val) => fmt.field("ModuleName", &val),
1606                Pin::Pad(val) => fmt.field("Pad", &val),
1607                Pin::ClockId(val) => fmt.field("ClockId", &val),
1608                Pin::BoardLabel(val) => fmt.field("BoardLabel", &val),
1609                Pin::PanelLabel(val) => fmt.field("PanelLabel", &val),
1610                Pin::PackageLabel(val) => fmt.field("PackageLabel", &val),
1611                Pin::Type(val) => fmt.field("Type", &FormatEnum(val.into(), PinType::from_value)),
1612                Pin::Direction(val) => fmt.field(
1613                    "Direction",
1614                    &FormatEnum(val.into(), PinDirection::from_value),
1615                ),
1616                Pin::Frequency(val) => fmt.field("Frequency", &val),
1617                Pin::FrequencySupported(val) => fmt.field("FrequencySupported", &val),
1618                Pin::FrequencyMin(val) => fmt.field("FrequencyMin", &val),
1619                Pin::FrequencyMax(val) => fmt.field("FrequencyMax", &val),
1620                Pin::Prio(val) => fmt.field("Prio", &val),
1621                Pin::State(val) => {
1622                    fmt.field("State", &FormatEnum(val.into(), PinState::from_value))
1623                }
1624                Pin::Capabilities(val) => fmt.field(
1625                    "Capabilities",
1626                    &FormatFlags(val.into(), PinCapabilities::from_value),
1627                ),
1628                Pin::ParentDevice(val) => fmt.field("ParentDevice", &val),
1629                Pin::ParentPin(val) => fmt.field("ParentPin", &val),
1630                Pin::PhaseAdjustMin(val) => fmt.field("PhaseAdjustMin", &val),
1631                Pin::PhaseAdjustMax(val) => fmt.field("PhaseAdjustMax", &val),
1632                Pin::PhaseAdjust(val) => fmt.field("PhaseAdjust", &val),
1633                Pin::PhaseOffset(val) => fmt.field("PhaseOffset", &val),
1634                Pin::FractionalFrequencyOffset(val) => fmt.field("FractionalFrequencyOffset", &val),
1635                Pin::EsyncFrequency(val) => fmt.field("EsyncFrequency", &val),
1636                Pin::EsyncFrequencySupported(val) => fmt.field("EsyncFrequencySupported", &val),
1637                Pin::EsyncPulse(val) => fmt.field("EsyncPulse", &val),
1638                Pin::ReferenceSync(val) => fmt.field("ReferenceSync", &val),
1639                Pin::PhaseAdjustGran(val) => fmt.field("PhaseAdjustGran", &val),
1640                Pin::FractionalFrequencyOffsetPpt(val) => {
1641                    fmt.field("FractionalFrequencyOffsetPpt", &val)
1642                }
1643                Pin::MeasuredFrequency(val) => fmt.field("MeasuredFrequency", &val),
1644                Pin::Operstate(val) => fmt.field(
1645                    "Operstate",
1646                    &FormatEnum(val.into(), PinOperstate::from_value),
1647                ),
1648            };
1649        }
1650        fmt.finish()
1651    }
1652}
1653impl IterablePin<'_> {
1654    pub fn lookup_attr(
1655        &self,
1656        offset: usize,
1657        missing_type: Option<u16>,
1658    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
1659        let mut stack = Vec::new();
1660        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
1661        if missing_type.is_some() && cur == offset {
1662            stack.push(("Pin", offset));
1663            return (stack, missing_type.and_then(|t| Pin::attr_from_type(t)));
1664        }
1665        if cur > offset || cur + self.buf.len() < offset {
1666            return (stack, None);
1667        }
1668        let mut attrs = self.clone();
1669        let mut last_off = cur + attrs.pos;
1670        let mut missing = None;
1671        while let Some(attr) = attrs.next() {
1672            let Ok(attr) = attr else { break };
1673            match attr {
1674                Pin::Id(val) => {
1675                    if last_off == offset {
1676                        stack.push(("Id", last_off));
1677                        break;
1678                    }
1679                }
1680                Pin::ParentId(val) => {
1681                    if last_off == offset {
1682                        stack.push(("ParentId", last_off));
1683                        break;
1684                    }
1685                }
1686                Pin::ModuleName(val) => {
1687                    if last_off == offset {
1688                        stack.push(("ModuleName", last_off));
1689                        break;
1690                    }
1691                }
1692                Pin::Pad(val) => {
1693                    if last_off == offset {
1694                        stack.push(("Pad", last_off));
1695                        break;
1696                    }
1697                }
1698                Pin::ClockId(val) => {
1699                    if last_off == offset {
1700                        stack.push(("ClockId", last_off));
1701                        break;
1702                    }
1703                }
1704                Pin::BoardLabel(val) => {
1705                    if last_off == offset {
1706                        stack.push(("BoardLabel", last_off));
1707                        break;
1708                    }
1709                }
1710                Pin::PanelLabel(val) => {
1711                    if last_off == offset {
1712                        stack.push(("PanelLabel", last_off));
1713                        break;
1714                    }
1715                }
1716                Pin::PackageLabel(val) => {
1717                    if last_off == offset {
1718                        stack.push(("PackageLabel", last_off));
1719                        break;
1720                    }
1721                }
1722                Pin::Type(val) => {
1723                    if last_off == offset {
1724                        stack.push(("Type", last_off));
1725                        break;
1726                    }
1727                }
1728                Pin::Direction(val) => {
1729                    if last_off == offset {
1730                        stack.push(("Direction", last_off));
1731                        break;
1732                    }
1733                }
1734                Pin::Frequency(val) => {
1735                    if last_off == offset {
1736                        stack.push(("Frequency", last_off));
1737                        break;
1738                    }
1739                }
1740                Pin::FrequencySupported(val) => {
1741                    (stack, missing) = val.lookup_attr(offset, missing_type);
1742                    if !stack.is_empty() {
1743                        break;
1744                    }
1745                }
1746                Pin::FrequencyMin(val) => {
1747                    if last_off == offset {
1748                        stack.push(("FrequencyMin", last_off));
1749                        break;
1750                    }
1751                }
1752                Pin::FrequencyMax(val) => {
1753                    if last_off == offset {
1754                        stack.push(("FrequencyMax", last_off));
1755                        break;
1756                    }
1757                }
1758                Pin::Prio(val) => {
1759                    if last_off == offset {
1760                        stack.push(("Prio", last_off));
1761                        break;
1762                    }
1763                }
1764                Pin::State(val) => {
1765                    if last_off == offset {
1766                        stack.push(("State", last_off));
1767                        break;
1768                    }
1769                }
1770                Pin::Capabilities(val) => {
1771                    if last_off == offset {
1772                        stack.push(("Capabilities", last_off));
1773                        break;
1774                    }
1775                }
1776                Pin::ParentDevice(val) => {
1777                    (stack, missing) = val.lookup_attr(offset, missing_type);
1778                    if !stack.is_empty() {
1779                        break;
1780                    }
1781                }
1782                Pin::ParentPin(val) => {
1783                    (stack, missing) = val.lookup_attr(offset, missing_type);
1784                    if !stack.is_empty() {
1785                        break;
1786                    }
1787                }
1788                Pin::PhaseAdjustMin(val) => {
1789                    if last_off == offset {
1790                        stack.push(("PhaseAdjustMin", last_off));
1791                        break;
1792                    }
1793                }
1794                Pin::PhaseAdjustMax(val) => {
1795                    if last_off == offset {
1796                        stack.push(("PhaseAdjustMax", last_off));
1797                        break;
1798                    }
1799                }
1800                Pin::PhaseAdjust(val) => {
1801                    if last_off == offset {
1802                        stack.push(("PhaseAdjust", last_off));
1803                        break;
1804                    }
1805                }
1806                Pin::PhaseOffset(val) => {
1807                    if last_off == offset {
1808                        stack.push(("PhaseOffset", last_off));
1809                        break;
1810                    }
1811                }
1812                Pin::FractionalFrequencyOffset(val) => {
1813                    if last_off == offset {
1814                        stack.push(("FractionalFrequencyOffset", last_off));
1815                        break;
1816                    }
1817                }
1818                Pin::EsyncFrequency(val) => {
1819                    if last_off == offset {
1820                        stack.push(("EsyncFrequency", last_off));
1821                        break;
1822                    }
1823                }
1824                Pin::EsyncFrequencySupported(val) => {
1825                    (stack, missing) = val.lookup_attr(offset, missing_type);
1826                    if !stack.is_empty() {
1827                        break;
1828                    }
1829                }
1830                Pin::EsyncPulse(val) => {
1831                    if last_off == offset {
1832                        stack.push(("EsyncPulse", last_off));
1833                        break;
1834                    }
1835                }
1836                Pin::ReferenceSync(val) => {
1837                    (stack, missing) = val.lookup_attr(offset, missing_type);
1838                    if !stack.is_empty() {
1839                        break;
1840                    }
1841                }
1842                Pin::PhaseAdjustGran(val) => {
1843                    if last_off == offset {
1844                        stack.push(("PhaseAdjustGran", last_off));
1845                        break;
1846                    }
1847                }
1848                Pin::FractionalFrequencyOffsetPpt(val) => {
1849                    if last_off == offset {
1850                        stack.push(("FractionalFrequencyOffsetPpt", last_off));
1851                        break;
1852                    }
1853                }
1854                Pin::MeasuredFrequency(val) => {
1855                    if last_off == offset {
1856                        stack.push(("MeasuredFrequency", last_off));
1857                        break;
1858                    }
1859                }
1860                Pin::Operstate(val) => {
1861                    if last_off == offset {
1862                        stack.push(("Operstate", last_off));
1863                        break;
1864                    }
1865                }
1866                _ => {}
1867            };
1868            last_off = cur + attrs.pos;
1869        }
1870        if !stack.is_empty() {
1871            stack.push(("Pin", cur));
1872        }
1873        (stack, missing)
1874    }
1875}
1876#[derive(Clone)]
1877pub enum PinParentDevice {
1878    ParentId(u32),
1879    #[doc = "Associated type: [`PinDirection`] (enum)"]
1880    Direction(u32),
1881    Prio(u32),
1882    #[doc = "Associated type: [`PinState`] (enum)"]
1883    State(u32),
1884    PhaseOffset(i64),
1885    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
1886    FractionalFrequencyOffset(i32),
1887    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
1888    FractionalFrequencyOffsetPpt(i32),
1889    #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
1890    Operstate(u32),
1891}
1892impl<'a> IterablePinParentDevice<'a> {
1893    pub fn get_parent_id(&self) -> Result<u32, ErrorContext> {
1894        let mut iter = self.clone();
1895        iter.pos = 0;
1896        for attr in iter {
1897            if let Ok(PinParentDevice::ParentId(val)) = attr {
1898                return Ok(val);
1899            }
1900        }
1901        Err(ErrorContext::new_missing(
1902            "PinParentDevice",
1903            "ParentId",
1904            self.orig_loc,
1905            self.buf.as_ptr() as usize,
1906        ))
1907    }
1908    #[doc = "Associated type: [`PinDirection`] (enum)"]
1909    pub fn get_direction(&self) -> Result<u32, ErrorContext> {
1910        let mut iter = self.clone();
1911        iter.pos = 0;
1912        for attr in iter {
1913            if let Ok(PinParentDevice::Direction(val)) = attr {
1914                return Ok(val);
1915            }
1916        }
1917        Err(ErrorContext::new_missing(
1918            "PinParentDevice",
1919            "Direction",
1920            self.orig_loc,
1921            self.buf.as_ptr() as usize,
1922        ))
1923    }
1924    pub fn get_prio(&self) -> Result<u32, ErrorContext> {
1925        let mut iter = self.clone();
1926        iter.pos = 0;
1927        for attr in iter {
1928            if let Ok(PinParentDevice::Prio(val)) = attr {
1929                return Ok(val);
1930            }
1931        }
1932        Err(ErrorContext::new_missing(
1933            "PinParentDevice",
1934            "Prio",
1935            self.orig_loc,
1936            self.buf.as_ptr() as usize,
1937        ))
1938    }
1939    #[doc = "Associated type: [`PinState`] (enum)"]
1940    pub fn get_state(&self) -> Result<u32, ErrorContext> {
1941        let mut iter = self.clone();
1942        iter.pos = 0;
1943        for attr in iter {
1944            if let Ok(PinParentDevice::State(val)) = attr {
1945                return Ok(val);
1946            }
1947        }
1948        Err(ErrorContext::new_missing(
1949            "PinParentDevice",
1950            "State",
1951            self.orig_loc,
1952            self.buf.as_ptr() as usize,
1953        ))
1954    }
1955    pub fn get_phase_offset(&self) -> Result<i64, ErrorContext> {
1956        let mut iter = self.clone();
1957        iter.pos = 0;
1958        for attr in iter {
1959            if let Ok(PinParentDevice::PhaseOffset(val)) = attr {
1960                return Ok(val);
1961            }
1962        }
1963        Err(ErrorContext::new_missing(
1964            "PinParentDevice",
1965            "PhaseOffset",
1966            self.orig_loc,
1967            self.buf.as_ptr() as usize,
1968        ))
1969    }
1970    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
1971    pub fn get_fractional_frequency_offset(&self) -> Result<i32, ErrorContext> {
1972        let mut iter = self.clone();
1973        iter.pos = 0;
1974        for attr in iter {
1975            if let Ok(PinParentDevice::FractionalFrequencyOffset(val)) = attr {
1976                return Ok(val);
1977            }
1978        }
1979        Err(ErrorContext::new_missing(
1980            "PinParentDevice",
1981            "FractionalFrequencyOffset",
1982            self.orig_loc,
1983            self.buf.as_ptr() as usize,
1984        ))
1985    }
1986    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
1987    pub fn get_fractional_frequency_offset_ppt(&self) -> Result<i32, ErrorContext> {
1988        let mut iter = self.clone();
1989        iter.pos = 0;
1990        for attr in iter {
1991            if let Ok(PinParentDevice::FractionalFrequencyOffsetPpt(val)) = attr {
1992                return Ok(val);
1993            }
1994        }
1995        Err(ErrorContext::new_missing(
1996            "PinParentDevice",
1997            "FractionalFrequencyOffsetPpt",
1998            self.orig_loc,
1999            self.buf.as_ptr() as usize,
2000        ))
2001    }
2002    #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
2003    pub fn get_operstate(&self) -> Result<u32, ErrorContext> {
2004        let mut iter = self.clone();
2005        iter.pos = 0;
2006        for attr in iter {
2007            if let Ok(PinParentDevice::Operstate(val)) = attr {
2008                return Ok(val);
2009            }
2010        }
2011        Err(ErrorContext::new_missing(
2012            "PinParentDevice",
2013            "Operstate",
2014            self.orig_loc,
2015            self.buf.as_ptr() as usize,
2016        ))
2017    }
2018}
2019impl PinParentDevice {
2020    pub fn new<'a>(buf: &'a [u8]) -> IterablePinParentDevice<'a> {
2021        IterablePinParentDevice::with_loc(buf, buf.as_ptr() as usize)
2022    }
2023    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2024        Pin::attr_from_type(r#type)
2025    }
2026}
2027#[derive(Clone, Copy, Default)]
2028pub struct IterablePinParentDevice<'a> {
2029    buf: &'a [u8],
2030    pos: usize,
2031    orig_loc: usize,
2032}
2033impl<'a> IterablePinParentDevice<'a> {
2034    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2035        Self {
2036            buf,
2037            pos: 0,
2038            orig_loc,
2039        }
2040    }
2041    pub fn get_buf(&self) -> &'a [u8] {
2042        self.buf
2043    }
2044}
2045impl<'a> Iterator for IterablePinParentDevice<'a> {
2046    type Item = Result<PinParentDevice, ErrorContext>;
2047    fn next(&mut self) -> Option<Self::Item> {
2048        let mut pos;
2049        let mut r#type;
2050        loop {
2051            pos = self.pos;
2052            r#type = None;
2053            if self.buf.len() == self.pos {
2054                return None;
2055            }
2056            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2057                self.pos = self.buf.len();
2058                break;
2059            };
2060            r#type = Some(header.r#type);
2061            let res = match header.r#type {
2062                2u16 => PinParentDevice::ParentId({
2063                    let res = parse_u32(next);
2064                    let Some(val) = res else { break };
2065                    val
2066                }),
2067                10u16 => PinParentDevice::Direction({
2068                    let res = parse_u32(next);
2069                    let Some(val) = res else { break };
2070                    val
2071                }),
2072                15u16 => PinParentDevice::Prio({
2073                    let res = parse_u32(next);
2074                    let Some(val) = res else { break };
2075                    val
2076                }),
2077                16u16 => PinParentDevice::State({
2078                    let res = parse_u32(next);
2079                    let Some(val) = res else { break };
2080                    val
2081                }),
2082                23u16 => PinParentDevice::PhaseOffset({
2083                    let res = parse_i64(next);
2084                    let Some(val) = res else { break };
2085                    val
2086                }),
2087                24u16 => PinParentDevice::FractionalFrequencyOffset({
2088                    let res = parse_i32(next);
2089                    let Some(val) = res else { break };
2090                    val
2091                }),
2092                30u16 => PinParentDevice::FractionalFrequencyOffsetPpt({
2093                    let res = parse_i32(next);
2094                    let Some(val) = res else { break };
2095                    val
2096                }),
2097                32u16 => PinParentDevice::Operstate({
2098                    let res = parse_u32(next);
2099                    let Some(val) = res else { break };
2100                    val
2101                }),
2102                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2103                n => continue,
2104            };
2105            return Some(Ok(res));
2106        }
2107        Some(Err(ErrorContext::new(
2108            "PinParentDevice",
2109            r#type.and_then(|t| PinParentDevice::attr_from_type(t)),
2110            self.orig_loc,
2111            self.buf.as_ptr().wrapping_add(pos) as usize,
2112        )))
2113    }
2114}
2115impl std::fmt::Debug for IterablePinParentDevice<'_> {
2116    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2117        let mut fmt = f.debug_struct("PinParentDevice");
2118        for attr in self.clone() {
2119            let attr = match attr {
2120                Ok(a) => a,
2121                Err(err) => {
2122                    fmt.finish()?;
2123                    f.write_str("Err(")?;
2124                    err.fmt(f)?;
2125                    return f.write_str(")");
2126                }
2127            };
2128            match attr {
2129                PinParentDevice::ParentId(val) => fmt.field("ParentId", &val),
2130                PinParentDevice::Direction(val) => fmt.field(
2131                    "Direction",
2132                    &FormatEnum(val.into(), PinDirection::from_value),
2133                ),
2134                PinParentDevice::Prio(val) => fmt.field("Prio", &val),
2135                PinParentDevice::State(val) => {
2136                    fmt.field("State", &FormatEnum(val.into(), PinState::from_value))
2137                }
2138                PinParentDevice::PhaseOffset(val) => fmt.field("PhaseOffset", &val),
2139                PinParentDevice::FractionalFrequencyOffset(val) => {
2140                    fmt.field("FractionalFrequencyOffset", &val)
2141                }
2142                PinParentDevice::FractionalFrequencyOffsetPpt(val) => {
2143                    fmt.field("FractionalFrequencyOffsetPpt", &val)
2144                }
2145                PinParentDevice::Operstate(val) => fmt.field(
2146                    "Operstate",
2147                    &FormatEnum(val.into(), PinOperstate::from_value),
2148                ),
2149            };
2150        }
2151        fmt.finish()
2152    }
2153}
2154impl IterablePinParentDevice<'_> {
2155    pub fn lookup_attr(
2156        &self,
2157        offset: usize,
2158        missing_type: Option<u16>,
2159    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2160        let mut stack = Vec::new();
2161        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2162        if missing_type.is_some() && cur == offset {
2163            stack.push(("PinParentDevice", offset));
2164            return (
2165                stack,
2166                missing_type.and_then(|t| PinParentDevice::attr_from_type(t)),
2167            );
2168        }
2169        if cur > offset || cur + self.buf.len() < offset {
2170            return (stack, None);
2171        }
2172        let mut attrs = self.clone();
2173        let mut last_off = cur + attrs.pos;
2174        while let Some(attr) = attrs.next() {
2175            let Ok(attr) = attr else { break };
2176            match attr {
2177                PinParentDevice::ParentId(val) => {
2178                    if last_off == offset {
2179                        stack.push(("ParentId", last_off));
2180                        break;
2181                    }
2182                }
2183                PinParentDevice::Direction(val) => {
2184                    if last_off == offset {
2185                        stack.push(("Direction", last_off));
2186                        break;
2187                    }
2188                }
2189                PinParentDevice::Prio(val) => {
2190                    if last_off == offset {
2191                        stack.push(("Prio", last_off));
2192                        break;
2193                    }
2194                }
2195                PinParentDevice::State(val) => {
2196                    if last_off == offset {
2197                        stack.push(("State", last_off));
2198                        break;
2199                    }
2200                }
2201                PinParentDevice::PhaseOffset(val) => {
2202                    if last_off == offset {
2203                        stack.push(("PhaseOffset", last_off));
2204                        break;
2205                    }
2206                }
2207                PinParentDevice::FractionalFrequencyOffset(val) => {
2208                    if last_off == offset {
2209                        stack.push(("FractionalFrequencyOffset", last_off));
2210                        break;
2211                    }
2212                }
2213                PinParentDevice::FractionalFrequencyOffsetPpt(val) => {
2214                    if last_off == offset {
2215                        stack.push(("FractionalFrequencyOffsetPpt", last_off));
2216                        break;
2217                    }
2218                }
2219                PinParentDevice::Operstate(val) => {
2220                    if last_off == offset {
2221                        stack.push(("Operstate", last_off));
2222                        break;
2223                    }
2224                }
2225                _ => {}
2226            };
2227            last_off = cur + attrs.pos;
2228        }
2229        if !stack.is_empty() {
2230            stack.push(("PinParentDevice", cur));
2231        }
2232        (stack, None)
2233    }
2234}
2235#[derive(Clone)]
2236pub enum PinParentPin {
2237    ParentId(u32),
2238    #[doc = "Associated type: [`PinState`] (enum)"]
2239    State(u32),
2240}
2241impl<'a> IterablePinParentPin<'a> {
2242    pub fn get_parent_id(&self) -> Result<u32, ErrorContext> {
2243        let mut iter = self.clone();
2244        iter.pos = 0;
2245        for attr in iter {
2246            if let Ok(PinParentPin::ParentId(val)) = attr {
2247                return Ok(val);
2248            }
2249        }
2250        Err(ErrorContext::new_missing(
2251            "PinParentPin",
2252            "ParentId",
2253            self.orig_loc,
2254            self.buf.as_ptr() as usize,
2255        ))
2256    }
2257    #[doc = "Associated type: [`PinState`] (enum)"]
2258    pub fn get_state(&self) -> Result<u32, ErrorContext> {
2259        let mut iter = self.clone();
2260        iter.pos = 0;
2261        for attr in iter {
2262            if let Ok(PinParentPin::State(val)) = attr {
2263                return Ok(val);
2264            }
2265        }
2266        Err(ErrorContext::new_missing(
2267            "PinParentPin",
2268            "State",
2269            self.orig_loc,
2270            self.buf.as_ptr() as usize,
2271        ))
2272    }
2273}
2274impl PinParentPin {
2275    pub fn new<'a>(buf: &'a [u8]) -> IterablePinParentPin<'a> {
2276        IterablePinParentPin::with_loc(buf, buf.as_ptr() as usize)
2277    }
2278    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2279        Pin::attr_from_type(r#type)
2280    }
2281}
2282#[derive(Clone, Copy, Default)]
2283pub struct IterablePinParentPin<'a> {
2284    buf: &'a [u8],
2285    pos: usize,
2286    orig_loc: usize,
2287}
2288impl<'a> IterablePinParentPin<'a> {
2289    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2290        Self {
2291            buf,
2292            pos: 0,
2293            orig_loc,
2294        }
2295    }
2296    pub fn get_buf(&self) -> &'a [u8] {
2297        self.buf
2298    }
2299}
2300impl<'a> Iterator for IterablePinParentPin<'a> {
2301    type Item = Result<PinParentPin, ErrorContext>;
2302    fn next(&mut self) -> Option<Self::Item> {
2303        let mut pos;
2304        let mut r#type;
2305        loop {
2306            pos = self.pos;
2307            r#type = None;
2308            if self.buf.len() == self.pos {
2309                return None;
2310            }
2311            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2312                self.pos = self.buf.len();
2313                break;
2314            };
2315            r#type = Some(header.r#type);
2316            let res = match header.r#type {
2317                2u16 => PinParentPin::ParentId({
2318                    let res = parse_u32(next);
2319                    let Some(val) = res else { break };
2320                    val
2321                }),
2322                16u16 => PinParentPin::State({
2323                    let res = parse_u32(next);
2324                    let Some(val) = res else { break };
2325                    val
2326                }),
2327                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2328                n => continue,
2329            };
2330            return Some(Ok(res));
2331        }
2332        Some(Err(ErrorContext::new(
2333            "PinParentPin",
2334            r#type.and_then(|t| PinParentPin::attr_from_type(t)),
2335            self.orig_loc,
2336            self.buf.as_ptr().wrapping_add(pos) as usize,
2337        )))
2338    }
2339}
2340impl std::fmt::Debug for IterablePinParentPin<'_> {
2341    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2342        let mut fmt = f.debug_struct("PinParentPin");
2343        for attr in self.clone() {
2344            let attr = match attr {
2345                Ok(a) => a,
2346                Err(err) => {
2347                    fmt.finish()?;
2348                    f.write_str("Err(")?;
2349                    err.fmt(f)?;
2350                    return f.write_str(")");
2351                }
2352            };
2353            match attr {
2354                PinParentPin::ParentId(val) => fmt.field("ParentId", &val),
2355                PinParentPin::State(val) => {
2356                    fmt.field("State", &FormatEnum(val.into(), PinState::from_value))
2357                }
2358            };
2359        }
2360        fmt.finish()
2361    }
2362}
2363impl IterablePinParentPin<'_> {
2364    pub fn lookup_attr(
2365        &self,
2366        offset: usize,
2367        missing_type: Option<u16>,
2368    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2369        let mut stack = Vec::new();
2370        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2371        if missing_type.is_some() && cur == offset {
2372            stack.push(("PinParentPin", offset));
2373            return (
2374                stack,
2375                missing_type.and_then(|t| PinParentPin::attr_from_type(t)),
2376            );
2377        }
2378        if cur > offset || cur + self.buf.len() < offset {
2379            return (stack, None);
2380        }
2381        let mut attrs = self.clone();
2382        let mut last_off = cur + attrs.pos;
2383        while let Some(attr) = attrs.next() {
2384            let Ok(attr) = attr else { break };
2385            match attr {
2386                PinParentPin::ParentId(val) => {
2387                    if last_off == offset {
2388                        stack.push(("ParentId", last_off));
2389                        break;
2390                    }
2391                }
2392                PinParentPin::State(val) => {
2393                    if last_off == offset {
2394                        stack.push(("State", last_off));
2395                        break;
2396                    }
2397                }
2398                _ => {}
2399            };
2400            last_off = cur + attrs.pos;
2401        }
2402        if !stack.is_empty() {
2403            stack.push(("PinParentPin", cur));
2404        }
2405        (stack, None)
2406    }
2407}
2408#[derive(Clone)]
2409pub enum FrequencyRange {
2410    FrequencyMin(u64),
2411    FrequencyMax(u64),
2412}
2413impl<'a> IterableFrequencyRange<'a> {
2414    pub fn get_frequency_min(&self) -> Result<u64, ErrorContext> {
2415        let mut iter = self.clone();
2416        iter.pos = 0;
2417        for attr in iter {
2418            if let Ok(FrequencyRange::FrequencyMin(val)) = attr {
2419                return Ok(val);
2420            }
2421        }
2422        Err(ErrorContext::new_missing(
2423            "FrequencyRange",
2424            "FrequencyMin",
2425            self.orig_loc,
2426            self.buf.as_ptr() as usize,
2427        ))
2428    }
2429    pub fn get_frequency_max(&self) -> Result<u64, ErrorContext> {
2430        let mut iter = self.clone();
2431        iter.pos = 0;
2432        for attr in iter {
2433            if let Ok(FrequencyRange::FrequencyMax(val)) = attr {
2434                return Ok(val);
2435            }
2436        }
2437        Err(ErrorContext::new_missing(
2438            "FrequencyRange",
2439            "FrequencyMax",
2440            self.orig_loc,
2441            self.buf.as_ptr() as usize,
2442        ))
2443    }
2444}
2445impl FrequencyRange {
2446    pub fn new<'a>(buf: &'a [u8]) -> IterableFrequencyRange<'a> {
2447        IterableFrequencyRange::with_loc(buf, buf.as_ptr() as usize)
2448    }
2449    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2450        Pin::attr_from_type(r#type)
2451    }
2452}
2453#[derive(Clone, Copy, Default)]
2454pub struct IterableFrequencyRange<'a> {
2455    buf: &'a [u8],
2456    pos: usize,
2457    orig_loc: usize,
2458}
2459impl<'a> IterableFrequencyRange<'a> {
2460    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2461        Self {
2462            buf,
2463            pos: 0,
2464            orig_loc,
2465        }
2466    }
2467    pub fn get_buf(&self) -> &'a [u8] {
2468        self.buf
2469    }
2470}
2471impl<'a> Iterator for IterableFrequencyRange<'a> {
2472    type Item = Result<FrequencyRange, ErrorContext>;
2473    fn next(&mut self) -> Option<Self::Item> {
2474        let mut pos;
2475        let mut r#type;
2476        loop {
2477            pos = self.pos;
2478            r#type = None;
2479            if self.buf.len() == self.pos {
2480                return None;
2481            }
2482            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2483                self.pos = self.buf.len();
2484                break;
2485            };
2486            r#type = Some(header.r#type);
2487            let res = match header.r#type {
2488                13u16 => FrequencyRange::FrequencyMin({
2489                    let res = parse_u64(next);
2490                    let Some(val) = res else { break };
2491                    val
2492                }),
2493                14u16 => FrequencyRange::FrequencyMax({
2494                    let res = parse_u64(next);
2495                    let Some(val) = res else { break };
2496                    val
2497                }),
2498                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2499                n => continue,
2500            };
2501            return Some(Ok(res));
2502        }
2503        Some(Err(ErrorContext::new(
2504            "FrequencyRange",
2505            r#type.and_then(|t| FrequencyRange::attr_from_type(t)),
2506            self.orig_loc,
2507            self.buf.as_ptr().wrapping_add(pos) as usize,
2508        )))
2509    }
2510}
2511impl std::fmt::Debug for IterableFrequencyRange<'_> {
2512    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2513        let mut fmt = f.debug_struct("FrequencyRange");
2514        for attr in self.clone() {
2515            let attr = match attr {
2516                Ok(a) => a,
2517                Err(err) => {
2518                    fmt.finish()?;
2519                    f.write_str("Err(")?;
2520                    err.fmt(f)?;
2521                    return f.write_str(")");
2522                }
2523            };
2524            match attr {
2525                FrequencyRange::FrequencyMin(val) => fmt.field("FrequencyMin", &val),
2526                FrequencyRange::FrequencyMax(val) => fmt.field("FrequencyMax", &val),
2527            };
2528        }
2529        fmt.finish()
2530    }
2531}
2532impl IterableFrequencyRange<'_> {
2533    pub fn lookup_attr(
2534        &self,
2535        offset: usize,
2536        missing_type: Option<u16>,
2537    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2538        let mut stack = Vec::new();
2539        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2540        if missing_type.is_some() && cur == offset {
2541            stack.push(("FrequencyRange", offset));
2542            return (
2543                stack,
2544                missing_type.and_then(|t| FrequencyRange::attr_from_type(t)),
2545            );
2546        }
2547        if cur > offset || cur + self.buf.len() < offset {
2548            return (stack, None);
2549        }
2550        let mut attrs = self.clone();
2551        let mut last_off = cur + attrs.pos;
2552        while let Some(attr) = attrs.next() {
2553            let Ok(attr) = attr else { break };
2554            match attr {
2555                FrequencyRange::FrequencyMin(val) => {
2556                    if last_off == offset {
2557                        stack.push(("FrequencyMin", last_off));
2558                        break;
2559                    }
2560                }
2561                FrequencyRange::FrequencyMax(val) => {
2562                    if last_off == offset {
2563                        stack.push(("FrequencyMax", last_off));
2564                        break;
2565                    }
2566                }
2567                _ => {}
2568            };
2569            last_off = cur + attrs.pos;
2570        }
2571        if !stack.is_empty() {
2572            stack.push(("FrequencyRange", cur));
2573        }
2574        (stack, None)
2575    }
2576}
2577#[derive(Clone)]
2578pub enum ReferenceSync {
2579    Id(u32),
2580    #[doc = "Associated type: [`PinState`] (enum)"]
2581    State(u32),
2582}
2583impl<'a> IterableReferenceSync<'a> {
2584    pub fn get_id(&self) -> Result<u32, ErrorContext> {
2585        let mut iter = self.clone();
2586        iter.pos = 0;
2587        for attr in iter {
2588            if let Ok(ReferenceSync::Id(val)) = attr {
2589                return Ok(val);
2590            }
2591        }
2592        Err(ErrorContext::new_missing(
2593            "ReferenceSync",
2594            "Id",
2595            self.orig_loc,
2596            self.buf.as_ptr() as usize,
2597        ))
2598    }
2599    #[doc = "Associated type: [`PinState`] (enum)"]
2600    pub fn get_state(&self) -> Result<u32, ErrorContext> {
2601        let mut iter = self.clone();
2602        iter.pos = 0;
2603        for attr in iter {
2604            if let Ok(ReferenceSync::State(val)) = attr {
2605                return Ok(val);
2606            }
2607        }
2608        Err(ErrorContext::new_missing(
2609            "ReferenceSync",
2610            "State",
2611            self.orig_loc,
2612            self.buf.as_ptr() as usize,
2613        ))
2614    }
2615}
2616impl ReferenceSync {
2617    pub fn new<'a>(buf: &'a [u8]) -> IterableReferenceSync<'a> {
2618        IterableReferenceSync::with_loc(buf, buf.as_ptr() as usize)
2619    }
2620    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2621        Pin::attr_from_type(r#type)
2622    }
2623}
2624#[derive(Clone, Copy, Default)]
2625pub struct IterableReferenceSync<'a> {
2626    buf: &'a [u8],
2627    pos: usize,
2628    orig_loc: usize,
2629}
2630impl<'a> IterableReferenceSync<'a> {
2631    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2632        Self {
2633            buf,
2634            pos: 0,
2635            orig_loc,
2636        }
2637    }
2638    pub fn get_buf(&self) -> &'a [u8] {
2639        self.buf
2640    }
2641}
2642impl<'a> Iterator for IterableReferenceSync<'a> {
2643    type Item = Result<ReferenceSync, ErrorContext>;
2644    fn next(&mut self) -> Option<Self::Item> {
2645        let mut pos;
2646        let mut r#type;
2647        loop {
2648            pos = self.pos;
2649            r#type = None;
2650            if self.buf.len() == self.pos {
2651                return None;
2652            }
2653            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2654                self.pos = self.buf.len();
2655                break;
2656            };
2657            r#type = Some(header.r#type);
2658            let res = match header.r#type {
2659                1u16 => ReferenceSync::Id({
2660                    let res = parse_u32(next);
2661                    let Some(val) = res else { break };
2662                    val
2663                }),
2664                16u16 => ReferenceSync::State({
2665                    let res = parse_u32(next);
2666                    let Some(val) = res else { break };
2667                    val
2668                }),
2669                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2670                n => continue,
2671            };
2672            return Some(Ok(res));
2673        }
2674        Some(Err(ErrorContext::new(
2675            "ReferenceSync",
2676            r#type.and_then(|t| ReferenceSync::attr_from_type(t)),
2677            self.orig_loc,
2678            self.buf.as_ptr().wrapping_add(pos) as usize,
2679        )))
2680    }
2681}
2682impl std::fmt::Debug for IterableReferenceSync<'_> {
2683    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2684        let mut fmt = f.debug_struct("ReferenceSync");
2685        for attr in self.clone() {
2686            let attr = match attr {
2687                Ok(a) => a,
2688                Err(err) => {
2689                    fmt.finish()?;
2690                    f.write_str("Err(")?;
2691                    err.fmt(f)?;
2692                    return f.write_str(")");
2693                }
2694            };
2695            match attr {
2696                ReferenceSync::Id(val) => fmt.field("Id", &val),
2697                ReferenceSync::State(val) => {
2698                    fmt.field("State", &FormatEnum(val.into(), PinState::from_value))
2699                }
2700            };
2701        }
2702        fmt.finish()
2703    }
2704}
2705impl IterableReferenceSync<'_> {
2706    pub fn lookup_attr(
2707        &self,
2708        offset: usize,
2709        missing_type: Option<u16>,
2710    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2711        let mut stack = Vec::new();
2712        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2713        if missing_type.is_some() && cur == offset {
2714            stack.push(("ReferenceSync", offset));
2715            return (
2716                stack,
2717                missing_type.and_then(|t| ReferenceSync::attr_from_type(t)),
2718            );
2719        }
2720        if cur > offset || cur + self.buf.len() < offset {
2721            return (stack, None);
2722        }
2723        let mut attrs = self.clone();
2724        let mut last_off = cur + attrs.pos;
2725        while let Some(attr) = attrs.next() {
2726            let Ok(attr) = attr else { break };
2727            match attr {
2728                ReferenceSync::Id(val) => {
2729                    if last_off == offset {
2730                        stack.push(("Id", last_off));
2731                        break;
2732                    }
2733                }
2734                ReferenceSync::State(val) => {
2735                    if last_off == offset {
2736                        stack.push(("State", last_off));
2737                        break;
2738                    }
2739                }
2740                _ => {}
2741            };
2742            last_off = cur + attrs.pos;
2743        }
2744        if !stack.is_empty() {
2745            stack.push(("ReferenceSync", cur));
2746        }
2747        (stack, None)
2748    }
2749}
2750pub struct PushDpll<Prev: Rec> {
2751    pub(crate) prev: Option<Prev>,
2752    pub(crate) header_offset: Option<usize>,
2753}
2754impl<Prev: Rec> Rec for PushDpll<Prev> {
2755    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
2756        self.prev.as_mut().unwrap().as_rec_mut()
2757    }
2758    fn as_rec(&self) -> &Vec<u8> {
2759        self.prev.as_ref().unwrap().as_rec()
2760    }
2761}
2762impl<Prev: Rec> PushDpll<Prev> {
2763    pub fn new(prev: Prev) -> Self {
2764        Self {
2765            prev: Some(prev),
2766            header_offset: None,
2767        }
2768    }
2769    pub fn end_nested(mut self) -> Prev {
2770        let mut prev = self.prev.take().unwrap();
2771        if let Some(header_offset) = &self.header_offset {
2772            finalize_nested_header(prev.as_rec_mut(), *header_offset);
2773        }
2774        prev
2775    }
2776    pub fn push_id(mut self, value: u32) -> Self {
2777        push_header(self.as_rec_mut(), 1u16, 4 as u16);
2778        self.as_rec_mut().extend(value.to_ne_bytes());
2779        self
2780    }
2781    pub fn push_module_name(mut self, value: &CStr) -> Self {
2782        push_header(
2783            self.as_rec_mut(),
2784            2u16,
2785            value.to_bytes_with_nul().len() as u16,
2786        );
2787        self.as_rec_mut().extend(value.to_bytes_with_nul());
2788        self
2789    }
2790    pub fn push_module_name_bytes(mut self, value: &[u8]) -> Self {
2791        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
2792        self.as_rec_mut().extend(value);
2793        self.as_rec_mut().push(0);
2794        self
2795    }
2796    pub fn push_pad(mut self, value: &[u8]) -> Self {
2797        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
2798        self.as_rec_mut().extend(value);
2799        self
2800    }
2801    pub fn push_clock_id(mut self, value: u64) -> Self {
2802        push_header(self.as_rec_mut(), 4u16, 8 as u16);
2803        self.as_rec_mut().extend(value.to_ne_bytes());
2804        self
2805    }
2806    #[doc = "Associated type: [`Mode`] (enum)"]
2807    pub fn push_mode(mut self, value: u32) -> Self {
2808        push_header(self.as_rec_mut(), 5u16, 4 as u16);
2809        self.as_rec_mut().extend(value.to_ne_bytes());
2810        self
2811    }
2812    #[doc = "Associated type: [`Mode`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
2813    pub fn push_mode_supported(mut self, value: u32) -> Self {
2814        push_header(self.as_rec_mut(), 6u16, 4 as u16);
2815        self.as_rec_mut().extend(value.to_ne_bytes());
2816        self
2817    }
2818    #[doc = "Associated type: [`LockStatus`] (enum)"]
2819    pub fn push_lock_status(mut self, value: u32) -> Self {
2820        push_header(self.as_rec_mut(), 7u16, 4 as u16);
2821        self.as_rec_mut().extend(value.to_ne_bytes());
2822        self
2823    }
2824    pub fn push_temp(mut self, value: i32) -> Self {
2825        push_header(self.as_rec_mut(), 8u16, 4 as u16);
2826        self.as_rec_mut().extend(value.to_ne_bytes());
2827        self
2828    }
2829    #[doc = "Associated type: [`Type`] (enum)"]
2830    pub fn push_type(mut self, value: u32) -> Self {
2831        push_header(self.as_rec_mut(), 9u16, 4 as u16);
2832        self.as_rec_mut().extend(value.to_ne_bytes());
2833        self
2834    }
2835    #[doc = "Associated type: [`LockStatusError`] (enum)"]
2836    pub fn push_lock_status_error(mut self, value: u32) -> Self {
2837        push_header(self.as_rec_mut(), 10u16, 4 as u16);
2838        self.as_rec_mut().extend(value.to_ne_bytes());
2839        self
2840    }
2841    #[doc = "Level of quality of a clock device. This mainly applies when the dpll\nlock-status is DPLL_LOCK_STATUS_HOLDOVER. This could be put to message\nmultiple times to indicate possible parallel quality levels (e.g. one\nspecified by ITU option 1 and another one specified by option 2).\n\nAssociated type: [`ClockQualityLevel`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
2842    pub fn push_clock_quality_level(mut self, value: u32) -> Self {
2843        push_header(self.as_rec_mut(), 11u16, 4 as u16);
2844        self.as_rec_mut().extend(value.to_ne_bytes());
2845        self
2846    }
2847    #[doc = "Receive or request state of phase offset monitor feature. If enabled,\ndpll device shall monitor and notify all currently available inputs for\nchanges of their phase offset against the dpll device.\n\nAssociated type: [`FeatureState`] (enum)"]
2848    pub fn push_phase_offset_monitor(mut self, value: u32) -> Self {
2849        push_header(self.as_rec_mut(), 12u16, 4 as u16);
2850        self.as_rec_mut().extend(value.to_ne_bytes());
2851        self
2852    }
2853    #[doc = "Averaging factor applied to calculation of reported phase offset.\n"]
2854    pub fn push_phase_offset_avg_factor(mut self, value: u32) -> Self {
2855        push_header(self.as_rec_mut(), 13u16, 4 as u16);
2856        self.as_rec_mut().extend(value.to_ne_bytes());
2857        self
2858    }
2859    #[doc = "Current or desired state of the frequency monitor feature. If enabled,\ndpll device shall measure all currently available inputs for their\nactual input frequency.\n\nAssociated type: [`FeatureState`] (enum)"]
2860    pub fn push_frequency_monitor(mut self, value: u32) -> Self {
2861        push_header(self.as_rec_mut(), 14u16, 4 as u16);
2862        self.as_rec_mut().extend(value.to_ne_bytes());
2863        self
2864    }
2865}
2866impl<Prev: Rec> Drop for PushDpll<Prev> {
2867    fn drop(&mut self) {
2868        if let Some(prev) = &mut self.prev {
2869            if let Some(header_offset) = &self.header_offset {
2870                finalize_nested_header(prev.as_rec_mut(), *header_offset);
2871            }
2872        }
2873    }
2874}
2875pub struct PushPin<Prev: Rec> {
2876    pub(crate) prev: Option<Prev>,
2877    pub(crate) header_offset: Option<usize>,
2878}
2879impl<Prev: Rec> Rec for PushPin<Prev> {
2880    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
2881        self.prev.as_mut().unwrap().as_rec_mut()
2882    }
2883    fn as_rec(&self) -> &Vec<u8> {
2884        self.prev.as_ref().unwrap().as_rec()
2885    }
2886}
2887impl<Prev: Rec> PushPin<Prev> {
2888    pub fn new(prev: Prev) -> Self {
2889        Self {
2890            prev: Some(prev),
2891            header_offset: None,
2892        }
2893    }
2894    pub fn end_nested(mut self) -> Prev {
2895        let mut prev = self.prev.take().unwrap();
2896        if let Some(header_offset) = &self.header_offset {
2897            finalize_nested_header(prev.as_rec_mut(), *header_offset);
2898        }
2899        prev
2900    }
2901    pub fn push_id(mut self, value: u32) -> Self {
2902        push_header(self.as_rec_mut(), 1u16, 4 as u16);
2903        self.as_rec_mut().extend(value.to_ne_bytes());
2904        self
2905    }
2906    pub fn push_parent_id(mut self, value: u32) -> Self {
2907        push_header(self.as_rec_mut(), 2u16, 4 as u16);
2908        self.as_rec_mut().extend(value.to_ne_bytes());
2909        self
2910    }
2911    pub fn push_module_name(mut self, value: &CStr) -> Self {
2912        push_header(
2913            self.as_rec_mut(),
2914            3u16,
2915            value.to_bytes_with_nul().len() as u16,
2916        );
2917        self.as_rec_mut().extend(value.to_bytes_with_nul());
2918        self
2919    }
2920    pub fn push_module_name_bytes(mut self, value: &[u8]) -> Self {
2921        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
2922        self.as_rec_mut().extend(value);
2923        self.as_rec_mut().push(0);
2924        self
2925    }
2926    pub fn push_pad(mut self, value: &[u8]) -> Self {
2927        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
2928        self.as_rec_mut().extend(value);
2929        self
2930    }
2931    pub fn push_clock_id(mut self, value: u64) -> Self {
2932        push_header(self.as_rec_mut(), 5u16, 8 as u16);
2933        self.as_rec_mut().extend(value.to_ne_bytes());
2934        self
2935    }
2936    pub fn push_board_label(mut self, value: &CStr) -> Self {
2937        push_header(
2938            self.as_rec_mut(),
2939            6u16,
2940            value.to_bytes_with_nul().len() as u16,
2941        );
2942        self.as_rec_mut().extend(value.to_bytes_with_nul());
2943        self
2944    }
2945    pub fn push_board_label_bytes(mut self, value: &[u8]) -> Self {
2946        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
2947        self.as_rec_mut().extend(value);
2948        self.as_rec_mut().push(0);
2949        self
2950    }
2951    pub fn push_panel_label(mut self, value: &CStr) -> Self {
2952        push_header(
2953            self.as_rec_mut(),
2954            7u16,
2955            value.to_bytes_with_nul().len() as u16,
2956        );
2957        self.as_rec_mut().extend(value.to_bytes_with_nul());
2958        self
2959    }
2960    pub fn push_panel_label_bytes(mut self, value: &[u8]) -> Self {
2961        push_header(self.as_rec_mut(), 7u16, (value.len() + 1) as u16);
2962        self.as_rec_mut().extend(value);
2963        self.as_rec_mut().push(0);
2964        self
2965    }
2966    pub fn push_package_label(mut self, value: &CStr) -> Self {
2967        push_header(
2968            self.as_rec_mut(),
2969            8u16,
2970            value.to_bytes_with_nul().len() as u16,
2971        );
2972        self.as_rec_mut().extend(value.to_bytes_with_nul());
2973        self
2974    }
2975    pub fn push_package_label_bytes(mut self, value: &[u8]) -> Self {
2976        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
2977        self.as_rec_mut().extend(value);
2978        self.as_rec_mut().push(0);
2979        self
2980    }
2981    #[doc = "Associated type: [`PinType`] (enum)"]
2982    pub fn push_type(mut self, value: u32) -> Self {
2983        push_header(self.as_rec_mut(), 9u16, 4 as u16);
2984        self.as_rec_mut().extend(value.to_ne_bytes());
2985        self
2986    }
2987    #[doc = "Associated type: [`PinDirection`] (enum)"]
2988    pub fn push_direction(mut self, value: u32) -> Self {
2989        push_header(self.as_rec_mut(), 10u16, 4 as u16);
2990        self.as_rec_mut().extend(value.to_ne_bytes());
2991        self
2992    }
2993    pub fn push_frequency(mut self, value: u64) -> Self {
2994        push_header(self.as_rec_mut(), 11u16, 8 as u16);
2995        self.as_rec_mut().extend(value.to_ne_bytes());
2996        self
2997    }
2998    #[doc = "Attribute may repeat multiple times (treat it as array)"]
2999    pub fn nested_frequency_supported(mut self) -> PushFrequencyRange<Self> {
3000        let header_offset = push_nested_header(self.as_rec_mut(), 12u16);
3001        PushFrequencyRange {
3002            prev: Some(self),
3003            header_offset: Some(header_offset),
3004        }
3005    }
3006    pub fn push_frequency_min(mut self, value: u64) -> Self {
3007        push_header(self.as_rec_mut(), 13u16, 8 as u16);
3008        self.as_rec_mut().extend(value.to_ne_bytes());
3009        self
3010    }
3011    pub fn push_frequency_max(mut self, value: u64) -> Self {
3012        push_header(self.as_rec_mut(), 14u16, 8 as u16);
3013        self.as_rec_mut().extend(value.to_ne_bytes());
3014        self
3015    }
3016    pub fn push_prio(mut self, value: u32) -> Self {
3017        push_header(self.as_rec_mut(), 15u16, 4 as u16);
3018        self.as_rec_mut().extend(value.to_ne_bytes());
3019        self
3020    }
3021    #[doc = "Associated type: [`PinState`] (enum)"]
3022    pub fn push_state(mut self, value: u32) -> Self {
3023        push_header(self.as_rec_mut(), 16u16, 4 as u16);
3024        self.as_rec_mut().extend(value.to_ne_bytes());
3025        self
3026    }
3027    #[doc = "Associated type: [`PinCapabilities`] (enum)"]
3028    pub fn push_capabilities(mut self, value: u32) -> Self {
3029        push_header(self.as_rec_mut(), 17u16, 4 as u16);
3030        self.as_rec_mut().extend(value.to_ne_bytes());
3031        self
3032    }
3033    #[doc = "Attribute may repeat multiple times (treat it as array)"]
3034    pub fn nested_parent_device(mut self) -> PushPinParentDevice<Self> {
3035        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
3036        PushPinParentDevice {
3037            prev: Some(self),
3038            header_offset: Some(header_offset),
3039        }
3040    }
3041    #[doc = "Attribute may repeat multiple times (treat it as array)"]
3042    pub fn nested_parent_pin(mut self) -> PushPinParentPin<Self> {
3043        let header_offset = push_nested_header(self.as_rec_mut(), 19u16);
3044        PushPinParentPin {
3045            prev: Some(self),
3046            header_offset: Some(header_offset),
3047        }
3048    }
3049    pub fn push_phase_adjust_min(mut self, value: i32) -> Self {
3050        push_header(self.as_rec_mut(), 20u16, 4 as u16);
3051        self.as_rec_mut().extend(value.to_ne_bytes());
3052        self
3053    }
3054    pub fn push_phase_adjust_max(mut self, value: i32) -> Self {
3055        push_header(self.as_rec_mut(), 21u16, 4 as u16);
3056        self.as_rec_mut().extend(value.to_ne_bytes());
3057        self
3058    }
3059    pub fn push_phase_adjust(mut self, value: i32) -> Self {
3060        push_header(self.as_rec_mut(), 22u16, 4 as u16);
3061        self.as_rec_mut().extend(value.to_ne_bytes());
3062        self
3063    }
3064    pub fn push_phase_offset(mut self, value: i64) -> Self {
3065        push_header(self.as_rec_mut(), 23u16, 8 as u16);
3066        self.as_rec_mut().extend(value.to_ne_bytes());
3067        self
3068    }
3069    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
3070    pub fn push_fractional_frequency_offset(mut self, value: i32) -> Self {
3071        push_header(self.as_rec_mut(), 24u16, 4 as u16);
3072        self.as_rec_mut().extend(value.to_ne_bytes());
3073        self
3074    }
3075    #[doc = "Frequency of Embedded SYNC signal. If provided, the pin is configured\nwith a SYNC signal embedded into its base clock frequency.\n"]
3076    pub fn push_esync_frequency(mut self, value: u64) -> Self {
3077        push_header(self.as_rec_mut(), 25u16, 8 as u16);
3078        self.as_rec_mut().extend(value.to_ne_bytes());
3079        self
3080    }
3081    #[doc = "If provided a pin is capable of embedding a SYNC signal (within given\nrange) into its base frequency signal.\n\nAttribute may repeat multiple times (treat it as array)"]
3082    pub fn nested_esync_frequency_supported(mut self) -> PushFrequencyRange<Self> {
3083        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
3084        PushFrequencyRange {
3085            prev: Some(self),
3086            header_offset: Some(header_offset),
3087        }
3088    }
3089    #[doc = "A ratio of high to low state of a SYNC signal pulse embedded into base\nclock frequency. Value is in percents.\n"]
3090    pub fn push_esync_pulse(mut self, value: u32) -> Self {
3091        push_header(self.as_rec_mut(), 27u16, 4 as u16);
3092        self.as_rec_mut().extend(value.to_ne_bytes());
3093        self
3094    }
3095    #[doc = "Capable pin provides list of pins that can be bound to create a\nreference-sync pin pair.\n\nAttribute may repeat multiple times (treat it as array)"]
3096    pub fn nested_reference_sync(mut self) -> PushReferenceSync<Self> {
3097        let header_offset = push_nested_header(self.as_rec_mut(), 28u16);
3098        PushReferenceSync {
3099            prev: Some(self),
3100            header_offset: Some(header_offset),
3101        }
3102    }
3103    #[doc = "Granularity of phase adjustment, in picoseconds. The value of phase\nadjustment must be a multiple of this granularity.\n"]
3104    pub fn push_phase_adjust_gran(mut self, value: u32) -> Self {
3105        push_header(self.as_rec_mut(), 29u16, 4 as u16);
3106        self.as_rec_mut().extend(value.to_ne_bytes());
3107        self
3108    }
3109    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
3110    pub fn push_fractional_frequency_offset_ppt(mut self, value: i32) -> Self {
3111        push_header(self.as_rec_mut(), 30u16, 4 as u16);
3112        self.as_rec_mut().extend(value.to_ne_bytes());
3113        self
3114    }
3115    #[doc = "The measured frequency of the input pin in millihertz (mHz). Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY / DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\nan integer part (Hz) of a measured frequency value. Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY % DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\na fractional part of a measured frequency value.\n"]
3116    pub fn push_measured_frequency(mut self, value: u64) -> Self {
3117        push_header(self.as_rec_mut(), 31u16, 8 as u16);
3118        self.as_rec_mut().extend(value.to_ne_bytes());
3119        self
3120    }
3121    #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
3122    pub fn push_operstate(mut self, value: u32) -> Self {
3123        push_header(self.as_rec_mut(), 32u16, 4 as u16);
3124        self.as_rec_mut().extend(value.to_ne_bytes());
3125        self
3126    }
3127}
3128impl<Prev: Rec> Drop for PushPin<Prev> {
3129    fn drop(&mut self) {
3130        if let Some(prev) = &mut self.prev {
3131            if let Some(header_offset) = &self.header_offset {
3132                finalize_nested_header(prev.as_rec_mut(), *header_offset);
3133            }
3134        }
3135    }
3136}
3137pub struct PushPinParentDevice<Prev: Rec> {
3138    pub(crate) prev: Option<Prev>,
3139    pub(crate) header_offset: Option<usize>,
3140}
3141impl<Prev: Rec> Rec for PushPinParentDevice<Prev> {
3142    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
3143        self.prev.as_mut().unwrap().as_rec_mut()
3144    }
3145    fn as_rec(&self) -> &Vec<u8> {
3146        self.prev.as_ref().unwrap().as_rec()
3147    }
3148}
3149impl<Prev: Rec> PushPinParentDevice<Prev> {
3150    pub fn new(prev: Prev) -> Self {
3151        Self {
3152            prev: Some(prev),
3153            header_offset: None,
3154        }
3155    }
3156    pub fn end_nested(mut self) -> Prev {
3157        let mut prev = self.prev.take().unwrap();
3158        if let Some(header_offset) = &self.header_offset {
3159            finalize_nested_header(prev.as_rec_mut(), *header_offset);
3160        }
3161        prev
3162    }
3163    pub fn push_parent_id(mut self, value: u32) -> Self {
3164        push_header(self.as_rec_mut(), 2u16, 4 as u16);
3165        self.as_rec_mut().extend(value.to_ne_bytes());
3166        self
3167    }
3168    #[doc = "Associated type: [`PinDirection`] (enum)"]
3169    pub fn push_direction(mut self, value: u32) -> Self {
3170        push_header(self.as_rec_mut(), 10u16, 4 as u16);
3171        self.as_rec_mut().extend(value.to_ne_bytes());
3172        self
3173    }
3174    pub fn push_prio(mut self, value: u32) -> Self {
3175        push_header(self.as_rec_mut(), 15u16, 4 as u16);
3176        self.as_rec_mut().extend(value.to_ne_bytes());
3177        self
3178    }
3179    #[doc = "Associated type: [`PinState`] (enum)"]
3180    pub fn push_state(mut self, value: u32) -> Self {
3181        push_header(self.as_rec_mut(), 16u16, 4 as u16);
3182        self.as_rec_mut().extend(value.to_ne_bytes());
3183        self
3184    }
3185    pub fn push_phase_offset(mut self, value: i64) -> Self {
3186        push_header(self.as_rec_mut(), 23u16, 8 as u16);
3187        self.as_rec_mut().extend(value.to_ne_bytes());
3188        self
3189    }
3190    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
3191    pub fn push_fractional_frequency_offset(mut self, value: i32) -> Self {
3192        push_header(self.as_rec_mut(), 24u16, 4 as u16);
3193        self.as_rec_mut().extend(value.to_ne_bytes());
3194        self
3195    }
3196    #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
3197    pub fn push_fractional_frequency_offset_ppt(mut self, value: i32) -> Self {
3198        push_header(self.as_rec_mut(), 30u16, 4 as u16);
3199        self.as_rec_mut().extend(value.to_ne_bytes());
3200        self
3201    }
3202    #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
3203    pub fn push_operstate(mut self, value: u32) -> Self {
3204        push_header(self.as_rec_mut(), 32u16, 4 as u16);
3205        self.as_rec_mut().extend(value.to_ne_bytes());
3206        self
3207    }
3208}
3209impl<Prev: Rec> Drop for PushPinParentDevice<Prev> {
3210    fn drop(&mut self) {
3211        if let Some(prev) = &mut self.prev {
3212            if let Some(header_offset) = &self.header_offset {
3213                finalize_nested_header(prev.as_rec_mut(), *header_offset);
3214            }
3215        }
3216    }
3217}
3218pub struct PushPinParentPin<Prev: Rec> {
3219    pub(crate) prev: Option<Prev>,
3220    pub(crate) header_offset: Option<usize>,
3221}
3222impl<Prev: Rec> Rec for PushPinParentPin<Prev> {
3223    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
3224        self.prev.as_mut().unwrap().as_rec_mut()
3225    }
3226    fn as_rec(&self) -> &Vec<u8> {
3227        self.prev.as_ref().unwrap().as_rec()
3228    }
3229}
3230impl<Prev: Rec> PushPinParentPin<Prev> {
3231    pub fn new(prev: Prev) -> Self {
3232        Self {
3233            prev: Some(prev),
3234            header_offset: None,
3235        }
3236    }
3237    pub fn end_nested(mut self) -> Prev {
3238        let mut prev = self.prev.take().unwrap();
3239        if let Some(header_offset) = &self.header_offset {
3240            finalize_nested_header(prev.as_rec_mut(), *header_offset);
3241        }
3242        prev
3243    }
3244    pub fn push_parent_id(mut self, value: u32) -> Self {
3245        push_header(self.as_rec_mut(), 2u16, 4 as u16);
3246        self.as_rec_mut().extend(value.to_ne_bytes());
3247        self
3248    }
3249    #[doc = "Associated type: [`PinState`] (enum)"]
3250    pub fn push_state(mut self, value: u32) -> Self {
3251        push_header(self.as_rec_mut(), 16u16, 4 as u16);
3252        self.as_rec_mut().extend(value.to_ne_bytes());
3253        self
3254    }
3255}
3256impl<Prev: Rec> Drop for PushPinParentPin<Prev> {
3257    fn drop(&mut self) {
3258        if let Some(prev) = &mut self.prev {
3259            if let Some(header_offset) = &self.header_offset {
3260                finalize_nested_header(prev.as_rec_mut(), *header_offset);
3261            }
3262        }
3263    }
3264}
3265pub struct PushFrequencyRange<Prev: Rec> {
3266    pub(crate) prev: Option<Prev>,
3267    pub(crate) header_offset: Option<usize>,
3268}
3269impl<Prev: Rec> Rec for PushFrequencyRange<Prev> {
3270    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
3271        self.prev.as_mut().unwrap().as_rec_mut()
3272    }
3273    fn as_rec(&self) -> &Vec<u8> {
3274        self.prev.as_ref().unwrap().as_rec()
3275    }
3276}
3277impl<Prev: Rec> PushFrequencyRange<Prev> {
3278    pub fn new(prev: Prev) -> Self {
3279        Self {
3280            prev: Some(prev),
3281            header_offset: None,
3282        }
3283    }
3284    pub fn end_nested(mut self) -> Prev {
3285        let mut prev = self.prev.take().unwrap();
3286        if let Some(header_offset) = &self.header_offset {
3287            finalize_nested_header(prev.as_rec_mut(), *header_offset);
3288        }
3289        prev
3290    }
3291    pub fn push_frequency_min(mut self, value: u64) -> Self {
3292        push_header(self.as_rec_mut(), 13u16, 8 as u16);
3293        self.as_rec_mut().extend(value.to_ne_bytes());
3294        self
3295    }
3296    pub fn push_frequency_max(mut self, value: u64) -> Self {
3297        push_header(self.as_rec_mut(), 14u16, 8 as u16);
3298        self.as_rec_mut().extend(value.to_ne_bytes());
3299        self
3300    }
3301}
3302impl<Prev: Rec> Drop for PushFrequencyRange<Prev> {
3303    fn drop(&mut self) {
3304        if let Some(prev) = &mut self.prev {
3305            if let Some(header_offset) = &self.header_offset {
3306                finalize_nested_header(prev.as_rec_mut(), *header_offset);
3307            }
3308        }
3309    }
3310}
3311pub struct PushReferenceSync<Prev: Rec> {
3312    pub(crate) prev: Option<Prev>,
3313    pub(crate) header_offset: Option<usize>,
3314}
3315impl<Prev: Rec> Rec for PushReferenceSync<Prev> {
3316    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
3317        self.prev.as_mut().unwrap().as_rec_mut()
3318    }
3319    fn as_rec(&self) -> &Vec<u8> {
3320        self.prev.as_ref().unwrap().as_rec()
3321    }
3322}
3323impl<Prev: Rec> PushReferenceSync<Prev> {
3324    pub fn new(prev: Prev) -> Self {
3325        Self {
3326            prev: Some(prev),
3327            header_offset: None,
3328        }
3329    }
3330    pub fn end_nested(mut self) -> Prev {
3331        let mut prev = self.prev.take().unwrap();
3332        if let Some(header_offset) = &self.header_offset {
3333            finalize_nested_header(prev.as_rec_mut(), *header_offset);
3334        }
3335        prev
3336    }
3337    pub fn push_id(mut self, value: u32) -> Self {
3338        push_header(self.as_rec_mut(), 1u16, 4 as u16);
3339        self.as_rec_mut().extend(value.to_ne_bytes());
3340        self
3341    }
3342    #[doc = "Associated type: [`PinState`] (enum)"]
3343    pub fn push_state(mut self, value: u32) -> Self {
3344        push_header(self.as_rec_mut(), 16u16, 4 as u16);
3345        self.as_rec_mut().extend(value.to_ne_bytes());
3346        self
3347    }
3348}
3349impl<Prev: Rec> Drop for PushReferenceSync<Prev> {
3350    fn drop(&mut self) {
3351        if let Some(prev) = &mut self.prev {
3352            if let Some(header_offset) = &self.header_offset {
3353                finalize_nested_header(prev.as_rec_mut(), *header_offset);
3354            }
3355        }
3356    }
3357}
3358#[doc = "Notify attributes:\n- [`.get_id()`](IterableDpll::get_id)\n- [`.get_module_name()`](IterableDpll::get_module_name)\n- [`.get_mode()`](IterableDpll::get_mode)\n- [`.get_mode_supported()`](IterableDpll::get_mode_supported)\n- [`.get_lock_status()`](IterableDpll::get_lock_status)\n- [`.get_lock_status_error()`](IterableDpll::get_lock_status_error)\n- [`.get_temp()`](IterableDpll::get_temp)\n- [`.get_clock_id()`](IterableDpll::get_clock_id)\n- [`.get_type()`](IterableDpll::get_type)\n- [`.get_phase_offset_monitor()`](IterableDpll::get_phase_offset_monitor)\n- [`.get_phase_offset_avg_factor()`](IterableDpll::get_phase_offset_avg_factor)\n- [`.get_frequency_monitor()`](IterableDpll::get_frequency_monitor)\n"]
3359#[derive(Debug)]
3360pub struct OpDeviceCreateNotif;
3361impl OpDeviceCreateNotif {
3362    pub const CMD: u8 = 4u8;
3363    pub fn decode_notif<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3364        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3365        IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3366    }
3367}
3368#[doc = "Notify attributes:\n- [`.get_id()`](IterableDpll::get_id)\n- [`.get_module_name()`](IterableDpll::get_module_name)\n- [`.get_mode()`](IterableDpll::get_mode)\n- [`.get_mode_supported()`](IterableDpll::get_mode_supported)\n- [`.get_lock_status()`](IterableDpll::get_lock_status)\n- [`.get_lock_status_error()`](IterableDpll::get_lock_status_error)\n- [`.get_temp()`](IterableDpll::get_temp)\n- [`.get_clock_id()`](IterableDpll::get_clock_id)\n- [`.get_type()`](IterableDpll::get_type)\n- [`.get_phase_offset_monitor()`](IterableDpll::get_phase_offset_monitor)\n- [`.get_phase_offset_avg_factor()`](IterableDpll::get_phase_offset_avg_factor)\n- [`.get_frequency_monitor()`](IterableDpll::get_frequency_monitor)\n"]
3369#[derive(Debug)]
3370pub struct OpDeviceDeleteNotif;
3371impl OpDeviceDeleteNotif {
3372    pub const CMD: u8 = 5u8;
3373    pub fn decode_notif<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3374        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3375        IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3376    }
3377}
3378#[doc = "Notify attributes:\n- [`.get_id()`](IterableDpll::get_id)\n- [`.get_module_name()`](IterableDpll::get_module_name)\n- [`.get_mode()`](IterableDpll::get_mode)\n- [`.get_mode_supported()`](IterableDpll::get_mode_supported)\n- [`.get_lock_status()`](IterableDpll::get_lock_status)\n- [`.get_lock_status_error()`](IterableDpll::get_lock_status_error)\n- [`.get_temp()`](IterableDpll::get_temp)\n- [`.get_clock_id()`](IterableDpll::get_clock_id)\n- [`.get_type()`](IterableDpll::get_type)\n- [`.get_phase_offset_monitor()`](IterableDpll::get_phase_offset_monitor)\n- [`.get_phase_offset_avg_factor()`](IterableDpll::get_phase_offset_avg_factor)\n- [`.get_frequency_monitor()`](IterableDpll::get_frequency_monitor)\n"]
3379#[derive(Debug)]
3380pub struct OpDeviceChangeNotif;
3381impl OpDeviceChangeNotif {
3382    pub const CMD: u8 = 6u8;
3383    pub fn decode_notif<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3384        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3385        IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3386    }
3387}
3388#[doc = "Notify attributes:\n- [`.get_id()`](IterablePin::get_id)\n- [`.get_module_name()`](IterablePin::get_module_name)\n- [`.get_clock_id()`](IterablePin::get_clock_id)\n- [`.get_board_label()`](IterablePin::get_board_label)\n- [`.get_panel_label()`](IterablePin::get_panel_label)\n- [`.get_package_label()`](IterablePin::get_package_label)\n- [`.get_type()`](IterablePin::get_type)\n- [`.get_frequency()`](IterablePin::get_frequency)\n- [`.get_frequency_supported()`](IterablePin::get_frequency_supported)\n- [`.get_capabilities()`](IterablePin::get_capabilities)\n- [`.get_parent_device()`](IterablePin::get_parent_device)\n- [`.get_parent_pin()`](IterablePin::get_parent_pin)\n- [`.get_phase_adjust_gran()`](IterablePin::get_phase_adjust_gran)\n- [`.get_phase_adjust_min()`](IterablePin::get_phase_adjust_min)\n- [`.get_phase_adjust_max()`](IterablePin::get_phase_adjust_max)\n- [`.get_phase_adjust()`](IterablePin::get_phase_adjust)\n- [`.get_fractional_frequency_offset()`](IterablePin::get_fractional_frequency_offset)\n- [`.get_fractional_frequency_offset_ppt()`](IterablePin::get_fractional_frequency_offset_ppt)\n- [`.get_esync_frequency()`](IterablePin::get_esync_frequency)\n- [`.get_esync_frequency_supported()`](IterablePin::get_esync_frequency_supported)\n- [`.get_esync_pulse()`](IterablePin::get_esync_pulse)\n- [`.get_reference_sync()`](IterablePin::get_reference_sync)\n- [`.get_measured_frequency()`](IterablePin::get_measured_frequency)\n"]
3389#[derive(Debug)]
3390pub struct OpPinCreateNotif;
3391impl OpPinCreateNotif {
3392    pub const CMD: u8 = 10u8;
3393    pub fn decode_notif<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3394        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3395        IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3396    }
3397}
3398#[doc = "Notify attributes:\n- [`.get_id()`](IterablePin::get_id)\n- [`.get_module_name()`](IterablePin::get_module_name)\n- [`.get_clock_id()`](IterablePin::get_clock_id)\n- [`.get_board_label()`](IterablePin::get_board_label)\n- [`.get_panel_label()`](IterablePin::get_panel_label)\n- [`.get_package_label()`](IterablePin::get_package_label)\n- [`.get_type()`](IterablePin::get_type)\n- [`.get_frequency()`](IterablePin::get_frequency)\n- [`.get_frequency_supported()`](IterablePin::get_frequency_supported)\n- [`.get_capabilities()`](IterablePin::get_capabilities)\n- [`.get_parent_device()`](IterablePin::get_parent_device)\n- [`.get_parent_pin()`](IterablePin::get_parent_pin)\n- [`.get_phase_adjust_gran()`](IterablePin::get_phase_adjust_gran)\n- [`.get_phase_adjust_min()`](IterablePin::get_phase_adjust_min)\n- [`.get_phase_adjust_max()`](IterablePin::get_phase_adjust_max)\n- [`.get_phase_adjust()`](IterablePin::get_phase_adjust)\n- [`.get_fractional_frequency_offset()`](IterablePin::get_fractional_frequency_offset)\n- [`.get_fractional_frequency_offset_ppt()`](IterablePin::get_fractional_frequency_offset_ppt)\n- [`.get_esync_frequency()`](IterablePin::get_esync_frequency)\n- [`.get_esync_frequency_supported()`](IterablePin::get_esync_frequency_supported)\n- [`.get_esync_pulse()`](IterablePin::get_esync_pulse)\n- [`.get_reference_sync()`](IterablePin::get_reference_sync)\n- [`.get_measured_frequency()`](IterablePin::get_measured_frequency)\n"]
3399#[derive(Debug)]
3400pub struct OpPinDeleteNotif;
3401impl OpPinDeleteNotif {
3402    pub const CMD: u8 = 11u8;
3403    pub fn decode_notif<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3404        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3405        IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3406    }
3407}
3408#[doc = "Notify attributes:\n- [`.get_id()`](IterablePin::get_id)\n- [`.get_module_name()`](IterablePin::get_module_name)\n- [`.get_clock_id()`](IterablePin::get_clock_id)\n- [`.get_board_label()`](IterablePin::get_board_label)\n- [`.get_panel_label()`](IterablePin::get_panel_label)\n- [`.get_package_label()`](IterablePin::get_package_label)\n- [`.get_type()`](IterablePin::get_type)\n- [`.get_frequency()`](IterablePin::get_frequency)\n- [`.get_frequency_supported()`](IterablePin::get_frequency_supported)\n- [`.get_capabilities()`](IterablePin::get_capabilities)\n- [`.get_parent_device()`](IterablePin::get_parent_device)\n- [`.get_parent_pin()`](IterablePin::get_parent_pin)\n- [`.get_phase_adjust_gran()`](IterablePin::get_phase_adjust_gran)\n- [`.get_phase_adjust_min()`](IterablePin::get_phase_adjust_min)\n- [`.get_phase_adjust_max()`](IterablePin::get_phase_adjust_max)\n- [`.get_phase_adjust()`](IterablePin::get_phase_adjust)\n- [`.get_fractional_frequency_offset()`](IterablePin::get_fractional_frequency_offset)\n- [`.get_fractional_frequency_offset_ppt()`](IterablePin::get_fractional_frequency_offset_ppt)\n- [`.get_esync_frequency()`](IterablePin::get_esync_frequency)\n- [`.get_esync_frequency_supported()`](IterablePin::get_esync_frequency_supported)\n- [`.get_esync_pulse()`](IterablePin::get_esync_pulse)\n- [`.get_reference_sync()`](IterablePin::get_reference_sync)\n- [`.get_measured_frequency()`](IterablePin::get_measured_frequency)\n"]
3409#[derive(Debug)]
3410pub struct OpPinChangeNotif;
3411impl OpPinChangeNotif {
3412    pub const CMD: u8 = 12u8;
3413    pub fn decode_notif<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3414        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3415        IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3416    }
3417}
3418pub struct NotifGroup;
3419impl NotifGroup {
3420    #[doc = "Notifications:\n- [`OpDeviceCreateNotif`]\n- [`OpDeviceDeleteNotif`]\n- [`OpDeviceChangeNotif`]\n- [`OpPinCreateNotif`]\n- [`OpPinDeleteNotif`]\n- [`OpPinChangeNotif`]\n"]
3421    pub const MONITOR: &str = "monitor";
3422    #[doc = "Notifications:\n- [`OpDeviceCreateNotif`]\n- [`OpDeviceDeleteNotif`]\n- [`OpDeviceChangeNotif`]\n- [`OpPinCreateNotif`]\n- [`OpPinDeleteNotif`]\n- [`OpPinChangeNotif`]\n"]
3423    pub const MONITOR_CSTR: &CStr = c"monitor";
3424}
3425#[doc = "Get id of dpll device that matches given attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_module_name()](PushDpll::push_module_name)\n- [.push_clock_id()](PushDpll::push_clock_id)\n- [.push_type()](PushDpll::push_type)\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n\n"]
3426#[derive(Debug)]
3427pub struct OpDeviceIdGetDo<'r> {
3428    request: Request<'r>,
3429}
3430impl<'r> OpDeviceIdGetDo<'r> {
3431    pub fn new(mut request: Request<'r>) -> Self {
3432        Self::write_header(request.buf_mut());
3433        Self { request: request }
3434    }
3435    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushDpll<&'buf mut Vec<u8>> {
3436        Self::write_header(buf);
3437        PushDpll::new(buf)
3438    }
3439    pub fn encode(&mut self) -> PushDpll<&mut Vec<u8>> {
3440        PushDpll::new(self.request.buf_mut())
3441    }
3442    pub fn into_encoder(self) -> PushDpll<RequestBuf<'r>> {
3443        PushDpll::new(self.request.buf)
3444    }
3445    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3446        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3447        IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3448    }
3449    fn write_header<Prev: Rec>(prev: &mut Prev) {
3450        let mut header = BuiltinNfgenmsg::new();
3451        header.cmd = 1u8;
3452        header.version = 1u8;
3453        prev.as_rec_mut().extend(header.as_slice());
3454    }
3455}
3456impl NetlinkRequest for OpDeviceIdGetDo<'_> {
3457    fn protocol(&self) -> Protocol {
3458        Protocol::Generic("dpll".as_bytes())
3459    }
3460    fn flags(&self) -> u16 {
3461        self.request.flags
3462    }
3463    fn payload(&self) -> &[u8] {
3464        self.request.buf()
3465    }
3466    type ReplyType<'buf> = IterableDpll<'buf>;
3467    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3468        Self::decode_request(buf)
3469    }
3470    fn lookup(
3471        buf: &[u8],
3472        offset: usize,
3473        missing_type: Option<u16>,
3474    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3475        Self::decode_request(buf).lookup_attr(offset, missing_type)
3476    }
3477}
3478#[doc = "Get list of DPLL devices (dump) or attributes of a single dpll device\n\nFlags: admin-perm\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n- [.get_module_name()](IterableDpll::get_module_name)\n- [.get_clock_id()](IterableDpll::get_clock_id)\n- [.get_mode()](IterableDpll::get_mode)\n- [.get_mode_supported()](IterableDpll::get_mode_supported)\n- [.get_lock_status()](IterableDpll::get_lock_status)\n- [.get_temp()](IterableDpll::get_temp)\n- [.get_type()](IterableDpll::get_type)\n- [.get_lock_status_error()](IterableDpll::get_lock_status_error)\n- [.get_phase_offset_monitor()](IterableDpll::get_phase_offset_monitor)\n- [.get_phase_offset_avg_factor()](IterableDpll::get_phase_offset_avg_factor)\n- [.get_frequency_monitor()](IterableDpll::get_frequency_monitor)\n\n"]
3479#[derive(Debug)]
3480pub struct OpDeviceGetDump<'r> {
3481    request: Request<'r>,
3482}
3483impl<'r> OpDeviceGetDump<'r> {
3484    pub fn new(mut request: Request<'r>) -> Self {
3485        Self::write_header(request.buf_mut());
3486        Self {
3487            request: request.set_dump(),
3488        }
3489    }
3490    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushDpll<&'buf mut Vec<u8>> {
3491        Self::write_header(buf);
3492        PushDpll::new(buf)
3493    }
3494    pub fn encode(&mut self) -> PushDpll<&mut Vec<u8>> {
3495        PushDpll::new(self.request.buf_mut())
3496    }
3497    pub fn into_encoder(self) -> PushDpll<RequestBuf<'r>> {
3498        PushDpll::new(self.request.buf)
3499    }
3500    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3501        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3502        IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3503    }
3504    fn write_header<Prev: Rec>(prev: &mut Prev) {
3505        let mut header = BuiltinNfgenmsg::new();
3506        header.cmd = 2u8;
3507        header.version = 1u8;
3508        prev.as_rec_mut().extend(header.as_slice());
3509    }
3510}
3511impl NetlinkRequest for OpDeviceGetDump<'_> {
3512    fn protocol(&self) -> Protocol {
3513        Protocol::Generic("dpll".as_bytes())
3514    }
3515    fn flags(&self) -> u16 {
3516        self.request.flags
3517    }
3518    fn payload(&self) -> &[u8] {
3519        self.request.buf()
3520    }
3521    type ReplyType<'buf> = IterableDpll<'buf>;
3522    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3523        Self::decode_request(buf)
3524    }
3525    fn lookup(
3526        buf: &[u8],
3527        offset: usize,
3528        missing_type: Option<u16>,
3529    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3530        Self::decode_request(buf).lookup_attr(offset, missing_type)
3531    }
3532}
3533#[doc = "Get list of DPLL devices (dump) or attributes of a single dpll device\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushDpll::push_id)\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n- [.get_module_name()](IterableDpll::get_module_name)\n- [.get_clock_id()](IterableDpll::get_clock_id)\n- [.get_mode()](IterableDpll::get_mode)\n- [.get_mode_supported()](IterableDpll::get_mode_supported)\n- [.get_lock_status()](IterableDpll::get_lock_status)\n- [.get_temp()](IterableDpll::get_temp)\n- [.get_type()](IterableDpll::get_type)\n- [.get_lock_status_error()](IterableDpll::get_lock_status_error)\n- [.get_phase_offset_monitor()](IterableDpll::get_phase_offset_monitor)\n- [.get_phase_offset_avg_factor()](IterableDpll::get_phase_offset_avg_factor)\n- [.get_frequency_monitor()](IterableDpll::get_frequency_monitor)\n\n"]
3534#[derive(Debug)]
3535pub struct OpDeviceGetDo<'r> {
3536    request: Request<'r>,
3537}
3538impl<'r> OpDeviceGetDo<'r> {
3539    pub fn new(mut request: Request<'r>) -> Self {
3540        Self::write_header(request.buf_mut());
3541        Self { request: request }
3542    }
3543    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushDpll<&'buf mut Vec<u8>> {
3544        Self::write_header(buf);
3545        PushDpll::new(buf)
3546    }
3547    pub fn encode(&mut self) -> PushDpll<&mut Vec<u8>> {
3548        PushDpll::new(self.request.buf_mut())
3549    }
3550    pub fn into_encoder(self) -> PushDpll<RequestBuf<'r>> {
3551        PushDpll::new(self.request.buf)
3552    }
3553    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3554        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3555        IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3556    }
3557    fn write_header<Prev: Rec>(prev: &mut Prev) {
3558        let mut header = BuiltinNfgenmsg::new();
3559        header.cmd = 2u8;
3560        header.version = 1u8;
3561        prev.as_rec_mut().extend(header.as_slice());
3562    }
3563}
3564impl NetlinkRequest for OpDeviceGetDo<'_> {
3565    fn protocol(&self) -> Protocol {
3566        Protocol::Generic("dpll".as_bytes())
3567    }
3568    fn flags(&self) -> u16 {
3569        self.request.flags
3570    }
3571    fn payload(&self) -> &[u8] {
3572        self.request.buf()
3573    }
3574    type ReplyType<'buf> = IterableDpll<'buf>;
3575    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3576        Self::decode_request(buf)
3577    }
3578    fn lookup(
3579        buf: &[u8],
3580        offset: usize,
3581        missing_type: Option<u16>,
3582    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3583        Self::decode_request(buf).lookup_attr(offset, missing_type)
3584    }
3585}
3586#[doc = "Set attributes for a DPLL device\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushDpll::push_id)\n- [.push_mode()](PushDpll::push_mode)\n- [.push_phase_offset_monitor()](PushDpll::push_phase_offset_monitor)\n- [.push_phase_offset_avg_factor()](PushDpll::push_phase_offset_avg_factor)\n- [.push_frequency_monitor()](PushDpll::push_frequency_monitor)\n\n"]
3587#[derive(Debug)]
3588pub struct OpDeviceSetDo<'r> {
3589    request: Request<'r>,
3590}
3591impl<'r> OpDeviceSetDo<'r> {
3592    pub fn new(mut request: Request<'r>) -> Self {
3593        Self::write_header(request.buf_mut());
3594        Self { request: request }
3595    }
3596    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushDpll<&'buf mut Vec<u8>> {
3597        Self::write_header(buf);
3598        PushDpll::new(buf)
3599    }
3600    pub fn encode(&mut self) -> PushDpll<&mut Vec<u8>> {
3601        PushDpll::new(self.request.buf_mut())
3602    }
3603    pub fn into_encoder(self) -> PushDpll<RequestBuf<'r>> {
3604        PushDpll::new(self.request.buf)
3605    }
3606    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3607        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3608        IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3609    }
3610    fn write_header<Prev: Rec>(prev: &mut Prev) {
3611        let mut header = BuiltinNfgenmsg::new();
3612        header.cmd = 3u8;
3613        header.version = 1u8;
3614        prev.as_rec_mut().extend(header.as_slice());
3615    }
3616}
3617impl NetlinkRequest for OpDeviceSetDo<'_> {
3618    fn protocol(&self) -> Protocol {
3619        Protocol::Generic("dpll".as_bytes())
3620    }
3621    fn flags(&self) -> u16 {
3622        self.request.flags
3623    }
3624    fn payload(&self) -> &[u8] {
3625        self.request.buf()
3626    }
3627    type ReplyType<'buf> = IterableDpll<'buf>;
3628    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3629        Self::decode_request(buf)
3630    }
3631    fn lookup(
3632        buf: &[u8],
3633        offset: usize,
3634        missing_type: Option<u16>,
3635    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3636        Self::decode_request(buf).lookup_attr(offset, missing_type)
3637    }
3638}
3639#[doc = "Get id of a pin that matches given attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_module_name()](PushPin::push_module_name)\n- [.push_clock_id()](PushPin::push_clock_id)\n- [.push_board_label()](PushPin::push_board_label)\n- [.push_panel_label()](PushPin::push_panel_label)\n- [.push_package_label()](PushPin::push_package_label)\n- [.push_type()](PushPin::push_type)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n\n"]
3640#[derive(Debug)]
3641pub struct OpPinIdGetDo<'r> {
3642    request: Request<'r>,
3643}
3644impl<'r> OpPinIdGetDo<'r> {
3645    pub fn new(mut request: Request<'r>) -> Self {
3646        Self::write_header(request.buf_mut());
3647        Self { request: request }
3648    }
3649    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushPin<&'buf mut Vec<u8>> {
3650        Self::write_header(buf);
3651        PushPin::new(buf)
3652    }
3653    pub fn encode(&mut self) -> PushPin<&mut Vec<u8>> {
3654        PushPin::new(self.request.buf_mut())
3655    }
3656    pub fn into_encoder(self) -> PushPin<RequestBuf<'r>> {
3657        PushPin::new(self.request.buf)
3658    }
3659    pub fn decode_request<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3660        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3661        IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3662    }
3663    fn write_header<Prev: Rec>(prev: &mut Prev) {
3664        let mut header = BuiltinNfgenmsg::new();
3665        header.cmd = 7u8;
3666        header.version = 1u8;
3667        prev.as_rec_mut().extend(header.as_slice());
3668    }
3669}
3670impl NetlinkRequest for OpPinIdGetDo<'_> {
3671    fn protocol(&self) -> Protocol {
3672        Protocol::Generic("dpll".as_bytes())
3673    }
3674    fn flags(&self) -> u16 {
3675        self.request.flags
3676    }
3677    fn payload(&self) -> &[u8] {
3678        self.request.buf()
3679    }
3680    type ReplyType<'buf> = IterablePin<'buf>;
3681    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3682        Self::decode_request(buf)
3683    }
3684    fn lookup(
3685        buf: &[u8],
3686        offset: usize,
3687        missing_type: Option<u16>,
3688    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3689        Self::decode_request(buf).lookup_attr(offset, missing_type)
3690    }
3691}
3692#[doc = "Get list of pins and its attributes.\n\n- dump request without any attributes given - list all the pins in the\n  system\n- dump request with target dpll - list all the pins registered with a\n  given dpll device\n- do request with target dpll and target pin - single pin attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n- [.get_module_name()](IterablePin::get_module_name)\n- [.get_clock_id()](IterablePin::get_clock_id)\n- [.get_board_label()](IterablePin::get_board_label)\n- [.get_panel_label()](IterablePin::get_panel_label)\n- [.get_package_label()](IterablePin::get_package_label)\n- [.get_type()](IterablePin::get_type)\n- [.get_frequency()](IterablePin::get_frequency)\n- [.get_frequency_supported()](IterablePin::get_frequency_supported)\n- [.get_capabilities()](IterablePin::get_capabilities)\n- [.get_parent_device()](IterablePin::get_parent_device)\n- [.get_parent_pin()](IterablePin::get_parent_pin)\n- [.get_phase_adjust_min()](IterablePin::get_phase_adjust_min)\n- [.get_phase_adjust_max()](IterablePin::get_phase_adjust_max)\n- [.get_phase_adjust()](IterablePin::get_phase_adjust)\n- [.get_fractional_frequency_offset()](IterablePin::get_fractional_frequency_offset)\n- [.get_esync_frequency()](IterablePin::get_esync_frequency)\n- [.get_esync_frequency_supported()](IterablePin::get_esync_frequency_supported)\n- [.get_esync_pulse()](IterablePin::get_esync_pulse)\n- [.get_reference_sync()](IterablePin::get_reference_sync)\n- [.get_phase_adjust_gran()](IterablePin::get_phase_adjust_gran)\n- [.get_fractional_frequency_offset_ppt()](IterablePin::get_fractional_frequency_offset_ppt)\n- [.get_measured_frequency()](IterablePin::get_measured_frequency)\n\n"]
3693#[derive(Debug)]
3694pub struct OpPinGetDump<'r> {
3695    request: Request<'r>,
3696}
3697impl<'r> OpPinGetDump<'r> {
3698    pub fn new(mut request: Request<'r>) -> Self {
3699        Self::write_header(request.buf_mut());
3700        Self {
3701            request: request.set_dump(),
3702        }
3703    }
3704    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushPin<&'buf mut Vec<u8>> {
3705        Self::write_header(buf);
3706        PushPin::new(buf)
3707    }
3708    pub fn encode(&mut self) -> PushPin<&mut Vec<u8>> {
3709        PushPin::new(self.request.buf_mut())
3710    }
3711    pub fn into_encoder(self) -> PushPin<RequestBuf<'r>> {
3712        PushPin::new(self.request.buf)
3713    }
3714    pub fn decode_request<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3715        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3716        IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3717    }
3718    fn write_header<Prev: Rec>(prev: &mut Prev) {
3719        let mut header = BuiltinNfgenmsg::new();
3720        header.cmd = 8u8;
3721        header.version = 1u8;
3722        prev.as_rec_mut().extend(header.as_slice());
3723    }
3724}
3725impl NetlinkRequest for OpPinGetDump<'_> {
3726    fn protocol(&self) -> Protocol {
3727        Protocol::Generic("dpll".as_bytes())
3728    }
3729    fn flags(&self) -> u16 {
3730        self.request.flags
3731    }
3732    fn payload(&self) -> &[u8] {
3733        self.request.buf()
3734    }
3735    type ReplyType<'buf> = IterablePin<'buf>;
3736    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3737        Self::decode_request(buf)
3738    }
3739    fn lookup(
3740        buf: &[u8],
3741        offset: usize,
3742        missing_type: Option<u16>,
3743    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3744        Self::decode_request(buf).lookup_attr(offset, missing_type)
3745    }
3746}
3747#[doc = "Get list of pins and its attributes.\n\n- dump request without any attributes given - list all the pins in the\n  system\n- dump request with target dpll - list all the pins registered with a\n  given dpll device\n- do request with target dpll and target pin - single pin attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n- [.get_module_name()](IterablePin::get_module_name)\n- [.get_clock_id()](IterablePin::get_clock_id)\n- [.get_board_label()](IterablePin::get_board_label)\n- [.get_panel_label()](IterablePin::get_panel_label)\n- [.get_package_label()](IterablePin::get_package_label)\n- [.get_type()](IterablePin::get_type)\n- [.get_frequency()](IterablePin::get_frequency)\n- [.get_frequency_supported()](IterablePin::get_frequency_supported)\n- [.get_capabilities()](IterablePin::get_capabilities)\n- [.get_parent_device()](IterablePin::get_parent_device)\n- [.get_parent_pin()](IterablePin::get_parent_pin)\n- [.get_phase_adjust_min()](IterablePin::get_phase_adjust_min)\n- [.get_phase_adjust_max()](IterablePin::get_phase_adjust_max)\n- [.get_phase_adjust()](IterablePin::get_phase_adjust)\n- [.get_fractional_frequency_offset()](IterablePin::get_fractional_frequency_offset)\n- [.get_esync_frequency()](IterablePin::get_esync_frequency)\n- [.get_esync_frequency_supported()](IterablePin::get_esync_frequency_supported)\n- [.get_esync_pulse()](IterablePin::get_esync_pulse)\n- [.get_reference_sync()](IterablePin::get_reference_sync)\n- [.get_phase_adjust_gran()](IterablePin::get_phase_adjust_gran)\n- [.get_fractional_frequency_offset_ppt()](IterablePin::get_fractional_frequency_offset_ppt)\n- [.get_measured_frequency()](IterablePin::get_measured_frequency)\n\n"]
3748#[derive(Debug)]
3749pub struct OpPinGetDo<'r> {
3750    request: Request<'r>,
3751}
3752impl<'r> OpPinGetDo<'r> {
3753    pub fn new(mut request: Request<'r>) -> Self {
3754        Self::write_header(request.buf_mut());
3755        Self { request: request }
3756    }
3757    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushPin<&'buf mut Vec<u8>> {
3758        Self::write_header(buf);
3759        PushPin::new(buf)
3760    }
3761    pub fn encode(&mut self) -> PushPin<&mut Vec<u8>> {
3762        PushPin::new(self.request.buf_mut())
3763    }
3764    pub fn into_encoder(self) -> PushPin<RequestBuf<'r>> {
3765        PushPin::new(self.request.buf)
3766    }
3767    pub fn decode_request<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3768        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3769        IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3770    }
3771    fn write_header<Prev: Rec>(prev: &mut Prev) {
3772        let mut header = BuiltinNfgenmsg::new();
3773        header.cmd = 8u8;
3774        header.version = 1u8;
3775        prev.as_rec_mut().extend(header.as_slice());
3776    }
3777}
3778impl NetlinkRequest for OpPinGetDo<'_> {
3779    fn protocol(&self) -> Protocol {
3780        Protocol::Generic("dpll".as_bytes())
3781    }
3782    fn flags(&self) -> u16 {
3783        self.request.flags
3784    }
3785    fn payload(&self) -> &[u8] {
3786        self.request.buf()
3787    }
3788    type ReplyType<'buf> = IterablePin<'buf>;
3789    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3790        Self::decode_request(buf)
3791    }
3792    fn lookup(
3793        buf: &[u8],
3794        offset: usize,
3795        missing_type: Option<u16>,
3796    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3797        Self::decode_request(buf).lookup_attr(offset, missing_type)
3798    }
3799}
3800#[doc = "Set attributes of a target pin\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n- [.push_direction()](PushPin::push_direction)\n- [.push_frequency()](PushPin::push_frequency)\n- [.push_prio()](PushPin::push_prio)\n- [.push_state()](PushPin::push_state)\n- [.nested_parent_device()](PushPin::nested_parent_device)\n- [.nested_parent_pin()](PushPin::nested_parent_pin)\n- [.push_phase_adjust()](PushPin::push_phase_adjust)\n- [.push_esync_frequency()](PushPin::push_esync_frequency)\n- [.nested_reference_sync()](PushPin::nested_reference_sync)\n\n"]
3801#[derive(Debug)]
3802pub struct OpPinSetDo<'r> {
3803    request: Request<'r>,
3804}
3805impl<'r> OpPinSetDo<'r> {
3806    pub fn new(mut request: Request<'r>) -> Self {
3807        Self::write_header(request.buf_mut());
3808        Self { request: request }
3809    }
3810    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushPin<&'buf mut Vec<u8>> {
3811        Self::write_header(buf);
3812        PushPin::new(buf)
3813    }
3814    pub fn encode(&mut self) -> PushPin<&mut Vec<u8>> {
3815        PushPin::new(self.request.buf_mut())
3816    }
3817    pub fn into_encoder(self) -> PushPin<RequestBuf<'r>> {
3818        PushPin::new(self.request.buf)
3819    }
3820    pub fn decode_request<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3821        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3822        IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3823    }
3824    fn write_header<Prev: Rec>(prev: &mut Prev) {
3825        let mut header = BuiltinNfgenmsg::new();
3826        header.cmd = 9u8;
3827        header.version = 1u8;
3828        prev.as_rec_mut().extend(header.as_slice());
3829    }
3830}
3831impl NetlinkRequest for OpPinSetDo<'_> {
3832    fn protocol(&self) -> Protocol {
3833        Protocol::Generic("dpll".as_bytes())
3834    }
3835    fn flags(&self) -> u16 {
3836        self.request.flags
3837    }
3838    fn payload(&self) -> &[u8] {
3839        self.request.buf()
3840    }
3841    type ReplyType<'buf> = IterablePin<'buf>;
3842    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3843        Self::decode_request(buf)
3844    }
3845    fn lookup(
3846        buf: &[u8],
3847        offset: usize,
3848        missing_type: Option<u16>,
3849    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3850        Self::decode_request(buf).lookup_attr(offset, missing_type)
3851    }
3852}
3853use crate::traits::LookupFn;
3854use crate::utils::RequestBuf;
3855#[derive(Debug)]
3856pub struct Request<'buf> {
3857    buf: RequestBuf<'buf>,
3858    flags: u16,
3859    writeback: Option<&'buf mut Option<RequestInfo>>,
3860}
3861#[allow(unused)]
3862#[derive(Debug, Clone)]
3863pub struct RequestInfo {
3864    protocol: Protocol,
3865    flags: u16,
3866    name: &'static str,
3867    lookup: LookupFn,
3868}
3869impl Request<'static> {
3870    pub fn new() -> Self {
3871        Self::new_from_buf(Vec::new())
3872    }
3873    pub fn new_from_buf(buf: Vec<u8>) -> Self {
3874        Self {
3875            flags: 0,
3876            buf: RequestBuf::Own(buf),
3877            writeback: None,
3878        }
3879    }
3880    pub fn into_buf(self) -> Vec<u8> {
3881        match self.buf {
3882            RequestBuf::Own(buf) => buf,
3883            _ => unreachable!(),
3884        }
3885    }
3886}
3887impl<'buf> Request<'buf> {
3888    pub fn new_with_buf(buf: &'buf mut Vec<u8>) -> Self {
3889        buf.clear();
3890        Self::new_extend(buf)
3891    }
3892    pub fn new_extend(buf: &'buf mut Vec<u8>) -> Self {
3893        Self {
3894            flags: 0,
3895            buf: RequestBuf::Ref(buf),
3896            writeback: None,
3897        }
3898    }
3899    fn do_writeback(&mut self, protocol: Protocol, name: &'static str, lookup: LookupFn) {
3900        let Some(writeback) = &mut self.writeback else {
3901            return;
3902        };
3903        **writeback = Some(RequestInfo {
3904            protocol,
3905            flags: self.flags,
3906            name,
3907            lookup,
3908        })
3909    }
3910    pub fn buf(&self) -> &Vec<u8> {
3911        self.buf.buf()
3912    }
3913    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
3914        self.buf.buf_mut()
3915    }
3916    #[doc = "Set `NLM_F_CREATE` flag"]
3917    pub fn set_create(mut self) -> Self {
3918        self.flags |= consts::NLM_F_CREATE as u16;
3919        self
3920    }
3921    #[doc = "Set `NLM_F_EXCL` flag"]
3922    pub fn set_excl(mut self) -> Self {
3923        self.flags |= consts::NLM_F_EXCL as u16;
3924        self
3925    }
3926    #[doc = "Set `NLM_F_REPLACE` flag"]
3927    pub fn set_replace(mut self) -> Self {
3928        self.flags |= consts::NLM_F_REPLACE as u16;
3929        self
3930    }
3931    #[doc = "Set `NLM_F_CREATE` and `NLM_F_REPLACE` flag"]
3932    pub fn set_change(self) -> Self {
3933        self.set_create().set_replace()
3934    }
3935    #[doc = "Set `NLM_F_APPEND` flag"]
3936    pub fn set_append(mut self) -> Self {
3937        self.flags |= consts::NLM_F_APPEND as u16;
3938        self
3939    }
3940    #[doc = "Set `self.flags |= flags`"]
3941    pub fn set_flags(mut self, flags: u16) -> Self {
3942        self.flags |= flags;
3943        self
3944    }
3945    #[doc = "Set `self.flags ^= self.flags & flags`"]
3946    pub fn unset_flags(mut self, flags: u16) -> Self {
3947        self.flags ^= self.flags & flags;
3948        self
3949    }
3950    #[doc = "Set `NLM_F_DUMP` flag"]
3951    fn set_dump(mut self) -> Self {
3952        self.flags |= consts::NLM_F_DUMP as u16;
3953        self
3954    }
3955    #[doc = "Get id of dpll device that matches given attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_module_name()](PushDpll::push_module_name)\n- [.push_clock_id()](PushDpll::push_clock_id)\n- [.push_type()](PushDpll::push_type)\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n\n"]
3956    pub fn op_device_id_get_do(self) -> OpDeviceIdGetDo<'buf> {
3957        let mut res = OpDeviceIdGetDo::new(self);
3958        res.request.do_writeback(
3959            res.protocol(),
3960            "op-device-id-get-do",
3961            OpDeviceIdGetDo::lookup,
3962        );
3963        res
3964    }
3965    #[doc = "Get list of DPLL devices (dump) or attributes of a single dpll device\n\nFlags: admin-perm\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n- [.get_module_name()](IterableDpll::get_module_name)\n- [.get_clock_id()](IterableDpll::get_clock_id)\n- [.get_mode()](IterableDpll::get_mode)\n- [.get_mode_supported()](IterableDpll::get_mode_supported)\n- [.get_lock_status()](IterableDpll::get_lock_status)\n- [.get_temp()](IterableDpll::get_temp)\n- [.get_type()](IterableDpll::get_type)\n- [.get_lock_status_error()](IterableDpll::get_lock_status_error)\n- [.get_phase_offset_monitor()](IterableDpll::get_phase_offset_monitor)\n- [.get_phase_offset_avg_factor()](IterableDpll::get_phase_offset_avg_factor)\n- [.get_frequency_monitor()](IterableDpll::get_frequency_monitor)\n\n"]
3966    pub fn op_device_get_dump(self) -> OpDeviceGetDump<'buf> {
3967        let mut res = OpDeviceGetDump::new(self);
3968        res.request.do_writeback(
3969            res.protocol(),
3970            "op-device-get-dump",
3971            OpDeviceGetDump::lookup,
3972        );
3973        res
3974    }
3975    #[doc = "Get list of DPLL devices (dump) or attributes of a single dpll device\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushDpll::push_id)\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n- [.get_module_name()](IterableDpll::get_module_name)\n- [.get_clock_id()](IterableDpll::get_clock_id)\n- [.get_mode()](IterableDpll::get_mode)\n- [.get_mode_supported()](IterableDpll::get_mode_supported)\n- [.get_lock_status()](IterableDpll::get_lock_status)\n- [.get_temp()](IterableDpll::get_temp)\n- [.get_type()](IterableDpll::get_type)\n- [.get_lock_status_error()](IterableDpll::get_lock_status_error)\n- [.get_phase_offset_monitor()](IterableDpll::get_phase_offset_monitor)\n- [.get_phase_offset_avg_factor()](IterableDpll::get_phase_offset_avg_factor)\n- [.get_frequency_monitor()](IterableDpll::get_frequency_monitor)\n\n"]
3976    pub fn op_device_get_do(self) -> OpDeviceGetDo<'buf> {
3977        let mut res = OpDeviceGetDo::new(self);
3978        res.request
3979            .do_writeback(res.protocol(), "op-device-get-do", OpDeviceGetDo::lookup);
3980        res
3981    }
3982    #[doc = "Set attributes for a DPLL device\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushDpll::push_id)\n- [.push_mode()](PushDpll::push_mode)\n- [.push_phase_offset_monitor()](PushDpll::push_phase_offset_monitor)\n- [.push_phase_offset_avg_factor()](PushDpll::push_phase_offset_avg_factor)\n- [.push_frequency_monitor()](PushDpll::push_frequency_monitor)\n\n"]
3983    pub fn op_device_set_do(self) -> OpDeviceSetDo<'buf> {
3984        let mut res = OpDeviceSetDo::new(self);
3985        res.request
3986            .do_writeback(res.protocol(), "op-device-set-do", OpDeviceSetDo::lookup);
3987        res
3988    }
3989    #[doc = "Get id of a pin that matches given attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_module_name()](PushPin::push_module_name)\n- [.push_clock_id()](PushPin::push_clock_id)\n- [.push_board_label()](PushPin::push_board_label)\n- [.push_panel_label()](PushPin::push_panel_label)\n- [.push_package_label()](PushPin::push_package_label)\n- [.push_type()](PushPin::push_type)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n\n"]
3990    pub fn op_pin_id_get_do(self) -> OpPinIdGetDo<'buf> {
3991        let mut res = OpPinIdGetDo::new(self);
3992        res.request
3993            .do_writeback(res.protocol(), "op-pin-id-get-do", OpPinIdGetDo::lookup);
3994        res
3995    }
3996    #[doc = "Get list of pins and its attributes.\n\n- dump request without any attributes given - list all the pins in the\n  system\n- dump request with target dpll - list all the pins registered with a\n  given dpll device\n- do request with target dpll and target pin - single pin attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n- [.get_module_name()](IterablePin::get_module_name)\n- [.get_clock_id()](IterablePin::get_clock_id)\n- [.get_board_label()](IterablePin::get_board_label)\n- [.get_panel_label()](IterablePin::get_panel_label)\n- [.get_package_label()](IterablePin::get_package_label)\n- [.get_type()](IterablePin::get_type)\n- [.get_frequency()](IterablePin::get_frequency)\n- [.get_frequency_supported()](IterablePin::get_frequency_supported)\n- [.get_capabilities()](IterablePin::get_capabilities)\n- [.get_parent_device()](IterablePin::get_parent_device)\n- [.get_parent_pin()](IterablePin::get_parent_pin)\n- [.get_phase_adjust_min()](IterablePin::get_phase_adjust_min)\n- [.get_phase_adjust_max()](IterablePin::get_phase_adjust_max)\n- [.get_phase_adjust()](IterablePin::get_phase_adjust)\n- [.get_fractional_frequency_offset()](IterablePin::get_fractional_frequency_offset)\n- [.get_esync_frequency()](IterablePin::get_esync_frequency)\n- [.get_esync_frequency_supported()](IterablePin::get_esync_frequency_supported)\n- [.get_esync_pulse()](IterablePin::get_esync_pulse)\n- [.get_reference_sync()](IterablePin::get_reference_sync)\n- [.get_phase_adjust_gran()](IterablePin::get_phase_adjust_gran)\n- [.get_fractional_frequency_offset_ppt()](IterablePin::get_fractional_frequency_offset_ppt)\n- [.get_measured_frequency()](IterablePin::get_measured_frequency)\n\n"]
3997    pub fn op_pin_get_dump(self) -> OpPinGetDump<'buf> {
3998        let mut res = OpPinGetDump::new(self);
3999        res.request
4000            .do_writeback(res.protocol(), "op-pin-get-dump", OpPinGetDump::lookup);
4001        res
4002    }
4003    #[doc = "Get list of pins and its attributes.\n\n- dump request without any attributes given - list all the pins in the\n  system\n- dump request with target dpll - list all the pins registered with a\n  given dpll device\n- do request with target dpll and target pin - single pin attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n- [.get_module_name()](IterablePin::get_module_name)\n- [.get_clock_id()](IterablePin::get_clock_id)\n- [.get_board_label()](IterablePin::get_board_label)\n- [.get_panel_label()](IterablePin::get_panel_label)\n- [.get_package_label()](IterablePin::get_package_label)\n- [.get_type()](IterablePin::get_type)\n- [.get_frequency()](IterablePin::get_frequency)\n- [.get_frequency_supported()](IterablePin::get_frequency_supported)\n- [.get_capabilities()](IterablePin::get_capabilities)\n- [.get_parent_device()](IterablePin::get_parent_device)\n- [.get_parent_pin()](IterablePin::get_parent_pin)\n- [.get_phase_adjust_min()](IterablePin::get_phase_adjust_min)\n- [.get_phase_adjust_max()](IterablePin::get_phase_adjust_max)\n- [.get_phase_adjust()](IterablePin::get_phase_adjust)\n- [.get_fractional_frequency_offset()](IterablePin::get_fractional_frequency_offset)\n- [.get_esync_frequency()](IterablePin::get_esync_frequency)\n- [.get_esync_frequency_supported()](IterablePin::get_esync_frequency_supported)\n- [.get_esync_pulse()](IterablePin::get_esync_pulse)\n- [.get_reference_sync()](IterablePin::get_reference_sync)\n- [.get_phase_adjust_gran()](IterablePin::get_phase_adjust_gran)\n- [.get_fractional_frequency_offset_ppt()](IterablePin::get_fractional_frequency_offset_ppt)\n- [.get_measured_frequency()](IterablePin::get_measured_frequency)\n\n"]
4004    pub fn op_pin_get_do(self) -> OpPinGetDo<'buf> {
4005        let mut res = OpPinGetDo::new(self);
4006        res.request
4007            .do_writeback(res.protocol(), "op-pin-get-do", OpPinGetDo::lookup);
4008        res
4009    }
4010    #[doc = "Set attributes of a target pin\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n- [.push_direction()](PushPin::push_direction)\n- [.push_frequency()](PushPin::push_frequency)\n- [.push_prio()](PushPin::push_prio)\n- [.push_state()](PushPin::push_state)\n- [.nested_parent_device()](PushPin::nested_parent_device)\n- [.nested_parent_pin()](PushPin::nested_parent_pin)\n- [.push_phase_adjust()](PushPin::push_phase_adjust)\n- [.push_esync_frequency()](PushPin::push_esync_frequency)\n- [.nested_reference_sync()](PushPin::nested_reference_sync)\n\n"]
4011    pub fn op_pin_set_do(self) -> OpPinSetDo<'buf> {
4012        let mut res = OpPinSetDo::new(self);
4013        res.request
4014            .do_writeback(res.protocol(), "op-pin-set-do", OpPinSetDo::lookup);
4015        res
4016    }
4017}
4018#[cfg(test)]
4019mod generated_tests {
4020    use super::*;
4021    #[test]
4022    fn tests() {
4023        let _ = IterableDpll::get_clock_id;
4024        let _ = IterableDpll::get_frequency_monitor;
4025        let _ = IterableDpll::get_id;
4026        let _ = IterableDpll::get_lock_status;
4027        let _ = IterableDpll::get_lock_status_error;
4028        let _ = IterableDpll::get_mode;
4029        let _ = IterableDpll::get_mode_supported;
4030        let _ = IterableDpll::get_module_name;
4031        let _ = IterableDpll::get_phase_offset_avg_factor;
4032        let _ = IterableDpll::get_phase_offset_monitor;
4033        let _ = IterableDpll::get_temp;
4034        let _ = IterableDpll::get_type;
4035        let _ = IterablePin::get_board_label;
4036        let _ = IterablePin::get_capabilities;
4037        let _ = IterablePin::get_clock_id;
4038        let _ = IterablePin::get_esync_frequency;
4039        let _ = IterablePin::get_esync_frequency_supported;
4040        let _ = IterablePin::get_esync_pulse;
4041        let _ = IterablePin::get_fractional_frequency_offset;
4042        let _ = IterablePin::get_fractional_frequency_offset_ppt;
4043        let _ = IterablePin::get_frequency;
4044        let _ = IterablePin::get_frequency_supported;
4045        let _ = IterablePin::get_id;
4046        let _ = IterablePin::get_measured_frequency;
4047        let _ = IterablePin::get_module_name;
4048        let _ = IterablePin::get_package_label;
4049        let _ = IterablePin::get_panel_label;
4050        let _ = IterablePin::get_parent_device;
4051        let _ = IterablePin::get_parent_pin;
4052        let _ = IterablePin::get_phase_adjust;
4053        let _ = IterablePin::get_phase_adjust_gran;
4054        let _ = IterablePin::get_phase_adjust_max;
4055        let _ = IterablePin::get_phase_adjust_min;
4056        let _ = IterablePin::get_reference_sync;
4057        let _ = IterablePin::get_type;
4058        let _ = OpDeviceChangeNotif;
4059        let _ = OpDeviceCreateNotif;
4060        let _ = OpDeviceDeleteNotif;
4061        let _ = OpPinChangeNotif;
4062        let _ = OpPinCreateNotif;
4063        let _ = OpPinDeleteNotif;
4064        let _ = PushDpll::<&mut Vec<u8>>::push_clock_id;
4065        let _ = PushDpll::<&mut Vec<u8>>::push_frequency_monitor;
4066        let _ = PushDpll::<&mut Vec<u8>>::push_id;
4067        let _ = PushDpll::<&mut Vec<u8>>::push_mode;
4068        let _ = PushDpll::<&mut Vec<u8>>::push_module_name;
4069        let _ = PushDpll::<&mut Vec<u8>>::push_phase_offset_avg_factor;
4070        let _ = PushDpll::<&mut Vec<u8>>::push_phase_offset_monitor;
4071        let _ = PushDpll::<&mut Vec<u8>>::push_type;
4072        let _ = PushPin::<&mut Vec<u8>>::nested_parent_device;
4073        let _ = PushPin::<&mut Vec<u8>>::nested_parent_pin;
4074        let _ = PushPin::<&mut Vec<u8>>::nested_reference_sync;
4075        let _ = PushPin::<&mut Vec<u8>>::push_board_label;
4076        let _ = PushPin::<&mut Vec<u8>>::push_clock_id;
4077        let _ = PushPin::<&mut Vec<u8>>::push_direction;
4078        let _ = PushPin::<&mut Vec<u8>>::push_esync_frequency;
4079        let _ = PushPin::<&mut Vec<u8>>::push_frequency;
4080        let _ = PushPin::<&mut Vec<u8>>::push_id;
4081        let _ = PushPin::<&mut Vec<u8>>::push_module_name;
4082        let _ = PushPin::<&mut Vec<u8>>::push_package_label;
4083        let _ = PushPin::<&mut Vec<u8>>::push_panel_label;
4084        let _ = PushPin::<&mut Vec<u8>>::push_phase_adjust;
4085        let _ = PushPin::<&mut Vec<u8>>::push_prio;
4086        let _ = PushPin::<&mut Vec<u8>>::push_state;
4087        let _ = PushPin::<&mut Vec<u8>>::push_type;
4088    }
4089}