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(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12pub struct LocalDevice;
13
14impl fidl::Persistable for LocalDevice {}
15
16#[derive(Clone, Debug, PartialEq)]
17pub struct WatcherWatchRequest {
18 pub ids: Vec<Identifier>,
19}
20
21impl fidl::Persistable for WatcherWatchRequest {}
22
23#[derive(Clone, Debug, PartialEq)]
24pub struct WatcherWatchResponse {
25 pub peripherals: Vec<Information>,
26}
27
28impl fidl::Persistable for WatcherWatchResponse {}
29
30#[derive(Clone, Debug, Default, PartialEq)]
32pub struct Information {
33 pub identifier: Option<Identifier>,
35 pub battery_info: Option<fidl_fuchsia_power_battery__common::BatteryInfo>,
42 #[doc(hidden)]
43 pub __source_breaking: fidl::marker::SourceBreaking,
44}
45
46impl fidl::Persistable for Information {}
47
48#[derive(Clone, Debug)]
50pub enum Identifier {
51 LocalDevice(LocalDevice),
52 PeerId(fidl_fuchsia_bluetooth__common::PeerId),
53 #[doc(hidden)]
54 __SourceBreaking {
55 unknown_ordinal: u64,
56 },
57}
58
59#[macro_export]
61macro_rules! IdentifierUnknown {
62 () => {
63 _
64 };
65}
66
67impl PartialEq for Identifier {
69 fn eq(&self, other: &Self) -> bool {
70 match (self, other) {
71 (Self::LocalDevice(x), Self::LocalDevice(y)) => *x == *y,
72 (Self::PeerId(x), Self::PeerId(y)) => *x == *y,
73 _ => false,
74 }
75 }
76}
77
78impl Identifier {
79 #[inline]
80 pub fn ordinal(&self) -> u64 {
81 match *self {
82 Self::LocalDevice(_) => 1,
83 Self::PeerId(_) => 2,
84 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
85 }
86 }
87
88 #[inline]
89 pub fn unknown_variant_for_testing() -> Self {
90 Self::__SourceBreaking { unknown_ordinal: 0 }
91 }
92
93 #[inline]
94 pub fn is_unknown(&self) -> bool {
95 match self {
96 Self::__SourceBreaking { .. } => true,
97 _ => false,
98 }
99 }
100}
101
102impl fidl::Persistable for Identifier {}
103
104pub mod reporter_ordinals {
105 pub const REPORT: u64 = 0x282927fd7363f17f;
106}
107
108pub mod watcher_ordinals {
109 pub const WATCH: u64 = 0x7cc4d24741dddb85;
110}
111
112mod internal {
113 use super::*;
114
115 impl fidl::encoding::ValueTypeMarker for LocalDevice {
116 type Borrowed<'a> = &'a Self;
117 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
118 value
119 }
120 }
121
122 unsafe impl fidl::encoding::TypeMarker for LocalDevice {
123 type Owned = Self;
124
125 #[inline(always)]
126 fn inline_align(_context: fidl::encoding::Context) -> usize {
127 1
128 }
129
130 #[inline(always)]
131 fn inline_size(_context: fidl::encoding::Context) -> usize {
132 1
133 }
134 }
135
136 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LocalDevice, D>
137 for &LocalDevice
138 {
139 #[inline]
140 unsafe fn encode(
141 self,
142 encoder: &mut fidl::encoding::Encoder<'_, D>,
143 offset: usize,
144 _depth: fidl::encoding::Depth,
145 ) -> fidl::Result<()> {
146 encoder.debug_check_bounds::<LocalDevice>(offset);
147 encoder.write_num(0u8, offset);
148 Ok(())
149 }
150 }
151
152 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LocalDevice {
153 #[inline(always)]
154 fn new_empty() -> Self {
155 Self
156 }
157
158 #[inline]
159 unsafe fn decode(
160 &mut self,
161 decoder: &mut fidl::encoding::Decoder<'_, D>,
162 offset: usize,
163 _depth: fidl::encoding::Depth,
164 ) -> fidl::Result<()> {
165 decoder.debug_check_bounds::<Self>(offset);
166 match decoder.read_num::<u8>(offset) {
167 0 => Ok(()),
168 _ => Err(fidl::Error::Invalid),
169 }
170 }
171 }
172
173 impl fidl::encoding::ValueTypeMarker for WatcherWatchRequest {
174 type Borrowed<'a> = &'a Self;
175 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
176 value
177 }
178 }
179
180 unsafe impl fidl::encoding::TypeMarker for WatcherWatchRequest {
181 type Owned = Self;
182
183 #[inline(always)]
184 fn inline_align(_context: fidl::encoding::Context) -> usize {
185 8
186 }
187
188 #[inline(always)]
189 fn inline_size(_context: fidl::encoding::Context) -> usize {
190 16
191 }
192 }
193
194 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WatcherWatchRequest, D>
195 for &WatcherWatchRequest
196 {
197 #[inline]
198 unsafe fn encode(
199 self,
200 encoder: &mut fidl::encoding::Encoder<'_, D>,
201 offset: usize,
202 _depth: fidl::encoding::Depth,
203 ) -> fidl::Result<()> {
204 encoder.debug_check_bounds::<WatcherWatchRequest>(offset);
205 fidl::encoding::Encode::<WatcherWatchRequest, D>::encode(
207 (
208 <fidl::encoding::UnboundedVector<Identifier> as fidl::encoding::ValueTypeMarker>::borrow(&self.ids),
209 ),
210 encoder, offset, _depth
211 )
212 }
213 }
214 unsafe impl<
215 D: fidl::encoding::ResourceDialect,
216 T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<Identifier>, D>,
217 > fidl::encoding::Encode<WatcherWatchRequest, D> for (T0,)
218 {
219 #[inline]
220 unsafe fn encode(
221 self,
222 encoder: &mut fidl::encoding::Encoder<'_, D>,
223 offset: usize,
224 depth: fidl::encoding::Depth,
225 ) -> fidl::Result<()> {
226 encoder.debug_check_bounds::<WatcherWatchRequest>(offset);
227 self.0.encode(encoder, offset + 0, depth)?;
231 Ok(())
232 }
233 }
234
235 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WatcherWatchRequest {
236 #[inline(always)]
237 fn new_empty() -> Self {
238 Self { ids: fidl::new_empty!(fidl::encoding::UnboundedVector<Identifier>, D) }
239 }
240
241 #[inline]
242 unsafe fn decode(
243 &mut self,
244 decoder: &mut fidl::encoding::Decoder<'_, D>,
245 offset: usize,
246 _depth: fidl::encoding::Depth,
247 ) -> fidl::Result<()> {
248 decoder.debug_check_bounds::<Self>(offset);
249 fidl::decode!(
251 fidl::encoding::UnboundedVector<Identifier>,
252 D,
253 &mut self.ids,
254 decoder,
255 offset + 0,
256 _depth
257 )?;
258 Ok(())
259 }
260 }
261
262 impl fidl::encoding::ValueTypeMarker for WatcherWatchResponse {
263 type Borrowed<'a> = &'a Self;
264 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
265 value
266 }
267 }
268
269 unsafe impl fidl::encoding::TypeMarker for WatcherWatchResponse {
270 type Owned = Self;
271
272 #[inline(always)]
273 fn inline_align(_context: fidl::encoding::Context) -> usize {
274 8
275 }
276
277 #[inline(always)]
278 fn inline_size(_context: fidl::encoding::Context) -> usize {
279 16
280 }
281 }
282
283 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WatcherWatchResponse, D>
284 for &WatcherWatchResponse
285 {
286 #[inline]
287 unsafe fn encode(
288 self,
289 encoder: &mut fidl::encoding::Encoder<'_, D>,
290 offset: usize,
291 _depth: fidl::encoding::Depth,
292 ) -> fidl::Result<()> {
293 encoder.debug_check_bounds::<WatcherWatchResponse>(offset);
294 fidl::encoding::Encode::<WatcherWatchResponse, D>::encode(
296 (
297 <fidl::encoding::UnboundedVector<Information> as fidl::encoding::ValueTypeMarker>::borrow(&self.peripherals),
298 ),
299 encoder, offset, _depth
300 )
301 }
302 }
303 unsafe impl<
304 D: fidl::encoding::ResourceDialect,
305 T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<Information>, D>,
306 > fidl::encoding::Encode<WatcherWatchResponse, D> for (T0,)
307 {
308 #[inline]
309 unsafe fn encode(
310 self,
311 encoder: &mut fidl::encoding::Encoder<'_, D>,
312 offset: usize,
313 depth: fidl::encoding::Depth,
314 ) -> fidl::Result<()> {
315 encoder.debug_check_bounds::<WatcherWatchResponse>(offset);
316 self.0.encode(encoder, offset + 0, depth)?;
320 Ok(())
321 }
322 }
323
324 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WatcherWatchResponse {
325 #[inline(always)]
326 fn new_empty() -> Self {
327 Self { peripherals: fidl::new_empty!(fidl::encoding::UnboundedVector<Information>, D) }
328 }
329
330 #[inline]
331 unsafe fn decode(
332 &mut self,
333 decoder: &mut fidl::encoding::Decoder<'_, D>,
334 offset: usize,
335 _depth: fidl::encoding::Depth,
336 ) -> fidl::Result<()> {
337 decoder.debug_check_bounds::<Self>(offset);
338 fidl::decode!(
340 fidl::encoding::UnboundedVector<Information>,
341 D,
342 &mut self.peripherals,
343 decoder,
344 offset + 0,
345 _depth
346 )?;
347 Ok(())
348 }
349 }
350
351 impl Information {
352 #[inline(always)]
353 fn max_ordinal_present(&self) -> u64 {
354 if let Some(_) = self.battery_info {
355 return 2;
356 }
357 if let Some(_) = self.identifier {
358 return 1;
359 }
360 0
361 }
362 }
363
364 impl fidl::encoding::ValueTypeMarker for Information {
365 type Borrowed<'a> = &'a Self;
366 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
367 value
368 }
369 }
370
371 unsafe impl fidl::encoding::TypeMarker for Information {
372 type Owned = Self;
373
374 #[inline(always)]
375 fn inline_align(_context: fidl::encoding::Context) -> usize {
376 8
377 }
378
379 #[inline(always)]
380 fn inline_size(_context: fidl::encoding::Context) -> usize {
381 16
382 }
383 }
384
385 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Information, D>
386 for &Information
387 {
388 unsafe fn encode(
389 self,
390 encoder: &mut fidl::encoding::Encoder<'_, D>,
391 offset: usize,
392 mut depth: fidl::encoding::Depth,
393 ) -> fidl::Result<()> {
394 encoder.debug_check_bounds::<Information>(offset);
395 let max_ordinal: u64 = self.max_ordinal_present();
397 encoder.write_num(max_ordinal, offset);
398 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
399 if max_ordinal == 0 {
401 return Ok(());
402 }
403 depth.increment()?;
404 let envelope_size = 8;
405 let bytes_len = max_ordinal as usize * envelope_size;
406 #[allow(unused_variables)]
407 let offset = encoder.out_of_line_offset(bytes_len);
408 let mut _prev_end_offset: usize = 0;
409 if 1 > max_ordinal {
410 return Ok(());
411 }
412
413 let cur_offset: usize = (1 - 1) * envelope_size;
416
417 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
419
420 fidl::encoding::encode_in_envelope_optional::<Identifier, D>(
425 self.identifier
426 .as_ref()
427 .map(<Identifier as fidl::encoding::ValueTypeMarker>::borrow),
428 encoder,
429 offset + cur_offset,
430 depth,
431 )?;
432
433 _prev_end_offset = cur_offset + envelope_size;
434 if 2 > max_ordinal {
435 return Ok(());
436 }
437
438 let cur_offset: usize = (2 - 1) * envelope_size;
441
442 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
444
445 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_power_battery__common::BatteryInfo, D>(
450 self.battery_info.as_ref().map(<fidl_fuchsia_power_battery__common::BatteryInfo as fidl::encoding::ValueTypeMarker>::borrow),
451 encoder, offset + cur_offset, depth
452 )?;
453
454 _prev_end_offset = cur_offset + envelope_size;
455
456 Ok(())
457 }
458 }
459
460 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Information {
461 #[inline(always)]
462 fn new_empty() -> Self {
463 Self::default()
464 }
465
466 unsafe fn decode(
467 &mut self,
468 decoder: &mut fidl::encoding::Decoder<'_, D>,
469 offset: usize,
470 mut depth: fidl::encoding::Depth,
471 ) -> fidl::Result<()> {
472 decoder.debug_check_bounds::<Self>(offset);
473 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
474 None => return Err(fidl::Error::NotNullable),
475 Some(len) => len,
476 };
477 if len == 0 {
479 return Ok(());
480 };
481 depth.increment()?;
482 let envelope_size = 8;
483 let bytes_len = len * envelope_size;
484 let offset = decoder.out_of_line_offset(bytes_len)?;
485 let mut _next_ordinal_to_read = 0;
487 let mut next_offset = offset;
488 let end_offset = offset + bytes_len;
489 _next_ordinal_to_read += 1;
490 if next_offset >= end_offset {
491 return Ok(());
492 }
493
494 while _next_ordinal_to_read < 1 {
496 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
497 _next_ordinal_to_read += 1;
498 next_offset += envelope_size;
499 }
500
501 let next_out_of_line = decoder.next_out_of_line();
502 let handles_before = decoder.remaining_handles();
503 if let Some((inlined, num_bytes, num_handles)) =
504 fidl::encoding::decode_envelope_header(decoder, next_offset)?
505 {
506 let member_inline_size =
507 <Identifier as fidl::encoding::TypeMarker>::inline_size(decoder.context);
508 if inlined != (member_inline_size <= 4) {
509 return Err(fidl::Error::InvalidInlineBitInEnvelope);
510 }
511 let inner_offset;
512 let mut inner_depth = depth.clone();
513 if inlined {
514 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
515 inner_offset = next_offset;
516 } else {
517 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
518 inner_depth.increment()?;
519 }
520 let val_ref =
521 self.identifier.get_or_insert_with(|| fidl::new_empty!(Identifier, D));
522 fidl::decode!(Identifier, D, val_ref, decoder, inner_offset, inner_depth)?;
523 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
524 {
525 return Err(fidl::Error::InvalidNumBytesInEnvelope);
526 }
527 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
528 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
529 }
530 }
531
532 next_offset += envelope_size;
533 _next_ordinal_to_read += 1;
534 if next_offset >= end_offset {
535 return Ok(());
536 }
537
538 while _next_ordinal_to_read < 2 {
540 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
541 _next_ordinal_to_read += 1;
542 next_offset += envelope_size;
543 }
544
545 let next_out_of_line = decoder.next_out_of_line();
546 let handles_before = decoder.remaining_handles();
547 if let Some((inlined, num_bytes, num_handles)) =
548 fidl::encoding::decode_envelope_header(decoder, next_offset)?
549 {
550 let member_inline_size = <fidl_fuchsia_power_battery__common::BatteryInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
551 if inlined != (member_inline_size <= 4) {
552 return Err(fidl::Error::InvalidInlineBitInEnvelope);
553 }
554 let inner_offset;
555 let mut inner_depth = depth.clone();
556 if inlined {
557 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
558 inner_offset = next_offset;
559 } else {
560 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
561 inner_depth.increment()?;
562 }
563 let val_ref = self.battery_info.get_or_insert_with(|| {
564 fidl::new_empty!(fidl_fuchsia_power_battery__common::BatteryInfo, D)
565 });
566 fidl::decode!(
567 fidl_fuchsia_power_battery__common::BatteryInfo,
568 D,
569 val_ref,
570 decoder,
571 inner_offset,
572 inner_depth
573 )?;
574 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
575 {
576 return Err(fidl::Error::InvalidNumBytesInEnvelope);
577 }
578 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
579 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
580 }
581 }
582
583 next_offset += envelope_size;
584
585 while next_offset < end_offset {
587 _next_ordinal_to_read += 1;
588 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
589 next_offset += envelope_size;
590 }
591
592 Ok(())
593 }
594 }
595
596 impl fidl::encoding::ValueTypeMarker for Identifier {
597 type Borrowed<'a> = &'a Self;
598 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
599 value
600 }
601 }
602
603 unsafe impl fidl::encoding::TypeMarker for Identifier {
604 type Owned = Self;
605
606 #[inline(always)]
607 fn inline_align(_context: fidl::encoding::Context) -> usize {
608 8
609 }
610
611 #[inline(always)]
612 fn inline_size(_context: fidl::encoding::Context) -> usize {
613 16
614 }
615 }
616
617 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Identifier, D>
618 for &Identifier
619 {
620 #[inline]
621 unsafe fn encode(
622 self,
623 encoder: &mut fidl::encoding::Encoder<'_, D>,
624 offset: usize,
625 _depth: fidl::encoding::Depth,
626 ) -> fidl::Result<()> {
627 encoder.debug_check_bounds::<Identifier>(offset);
628 encoder.write_num::<u64>(self.ordinal(), offset);
629 match self {
630 Identifier::LocalDevice(ref val) => {
631 fidl::encoding::encode_in_envelope::<LocalDevice, D>(
632 <LocalDevice as fidl::encoding::ValueTypeMarker>::borrow(val),
633 encoder, offset + 8, _depth
634 )
635 }
636 Identifier::PeerId(ref val) => {
637 fidl::encoding::encode_in_envelope::<fidl_fuchsia_bluetooth__common::PeerId, D>(
638 <fidl_fuchsia_bluetooth__common::PeerId as fidl::encoding::ValueTypeMarker>::borrow(val),
639 encoder, offset + 8, _depth
640 )
641 }
642 Identifier::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
643 }
644 }
645 }
646
647 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Identifier {
648 #[inline(always)]
649 fn new_empty() -> Self {
650 Self::__SourceBreaking { unknown_ordinal: 0 }
651 }
652
653 #[inline]
654 unsafe fn decode(
655 &mut self,
656 decoder: &mut fidl::encoding::Decoder<'_, D>,
657 offset: usize,
658 mut depth: fidl::encoding::Depth,
659 ) -> fidl::Result<()> {
660 decoder.debug_check_bounds::<Self>(offset);
661 #[allow(unused_variables)]
662 let next_out_of_line = decoder.next_out_of_line();
663 let handles_before = decoder.remaining_handles();
664 let (ordinal, inlined, num_bytes, num_handles) =
665 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
666
667 let member_inline_size = match ordinal {
668 1 => <LocalDevice as fidl::encoding::TypeMarker>::inline_size(decoder.context),
669 2 => <fidl_fuchsia_bluetooth__common::PeerId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
670 0 => return Err(fidl::Error::UnknownUnionTag),
671 _ => num_bytes as usize,
672 };
673
674 if inlined != (member_inline_size <= 4) {
675 return Err(fidl::Error::InvalidInlineBitInEnvelope);
676 }
677 let _inner_offset;
678 if inlined {
679 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
680 _inner_offset = offset + 8;
681 } else {
682 depth.increment()?;
683 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
684 }
685 match ordinal {
686 1 => {
687 #[allow(irrefutable_let_patterns)]
688 if let Identifier::LocalDevice(_) = self {
689 } else {
691 *self = Identifier::LocalDevice(fidl::new_empty!(LocalDevice, D));
693 }
694 #[allow(irrefutable_let_patterns)]
695 if let Identifier::LocalDevice(ref mut val) = self {
696 fidl::decode!(LocalDevice, D, val, decoder, _inner_offset, depth)?;
697 } else {
698 unreachable!()
699 }
700 }
701 2 => {
702 #[allow(irrefutable_let_patterns)]
703 if let Identifier::PeerId(_) = self {
704 } else {
706 *self = Identifier::PeerId(fidl::new_empty!(
708 fidl_fuchsia_bluetooth__common::PeerId,
709 D
710 ));
711 }
712 #[allow(irrefutable_let_patterns)]
713 if let Identifier::PeerId(ref mut val) = self {
714 fidl::decode!(
715 fidl_fuchsia_bluetooth__common::PeerId,
716 D,
717 val,
718 decoder,
719 _inner_offset,
720 depth
721 )?;
722 } else {
723 unreachable!()
724 }
725 }
726 #[allow(deprecated)]
727 ordinal => {
728 for _ in 0..num_handles {
729 decoder.drop_next_handle()?;
730 }
731 *self = Identifier::__SourceBreaking { unknown_ordinal: ordinal };
732 }
733 }
734 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
735 return Err(fidl::Error::InvalidNumBytesInEnvelope);
736 }
737 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
738 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
739 }
740 Ok(())
741 }
742 }
743}