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/// High-level charging status for clients.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13pub enum ChargeStatus {
14    NotCharging,
15    Charging,
16    Discharging,
17    Full,
18    #[doc(hidden)]
19    __SourceBreaking {
20        unknown_ordinal: u32,
21    },
22}
23
24/// Pattern that matches an unknown `ChargeStatus` member.
25#[macro_export]
26macro_rules! ChargeStatusUnknown {
27    () => {
28        _
29    };
30}
31
32impl ChargeStatus {
33    #[inline]
34    pub fn from_primitive(prim: u32) -> Option<Self> {
35        match prim {
36            1 => Some(Self::NotCharging),
37            2 => Some(Self::Charging),
38            3 => Some(Self::Discharging),
39            4 => Some(Self::Full),
40            _ => None,
41        }
42    }
43
44    #[inline]
45    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
46        match prim {
47            1 => Self::NotCharging,
48            2 => Self::Charging,
49            3 => Self::Discharging,
50            4 => Self::Full,
51            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
52        }
53    }
54
55    #[inline]
56    pub fn unknown() -> Self {
57        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
58    }
59
60    #[inline]
61    pub const fn into_primitive(self) -> u32 {
62        match self {
63            Self::NotCharging => 1,
64            Self::Charging => 2,
65            Self::Discharging => 3,
66            Self::Full => 4,
67            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
68        }
69    }
70
71    #[inline]
72    pub fn is_unknown(&self) -> bool {
73        match self {
74            Self::__SourceBreaking { unknown_ordinal: _ } => true,
75            _ => false,
76        }
77    }
78}
79
80/// Battery health status.
81#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
82pub enum HealthStatus {
83    Good,
84    Cold,
85    Cool,
86    Warm,
87    Hot,
88    Dead,
89    OverVoltage,
90    UnspecifiedFailure,
91    #[doc(hidden)]
92    __SourceBreaking {
93        unknown_ordinal: u32,
94    },
95}
96
97/// Pattern that matches an unknown `HealthStatus` member.
98#[macro_export]
99macro_rules! HealthStatusUnknown {
100    () => {
101        _
102    };
103}
104
105impl HealthStatus {
106    #[inline]
107    pub fn from_primitive(prim: u32) -> Option<Self> {
108        match prim {
109            1 => Some(Self::Good),
110            2 => Some(Self::Cold),
111            3 => Some(Self::Cool),
112            4 => Some(Self::Warm),
113            5 => Some(Self::Hot),
114            6 => Some(Self::Dead),
115            7 => Some(Self::OverVoltage),
116            8 => Some(Self::UnspecifiedFailure),
117            _ => None,
118        }
119    }
120
121    #[inline]
122    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
123        match prim {
124            1 => Self::Good,
125            2 => Self::Cold,
126            3 => Self::Cool,
127            4 => Self::Warm,
128            5 => Self::Hot,
129            6 => Self::Dead,
130            7 => Self::OverVoltage,
131            8 => Self::UnspecifiedFailure,
132            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
133        }
134    }
135
136    #[inline]
137    pub fn unknown() -> Self {
138        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
139    }
140
141    #[inline]
142    pub const fn into_primitive(self) -> u32 {
143        match self {
144            Self::Good => 1,
145            Self::Cold => 2,
146            Self::Cool => 3,
147            Self::Warm => 4,
148            Self::Hot => 5,
149            Self::Dead => 6,
150            Self::OverVoltage => 7,
151            Self::UnspecifiedFailure => 8,
152            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
153        }
154    }
155
156    #[inline]
157    pub fn is_unknown(&self) -> bool {
158        match self {
159            Self::__SourceBreaking { unknown_ordinal: _ } => true,
160            _ => false,
161        }
162    }
163}
164
165#[derive(Clone, Debug, PartialEq)]
166pub struct BatteryGetSpecResponse {
167    pub spec: Spec,
168}
169
170impl fidl::Persistable for BatteryGetSpecResponse {}
171
172#[derive(Clone, Debug, PartialEq)]
173pub struct BatteryGetStatusResponse {
174    pub status: Status,
175}
176
177impl fidl::Persistable for BatteryGetStatusResponse {}
178
179/// Static hardware characteristics of the battery pack.
180#[derive(Clone, Debug, Default, PartialEq)]
181pub struct Spec {
182    /// Base spec from the underlying power source.
183    pub source_spec: Option<fidl_fuchsia_hardware_power_source_common::Spec>,
184    /// Design capacity in microamp-hours.
185    pub design_capacity_uah: Option<u32>,
186    /// Design voltage in microvolts.
187    pub design_voltage_uv: Option<u32>,
188    /// Battery chemistry description.
189    pub chemistry: Option<String>,
190    #[doc(hidden)]
191    pub __source_breaking: fidl::marker::SourceBreaking,
192}
193
194impl fidl::Persistable for Spec {}
195
196/// Dynamic status of the battery pack telemetry.
197#[derive(Clone, Debug, Default, PartialEq)]
198pub struct Status {
199    /// Base status from the underlying power source.
200    pub source_status: Option<fidl_fuchsia_hardware_power_source_common::Status>,
201    /// High-level charging status.
202    pub charge_status: Option<ChargeStatus>,
203    /// Battery level percentage (0.0 to 100.0).
204    pub level_percent: Option<f32>,
205    /// Remaining capacity in microamp-hours.
206    pub remaining_capacity_uah: Option<u32>,
207    /// Full charge capacity in microamp-hours.
208    pub full_charge_capacity_uah: Option<u32>,
209    /// Battery health status.
210    pub health: Option<HealthStatus>,
211    /// Temperature in milli-Celsius.
212    pub temperature_mc: Option<i32>,
213    /// Number of charge cycles.
214    pub cycle_count: Option<u32>,
215    /// Estimated time remaining until empty or full.
216    pub time_remaining: Option<i64>,
217    #[doc(hidden)]
218    pub __source_breaking: fidl::marker::SourceBreaking,
219}
220
221impl fidl::Persistable for Status {}
222
223pub mod battery_ordinals {
224    pub const GET_SPEC: u64 = 0x235609229653654f;
225    pub const GET_STATUS: u64 = 0x2e0c03524d47095a;
226    pub const WATCH: u64 = 0x7386830cdd9e3390;
227}
228
229mod internal {
230    use super::*;
231    unsafe impl fidl::encoding::TypeMarker for ChargeStatus {
232        type Owned = Self;
233
234        #[inline(always)]
235        fn inline_align(_context: fidl::encoding::Context) -> usize {
236            std::mem::align_of::<u32>()
237        }
238
239        #[inline(always)]
240        fn inline_size(_context: fidl::encoding::Context) -> usize {
241            std::mem::size_of::<u32>()
242        }
243
244        #[inline(always)]
245        fn encode_is_copy() -> bool {
246            false
247        }
248
249        #[inline(always)]
250        fn decode_is_copy() -> bool {
251            false
252        }
253    }
254
255    impl fidl::encoding::ValueTypeMarker for ChargeStatus {
256        type Borrowed<'a> = Self;
257        #[inline(always)]
258        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
259            *value
260        }
261    }
262
263    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ChargeStatus {
264        #[inline]
265        unsafe fn encode(
266            self,
267            encoder: &mut fidl::encoding::Encoder<'_, D>,
268            offset: usize,
269            _depth: fidl::encoding::Depth,
270        ) -> fidl::Result<()> {
271            encoder.debug_check_bounds::<Self>(offset);
272            encoder.write_num(self.into_primitive(), offset);
273            Ok(())
274        }
275    }
276
277    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChargeStatus {
278        #[inline(always)]
279        fn new_empty() -> Self {
280            Self::unknown()
281        }
282
283        #[inline]
284        unsafe fn decode(
285            &mut self,
286            decoder: &mut fidl::encoding::Decoder<'_, D>,
287            offset: usize,
288            _depth: fidl::encoding::Depth,
289        ) -> fidl::Result<()> {
290            decoder.debug_check_bounds::<Self>(offset);
291            let prim = decoder.read_num::<u32>(offset);
292
293            *self = Self::from_primitive_allow_unknown(prim);
294            Ok(())
295        }
296    }
297    unsafe impl fidl::encoding::TypeMarker for HealthStatus {
298        type Owned = Self;
299
300        #[inline(always)]
301        fn inline_align(_context: fidl::encoding::Context) -> usize {
302            std::mem::align_of::<u32>()
303        }
304
305        #[inline(always)]
306        fn inline_size(_context: fidl::encoding::Context) -> usize {
307            std::mem::size_of::<u32>()
308        }
309
310        #[inline(always)]
311        fn encode_is_copy() -> bool {
312            false
313        }
314
315        #[inline(always)]
316        fn decode_is_copy() -> bool {
317            false
318        }
319    }
320
321    impl fidl::encoding::ValueTypeMarker for HealthStatus {
322        type Borrowed<'a> = Self;
323        #[inline(always)]
324        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
325            *value
326        }
327    }
328
329    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for HealthStatus {
330        #[inline]
331        unsafe fn encode(
332            self,
333            encoder: &mut fidl::encoding::Encoder<'_, D>,
334            offset: usize,
335            _depth: fidl::encoding::Depth,
336        ) -> fidl::Result<()> {
337            encoder.debug_check_bounds::<Self>(offset);
338            encoder.write_num(self.into_primitive(), offset);
339            Ok(())
340        }
341    }
342
343    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HealthStatus {
344        #[inline(always)]
345        fn new_empty() -> Self {
346            Self::unknown()
347        }
348
349        #[inline]
350        unsafe fn decode(
351            &mut self,
352            decoder: &mut fidl::encoding::Decoder<'_, D>,
353            offset: usize,
354            _depth: fidl::encoding::Depth,
355        ) -> fidl::Result<()> {
356            decoder.debug_check_bounds::<Self>(offset);
357            let prim = decoder.read_num::<u32>(offset);
358
359            *self = Self::from_primitive_allow_unknown(prim);
360            Ok(())
361        }
362    }
363
364    impl fidl::encoding::ValueTypeMarker for BatteryGetSpecResponse {
365        type Borrowed<'a> = &'a Self;
366        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
367            value
368        }
369    }
370
371    unsafe impl fidl::encoding::TypeMarker for BatteryGetSpecResponse {
372        type Owned = Self;
373
374        #[inline(always)]
375        fn inline_align(_context: fidl::encoding::Context) -> usize {
376            8
377        }
378
379        #[inline(always)]
380        fn inline_size(_context: fidl::encoding::Context) -> usize {
381            16
382        }
383    }
384
385    unsafe impl<D: fidl::encoding::ResourceDialect>
386        fidl::encoding::Encode<BatteryGetSpecResponse, D> for &BatteryGetSpecResponse
387    {
388        #[inline]
389        unsafe fn encode(
390            self,
391            encoder: &mut fidl::encoding::Encoder<'_, D>,
392            offset: usize,
393            _depth: fidl::encoding::Depth,
394        ) -> fidl::Result<()> {
395            encoder.debug_check_bounds::<BatteryGetSpecResponse>(offset);
396            // Delegate to tuple encoding.
397            fidl::encoding::Encode::<BatteryGetSpecResponse, D>::encode(
398                (<Spec as fidl::encoding::ValueTypeMarker>::borrow(&self.spec),),
399                encoder,
400                offset,
401                _depth,
402            )
403        }
404    }
405    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Spec, D>>
406        fidl::encoding::Encode<BatteryGetSpecResponse, D> for (T0,)
407    {
408        #[inline]
409        unsafe fn encode(
410            self,
411            encoder: &mut fidl::encoding::Encoder<'_, D>,
412            offset: usize,
413            depth: fidl::encoding::Depth,
414        ) -> fidl::Result<()> {
415            encoder.debug_check_bounds::<BatteryGetSpecResponse>(offset);
416            // Zero out padding regions. There's no need to apply masks
417            // because the unmasked parts will be overwritten by fields.
418            // Write the fields.
419            self.0.encode(encoder, offset + 0, depth)?;
420            Ok(())
421        }
422    }
423
424    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
425        for BatteryGetSpecResponse
426    {
427        #[inline(always)]
428        fn new_empty() -> Self {
429            Self { spec: fidl::new_empty!(Spec, D) }
430        }
431
432        #[inline]
433        unsafe fn decode(
434            &mut self,
435            decoder: &mut fidl::encoding::Decoder<'_, D>,
436            offset: usize,
437            _depth: fidl::encoding::Depth,
438        ) -> fidl::Result<()> {
439            decoder.debug_check_bounds::<Self>(offset);
440            // Verify that padding bytes are zero.
441            fidl::decode!(Spec, D, &mut self.spec, decoder, offset + 0, _depth)?;
442            Ok(())
443        }
444    }
445
446    impl fidl::encoding::ValueTypeMarker for BatteryGetStatusResponse {
447        type Borrowed<'a> = &'a Self;
448        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
449            value
450        }
451    }
452
453    unsafe impl fidl::encoding::TypeMarker for BatteryGetStatusResponse {
454        type Owned = Self;
455
456        #[inline(always)]
457        fn inline_align(_context: fidl::encoding::Context) -> usize {
458            8
459        }
460
461        #[inline(always)]
462        fn inline_size(_context: fidl::encoding::Context) -> usize {
463            16
464        }
465    }
466
467    unsafe impl<D: fidl::encoding::ResourceDialect>
468        fidl::encoding::Encode<BatteryGetStatusResponse, D> for &BatteryGetStatusResponse
469    {
470        #[inline]
471        unsafe fn encode(
472            self,
473            encoder: &mut fidl::encoding::Encoder<'_, D>,
474            offset: usize,
475            _depth: fidl::encoding::Depth,
476        ) -> fidl::Result<()> {
477            encoder.debug_check_bounds::<BatteryGetStatusResponse>(offset);
478            // Delegate to tuple encoding.
479            fidl::encoding::Encode::<BatteryGetStatusResponse, D>::encode(
480                (<Status as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
481                encoder,
482                offset,
483                _depth,
484            )
485        }
486    }
487    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Status, D>>
488        fidl::encoding::Encode<BatteryGetStatusResponse, D> for (T0,)
489    {
490        #[inline]
491        unsafe fn encode(
492            self,
493            encoder: &mut fidl::encoding::Encoder<'_, D>,
494            offset: usize,
495            depth: fidl::encoding::Depth,
496        ) -> fidl::Result<()> {
497            encoder.debug_check_bounds::<BatteryGetStatusResponse>(offset);
498            // Zero out padding regions. There's no need to apply masks
499            // because the unmasked parts will be overwritten by fields.
500            // Write the fields.
501            self.0.encode(encoder, offset + 0, depth)?;
502            Ok(())
503        }
504    }
505
506    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
507        for BatteryGetStatusResponse
508    {
509        #[inline(always)]
510        fn new_empty() -> Self {
511            Self { status: fidl::new_empty!(Status, D) }
512        }
513
514        #[inline]
515        unsafe fn decode(
516            &mut self,
517            decoder: &mut fidl::encoding::Decoder<'_, D>,
518            offset: usize,
519            _depth: fidl::encoding::Depth,
520        ) -> fidl::Result<()> {
521            decoder.debug_check_bounds::<Self>(offset);
522            // Verify that padding bytes are zero.
523            fidl::decode!(Status, D, &mut self.status, decoder, offset + 0, _depth)?;
524            Ok(())
525        }
526    }
527
528    impl Spec {
529        #[inline(always)]
530        fn max_ordinal_present(&self) -> u64 {
531            if let Some(_) = self.chemistry {
532                return 4;
533            }
534            if let Some(_) = self.design_voltage_uv {
535                return 3;
536            }
537            if let Some(_) = self.design_capacity_uah {
538                return 2;
539            }
540            if let Some(_) = self.source_spec {
541                return 1;
542            }
543            0
544        }
545    }
546
547    impl fidl::encoding::ValueTypeMarker for Spec {
548        type Borrowed<'a> = &'a Self;
549        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
550            value
551        }
552    }
553
554    unsafe impl fidl::encoding::TypeMarker for Spec {
555        type Owned = Self;
556
557        #[inline(always)]
558        fn inline_align(_context: fidl::encoding::Context) -> usize {
559            8
560        }
561
562        #[inline(always)]
563        fn inline_size(_context: fidl::encoding::Context) -> usize {
564            16
565        }
566    }
567
568    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Spec, D> for &Spec {
569        unsafe fn encode(
570            self,
571            encoder: &mut fidl::encoding::Encoder<'_, D>,
572            offset: usize,
573            mut depth: fidl::encoding::Depth,
574        ) -> fidl::Result<()> {
575            encoder.debug_check_bounds::<Spec>(offset);
576            // Vector header
577            let max_ordinal: u64 = self.max_ordinal_present();
578            encoder.write_num(max_ordinal, offset);
579            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
580            // Calling encoder.out_of_line_offset(0) is not allowed.
581            if max_ordinal == 0 {
582                return Ok(());
583            }
584            depth.increment()?;
585            let envelope_size = 8;
586            let bytes_len = max_ordinal as usize * envelope_size;
587            #[allow(unused_variables)]
588            let offset = encoder.out_of_line_offset(bytes_len);
589            let mut _prev_end_offset: usize = 0;
590            if 1 > max_ordinal {
591                return Ok(());
592            }
593
594            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
595            // are envelope_size bytes.
596            let cur_offset: usize = (1 - 1) * envelope_size;
597
598            // Zero reserved fields.
599            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
600
601            // Safety:
602            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
603            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
604            //   envelope_size bytes, there is always sufficient room.
605            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_power_source_common::Spec, D>(
606            self.source_spec.as_ref().map(<fidl_fuchsia_hardware_power_source_common::Spec as fidl::encoding::ValueTypeMarker>::borrow),
607            encoder, offset + cur_offset, depth
608        )?;
609
610            _prev_end_offset = cur_offset + envelope_size;
611            if 2 > max_ordinal {
612                return Ok(());
613            }
614
615            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
616            // are envelope_size bytes.
617            let cur_offset: usize = (2 - 1) * envelope_size;
618
619            // Zero reserved fields.
620            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
621
622            // Safety:
623            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
624            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
625            //   envelope_size bytes, there is always sufficient room.
626            fidl::encoding::encode_in_envelope_optional::<u32, D>(
627                self.design_capacity_uah
628                    .as_ref()
629                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
630                encoder,
631                offset + cur_offset,
632                depth,
633            )?;
634
635            _prev_end_offset = cur_offset + envelope_size;
636            if 3 > max_ordinal {
637                return Ok(());
638            }
639
640            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
641            // are envelope_size bytes.
642            let cur_offset: usize = (3 - 1) * envelope_size;
643
644            // Zero reserved fields.
645            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
646
647            // Safety:
648            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
649            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
650            //   envelope_size bytes, there is always sufficient room.
651            fidl::encoding::encode_in_envelope_optional::<u32, D>(
652                self.design_voltage_uv
653                    .as_ref()
654                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
655                encoder,
656                offset + cur_offset,
657                depth,
658            )?;
659
660            _prev_end_offset = cur_offset + envelope_size;
661            if 4 > max_ordinal {
662                return Ok(());
663            }
664
665            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
666            // are envelope_size bytes.
667            let cur_offset: usize = (4 - 1) * envelope_size;
668
669            // Zero reserved fields.
670            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
671
672            // Safety:
673            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
674            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
675            //   envelope_size bytes, there is always sufficient room.
676            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedString, D>(
677                self.chemistry.as_ref().map(
678                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
679                ),
680                encoder,
681                offset + cur_offset,
682                depth,
683            )?;
684
685            _prev_end_offset = cur_offset + envelope_size;
686
687            Ok(())
688        }
689    }
690
691    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Spec {
692        #[inline(always)]
693        fn new_empty() -> Self {
694            Self::default()
695        }
696
697        unsafe fn decode(
698            &mut self,
699            decoder: &mut fidl::encoding::Decoder<'_, D>,
700            offset: usize,
701            mut depth: fidl::encoding::Depth,
702        ) -> fidl::Result<()> {
703            decoder.debug_check_bounds::<Self>(offset);
704            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
705                None => return Err(fidl::Error::NotNullable),
706                Some(len) => len,
707            };
708            // Calling decoder.out_of_line_offset(0) is not allowed.
709            if len == 0 {
710                return Ok(());
711            };
712            depth.increment()?;
713            let envelope_size = 8;
714            let bytes_len = len * envelope_size;
715            let offset = decoder.out_of_line_offset(bytes_len)?;
716            // Decode the envelope for each type.
717            let mut _next_ordinal_to_read = 0;
718            let mut next_offset = offset;
719            let end_offset = offset + bytes_len;
720            _next_ordinal_to_read += 1;
721            if next_offset >= end_offset {
722                return Ok(());
723            }
724
725            // Decode unknown envelopes for gaps in ordinals.
726            while _next_ordinal_to_read < 1 {
727                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
728                _next_ordinal_to_read += 1;
729                next_offset += envelope_size;
730            }
731
732            let next_out_of_line = decoder.next_out_of_line();
733            let handles_before = decoder.remaining_handles();
734            if let Some((inlined, num_bytes, num_handles)) =
735                fidl::encoding::decode_envelope_header(decoder, next_offset)?
736            {
737                let member_inline_size = <fidl_fuchsia_hardware_power_source_common::Spec as fidl::encoding::TypeMarker>::inline_size(decoder.context);
738                if inlined != (member_inline_size <= 4) {
739                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
740                }
741                let inner_offset;
742                let mut inner_depth = depth.clone();
743                if inlined {
744                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
745                    inner_offset = next_offset;
746                } else {
747                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
748                    inner_depth.increment()?;
749                }
750                let val_ref = self.source_spec.get_or_insert_with(|| {
751                    fidl::new_empty!(fidl_fuchsia_hardware_power_source_common::Spec, D)
752                });
753                fidl::decode!(
754                    fidl_fuchsia_hardware_power_source_common::Spec,
755                    D,
756                    val_ref,
757                    decoder,
758                    inner_offset,
759                    inner_depth
760                )?;
761                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
762                {
763                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
764                }
765                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
766                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
767                }
768            }
769
770            next_offset += envelope_size;
771            _next_ordinal_to_read += 1;
772            if next_offset >= end_offset {
773                return Ok(());
774            }
775
776            // Decode unknown envelopes for gaps in ordinals.
777            while _next_ordinal_to_read < 2 {
778                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
779                _next_ordinal_to_read += 1;
780                next_offset += envelope_size;
781            }
782
783            let next_out_of_line = decoder.next_out_of_line();
784            let handles_before = decoder.remaining_handles();
785            if let Some((inlined, num_bytes, num_handles)) =
786                fidl::encoding::decode_envelope_header(decoder, next_offset)?
787            {
788                let member_inline_size =
789                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
790                if inlined != (member_inline_size <= 4) {
791                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
792                }
793                let inner_offset;
794                let mut inner_depth = depth.clone();
795                if inlined {
796                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
797                    inner_offset = next_offset;
798                } else {
799                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
800                    inner_depth.increment()?;
801                }
802                let val_ref =
803                    self.design_capacity_uah.get_or_insert_with(|| fidl::new_empty!(u32, D));
804                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
805                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
806                {
807                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
808                }
809                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
810                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
811                }
812            }
813
814            next_offset += envelope_size;
815            _next_ordinal_to_read += 1;
816            if next_offset >= end_offset {
817                return Ok(());
818            }
819
820            // Decode unknown envelopes for gaps in ordinals.
821            while _next_ordinal_to_read < 3 {
822                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
823                _next_ordinal_to_read += 1;
824                next_offset += envelope_size;
825            }
826
827            let next_out_of_line = decoder.next_out_of_line();
828            let handles_before = decoder.remaining_handles();
829            if let Some((inlined, num_bytes, num_handles)) =
830                fidl::encoding::decode_envelope_header(decoder, next_offset)?
831            {
832                let member_inline_size =
833                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
834                if inlined != (member_inline_size <= 4) {
835                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
836                }
837                let inner_offset;
838                let mut inner_depth = depth.clone();
839                if inlined {
840                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
841                    inner_offset = next_offset;
842                } else {
843                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
844                    inner_depth.increment()?;
845                }
846                let val_ref =
847                    self.design_voltage_uv.get_or_insert_with(|| fidl::new_empty!(u32, D));
848                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
849                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
850                {
851                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
852                }
853                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
854                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
855                }
856            }
857
858            next_offset += envelope_size;
859            _next_ordinal_to_read += 1;
860            if next_offset >= end_offset {
861                return Ok(());
862            }
863
864            // Decode unknown envelopes for gaps in ordinals.
865            while _next_ordinal_to_read < 4 {
866                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
867                _next_ordinal_to_read += 1;
868                next_offset += envelope_size;
869            }
870
871            let next_out_of_line = decoder.next_out_of_line();
872            let handles_before = decoder.remaining_handles();
873            if let Some((inlined, num_bytes, num_handles)) =
874                fidl::encoding::decode_envelope_header(decoder, next_offset)?
875            {
876                let member_inline_size =
877                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
878                        decoder.context,
879                    );
880                if inlined != (member_inline_size <= 4) {
881                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
882                }
883                let inner_offset;
884                let mut inner_depth = depth.clone();
885                if inlined {
886                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
887                    inner_offset = next_offset;
888                } else {
889                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
890                    inner_depth.increment()?;
891                }
892                let val_ref = self
893                    .chemistry
894                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedString, D));
895                fidl::decode!(
896                    fidl::encoding::UnboundedString,
897                    D,
898                    val_ref,
899                    decoder,
900                    inner_offset,
901                    inner_depth
902                )?;
903                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
904                {
905                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
906                }
907                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
908                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
909                }
910            }
911
912            next_offset += envelope_size;
913
914            // Decode the remaining unknown envelopes.
915            while next_offset < end_offset {
916                _next_ordinal_to_read += 1;
917                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
918                next_offset += envelope_size;
919            }
920
921            Ok(())
922        }
923    }
924
925    impl Status {
926        #[inline(always)]
927        fn max_ordinal_present(&self) -> u64 {
928            if let Some(_) = self.time_remaining {
929                return 9;
930            }
931            if let Some(_) = self.cycle_count {
932                return 8;
933            }
934            if let Some(_) = self.temperature_mc {
935                return 7;
936            }
937            if let Some(_) = self.health {
938                return 6;
939            }
940            if let Some(_) = self.full_charge_capacity_uah {
941                return 5;
942            }
943            if let Some(_) = self.remaining_capacity_uah {
944                return 4;
945            }
946            if let Some(_) = self.level_percent {
947                return 3;
948            }
949            if let Some(_) = self.charge_status {
950                return 2;
951            }
952            if let Some(_) = self.source_status {
953                return 1;
954            }
955            0
956        }
957    }
958
959    impl fidl::encoding::ValueTypeMarker for Status {
960        type Borrowed<'a> = &'a Self;
961        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
962            value
963        }
964    }
965
966    unsafe impl fidl::encoding::TypeMarker for Status {
967        type Owned = Self;
968
969        #[inline(always)]
970        fn inline_align(_context: fidl::encoding::Context) -> usize {
971            8
972        }
973
974        #[inline(always)]
975        fn inline_size(_context: fidl::encoding::Context) -> usize {
976            16
977        }
978    }
979
980    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Status, D> for &Status {
981        unsafe fn encode(
982            self,
983            encoder: &mut fidl::encoding::Encoder<'_, D>,
984            offset: usize,
985            mut depth: fidl::encoding::Depth,
986        ) -> fidl::Result<()> {
987            encoder.debug_check_bounds::<Status>(offset);
988            // Vector header
989            let max_ordinal: u64 = self.max_ordinal_present();
990            encoder.write_num(max_ordinal, offset);
991            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
992            // Calling encoder.out_of_line_offset(0) is not allowed.
993            if max_ordinal == 0 {
994                return Ok(());
995            }
996            depth.increment()?;
997            let envelope_size = 8;
998            let bytes_len = max_ordinal as usize * envelope_size;
999            #[allow(unused_variables)]
1000            let offset = encoder.out_of_line_offset(bytes_len);
1001            let mut _prev_end_offset: usize = 0;
1002            if 1 > max_ordinal {
1003                return Ok(());
1004            }
1005
1006            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1007            // are envelope_size bytes.
1008            let cur_offset: usize = (1 - 1) * envelope_size;
1009
1010            // Zero reserved fields.
1011            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1012
1013            // Safety:
1014            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1015            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1016            //   envelope_size bytes, there is always sufficient room.
1017            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_power_source_common::Status, D>(
1018            self.source_status.as_ref().map(<fidl_fuchsia_hardware_power_source_common::Status as fidl::encoding::ValueTypeMarker>::borrow),
1019            encoder, offset + cur_offset, depth
1020        )?;
1021
1022            _prev_end_offset = cur_offset + envelope_size;
1023            if 2 > max_ordinal {
1024                return Ok(());
1025            }
1026
1027            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1028            // are envelope_size bytes.
1029            let cur_offset: usize = (2 - 1) * envelope_size;
1030
1031            // Zero reserved fields.
1032            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1033
1034            // Safety:
1035            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1036            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1037            //   envelope_size bytes, there is always sufficient room.
1038            fidl::encoding::encode_in_envelope_optional::<ChargeStatus, D>(
1039                self.charge_status
1040                    .as_ref()
1041                    .map(<ChargeStatus as fidl::encoding::ValueTypeMarker>::borrow),
1042                encoder,
1043                offset + cur_offset,
1044                depth,
1045            )?;
1046
1047            _prev_end_offset = cur_offset + envelope_size;
1048            if 3 > max_ordinal {
1049                return Ok(());
1050            }
1051
1052            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1053            // are envelope_size bytes.
1054            let cur_offset: usize = (3 - 1) * envelope_size;
1055
1056            // Zero reserved fields.
1057            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1058
1059            // Safety:
1060            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1061            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1062            //   envelope_size bytes, there is always sufficient room.
1063            fidl::encoding::encode_in_envelope_optional::<f32, D>(
1064                self.level_percent.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
1065                encoder,
1066                offset + cur_offset,
1067                depth,
1068            )?;
1069
1070            _prev_end_offset = cur_offset + envelope_size;
1071            if 4 > max_ordinal {
1072                return Ok(());
1073            }
1074
1075            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1076            // are envelope_size bytes.
1077            let cur_offset: usize = (4 - 1) * envelope_size;
1078
1079            // Zero reserved fields.
1080            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1081
1082            // Safety:
1083            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1084            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1085            //   envelope_size bytes, there is always sufficient room.
1086            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1087                self.remaining_capacity_uah
1088                    .as_ref()
1089                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1090                encoder,
1091                offset + cur_offset,
1092                depth,
1093            )?;
1094
1095            _prev_end_offset = cur_offset + envelope_size;
1096            if 5 > max_ordinal {
1097                return Ok(());
1098            }
1099
1100            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1101            // are envelope_size bytes.
1102            let cur_offset: usize = (5 - 1) * envelope_size;
1103
1104            // Zero reserved fields.
1105            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1106
1107            // Safety:
1108            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1109            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1110            //   envelope_size bytes, there is always sufficient room.
1111            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1112                self.full_charge_capacity_uah
1113                    .as_ref()
1114                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1115                encoder,
1116                offset + cur_offset,
1117                depth,
1118            )?;
1119
1120            _prev_end_offset = cur_offset + envelope_size;
1121            if 6 > max_ordinal {
1122                return Ok(());
1123            }
1124
1125            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1126            // are envelope_size bytes.
1127            let cur_offset: usize = (6 - 1) * envelope_size;
1128
1129            // Zero reserved fields.
1130            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1131
1132            // Safety:
1133            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1134            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1135            //   envelope_size bytes, there is always sufficient room.
1136            fidl::encoding::encode_in_envelope_optional::<HealthStatus, D>(
1137                self.health.as_ref().map(<HealthStatus as fidl::encoding::ValueTypeMarker>::borrow),
1138                encoder,
1139                offset + cur_offset,
1140                depth,
1141            )?;
1142
1143            _prev_end_offset = cur_offset + envelope_size;
1144            if 7 > max_ordinal {
1145                return Ok(());
1146            }
1147
1148            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1149            // are envelope_size bytes.
1150            let cur_offset: usize = (7 - 1) * envelope_size;
1151
1152            // Zero reserved fields.
1153            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1154
1155            // Safety:
1156            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1157            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1158            //   envelope_size bytes, there is always sufficient room.
1159            fidl::encoding::encode_in_envelope_optional::<i32, D>(
1160                self.temperature_mc.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1161                encoder,
1162                offset + cur_offset,
1163                depth,
1164            )?;
1165
1166            _prev_end_offset = cur_offset + envelope_size;
1167            if 8 > max_ordinal {
1168                return Ok(());
1169            }
1170
1171            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1172            // are envelope_size bytes.
1173            let cur_offset: usize = (8 - 1) * envelope_size;
1174
1175            // Zero reserved fields.
1176            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1177
1178            // Safety:
1179            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1180            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1181            //   envelope_size bytes, there is always sufficient room.
1182            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1183                self.cycle_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1184                encoder,
1185                offset + cur_offset,
1186                depth,
1187            )?;
1188
1189            _prev_end_offset = cur_offset + envelope_size;
1190            if 9 > max_ordinal {
1191                return Ok(());
1192            }
1193
1194            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1195            // are envelope_size bytes.
1196            let cur_offset: usize = (9 - 1) * envelope_size;
1197
1198            // Zero reserved fields.
1199            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1200
1201            // Safety:
1202            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1203            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1204            //   envelope_size bytes, there is always sufficient room.
1205            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1206                self.time_remaining.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1207                encoder,
1208                offset + cur_offset,
1209                depth,
1210            )?;
1211
1212            _prev_end_offset = cur_offset + envelope_size;
1213
1214            Ok(())
1215        }
1216    }
1217
1218    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Status {
1219        #[inline(always)]
1220        fn new_empty() -> Self {
1221            Self::default()
1222        }
1223
1224        unsafe fn decode(
1225            &mut self,
1226            decoder: &mut fidl::encoding::Decoder<'_, D>,
1227            offset: usize,
1228            mut depth: fidl::encoding::Depth,
1229        ) -> fidl::Result<()> {
1230            decoder.debug_check_bounds::<Self>(offset);
1231            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1232                None => return Err(fidl::Error::NotNullable),
1233                Some(len) => len,
1234            };
1235            // Calling decoder.out_of_line_offset(0) is not allowed.
1236            if len == 0 {
1237                return Ok(());
1238            };
1239            depth.increment()?;
1240            let envelope_size = 8;
1241            let bytes_len = len * envelope_size;
1242            let offset = decoder.out_of_line_offset(bytes_len)?;
1243            // Decode the envelope for each type.
1244            let mut _next_ordinal_to_read = 0;
1245            let mut next_offset = offset;
1246            let end_offset = offset + bytes_len;
1247            _next_ordinal_to_read += 1;
1248            if next_offset >= end_offset {
1249                return Ok(());
1250            }
1251
1252            // Decode unknown envelopes for gaps in ordinals.
1253            while _next_ordinal_to_read < 1 {
1254                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1255                _next_ordinal_to_read += 1;
1256                next_offset += envelope_size;
1257            }
1258
1259            let next_out_of_line = decoder.next_out_of_line();
1260            let handles_before = decoder.remaining_handles();
1261            if let Some((inlined, num_bytes, num_handles)) =
1262                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1263            {
1264                let member_inline_size = <fidl_fuchsia_hardware_power_source_common::Status as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1265                if inlined != (member_inline_size <= 4) {
1266                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1267                }
1268                let inner_offset;
1269                let mut inner_depth = depth.clone();
1270                if inlined {
1271                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1272                    inner_offset = next_offset;
1273                } else {
1274                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1275                    inner_depth.increment()?;
1276                }
1277                let val_ref = self.source_status.get_or_insert_with(|| {
1278                    fidl::new_empty!(fidl_fuchsia_hardware_power_source_common::Status, D)
1279                });
1280                fidl::decode!(
1281                    fidl_fuchsia_hardware_power_source_common::Status,
1282                    D,
1283                    val_ref,
1284                    decoder,
1285                    inner_offset,
1286                    inner_depth
1287                )?;
1288                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1289                {
1290                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1291                }
1292                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1293                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1294                }
1295            }
1296
1297            next_offset += envelope_size;
1298            _next_ordinal_to_read += 1;
1299            if next_offset >= end_offset {
1300                return Ok(());
1301            }
1302
1303            // Decode unknown envelopes for gaps in ordinals.
1304            while _next_ordinal_to_read < 2 {
1305                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1306                _next_ordinal_to_read += 1;
1307                next_offset += envelope_size;
1308            }
1309
1310            let next_out_of_line = decoder.next_out_of_line();
1311            let handles_before = decoder.remaining_handles();
1312            if let Some((inlined, num_bytes, num_handles)) =
1313                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1314            {
1315                let member_inline_size =
1316                    <ChargeStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1317                if inlined != (member_inline_size <= 4) {
1318                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1319                }
1320                let inner_offset;
1321                let mut inner_depth = depth.clone();
1322                if inlined {
1323                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1324                    inner_offset = next_offset;
1325                } else {
1326                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1327                    inner_depth.increment()?;
1328                }
1329                let val_ref =
1330                    self.charge_status.get_or_insert_with(|| fidl::new_empty!(ChargeStatus, D));
1331                fidl::decode!(ChargeStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
1332                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1333                {
1334                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1335                }
1336                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1337                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1338                }
1339            }
1340
1341            next_offset += envelope_size;
1342            _next_ordinal_to_read += 1;
1343            if next_offset >= end_offset {
1344                return Ok(());
1345            }
1346
1347            // Decode unknown envelopes for gaps in ordinals.
1348            while _next_ordinal_to_read < 3 {
1349                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1350                _next_ordinal_to_read += 1;
1351                next_offset += envelope_size;
1352            }
1353
1354            let next_out_of_line = decoder.next_out_of_line();
1355            let handles_before = decoder.remaining_handles();
1356            if let Some((inlined, num_bytes, num_handles)) =
1357                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1358            {
1359                let member_inline_size =
1360                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1361                if inlined != (member_inline_size <= 4) {
1362                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1363                }
1364                let inner_offset;
1365                let mut inner_depth = depth.clone();
1366                if inlined {
1367                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1368                    inner_offset = next_offset;
1369                } else {
1370                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1371                    inner_depth.increment()?;
1372                }
1373                let val_ref = self.level_percent.get_or_insert_with(|| fidl::new_empty!(f32, D));
1374                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
1375                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1376                {
1377                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1378                }
1379                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1380                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1381                }
1382            }
1383
1384            next_offset += envelope_size;
1385            _next_ordinal_to_read += 1;
1386            if next_offset >= end_offset {
1387                return Ok(());
1388            }
1389
1390            // Decode unknown envelopes for gaps in ordinals.
1391            while _next_ordinal_to_read < 4 {
1392                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1393                _next_ordinal_to_read += 1;
1394                next_offset += envelope_size;
1395            }
1396
1397            let next_out_of_line = decoder.next_out_of_line();
1398            let handles_before = decoder.remaining_handles();
1399            if let Some((inlined, num_bytes, num_handles)) =
1400                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1401            {
1402                let member_inline_size =
1403                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1404                if inlined != (member_inline_size <= 4) {
1405                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1406                }
1407                let inner_offset;
1408                let mut inner_depth = depth.clone();
1409                if inlined {
1410                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1411                    inner_offset = next_offset;
1412                } else {
1413                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1414                    inner_depth.increment()?;
1415                }
1416                let val_ref =
1417                    self.remaining_capacity_uah.get_or_insert_with(|| fidl::new_empty!(u32, D));
1418                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1419                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1420                {
1421                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1422                }
1423                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1424                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1425                }
1426            }
1427
1428            next_offset += envelope_size;
1429            _next_ordinal_to_read += 1;
1430            if next_offset >= end_offset {
1431                return Ok(());
1432            }
1433
1434            // Decode unknown envelopes for gaps in ordinals.
1435            while _next_ordinal_to_read < 5 {
1436                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1437                _next_ordinal_to_read += 1;
1438                next_offset += envelope_size;
1439            }
1440
1441            let next_out_of_line = decoder.next_out_of_line();
1442            let handles_before = decoder.remaining_handles();
1443            if let Some((inlined, num_bytes, num_handles)) =
1444                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1445            {
1446                let member_inline_size =
1447                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1448                if inlined != (member_inline_size <= 4) {
1449                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1450                }
1451                let inner_offset;
1452                let mut inner_depth = depth.clone();
1453                if inlined {
1454                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1455                    inner_offset = next_offset;
1456                } else {
1457                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1458                    inner_depth.increment()?;
1459                }
1460                let val_ref =
1461                    self.full_charge_capacity_uah.get_or_insert_with(|| fidl::new_empty!(u32, D));
1462                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1463                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1464                {
1465                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1466                }
1467                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1468                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1469                }
1470            }
1471
1472            next_offset += envelope_size;
1473            _next_ordinal_to_read += 1;
1474            if next_offset >= end_offset {
1475                return Ok(());
1476            }
1477
1478            // Decode unknown envelopes for gaps in ordinals.
1479            while _next_ordinal_to_read < 6 {
1480                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1481                _next_ordinal_to_read += 1;
1482                next_offset += envelope_size;
1483            }
1484
1485            let next_out_of_line = decoder.next_out_of_line();
1486            let handles_before = decoder.remaining_handles();
1487            if let Some((inlined, num_bytes, num_handles)) =
1488                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1489            {
1490                let member_inline_size =
1491                    <HealthStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1492                if inlined != (member_inline_size <= 4) {
1493                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1494                }
1495                let inner_offset;
1496                let mut inner_depth = depth.clone();
1497                if inlined {
1498                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1499                    inner_offset = next_offset;
1500                } else {
1501                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1502                    inner_depth.increment()?;
1503                }
1504                let val_ref = self.health.get_or_insert_with(|| fidl::new_empty!(HealthStatus, D));
1505                fidl::decode!(HealthStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
1506                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1507                {
1508                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1509                }
1510                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1511                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1512                }
1513            }
1514
1515            next_offset += envelope_size;
1516            _next_ordinal_to_read += 1;
1517            if next_offset >= end_offset {
1518                return Ok(());
1519            }
1520
1521            // Decode unknown envelopes for gaps in ordinals.
1522            while _next_ordinal_to_read < 7 {
1523                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1524                _next_ordinal_to_read += 1;
1525                next_offset += envelope_size;
1526            }
1527
1528            let next_out_of_line = decoder.next_out_of_line();
1529            let handles_before = decoder.remaining_handles();
1530            if let Some((inlined, num_bytes, num_handles)) =
1531                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1532            {
1533                let member_inline_size =
1534                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1535                if inlined != (member_inline_size <= 4) {
1536                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1537                }
1538                let inner_offset;
1539                let mut inner_depth = depth.clone();
1540                if inlined {
1541                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1542                    inner_offset = next_offset;
1543                } else {
1544                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1545                    inner_depth.increment()?;
1546                }
1547                let val_ref = self.temperature_mc.get_or_insert_with(|| fidl::new_empty!(i32, D));
1548                fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
1549                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1550                {
1551                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1552                }
1553                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1554                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1555                }
1556            }
1557
1558            next_offset += envelope_size;
1559            _next_ordinal_to_read += 1;
1560            if next_offset >= end_offset {
1561                return Ok(());
1562            }
1563
1564            // Decode unknown envelopes for gaps in ordinals.
1565            while _next_ordinal_to_read < 8 {
1566                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1567                _next_ordinal_to_read += 1;
1568                next_offset += envelope_size;
1569            }
1570
1571            let next_out_of_line = decoder.next_out_of_line();
1572            let handles_before = decoder.remaining_handles();
1573            if let Some((inlined, num_bytes, num_handles)) =
1574                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1575            {
1576                let member_inline_size =
1577                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1578                if inlined != (member_inline_size <= 4) {
1579                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1580                }
1581                let inner_offset;
1582                let mut inner_depth = depth.clone();
1583                if inlined {
1584                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1585                    inner_offset = next_offset;
1586                } else {
1587                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1588                    inner_depth.increment()?;
1589                }
1590                let val_ref = self.cycle_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
1591                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1592                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1593                {
1594                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1595                }
1596                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1597                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1598                }
1599            }
1600
1601            next_offset += envelope_size;
1602            _next_ordinal_to_read += 1;
1603            if next_offset >= end_offset {
1604                return Ok(());
1605            }
1606
1607            // Decode unknown envelopes for gaps in ordinals.
1608            while _next_ordinal_to_read < 9 {
1609                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1610                _next_ordinal_to_read += 1;
1611                next_offset += envelope_size;
1612            }
1613
1614            let next_out_of_line = decoder.next_out_of_line();
1615            let handles_before = decoder.remaining_handles();
1616            if let Some((inlined, num_bytes, num_handles)) =
1617                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1618            {
1619                let member_inline_size =
1620                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1621                if inlined != (member_inline_size <= 4) {
1622                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1623                }
1624                let inner_offset;
1625                let mut inner_depth = depth.clone();
1626                if inlined {
1627                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1628                    inner_offset = next_offset;
1629                } else {
1630                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1631                    inner_depth.increment()?;
1632                }
1633                let val_ref = self.time_remaining.get_or_insert_with(|| fidl::new_empty!(i64, D));
1634                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1635                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1636                {
1637                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1638                }
1639                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1640                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1641                }
1642            }
1643
1644            next_offset += envelope_size;
1645
1646            // Decode the remaining unknown envelopes.
1647            while next_offset < end_offset {
1648                _next_ordinal_to_read += 1;
1649                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1650                next_offset += envelope_size;
1651            }
1652
1653            Ok(())
1654        }
1655    }
1656}