1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12pub enum Property {
13 SocketMarks,
14 DnsConfiguration,
15 #[doc(hidden)]
16 __SourceBreaking {
17 unknown_ordinal: u32,
18 },
19}
20
21#[macro_export]
23macro_rules! PropertyUnknown {
24 () => {
25 _
26 };
27}
28
29impl Property {
30 #[inline]
31 pub fn from_primitive(prim: u32) -> Option<Self> {
32 match prim {
33 1 => Some(Self::SocketMarks),
34 2 => Some(Self::DnsConfiguration),
35 _ => None,
36 }
37 }
38
39 #[inline]
40 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
41 match prim {
42 1 => Self::SocketMarks,
43 2 => Self::DnsConfiguration,
44 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
45 }
46 }
47
48 #[inline]
49 pub fn unknown() -> Self {
50 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
51 }
52
53 #[inline]
54 pub const fn into_primitive(self) -> u32 {
55 match self {
56 Self::SocketMarks => 1,
57 Self::DnsConfiguration => 2,
58 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
59 }
60 }
61
62 #[inline]
63 pub fn is_unknown(&self) -> bool {
64 match self {
65 Self::__SourceBreaking { unknown_ordinal: _ } => true,
66 _ => false,
67 }
68 }
69}
70
71#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
72pub enum WatchError {
73 NoProperties,
75 InvalidNetworkToken,
78 NetworkGone,
81 DefaultNetworkChanged,
84 DefaultNetworkLost,
87 MissingRequiredArgument,
89 #[doc(hidden)]
90 __SourceBreaking { unknown_ordinal: u32 },
91}
92
93#[macro_export]
95macro_rules! WatchErrorUnknown {
96 () => {
97 _
98 };
99}
100
101impl WatchError {
102 #[inline]
103 pub fn from_primitive(prim: u32) -> Option<Self> {
104 match prim {
105 1 => Some(Self::NoProperties),
106 2 => Some(Self::InvalidNetworkToken),
107 3 => Some(Self::NetworkGone),
108 4 => Some(Self::DefaultNetworkChanged),
109 5 => Some(Self::DefaultNetworkLost),
110 99 => Some(Self::MissingRequiredArgument),
111 _ => None,
112 }
113 }
114
115 #[inline]
116 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
117 match prim {
118 1 => Self::NoProperties,
119 2 => Self::InvalidNetworkToken,
120 3 => Self::NetworkGone,
121 4 => Self::DefaultNetworkChanged,
122 5 => Self::DefaultNetworkLost,
123 99 => Self::MissingRequiredArgument,
124 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
125 }
126 }
127
128 #[inline]
129 pub fn unknown() -> Self {
130 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
131 }
132
133 #[inline]
134 pub const fn into_primitive(self) -> u32 {
135 match self {
136 Self::NoProperties => 1,
137 Self::InvalidNetworkToken => 2,
138 Self::NetworkGone => 3,
139 Self::DefaultNetworkChanged => 4,
140 Self::DefaultNetworkLost => 5,
141 Self::MissingRequiredArgument => 99,
142 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
143 }
144 }
145
146 #[inline]
147 pub fn is_unknown(&self) -> bool {
148 match self {
149 Self::__SourceBreaking { unknown_ordinal: _ } => true,
150 _ => false,
151 }
152 }
153}
154
155#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
156pub struct Empty;
157
158impl fidl::Persistable for Empty {}
159
160#[derive(Clone, Debug, PartialEq)]
161pub struct NetworksWatchPropertiesResponse {
162 pub updates: Vec<PropertyUpdate>,
167}
168
169impl fidl::Persistable for NetworksWatchPropertiesResponse {}
170
171#[derive(Clone, Debug, Default, PartialEq)]
172pub struct DefaultNetworkUpdate {
173 pub interface_id: Option<u64>,
176 pub socket_marks: Option<fidl_fuchsia_net__common::Marks>,
179 #[doc(hidden)]
180 pub __source_breaking: fidl::marker::SourceBreaking,
181}
182
183impl fidl::Persistable for DefaultNetworkUpdate {}
184
185#[derive(Clone, Debug, Default, PartialEq)]
186pub struct DnsConfiguration {
187 pub servers: Option<Vec<fidl_fuchsia_net_name__common::DnsServer_>>,
188 #[doc(hidden)]
189 pub __source_breaking: fidl::marker::SourceBreaking,
190}
191
192impl fidl::Persistable for DnsConfiguration {}
193
194#[derive(Clone, Debug)]
195pub enum PropertyUpdate {
196 SocketMarks(fidl_fuchsia_net__common::Marks),
197 DnsConfiguration(DnsConfiguration),
198 #[doc(hidden)]
199 __SourceBreaking {
200 unknown_ordinal: u64,
201 },
202}
203
204#[macro_export]
206macro_rules! PropertyUpdateUnknown {
207 () => {
208 _
209 };
210}
211
212impl PartialEq for PropertyUpdate {
214 fn eq(&self, other: &Self) -> bool {
215 match (self, other) {
216 (Self::SocketMarks(x), Self::SocketMarks(y)) => *x == *y,
217 (Self::DnsConfiguration(x), Self::DnsConfiguration(y)) => *x == *y,
218 _ => false,
219 }
220 }
221}
222
223impl PropertyUpdate {
224 #[inline]
225 pub fn ordinal(&self) -> u64 {
226 match *self {
227 Self::SocketMarks(_) => 1,
228 Self::DnsConfiguration(_) => 2,
229 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
230 }
231 }
232
233 #[inline]
234 pub fn unknown_variant_for_testing() -> Self {
235 Self::__SourceBreaking { unknown_ordinal: 0 }
236 }
237
238 #[inline]
239 pub fn is_unknown(&self) -> bool {
240 match self {
241 Self::__SourceBreaking { .. } => true,
242 _ => false,
243 }
244 }
245}
246
247impl fidl::Persistable for PropertyUpdate {}
248
249pub mod default_network_watcher_ordinals {
250 pub const WATCH: u64 = 0x5fa419d19afc90b2;
251}
252
253pub mod networks_ordinals {
254 pub const WATCH_DEFAULT: u64 = 0x346880b2d7db0f98;
255 pub const WATCH_PROPERTIES: u64 = 0x24d2340905f7dcc6;
256}
257
258mod internal {
259 use super::*;
260 unsafe impl fidl::encoding::TypeMarker for Property {
261 type Owned = Self;
262
263 #[inline(always)]
264 fn inline_align(_context: fidl::encoding::Context) -> usize {
265 std::mem::align_of::<u32>()
266 }
267
268 #[inline(always)]
269 fn inline_size(_context: fidl::encoding::Context) -> usize {
270 std::mem::size_of::<u32>()
271 }
272
273 #[inline(always)]
274 fn encode_is_copy() -> bool {
275 false
276 }
277
278 #[inline(always)]
279 fn decode_is_copy() -> bool {
280 false
281 }
282 }
283
284 impl fidl::encoding::ValueTypeMarker for Property {
285 type Borrowed<'a> = Self;
286 #[inline(always)]
287 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
288 *value
289 }
290 }
291
292 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Property {
293 #[inline]
294 unsafe fn encode(
295 self,
296 encoder: &mut fidl::encoding::Encoder<'_, D>,
297 offset: usize,
298 _depth: fidl::encoding::Depth,
299 ) -> fidl::Result<()> {
300 encoder.debug_check_bounds::<Self>(offset);
301 encoder.write_num(self.into_primitive(), offset);
302 Ok(())
303 }
304 }
305
306 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Property {
307 #[inline(always)]
308 fn new_empty() -> Self {
309 Self::unknown()
310 }
311
312 #[inline]
313 unsafe fn decode(
314 &mut self,
315 decoder: &mut fidl::encoding::Decoder<'_, D>,
316 offset: usize,
317 _depth: fidl::encoding::Depth,
318 ) -> fidl::Result<()> {
319 decoder.debug_check_bounds::<Self>(offset);
320 let prim = decoder.read_num::<u32>(offset);
321
322 *self = Self::from_primitive_allow_unknown(prim);
323 Ok(())
324 }
325 }
326 unsafe impl fidl::encoding::TypeMarker for WatchError {
327 type Owned = Self;
328
329 #[inline(always)]
330 fn inline_align(_context: fidl::encoding::Context) -> usize {
331 std::mem::align_of::<u32>()
332 }
333
334 #[inline(always)]
335 fn inline_size(_context: fidl::encoding::Context) -> usize {
336 std::mem::size_of::<u32>()
337 }
338
339 #[inline(always)]
340 fn encode_is_copy() -> bool {
341 false
342 }
343
344 #[inline(always)]
345 fn decode_is_copy() -> bool {
346 false
347 }
348 }
349
350 impl fidl::encoding::ValueTypeMarker for WatchError {
351 type Borrowed<'a> = Self;
352 #[inline(always)]
353 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
354 *value
355 }
356 }
357
358 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for WatchError {
359 #[inline]
360 unsafe fn encode(
361 self,
362 encoder: &mut fidl::encoding::Encoder<'_, D>,
363 offset: usize,
364 _depth: fidl::encoding::Depth,
365 ) -> fidl::Result<()> {
366 encoder.debug_check_bounds::<Self>(offset);
367 encoder.write_num(self.into_primitive(), offset);
368 Ok(())
369 }
370 }
371
372 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WatchError {
373 #[inline(always)]
374 fn new_empty() -> Self {
375 Self::unknown()
376 }
377
378 #[inline]
379 unsafe fn decode(
380 &mut self,
381 decoder: &mut fidl::encoding::Decoder<'_, D>,
382 offset: usize,
383 _depth: fidl::encoding::Depth,
384 ) -> fidl::Result<()> {
385 decoder.debug_check_bounds::<Self>(offset);
386 let prim = decoder.read_num::<u32>(offset);
387
388 *self = Self::from_primitive_allow_unknown(prim);
389 Ok(())
390 }
391 }
392
393 impl fidl::encoding::ValueTypeMarker for Empty {
394 type Borrowed<'a> = &'a Self;
395 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
396 value
397 }
398 }
399
400 unsafe impl fidl::encoding::TypeMarker for Empty {
401 type Owned = Self;
402
403 #[inline(always)]
404 fn inline_align(_context: fidl::encoding::Context) -> usize {
405 1
406 }
407
408 #[inline(always)]
409 fn inline_size(_context: fidl::encoding::Context) -> usize {
410 1
411 }
412 }
413
414 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Empty, D> for &Empty {
415 #[inline]
416 unsafe fn encode(
417 self,
418 encoder: &mut fidl::encoding::Encoder<'_, D>,
419 offset: usize,
420 _depth: fidl::encoding::Depth,
421 ) -> fidl::Result<()> {
422 encoder.debug_check_bounds::<Empty>(offset);
423 encoder.write_num(0u8, offset);
424 Ok(())
425 }
426 }
427
428 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Empty {
429 #[inline(always)]
430 fn new_empty() -> Self {
431 Self
432 }
433
434 #[inline]
435 unsafe fn decode(
436 &mut self,
437 decoder: &mut fidl::encoding::Decoder<'_, D>,
438 offset: usize,
439 _depth: fidl::encoding::Depth,
440 ) -> fidl::Result<()> {
441 decoder.debug_check_bounds::<Self>(offset);
442 match decoder.read_num::<u8>(offset) {
443 0 => Ok(()),
444 _ => Err(fidl::Error::Invalid),
445 }
446 }
447 }
448
449 impl fidl::encoding::ValueTypeMarker for NetworksWatchPropertiesResponse {
450 type Borrowed<'a> = &'a Self;
451 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
452 value
453 }
454 }
455
456 unsafe impl fidl::encoding::TypeMarker for NetworksWatchPropertiesResponse {
457 type Owned = Self;
458
459 #[inline(always)]
460 fn inline_align(_context: fidl::encoding::Context) -> usize {
461 8
462 }
463
464 #[inline(always)]
465 fn inline_size(_context: fidl::encoding::Context) -> usize {
466 16
467 }
468 }
469
470 unsafe impl<D: fidl::encoding::ResourceDialect>
471 fidl::encoding::Encode<NetworksWatchPropertiesResponse, D>
472 for &NetworksWatchPropertiesResponse
473 {
474 #[inline]
475 unsafe fn encode(
476 self,
477 encoder: &mut fidl::encoding::Encoder<'_, D>,
478 offset: usize,
479 _depth: fidl::encoding::Depth,
480 ) -> fidl::Result<()> {
481 encoder.debug_check_bounds::<NetworksWatchPropertiesResponse>(offset);
482 fidl::encoding::Encode::<NetworksWatchPropertiesResponse, D>::encode(
484 (
485 <fidl::encoding::UnboundedVector<PropertyUpdate> as fidl::encoding::ValueTypeMarker>::borrow(&self.updates),
486 ),
487 encoder, offset, _depth
488 )
489 }
490 }
491 unsafe impl<
492 D: fidl::encoding::ResourceDialect,
493 T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<PropertyUpdate>, D>,
494 > fidl::encoding::Encode<NetworksWatchPropertiesResponse, D> for (T0,)
495 {
496 #[inline]
497 unsafe fn encode(
498 self,
499 encoder: &mut fidl::encoding::Encoder<'_, D>,
500 offset: usize,
501 depth: fidl::encoding::Depth,
502 ) -> fidl::Result<()> {
503 encoder.debug_check_bounds::<NetworksWatchPropertiesResponse>(offset);
504 self.0.encode(encoder, offset + 0, depth)?;
508 Ok(())
509 }
510 }
511
512 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
513 for NetworksWatchPropertiesResponse
514 {
515 #[inline(always)]
516 fn new_empty() -> Self {
517 Self { updates: fidl::new_empty!(fidl::encoding::UnboundedVector<PropertyUpdate>, D) }
518 }
519
520 #[inline]
521 unsafe fn decode(
522 &mut self,
523 decoder: &mut fidl::encoding::Decoder<'_, D>,
524 offset: usize,
525 _depth: fidl::encoding::Depth,
526 ) -> fidl::Result<()> {
527 decoder.debug_check_bounds::<Self>(offset);
528 fidl::decode!(
530 fidl::encoding::UnboundedVector<PropertyUpdate>,
531 D,
532 &mut self.updates,
533 decoder,
534 offset + 0,
535 _depth
536 )?;
537 Ok(())
538 }
539 }
540
541 impl DefaultNetworkUpdate {
542 #[inline(always)]
543 fn max_ordinal_present(&self) -> u64 {
544 if let Some(_) = self.socket_marks {
545 return 2;
546 }
547 if let Some(_) = self.interface_id {
548 return 1;
549 }
550 0
551 }
552 }
553
554 impl fidl::encoding::ValueTypeMarker for DefaultNetworkUpdate {
555 type Borrowed<'a> = &'a Self;
556 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
557 value
558 }
559 }
560
561 unsafe impl fidl::encoding::TypeMarker for DefaultNetworkUpdate {
562 type Owned = Self;
563
564 #[inline(always)]
565 fn inline_align(_context: fidl::encoding::Context) -> usize {
566 8
567 }
568
569 #[inline(always)]
570 fn inline_size(_context: fidl::encoding::Context) -> usize {
571 16
572 }
573 }
574
575 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DefaultNetworkUpdate, D>
576 for &DefaultNetworkUpdate
577 {
578 unsafe fn encode(
579 self,
580 encoder: &mut fidl::encoding::Encoder<'_, D>,
581 offset: usize,
582 mut depth: fidl::encoding::Depth,
583 ) -> fidl::Result<()> {
584 encoder.debug_check_bounds::<DefaultNetworkUpdate>(offset);
585 let max_ordinal: u64 = self.max_ordinal_present();
587 encoder.write_num(max_ordinal, offset);
588 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
589 if max_ordinal == 0 {
591 return Ok(());
592 }
593 depth.increment()?;
594 let envelope_size = 8;
595 let bytes_len = max_ordinal as usize * envelope_size;
596 #[allow(unused_variables)]
597 let offset = encoder.out_of_line_offset(bytes_len);
598 let mut _prev_end_offset: usize = 0;
599 if 1 > max_ordinal {
600 return Ok(());
601 }
602
603 let cur_offset: usize = (1 - 1) * envelope_size;
606
607 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
609
610 fidl::encoding::encode_in_envelope_optional::<u64, D>(
615 self.interface_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
616 encoder,
617 offset + cur_offset,
618 depth,
619 )?;
620
621 _prev_end_offset = cur_offset + envelope_size;
622 if 2 > max_ordinal {
623 return Ok(());
624 }
625
626 let cur_offset: usize = (2 - 1) * envelope_size;
629
630 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
632
633 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_net__common::Marks, D>(
638 self.socket_marks.as_ref().map(
639 <fidl_fuchsia_net__common::Marks as fidl::encoding::ValueTypeMarker>::borrow,
640 ),
641 encoder,
642 offset + cur_offset,
643 depth,
644 )?;
645
646 _prev_end_offset = cur_offset + envelope_size;
647
648 Ok(())
649 }
650 }
651
652 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DefaultNetworkUpdate {
653 #[inline(always)]
654 fn new_empty() -> Self {
655 Self::default()
656 }
657
658 unsafe fn decode(
659 &mut self,
660 decoder: &mut fidl::encoding::Decoder<'_, D>,
661 offset: usize,
662 mut depth: fidl::encoding::Depth,
663 ) -> fidl::Result<()> {
664 decoder.debug_check_bounds::<Self>(offset);
665 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
666 None => return Err(fidl::Error::NotNullable),
667 Some(len) => len,
668 };
669 if len == 0 {
671 return Ok(());
672 };
673 depth.increment()?;
674 let envelope_size = 8;
675 let bytes_len = len * envelope_size;
676 let offset = decoder.out_of_line_offset(bytes_len)?;
677 let mut _next_ordinal_to_read = 0;
679 let mut next_offset = offset;
680 let end_offset = offset + bytes_len;
681 _next_ordinal_to_read += 1;
682 if next_offset >= end_offset {
683 return Ok(());
684 }
685
686 while _next_ordinal_to_read < 1 {
688 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
689 _next_ordinal_to_read += 1;
690 next_offset += envelope_size;
691 }
692
693 let next_out_of_line = decoder.next_out_of_line();
694 let handles_before = decoder.remaining_handles();
695 if let Some((inlined, num_bytes, num_handles)) =
696 fidl::encoding::decode_envelope_header(decoder, next_offset)?
697 {
698 let member_inline_size =
699 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
700 if inlined != (member_inline_size <= 4) {
701 return Err(fidl::Error::InvalidInlineBitInEnvelope);
702 }
703 let inner_offset;
704 let mut inner_depth = depth.clone();
705 if inlined {
706 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
707 inner_offset = next_offset;
708 } else {
709 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
710 inner_depth.increment()?;
711 }
712 let val_ref = self.interface_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
713 fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
714 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
715 {
716 return Err(fidl::Error::InvalidNumBytesInEnvelope);
717 }
718 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
719 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
720 }
721 }
722
723 next_offset += envelope_size;
724 _next_ordinal_to_read += 1;
725 if next_offset >= end_offset {
726 return Ok(());
727 }
728
729 while _next_ordinal_to_read < 2 {
731 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
732 _next_ordinal_to_read += 1;
733 next_offset += envelope_size;
734 }
735
736 let next_out_of_line = decoder.next_out_of_line();
737 let handles_before = decoder.remaining_handles();
738 if let Some((inlined, num_bytes, num_handles)) =
739 fidl::encoding::decode_envelope_header(decoder, next_offset)?
740 {
741 let member_inline_size =
742 <fidl_fuchsia_net__common::Marks as fidl::encoding::TypeMarker>::inline_size(
743 decoder.context,
744 );
745 if inlined != (member_inline_size <= 4) {
746 return Err(fidl::Error::InvalidInlineBitInEnvelope);
747 }
748 let inner_offset;
749 let mut inner_depth = depth.clone();
750 if inlined {
751 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
752 inner_offset = next_offset;
753 } else {
754 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
755 inner_depth.increment()?;
756 }
757 let val_ref = self
758 .socket_marks
759 .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_net__common::Marks, D));
760 fidl::decode!(
761 fidl_fuchsia_net__common::Marks,
762 D,
763 val_ref,
764 decoder,
765 inner_offset,
766 inner_depth
767 )?;
768 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
769 {
770 return Err(fidl::Error::InvalidNumBytesInEnvelope);
771 }
772 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
773 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
774 }
775 }
776
777 next_offset += envelope_size;
778
779 while next_offset < end_offset {
781 _next_ordinal_to_read += 1;
782 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
783 next_offset += envelope_size;
784 }
785
786 Ok(())
787 }
788 }
789
790 impl DnsConfiguration {
791 #[inline(always)]
792 fn max_ordinal_present(&self) -> u64 {
793 if let Some(_) = self.servers {
794 return 1;
795 }
796 0
797 }
798 }
799
800 impl fidl::encoding::ValueTypeMarker for DnsConfiguration {
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 DnsConfiguration {
808 type Owned = Self;
809
810 #[inline(always)]
811 fn inline_align(_context: fidl::encoding::Context) -> usize {
812 8
813 }
814
815 #[inline(always)]
816 fn inline_size(_context: fidl::encoding::Context) -> usize {
817 16
818 }
819 }
820
821 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DnsConfiguration, D>
822 for &DnsConfiguration
823 {
824 unsafe fn encode(
825 self,
826 encoder: &mut fidl::encoding::Encoder<'_, D>,
827 offset: usize,
828 mut depth: fidl::encoding::Depth,
829 ) -> fidl::Result<()> {
830 encoder.debug_check_bounds::<DnsConfiguration>(offset);
831 let max_ordinal: u64 = self.max_ordinal_present();
833 encoder.write_num(max_ordinal, offset);
834 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
835 if max_ordinal == 0 {
837 return Ok(());
838 }
839 depth.increment()?;
840 let envelope_size = 8;
841 let bytes_len = max_ordinal as usize * envelope_size;
842 #[allow(unused_variables)]
843 let offset = encoder.out_of_line_offset(bytes_len);
844 let mut _prev_end_offset: usize = 0;
845 if 1 > max_ordinal {
846 return Ok(());
847 }
848
849 let cur_offset: usize = (1 - 1) * envelope_size;
852
853 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
855
856 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_net_name__common::DnsServer_>, D>(
861 self.servers.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_net_name__common::DnsServer_> as fidl::encoding::ValueTypeMarker>::borrow),
862 encoder, offset + cur_offset, depth
863 )?;
864
865 _prev_end_offset = cur_offset + envelope_size;
866
867 Ok(())
868 }
869 }
870
871 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DnsConfiguration {
872 #[inline(always)]
873 fn new_empty() -> Self {
874 Self::default()
875 }
876
877 unsafe fn decode(
878 &mut self,
879 decoder: &mut fidl::encoding::Decoder<'_, D>,
880 offset: usize,
881 mut depth: fidl::encoding::Depth,
882 ) -> fidl::Result<()> {
883 decoder.debug_check_bounds::<Self>(offset);
884 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
885 None => return Err(fidl::Error::NotNullable),
886 Some(len) => len,
887 };
888 if len == 0 {
890 return Ok(());
891 };
892 depth.increment()?;
893 let envelope_size = 8;
894 let bytes_len = len * envelope_size;
895 let offset = decoder.out_of_line_offset(bytes_len)?;
896 let mut _next_ordinal_to_read = 0;
898 let mut next_offset = offset;
899 let end_offset = offset + bytes_len;
900 _next_ordinal_to_read += 1;
901 if next_offset >= end_offset {
902 return Ok(());
903 }
904
905 while _next_ordinal_to_read < 1 {
907 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
908 _next_ordinal_to_read += 1;
909 next_offset += envelope_size;
910 }
911
912 let next_out_of_line = decoder.next_out_of_line();
913 let handles_before = decoder.remaining_handles();
914 if let Some((inlined, num_bytes, num_handles)) =
915 fidl::encoding::decode_envelope_header(decoder, next_offset)?
916 {
917 let member_inline_size = <fidl::encoding::UnboundedVector<
918 fidl_fuchsia_net_name__common::DnsServer_,
919 > as fidl::encoding::TypeMarker>::inline_size(
920 decoder.context
921 );
922 if inlined != (member_inline_size <= 4) {
923 return Err(fidl::Error::InvalidInlineBitInEnvelope);
924 }
925 let inner_offset;
926 let mut inner_depth = depth.clone();
927 if inlined {
928 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
929 inner_offset = next_offset;
930 } else {
931 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
932 inner_depth.increment()?;
933 }
934 let val_ref = self.servers.get_or_insert_with(|| {
935 fidl::new_empty!(
936 fidl::encoding::UnboundedVector<fidl_fuchsia_net_name__common::DnsServer_>,
937 D
938 )
939 });
940 fidl::decode!(
941 fidl::encoding::UnboundedVector<fidl_fuchsia_net_name__common::DnsServer_>,
942 D,
943 val_ref,
944 decoder,
945 inner_offset,
946 inner_depth
947 )?;
948 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
949 {
950 return Err(fidl::Error::InvalidNumBytesInEnvelope);
951 }
952 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
953 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
954 }
955 }
956
957 next_offset += envelope_size;
958
959 while next_offset < end_offset {
961 _next_ordinal_to_read += 1;
962 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
963 next_offset += envelope_size;
964 }
965
966 Ok(())
967 }
968 }
969
970 impl fidl::encoding::ValueTypeMarker for PropertyUpdate {
971 type Borrowed<'a> = &'a Self;
972 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
973 value
974 }
975 }
976
977 unsafe impl fidl::encoding::TypeMarker for PropertyUpdate {
978 type Owned = Self;
979
980 #[inline(always)]
981 fn inline_align(_context: fidl::encoding::Context) -> usize {
982 8
983 }
984
985 #[inline(always)]
986 fn inline_size(_context: fidl::encoding::Context) -> usize {
987 16
988 }
989 }
990
991 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PropertyUpdate, D>
992 for &PropertyUpdate
993 {
994 #[inline]
995 unsafe fn encode(
996 self,
997 encoder: &mut fidl::encoding::Encoder<'_, D>,
998 offset: usize,
999 _depth: fidl::encoding::Depth,
1000 ) -> fidl::Result<()> {
1001 encoder.debug_check_bounds::<PropertyUpdate>(offset);
1002 encoder.write_num::<u64>(self.ordinal(), offset);
1003 match self {
1004 PropertyUpdate::SocketMarks(ref val) => fidl::encoding::encode_in_envelope::<
1005 fidl_fuchsia_net__common::Marks,
1006 D,
1007 >(
1008 <fidl_fuchsia_net__common::Marks as fidl::encoding::ValueTypeMarker>::borrow(
1009 val,
1010 ),
1011 encoder,
1012 offset + 8,
1013 _depth,
1014 ),
1015 PropertyUpdate::DnsConfiguration(ref val) => {
1016 fidl::encoding::encode_in_envelope::<DnsConfiguration, D>(
1017 <DnsConfiguration as fidl::encoding::ValueTypeMarker>::borrow(val),
1018 encoder,
1019 offset + 8,
1020 _depth,
1021 )
1022 }
1023 PropertyUpdate::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1024 }
1025 }
1026 }
1027
1028 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PropertyUpdate {
1029 #[inline(always)]
1030 fn new_empty() -> Self {
1031 Self::__SourceBreaking { unknown_ordinal: 0 }
1032 }
1033
1034 #[inline]
1035 unsafe fn decode(
1036 &mut self,
1037 decoder: &mut fidl::encoding::Decoder<'_, D>,
1038 offset: usize,
1039 mut depth: fidl::encoding::Depth,
1040 ) -> fidl::Result<()> {
1041 decoder.debug_check_bounds::<Self>(offset);
1042 #[allow(unused_variables)]
1043 let next_out_of_line = decoder.next_out_of_line();
1044 let handles_before = decoder.remaining_handles();
1045 let (ordinal, inlined, num_bytes, num_handles) =
1046 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1047
1048 let member_inline_size = match ordinal {
1049 1 => <fidl_fuchsia_net__common::Marks as fidl::encoding::TypeMarker>::inline_size(
1050 decoder.context,
1051 ),
1052 2 => <DnsConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1053 0 => return Err(fidl::Error::UnknownUnionTag),
1054 _ => num_bytes as usize,
1055 };
1056
1057 if inlined != (member_inline_size <= 4) {
1058 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1059 }
1060 let _inner_offset;
1061 if inlined {
1062 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1063 _inner_offset = offset + 8;
1064 } else {
1065 depth.increment()?;
1066 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1067 }
1068 match ordinal {
1069 1 => {
1070 #[allow(irrefutable_let_patterns)]
1071 if let PropertyUpdate::SocketMarks(_) = self {
1072 } else {
1074 *self = PropertyUpdate::SocketMarks(fidl::new_empty!(
1076 fidl_fuchsia_net__common::Marks,
1077 D
1078 ));
1079 }
1080 #[allow(irrefutable_let_patterns)]
1081 if let PropertyUpdate::SocketMarks(ref mut val) = self {
1082 fidl::decode!(
1083 fidl_fuchsia_net__common::Marks,
1084 D,
1085 val,
1086 decoder,
1087 _inner_offset,
1088 depth
1089 )?;
1090 } else {
1091 unreachable!()
1092 }
1093 }
1094 2 => {
1095 #[allow(irrefutable_let_patterns)]
1096 if let PropertyUpdate::DnsConfiguration(_) = self {
1097 } else {
1099 *self =
1101 PropertyUpdate::DnsConfiguration(fidl::new_empty!(DnsConfiguration, D));
1102 }
1103 #[allow(irrefutable_let_patterns)]
1104 if let PropertyUpdate::DnsConfiguration(ref mut val) = self {
1105 fidl::decode!(DnsConfiguration, D, val, decoder, _inner_offset, depth)?;
1106 } else {
1107 unreachable!()
1108 }
1109 }
1110 #[allow(deprecated)]
1111 ordinal => {
1112 for _ in 0..num_handles {
1113 decoder.drop_next_handle()?;
1114 }
1115 *self = PropertyUpdate::__SourceBreaking { unknown_ordinal: ordinal };
1116 }
1117 }
1118 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1119 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1120 }
1121 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1122 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1123 }
1124 Ok(())
1125 }
1126 }
1127}