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