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