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}
115
116impl HealthStatus {
117    #[inline]
118    pub fn from_primitive(prim: u32) -> Option<Self> {
119        match prim {
120            0 => Some(Self::Unknown),
121            1 => Some(Self::Good),
122            2 => Some(Self::Cold),
123            3 => Some(Self::Hot),
124            4 => Some(Self::Dead),
125            5 => Some(Self::OverVoltage),
126            6 => Some(Self::UnspecifiedFailure),
127            _ => None,
128        }
129    }
130
131    #[inline]
132    pub const fn into_primitive(self) -> u32 {
133        self as u32
134    }
135}
136
137/// The general status of the battery level.
138#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
139#[repr(u32)]
140pub enum LevelStatus {
141    Unknown = 0,
142    Ok = 1,
143    Warning = 2,
144    Low = 3,
145    Critical = 4,
146}
147
148impl LevelStatus {
149    #[inline]
150    pub fn from_primitive(prim: u32) -> Option<Self> {
151        match prim {
152            0 => Some(Self::Unknown),
153            1 => Some(Self::Ok),
154            2 => Some(Self::Warning),
155            3 => Some(Self::Low),
156            4 => Some(Self::Critical),
157            _ => None,
158        }
159    }
160
161    #[inline]
162    pub const fn into_primitive(self) -> u32 {
163        self as u32
164    }
165}
166
167#[derive(Clone, Debug, PartialEq)]
168pub struct BatteryInfoProviderGetBatteryInfoResponse {
169    pub info: BatteryInfo,
170}
171
172impl fidl::Persistable for BatteryInfoProviderGetBatteryInfoResponse {}
173
174#[derive(Clone, Debug, PartialEq)]
175pub struct BatteryInfoWatcherOnChangeBatteryInfoRequest {
176    pub info: BatteryInfo,
177}
178
179impl fidl::Persistable for BatteryInfoWatcherOnChangeBatteryInfoRequest {}
180
181/// Current battery state information
182#[derive(Clone, Debug, Default, PartialEq)]
183pub struct BatteryInfo {
184    /// General battery status with respect to presence & availability
185    pub status: Option<BatteryStatus>,
186    /// The current state of the battery with respect to charging
187    pub charge_status: Option<ChargeStatus>,
188    /// The charge source while battery is actively charging.
189    /// When not actively charging, this will reflect that the source is
190    /// NONE (not charging) or UNKNOWN.
191    pub charge_source: Option<ChargeSource>,
192    /// Battery level in percentage. Level percent is only available if
193    /// level status is known.
194    pub level_percent: Option<f32>,
195    /// Battery level as a general status, including low and critical
196    pub level_status: Option<LevelStatus>,
197    /// Overall battery health
198    pub health: Option<HealthStatus>,
199    /// Time remaining relative to the current charge status
200    pub time_remaining: Option<TimeRemaining>,
201    /// Timestamp to distinguish between latest and stale status
202    pub timestamp: Option<i64>,
203    /// Forward the voltage level in mv
204    pub present_voltage_mv: Option<u32>,
205    /// Forward the battery capqacity in uAh
206    pub remaining_capacity_uah: Option<u32>,
207    /// Battery spec
208    pub battery_spec: Option<BatterySpec>,
209    #[doc(hidden)]
210    pub __source_breaking: fidl::marker::SourceBreaking,
211}
212
213impl fidl::Persistable for BatteryInfo {}
214
215/// Type of data that are determined by manufacturer
216#[derive(Clone, Debug, Default, PartialEq)]
217pub struct BatterySpec {
218    /// Represent the battery's charging current spec in micro amps
219    pub max_charging_current_ua: Option<i32>,
220    /// Represent the battery's charging voltage spec in micro volt
221    pub max_charnging_voltage_uv: Option<i32>,
222    /// Battery Full Charge Design Capacity in micro amp hour
223    pub design_capacity_uah: Option<i32>,
224    #[doc(hidden)]
225    pub __source_breaking: fidl::marker::SourceBreaking,
226}
227
228impl fidl::Persistable for BatterySpec {}
229
230/// The time remaining while actively charging or discharging.
231#[derive(Clone, Debug)]
232pub enum TimeRemaining {
233    /// Representation of indeterminate state with zero duration.
234    Indeterminate(i64),
235    /// Remaining battery life while discharging
236    BatteryLife(i64),
237    /// Remaining time until full while charging
238    FullCharge(i64),
239    #[doc(hidden)]
240    __SourceBreaking { unknown_ordinal: u64 },
241}
242
243/// Pattern that matches an unknown `TimeRemaining` member.
244#[macro_export]
245macro_rules! TimeRemainingUnknown {
246    () => {
247        _
248    };
249}
250
251// Custom PartialEq so that unknown variants are not equal to themselves.
252impl PartialEq for TimeRemaining {
253    fn eq(&self, other: &Self) -> bool {
254        match (self, other) {
255            (Self::Indeterminate(x), Self::Indeterminate(y)) => *x == *y,
256            (Self::BatteryLife(x), Self::BatteryLife(y)) => *x == *y,
257            (Self::FullCharge(x), Self::FullCharge(y)) => *x == *y,
258            _ => false,
259        }
260    }
261}
262
263impl TimeRemaining {
264    #[inline]
265    pub fn ordinal(&self) -> u64 {
266        match *self {
267            Self::Indeterminate(_) => 1,
268            Self::BatteryLife(_) => 2,
269            Self::FullCharge(_) => 3,
270            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
271        }
272    }
273
274    #[inline]
275    pub fn unknown_variant_for_testing() -> Self {
276        Self::__SourceBreaking { unknown_ordinal: 0 }
277    }
278
279    #[inline]
280    pub fn is_unknown(&self) -> bool {
281        match self {
282            Self::__SourceBreaking { .. } => true,
283            _ => false,
284        }
285    }
286}
287
288impl fidl::Persistable for TimeRemaining {}
289
290mod internal {
291    use super::*;
292    unsafe impl fidl::encoding::TypeMarker for BatteryStatus {
293        type Owned = Self;
294
295        #[inline(always)]
296        fn inline_align(_context: fidl::encoding::Context) -> usize {
297            std::mem::align_of::<u32>()
298        }
299
300        #[inline(always)]
301        fn inline_size(_context: fidl::encoding::Context) -> usize {
302            std::mem::size_of::<u32>()
303        }
304
305        #[inline(always)]
306        fn encode_is_copy() -> bool {
307            true
308        }
309
310        #[inline(always)]
311        fn decode_is_copy() -> bool {
312            false
313        }
314    }
315
316    impl fidl::encoding::ValueTypeMarker for BatteryStatus {
317        type Borrowed<'a> = Self;
318        #[inline(always)]
319        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
320            *value
321        }
322    }
323
324    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for BatteryStatus {
325        #[inline]
326        unsafe fn encode(
327            self,
328            encoder: &mut fidl::encoding::Encoder<'_, D>,
329            offset: usize,
330            _depth: fidl::encoding::Depth,
331        ) -> fidl::Result<()> {
332            encoder.debug_check_bounds::<Self>(offset);
333            encoder.write_num(self.into_primitive(), offset);
334            Ok(())
335        }
336    }
337
338    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BatteryStatus {
339        #[inline(always)]
340        fn new_empty() -> Self {
341            Self::Unknown
342        }
343
344        #[inline]
345        unsafe fn decode(
346            &mut self,
347            decoder: &mut fidl::encoding::Decoder<'_, D>,
348            offset: usize,
349            _depth: fidl::encoding::Depth,
350        ) -> fidl::Result<()> {
351            decoder.debug_check_bounds::<Self>(offset);
352            let prim = decoder.read_num::<u32>(offset);
353
354            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
355            Ok(())
356        }
357    }
358    unsafe impl fidl::encoding::TypeMarker for ChargeSource {
359        type Owned = Self;
360
361        #[inline(always)]
362        fn inline_align(_context: fidl::encoding::Context) -> usize {
363            std::mem::align_of::<u32>()
364        }
365
366        #[inline(always)]
367        fn inline_size(_context: fidl::encoding::Context) -> usize {
368            std::mem::size_of::<u32>()
369        }
370
371        #[inline(always)]
372        fn encode_is_copy() -> bool {
373            true
374        }
375
376        #[inline(always)]
377        fn decode_is_copy() -> bool {
378            false
379        }
380    }
381
382    impl fidl::encoding::ValueTypeMarker for ChargeSource {
383        type Borrowed<'a> = Self;
384        #[inline(always)]
385        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
386            *value
387        }
388    }
389
390    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ChargeSource {
391        #[inline]
392        unsafe fn encode(
393            self,
394            encoder: &mut fidl::encoding::Encoder<'_, D>,
395            offset: usize,
396            _depth: fidl::encoding::Depth,
397        ) -> fidl::Result<()> {
398            encoder.debug_check_bounds::<Self>(offset);
399            encoder.write_num(self.into_primitive(), offset);
400            Ok(())
401        }
402    }
403
404    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChargeSource {
405        #[inline(always)]
406        fn new_empty() -> Self {
407            Self::Unknown
408        }
409
410        #[inline]
411        unsafe fn decode(
412            &mut self,
413            decoder: &mut fidl::encoding::Decoder<'_, D>,
414            offset: usize,
415            _depth: fidl::encoding::Depth,
416        ) -> fidl::Result<()> {
417            decoder.debug_check_bounds::<Self>(offset);
418            let prim = decoder.read_num::<u32>(offset);
419
420            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
421            Ok(())
422        }
423    }
424    unsafe impl fidl::encoding::TypeMarker for ChargeStatus {
425        type Owned = Self;
426
427        #[inline(always)]
428        fn inline_align(_context: fidl::encoding::Context) -> usize {
429            std::mem::align_of::<u32>()
430        }
431
432        #[inline(always)]
433        fn inline_size(_context: fidl::encoding::Context) -> usize {
434            std::mem::size_of::<u32>()
435        }
436
437        #[inline(always)]
438        fn encode_is_copy() -> bool {
439            true
440        }
441
442        #[inline(always)]
443        fn decode_is_copy() -> bool {
444            false
445        }
446    }
447
448    impl fidl::encoding::ValueTypeMarker for ChargeStatus {
449        type Borrowed<'a> = Self;
450        #[inline(always)]
451        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
452            *value
453        }
454    }
455
456    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ChargeStatus {
457        #[inline]
458        unsafe fn encode(
459            self,
460            encoder: &mut fidl::encoding::Encoder<'_, D>,
461            offset: usize,
462            _depth: fidl::encoding::Depth,
463        ) -> fidl::Result<()> {
464            encoder.debug_check_bounds::<Self>(offset);
465            encoder.write_num(self.into_primitive(), offset);
466            Ok(())
467        }
468    }
469
470    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChargeStatus {
471        #[inline(always)]
472        fn new_empty() -> Self {
473            Self::Unknown
474        }
475
476        #[inline]
477        unsafe fn decode(
478            &mut self,
479            decoder: &mut fidl::encoding::Decoder<'_, D>,
480            offset: usize,
481            _depth: fidl::encoding::Depth,
482        ) -> fidl::Result<()> {
483            decoder.debug_check_bounds::<Self>(offset);
484            let prim = decoder.read_num::<u32>(offset);
485
486            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
487            Ok(())
488        }
489    }
490    unsafe impl fidl::encoding::TypeMarker for HealthStatus {
491        type Owned = Self;
492
493        #[inline(always)]
494        fn inline_align(_context: fidl::encoding::Context) -> usize {
495            std::mem::align_of::<u32>()
496        }
497
498        #[inline(always)]
499        fn inline_size(_context: fidl::encoding::Context) -> usize {
500            std::mem::size_of::<u32>()
501        }
502
503        #[inline(always)]
504        fn encode_is_copy() -> bool {
505            true
506        }
507
508        #[inline(always)]
509        fn decode_is_copy() -> bool {
510            false
511        }
512    }
513
514    impl fidl::encoding::ValueTypeMarker for HealthStatus {
515        type Borrowed<'a> = Self;
516        #[inline(always)]
517        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
518            *value
519        }
520    }
521
522    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for HealthStatus {
523        #[inline]
524        unsafe fn encode(
525            self,
526            encoder: &mut fidl::encoding::Encoder<'_, D>,
527            offset: usize,
528            _depth: fidl::encoding::Depth,
529        ) -> fidl::Result<()> {
530            encoder.debug_check_bounds::<Self>(offset);
531            encoder.write_num(self.into_primitive(), offset);
532            Ok(())
533        }
534    }
535
536    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HealthStatus {
537        #[inline(always)]
538        fn new_empty() -> Self {
539            Self::Unknown
540        }
541
542        #[inline]
543        unsafe fn decode(
544            &mut self,
545            decoder: &mut fidl::encoding::Decoder<'_, D>,
546            offset: usize,
547            _depth: fidl::encoding::Depth,
548        ) -> fidl::Result<()> {
549            decoder.debug_check_bounds::<Self>(offset);
550            let prim = decoder.read_num::<u32>(offset);
551
552            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
553            Ok(())
554        }
555    }
556    unsafe impl fidl::encoding::TypeMarker for LevelStatus {
557        type Owned = Self;
558
559        #[inline(always)]
560        fn inline_align(_context: fidl::encoding::Context) -> usize {
561            std::mem::align_of::<u32>()
562        }
563
564        #[inline(always)]
565        fn inline_size(_context: fidl::encoding::Context) -> usize {
566            std::mem::size_of::<u32>()
567        }
568
569        #[inline(always)]
570        fn encode_is_copy() -> bool {
571            true
572        }
573
574        #[inline(always)]
575        fn decode_is_copy() -> bool {
576            false
577        }
578    }
579
580    impl fidl::encoding::ValueTypeMarker for LevelStatus {
581        type Borrowed<'a> = Self;
582        #[inline(always)]
583        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
584            *value
585        }
586    }
587
588    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LevelStatus {
589        #[inline]
590        unsafe fn encode(
591            self,
592            encoder: &mut fidl::encoding::Encoder<'_, D>,
593            offset: usize,
594            _depth: fidl::encoding::Depth,
595        ) -> fidl::Result<()> {
596            encoder.debug_check_bounds::<Self>(offset);
597            encoder.write_num(self.into_primitive(), offset);
598            Ok(())
599        }
600    }
601
602    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LevelStatus {
603        #[inline(always)]
604        fn new_empty() -> Self {
605            Self::Unknown
606        }
607
608        #[inline]
609        unsafe fn decode(
610            &mut self,
611            decoder: &mut fidl::encoding::Decoder<'_, D>,
612            offset: usize,
613            _depth: fidl::encoding::Depth,
614        ) -> fidl::Result<()> {
615            decoder.debug_check_bounds::<Self>(offset);
616            let prim = decoder.read_num::<u32>(offset);
617
618            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
619            Ok(())
620        }
621    }
622
623    impl fidl::encoding::ValueTypeMarker for BatteryInfoProviderGetBatteryInfoResponse {
624        type Borrowed<'a> = &'a Self;
625        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
626            value
627        }
628    }
629
630    unsafe impl fidl::encoding::TypeMarker for BatteryInfoProviderGetBatteryInfoResponse {
631        type Owned = Self;
632
633        #[inline(always)]
634        fn inline_align(_context: fidl::encoding::Context) -> usize {
635            8
636        }
637
638        #[inline(always)]
639        fn inline_size(_context: fidl::encoding::Context) -> usize {
640            16
641        }
642    }
643
644    unsafe impl<D: fidl::encoding::ResourceDialect>
645        fidl::encoding::Encode<BatteryInfoProviderGetBatteryInfoResponse, D>
646        for &BatteryInfoProviderGetBatteryInfoResponse
647    {
648        #[inline]
649        unsafe fn encode(
650            self,
651            encoder: &mut fidl::encoding::Encoder<'_, D>,
652            offset: usize,
653            _depth: fidl::encoding::Depth,
654        ) -> fidl::Result<()> {
655            encoder.debug_check_bounds::<BatteryInfoProviderGetBatteryInfoResponse>(offset);
656            // Delegate to tuple encoding.
657            fidl::encoding::Encode::<BatteryInfoProviderGetBatteryInfoResponse, D>::encode(
658                (<BatteryInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
659                encoder,
660                offset,
661                _depth,
662            )
663        }
664    }
665    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<BatteryInfo, D>>
666        fidl::encoding::Encode<BatteryInfoProviderGetBatteryInfoResponse, D> for (T0,)
667    {
668        #[inline]
669        unsafe fn encode(
670            self,
671            encoder: &mut fidl::encoding::Encoder<'_, D>,
672            offset: usize,
673            depth: fidl::encoding::Depth,
674        ) -> fidl::Result<()> {
675            encoder.debug_check_bounds::<BatteryInfoProviderGetBatteryInfoResponse>(offset);
676            // Zero out padding regions. There's no need to apply masks
677            // because the unmasked parts will be overwritten by fields.
678            // Write the fields.
679            self.0.encode(encoder, offset + 0, depth)?;
680            Ok(())
681        }
682    }
683
684    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
685        for BatteryInfoProviderGetBatteryInfoResponse
686    {
687        #[inline(always)]
688        fn new_empty() -> Self {
689            Self { info: fidl::new_empty!(BatteryInfo, D) }
690        }
691
692        #[inline]
693        unsafe fn decode(
694            &mut self,
695            decoder: &mut fidl::encoding::Decoder<'_, D>,
696            offset: usize,
697            _depth: fidl::encoding::Depth,
698        ) -> fidl::Result<()> {
699            decoder.debug_check_bounds::<Self>(offset);
700            // Verify that padding bytes are zero.
701            fidl::decode!(BatteryInfo, D, &mut self.info, decoder, offset + 0, _depth)?;
702            Ok(())
703        }
704    }
705
706    impl fidl::encoding::ValueTypeMarker for BatteryInfoWatcherOnChangeBatteryInfoRequest {
707        type Borrowed<'a> = &'a Self;
708        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
709            value
710        }
711    }
712
713    unsafe impl fidl::encoding::TypeMarker for BatteryInfoWatcherOnChangeBatteryInfoRequest {
714        type Owned = Self;
715
716        #[inline(always)]
717        fn inline_align(_context: fidl::encoding::Context) -> usize {
718            8
719        }
720
721        #[inline(always)]
722        fn inline_size(_context: fidl::encoding::Context) -> usize {
723            16
724        }
725    }
726
727    unsafe impl<D: fidl::encoding::ResourceDialect>
728        fidl::encoding::Encode<BatteryInfoWatcherOnChangeBatteryInfoRequest, D>
729        for &BatteryInfoWatcherOnChangeBatteryInfoRequest
730    {
731        #[inline]
732        unsafe fn encode(
733            self,
734            encoder: &mut fidl::encoding::Encoder<'_, D>,
735            offset: usize,
736            _depth: fidl::encoding::Depth,
737        ) -> fidl::Result<()> {
738            encoder.debug_check_bounds::<BatteryInfoWatcherOnChangeBatteryInfoRequest>(offset);
739            // Delegate to tuple encoding.
740            fidl::encoding::Encode::<BatteryInfoWatcherOnChangeBatteryInfoRequest, D>::encode(
741                (<BatteryInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
742                encoder,
743                offset,
744                _depth,
745            )
746        }
747    }
748    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<BatteryInfo, D>>
749        fidl::encoding::Encode<BatteryInfoWatcherOnChangeBatteryInfoRequest, D> for (T0,)
750    {
751        #[inline]
752        unsafe fn encode(
753            self,
754            encoder: &mut fidl::encoding::Encoder<'_, D>,
755            offset: usize,
756            depth: fidl::encoding::Depth,
757        ) -> fidl::Result<()> {
758            encoder.debug_check_bounds::<BatteryInfoWatcherOnChangeBatteryInfoRequest>(offset);
759            // Zero out padding regions. There's no need to apply masks
760            // because the unmasked parts will be overwritten by fields.
761            // Write the fields.
762            self.0.encode(encoder, offset + 0, depth)?;
763            Ok(())
764        }
765    }
766
767    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
768        for BatteryInfoWatcherOnChangeBatteryInfoRequest
769    {
770        #[inline(always)]
771        fn new_empty() -> Self {
772            Self { info: fidl::new_empty!(BatteryInfo, D) }
773        }
774
775        #[inline]
776        unsafe fn decode(
777            &mut self,
778            decoder: &mut fidl::encoding::Decoder<'_, D>,
779            offset: usize,
780            _depth: fidl::encoding::Depth,
781        ) -> fidl::Result<()> {
782            decoder.debug_check_bounds::<Self>(offset);
783            // Verify that padding bytes are zero.
784            fidl::decode!(BatteryInfo, D, &mut self.info, decoder, offset + 0, _depth)?;
785            Ok(())
786        }
787    }
788
789    impl BatteryInfo {
790        #[inline(always)]
791        fn max_ordinal_present(&self) -> u64 {
792            if let Some(_) = self.battery_spec {
793                return 11;
794            }
795            if let Some(_) = self.remaining_capacity_uah {
796                return 10;
797            }
798            if let Some(_) = self.present_voltage_mv {
799                return 9;
800            }
801            if let Some(_) = self.timestamp {
802                return 8;
803            }
804            if let Some(_) = self.time_remaining {
805                return 7;
806            }
807            if let Some(_) = self.health {
808                return 6;
809            }
810            if let Some(_) = self.level_status {
811                return 5;
812            }
813            if let Some(_) = self.level_percent {
814                return 4;
815            }
816            if let Some(_) = self.charge_source {
817                return 3;
818            }
819            if let Some(_) = self.charge_status {
820                return 2;
821            }
822            if let Some(_) = self.status {
823                return 1;
824            }
825            0
826        }
827    }
828
829    impl fidl::encoding::ValueTypeMarker for BatteryInfo {
830        type Borrowed<'a> = &'a Self;
831        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
832            value
833        }
834    }
835
836    unsafe impl fidl::encoding::TypeMarker for BatteryInfo {
837        type Owned = Self;
838
839        #[inline(always)]
840        fn inline_align(_context: fidl::encoding::Context) -> usize {
841            8
842        }
843
844        #[inline(always)]
845        fn inline_size(_context: fidl::encoding::Context) -> usize {
846            16
847        }
848    }
849
850    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BatteryInfo, D>
851        for &BatteryInfo
852    {
853        unsafe fn encode(
854            self,
855            encoder: &mut fidl::encoding::Encoder<'_, D>,
856            offset: usize,
857            mut depth: fidl::encoding::Depth,
858        ) -> fidl::Result<()> {
859            encoder.debug_check_bounds::<BatteryInfo>(offset);
860            // Vector header
861            let max_ordinal: u64 = self.max_ordinal_present();
862            encoder.write_num(max_ordinal, offset);
863            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
864            // Calling encoder.out_of_line_offset(0) is not allowed.
865            if max_ordinal == 0 {
866                return Ok(());
867            }
868            depth.increment()?;
869            let envelope_size = 8;
870            let bytes_len = max_ordinal as usize * envelope_size;
871            #[allow(unused_variables)]
872            let offset = encoder.out_of_line_offset(bytes_len);
873            let mut _prev_end_offset: usize = 0;
874            if 1 > max_ordinal {
875                return Ok(());
876            }
877
878            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
879            // are envelope_size bytes.
880            let cur_offset: usize = (1 - 1) * envelope_size;
881
882            // Zero reserved fields.
883            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
884
885            // Safety:
886            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
887            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
888            //   envelope_size bytes, there is always sufficient room.
889            fidl::encoding::encode_in_envelope_optional::<BatteryStatus, D>(
890                self.status
891                    .as_ref()
892                    .map(<BatteryStatus as fidl::encoding::ValueTypeMarker>::borrow),
893                encoder,
894                offset + cur_offset,
895                depth,
896            )?;
897
898            _prev_end_offset = cur_offset + envelope_size;
899            if 2 > max_ordinal {
900                return Ok(());
901            }
902
903            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
904            // are envelope_size bytes.
905            let cur_offset: usize = (2 - 1) * envelope_size;
906
907            // Zero reserved fields.
908            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
909
910            // Safety:
911            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
912            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
913            //   envelope_size bytes, there is always sufficient room.
914            fidl::encoding::encode_in_envelope_optional::<ChargeStatus, D>(
915                self.charge_status
916                    .as_ref()
917                    .map(<ChargeStatus as fidl::encoding::ValueTypeMarker>::borrow),
918                encoder,
919                offset + cur_offset,
920                depth,
921            )?;
922
923            _prev_end_offset = cur_offset + envelope_size;
924            if 3 > max_ordinal {
925                return Ok(());
926            }
927
928            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
929            // are envelope_size bytes.
930            let cur_offset: usize = (3 - 1) * envelope_size;
931
932            // Zero reserved fields.
933            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
934
935            // Safety:
936            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
937            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
938            //   envelope_size bytes, there is always sufficient room.
939            fidl::encoding::encode_in_envelope_optional::<ChargeSource, D>(
940                self.charge_source
941                    .as_ref()
942                    .map(<ChargeSource as fidl::encoding::ValueTypeMarker>::borrow),
943                encoder,
944                offset + cur_offset,
945                depth,
946            )?;
947
948            _prev_end_offset = cur_offset + envelope_size;
949            if 4 > max_ordinal {
950                return Ok(());
951            }
952
953            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
954            // are envelope_size bytes.
955            let cur_offset: usize = (4 - 1) * envelope_size;
956
957            // Zero reserved fields.
958            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
959
960            // Safety:
961            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
962            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
963            //   envelope_size bytes, there is always sufficient room.
964            fidl::encoding::encode_in_envelope_optional::<f32, D>(
965                self.level_percent.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
966                encoder,
967                offset + cur_offset,
968                depth,
969            )?;
970
971            _prev_end_offset = cur_offset + envelope_size;
972            if 5 > max_ordinal {
973                return Ok(());
974            }
975
976            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
977            // are envelope_size bytes.
978            let cur_offset: usize = (5 - 1) * envelope_size;
979
980            // Zero reserved fields.
981            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
982
983            // Safety:
984            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
985            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
986            //   envelope_size bytes, there is always sufficient room.
987            fidl::encoding::encode_in_envelope_optional::<LevelStatus, D>(
988                self.level_status
989                    .as_ref()
990                    .map(<LevelStatus as fidl::encoding::ValueTypeMarker>::borrow),
991                encoder,
992                offset + cur_offset,
993                depth,
994            )?;
995
996            _prev_end_offset = cur_offset + envelope_size;
997            if 6 > max_ordinal {
998                return Ok(());
999            }
1000
1001            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1002            // are envelope_size bytes.
1003            let cur_offset: usize = (6 - 1) * envelope_size;
1004
1005            // Zero reserved fields.
1006            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1007
1008            // Safety:
1009            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1010            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1011            //   envelope_size bytes, there is always sufficient room.
1012            fidl::encoding::encode_in_envelope_optional::<HealthStatus, D>(
1013                self.health.as_ref().map(<HealthStatus as fidl::encoding::ValueTypeMarker>::borrow),
1014                encoder,
1015                offset + cur_offset,
1016                depth,
1017            )?;
1018
1019            _prev_end_offset = cur_offset + envelope_size;
1020            if 7 > max_ordinal {
1021                return Ok(());
1022            }
1023
1024            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1025            // are envelope_size bytes.
1026            let cur_offset: usize = (7 - 1) * envelope_size;
1027
1028            // Zero reserved fields.
1029            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1030
1031            // Safety:
1032            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1033            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1034            //   envelope_size bytes, there is always sufficient room.
1035            fidl::encoding::encode_in_envelope_optional::<TimeRemaining, D>(
1036                self.time_remaining
1037                    .as_ref()
1038                    .map(<TimeRemaining as fidl::encoding::ValueTypeMarker>::borrow),
1039                encoder,
1040                offset + cur_offset,
1041                depth,
1042            )?;
1043
1044            _prev_end_offset = cur_offset + envelope_size;
1045            if 8 > max_ordinal {
1046                return Ok(());
1047            }
1048
1049            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1050            // are envelope_size bytes.
1051            let cur_offset: usize = (8 - 1) * envelope_size;
1052
1053            // Zero reserved fields.
1054            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1055
1056            // Safety:
1057            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1058            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1059            //   envelope_size bytes, there is always sufficient room.
1060            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1061                self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1062                encoder,
1063                offset + cur_offset,
1064                depth,
1065            )?;
1066
1067            _prev_end_offset = cur_offset + envelope_size;
1068            if 9 > max_ordinal {
1069                return Ok(());
1070            }
1071
1072            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1073            // are envelope_size bytes.
1074            let cur_offset: usize = (9 - 1) * envelope_size;
1075
1076            // Zero reserved fields.
1077            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1078
1079            // Safety:
1080            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1081            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1082            //   envelope_size bytes, there is always sufficient room.
1083            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1084                self.present_voltage_mv
1085                    .as_ref()
1086                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1087                encoder,
1088                offset + cur_offset,
1089                depth,
1090            )?;
1091
1092            _prev_end_offset = cur_offset + envelope_size;
1093            if 10 > max_ordinal {
1094                return Ok(());
1095            }
1096
1097            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1098            // are envelope_size bytes.
1099            let cur_offset: usize = (10 - 1) * envelope_size;
1100
1101            // Zero reserved fields.
1102            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1103
1104            // Safety:
1105            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1106            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1107            //   envelope_size bytes, there is always sufficient room.
1108            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1109                self.remaining_capacity_uah
1110                    .as_ref()
1111                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1112                encoder,
1113                offset + cur_offset,
1114                depth,
1115            )?;
1116
1117            _prev_end_offset = cur_offset + envelope_size;
1118            if 11 > max_ordinal {
1119                return Ok(());
1120            }
1121
1122            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1123            // are envelope_size bytes.
1124            let cur_offset: usize = (11 - 1) * envelope_size;
1125
1126            // Zero reserved fields.
1127            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1128
1129            // Safety:
1130            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1131            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1132            //   envelope_size bytes, there is always sufficient room.
1133            fidl::encoding::encode_in_envelope_optional::<BatterySpec, D>(
1134                self.battery_spec
1135                    .as_ref()
1136                    .map(<BatterySpec as fidl::encoding::ValueTypeMarker>::borrow),
1137                encoder,
1138                offset + cur_offset,
1139                depth,
1140            )?;
1141
1142            _prev_end_offset = cur_offset + envelope_size;
1143
1144            Ok(())
1145        }
1146    }
1147
1148    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BatteryInfo {
1149        #[inline(always)]
1150        fn new_empty() -> Self {
1151            Self::default()
1152        }
1153
1154        unsafe fn decode(
1155            &mut self,
1156            decoder: &mut fidl::encoding::Decoder<'_, D>,
1157            offset: usize,
1158            mut depth: fidl::encoding::Depth,
1159        ) -> fidl::Result<()> {
1160            decoder.debug_check_bounds::<Self>(offset);
1161            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1162                None => return Err(fidl::Error::NotNullable),
1163                Some(len) => len,
1164            };
1165            // Calling decoder.out_of_line_offset(0) is not allowed.
1166            if len == 0 {
1167                return Ok(());
1168            };
1169            depth.increment()?;
1170            let envelope_size = 8;
1171            let bytes_len = len * envelope_size;
1172            let offset = decoder.out_of_line_offset(bytes_len)?;
1173            // Decode the envelope for each type.
1174            let mut _next_ordinal_to_read = 0;
1175            let mut next_offset = offset;
1176            let end_offset = offset + bytes_len;
1177            _next_ordinal_to_read += 1;
1178            if next_offset >= end_offset {
1179                return Ok(());
1180            }
1181
1182            // Decode unknown envelopes for gaps in ordinals.
1183            while _next_ordinal_to_read < 1 {
1184                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1185                _next_ordinal_to_read += 1;
1186                next_offset += envelope_size;
1187            }
1188
1189            let next_out_of_line = decoder.next_out_of_line();
1190            let handles_before = decoder.remaining_handles();
1191            if let Some((inlined, num_bytes, num_handles)) =
1192                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1193            {
1194                let member_inline_size =
1195                    <BatteryStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1196                if inlined != (member_inline_size <= 4) {
1197                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1198                }
1199                let inner_offset;
1200                let mut inner_depth = depth.clone();
1201                if inlined {
1202                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1203                    inner_offset = next_offset;
1204                } else {
1205                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1206                    inner_depth.increment()?;
1207                }
1208                let val_ref = self.status.get_or_insert_with(|| fidl::new_empty!(BatteryStatus, D));
1209                fidl::decode!(BatteryStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
1210                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1211                {
1212                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1213                }
1214                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1215                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1216                }
1217            }
1218
1219            next_offset += envelope_size;
1220            _next_ordinal_to_read += 1;
1221            if next_offset >= end_offset {
1222                return Ok(());
1223            }
1224
1225            // Decode unknown envelopes for gaps in ordinals.
1226            while _next_ordinal_to_read < 2 {
1227                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1228                _next_ordinal_to_read += 1;
1229                next_offset += envelope_size;
1230            }
1231
1232            let next_out_of_line = decoder.next_out_of_line();
1233            let handles_before = decoder.remaining_handles();
1234            if let Some((inlined, num_bytes, num_handles)) =
1235                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1236            {
1237                let member_inline_size =
1238                    <ChargeStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1239                if inlined != (member_inline_size <= 4) {
1240                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1241                }
1242                let inner_offset;
1243                let mut inner_depth = depth.clone();
1244                if inlined {
1245                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1246                    inner_offset = next_offset;
1247                } else {
1248                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1249                    inner_depth.increment()?;
1250                }
1251                let val_ref =
1252                    self.charge_status.get_or_insert_with(|| fidl::new_empty!(ChargeStatus, D));
1253                fidl::decode!(ChargeStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
1254                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1255                {
1256                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1257                }
1258                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1259                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1260                }
1261            }
1262
1263            next_offset += envelope_size;
1264            _next_ordinal_to_read += 1;
1265            if next_offset >= end_offset {
1266                return Ok(());
1267            }
1268
1269            // Decode unknown envelopes for gaps in ordinals.
1270            while _next_ordinal_to_read < 3 {
1271                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1272                _next_ordinal_to_read += 1;
1273                next_offset += envelope_size;
1274            }
1275
1276            let next_out_of_line = decoder.next_out_of_line();
1277            let handles_before = decoder.remaining_handles();
1278            if let Some((inlined, num_bytes, num_handles)) =
1279                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1280            {
1281                let member_inline_size =
1282                    <ChargeSource as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1283                if inlined != (member_inline_size <= 4) {
1284                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1285                }
1286                let inner_offset;
1287                let mut inner_depth = depth.clone();
1288                if inlined {
1289                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1290                    inner_offset = next_offset;
1291                } else {
1292                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1293                    inner_depth.increment()?;
1294                }
1295                let val_ref =
1296                    self.charge_source.get_or_insert_with(|| fidl::new_empty!(ChargeSource, D));
1297                fidl::decode!(ChargeSource, D, val_ref, decoder, inner_offset, inner_depth)?;
1298                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1299                {
1300                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1301                }
1302                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1303                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1304                }
1305            }
1306
1307            next_offset += envelope_size;
1308            _next_ordinal_to_read += 1;
1309            if next_offset >= end_offset {
1310                return Ok(());
1311            }
1312
1313            // Decode unknown envelopes for gaps in ordinals.
1314            while _next_ordinal_to_read < 4 {
1315                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1316                _next_ordinal_to_read += 1;
1317                next_offset += envelope_size;
1318            }
1319
1320            let next_out_of_line = decoder.next_out_of_line();
1321            let handles_before = decoder.remaining_handles();
1322            if let Some((inlined, num_bytes, num_handles)) =
1323                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1324            {
1325                let member_inline_size =
1326                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1327                if inlined != (member_inline_size <= 4) {
1328                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1329                }
1330                let inner_offset;
1331                let mut inner_depth = depth.clone();
1332                if inlined {
1333                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1334                    inner_offset = next_offset;
1335                } else {
1336                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1337                    inner_depth.increment()?;
1338                }
1339                let val_ref = self.level_percent.get_or_insert_with(|| fidl::new_empty!(f32, D));
1340                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
1341                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1342                {
1343                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1344                }
1345                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1346                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1347                }
1348            }
1349
1350            next_offset += envelope_size;
1351            _next_ordinal_to_read += 1;
1352            if next_offset >= end_offset {
1353                return Ok(());
1354            }
1355
1356            // Decode unknown envelopes for gaps in ordinals.
1357            while _next_ordinal_to_read < 5 {
1358                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1359                _next_ordinal_to_read += 1;
1360                next_offset += envelope_size;
1361            }
1362
1363            let next_out_of_line = decoder.next_out_of_line();
1364            let handles_before = decoder.remaining_handles();
1365            if let Some((inlined, num_bytes, num_handles)) =
1366                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1367            {
1368                let member_inline_size =
1369                    <LevelStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1370                if inlined != (member_inline_size <= 4) {
1371                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1372                }
1373                let inner_offset;
1374                let mut inner_depth = depth.clone();
1375                if inlined {
1376                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1377                    inner_offset = next_offset;
1378                } else {
1379                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1380                    inner_depth.increment()?;
1381                }
1382                let val_ref =
1383                    self.level_status.get_or_insert_with(|| fidl::new_empty!(LevelStatus, D));
1384                fidl::decode!(LevelStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
1385                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1386                {
1387                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1388                }
1389                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1390                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1391                }
1392            }
1393
1394            next_offset += envelope_size;
1395            _next_ordinal_to_read += 1;
1396            if next_offset >= end_offset {
1397                return Ok(());
1398            }
1399
1400            // Decode unknown envelopes for gaps in ordinals.
1401            while _next_ordinal_to_read < 6 {
1402                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1403                _next_ordinal_to_read += 1;
1404                next_offset += envelope_size;
1405            }
1406
1407            let next_out_of_line = decoder.next_out_of_line();
1408            let handles_before = decoder.remaining_handles();
1409            if let Some((inlined, num_bytes, num_handles)) =
1410                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1411            {
1412                let member_inline_size =
1413                    <HealthStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1414                if inlined != (member_inline_size <= 4) {
1415                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1416                }
1417                let inner_offset;
1418                let mut inner_depth = depth.clone();
1419                if inlined {
1420                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1421                    inner_offset = next_offset;
1422                } else {
1423                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1424                    inner_depth.increment()?;
1425                }
1426                let val_ref = self.health.get_or_insert_with(|| fidl::new_empty!(HealthStatus, D));
1427                fidl::decode!(HealthStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
1428                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1429                {
1430                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1431                }
1432                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1433                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1434                }
1435            }
1436
1437            next_offset += envelope_size;
1438            _next_ordinal_to_read += 1;
1439            if next_offset >= end_offset {
1440                return Ok(());
1441            }
1442
1443            // Decode unknown envelopes for gaps in ordinals.
1444            while _next_ordinal_to_read < 7 {
1445                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1446                _next_ordinal_to_read += 1;
1447                next_offset += envelope_size;
1448            }
1449
1450            let next_out_of_line = decoder.next_out_of_line();
1451            let handles_before = decoder.remaining_handles();
1452            if let Some((inlined, num_bytes, num_handles)) =
1453                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1454            {
1455                let member_inline_size =
1456                    <TimeRemaining as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1457                if inlined != (member_inline_size <= 4) {
1458                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1459                }
1460                let inner_offset;
1461                let mut inner_depth = depth.clone();
1462                if inlined {
1463                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1464                    inner_offset = next_offset;
1465                } else {
1466                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1467                    inner_depth.increment()?;
1468                }
1469                let val_ref =
1470                    self.time_remaining.get_or_insert_with(|| fidl::new_empty!(TimeRemaining, D));
1471                fidl::decode!(TimeRemaining, D, val_ref, decoder, inner_offset, inner_depth)?;
1472                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1473                {
1474                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1475                }
1476                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1477                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1478                }
1479            }
1480
1481            next_offset += envelope_size;
1482            _next_ordinal_to_read += 1;
1483            if next_offset >= end_offset {
1484                return Ok(());
1485            }
1486
1487            // Decode unknown envelopes for gaps in ordinals.
1488            while _next_ordinal_to_read < 8 {
1489                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1490                _next_ordinal_to_read += 1;
1491                next_offset += envelope_size;
1492            }
1493
1494            let next_out_of_line = decoder.next_out_of_line();
1495            let handles_before = decoder.remaining_handles();
1496            if let Some((inlined, num_bytes, num_handles)) =
1497                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1498            {
1499                let member_inline_size =
1500                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1501                if inlined != (member_inline_size <= 4) {
1502                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1503                }
1504                let inner_offset;
1505                let mut inner_depth = depth.clone();
1506                if inlined {
1507                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1508                    inner_offset = next_offset;
1509                } else {
1510                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1511                    inner_depth.increment()?;
1512                }
1513                let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
1514                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1515                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1516                {
1517                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1518                }
1519                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1520                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1521                }
1522            }
1523
1524            next_offset += envelope_size;
1525            _next_ordinal_to_read += 1;
1526            if next_offset >= end_offset {
1527                return Ok(());
1528            }
1529
1530            // Decode unknown envelopes for gaps in ordinals.
1531            while _next_ordinal_to_read < 9 {
1532                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1533                _next_ordinal_to_read += 1;
1534                next_offset += envelope_size;
1535            }
1536
1537            let next_out_of_line = decoder.next_out_of_line();
1538            let handles_before = decoder.remaining_handles();
1539            if let Some((inlined, num_bytes, num_handles)) =
1540                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1541            {
1542                let member_inline_size =
1543                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1544                if inlined != (member_inline_size <= 4) {
1545                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1546                }
1547                let inner_offset;
1548                let mut inner_depth = depth.clone();
1549                if inlined {
1550                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1551                    inner_offset = next_offset;
1552                } else {
1553                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1554                    inner_depth.increment()?;
1555                }
1556                let val_ref =
1557                    self.present_voltage_mv.get_or_insert_with(|| fidl::new_empty!(u32, D));
1558                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1559                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1560                {
1561                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1562                }
1563                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1564                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1565                }
1566            }
1567
1568            next_offset += envelope_size;
1569            _next_ordinal_to_read += 1;
1570            if next_offset >= end_offset {
1571                return Ok(());
1572            }
1573
1574            // Decode unknown envelopes for gaps in ordinals.
1575            while _next_ordinal_to_read < 10 {
1576                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1577                _next_ordinal_to_read += 1;
1578                next_offset += envelope_size;
1579            }
1580
1581            let next_out_of_line = decoder.next_out_of_line();
1582            let handles_before = decoder.remaining_handles();
1583            if let Some((inlined, num_bytes, num_handles)) =
1584                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1585            {
1586                let member_inline_size =
1587                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1588                if inlined != (member_inline_size <= 4) {
1589                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1590                }
1591                let inner_offset;
1592                let mut inner_depth = depth.clone();
1593                if inlined {
1594                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1595                    inner_offset = next_offset;
1596                } else {
1597                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1598                    inner_depth.increment()?;
1599                }
1600                let val_ref =
1601                    self.remaining_capacity_uah.get_or_insert_with(|| fidl::new_empty!(u32, D));
1602                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1603                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1604                {
1605                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1606                }
1607                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1608                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1609                }
1610            }
1611
1612            next_offset += envelope_size;
1613            _next_ordinal_to_read += 1;
1614            if next_offset >= end_offset {
1615                return Ok(());
1616            }
1617
1618            // Decode unknown envelopes for gaps in ordinals.
1619            while _next_ordinal_to_read < 11 {
1620                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1621                _next_ordinal_to_read += 1;
1622                next_offset += envelope_size;
1623            }
1624
1625            let next_out_of_line = decoder.next_out_of_line();
1626            let handles_before = decoder.remaining_handles();
1627            if let Some((inlined, num_bytes, num_handles)) =
1628                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1629            {
1630                let member_inline_size =
1631                    <BatterySpec as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1632                if inlined != (member_inline_size <= 4) {
1633                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1634                }
1635                let inner_offset;
1636                let mut inner_depth = depth.clone();
1637                if inlined {
1638                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1639                    inner_offset = next_offset;
1640                } else {
1641                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1642                    inner_depth.increment()?;
1643                }
1644                let val_ref =
1645                    self.battery_spec.get_or_insert_with(|| fidl::new_empty!(BatterySpec, D));
1646                fidl::decode!(BatterySpec, D, val_ref, decoder, inner_offset, inner_depth)?;
1647                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1648                {
1649                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1650                }
1651                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1652                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1653                }
1654            }
1655
1656            next_offset += envelope_size;
1657
1658            // Decode the remaining unknown envelopes.
1659            while next_offset < end_offset {
1660                _next_ordinal_to_read += 1;
1661                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1662                next_offset += envelope_size;
1663            }
1664
1665            Ok(())
1666        }
1667    }
1668
1669    impl BatterySpec {
1670        #[inline(always)]
1671        fn max_ordinal_present(&self) -> u64 {
1672            if let Some(_) = self.design_capacity_uah {
1673                return 3;
1674            }
1675            if let Some(_) = self.max_charnging_voltage_uv {
1676                return 2;
1677            }
1678            if let Some(_) = self.max_charging_current_ua {
1679                return 1;
1680            }
1681            0
1682        }
1683    }
1684
1685    impl fidl::encoding::ValueTypeMarker for BatterySpec {
1686        type Borrowed<'a> = &'a Self;
1687        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1688            value
1689        }
1690    }
1691
1692    unsafe impl fidl::encoding::TypeMarker for BatterySpec {
1693        type Owned = Self;
1694
1695        #[inline(always)]
1696        fn inline_align(_context: fidl::encoding::Context) -> usize {
1697            8
1698        }
1699
1700        #[inline(always)]
1701        fn inline_size(_context: fidl::encoding::Context) -> usize {
1702            16
1703        }
1704    }
1705
1706    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BatterySpec, D>
1707        for &BatterySpec
1708    {
1709        unsafe fn encode(
1710            self,
1711            encoder: &mut fidl::encoding::Encoder<'_, D>,
1712            offset: usize,
1713            mut depth: fidl::encoding::Depth,
1714        ) -> fidl::Result<()> {
1715            encoder.debug_check_bounds::<BatterySpec>(offset);
1716            // Vector header
1717            let max_ordinal: u64 = self.max_ordinal_present();
1718            encoder.write_num(max_ordinal, offset);
1719            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1720            // Calling encoder.out_of_line_offset(0) is not allowed.
1721            if max_ordinal == 0 {
1722                return Ok(());
1723            }
1724            depth.increment()?;
1725            let envelope_size = 8;
1726            let bytes_len = max_ordinal as usize * envelope_size;
1727            #[allow(unused_variables)]
1728            let offset = encoder.out_of_line_offset(bytes_len);
1729            let mut _prev_end_offset: usize = 0;
1730            if 1 > max_ordinal {
1731                return Ok(());
1732            }
1733
1734            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1735            // are envelope_size bytes.
1736            let cur_offset: usize = (1 - 1) * envelope_size;
1737
1738            // Zero reserved fields.
1739            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1740
1741            // Safety:
1742            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1743            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1744            //   envelope_size bytes, there is always sufficient room.
1745            fidl::encoding::encode_in_envelope_optional::<i32, D>(
1746                self.max_charging_current_ua
1747                    .as_ref()
1748                    .map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1749                encoder,
1750                offset + cur_offset,
1751                depth,
1752            )?;
1753
1754            _prev_end_offset = cur_offset + envelope_size;
1755            if 2 > max_ordinal {
1756                return Ok(());
1757            }
1758
1759            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1760            // are envelope_size bytes.
1761            let cur_offset: usize = (2 - 1) * envelope_size;
1762
1763            // Zero reserved fields.
1764            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1765
1766            // Safety:
1767            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1768            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1769            //   envelope_size bytes, there is always sufficient room.
1770            fidl::encoding::encode_in_envelope_optional::<i32, D>(
1771                self.max_charnging_voltage_uv
1772                    .as_ref()
1773                    .map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1774                encoder,
1775                offset + cur_offset,
1776                depth,
1777            )?;
1778
1779            _prev_end_offset = cur_offset + envelope_size;
1780            if 3 > max_ordinal {
1781                return Ok(());
1782            }
1783
1784            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1785            // are envelope_size bytes.
1786            let cur_offset: usize = (3 - 1) * envelope_size;
1787
1788            // Zero reserved fields.
1789            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1790
1791            // Safety:
1792            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1793            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1794            //   envelope_size bytes, there is always sufficient room.
1795            fidl::encoding::encode_in_envelope_optional::<i32, D>(
1796                self.design_capacity_uah
1797                    .as_ref()
1798                    .map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1799                encoder,
1800                offset + cur_offset,
1801                depth,
1802            )?;
1803
1804            _prev_end_offset = cur_offset + envelope_size;
1805
1806            Ok(())
1807        }
1808    }
1809
1810    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BatterySpec {
1811        #[inline(always)]
1812        fn new_empty() -> Self {
1813            Self::default()
1814        }
1815
1816        unsafe fn decode(
1817            &mut self,
1818            decoder: &mut fidl::encoding::Decoder<'_, D>,
1819            offset: usize,
1820            mut depth: fidl::encoding::Depth,
1821        ) -> fidl::Result<()> {
1822            decoder.debug_check_bounds::<Self>(offset);
1823            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1824                None => return Err(fidl::Error::NotNullable),
1825                Some(len) => len,
1826            };
1827            // Calling decoder.out_of_line_offset(0) is not allowed.
1828            if len == 0 {
1829                return Ok(());
1830            };
1831            depth.increment()?;
1832            let envelope_size = 8;
1833            let bytes_len = len * envelope_size;
1834            let offset = decoder.out_of_line_offset(bytes_len)?;
1835            // Decode the envelope for each type.
1836            let mut _next_ordinal_to_read = 0;
1837            let mut next_offset = offset;
1838            let end_offset = offset + bytes_len;
1839            _next_ordinal_to_read += 1;
1840            if next_offset >= end_offset {
1841                return Ok(());
1842            }
1843
1844            // Decode unknown envelopes for gaps in ordinals.
1845            while _next_ordinal_to_read < 1 {
1846                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1847                _next_ordinal_to_read += 1;
1848                next_offset += envelope_size;
1849            }
1850
1851            let next_out_of_line = decoder.next_out_of_line();
1852            let handles_before = decoder.remaining_handles();
1853            if let Some((inlined, num_bytes, num_handles)) =
1854                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1855            {
1856                let member_inline_size =
1857                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1858                if inlined != (member_inline_size <= 4) {
1859                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1860                }
1861                let inner_offset;
1862                let mut inner_depth = depth.clone();
1863                if inlined {
1864                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1865                    inner_offset = next_offset;
1866                } else {
1867                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1868                    inner_depth.increment()?;
1869                }
1870                let val_ref =
1871                    self.max_charging_current_ua.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 < 2 {
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.max_charnging_voltage_uv.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 < 3 {
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.design_capacity_uah.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 fidl::encoding::ValueTypeMarker for TimeRemaining {
1984        type Borrowed<'a> = &'a Self;
1985        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1986            value
1987        }
1988    }
1989
1990    unsafe impl fidl::encoding::TypeMarker for TimeRemaining {
1991        type Owned = Self;
1992
1993        #[inline(always)]
1994        fn inline_align(_context: fidl::encoding::Context) -> usize {
1995            8
1996        }
1997
1998        #[inline(always)]
1999        fn inline_size(_context: fidl::encoding::Context) -> usize {
2000            16
2001        }
2002    }
2003
2004    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TimeRemaining, D>
2005        for &TimeRemaining
2006    {
2007        #[inline]
2008        unsafe fn encode(
2009            self,
2010            encoder: &mut fidl::encoding::Encoder<'_, D>,
2011            offset: usize,
2012            _depth: fidl::encoding::Depth,
2013        ) -> fidl::Result<()> {
2014            encoder.debug_check_bounds::<TimeRemaining>(offset);
2015            encoder.write_num::<u64>(self.ordinal(), offset);
2016            match self {
2017                TimeRemaining::Indeterminate(ref val) => {
2018                    fidl::encoding::encode_in_envelope::<i64, D>(
2019                        <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2020                        encoder,
2021                        offset + 8,
2022                        _depth,
2023                    )
2024                }
2025                TimeRemaining::BatteryLife(ref val) => {
2026                    fidl::encoding::encode_in_envelope::<i64, D>(
2027                        <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2028                        encoder,
2029                        offset + 8,
2030                        _depth,
2031                    )
2032                }
2033                TimeRemaining::FullCharge(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
2034                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2035                    encoder,
2036                    offset + 8,
2037                    _depth,
2038                ),
2039                TimeRemaining::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2040            }
2041        }
2042    }
2043
2044    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TimeRemaining {
2045        #[inline(always)]
2046        fn new_empty() -> Self {
2047            Self::__SourceBreaking { unknown_ordinal: 0 }
2048        }
2049
2050        #[inline]
2051        unsafe fn decode(
2052            &mut self,
2053            decoder: &mut fidl::encoding::Decoder<'_, D>,
2054            offset: usize,
2055            mut depth: fidl::encoding::Depth,
2056        ) -> fidl::Result<()> {
2057            decoder.debug_check_bounds::<Self>(offset);
2058            #[allow(unused_variables)]
2059            let next_out_of_line = decoder.next_out_of_line();
2060            let handles_before = decoder.remaining_handles();
2061            let (ordinal, inlined, num_bytes, num_handles) =
2062                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2063
2064            let member_inline_size = match ordinal {
2065                1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2066                2 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2067                3 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2068                0 => return Err(fidl::Error::UnknownUnionTag),
2069                _ => num_bytes as usize,
2070            };
2071
2072            if inlined != (member_inline_size <= 4) {
2073                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2074            }
2075            let _inner_offset;
2076            if inlined {
2077                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2078                _inner_offset = offset + 8;
2079            } else {
2080                depth.increment()?;
2081                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2082            }
2083            match ordinal {
2084                1 => {
2085                    #[allow(irrefutable_let_patterns)]
2086                    if let TimeRemaining::Indeterminate(_) = self {
2087                        // Do nothing, read the value into the object
2088                    } else {
2089                        // Initialize `self` to the right variant
2090                        *self = TimeRemaining::Indeterminate(fidl::new_empty!(i64, D));
2091                    }
2092                    #[allow(irrefutable_let_patterns)]
2093                    if let TimeRemaining::Indeterminate(ref mut val) = self {
2094                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
2095                    } else {
2096                        unreachable!()
2097                    }
2098                }
2099                2 => {
2100                    #[allow(irrefutable_let_patterns)]
2101                    if let TimeRemaining::BatteryLife(_) = self {
2102                        // Do nothing, read the value into the object
2103                    } else {
2104                        // Initialize `self` to the right variant
2105                        *self = TimeRemaining::BatteryLife(fidl::new_empty!(i64, D));
2106                    }
2107                    #[allow(irrefutable_let_patterns)]
2108                    if let TimeRemaining::BatteryLife(ref mut val) = self {
2109                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
2110                    } else {
2111                        unreachable!()
2112                    }
2113                }
2114                3 => {
2115                    #[allow(irrefutable_let_patterns)]
2116                    if let TimeRemaining::FullCharge(_) = self {
2117                        // Do nothing, read the value into the object
2118                    } else {
2119                        // Initialize `self` to the right variant
2120                        *self = TimeRemaining::FullCharge(fidl::new_empty!(i64, D));
2121                    }
2122                    #[allow(irrefutable_let_patterns)]
2123                    if let TimeRemaining::FullCharge(ref mut val) = self {
2124                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
2125                    } else {
2126                        unreachable!()
2127                    }
2128                }
2129                #[allow(deprecated)]
2130                ordinal => {
2131                    for _ in 0..num_handles {
2132                        decoder.drop_next_handle()?;
2133                    }
2134                    *self = TimeRemaining::__SourceBreaking { unknown_ordinal: ordinal };
2135                }
2136            }
2137            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2138                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2139            }
2140            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2141                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2142            }
2143            Ok(())
2144        }
2145    }
2146}