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