Skip to main content

fidl_fuchsia_hardware_power_charger_common/
fidl_fuchsia_hardware_power_charger_common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// Describes the active charging phase of the charger hardware.
12///
13/// Lithium-ion battery charging typically transitions across distinct stages:
14/// Pre-conditioning/Trickle -> Constant Current (Fast) -> Constant Voltage (Taper) -> Top-off ->
15/// Done.
16#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
17pub enum ChargePhase {
18    /// The charger is idle, off, or not supplying charging power to the battery (including during
19    /// passthrough, bypass, or charge-inhibit mode).
20    None,
21    /// Pre-qualification / trickle charging phase.
22    /// Used when the battery is deeply depleted below the pre-charge voltage threshold; current is
23    /// limited to a small, safe level to restore cell voltage before fast charge.
24    Trickle,
25    /// Constant Current (CC) fast charging phase.
26    /// The charger acts as a regulated current source supplying maximum programmed fast charge
27    /// current.
28    Fast,
29    /// Constant Voltage (CV) taper phase.
30    /// The battery voltage has reached the regulation target limit; current naturally tapers down
31    /// as the cell saturates.
32    Taper,
33    /// Top-off charging phase.
34    /// Low-current charging stage right after the CV termination threshold is reached, providing a
35    /// timed saturation before stopping.
36    TopOff,
37    /// Charge termination complete.
38    /// The charger has completed its charging cycle (e.g. top-off timer or termination-current
39    /// threshold reached) and has cut off charge current to the battery while continuing to supply
40    /// system load. The charger may automatically re-enter `FAST` if battery voltage decays below
41    /// the recharge threshold.
42    Done,
43    #[doc(hidden)]
44    __SourceBreaking { unknown_ordinal: u32 },
45}
46
47/// Pattern that matches an unknown `ChargePhase` member.
48#[macro_export]
49macro_rules! ChargePhaseUnknown {
50    () => {
51        _
52    };
53}
54
55impl ChargePhase {
56    #[inline]
57    pub fn from_primitive(prim: u32) -> Option<Self> {
58        match prim {
59            1 => Some(Self::None),
60            2 => Some(Self::Trickle),
61            3 => Some(Self::Fast),
62            4 => Some(Self::Taper),
63            5 => Some(Self::TopOff),
64            6 => Some(Self::Done),
65            _ => None,
66        }
67    }
68
69    #[inline]
70    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
71        match prim {
72            1 => Self::None,
73            2 => Self::Trickle,
74            3 => Self::Fast,
75            4 => Self::Taper,
76            5 => Self::TopOff,
77            6 => Self::Done,
78            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
79        }
80    }
81
82    #[inline]
83    pub fn unknown() -> Self {
84        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
85    }
86
87    #[inline]
88    pub const fn into_primitive(self) -> u32 {
89        match self {
90            Self::None => 1,
91            Self::Trickle => 2,
92            Self::Fast => 3,
93            Self::Taper => 4,
94            Self::TopOff => 5,
95            Self::Done => 6,
96            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
97        }
98    }
99
100    #[inline]
101    pub fn is_unknown(&self) -> bool {
102        match self {
103            Self::__SourceBreaking { unknown_ordinal: _ } => true,
104            _ => false,
105        }
106    }
107}
108
109/// Errors returned by the charger protocols.
110#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
111pub enum Error {
112    /// An unexpected error occurred within the driver.
113    Internal,
114    /// The requested operation, field, or mode is not supported by this hardware.
115    NotSupported,
116    /// One or more arguments provided to the method were invalid, or a requested value lies outside
117    /// the range the hardware can program.
118    InvalidArgs,
119    /// Communication with the charger hardware failed (e.g. a bus transfer error).
120    Io,
121    /// A `Watch` call is already pending on this connection.
122    AlreadyWatching,
123    #[doc(hidden)]
124    __SourceBreaking { unknown_ordinal: u32 },
125}
126
127/// Pattern that matches an unknown `Error` member.
128#[macro_export]
129macro_rules! ErrorUnknown {
130    () => {
131        _
132    };
133}
134
135impl Error {
136    #[inline]
137    pub fn from_primitive(prim: u32) -> Option<Self> {
138        match prim {
139            1 => Some(Self::Internal),
140            2 => Some(Self::NotSupported),
141            3 => Some(Self::InvalidArgs),
142            4 => Some(Self::Io),
143            5 => Some(Self::AlreadyWatching),
144            _ => None,
145        }
146    }
147
148    #[inline]
149    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
150        match prim {
151            1 => Self::Internal,
152            2 => Self::NotSupported,
153            3 => Self::InvalidArgs,
154            4 => Self::Io,
155            5 => Self::AlreadyWatching,
156            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
157        }
158    }
159
160    #[inline]
161    pub fn unknown() -> Self {
162        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
163    }
164
165    #[inline]
166    pub const fn into_primitive(self) -> u32 {
167        match self {
168            Self::Internal => 1,
169            Self::NotSupported => 2,
170            Self::InvalidArgs => 3,
171            Self::Io => 4,
172            Self::AlreadyWatching => 5,
173            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
174        }
175    }
176
177    #[inline]
178    pub fn is_unknown(&self) -> bool {
179        match self {
180            Self::__SourceBreaking { unknown_ordinal: _ } => true,
181            _ => false,
182        }
183    }
184}
185
186/// Hardware health and fault conditions of the charging converter.
187#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
188pub enum Health {
189    /// Normal operation; no faults or converter thermal throttling detected.
190    Good,
191    /// Input voltage on the charger supply rail exceeds the over-voltage lockout (OVLO) limit.
192    InputOverVoltage,
193    /// Input voltage on the charger supply rail fell below the under-voltage lockout (UVLO)
194    /// operational floor.
195    InputUnderVoltage,
196    /// Internal charger die temperature reached the thermal regulation (TREG) threshold; the
197    /// converter is still operating but actively folding back current to limit die heating.
198    ThermalWarning,
199    /// Internal charger die or input connector temperature exceeded thermal shutdown (TSHDN)
200    /// protection limits and the converter has suspended operation.
201    ThermalShutdown,
202    /// Hardware charge safety timer expired before reaching the target charge state.
203    SafetyTimerExpired,
204    /// Voltage sensed at the charger output rail exceeded the converter's over-voltage threshold.
205    BatteryOverVoltage,
206    /// Hardware watchdog timer expired (`WDT`), suspending converter operation.
207    WatchdogTimerExpired,
208    /// Unspecified charger hardware fault.
209    UnspecifiedFailure,
210    #[doc(hidden)]
211    __SourceBreaking { unknown_ordinal: u32 },
212}
213
214/// Pattern that matches an unknown `Health` member.
215#[macro_export]
216macro_rules! HealthUnknown {
217    () => {
218        _
219    };
220}
221
222impl Health {
223    #[inline]
224    pub fn from_primitive(prim: u32) -> Option<Self> {
225        match prim {
226            1 => Some(Self::Good),
227            2 => Some(Self::InputOverVoltage),
228            3 => Some(Self::InputUnderVoltage),
229            4 => Some(Self::ThermalWarning),
230            5 => Some(Self::ThermalShutdown),
231            6 => Some(Self::SafetyTimerExpired),
232            7 => Some(Self::BatteryOverVoltage),
233            8 => Some(Self::WatchdogTimerExpired),
234            9 => Some(Self::UnspecifiedFailure),
235            _ => None,
236        }
237    }
238
239    #[inline]
240    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
241        match prim {
242            1 => Self::Good,
243            2 => Self::InputOverVoltage,
244            3 => Self::InputUnderVoltage,
245            4 => Self::ThermalWarning,
246            5 => Self::ThermalShutdown,
247            6 => Self::SafetyTimerExpired,
248            7 => Self::BatteryOverVoltage,
249            8 => Self::WatchdogTimerExpired,
250            9 => Self::UnspecifiedFailure,
251            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
252        }
253    }
254
255    #[inline]
256    pub fn unknown() -> Self {
257        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
258    }
259
260    #[inline]
261    pub const fn into_primitive(self) -> u32 {
262        match self {
263            Self::Good => 1,
264            Self::InputOverVoltage => 2,
265            Self::InputUnderVoltage => 3,
266            Self::ThermalWarning => 4,
267            Self::ThermalShutdown => 5,
268            Self::SafetyTimerExpired => 6,
269            Self::BatteryOverVoltage => 7,
270            Self::WatchdogTimerExpired => 8,
271            Self::UnspecifiedFailure => 9,
272            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
273        }
274    }
275
276    #[inline]
277    pub fn is_unknown(&self) -> bool {
278        match self {
279            Self::__SourceBreaking { unknown_ordinal: _ } => true,
280            _ => false,
281        }
282    }
283}
284
285/// Describes the primary power converter operating state across the power path and battery
286/// interface.
287///
288/// Reported as state in `Status` and requested as a target in `ControlOptions`. A requested mode
289/// selects the converter configuration; the state subsequently reported also accounts for whether
290/// external power is actually present, so a charger left in `CHARGING` reports `DISCHARGING` once
291/// the input goes away.
292#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
293pub enum OperatingMode {
294    /// Normal operation: External power supplies system rails and charges the battery.
295    /// Requesting this mode resumes normal charging after `PASSTHROUGH` or `DISCHARGING`.
296    Charging,
297    /// Inhibit charge / passthrough: External power supplies system rails, but battery charging is
298    /// disabled (cell rests at current state of charge).
299    Passthrough,
300    /// As a request: force discharge. External power draw is suspended; the system runs
301    /// exclusively on battery while external communication (e.g. USB data) remains active.
302    ///
303    /// As reported state: the battery is supplying the system, either because discharge was
304    /// requested or because no external power is present. Use `Status.online` to tell these
305    /// apart. A configured `PASSTHROUGH` is not separately observable while offline.
306    Discharging,
307    /// OTG / Reverse Boost: Power is sourced outward from the battery to the external port.
308    Otg,
309    #[doc(hidden)]
310    __SourceBreaking { unknown_ordinal: u32 },
311}
312
313/// Pattern that matches an unknown `OperatingMode` member.
314#[macro_export]
315macro_rules! OperatingModeUnknown {
316    () => {
317        _
318    };
319}
320
321impl OperatingMode {
322    #[inline]
323    pub fn from_primitive(prim: u32) -> Option<Self> {
324        match prim {
325            1 => Some(Self::Charging),
326            2 => Some(Self::Passthrough),
327            3 => Some(Self::Discharging),
328            4 => Some(Self::Otg),
329            _ => None,
330        }
331    }
332
333    #[inline]
334    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
335        match prim {
336            1 => Self::Charging,
337            2 => Self::Passthrough,
338            3 => Self::Discharging,
339            4 => Self::Otg,
340            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
341        }
342    }
343
344    #[inline]
345    pub fn unknown() -> Self {
346        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
347    }
348
349    #[inline]
350    pub const fn into_primitive(self) -> u32 {
351        match self {
352            Self::Charging => 1,
353            Self::Passthrough => 2,
354            Self::Discharging => 3,
355            Self::Otg => 4,
356            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
357        }
358    }
359
360    #[inline]
361    pub fn is_unknown(&self) -> bool {
362        match self {
363            Self::__SourceBreaking { unknown_ordinal: _ } => true,
364            _ => false,
365        }
366    }
367}
368
369/// Describes the external power source type feeding the charger.
370#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
371pub enum SourceType {
372    /// Standard wall-plug adapter or dedicated charger (e.g. BC1.2 DCP).
373    Ac,
374    /// Standard USB host or charging downstream port (e.g. BC1.2 SDP / CDP).
375    Usb,
376    /// Inductive or magnetic resonance wireless charging pad (e.g. WCIN / Qi).
377    Wireless,
378    #[doc(hidden)]
379    __SourceBreaking { unknown_ordinal: u32 },
380}
381
382/// Pattern that matches an unknown `SourceType` member.
383#[macro_export]
384macro_rules! SourceTypeUnknown {
385    () => {
386        _
387    };
388}
389
390impl SourceType {
391    #[inline]
392    pub fn from_primitive(prim: u32) -> Option<Self> {
393        match prim {
394            1 => Some(Self::Ac),
395            2 => Some(Self::Usb),
396            3 => Some(Self::Wireless),
397            _ => None,
398        }
399    }
400
401    #[inline]
402    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
403        match prim {
404            1 => Self::Ac,
405            2 => Self::Usb,
406            3 => Self::Wireless,
407            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
408        }
409    }
410
411    #[inline]
412    pub fn unknown() -> Self {
413        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
414    }
415
416    #[inline]
417    pub const fn into_primitive(self) -> u32 {
418        match self {
419            Self::Ac => 1,
420            Self::Usb => 2,
421            Self::Wireless => 3,
422            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
423        }
424    }
425
426    #[inline]
427    pub fn is_unknown(&self) -> bool {
428        match self {
429            Self::__SourceBreaking { unknown_ordinal: _ } => true,
430            _ => false,
431        }
432    }
433}
434
435#[derive(Clone, Debug, PartialEq)]
436pub struct ChargerConfigureWatchRequest {
437    pub options: WatchOptions,
438}
439
440impl fidl::Persistable for ChargerConfigureWatchRequest {}
441
442#[derive(Clone, Debug, PartialEq)]
443pub struct ChargerConfigureWatchResponse {
444    pub effective_options: WatchOptions,
445}
446
447impl fidl::Persistable for ChargerConfigureWatchResponse {}
448
449#[derive(Clone, Debug, PartialEq)]
450pub struct ChargerGetSpecResponse {
451    pub spec: Spec,
452}
453
454impl fidl::Persistable for ChargerGetSpecResponse {}
455
456#[derive(Clone, Debug, PartialEq)]
457pub struct ChargerGetStatusResponse {
458    pub status: Status,
459}
460
461impl fidl::Persistable for ChargerGetStatusResponse {}
462
463#[derive(Clone, Debug, PartialEq)]
464pub struct ControllerClearControlRequest {
465    pub options: ControlOptions,
466}
467
468impl fidl::Persistable for ControllerClearControlRequest {}
469
470#[derive(Clone, Debug, PartialEq)]
471pub struct ControllerSetControlRequest {
472    pub options: ControlOptions,
473}
474
475impl fidl::Persistable for ControllerSetControlRequest {}
476
477/// Operational and electrical constraints applicable to the charger converter.
478///
479/// This is a partial update: only the fields present are applied, and any omitted field leaves the
480/// corresponding hardware setting unchanged. While the `Controller` connection remains open, to
481/// relax or withdraw a previously applied limit, set the field again to the desired value, call
482/// [`Controller.ClearControl`] with a mask of fields to withdraw, or close the `Controller`
483/// channel to withdraw all constraints and restore driver defaults.
484///
485/// Values between discrete hardware register steps are rounded in the direction that honors the
486/// constraint. Ceilings (current and voltage limits) round down, so a value below the lowest
487/// programmable step is rejected with `Error::INVALID_ARGS`; the `input_voltage_limit_uv` floor
488/// rounds up, so a value below the lowest programmable step is clamped to it.
489#[derive(Clone, Debug, Default, PartialEq)]
490pub struct ControlOptions {
491    /// Desired operational mode of the power converter.
492    pub operating_mode: Option<OperatingMode>,
493    /// Active Input Current Limit (ICL) programmed into the input power path, in microamps.
494    /// Values between discrete hardware register steps are rounded down to the nearest
495    /// programmable step so the requested ceiling is never exceeded.
496    pub input_current_limit_ua: Option<u32>,
497    /// Active Fast Charge Current (FCC) regulation limit for the battery, in microamps.
498    /// Values between discrete hardware register steps are rounded down to the nearest
499    /// programmable step so the requested ceiling is never exceeded.
500    pub charge_current_limit_ua: Option<u32>,
501    /// Active float (constant voltage / CV) regulation target across the battery, in microvolts
502    /// (bounded by `Spec.max_charge_voltage_uv`).
503    /// Values between discrete hardware register steps are rounded down to the nearest
504    /// programmable step. Note that writing a float voltage target may cause the hardware charge
505    /// state machine to exit `ChargePhase::TOP_OFF` and re-evaluate CV regulation.
506    pub float_voltage_uv: Option<u32>,
507    /// Active charge termination (top-off / taper cutoff) current threshold, in microamps.
508    /// Values between discrete hardware register steps are rounded down to the nearest
509    /// programmable step.
510    pub charge_term_current_ua: Option<u32>,
511    /// Minimum input voltage regulation floor (VINDPM), in microvolts, below which the converter
512    /// throttles input current draw to prevent source collapse.
513    /// Values between discrete hardware register steps are rounded up to the nearest programmable
514    /// step so the input voltage never drops below the requested floor.
515    pub input_voltage_limit_uv: Option<u32>,
516    #[doc(hidden)]
517    pub __source_breaking: fidl::marker::SourceBreaking,
518}
519
520impl fidl::Persistable for ControlOptions {}
521
522/// Static hardware characteristics and driver capabilities.
523#[derive(Clone, Debug, Default, PartialEq)]
524pub struct Spec {
525    /// Optional. Maximum current the charger hardware can supply to the battery, in microamps.
526    /// Omitted if unsupported by hardware.
527    pub max_charge_current_ua: Option<u32>,
528    /// Optional. Maximum voltage the charger hardware can regulate across the battery, in
529    /// microvolts.
530    /// Omitted if unsupported by hardware.
531    pub max_charge_voltage_uv: Option<u32>,
532    /// Optional. Maximum input current the charger input power path can draw, in microamps.
533    /// Omitted if unsupported by hardware.
534    pub max_input_current_ua: Option<u32>,
535    /// Optional. Informational charger model string or manufacturer part number.
536    /// Omitted if unknown or unprogrammed in hardware.
537    pub model: Option<String>,
538    /// Optional. List of operating modes supported by this charger hardware implementation.
539    /// Omitted if unsupported or unconfigurable by hardware.
540    pub supported_modes: Option<Vec<OperatingMode>>,
541    /// Required. The interest and wake options supported by this driver/hardware.
542    ///
543    /// Drivers must populate this table so clients know which fields support active change
544    /// notifications. If omitted by the driver, clients should assume no active interrupt watching
545    /// is supported.
546    ///
547    /// - `supported_options.interest`: Telemetry fields that can actively trigger hanging-get watch
548    ///   notifications on change. Fields omitted are passive measurements that do not generate
549    ///   hardware interrupts; their freshest values are returned during active state changes or via
550    ///   [`Charger.GetStatus`].
551    /// - `supported_options.wake_on`: Telemetry fields capable of actively waking the system from
552    ///   suspend via hardware interrupt lines etc.
553    pub supported_options: Option<WatchOptions>,
554    /// Optional. Trickle/precharge current supplied when battery voltage is below the fast-charge
555    /// threshold, in microamps.
556    /// Omitted if unsupported by hardware.
557    pub precharge_current_ua: Option<u32>,
558    /// Optional. Default or minimum charge termination (top-off / taper cutoff) current threshold,
559    /// in microamps.
560    /// Omitted if unsupported by hardware.
561    pub charge_term_current_ua: Option<u32>,
562    /// Optional. Battery voltage threshold (or drop below float voltage) at which the charger
563    /// automatically initiates a recharge cycle after reaching `ChargePhase::DONE`, in microvolts.
564    /// Omitted if unsupported by hardware.
565    pub recharge_voltage_uv: Option<u32>,
566    /// Optional. Minimum programmable input voltage regulation floor (VINDPM), in microvolts.
567    /// Omitted if unsupported by hardware.
568    pub min_input_voltage_uv: Option<u32>,
569    /// Optional. Maximum programmable input voltage regulation floor (VINDPM), in microvolts.
570    /// Omitted if unsupported by hardware.
571    pub max_input_voltage_uv: Option<u32>,
572    #[doc(hidden)]
573    pub __source_breaking: fidl::marker::SourceBreaking,
574}
575
576impl fidl::Persistable for Spec {}
577
578/// Primary telemetry snapshot of the charging regulator and its power inputs.
579#[derive(Clone, Debug, Default, PartialEq)]
580pub struct Status {
581    /// Whether an external power supply or adapter (e.g. VBUS / USB-C / wireless)
582    /// is physically attached and supplying valid power.
583    /// If false, no external source is detected. Omitted if attachment status is indeterminate.
584    pub online: Option<bool>,
585    /// The measured input voltage from the external power source in microvolts.
586    /// Omitted if unsupported by hardware or unavailable.
587    pub input_voltage_uv: Option<u32>,
588    /// The measured input current drawn from the external power source in microamps.
589    /// Positive (+) indicates current drawn into the charger from the external power source;
590    /// negative (-) indicates current sourced outward to the external port (e.g. during
591    /// `OperatingMode::OTG` reverse boost, if the hardware senses reverse port current).
592    /// Omitted if unsupported by hardware or unavailable.
593    pub input_current_ua: Option<i32>,
594    /// Active operational mode of the power converter and battery interface.
595    /// Omitted if indeterminate or unsupported by hardware.
596    pub operating_mode: Option<OperatingMode>,
597    /// Current charging phase.
598    /// Omitted if indeterminate or unsupported by hardware.
599    pub charge_phase: Option<ChargePhase>,
600    /// Active Input Current Limit (ICL) programmed into the input power path, in microamps.
601    /// Represents the maximum current the charger is permitted to draw from the external input.
602    /// Omitted if indeterminate or unsupported by hardware.
603    pub input_current_limit_ua: Option<u32>,
604    /// Active Fast Charge Current (FCC) regulation limit programmed for the battery, in microamps.
605    /// Represents the target constant-current delivered to the battery terminals during fast charge.
606    /// Omitted if indeterminate or unsupported by hardware.
607    pub charge_current_limit_ua: Option<u32>,
608    /// Active float (constant voltage / CV) regulation target programmed for the battery, in
609    /// microvolts. Represents the maximum terminal voltage across the battery pack (as distinct
610    /// from the static hardware ceiling `Spec.max_charge_voltage_uv`).
611    /// Omitted if indeterminate or unsupported by hardware.
612    pub float_voltage_uv: Option<u32>,
613    /// The detected external power supply type feeding the charger.
614    /// Omitted if indeterminate or disconnected.
615    pub source_type: Option<SourceType>,
616    /// Hardware health and fault condition of the charging converter.
617    /// Omitted if indeterminate or unsupported by hardware.
618    pub health: Option<Health>,
619    /// Active charge termination (top-off / taper cutoff) current threshold programmed into the
620    /// charger, in microamps.
621    /// Omitted if indeterminate or unsupported by hardware.
622    pub charge_term_current_ua: Option<u32>,
623    /// Active minimum input voltage regulation floor (VINDPM) programmed into the input power
624    /// path, in microvolts.
625    /// Omitted if indeterminate or unsupported by hardware.
626    pub input_voltage_limit_uv: Option<u32>,
627    #[doc(hidden)]
628    pub __source_breaking: fidl::marker::SourceBreaking,
629}
630
631impl fidl::Persistable for Status {}
632
633/// Configuration options for charger state watching.
634///
635/// Both fields are optional masks. In both `interest` and `wake_on`, the actual field values within
636/// the `Status` table are ignored; only field presence (set vs. unset) determines the mask.
637///
638/// An absent mask means "use this field's default"; a present but empty mask means "no fields".
639/// The two defaults differ because the safe choice differs: `interest` defaults to everything the
640/// driver supports watching, so a client that never configures anything still makes progress,
641/// while `wake_on` defaults to nothing, since waking the system is a cost a client must opt into.
642#[derive(Clone, Debug, Default, PartialEq)]
643pub struct WatchOptions {
644    /// Fields the client wants to receive change notifications for.
645    /// Defaults to every field the driver supports watching, as reported by
646    /// `Spec.supported_options`. Pass an explicitly empty table to be notified only for the
647    /// fields named in `wake_on`.
648    pub interest: Option<Status>,
649    /// Fields that should actively wake the system from suspend.
650    /// Any field present in `wake_on` is implicitly included in `interest`.
651    /// Defaults to no fields: changes occurring during suspend are deferred until the next system
652    /// wakeup and do not wake the device.
653    pub wake_on: Option<Status>,
654    #[doc(hidden)]
655    pub __source_breaking: fidl::marker::SourceBreaking,
656}
657
658impl fidl::Persistable for WatchOptions {}
659
660pub mod charger_ordinals {
661    pub const GET_SPEC: u64 = 0x4f1a5fc6df415db3;
662    pub const GET_STATUS: u64 = 0x3c67651b7ec14d5e;
663    pub const CONFIGURE_WATCH: u64 = 0x739a314e3494d695;
664    pub const WATCH: u64 = 0x5a52d95d33d7c66e;
665}
666
667pub mod controller_ordinals {
668    pub const SET_CONTROL: u64 = 0x363a64b0c8d45594;
669    pub const CLEAR_CONTROL: u64 = 0x2b2a45d9fa0cd3c1;
670}
671
672pub mod debug_ordinals {
673    pub const SET_CONTROL: u64 = 0x363a64b0c8d45594;
674    pub const CLEAR_CONTROL: u64 = 0x2b2a45d9fa0cd3c1;
675}
676
677mod internal {
678    use super::*;
679    unsafe impl fidl::encoding::TypeMarker for ChargePhase {
680        type Owned = Self;
681
682        #[inline(always)]
683        fn inline_align(_context: fidl::encoding::Context) -> usize {
684            std::mem::align_of::<u32>()
685        }
686
687        #[inline(always)]
688        fn inline_size(_context: fidl::encoding::Context) -> usize {
689            std::mem::size_of::<u32>()
690        }
691
692        #[inline(always)]
693        fn encode_is_copy() -> bool {
694            false
695        }
696
697        #[inline(always)]
698        fn decode_is_copy() -> bool {
699            false
700        }
701    }
702
703    impl fidl::encoding::ValueTypeMarker for ChargePhase {
704        type Borrowed<'a> = Self;
705        #[inline(always)]
706        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
707            *value
708        }
709    }
710
711    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ChargePhase {
712        #[inline]
713        unsafe fn encode(
714            self,
715            encoder: &mut fidl::encoding::Encoder<'_, D>,
716            offset: usize,
717            _depth: fidl::encoding::Depth,
718        ) -> fidl::Result<()> {
719            encoder.debug_check_bounds::<Self>(offset);
720            encoder.write_num(self.into_primitive(), offset);
721            Ok(())
722        }
723    }
724
725    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChargePhase {
726        #[inline(always)]
727        fn new_empty() -> Self {
728            Self::unknown()
729        }
730
731        #[inline]
732        unsafe fn decode(
733            &mut self,
734            decoder: &mut fidl::encoding::Decoder<'_, D>,
735            offset: usize,
736            _depth: fidl::encoding::Depth,
737        ) -> fidl::Result<()> {
738            decoder.debug_check_bounds::<Self>(offset);
739            let prim = decoder.read_num::<u32>(offset);
740
741            *self = Self::from_primitive_allow_unknown(prim);
742            Ok(())
743        }
744    }
745    unsafe impl fidl::encoding::TypeMarker for Error {
746        type Owned = Self;
747
748        #[inline(always)]
749        fn inline_align(_context: fidl::encoding::Context) -> usize {
750            std::mem::align_of::<u32>()
751        }
752
753        #[inline(always)]
754        fn inline_size(_context: fidl::encoding::Context) -> usize {
755            std::mem::size_of::<u32>()
756        }
757
758        #[inline(always)]
759        fn encode_is_copy() -> bool {
760            false
761        }
762
763        #[inline(always)]
764        fn decode_is_copy() -> bool {
765            false
766        }
767    }
768
769    impl fidl::encoding::ValueTypeMarker for Error {
770        type Borrowed<'a> = Self;
771        #[inline(always)]
772        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
773            *value
774        }
775    }
776
777    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
778        #[inline]
779        unsafe fn encode(
780            self,
781            encoder: &mut fidl::encoding::Encoder<'_, D>,
782            offset: usize,
783            _depth: fidl::encoding::Depth,
784        ) -> fidl::Result<()> {
785            encoder.debug_check_bounds::<Self>(offset);
786            encoder.write_num(self.into_primitive(), offset);
787            Ok(())
788        }
789    }
790
791    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
792        #[inline(always)]
793        fn new_empty() -> Self {
794            Self::unknown()
795        }
796
797        #[inline]
798        unsafe fn decode(
799            &mut self,
800            decoder: &mut fidl::encoding::Decoder<'_, D>,
801            offset: usize,
802            _depth: fidl::encoding::Depth,
803        ) -> fidl::Result<()> {
804            decoder.debug_check_bounds::<Self>(offset);
805            let prim = decoder.read_num::<u32>(offset);
806
807            *self = Self::from_primitive_allow_unknown(prim);
808            Ok(())
809        }
810    }
811    unsafe impl fidl::encoding::TypeMarker for Health {
812        type Owned = Self;
813
814        #[inline(always)]
815        fn inline_align(_context: fidl::encoding::Context) -> usize {
816            std::mem::align_of::<u32>()
817        }
818
819        #[inline(always)]
820        fn inline_size(_context: fidl::encoding::Context) -> usize {
821            std::mem::size_of::<u32>()
822        }
823
824        #[inline(always)]
825        fn encode_is_copy() -> bool {
826            false
827        }
828
829        #[inline(always)]
830        fn decode_is_copy() -> bool {
831            false
832        }
833    }
834
835    impl fidl::encoding::ValueTypeMarker for Health {
836        type Borrowed<'a> = Self;
837        #[inline(always)]
838        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
839            *value
840        }
841    }
842
843    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Health {
844        #[inline]
845        unsafe fn encode(
846            self,
847            encoder: &mut fidl::encoding::Encoder<'_, D>,
848            offset: usize,
849            _depth: fidl::encoding::Depth,
850        ) -> fidl::Result<()> {
851            encoder.debug_check_bounds::<Self>(offset);
852            encoder.write_num(self.into_primitive(), offset);
853            Ok(())
854        }
855    }
856
857    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Health {
858        #[inline(always)]
859        fn new_empty() -> Self {
860            Self::unknown()
861        }
862
863        #[inline]
864        unsafe fn decode(
865            &mut self,
866            decoder: &mut fidl::encoding::Decoder<'_, D>,
867            offset: usize,
868            _depth: fidl::encoding::Depth,
869        ) -> fidl::Result<()> {
870            decoder.debug_check_bounds::<Self>(offset);
871            let prim = decoder.read_num::<u32>(offset);
872
873            *self = Self::from_primitive_allow_unknown(prim);
874            Ok(())
875        }
876    }
877    unsafe impl fidl::encoding::TypeMarker for OperatingMode {
878        type Owned = Self;
879
880        #[inline(always)]
881        fn inline_align(_context: fidl::encoding::Context) -> usize {
882            std::mem::align_of::<u32>()
883        }
884
885        #[inline(always)]
886        fn inline_size(_context: fidl::encoding::Context) -> usize {
887            std::mem::size_of::<u32>()
888        }
889
890        #[inline(always)]
891        fn encode_is_copy() -> bool {
892            false
893        }
894
895        #[inline(always)]
896        fn decode_is_copy() -> bool {
897            false
898        }
899    }
900
901    impl fidl::encoding::ValueTypeMarker for OperatingMode {
902        type Borrowed<'a> = Self;
903        #[inline(always)]
904        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
905            *value
906        }
907    }
908
909    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for OperatingMode {
910        #[inline]
911        unsafe fn encode(
912            self,
913            encoder: &mut fidl::encoding::Encoder<'_, D>,
914            offset: usize,
915            _depth: fidl::encoding::Depth,
916        ) -> fidl::Result<()> {
917            encoder.debug_check_bounds::<Self>(offset);
918            encoder.write_num(self.into_primitive(), offset);
919            Ok(())
920        }
921    }
922
923    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OperatingMode {
924        #[inline(always)]
925        fn new_empty() -> Self {
926            Self::unknown()
927        }
928
929        #[inline]
930        unsafe fn decode(
931            &mut self,
932            decoder: &mut fidl::encoding::Decoder<'_, D>,
933            offset: usize,
934            _depth: fidl::encoding::Depth,
935        ) -> fidl::Result<()> {
936            decoder.debug_check_bounds::<Self>(offset);
937            let prim = decoder.read_num::<u32>(offset);
938
939            *self = Self::from_primitive_allow_unknown(prim);
940            Ok(())
941        }
942    }
943    unsafe impl fidl::encoding::TypeMarker for SourceType {
944        type Owned = Self;
945
946        #[inline(always)]
947        fn inline_align(_context: fidl::encoding::Context) -> usize {
948            std::mem::align_of::<u32>()
949        }
950
951        #[inline(always)]
952        fn inline_size(_context: fidl::encoding::Context) -> usize {
953            std::mem::size_of::<u32>()
954        }
955
956        #[inline(always)]
957        fn encode_is_copy() -> bool {
958            false
959        }
960
961        #[inline(always)]
962        fn decode_is_copy() -> bool {
963            false
964        }
965    }
966
967    impl fidl::encoding::ValueTypeMarker for SourceType {
968        type Borrowed<'a> = Self;
969        #[inline(always)]
970        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
971            *value
972        }
973    }
974
975    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SourceType {
976        #[inline]
977        unsafe fn encode(
978            self,
979            encoder: &mut fidl::encoding::Encoder<'_, D>,
980            offset: usize,
981            _depth: fidl::encoding::Depth,
982        ) -> fidl::Result<()> {
983            encoder.debug_check_bounds::<Self>(offset);
984            encoder.write_num(self.into_primitive(), offset);
985            Ok(())
986        }
987    }
988
989    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SourceType {
990        #[inline(always)]
991        fn new_empty() -> Self {
992            Self::unknown()
993        }
994
995        #[inline]
996        unsafe fn decode(
997            &mut self,
998            decoder: &mut fidl::encoding::Decoder<'_, D>,
999            offset: usize,
1000            _depth: fidl::encoding::Depth,
1001        ) -> fidl::Result<()> {
1002            decoder.debug_check_bounds::<Self>(offset);
1003            let prim = decoder.read_num::<u32>(offset);
1004
1005            *self = Self::from_primitive_allow_unknown(prim);
1006            Ok(())
1007        }
1008    }
1009
1010    impl fidl::encoding::ValueTypeMarker for ChargerConfigureWatchRequest {
1011        type Borrowed<'a> = &'a Self;
1012        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1013            value
1014        }
1015    }
1016
1017    unsafe impl fidl::encoding::TypeMarker for ChargerConfigureWatchRequest {
1018        type Owned = Self;
1019
1020        #[inline(always)]
1021        fn inline_align(_context: fidl::encoding::Context) -> usize {
1022            8
1023        }
1024
1025        #[inline(always)]
1026        fn inline_size(_context: fidl::encoding::Context) -> usize {
1027            16
1028        }
1029    }
1030
1031    unsafe impl<D: fidl::encoding::ResourceDialect>
1032        fidl::encoding::Encode<ChargerConfigureWatchRequest, D> for &ChargerConfigureWatchRequest
1033    {
1034        #[inline]
1035        unsafe fn encode(
1036            self,
1037            encoder: &mut fidl::encoding::Encoder<'_, D>,
1038            offset: usize,
1039            _depth: fidl::encoding::Depth,
1040        ) -> fidl::Result<()> {
1041            encoder.debug_check_bounds::<ChargerConfigureWatchRequest>(offset);
1042            // Delegate to tuple encoding.
1043            fidl::encoding::Encode::<ChargerConfigureWatchRequest, D>::encode(
1044                (<WatchOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),),
1045                encoder,
1046                offset,
1047                _depth,
1048            )
1049        }
1050    }
1051    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<WatchOptions, D>>
1052        fidl::encoding::Encode<ChargerConfigureWatchRequest, D> for (T0,)
1053    {
1054        #[inline]
1055        unsafe fn encode(
1056            self,
1057            encoder: &mut fidl::encoding::Encoder<'_, D>,
1058            offset: usize,
1059            depth: fidl::encoding::Depth,
1060        ) -> fidl::Result<()> {
1061            encoder.debug_check_bounds::<ChargerConfigureWatchRequest>(offset);
1062            // Zero out padding regions. There's no need to apply masks
1063            // because the unmasked parts will be overwritten by fields.
1064            // Write the fields.
1065            self.0.encode(encoder, offset + 0, depth)?;
1066            Ok(())
1067        }
1068    }
1069
1070    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1071        for ChargerConfigureWatchRequest
1072    {
1073        #[inline(always)]
1074        fn new_empty() -> Self {
1075            Self { options: fidl::new_empty!(WatchOptions, D) }
1076        }
1077
1078        #[inline]
1079        unsafe fn decode(
1080            &mut self,
1081            decoder: &mut fidl::encoding::Decoder<'_, D>,
1082            offset: usize,
1083            _depth: fidl::encoding::Depth,
1084        ) -> fidl::Result<()> {
1085            decoder.debug_check_bounds::<Self>(offset);
1086            // Verify that padding bytes are zero.
1087            fidl::decode!(WatchOptions, D, &mut self.options, decoder, offset + 0, _depth)?;
1088            Ok(())
1089        }
1090    }
1091
1092    impl fidl::encoding::ValueTypeMarker for ChargerConfigureWatchResponse {
1093        type Borrowed<'a> = &'a Self;
1094        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1095            value
1096        }
1097    }
1098
1099    unsafe impl fidl::encoding::TypeMarker for ChargerConfigureWatchResponse {
1100        type Owned = Self;
1101
1102        #[inline(always)]
1103        fn inline_align(_context: fidl::encoding::Context) -> usize {
1104            8
1105        }
1106
1107        #[inline(always)]
1108        fn inline_size(_context: fidl::encoding::Context) -> usize {
1109            16
1110        }
1111    }
1112
1113    unsafe impl<D: fidl::encoding::ResourceDialect>
1114        fidl::encoding::Encode<ChargerConfigureWatchResponse, D>
1115        for &ChargerConfigureWatchResponse
1116    {
1117        #[inline]
1118        unsafe fn encode(
1119            self,
1120            encoder: &mut fidl::encoding::Encoder<'_, D>,
1121            offset: usize,
1122            _depth: fidl::encoding::Depth,
1123        ) -> fidl::Result<()> {
1124            encoder.debug_check_bounds::<ChargerConfigureWatchResponse>(offset);
1125            // Delegate to tuple encoding.
1126            fidl::encoding::Encode::<ChargerConfigureWatchResponse, D>::encode(
1127                (<WatchOptions as fidl::encoding::ValueTypeMarker>::borrow(
1128                    &self.effective_options,
1129                ),),
1130                encoder,
1131                offset,
1132                _depth,
1133            )
1134        }
1135    }
1136    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<WatchOptions, D>>
1137        fidl::encoding::Encode<ChargerConfigureWatchResponse, D> for (T0,)
1138    {
1139        #[inline]
1140        unsafe fn encode(
1141            self,
1142            encoder: &mut fidl::encoding::Encoder<'_, D>,
1143            offset: usize,
1144            depth: fidl::encoding::Depth,
1145        ) -> fidl::Result<()> {
1146            encoder.debug_check_bounds::<ChargerConfigureWatchResponse>(offset);
1147            // Zero out padding regions. There's no need to apply masks
1148            // because the unmasked parts will be overwritten by fields.
1149            // Write the fields.
1150            self.0.encode(encoder, offset + 0, depth)?;
1151            Ok(())
1152        }
1153    }
1154
1155    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1156        for ChargerConfigureWatchResponse
1157    {
1158        #[inline(always)]
1159        fn new_empty() -> Self {
1160            Self { effective_options: fidl::new_empty!(WatchOptions, D) }
1161        }
1162
1163        #[inline]
1164        unsafe fn decode(
1165            &mut self,
1166            decoder: &mut fidl::encoding::Decoder<'_, D>,
1167            offset: usize,
1168            _depth: fidl::encoding::Depth,
1169        ) -> fidl::Result<()> {
1170            decoder.debug_check_bounds::<Self>(offset);
1171            // Verify that padding bytes are zero.
1172            fidl::decode!(
1173                WatchOptions,
1174                D,
1175                &mut self.effective_options,
1176                decoder,
1177                offset + 0,
1178                _depth
1179            )?;
1180            Ok(())
1181        }
1182    }
1183
1184    impl fidl::encoding::ValueTypeMarker for ChargerGetSpecResponse {
1185        type Borrowed<'a> = &'a Self;
1186        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1187            value
1188        }
1189    }
1190
1191    unsafe impl fidl::encoding::TypeMarker for ChargerGetSpecResponse {
1192        type Owned = Self;
1193
1194        #[inline(always)]
1195        fn inline_align(_context: fidl::encoding::Context) -> usize {
1196            8
1197        }
1198
1199        #[inline(always)]
1200        fn inline_size(_context: fidl::encoding::Context) -> usize {
1201            16
1202        }
1203    }
1204
1205    unsafe impl<D: fidl::encoding::ResourceDialect>
1206        fidl::encoding::Encode<ChargerGetSpecResponse, D> for &ChargerGetSpecResponse
1207    {
1208        #[inline]
1209        unsafe fn encode(
1210            self,
1211            encoder: &mut fidl::encoding::Encoder<'_, D>,
1212            offset: usize,
1213            _depth: fidl::encoding::Depth,
1214        ) -> fidl::Result<()> {
1215            encoder.debug_check_bounds::<ChargerGetSpecResponse>(offset);
1216            // Delegate to tuple encoding.
1217            fidl::encoding::Encode::<ChargerGetSpecResponse, D>::encode(
1218                (<Spec as fidl::encoding::ValueTypeMarker>::borrow(&self.spec),),
1219                encoder,
1220                offset,
1221                _depth,
1222            )
1223        }
1224    }
1225    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Spec, D>>
1226        fidl::encoding::Encode<ChargerGetSpecResponse, D> for (T0,)
1227    {
1228        #[inline]
1229        unsafe fn encode(
1230            self,
1231            encoder: &mut fidl::encoding::Encoder<'_, D>,
1232            offset: usize,
1233            depth: fidl::encoding::Depth,
1234        ) -> fidl::Result<()> {
1235            encoder.debug_check_bounds::<ChargerGetSpecResponse>(offset);
1236            // Zero out padding regions. There's no need to apply masks
1237            // because the unmasked parts will be overwritten by fields.
1238            // Write the fields.
1239            self.0.encode(encoder, offset + 0, depth)?;
1240            Ok(())
1241        }
1242    }
1243
1244    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1245        for ChargerGetSpecResponse
1246    {
1247        #[inline(always)]
1248        fn new_empty() -> Self {
1249            Self { spec: fidl::new_empty!(Spec, D) }
1250        }
1251
1252        #[inline]
1253        unsafe fn decode(
1254            &mut self,
1255            decoder: &mut fidl::encoding::Decoder<'_, D>,
1256            offset: usize,
1257            _depth: fidl::encoding::Depth,
1258        ) -> fidl::Result<()> {
1259            decoder.debug_check_bounds::<Self>(offset);
1260            // Verify that padding bytes are zero.
1261            fidl::decode!(Spec, D, &mut self.spec, decoder, offset + 0, _depth)?;
1262            Ok(())
1263        }
1264    }
1265
1266    impl fidl::encoding::ValueTypeMarker for ChargerGetStatusResponse {
1267        type Borrowed<'a> = &'a Self;
1268        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1269            value
1270        }
1271    }
1272
1273    unsafe impl fidl::encoding::TypeMarker for ChargerGetStatusResponse {
1274        type Owned = Self;
1275
1276        #[inline(always)]
1277        fn inline_align(_context: fidl::encoding::Context) -> usize {
1278            8
1279        }
1280
1281        #[inline(always)]
1282        fn inline_size(_context: fidl::encoding::Context) -> usize {
1283            16
1284        }
1285    }
1286
1287    unsafe impl<D: fidl::encoding::ResourceDialect>
1288        fidl::encoding::Encode<ChargerGetStatusResponse, D> for &ChargerGetStatusResponse
1289    {
1290        #[inline]
1291        unsafe fn encode(
1292            self,
1293            encoder: &mut fidl::encoding::Encoder<'_, D>,
1294            offset: usize,
1295            _depth: fidl::encoding::Depth,
1296        ) -> fidl::Result<()> {
1297            encoder.debug_check_bounds::<ChargerGetStatusResponse>(offset);
1298            // Delegate to tuple encoding.
1299            fidl::encoding::Encode::<ChargerGetStatusResponse, D>::encode(
1300                (<Status as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
1301                encoder,
1302                offset,
1303                _depth,
1304            )
1305        }
1306    }
1307    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Status, D>>
1308        fidl::encoding::Encode<ChargerGetStatusResponse, D> for (T0,)
1309    {
1310        #[inline]
1311        unsafe fn encode(
1312            self,
1313            encoder: &mut fidl::encoding::Encoder<'_, D>,
1314            offset: usize,
1315            depth: fidl::encoding::Depth,
1316        ) -> fidl::Result<()> {
1317            encoder.debug_check_bounds::<ChargerGetStatusResponse>(offset);
1318            // Zero out padding regions. There's no need to apply masks
1319            // because the unmasked parts will be overwritten by fields.
1320            // Write the fields.
1321            self.0.encode(encoder, offset + 0, depth)?;
1322            Ok(())
1323        }
1324    }
1325
1326    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1327        for ChargerGetStatusResponse
1328    {
1329        #[inline(always)]
1330        fn new_empty() -> Self {
1331            Self { status: fidl::new_empty!(Status, D) }
1332        }
1333
1334        #[inline]
1335        unsafe fn decode(
1336            &mut self,
1337            decoder: &mut fidl::encoding::Decoder<'_, D>,
1338            offset: usize,
1339            _depth: fidl::encoding::Depth,
1340        ) -> fidl::Result<()> {
1341            decoder.debug_check_bounds::<Self>(offset);
1342            // Verify that padding bytes are zero.
1343            fidl::decode!(Status, D, &mut self.status, decoder, offset + 0, _depth)?;
1344            Ok(())
1345        }
1346    }
1347
1348    impl fidl::encoding::ValueTypeMarker for ControllerClearControlRequest {
1349        type Borrowed<'a> = &'a Self;
1350        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1351            value
1352        }
1353    }
1354
1355    unsafe impl fidl::encoding::TypeMarker for ControllerClearControlRequest {
1356        type Owned = Self;
1357
1358        #[inline(always)]
1359        fn inline_align(_context: fidl::encoding::Context) -> usize {
1360            8
1361        }
1362
1363        #[inline(always)]
1364        fn inline_size(_context: fidl::encoding::Context) -> usize {
1365            16
1366        }
1367    }
1368
1369    unsafe impl<D: fidl::encoding::ResourceDialect>
1370        fidl::encoding::Encode<ControllerClearControlRequest, D>
1371        for &ControllerClearControlRequest
1372    {
1373        #[inline]
1374        unsafe fn encode(
1375            self,
1376            encoder: &mut fidl::encoding::Encoder<'_, D>,
1377            offset: usize,
1378            _depth: fidl::encoding::Depth,
1379        ) -> fidl::Result<()> {
1380            encoder.debug_check_bounds::<ControllerClearControlRequest>(offset);
1381            // Delegate to tuple encoding.
1382            fidl::encoding::Encode::<ControllerClearControlRequest, D>::encode(
1383                (<ControlOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),),
1384                encoder,
1385                offset,
1386                _depth,
1387            )
1388        }
1389    }
1390    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ControlOptions, D>>
1391        fidl::encoding::Encode<ControllerClearControlRequest, D> for (T0,)
1392    {
1393        #[inline]
1394        unsafe fn encode(
1395            self,
1396            encoder: &mut fidl::encoding::Encoder<'_, D>,
1397            offset: usize,
1398            depth: fidl::encoding::Depth,
1399        ) -> fidl::Result<()> {
1400            encoder.debug_check_bounds::<ControllerClearControlRequest>(offset);
1401            // Zero out padding regions. There's no need to apply masks
1402            // because the unmasked parts will be overwritten by fields.
1403            // Write the fields.
1404            self.0.encode(encoder, offset + 0, depth)?;
1405            Ok(())
1406        }
1407    }
1408
1409    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1410        for ControllerClearControlRequest
1411    {
1412        #[inline(always)]
1413        fn new_empty() -> Self {
1414            Self { options: fidl::new_empty!(ControlOptions, D) }
1415        }
1416
1417        #[inline]
1418        unsafe fn decode(
1419            &mut self,
1420            decoder: &mut fidl::encoding::Decoder<'_, D>,
1421            offset: usize,
1422            _depth: fidl::encoding::Depth,
1423        ) -> fidl::Result<()> {
1424            decoder.debug_check_bounds::<Self>(offset);
1425            // Verify that padding bytes are zero.
1426            fidl::decode!(ControlOptions, D, &mut self.options, decoder, offset + 0, _depth)?;
1427            Ok(())
1428        }
1429    }
1430
1431    impl fidl::encoding::ValueTypeMarker for ControllerSetControlRequest {
1432        type Borrowed<'a> = &'a Self;
1433        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1434            value
1435        }
1436    }
1437
1438    unsafe impl fidl::encoding::TypeMarker for ControllerSetControlRequest {
1439        type Owned = Self;
1440
1441        #[inline(always)]
1442        fn inline_align(_context: fidl::encoding::Context) -> usize {
1443            8
1444        }
1445
1446        #[inline(always)]
1447        fn inline_size(_context: fidl::encoding::Context) -> usize {
1448            16
1449        }
1450    }
1451
1452    unsafe impl<D: fidl::encoding::ResourceDialect>
1453        fidl::encoding::Encode<ControllerSetControlRequest, D> for &ControllerSetControlRequest
1454    {
1455        #[inline]
1456        unsafe fn encode(
1457            self,
1458            encoder: &mut fidl::encoding::Encoder<'_, D>,
1459            offset: usize,
1460            _depth: fidl::encoding::Depth,
1461        ) -> fidl::Result<()> {
1462            encoder.debug_check_bounds::<ControllerSetControlRequest>(offset);
1463            // Delegate to tuple encoding.
1464            fidl::encoding::Encode::<ControllerSetControlRequest, D>::encode(
1465                (<ControlOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),),
1466                encoder,
1467                offset,
1468                _depth,
1469            )
1470        }
1471    }
1472    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ControlOptions, D>>
1473        fidl::encoding::Encode<ControllerSetControlRequest, D> for (T0,)
1474    {
1475        #[inline]
1476        unsafe fn encode(
1477            self,
1478            encoder: &mut fidl::encoding::Encoder<'_, D>,
1479            offset: usize,
1480            depth: fidl::encoding::Depth,
1481        ) -> fidl::Result<()> {
1482            encoder.debug_check_bounds::<ControllerSetControlRequest>(offset);
1483            // Zero out padding regions. There's no need to apply masks
1484            // because the unmasked parts will be overwritten by fields.
1485            // Write the fields.
1486            self.0.encode(encoder, offset + 0, depth)?;
1487            Ok(())
1488        }
1489    }
1490
1491    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1492        for ControllerSetControlRequest
1493    {
1494        #[inline(always)]
1495        fn new_empty() -> Self {
1496            Self { options: fidl::new_empty!(ControlOptions, D) }
1497        }
1498
1499        #[inline]
1500        unsafe fn decode(
1501            &mut self,
1502            decoder: &mut fidl::encoding::Decoder<'_, D>,
1503            offset: usize,
1504            _depth: fidl::encoding::Depth,
1505        ) -> fidl::Result<()> {
1506            decoder.debug_check_bounds::<Self>(offset);
1507            // Verify that padding bytes are zero.
1508            fidl::decode!(ControlOptions, D, &mut self.options, decoder, offset + 0, _depth)?;
1509            Ok(())
1510        }
1511    }
1512
1513    impl ControlOptions {
1514        #[inline(always)]
1515        fn max_ordinal_present(&self) -> u64 {
1516            if let Some(_) = self.input_voltage_limit_uv {
1517                return 6;
1518            }
1519            if let Some(_) = self.charge_term_current_ua {
1520                return 5;
1521            }
1522            if let Some(_) = self.float_voltage_uv {
1523                return 4;
1524            }
1525            if let Some(_) = self.charge_current_limit_ua {
1526                return 3;
1527            }
1528            if let Some(_) = self.input_current_limit_ua {
1529                return 2;
1530            }
1531            if let Some(_) = self.operating_mode {
1532                return 1;
1533            }
1534            0
1535        }
1536    }
1537
1538    impl fidl::encoding::ValueTypeMarker for ControlOptions {
1539        type Borrowed<'a> = &'a Self;
1540        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1541            value
1542        }
1543    }
1544
1545    unsafe impl fidl::encoding::TypeMarker for ControlOptions {
1546        type Owned = Self;
1547
1548        #[inline(always)]
1549        fn inline_align(_context: fidl::encoding::Context) -> usize {
1550            8
1551        }
1552
1553        #[inline(always)]
1554        fn inline_size(_context: fidl::encoding::Context) -> usize {
1555            16
1556        }
1557    }
1558
1559    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ControlOptions, D>
1560        for &ControlOptions
1561    {
1562        unsafe fn encode(
1563            self,
1564            encoder: &mut fidl::encoding::Encoder<'_, D>,
1565            offset: usize,
1566            mut depth: fidl::encoding::Depth,
1567        ) -> fidl::Result<()> {
1568            encoder.debug_check_bounds::<ControlOptions>(offset);
1569            // Vector header
1570            let max_ordinal: u64 = self.max_ordinal_present();
1571            encoder.write_num(max_ordinal, offset);
1572            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1573            // Calling encoder.out_of_line_offset(0) is not allowed.
1574            if max_ordinal == 0 {
1575                return Ok(());
1576            }
1577            depth.increment()?;
1578            let envelope_size = 8;
1579            let bytes_len = max_ordinal as usize * envelope_size;
1580            #[allow(unused_variables)]
1581            let offset = encoder.out_of_line_offset(bytes_len);
1582            let mut _prev_end_offset: usize = 0;
1583            if 1 > max_ordinal {
1584                return Ok(());
1585            }
1586
1587            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1588            // are envelope_size bytes.
1589            let cur_offset: usize = (1 - 1) * envelope_size;
1590
1591            // Zero reserved fields.
1592            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1593
1594            // Safety:
1595            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1596            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1597            //   envelope_size bytes, there is always sufficient room.
1598            fidl::encoding::encode_in_envelope_optional::<OperatingMode, D>(
1599                self.operating_mode
1600                    .as_ref()
1601                    .map(<OperatingMode as fidl::encoding::ValueTypeMarker>::borrow),
1602                encoder,
1603                offset + cur_offset,
1604                depth,
1605            )?;
1606
1607            _prev_end_offset = cur_offset + envelope_size;
1608            if 2 > max_ordinal {
1609                return Ok(());
1610            }
1611
1612            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1613            // are envelope_size bytes.
1614            let cur_offset: usize = (2 - 1) * envelope_size;
1615
1616            // Zero reserved fields.
1617            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1618
1619            // Safety:
1620            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1621            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1622            //   envelope_size bytes, there is always sufficient room.
1623            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1624                self.input_current_limit_ua
1625                    .as_ref()
1626                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1627                encoder,
1628                offset + cur_offset,
1629                depth,
1630            )?;
1631
1632            _prev_end_offset = cur_offset + envelope_size;
1633            if 3 > max_ordinal {
1634                return Ok(());
1635            }
1636
1637            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1638            // are envelope_size bytes.
1639            let cur_offset: usize = (3 - 1) * envelope_size;
1640
1641            // Zero reserved fields.
1642            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1643
1644            // Safety:
1645            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1646            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1647            //   envelope_size bytes, there is always sufficient room.
1648            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1649                self.charge_current_limit_ua
1650                    .as_ref()
1651                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1652                encoder,
1653                offset + cur_offset,
1654                depth,
1655            )?;
1656
1657            _prev_end_offset = cur_offset + envelope_size;
1658            if 4 > max_ordinal {
1659                return Ok(());
1660            }
1661
1662            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1663            // are envelope_size bytes.
1664            let cur_offset: usize = (4 - 1) * envelope_size;
1665
1666            // Zero reserved fields.
1667            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1668
1669            // Safety:
1670            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1671            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1672            //   envelope_size bytes, there is always sufficient room.
1673            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1674                self.float_voltage_uv
1675                    .as_ref()
1676                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1677                encoder,
1678                offset + cur_offset,
1679                depth,
1680            )?;
1681
1682            _prev_end_offset = cur_offset + envelope_size;
1683            if 5 > max_ordinal {
1684                return Ok(());
1685            }
1686
1687            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1688            // are envelope_size bytes.
1689            let cur_offset: usize = (5 - 1) * envelope_size;
1690
1691            // Zero reserved fields.
1692            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1693
1694            // Safety:
1695            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1696            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1697            //   envelope_size bytes, there is always sufficient room.
1698            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1699                self.charge_term_current_ua
1700                    .as_ref()
1701                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1702                encoder,
1703                offset + cur_offset,
1704                depth,
1705            )?;
1706
1707            _prev_end_offset = cur_offset + envelope_size;
1708            if 6 > max_ordinal {
1709                return Ok(());
1710            }
1711
1712            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1713            // are envelope_size bytes.
1714            let cur_offset: usize = (6 - 1) * envelope_size;
1715
1716            // Zero reserved fields.
1717            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1718
1719            // Safety:
1720            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1721            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1722            //   envelope_size bytes, there is always sufficient room.
1723            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1724                self.input_voltage_limit_uv
1725                    .as_ref()
1726                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1727                encoder,
1728                offset + cur_offset,
1729                depth,
1730            )?;
1731
1732            _prev_end_offset = cur_offset + envelope_size;
1733
1734            Ok(())
1735        }
1736    }
1737
1738    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ControlOptions {
1739        #[inline(always)]
1740        fn new_empty() -> Self {
1741            Self::default()
1742        }
1743
1744        unsafe fn decode(
1745            &mut self,
1746            decoder: &mut fidl::encoding::Decoder<'_, D>,
1747            offset: usize,
1748            mut depth: fidl::encoding::Depth,
1749        ) -> fidl::Result<()> {
1750            decoder.debug_check_bounds::<Self>(offset);
1751            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1752                None => return Err(fidl::Error::NotNullable),
1753                Some(len) => len,
1754            };
1755            // Calling decoder.out_of_line_offset(0) is not allowed.
1756            if len == 0 {
1757                return Ok(());
1758            };
1759            depth.increment()?;
1760            let envelope_size = 8;
1761            let bytes_len = len * envelope_size;
1762            let offset = decoder.out_of_line_offset(bytes_len)?;
1763            // Decode the envelope for each type.
1764            let mut _next_ordinal_to_read = 0;
1765            let mut next_offset = offset;
1766            let end_offset = offset + bytes_len;
1767            _next_ordinal_to_read += 1;
1768            if next_offset >= end_offset {
1769                return Ok(());
1770            }
1771
1772            // Decode unknown envelopes for gaps in ordinals.
1773            while _next_ordinal_to_read < 1 {
1774                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1775                _next_ordinal_to_read += 1;
1776                next_offset += envelope_size;
1777            }
1778
1779            let next_out_of_line = decoder.next_out_of_line();
1780            let handles_before = decoder.remaining_handles();
1781            if let Some((inlined, num_bytes, num_handles)) =
1782                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1783            {
1784                let member_inline_size =
1785                    <OperatingMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1786                if inlined != (member_inline_size <= 4) {
1787                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1788                }
1789                let inner_offset;
1790                let mut inner_depth = depth.clone();
1791                if inlined {
1792                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1793                    inner_offset = next_offset;
1794                } else {
1795                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1796                    inner_depth.increment()?;
1797                }
1798                let val_ref =
1799                    self.operating_mode.get_or_insert_with(|| fidl::new_empty!(OperatingMode, D));
1800                fidl::decode!(OperatingMode, D, val_ref, decoder, inner_offset, inner_depth)?;
1801                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1802                {
1803                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1804                }
1805                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1806                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1807                }
1808            }
1809
1810            next_offset += envelope_size;
1811            _next_ordinal_to_read += 1;
1812            if next_offset >= end_offset {
1813                return Ok(());
1814            }
1815
1816            // Decode unknown envelopes for gaps in ordinals.
1817            while _next_ordinal_to_read < 2 {
1818                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1819                _next_ordinal_to_read += 1;
1820                next_offset += envelope_size;
1821            }
1822
1823            let next_out_of_line = decoder.next_out_of_line();
1824            let handles_before = decoder.remaining_handles();
1825            if let Some((inlined, num_bytes, num_handles)) =
1826                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1827            {
1828                let member_inline_size =
1829                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1830                if inlined != (member_inline_size <= 4) {
1831                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1832                }
1833                let inner_offset;
1834                let mut inner_depth = depth.clone();
1835                if inlined {
1836                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1837                    inner_offset = next_offset;
1838                } else {
1839                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1840                    inner_depth.increment()?;
1841                }
1842                let val_ref =
1843                    self.input_current_limit_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
1844                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1845                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1846                {
1847                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1848                }
1849                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1850                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1851                }
1852            }
1853
1854            next_offset += envelope_size;
1855            _next_ordinal_to_read += 1;
1856            if next_offset >= end_offset {
1857                return Ok(());
1858            }
1859
1860            // Decode unknown envelopes for gaps in ordinals.
1861            while _next_ordinal_to_read < 3 {
1862                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1863                _next_ordinal_to_read += 1;
1864                next_offset += envelope_size;
1865            }
1866
1867            let next_out_of_line = decoder.next_out_of_line();
1868            let handles_before = decoder.remaining_handles();
1869            if let Some((inlined, num_bytes, num_handles)) =
1870                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1871            {
1872                let member_inline_size =
1873                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1874                if inlined != (member_inline_size <= 4) {
1875                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1876                }
1877                let inner_offset;
1878                let mut inner_depth = depth.clone();
1879                if inlined {
1880                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1881                    inner_offset = next_offset;
1882                } else {
1883                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1884                    inner_depth.increment()?;
1885                }
1886                let val_ref =
1887                    self.charge_current_limit_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
1888                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1889                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1890                {
1891                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1892                }
1893                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1894                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1895                }
1896            }
1897
1898            next_offset += envelope_size;
1899            _next_ordinal_to_read += 1;
1900            if next_offset >= end_offset {
1901                return Ok(());
1902            }
1903
1904            // Decode unknown envelopes for gaps in ordinals.
1905            while _next_ordinal_to_read < 4 {
1906                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1907                _next_ordinal_to_read += 1;
1908                next_offset += envelope_size;
1909            }
1910
1911            let next_out_of_line = decoder.next_out_of_line();
1912            let handles_before = decoder.remaining_handles();
1913            if let Some((inlined, num_bytes, num_handles)) =
1914                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1915            {
1916                let member_inline_size =
1917                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1918                if inlined != (member_inline_size <= 4) {
1919                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1920                }
1921                let inner_offset;
1922                let mut inner_depth = depth.clone();
1923                if inlined {
1924                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1925                    inner_offset = next_offset;
1926                } else {
1927                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1928                    inner_depth.increment()?;
1929                }
1930                let val_ref = self.float_voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
1931                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1932                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1933                {
1934                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1935                }
1936                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1937                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1938                }
1939            }
1940
1941            next_offset += envelope_size;
1942            _next_ordinal_to_read += 1;
1943            if next_offset >= end_offset {
1944                return Ok(());
1945            }
1946
1947            // Decode unknown envelopes for gaps in ordinals.
1948            while _next_ordinal_to_read < 5 {
1949                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1950                _next_ordinal_to_read += 1;
1951                next_offset += envelope_size;
1952            }
1953
1954            let next_out_of_line = decoder.next_out_of_line();
1955            let handles_before = decoder.remaining_handles();
1956            if let Some((inlined, num_bytes, num_handles)) =
1957                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1958            {
1959                let member_inline_size =
1960                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1961                if inlined != (member_inline_size <= 4) {
1962                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1963                }
1964                let inner_offset;
1965                let mut inner_depth = depth.clone();
1966                if inlined {
1967                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1968                    inner_offset = next_offset;
1969                } else {
1970                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1971                    inner_depth.increment()?;
1972                }
1973                let val_ref =
1974                    self.charge_term_current_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
1975                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1976                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1977                {
1978                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1979                }
1980                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1981                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1982                }
1983            }
1984
1985            next_offset += envelope_size;
1986            _next_ordinal_to_read += 1;
1987            if next_offset >= end_offset {
1988                return Ok(());
1989            }
1990
1991            // Decode unknown envelopes for gaps in ordinals.
1992            while _next_ordinal_to_read < 6 {
1993                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1994                _next_ordinal_to_read += 1;
1995                next_offset += envelope_size;
1996            }
1997
1998            let next_out_of_line = decoder.next_out_of_line();
1999            let handles_before = decoder.remaining_handles();
2000            if let Some((inlined, num_bytes, num_handles)) =
2001                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2002            {
2003                let member_inline_size =
2004                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2005                if inlined != (member_inline_size <= 4) {
2006                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2007                }
2008                let inner_offset;
2009                let mut inner_depth = depth.clone();
2010                if inlined {
2011                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2012                    inner_offset = next_offset;
2013                } else {
2014                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2015                    inner_depth.increment()?;
2016                }
2017                let val_ref =
2018                    self.input_voltage_limit_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
2019                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2020                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2021                {
2022                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2023                }
2024                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2025                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2026                }
2027            }
2028
2029            next_offset += envelope_size;
2030
2031            // Decode the remaining unknown envelopes.
2032            while next_offset < end_offset {
2033                _next_ordinal_to_read += 1;
2034                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2035                next_offset += envelope_size;
2036            }
2037
2038            Ok(())
2039        }
2040    }
2041
2042    impl Spec {
2043        #[inline(always)]
2044        fn max_ordinal_present(&self) -> u64 {
2045            if let Some(_) = self.max_input_voltage_uv {
2046                return 11;
2047            }
2048            if let Some(_) = self.min_input_voltage_uv {
2049                return 10;
2050            }
2051            if let Some(_) = self.recharge_voltage_uv {
2052                return 9;
2053            }
2054            if let Some(_) = self.charge_term_current_ua {
2055                return 8;
2056            }
2057            if let Some(_) = self.precharge_current_ua {
2058                return 7;
2059            }
2060            if let Some(_) = self.supported_options {
2061                return 6;
2062            }
2063            if let Some(_) = self.supported_modes {
2064                return 5;
2065            }
2066            if let Some(_) = self.model {
2067                return 4;
2068            }
2069            if let Some(_) = self.max_input_current_ua {
2070                return 3;
2071            }
2072            if let Some(_) = self.max_charge_voltage_uv {
2073                return 2;
2074            }
2075            if let Some(_) = self.max_charge_current_ua {
2076                return 1;
2077            }
2078            0
2079        }
2080    }
2081
2082    impl fidl::encoding::ValueTypeMarker for Spec {
2083        type Borrowed<'a> = &'a Self;
2084        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2085            value
2086        }
2087    }
2088
2089    unsafe impl fidl::encoding::TypeMarker for Spec {
2090        type Owned = Self;
2091
2092        #[inline(always)]
2093        fn inline_align(_context: fidl::encoding::Context) -> usize {
2094            8
2095        }
2096
2097        #[inline(always)]
2098        fn inline_size(_context: fidl::encoding::Context) -> usize {
2099            16
2100        }
2101    }
2102
2103    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Spec, D> for &Spec {
2104        unsafe fn encode(
2105            self,
2106            encoder: &mut fidl::encoding::Encoder<'_, D>,
2107            offset: usize,
2108            mut depth: fidl::encoding::Depth,
2109        ) -> fidl::Result<()> {
2110            encoder.debug_check_bounds::<Spec>(offset);
2111            // Vector header
2112            let max_ordinal: u64 = self.max_ordinal_present();
2113            encoder.write_num(max_ordinal, offset);
2114            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2115            // Calling encoder.out_of_line_offset(0) is not allowed.
2116            if max_ordinal == 0 {
2117                return Ok(());
2118            }
2119            depth.increment()?;
2120            let envelope_size = 8;
2121            let bytes_len = max_ordinal as usize * envelope_size;
2122            #[allow(unused_variables)]
2123            let offset = encoder.out_of_line_offset(bytes_len);
2124            let mut _prev_end_offset: usize = 0;
2125            if 1 > max_ordinal {
2126                return Ok(());
2127            }
2128
2129            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2130            // are envelope_size bytes.
2131            let cur_offset: usize = (1 - 1) * envelope_size;
2132
2133            // Zero reserved fields.
2134            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2135
2136            // Safety:
2137            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2138            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2139            //   envelope_size bytes, there is always sufficient room.
2140            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2141                self.max_charge_current_ua
2142                    .as_ref()
2143                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2144                encoder,
2145                offset + cur_offset,
2146                depth,
2147            )?;
2148
2149            _prev_end_offset = cur_offset + envelope_size;
2150            if 2 > max_ordinal {
2151                return Ok(());
2152            }
2153
2154            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2155            // are envelope_size bytes.
2156            let cur_offset: usize = (2 - 1) * envelope_size;
2157
2158            // Zero reserved fields.
2159            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2160
2161            // Safety:
2162            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2163            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2164            //   envelope_size bytes, there is always sufficient room.
2165            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2166                self.max_charge_voltage_uv
2167                    .as_ref()
2168                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2169                encoder,
2170                offset + cur_offset,
2171                depth,
2172            )?;
2173
2174            _prev_end_offset = cur_offset + envelope_size;
2175            if 3 > max_ordinal {
2176                return Ok(());
2177            }
2178
2179            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2180            // are envelope_size bytes.
2181            let cur_offset: usize = (3 - 1) * envelope_size;
2182
2183            // Zero reserved fields.
2184            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2185
2186            // Safety:
2187            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2188            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2189            //   envelope_size bytes, there is always sufficient room.
2190            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2191                self.max_input_current_ua
2192                    .as_ref()
2193                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2194                encoder,
2195                offset + cur_offset,
2196                depth,
2197            )?;
2198
2199            _prev_end_offset = cur_offset + envelope_size;
2200            if 4 > max_ordinal {
2201                return Ok(());
2202            }
2203
2204            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2205            // are envelope_size bytes.
2206            let cur_offset: usize = (4 - 1) * envelope_size;
2207
2208            // Zero reserved fields.
2209            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2210
2211            // Safety:
2212            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2213            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2214            //   envelope_size bytes, there is always sufficient room.
2215            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
2216                self.model.as_ref().map(
2217                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
2218                ),
2219                encoder,
2220                offset + cur_offset,
2221                depth,
2222            )?;
2223
2224            _prev_end_offset = cur_offset + envelope_size;
2225            if 5 > max_ordinal {
2226                return Ok(());
2227            }
2228
2229            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2230            // are envelope_size bytes.
2231            let cur_offset: usize = (5 - 1) * envelope_size;
2232
2233            // Zero reserved fields.
2234            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2235
2236            // Safety:
2237            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2238            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2239            //   envelope_size bytes, there is always sufficient room.
2240            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<OperatingMode, 16>, D>(
2241            self.supported_modes.as_ref().map(<fidl::encoding::Vector<OperatingMode, 16> as fidl::encoding::ValueTypeMarker>::borrow),
2242            encoder, offset + cur_offset, depth
2243        )?;
2244
2245            _prev_end_offset = cur_offset + envelope_size;
2246            if 6 > max_ordinal {
2247                return Ok(());
2248            }
2249
2250            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2251            // are envelope_size bytes.
2252            let cur_offset: usize = (6 - 1) * envelope_size;
2253
2254            // Zero reserved fields.
2255            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2256
2257            // Safety:
2258            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2259            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2260            //   envelope_size bytes, there is always sufficient room.
2261            fidl::encoding::encode_in_envelope_optional::<WatchOptions, D>(
2262                self.supported_options
2263                    .as_ref()
2264                    .map(<WatchOptions as fidl::encoding::ValueTypeMarker>::borrow),
2265                encoder,
2266                offset + cur_offset,
2267                depth,
2268            )?;
2269
2270            _prev_end_offset = cur_offset + envelope_size;
2271            if 7 > max_ordinal {
2272                return Ok(());
2273            }
2274
2275            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2276            // are envelope_size bytes.
2277            let cur_offset: usize = (7 - 1) * envelope_size;
2278
2279            // Zero reserved fields.
2280            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2281
2282            // Safety:
2283            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2284            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2285            //   envelope_size bytes, there is always sufficient room.
2286            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2287                self.precharge_current_ua
2288                    .as_ref()
2289                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2290                encoder,
2291                offset + cur_offset,
2292                depth,
2293            )?;
2294
2295            _prev_end_offset = cur_offset + envelope_size;
2296            if 8 > max_ordinal {
2297                return Ok(());
2298            }
2299
2300            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2301            // are envelope_size bytes.
2302            let cur_offset: usize = (8 - 1) * envelope_size;
2303
2304            // Zero reserved fields.
2305            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2306
2307            // Safety:
2308            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2309            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2310            //   envelope_size bytes, there is always sufficient room.
2311            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2312                self.charge_term_current_ua
2313                    .as_ref()
2314                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2315                encoder,
2316                offset + cur_offset,
2317                depth,
2318            )?;
2319
2320            _prev_end_offset = cur_offset + envelope_size;
2321            if 9 > max_ordinal {
2322                return Ok(());
2323            }
2324
2325            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2326            // are envelope_size bytes.
2327            let cur_offset: usize = (9 - 1) * envelope_size;
2328
2329            // Zero reserved fields.
2330            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2331
2332            // Safety:
2333            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2334            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2335            //   envelope_size bytes, there is always sufficient room.
2336            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2337                self.recharge_voltage_uv
2338                    .as_ref()
2339                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2340                encoder,
2341                offset + cur_offset,
2342                depth,
2343            )?;
2344
2345            _prev_end_offset = cur_offset + envelope_size;
2346            if 10 > max_ordinal {
2347                return Ok(());
2348            }
2349
2350            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2351            // are envelope_size bytes.
2352            let cur_offset: usize = (10 - 1) * envelope_size;
2353
2354            // Zero reserved fields.
2355            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2356
2357            // Safety:
2358            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2359            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2360            //   envelope_size bytes, there is always sufficient room.
2361            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2362                self.min_input_voltage_uv
2363                    .as_ref()
2364                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2365                encoder,
2366                offset + cur_offset,
2367                depth,
2368            )?;
2369
2370            _prev_end_offset = cur_offset + envelope_size;
2371            if 11 > max_ordinal {
2372                return Ok(());
2373            }
2374
2375            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2376            // are envelope_size bytes.
2377            let cur_offset: usize = (11 - 1) * envelope_size;
2378
2379            // Zero reserved fields.
2380            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2381
2382            // Safety:
2383            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2384            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2385            //   envelope_size bytes, there is always sufficient room.
2386            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2387                self.max_input_voltage_uv
2388                    .as_ref()
2389                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2390                encoder,
2391                offset + cur_offset,
2392                depth,
2393            )?;
2394
2395            _prev_end_offset = cur_offset + envelope_size;
2396
2397            Ok(())
2398        }
2399    }
2400
2401    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Spec {
2402        #[inline(always)]
2403        fn new_empty() -> Self {
2404            Self::default()
2405        }
2406
2407        unsafe fn decode(
2408            &mut self,
2409            decoder: &mut fidl::encoding::Decoder<'_, D>,
2410            offset: usize,
2411            mut depth: fidl::encoding::Depth,
2412        ) -> fidl::Result<()> {
2413            decoder.debug_check_bounds::<Self>(offset);
2414            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2415                None => return Err(fidl::Error::NotNullable),
2416                Some(len) => len,
2417            };
2418            // Calling decoder.out_of_line_offset(0) is not allowed.
2419            if len == 0 {
2420                return Ok(());
2421            };
2422            depth.increment()?;
2423            let envelope_size = 8;
2424            let bytes_len = len * envelope_size;
2425            let offset = decoder.out_of_line_offset(bytes_len)?;
2426            // Decode the envelope for each type.
2427            let mut _next_ordinal_to_read = 0;
2428            let mut next_offset = offset;
2429            let end_offset = offset + bytes_len;
2430            _next_ordinal_to_read += 1;
2431            if next_offset >= end_offset {
2432                return Ok(());
2433            }
2434
2435            // Decode unknown envelopes for gaps in ordinals.
2436            while _next_ordinal_to_read < 1 {
2437                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2438                _next_ordinal_to_read += 1;
2439                next_offset += envelope_size;
2440            }
2441
2442            let next_out_of_line = decoder.next_out_of_line();
2443            let handles_before = decoder.remaining_handles();
2444            if let Some((inlined, num_bytes, num_handles)) =
2445                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2446            {
2447                let member_inline_size =
2448                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2449                if inlined != (member_inline_size <= 4) {
2450                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2451                }
2452                let inner_offset;
2453                let mut inner_depth = depth.clone();
2454                if inlined {
2455                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2456                    inner_offset = next_offset;
2457                } else {
2458                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2459                    inner_depth.increment()?;
2460                }
2461                let val_ref =
2462                    self.max_charge_current_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
2463                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2464                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2465                {
2466                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2467                }
2468                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2469                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2470                }
2471            }
2472
2473            next_offset += envelope_size;
2474            _next_ordinal_to_read += 1;
2475            if next_offset >= end_offset {
2476                return Ok(());
2477            }
2478
2479            // Decode unknown envelopes for gaps in ordinals.
2480            while _next_ordinal_to_read < 2 {
2481                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2482                _next_ordinal_to_read += 1;
2483                next_offset += envelope_size;
2484            }
2485
2486            let next_out_of_line = decoder.next_out_of_line();
2487            let handles_before = decoder.remaining_handles();
2488            if let Some((inlined, num_bytes, num_handles)) =
2489                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2490            {
2491                let member_inline_size =
2492                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2493                if inlined != (member_inline_size <= 4) {
2494                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2495                }
2496                let inner_offset;
2497                let mut inner_depth = depth.clone();
2498                if inlined {
2499                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2500                    inner_offset = next_offset;
2501                } else {
2502                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2503                    inner_depth.increment()?;
2504                }
2505                let val_ref =
2506                    self.max_charge_voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
2507                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2508                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2509                {
2510                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2511                }
2512                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2513                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2514                }
2515            }
2516
2517            next_offset += envelope_size;
2518            _next_ordinal_to_read += 1;
2519            if next_offset >= end_offset {
2520                return Ok(());
2521            }
2522
2523            // Decode unknown envelopes for gaps in ordinals.
2524            while _next_ordinal_to_read < 3 {
2525                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2526                _next_ordinal_to_read += 1;
2527                next_offset += envelope_size;
2528            }
2529
2530            let next_out_of_line = decoder.next_out_of_line();
2531            let handles_before = decoder.remaining_handles();
2532            if let Some((inlined, num_bytes, num_handles)) =
2533                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2534            {
2535                let member_inline_size =
2536                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2537                if inlined != (member_inline_size <= 4) {
2538                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2539                }
2540                let inner_offset;
2541                let mut inner_depth = depth.clone();
2542                if inlined {
2543                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2544                    inner_offset = next_offset;
2545                } else {
2546                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2547                    inner_depth.increment()?;
2548                }
2549                let val_ref =
2550                    self.max_input_current_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
2551                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2552                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2553                {
2554                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2555                }
2556                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2557                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2558                }
2559            }
2560
2561            next_offset += envelope_size;
2562            _next_ordinal_to_read += 1;
2563            if next_offset >= end_offset {
2564                return Ok(());
2565            }
2566
2567            // Decode unknown envelopes for gaps in ordinals.
2568            while _next_ordinal_to_read < 4 {
2569                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2570                _next_ordinal_to_read += 1;
2571                next_offset += envelope_size;
2572            }
2573
2574            let next_out_of_line = decoder.next_out_of_line();
2575            let handles_before = decoder.remaining_handles();
2576            if let Some((inlined, num_bytes, num_handles)) =
2577                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2578            {
2579                let member_inline_size =
2580                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
2581                        decoder.context,
2582                    );
2583                if inlined != (member_inline_size <= 4) {
2584                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2585                }
2586                let inner_offset;
2587                let mut inner_depth = depth.clone();
2588                if inlined {
2589                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2590                    inner_offset = next_offset;
2591                } else {
2592                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2593                    inner_depth.increment()?;
2594                }
2595                let val_ref = self
2596                    .model
2597                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
2598                fidl::decode!(
2599                    fidl::encoding::BoundedString<128>,
2600                    D,
2601                    val_ref,
2602                    decoder,
2603                    inner_offset,
2604                    inner_depth
2605                )?;
2606                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2607                {
2608                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2609                }
2610                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2611                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2612                }
2613            }
2614
2615            next_offset += envelope_size;
2616            _next_ordinal_to_read += 1;
2617            if next_offset >= end_offset {
2618                return Ok(());
2619            }
2620
2621            // Decode unknown envelopes for gaps in ordinals.
2622            while _next_ordinal_to_read < 5 {
2623                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2624                _next_ordinal_to_read += 1;
2625                next_offset += envelope_size;
2626            }
2627
2628            let next_out_of_line = decoder.next_out_of_line();
2629            let handles_before = decoder.remaining_handles();
2630            if let Some((inlined, num_bytes, num_handles)) =
2631                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2632            {
2633                let member_inline_size = <fidl::encoding::Vector<OperatingMode, 16> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2634                if inlined != (member_inline_size <= 4) {
2635                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2636                }
2637                let inner_offset;
2638                let mut inner_depth = depth.clone();
2639                if inlined {
2640                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2641                    inner_offset = next_offset;
2642                } else {
2643                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2644                    inner_depth.increment()?;
2645                }
2646                let val_ref = self.supported_modes.get_or_insert_with(
2647                    || fidl::new_empty!(fidl::encoding::Vector<OperatingMode, 16>, D),
2648                );
2649                fidl::decode!(fidl::encoding::Vector<OperatingMode, 16>, D, val_ref, decoder, inner_offset, inner_depth)?;
2650                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2651                {
2652                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2653                }
2654                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2655                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2656                }
2657            }
2658
2659            next_offset += envelope_size;
2660            _next_ordinal_to_read += 1;
2661            if next_offset >= end_offset {
2662                return Ok(());
2663            }
2664
2665            // Decode unknown envelopes for gaps in ordinals.
2666            while _next_ordinal_to_read < 6 {
2667                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2668                _next_ordinal_to_read += 1;
2669                next_offset += envelope_size;
2670            }
2671
2672            let next_out_of_line = decoder.next_out_of_line();
2673            let handles_before = decoder.remaining_handles();
2674            if let Some((inlined, num_bytes, num_handles)) =
2675                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2676            {
2677                let member_inline_size =
2678                    <WatchOptions as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2679                if inlined != (member_inline_size <= 4) {
2680                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2681                }
2682                let inner_offset;
2683                let mut inner_depth = depth.clone();
2684                if inlined {
2685                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2686                    inner_offset = next_offset;
2687                } else {
2688                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2689                    inner_depth.increment()?;
2690                }
2691                let val_ref =
2692                    self.supported_options.get_or_insert_with(|| fidl::new_empty!(WatchOptions, D));
2693                fidl::decode!(WatchOptions, D, val_ref, decoder, inner_offset, inner_depth)?;
2694                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2695                {
2696                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2697                }
2698                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2699                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2700                }
2701            }
2702
2703            next_offset += envelope_size;
2704            _next_ordinal_to_read += 1;
2705            if next_offset >= end_offset {
2706                return Ok(());
2707            }
2708
2709            // Decode unknown envelopes for gaps in ordinals.
2710            while _next_ordinal_to_read < 7 {
2711                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2712                _next_ordinal_to_read += 1;
2713                next_offset += envelope_size;
2714            }
2715
2716            let next_out_of_line = decoder.next_out_of_line();
2717            let handles_before = decoder.remaining_handles();
2718            if let Some((inlined, num_bytes, num_handles)) =
2719                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2720            {
2721                let member_inline_size =
2722                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2723                if inlined != (member_inline_size <= 4) {
2724                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2725                }
2726                let inner_offset;
2727                let mut inner_depth = depth.clone();
2728                if inlined {
2729                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2730                    inner_offset = next_offset;
2731                } else {
2732                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2733                    inner_depth.increment()?;
2734                }
2735                let val_ref =
2736                    self.precharge_current_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
2737                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2738                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2739                {
2740                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2741                }
2742                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2743                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2744                }
2745            }
2746
2747            next_offset += envelope_size;
2748            _next_ordinal_to_read += 1;
2749            if next_offset >= end_offset {
2750                return Ok(());
2751            }
2752
2753            // Decode unknown envelopes for gaps in ordinals.
2754            while _next_ordinal_to_read < 8 {
2755                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2756                _next_ordinal_to_read += 1;
2757                next_offset += envelope_size;
2758            }
2759
2760            let next_out_of_line = decoder.next_out_of_line();
2761            let handles_before = decoder.remaining_handles();
2762            if let Some((inlined, num_bytes, num_handles)) =
2763                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2764            {
2765                let member_inline_size =
2766                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2767                if inlined != (member_inline_size <= 4) {
2768                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2769                }
2770                let inner_offset;
2771                let mut inner_depth = depth.clone();
2772                if inlined {
2773                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2774                    inner_offset = next_offset;
2775                } else {
2776                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2777                    inner_depth.increment()?;
2778                }
2779                let val_ref =
2780                    self.charge_term_current_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
2781                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2782                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2783                {
2784                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2785                }
2786                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2787                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2788                }
2789            }
2790
2791            next_offset += envelope_size;
2792            _next_ordinal_to_read += 1;
2793            if next_offset >= end_offset {
2794                return Ok(());
2795            }
2796
2797            // Decode unknown envelopes for gaps in ordinals.
2798            while _next_ordinal_to_read < 9 {
2799                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2800                _next_ordinal_to_read += 1;
2801                next_offset += envelope_size;
2802            }
2803
2804            let next_out_of_line = decoder.next_out_of_line();
2805            let handles_before = decoder.remaining_handles();
2806            if let Some((inlined, num_bytes, num_handles)) =
2807                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2808            {
2809                let member_inline_size =
2810                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2811                if inlined != (member_inline_size <= 4) {
2812                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2813                }
2814                let inner_offset;
2815                let mut inner_depth = depth.clone();
2816                if inlined {
2817                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2818                    inner_offset = next_offset;
2819                } else {
2820                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2821                    inner_depth.increment()?;
2822                }
2823                let val_ref =
2824                    self.recharge_voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
2825                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2826                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2827                {
2828                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2829                }
2830                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2831                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2832                }
2833            }
2834
2835            next_offset += envelope_size;
2836            _next_ordinal_to_read += 1;
2837            if next_offset >= end_offset {
2838                return Ok(());
2839            }
2840
2841            // Decode unknown envelopes for gaps in ordinals.
2842            while _next_ordinal_to_read < 10 {
2843                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2844                _next_ordinal_to_read += 1;
2845                next_offset += envelope_size;
2846            }
2847
2848            let next_out_of_line = decoder.next_out_of_line();
2849            let handles_before = decoder.remaining_handles();
2850            if let Some((inlined, num_bytes, num_handles)) =
2851                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2852            {
2853                let member_inline_size =
2854                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2855                if inlined != (member_inline_size <= 4) {
2856                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2857                }
2858                let inner_offset;
2859                let mut inner_depth = depth.clone();
2860                if inlined {
2861                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2862                    inner_offset = next_offset;
2863                } else {
2864                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2865                    inner_depth.increment()?;
2866                }
2867                let val_ref =
2868                    self.min_input_voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
2869                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2870                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2871                {
2872                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2873                }
2874                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2875                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2876                }
2877            }
2878
2879            next_offset += envelope_size;
2880            _next_ordinal_to_read += 1;
2881            if next_offset >= end_offset {
2882                return Ok(());
2883            }
2884
2885            // Decode unknown envelopes for gaps in ordinals.
2886            while _next_ordinal_to_read < 11 {
2887                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2888                _next_ordinal_to_read += 1;
2889                next_offset += envelope_size;
2890            }
2891
2892            let next_out_of_line = decoder.next_out_of_line();
2893            let handles_before = decoder.remaining_handles();
2894            if let Some((inlined, num_bytes, num_handles)) =
2895                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2896            {
2897                let member_inline_size =
2898                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2899                if inlined != (member_inline_size <= 4) {
2900                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2901                }
2902                let inner_offset;
2903                let mut inner_depth = depth.clone();
2904                if inlined {
2905                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2906                    inner_offset = next_offset;
2907                } else {
2908                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2909                    inner_depth.increment()?;
2910                }
2911                let val_ref =
2912                    self.max_input_voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
2913                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2914                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2915                {
2916                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2917                }
2918                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2919                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2920                }
2921            }
2922
2923            next_offset += envelope_size;
2924
2925            // Decode the remaining unknown envelopes.
2926            while next_offset < end_offset {
2927                _next_ordinal_to_read += 1;
2928                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2929                next_offset += envelope_size;
2930            }
2931
2932            Ok(())
2933        }
2934    }
2935
2936    impl Status {
2937        #[inline(always)]
2938        fn max_ordinal_present(&self) -> u64 {
2939            if let Some(_) = self.input_voltage_limit_uv {
2940                return 12;
2941            }
2942            if let Some(_) = self.charge_term_current_ua {
2943                return 11;
2944            }
2945            if let Some(_) = self.health {
2946                return 10;
2947            }
2948            if let Some(_) = self.source_type {
2949                return 9;
2950            }
2951            if let Some(_) = self.float_voltage_uv {
2952                return 8;
2953            }
2954            if let Some(_) = self.charge_current_limit_ua {
2955                return 7;
2956            }
2957            if let Some(_) = self.input_current_limit_ua {
2958                return 6;
2959            }
2960            if let Some(_) = self.charge_phase {
2961                return 5;
2962            }
2963            if let Some(_) = self.operating_mode {
2964                return 4;
2965            }
2966            if let Some(_) = self.input_current_ua {
2967                return 3;
2968            }
2969            if let Some(_) = self.input_voltage_uv {
2970                return 2;
2971            }
2972            if let Some(_) = self.online {
2973                return 1;
2974            }
2975            0
2976        }
2977    }
2978
2979    impl fidl::encoding::ValueTypeMarker for Status {
2980        type Borrowed<'a> = &'a Self;
2981        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2982            value
2983        }
2984    }
2985
2986    unsafe impl fidl::encoding::TypeMarker for Status {
2987        type Owned = Self;
2988
2989        #[inline(always)]
2990        fn inline_align(_context: fidl::encoding::Context) -> usize {
2991            8
2992        }
2993
2994        #[inline(always)]
2995        fn inline_size(_context: fidl::encoding::Context) -> usize {
2996            16
2997        }
2998    }
2999
3000    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Status, D> for &Status {
3001        unsafe fn encode(
3002            self,
3003            encoder: &mut fidl::encoding::Encoder<'_, D>,
3004            offset: usize,
3005            mut depth: fidl::encoding::Depth,
3006        ) -> fidl::Result<()> {
3007            encoder.debug_check_bounds::<Status>(offset);
3008            // Vector header
3009            let max_ordinal: u64 = self.max_ordinal_present();
3010            encoder.write_num(max_ordinal, offset);
3011            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3012            // Calling encoder.out_of_line_offset(0) is not allowed.
3013            if max_ordinal == 0 {
3014                return Ok(());
3015            }
3016            depth.increment()?;
3017            let envelope_size = 8;
3018            let bytes_len = max_ordinal as usize * envelope_size;
3019            #[allow(unused_variables)]
3020            let offset = encoder.out_of_line_offset(bytes_len);
3021            let mut _prev_end_offset: usize = 0;
3022            if 1 > max_ordinal {
3023                return Ok(());
3024            }
3025
3026            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3027            // are envelope_size bytes.
3028            let cur_offset: usize = (1 - 1) * envelope_size;
3029
3030            // Zero reserved fields.
3031            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3032
3033            // Safety:
3034            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3035            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3036            //   envelope_size bytes, there is always sufficient room.
3037            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3038                self.online.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3039                encoder,
3040                offset + cur_offset,
3041                depth,
3042            )?;
3043
3044            _prev_end_offset = cur_offset + envelope_size;
3045            if 2 > max_ordinal {
3046                return Ok(());
3047            }
3048
3049            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3050            // are envelope_size bytes.
3051            let cur_offset: usize = (2 - 1) * envelope_size;
3052
3053            // Zero reserved fields.
3054            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3055
3056            // Safety:
3057            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3058            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3059            //   envelope_size bytes, there is always sufficient room.
3060            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3061                self.input_voltage_uv
3062                    .as_ref()
3063                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3064                encoder,
3065                offset + cur_offset,
3066                depth,
3067            )?;
3068
3069            _prev_end_offset = cur_offset + envelope_size;
3070            if 3 > max_ordinal {
3071                return Ok(());
3072            }
3073
3074            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3075            // are envelope_size bytes.
3076            let cur_offset: usize = (3 - 1) * envelope_size;
3077
3078            // Zero reserved fields.
3079            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3080
3081            // Safety:
3082            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3083            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3084            //   envelope_size bytes, there is always sufficient room.
3085            fidl::encoding::encode_in_envelope_optional::<i32, D>(
3086                self.input_current_ua
3087                    .as_ref()
3088                    .map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
3089                encoder,
3090                offset + cur_offset,
3091                depth,
3092            )?;
3093
3094            _prev_end_offset = cur_offset + envelope_size;
3095            if 4 > max_ordinal {
3096                return Ok(());
3097            }
3098
3099            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3100            // are envelope_size bytes.
3101            let cur_offset: usize = (4 - 1) * envelope_size;
3102
3103            // Zero reserved fields.
3104            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3105
3106            // Safety:
3107            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3108            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3109            //   envelope_size bytes, there is always sufficient room.
3110            fidl::encoding::encode_in_envelope_optional::<OperatingMode, D>(
3111                self.operating_mode
3112                    .as_ref()
3113                    .map(<OperatingMode as fidl::encoding::ValueTypeMarker>::borrow),
3114                encoder,
3115                offset + cur_offset,
3116                depth,
3117            )?;
3118
3119            _prev_end_offset = cur_offset + envelope_size;
3120            if 5 > max_ordinal {
3121                return Ok(());
3122            }
3123
3124            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3125            // are envelope_size bytes.
3126            let cur_offset: usize = (5 - 1) * envelope_size;
3127
3128            // Zero reserved fields.
3129            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3130
3131            // Safety:
3132            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3133            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3134            //   envelope_size bytes, there is always sufficient room.
3135            fidl::encoding::encode_in_envelope_optional::<ChargePhase, D>(
3136                self.charge_phase
3137                    .as_ref()
3138                    .map(<ChargePhase as fidl::encoding::ValueTypeMarker>::borrow),
3139                encoder,
3140                offset + cur_offset,
3141                depth,
3142            )?;
3143
3144            _prev_end_offset = cur_offset + envelope_size;
3145            if 6 > max_ordinal {
3146                return Ok(());
3147            }
3148
3149            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3150            // are envelope_size bytes.
3151            let cur_offset: usize = (6 - 1) * envelope_size;
3152
3153            // Zero reserved fields.
3154            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3155
3156            // Safety:
3157            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3158            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3159            //   envelope_size bytes, there is always sufficient room.
3160            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3161                self.input_current_limit_ua
3162                    .as_ref()
3163                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3164                encoder,
3165                offset + cur_offset,
3166                depth,
3167            )?;
3168
3169            _prev_end_offset = cur_offset + envelope_size;
3170            if 7 > max_ordinal {
3171                return Ok(());
3172            }
3173
3174            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3175            // are envelope_size bytes.
3176            let cur_offset: usize = (7 - 1) * envelope_size;
3177
3178            // Zero reserved fields.
3179            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3180
3181            // Safety:
3182            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3183            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3184            //   envelope_size bytes, there is always sufficient room.
3185            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3186                self.charge_current_limit_ua
3187                    .as_ref()
3188                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3189                encoder,
3190                offset + cur_offset,
3191                depth,
3192            )?;
3193
3194            _prev_end_offset = cur_offset + envelope_size;
3195            if 8 > max_ordinal {
3196                return Ok(());
3197            }
3198
3199            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3200            // are envelope_size bytes.
3201            let cur_offset: usize = (8 - 1) * envelope_size;
3202
3203            // Zero reserved fields.
3204            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3205
3206            // Safety:
3207            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3208            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3209            //   envelope_size bytes, there is always sufficient room.
3210            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3211                self.float_voltage_uv
3212                    .as_ref()
3213                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3214                encoder,
3215                offset + cur_offset,
3216                depth,
3217            )?;
3218
3219            _prev_end_offset = cur_offset + envelope_size;
3220            if 9 > max_ordinal {
3221                return Ok(());
3222            }
3223
3224            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3225            // are envelope_size bytes.
3226            let cur_offset: usize = (9 - 1) * envelope_size;
3227
3228            // Zero reserved fields.
3229            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3230
3231            // Safety:
3232            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3233            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3234            //   envelope_size bytes, there is always sufficient room.
3235            fidl::encoding::encode_in_envelope_optional::<SourceType, D>(
3236                self.source_type
3237                    .as_ref()
3238                    .map(<SourceType as fidl::encoding::ValueTypeMarker>::borrow),
3239                encoder,
3240                offset + cur_offset,
3241                depth,
3242            )?;
3243
3244            _prev_end_offset = cur_offset + envelope_size;
3245            if 10 > max_ordinal {
3246                return Ok(());
3247            }
3248
3249            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3250            // are envelope_size bytes.
3251            let cur_offset: usize = (10 - 1) * envelope_size;
3252
3253            // Zero reserved fields.
3254            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3255
3256            // Safety:
3257            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3258            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3259            //   envelope_size bytes, there is always sufficient room.
3260            fidl::encoding::encode_in_envelope_optional::<Health, D>(
3261                self.health.as_ref().map(<Health as fidl::encoding::ValueTypeMarker>::borrow),
3262                encoder,
3263                offset + cur_offset,
3264                depth,
3265            )?;
3266
3267            _prev_end_offset = cur_offset + envelope_size;
3268            if 11 > max_ordinal {
3269                return Ok(());
3270            }
3271
3272            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3273            // are envelope_size bytes.
3274            let cur_offset: usize = (11 - 1) * envelope_size;
3275
3276            // Zero reserved fields.
3277            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3278
3279            // Safety:
3280            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3281            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3282            //   envelope_size bytes, there is always sufficient room.
3283            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3284                self.charge_term_current_ua
3285                    .as_ref()
3286                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3287                encoder,
3288                offset + cur_offset,
3289                depth,
3290            )?;
3291
3292            _prev_end_offset = cur_offset + envelope_size;
3293            if 12 > max_ordinal {
3294                return Ok(());
3295            }
3296
3297            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3298            // are envelope_size bytes.
3299            let cur_offset: usize = (12 - 1) * envelope_size;
3300
3301            // Zero reserved fields.
3302            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3303
3304            // Safety:
3305            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3306            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3307            //   envelope_size bytes, there is always sufficient room.
3308            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3309                self.input_voltage_limit_uv
3310                    .as_ref()
3311                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3312                encoder,
3313                offset + cur_offset,
3314                depth,
3315            )?;
3316
3317            _prev_end_offset = cur_offset + envelope_size;
3318
3319            Ok(())
3320        }
3321    }
3322
3323    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Status {
3324        #[inline(always)]
3325        fn new_empty() -> Self {
3326            Self::default()
3327        }
3328
3329        unsafe fn decode(
3330            &mut self,
3331            decoder: &mut fidl::encoding::Decoder<'_, D>,
3332            offset: usize,
3333            mut depth: fidl::encoding::Depth,
3334        ) -> fidl::Result<()> {
3335            decoder.debug_check_bounds::<Self>(offset);
3336            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3337                None => return Err(fidl::Error::NotNullable),
3338                Some(len) => len,
3339            };
3340            // Calling decoder.out_of_line_offset(0) is not allowed.
3341            if len == 0 {
3342                return Ok(());
3343            };
3344            depth.increment()?;
3345            let envelope_size = 8;
3346            let bytes_len = len * envelope_size;
3347            let offset = decoder.out_of_line_offset(bytes_len)?;
3348            // Decode the envelope for each type.
3349            let mut _next_ordinal_to_read = 0;
3350            let mut next_offset = offset;
3351            let end_offset = offset + bytes_len;
3352            _next_ordinal_to_read += 1;
3353            if next_offset >= end_offset {
3354                return Ok(());
3355            }
3356
3357            // Decode unknown envelopes for gaps in ordinals.
3358            while _next_ordinal_to_read < 1 {
3359                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3360                _next_ordinal_to_read += 1;
3361                next_offset += envelope_size;
3362            }
3363
3364            let next_out_of_line = decoder.next_out_of_line();
3365            let handles_before = decoder.remaining_handles();
3366            if let Some((inlined, num_bytes, num_handles)) =
3367                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3368            {
3369                let member_inline_size =
3370                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3371                if inlined != (member_inline_size <= 4) {
3372                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3373                }
3374                let inner_offset;
3375                let mut inner_depth = depth.clone();
3376                if inlined {
3377                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3378                    inner_offset = next_offset;
3379                } else {
3380                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3381                    inner_depth.increment()?;
3382                }
3383                let val_ref = self.online.get_or_insert_with(|| fidl::new_empty!(bool, D));
3384                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3385                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3386                {
3387                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3388                }
3389                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3390                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3391                }
3392            }
3393
3394            next_offset += envelope_size;
3395            _next_ordinal_to_read += 1;
3396            if next_offset >= end_offset {
3397                return Ok(());
3398            }
3399
3400            // Decode unknown envelopes for gaps in ordinals.
3401            while _next_ordinal_to_read < 2 {
3402                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3403                _next_ordinal_to_read += 1;
3404                next_offset += envelope_size;
3405            }
3406
3407            let next_out_of_line = decoder.next_out_of_line();
3408            let handles_before = decoder.remaining_handles();
3409            if let Some((inlined, num_bytes, num_handles)) =
3410                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3411            {
3412                let member_inline_size =
3413                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3414                if inlined != (member_inline_size <= 4) {
3415                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3416                }
3417                let inner_offset;
3418                let mut inner_depth = depth.clone();
3419                if inlined {
3420                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3421                    inner_offset = next_offset;
3422                } else {
3423                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3424                    inner_depth.increment()?;
3425                }
3426                let val_ref = self.input_voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
3427                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3428                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3429                {
3430                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3431                }
3432                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3433                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3434                }
3435            }
3436
3437            next_offset += envelope_size;
3438            _next_ordinal_to_read += 1;
3439            if next_offset >= end_offset {
3440                return Ok(());
3441            }
3442
3443            // Decode unknown envelopes for gaps in ordinals.
3444            while _next_ordinal_to_read < 3 {
3445                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3446                _next_ordinal_to_read += 1;
3447                next_offset += envelope_size;
3448            }
3449
3450            let next_out_of_line = decoder.next_out_of_line();
3451            let handles_before = decoder.remaining_handles();
3452            if let Some((inlined, num_bytes, num_handles)) =
3453                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3454            {
3455                let member_inline_size =
3456                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3457                if inlined != (member_inline_size <= 4) {
3458                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3459                }
3460                let inner_offset;
3461                let mut inner_depth = depth.clone();
3462                if inlined {
3463                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3464                    inner_offset = next_offset;
3465                } else {
3466                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3467                    inner_depth.increment()?;
3468                }
3469                let val_ref = self.input_current_ua.get_or_insert_with(|| fidl::new_empty!(i32, D));
3470                fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
3471                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3472                {
3473                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3474                }
3475                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3476                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3477                }
3478            }
3479
3480            next_offset += envelope_size;
3481            _next_ordinal_to_read += 1;
3482            if next_offset >= end_offset {
3483                return Ok(());
3484            }
3485
3486            // Decode unknown envelopes for gaps in ordinals.
3487            while _next_ordinal_to_read < 4 {
3488                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3489                _next_ordinal_to_read += 1;
3490                next_offset += envelope_size;
3491            }
3492
3493            let next_out_of_line = decoder.next_out_of_line();
3494            let handles_before = decoder.remaining_handles();
3495            if let Some((inlined, num_bytes, num_handles)) =
3496                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3497            {
3498                let member_inline_size =
3499                    <OperatingMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3500                if inlined != (member_inline_size <= 4) {
3501                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3502                }
3503                let inner_offset;
3504                let mut inner_depth = depth.clone();
3505                if inlined {
3506                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3507                    inner_offset = next_offset;
3508                } else {
3509                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3510                    inner_depth.increment()?;
3511                }
3512                let val_ref =
3513                    self.operating_mode.get_or_insert_with(|| fidl::new_empty!(OperatingMode, D));
3514                fidl::decode!(OperatingMode, D, val_ref, decoder, inner_offset, inner_depth)?;
3515                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3516                {
3517                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3518                }
3519                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3520                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3521                }
3522            }
3523
3524            next_offset += envelope_size;
3525            _next_ordinal_to_read += 1;
3526            if next_offset >= end_offset {
3527                return Ok(());
3528            }
3529
3530            // Decode unknown envelopes for gaps in ordinals.
3531            while _next_ordinal_to_read < 5 {
3532                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3533                _next_ordinal_to_read += 1;
3534                next_offset += envelope_size;
3535            }
3536
3537            let next_out_of_line = decoder.next_out_of_line();
3538            let handles_before = decoder.remaining_handles();
3539            if let Some((inlined, num_bytes, num_handles)) =
3540                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3541            {
3542                let member_inline_size =
3543                    <ChargePhase as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3544                if inlined != (member_inline_size <= 4) {
3545                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3546                }
3547                let inner_offset;
3548                let mut inner_depth = depth.clone();
3549                if inlined {
3550                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3551                    inner_offset = next_offset;
3552                } else {
3553                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3554                    inner_depth.increment()?;
3555                }
3556                let val_ref =
3557                    self.charge_phase.get_or_insert_with(|| fidl::new_empty!(ChargePhase, D));
3558                fidl::decode!(ChargePhase, D, val_ref, decoder, inner_offset, inner_depth)?;
3559                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3560                {
3561                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3562                }
3563                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3564                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3565                }
3566            }
3567
3568            next_offset += envelope_size;
3569            _next_ordinal_to_read += 1;
3570            if next_offset >= end_offset {
3571                return Ok(());
3572            }
3573
3574            // Decode unknown envelopes for gaps in ordinals.
3575            while _next_ordinal_to_read < 6 {
3576                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3577                _next_ordinal_to_read += 1;
3578                next_offset += envelope_size;
3579            }
3580
3581            let next_out_of_line = decoder.next_out_of_line();
3582            let handles_before = decoder.remaining_handles();
3583            if let Some((inlined, num_bytes, num_handles)) =
3584                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3585            {
3586                let member_inline_size =
3587                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3588                if inlined != (member_inline_size <= 4) {
3589                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3590                }
3591                let inner_offset;
3592                let mut inner_depth = depth.clone();
3593                if inlined {
3594                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3595                    inner_offset = next_offset;
3596                } else {
3597                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3598                    inner_depth.increment()?;
3599                }
3600                let val_ref =
3601                    self.input_current_limit_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
3602                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3603                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3604                {
3605                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3606                }
3607                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3608                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3609                }
3610            }
3611
3612            next_offset += envelope_size;
3613            _next_ordinal_to_read += 1;
3614            if next_offset >= end_offset {
3615                return Ok(());
3616            }
3617
3618            // Decode unknown envelopes for gaps in ordinals.
3619            while _next_ordinal_to_read < 7 {
3620                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3621                _next_ordinal_to_read += 1;
3622                next_offset += envelope_size;
3623            }
3624
3625            let next_out_of_line = decoder.next_out_of_line();
3626            let handles_before = decoder.remaining_handles();
3627            if let Some((inlined, num_bytes, num_handles)) =
3628                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3629            {
3630                let member_inline_size =
3631                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3632                if inlined != (member_inline_size <= 4) {
3633                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3634                }
3635                let inner_offset;
3636                let mut inner_depth = depth.clone();
3637                if inlined {
3638                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3639                    inner_offset = next_offset;
3640                } else {
3641                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3642                    inner_depth.increment()?;
3643                }
3644                let val_ref =
3645                    self.charge_current_limit_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
3646                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3647                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3648                {
3649                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3650                }
3651                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3652                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3653                }
3654            }
3655
3656            next_offset += envelope_size;
3657            _next_ordinal_to_read += 1;
3658            if next_offset >= end_offset {
3659                return Ok(());
3660            }
3661
3662            // Decode unknown envelopes for gaps in ordinals.
3663            while _next_ordinal_to_read < 8 {
3664                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3665                _next_ordinal_to_read += 1;
3666                next_offset += envelope_size;
3667            }
3668
3669            let next_out_of_line = decoder.next_out_of_line();
3670            let handles_before = decoder.remaining_handles();
3671            if let Some((inlined, num_bytes, num_handles)) =
3672                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3673            {
3674                let member_inline_size =
3675                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3676                if inlined != (member_inline_size <= 4) {
3677                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3678                }
3679                let inner_offset;
3680                let mut inner_depth = depth.clone();
3681                if inlined {
3682                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3683                    inner_offset = next_offset;
3684                } else {
3685                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3686                    inner_depth.increment()?;
3687                }
3688                let val_ref = self.float_voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
3689                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3690                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3691                {
3692                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3693                }
3694                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3695                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3696                }
3697            }
3698
3699            next_offset += envelope_size;
3700            _next_ordinal_to_read += 1;
3701            if next_offset >= end_offset {
3702                return Ok(());
3703            }
3704
3705            // Decode unknown envelopes for gaps in ordinals.
3706            while _next_ordinal_to_read < 9 {
3707                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3708                _next_ordinal_to_read += 1;
3709                next_offset += envelope_size;
3710            }
3711
3712            let next_out_of_line = decoder.next_out_of_line();
3713            let handles_before = decoder.remaining_handles();
3714            if let Some((inlined, num_bytes, num_handles)) =
3715                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3716            {
3717                let member_inline_size =
3718                    <SourceType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3719                if inlined != (member_inline_size <= 4) {
3720                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3721                }
3722                let inner_offset;
3723                let mut inner_depth = depth.clone();
3724                if inlined {
3725                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3726                    inner_offset = next_offset;
3727                } else {
3728                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3729                    inner_depth.increment()?;
3730                }
3731                let val_ref =
3732                    self.source_type.get_or_insert_with(|| fidl::new_empty!(SourceType, D));
3733                fidl::decode!(SourceType, D, val_ref, decoder, inner_offset, inner_depth)?;
3734                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3735                {
3736                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3737                }
3738                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3739                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3740                }
3741            }
3742
3743            next_offset += envelope_size;
3744            _next_ordinal_to_read += 1;
3745            if next_offset >= end_offset {
3746                return Ok(());
3747            }
3748
3749            // Decode unknown envelopes for gaps in ordinals.
3750            while _next_ordinal_to_read < 10 {
3751                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3752                _next_ordinal_to_read += 1;
3753                next_offset += envelope_size;
3754            }
3755
3756            let next_out_of_line = decoder.next_out_of_line();
3757            let handles_before = decoder.remaining_handles();
3758            if let Some((inlined, num_bytes, num_handles)) =
3759                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3760            {
3761                let member_inline_size =
3762                    <Health as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3763                if inlined != (member_inline_size <= 4) {
3764                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3765                }
3766                let inner_offset;
3767                let mut inner_depth = depth.clone();
3768                if inlined {
3769                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3770                    inner_offset = next_offset;
3771                } else {
3772                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3773                    inner_depth.increment()?;
3774                }
3775                let val_ref = self.health.get_or_insert_with(|| fidl::new_empty!(Health, D));
3776                fidl::decode!(Health, D, val_ref, decoder, inner_offset, inner_depth)?;
3777                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3778                {
3779                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3780                }
3781                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3782                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3783                }
3784            }
3785
3786            next_offset += envelope_size;
3787            _next_ordinal_to_read += 1;
3788            if next_offset >= end_offset {
3789                return Ok(());
3790            }
3791
3792            // Decode unknown envelopes for gaps in ordinals.
3793            while _next_ordinal_to_read < 11 {
3794                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3795                _next_ordinal_to_read += 1;
3796                next_offset += envelope_size;
3797            }
3798
3799            let next_out_of_line = decoder.next_out_of_line();
3800            let handles_before = decoder.remaining_handles();
3801            if let Some((inlined, num_bytes, num_handles)) =
3802                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3803            {
3804                let member_inline_size =
3805                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3806                if inlined != (member_inline_size <= 4) {
3807                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3808                }
3809                let inner_offset;
3810                let mut inner_depth = depth.clone();
3811                if inlined {
3812                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3813                    inner_offset = next_offset;
3814                } else {
3815                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3816                    inner_depth.increment()?;
3817                }
3818                let val_ref =
3819                    self.charge_term_current_ua.get_or_insert_with(|| fidl::new_empty!(u32, D));
3820                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3821                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3822                {
3823                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3824                }
3825                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3826                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3827                }
3828            }
3829
3830            next_offset += envelope_size;
3831            _next_ordinal_to_read += 1;
3832            if next_offset >= end_offset {
3833                return Ok(());
3834            }
3835
3836            // Decode unknown envelopes for gaps in ordinals.
3837            while _next_ordinal_to_read < 12 {
3838                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3839                _next_ordinal_to_read += 1;
3840                next_offset += envelope_size;
3841            }
3842
3843            let next_out_of_line = decoder.next_out_of_line();
3844            let handles_before = decoder.remaining_handles();
3845            if let Some((inlined, num_bytes, num_handles)) =
3846                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3847            {
3848                let member_inline_size =
3849                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3850                if inlined != (member_inline_size <= 4) {
3851                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3852                }
3853                let inner_offset;
3854                let mut inner_depth = depth.clone();
3855                if inlined {
3856                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3857                    inner_offset = next_offset;
3858                } else {
3859                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3860                    inner_depth.increment()?;
3861                }
3862                let val_ref =
3863                    self.input_voltage_limit_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
3864                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3865                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3866                {
3867                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3868                }
3869                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3870                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3871                }
3872            }
3873
3874            next_offset += envelope_size;
3875
3876            // Decode the remaining unknown envelopes.
3877            while next_offset < end_offset {
3878                _next_ordinal_to_read += 1;
3879                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3880                next_offset += envelope_size;
3881            }
3882
3883            Ok(())
3884        }
3885    }
3886
3887    impl WatchOptions {
3888        #[inline(always)]
3889        fn max_ordinal_present(&self) -> u64 {
3890            if let Some(_) = self.wake_on {
3891                return 2;
3892            }
3893            if let Some(_) = self.interest {
3894                return 1;
3895            }
3896            0
3897        }
3898    }
3899
3900    impl fidl::encoding::ValueTypeMarker for WatchOptions {
3901        type Borrowed<'a> = &'a Self;
3902        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3903            value
3904        }
3905    }
3906
3907    unsafe impl fidl::encoding::TypeMarker for WatchOptions {
3908        type Owned = Self;
3909
3910        #[inline(always)]
3911        fn inline_align(_context: fidl::encoding::Context) -> usize {
3912            8
3913        }
3914
3915        #[inline(always)]
3916        fn inline_size(_context: fidl::encoding::Context) -> usize {
3917            16
3918        }
3919    }
3920
3921    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WatchOptions, D>
3922        for &WatchOptions
3923    {
3924        unsafe fn encode(
3925            self,
3926            encoder: &mut fidl::encoding::Encoder<'_, D>,
3927            offset: usize,
3928            mut depth: fidl::encoding::Depth,
3929        ) -> fidl::Result<()> {
3930            encoder.debug_check_bounds::<WatchOptions>(offset);
3931            // Vector header
3932            let max_ordinal: u64 = self.max_ordinal_present();
3933            encoder.write_num(max_ordinal, offset);
3934            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3935            // Calling encoder.out_of_line_offset(0) is not allowed.
3936            if max_ordinal == 0 {
3937                return Ok(());
3938            }
3939            depth.increment()?;
3940            let envelope_size = 8;
3941            let bytes_len = max_ordinal as usize * envelope_size;
3942            #[allow(unused_variables)]
3943            let offset = encoder.out_of_line_offset(bytes_len);
3944            let mut _prev_end_offset: usize = 0;
3945            if 1 > max_ordinal {
3946                return Ok(());
3947            }
3948
3949            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3950            // are envelope_size bytes.
3951            let cur_offset: usize = (1 - 1) * envelope_size;
3952
3953            // Zero reserved fields.
3954            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3955
3956            // Safety:
3957            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3958            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3959            //   envelope_size bytes, there is always sufficient room.
3960            fidl::encoding::encode_in_envelope_optional::<Status, D>(
3961                self.interest.as_ref().map(<Status as fidl::encoding::ValueTypeMarker>::borrow),
3962                encoder,
3963                offset + cur_offset,
3964                depth,
3965            )?;
3966
3967            _prev_end_offset = cur_offset + envelope_size;
3968            if 2 > max_ordinal {
3969                return Ok(());
3970            }
3971
3972            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3973            // are envelope_size bytes.
3974            let cur_offset: usize = (2 - 1) * envelope_size;
3975
3976            // Zero reserved fields.
3977            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3978
3979            // Safety:
3980            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3981            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3982            //   envelope_size bytes, there is always sufficient room.
3983            fidl::encoding::encode_in_envelope_optional::<Status, D>(
3984                self.wake_on.as_ref().map(<Status as fidl::encoding::ValueTypeMarker>::borrow),
3985                encoder,
3986                offset + cur_offset,
3987                depth,
3988            )?;
3989
3990            _prev_end_offset = cur_offset + envelope_size;
3991
3992            Ok(())
3993        }
3994    }
3995
3996    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WatchOptions {
3997        #[inline(always)]
3998        fn new_empty() -> Self {
3999            Self::default()
4000        }
4001
4002        unsafe fn decode(
4003            &mut self,
4004            decoder: &mut fidl::encoding::Decoder<'_, D>,
4005            offset: usize,
4006            mut depth: fidl::encoding::Depth,
4007        ) -> fidl::Result<()> {
4008            decoder.debug_check_bounds::<Self>(offset);
4009            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4010                None => return Err(fidl::Error::NotNullable),
4011                Some(len) => len,
4012            };
4013            // Calling decoder.out_of_line_offset(0) is not allowed.
4014            if len == 0 {
4015                return Ok(());
4016            };
4017            depth.increment()?;
4018            let envelope_size = 8;
4019            let bytes_len = len * envelope_size;
4020            let offset = decoder.out_of_line_offset(bytes_len)?;
4021            // Decode the envelope for each type.
4022            let mut _next_ordinal_to_read = 0;
4023            let mut next_offset = offset;
4024            let end_offset = offset + bytes_len;
4025            _next_ordinal_to_read += 1;
4026            if next_offset >= end_offset {
4027                return Ok(());
4028            }
4029
4030            // Decode unknown envelopes for gaps in ordinals.
4031            while _next_ordinal_to_read < 1 {
4032                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4033                _next_ordinal_to_read += 1;
4034                next_offset += envelope_size;
4035            }
4036
4037            let next_out_of_line = decoder.next_out_of_line();
4038            let handles_before = decoder.remaining_handles();
4039            if let Some((inlined, num_bytes, num_handles)) =
4040                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4041            {
4042                let member_inline_size =
4043                    <Status as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4044                if inlined != (member_inline_size <= 4) {
4045                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4046                }
4047                let inner_offset;
4048                let mut inner_depth = depth.clone();
4049                if inlined {
4050                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4051                    inner_offset = next_offset;
4052                } else {
4053                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4054                    inner_depth.increment()?;
4055                }
4056                let val_ref = self.interest.get_or_insert_with(|| fidl::new_empty!(Status, D));
4057                fidl::decode!(Status, D, val_ref, decoder, inner_offset, inner_depth)?;
4058                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4059                {
4060                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4061                }
4062                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4063                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4064                }
4065            }
4066
4067            next_offset += envelope_size;
4068            _next_ordinal_to_read += 1;
4069            if next_offset >= end_offset {
4070                return Ok(());
4071            }
4072
4073            // Decode unknown envelopes for gaps in ordinals.
4074            while _next_ordinal_to_read < 2 {
4075                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4076                _next_ordinal_to_read += 1;
4077                next_offset += envelope_size;
4078            }
4079
4080            let next_out_of_line = decoder.next_out_of_line();
4081            let handles_before = decoder.remaining_handles();
4082            if let Some((inlined, num_bytes, num_handles)) =
4083                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4084            {
4085                let member_inline_size =
4086                    <Status as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4087                if inlined != (member_inline_size <= 4) {
4088                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4089                }
4090                let inner_offset;
4091                let mut inner_depth = depth.clone();
4092                if inlined {
4093                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4094                    inner_offset = next_offset;
4095                } else {
4096                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4097                    inner_depth.increment()?;
4098                }
4099                let val_ref = self.wake_on.get_or_insert_with(|| fidl::new_empty!(Status, D));
4100                fidl::decode!(Status, D, val_ref, decoder, inner_offset, inner_depth)?;
4101                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4102                {
4103                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4104                }
4105                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4106                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4107                }
4108            }
4109
4110            next_offset += envelope_size;
4111
4112            // Decode the remaining unknown envelopes.
4113            while next_offset < end_offset {
4114                _next_ordinal_to_read += 1;
4115                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4116                next_offset += envelope_size;
4117            }
4118
4119            Ok(())
4120        }
4121    }
4122}