fidl_fuchsia_net_policy_properties/
fidl_fuchsia_net_policy_properties.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_policy_properties__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14/// The NetworkToken is an opaque token minted by [`Networks::WatchDefault`]
15/// that represents a logical network for the purpose of accessing network
16/// properties.
17#[derive(Debug, Default, PartialEq)]
18pub struct NetworkToken {
19    pub value: Option<fidl::EventPair>,
20    #[doc(hidden)]
21    pub __source_breaking: fidl::marker::SourceBreaking,
22}
23
24impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NetworkToken {}
25
26#[derive(Debug, Default, PartialEq)]
27pub struct NetworksWatchPropertiesRequest {
28    /// A network token acquired from [`WatchDefault`].
29    /// NOTE: REQUIRED
30    pub network: Option<NetworkToken>,
31    /// List of properties for which changes should be reported. Must be
32    /// non-empty, duplicates will be ignored.
33    /// NOTE: REQUIRED
34    pub properties: Option<Vec<Property>>,
35    #[doc(hidden)]
36    pub __source_breaking: fidl::marker::SourceBreaking,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40    for NetworksWatchPropertiesRequest
41{
42}
43
44#[derive(Debug)]
45pub enum NetworksWatchDefaultResponse {
46    Network(NetworkToken),
47    NoDefaultNetwork(Empty),
48    #[doc(hidden)]
49    __SourceBreaking {
50        unknown_ordinal: u64,
51    },
52}
53
54/// Pattern that matches an unknown `NetworksWatchDefaultResponse` member.
55#[macro_export]
56macro_rules! NetworksWatchDefaultResponseUnknown {
57    () => {
58        _
59    };
60}
61
62// Custom PartialEq so that unknown variants are not equal to themselves.
63impl PartialEq for NetworksWatchDefaultResponse {
64    fn eq(&self, other: &Self) -> bool {
65        match (self, other) {
66            (Self::Network(x), Self::Network(y)) => *x == *y,
67            (Self::NoDefaultNetwork(x), Self::NoDefaultNetwork(y)) => *x == *y,
68            _ => false,
69        }
70    }
71}
72
73impl NetworksWatchDefaultResponse {
74    #[inline]
75    pub fn ordinal(&self) -> u64 {
76        match *self {
77            Self::Network(_) => 1,
78            Self::NoDefaultNetwork(_) => 2,
79            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
80        }
81    }
82
83    #[inline]
84    pub fn unknown_variant_for_testing() -> Self {
85        Self::__SourceBreaking { unknown_ordinal: 0 }
86    }
87
88    #[inline]
89    pub fn is_unknown(&self) -> bool {
90        match self {
91            Self::__SourceBreaking { .. } => true,
92            _ => false,
93        }
94    }
95}
96
97impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
98    for NetworksWatchDefaultResponse
99{
100}
101
102#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
103pub struct NetworksMarker;
104
105impl fidl::endpoints::ProtocolMarker for NetworksMarker {
106    type Proxy = NetworksProxy;
107    type RequestStream = NetworksRequestStream;
108    #[cfg(target_os = "fuchsia")]
109    type SynchronousProxy = NetworksSynchronousProxy;
110
111    const DEBUG_NAME: &'static str = "fuchsia.net.policy.properties.Networks";
112}
113impl fidl::endpoints::DiscoverableProtocolMarker for NetworksMarker {}
114pub type NetworksWatchPropertiesResult = Result<Vec<PropertyUpdate>, WatchError>;
115
116pub trait NetworksProxyInterface: Send + Sync {
117    type WatchDefaultResponseFut: std::future::Future<Output = Result<NetworksWatchDefaultResponse, fidl::Error>>
118        + Send;
119    fn r#watch_default(&self) -> Self::WatchDefaultResponseFut;
120    type WatchPropertiesResponseFut: std::future::Future<Output = Result<NetworksWatchPropertiesResult, fidl::Error>>
121        + Send;
122    fn r#watch_properties(
123        &self,
124        payload: NetworksWatchPropertiesRequest,
125    ) -> Self::WatchPropertiesResponseFut;
126}
127#[derive(Debug)]
128#[cfg(target_os = "fuchsia")]
129pub struct NetworksSynchronousProxy {
130    client: fidl::client::sync::Client,
131}
132
133#[cfg(target_os = "fuchsia")]
134impl fidl::endpoints::SynchronousProxy for NetworksSynchronousProxy {
135    type Proxy = NetworksProxy;
136    type Protocol = NetworksMarker;
137
138    fn from_channel(inner: fidl::Channel) -> Self {
139        Self::new(inner)
140    }
141
142    fn into_channel(self) -> fidl::Channel {
143        self.client.into_channel()
144    }
145
146    fn as_channel(&self) -> &fidl::Channel {
147        self.client.as_channel()
148    }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl NetworksSynchronousProxy {
153    pub fn new(channel: fidl::Channel) -> Self {
154        let protocol_name = <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
155        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
156    }
157
158    pub fn into_channel(self) -> fidl::Channel {
159        self.client.into_channel()
160    }
161
162    /// Waits until an event arrives and returns it. It is safe for other
163    /// threads to make concurrent requests while waiting for an event.
164    pub fn wait_for_event(
165        &self,
166        deadline: zx::MonotonicInstant,
167    ) -> Result<NetworksEvent, fidl::Error> {
168        NetworksEvent::decode(self.client.wait_for_event(deadline)?)
169    }
170
171    /// Watches for changes in the default network.
172    ///
173    /// The first call always returns a [`NetworkToken`] representing the
174    /// current default network, or if one is not present, blocks until a
175    /// default network is set. Subsequent calls will block until the default
176    /// network has changed, or has been lost, returning a new [`NetworkToken`]
177    /// for the updated default network, or [`no_default_network`] if the
178    /// network is lost.
179    ///
180    /// Only one call to this method should be pending per connection.
181    pub fn r#watch_default(
182        &self,
183        ___deadline: zx::MonotonicInstant,
184    ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
185        let _response = self.client.send_query::<
186            fidl::encoding::EmptyPayload,
187            fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
188        >(
189            (),
190            0x346880b2d7db0f98,
191            fidl::encoding::DynamicFlags::FLEXIBLE,
192            ___deadline,
193        )?
194        .into_result::<NetworksMarker>("watch_default")?;
195        Ok(_response)
196    }
197
198    /// Watches for changes in requested properties for the given [`NetworkToken`]
199    ///
200    /// The first call will always return a snapshot of all requested
201    /// properties. Subsequent calls will block until any property changes, at
202    /// which point the changed property or properties will be sent. If the set
203    /// of requested [`properties`] changes on a subsequent call, the previously
204    /// unreported property will be sent immediately, before future calls will
205    /// return to the hanging get pattern. If the network represented by
206    /// `network` is no longer the default network, the connection will be
207    /// closed with `DEFAULT_NETWORK_CHANGED`.
208    ///
209    /// Only one call to this method should be pending per [`NetworkToken`] per connection.
210    pub fn r#watch_properties(
211        &self,
212        mut payload: NetworksWatchPropertiesRequest,
213        ___deadline: zx::MonotonicInstant,
214    ) -> Result<NetworksWatchPropertiesResult, fidl::Error> {
215        let _response = self.client.send_query::<
216            NetworksWatchPropertiesRequest,
217            fidl::encoding::FlexibleResultType<NetworksWatchPropertiesResponse, WatchError>,
218        >(
219            &mut payload,
220            0x24d2340905f7dcc6,
221            fidl::encoding::DynamicFlags::FLEXIBLE,
222            ___deadline,
223        )?
224        .into_result::<NetworksMarker>("watch_properties")?;
225        Ok(_response.map(|x| x.updates))
226    }
227}
228
229#[cfg(target_os = "fuchsia")]
230impl From<NetworksSynchronousProxy> for zx::NullableHandle {
231    fn from(value: NetworksSynchronousProxy) -> Self {
232        value.into_channel().into()
233    }
234}
235
236#[cfg(target_os = "fuchsia")]
237impl From<fidl::Channel> for NetworksSynchronousProxy {
238    fn from(value: fidl::Channel) -> Self {
239        Self::new(value)
240    }
241}
242
243#[cfg(target_os = "fuchsia")]
244impl fidl::endpoints::FromClient for NetworksSynchronousProxy {
245    type Protocol = NetworksMarker;
246
247    fn from_client(value: fidl::endpoints::ClientEnd<NetworksMarker>) -> Self {
248        Self::new(value.into_channel())
249    }
250}
251
252#[derive(Debug, Clone)]
253pub struct NetworksProxy {
254    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
255}
256
257impl fidl::endpoints::Proxy for NetworksProxy {
258    type Protocol = NetworksMarker;
259
260    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
261        Self::new(inner)
262    }
263
264    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
265        self.client.into_channel().map_err(|client| Self { client })
266    }
267
268    fn as_channel(&self) -> &::fidl::AsyncChannel {
269        self.client.as_channel()
270    }
271}
272
273impl NetworksProxy {
274    /// Create a new Proxy for fuchsia.net.policy.properties/Networks.
275    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
276        let protocol_name = <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
277        Self { client: fidl::client::Client::new(channel, protocol_name) }
278    }
279
280    /// Get a Stream of events from the remote end of the protocol.
281    ///
282    /// # Panics
283    ///
284    /// Panics if the event stream was already taken.
285    pub fn take_event_stream(&self) -> NetworksEventStream {
286        NetworksEventStream { event_receiver: self.client.take_event_receiver() }
287    }
288
289    /// Watches for changes in the default network.
290    ///
291    /// The first call always returns a [`NetworkToken`] representing the
292    /// current default network, or if one is not present, blocks until a
293    /// default network is set. Subsequent calls will block until the default
294    /// network has changed, or has been lost, returning a new [`NetworkToken`]
295    /// for the updated default network, or [`no_default_network`] if the
296    /// network is lost.
297    ///
298    /// Only one call to this method should be pending per connection.
299    pub fn r#watch_default(
300        &self,
301    ) -> fidl::client::QueryResponseFut<
302        NetworksWatchDefaultResponse,
303        fidl::encoding::DefaultFuchsiaResourceDialect,
304    > {
305        NetworksProxyInterface::r#watch_default(self)
306    }
307
308    /// Watches for changes in requested properties for the given [`NetworkToken`]
309    ///
310    /// The first call will always return a snapshot of all requested
311    /// properties. Subsequent calls will block until any property changes, at
312    /// which point the changed property or properties will be sent. If the set
313    /// of requested [`properties`] changes on a subsequent call, the previously
314    /// unreported property will be sent immediately, before future calls will
315    /// return to the hanging get pattern. If the network represented by
316    /// `network` is no longer the default network, the connection will be
317    /// closed with `DEFAULT_NETWORK_CHANGED`.
318    ///
319    /// Only one call to this method should be pending per [`NetworkToken`] per connection.
320    pub fn r#watch_properties(
321        &self,
322        mut payload: NetworksWatchPropertiesRequest,
323    ) -> fidl::client::QueryResponseFut<
324        NetworksWatchPropertiesResult,
325        fidl::encoding::DefaultFuchsiaResourceDialect,
326    > {
327        NetworksProxyInterface::r#watch_properties(self, payload)
328    }
329}
330
331impl NetworksProxyInterface for NetworksProxy {
332    type WatchDefaultResponseFut = fidl::client::QueryResponseFut<
333        NetworksWatchDefaultResponse,
334        fidl::encoding::DefaultFuchsiaResourceDialect,
335    >;
336    fn r#watch_default(&self) -> Self::WatchDefaultResponseFut {
337        fn _decode(
338            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
339        ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
340            let _response = fidl::client::decode_transaction_body::<
341                fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
342                fidl::encoding::DefaultFuchsiaResourceDialect,
343                0x346880b2d7db0f98,
344            >(_buf?)?
345            .into_result::<NetworksMarker>("watch_default")?;
346            Ok(_response)
347        }
348        self.client
349            .send_query_and_decode::<fidl::encoding::EmptyPayload, NetworksWatchDefaultResponse>(
350                (),
351                0x346880b2d7db0f98,
352                fidl::encoding::DynamicFlags::FLEXIBLE,
353                _decode,
354            )
355    }
356
357    type WatchPropertiesResponseFut = fidl::client::QueryResponseFut<
358        NetworksWatchPropertiesResult,
359        fidl::encoding::DefaultFuchsiaResourceDialect,
360    >;
361    fn r#watch_properties(
362        &self,
363        mut payload: NetworksWatchPropertiesRequest,
364    ) -> Self::WatchPropertiesResponseFut {
365        fn _decode(
366            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
367        ) -> Result<NetworksWatchPropertiesResult, fidl::Error> {
368            let _response = fidl::client::decode_transaction_body::<
369                fidl::encoding::FlexibleResultType<NetworksWatchPropertiesResponse, WatchError>,
370                fidl::encoding::DefaultFuchsiaResourceDialect,
371                0x24d2340905f7dcc6,
372            >(_buf?)?
373            .into_result::<NetworksMarker>("watch_properties")?;
374            Ok(_response.map(|x| x.updates))
375        }
376        self.client
377            .send_query_and_decode::<NetworksWatchPropertiesRequest, NetworksWatchPropertiesResult>(
378                &mut payload,
379                0x24d2340905f7dcc6,
380                fidl::encoding::DynamicFlags::FLEXIBLE,
381                _decode,
382            )
383    }
384}
385
386pub struct NetworksEventStream {
387    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
388}
389
390impl std::marker::Unpin for NetworksEventStream {}
391
392impl futures::stream::FusedStream for NetworksEventStream {
393    fn is_terminated(&self) -> bool {
394        self.event_receiver.is_terminated()
395    }
396}
397
398impl futures::Stream for NetworksEventStream {
399    type Item = Result<NetworksEvent, fidl::Error>;
400
401    fn poll_next(
402        mut self: std::pin::Pin<&mut Self>,
403        cx: &mut std::task::Context<'_>,
404    ) -> std::task::Poll<Option<Self::Item>> {
405        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
406            &mut self.event_receiver,
407            cx
408        )?) {
409            Some(buf) => std::task::Poll::Ready(Some(NetworksEvent::decode(buf))),
410            None => std::task::Poll::Ready(None),
411        }
412    }
413}
414
415#[derive(Debug)]
416pub enum NetworksEvent {
417    #[non_exhaustive]
418    _UnknownEvent {
419        /// Ordinal of the event that was sent.
420        ordinal: u64,
421    },
422}
423
424impl NetworksEvent {
425    /// Decodes a message buffer as a [`NetworksEvent`].
426    fn decode(
427        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
428    ) -> Result<NetworksEvent, fidl::Error> {
429        let (bytes, _handles) = buf.split_mut();
430        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
431        debug_assert_eq!(tx_header.tx_id, 0);
432        match tx_header.ordinal {
433            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
434                Ok(NetworksEvent::_UnknownEvent { ordinal: tx_header.ordinal })
435            }
436            _ => Err(fidl::Error::UnknownOrdinal {
437                ordinal: tx_header.ordinal,
438                protocol_name: <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
439            }),
440        }
441    }
442}
443
444/// A Stream of incoming requests for fuchsia.net.policy.properties/Networks.
445pub struct NetworksRequestStream {
446    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
447    is_terminated: bool,
448}
449
450impl std::marker::Unpin for NetworksRequestStream {}
451
452impl futures::stream::FusedStream for NetworksRequestStream {
453    fn is_terminated(&self) -> bool {
454        self.is_terminated
455    }
456}
457
458impl fidl::endpoints::RequestStream for NetworksRequestStream {
459    type Protocol = NetworksMarker;
460    type ControlHandle = NetworksControlHandle;
461
462    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
463        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
464    }
465
466    fn control_handle(&self) -> Self::ControlHandle {
467        NetworksControlHandle { inner: self.inner.clone() }
468    }
469
470    fn into_inner(
471        self,
472    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
473    {
474        (self.inner, self.is_terminated)
475    }
476
477    fn from_inner(
478        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
479        is_terminated: bool,
480    ) -> Self {
481        Self { inner, is_terminated }
482    }
483}
484
485impl futures::Stream for NetworksRequestStream {
486    type Item = Result<NetworksRequest, fidl::Error>;
487
488    fn poll_next(
489        mut self: std::pin::Pin<&mut Self>,
490        cx: &mut std::task::Context<'_>,
491    ) -> std::task::Poll<Option<Self::Item>> {
492        let this = &mut *self;
493        if this.inner.check_shutdown(cx) {
494            this.is_terminated = true;
495            return std::task::Poll::Ready(None);
496        }
497        if this.is_terminated {
498            panic!("polled NetworksRequestStream after completion");
499        }
500        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
501            |bytes, handles| {
502                match this.inner.channel().read_etc(cx, bytes, handles) {
503                    std::task::Poll::Ready(Ok(())) => {}
504                    std::task::Poll::Pending => return std::task::Poll::Pending,
505                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
506                        this.is_terminated = true;
507                        return std::task::Poll::Ready(None);
508                    }
509                    std::task::Poll::Ready(Err(e)) => {
510                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
511                            e.into(),
512                        ))));
513                    }
514                }
515
516                // A message has been received from the channel
517                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
518
519                std::task::Poll::Ready(Some(match header.ordinal {
520                    0x346880b2d7db0f98 => {
521                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
522                        let mut req = fidl::new_empty!(
523                            fidl::encoding::EmptyPayload,
524                            fidl::encoding::DefaultFuchsiaResourceDialect
525                        );
526                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
527                        let control_handle = NetworksControlHandle { inner: this.inner.clone() };
528                        Ok(NetworksRequest::WatchDefault {
529                            responder: NetworksWatchDefaultResponder {
530                                control_handle: std::mem::ManuallyDrop::new(control_handle),
531                                tx_id: header.tx_id,
532                            },
533                        })
534                    }
535                    0x24d2340905f7dcc6 => {
536                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
537                        let mut req = fidl::new_empty!(
538                            NetworksWatchPropertiesRequest,
539                            fidl::encoding::DefaultFuchsiaResourceDialect
540                        );
541                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworksWatchPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
542                        let control_handle = NetworksControlHandle { inner: this.inner.clone() };
543                        Ok(NetworksRequest::WatchProperties {
544                            payload: req,
545                            responder: NetworksWatchPropertiesResponder {
546                                control_handle: std::mem::ManuallyDrop::new(control_handle),
547                                tx_id: header.tx_id,
548                            },
549                        })
550                    }
551                    _ if header.tx_id == 0
552                        && header
553                            .dynamic_flags()
554                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
555                    {
556                        Ok(NetworksRequest::_UnknownMethod {
557                            ordinal: header.ordinal,
558                            control_handle: NetworksControlHandle { inner: this.inner.clone() },
559                            method_type: fidl::MethodType::OneWay,
560                        })
561                    }
562                    _ if header
563                        .dynamic_flags()
564                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
565                    {
566                        this.inner.send_framework_err(
567                            fidl::encoding::FrameworkErr::UnknownMethod,
568                            header.tx_id,
569                            header.ordinal,
570                            header.dynamic_flags(),
571                            (bytes, handles),
572                        )?;
573                        Ok(NetworksRequest::_UnknownMethod {
574                            ordinal: header.ordinal,
575                            control_handle: NetworksControlHandle { inner: this.inner.clone() },
576                            method_type: fidl::MethodType::TwoWay,
577                        })
578                    }
579                    _ => Err(fidl::Error::UnknownOrdinal {
580                        ordinal: header.ordinal,
581                        protocol_name:
582                            <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
583                    }),
584                }))
585            },
586        )
587    }
588}
589
590/// Protocol for acquiring [`NetworkToken`]s, and querying properties of that
591/// network.
592#[derive(Debug)]
593pub enum NetworksRequest {
594    /// Watches for changes in the default network.
595    ///
596    /// The first call always returns a [`NetworkToken`] representing the
597    /// current default network, or if one is not present, blocks until a
598    /// default network is set. Subsequent calls will block until the default
599    /// network has changed, or has been lost, returning a new [`NetworkToken`]
600    /// for the updated default network, or [`no_default_network`] if the
601    /// network is lost.
602    ///
603    /// Only one call to this method should be pending per connection.
604    WatchDefault { responder: NetworksWatchDefaultResponder },
605    /// Watches for changes in requested properties for the given [`NetworkToken`]
606    ///
607    /// The first call will always return a snapshot of all requested
608    /// properties. Subsequent calls will block until any property changes, at
609    /// which point the changed property or properties will be sent. If the set
610    /// of requested [`properties`] changes on a subsequent call, the previously
611    /// unreported property will be sent immediately, before future calls will
612    /// return to the hanging get pattern. If the network represented by
613    /// `network` is no longer the default network, the connection will be
614    /// closed with `DEFAULT_NETWORK_CHANGED`.
615    ///
616    /// Only one call to this method should be pending per [`NetworkToken`] per connection.
617    WatchProperties {
618        payload: NetworksWatchPropertiesRequest,
619        responder: NetworksWatchPropertiesResponder,
620    },
621    /// An interaction was received which does not match any known method.
622    #[non_exhaustive]
623    _UnknownMethod {
624        /// Ordinal of the method that was called.
625        ordinal: u64,
626        control_handle: NetworksControlHandle,
627        method_type: fidl::MethodType,
628    },
629}
630
631impl NetworksRequest {
632    #[allow(irrefutable_let_patterns)]
633    pub fn into_watch_default(self) -> Option<(NetworksWatchDefaultResponder)> {
634        if let NetworksRequest::WatchDefault { responder } = self {
635            Some((responder))
636        } else {
637            None
638        }
639    }
640
641    #[allow(irrefutable_let_patterns)]
642    pub fn into_watch_properties(
643        self,
644    ) -> Option<(NetworksWatchPropertiesRequest, NetworksWatchPropertiesResponder)> {
645        if let NetworksRequest::WatchProperties { payload, responder } = self {
646            Some((payload, responder))
647        } else {
648            None
649        }
650    }
651
652    /// Name of the method defined in FIDL
653    pub fn method_name(&self) -> &'static str {
654        match *self {
655            NetworksRequest::WatchDefault { .. } => "watch_default",
656            NetworksRequest::WatchProperties { .. } => "watch_properties",
657            NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
658                "unknown one-way method"
659            }
660            NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
661                "unknown two-way method"
662            }
663        }
664    }
665}
666
667#[derive(Debug, Clone)]
668pub struct NetworksControlHandle {
669    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
670}
671
672impl fidl::endpoints::ControlHandle for NetworksControlHandle {
673    fn shutdown(&self) {
674        self.inner.shutdown()
675    }
676
677    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
678        self.inner.shutdown_with_epitaph(status)
679    }
680
681    fn is_closed(&self) -> bool {
682        self.inner.channel().is_closed()
683    }
684    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
685        self.inner.channel().on_closed()
686    }
687
688    #[cfg(target_os = "fuchsia")]
689    fn signal_peer(
690        &self,
691        clear_mask: zx::Signals,
692        set_mask: zx::Signals,
693    ) -> Result<(), zx_status::Status> {
694        use fidl::Peered;
695        self.inner.channel().signal_peer(clear_mask, set_mask)
696    }
697}
698
699impl NetworksControlHandle {}
700
701#[must_use = "FIDL methods require a response to be sent"]
702#[derive(Debug)]
703pub struct NetworksWatchDefaultResponder {
704    control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
705    tx_id: u32,
706}
707
708/// Set the the channel to be shutdown (see [`NetworksControlHandle::shutdown`])
709/// if the responder is dropped without sending a response, so that the client
710/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
711impl std::ops::Drop for NetworksWatchDefaultResponder {
712    fn drop(&mut self) {
713        self.control_handle.shutdown();
714        // Safety: drops once, never accessed again
715        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
716    }
717}
718
719impl fidl::endpoints::Responder for NetworksWatchDefaultResponder {
720    type ControlHandle = NetworksControlHandle;
721
722    fn control_handle(&self) -> &NetworksControlHandle {
723        &self.control_handle
724    }
725
726    fn drop_without_shutdown(mut self) {
727        // Safety: drops once, never accessed again due to mem::forget
728        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
729        // Prevent Drop from running (which would shut down the channel)
730        std::mem::forget(self);
731    }
732}
733
734impl NetworksWatchDefaultResponder {
735    /// Sends a response to the FIDL transaction.
736    ///
737    /// Sets the channel to shutdown if an error occurs.
738    pub fn send(self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
739        let _result = self.send_raw(payload);
740        if _result.is_err() {
741            self.control_handle.shutdown();
742        }
743        self.drop_without_shutdown();
744        _result
745    }
746
747    /// Similar to "send" but does not shutdown the channel if an error occurs.
748    pub fn send_no_shutdown_on_err(
749        self,
750        mut payload: NetworksWatchDefaultResponse,
751    ) -> Result<(), fidl::Error> {
752        let _result = self.send_raw(payload);
753        self.drop_without_shutdown();
754        _result
755    }
756
757    fn send_raw(&self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
758        self.control_handle
759            .inner
760            .send::<fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>>(
761                fidl::encoding::Flexible::new(&mut payload),
762                self.tx_id,
763                0x346880b2d7db0f98,
764                fidl::encoding::DynamicFlags::FLEXIBLE,
765            )
766    }
767}
768
769#[must_use = "FIDL methods require a response to be sent"]
770#[derive(Debug)]
771pub struct NetworksWatchPropertiesResponder {
772    control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
773    tx_id: u32,
774}
775
776/// Set the the channel to be shutdown (see [`NetworksControlHandle::shutdown`])
777/// if the responder is dropped without sending a response, so that the client
778/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
779impl std::ops::Drop for NetworksWatchPropertiesResponder {
780    fn drop(&mut self) {
781        self.control_handle.shutdown();
782        // Safety: drops once, never accessed again
783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
784    }
785}
786
787impl fidl::endpoints::Responder for NetworksWatchPropertiesResponder {
788    type ControlHandle = NetworksControlHandle;
789
790    fn control_handle(&self) -> &NetworksControlHandle {
791        &self.control_handle
792    }
793
794    fn drop_without_shutdown(mut self) {
795        // Safety: drops once, never accessed again due to mem::forget
796        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
797        // Prevent Drop from running (which would shut down the channel)
798        std::mem::forget(self);
799    }
800}
801
802impl NetworksWatchPropertiesResponder {
803    /// Sends a response to the FIDL transaction.
804    ///
805    /// Sets the channel to shutdown if an error occurs.
806    pub fn send(
807        self,
808        mut result: Result<&[PropertyUpdate], WatchError>,
809    ) -> Result<(), fidl::Error> {
810        let _result = self.send_raw(result);
811        if _result.is_err() {
812            self.control_handle.shutdown();
813        }
814        self.drop_without_shutdown();
815        _result
816    }
817
818    /// Similar to "send" but does not shutdown the channel if an error occurs.
819    pub fn send_no_shutdown_on_err(
820        self,
821        mut result: Result<&[PropertyUpdate], WatchError>,
822    ) -> Result<(), fidl::Error> {
823        let _result = self.send_raw(result);
824        self.drop_without_shutdown();
825        _result
826    }
827
828    fn send_raw(
829        &self,
830        mut result: Result<&[PropertyUpdate], WatchError>,
831    ) -> Result<(), fidl::Error> {
832        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
833            NetworksWatchPropertiesResponse,
834            WatchError,
835        >>(
836            fidl::encoding::FlexibleResult::new(result.map(|updates| (updates,))),
837            self.tx_id,
838            0x24d2340905f7dcc6,
839            fidl::encoding::DynamicFlags::FLEXIBLE,
840        )
841    }
842}
843
844mod internal {
845    use super::*;
846
847    impl NetworkToken {
848        #[inline(always)]
849        fn max_ordinal_present(&self) -> u64 {
850            if let Some(_) = self.value {
851                return 1;
852            }
853            0
854        }
855    }
856
857    impl fidl::encoding::ResourceTypeMarker for NetworkToken {
858        type Borrowed<'a> = &'a mut Self;
859        fn take_or_borrow<'a>(
860            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
861        ) -> Self::Borrowed<'a> {
862            value
863        }
864    }
865
866    unsafe impl fidl::encoding::TypeMarker for NetworkToken {
867        type Owned = Self;
868
869        #[inline(always)]
870        fn inline_align(_context: fidl::encoding::Context) -> usize {
871            8
872        }
873
874        #[inline(always)]
875        fn inline_size(_context: fidl::encoding::Context) -> usize {
876            16
877        }
878    }
879
880    unsafe impl fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>
881        for &mut NetworkToken
882    {
883        unsafe fn encode(
884            self,
885            encoder: &mut fidl::encoding::Encoder<
886                '_,
887                fidl::encoding::DefaultFuchsiaResourceDialect,
888            >,
889            offset: usize,
890            mut depth: fidl::encoding::Depth,
891        ) -> fidl::Result<()> {
892            encoder.debug_check_bounds::<NetworkToken>(offset);
893            // Vector header
894            let max_ordinal: u64 = self.max_ordinal_present();
895            encoder.write_num(max_ordinal, offset);
896            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
897            // Calling encoder.out_of_line_offset(0) is not allowed.
898            if max_ordinal == 0 {
899                return Ok(());
900            }
901            depth.increment()?;
902            let envelope_size = 8;
903            let bytes_len = max_ordinal as usize * envelope_size;
904            #[allow(unused_variables)]
905            let offset = encoder.out_of_line_offset(bytes_len);
906            let mut _prev_end_offset: usize = 0;
907            if 1 > max_ordinal {
908                return Ok(());
909            }
910
911            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
912            // are envelope_size bytes.
913            let cur_offset: usize = (1 - 1) * envelope_size;
914
915            // Zero reserved fields.
916            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
917
918            // Safety:
919            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
920            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
921            //   envelope_size bytes, there is always sufficient room.
922            fidl::encoding::encode_in_envelope_optional::<
923                fidl::encoding::HandleType<
924                    fidl::EventPair,
925                    { fidl::ObjectType::EVENTPAIR.into_raw() },
926                    2147483648,
927                >,
928                fidl::encoding::DefaultFuchsiaResourceDialect,
929            >(
930                self.value.as_mut().map(
931                    <fidl::encoding::HandleType<
932                        fidl::EventPair,
933                        { fidl::ObjectType::EVENTPAIR.into_raw() },
934                        2147483648,
935                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
936                ),
937                encoder,
938                offset + cur_offset,
939                depth,
940            )?;
941
942            _prev_end_offset = cur_offset + envelope_size;
943
944            Ok(())
945        }
946    }
947
948    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NetworkToken {
949        #[inline(always)]
950        fn new_empty() -> Self {
951            Self::default()
952        }
953
954        unsafe fn decode(
955            &mut self,
956            decoder: &mut fidl::encoding::Decoder<
957                '_,
958                fidl::encoding::DefaultFuchsiaResourceDialect,
959            >,
960            offset: usize,
961            mut depth: fidl::encoding::Depth,
962        ) -> fidl::Result<()> {
963            decoder.debug_check_bounds::<Self>(offset);
964            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
965                None => return Err(fidl::Error::NotNullable),
966                Some(len) => len,
967            };
968            // Calling decoder.out_of_line_offset(0) is not allowed.
969            if len == 0 {
970                return Ok(());
971            };
972            depth.increment()?;
973            let envelope_size = 8;
974            let bytes_len = len * envelope_size;
975            let offset = decoder.out_of_line_offset(bytes_len)?;
976            // Decode the envelope for each type.
977            let mut _next_ordinal_to_read = 0;
978            let mut next_offset = offset;
979            let end_offset = offset + bytes_len;
980            _next_ordinal_to_read += 1;
981            if next_offset >= end_offset {
982                return Ok(());
983            }
984
985            // Decode unknown envelopes for gaps in ordinals.
986            while _next_ordinal_to_read < 1 {
987                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
988                _next_ordinal_to_read += 1;
989                next_offset += envelope_size;
990            }
991
992            let next_out_of_line = decoder.next_out_of_line();
993            let handles_before = decoder.remaining_handles();
994            if let Some((inlined, num_bytes, num_handles)) =
995                fidl::encoding::decode_envelope_header(decoder, next_offset)?
996            {
997                let member_inline_size = <fidl::encoding::HandleType<
998                    fidl::EventPair,
999                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1000                    2147483648,
1001                > as fidl::encoding::TypeMarker>::inline_size(
1002                    decoder.context
1003                );
1004                if inlined != (member_inline_size <= 4) {
1005                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1006                }
1007                let inner_offset;
1008                let mut inner_depth = depth.clone();
1009                if inlined {
1010                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1011                    inner_offset = next_offset;
1012                } else {
1013                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1014                    inner_depth.increment()?;
1015                }
1016                let val_ref =
1017                self.value.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1018                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1019                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1020                {
1021                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1022                }
1023                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1024                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1025                }
1026            }
1027
1028            next_offset += envelope_size;
1029
1030            // Decode the remaining unknown envelopes.
1031            while next_offset < end_offset {
1032                _next_ordinal_to_read += 1;
1033                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1034                next_offset += envelope_size;
1035            }
1036
1037            Ok(())
1038        }
1039    }
1040
1041    impl NetworksWatchPropertiesRequest {
1042        #[inline(always)]
1043        fn max_ordinal_present(&self) -> u64 {
1044            if let Some(_) = self.properties {
1045                return 2;
1046            }
1047            if let Some(_) = self.network {
1048                return 1;
1049            }
1050            0
1051        }
1052    }
1053
1054    impl fidl::encoding::ResourceTypeMarker for NetworksWatchPropertiesRequest {
1055        type Borrowed<'a> = &'a mut Self;
1056        fn take_or_borrow<'a>(
1057            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1058        ) -> Self::Borrowed<'a> {
1059            value
1060        }
1061    }
1062
1063    unsafe impl fidl::encoding::TypeMarker for NetworksWatchPropertiesRequest {
1064        type Owned = Self;
1065
1066        #[inline(always)]
1067        fn inline_align(_context: fidl::encoding::Context) -> usize {
1068            8
1069        }
1070
1071        #[inline(always)]
1072        fn inline_size(_context: fidl::encoding::Context) -> usize {
1073            16
1074        }
1075    }
1076
1077    unsafe impl
1078        fidl::encoding::Encode<
1079            NetworksWatchPropertiesRequest,
1080            fidl::encoding::DefaultFuchsiaResourceDialect,
1081        > for &mut NetworksWatchPropertiesRequest
1082    {
1083        unsafe fn encode(
1084            self,
1085            encoder: &mut fidl::encoding::Encoder<
1086                '_,
1087                fidl::encoding::DefaultFuchsiaResourceDialect,
1088            >,
1089            offset: usize,
1090            mut depth: fidl::encoding::Depth,
1091        ) -> fidl::Result<()> {
1092            encoder.debug_check_bounds::<NetworksWatchPropertiesRequest>(offset);
1093            // Vector header
1094            let max_ordinal: u64 = self.max_ordinal_present();
1095            encoder.write_num(max_ordinal, offset);
1096            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1097            // Calling encoder.out_of_line_offset(0) is not allowed.
1098            if max_ordinal == 0 {
1099                return Ok(());
1100            }
1101            depth.increment()?;
1102            let envelope_size = 8;
1103            let bytes_len = max_ordinal as usize * envelope_size;
1104            #[allow(unused_variables)]
1105            let offset = encoder.out_of_line_offset(bytes_len);
1106            let mut _prev_end_offset: usize = 0;
1107            if 1 > max_ordinal {
1108                return Ok(());
1109            }
1110
1111            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1112            // are envelope_size bytes.
1113            let cur_offset: usize = (1 - 1) * envelope_size;
1114
1115            // Zero reserved fields.
1116            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1117
1118            // Safety:
1119            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1120            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1121            //   envelope_size bytes, there is always sufficient room.
1122            fidl::encoding::encode_in_envelope_optional::<
1123                NetworkToken,
1124                fidl::encoding::DefaultFuchsiaResourceDialect,
1125            >(
1126                self.network
1127                    .as_mut()
1128                    .map(<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1129                encoder,
1130                offset + cur_offset,
1131                depth,
1132            )?;
1133
1134            _prev_end_offset = cur_offset + envelope_size;
1135            if 2 > max_ordinal {
1136                return Ok(());
1137            }
1138
1139            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1140            // are envelope_size bytes.
1141            let cur_offset: usize = (2 - 1) * envelope_size;
1142
1143            // Zero reserved fields.
1144            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1145
1146            // Safety:
1147            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1148            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1149            //   envelope_size bytes, there is always sufficient room.
1150            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Property>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1151            self.properties.as_ref().map(<fidl::encoding::UnboundedVector<Property> as fidl::encoding::ValueTypeMarker>::borrow),
1152            encoder, offset + cur_offset, depth
1153        )?;
1154
1155            _prev_end_offset = cur_offset + envelope_size;
1156
1157            Ok(())
1158        }
1159    }
1160
1161    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1162        for NetworksWatchPropertiesRequest
1163    {
1164        #[inline(always)]
1165        fn new_empty() -> Self {
1166            Self::default()
1167        }
1168
1169        unsafe fn decode(
1170            &mut self,
1171            decoder: &mut fidl::encoding::Decoder<
1172                '_,
1173                fidl::encoding::DefaultFuchsiaResourceDialect,
1174            >,
1175            offset: usize,
1176            mut depth: fidl::encoding::Depth,
1177        ) -> fidl::Result<()> {
1178            decoder.debug_check_bounds::<Self>(offset);
1179            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1180                None => return Err(fidl::Error::NotNullable),
1181                Some(len) => len,
1182            };
1183            // Calling decoder.out_of_line_offset(0) is not allowed.
1184            if len == 0 {
1185                return Ok(());
1186            };
1187            depth.increment()?;
1188            let envelope_size = 8;
1189            let bytes_len = len * envelope_size;
1190            let offset = decoder.out_of_line_offset(bytes_len)?;
1191            // Decode the envelope for each type.
1192            let mut _next_ordinal_to_read = 0;
1193            let mut next_offset = offset;
1194            let end_offset = offset + bytes_len;
1195            _next_ordinal_to_read += 1;
1196            if next_offset >= end_offset {
1197                return Ok(());
1198            }
1199
1200            // Decode unknown envelopes for gaps in ordinals.
1201            while _next_ordinal_to_read < 1 {
1202                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1203                _next_ordinal_to_read += 1;
1204                next_offset += envelope_size;
1205            }
1206
1207            let next_out_of_line = decoder.next_out_of_line();
1208            let handles_before = decoder.remaining_handles();
1209            if let Some((inlined, num_bytes, num_handles)) =
1210                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1211            {
1212                let member_inline_size =
1213                    <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1214                if inlined != (member_inline_size <= 4) {
1215                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1216                }
1217                let inner_offset;
1218                let mut inner_depth = depth.clone();
1219                if inlined {
1220                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1221                    inner_offset = next_offset;
1222                } else {
1223                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1224                    inner_depth.increment()?;
1225                }
1226                let val_ref = self.network.get_or_insert_with(|| {
1227                    fidl::new_empty!(NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect)
1228                });
1229                fidl::decode!(
1230                    NetworkToken,
1231                    fidl::encoding::DefaultFuchsiaResourceDialect,
1232                    val_ref,
1233                    decoder,
1234                    inner_offset,
1235                    inner_depth
1236                )?;
1237                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1238                {
1239                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1240                }
1241                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1242                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1243                }
1244            }
1245
1246            next_offset += envelope_size;
1247            _next_ordinal_to_read += 1;
1248            if next_offset >= end_offset {
1249                return Ok(());
1250            }
1251
1252            // Decode unknown envelopes for gaps in ordinals.
1253            while _next_ordinal_to_read < 2 {
1254                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1255                _next_ordinal_to_read += 1;
1256                next_offset += envelope_size;
1257            }
1258
1259            let next_out_of_line = decoder.next_out_of_line();
1260            let handles_before = decoder.remaining_handles();
1261            if let Some((inlined, num_bytes, num_handles)) =
1262                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1263            {
1264                let member_inline_size = <fidl::encoding::UnboundedVector<Property> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1265                if inlined != (member_inline_size <= 4) {
1266                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1267                }
1268                let inner_offset;
1269                let mut inner_depth = depth.clone();
1270                if inlined {
1271                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1272                    inner_offset = next_offset;
1273                } else {
1274                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1275                    inner_depth.increment()?;
1276                }
1277                let val_ref = self.properties.get_or_insert_with(|| {
1278                    fidl::new_empty!(
1279                        fidl::encoding::UnboundedVector<Property>,
1280                        fidl::encoding::DefaultFuchsiaResourceDialect
1281                    )
1282                });
1283                fidl::decode!(
1284                    fidl::encoding::UnboundedVector<Property>,
1285                    fidl::encoding::DefaultFuchsiaResourceDialect,
1286                    val_ref,
1287                    decoder,
1288                    inner_offset,
1289                    inner_depth
1290                )?;
1291                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1292                {
1293                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1294                }
1295                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1296                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1297                }
1298            }
1299
1300            next_offset += envelope_size;
1301
1302            // Decode the remaining unknown envelopes.
1303            while next_offset < end_offset {
1304                _next_ordinal_to_read += 1;
1305                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1306                next_offset += envelope_size;
1307            }
1308
1309            Ok(())
1310        }
1311    }
1312
1313    impl fidl::encoding::ResourceTypeMarker for NetworksWatchDefaultResponse {
1314        type Borrowed<'a> = &'a mut Self;
1315        fn take_or_borrow<'a>(
1316            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1317        ) -> Self::Borrowed<'a> {
1318            value
1319        }
1320    }
1321
1322    unsafe impl fidl::encoding::TypeMarker for NetworksWatchDefaultResponse {
1323        type Owned = Self;
1324
1325        #[inline(always)]
1326        fn inline_align(_context: fidl::encoding::Context) -> usize {
1327            8
1328        }
1329
1330        #[inline(always)]
1331        fn inline_size(_context: fidl::encoding::Context) -> usize {
1332            16
1333        }
1334    }
1335
1336    unsafe impl
1337        fidl::encoding::Encode<
1338            NetworksWatchDefaultResponse,
1339            fidl::encoding::DefaultFuchsiaResourceDialect,
1340        > for &mut NetworksWatchDefaultResponse
1341    {
1342        #[inline]
1343        unsafe fn encode(
1344            self,
1345            encoder: &mut fidl::encoding::Encoder<
1346                '_,
1347                fidl::encoding::DefaultFuchsiaResourceDialect,
1348            >,
1349            offset: usize,
1350            _depth: fidl::encoding::Depth,
1351        ) -> fidl::Result<()> {
1352            encoder.debug_check_bounds::<NetworksWatchDefaultResponse>(offset);
1353            encoder.write_num::<u64>(self.ordinal(), offset);
1354            match self {
1355                NetworksWatchDefaultResponse::Network(ref mut val) => {
1356                    fidl::encoding::encode_in_envelope::<
1357                        NetworkToken,
1358                        fidl::encoding::DefaultFuchsiaResourceDialect,
1359                    >(
1360                        <NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1361                        encoder,
1362                        offset + 8,
1363                        _depth,
1364                    )
1365                }
1366                NetworksWatchDefaultResponse::NoDefaultNetwork(ref val) => {
1367                    fidl::encoding::encode_in_envelope::<
1368                        Empty,
1369                        fidl::encoding::DefaultFuchsiaResourceDialect,
1370                    >(
1371                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
1372                        encoder,
1373                        offset + 8,
1374                        _depth,
1375                    )
1376                }
1377                NetworksWatchDefaultResponse::__SourceBreaking { .. } => {
1378                    Err(fidl::Error::UnknownUnionTag)
1379                }
1380            }
1381        }
1382    }
1383
1384    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1385        for NetworksWatchDefaultResponse
1386    {
1387        #[inline(always)]
1388        fn new_empty() -> Self {
1389            Self::__SourceBreaking { unknown_ordinal: 0 }
1390        }
1391
1392        #[inline]
1393        unsafe fn decode(
1394            &mut self,
1395            decoder: &mut fidl::encoding::Decoder<
1396                '_,
1397                fidl::encoding::DefaultFuchsiaResourceDialect,
1398            >,
1399            offset: usize,
1400            mut depth: fidl::encoding::Depth,
1401        ) -> fidl::Result<()> {
1402            decoder.debug_check_bounds::<Self>(offset);
1403            #[allow(unused_variables)]
1404            let next_out_of_line = decoder.next_out_of_line();
1405            let handles_before = decoder.remaining_handles();
1406            let (ordinal, inlined, num_bytes, num_handles) =
1407                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1408
1409            let member_inline_size = match ordinal {
1410                1 => <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1411                2 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1412                0 => return Err(fidl::Error::UnknownUnionTag),
1413                _ => num_bytes as usize,
1414            };
1415
1416            if inlined != (member_inline_size <= 4) {
1417                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1418            }
1419            let _inner_offset;
1420            if inlined {
1421                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1422                _inner_offset = offset + 8;
1423            } else {
1424                depth.increment()?;
1425                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1426            }
1427            match ordinal {
1428                1 => {
1429                    #[allow(irrefutable_let_patterns)]
1430                    if let NetworksWatchDefaultResponse::Network(_) = self {
1431                        // Do nothing, read the value into the object
1432                    } else {
1433                        // Initialize `self` to the right variant
1434                        *self = NetworksWatchDefaultResponse::Network(fidl::new_empty!(
1435                            NetworkToken,
1436                            fidl::encoding::DefaultFuchsiaResourceDialect
1437                        ));
1438                    }
1439                    #[allow(irrefutable_let_patterns)]
1440                    if let NetworksWatchDefaultResponse::Network(ref mut val) = self {
1441                        fidl::decode!(
1442                            NetworkToken,
1443                            fidl::encoding::DefaultFuchsiaResourceDialect,
1444                            val,
1445                            decoder,
1446                            _inner_offset,
1447                            depth
1448                        )?;
1449                    } else {
1450                        unreachable!()
1451                    }
1452                }
1453                2 => {
1454                    #[allow(irrefutable_let_patterns)]
1455                    if let NetworksWatchDefaultResponse::NoDefaultNetwork(_) = self {
1456                        // Do nothing, read the value into the object
1457                    } else {
1458                        // Initialize `self` to the right variant
1459                        *self = NetworksWatchDefaultResponse::NoDefaultNetwork(fidl::new_empty!(
1460                            Empty,
1461                            fidl::encoding::DefaultFuchsiaResourceDialect
1462                        ));
1463                    }
1464                    #[allow(irrefutable_let_patterns)]
1465                    if let NetworksWatchDefaultResponse::NoDefaultNetwork(ref mut val) = self {
1466                        fidl::decode!(
1467                            Empty,
1468                            fidl::encoding::DefaultFuchsiaResourceDialect,
1469                            val,
1470                            decoder,
1471                            _inner_offset,
1472                            depth
1473                        )?;
1474                    } else {
1475                        unreachable!()
1476                    }
1477                }
1478                #[allow(deprecated)]
1479                ordinal => {
1480                    for _ in 0..num_handles {
1481                        decoder.drop_next_handle()?;
1482                    }
1483                    *self =
1484                        NetworksWatchDefaultResponse::__SourceBreaking { unknown_ordinal: ordinal };
1485                }
1486            }
1487            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1488                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1489            }
1490            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1491                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1492            }
1493            Ok(())
1494        }
1495    }
1496}