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