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
11bitflags! {
12 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
13 pub struct TcpState: u32 {
14 const ESTABLISHED = 1;
15 const SYN_SENT = 2;
16 const SYN_RECV = 4;
17 const FIN_WAIT1 = 8;
18 const FIN_WAIT2 = 16;
19 const TIME_WAIT = 32;
20 const CLOSE = 64;
21 const CLOSE_WAIT = 128;
22 const LAST_ACK = 256;
23 const LISTEN = 512;
24 const CLOSING = 1024;
25 }
26}
27
28impl TcpState {}
29
30bitflags! {
31 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
32 pub struct UdpState: u32 {
33 const BOUND = 1;
35 const CONNECTED = 2;
37 }
38}
39
40impl UdpState {}
41
42#[derive(Clone, Debug, PartialEq)]
44pub struct Address {
45 pub matcher: AddressMatcherType,
46 pub invert: bool,
50}
51
52impl fidl::Persistable for Address {}
53
54#[derive(Clone, Debug, PartialEq)]
55pub struct AddressRange {
56 pub start: fidl_fuchsia_net__common::IpAddress,
58 pub end: fidl_fuchsia_net__common::IpAddress,
60}
61
62impl fidl::Persistable for AddressRange {}
63
64#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
66pub struct Empty;
67
68impl fidl::Persistable for Empty {}
69
70#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
72pub struct Mark {
73 pub domain: fidl_fuchsia_net__common::MarkDomain,
75 pub mask: u32,
78 pub value: u32,
80 pub invert: bool,
84}
85
86impl fidl::Persistable for Mark {}
87
88#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
92pub struct Port {
93 pub start: u16,
95 pub end: u16,
97 pub invert: bool,
99}
100
101impl fidl::Persistable for Port {}
102
103#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
105pub struct SocketCookie {
106 pub cookie: u64,
108 pub invert: bool,
110}
111
112impl fidl::Persistable for SocketCookie {}
113
114#[derive(Clone, Debug, Default, PartialEq)]
116pub struct IcmpPacket {
117 #[doc(hidden)]
118 pub __source_breaking: fidl::marker::SourceBreaking,
119}
120
121impl fidl::Persistable for IcmpPacket {}
122
123#[derive(Clone, Debug, Default, PartialEq)]
125pub struct Icmpv6Packet {
126 #[doc(hidden)]
127 pub __source_breaking: fidl::marker::SourceBreaking,
128}
129
130impl fidl::Persistable for Icmpv6Packet {}
131
132#[derive(Clone, Debug, Default, PartialEq)]
134pub struct TcpPacket {
135 pub src_port: Option<Port>,
137 pub dst_port: Option<Port>,
139 #[doc(hidden)]
140 pub __source_breaking: fidl::marker::SourceBreaking,
141}
142
143impl fidl::Persistable for TcpPacket {}
144
145#[derive(Clone, Debug, Default, PartialEq)]
147pub struct UdpPacket {
148 pub src_port: Option<Port>,
150 pub dst_port: Option<Port>,
152 #[doc(hidden)]
153 pub __source_breaking: fidl::marker::SourceBreaking,
154}
155
156impl fidl::Persistable for UdpPacket {}
157
158#[derive(Clone, Debug)]
159pub enum AddressMatcherType {
160 Subnet(fidl_fuchsia_net__common::Subnet),
163 Range(AddressRange),
170 #[doc(hidden)]
171 __SourceBreaking { unknown_ordinal: u64 },
172}
173
174#[macro_export]
176macro_rules! AddressMatcherTypeUnknown {
177 () => {
178 _
179 };
180}
181
182impl PartialEq for AddressMatcherType {
184 fn eq(&self, other: &Self) -> bool {
185 match (self, other) {
186 (Self::Subnet(x), Self::Subnet(y)) => *x == *y,
187 (Self::Range(x), Self::Range(y)) => *x == *y,
188 _ => false,
189 }
190 }
191}
192
193impl AddressMatcherType {
194 #[inline]
195 pub fn ordinal(&self) -> u64 {
196 match *self {
197 Self::Subnet(_) => 1,
198 Self::Range(_) => 2,
199 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
200 }
201 }
202
203 #[inline]
204 pub fn unknown_variant_for_testing() -> Self {
205 Self::__SourceBreaking { unknown_ordinal: 0 }
206 }
207
208 #[inline]
209 pub fn is_unknown(&self) -> bool {
210 match self {
211 Self::__SourceBreaking { .. } => true,
212 _ => false,
213 }
214 }
215}
216
217impl fidl::Persistable for AddressMatcherType {}
218
219#[derive(Clone, Debug)]
221pub enum Interface {
222 Id(u64),
224 Name(String),
226 PortClass(fidl_fuchsia_net_interfaces__common::PortClass),
228 #[doc(hidden)]
229 __SourceBreaking { unknown_ordinal: u64 },
230}
231
232#[macro_export]
234macro_rules! InterfaceUnknown {
235 () => {
236 _
237 };
238}
239
240impl PartialEq for Interface {
242 fn eq(&self, other: &Self) -> bool {
243 match (self, other) {
244 (Self::Id(x), Self::Id(y)) => *x == *y,
245 (Self::Name(x), Self::Name(y)) => *x == *y,
246 (Self::PortClass(x), Self::PortClass(y)) => *x == *y,
247 _ => false,
248 }
249 }
250}
251
252impl Interface {
253 #[inline]
254 pub fn ordinal(&self) -> u64 {
255 match *self {
256 Self::Id(_) => 1,
257 Self::Name(_) => 2,
258 Self::PortClass(_) => 3,
259 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
260 }
261 }
262
263 #[inline]
264 pub fn unknown_variant_for_testing() -> Self {
265 Self::__SourceBreaking { unknown_ordinal: 0 }
266 }
267
268 #[inline]
269 pub fn is_unknown(&self) -> bool {
270 match self {
271 Self::__SourceBreaking { .. } => true,
272 _ => false,
273 }
274 }
275}
276
277impl fidl::Persistable for Interface {}
278
279#[derive(Clone, Debug)]
281pub enum PacketTransportProtocol {
282 Tcp(TcpPacket),
283 Udp(UdpPacket),
284 Icmp(IcmpPacket),
285 Icmpv6(Icmpv6Packet),
286 #[doc(hidden)]
287 __SourceBreaking {
288 unknown_ordinal: u64,
289 },
290}
291
292#[macro_export]
294macro_rules! PacketTransportProtocolUnknown {
295 () => {
296 _
297 };
298}
299
300impl PartialEq for PacketTransportProtocol {
302 fn eq(&self, other: &Self) -> bool {
303 match (self, other) {
304 (Self::Tcp(x), Self::Tcp(y)) => *x == *y,
305 (Self::Udp(x), Self::Udp(y)) => *x == *y,
306 (Self::Icmp(x), Self::Icmp(y)) => *x == *y,
307 (Self::Icmpv6(x), Self::Icmpv6(y)) => *x == *y,
308 _ => false,
309 }
310 }
311}
312
313impl PacketTransportProtocol {
314 #[inline]
315 pub fn ordinal(&self) -> u64 {
316 match *self {
317 Self::Tcp(_) => 1,
318 Self::Udp(_) => 2,
319 Self::Icmp(_) => 3,
320 Self::Icmpv6(_) => 4,
321 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
322 }
323 }
324
325 #[inline]
326 pub fn unknown_variant_for_testing() -> Self {
327 Self::__SourceBreaking { unknown_ordinal: 0 }
328 }
329
330 #[inline]
331 pub fn is_unknown(&self) -> bool {
332 match self {
333 Self::__SourceBreaking { .. } => true,
334 _ => false,
335 }
336 }
337}
338
339impl fidl::Persistable for PacketTransportProtocol {}
340
341#[derive(Clone, Debug)]
343pub enum SocketTransportProtocol {
344 Tcp(TcpSocket),
346 Udp(UdpSocket),
348 #[doc(hidden)]
349 __SourceBreaking { unknown_ordinal: u64 },
350}
351
352#[macro_export]
354macro_rules! SocketTransportProtocolUnknown {
355 () => {
356 _
357 };
358}
359
360impl PartialEq for SocketTransportProtocol {
362 fn eq(&self, other: &Self) -> bool {
363 match (self, other) {
364 (Self::Tcp(x), Self::Tcp(y)) => *x == *y,
365 (Self::Udp(x), Self::Udp(y)) => *x == *y,
366 _ => false,
367 }
368 }
369}
370
371impl SocketTransportProtocol {
372 #[inline]
373 pub fn ordinal(&self) -> u64 {
374 match *self {
375 Self::Tcp(_) => 1,
376 Self::Udp(_) => 2,
377 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
378 }
379 }
380
381 #[inline]
382 pub fn unknown_variant_for_testing() -> Self {
383 Self::__SourceBreaking { unknown_ordinal: 0 }
384 }
385
386 #[inline]
387 pub fn is_unknown(&self) -> bool {
388 match self {
389 Self::__SourceBreaking { .. } => true,
390 _ => false,
391 }
392 }
393}
394
395impl fidl::Persistable for SocketTransportProtocol {}
396
397#[derive(Clone, Debug)]
399pub enum TcpSocket {
400 Empty(Empty),
402 SrcPort(Port),
404 DstPort(Port),
406 States(TcpState),
412 #[doc(hidden)]
413 __SourceBreaking { unknown_ordinal: u64 },
414}
415
416#[macro_export]
418macro_rules! TcpSocketUnknown {
419 () => {
420 _
421 };
422}
423
424impl PartialEq for TcpSocket {
426 fn eq(&self, other: &Self) -> bool {
427 match (self, other) {
428 (Self::Empty(x), Self::Empty(y)) => *x == *y,
429 (Self::SrcPort(x), Self::SrcPort(y)) => *x == *y,
430 (Self::DstPort(x), Self::DstPort(y)) => *x == *y,
431 (Self::States(x), Self::States(y)) => *x == *y,
432 _ => false,
433 }
434 }
435}
436
437impl TcpSocket {
438 #[inline]
439 pub fn ordinal(&self) -> u64 {
440 match *self {
441 Self::Empty(_) => 1,
442 Self::SrcPort(_) => 2,
443 Self::DstPort(_) => 3,
444 Self::States(_) => 4,
445 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
446 }
447 }
448
449 #[inline]
450 pub fn unknown_variant_for_testing() -> Self {
451 Self::__SourceBreaking { unknown_ordinal: 0 }
452 }
453
454 #[inline]
455 pub fn is_unknown(&self) -> bool {
456 match self {
457 Self::__SourceBreaking { .. } => true,
458 _ => false,
459 }
460 }
461}
462
463impl fidl::Persistable for TcpSocket {}
464
465#[derive(Clone, Debug)]
467pub enum UdpSocket {
468 Empty(Empty),
470 SrcPort(Port),
472 DstPort(Port),
474 States(UdpState),
478 #[doc(hidden)]
479 __SourceBreaking { unknown_ordinal: u64 },
480}
481
482#[macro_export]
484macro_rules! UdpSocketUnknown {
485 () => {
486 _
487 };
488}
489
490impl PartialEq for UdpSocket {
492 fn eq(&self, other: &Self) -> bool {
493 match (self, other) {
494 (Self::Empty(x), Self::Empty(y)) => *x == *y,
495 (Self::SrcPort(x), Self::SrcPort(y)) => *x == *y,
496 (Self::DstPort(x), Self::DstPort(y)) => *x == *y,
497 (Self::States(x), Self::States(y)) => *x == *y,
498 _ => false,
499 }
500 }
501}
502
503impl UdpSocket {
504 #[inline]
505 pub fn ordinal(&self) -> u64 {
506 match *self {
507 Self::Empty(_) => 1,
508 Self::SrcPort(_) => 2,
509 Self::DstPort(_) => 3,
510 Self::States(_) => 4,
511 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
512 }
513 }
514
515 #[inline]
516 pub fn unknown_variant_for_testing() -> Self {
517 Self::__SourceBreaking { unknown_ordinal: 0 }
518 }
519
520 #[inline]
521 pub fn is_unknown(&self) -> bool {
522 match self {
523 Self::__SourceBreaking { .. } => true,
524 _ => false,
525 }
526 }
527}
528
529impl fidl::Persistable for UdpSocket {}
530
531mod internal {
532 use super::*;
533 unsafe impl fidl::encoding::TypeMarker for TcpState {
534 type Owned = Self;
535
536 #[inline(always)]
537 fn inline_align(_context: fidl::encoding::Context) -> usize {
538 4
539 }
540
541 #[inline(always)]
542 fn inline_size(_context: fidl::encoding::Context) -> usize {
543 4
544 }
545 }
546
547 impl fidl::encoding::ValueTypeMarker for TcpState {
548 type Borrowed<'a> = Self;
549 #[inline(always)]
550 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
551 *value
552 }
553 }
554
555 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for TcpState {
556 #[inline]
557 unsafe fn encode(
558 self,
559 encoder: &mut fidl::encoding::Encoder<'_, D>,
560 offset: usize,
561 _depth: fidl::encoding::Depth,
562 ) -> fidl::Result<()> {
563 encoder.debug_check_bounds::<Self>(offset);
564 if self.bits() & Self::all().bits() != self.bits() {
565 return Err(fidl::Error::InvalidBitsValue);
566 }
567 encoder.write_num(self.bits(), offset);
568 Ok(())
569 }
570 }
571
572 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TcpState {
573 #[inline(always)]
574 fn new_empty() -> Self {
575 Self::empty()
576 }
577
578 #[inline]
579 unsafe fn decode(
580 &mut self,
581 decoder: &mut fidl::encoding::Decoder<'_, D>,
582 offset: usize,
583 _depth: fidl::encoding::Depth,
584 ) -> fidl::Result<()> {
585 decoder.debug_check_bounds::<Self>(offset);
586 let prim = decoder.read_num::<u32>(offset);
587 *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
588 Ok(())
589 }
590 }
591 unsafe impl fidl::encoding::TypeMarker for UdpState {
592 type Owned = Self;
593
594 #[inline(always)]
595 fn inline_align(_context: fidl::encoding::Context) -> usize {
596 4
597 }
598
599 #[inline(always)]
600 fn inline_size(_context: fidl::encoding::Context) -> usize {
601 4
602 }
603 }
604
605 impl fidl::encoding::ValueTypeMarker for UdpState {
606 type Borrowed<'a> = Self;
607 #[inline(always)]
608 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
609 *value
610 }
611 }
612
613 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for UdpState {
614 #[inline]
615 unsafe fn encode(
616 self,
617 encoder: &mut fidl::encoding::Encoder<'_, D>,
618 offset: usize,
619 _depth: fidl::encoding::Depth,
620 ) -> fidl::Result<()> {
621 encoder.debug_check_bounds::<Self>(offset);
622 if self.bits() & Self::all().bits() != self.bits() {
623 return Err(fidl::Error::InvalidBitsValue);
624 }
625 encoder.write_num(self.bits(), offset);
626 Ok(())
627 }
628 }
629
630 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UdpState {
631 #[inline(always)]
632 fn new_empty() -> Self {
633 Self::empty()
634 }
635
636 #[inline]
637 unsafe fn decode(
638 &mut self,
639 decoder: &mut fidl::encoding::Decoder<'_, D>,
640 offset: usize,
641 _depth: fidl::encoding::Depth,
642 ) -> fidl::Result<()> {
643 decoder.debug_check_bounds::<Self>(offset);
644 let prim = decoder.read_num::<u32>(offset);
645 *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
646 Ok(())
647 }
648 }
649
650 impl fidl::encoding::ValueTypeMarker for Address {
651 type Borrowed<'a> = &'a Self;
652 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
653 value
654 }
655 }
656
657 unsafe impl fidl::encoding::TypeMarker for Address {
658 type Owned = Self;
659
660 #[inline(always)]
661 fn inline_align(_context: fidl::encoding::Context) -> usize {
662 8
663 }
664
665 #[inline(always)]
666 fn inline_size(_context: fidl::encoding::Context) -> usize {
667 24
668 }
669 }
670
671 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Address, D> for &Address {
672 #[inline]
673 unsafe fn encode(
674 self,
675 encoder: &mut fidl::encoding::Encoder<'_, D>,
676 offset: usize,
677 _depth: fidl::encoding::Depth,
678 ) -> fidl::Result<()> {
679 encoder.debug_check_bounds::<Address>(offset);
680 fidl::encoding::Encode::<Address, D>::encode(
682 (
683 <AddressMatcherType as fidl::encoding::ValueTypeMarker>::borrow(&self.matcher),
684 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.invert),
685 ),
686 encoder,
687 offset,
688 _depth,
689 )
690 }
691 }
692 unsafe impl<
693 D: fidl::encoding::ResourceDialect,
694 T0: fidl::encoding::Encode<AddressMatcherType, D>,
695 T1: fidl::encoding::Encode<bool, D>,
696 > fidl::encoding::Encode<Address, D> for (T0, T1)
697 {
698 #[inline]
699 unsafe fn encode(
700 self,
701 encoder: &mut fidl::encoding::Encoder<'_, D>,
702 offset: usize,
703 depth: fidl::encoding::Depth,
704 ) -> fidl::Result<()> {
705 encoder.debug_check_bounds::<Address>(offset);
706 unsafe {
709 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
710 (ptr as *mut u64).write_unaligned(0);
711 }
712 self.0.encode(encoder, offset + 0, depth)?;
714 self.1.encode(encoder, offset + 16, depth)?;
715 Ok(())
716 }
717 }
718
719 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Address {
720 #[inline(always)]
721 fn new_empty() -> Self {
722 Self {
723 matcher: fidl::new_empty!(AddressMatcherType, D),
724 invert: fidl::new_empty!(bool, D),
725 }
726 }
727
728 #[inline]
729 unsafe fn decode(
730 &mut self,
731 decoder: &mut fidl::encoding::Decoder<'_, D>,
732 offset: usize,
733 _depth: fidl::encoding::Depth,
734 ) -> fidl::Result<()> {
735 decoder.debug_check_bounds::<Self>(offset);
736 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
738 let padval = unsafe { (ptr as *const u64).read_unaligned() };
739 let mask = 0xffffffffffffff00u64;
740 let maskedval = padval & mask;
741 if maskedval != 0 {
742 return Err(fidl::Error::NonZeroPadding {
743 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
744 });
745 }
746 fidl::decode!(AddressMatcherType, D, &mut self.matcher, decoder, offset + 0, _depth)?;
747 fidl::decode!(bool, D, &mut self.invert, decoder, offset + 16, _depth)?;
748 Ok(())
749 }
750 }
751
752 impl fidl::encoding::ValueTypeMarker for AddressRange {
753 type Borrowed<'a> = &'a Self;
754 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
755 value
756 }
757 }
758
759 unsafe impl fidl::encoding::TypeMarker for AddressRange {
760 type Owned = Self;
761
762 #[inline(always)]
763 fn inline_align(_context: fidl::encoding::Context) -> usize {
764 8
765 }
766
767 #[inline(always)]
768 fn inline_size(_context: fidl::encoding::Context) -> usize {
769 32
770 }
771 }
772
773 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<AddressRange, D>
774 for &AddressRange
775 {
776 #[inline]
777 unsafe fn encode(
778 self,
779 encoder: &mut fidl::encoding::Encoder<'_, D>,
780 offset: usize,
781 _depth: fidl::encoding::Depth,
782 ) -> fidl::Result<()> {
783 encoder.debug_check_bounds::<AddressRange>(offset);
784 fidl::encoding::Encode::<AddressRange, D>::encode(
786 (
787 <fidl_fuchsia_net__common::IpAddress as fidl::encoding::ValueTypeMarker>::borrow(&self.start),
788 <fidl_fuchsia_net__common::IpAddress as fidl::encoding::ValueTypeMarker>::borrow(&self.end),
789 ),
790 encoder, offset, _depth
791 )
792 }
793 }
794 unsafe impl<
795 D: fidl::encoding::ResourceDialect,
796 T0: fidl::encoding::Encode<fidl_fuchsia_net__common::IpAddress, D>,
797 T1: fidl::encoding::Encode<fidl_fuchsia_net__common::IpAddress, D>,
798 > fidl::encoding::Encode<AddressRange, D> for (T0, T1)
799 {
800 #[inline]
801 unsafe fn encode(
802 self,
803 encoder: &mut fidl::encoding::Encoder<'_, D>,
804 offset: usize,
805 depth: fidl::encoding::Depth,
806 ) -> fidl::Result<()> {
807 encoder.debug_check_bounds::<AddressRange>(offset);
808 self.0.encode(encoder, offset + 0, depth)?;
812 self.1.encode(encoder, offset + 16, depth)?;
813 Ok(())
814 }
815 }
816
817 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AddressRange {
818 #[inline(always)]
819 fn new_empty() -> Self {
820 Self {
821 start: fidl::new_empty!(fidl_fuchsia_net__common::IpAddress, D),
822 end: fidl::new_empty!(fidl_fuchsia_net__common::IpAddress, D),
823 }
824 }
825
826 #[inline]
827 unsafe fn decode(
828 &mut self,
829 decoder: &mut fidl::encoding::Decoder<'_, D>,
830 offset: usize,
831 _depth: fidl::encoding::Depth,
832 ) -> fidl::Result<()> {
833 decoder.debug_check_bounds::<Self>(offset);
834 fidl::decode!(
836 fidl_fuchsia_net__common::IpAddress,
837 D,
838 &mut self.start,
839 decoder,
840 offset + 0,
841 _depth
842 )?;
843 fidl::decode!(
844 fidl_fuchsia_net__common::IpAddress,
845 D,
846 &mut self.end,
847 decoder,
848 offset + 16,
849 _depth
850 )?;
851 Ok(())
852 }
853 }
854
855 impl fidl::encoding::ValueTypeMarker for Empty {
856 type Borrowed<'a> = &'a Self;
857 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
858 value
859 }
860 }
861
862 unsafe impl fidl::encoding::TypeMarker for Empty {
863 type Owned = Self;
864
865 #[inline(always)]
866 fn inline_align(_context: fidl::encoding::Context) -> usize {
867 1
868 }
869
870 #[inline(always)]
871 fn inline_size(_context: fidl::encoding::Context) -> usize {
872 1
873 }
874 }
875
876 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Empty, D> for &Empty {
877 #[inline]
878 unsafe fn encode(
879 self,
880 encoder: &mut fidl::encoding::Encoder<'_, D>,
881 offset: usize,
882 _depth: fidl::encoding::Depth,
883 ) -> fidl::Result<()> {
884 encoder.debug_check_bounds::<Empty>(offset);
885 encoder.write_num(0u8, offset);
886 Ok(())
887 }
888 }
889
890 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Empty {
891 #[inline(always)]
892 fn new_empty() -> Self {
893 Self
894 }
895
896 #[inline]
897 unsafe fn decode(
898 &mut self,
899 decoder: &mut fidl::encoding::Decoder<'_, D>,
900 offset: usize,
901 _depth: fidl::encoding::Depth,
902 ) -> fidl::Result<()> {
903 decoder.debug_check_bounds::<Self>(offset);
904 match decoder.read_num::<u8>(offset) {
905 0 => Ok(()),
906 _ => Err(fidl::Error::Invalid),
907 }
908 }
909 }
910
911 impl fidl::encoding::ValueTypeMarker for Mark {
912 type Borrowed<'a> = &'a Self;
913 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
914 value
915 }
916 }
917
918 unsafe impl fidl::encoding::TypeMarker for Mark {
919 type Owned = Self;
920
921 #[inline(always)]
922 fn inline_align(_context: fidl::encoding::Context) -> usize {
923 4
924 }
925
926 #[inline(always)]
927 fn inline_size(_context: fidl::encoding::Context) -> usize {
928 16
929 }
930 }
931
932 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Mark, D> for &Mark {
933 #[inline]
934 unsafe fn encode(
935 self,
936 encoder: &mut fidl::encoding::Encoder<'_, D>,
937 offset: usize,
938 _depth: fidl::encoding::Depth,
939 ) -> fidl::Result<()> {
940 encoder.debug_check_bounds::<Mark>(offset);
941 fidl::encoding::Encode::<Mark, D>::encode(
943 (
944 <fidl_fuchsia_net__common::MarkDomain as fidl::encoding::ValueTypeMarker>::borrow(&self.domain),
945 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.mask),
946 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.value),
947 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.invert),
948 ),
949 encoder, offset, _depth
950 )
951 }
952 }
953 unsafe impl<
954 D: fidl::encoding::ResourceDialect,
955 T0: fidl::encoding::Encode<fidl_fuchsia_net__common::MarkDomain, D>,
956 T1: fidl::encoding::Encode<u32, D>,
957 T2: fidl::encoding::Encode<u32, D>,
958 T3: fidl::encoding::Encode<bool, D>,
959 > fidl::encoding::Encode<Mark, D> for (T0, T1, T2, T3)
960 {
961 #[inline]
962 unsafe fn encode(
963 self,
964 encoder: &mut fidl::encoding::Encoder<'_, D>,
965 offset: usize,
966 depth: fidl::encoding::Depth,
967 ) -> fidl::Result<()> {
968 encoder.debug_check_bounds::<Mark>(offset);
969 unsafe {
972 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
973 (ptr as *mut u32).write_unaligned(0);
974 }
975 unsafe {
976 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(12);
977 (ptr as *mut u32).write_unaligned(0);
978 }
979 self.0.encode(encoder, offset + 0, depth)?;
981 self.1.encode(encoder, offset + 4, depth)?;
982 self.2.encode(encoder, offset + 8, depth)?;
983 self.3.encode(encoder, offset + 12, depth)?;
984 Ok(())
985 }
986 }
987
988 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Mark {
989 #[inline(always)]
990 fn new_empty() -> Self {
991 Self {
992 domain: fidl::new_empty!(fidl_fuchsia_net__common::MarkDomain, D),
993 mask: fidl::new_empty!(u32, D),
994 value: fidl::new_empty!(u32, D),
995 invert: fidl::new_empty!(bool, D),
996 }
997 }
998
999 #[inline]
1000 unsafe fn decode(
1001 &mut self,
1002 decoder: &mut fidl::encoding::Decoder<'_, D>,
1003 offset: usize,
1004 _depth: fidl::encoding::Depth,
1005 ) -> fidl::Result<()> {
1006 decoder.debug_check_bounds::<Self>(offset);
1007 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1009 let padval = unsafe { (ptr as *const u32).read_unaligned() };
1010 let mask = 0xffffff00u32;
1011 let maskedval = padval & mask;
1012 if maskedval != 0 {
1013 return Err(fidl::Error::NonZeroPadding {
1014 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1015 });
1016 }
1017 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(12) };
1018 let padval = unsafe { (ptr as *const u32).read_unaligned() };
1019 let mask = 0xffffff00u32;
1020 let maskedval = padval & mask;
1021 if maskedval != 0 {
1022 return Err(fidl::Error::NonZeroPadding {
1023 padding_start: offset + 12 + ((mask as u64).trailing_zeros() / 8) as usize,
1024 });
1025 }
1026 fidl::decode!(
1027 fidl_fuchsia_net__common::MarkDomain,
1028 D,
1029 &mut self.domain,
1030 decoder,
1031 offset + 0,
1032 _depth
1033 )?;
1034 fidl::decode!(u32, D, &mut self.mask, decoder, offset + 4, _depth)?;
1035 fidl::decode!(u32, D, &mut self.value, decoder, offset + 8, _depth)?;
1036 fidl::decode!(bool, D, &mut self.invert, decoder, offset + 12, _depth)?;
1037 Ok(())
1038 }
1039 }
1040
1041 impl fidl::encoding::ValueTypeMarker for Port {
1042 type Borrowed<'a> = &'a Self;
1043 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1044 value
1045 }
1046 }
1047
1048 unsafe impl fidl::encoding::TypeMarker for Port {
1049 type Owned = Self;
1050
1051 #[inline(always)]
1052 fn inline_align(_context: fidl::encoding::Context) -> usize {
1053 2
1054 }
1055
1056 #[inline(always)]
1057 fn inline_size(_context: fidl::encoding::Context) -> usize {
1058 6
1059 }
1060 }
1061
1062 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Port, D> for &Port {
1063 #[inline]
1064 unsafe fn encode(
1065 self,
1066 encoder: &mut fidl::encoding::Encoder<'_, D>,
1067 offset: usize,
1068 _depth: fidl::encoding::Depth,
1069 ) -> fidl::Result<()> {
1070 encoder.debug_check_bounds::<Port>(offset);
1071 fidl::encoding::Encode::<Port, D>::encode(
1073 (
1074 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.start),
1075 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.end),
1076 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.invert),
1077 ),
1078 encoder,
1079 offset,
1080 _depth,
1081 )
1082 }
1083 }
1084 unsafe impl<
1085 D: fidl::encoding::ResourceDialect,
1086 T0: fidl::encoding::Encode<u16, D>,
1087 T1: fidl::encoding::Encode<u16, D>,
1088 T2: fidl::encoding::Encode<bool, D>,
1089 > fidl::encoding::Encode<Port, D> for (T0, T1, T2)
1090 {
1091 #[inline]
1092 unsafe fn encode(
1093 self,
1094 encoder: &mut fidl::encoding::Encoder<'_, D>,
1095 offset: usize,
1096 depth: fidl::encoding::Depth,
1097 ) -> fidl::Result<()> {
1098 encoder.debug_check_bounds::<Port>(offset);
1099 unsafe {
1102 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
1103 (ptr as *mut u16).write_unaligned(0);
1104 }
1105 self.0.encode(encoder, offset + 0, depth)?;
1107 self.1.encode(encoder, offset + 2, depth)?;
1108 self.2.encode(encoder, offset + 4, depth)?;
1109 Ok(())
1110 }
1111 }
1112
1113 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Port {
1114 #[inline(always)]
1115 fn new_empty() -> Self {
1116 Self {
1117 start: fidl::new_empty!(u16, D),
1118 end: fidl::new_empty!(u16, D),
1119 invert: fidl::new_empty!(bool, D),
1120 }
1121 }
1122
1123 #[inline]
1124 unsafe fn decode(
1125 &mut self,
1126 decoder: &mut fidl::encoding::Decoder<'_, D>,
1127 offset: usize,
1128 _depth: fidl::encoding::Depth,
1129 ) -> fidl::Result<()> {
1130 decoder.debug_check_bounds::<Self>(offset);
1131 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
1133 let padval = unsafe { (ptr as *const u16).read_unaligned() };
1134 let mask = 0xff00u16;
1135 let maskedval = padval & mask;
1136 if maskedval != 0 {
1137 return Err(fidl::Error::NonZeroPadding {
1138 padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
1139 });
1140 }
1141 fidl::decode!(u16, D, &mut self.start, decoder, offset + 0, _depth)?;
1142 fidl::decode!(u16, D, &mut self.end, decoder, offset + 2, _depth)?;
1143 fidl::decode!(bool, D, &mut self.invert, decoder, offset + 4, _depth)?;
1144 Ok(())
1145 }
1146 }
1147
1148 impl fidl::encoding::ValueTypeMarker for SocketCookie {
1149 type Borrowed<'a> = &'a Self;
1150 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1151 value
1152 }
1153 }
1154
1155 unsafe impl fidl::encoding::TypeMarker for SocketCookie {
1156 type Owned = Self;
1157
1158 #[inline(always)]
1159 fn inline_align(_context: fidl::encoding::Context) -> usize {
1160 8
1161 }
1162
1163 #[inline(always)]
1164 fn inline_size(_context: fidl::encoding::Context) -> usize {
1165 16
1166 }
1167 }
1168
1169 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SocketCookie, D>
1170 for &SocketCookie
1171 {
1172 #[inline]
1173 unsafe fn encode(
1174 self,
1175 encoder: &mut fidl::encoding::Encoder<'_, D>,
1176 offset: usize,
1177 _depth: fidl::encoding::Depth,
1178 ) -> fidl::Result<()> {
1179 encoder.debug_check_bounds::<SocketCookie>(offset);
1180 fidl::encoding::Encode::<SocketCookie, D>::encode(
1182 (
1183 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.cookie),
1184 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.invert),
1185 ),
1186 encoder,
1187 offset,
1188 _depth,
1189 )
1190 }
1191 }
1192 unsafe impl<
1193 D: fidl::encoding::ResourceDialect,
1194 T0: fidl::encoding::Encode<u64, D>,
1195 T1: fidl::encoding::Encode<bool, D>,
1196 > fidl::encoding::Encode<SocketCookie, D> for (T0, T1)
1197 {
1198 #[inline]
1199 unsafe fn encode(
1200 self,
1201 encoder: &mut fidl::encoding::Encoder<'_, D>,
1202 offset: usize,
1203 depth: fidl::encoding::Depth,
1204 ) -> fidl::Result<()> {
1205 encoder.debug_check_bounds::<SocketCookie>(offset);
1206 unsafe {
1209 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
1210 (ptr as *mut u64).write_unaligned(0);
1211 }
1212 self.0.encode(encoder, offset + 0, depth)?;
1214 self.1.encode(encoder, offset + 8, depth)?;
1215 Ok(())
1216 }
1217 }
1218
1219 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketCookie {
1220 #[inline(always)]
1221 fn new_empty() -> Self {
1222 Self { cookie: fidl::new_empty!(u64, D), invert: fidl::new_empty!(bool, D) }
1223 }
1224
1225 #[inline]
1226 unsafe fn decode(
1227 &mut self,
1228 decoder: &mut fidl::encoding::Decoder<'_, D>,
1229 offset: usize,
1230 _depth: fidl::encoding::Depth,
1231 ) -> fidl::Result<()> {
1232 decoder.debug_check_bounds::<Self>(offset);
1233 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
1235 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1236 let mask = 0xffffffffffffff00u64;
1237 let maskedval = padval & mask;
1238 if maskedval != 0 {
1239 return Err(fidl::Error::NonZeroPadding {
1240 padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
1241 });
1242 }
1243 fidl::decode!(u64, D, &mut self.cookie, decoder, offset + 0, _depth)?;
1244 fidl::decode!(bool, D, &mut self.invert, decoder, offset + 8, _depth)?;
1245 Ok(())
1246 }
1247 }
1248
1249 impl IcmpPacket {
1250 #[inline(always)]
1251 fn max_ordinal_present(&self) -> u64 {
1252 0
1253 }
1254 }
1255
1256 impl fidl::encoding::ValueTypeMarker for IcmpPacket {
1257 type Borrowed<'a> = &'a Self;
1258 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1259 value
1260 }
1261 }
1262
1263 unsafe impl fidl::encoding::TypeMarker for IcmpPacket {
1264 type Owned = Self;
1265
1266 #[inline(always)]
1267 fn inline_align(_context: fidl::encoding::Context) -> usize {
1268 8
1269 }
1270
1271 #[inline(always)]
1272 fn inline_size(_context: fidl::encoding::Context) -> usize {
1273 16
1274 }
1275 }
1276
1277 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<IcmpPacket, D>
1278 for &IcmpPacket
1279 {
1280 unsafe fn encode(
1281 self,
1282 encoder: &mut fidl::encoding::Encoder<'_, D>,
1283 offset: usize,
1284 mut depth: fidl::encoding::Depth,
1285 ) -> fidl::Result<()> {
1286 encoder.debug_check_bounds::<IcmpPacket>(offset);
1287 let max_ordinal: u64 = self.max_ordinal_present();
1289 encoder.write_num(max_ordinal, offset);
1290 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1291 if max_ordinal == 0 {
1293 return Ok(());
1294 }
1295 depth.increment()?;
1296 let envelope_size = 8;
1297 let bytes_len = max_ordinal as usize * envelope_size;
1298 #[allow(unused_variables)]
1299 let offset = encoder.out_of_line_offset(bytes_len);
1300 let mut _prev_end_offset: usize = 0;
1301
1302 Ok(())
1303 }
1304 }
1305
1306 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for IcmpPacket {
1307 #[inline(always)]
1308 fn new_empty() -> Self {
1309 Self::default()
1310 }
1311
1312 unsafe fn decode(
1313 &mut self,
1314 decoder: &mut fidl::encoding::Decoder<'_, D>,
1315 offset: usize,
1316 mut depth: fidl::encoding::Depth,
1317 ) -> fidl::Result<()> {
1318 decoder.debug_check_bounds::<Self>(offset);
1319 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1320 None => return Err(fidl::Error::NotNullable),
1321 Some(len) => len,
1322 };
1323 if len == 0 {
1325 return Ok(());
1326 };
1327 depth.increment()?;
1328 let envelope_size = 8;
1329 let bytes_len = len * envelope_size;
1330 let offset = decoder.out_of_line_offset(bytes_len)?;
1331 let mut _next_ordinal_to_read = 0;
1333 let mut next_offset = offset;
1334 let end_offset = offset + bytes_len;
1335
1336 while next_offset < end_offset {
1338 _next_ordinal_to_read += 1;
1339 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1340 next_offset += envelope_size;
1341 }
1342
1343 Ok(())
1344 }
1345 }
1346
1347 impl Icmpv6Packet {
1348 #[inline(always)]
1349 fn max_ordinal_present(&self) -> u64 {
1350 0
1351 }
1352 }
1353
1354 impl fidl::encoding::ValueTypeMarker for Icmpv6Packet {
1355 type Borrowed<'a> = &'a Self;
1356 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1357 value
1358 }
1359 }
1360
1361 unsafe impl fidl::encoding::TypeMarker for Icmpv6Packet {
1362 type Owned = Self;
1363
1364 #[inline(always)]
1365 fn inline_align(_context: fidl::encoding::Context) -> usize {
1366 8
1367 }
1368
1369 #[inline(always)]
1370 fn inline_size(_context: fidl::encoding::Context) -> usize {
1371 16
1372 }
1373 }
1374
1375 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Icmpv6Packet, D>
1376 for &Icmpv6Packet
1377 {
1378 unsafe fn encode(
1379 self,
1380 encoder: &mut fidl::encoding::Encoder<'_, D>,
1381 offset: usize,
1382 mut depth: fidl::encoding::Depth,
1383 ) -> fidl::Result<()> {
1384 encoder.debug_check_bounds::<Icmpv6Packet>(offset);
1385 let max_ordinal: u64 = self.max_ordinal_present();
1387 encoder.write_num(max_ordinal, offset);
1388 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1389 if max_ordinal == 0 {
1391 return Ok(());
1392 }
1393 depth.increment()?;
1394 let envelope_size = 8;
1395 let bytes_len = max_ordinal as usize * envelope_size;
1396 #[allow(unused_variables)]
1397 let offset = encoder.out_of_line_offset(bytes_len);
1398 let mut _prev_end_offset: usize = 0;
1399
1400 Ok(())
1401 }
1402 }
1403
1404 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Icmpv6Packet {
1405 #[inline(always)]
1406 fn new_empty() -> Self {
1407 Self::default()
1408 }
1409
1410 unsafe fn decode(
1411 &mut self,
1412 decoder: &mut fidl::encoding::Decoder<'_, D>,
1413 offset: usize,
1414 mut depth: fidl::encoding::Depth,
1415 ) -> fidl::Result<()> {
1416 decoder.debug_check_bounds::<Self>(offset);
1417 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1418 None => return Err(fidl::Error::NotNullable),
1419 Some(len) => len,
1420 };
1421 if len == 0 {
1423 return Ok(());
1424 };
1425 depth.increment()?;
1426 let envelope_size = 8;
1427 let bytes_len = len * envelope_size;
1428 let offset = decoder.out_of_line_offset(bytes_len)?;
1429 let mut _next_ordinal_to_read = 0;
1431 let mut next_offset = offset;
1432 let end_offset = offset + bytes_len;
1433
1434 while next_offset < end_offset {
1436 _next_ordinal_to_read += 1;
1437 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1438 next_offset += envelope_size;
1439 }
1440
1441 Ok(())
1442 }
1443 }
1444
1445 impl TcpPacket {
1446 #[inline(always)]
1447 fn max_ordinal_present(&self) -> u64 {
1448 if let Some(_) = self.dst_port {
1449 return 2;
1450 }
1451 if let Some(_) = self.src_port {
1452 return 1;
1453 }
1454 0
1455 }
1456 }
1457
1458 impl fidl::encoding::ValueTypeMarker for TcpPacket {
1459 type Borrowed<'a> = &'a Self;
1460 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1461 value
1462 }
1463 }
1464
1465 unsafe impl fidl::encoding::TypeMarker for TcpPacket {
1466 type Owned = Self;
1467
1468 #[inline(always)]
1469 fn inline_align(_context: fidl::encoding::Context) -> usize {
1470 8
1471 }
1472
1473 #[inline(always)]
1474 fn inline_size(_context: fidl::encoding::Context) -> usize {
1475 16
1476 }
1477 }
1478
1479 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TcpPacket, D>
1480 for &TcpPacket
1481 {
1482 unsafe fn encode(
1483 self,
1484 encoder: &mut fidl::encoding::Encoder<'_, D>,
1485 offset: usize,
1486 mut depth: fidl::encoding::Depth,
1487 ) -> fidl::Result<()> {
1488 encoder.debug_check_bounds::<TcpPacket>(offset);
1489 let max_ordinal: u64 = self.max_ordinal_present();
1491 encoder.write_num(max_ordinal, offset);
1492 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1493 if max_ordinal == 0 {
1495 return Ok(());
1496 }
1497 depth.increment()?;
1498 let envelope_size = 8;
1499 let bytes_len = max_ordinal as usize * envelope_size;
1500 #[allow(unused_variables)]
1501 let offset = encoder.out_of_line_offset(bytes_len);
1502 let mut _prev_end_offset: usize = 0;
1503 if 1 > max_ordinal {
1504 return Ok(());
1505 }
1506
1507 let cur_offset: usize = (1 - 1) * envelope_size;
1510
1511 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1513
1514 fidl::encoding::encode_in_envelope_optional::<Port, D>(
1519 self.src_port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
1520 encoder,
1521 offset + cur_offset,
1522 depth,
1523 )?;
1524
1525 _prev_end_offset = cur_offset + envelope_size;
1526 if 2 > max_ordinal {
1527 return Ok(());
1528 }
1529
1530 let cur_offset: usize = (2 - 1) * envelope_size;
1533
1534 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1536
1537 fidl::encoding::encode_in_envelope_optional::<Port, D>(
1542 self.dst_port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
1543 encoder,
1544 offset + cur_offset,
1545 depth,
1546 )?;
1547
1548 _prev_end_offset = cur_offset + envelope_size;
1549
1550 Ok(())
1551 }
1552 }
1553
1554 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TcpPacket {
1555 #[inline(always)]
1556 fn new_empty() -> Self {
1557 Self::default()
1558 }
1559
1560 unsafe fn decode(
1561 &mut self,
1562 decoder: &mut fidl::encoding::Decoder<'_, D>,
1563 offset: usize,
1564 mut depth: fidl::encoding::Depth,
1565 ) -> fidl::Result<()> {
1566 decoder.debug_check_bounds::<Self>(offset);
1567 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1568 None => return Err(fidl::Error::NotNullable),
1569 Some(len) => len,
1570 };
1571 if len == 0 {
1573 return Ok(());
1574 };
1575 depth.increment()?;
1576 let envelope_size = 8;
1577 let bytes_len = len * envelope_size;
1578 let offset = decoder.out_of_line_offset(bytes_len)?;
1579 let mut _next_ordinal_to_read = 0;
1581 let mut next_offset = offset;
1582 let end_offset = offset + bytes_len;
1583 _next_ordinal_to_read += 1;
1584 if next_offset >= end_offset {
1585 return Ok(());
1586 }
1587
1588 while _next_ordinal_to_read < 1 {
1590 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1591 _next_ordinal_to_read += 1;
1592 next_offset += envelope_size;
1593 }
1594
1595 let next_out_of_line = decoder.next_out_of_line();
1596 let handles_before = decoder.remaining_handles();
1597 if let Some((inlined, num_bytes, num_handles)) =
1598 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1599 {
1600 let member_inline_size =
1601 <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1602 if inlined != (member_inline_size <= 4) {
1603 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1604 }
1605 let inner_offset;
1606 let mut inner_depth = depth.clone();
1607 if inlined {
1608 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1609 inner_offset = next_offset;
1610 } else {
1611 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1612 inner_depth.increment()?;
1613 }
1614 let val_ref = self.src_port.get_or_insert_with(|| fidl::new_empty!(Port, D));
1615 fidl::decode!(Port, D, val_ref, decoder, inner_offset, inner_depth)?;
1616 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1617 {
1618 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1619 }
1620 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1621 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1622 }
1623 }
1624
1625 next_offset += envelope_size;
1626 _next_ordinal_to_read += 1;
1627 if next_offset >= end_offset {
1628 return Ok(());
1629 }
1630
1631 while _next_ordinal_to_read < 2 {
1633 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1634 _next_ordinal_to_read += 1;
1635 next_offset += envelope_size;
1636 }
1637
1638 let next_out_of_line = decoder.next_out_of_line();
1639 let handles_before = decoder.remaining_handles();
1640 if let Some((inlined, num_bytes, num_handles)) =
1641 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1642 {
1643 let member_inline_size =
1644 <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1645 if inlined != (member_inline_size <= 4) {
1646 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1647 }
1648 let inner_offset;
1649 let mut inner_depth = depth.clone();
1650 if inlined {
1651 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1652 inner_offset = next_offset;
1653 } else {
1654 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1655 inner_depth.increment()?;
1656 }
1657 let val_ref = self.dst_port.get_or_insert_with(|| fidl::new_empty!(Port, D));
1658 fidl::decode!(Port, D, val_ref, decoder, inner_offset, inner_depth)?;
1659 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1660 {
1661 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1662 }
1663 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1664 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1665 }
1666 }
1667
1668 next_offset += envelope_size;
1669
1670 while next_offset < end_offset {
1672 _next_ordinal_to_read += 1;
1673 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1674 next_offset += envelope_size;
1675 }
1676
1677 Ok(())
1678 }
1679 }
1680
1681 impl UdpPacket {
1682 #[inline(always)]
1683 fn max_ordinal_present(&self) -> u64 {
1684 if let Some(_) = self.dst_port {
1685 return 2;
1686 }
1687 if let Some(_) = self.src_port {
1688 return 1;
1689 }
1690 0
1691 }
1692 }
1693
1694 impl fidl::encoding::ValueTypeMarker for UdpPacket {
1695 type Borrowed<'a> = &'a Self;
1696 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1697 value
1698 }
1699 }
1700
1701 unsafe impl fidl::encoding::TypeMarker for UdpPacket {
1702 type Owned = Self;
1703
1704 #[inline(always)]
1705 fn inline_align(_context: fidl::encoding::Context) -> usize {
1706 8
1707 }
1708
1709 #[inline(always)]
1710 fn inline_size(_context: fidl::encoding::Context) -> usize {
1711 16
1712 }
1713 }
1714
1715 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UdpPacket, D>
1716 for &UdpPacket
1717 {
1718 unsafe fn encode(
1719 self,
1720 encoder: &mut fidl::encoding::Encoder<'_, D>,
1721 offset: usize,
1722 mut depth: fidl::encoding::Depth,
1723 ) -> fidl::Result<()> {
1724 encoder.debug_check_bounds::<UdpPacket>(offset);
1725 let max_ordinal: u64 = self.max_ordinal_present();
1727 encoder.write_num(max_ordinal, offset);
1728 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1729 if max_ordinal == 0 {
1731 return Ok(());
1732 }
1733 depth.increment()?;
1734 let envelope_size = 8;
1735 let bytes_len = max_ordinal as usize * envelope_size;
1736 #[allow(unused_variables)]
1737 let offset = encoder.out_of_line_offset(bytes_len);
1738 let mut _prev_end_offset: usize = 0;
1739 if 1 > max_ordinal {
1740 return Ok(());
1741 }
1742
1743 let cur_offset: usize = (1 - 1) * envelope_size;
1746
1747 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1749
1750 fidl::encoding::encode_in_envelope_optional::<Port, D>(
1755 self.src_port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
1756 encoder,
1757 offset + cur_offset,
1758 depth,
1759 )?;
1760
1761 _prev_end_offset = cur_offset + envelope_size;
1762 if 2 > max_ordinal {
1763 return Ok(());
1764 }
1765
1766 let cur_offset: usize = (2 - 1) * envelope_size;
1769
1770 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1772
1773 fidl::encoding::encode_in_envelope_optional::<Port, D>(
1778 self.dst_port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
1779 encoder,
1780 offset + cur_offset,
1781 depth,
1782 )?;
1783
1784 _prev_end_offset = cur_offset + envelope_size;
1785
1786 Ok(())
1787 }
1788 }
1789
1790 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UdpPacket {
1791 #[inline(always)]
1792 fn new_empty() -> Self {
1793 Self::default()
1794 }
1795
1796 unsafe fn decode(
1797 &mut self,
1798 decoder: &mut fidl::encoding::Decoder<'_, D>,
1799 offset: usize,
1800 mut depth: fidl::encoding::Depth,
1801 ) -> fidl::Result<()> {
1802 decoder.debug_check_bounds::<Self>(offset);
1803 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1804 None => return Err(fidl::Error::NotNullable),
1805 Some(len) => len,
1806 };
1807 if len == 0 {
1809 return Ok(());
1810 };
1811 depth.increment()?;
1812 let envelope_size = 8;
1813 let bytes_len = len * envelope_size;
1814 let offset = decoder.out_of_line_offset(bytes_len)?;
1815 let mut _next_ordinal_to_read = 0;
1817 let mut next_offset = offset;
1818 let end_offset = offset + bytes_len;
1819 _next_ordinal_to_read += 1;
1820 if next_offset >= end_offset {
1821 return Ok(());
1822 }
1823
1824 while _next_ordinal_to_read < 1 {
1826 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1827 _next_ordinal_to_read += 1;
1828 next_offset += envelope_size;
1829 }
1830
1831 let next_out_of_line = decoder.next_out_of_line();
1832 let handles_before = decoder.remaining_handles();
1833 if let Some((inlined, num_bytes, num_handles)) =
1834 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1835 {
1836 let member_inline_size =
1837 <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1838 if inlined != (member_inline_size <= 4) {
1839 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1840 }
1841 let inner_offset;
1842 let mut inner_depth = depth.clone();
1843 if inlined {
1844 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1845 inner_offset = next_offset;
1846 } else {
1847 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1848 inner_depth.increment()?;
1849 }
1850 let val_ref = self.src_port.get_or_insert_with(|| fidl::new_empty!(Port, D));
1851 fidl::decode!(Port, D, val_ref, decoder, inner_offset, inner_depth)?;
1852 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1853 {
1854 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1855 }
1856 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1857 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1858 }
1859 }
1860
1861 next_offset += envelope_size;
1862 _next_ordinal_to_read += 1;
1863 if next_offset >= end_offset {
1864 return Ok(());
1865 }
1866
1867 while _next_ordinal_to_read < 2 {
1869 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1870 _next_ordinal_to_read += 1;
1871 next_offset += envelope_size;
1872 }
1873
1874 let next_out_of_line = decoder.next_out_of_line();
1875 let handles_before = decoder.remaining_handles();
1876 if let Some((inlined, num_bytes, num_handles)) =
1877 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1878 {
1879 let member_inline_size =
1880 <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1881 if inlined != (member_inline_size <= 4) {
1882 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1883 }
1884 let inner_offset;
1885 let mut inner_depth = depth.clone();
1886 if inlined {
1887 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1888 inner_offset = next_offset;
1889 } else {
1890 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1891 inner_depth.increment()?;
1892 }
1893 let val_ref = self.dst_port.get_or_insert_with(|| fidl::new_empty!(Port, D));
1894 fidl::decode!(Port, D, val_ref, decoder, inner_offset, inner_depth)?;
1895 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1896 {
1897 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1898 }
1899 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1900 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1901 }
1902 }
1903
1904 next_offset += envelope_size;
1905
1906 while next_offset < end_offset {
1908 _next_ordinal_to_read += 1;
1909 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1910 next_offset += envelope_size;
1911 }
1912
1913 Ok(())
1914 }
1915 }
1916
1917 impl fidl::encoding::ValueTypeMarker for AddressMatcherType {
1918 type Borrowed<'a> = &'a Self;
1919 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1920 value
1921 }
1922 }
1923
1924 unsafe impl fidl::encoding::TypeMarker for AddressMatcherType {
1925 type Owned = Self;
1926
1927 #[inline(always)]
1928 fn inline_align(_context: fidl::encoding::Context) -> usize {
1929 8
1930 }
1931
1932 #[inline(always)]
1933 fn inline_size(_context: fidl::encoding::Context) -> usize {
1934 16
1935 }
1936 }
1937
1938 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<AddressMatcherType, D>
1939 for &AddressMatcherType
1940 {
1941 #[inline]
1942 unsafe fn encode(
1943 self,
1944 encoder: &mut fidl::encoding::Encoder<'_, D>,
1945 offset: usize,
1946 _depth: fidl::encoding::Depth,
1947 ) -> fidl::Result<()> {
1948 encoder.debug_check_bounds::<AddressMatcherType>(offset);
1949 encoder.write_num::<u64>(self.ordinal(), offset);
1950 match self {
1951 AddressMatcherType::Subnet(ref val) => fidl::encoding::encode_in_envelope::<
1952 fidl_fuchsia_net__common::Subnet,
1953 D,
1954 >(
1955 <fidl_fuchsia_net__common::Subnet as fidl::encoding::ValueTypeMarker>::borrow(
1956 val,
1957 ),
1958 encoder,
1959 offset + 8,
1960 _depth,
1961 ),
1962 AddressMatcherType::Range(ref val) => {
1963 fidl::encoding::encode_in_envelope::<AddressRange, D>(
1964 <AddressRange as fidl::encoding::ValueTypeMarker>::borrow(val),
1965 encoder,
1966 offset + 8,
1967 _depth,
1968 )
1969 }
1970 AddressMatcherType::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1971 }
1972 }
1973 }
1974
1975 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AddressMatcherType {
1976 #[inline(always)]
1977 fn new_empty() -> Self {
1978 Self::__SourceBreaking { unknown_ordinal: 0 }
1979 }
1980
1981 #[inline]
1982 unsafe fn decode(
1983 &mut self,
1984 decoder: &mut fidl::encoding::Decoder<'_, D>,
1985 offset: usize,
1986 mut depth: fidl::encoding::Depth,
1987 ) -> fidl::Result<()> {
1988 decoder.debug_check_bounds::<Self>(offset);
1989 #[allow(unused_variables)]
1990 let next_out_of_line = decoder.next_out_of_line();
1991 let handles_before = decoder.remaining_handles();
1992 let (ordinal, inlined, num_bytes, num_handles) =
1993 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1994
1995 let member_inline_size = match ordinal {
1996 1 => <fidl_fuchsia_net__common::Subnet as fidl::encoding::TypeMarker>::inline_size(
1997 decoder.context,
1998 ),
1999 2 => <AddressRange as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2000 0 => return Err(fidl::Error::UnknownUnionTag),
2001 _ => num_bytes as usize,
2002 };
2003
2004 if inlined != (member_inline_size <= 4) {
2005 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2006 }
2007 let _inner_offset;
2008 if inlined {
2009 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2010 _inner_offset = offset + 8;
2011 } else {
2012 depth.increment()?;
2013 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2014 }
2015 match ordinal {
2016 1 => {
2017 #[allow(irrefutable_let_patterns)]
2018 if let AddressMatcherType::Subnet(_) = self {
2019 } else {
2021 *self = AddressMatcherType::Subnet(fidl::new_empty!(
2023 fidl_fuchsia_net__common::Subnet,
2024 D
2025 ));
2026 }
2027 #[allow(irrefutable_let_patterns)]
2028 if let AddressMatcherType::Subnet(ref mut val) = self {
2029 fidl::decode!(
2030 fidl_fuchsia_net__common::Subnet,
2031 D,
2032 val,
2033 decoder,
2034 _inner_offset,
2035 depth
2036 )?;
2037 } else {
2038 unreachable!()
2039 }
2040 }
2041 2 => {
2042 #[allow(irrefutable_let_patterns)]
2043 if let AddressMatcherType::Range(_) = self {
2044 } else {
2046 *self = AddressMatcherType::Range(fidl::new_empty!(AddressRange, D));
2048 }
2049 #[allow(irrefutable_let_patterns)]
2050 if let AddressMatcherType::Range(ref mut val) = self {
2051 fidl::decode!(AddressRange, D, val, decoder, _inner_offset, depth)?;
2052 } else {
2053 unreachable!()
2054 }
2055 }
2056 #[allow(deprecated)]
2057 ordinal => {
2058 for _ in 0..num_handles {
2059 decoder.drop_next_handle()?;
2060 }
2061 *self = AddressMatcherType::__SourceBreaking { unknown_ordinal: ordinal };
2062 }
2063 }
2064 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2065 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2066 }
2067 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2068 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2069 }
2070 Ok(())
2071 }
2072 }
2073
2074 impl fidl::encoding::ValueTypeMarker for Interface {
2075 type Borrowed<'a> = &'a Self;
2076 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2077 value
2078 }
2079 }
2080
2081 unsafe impl fidl::encoding::TypeMarker for Interface {
2082 type Owned = Self;
2083
2084 #[inline(always)]
2085 fn inline_align(_context: fidl::encoding::Context) -> usize {
2086 8
2087 }
2088
2089 #[inline(always)]
2090 fn inline_size(_context: fidl::encoding::Context) -> usize {
2091 16
2092 }
2093 }
2094
2095 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Interface, D>
2096 for &Interface
2097 {
2098 #[inline]
2099 unsafe fn encode(
2100 self,
2101 encoder: &mut fidl::encoding::Encoder<'_, D>,
2102 offset: usize,
2103 _depth: fidl::encoding::Depth,
2104 ) -> fidl::Result<()> {
2105 encoder.debug_check_bounds::<Interface>(offset);
2106 encoder.write_num::<u64>(self.ordinal(), offset);
2107 match self {
2108 Interface::Id(ref val) => {
2109 fidl::encoding::encode_in_envelope::<u64, D>(
2110 <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2111 encoder, offset + 8, _depth
2112 )
2113 }
2114 Interface::Name(ref val) => {
2115 fidl::encoding::encode_in_envelope::<fidl::encoding::BoundedString<15>, D>(
2116 <fidl::encoding::BoundedString<15> as fidl::encoding::ValueTypeMarker>::borrow(val),
2117 encoder, offset + 8, _depth
2118 )
2119 }
2120 Interface::PortClass(ref val) => {
2121 fidl::encoding::encode_in_envelope::<fidl_fuchsia_net_interfaces__common::PortClass, D>(
2122 <fidl_fuchsia_net_interfaces__common::PortClass as fidl::encoding::ValueTypeMarker>::borrow(val),
2123 encoder, offset + 8, _depth
2124 )
2125 }
2126 Interface::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2127 }
2128 }
2129 }
2130
2131 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Interface {
2132 #[inline(always)]
2133 fn new_empty() -> Self {
2134 Self::__SourceBreaking { unknown_ordinal: 0 }
2135 }
2136
2137 #[inline]
2138 unsafe fn decode(
2139 &mut self,
2140 decoder: &mut fidl::encoding::Decoder<'_, D>,
2141 offset: usize,
2142 mut depth: fidl::encoding::Depth,
2143 ) -> fidl::Result<()> {
2144 decoder.debug_check_bounds::<Self>(offset);
2145 #[allow(unused_variables)]
2146 let next_out_of_line = decoder.next_out_of_line();
2147 let handles_before = decoder.remaining_handles();
2148 let (ordinal, inlined, num_bytes, num_handles) =
2149 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2150
2151 let member_inline_size = match ordinal {
2152 1 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2153 2 => <fidl::encoding::BoundedString<15> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2154 3 => <fidl_fuchsia_net_interfaces__common::PortClass as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2155 0 => return Err(fidl::Error::UnknownUnionTag),
2156 _ => num_bytes as usize,
2157 };
2158
2159 if inlined != (member_inline_size <= 4) {
2160 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2161 }
2162 let _inner_offset;
2163 if inlined {
2164 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2165 _inner_offset = offset + 8;
2166 } else {
2167 depth.increment()?;
2168 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2169 }
2170 match ordinal {
2171 1 => {
2172 #[allow(irrefutable_let_patterns)]
2173 if let Interface::Id(_) = self {
2174 } else {
2176 *self = Interface::Id(fidl::new_empty!(u64, D));
2178 }
2179 #[allow(irrefutable_let_patterns)]
2180 if let Interface::Id(ref mut val) = self {
2181 fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
2182 } else {
2183 unreachable!()
2184 }
2185 }
2186 2 => {
2187 #[allow(irrefutable_let_patterns)]
2188 if let Interface::Name(_) = self {
2189 } else {
2191 *self =
2193 Interface::Name(fidl::new_empty!(fidl::encoding::BoundedString<15>, D));
2194 }
2195 #[allow(irrefutable_let_patterns)]
2196 if let Interface::Name(ref mut val) = self {
2197 fidl::decode!(
2198 fidl::encoding::BoundedString<15>,
2199 D,
2200 val,
2201 decoder,
2202 _inner_offset,
2203 depth
2204 )?;
2205 } else {
2206 unreachable!()
2207 }
2208 }
2209 3 => {
2210 #[allow(irrefutable_let_patterns)]
2211 if let Interface::PortClass(_) = self {
2212 } else {
2214 *self = Interface::PortClass(fidl::new_empty!(
2216 fidl_fuchsia_net_interfaces__common::PortClass,
2217 D
2218 ));
2219 }
2220 #[allow(irrefutable_let_patterns)]
2221 if let Interface::PortClass(ref mut val) = self {
2222 fidl::decode!(
2223 fidl_fuchsia_net_interfaces__common::PortClass,
2224 D,
2225 val,
2226 decoder,
2227 _inner_offset,
2228 depth
2229 )?;
2230 } else {
2231 unreachable!()
2232 }
2233 }
2234 #[allow(deprecated)]
2235 ordinal => {
2236 for _ in 0..num_handles {
2237 decoder.drop_next_handle()?;
2238 }
2239 *self = Interface::__SourceBreaking { unknown_ordinal: ordinal };
2240 }
2241 }
2242 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2243 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2244 }
2245 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2246 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2247 }
2248 Ok(())
2249 }
2250 }
2251
2252 impl fidl::encoding::ValueTypeMarker for PacketTransportProtocol {
2253 type Borrowed<'a> = &'a Self;
2254 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2255 value
2256 }
2257 }
2258
2259 unsafe impl fidl::encoding::TypeMarker for PacketTransportProtocol {
2260 type Owned = Self;
2261
2262 #[inline(always)]
2263 fn inline_align(_context: fidl::encoding::Context) -> usize {
2264 8
2265 }
2266
2267 #[inline(always)]
2268 fn inline_size(_context: fidl::encoding::Context) -> usize {
2269 16
2270 }
2271 }
2272
2273 unsafe impl<D: fidl::encoding::ResourceDialect>
2274 fidl::encoding::Encode<PacketTransportProtocol, D> for &PacketTransportProtocol
2275 {
2276 #[inline]
2277 unsafe fn encode(
2278 self,
2279 encoder: &mut fidl::encoding::Encoder<'_, D>,
2280 offset: usize,
2281 _depth: fidl::encoding::Depth,
2282 ) -> fidl::Result<()> {
2283 encoder.debug_check_bounds::<PacketTransportProtocol>(offset);
2284 encoder.write_num::<u64>(self.ordinal(), offset);
2285 match self {
2286 PacketTransportProtocol::Tcp(ref val) => {
2287 fidl::encoding::encode_in_envelope::<TcpPacket, D>(
2288 <TcpPacket as fidl::encoding::ValueTypeMarker>::borrow(val),
2289 encoder,
2290 offset + 8,
2291 _depth,
2292 )
2293 }
2294 PacketTransportProtocol::Udp(ref val) => {
2295 fidl::encoding::encode_in_envelope::<UdpPacket, D>(
2296 <UdpPacket as fidl::encoding::ValueTypeMarker>::borrow(val),
2297 encoder,
2298 offset + 8,
2299 _depth,
2300 )
2301 }
2302 PacketTransportProtocol::Icmp(ref val) => {
2303 fidl::encoding::encode_in_envelope::<IcmpPacket, D>(
2304 <IcmpPacket as fidl::encoding::ValueTypeMarker>::borrow(val),
2305 encoder,
2306 offset + 8,
2307 _depth,
2308 )
2309 }
2310 PacketTransportProtocol::Icmpv6(ref val) => {
2311 fidl::encoding::encode_in_envelope::<Icmpv6Packet, D>(
2312 <Icmpv6Packet as fidl::encoding::ValueTypeMarker>::borrow(val),
2313 encoder,
2314 offset + 8,
2315 _depth,
2316 )
2317 }
2318 PacketTransportProtocol::__SourceBreaking { .. } => {
2319 Err(fidl::Error::UnknownUnionTag)
2320 }
2321 }
2322 }
2323 }
2324
2325 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2326 for PacketTransportProtocol
2327 {
2328 #[inline(always)]
2329 fn new_empty() -> Self {
2330 Self::__SourceBreaking { unknown_ordinal: 0 }
2331 }
2332
2333 #[inline]
2334 unsafe fn decode(
2335 &mut self,
2336 decoder: &mut fidl::encoding::Decoder<'_, D>,
2337 offset: usize,
2338 mut depth: fidl::encoding::Depth,
2339 ) -> fidl::Result<()> {
2340 decoder.debug_check_bounds::<Self>(offset);
2341 #[allow(unused_variables)]
2342 let next_out_of_line = decoder.next_out_of_line();
2343 let handles_before = decoder.remaining_handles();
2344 let (ordinal, inlined, num_bytes, num_handles) =
2345 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2346
2347 let member_inline_size = match ordinal {
2348 1 => <TcpPacket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2349 2 => <UdpPacket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2350 3 => <IcmpPacket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2351 4 => <Icmpv6Packet as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2352 0 => return Err(fidl::Error::UnknownUnionTag),
2353 _ => num_bytes as usize,
2354 };
2355
2356 if inlined != (member_inline_size <= 4) {
2357 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2358 }
2359 let _inner_offset;
2360 if inlined {
2361 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2362 _inner_offset = offset + 8;
2363 } else {
2364 depth.increment()?;
2365 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2366 }
2367 match ordinal {
2368 1 => {
2369 #[allow(irrefutable_let_patterns)]
2370 if let PacketTransportProtocol::Tcp(_) = self {
2371 } else {
2373 *self = PacketTransportProtocol::Tcp(fidl::new_empty!(TcpPacket, D));
2375 }
2376 #[allow(irrefutable_let_patterns)]
2377 if let PacketTransportProtocol::Tcp(ref mut val) = self {
2378 fidl::decode!(TcpPacket, D, val, decoder, _inner_offset, depth)?;
2379 } else {
2380 unreachable!()
2381 }
2382 }
2383 2 => {
2384 #[allow(irrefutable_let_patterns)]
2385 if let PacketTransportProtocol::Udp(_) = self {
2386 } else {
2388 *self = PacketTransportProtocol::Udp(fidl::new_empty!(UdpPacket, D));
2390 }
2391 #[allow(irrefutable_let_patterns)]
2392 if let PacketTransportProtocol::Udp(ref mut val) = self {
2393 fidl::decode!(UdpPacket, D, val, decoder, _inner_offset, depth)?;
2394 } else {
2395 unreachable!()
2396 }
2397 }
2398 3 => {
2399 #[allow(irrefutable_let_patterns)]
2400 if let PacketTransportProtocol::Icmp(_) = self {
2401 } else {
2403 *self = PacketTransportProtocol::Icmp(fidl::new_empty!(IcmpPacket, D));
2405 }
2406 #[allow(irrefutable_let_patterns)]
2407 if let PacketTransportProtocol::Icmp(ref mut val) = self {
2408 fidl::decode!(IcmpPacket, D, val, decoder, _inner_offset, depth)?;
2409 } else {
2410 unreachable!()
2411 }
2412 }
2413 4 => {
2414 #[allow(irrefutable_let_patterns)]
2415 if let PacketTransportProtocol::Icmpv6(_) = self {
2416 } else {
2418 *self = PacketTransportProtocol::Icmpv6(fidl::new_empty!(Icmpv6Packet, D));
2420 }
2421 #[allow(irrefutable_let_patterns)]
2422 if let PacketTransportProtocol::Icmpv6(ref mut val) = self {
2423 fidl::decode!(Icmpv6Packet, D, val, decoder, _inner_offset, depth)?;
2424 } else {
2425 unreachable!()
2426 }
2427 }
2428 #[allow(deprecated)]
2429 ordinal => {
2430 for _ in 0..num_handles {
2431 decoder.drop_next_handle()?;
2432 }
2433 *self = PacketTransportProtocol::__SourceBreaking { unknown_ordinal: ordinal };
2434 }
2435 }
2436 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2437 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2438 }
2439 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2440 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2441 }
2442 Ok(())
2443 }
2444 }
2445
2446 impl fidl::encoding::ValueTypeMarker for SocketTransportProtocol {
2447 type Borrowed<'a> = &'a Self;
2448 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2449 value
2450 }
2451 }
2452
2453 unsafe impl fidl::encoding::TypeMarker for SocketTransportProtocol {
2454 type Owned = Self;
2455
2456 #[inline(always)]
2457 fn inline_align(_context: fidl::encoding::Context) -> usize {
2458 8
2459 }
2460
2461 #[inline(always)]
2462 fn inline_size(_context: fidl::encoding::Context) -> usize {
2463 16
2464 }
2465 }
2466
2467 unsafe impl<D: fidl::encoding::ResourceDialect>
2468 fidl::encoding::Encode<SocketTransportProtocol, D> for &SocketTransportProtocol
2469 {
2470 #[inline]
2471 unsafe fn encode(
2472 self,
2473 encoder: &mut fidl::encoding::Encoder<'_, D>,
2474 offset: usize,
2475 _depth: fidl::encoding::Depth,
2476 ) -> fidl::Result<()> {
2477 encoder.debug_check_bounds::<SocketTransportProtocol>(offset);
2478 encoder.write_num::<u64>(self.ordinal(), offset);
2479 match self {
2480 SocketTransportProtocol::Tcp(ref val) => {
2481 fidl::encoding::encode_in_envelope::<TcpSocket, D>(
2482 <TcpSocket as fidl::encoding::ValueTypeMarker>::borrow(val),
2483 encoder,
2484 offset + 8,
2485 _depth,
2486 )
2487 }
2488 SocketTransportProtocol::Udp(ref val) => {
2489 fidl::encoding::encode_in_envelope::<UdpSocket, D>(
2490 <UdpSocket as fidl::encoding::ValueTypeMarker>::borrow(val),
2491 encoder,
2492 offset + 8,
2493 _depth,
2494 )
2495 }
2496 SocketTransportProtocol::__SourceBreaking { .. } => {
2497 Err(fidl::Error::UnknownUnionTag)
2498 }
2499 }
2500 }
2501 }
2502
2503 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2504 for SocketTransportProtocol
2505 {
2506 #[inline(always)]
2507 fn new_empty() -> Self {
2508 Self::__SourceBreaking { unknown_ordinal: 0 }
2509 }
2510
2511 #[inline]
2512 unsafe fn decode(
2513 &mut self,
2514 decoder: &mut fidl::encoding::Decoder<'_, D>,
2515 offset: usize,
2516 mut depth: fidl::encoding::Depth,
2517 ) -> fidl::Result<()> {
2518 decoder.debug_check_bounds::<Self>(offset);
2519 #[allow(unused_variables)]
2520 let next_out_of_line = decoder.next_out_of_line();
2521 let handles_before = decoder.remaining_handles();
2522 let (ordinal, inlined, num_bytes, num_handles) =
2523 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2524
2525 let member_inline_size = match ordinal {
2526 1 => <TcpSocket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2527 2 => <UdpSocket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2528 0 => return Err(fidl::Error::UnknownUnionTag),
2529 _ => num_bytes as usize,
2530 };
2531
2532 if inlined != (member_inline_size <= 4) {
2533 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2534 }
2535 let _inner_offset;
2536 if inlined {
2537 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2538 _inner_offset = offset + 8;
2539 } else {
2540 depth.increment()?;
2541 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2542 }
2543 match ordinal {
2544 1 => {
2545 #[allow(irrefutable_let_patterns)]
2546 if let SocketTransportProtocol::Tcp(_) = self {
2547 } else {
2549 *self = SocketTransportProtocol::Tcp(fidl::new_empty!(TcpSocket, D));
2551 }
2552 #[allow(irrefutable_let_patterns)]
2553 if let SocketTransportProtocol::Tcp(ref mut val) = self {
2554 fidl::decode!(TcpSocket, D, val, decoder, _inner_offset, depth)?;
2555 } else {
2556 unreachable!()
2557 }
2558 }
2559 2 => {
2560 #[allow(irrefutable_let_patterns)]
2561 if let SocketTransportProtocol::Udp(_) = self {
2562 } else {
2564 *self = SocketTransportProtocol::Udp(fidl::new_empty!(UdpSocket, D));
2566 }
2567 #[allow(irrefutable_let_patterns)]
2568 if let SocketTransportProtocol::Udp(ref mut val) = self {
2569 fidl::decode!(UdpSocket, D, val, decoder, _inner_offset, depth)?;
2570 } else {
2571 unreachable!()
2572 }
2573 }
2574 #[allow(deprecated)]
2575 ordinal => {
2576 for _ in 0..num_handles {
2577 decoder.drop_next_handle()?;
2578 }
2579 *self = SocketTransportProtocol::__SourceBreaking { unknown_ordinal: ordinal };
2580 }
2581 }
2582 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2583 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2584 }
2585 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2586 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2587 }
2588 Ok(())
2589 }
2590 }
2591
2592 impl fidl::encoding::ValueTypeMarker for TcpSocket {
2593 type Borrowed<'a> = &'a Self;
2594 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2595 value
2596 }
2597 }
2598
2599 unsafe impl fidl::encoding::TypeMarker for TcpSocket {
2600 type Owned = Self;
2601
2602 #[inline(always)]
2603 fn inline_align(_context: fidl::encoding::Context) -> usize {
2604 8
2605 }
2606
2607 #[inline(always)]
2608 fn inline_size(_context: fidl::encoding::Context) -> usize {
2609 16
2610 }
2611 }
2612
2613 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TcpSocket, D>
2614 for &TcpSocket
2615 {
2616 #[inline]
2617 unsafe fn encode(
2618 self,
2619 encoder: &mut fidl::encoding::Encoder<'_, D>,
2620 offset: usize,
2621 _depth: fidl::encoding::Depth,
2622 ) -> fidl::Result<()> {
2623 encoder.debug_check_bounds::<TcpSocket>(offset);
2624 encoder.write_num::<u64>(self.ordinal(), offset);
2625 match self {
2626 TcpSocket::Empty(ref val) => fidl::encoding::encode_in_envelope::<Empty, D>(
2627 <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2628 encoder,
2629 offset + 8,
2630 _depth,
2631 ),
2632 TcpSocket::SrcPort(ref val) => fidl::encoding::encode_in_envelope::<Port, D>(
2633 <Port as fidl::encoding::ValueTypeMarker>::borrow(val),
2634 encoder,
2635 offset + 8,
2636 _depth,
2637 ),
2638 TcpSocket::DstPort(ref val) => fidl::encoding::encode_in_envelope::<Port, D>(
2639 <Port as fidl::encoding::ValueTypeMarker>::borrow(val),
2640 encoder,
2641 offset + 8,
2642 _depth,
2643 ),
2644 TcpSocket::States(ref val) => fidl::encoding::encode_in_envelope::<TcpState, D>(
2645 <TcpState as fidl::encoding::ValueTypeMarker>::borrow(val),
2646 encoder,
2647 offset + 8,
2648 _depth,
2649 ),
2650 TcpSocket::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2651 }
2652 }
2653 }
2654
2655 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TcpSocket {
2656 #[inline(always)]
2657 fn new_empty() -> Self {
2658 Self::__SourceBreaking { unknown_ordinal: 0 }
2659 }
2660
2661 #[inline]
2662 unsafe fn decode(
2663 &mut self,
2664 decoder: &mut fidl::encoding::Decoder<'_, D>,
2665 offset: usize,
2666 mut depth: fidl::encoding::Depth,
2667 ) -> fidl::Result<()> {
2668 decoder.debug_check_bounds::<Self>(offset);
2669 #[allow(unused_variables)]
2670 let next_out_of_line = decoder.next_out_of_line();
2671 let handles_before = decoder.remaining_handles();
2672 let (ordinal, inlined, num_bytes, num_handles) =
2673 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2674
2675 let member_inline_size = match ordinal {
2676 1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2677 2 => <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2678 3 => <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2679 4 => <TcpState as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2680 0 => return Err(fidl::Error::UnknownUnionTag),
2681 _ => num_bytes as usize,
2682 };
2683
2684 if inlined != (member_inline_size <= 4) {
2685 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2686 }
2687 let _inner_offset;
2688 if inlined {
2689 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2690 _inner_offset = offset + 8;
2691 } else {
2692 depth.increment()?;
2693 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2694 }
2695 match ordinal {
2696 1 => {
2697 #[allow(irrefutable_let_patterns)]
2698 if let TcpSocket::Empty(_) = self {
2699 } else {
2701 *self = TcpSocket::Empty(fidl::new_empty!(Empty, D));
2703 }
2704 #[allow(irrefutable_let_patterns)]
2705 if let TcpSocket::Empty(ref mut val) = self {
2706 fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2707 } else {
2708 unreachable!()
2709 }
2710 }
2711 2 => {
2712 #[allow(irrefutable_let_patterns)]
2713 if let TcpSocket::SrcPort(_) = self {
2714 } else {
2716 *self = TcpSocket::SrcPort(fidl::new_empty!(Port, D));
2718 }
2719 #[allow(irrefutable_let_patterns)]
2720 if let TcpSocket::SrcPort(ref mut val) = self {
2721 fidl::decode!(Port, D, val, decoder, _inner_offset, depth)?;
2722 } else {
2723 unreachable!()
2724 }
2725 }
2726 3 => {
2727 #[allow(irrefutable_let_patterns)]
2728 if let TcpSocket::DstPort(_) = self {
2729 } else {
2731 *self = TcpSocket::DstPort(fidl::new_empty!(Port, D));
2733 }
2734 #[allow(irrefutable_let_patterns)]
2735 if let TcpSocket::DstPort(ref mut val) = self {
2736 fidl::decode!(Port, D, val, decoder, _inner_offset, depth)?;
2737 } else {
2738 unreachable!()
2739 }
2740 }
2741 4 => {
2742 #[allow(irrefutable_let_patterns)]
2743 if let TcpSocket::States(_) = self {
2744 } else {
2746 *self = TcpSocket::States(fidl::new_empty!(TcpState, D));
2748 }
2749 #[allow(irrefutable_let_patterns)]
2750 if let TcpSocket::States(ref mut val) = self {
2751 fidl::decode!(TcpState, D, val, decoder, _inner_offset, depth)?;
2752 } else {
2753 unreachable!()
2754 }
2755 }
2756 #[allow(deprecated)]
2757 ordinal => {
2758 for _ in 0..num_handles {
2759 decoder.drop_next_handle()?;
2760 }
2761 *self = TcpSocket::__SourceBreaking { unknown_ordinal: ordinal };
2762 }
2763 }
2764 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2765 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2766 }
2767 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2768 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2769 }
2770 Ok(())
2771 }
2772 }
2773
2774 impl fidl::encoding::ValueTypeMarker for UdpSocket {
2775 type Borrowed<'a> = &'a Self;
2776 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2777 value
2778 }
2779 }
2780
2781 unsafe impl fidl::encoding::TypeMarker for UdpSocket {
2782 type Owned = Self;
2783
2784 #[inline(always)]
2785 fn inline_align(_context: fidl::encoding::Context) -> usize {
2786 8
2787 }
2788
2789 #[inline(always)]
2790 fn inline_size(_context: fidl::encoding::Context) -> usize {
2791 16
2792 }
2793 }
2794
2795 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UdpSocket, D>
2796 for &UdpSocket
2797 {
2798 #[inline]
2799 unsafe fn encode(
2800 self,
2801 encoder: &mut fidl::encoding::Encoder<'_, D>,
2802 offset: usize,
2803 _depth: fidl::encoding::Depth,
2804 ) -> fidl::Result<()> {
2805 encoder.debug_check_bounds::<UdpSocket>(offset);
2806 encoder.write_num::<u64>(self.ordinal(), offset);
2807 match self {
2808 UdpSocket::Empty(ref val) => fidl::encoding::encode_in_envelope::<Empty, D>(
2809 <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2810 encoder,
2811 offset + 8,
2812 _depth,
2813 ),
2814 UdpSocket::SrcPort(ref val) => fidl::encoding::encode_in_envelope::<Port, D>(
2815 <Port as fidl::encoding::ValueTypeMarker>::borrow(val),
2816 encoder,
2817 offset + 8,
2818 _depth,
2819 ),
2820 UdpSocket::DstPort(ref val) => fidl::encoding::encode_in_envelope::<Port, D>(
2821 <Port as fidl::encoding::ValueTypeMarker>::borrow(val),
2822 encoder,
2823 offset + 8,
2824 _depth,
2825 ),
2826 UdpSocket::States(ref val) => fidl::encoding::encode_in_envelope::<UdpState, D>(
2827 <UdpState as fidl::encoding::ValueTypeMarker>::borrow(val),
2828 encoder,
2829 offset + 8,
2830 _depth,
2831 ),
2832 UdpSocket::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2833 }
2834 }
2835 }
2836
2837 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UdpSocket {
2838 #[inline(always)]
2839 fn new_empty() -> Self {
2840 Self::__SourceBreaking { unknown_ordinal: 0 }
2841 }
2842
2843 #[inline]
2844 unsafe fn decode(
2845 &mut self,
2846 decoder: &mut fidl::encoding::Decoder<'_, D>,
2847 offset: usize,
2848 mut depth: fidl::encoding::Depth,
2849 ) -> fidl::Result<()> {
2850 decoder.debug_check_bounds::<Self>(offset);
2851 #[allow(unused_variables)]
2852 let next_out_of_line = decoder.next_out_of_line();
2853 let handles_before = decoder.remaining_handles();
2854 let (ordinal, inlined, num_bytes, num_handles) =
2855 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2856
2857 let member_inline_size = match ordinal {
2858 1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2859 2 => <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2860 3 => <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2861 4 => <UdpState as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2862 0 => return Err(fidl::Error::UnknownUnionTag),
2863 _ => num_bytes as usize,
2864 };
2865
2866 if inlined != (member_inline_size <= 4) {
2867 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2868 }
2869 let _inner_offset;
2870 if inlined {
2871 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2872 _inner_offset = offset + 8;
2873 } else {
2874 depth.increment()?;
2875 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2876 }
2877 match ordinal {
2878 1 => {
2879 #[allow(irrefutable_let_patterns)]
2880 if let UdpSocket::Empty(_) = self {
2881 } else {
2883 *self = UdpSocket::Empty(fidl::new_empty!(Empty, D));
2885 }
2886 #[allow(irrefutable_let_patterns)]
2887 if let UdpSocket::Empty(ref mut val) = self {
2888 fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2889 } else {
2890 unreachable!()
2891 }
2892 }
2893 2 => {
2894 #[allow(irrefutable_let_patterns)]
2895 if let UdpSocket::SrcPort(_) = self {
2896 } else {
2898 *self = UdpSocket::SrcPort(fidl::new_empty!(Port, D));
2900 }
2901 #[allow(irrefutable_let_patterns)]
2902 if let UdpSocket::SrcPort(ref mut val) = self {
2903 fidl::decode!(Port, D, val, decoder, _inner_offset, depth)?;
2904 } else {
2905 unreachable!()
2906 }
2907 }
2908 3 => {
2909 #[allow(irrefutable_let_patterns)]
2910 if let UdpSocket::DstPort(_) = self {
2911 } else {
2913 *self = UdpSocket::DstPort(fidl::new_empty!(Port, D));
2915 }
2916 #[allow(irrefutable_let_patterns)]
2917 if let UdpSocket::DstPort(ref mut val) = self {
2918 fidl::decode!(Port, D, val, decoder, _inner_offset, depth)?;
2919 } else {
2920 unreachable!()
2921 }
2922 }
2923 4 => {
2924 #[allow(irrefutable_let_patterns)]
2925 if let UdpSocket::States(_) = self {
2926 } else {
2928 *self = UdpSocket::States(fidl::new_empty!(UdpState, D));
2930 }
2931 #[allow(irrefutable_let_patterns)]
2932 if let UdpSocket::States(ref mut val) = self {
2933 fidl::decode!(UdpState, D, val, decoder, _inner_offset, depth)?;
2934 } else {
2935 unreachable!()
2936 }
2937 }
2938 #[allow(deprecated)]
2939 ordinal => {
2940 for _ in 0..num_handles {
2941 decoder.drop_next_handle()?;
2942 }
2943 *self = UdpSocket::__SourceBreaking { unknown_ordinal: ordinal };
2944 }
2945 }
2946 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2947 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2948 }
2949 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2950 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2951 }
2952 Ok(())
2953 }
2954 }
2955}