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
11pub type Name = String;
13
14pub const INTERFACE_NAME_LENGTH: u8 = 15;
16
17bitflags! {
18 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
19 pub struct AddressPropertiesInterest: u64 {
20 const VALID_UNTIL = 1;
21 const PREFERRED_LIFETIME_INFO = 2;
22 }
23}
24
25impl AddressPropertiesInterest {
26 #[inline(always)]
27 pub fn from_bits_allow_unknown(bits: u64) -> Self {
28 Self::from_bits_retain(bits)
29 }
30
31 #[inline(always)]
32 pub fn has_unknown_bits(&self) -> bool {
33 self.get_unknown_bits() != 0
34 }
35
36 #[inline(always)]
37 pub fn get_unknown_bits(&self) -> u64 {
38 self.bits() & !Self::all().bits()
39 }
40}
41
42#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
44#[repr(u32)]
45pub enum AddressAssignmentState {
46 Tentative = 1,
53 Assigned = 2,
55 Unavailable = 3,
58}
59
60impl AddressAssignmentState {
61 #[inline]
62 pub fn from_primitive(prim: u32) -> Option<Self> {
63 match prim {
64 1 => Some(Self::Tentative),
65 2 => Some(Self::Assigned),
66 3 => Some(Self::Unavailable),
67 _ => None,
68 }
69 }
70
71 #[inline]
72 pub const fn into_primitive(self) -> u32 {
73 self as u32
74 }
75
76 #[deprecated = "Strict enums should not use `is_unknown`"]
77 #[inline]
78 pub fn is_unknown(&self) -> bool {
79 false
80 }
81}
82
83#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
84pub struct Empty;
85
86impl fidl::Persistable for Empty {}
87
88#[derive(Clone, Debug, PartialEq)]
89pub struct WatcherWatchResponse {
90 pub event: Event,
91}
92
93impl fidl::Persistable for WatcherWatchResponse {}
94
95#[derive(Clone, Debug, Default, PartialEq)]
96pub struct Address {
97 pub addr: Option<fidl_fuchsia_net::Subnet>,
101 pub valid_until: Option<i64>,
114 pub preferred_lifetime_info: Option<PreferredLifetimeInfo>,
118 pub assignment_state: Option<AddressAssignmentState>,
122 #[doc(hidden)]
123 pub __source_breaking: fidl::marker::SourceBreaking,
124}
125
126impl fidl::Persistable for Address {}
127
128#[derive(Clone, Debug, Default, PartialEq)]
130pub struct Properties {
131 pub id: Option<u64>,
134 pub addresses: Option<Vec<Address>>,
142 pub online: Option<bool>,
144 pub device_class: Option<DeviceClass>,
150 pub has_default_ipv4_route: Option<bool>,
152 pub has_default_ipv6_route: Option<bool>,
154 pub name: Option<String>,
156 pub port_class: Option<PortClass>,
158 #[doc(hidden)]
159 pub __source_breaking: fidl::marker::SourceBreaking,
160}
161
162impl fidl::Persistable for Properties {}
163
164#[derive(Clone, Debug, Default, PartialEq)]
165pub struct WatcherOptions {
166 pub address_properties_interest: Option<AddressPropertiesInterest>,
170 pub include_non_assigned_addresses: Option<bool>,
176 #[doc(hidden)]
177 pub __source_breaking: fidl::marker::SourceBreaking,
178}
179
180impl fidl::Persistable for WatcherOptions {}
181
182#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
183pub enum DeviceClass {
184 Loopback(Empty),
186 Device(fidl_fuchsia_hardware_network::DeviceClass),
187}
188
189impl DeviceClass {
190 #[inline]
191 pub fn ordinal(&self) -> u64 {
192 match *self {
193 Self::Loopback(_) => 1,
194 Self::Device(_) => 2,
195 }
196 }
197
198 #[deprecated = "Strict unions should not use `is_unknown`"]
199 #[inline]
200 pub fn is_unknown(&self) -> bool {
201 false
202 }
203}
204
205impl fidl::Persistable for DeviceClass {}
206
207#[derive(Clone, Debug, PartialEq)]
208pub enum Event {
209 Existing(Properties),
213 Added(Properties),
217 Removed(u64),
219 Changed(Properties),
224 Idle(Empty),
227}
228
229impl Event {
230 #[inline]
231 pub fn ordinal(&self) -> u64 {
232 match *self {
233 Self::Existing(_) => 1,
234 Self::Added(_) => 2,
235 Self::Removed(_) => 3,
236 Self::Changed(_) => 4,
237 Self::Idle(_) => 5,
238 }
239 }
240
241 #[deprecated = "Strict unions should not use `is_unknown`"]
242 #[inline]
243 pub fn is_unknown(&self) -> bool {
244 false
245 }
246}
247
248impl fidl::Persistable for Event {}
249
250#[derive(Clone, Debug)]
252pub enum PortClass {
253 Loopback(Empty),
255 Device(fidl_fuchsia_hardware_network::PortClass),
257 Blackhole(Empty),
259 #[doc(hidden)]
260 __SourceBreaking { unknown_ordinal: u64 },
261}
262
263#[macro_export]
265macro_rules! PortClassUnknown {
266 () => {
267 _
268 };
269}
270
271impl PartialEq for PortClass {
273 fn eq(&self, other: &Self) -> bool {
274 match (self, other) {
275 (Self::Loopback(x), Self::Loopback(y)) => *x == *y,
276 (Self::Device(x), Self::Device(y)) => *x == *y,
277 (Self::Blackhole(x), Self::Blackhole(y)) => *x == *y,
278 _ => false,
279 }
280 }
281}
282
283impl PortClass {
284 #[inline]
285 pub fn ordinal(&self) -> u64 {
286 match *self {
287 Self::Loopback(_) => 1,
288 Self::Device(_) => 2,
289 Self::Blackhole(_) => 3,
290 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
291 }
292 }
293
294 #[inline]
295 pub fn unknown_variant_for_testing() -> Self {
296 Self::__SourceBreaking { unknown_ordinal: 0 }
297 }
298
299 #[inline]
300 pub fn is_unknown(&self) -> bool {
301 match self {
302 Self::__SourceBreaking { .. } => true,
303 _ => false,
304 }
305 }
306}
307
308impl fidl::Persistable for PortClass {}
309
310#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
313pub enum PreferredLifetimeInfo {
314 PreferredUntil(i64),
330 Deprecated(Empty),
344}
345
346impl PreferredLifetimeInfo {
347 #[inline]
348 pub fn ordinal(&self) -> u64 {
349 match *self {
350 Self::PreferredUntil(_) => 1,
351 Self::Deprecated(_) => 2,
352 }
353 }
354
355 #[deprecated = "Strict unions should not use `is_unknown`"]
356 #[inline]
357 pub fn is_unknown(&self) -> bool {
358 false
359 }
360}
361
362impl fidl::Persistable for PreferredLifetimeInfo {}
363
364mod internal {
365 use super::*;
366 unsafe impl fidl::encoding::TypeMarker for AddressPropertiesInterest {
367 type Owned = Self;
368
369 #[inline(always)]
370 fn inline_align(_context: fidl::encoding::Context) -> usize {
371 8
372 }
373
374 #[inline(always)]
375 fn inline_size(_context: fidl::encoding::Context) -> usize {
376 8
377 }
378 }
379
380 impl fidl::encoding::ValueTypeMarker for AddressPropertiesInterest {
381 type Borrowed<'a> = Self;
382 #[inline(always)]
383 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
384 *value
385 }
386 }
387
388 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
389 for AddressPropertiesInterest
390 {
391 #[inline]
392 unsafe fn encode(
393 self,
394 encoder: &mut fidl::encoding::Encoder<'_, D>,
395 offset: usize,
396 _depth: fidl::encoding::Depth,
397 ) -> fidl::Result<()> {
398 encoder.debug_check_bounds::<Self>(offset);
399 encoder.write_num(self.bits(), offset);
400 Ok(())
401 }
402 }
403
404 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
405 for AddressPropertiesInterest
406 {
407 #[inline(always)]
408 fn new_empty() -> Self {
409 Self::empty()
410 }
411
412 #[inline]
413 unsafe fn decode(
414 &mut self,
415 decoder: &mut fidl::encoding::Decoder<'_, D>,
416 offset: usize,
417 _depth: fidl::encoding::Depth,
418 ) -> fidl::Result<()> {
419 decoder.debug_check_bounds::<Self>(offset);
420 let prim = decoder.read_num::<u64>(offset);
421 *self = Self::from_bits_allow_unknown(prim);
422 Ok(())
423 }
424 }
425 unsafe impl fidl::encoding::TypeMarker for AddressAssignmentState {
426 type Owned = Self;
427
428 #[inline(always)]
429 fn inline_align(_context: fidl::encoding::Context) -> usize {
430 std::mem::align_of::<u32>()
431 }
432
433 #[inline(always)]
434 fn inline_size(_context: fidl::encoding::Context) -> usize {
435 std::mem::size_of::<u32>()
436 }
437
438 #[inline(always)]
439 fn encode_is_copy() -> bool {
440 true
441 }
442
443 #[inline(always)]
444 fn decode_is_copy() -> bool {
445 false
446 }
447 }
448
449 impl fidl::encoding::ValueTypeMarker for AddressAssignmentState {
450 type Borrowed<'a> = Self;
451 #[inline(always)]
452 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
453 *value
454 }
455 }
456
457 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
458 for AddressAssignmentState
459 {
460 #[inline]
461 unsafe fn encode(
462 self,
463 encoder: &mut fidl::encoding::Encoder<'_, D>,
464 offset: usize,
465 _depth: fidl::encoding::Depth,
466 ) -> fidl::Result<()> {
467 encoder.debug_check_bounds::<Self>(offset);
468 encoder.write_num(self.into_primitive(), offset);
469 Ok(())
470 }
471 }
472
473 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
474 for AddressAssignmentState
475 {
476 #[inline(always)]
477 fn new_empty() -> Self {
478 Self::Tentative
479 }
480
481 #[inline]
482 unsafe fn decode(
483 &mut self,
484 decoder: &mut fidl::encoding::Decoder<'_, D>,
485 offset: usize,
486 _depth: fidl::encoding::Depth,
487 ) -> fidl::Result<()> {
488 decoder.debug_check_bounds::<Self>(offset);
489 let prim = decoder.read_num::<u32>(offset);
490
491 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
492 Ok(())
493 }
494 }
495
496 impl fidl::encoding::ValueTypeMarker for Empty {
497 type Borrowed<'a> = &'a Self;
498 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
499 value
500 }
501 }
502
503 unsafe impl fidl::encoding::TypeMarker for Empty {
504 type Owned = Self;
505
506 #[inline(always)]
507 fn inline_align(_context: fidl::encoding::Context) -> usize {
508 1
509 }
510
511 #[inline(always)]
512 fn inline_size(_context: fidl::encoding::Context) -> usize {
513 1
514 }
515 }
516
517 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Empty, D> for &Empty {
518 #[inline]
519 unsafe fn encode(
520 self,
521 encoder: &mut fidl::encoding::Encoder<'_, D>,
522 offset: usize,
523 _depth: fidl::encoding::Depth,
524 ) -> fidl::Result<()> {
525 encoder.debug_check_bounds::<Empty>(offset);
526 encoder.write_num(0u8, offset);
527 Ok(())
528 }
529 }
530
531 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Empty {
532 #[inline(always)]
533 fn new_empty() -> Self {
534 Self
535 }
536
537 #[inline]
538 unsafe fn decode(
539 &mut self,
540 decoder: &mut fidl::encoding::Decoder<'_, D>,
541 offset: usize,
542 _depth: fidl::encoding::Depth,
543 ) -> fidl::Result<()> {
544 decoder.debug_check_bounds::<Self>(offset);
545 match decoder.read_num::<u8>(offset) {
546 0 => Ok(()),
547 _ => Err(fidl::Error::Invalid),
548 }
549 }
550 }
551
552 impl fidl::encoding::ValueTypeMarker for WatcherWatchResponse {
553 type Borrowed<'a> = &'a Self;
554 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
555 value
556 }
557 }
558
559 unsafe impl fidl::encoding::TypeMarker for WatcherWatchResponse {
560 type Owned = Self;
561
562 #[inline(always)]
563 fn inline_align(_context: fidl::encoding::Context) -> usize {
564 8
565 }
566
567 #[inline(always)]
568 fn inline_size(_context: fidl::encoding::Context) -> usize {
569 16
570 }
571 }
572
573 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WatcherWatchResponse, D>
574 for &WatcherWatchResponse
575 {
576 #[inline]
577 unsafe fn encode(
578 self,
579 encoder: &mut fidl::encoding::Encoder<'_, D>,
580 offset: usize,
581 _depth: fidl::encoding::Depth,
582 ) -> fidl::Result<()> {
583 encoder.debug_check_bounds::<WatcherWatchResponse>(offset);
584 fidl::encoding::Encode::<WatcherWatchResponse, D>::encode(
586 (<Event as fidl::encoding::ValueTypeMarker>::borrow(&self.event),),
587 encoder,
588 offset,
589 _depth,
590 )
591 }
592 }
593 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Event, D>>
594 fidl::encoding::Encode<WatcherWatchResponse, D> for (T0,)
595 {
596 #[inline]
597 unsafe fn encode(
598 self,
599 encoder: &mut fidl::encoding::Encoder<'_, D>,
600 offset: usize,
601 depth: fidl::encoding::Depth,
602 ) -> fidl::Result<()> {
603 encoder.debug_check_bounds::<WatcherWatchResponse>(offset);
604 self.0.encode(encoder, offset + 0, depth)?;
608 Ok(())
609 }
610 }
611
612 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WatcherWatchResponse {
613 #[inline(always)]
614 fn new_empty() -> Self {
615 Self { event: fidl::new_empty!(Event, D) }
616 }
617
618 #[inline]
619 unsafe fn decode(
620 &mut self,
621 decoder: &mut fidl::encoding::Decoder<'_, D>,
622 offset: usize,
623 _depth: fidl::encoding::Depth,
624 ) -> fidl::Result<()> {
625 decoder.debug_check_bounds::<Self>(offset);
626 fidl::decode!(Event, D, &mut self.event, decoder, offset + 0, _depth)?;
628 Ok(())
629 }
630 }
631
632 impl Address {
633 #[inline(always)]
634 fn max_ordinal_present(&self) -> u64 {
635 if let Some(_) = self.assignment_state {
636 return 4;
637 }
638 if let Some(_) = self.preferred_lifetime_info {
639 return 3;
640 }
641 if let Some(_) = self.valid_until {
642 return 2;
643 }
644 if let Some(_) = self.addr {
645 return 1;
646 }
647 0
648 }
649 }
650
651 impl fidl::encoding::ValueTypeMarker for Address {
652 type Borrowed<'a> = &'a Self;
653 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
654 value
655 }
656 }
657
658 unsafe impl fidl::encoding::TypeMarker for Address {
659 type Owned = Self;
660
661 #[inline(always)]
662 fn inline_align(_context: fidl::encoding::Context) -> usize {
663 8
664 }
665
666 #[inline(always)]
667 fn inline_size(_context: fidl::encoding::Context) -> usize {
668 16
669 }
670 }
671
672 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Address, D> for &Address {
673 unsafe fn encode(
674 self,
675 encoder: &mut fidl::encoding::Encoder<'_, D>,
676 offset: usize,
677 mut depth: fidl::encoding::Depth,
678 ) -> fidl::Result<()> {
679 encoder.debug_check_bounds::<Address>(offset);
680 let max_ordinal: u64 = self.max_ordinal_present();
682 encoder.write_num(max_ordinal, offset);
683 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
684 if max_ordinal == 0 {
686 return Ok(());
687 }
688 depth.increment()?;
689 let envelope_size = 8;
690 let bytes_len = max_ordinal as usize * envelope_size;
691 #[allow(unused_variables)]
692 let offset = encoder.out_of_line_offset(bytes_len);
693 let mut _prev_end_offset: usize = 0;
694 if 1 > max_ordinal {
695 return Ok(());
696 }
697
698 let cur_offset: usize = (1 - 1) * envelope_size;
701
702 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
704
705 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_net::Subnet, D>(
710 self.addr
711 .as_ref()
712 .map(<fidl_fuchsia_net::Subnet as fidl::encoding::ValueTypeMarker>::borrow),
713 encoder,
714 offset + cur_offset,
715 depth,
716 )?;
717
718 _prev_end_offset = cur_offset + envelope_size;
719 if 2 > max_ordinal {
720 return Ok(());
721 }
722
723 let cur_offset: usize = (2 - 1) * envelope_size;
726
727 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
729
730 fidl::encoding::encode_in_envelope_optional::<i64, D>(
735 self.valid_until.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
736 encoder,
737 offset + cur_offset,
738 depth,
739 )?;
740
741 _prev_end_offset = cur_offset + envelope_size;
742 if 3 > max_ordinal {
743 return Ok(());
744 }
745
746 let cur_offset: usize = (3 - 1) * envelope_size;
749
750 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
752
753 fidl::encoding::encode_in_envelope_optional::<PreferredLifetimeInfo, D>(
758 self.preferred_lifetime_info
759 .as_ref()
760 .map(<PreferredLifetimeInfo as fidl::encoding::ValueTypeMarker>::borrow),
761 encoder,
762 offset + cur_offset,
763 depth,
764 )?;
765
766 _prev_end_offset = cur_offset + envelope_size;
767 if 4 > max_ordinal {
768 return Ok(());
769 }
770
771 let cur_offset: usize = (4 - 1) * envelope_size;
774
775 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
777
778 fidl::encoding::encode_in_envelope_optional::<AddressAssignmentState, D>(
783 self.assignment_state
784 .as_ref()
785 .map(<AddressAssignmentState as fidl::encoding::ValueTypeMarker>::borrow),
786 encoder,
787 offset + cur_offset,
788 depth,
789 )?;
790
791 _prev_end_offset = cur_offset + envelope_size;
792
793 Ok(())
794 }
795 }
796
797 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Address {
798 #[inline(always)]
799 fn new_empty() -> Self {
800 Self::default()
801 }
802
803 unsafe fn decode(
804 &mut self,
805 decoder: &mut fidl::encoding::Decoder<'_, D>,
806 offset: usize,
807 mut depth: fidl::encoding::Depth,
808 ) -> fidl::Result<()> {
809 decoder.debug_check_bounds::<Self>(offset);
810 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
811 None => return Err(fidl::Error::NotNullable),
812 Some(len) => len,
813 };
814 if len == 0 {
816 return Ok(());
817 };
818 depth.increment()?;
819 let envelope_size = 8;
820 let bytes_len = len * envelope_size;
821 let offset = decoder.out_of_line_offset(bytes_len)?;
822 let mut _next_ordinal_to_read = 0;
824 let mut next_offset = offset;
825 let end_offset = offset + bytes_len;
826 _next_ordinal_to_read += 1;
827 if next_offset >= end_offset {
828 return Ok(());
829 }
830
831 while _next_ordinal_to_read < 1 {
833 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
834 _next_ordinal_to_read += 1;
835 next_offset += envelope_size;
836 }
837
838 let next_out_of_line = decoder.next_out_of_line();
839 let handles_before = decoder.remaining_handles();
840 if let Some((inlined, num_bytes, num_handles)) =
841 fidl::encoding::decode_envelope_header(decoder, next_offset)?
842 {
843 let member_inline_size =
844 <fidl_fuchsia_net::Subnet as fidl::encoding::TypeMarker>::inline_size(
845 decoder.context,
846 );
847 if inlined != (member_inline_size <= 4) {
848 return Err(fidl::Error::InvalidInlineBitInEnvelope);
849 }
850 let inner_offset;
851 let mut inner_depth = depth.clone();
852 if inlined {
853 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
854 inner_offset = next_offset;
855 } else {
856 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
857 inner_depth.increment()?;
858 }
859 let val_ref =
860 self.addr.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_net::Subnet, D));
861 fidl::decode!(
862 fidl_fuchsia_net::Subnet,
863 D,
864 val_ref,
865 decoder,
866 inner_offset,
867 inner_depth
868 )?;
869 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
870 {
871 return Err(fidl::Error::InvalidNumBytesInEnvelope);
872 }
873 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
874 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
875 }
876 }
877
878 next_offset += envelope_size;
879 _next_ordinal_to_read += 1;
880 if next_offset >= end_offset {
881 return Ok(());
882 }
883
884 while _next_ordinal_to_read < 2 {
886 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
887 _next_ordinal_to_read += 1;
888 next_offset += envelope_size;
889 }
890
891 let next_out_of_line = decoder.next_out_of_line();
892 let handles_before = decoder.remaining_handles();
893 if let Some((inlined, num_bytes, num_handles)) =
894 fidl::encoding::decode_envelope_header(decoder, next_offset)?
895 {
896 let member_inline_size =
897 <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
898 if inlined != (member_inline_size <= 4) {
899 return Err(fidl::Error::InvalidInlineBitInEnvelope);
900 }
901 let inner_offset;
902 let mut inner_depth = depth.clone();
903 if inlined {
904 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
905 inner_offset = next_offset;
906 } else {
907 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
908 inner_depth.increment()?;
909 }
910 let val_ref = self.valid_until.get_or_insert_with(|| fidl::new_empty!(i64, D));
911 fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
912 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
913 {
914 return Err(fidl::Error::InvalidNumBytesInEnvelope);
915 }
916 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
917 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
918 }
919 }
920
921 next_offset += envelope_size;
922 _next_ordinal_to_read += 1;
923 if next_offset >= end_offset {
924 return Ok(());
925 }
926
927 while _next_ordinal_to_read < 3 {
929 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
930 _next_ordinal_to_read += 1;
931 next_offset += envelope_size;
932 }
933
934 let next_out_of_line = decoder.next_out_of_line();
935 let handles_before = decoder.remaining_handles();
936 if let Some((inlined, num_bytes, num_handles)) =
937 fidl::encoding::decode_envelope_header(decoder, next_offset)?
938 {
939 let member_inline_size =
940 <PreferredLifetimeInfo as fidl::encoding::TypeMarker>::inline_size(
941 decoder.context,
942 );
943 if inlined != (member_inline_size <= 4) {
944 return Err(fidl::Error::InvalidInlineBitInEnvelope);
945 }
946 let inner_offset;
947 let mut inner_depth = depth.clone();
948 if inlined {
949 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
950 inner_offset = next_offset;
951 } else {
952 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
953 inner_depth.increment()?;
954 }
955 let val_ref = self
956 .preferred_lifetime_info
957 .get_or_insert_with(|| fidl::new_empty!(PreferredLifetimeInfo, D));
958 fidl::decode!(
959 PreferredLifetimeInfo,
960 D,
961 val_ref,
962 decoder,
963 inner_offset,
964 inner_depth
965 )?;
966 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
967 {
968 return Err(fidl::Error::InvalidNumBytesInEnvelope);
969 }
970 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
971 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
972 }
973 }
974
975 next_offset += envelope_size;
976 _next_ordinal_to_read += 1;
977 if next_offset >= end_offset {
978 return Ok(());
979 }
980
981 while _next_ordinal_to_read < 4 {
983 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
984 _next_ordinal_to_read += 1;
985 next_offset += envelope_size;
986 }
987
988 let next_out_of_line = decoder.next_out_of_line();
989 let handles_before = decoder.remaining_handles();
990 if let Some((inlined, num_bytes, num_handles)) =
991 fidl::encoding::decode_envelope_header(decoder, next_offset)?
992 {
993 let member_inline_size =
994 <AddressAssignmentState as fidl::encoding::TypeMarker>::inline_size(
995 decoder.context,
996 );
997 if inlined != (member_inline_size <= 4) {
998 return Err(fidl::Error::InvalidInlineBitInEnvelope);
999 }
1000 let inner_offset;
1001 let mut inner_depth = depth.clone();
1002 if inlined {
1003 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1004 inner_offset = next_offset;
1005 } else {
1006 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1007 inner_depth.increment()?;
1008 }
1009 let val_ref = self
1010 .assignment_state
1011 .get_or_insert_with(|| fidl::new_empty!(AddressAssignmentState, D));
1012 fidl::decode!(
1013 AddressAssignmentState,
1014 D,
1015 val_ref,
1016 decoder,
1017 inner_offset,
1018 inner_depth
1019 )?;
1020 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1021 {
1022 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1023 }
1024 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1025 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1026 }
1027 }
1028
1029 next_offset += envelope_size;
1030
1031 while next_offset < end_offset {
1033 _next_ordinal_to_read += 1;
1034 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1035 next_offset += envelope_size;
1036 }
1037
1038 Ok(())
1039 }
1040 }
1041
1042 impl Properties {
1043 #[inline(always)]
1044 fn max_ordinal_present(&self) -> u64 {
1045 if let Some(_) = self.port_class {
1046 return 8;
1047 }
1048 if let Some(_) = self.name {
1049 return 7;
1050 }
1051 if let Some(_) = self.has_default_ipv6_route {
1052 return 6;
1053 }
1054 if let Some(_) = self.has_default_ipv4_route {
1055 return 5;
1056 }
1057 if let Some(_) = self.device_class {
1058 return 4;
1059 }
1060 if let Some(_) = self.online {
1061 return 3;
1062 }
1063 if let Some(_) = self.addresses {
1064 return 2;
1065 }
1066 if let Some(_) = self.id {
1067 return 1;
1068 }
1069 0
1070 }
1071 }
1072
1073 impl fidl::encoding::ValueTypeMarker for Properties {
1074 type Borrowed<'a> = &'a Self;
1075 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1076 value
1077 }
1078 }
1079
1080 unsafe impl fidl::encoding::TypeMarker for Properties {
1081 type Owned = Self;
1082
1083 #[inline(always)]
1084 fn inline_align(_context: fidl::encoding::Context) -> usize {
1085 8
1086 }
1087
1088 #[inline(always)]
1089 fn inline_size(_context: fidl::encoding::Context) -> usize {
1090 16
1091 }
1092 }
1093
1094 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Properties, D>
1095 for &Properties
1096 {
1097 unsafe fn encode(
1098 self,
1099 encoder: &mut fidl::encoding::Encoder<'_, D>,
1100 offset: usize,
1101 mut depth: fidl::encoding::Depth,
1102 ) -> fidl::Result<()> {
1103 encoder.debug_check_bounds::<Properties>(offset);
1104 let max_ordinal: u64 = self.max_ordinal_present();
1106 encoder.write_num(max_ordinal, offset);
1107 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1108 if max_ordinal == 0 {
1110 return Ok(());
1111 }
1112 depth.increment()?;
1113 let envelope_size = 8;
1114 let bytes_len = max_ordinal as usize * envelope_size;
1115 #[allow(unused_variables)]
1116 let offset = encoder.out_of_line_offset(bytes_len);
1117 let mut _prev_end_offset: usize = 0;
1118 if 1 > max_ordinal {
1119 return Ok(());
1120 }
1121
1122 let cur_offset: usize = (1 - 1) * envelope_size;
1125
1126 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1128
1129 fidl::encoding::encode_in_envelope_optional::<u64, D>(
1134 self.id.as_ref().map(<u64 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 2 > max_ordinal {
1142 return Ok(());
1143 }
1144
1145 let cur_offset: usize = (2 - 1) * envelope_size;
1148
1149 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1151
1152 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Address>, D>(
1157 self.addresses.as_ref().map(<fidl::encoding::UnboundedVector<Address> as fidl::encoding::ValueTypeMarker>::borrow),
1158 encoder, offset + cur_offset, depth
1159 )?;
1160
1161 _prev_end_offset = cur_offset + envelope_size;
1162 if 3 > max_ordinal {
1163 return Ok(());
1164 }
1165
1166 let cur_offset: usize = (3 - 1) * envelope_size;
1169
1170 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1172
1173 fidl::encoding::encode_in_envelope_optional::<bool, D>(
1178 self.online.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1179 encoder,
1180 offset + cur_offset,
1181 depth,
1182 )?;
1183
1184 _prev_end_offset = cur_offset + envelope_size;
1185 if 4 > max_ordinal {
1186 return Ok(());
1187 }
1188
1189 let cur_offset: usize = (4 - 1) * envelope_size;
1192
1193 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1195
1196 fidl::encoding::encode_in_envelope_optional::<DeviceClass, D>(
1201 self.device_class
1202 .as_ref()
1203 .map(<DeviceClass as fidl::encoding::ValueTypeMarker>::borrow),
1204 encoder,
1205 offset + cur_offset,
1206 depth,
1207 )?;
1208
1209 _prev_end_offset = cur_offset + envelope_size;
1210 if 5 > max_ordinal {
1211 return Ok(());
1212 }
1213
1214 let cur_offset: usize = (5 - 1) * envelope_size;
1217
1218 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1220
1221 fidl::encoding::encode_in_envelope_optional::<bool, D>(
1226 self.has_default_ipv4_route
1227 .as_ref()
1228 .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1229 encoder,
1230 offset + cur_offset,
1231 depth,
1232 )?;
1233
1234 _prev_end_offset = cur_offset + envelope_size;
1235 if 6 > max_ordinal {
1236 return Ok(());
1237 }
1238
1239 let cur_offset: usize = (6 - 1) * envelope_size;
1242
1243 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1245
1246 fidl::encoding::encode_in_envelope_optional::<bool, D>(
1251 self.has_default_ipv6_route
1252 .as_ref()
1253 .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1254 encoder,
1255 offset + cur_offset,
1256 depth,
1257 )?;
1258
1259 _prev_end_offset = cur_offset + envelope_size;
1260 if 7 > max_ordinal {
1261 return Ok(());
1262 }
1263
1264 let cur_offset: usize = (7 - 1) * envelope_size;
1267
1268 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1270
1271 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<15>, D>(
1276 self.name.as_ref().map(
1277 <fidl::encoding::BoundedString<15> as fidl::encoding::ValueTypeMarker>::borrow,
1278 ),
1279 encoder,
1280 offset + cur_offset,
1281 depth,
1282 )?;
1283
1284 _prev_end_offset = cur_offset + envelope_size;
1285 if 8 > max_ordinal {
1286 return Ok(());
1287 }
1288
1289 let cur_offset: usize = (8 - 1) * envelope_size;
1292
1293 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1295
1296 fidl::encoding::encode_in_envelope_optional::<PortClass, D>(
1301 self.port_class
1302 .as_ref()
1303 .map(<PortClass as fidl::encoding::ValueTypeMarker>::borrow),
1304 encoder,
1305 offset + cur_offset,
1306 depth,
1307 )?;
1308
1309 _prev_end_offset = cur_offset + envelope_size;
1310
1311 Ok(())
1312 }
1313 }
1314
1315 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Properties {
1316 #[inline(always)]
1317 fn new_empty() -> Self {
1318 Self::default()
1319 }
1320
1321 unsafe fn decode(
1322 &mut self,
1323 decoder: &mut fidl::encoding::Decoder<'_, D>,
1324 offset: usize,
1325 mut depth: fidl::encoding::Depth,
1326 ) -> fidl::Result<()> {
1327 decoder.debug_check_bounds::<Self>(offset);
1328 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1329 None => return Err(fidl::Error::NotNullable),
1330 Some(len) => len,
1331 };
1332 if len == 0 {
1334 return Ok(());
1335 };
1336 depth.increment()?;
1337 let envelope_size = 8;
1338 let bytes_len = len * envelope_size;
1339 let offset = decoder.out_of_line_offset(bytes_len)?;
1340 let mut _next_ordinal_to_read = 0;
1342 let mut next_offset = offset;
1343 let end_offset = offset + bytes_len;
1344 _next_ordinal_to_read += 1;
1345 if next_offset >= end_offset {
1346 return Ok(());
1347 }
1348
1349 while _next_ordinal_to_read < 1 {
1351 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1352 _next_ordinal_to_read += 1;
1353 next_offset += envelope_size;
1354 }
1355
1356 let next_out_of_line = decoder.next_out_of_line();
1357 let handles_before = decoder.remaining_handles();
1358 if let Some((inlined, num_bytes, num_handles)) =
1359 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1360 {
1361 let member_inline_size =
1362 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1363 if inlined != (member_inline_size <= 4) {
1364 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1365 }
1366 let inner_offset;
1367 let mut inner_depth = depth.clone();
1368 if inlined {
1369 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1370 inner_offset = next_offset;
1371 } else {
1372 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1373 inner_depth.increment()?;
1374 }
1375 let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
1376 fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1377 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1378 {
1379 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1380 }
1381 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1382 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1383 }
1384 }
1385
1386 next_offset += envelope_size;
1387 _next_ordinal_to_read += 1;
1388 if next_offset >= end_offset {
1389 return Ok(());
1390 }
1391
1392 while _next_ordinal_to_read < 2 {
1394 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1395 _next_ordinal_to_read += 1;
1396 next_offset += envelope_size;
1397 }
1398
1399 let next_out_of_line = decoder.next_out_of_line();
1400 let handles_before = decoder.remaining_handles();
1401 if let Some((inlined, num_bytes, num_handles)) =
1402 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1403 {
1404 let member_inline_size = <fidl::encoding::UnboundedVector<Address> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1405 if inlined != (member_inline_size <= 4) {
1406 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1407 }
1408 let inner_offset;
1409 let mut inner_depth = depth.clone();
1410 if inlined {
1411 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1412 inner_offset = next_offset;
1413 } else {
1414 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1415 inner_depth.increment()?;
1416 }
1417 let val_ref = self.addresses.get_or_insert_with(|| {
1418 fidl::new_empty!(fidl::encoding::UnboundedVector<Address>, D)
1419 });
1420 fidl::decode!(
1421 fidl::encoding::UnboundedVector<Address>,
1422 D,
1423 val_ref,
1424 decoder,
1425 inner_offset,
1426 inner_depth
1427 )?;
1428 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1429 {
1430 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1431 }
1432 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1433 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1434 }
1435 }
1436
1437 next_offset += envelope_size;
1438 _next_ordinal_to_read += 1;
1439 if next_offset >= end_offset {
1440 return Ok(());
1441 }
1442
1443 while _next_ordinal_to_read < 3 {
1445 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1446 _next_ordinal_to_read += 1;
1447 next_offset += envelope_size;
1448 }
1449
1450 let next_out_of_line = decoder.next_out_of_line();
1451 let handles_before = decoder.remaining_handles();
1452 if let Some((inlined, num_bytes, num_handles)) =
1453 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1454 {
1455 let member_inline_size =
1456 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1457 if inlined != (member_inline_size <= 4) {
1458 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1459 }
1460 let inner_offset;
1461 let mut inner_depth = depth.clone();
1462 if inlined {
1463 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1464 inner_offset = next_offset;
1465 } else {
1466 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1467 inner_depth.increment()?;
1468 }
1469 let val_ref = self.online.get_or_insert_with(|| fidl::new_empty!(bool, D));
1470 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1471 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1472 {
1473 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1474 }
1475 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1476 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1477 }
1478 }
1479
1480 next_offset += envelope_size;
1481 _next_ordinal_to_read += 1;
1482 if next_offset >= end_offset {
1483 return Ok(());
1484 }
1485
1486 while _next_ordinal_to_read < 4 {
1488 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1489 _next_ordinal_to_read += 1;
1490 next_offset += envelope_size;
1491 }
1492
1493 let next_out_of_line = decoder.next_out_of_line();
1494 let handles_before = decoder.remaining_handles();
1495 if let Some((inlined, num_bytes, num_handles)) =
1496 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1497 {
1498 let member_inline_size =
1499 <DeviceClass as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1500 if inlined != (member_inline_size <= 4) {
1501 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1502 }
1503 let inner_offset;
1504 let mut inner_depth = depth.clone();
1505 if inlined {
1506 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1507 inner_offset = next_offset;
1508 } else {
1509 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1510 inner_depth.increment()?;
1511 }
1512 let val_ref =
1513 self.device_class.get_or_insert_with(|| fidl::new_empty!(DeviceClass, D));
1514 fidl::decode!(DeviceClass, D, val_ref, decoder, inner_offset, inner_depth)?;
1515 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1516 {
1517 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1518 }
1519 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1520 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1521 }
1522 }
1523
1524 next_offset += envelope_size;
1525 _next_ordinal_to_read += 1;
1526 if next_offset >= end_offset {
1527 return Ok(());
1528 }
1529
1530 while _next_ordinal_to_read < 5 {
1532 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1533 _next_ordinal_to_read += 1;
1534 next_offset += envelope_size;
1535 }
1536
1537 let next_out_of_line = decoder.next_out_of_line();
1538 let handles_before = decoder.remaining_handles();
1539 if let Some((inlined, num_bytes, num_handles)) =
1540 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1541 {
1542 let member_inline_size =
1543 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1544 if inlined != (member_inline_size <= 4) {
1545 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1546 }
1547 let inner_offset;
1548 let mut inner_depth = depth.clone();
1549 if inlined {
1550 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1551 inner_offset = next_offset;
1552 } else {
1553 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1554 inner_depth.increment()?;
1555 }
1556 let val_ref =
1557 self.has_default_ipv4_route.get_or_insert_with(|| fidl::new_empty!(bool, D));
1558 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1559 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1560 {
1561 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1562 }
1563 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1564 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1565 }
1566 }
1567
1568 next_offset += envelope_size;
1569 _next_ordinal_to_read += 1;
1570 if next_offset >= end_offset {
1571 return Ok(());
1572 }
1573
1574 while _next_ordinal_to_read < 6 {
1576 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1577 _next_ordinal_to_read += 1;
1578 next_offset += envelope_size;
1579 }
1580
1581 let next_out_of_line = decoder.next_out_of_line();
1582 let handles_before = decoder.remaining_handles();
1583 if let Some((inlined, num_bytes, num_handles)) =
1584 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1585 {
1586 let member_inline_size =
1587 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1588 if inlined != (member_inline_size <= 4) {
1589 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1590 }
1591 let inner_offset;
1592 let mut inner_depth = depth.clone();
1593 if inlined {
1594 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1595 inner_offset = next_offset;
1596 } else {
1597 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1598 inner_depth.increment()?;
1599 }
1600 let val_ref =
1601 self.has_default_ipv6_route.get_or_insert_with(|| fidl::new_empty!(bool, D));
1602 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1603 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1604 {
1605 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1606 }
1607 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1608 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1609 }
1610 }
1611
1612 next_offset += envelope_size;
1613 _next_ordinal_to_read += 1;
1614 if next_offset >= end_offset {
1615 return Ok(());
1616 }
1617
1618 while _next_ordinal_to_read < 7 {
1620 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1621 _next_ordinal_to_read += 1;
1622 next_offset += envelope_size;
1623 }
1624
1625 let next_out_of_line = decoder.next_out_of_line();
1626 let handles_before = decoder.remaining_handles();
1627 if let Some((inlined, num_bytes, num_handles)) =
1628 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1629 {
1630 let member_inline_size =
1631 <fidl::encoding::BoundedString<15> as fidl::encoding::TypeMarker>::inline_size(
1632 decoder.context,
1633 );
1634 if inlined != (member_inline_size <= 4) {
1635 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1636 }
1637 let inner_offset;
1638 let mut inner_depth = depth.clone();
1639 if inlined {
1640 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1641 inner_offset = next_offset;
1642 } else {
1643 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1644 inner_depth.increment()?;
1645 }
1646 let val_ref = self
1647 .name
1648 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<15>, D));
1649 fidl::decode!(
1650 fidl::encoding::BoundedString<15>,
1651 D,
1652 val_ref,
1653 decoder,
1654 inner_offset,
1655 inner_depth
1656 )?;
1657 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1658 {
1659 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1660 }
1661 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1662 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1663 }
1664 }
1665
1666 next_offset += envelope_size;
1667 _next_ordinal_to_read += 1;
1668 if next_offset >= end_offset {
1669 return Ok(());
1670 }
1671
1672 while _next_ordinal_to_read < 8 {
1674 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1675 _next_ordinal_to_read += 1;
1676 next_offset += envelope_size;
1677 }
1678
1679 let next_out_of_line = decoder.next_out_of_line();
1680 let handles_before = decoder.remaining_handles();
1681 if let Some((inlined, num_bytes, num_handles)) =
1682 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1683 {
1684 let member_inline_size =
1685 <PortClass as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1686 if inlined != (member_inline_size <= 4) {
1687 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1688 }
1689 let inner_offset;
1690 let mut inner_depth = depth.clone();
1691 if inlined {
1692 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1693 inner_offset = next_offset;
1694 } else {
1695 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1696 inner_depth.increment()?;
1697 }
1698 let val_ref = self.port_class.get_or_insert_with(|| fidl::new_empty!(PortClass, D));
1699 fidl::decode!(PortClass, D, val_ref, decoder, inner_offset, inner_depth)?;
1700 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1701 {
1702 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1703 }
1704 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1705 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1706 }
1707 }
1708
1709 next_offset += envelope_size;
1710
1711 while next_offset < end_offset {
1713 _next_ordinal_to_read += 1;
1714 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1715 next_offset += envelope_size;
1716 }
1717
1718 Ok(())
1719 }
1720 }
1721
1722 impl WatcherOptions {
1723 #[inline(always)]
1724 fn max_ordinal_present(&self) -> u64 {
1725 if let Some(_) = self.include_non_assigned_addresses {
1726 return 2;
1727 }
1728 if let Some(_) = self.address_properties_interest {
1729 return 1;
1730 }
1731 0
1732 }
1733 }
1734
1735 impl fidl::encoding::ValueTypeMarker for WatcherOptions {
1736 type Borrowed<'a> = &'a Self;
1737 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1738 value
1739 }
1740 }
1741
1742 unsafe impl fidl::encoding::TypeMarker for WatcherOptions {
1743 type Owned = Self;
1744
1745 #[inline(always)]
1746 fn inline_align(_context: fidl::encoding::Context) -> usize {
1747 8
1748 }
1749
1750 #[inline(always)]
1751 fn inline_size(_context: fidl::encoding::Context) -> usize {
1752 16
1753 }
1754 }
1755
1756 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WatcherOptions, D>
1757 for &WatcherOptions
1758 {
1759 unsafe fn encode(
1760 self,
1761 encoder: &mut fidl::encoding::Encoder<'_, D>,
1762 offset: usize,
1763 mut depth: fidl::encoding::Depth,
1764 ) -> fidl::Result<()> {
1765 encoder.debug_check_bounds::<WatcherOptions>(offset);
1766 let max_ordinal: u64 = self.max_ordinal_present();
1768 encoder.write_num(max_ordinal, offset);
1769 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1770 if max_ordinal == 0 {
1772 return Ok(());
1773 }
1774 depth.increment()?;
1775 let envelope_size = 8;
1776 let bytes_len = max_ordinal as usize * envelope_size;
1777 #[allow(unused_variables)]
1778 let offset = encoder.out_of_line_offset(bytes_len);
1779 let mut _prev_end_offset: usize = 0;
1780 if 1 > max_ordinal {
1781 return Ok(());
1782 }
1783
1784 let cur_offset: usize = (1 - 1) * envelope_size;
1787
1788 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1790
1791 fidl::encoding::encode_in_envelope_optional::<AddressPropertiesInterest, D>(
1796 self.address_properties_interest
1797 .as_ref()
1798 .map(<AddressPropertiesInterest as fidl::encoding::ValueTypeMarker>::borrow),
1799 encoder,
1800 offset + cur_offset,
1801 depth,
1802 )?;
1803
1804 _prev_end_offset = cur_offset + envelope_size;
1805 if 2 > max_ordinal {
1806 return Ok(());
1807 }
1808
1809 let cur_offset: usize = (2 - 1) * envelope_size;
1812
1813 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1815
1816 fidl::encoding::encode_in_envelope_optional::<bool, D>(
1821 self.include_non_assigned_addresses
1822 .as_ref()
1823 .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1824 encoder,
1825 offset + cur_offset,
1826 depth,
1827 )?;
1828
1829 _prev_end_offset = cur_offset + envelope_size;
1830
1831 Ok(())
1832 }
1833 }
1834
1835 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WatcherOptions {
1836 #[inline(always)]
1837 fn new_empty() -> Self {
1838 Self::default()
1839 }
1840
1841 unsafe fn decode(
1842 &mut self,
1843 decoder: &mut fidl::encoding::Decoder<'_, D>,
1844 offset: usize,
1845 mut depth: fidl::encoding::Depth,
1846 ) -> fidl::Result<()> {
1847 decoder.debug_check_bounds::<Self>(offset);
1848 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1849 None => return Err(fidl::Error::NotNullable),
1850 Some(len) => len,
1851 };
1852 if len == 0 {
1854 return Ok(());
1855 };
1856 depth.increment()?;
1857 let envelope_size = 8;
1858 let bytes_len = len * envelope_size;
1859 let offset = decoder.out_of_line_offset(bytes_len)?;
1860 let mut _next_ordinal_to_read = 0;
1862 let mut next_offset = offset;
1863 let end_offset = offset + bytes_len;
1864 _next_ordinal_to_read += 1;
1865 if next_offset >= end_offset {
1866 return Ok(());
1867 }
1868
1869 while _next_ordinal_to_read < 1 {
1871 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1872 _next_ordinal_to_read += 1;
1873 next_offset += envelope_size;
1874 }
1875
1876 let next_out_of_line = decoder.next_out_of_line();
1877 let handles_before = decoder.remaining_handles();
1878 if let Some((inlined, num_bytes, num_handles)) =
1879 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1880 {
1881 let member_inline_size =
1882 <AddressPropertiesInterest as fidl::encoding::TypeMarker>::inline_size(
1883 decoder.context,
1884 );
1885 if inlined != (member_inline_size <= 4) {
1886 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1887 }
1888 let inner_offset;
1889 let mut inner_depth = depth.clone();
1890 if inlined {
1891 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1892 inner_offset = next_offset;
1893 } else {
1894 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1895 inner_depth.increment()?;
1896 }
1897 let val_ref = self
1898 .address_properties_interest
1899 .get_or_insert_with(|| fidl::new_empty!(AddressPropertiesInterest, D));
1900 fidl::decode!(
1901 AddressPropertiesInterest,
1902 D,
1903 val_ref,
1904 decoder,
1905 inner_offset,
1906 inner_depth
1907 )?;
1908 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1909 {
1910 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1911 }
1912 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1913 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1914 }
1915 }
1916
1917 next_offset += envelope_size;
1918 _next_ordinal_to_read += 1;
1919 if next_offset >= end_offset {
1920 return Ok(());
1921 }
1922
1923 while _next_ordinal_to_read < 2 {
1925 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1926 _next_ordinal_to_read += 1;
1927 next_offset += envelope_size;
1928 }
1929
1930 let next_out_of_line = decoder.next_out_of_line();
1931 let handles_before = decoder.remaining_handles();
1932 if let Some((inlined, num_bytes, num_handles)) =
1933 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1934 {
1935 let member_inline_size =
1936 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1937 if inlined != (member_inline_size <= 4) {
1938 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1939 }
1940 let inner_offset;
1941 let mut inner_depth = depth.clone();
1942 if inlined {
1943 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1944 inner_offset = next_offset;
1945 } else {
1946 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1947 inner_depth.increment()?;
1948 }
1949 let val_ref = self
1950 .include_non_assigned_addresses
1951 .get_or_insert_with(|| fidl::new_empty!(bool, D));
1952 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1953 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1954 {
1955 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1956 }
1957 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1958 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1959 }
1960 }
1961
1962 next_offset += envelope_size;
1963
1964 while next_offset < end_offset {
1966 _next_ordinal_to_read += 1;
1967 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1968 next_offset += envelope_size;
1969 }
1970
1971 Ok(())
1972 }
1973 }
1974
1975 impl fidl::encoding::ValueTypeMarker for DeviceClass {
1976 type Borrowed<'a> = &'a Self;
1977 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1978 value
1979 }
1980 }
1981
1982 unsafe impl fidl::encoding::TypeMarker for DeviceClass {
1983 type Owned = Self;
1984
1985 #[inline(always)]
1986 fn inline_align(_context: fidl::encoding::Context) -> usize {
1987 8
1988 }
1989
1990 #[inline(always)]
1991 fn inline_size(_context: fidl::encoding::Context) -> usize {
1992 16
1993 }
1994 }
1995
1996 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceClass, D>
1997 for &DeviceClass
1998 {
1999 #[inline]
2000 unsafe fn encode(
2001 self,
2002 encoder: &mut fidl::encoding::Encoder<'_, D>,
2003 offset: usize,
2004 _depth: fidl::encoding::Depth,
2005 ) -> fidl::Result<()> {
2006 encoder.debug_check_bounds::<DeviceClass>(offset);
2007 encoder.write_num::<u64>(self.ordinal(), offset);
2008 match self {
2009 DeviceClass::Loopback(ref val) => {
2010 fidl::encoding::encode_in_envelope::<Empty, D>(
2011 <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2012 encoder, offset + 8, _depth
2013 )
2014 }
2015 DeviceClass::Device(ref val) => {
2016 fidl::encoding::encode_in_envelope::<fidl_fuchsia_hardware_network::DeviceClass, D>(
2017 <fidl_fuchsia_hardware_network::DeviceClass as fidl::encoding::ValueTypeMarker>::borrow(val),
2018 encoder, offset + 8, _depth
2019 )
2020 }
2021 }
2022 }
2023 }
2024
2025 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceClass {
2026 #[inline(always)]
2027 fn new_empty() -> Self {
2028 Self::Loopback(fidl::new_empty!(Empty, D))
2029 }
2030
2031 #[inline]
2032 unsafe fn decode(
2033 &mut self,
2034 decoder: &mut fidl::encoding::Decoder<'_, D>,
2035 offset: usize,
2036 mut depth: fidl::encoding::Depth,
2037 ) -> fidl::Result<()> {
2038 decoder.debug_check_bounds::<Self>(offset);
2039 #[allow(unused_variables)]
2040 let next_out_of_line = decoder.next_out_of_line();
2041 let handles_before = decoder.remaining_handles();
2042 let (ordinal, inlined, num_bytes, num_handles) =
2043 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2044
2045 let member_inline_size = match ordinal {
2046 1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2047 2 => <fidl_fuchsia_hardware_network::DeviceClass as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2048 _ => return Err(fidl::Error::UnknownUnionTag),
2049 };
2050
2051 if inlined != (member_inline_size <= 4) {
2052 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2053 }
2054 let _inner_offset;
2055 if inlined {
2056 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2057 _inner_offset = offset + 8;
2058 } else {
2059 depth.increment()?;
2060 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2061 }
2062 match ordinal {
2063 1 => {
2064 #[allow(irrefutable_let_patterns)]
2065 if let DeviceClass::Loopback(_) = self {
2066 } else {
2068 *self = DeviceClass::Loopback(fidl::new_empty!(Empty, D));
2070 }
2071 #[allow(irrefutable_let_patterns)]
2072 if let DeviceClass::Loopback(ref mut val) = self {
2073 fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2074 } else {
2075 unreachable!()
2076 }
2077 }
2078 2 => {
2079 #[allow(irrefutable_let_patterns)]
2080 if let DeviceClass::Device(_) = self {
2081 } else {
2083 *self = DeviceClass::Device(fidl::new_empty!(
2085 fidl_fuchsia_hardware_network::DeviceClass,
2086 D
2087 ));
2088 }
2089 #[allow(irrefutable_let_patterns)]
2090 if let DeviceClass::Device(ref mut val) = self {
2091 fidl::decode!(
2092 fidl_fuchsia_hardware_network::DeviceClass,
2093 D,
2094 val,
2095 decoder,
2096 _inner_offset,
2097 depth
2098 )?;
2099 } else {
2100 unreachable!()
2101 }
2102 }
2103 ordinal => panic!("unexpected ordinal {:?}", ordinal),
2104 }
2105 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2106 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2107 }
2108 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2109 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2110 }
2111 Ok(())
2112 }
2113 }
2114
2115 impl fidl::encoding::ValueTypeMarker for Event {
2116 type Borrowed<'a> = &'a Self;
2117 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2118 value
2119 }
2120 }
2121
2122 unsafe impl fidl::encoding::TypeMarker for Event {
2123 type Owned = Self;
2124
2125 #[inline(always)]
2126 fn inline_align(_context: fidl::encoding::Context) -> usize {
2127 8
2128 }
2129
2130 #[inline(always)]
2131 fn inline_size(_context: fidl::encoding::Context) -> usize {
2132 16
2133 }
2134 }
2135
2136 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Event, D> for &Event {
2137 #[inline]
2138 unsafe fn encode(
2139 self,
2140 encoder: &mut fidl::encoding::Encoder<'_, D>,
2141 offset: usize,
2142 _depth: fidl::encoding::Depth,
2143 ) -> fidl::Result<()> {
2144 encoder.debug_check_bounds::<Event>(offset);
2145 encoder.write_num::<u64>(self.ordinal(), offset);
2146 match self {
2147 Event::Existing(ref val) => fidl::encoding::encode_in_envelope::<Properties, D>(
2148 <Properties as fidl::encoding::ValueTypeMarker>::borrow(val),
2149 encoder,
2150 offset + 8,
2151 _depth,
2152 ),
2153 Event::Added(ref val) => fidl::encoding::encode_in_envelope::<Properties, D>(
2154 <Properties as fidl::encoding::ValueTypeMarker>::borrow(val),
2155 encoder,
2156 offset + 8,
2157 _depth,
2158 ),
2159 Event::Removed(ref val) => fidl::encoding::encode_in_envelope::<u64, D>(
2160 <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2161 encoder,
2162 offset + 8,
2163 _depth,
2164 ),
2165 Event::Changed(ref val) => fidl::encoding::encode_in_envelope::<Properties, D>(
2166 <Properties as fidl::encoding::ValueTypeMarker>::borrow(val),
2167 encoder,
2168 offset + 8,
2169 _depth,
2170 ),
2171 Event::Idle(ref val) => fidl::encoding::encode_in_envelope::<Empty, D>(
2172 <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2173 encoder,
2174 offset + 8,
2175 _depth,
2176 ),
2177 }
2178 }
2179 }
2180
2181 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Event {
2182 #[inline(always)]
2183 fn new_empty() -> Self {
2184 Self::Existing(fidl::new_empty!(Properties, D))
2185 }
2186
2187 #[inline]
2188 unsafe fn decode(
2189 &mut self,
2190 decoder: &mut fidl::encoding::Decoder<'_, D>,
2191 offset: usize,
2192 mut depth: fidl::encoding::Depth,
2193 ) -> fidl::Result<()> {
2194 decoder.debug_check_bounds::<Self>(offset);
2195 #[allow(unused_variables)]
2196 let next_out_of_line = decoder.next_out_of_line();
2197 let handles_before = decoder.remaining_handles();
2198 let (ordinal, inlined, num_bytes, num_handles) =
2199 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2200
2201 let member_inline_size = match ordinal {
2202 1 => <Properties as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2203 2 => <Properties as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2204 3 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2205 4 => <Properties as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2206 5 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2207 _ => return Err(fidl::Error::UnknownUnionTag),
2208 };
2209
2210 if inlined != (member_inline_size <= 4) {
2211 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2212 }
2213 let _inner_offset;
2214 if inlined {
2215 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2216 _inner_offset = offset + 8;
2217 } else {
2218 depth.increment()?;
2219 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2220 }
2221 match ordinal {
2222 1 => {
2223 #[allow(irrefutable_let_patterns)]
2224 if let Event::Existing(_) = self {
2225 } else {
2227 *self = Event::Existing(fidl::new_empty!(Properties, D));
2229 }
2230 #[allow(irrefutable_let_patterns)]
2231 if let Event::Existing(ref mut val) = self {
2232 fidl::decode!(Properties, D, val, decoder, _inner_offset, depth)?;
2233 } else {
2234 unreachable!()
2235 }
2236 }
2237 2 => {
2238 #[allow(irrefutable_let_patterns)]
2239 if let Event::Added(_) = self {
2240 } else {
2242 *self = Event::Added(fidl::new_empty!(Properties, D));
2244 }
2245 #[allow(irrefutable_let_patterns)]
2246 if let Event::Added(ref mut val) = self {
2247 fidl::decode!(Properties, D, val, decoder, _inner_offset, depth)?;
2248 } else {
2249 unreachable!()
2250 }
2251 }
2252 3 => {
2253 #[allow(irrefutable_let_patterns)]
2254 if let Event::Removed(_) = self {
2255 } else {
2257 *self = Event::Removed(fidl::new_empty!(u64, D));
2259 }
2260 #[allow(irrefutable_let_patterns)]
2261 if let Event::Removed(ref mut val) = self {
2262 fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
2263 } else {
2264 unreachable!()
2265 }
2266 }
2267 4 => {
2268 #[allow(irrefutable_let_patterns)]
2269 if let Event::Changed(_) = self {
2270 } else {
2272 *self = Event::Changed(fidl::new_empty!(Properties, D));
2274 }
2275 #[allow(irrefutable_let_patterns)]
2276 if let Event::Changed(ref mut val) = self {
2277 fidl::decode!(Properties, D, val, decoder, _inner_offset, depth)?;
2278 } else {
2279 unreachable!()
2280 }
2281 }
2282 5 => {
2283 #[allow(irrefutable_let_patterns)]
2284 if let Event::Idle(_) = self {
2285 } else {
2287 *self = Event::Idle(fidl::new_empty!(Empty, D));
2289 }
2290 #[allow(irrefutable_let_patterns)]
2291 if let Event::Idle(ref mut val) = self {
2292 fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2293 } else {
2294 unreachable!()
2295 }
2296 }
2297 ordinal => panic!("unexpected ordinal {:?}", ordinal),
2298 }
2299 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2300 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2301 }
2302 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2303 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2304 }
2305 Ok(())
2306 }
2307 }
2308
2309 impl fidl::encoding::ValueTypeMarker for PortClass {
2310 type Borrowed<'a> = &'a Self;
2311 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2312 value
2313 }
2314 }
2315
2316 unsafe impl fidl::encoding::TypeMarker for PortClass {
2317 type Owned = Self;
2318
2319 #[inline(always)]
2320 fn inline_align(_context: fidl::encoding::Context) -> usize {
2321 8
2322 }
2323
2324 #[inline(always)]
2325 fn inline_size(_context: fidl::encoding::Context) -> usize {
2326 16
2327 }
2328 }
2329
2330 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PortClass, D>
2331 for &PortClass
2332 {
2333 #[inline]
2334 unsafe fn encode(
2335 self,
2336 encoder: &mut fidl::encoding::Encoder<'_, D>,
2337 offset: usize,
2338 _depth: fidl::encoding::Depth,
2339 ) -> fidl::Result<()> {
2340 encoder.debug_check_bounds::<PortClass>(offset);
2341 encoder.write_num::<u64>(self.ordinal(), offset);
2342 match self {
2343 PortClass::Loopback(ref val) => {
2344 fidl::encoding::encode_in_envelope::<Empty, D>(
2345 <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2346 encoder, offset + 8, _depth
2347 )
2348 }
2349 PortClass::Device(ref val) => {
2350 fidl::encoding::encode_in_envelope::<fidl_fuchsia_hardware_network::PortClass, D>(
2351 <fidl_fuchsia_hardware_network::PortClass as fidl::encoding::ValueTypeMarker>::borrow(val),
2352 encoder, offset + 8, _depth
2353 )
2354 }
2355 PortClass::Blackhole(ref val) => {
2356 fidl::encoding::encode_in_envelope::<Empty, D>(
2357 <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2358 encoder, offset + 8, _depth
2359 )
2360 }
2361 PortClass::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2362 }
2363 }
2364 }
2365
2366 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PortClass {
2367 #[inline(always)]
2368 fn new_empty() -> Self {
2369 Self::__SourceBreaking { unknown_ordinal: 0 }
2370 }
2371
2372 #[inline]
2373 unsafe fn decode(
2374 &mut self,
2375 decoder: &mut fidl::encoding::Decoder<'_, D>,
2376 offset: usize,
2377 mut depth: fidl::encoding::Depth,
2378 ) -> fidl::Result<()> {
2379 decoder.debug_check_bounds::<Self>(offset);
2380 #[allow(unused_variables)]
2381 let next_out_of_line = decoder.next_out_of_line();
2382 let handles_before = decoder.remaining_handles();
2383 let (ordinal, inlined, num_bytes, num_handles) =
2384 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2385
2386 let member_inline_size = match ordinal {
2387 1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2388 2 => <fidl_fuchsia_hardware_network::PortClass as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2389 3 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2390 0 => return Err(fidl::Error::UnknownUnionTag),
2391 _ => num_bytes as usize,
2392 };
2393
2394 if inlined != (member_inline_size <= 4) {
2395 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2396 }
2397 let _inner_offset;
2398 if inlined {
2399 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2400 _inner_offset = offset + 8;
2401 } else {
2402 depth.increment()?;
2403 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2404 }
2405 match ordinal {
2406 1 => {
2407 #[allow(irrefutable_let_patterns)]
2408 if let PortClass::Loopback(_) = self {
2409 } else {
2411 *self = PortClass::Loopback(fidl::new_empty!(Empty, D));
2413 }
2414 #[allow(irrefutable_let_patterns)]
2415 if let PortClass::Loopback(ref mut val) = self {
2416 fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2417 } else {
2418 unreachable!()
2419 }
2420 }
2421 2 => {
2422 #[allow(irrefutable_let_patterns)]
2423 if let PortClass::Device(_) = self {
2424 } else {
2426 *self = PortClass::Device(fidl::new_empty!(
2428 fidl_fuchsia_hardware_network::PortClass,
2429 D
2430 ));
2431 }
2432 #[allow(irrefutable_let_patterns)]
2433 if let PortClass::Device(ref mut val) = self {
2434 fidl::decode!(
2435 fidl_fuchsia_hardware_network::PortClass,
2436 D,
2437 val,
2438 decoder,
2439 _inner_offset,
2440 depth
2441 )?;
2442 } else {
2443 unreachable!()
2444 }
2445 }
2446 3 => {
2447 #[allow(irrefutable_let_patterns)]
2448 if let PortClass::Blackhole(_) = self {
2449 } else {
2451 *self = PortClass::Blackhole(fidl::new_empty!(Empty, D));
2453 }
2454 #[allow(irrefutable_let_patterns)]
2455 if let PortClass::Blackhole(ref mut val) = self {
2456 fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2457 } else {
2458 unreachable!()
2459 }
2460 }
2461 #[allow(deprecated)]
2462 ordinal => {
2463 for _ in 0..num_handles {
2464 decoder.drop_next_handle()?;
2465 }
2466 *self = PortClass::__SourceBreaking { unknown_ordinal: ordinal };
2467 }
2468 }
2469 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2470 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2471 }
2472 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2473 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2474 }
2475 Ok(())
2476 }
2477 }
2478
2479 impl fidl::encoding::ValueTypeMarker for PreferredLifetimeInfo {
2480 type Borrowed<'a> = &'a Self;
2481 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2482 value
2483 }
2484 }
2485
2486 unsafe impl fidl::encoding::TypeMarker for PreferredLifetimeInfo {
2487 type Owned = Self;
2488
2489 #[inline(always)]
2490 fn inline_align(_context: fidl::encoding::Context) -> usize {
2491 8
2492 }
2493
2494 #[inline(always)]
2495 fn inline_size(_context: fidl::encoding::Context) -> usize {
2496 16
2497 }
2498 }
2499
2500 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PreferredLifetimeInfo, D>
2501 for &PreferredLifetimeInfo
2502 {
2503 #[inline]
2504 unsafe fn encode(
2505 self,
2506 encoder: &mut fidl::encoding::Encoder<'_, D>,
2507 offset: usize,
2508 _depth: fidl::encoding::Depth,
2509 ) -> fidl::Result<()> {
2510 encoder.debug_check_bounds::<PreferredLifetimeInfo>(offset);
2511 encoder.write_num::<u64>(self.ordinal(), offset);
2512 match self {
2513 PreferredLifetimeInfo::PreferredUntil(ref val) => {
2514 fidl::encoding::encode_in_envelope::<i64, D>(
2515 <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2516 encoder,
2517 offset + 8,
2518 _depth,
2519 )
2520 }
2521 PreferredLifetimeInfo::Deprecated(ref val) => {
2522 fidl::encoding::encode_in_envelope::<Empty, D>(
2523 <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2524 encoder,
2525 offset + 8,
2526 _depth,
2527 )
2528 }
2529 }
2530 }
2531 }
2532
2533 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PreferredLifetimeInfo {
2534 #[inline(always)]
2535 fn new_empty() -> Self {
2536 Self::PreferredUntil(fidl::new_empty!(i64, D))
2537 }
2538
2539 #[inline]
2540 unsafe fn decode(
2541 &mut self,
2542 decoder: &mut fidl::encoding::Decoder<'_, D>,
2543 offset: usize,
2544 mut depth: fidl::encoding::Depth,
2545 ) -> fidl::Result<()> {
2546 decoder.debug_check_bounds::<Self>(offset);
2547 #[allow(unused_variables)]
2548 let next_out_of_line = decoder.next_out_of_line();
2549 let handles_before = decoder.remaining_handles();
2550 let (ordinal, inlined, num_bytes, num_handles) =
2551 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2552
2553 let member_inline_size = match ordinal {
2554 1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2555 2 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2556 _ => return Err(fidl::Error::UnknownUnionTag),
2557 };
2558
2559 if inlined != (member_inline_size <= 4) {
2560 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2561 }
2562 let _inner_offset;
2563 if inlined {
2564 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2565 _inner_offset = offset + 8;
2566 } else {
2567 depth.increment()?;
2568 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2569 }
2570 match ordinal {
2571 1 => {
2572 #[allow(irrefutable_let_patterns)]
2573 if let PreferredLifetimeInfo::PreferredUntil(_) = self {
2574 } else {
2576 *self = PreferredLifetimeInfo::PreferredUntil(fidl::new_empty!(i64, D));
2578 }
2579 #[allow(irrefutable_let_patterns)]
2580 if let PreferredLifetimeInfo::PreferredUntil(ref mut val) = self {
2581 fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
2582 } else {
2583 unreachable!()
2584 }
2585 }
2586 2 => {
2587 #[allow(irrefutable_let_patterns)]
2588 if let PreferredLifetimeInfo::Deprecated(_) = self {
2589 } else {
2591 *self = PreferredLifetimeInfo::Deprecated(fidl::new_empty!(Empty, D));
2593 }
2594 #[allow(irrefutable_let_patterns)]
2595 if let PreferredLifetimeInfo::Deprecated(ref mut val) = self {
2596 fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2597 } else {
2598 unreachable!()
2599 }
2600 }
2601 ordinal => panic!("unexpected ordinal {:?}", ordinal),
2602 }
2603 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2604 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2605 }
2606 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2607 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2608 }
2609 Ok(())
2610 }
2611 }
2612}