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