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 Hostname = String;
19
20pub type InterfaceId = u64;
22
23pub type Mark = u32;
25
26pub type RouteMetric = u32;
28
29pub const MAX_HOSTNAME_SIZE: u64 = 255;
32
33#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
35#[repr(u32)]
36pub enum IpVersion {
37 V4 = 1,
38 V6 = 2,
39}
40
41impl IpVersion {
42 #[inline]
43 pub fn from_primitive(prim: u32) -> Option<Self> {
44 match prim {
45 1 => Some(Self::V4),
46 2 => Some(Self::V6),
47 _ => None,
48 }
49 }
50
51 #[inline]
52 pub const fn into_primitive(self) -> u32 {
53 self as u32
54 }
55
56 #[deprecated = "Strict enums should not use `is_unknown`"]
57 #[inline]
58 pub fn is_unknown(&self) -> bool {
59 false
60 }
61}
62
63#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
66#[repr(u8)]
67pub enum MarkDomain {
68 Mark1 = 1,
69 Mark2 = 2,
70}
71
72impl MarkDomain {
73 #[inline]
74 pub fn from_primitive(prim: u8) -> Option<Self> {
75 match prim {
76 1 => Some(Self::Mark1),
77 2 => Some(Self::Mark2),
78 _ => None,
79 }
80 }
81
82 #[inline]
83 pub const fn into_primitive(self) -> u8 {
84 self as u8
85 }
86
87 #[deprecated = "Strict enums should not use `is_unknown`"]
88 #[inline]
89 pub fn is_unknown(&self) -> bool {
90 false
91 }
92}
93
94#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
97#[repr(C)]
98pub struct Ipv4Address {
99 pub addr: [u8; 4],
100}
101
102impl fidl::Persistable for Ipv4Address {}
103
104#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
106#[repr(C)]
107pub struct Ipv4AddressWithPrefix {
108 pub addr: Ipv4Address,
110 pub prefix_len: u8,
112}
113
114impl fidl::Persistable for Ipv4AddressWithPrefix {}
115
116#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
122#[repr(C)]
123pub struct Ipv4SocketAddress {
124 pub address: Ipv4Address,
126 pub port: u16,
128}
129
130impl fidl::Persistable for Ipv4SocketAddress {}
131
132#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
135#[repr(C)]
136pub struct Ipv6Address {
137 pub addr: [u8; 16],
138}
139
140impl fidl::Persistable for Ipv6Address {}
141
142#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
144#[repr(C)]
145pub struct Ipv6AddressWithPrefix {
146 pub addr: Ipv6Address,
148 pub prefix_len: u8,
150}
151
152impl fidl::Persistable for Ipv6AddressWithPrefix {}
153
154#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
160#[repr(C)]
161pub struct Ipv6SocketAddress {
162 pub address: Ipv6Address,
164 pub port: u16,
166 pub zone_index: u64,
178}
179
180impl fidl::Persistable for Ipv6SocketAddress {}
181
182#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
184#[repr(C)]
185pub struct MacAddress {
186 pub octets: [u8; 6],
187}
188
189impl fidl::Persistable for MacAddress {}
190
191#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
193pub struct Subnet {
194 pub addr: IpAddress,
196 pub prefix_len: u8,
201}
202
203impl fidl::Persistable for Subnet {}
204
205#[derive(Clone, Debug, Default, PartialEq)]
207pub struct Marks {
208 pub mark_1: Option<u32>,
210 pub mark_2: Option<u32>,
212 #[doc(hidden)]
213 pub __source_breaking: fidl::marker::SourceBreaking,
214}
215
216impl fidl::Persistable for Marks {}
217
218#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
220pub enum IpAddress {
221 Ipv4(Ipv4Address),
222 Ipv6(Ipv6Address),
223}
224
225impl IpAddress {
226 #[inline]
227 pub fn ordinal(&self) -> u64 {
228 match *self {
229 Self::Ipv4(_) => 1,
230 Self::Ipv6(_) => 2,
231 }
232 }
233
234 #[deprecated = "Strict unions should not use `is_unknown`"]
235 #[inline]
236 pub fn is_unknown(&self) -> bool {
237 false
238 }
239}
240
241impl fidl::Persistable for IpAddress {}
242
243#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
245pub enum SocketAddress {
246 Ipv4(Ipv4SocketAddress),
247 Ipv6(Ipv6SocketAddress),
248}
249
250impl SocketAddress {
251 #[inline]
252 pub fn ordinal(&self) -> u64 {
253 match *self {
254 Self::Ipv4(_) => 1,
255 Self::Ipv6(_) => 2,
256 }
257 }
258
259 #[deprecated = "Strict unions should not use `is_unknown`"]
260 #[inline]
261 pub fn is_unknown(&self) -> bool {
262 false
263 }
264}
265
266impl fidl::Persistable for SocketAddress {}
267
268mod internal {
269 use super::*;
270 unsafe impl fidl::encoding::TypeMarker for IpVersion {
271 type Owned = Self;
272
273 #[inline(always)]
274 fn inline_align(_context: fidl::encoding::Context) -> usize {
275 std::mem::align_of::<u32>()
276 }
277
278 #[inline(always)]
279 fn inline_size(_context: fidl::encoding::Context) -> usize {
280 std::mem::size_of::<u32>()
281 }
282
283 #[inline(always)]
284 fn encode_is_copy() -> bool {
285 true
286 }
287
288 #[inline(always)]
289 fn decode_is_copy() -> bool {
290 false
291 }
292 }
293
294 impl fidl::encoding::ValueTypeMarker for IpVersion {
295 type Borrowed<'a> = Self;
296 #[inline(always)]
297 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
298 *value
299 }
300 }
301
302 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for IpVersion {
303 #[inline]
304 unsafe fn encode(
305 self,
306 encoder: &mut fidl::encoding::Encoder<'_, D>,
307 offset: usize,
308 _depth: fidl::encoding::Depth,
309 ) -> fidl::Result<()> {
310 encoder.debug_check_bounds::<Self>(offset);
311 encoder.write_num(self.into_primitive(), offset);
312 Ok(())
313 }
314 }
315
316 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for IpVersion {
317 #[inline(always)]
318 fn new_empty() -> Self {
319 Self::V4
320 }
321
322 #[inline]
323 unsafe fn decode(
324 &mut self,
325 decoder: &mut fidl::encoding::Decoder<'_, D>,
326 offset: usize,
327 _depth: fidl::encoding::Depth,
328 ) -> fidl::Result<()> {
329 decoder.debug_check_bounds::<Self>(offset);
330 let prim = decoder.read_num::<u32>(offset);
331
332 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
333 Ok(())
334 }
335 }
336 unsafe impl fidl::encoding::TypeMarker for MarkDomain {
337 type Owned = Self;
338
339 #[inline(always)]
340 fn inline_align(_context: fidl::encoding::Context) -> usize {
341 std::mem::align_of::<u8>()
342 }
343
344 #[inline(always)]
345 fn inline_size(_context: fidl::encoding::Context) -> usize {
346 std::mem::size_of::<u8>()
347 }
348
349 #[inline(always)]
350 fn encode_is_copy() -> bool {
351 true
352 }
353
354 #[inline(always)]
355 fn decode_is_copy() -> bool {
356 false
357 }
358 }
359
360 impl fidl::encoding::ValueTypeMarker for MarkDomain {
361 type Borrowed<'a> = Self;
362 #[inline(always)]
363 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
364 *value
365 }
366 }
367
368 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for MarkDomain {
369 #[inline]
370 unsafe fn encode(
371 self,
372 encoder: &mut fidl::encoding::Encoder<'_, D>,
373 offset: usize,
374 _depth: fidl::encoding::Depth,
375 ) -> fidl::Result<()> {
376 encoder.debug_check_bounds::<Self>(offset);
377 encoder.write_num(self.into_primitive(), offset);
378 Ok(())
379 }
380 }
381
382 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MarkDomain {
383 #[inline(always)]
384 fn new_empty() -> Self {
385 Self::Mark1
386 }
387
388 #[inline]
389 unsafe fn decode(
390 &mut self,
391 decoder: &mut fidl::encoding::Decoder<'_, D>,
392 offset: usize,
393 _depth: fidl::encoding::Depth,
394 ) -> fidl::Result<()> {
395 decoder.debug_check_bounds::<Self>(offset);
396 let prim = decoder.read_num::<u8>(offset);
397
398 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
399 Ok(())
400 }
401 }
402
403 impl fidl::encoding::ValueTypeMarker for Ipv4Address {
404 type Borrowed<'a> = &'a Self;
405 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
406 value
407 }
408 }
409
410 unsafe impl fidl::encoding::TypeMarker for Ipv4Address {
411 type Owned = Self;
412
413 #[inline(always)]
414 fn inline_align(_context: fidl::encoding::Context) -> usize {
415 1
416 }
417
418 #[inline(always)]
419 fn inline_size(_context: fidl::encoding::Context) -> usize {
420 4
421 }
422 #[inline(always)]
423 fn encode_is_copy() -> bool {
424 true
425 }
426
427 #[inline(always)]
428 fn decode_is_copy() -> bool {
429 true
430 }
431 }
432
433 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv4Address, D>
434 for &Ipv4Address
435 {
436 #[inline]
437 unsafe fn encode(
438 self,
439 encoder: &mut fidl::encoding::Encoder<'_, D>,
440 offset: usize,
441 _depth: fidl::encoding::Depth,
442 ) -> fidl::Result<()> {
443 encoder.debug_check_bounds::<Ipv4Address>(offset);
444 unsafe {
445 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
447 (buf_ptr as *mut Ipv4Address).write_unaligned((self as *const Ipv4Address).read());
448 }
451 Ok(())
452 }
453 }
454 unsafe impl<
455 D: fidl::encoding::ResourceDialect,
456 T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 4>, D>,
457 > fidl::encoding::Encode<Ipv4Address, D> for (T0,)
458 {
459 #[inline]
460 unsafe fn encode(
461 self,
462 encoder: &mut fidl::encoding::Encoder<'_, D>,
463 offset: usize,
464 depth: fidl::encoding::Depth,
465 ) -> fidl::Result<()> {
466 encoder.debug_check_bounds::<Ipv4Address>(offset);
467 self.0.encode(encoder, offset + 0, depth)?;
471 Ok(())
472 }
473 }
474
475 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv4Address {
476 #[inline(always)]
477 fn new_empty() -> Self {
478 Self { addr: fidl::new_empty!(fidl::encoding::Array<u8, 4>, D) }
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 buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
490 unsafe {
493 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
494 }
495 Ok(())
496 }
497 }
498
499 impl fidl::encoding::ValueTypeMarker for Ipv4AddressWithPrefix {
500 type Borrowed<'a> = &'a Self;
501 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
502 value
503 }
504 }
505
506 unsafe impl fidl::encoding::TypeMarker for Ipv4AddressWithPrefix {
507 type Owned = Self;
508
509 #[inline(always)]
510 fn inline_align(_context: fidl::encoding::Context) -> usize {
511 1
512 }
513
514 #[inline(always)]
515 fn inline_size(_context: fidl::encoding::Context) -> usize {
516 5
517 }
518 #[inline(always)]
519 fn encode_is_copy() -> bool {
520 true
521 }
522
523 #[inline(always)]
524 fn decode_is_copy() -> bool {
525 true
526 }
527 }
528
529 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv4AddressWithPrefix, D>
530 for &Ipv4AddressWithPrefix
531 {
532 #[inline]
533 unsafe fn encode(
534 self,
535 encoder: &mut fidl::encoding::Encoder<'_, D>,
536 offset: usize,
537 _depth: fidl::encoding::Depth,
538 ) -> fidl::Result<()> {
539 encoder.debug_check_bounds::<Ipv4AddressWithPrefix>(offset);
540 unsafe {
541 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
543 (buf_ptr as *mut Ipv4AddressWithPrefix)
544 .write_unaligned((self as *const Ipv4AddressWithPrefix).read());
545 }
548 Ok(())
549 }
550 }
551 unsafe impl<
552 D: fidl::encoding::ResourceDialect,
553 T0: fidl::encoding::Encode<Ipv4Address, D>,
554 T1: fidl::encoding::Encode<u8, D>,
555 > fidl::encoding::Encode<Ipv4AddressWithPrefix, D> for (T0, T1)
556 {
557 #[inline]
558 unsafe fn encode(
559 self,
560 encoder: &mut fidl::encoding::Encoder<'_, D>,
561 offset: usize,
562 depth: fidl::encoding::Depth,
563 ) -> fidl::Result<()> {
564 encoder.debug_check_bounds::<Ipv4AddressWithPrefix>(offset);
565 self.0.encode(encoder, offset + 0, depth)?;
569 self.1.encode(encoder, offset + 4, depth)?;
570 Ok(())
571 }
572 }
573
574 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv4AddressWithPrefix {
575 #[inline(always)]
576 fn new_empty() -> Self {
577 Self { addr: fidl::new_empty!(Ipv4Address, D), prefix_len: fidl::new_empty!(u8, D) }
578 }
579
580 #[inline]
581 unsafe fn decode(
582 &mut self,
583 decoder: &mut fidl::encoding::Decoder<'_, D>,
584 offset: usize,
585 _depth: fidl::encoding::Depth,
586 ) -> fidl::Result<()> {
587 decoder.debug_check_bounds::<Self>(offset);
588 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
589 unsafe {
592 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 5);
593 }
594 Ok(())
595 }
596 }
597
598 impl fidl::encoding::ValueTypeMarker for Ipv4SocketAddress {
599 type Borrowed<'a> = &'a Self;
600 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
601 value
602 }
603 }
604
605 unsafe impl fidl::encoding::TypeMarker for Ipv4SocketAddress {
606 type Owned = Self;
607
608 #[inline(always)]
609 fn inline_align(_context: fidl::encoding::Context) -> usize {
610 2
611 }
612
613 #[inline(always)]
614 fn inline_size(_context: fidl::encoding::Context) -> usize {
615 6
616 }
617 #[inline(always)]
618 fn encode_is_copy() -> bool {
619 true
620 }
621
622 #[inline(always)]
623 fn decode_is_copy() -> bool {
624 true
625 }
626 }
627
628 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv4SocketAddress, D>
629 for &Ipv4SocketAddress
630 {
631 #[inline]
632 unsafe fn encode(
633 self,
634 encoder: &mut fidl::encoding::Encoder<'_, D>,
635 offset: usize,
636 _depth: fidl::encoding::Depth,
637 ) -> fidl::Result<()> {
638 encoder.debug_check_bounds::<Ipv4SocketAddress>(offset);
639 unsafe {
640 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
642 (buf_ptr as *mut Ipv4SocketAddress)
643 .write_unaligned((self as *const Ipv4SocketAddress).read());
644 }
647 Ok(())
648 }
649 }
650 unsafe impl<
651 D: fidl::encoding::ResourceDialect,
652 T0: fidl::encoding::Encode<Ipv4Address, D>,
653 T1: fidl::encoding::Encode<u16, D>,
654 > fidl::encoding::Encode<Ipv4SocketAddress, D> for (T0, T1)
655 {
656 #[inline]
657 unsafe fn encode(
658 self,
659 encoder: &mut fidl::encoding::Encoder<'_, D>,
660 offset: usize,
661 depth: fidl::encoding::Depth,
662 ) -> fidl::Result<()> {
663 encoder.debug_check_bounds::<Ipv4SocketAddress>(offset);
664 self.0.encode(encoder, offset + 0, depth)?;
668 self.1.encode(encoder, offset + 4, depth)?;
669 Ok(())
670 }
671 }
672
673 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv4SocketAddress {
674 #[inline(always)]
675 fn new_empty() -> Self {
676 Self { address: fidl::new_empty!(Ipv4Address, D), port: fidl::new_empty!(u16, D) }
677 }
678
679 #[inline]
680 unsafe fn decode(
681 &mut self,
682 decoder: &mut fidl::encoding::Decoder<'_, D>,
683 offset: usize,
684 _depth: fidl::encoding::Depth,
685 ) -> fidl::Result<()> {
686 decoder.debug_check_bounds::<Self>(offset);
687 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
688 unsafe {
691 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 6);
692 }
693 Ok(())
694 }
695 }
696
697 impl fidl::encoding::ValueTypeMarker for Ipv6Address {
698 type Borrowed<'a> = &'a Self;
699 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
700 value
701 }
702 }
703
704 unsafe impl fidl::encoding::TypeMarker for Ipv6Address {
705 type Owned = Self;
706
707 #[inline(always)]
708 fn inline_align(_context: fidl::encoding::Context) -> usize {
709 1
710 }
711
712 #[inline(always)]
713 fn inline_size(_context: fidl::encoding::Context) -> usize {
714 16
715 }
716 #[inline(always)]
717 fn encode_is_copy() -> bool {
718 true
719 }
720
721 #[inline(always)]
722 fn decode_is_copy() -> bool {
723 true
724 }
725 }
726
727 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv6Address, D>
728 for &Ipv6Address
729 {
730 #[inline]
731 unsafe fn encode(
732 self,
733 encoder: &mut fidl::encoding::Encoder<'_, D>,
734 offset: usize,
735 _depth: fidl::encoding::Depth,
736 ) -> fidl::Result<()> {
737 encoder.debug_check_bounds::<Ipv6Address>(offset);
738 unsafe {
739 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
741 (buf_ptr as *mut Ipv6Address).write_unaligned((self as *const Ipv6Address).read());
742 }
745 Ok(())
746 }
747 }
748 unsafe impl<
749 D: fidl::encoding::ResourceDialect,
750 T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>, D>,
751 > fidl::encoding::Encode<Ipv6Address, D> for (T0,)
752 {
753 #[inline]
754 unsafe fn encode(
755 self,
756 encoder: &mut fidl::encoding::Encoder<'_, D>,
757 offset: usize,
758 depth: fidl::encoding::Depth,
759 ) -> fidl::Result<()> {
760 encoder.debug_check_bounds::<Ipv6Address>(offset);
761 self.0.encode(encoder, offset + 0, depth)?;
765 Ok(())
766 }
767 }
768
769 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv6Address {
770 #[inline(always)]
771 fn new_empty() -> Self {
772 Self { addr: fidl::new_empty!(fidl::encoding::Array<u8, 16>, D) }
773 }
774
775 #[inline]
776 unsafe fn decode(
777 &mut self,
778 decoder: &mut fidl::encoding::Decoder<'_, D>,
779 offset: usize,
780 _depth: fidl::encoding::Depth,
781 ) -> fidl::Result<()> {
782 decoder.debug_check_bounds::<Self>(offset);
783 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
784 unsafe {
787 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
788 }
789 Ok(())
790 }
791 }
792
793 impl fidl::encoding::ValueTypeMarker for Ipv6AddressWithPrefix {
794 type Borrowed<'a> = &'a Self;
795 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
796 value
797 }
798 }
799
800 unsafe impl fidl::encoding::TypeMarker for Ipv6AddressWithPrefix {
801 type Owned = Self;
802
803 #[inline(always)]
804 fn inline_align(_context: fidl::encoding::Context) -> usize {
805 1
806 }
807
808 #[inline(always)]
809 fn inline_size(_context: fidl::encoding::Context) -> usize {
810 17
811 }
812 #[inline(always)]
813 fn encode_is_copy() -> bool {
814 true
815 }
816
817 #[inline(always)]
818 fn decode_is_copy() -> bool {
819 true
820 }
821 }
822
823 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv6AddressWithPrefix, D>
824 for &Ipv6AddressWithPrefix
825 {
826 #[inline]
827 unsafe fn encode(
828 self,
829 encoder: &mut fidl::encoding::Encoder<'_, D>,
830 offset: usize,
831 _depth: fidl::encoding::Depth,
832 ) -> fidl::Result<()> {
833 encoder.debug_check_bounds::<Ipv6AddressWithPrefix>(offset);
834 unsafe {
835 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
837 (buf_ptr as *mut Ipv6AddressWithPrefix)
838 .write_unaligned((self as *const Ipv6AddressWithPrefix).read());
839 }
842 Ok(())
843 }
844 }
845 unsafe impl<
846 D: fidl::encoding::ResourceDialect,
847 T0: fidl::encoding::Encode<Ipv6Address, D>,
848 T1: fidl::encoding::Encode<u8, D>,
849 > fidl::encoding::Encode<Ipv6AddressWithPrefix, D> for (T0, T1)
850 {
851 #[inline]
852 unsafe fn encode(
853 self,
854 encoder: &mut fidl::encoding::Encoder<'_, D>,
855 offset: usize,
856 depth: fidl::encoding::Depth,
857 ) -> fidl::Result<()> {
858 encoder.debug_check_bounds::<Ipv6AddressWithPrefix>(offset);
859 self.0.encode(encoder, offset + 0, depth)?;
863 self.1.encode(encoder, offset + 16, depth)?;
864 Ok(())
865 }
866 }
867
868 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv6AddressWithPrefix {
869 #[inline(always)]
870 fn new_empty() -> Self {
871 Self { addr: fidl::new_empty!(Ipv6Address, D), prefix_len: fidl::new_empty!(u8, D) }
872 }
873
874 #[inline]
875 unsafe fn decode(
876 &mut self,
877 decoder: &mut fidl::encoding::Decoder<'_, D>,
878 offset: usize,
879 _depth: fidl::encoding::Depth,
880 ) -> fidl::Result<()> {
881 decoder.debug_check_bounds::<Self>(offset);
882 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
883 unsafe {
886 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 17);
887 }
888 Ok(())
889 }
890 }
891
892 impl fidl::encoding::ValueTypeMarker for Ipv6SocketAddress {
893 type Borrowed<'a> = &'a Self;
894 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
895 value
896 }
897 }
898
899 unsafe impl fidl::encoding::TypeMarker for Ipv6SocketAddress {
900 type Owned = Self;
901
902 #[inline(always)]
903 fn inline_align(_context: fidl::encoding::Context) -> usize {
904 8
905 }
906
907 #[inline(always)]
908 fn inline_size(_context: fidl::encoding::Context) -> usize {
909 32
910 }
911 }
912
913 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv6SocketAddress, D>
914 for &Ipv6SocketAddress
915 {
916 #[inline]
917 unsafe fn encode(
918 self,
919 encoder: &mut fidl::encoding::Encoder<'_, D>,
920 offset: usize,
921 _depth: fidl::encoding::Depth,
922 ) -> fidl::Result<()> {
923 encoder.debug_check_bounds::<Ipv6SocketAddress>(offset);
924 unsafe {
925 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
927 (buf_ptr as *mut Ipv6SocketAddress)
928 .write_unaligned((self as *const Ipv6SocketAddress).read());
929 let padding_ptr = buf_ptr.offset(16) as *mut u64;
932 let padding_mask = 0xffffffffffff0000u64;
933 padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
934 }
935 Ok(())
936 }
937 }
938 unsafe impl<
939 D: fidl::encoding::ResourceDialect,
940 T0: fidl::encoding::Encode<Ipv6Address, D>,
941 T1: fidl::encoding::Encode<u16, D>,
942 T2: fidl::encoding::Encode<u64, D>,
943 > fidl::encoding::Encode<Ipv6SocketAddress, D> for (T0, T1, T2)
944 {
945 #[inline]
946 unsafe fn encode(
947 self,
948 encoder: &mut fidl::encoding::Encoder<'_, D>,
949 offset: usize,
950 depth: fidl::encoding::Depth,
951 ) -> fidl::Result<()> {
952 encoder.debug_check_bounds::<Ipv6SocketAddress>(offset);
953 unsafe {
956 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
957 (ptr as *mut u64).write_unaligned(0);
958 }
959 self.0.encode(encoder, offset + 0, depth)?;
961 self.1.encode(encoder, offset + 16, depth)?;
962 self.2.encode(encoder, offset + 24, depth)?;
963 Ok(())
964 }
965 }
966
967 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv6SocketAddress {
968 #[inline(always)]
969 fn new_empty() -> Self {
970 Self {
971 address: fidl::new_empty!(Ipv6Address, D),
972 port: fidl::new_empty!(u16, D),
973 zone_index: fidl::new_empty!(u64, D),
974 }
975 }
976
977 #[inline]
978 unsafe fn decode(
979 &mut self,
980 decoder: &mut fidl::encoding::Decoder<'_, D>,
981 offset: usize,
982 _depth: fidl::encoding::Depth,
983 ) -> fidl::Result<()> {
984 decoder.debug_check_bounds::<Self>(offset);
985 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
986 let ptr = unsafe { buf_ptr.offset(16) };
988 let padval = unsafe { (ptr as *const u64).read_unaligned() };
989 let mask = 0xffffffffffff0000u64;
990 let maskedval = padval & mask;
991 if maskedval != 0 {
992 return Err(fidl::Error::NonZeroPadding {
993 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
994 });
995 }
996 unsafe {
998 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 32);
999 }
1000 Ok(())
1001 }
1002 }
1003
1004 impl fidl::encoding::ValueTypeMarker for MacAddress {
1005 type Borrowed<'a> = &'a Self;
1006 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1007 value
1008 }
1009 }
1010
1011 unsafe impl fidl::encoding::TypeMarker for MacAddress {
1012 type Owned = Self;
1013
1014 #[inline(always)]
1015 fn inline_align(_context: fidl::encoding::Context) -> usize {
1016 1
1017 }
1018
1019 #[inline(always)]
1020 fn inline_size(_context: fidl::encoding::Context) -> usize {
1021 6
1022 }
1023 #[inline(always)]
1024 fn encode_is_copy() -> bool {
1025 true
1026 }
1027
1028 #[inline(always)]
1029 fn decode_is_copy() -> bool {
1030 true
1031 }
1032 }
1033
1034 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MacAddress, D>
1035 for &MacAddress
1036 {
1037 #[inline]
1038 unsafe fn encode(
1039 self,
1040 encoder: &mut fidl::encoding::Encoder<'_, D>,
1041 offset: usize,
1042 _depth: fidl::encoding::Depth,
1043 ) -> fidl::Result<()> {
1044 encoder.debug_check_bounds::<MacAddress>(offset);
1045 unsafe {
1046 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1048 (buf_ptr as *mut MacAddress).write_unaligned((self as *const MacAddress).read());
1049 }
1052 Ok(())
1053 }
1054 }
1055 unsafe impl<
1056 D: fidl::encoding::ResourceDialect,
1057 T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 6>, D>,
1058 > fidl::encoding::Encode<MacAddress, D> for (T0,)
1059 {
1060 #[inline]
1061 unsafe fn encode(
1062 self,
1063 encoder: &mut fidl::encoding::Encoder<'_, D>,
1064 offset: usize,
1065 depth: fidl::encoding::Depth,
1066 ) -> fidl::Result<()> {
1067 encoder.debug_check_bounds::<MacAddress>(offset);
1068 self.0.encode(encoder, offset + 0, depth)?;
1072 Ok(())
1073 }
1074 }
1075
1076 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MacAddress {
1077 #[inline(always)]
1078 fn new_empty() -> Self {
1079 Self { octets: fidl::new_empty!(fidl::encoding::Array<u8, 6>, D) }
1080 }
1081
1082 #[inline]
1083 unsafe fn decode(
1084 &mut self,
1085 decoder: &mut fidl::encoding::Decoder<'_, D>,
1086 offset: usize,
1087 _depth: fidl::encoding::Depth,
1088 ) -> fidl::Result<()> {
1089 decoder.debug_check_bounds::<Self>(offset);
1090 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1091 unsafe {
1094 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 6);
1095 }
1096 Ok(())
1097 }
1098 }
1099
1100 impl fidl::encoding::ValueTypeMarker for Subnet {
1101 type Borrowed<'a> = &'a Self;
1102 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1103 value
1104 }
1105 }
1106
1107 unsafe impl fidl::encoding::TypeMarker for Subnet {
1108 type Owned = Self;
1109
1110 #[inline(always)]
1111 fn inline_align(_context: fidl::encoding::Context) -> usize {
1112 8
1113 }
1114
1115 #[inline(always)]
1116 fn inline_size(_context: fidl::encoding::Context) -> usize {
1117 24
1118 }
1119 }
1120
1121 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Subnet, D> for &Subnet {
1122 #[inline]
1123 unsafe fn encode(
1124 self,
1125 encoder: &mut fidl::encoding::Encoder<'_, D>,
1126 offset: usize,
1127 _depth: fidl::encoding::Depth,
1128 ) -> fidl::Result<()> {
1129 encoder.debug_check_bounds::<Subnet>(offset);
1130 fidl::encoding::Encode::<Subnet, D>::encode(
1132 (
1133 <IpAddress as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
1134 <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.prefix_len),
1135 ),
1136 encoder,
1137 offset,
1138 _depth,
1139 )
1140 }
1141 }
1142 unsafe impl<
1143 D: fidl::encoding::ResourceDialect,
1144 T0: fidl::encoding::Encode<IpAddress, D>,
1145 T1: fidl::encoding::Encode<u8, D>,
1146 > fidl::encoding::Encode<Subnet, D> for (T0, T1)
1147 {
1148 #[inline]
1149 unsafe fn encode(
1150 self,
1151 encoder: &mut fidl::encoding::Encoder<'_, D>,
1152 offset: usize,
1153 depth: fidl::encoding::Depth,
1154 ) -> fidl::Result<()> {
1155 encoder.debug_check_bounds::<Subnet>(offset);
1156 unsafe {
1159 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1160 (ptr as *mut u64).write_unaligned(0);
1161 }
1162 self.0.encode(encoder, offset + 0, depth)?;
1164 self.1.encode(encoder, offset + 16, depth)?;
1165 Ok(())
1166 }
1167 }
1168
1169 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Subnet {
1170 #[inline(always)]
1171 fn new_empty() -> Self {
1172 Self { addr: fidl::new_empty!(IpAddress, D), prefix_len: fidl::new_empty!(u8, D) }
1173 }
1174
1175 #[inline]
1176 unsafe fn decode(
1177 &mut self,
1178 decoder: &mut fidl::encoding::Decoder<'_, D>,
1179 offset: usize,
1180 _depth: fidl::encoding::Depth,
1181 ) -> fidl::Result<()> {
1182 decoder.debug_check_bounds::<Self>(offset);
1183 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1185 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1186 let mask = 0xffffffffffffff00u64;
1187 let maskedval = padval & mask;
1188 if maskedval != 0 {
1189 return Err(fidl::Error::NonZeroPadding {
1190 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1191 });
1192 }
1193 fidl::decode!(IpAddress, D, &mut self.addr, decoder, offset + 0, _depth)?;
1194 fidl::decode!(u8, D, &mut self.prefix_len, decoder, offset + 16, _depth)?;
1195 Ok(())
1196 }
1197 }
1198
1199 impl Marks {
1200 #[inline(always)]
1201 fn max_ordinal_present(&self) -> u64 {
1202 if let Some(_) = self.mark_2 {
1203 return 2;
1204 }
1205 if let Some(_) = self.mark_1 {
1206 return 1;
1207 }
1208 0
1209 }
1210 }
1211
1212 impl fidl::encoding::ValueTypeMarker for Marks {
1213 type Borrowed<'a> = &'a Self;
1214 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1215 value
1216 }
1217 }
1218
1219 unsafe impl fidl::encoding::TypeMarker for Marks {
1220 type Owned = Self;
1221
1222 #[inline(always)]
1223 fn inline_align(_context: fidl::encoding::Context) -> usize {
1224 8
1225 }
1226
1227 #[inline(always)]
1228 fn inline_size(_context: fidl::encoding::Context) -> usize {
1229 16
1230 }
1231 }
1232
1233 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Marks, D> for &Marks {
1234 unsafe fn encode(
1235 self,
1236 encoder: &mut fidl::encoding::Encoder<'_, D>,
1237 offset: usize,
1238 mut depth: fidl::encoding::Depth,
1239 ) -> fidl::Result<()> {
1240 encoder.debug_check_bounds::<Marks>(offset);
1241 let max_ordinal: u64 = self.max_ordinal_present();
1243 encoder.write_num(max_ordinal, offset);
1244 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1245 if max_ordinal == 0 {
1247 return Ok(());
1248 }
1249 depth.increment()?;
1250 let envelope_size = 8;
1251 let bytes_len = max_ordinal as usize * envelope_size;
1252 #[allow(unused_variables)]
1253 let offset = encoder.out_of_line_offset(bytes_len);
1254 let mut _prev_end_offset: usize = 0;
1255 if 1 > max_ordinal {
1256 return Ok(());
1257 }
1258
1259 let cur_offset: usize = (1 - 1) * envelope_size;
1262
1263 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1265
1266 fidl::encoding::encode_in_envelope_optional::<u32, D>(
1271 self.mark_1.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1272 encoder,
1273 offset + cur_offset,
1274 depth,
1275 )?;
1276
1277 _prev_end_offset = cur_offset + envelope_size;
1278 if 2 > max_ordinal {
1279 return Ok(());
1280 }
1281
1282 let cur_offset: usize = (2 - 1) * envelope_size;
1285
1286 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1288
1289 fidl::encoding::encode_in_envelope_optional::<u32, D>(
1294 self.mark_2.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1295 encoder,
1296 offset + cur_offset,
1297 depth,
1298 )?;
1299
1300 _prev_end_offset = cur_offset + envelope_size;
1301
1302 Ok(())
1303 }
1304 }
1305
1306 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Marks {
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 _next_ordinal_to_read += 1;
1336 if next_offset >= end_offset {
1337 return Ok(());
1338 }
1339
1340 while _next_ordinal_to_read < 1 {
1342 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1343 _next_ordinal_to_read += 1;
1344 next_offset += envelope_size;
1345 }
1346
1347 let next_out_of_line = decoder.next_out_of_line();
1348 let handles_before = decoder.remaining_handles();
1349 if let Some((inlined, num_bytes, num_handles)) =
1350 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1351 {
1352 let member_inline_size =
1353 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1354 if inlined != (member_inline_size <= 4) {
1355 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1356 }
1357 let inner_offset;
1358 let mut inner_depth = depth.clone();
1359 if inlined {
1360 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1361 inner_offset = next_offset;
1362 } else {
1363 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1364 inner_depth.increment()?;
1365 }
1366 let val_ref = self.mark_1.get_or_insert_with(|| fidl::new_empty!(u32, D));
1367 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1368 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1369 {
1370 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1371 }
1372 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1373 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1374 }
1375 }
1376
1377 next_offset += envelope_size;
1378 _next_ordinal_to_read += 1;
1379 if next_offset >= end_offset {
1380 return Ok(());
1381 }
1382
1383 while _next_ordinal_to_read < 2 {
1385 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1386 _next_ordinal_to_read += 1;
1387 next_offset += envelope_size;
1388 }
1389
1390 let next_out_of_line = decoder.next_out_of_line();
1391 let handles_before = decoder.remaining_handles();
1392 if let Some((inlined, num_bytes, num_handles)) =
1393 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1394 {
1395 let member_inline_size =
1396 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1397 if inlined != (member_inline_size <= 4) {
1398 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1399 }
1400 let inner_offset;
1401 let mut inner_depth = depth.clone();
1402 if inlined {
1403 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1404 inner_offset = next_offset;
1405 } else {
1406 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1407 inner_depth.increment()?;
1408 }
1409 let val_ref = self.mark_2.get_or_insert_with(|| fidl::new_empty!(u32, D));
1410 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1411 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1412 {
1413 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1414 }
1415 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1416 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1417 }
1418 }
1419
1420 next_offset += envelope_size;
1421
1422 while next_offset < end_offset {
1424 _next_ordinal_to_read += 1;
1425 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1426 next_offset += envelope_size;
1427 }
1428
1429 Ok(())
1430 }
1431 }
1432
1433 impl fidl::encoding::ValueTypeMarker for IpAddress {
1434 type Borrowed<'a> = &'a Self;
1435 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1436 value
1437 }
1438 }
1439
1440 unsafe impl fidl::encoding::TypeMarker for IpAddress {
1441 type Owned = Self;
1442
1443 #[inline(always)]
1444 fn inline_align(_context: fidl::encoding::Context) -> usize {
1445 8
1446 }
1447
1448 #[inline(always)]
1449 fn inline_size(_context: fidl::encoding::Context) -> usize {
1450 16
1451 }
1452 }
1453
1454 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<IpAddress, D>
1455 for &IpAddress
1456 {
1457 #[inline]
1458 unsafe fn encode(
1459 self,
1460 encoder: &mut fidl::encoding::Encoder<'_, D>,
1461 offset: usize,
1462 _depth: fidl::encoding::Depth,
1463 ) -> fidl::Result<()> {
1464 encoder.debug_check_bounds::<IpAddress>(offset);
1465 encoder.write_num::<u64>(self.ordinal(), offset);
1466 match self {
1467 IpAddress::Ipv4(ref val) => fidl::encoding::encode_in_envelope::<Ipv4Address, D>(
1468 <Ipv4Address as fidl::encoding::ValueTypeMarker>::borrow(val),
1469 encoder,
1470 offset + 8,
1471 _depth,
1472 ),
1473 IpAddress::Ipv6(ref val) => fidl::encoding::encode_in_envelope::<Ipv6Address, D>(
1474 <Ipv6Address as fidl::encoding::ValueTypeMarker>::borrow(val),
1475 encoder,
1476 offset + 8,
1477 _depth,
1478 ),
1479 }
1480 }
1481 }
1482
1483 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for IpAddress {
1484 #[inline(always)]
1485 fn new_empty() -> Self {
1486 Self::Ipv4(fidl::new_empty!(Ipv4Address, D))
1487 }
1488
1489 #[inline]
1490 unsafe fn decode(
1491 &mut self,
1492 decoder: &mut fidl::encoding::Decoder<'_, D>,
1493 offset: usize,
1494 mut depth: fidl::encoding::Depth,
1495 ) -> fidl::Result<()> {
1496 decoder.debug_check_bounds::<Self>(offset);
1497 #[allow(unused_variables)]
1498 let next_out_of_line = decoder.next_out_of_line();
1499 let handles_before = decoder.remaining_handles();
1500 let (ordinal, inlined, num_bytes, num_handles) =
1501 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1502
1503 let member_inline_size = match ordinal {
1504 1 => <Ipv4Address as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1505 2 => <Ipv6Address as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1506 _ => return Err(fidl::Error::UnknownUnionTag),
1507 };
1508
1509 if inlined != (member_inline_size <= 4) {
1510 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1511 }
1512 let _inner_offset;
1513 if inlined {
1514 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1515 _inner_offset = offset + 8;
1516 } else {
1517 depth.increment()?;
1518 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1519 }
1520 match ordinal {
1521 1 => {
1522 #[allow(irrefutable_let_patterns)]
1523 if let IpAddress::Ipv4(_) = self {
1524 } else {
1526 *self = IpAddress::Ipv4(fidl::new_empty!(Ipv4Address, D));
1528 }
1529 #[allow(irrefutable_let_patterns)]
1530 if let IpAddress::Ipv4(ref mut val) = self {
1531 fidl::decode!(Ipv4Address, D, val, decoder, _inner_offset, depth)?;
1532 } else {
1533 unreachable!()
1534 }
1535 }
1536 2 => {
1537 #[allow(irrefutable_let_patterns)]
1538 if let IpAddress::Ipv6(_) = self {
1539 } else {
1541 *self = IpAddress::Ipv6(fidl::new_empty!(Ipv6Address, D));
1543 }
1544 #[allow(irrefutable_let_patterns)]
1545 if let IpAddress::Ipv6(ref mut val) = self {
1546 fidl::decode!(Ipv6Address, D, val, decoder, _inner_offset, depth)?;
1547 } else {
1548 unreachable!()
1549 }
1550 }
1551 ordinal => panic!("unexpected ordinal {:?}", ordinal),
1552 }
1553 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1554 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1555 }
1556 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1557 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1558 }
1559 Ok(())
1560 }
1561 }
1562
1563 impl fidl::encoding::ValueTypeMarker for SocketAddress {
1564 type Borrowed<'a> = &'a Self;
1565 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1566 value
1567 }
1568 }
1569
1570 unsafe impl fidl::encoding::TypeMarker for SocketAddress {
1571 type Owned = Self;
1572
1573 #[inline(always)]
1574 fn inline_align(_context: fidl::encoding::Context) -> usize {
1575 8
1576 }
1577
1578 #[inline(always)]
1579 fn inline_size(_context: fidl::encoding::Context) -> usize {
1580 16
1581 }
1582 }
1583
1584 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SocketAddress, D>
1585 for &SocketAddress
1586 {
1587 #[inline]
1588 unsafe fn encode(
1589 self,
1590 encoder: &mut fidl::encoding::Encoder<'_, D>,
1591 offset: usize,
1592 _depth: fidl::encoding::Depth,
1593 ) -> fidl::Result<()> {
1594 encoder.debug_check_bounds::<SocketAddress>(offset);
1595 encoder.write_num::<u64>(self.ordinal(), offset);
1596 match self {
1597 SocketAddress::Ipv4(ref val) => {
1598 fidl::encoding::encode_in_envelope::<Ipv4SocketAddress, D>(
1599 <Ipv4SocketAddress as fidl::encoding::ValueTypeMarker>::borrow(val),
1600 encoder,
1601 offset + 8,
1602 _depth,
1603 )
1604 }
1605 SocketAddress::Ipv6(ref val) => {
1606 fidl::encoding::encode_in_envelope::<Ipv6SocketAddress, D>(
1607 <Ipv6SocketAddress as fidl::encoding::ValueTypeMarker>::borrow(val),
1608 encoder,
1609 offset + 8,
1610 _depth,
1611 )
1612 }
1613 }
1614 }
1615 }
1616
1617 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketAddress {
1618 #[inline(always)]
1619 fn new_empty() -> Self {
1620 Self::Ipv4(fidl::new_empty!(Ipv4SocketAddress, D))
1621 }
1622
1623 #[inline]
1624 unsafe fn decode(
1625 &mut self,
1626 decoder: &mut fidl::encoding::Decoder<'_, D>,
1627 offset: usize,
1628 mut depth: fidl::encoding::Depth,
1629 ) -> fidl::Result<()> {
1630 decoder.debug_check_bounds::<Self>(offset);
1631 #[allow(unused_variables)]
1632 let next_out_of_line = decoder.next_out_of_line();
1633 let handles_before = decoder.remaining_handles();
1634 let (ordinal, inlined, num_bytes, num_handles) =
1635 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1636
1637 let member_inline_size = match ordinal {
1638 1 => {
1639 <Ipv4SocketAddress as fidl::encoding::TypeMarker>::inline_size(decoder.context)
1640 }
1641 2 => {
1642 <Ipv6SocketAddress as fidl::encoding::TypeMarker>::inline_size(decoder.context)
1643 }
1644 _ => return Err(fidl::Error::UnknownUnionTag),
1645 };
1646
1647 if inlined != (member_inline_size <= 4) {
1648 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1649 }
1650 let _inner_offset;
1651 if inlined {
1652 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1653 _inner_offset = offset + 8;
1654 } else {
1655 depth.increment()?;
1656 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1657 }
1658 match ordinal {
1659 1 => {
1660 #[allow(irrefutable_let_patterns)]
1661 if let SocketAddress::Ipv4(_) = self {
1662 } else {
1664 *self = SocketAddress::Ipv4(fidl::new_empty!(Ipv4SocketAddress, D));
1666 }
1667 #[allow(irrefutable_let_patterns)]
1668 if let SocketAddress::Ipv4(ref mut val) = self {
1669 fidl::decode!(Ipv4SocketAddress, D, val, decoder, _inner_offset, depth)?;
1670 } else {
1671 unreachable!()
1672 }
1673 }
1674 2 => {
1675 #[allow(irrefutable_let_patterns)]
1676 if let SocketAddress::Ipv6(_) = self {
1677 } else {
1679 *self = SocketAddress::Ipv6(fidl::new_empty!(Ipv6SocketAddress, D));
1681 }
1682 #[allow(irrefutable_let_patterns)]
1683 if let SocketAddress::Ipv6(ref mut val) = self {
1684 fidl::decode!(Ipv6SocketAddress, D, val, decoder, _inner_offset, depth)?;
1685 } else {
1686 unreachable!()
1687 }
1688 }
1689 ordinal => panic!("unexpected ordinal {:?}", ordinal),
1690 }
1691 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1692 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1693 }
1694 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1695 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1696 }
1697 Ok(())
1698 }
1699 }
1700}