Skip to main content

fidl_fuchsia_hardware_power_battery_common/
fidl_fuchsia_hardware_power_battery_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/// Errors returned by the battery protocol.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13pub enum Error {
14    /// An unexpected error occurred within the driver.
15    Internal,
16    /// The requested operation, field, or mode is not supported by this hardware.
17    NotSupported,
18    /// One or more arguments provided to the method were invalid, or a requested value lies
19    /// outside the range the hardware can program.
20    InvalidArgs,
21    /// Communication with the battery hardware failed (e.g. a bus transfer error).
22    Io,
23    /// A `Watch` call is already pending on this connection.
24    AlreadyWatching,
25    #[doc(hidden)]
26    __SourceBreaking { unknown_ordinal: u32 },
27}
28
29/// Pattern that matches an unknown `Error` member.
30#[macro_export]
31macro_rules! ErrorUnknown {
32    () => {
33        _
34    };
35}
36
37impl Error {
38    #[inline]
39    pub fn from_primitive(prim: u32) -> Option<Self> {
40        match prim {
41            1 => Some(Self::Internal),
42            2 => Some(Self::NotSupported),
43            3 => Some(Self::InvalidArgs),
44            4 => Some(Self::Io),
45            5 => Some(Self::AlreadyWatching),
46            _ => None,
47        }
48    }
49
50    #[inline]
51    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
52        match prim {
53            1 => Self::Internal,
54            2 => Self::NotSupported,
55            3 => Self::InvalidArgs,
56            4 => Self::Io,
57            5 => Self::AlreadyWatching,
58            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
59        }
60    }
61
62    #[inline]
63    pub fn unknown() -> Self {
64        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
65    }
66
67    #[inline]
68    pub const fn into_primitive(self) -> u32 {
69        match self {
70            Self::Internal => 1,
71            Self::NotSupported => 2,
72            Self::InvalidArgs => 3,
73            Self::Io => 4,
74            Self::AlreadyWatching => 5,
75            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
76        }
77    }
78
79    #[inline]
80    pub fn is_unknown(&self) -> bool {
81        match self {
82            Self::__SourceBreaking { unknown_ordinal: _ } => true,
83            _ => false,
84        }
85    }
86}
87
88/// Battery health and safety status, including JEITA temperature regions and fault conditions.
89///
90/// Each value describes whether the pack may be charged and whether it can still supply power to
91/// the system. Unless a value states otherwise, the battery can still supply power.
92#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
93pub enum HealthStatus {
94    /// Normal operating temperature and healthy battery condition.
95    /// Both charging and discharging are permitted.
96    Good,
97    /// Battery temperature is below safe charging threshold (charging prohibited).
98    /// The battery can still supply power, though available capacity and peak current are
99    /// typically reduced.
100    Cold,
101    /// Battery temperature is low (charging current or voltage may be restricted).
102    /// The battery can still supply power.
103    Cool,
104    /// Battery temperature is elevated (charging current or voltage may be restricted).
105    /// The battery can still supply power.
106    Warm,
107    /// Battery temperature exceeded safety threshold (charging prohibited).
108    /// The battery can usually still supply power, but hardware protection may open the discharge
109    /// path if the temperature continues to rise.
110    Hot,
111    /// Battery pack voltage is below operating threshold or cell is dead.
112    /// The battery cannot supply usable power to the system.
113    Dead,
114    /// Battery voltage exceeded hardware safety limit (charging prohibited).
115    /// The battery can still supply power; discharging is the expected recovery path.
116    OverVoltage,
117    /// Unspecified hardware or fuel gauge safety fault.
118    /// Whether the pack may be charged, or can supply power at all, is indeterminate.
119    UnspecifiedFailure,
120    #[doc(hidden)]
121    __SourceBreaking { unknown_ordinal: u32 },
122}
123
124/// Pattern that matches an unknown `HealthStatus` member.
125#[macro_export]
126macro_rules! HealthStatusUnknown {
127    () => {
128        _
129    };
130}
131
132impl HealthStatus {
133    #[inline]
134    pub fn from_primitive(prim: u32) -> Option<Self> {
135        match prim {
136            1 => Some(Self::Good),
137            2 => Some(Self::Cold),
138            3 => Some(Self::Cool),
139            4 => Some(Self::Warm),
140            5 => Some(Self::Hot),
141            6 => Some(Self::Dead),
142            7 => Some(Self::OverVoltage),
143            8 => Some(Self::UnspecifiedFailure),
144            _ => None,
145        }
146    }
147
148    #[inline]
149    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
150        match prim {
151            1 => Self::Good,
152            2 => Self::Cold,
153            3 => Self::Cool,
154            4 => Self::Warm,
155            5 => Self::Hot,
156            6 => Self::Dead,
157            7 => Self::OverVoltage,
158            8 => Self::UnspecifiedFailure,
159            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
160        }
161    }
162
163    #[inline]
164    pub fn unknown() -> Self {
165        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
166    }
167
168    #[inline]
169    pub const fn into_primitive(self) -> u32 {
170        match self {
171            Self::Good => 1,
172            Self::Cold => 2,
173            Self::Cool => 3,
174            Self::Warm => 4,
175            Self::Hot => 5,
176            Self::Dead => 6,
177            Self::OverVoltage => 7,
178            Self::UnspecifiedFailure => 8,
179            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
180        }
181    }
182
183    #[inline]
184    pub fn is_unknown(&self) -> bool {
185        match self {
186            Self::__SourceBreaking { unknown_ordinal: _ } => true,
187            _ => false,
188        }
189    }
190}
191
192#[derive(Clone, Debug, PartialEq)]
193pub struct BatteryConfigureWatchRequest {
194    pub options: WatchOptions,
195}
196
197impl fidl::Persistable for BatteryConfigureWatchRequest {}
198
199#[derive(Clone, Debug, PartialEq)]
200pub struct BatteryConfigureWatchResponse {
201    pub effective_options: WatchOptions,
202}
203
204impl fidl::Persistable for BatteryConfigureWatchResponse {}
205
206#[derive(Clone, Debug, PartialEq)]
207pub struct BatteryGetSpecResponse {
208    pub spec: Spec,
209}
210
211impl fidl::Persistable for BatteryGetSpecResponse {}
212
213#[derive(Clone, Debug, PartialEq)]
214pub struct BatteryGetStatusResponse {
215    pub status: Status,
216}
217
218impl fidl::Persistable for BatteryGetStatusResponse {}
219
220/// Static hardware characteristics and driver capabilities.
221#[derive(Clone, Debug, Default, PartialEq)]
222pub struct Spec {
223    /// Optional. Design capacity in microamp-hours.
224    /// Omitted if unsupported by hardware.
225    pub design_capacity_uah: Option<u32>,
226    /// Optional. Nominal design voltage in microvolts.
227    /// Omitted if unsupported by hardware.
228    pub design_voltage_uv: Option<u32>,
229    /// Optional. Informational battery chemistry description (e.g. "Li-ion", "LiFePO4", "NiMH").
230    /// Omitted if unknown or unprogrammed in hardware.
231    pub chemistry: Option<String>,
232    /// Optional. Informational battery model string or manufacturer part number.
233    /// Omitted if unknown or unprogrammed in hardware.
234    pub model: Option<String>,
235    /// Required. The interest and wake options supported by this driver/hardware.
236    ///
237    /// Drivers must populate this table so clients know which fields support active change
238    /// notifications. If omitted by the driver, clients should assume no active interrupt watching
239    /// is supported.
240    ///
241    /// - `supported_options.interest`: Telemetry fields that can actively trigger hanging-get watch
242    ///   notifications on change. Fields omitted are passive measurements that do not generate
243    ///   hardware interrupts; their freshest values are returned during active state changes or via
244    ///   [`Battery.GetStatus`].
245    /// - `supported_options.wake_on`: Telemetry fields capable of actively waking the system from
246    ///   suspend via hardware interrupt lines etc.
247    /// - `supported_options.max_interval`: Present if the server supports periodic sampling; its
248    ///   value is the shortest interval the server will honor.
249    /// - `supported_options.wake_on_max_interval`: True if the server can wake the system from
250    ///   suspend to take a `max_interval` sample.
251    pub supported_options: Option<WatchOptions>,
252    #[doc(hidden)]
253    pub __source_breaking: fidl::marker::SourceBreaking,
254}
255
256impl fidl::Persistable for Spec {}
257
258/// Primary telemetry snapshot from the battery fuel gauge.
259///
260/// All fields are optional. Each returned `Status` represents a complete snapshot, not a sparse
261/// delta; fields omitted by the driver indicate that the metric is unsupported by the hardware fuel
262/// gauge or currently unavailable/indeterminate.
263///
264/// NOTE: Some fields (e.g. instantaneous `voltage_uv` and `current_ua`) may be passive measurements
265/// that do not generate hardware interrupts on change. Refer to [`Spec.supported_options`] for the
266/// options that can actively trigger change notifications.
267#[derive(Clone, Debug, Default, PartialEq)]
268pub struct Status {
269    /// Whether the battery pack is physically present and connected.
270    /// If false, the battery is detached/missing. Omitted if presence is indeterminate.
271    pub present: Option<bool>,
272    /// Present terminal voltage in microvolts.
273    /// Omitted if unsupported by hardware or unavailable.
274    pub voltage_uv: Option<u32>,
275    /// Present current in microamps: positive (+) for charging, negative (-) for discharging.
276    /// Omitted if unsupported by hardware or unavailable.
277    pub current_ua: Option<i32>,
278    /// State of charge percentage in the range [0.0, 100.0].
279    /// Omitted if indeterminate or unsupported by hardware.
280    pub level_percent: Option<f32>,
281    /// Internal battery temperature in Celsius.
282    /// Omitted if temperature sensing is unsupported or unavailable.
283    pub temp_celsius: Option<f32>,
284    /// Estimated remaining usable capacity in microamp-hours.
285    /// Omitted if indeterminate or unsupported by hardware.
286    pub remaining_capacity_uah: Option<u32>,
287    /// Estimated full charge capacity in microamp-hours, reflecting pack aging.
288    /// Omitted if indeterminate or unsupported by hardware.
289    pub full_charge_capacity_uah: Option<u32>,
290    /// Health condition or safety trip status.
291    /// Omitted if health diagnostics are unsupported by hardware.
292    pub health: Option<HealthStatus>,
293    /// Total charge-discharge cycle count.
294    /// Omitted if cycle tracking is unsupported by hardware.
295    pub cycle_count: Option<u32>,
296    /// Estimated duration remaining until fully empty (discharging) or fully charged (charging).
297    /// Omitted if indeterminate, unsupported, or if the battery is idle.
298    pub time_remaining: Option<i64>,
299    #[doc(hidden)]
300    pub __source_breaking: fidl::marker::SourceBreaking,
301}
302
303impl fidl::Persistable for Status {}
304
305/// Configuration options for battery state watching.
306///
307/// `interest` and `wake_on` are optional masks: the actual field values within the `Status` table
308/// are ignored; only field presence (set vs. unset) determines the mask.
309///
310/// An absent mask means "use this field's default"; a present but empty mask means "no fields".
311/// The two defaults differ because the safe choice differs: `interest` defaults to everything the
312/// driver supports watching, so a client that never configures anything still makes progress,
313/// while `wake_on` defaults to nothing, since waking the system is a cost a client must opt into.
314#[derive(Clone, Debug, Default, PartialEq)]
315pub struct WatchOptions {
316    /// Fields the client wants to receive change notifications for.
317    /// Defaults to every field the driver supports watching, as reported by
318    /// `Spec.supported_options`. Pass an explicitly empty table to be notified only for the
319    /// fields named in `wake_on`.
320    pub interest: Option<Status>,
321    /// Fields that should actively wake the system from suspend.
322    /// Any field present in `wake_on` is implicitly included in `interest`.
323    /// Defaults to no fields: changes occurring during suspend are deferred until the next system
324    /// wakeup and do not wake the device.
325    pub wake_on: Option<Status>,
326    /// Maximum time between `Watch` responses. When set, the server completes a pending `Watch`
327    /// with a freshly sampled `Status` once this much time has passed since the previous response,
328    /// even if no field in `interest` changed.
329    /// The time is measured on the boot timeline, so time spent suspended counts towards it.
330    /// Defaults to absent: `Watch` only completes on changes.
331    /// Servers that do not support periodic sampling omit this field from the effective options
332    /// returned by `ConfigureWatch` and from `Spec.supported_options`. Servers may clamp the value,
333    /// and report the interval they will honor in the effective options.
334    /// Samples do not wake the system from suspend unless `wake_on_max_interval` is set: a sample
335    /// that falls due while the system is suspended is taken once the system resumes.
336    pub max_interval: Option<i64>,
337    /// Whether a `max_interval` sample that falls due while the system is suspended wakes the
338    /// system. Defaults to false; like `wake_on`, waking the system is a cost the client opts into.
339    /// Ignored if `max_interval` is absent.
340    /// Servers that cannot wake the system omit this field from the effective options returned by
341    /// `ConfigureWatch` and from `Spec.supported_options`.
342    pub wake_on_max_interval: Option<bool>,
343    #[doc(hidden)]
344    pub __source_breaking: fidl::marker::SourceBreaking,
345}
346
347impl fidl::Persistable for WatchOptions {}
348
349pub mod battery_ordinals {
350    pub const GET_SPEC: u64 = 0x235609229653654f;
351    pub const GET_STATUS: u64 = 0x2e0c03524d47095a;
352    pub const CONFIGURE_WATCH: u64 = 0x71fc28fbfc1f88c7;
353    pub const WATCH: u64 = 0x7386830cdd9e3390;
354}
355
356mod internal {
357    use super::*;
358    unsafe impl fidl::encoding::TypeMarker for Error {
359        type Owned = Self;
360
361        #[inline(always)]
362        fn inline_align(_context: fidl::encoding::Context) -> usize {
363            std::mem::align_of::<u32>()
364        }
365
366        #[inline(always)]
367        fn inline_size(_context: fidl::encoding::Context) -> usize {
368            std::mem::size_of::<u32>()
369        }
370
371        #[inline(always)]
372        fn encode_is_copy() -> bool {
373            false
374        }
375
376        #[inline(always)]
377        fn decode_is_copy() -> bool {
378            false
379        }
380    }
381
382    impl fidl::encoding::ValueTypeMarker for Error {
383        type Borrowed<'a> = Self;
384        #[inline(always)]
385        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
386            *value
387        }
388    }
389
390    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
391        #[inline]
392        unsafe fn encode(
393            self,
394            encoder: &mut fidl::encoding::Encoder<'_, D>,
395            offset: usize,
396            _depth: fidl::encoding::Depth,
397        ) -> fidl::Result<()> {
398            encoder.debug_check_bounds::<Self>(offset);
399            encoder.write_num(self.into_primitive(), offset);
400            Ok(())
401        }
402    }
403
404    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
405        #[inline(always)]
406        fn new_empty() -> Self {
407            Self::unknown()
408        }
409
410        #[inline]
411        unsafe fn decode(
412            &mut self,
413            decoder: &mut fidl::encoding::Decoder<'_, D>,
414            offset: usize,
415            _depth: fidl::encoding::Depth,
416        ) -> fidl::Result<()> {
417            decoder.debug_check_bounds::<Self>(offset);
418            let prim = decoder.read_num::<u32>(offset);
419
420            *self = Self::from_primitive_allow_unknown(prim);
421            Ok(())
422        }
423    }
424    unsafe impl fidl::encoding::TypeMarker for HealthStatus {
425        type Owned = Self;
426
427        #[inline(always)]
428        fn inline_align(_context: fidl::encoding::Context) -> usize {
429            std::mem::align_of::<u32>()
430        }
431
432        #[inline(always)]
433        fn inline_size(_context: fidl::encoding::Context) -> usize {
434            std::mem::size_of::<u32>()
435        }
436
437        #[inline(always)]
438        fn encode_is_copy() -> bool {
439            false
440        }
441
442        #[inline(always)]
443        fn decode_is_copy() -> bool {
444            false
445        }
446    }
447
448    impl fidl::encoding::ValueTypeMarker for HealthStatus {
449        type Borrowed<'a> = Self;
450        #[inline(always)]
451        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
452            *value
453        }
454    }
455
456    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for HealthStatus {
457        #[inline]
458        unsafe fn encode(
459            self,
460            encoder: &mut fidl::encoding::Encoder<'_, D>,
461            offset: usize,
462            _depth: fidl::encoding::Depth,
463        ) -> fidl::Result<()> {
464            encoder.debug_check_bounds::<Self>(offset);
465            encoder.write_num(self.into_primitive(), offset);
466            Ok(())
467        }
468    }
469
470    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HealthStatus {
471        #[inline(always)]
472        fn new_empty() -> Self {
473            Self::unknown()
474        }
475
476        #[inline]
477        unsafe fn decode(
478            &mut self,
479            decoder: &mut fidl::encoding::Decoder<'_, D>,
480            offset: usize,
481            _depth: fidl::encoding::Depth,
482        ) -> fidl::Result<()> {
483            decoder.debug_check_bounds::<Self>(offset);
484            let prim = decoder.read_num::<u32>(offset);
485
486            *self = Self::from_primitive_allow_unknown(prim);
487            Ok(())
488        }
489    }
490
491    impl fidl::encoding::ValueTypeMarker for BatteryConfigureWatchRequest {
492        type Borrowed<'a> = &'a Self;
493        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
494            value
495        }
496    }
497
498    unsafe impl fidl::encoding::TypeMarker for BatteryConfigureWatchRequest {
499        type Owned = Self;
500
501        #[inline(always)]
502        fn inline_align(_context: fidl::encoding::Context) -> usize {
503            8
504        }
505
506        #[inline(always)]
507        fn inline_size(_context: fidl::encoding::Context) -> usize {
508            16
509        }
510    }
511
512    unsafe impl<D: fidl::encoding::ResourceDialect>
513        fidl::encoding::Encode<BatteryConfigureWatchRequest, D> for &BatteryConfigureWatchRequest
514    {
515        #[inline]
516        unsafe fn encode(
517            self,
518            encoder: &mut fidl::encoding::Encoder<'_, D>,
519            offset: usize,
520            _depth: fidl::encoding::Depth,
521        ) -> fidl::Result<()> {
522            encoder.debug_check_bounds::<BatteryConfigureWatchRequest>(offset);
523            // Delegate to tuple encoding.
524            fidl::encoding::Encode::<BatteryConfigureWatchRequest, D>::encode(
525                (<WatchOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),),
526                encoder,
527                offset,
528                _depth,
529            )
530        }
531    }
532    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<WatchOptions, D>>
533        fidl::encoding::Encode<BatteryConfigureWatchRequest, D> for (T0,)
534    {
535        #[inline]
536        unsafe fn encode(
537            self,
538            encoder: &mut fidl::encoding::Encoder<'_, D>,
539            offset: usize,
540            depth: fidl::encoding::Depth,
541        ) -> fidl::Result<()> {
542            encoder.debug_check_bounds::<BatteryConfigureWatchRequest>(offset);
543            // Zero out padding regions. There's no need to apply masks
544            // because the unmasked parts will be overwritten by fields.
545            // Write the fields.
546            self.0.encode(encoder, offset + 0, depth)?;
547            Ok(())
548        }
549    }
550
551    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
552        for BatteryConfigureWatchRequest
553    {
554        #[inline(always)]
555        fn new_empty() -> Self {
556            Self { options: fidl::new_empty!(WatchOptions, D) }
557        }
558
559        #[inline]
560        unsafe fn decode(
561            &mut self,
562            decoder: &mut fidl::encoding::Decoder<'_, D>,
563            offset: usize,
564            _depth: fidl::encoding::Depth,
565        ) -> fidl::Result<()> {
566            decoder.debug_check_bounds::<Self>(offset);
567            // Verify that padding bytes are zero.
568            fidl::decode!(WatchOptions, D, &mut self.options, decoder, offset + 0, _depth)?;
569            Ok(())
570        }
571    }
572
573    impl fidl::encoding::ValueTypeMarker for BatteryConfigureWatchResponse {
574        type Borrowed<'a> = &'a Self;
575        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
576            value
577        }
578    }
579
580    unsafe impl fidl::encoding::TypeMarker for BatteryConfigureWatchResponse {
581        type Owned = Self;
582
583        #[inline(always)]
584        fn inline_align(_context: fidl::encoding::Context) -> usize {
585            8
586        }
587
588        #[inline(always)]
589        fn inline_size(_context: fidl::encoding::Context) -> usize {
590            16
591        }
592    }
593
594    unsafe impl<D: fidl::encoding::ResourceDialect>
595        fidl::encoding::Encode<BatteryConfigureWatchResponse, D>
596        for &BatteryConfigureWatchResponse
597    {
598        #[inline]
599        unsafe fn encode(
600            self,
601            encoder: &mut fidl::encoding::Encoder<'_, D>,
602            offset: usize,
603            _depth: fidl::encoding::Depth,
604        ) -> fidl::Result<()> {
605            encoder.debug_check_bounds::<BatteryConfigureWatchResponse>(offset);
606            // Delegate to tuple encoding.
607            fidl::encoding::Encode::<BatteryConfigureWatchResponse, D>::encode(
608                (<WatchOptions as fidl::encoding::ValueTypeMarker>::borrow(
609                    &self.effective_options,
610                ),),
611                encoder,
612                offset,
613                _depth,
614            )
615        }
616    }
617    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<WatchOptions, D>>
618        fidl::encoding::Encode<BatteryConfigureWatchResponse, D> for (T0,)
619    {
620        #[inline]
621        unsafe fn encode(
622            self,
623            encoder: &mut fidl::encoding::Encoder<'_, D>,
624            offset: usize,
625            depth: fidl::encoding::Depth,
626        ) -> fidl::Result<()> {
627            encoder.debug_check_bounds::<BatteryConfigureWatchResponse>(offset);
628            // Zero out padding regions. There's no need to apply masks
629            // because the unmasked parts will be overwritten by fields.
630            // Write the fields.
631            self.0.encode(encoder, offset + 0, depth)?;
632            Ok(())
633        }
634    }
635
636    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
637        for BatteryConfigureWatchResponse
638    {
639        #[inline(always)]
640        fn new_empty() -> Self {
641            Self { effective_options: fidl::new_empty!(WatchOptions, D) }
642        }
643
644        #[inline]
645        unsafe fn decode(
646            &mut self,
647            decoder: &mut fidl::encoding::Decoder<'_, D>,
648            offset: usize,
649            _depth: fidl::encoding::Depth,
650        ) -> fidl::Result<()> {
651            decoder.debug_check_bounds::<Self>(offset);
652            // Verify that padding bytes are zero.
653            fidl::decode!(
654                WatchOptions,
655                D,
656                &mut self.effective_options,
657                decoder,
658                offset + 0,
659                _depth
660            )?;
661            Ok(())
662        }
663    }
664
665    impl fidl::encoding::ValueTypeMarker for BatteryGetSpecResponse {
666        type Borrowed<'a> = &'a Self;
667        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
668            value
669        }
670    }
671
672    unsafe impl fidl::encoding::TypeMarker for BatteryGetSpecResponse {
673        type Owned = Self;
674
675        #[inline(always)]
676        fn inline_align(_context: fidl::encoding::Context) -> usize {
677            8
678        }
679
680        #[inline(always)]
681        fn inline_size(_context: fidl::encoding::Context) -> usize {
682            16
683        }
684    }
685
686    unsafe impl<D: fidl::encoding::ResourceDialect>
687        fidl::encoding::Encode<BatteryGetSpecResponse, D> for &BatteryGetSpecResponse
688    {
689        #[inline]
690        unsafe fn encode(
691            self,
692            encoder: &mut fidl::encoding::Encoder<'_, D>,
693            offset: usize,
694            _depth: fidl::encoding::Depth,
695        ) -> fidl::Result<()> {
696            encoder.debug_check_bounds::<BatteryGetSpecResponse>(offset);
697            // Delegate to tuple encoding.
698            fidl::encoding::Encode::<BatteryGetSpecResponse, D>::encode(
699                (<Spec as fidl::encoding::ValueTypeMarker>::borrow(&self.spec),),
700                encoder,
701                offset,
702                _depth,
703            )
704        }
705    }
706    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Spec, D>>
707        fidl::encoding::Encode<BatteryGetSpecResponse, D> for (T0,)
708    {
709        #[inline]
710        unsafe fn encode(
711            self,
712            encoder: &mut fidl::encoding::Encoder<'_, D>,
713            offset: usize,
714            depth: fidl::encoding::Depth,
715        ) -> fidl::Result<()> {
716            encoder.debug_check_bounds::<BatteryGetSpecResponse>(offset);
717            // Zero out padding regions. There's no need to apply masks
718            // because the unmasked parts will be overwritten by fields.
719            // Write the fields.
720            self.0.encode(encoder, offset + 0, depth)?;
721            Ok(())
722        }
723    }
724
725    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
726        for BatteryGetSpecResponse
727    {
728        #[inline(always)]
729        fn new_empty() -> Self {
730            Self { spec: fidl::new_empty!(Spec, D) }
731        }
732
733        #[inline]
734        unsafe fn decode(
735            &mut self,
736            decoder: &mut fidl::encoding::Decoder<'_, D>,
737            offset: usize,
738            _depth: fidl::encoding::Depth,
739        ) -> fidl::Result<()> {
740            decoder.debug_check_bounds::<Self>(offset);
741            // Verify that padding bytes are zero.
742            fidl::decode!(Spec, D, &mut self.spec, decoder, offset + 0, _depth)?;
743            Ok(())
744        }
745    }
746
747    impl fidl::encoding::ValueTypeMarker for BatteryGetStatusResponse {
748        type Borrowed<'a> = &'a Self;
749        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
750            value
751        }
752    }
753
754    unsafe impl fidl::encoding::TypeMarker for BatteryGetStatusResponse {
755        type Owned = Self;
756
757        #[inline(always)]
758        fn inline_align(_context: fidl::encoding::Context) -> usize {
759            8
760        }
761
762        #[inline(always)]
763        fn inline_size(_context: fidl::encoding::Context) -> usize {
764            16
765        }
766    }
767
768    unsafe impl<D: fidl::encoding::ResourceDialect>
769        fidl::encoding::Encode<BatteryGetStatusResponse, D> for &BatteryGetStatusResponse
770    {
771        #[inline]
772        unsafe fn encode(
773            self,
774            encoder: &mut fidl::encoding::Encoder<'_, D>,
775            offset: usize,
776            _depth: fidl::encoding::Depth,
777        ) -> fidl::Result<()> {
778            encoder.debug_check_bounds::<BatteryGetStatusResponse>(offset);
779            // Delegate to tuple encoding.
780            fidl::encoding::Encode::<BatteryGetStatusResponse, D>::encode(
781                (<Status as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
782                encoder,
783                offset,
784                _depth,
785            )
786        }
787    }
788    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Status, D>>
789        fidl::encoding::Encode<BatteryGetStatusResponse, D> for (T0,)
790    {
791        #[inline]
792        unsafe fn encode(
793            self,
794            encoder: &mut fidl::encoding::Encoder<'_, D>,
795            offset: usize,
796            depth: fidl::encoding::Depth,
797        ) -> fidl::Result<()> {
798            encoder.debug_check_bounds::<BatteryGetStatusResponse>(offset);
799            // Zero out padding regions. There's no need to apply masks
800            // because the unmasked parts will be overwritten by fields.
801            // Write the fields.
802            self.0.encode(encoder, offset + 0, depth)?;
803            Ok(())
804        }
805    }
806
807    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
808        for BatteryGetStatusResponse
809    {
810        #[inline(always)]
811        fn new_empty() -> Self {
812            Self { status: fidl::new_empty!(Status, D) }
813        }
814
815        #[inline]
816        unsafe fn decode(
817            &mut self,
818            decoder: &mut fidl::encoding::Decoder<'_, D>,
819            offset: usize,
820            _depth: fidl::encoding::Depth,
821        ) -> fidl::Result<()> {
822            decoder.debug_check_bounds::<Self>(offset);
823            // Verify that padding bytes are zero.
824            fidl::decode!(Status, D, &mut self.status, decoder, offset + 0, _depth)?;
825            Ok(())
826        }
827    }
828
829    impl Spec {
830        #[inline(always)]
831        fn max_ordinal_present(&self) -> u64 {
832            if let Some(_) = self.supported_options {
833                return 5;
834            }
835            if let Some(_) = self.model {
836                return 4;
837            }
838            if let Some(_) = self.chemistry {
839                return 3;
840            }
841            if let Some(_) = self.design_voltage_uv {
842                return 2;
843            }
844            if let Some(_) = self.design_capacity_uah {
845                return 1;
846            }
847            0
848        }
849    }
850
851    impl fidl::encoding::ValueTypeMarker for Spec {
852        type Borrowed<'a> = &'a Self;
853        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
854            value
855        }
856    }
857
858    unsafe impl fidl::encoding::TypeMarker for Spec {
859        type Owned = Self;
860
861        #[inline(always)]
862        fn inline_align(_context: fidl::encoding::Context) -> usize {
863            8
864        }
865
866        #[inline(always)]
867        fn inline_size(_context: fidl::encoding::Context) -> usize {
868            16
869        }
870    }
871
872    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Spec, D> for &Spec {
873        unsafe fn encode(
874            self,
875            encoder: &mut fidl::encoding::Encoder<'_, D>,
876            offset: usize,
877            mut depth: fidl::encoding::Depth,
878        ) -> fidl::Result<()> {
879            encoder.debug_check_bounds::<Spec>(offset);
880            // Vector header
881            let max_ordinal: u64 = self.max_ordinal_present();
882            encoder.write_num(max_ordinal, offset);
883            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
884            // Calling encoder.out_of_line_offset(0) is not allowed.
885            if max_ordinal == 0 {
886                return Ok(());
887            }
888            depth.increment()?;
889            let envelope_size = 8;
890            let bytes_len = max_ordinal as usize * envelope_size;
891            #[allow(unused_variables)]
892            let offset = encoder.out_of_line_offset(bytes_len);
893            let mut _prev_end_offset: usize = 0;
894            if 1 > max_ordinal {
895                return Ok(());
896            }
897
898            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
899            // are envelope_size bytes.
900            let cur_offset: usize = (1 - 1) * envelope_size;
901
902            // Zero reserved fields.
903            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
904
905            // Safety:
906            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
907            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
908            //   envelope_size bytes, there is always sufficient room.
909            fidl::encoding::encode_in_envelope_optional::<u32, D>(
910                self.design_capacity_uah
911                    .as_ref()
912                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
913                encoder,
914                offset + cur_offset,
915                depth,
916            )?;
917
918            _prev_end_offset = cur_offset + envelope_size;
919            if 2 > max_ordinal {
920                return Ok(());
921            }
922
923            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
924            // are envelope_size bytes.
925            let cur_offset: usize = (2 - 1) * envelope_size;
926
927            // Zero reserved fields.
928            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
929
930            // Safety:
931            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
932            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
933            //   envelope_size bytes, there is always sufficient room.
934            fidl::encoding::encode_in_envelope_optional::<u32, D>(
935                self.design_voltage_uv
936                    .as_ref()
937                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
938                encoder,
939                offset + cur_offset,
940                depth,
941            )?;
942
943            _prev_end_offset = cur_offset + envelope_size;
944            if 3 > max_ordinal {
945                return Ok(());
946            }
947
948            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
949            // are envelope_size bytes.
950            let cur_offset: usize = (3 - 1) * envelope_size;
951
952            // Zero reserved fields.
953            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
954
955            // Safety:
956            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
957            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
958            //   envelope_size bytes, there is always sufficient room.
959            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
960                self.chemistry.as_ref().map(
961                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
962                ),
963                encoder,
964                offset + cur_offset,
965                depth,
966            )?;
967
968            _prev_end_offset = cur_offset + envelope_size;
969            if 4 > max_ordinal {
970                return Ok(());
971            }
972
973            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
974            // are envelope_size bytes.
975            let cur_offset: usize = (4 - 1) * envelope_size;
976
977            // Zero reserved fields.
978            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
979
980            // Safety:
981            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
982            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
983            //   envelope_size bytes, there is always sufficient room.
984            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
985                self.model.as_ref().map(
986                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
987                ),
988                encoder,
989                offset + cur_offset,
990                depth,
991            )?;
992
993            _prev_end_offset = cur_offset + envelope_size;
994            if 5 > max_ordinal {
995                return Ok(());
996            }
997
998            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
999            // are envelope_size bytes.
1000            let cur_offset: usize = (5 - 1) * envelope_size;
1001
1002            // Zero reserved fields.
1003            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1004
1005            // Safety:
1006            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1007            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1008            //   envelope_size bytes, there is always sufficient room.
1009            fidl::encoding::encode_in_envelope_optional::<WatchOptions, D>(
1010                self.supported_options
1011                    .as_ref()
1012                    .map(<WatchOptions as fidl::encoding::ValueTypeMarker>::borrow),
1013                encoder,
1014                offset + cur_offset,
1015                depth,
1016            )?;
1017
1018            _prev_end_offset = cur_offset + envelope_size;
1019
1020            Ok(())
1021        }
1022    }
1023
1024    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Spec {
1025        #[inline(always)]
1026        fn new_empty() -> Self {
1027            Self::default()
1028        }
1029
1030        unsafe fn decode(
1031            &mut self,
1032            decoder: &mut fidl::encoding::Decoder<'_, D>,
1033            offset: usize,
1034            mut depth: fidl::encoding::Depth,
1035        ) -> fidl::Result<()> {
1036            decoder.debug_check_bounds::<Self>(offset);
1037            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1038                None => return Err(fidl::Error::NotNullable),
1039                Some(len) => len,
1040            };
1041            // Calling decoder.out_of_line_offset(0) is not allowed.
1042            if len == 0 {
1043                return Ok(());
1044            };
1045            depth.increment()?;
1046            let envelope_size = 8;
1047            let bytes_len = len * envelope_size;
1048            let offset = decoder.out_of_line_offset(bytes_len)?;
1049            // Decode the envelope for each type.
1050            let mut _next_ordinal_to_read = 0;
1051            let mut next_offset = offset;
1052            let end_offset = offset + bytes_len;
1053            _next_ordinal_to_read += 1;
1054            if next_offset >= end_offset {
1055                return Ok(());
1056            }
1057
1058            // Decode unknown envelopes for gaps in ordinals.
1059            while _next_ordinal_to_read < 1 {
1060                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1061                _next_ordinal_to_read += 1;
1062                next_offset += envelope_size;
1063            }
1064
1065            let next_out_of_line = decoder.next_out_of_line();
1066            let handles_before = decoder.remaining_handles();
1067            if let Some((inlined, num_bytes, num_handles)) =
1068                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1069            {
1070                let member_inline_size =
1071                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1072                if inlined != (member_inline_size <= 4) {
1073                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1074                }
1075                let inner_offset;
1076                let mut inner_depth = depth.clone();
1077                if inlined {
1078                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1079                    inner_offset = next_offset;
1080                } else {
1081                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1082                    inner_depth.increment()?;
1083                }
1084                let val_ref =
1085                    self.design_capacity_uah.get_or_insert_with(|| fidl::new_empty!(u32, D));
1086                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1087                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1088                {
1089                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1090                }
1091                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1092                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1093                }
1094            }
1095
1096            next_offset += envelope_size;
1097            _next_ordinal_to_read += 1;
1098            if next_offset >= end_offset {
1099                return Ok(());
1100            }
1101
1102            // Decode unknown envelopes for gaps in ordinals.
1103            while _next_ordinal_to_read < 2 {
1104                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1105                _next_ordinal_to_read += 1;
1106                next_offset += envelope_size;
1107            }
1108
1109            let next_out_of_line = decoder.next_out_of_line();
1110            let handles_before = decoder.remaining_handles();
1111            if let Some((inlined, num_bytes, num_handles)) =
1112                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1113            {
1114                let member_inline_size =
1115                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1116                if inlined != (member_inline_size <= 4) {
1117                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1118                }
1119                let inner_offset;
1120                let mut inner_depth = depth.clone();
1121                if inlined {
1122                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1123                    inner_offset = next_offset;
1124                } else {
1125                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1126                    inner_depth.increment()?;
1127                }
1128                let val_ref =
1129                    self.design_voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
1130                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1131                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1132                {
1133                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1134                }
1135                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1136                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1137                }
1138            }
1139
1140            next_offset += envelope_size;
1141            _next_ordinal_to_read += 1;
1142            if next_offset >= end_offset {
1143                return Ok(());
1144            }
1145
1146            // Decode unknown envelopes for gaps in ordinals.
1147            while _next_ordinal_to_read < 3 {
1148                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1149                _next_ordinal_to_read += 1;
1150                next_offset += envelope_size;
1151            }
1152
1153            let next_out_of_line = decoder.next_out_of_line();
1154            let handles_before = decoder.remaining_handles();
1155            if let Some((inlined, num_bytes, num_handles)) =
1156                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1157            {
1158                let member_inline_size =
1159                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
1160                        decoder.context,
1161                    );
1162                if inlined != (member_inline_size <= 4) {
1163                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1164                }
1165                let inner_offset;
1166                let mut inner_depth = depth.clone();
1167                if inlined {
1168                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1169                    inner_offset = next_offset;
1170                } else {
1171                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1172                    inner_depth.increment()?;
1173                }
1174                let val_ref = self
1175                    .chemistry
1176                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
1177                fidl::decode!(
1178                    fidl::encoding::BoundedString<128>,
1179                    D,
1180                    val_ref,
1181                    decoder,
1182                    inner_offset,
1183                    inner_depth
1184                )?;
1185                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1186                {
1187                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1188                }
1189                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1190                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1191                }
1192            }
1193
1194            next_offset += envelope_size;
1195            _next_ordinal_to_read += 1;
1196            if next_offset >= end_offset {
1197                return Ok(());
1198            }
1199
1200            // Decode unknown envelopes for gaps in ordinals.
1201            while _next_ordinal_to_read < 4 {
1202                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1203                _next_ordinal_to_read += 1;
1204                next_offset += envelope_size;
1205            }
1206
1207            let next_out_of_line = decoder.next_out_of_line();
1208            let handles_before = decoder.remaining_handles();
1209            if let Some((inlined, num_bytes, num_handles)) =
1210                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1211            {
1212                let member_inline_size =
1213                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
1214                        decoder.context,
1215                    );
1216                if inlined != (member_inline_size <= 4) {
1217                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1218                }
1219                let inner_offset;
1220                let mut inner_depth = depth.clone();
1221                if inlined {
1222                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1223                    inner_offset = next_offset;
1224                } else {
1225                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1226                    inner_depth.increment()?;
1227                }
1228                let val_ref = self
1229                    .model
1230                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
1231                fidl::decode!(
1232                    fidl::encoding::BoundedString<128>,
1233                    D,
1234                    val_ref,
1235                    decoder,
1236                    inner_offset,
1237                    inner_depth
1238                )?;
1239                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1240                {
1241                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1242                }
1243                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1244                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1245                }
1246            }
1247
1248            next_offset += envelope_size;
1249            _next_ordinal_to_read += 1;
1250            if next_offset >= end_offset {
1251                return Ok(());
1252            }
1253
1254            // Decode unknown envelopes for gaps in ordinals.
1255            while _next_ordinal_to_read < 5 {
1256                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1257                _next_ordinal_to_read += 1;
1258                next_offset += envelope_size;
1259            }
1260
1261            let next_out_of_line = decoder.next_out_of_line();
1262            let handles_before = decoder.remaining_handles();
1263            if let Some((inlined, num_bytes, num_handles)) =
1264                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1265            {
1266                let member_inline_size =
1267                    <WatchOptions as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1268                if inlined != (member_inline_size <= 4) {
1269                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1270                }
1271                let inner_offset;
1272                let mut inner_depth = depth.clone();
1273                if inlined {
1274                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1275                    inner_offset = next_offset;
1276                } else {
1277                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1278                    inner_depth.increment()?;
1279                }
1280                let val_ref =
1281                    self.supported_options.get_or_insert_with(|| fidl::new_empty!(WatchOptions, D));
1282                fidl::decode!(WatchOptions, D, val_ref, decoder, inner_offset, inner_depth)?;
1283                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1284                {
1285                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1286                }
1287                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1288                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1289                }
1290            }
1291
1292            next_offset += envelope_size;
1293
1294            // Decode the remaining unknown envelopes.
1295            while next_offset < end_offset {
1296                _next_ordinal_to_read += 1;
1297                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1298                next_offset += envelope_size;
1299            }
1300
1301            Ok(())
1302        }
1303    }
1304
1305    impl Status {
1306        #[inline(always)]
1307        fn max_ordinal_present(&self) -> u64 {
1308            if let Some(_) = self.time_remaining {
1309                return 10;
1310            }
1311            if let Some(_) = self.cycle_count {
1312                return 9;
1313            }
1314            if let Some(_) = self.health {
1315                return 8;
1316            }
1317            if let Some(_) = self.full_charge_capacity_uah {
1318                return 7;
1319            }
1320            if let Some(_) = self.remaining_capacity_uah {
1321                return 6;
1322            }
1323            if let Some(_) = self.temp_celsius {
1324                return 5;
1325            }
1326            if let Some(_) = self.level_percent {
1327                return 4;
1328            }
1329            if let Some(_) = self.current_ua {
1330                return 3;
1331            }
1332            if let Some(_) = self.voltage_uv {
1333                return 2;
1334            }
1335            if let Some(_) = self.present {
1336                return 1;
1337            }
1338            0
1339        }
1340    }
1341
1342    impl fidl::encoding::ValueTypeMarker for Status {
1343        type Borrowed<'a> = &'a Self;
1344        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1345            value
1346        }
1347    }
1348
1349    unsafe impl fidl::encoding::TypeMarker for Status {
1350        type Owned = Self;
1351
1352        #[inline(always)]
1353        fn inline_align(_context: fidl::encoding::Context) -> usize {
1354            8
1355        }
1356
1357        #[inline(always)]
1358        fn inline_size(_context: fidl::encoding::Context) -> usize {
1359            16
1360        }
1361    }
1362
1363    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Status, D> for &Status {
1364        unsafe fn encode(
1365            self,
1366            encoder: &mut fidl::encoding::Encoder<'_, D>,
1367            offset: usize,
1368            mut depth: fidl::encoding::Depth,
1369        ) -> fidl::Result<()> {
1370            encoder.debug_check_bounds::<Status>(offset);
1371            // Vector header
1372            let max_ordinal: u64 = self.max_ordinal_present();
1373            encoder.write_num(max_ordinal, offset);
1374            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1375            // Calling encoder.out_of_line_offset(0) is not allowed.
1376            if max_ordinal == 0 {
1377                return Ok(());
1378            }
1379            depth.increment()?;
1380            let envelope_size = 8;
1381            let bytes_len = max_ordinal as usize * envelope_size;
1382            #[allow(unused_variables)]
1383            let offset = encoder.out_of_line_offset(bytes_len);
1384            let mut _prev_end_offset: usize = 0;
1385            if 1 > max_ordinal {
1386                return Ok(());
1387            }
1388
1389            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1390            // are envelope_size bytes.
1391            let cur_offset: usize = (1 - 1) * envelope_size;
1392
1393            // Zero reserved fields.
1394            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1395
1396            // Safety:
1397            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1398            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1399            //   envelope_size bytes, there is always sufficient room.
1400            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1401                self.present.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1402                encoder,
1403                offset + cur_offset,
1404                depth,
1405            )?;
1406
1407            _prev_end_offset = cur_offset + envelope_size;
1408            if 2 > max_ordinal {
1409                return Ok(());
1410            }
1411
1412            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1413            // are envelope_size bytes.
1414            let cur_offset: usize = (2 - 1) * envelope_size;
1415
1416            // Zero reserved fields.
1417            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1418
1419            // Safety:
1420            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1421            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1422            //   envelope_size bytes, there is always sufficient room.
1423            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1424                self.voltage_uv.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1425                encoder,
1426                offset + cur_offset,
1427                depth,
1428            )?;
1429
1430            _prev_end_offset = cur_offset + envelope_size;
1431            if 3 > max_ordinal {
1432                return Ok(());
1433            }
1434
1435            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1436            // are envelope_size bytes.
1437            let cur_offset: usize = (3 - 1) * envelope_size;
1438
1439            // Zero reserved fields.
1440            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1441
1442            // Safety:
1443            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1444            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1445            //   envelope_size bytes, there is always sufficient room.
1446            fidl::encoding::encode_in_envelope_optional::<i32, D>(
1447                self.current_ua.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1448                encoder,
1449                offset + cur_offset,
1450                depth,
1451            )?;
1452
1453            _prev_end_offset = cur_offset + envelope_size;
1454            if 4 > max_ordinal {
1455                return Ok(());
1456            }
1457
1458            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1459            // are envelope_size bytes.
1460            let cur_offset: usize = (4 - 1) * envelope_size;
1461
1462            // Zero reserved fields.
1463            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1464
1465            // Safety:
1466            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1467            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1468            //   envelope_size bytes, there is always sufficient room.
1469            fidl::encoding::encode_in_envelope_optional::<f32, D>(
1470                self.level_percent.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
1471                encoder,
1472                offset + cur_offset,
1473                depth,
1474            )?;
1475
1476            _prev_end_offset = cur_offset + envelope_size;
1477            if 5 > max_ordinal {
1478                return Ok(());
1479            }
1480
1481            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1482            // are envelope_size bytes.
1483            let cur_offset: usize = (5 - 1) * envelope_size;
1484
1485            // Zero reserved fields.
1486            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1487
1488            // Safety:
1489            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1490            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1491            //   envelope_size bytes, there is always sufficient room.
1492            fidl::encoding::encode_in_envelope_optional::<f32, D>(
1493                self.temp_celsius.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
1494                encoder,
1495                offset + cur_offset,
1496                depth,
1497            )?;
1498
1499            _prev_end_offset = cur_offset + envelope_size;
1500            if 6 > max_ordinal {
1501                return Ok(());
1502            }
1503
1504            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1505            // are envelope_size bytes.
1506            let cur_offset: usize = (6 - 1) * envelope_size;
1507
1508            // Zero reserved fields.
1509            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1510
1511            // Safety:
1512            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1513            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1514            //   envelope_size bytes, there is always sufficient room.
1515            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1516                self.remaining_capacity_uah
1517                    .as_ref()
1518                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1519                encoder,
1520                offset + cur_offset,
1521                depth,
1522            )?;
1523
1524            _prev_end_offset = cur_offset + envelope_size;
1525            if 7 > max_ordinal {
1526                return Ok(());
1527            }
1528
1529            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1530            // are envelope_size bytes.
1531            let cur_offset: usize = (7 - 1) * envelope_size;
1532
1533            // Zero reserved fields.
1534            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1535
1536            // Safety:
1537            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1538            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1539            //   envelope_size bytes, there is always sufficient room.
1540            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1541                self.full_charge_capacity_uah
1542                    .as_ref()
1543                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1544                encoder,
1545                offset + cur_offset,
1546                depth,
1547            )?;
1548
1549            _prev_end_offset = cur_offset + envelope_size;
1550            if 8 > max_ordinal {
1551                return Ok(());
1552            }
1553
1554            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1555            // are envelope_size bytes.
1556            let cur_offset: usize = (8 - 1) * envelope_size;
1557
1558            // Zero reserved fields.
1559            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1560
1561            // Safety:
1562            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1563            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1564            //   envelope_size bytes, there is always sufficient room.
1565            fidl::encoding::encode_in_envelope_optional::<HealthStatus, D>(
1566                self.health.as_ref().map(<HealthStatus as fidl::encoding::ValueTypeMarker>::borrow),
1567                encoder,
1568                offset + cur_offset,
1569                depth,
1570            )?;
1571
1572            _prev_end_offset = cur_offset + envelope_size;
1573            if 9 > max_ordinal {
1574                return Ok(());
1575            }
1576
1577            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1578            // are envelope_size bytes.
1579            let cur_offset: usize = (9 - 1) * envelope_size;
1580
1581            // Zero reserved fields.
1582            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1583
1584            // Safety:
1585            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1586            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1587            //   envelope_size bytes, there is always sufficient room.
1588            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1589                self.cycle_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1590                encoder,
1591                offset + cur_offset,
1592                depth,
1593            )?;
1594
1595            _prev_end_offset = cur_offset + envelope_size;
1596            if 10 > max_ordinal {
1597                return Ok(());
1598            }
1599
1600            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1601            // are envelope_size bytes.
1602            let cur_offset: usize = (10 - 1) * envelope_size;
1603
1604            // Zero reserved fields.
1605            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1606
1607            // Safety:
1608            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1609            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1610            //   envelope_size bytes, there is always sufficient room.
1611            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1612                self.time_remaining.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1613                encoder,
1614                offset + cur_offset,
1615                depth,
1616            )?;
1617
1618            _prev_end_offset = cur_offset + envelope_size;
1619
1620            Ok(())
1621        }
1622    }
1623
1624    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Status {
1625        #[inline(always)]
1626        fn new_empty() -> Self {
1627            Self::default()
1628        }
1629
1630        unsafe fn decode(
1631            &mut self,
1632            decoder: &mut fidl::encoding::Decoder<'_, D>,
1633            offset: usize,
1634            mut depth: fidl::encoding::Depth,
1635        ) -> fidl::Result<()> {
1636            decoder.debug_check_bounds::<Self>(offset);
1637            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1638                None => return Err(fidl::Error::NotNullable),
1639                Some(len) => len,
1640            };
1641            // Calling decoder.out_of_line_offset(0) is not allowed.
1642            if len == 0 {
1643                return Ok(());
1644            };
1645            depth.increment()?;
1646            let envelope_size = 8;
1647            let bytes_len = len * envelope_size;
1648            let offset = decoder.out_of_line_offset(bytes_len)?;
1649            // Decode the envelope for each type.
1650            let mut _next_ordinal_to_read = 0;
1651            let mut next_offset = offset;
1652            let end_offset = offset + bytes_len;
1653            _next_ordinal_to_read += 1;
1654            if next_offset >= end_offset {
1655                return Ok(());
1656            }
1657
1658            // Decode unknown envelopes for gaps in ordinals.
1659            while _next_ordinal_to_read < 1 {
1660                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1661                _next_ordinal_to_read += 1;
1662                next_offset += envelope_size;
1663            }
1664
1665            let next_out_of_line = decoder.next_out_of_line();
1666            let handles_before = decoder.remaining_handles();
1667            if let Some((inlined, num_bytes, num_handles)) =
1668                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1669            {
1670                let member_inline_size =
1671                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1672                if inlined != (member_inline_size <= 4) {
1673                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1674                }
1675                let inner_offset;
1676                let mut inner_depth = depth.clone();
1677                if inlined {
1678                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1679                    inner_offset = next_offset;
1680                } else {
1681                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1682                    inner_depth.increment()?;
1683                }
1684                let val_ref = self.present.get_or_insert_with(|| fidl::new_empty!(bool, D));
1685                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1686                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1687                {
1688                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1689                }
1690                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1691                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1692                }
1693            }
1694
1695            next_offset += envelope_size;
1696            _next_ordinal_to_read += 1;
1697            if next_offset >= end_offset {
1698                return Ok(());
1699            }
1700
1701            // Decode unknown envelopes for gaps in ordinals.
1702            while _next_ordinal_to_read < 2 {
1703                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1704                _next_ordinal_to_read += 1;
1705                next_offset += envelope_size;
1706            }
1707
1708            let next_out_of_line = decoder.next_out_of_line();
1709            let handles_before = decoder.remaining_handles();
1710            if let Some((inlined, num_bytes, num_handles)) =
1711                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1712            {
1713                let member_inline_size =
1714                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1715                if inlined != (member_inline_size <= 4) {
1716                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1717                }
1718                let inner_offset;
1719                let mut inner_depth = depth.clone();
1720                if inlined {
1721                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1722                    inner_offset = next_offset;
1723                } else {
1724                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1725                    inner_depth.increment()?;
1726                }
1727                let val_ref = self.voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
1728                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1729                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1730                {
1731                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1732                }
1733                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1734                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1735                }
1736            }
1737
1738            next_offset += envelope_size;
1739            _next_ordinal_to_read += 1;
1740            if next_offset >= end_offset {
1741                return Ok(());
1742            }
1743
1744            // Decode unknown envelopes for gaps in ordinals.
1745            while _next_ordinal_to_read < 3 {
1746                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1747                _next_ordinal_to_read += 1;
1748                next_offset += envelope_size;
1749            }
1750
1751            let next_out_of_line = decoder.next_out_of_line();
1752            let handles_before = decoder.remaining_handles();
1753            if let Some((inlined, num_bytes, num_handles)) =
1754                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1755            {
1756                let member_inline_size =
1757                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1758                if inlined != (member_inline_size <= 4) {
1759                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1760                }
1761                let inner_offset;
1762                let mut inner_depth = depth.clone();
1763                if inlined {
1764                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1765                    inner_offset = next_offset;
1766                } else {
1767                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1768                    inner_depth.increment()?;
1769                }
1770                let val_ref = self.current_ua.get_or_insert_with(|| fidl::new_empty!(i32, D));
1771                fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
1772                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1773                {
1774                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1775                }
1776                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1777                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1778                }
1779            }
1780
1781            next_offset += envelope_size;
1782            _next_ordinal_to_read += 1;
1783            if next_offset >= end_offset {
1784                return Ok(());
1785            }
1786
1787            // Decode unknown envelopes for gaps in ordinals.
1788            while _next_ordinal_to_read < 4 {
1789                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1790                _next_ordinal_to_read += 1;
1791                next_offset += envelope_size;
1792            }
1793
1794            let next_out_of_line = decoder.next_out_of_line();
1795            let handles_before = decoder.remaining_handles();
1796            if let Some((inlined, num_bytes, num_handles)) =
1797                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1798            {
1799                let member_inline_size =
1800                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1801                if inlined != (member_inline_size <= 4) {
1802                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1803                }
1804                let inner_offset;
1805                let mut inner_depth = depth.clone();
1806                if inlined {
1807                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1808                    inner_offset = next_offset;
1809                } else {
1810                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1811                    inner_depth.increment()?;
1812                }
1813                let val_ref = self.level_percent.get_or_insert_with(|| fidl::new_empty!(f32, D));
1814                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
1815                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1816                {
1817                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1818                }
1819                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1820                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1821                }
1822            }
1823
1824            next_offset += envelope_size;
1825            _next_ordinal_to_read += 1;
1826            if next_offset >= end_offset {
1827                return Ok(());
1828            }
1829
1830            // Decode unknown envelopes for gaps in ordinals.
1831            while _next_ordinal_to_read < 5 {
1832                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1833                _next_ordinal_to_read += 1;
1834                next_offset += envelope_size;
1835            }
1836
1837            let next_out_of_line = decoder.next_out_of_line();
1838            let handles_before = decoder.remaining_handles();
1839            if let Some((inlined, num_bytes, num_handles)) =
1840                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1841            {
1842                let member_inline_size =
1843                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1844                if inlined != (member_inline_size <= 4) {
1845                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1846                }
1847                let inner_offset;
1848                let mut inner_depth = depth.clone();
1849                if inlined {
1850                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1851                    inner_offset = next_offset;
1852                } else {
1853                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1854                    inner_depth.increment()?;
1855                }
1856                let val_ref = self.temp_celsius.get_or_insert_with(|| fidl::new_empty!(f32, D));
1857                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
1858                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1859                {
1860                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1861                }
1862                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1863                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1864                }
1865            }
1866
1867            next_offset += envelope_size;
1868            _next_ordinal_to_read += 1;
1869            if next_offset >= end_offset {
1870                return Ok(());
1871            }
1872
1873            // Decode unknown envelopes for gaps in ordinals.
1874            while _next_ordinal_to_read < 6 {
1875                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1876                _next_ordinal_to_read += 1;
1877                next_offset += envelope_size;
1878            }
1879
1880            let next_out_of_line = decoder.next_out_of_line();
1881            let handles_before = decoder.remaining_handles();
1882            if let Some((inlined, num_bytes, num_handles)) =
1883                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1884            {
1885                let member_inline_size =
1886                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1887                if inlined != (member_inline_size <= 4) {
1888                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1889                }
1890                let inner_offset;
1891                let mut inner_depth = depth.clone();
1892                if inlined {
1893                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1894                    inner_offset = next_offset;
1895                } else {
1896                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1897                    inner_depth.increment()?;
1898                }
1899                let val_ref =
1900                    self.remaining_capacity_uah.get_or_insert_with(|| fidl::new_empty!(u32, D));
1901                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1902                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1903                {
1904                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1905                }
1906                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1907                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1908                }
1909            }
1910
1911            next_offset += envelope_size;
1912            _next_ordinal_to_read += 1;
1913            if next_offset >= end_offset {
1914                return Ok(());
1915            }
1916
1917            // Decode unknown envelopes for gaps in ordinals.
1918            while _next_ordinal_to_read < 7 {
1919                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1920                _next_ordinal_to_read += 1;
1921                next_offset += envelope_size;
1922            }
1923
1924            let next_out_of_line = decoder.next_out_of_line();
1925            let handles_before = decoder.remaining_handles();
1926            if let Some((inlined, num_bytes, num_handles)) =
1927                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1928            {
1929                let member_inline_size =
1930                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1931                if inlined != (member_inline_size <= 4) {
1932                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1933                }
1934                let inner_offset;
1935                let mut inner_depth = depth.clone();
1936                if inlined {
1937                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1938                    inner_offset = next_offset;
1939                } else {
1940                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1941                    inner_depth.increment()?;
1942                }
1943                let val_ref =
1944                    self.full_charge_capacity_uah.get_or_insert_with(|| fidl::new_empty!(u32, D));
1945                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1946                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1947                {
1948                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1949                }
1950                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1951                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1952                }
1953            }
1954
1955            next_offset += envelope_size;
1956            _next_ordinal_to_read += 1;
1957            if next_offset >= end_offset {
1958                return Ok(());
1959            }
1960
1961            // Decode unknown envelopes for gaps in ordinals.
1962            while _next_ordinal_to_read < 8 {
1963                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1964                _next_ordinal_to_read += 1;
1965                next_offset += envelope_size;
1966            }
1967
1968            let next_out_of_line = decoder.next_out_of_line();
1969            let handles_before = decoder.remaining_handles();
1970            if let Some((inlined, num_bytes, num_handles)) =
1971                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1972            {
1973                let member_inline_size =
1974                    <HealthStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1975                if inlined != (member_inline_size <= 4) {
1976                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1977                }
1978                let inner_offset;
1979                let mut inner_depth = depth.clone();
1980                if inlined {
1981                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1982                    inner_offset = next_offset;
1983                } else {
1984                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1985                    inner_depth.increment()?;
1986                }
1987                let val_ref = self.health.get_or_insert_with(|| fidl::new_empty!(HealthStatus, D));
1988                fidl::decode!(HealthStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
1989                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1990                {
1991                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1992                }
1993                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1994                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1995                }
1996            }
1997
1998            next_offset += envelope_size;
1999            _next_ordinal_to_read += 1;
2000            if next_offset >= end_offset {
2001                return Ok(());
2002            }
2003
2004            // Decode unknown envelopes for gaps in ordinals.
2005            while _next_ordinal_to_read < 9 {
2006                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2007                _next_ordinal_to_read += 1;
2008                next_offset += envelope_size;
2009            }
2010
2011            let next_out_of_line = decoder.next_out_of_line();
2012            let handles_before = decoder.remaining_handles();
2013            if let Some((inlined, num_bytes, num_handles)) =
2014                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2015            {
2016                let member_inline_size =
2017                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2018                if inlined != (member_inline_size <= 4) {
2019                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2020                }
2021                let inner_offset;
2022                let mut inner_depth = depth.clone();
2023                if inlined {
2024                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2025                    inner_offset = next_offset;
2026                } else {
2027                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2028                    inner_depth.increment()?;
2029                }
2030                let val_ref = self.cycle_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
2031                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2032                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2033                {
2034                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2035                }
2036                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2037                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2038                }
2039            }
2040
2041            next_offset += envelope_size;
2042            _next_ordinal_to_read += 1;
2043            if next_offset >= end_offset {
2044                return Ok(());
2045            }
2046
2047            // Decode unknown envelopes for gaps in ordinals.
2048            while _next_ordinal_to_read < 10 {
2049                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2050                _next_ordinal_to_read += 1;
2051                next_offset += envelope_size;
2052            }
2053
2054            let next_out_of_line = decoder.next_out_of_line();
2055            let handles_before = decoder.remaining_handles();
2056            if let Some((inlined, num_bytes, num_handles)) =
2057                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2058            {
2059                let member_inline_size =
2060                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2061                if inlined != (member_inline_size <= 4) {
2062                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2063                }
2064                let inner_offset;
2065                let mut inner_depth = depth.clone();
2066                if inlined {
2067                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2068                    inner_offset = next_offset;
2069                } else {
2070                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2071                    inner_depth.increment()?;
2072                }
2073                let val_ref = self.time_remaining.get_or_insert_with(|| fidl::new_empty!(i64, D));
2074                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
2075                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2076                {
2077                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2078                }
2079                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2080                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2081                }
2082            }
2083
2084            next_offset += envelope_size;
2085
2086            // Decode the remaining unknown envelopes.
2087            while next_offset < end_offset {
2088                _next_ordinal_to_read += 1;
2089                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2090                next_offset += envelope_size;
2091            }
2092
2093            Ok(())
2094        }
2095    }
2096
2097    impl WatchOptions {
2098        #[inline(always)]
2099        fn max_ordinal_present(&self) -> u64 {
2100            if let Some(_) = self.wake_on_max_interval {
2101                return 4;
2102            }
2103            if let Some(_) = self.max_interval {
2104                return 3;
2105            }
2106            if let Some(_) = self.wake_on {
2107                return 2;
2108            }
2109            if let Some(_) = self.interest {
2110                return 1;
2111            }
2112            0
2113        }
2114    }
2115
2116    impl fidl::encoding::ValueTypeMarker for WatchOptions {
2117        type Borrowed<'a> = &'a Self;
2118        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2119            value
2120        }
2121    }
2122
2123    unsafe impl fidl::encoding::TypeMarker for WatchOptions {
2124        type Owned = Self;
2125
2126        #[inline(always)]
2127        fn inline_align(_context: fidl::encoding::Context) -> usize {
2128            8
2129        }
2130
2131        #[inline(always)]
2132        fn inline_size(_context: fidl::encoding::Context) -> usize {
2133            16
2134        }
2135    }
2136
2137    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WatchOptions, D>
2138        for &WatchOptions
2139    {
2140        unsafe fn encode(
2141            self,
2142            encoder: &mut fidl::encoding::Encoder<'_, D>,
2143            offset: usize,
2144            mut depth: fidl::encoding::Depth,
2145        ) -> fidl::Result<()> {
2146            encoder.debug_check_bounds::<WatchOptions>(offset);
2147            // Vector header
2148            let max_ordinal: u64 = self.max_ordinal_present();
2149            encoder.write_num(max_ordinal, offset);
2150            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2151            // Calling encoder.out_of_line_offset(0) is not allowed.
2152            if max_ordinal == 0 {
2153                return Ok(());
2154            }
2155            depth.increment()?;
2156            let envelope_size = 8;
2157            let bytes_len = max_ordinal as usize * envelope_size;
2158            #[allow(unused_variables)]
2159            let offset = encoder.out_of_line_offset(bytes_len);
2160            let mut _prev_end_offset: usize = 0;
2161            if 1 > max_ordinal {
2162                return Ok(());
2163            }
2164
2165            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2166            // are envelope_size bytes.
2167            let cur_offset: usize = (1 - 1) * envelope_size;
2168
2169            // Zero reserved fields.
2170            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2171
2172            // Safety:
2173            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2174            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2175            //   envelope_size bytes, there is always sufficient room.
2176            fidl::encoding::encode_in_envelope_optional::<Status, D>(
2177                self.interest.as_ref().map(<Status as fidl::encoding::ValueTypeMarker>::borrow),
2178                encoder,
2179                offset + cur_offset,
2180                depth,
2181            )?;
2182
2183            _prev_end_offset = cur_offset + envelope_size;
2184            if 2 > max_ordinal {
2185                return Ok(());
2186            }
2187
2188            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2189            // are envelope_size bytes.
2190            let cur_offset: usize = (2 - 1) * envelope_size;
2191
2192            // Zero reserved fields.
2193            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2194
2195            // Safety:
2196            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2197            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2198            //   envelope_size bytes, there is always sufficient room.
2199            fidl::encoding::encode_in_envelope_optional::<Status, D>(
2200                self.wake_on.as_ref().map(<Status as fidl::encoding::ValueTypeMarker>::borrow),
2201                encoder,
2202                offset + cur_offset,
2203                depth,
2204            )?;
2205
2206            _prev_end_offset = cur_offset + envelope_size;
2207            if 3 > max_ordinal {
2208                return Ok(());
2209            }
2210
2211            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2212            // are envelope_size bytes.
2213            let cur_offset: usize = (3 - 1) * envelope_size;
2214
2215            // Zero reserved fields.
2216            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2217
2218            // Safety:
2219            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2220            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2221            //   envelope_size bytes, there is always sufficient room.
2222            fidl::encoding::encode_in_envelope_optional::<i64, D>(
2223                self.max_interval.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
2224                encoder,
2225                offset + cur_offset,
2226                depth,
2227            )?;
2228
2229            _prev_end_offset = cur_offset + envelope_size;
2230            if 4 > max_ordinal {
2231                return Ok(());
2232            }
2233
2234            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2235            // are envelope_size bytes.
2236            let cur_offset: usize = (4 - 1) * envelope_size;
2237
2238            // Zero reserved fields.
2239            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2240
2241            // Safety:
2242            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2243            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2244            //   envelope_size bytes, there is always sufficient room.
2245            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2246                self.wake_on_max_interval
2247                    .as_ref()
2248                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2249                encoder,
2250                offset + cur_offset,
2251                depth,
2252            )?;
2253
2254            _prev_end_offset = cur_offset + envelope_size;
2255
2256            Ok(())
2257        }
2258    }
2259
2260    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WatchOptions {
2261        #[inline(always)]
2262        fn new_empty() -> Self {
2263            Self::default()
2264        }
2265
2266        unsafe fn decode(
2267            &mut self,
2268            decoder: &mut fidl::encoding::Decoder<'_, D>,
2269            offset: usize,
2270            mut depth: fidl::encoding::Depth,
2271        ) -> fidl::Result<()> {
2272            decoder.debug_check_bounds::<Self>(offset);
2273            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2274                None => return Err(fidl::Error::NotNullable),
2275                Some(len) => len,
2276            };
2277            // Calling decoder.out_of_line_offset(0) is not allowed.
2278            if len == 0 {
2279                return Ok(());
2280            };
2281            depth.increment()?;
2282            let envelope_size = 8;
2283            let bytes_len = len * envelope_size;
2284            let offset = decoder.out_of_line_offset(bytes_len)?;
2285            // Decode the envelope for each type.
2286            let mut _next_ordinal_to_read = 0;
2287            let mut next_offset = offset;
2288            let end_offset = offset + bytes_len;
2289            _next_ordinal_to_read += 1;
2290            if next_offset >= end_offset {
2291                return Ok(());
2292            }
2293
2294            // Decode unknown envelopes for gaps in ordinals.
2295            while _next_ordinal_to_read < 1 {
2296                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2297                _next_ordinal_to_read += 1;
2298                next_offset += envelope_size;
2299            }
2300
2301            let next_out_of_line = decoder.next_out_of_line();
2302            let handles_before = decoder.remaining_handles();
2303            if let Some((inlined, num_bytes, num_handles)) =
2304                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2305            {
2306                let member_inline_size =
2307                    <Status as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2308                if inlined != (member_inline_size <= 4) {
2309                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2310                }
2311                let inner_offset;
2312                let mut inner_depth = depth.clone();
2313                if inlined {
2314                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2315                    inner_offset = next_offset;
2316                } else {
2317                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2318                    inner_depth.increment()?;
2319                }
2320                let val_ref = self.interest.get_or_insert_with(|| fidl::new_empty!(Status, D));
2321                fidl::decode!(Status, D, val_ref, decoder, inner_offset, inner_depth)?;
2322                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2323                {
2324                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2325                }
2326                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2327                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2328                }
2329            }
2330
2331            next_offset += envelope_size;
2332            _next_ordinal_to_read += 1;
2333            if next_offset >= end_offset {
2334                return Ok(());
2335            }
2336
2337            // Decode unknown envelopes for gaps in ordinals.
2338            while _next_ordinal_to_read < 2 {
2339                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2340                _next_ordinal_to_read += 1;
2341                next_offset += envelope_size;
2342            }
2343
2344            let next_out_of_line = decoder.next_out_of_line();
2345            let handles_before = decoder.remaining_handles();
2346            if let Some((inlined, num_bytes, num_handles)) =
2347                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2348            {
2349                let member_inline_size =
2350                    <Status as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2351                if inlined != (member_inline_size <= 4) {
2352                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2353                }
2354                let inner_offset;
2355                let mut inner_depth = depth.clone();
2356                if inlined {
2357                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2358                    inner_offset = next_offset;
2359                } else {
2360                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2361                    inner_depth.increment()?;
2362                }
2363                let val_ref = self.wake_on.get_or_insert_with(|| fidl::new_empty!(Status, D));
2364                fidl::decode!(Status, D, val_ref, decoder, inner_offset, inner_depth)?;
2365                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2366                {
2367                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2368                }
2369                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2370                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2371                }
2372            }
2373
2374            next_offset += envelope_size;
2375            _next_ordinal_to_read += 1;
2376            if next_offset >= end_offset {
2377                return Ok(());
2378            }
2379
2380            // Decode unknown envelopes for gaps in ordinals.
2381            while _next_ordinal_to_read < 3 {
2382                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2383                _next_ordinal_to_read += 1;
2384                next_offset += envelope_size;
2385            }
2386
2387            let next_out_of_line = decoder.next_out_of_line();
2388            let handles_before = decoder.remaining_handles();
2389            if let Some((inlined, num_bytes, num_handles)) =
2390                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2391            {
2392                let member_inline_size =
2393                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2394                if inlined != (member_inline_size <= 4) {
2395                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2396                }
2397                let inner_offset;
2398                let mut inner_depth = depth.clone();
2399                if inlined {
2400                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2401                    inner_offset = next_offset;
2402                } else {
2403                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2404                    inner_depth.increment()?;
2405                }
2406                let val_ref = self.max_interval.get_or_insert_with(|| fidl::new_empty!(i64, D));
2407                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
2408                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2409                {
2410                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2411                }
2412                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2413                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2414                }
2415            }
2416
2417            next_offset += envelope_size;
2418            _next_ordinal_to_read += 1;
2419            if next_offset >= end_offset {
2420                return Ok(());
2421            }
2422
2423            // Decode unknown envelopes for gaps in ordinals.
2424            while _next_ordinal_to_read < 4 {
2425                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2426                _next_ordinal_to_read += 1;
2427                next_offset += envelope_size;
2428            }
2429
2430            let next_out_of_line = decoder.next_out_of_line();
2431            let handles_before = decoder.remaining_handles();
2432            if let Some((inlined, num_bytes, num_handles)) =
2433                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2434            {
2435                let member_inline_size =
2436                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2437                if inlined != (member_inline_size <= 4) {
2438                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2439                }
2440                let inner_offset;
2441                let mut inner_depth = depth.clone();
2442                if inlined {
2443                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2444                    inner_offset = next_offset;
2445                } else {
2446                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2447                    inner_depth.increment()?;
2448                }
2449                let val_ref =
2450                    self.wake_on_max_interval.get_or_insert_with(|| fidl::new_empty!(bool, D));
2451                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2452                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2453                {
2454                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2455                }
2456                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2457                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2458                }
2459            }
2460
2461            next_offset += envelope_size;
2462
2463            // Decode the remaining unknown envelopes.
2464            while next_offset < end_offset {
2465                _next_ordinal_to_read += 1;
2466                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2467                next_offset += envelope_size;
2468            }
2469
2470            Ok(())
2471        }
2472    }
2473}