Skip to main content

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