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