Skip to main content

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 this service that represents a
15/// logical network for the purpose of accessing network properties.
16#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
17pub struct NetworkToken {
18    pub value: fidl::EventPair,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NetworkToken {}
22
23#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
24pub struct NetworkTokenResolverResolveTokenRequest {
25    pub token: NetworkToken,
26}
27
28impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
29    for NetworkTokenResolverResolveTokenRequest
30{
31}
32
33#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct NetworkTokenResolverResolveTokenResponse {
35    /// The resolved token, it represents a specific logical network,
36    /// regardless of if that network happens to be the current default
37    /// network.
38    pub resolved_token: NetworkToken,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
42    for NetworkTokenResolverResolveTokenResponse
43{
44}
45
46#[derive(Debug, Default, PartialEq)]
47pub struct NetworksWatchPropertiesRequest {
48    /// A network token acquired from [`WatchDefault`].
49    /// NOTE: REQUIRED
50    pub network: Option<NetworkToken>,
51    /// List of properties for which changes should be reported. Must be
52    /// non-empty, duplicates will be ignored.
53    /// NOTE: REQUIRED
54    pub properties: Option<Vec<Property>>,
55    #[doc(hidden)]
56    pub __source_breaking: fidl::marker::SourceBreaking,
57}
58
59impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
60    for NetworksWatchPropertiesRequest
61{
62}
63
64#[derive(Debug)]
65pub enum NetworksWatchDefaultResponse {
66    Network(NetworkToken),
67    NoDefaultNetwork(Empty),
68    #[doc(hidden)]
69    __SourceBreaking {
70        unknown_ordinal: u64,
71    },
72}
73
74/// Pattern that matches an unknown `NetworksWatchDefaultResponse` member.
75#[macro_export]
76macro_rules! NetworksWatchDefaultResponseUnknown {
77    () => {
78        _
79    };
80}
81
82// Custom PartialEq so that unknown variants are not equal to themselves.
83impl PartialEq for NetworksWatchDefaultResponse {
84    fn eq(&self, other: &Self) -> bool {
85        match (self, other) {
86            (Self::Network(x), Self::Network(y)) => *x == *y,
87            (Self::NoDefaultNetwork(x), Self::NoDefaultNetwork(y)) => *x == *y,
88            _ => false,
89        }
90    }
91}
92
93impl NetworksWatchDefaultResponse {
94    #[inline]
95    pub fn ordinal(&self) -> u64 {
96        match *self {
97            Self::Network(_) => 1,
98            Self::NoDefaultNetwork(_) => 2,
99            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
100        }
101    }
102
103    #[inline]
104    pub fn unknown_variant_for_testing() -> Self {
105        Self::__SourceBreaking { unknown_ordinal: 0 }
106    }
107
108    #[inline]
109    pub fn is_unknown(&self) -> bool {
110        match self {
111            Self::__SourceBreaking { .. } => true,
112            _ => false,
113        }
114    }
115}
116
117impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
118    for NetworksWatchDefaultResponse
119{
120}
121
122#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
123pub struct NetworkTokenResolverMarker;
124
125impl fidl::endpoints::ProtocolMarker for NetworkTokenResolverMarker {
126    type Proxy = NetworkTokenResolverProxy;
127    type RequestStream = NetworkTokenResolverRequestStream;
128    #[cfg(target_os = "fuchsia")]
129    type SynchronousProxy = NetworkTokenResolverSynchronousProxy;
130
131    const DEBUG_NAME: &'static str = "fuchsia.net.policy.properties.NetworkTokenResolver";
132}
133impl fidl::endpoints::DiscoverableProtocolMarker for NetworkTokenResolverMarker {}
134pub type NetworkTokenResolverResolveTokenResult =
135    Result<NetworkToken, NetworkTokenResolverResolveTokenError>;
136
137pub trait NetworkTokenResolverProxyInterface: Send + Sync {
138    type ResolveTokenResponseFut: std::future::Future<Output = Result<NetworkTokenResolverResolveTokenResult, fidl::Error>>
139        + Send;
140    fn r#resolve_token(&self, token: NetworkToken) -> Self::ResolveTokenResponseFut;
141}
142#[derive(Debug)]
143#[cfg(target_os = "fuchsia")]
144pub struct NetworkTokenResolverSynchronousProxy {
145    client: fidl::client::sync::Client,
146}
147
148#[cfg(target_os = "fuchsia")]
149impl fidl::endpoints::SynchronousProxy for NetworkTokenResolverSynchronousProxy {
150    type Proxy = NetworkTokenResolverProxy;
151    type Protocol = NetworkTokenResolverMarker;
152
153    fn from_channel(inner: fidl::Channel) -> Self {
154        Self::new(inner)
155    }
156
157    fn into_channel(self) -> fidl::Channel {
158        self.client.into_channel()
159    }
160
161    fn as_channel(&self) -> &fidl::Channel {
162        self.client.as_channel()
163    }
164}
165
166#[cfg(target_os = "fuchsia")]
167impl NetworkTokenResolverSynchronousProxy {
168    pub fn new(channel: fidl::Channel) -> Self {
169        let protocol_name =
170            <NetworkTokenResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
171        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
172    }
173
174    pub fn into_channel(self) -> fidl::Channel {
175        self.client.into_channel()
176    }
177
178    /// Waits until an event arrives and returns it. It is safe for other
179    /// threads to make concurrent requests while waiting for an event.
180    pub fn wait_for_event(
181        &self,
182        deadline: zx::MonotonicInstant,
183    ) -> Result<NetworkTokenResolverEvent, fidl::Error> {
184        NetworkTokenResolverEvent::decode(self.client.wait_for_event(deadline)?)
185    }
186
187    /// Resolves a network token to a canonical form.
188    ///
189    /// Since a "default network" network token is a distinct token from the
190    /// non-default network variant, there needs to be a way to disambiguate
191    /// the pair.
192    ///
193    /// Since a "default network" token (i.e. a token obtained from
194    /// [`Networks.WatchDefault`]) is a distinct token from the non-default
195    /// network variant, there needs to be a way to disambiguate the pair. If a
196    /// non-default network token is passed, the same token is returned.
197    pub fn r#resolve_token(
198        &self,
199        mut token: NetworkToken,
200        ___deadline: zx::MonotonicInstant,
201    ) -> Result<NetworkTokenResolverResolveTokenResult, fidl::Error> {
202        let _response = self
203            .client
204            .send_query::<NetworkTokenResolverResolveTokenRequest, fidl::encoding::ResultType<
205                NetworkTokenResolverResolveTokenResponse,
206                NetworkTokenResolverResolveTokenError,
207            >>(
208                (&mut token,),
209                0x4176f67517941bac,
210                fidl::encoding::DynamicFlags::empty(),
211                ___deadline,
212            )?;
213        Ok(_response.map(|x| x.resolved_token))
214    }
215}
216
217#[cfg(target_os = "fuchsia")]
218impl From<NetworkTokenResolverSynchronousProxy> for zx::NullableHandle {
219    fn from(value: NetworkTokenResolverSynchronousProxy) -> Self {
220        value.into_channel().into()
221    }
222}
223
224#[cfg(target_os = "fuchsia")]
225impl From<fidl::Channel> for NetworkTokenResolverSynchronousProxy {
226    fn from(value: fidl::Channel) -> Self {
227        Self::new(value)
228    }
229}
230
231#[cfg(target_os = "fuchsia")]
232impl fidl::endpoints::FromClient for NetworkTokenResolverSynchronousProxy {
233    type Protocol = NetworkTokenResolverMarker;
234
235    fn from_client(value: fidl::endpoints::ClientEnd<NetworkTokenResolverMarker>) -> Self {
236        Self::new(value.into_channel())
237    }
238}
239
240#[derive(Debug, Clone)]
241pub struct NetworkTokenResolverProxy {
242    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
243}
244
245impl fidl::endpoints::Proxy for NetworkTokenResolverProxy {
246    type Protocol = NetworkTokenResolverMarker;
247
248    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
249        Self::new(inner)
250    }
251
252    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
253        self.client.into_channel().map_err(|client| Self { client })
254    }
255
256    fn as_channel(&self) -> &::fidl::AsyncChannel {
257        self.client.as_channel()
258    }
259}
260
261impl NetworkTokenResolverProxy {
262    /// Create a new Proxy for fuchsia.net.policy.properties/NetworkTokenResolver.
263    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
264        let protocol_name =
265            <NetworkTokenResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
266        Self { client: fidl::client::Client::new(channel, protocol_name) }
267    }
268
269    /// Get a Stream of events from the remote end of the protocol.
270    ///
271    /// # Panics
272    ///
273    /// Panics if the event stream was already taken.
274    pub fn take_event_stream(&self) -> NetworkTokenResolverEventStream {
275        NetworkTokenResolverEventStream { event_receiver: self.client.take_event_receiver() }
276    }
277
278    /// Resolves a network token to a canonical form.
279    ///
280    /// Since a "default network" network token is a distinct token from the
281    /// non-default network variant, there needs to be a way to disambiguate
282    /// the pair.
283    ///
284    /// Since a "default network" token (i.e. a token obtained from
285    /// [`Networks.WatchDefault`]) is a distinct token from the non-default
286    /// network variant, there needs to be a way to disambiguate the pair. If a
287    /// non-default network token is passed, the same token is returned.
288    pub fn r#resolve_token(
289        &self,
290        mut token: NetworkToken,
291    ) -> fidl::client::QueryResponseFut<
292        NetworkTokenResolverResolveTokenResult,
293        fidl::encoding::DefaultFuchsiaResourceDialect,
294    > {
295        NetworkTokenResolverProxyInterface::r#resolve_token(self, token)
296    }
297}
298
299impl NetworkTokenResolverProxyInterface for NetworkTokenResolverProxy {
300    type ResolveTokenResponseFut = fidl::client::QueryResponseFut<
301        NetworkTokenResolverResolveTokenResult,
302        fidl::encoding::DefaultFuchsiaResourceDialect,
303    >;
304    fn r#resolve_token(&self, mut token: NetworkToken) -> Self::ResolveTokenResponseFut {
305        fn _decode(
306            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
307        ) -> Result<NetworkTokenResolverResolveTokenResult, fidl::Error> {
308            let _response = fidl::client::decode_transaction_body::<
309                fidl::encoding::ResultType<
310                    NetworkTokenResolverResolveTokenResponse,
311                    NetworkTokenResolverResolveTokenError,
312                >,
313                fidl::encoding::DefaultFuchsiaResourceDialect,
314                0x4176f67517941bac,
315            >(_buf?)?;
316            Ok(_response.map(|x| x.resolved_token))
317        }
318        self.client.send_query_and_decode::<
319            NetworkTokenResolverResolveTokenRequest,
320            NetworkTokenResolverResolveTokenResult,
321        >(
322            (&mut token,),
323            0x4176f67517941bac,
324            fidl::encoding::DynamicFlags::empty(),
325            _decode,
326        )
327    }
328}
329
330pub struct NetworkTokenResolverEventStream {
331    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
332}
333
334impl std::marker::Unpin for NetworkTokenResolverEventStream {}
335
336impl futures::stream::FusedStream for NetworkTokenResolverEventStream {
337    fn is_terminated(&self) -> bool {
338        self.event_receiver.is_terminated()
339    }
340}
341
342impl futures::Stream for NetworkTokenResolverEventStream {
343    type Item = Result<NetworkTokenResolverEvent, fidl::Error>;
344
345    fn poll_next(
346        mut self: std::pin::Pin<&mut Self>,
347        cx: &mut std::task::Context<'_>,
348    ) -> std::task::Poll<Option<Self::Item>> {
349        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
350            &mut self.event_receiver,
351            cx
352        )?) {
353            Some(buf) => std::task::Poll::Ready(Some(NetworkTokenResolverEvent::decode(buf))),
354            None => std::task::Poll::Ready(None),
355        }
356    }
357}
358
359#[derive(Debug)]
360pub enum NetworkTokenResolverEvent {
361    #[non_exhaustive]
362    _UnknownEvent {
363        /// Ordinal of the event that was sent.
364        ordinal: u64,
365    },
366}
367
368impl NetworkTokenResolverEvent {
369    /// Decodes a message buffer as a [`NetworkTokenResolverEvent`].
370    fn decode(
371        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
372    ) -> Result<NetworkTokenResolverEvent, fidl::Error> {
373        let (bytes, _handles) = buf.split_mut();
374        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
375        debug_assert_eq!(tx_header.tx_id, 0);
376        match tx_header.ordinal {
377            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
378                Ok(NetworkTokenResolverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
379            }
380            _ => Err(fidl::Error::UnknownOrdinal {
381                ordinal: tx_header.ordinal,
382                protocol_name:
383                    <NetworkTokenResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
384            }),
385        }
386    }
387}
388
389/// A Stream of incoming requests for fuchsia.net.policy.properties/NetworkTokenResolver.
390pub struct NetworkTokenResolverRequestStream {
391    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
392    is_terminated: bool,
393}
394
395impl std::marker::Unpin for NetworkTokenResolverRequestStream {}
396
397impl futures::stream::FusedStream for NetworkTokenResolverRequestStream {
398    fn is_terminated(&self) -> bool {
399        self.is_terminated
400    }
401}
402
403impl fidl::endpoints::RequestStream for NetworkTokenResolverRequestStream {
404    type Protocol = NetworkTokenResolverMarker;
405    type ControlHandle = NetworkTokenResolverControlHandle;
406
407    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
408        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
409    }
410
411    fn control_handle(&self) -> Self::ControlHandle {
412        NetworkTokenResolverControlHandle { inner: self.inner.clone() }
413    }
414
415    fn into_inner(
416        self,
417    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
418    {
419        (self.inner, self.is_terminated)
420    }
421
422    fn from_inner(
423        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
424        is_terminated: bool,
425    ) -> Self {
426        Self { inner, is_terminated }
427    }
428}
429
430impl futures::Stream for NetworkTokenResolverRequestStream {
431    type Item = Result<NetworkTokenResolverRequest, fidl::Error>;
432
433    fn poll_next(
434        mut self: std::pin::Pin<&mut Self>,
435        cx: &mut std::task::Context<'_>,
436    ) -> std::task::Poll<Option<Self::Item>> {
437        let this = &mut *self;
438        if this.inner.check_shutdown(cx) {
439            this.is_terminated = true;
440            return std::task::Poll::Ready(None);
441        }
442        if this.is_terminated {
443            panic!("polled NetworkTokenResolverRequestStream after completion");
444        }
445        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
446            |bytes, handles| {
447                match this.inner.channel().read_etc(cx, bytes, handles) {
448                    std::task::Poll::Ready(Ok(())) => {}
449                    std::task::Poll::Pending => return std::task::Poll::Pending,
450                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
451                        this.is_terminated = true;
452                        return std::task::Poll::Ready(None);
453                    }
454                    std::task::Poll::Ready(Err(e)) => {
455                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
456                            e.into(),
457                        ))));
458                    }
459                }
460
461                // A message has been received from the channel
462                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
463
464                std::task::Poll::Ready(Some(match header.ordinal {
465                0x4176f67517941bac => {
466                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
467                    let mut req = fidl::new_empty!(NetworkTokenResolverResolveTokenRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
468                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkTokenResolverResolveTokenRequest>(&header, _body_bytes, handles, &mut req)?;
469                    let control_handle = NetworkTokenResolverControlHandle {
470                        inner: this.inner.clone(),
471                    };
472                    Ok(NetworkTokenResolverRequest::ResolveToken {token: req.token,
473
474                        responder: NetworkTokenResolverResolveTokenResponder {
475                            control_handle: std::mem::ManuallyDrop::new(control_handle),
476                            tx_id: header.tx_id,
477                        },
478                    })
479                }
480                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
481                    Ok(NetworkTokenResolverRequest::_UnknownMethod {
482                        ordinal: header.ordinal,
483                        control_handle: NetworkTokenResolverControlHandle { inner: this.inner.clone() },
484                        method_type: fidl::MethodType::OneWay,
485                    })
486                }
487                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
488                    this.inner.send_framework_err(
489                        fidl::encoding::FrameworkErr::UnknownMethod,
490                        header.tx_id,
491                        header.ordinal,
492                        header.dynamic_flags(),
493                        (bytes, handles),
494                    )?;
495                    Ok(NetworkTokenResolverRequest::_UnknownMethod {
496                        ordinal: header.ordinal,
497                        control_handle: NetworkTokenResolverControlHandle { inner: this.inner.clone() },
498                        method_type: fidl::MethodType::TwoWay,
499                    })
500                }
501                _ => Err(fidl::Error::UnknownOrdinal {
502                    ordinal: header.ordinal,
503                    protocol_name: <NetworkTokenResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
504                }),
505            }))
506            },
507        )
508    }
509}
510
511/// Protocol to allow operations on `NetworkToken` objects, including resolving
512/// `NetworkToken` to its canonical form.
513#[derive(Debug)]
514pub enum NetworkTokenResolverRequest {
515    /// Resolves a network token to a canonical form.
516    ///
517    /// Since a "default network" network token is a distinct token from the
518    /// non-default network variant, there needs to be a way to disambiguate
519    /// the pair.
520    ///
521    /// Since a "default network" token (i.e. a token obtained from
522    /// [`Networks.WatchDefault`]) is a distinct token from the non-default
523    /// network variant, there needs to be a way to disambiguate the pair. If a
524    /// non-default network token is passed, the same token is returned.
525    ResolveToken { token: NetworkToken, responder: NetworkTokenResolverResolveTokenResponder },
526    /// An interaction was received which does not match any known method.
527    #[non_exhaustive]
528    _UnknownMethod {
529        /// Ordinal of the method that was called.
530        ordinal: u64,
531        control_handle: NetworkTokenResolverControlHandle,
532        method_type: fidl::MethodType,
533    },
534}
535
536impl NetworkTokenResolverRequest {
537    #[allow(irrefutable_let_patterns)]
538    pub fn into_resolve_token(
539        self,
540    ) -> Option<(NetworkToken, NetworkTokenResolverResolveTokenResponder)> {
541        if let NetworkTokenResolverRequest::ResolveToken { token, responder } = self {
542            Some((token, responder))
543        } else {
544            None
545        }
546    }
547
548    /// Name of the method defined in FIDL
549    pub fn method_name(&self) -> &'static str {
550        match *self {
551            NetworkTokenResolverRequest::ResolveToken { .. } => "resolve_token",
552            NetworkTokenResolverRequest::_UnknownMethod {
553                method_type: fidl::MethodType::OneWay,
554                ..
555            } => "unknown one-way method",
556            NetworkTokenResolverRequest::_UnknownMethod {
557                method_type: fidl::MethodType::TwoWay,
558                ..
559            } => "unknown two-way method",
560        }
561    }
562}
563
564#[derive(Debug, Clone)]
565pub struct NetworkTokenResolverControlHandle {
566    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
567}
568
569impl fidl::endpoints::ControlHandle for NetworkTokenResolverControlHandle {
570    fn shutdown(&self) {
571        self.inner.shutdown()
572    }
573
574    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
575        self.inner.shutdown_with_epitaph(status)
576    }
577
578    fn is_closed(&self) -> bool {
579        self.inner.channel().is_closed()
580    }
581    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
582        self.inner.channel().on_closed()
583    }
584
585    #[cfg(target_os = "fuchsia")]
586    fn signal_peer(
587        &self,
588        clear_mask: zx::Signals,
589        set_mask: zx::Signals,
590    ) -> Result<(), zx_status::Status> {
591        use fidl::Peered;
592        self.inner.channel().signal_peer(clear_mask, set_mask)
593    }
594}
595
596impl NetworkTokenResolverControlHandle {}
597
598#[must_use = "FIDL methods require a response to be sent"]
599#[derive(Debug)]
600pub struct NetworkTokenResolverResolveTokenResponder {
601    control_handle: std::mem::ManuallyDrop<NetworkTokenResolverControlHandle>,
602    tx_id: u32,
603}
604
605/// Set the the channel to be shutdown (see [`NetworkTokenResolverControlHandle::shutdown`])
606/// if the responder is dropped without sending a response, so that the client
607/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
608impl std::ops::Drop for NetworkTokenResolverResolveTokenResponder {
609    fn drop(&mut self) {
610        self.control_handle.shutdown();
611        // Safety: drops once, never accessed again
612        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
613    }
614}
615
616impl fidl::endpoints::Responder for NetworkTokenResolverResolveTokenResponder {
617    type ControlHandle = NetworkTokenResolverControlHandle;
618
619    fn control_handle(&self) -> &NetworkTokenResolverControlHandle {
620        &self.control_handle
621    }
622
623    fn drop_without_shutdown(mut self) {
624        // Safety: drops once, never accessed again due to mem::forget
625        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
626        // Prevent Drop from running (which would shut down the channel)
627        std::mem::forget(self);
628    }
629}
630
631impl NetworkTokenResolverResolveTokenResponder {
632    /// Sends a response to the FIDL transaction.
633    ///
634    /// Sets the channel to shutdown if an error occurs.
635    pub fn send(
636        self,
637        mut result: Result<NetworkToken, NetworkTokenResolverResolveTokenError>,
638    ) -> Result<(), fidl::Error> {
639        let _result = self.send_raw(result);
640        if _result.is_err() {
641            self.control_handle.shutdown();
642        }
643        self.drop_without_shutdown();
644        _result
645    }
646
647    /// Similar to "send" but does not shutdown the channel if an error occurs.
648    pub fn send_no_shutdown_on_err(
649        self,
650        mut result: Result<NetworkToken, NetworkTokenResolverResolveTokenError>,
651    ) -> Result<(), fidl::Error> {
652        let _result = self.send_raw(result);
653        self.drop_without_shutdown();
654        _result
655    }
656
657    fn send_raw(
658        &self,
659        mut result: Result<NetworkToken, NetworkTokenResolverResolveTokenError>,
660    ) -> Result<(), fidl::Error> {
661        self.control_handle.inner.send::<fidl::encoding::ResultType<
662            NetworkTokenResolverResolveTokenResponse,
663            NetworkTokenResolverResolveTokenError,
664        >>(
665            result.as_mut().map_err(|e| *e).map(|resolved_token| (resolved_token,)),
666            self.tx_id,
667            0x4176f67517941bac,
668            fidl::encoding::DynamicFlags::empty(),
669        )
670    }
671}
672
673#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
674pub struct NetworksMarker;
675
676impl fidl::endpoints::ProtocolMarker for NetworksMarker {
677    type Proxy = NetworksProxy;
678    type RequestStream = NetworksRequestStream;
679    #[cfg(target_os = "fuchsia")]
680    type SynchronousProxy = NetworksSynchronousProxy;
681
682    const DEBUG_NAME: &'static str = "fuchsia.net.policy.properties.Networks";
683}
684impl fidl::endpoints::DiscoverableProtocolMarker for NetworksMarker {}
685pub type NetworksWatchPropertiesResult = Result<Vec<PropertyUpdate>, WatchError>;
686
687pub trait NetworksProxyInterface: Send + Sync {
688    type WatchDefaultResponseFut: std::future::Future<Output = Result<NetworksWatchDefaultResponse, fidl::Error>>
689        + Send;
690    fn r#watch_default(&self) -> Self::WatchDefaultResponseFut;
691    type WatchPropertiesResponseFut: std::future::Future<Output = Result<NetworksWatchPropertiesResult, fidl::Error>>
692        + Send;
693    fn r#watch_properties(
694        &self,
695        payload: NetworksWatchPropertiesRequest,
696    ) -> Self::WatchPropertiesResponseFut;
697}
698#[derive(Debug)]
699#[cfg(target_os = "fuchsia")]
700pub struct NetworksSynchronousProxy {
701    client: fidl::client::sync::Client,
702}
703
704#[cfg(target_os = "fuchsia")]
705impl fidl::endpoints::SynchronousProxy for NetworksSynchronousProxy {
706    type Proxy = NetworksProxy;
707    type Protocol = NetworksMarker;
708
709    fn from_channel(inner: fidl::Channel) -> Self {
710        Self::new(inner)
711    }
712
713    fn into_channel(self) -> fidl::Channel {
714        self.client.into_channel()
715    }
716
717    fn as_channel(&self) -> &fidl::Channel {
718        self.client.as_channel()
719    }
720}
721
722#[cfg(target_os = "fuchsia")]
723impl NetworksSynchronousProxy {
724    pub fn new(channel: fidl::Channel) -> Self {
725        let protocol_name = <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
726        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
727    }
728
729    pub fn into_channel(self) -> fidl::Channel {
730        self.client.into_channel()
731    }
732
733    /// Waits until an event arrives and returns it. It is safe for other
734    /// threads to make concurrent requests while waiting for an event.
735    pub fn wait_for_event(
736        &self,
737        deadline: zx::MonotonicInstant,
738    ) -> Result<NetworksEvent, fidl::Error> {
739        NetworksEvent::decode(self.client.wait_for_event(deadline)?)
740    }
741
742    /// Watches for changes in the default network.
743    ///
744    /// The first call always returns a [`NetworkToken`] representing the
745    /// current default network, or if one is not present, blocks until a
746    /// default network is set. Subsequent calls will block until the default
747    /// network has changed, or has been lost, returning a new [`NetworkToken`]
748    /// for the updated default network, or [`no_default_network`] if the
749    /// network is lost.
750    ///
751    /// Only one call to this method should be pending per connection.
752    pub fn r#watch_default(
753        &self,
754        ___deadline: zx::MonotonicInstant,
755    ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
756        let _response = self.client.send_query::<
757            fidl::encoding::EmptyPayload,
758            fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
759        >(
760            (),
761            0x346880b2d7db0f98,
762            fidl::encoding::DynamicFlags::FLEXIBLE,
763            ___deadline,
764        )?
765        .into_result::<NetworksMarker>("watch_default")?;
766        Ok(_response)
767    }
768
769    /// Watches for changes in requested properties for the given [`NetworkToken`]
770    ///
771    /// The first call will always return a snapshot of all requested
772    /// properties. Subsequent calls will block until any property changes, at
773    /// which point the changed property or properties will be sent. If the set
774    /// of requested [`properties`] changes on a subsequent call, the previously
775    /// unreported property will be sent immediately, before future calls will
776    /// return to the hanging get pattern. If the network represented by
777    /// `network` is no longer the default network, the connection will be
778    /// closed with `DEFAULT_NETWORK_CHANGED`.
779    ///
780    /// Only one call to this method should be pending per [`NetworkToken`] per connection.
781    pub fn r#watch_properties(
782        &self,
783        mut payload: NetworksWatchPropertiesRequest,
784        ___deadline: zx::MonotonicInstant,
785    ) -> Result<NetworksWatchPropertiesResult, fidl::Error> {
786        let _response = self.client.send_query::<
787            NetworksWatchPropertiesRequest,
788            fidl::encoding::FlexibleResultType<NetworksWatchPropertiesResponse, WatchError>,
789        >(
790            &mut payload,
791            0x24d2340905f7dcc6,
792            fidl::encoding::DynamicFlags::FLEXIBLE,
793            ___deadline,
794        )?
795        .into_result::<NetworksMarker>("watch_properties")?;
796        Ok(_response.map(|x| x.updates))
797    }
798}
799
800#[cfg(target_os = "fuchsia")]
801impl From<NetworksSynchronousProxy> for zx::NullableHandle {
802    fn from(value: NetworksSynchronousProxy) -> Self {
803        value.into_channel().into()
804    }
805}
806
807#[cfg(target_os = "fuchsia")]
808impl From<fidl::Channel> for NetworksSynchronousProxy {
809    fn from(value: fidl::Channel) -> Self {
810        Self::new(value)
811    }
812}
813
814#[cfg(target_os = "fuchsia")]
815impl fidl::endpoints::FromClient for NetworksSynchronousProxy {
816    type Protocol = NetworksMarker;
817
818    fn from_client(value: fidl::endpoints::ClientEnd<NetworksMarker>) -> Self {
819        Self::new(value.into_channel())
820    }
821}
822
823#[derive(Debug, Clone)]
824pub struct NetworksProxy {
825    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
826}
827
828impl fidl::endpoints::Proxy for NetworksProxy {
829    type Protocol = NetworksMarker;
830
831    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
832        Self::new(inner)
833    }
834
835    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
836        self.client.into_channel().map_err(|client| Self { client })
837    }
838
839    fn as_channel(&self) -> &::fidl::AsyncChannel {
840        self.client.as_channel()
841    }
842}
843
844impl NetworksProxy {
845    /// Create a new Proxy for fuchsia.net.policy.properties/Networks.
846    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
847        let protocol_name = <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
848        Self { client: fidl::client::Client::new(channel, protocol_name) }
849    }
850
851    /// Get a Stream of events from the remote end of the protocol.
852    ///
853    /// # Panics
854    ///
855    /// Panics if the event stream was already taken.
856    pub fn take_event_stream(&self) -> NetworksEventStream {
857        NetworksEventStream { event_receiver: self.client.take_event_receiver() }
858    }
859
860    /// Watches for changes in the default network.
861    ///
862    /// The first call always returns a [`NetworkToken`] representing the
863    /// current default network, or if one is not present, blocks until a
864    /// default network is set. Subsequent calls will block until the default
865    /// network has changed, or has been lost, returning a new [`NetworkToken`]
866    /// for the updated default network, or [`no_default_network`] if the
867    /// network is lost.
868    ///
869    /// Only one call to this method should be pending per connection.
870    pub fn r#watch_default(
871        &self,
872    ) -> fidl::client::QueryResponseFut<
873        NetworksWatchDefaultResponse,
874        fidl::encoding::DefaultFuchsiaResourceDialect,
875    > {
876        NetworksProxyInterface::r#watch_default(self)
877    }
878
879    /// Watches for changes in requested properties for the given [`NetworkToken`]
880    ///
881    /// The first call will always return a snapshot of all requested
882    /// properties. Subsequent calls will block until any property changes, at
883    /// which point the changed property or properties will be sent. If the set
884    /// of requested [`properties`] changes on a subsequent call, the previously
885    /// unreported property will be sent immediately, before future calls will
886    /// return to the hanging get pattern. If the network represented by
887    /// `network` is no longer the default network, the connection will be
888    /// closed with `DEFAULT_NETWORK_CHANGED`.
889    ///
890    /// Only one call to this method should be pending per [`NetworkToken`] per connection.
891    pub fn r#watch_properties(
892        &self,
893        mut payload: NetworksWatchPropertiesRequest,
894    ) -> fidl::client::QueryResponseFut<
895        NetworksWatchPropertiesResult,
896        fidl::encoding::DefaultFuchsiaResourceDialect,
897    > {
898        NetworksProxyInterface::r#watch_properties(self, payload)
899    }
900}
901
902impl NetworksProxyInterface for NetworksProxy {
903    type WatchDefaultResponseFut = fidl::client::QueryResponseFut<
904        NetworksWatchDefaultResponse,
905        fidl::encoding::DefaultFuchsiaResourceDialect,
906    >;
907    fn r#watch_default(&self) -> Self::WatchDefaultResponseFut {
908        fn _decode(
909            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
910        ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
911            let _response = fidl::client::decode_transaction_body::<
912                fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
913                fidl::encoding::DefaultFuchsiaResourceDialect,
914                0x346880b2d7db0f98,
915            >(_buf?)?
916            .into_result::<NetworksMarker>("watch_default")?;
917            Ok(_response)
918        }
919        self.client
920            .send_query_and_decode::<fidl::encoding::EmptyPayload, NetworksWatchDefaultResponse>(
921                (),
922                0x346880b2d7db0f98,
923                fidl::encoding::DynamicFlags::FLEXIBLE,
924                _decode,
925            )
926    }
927
928    type WatchPropertiesResponseFut = fidl::client::QueryResponseFut<
929        NetworksWatchPropertiesResult,
930        fidl::encoding::DefaultFuchsiaResourceDialect,
931    >;
932    fn r#watch_properties(
933        &self,
934        mut payload: NetworksWatchPropertiesRequest,
935    ) -> Self::WatchPropertiesResponseFut {
936        fn _decode(
937            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
938        ) -> Result<NetworksWatchPropertiesResult, fidl::Error> {
939            let _response = fidl::client::decode_transaction_body::<
940                fidl::encoding::FlexibleResultType<NetworksWatchPropertiesResponse, WatchError>,
941                fidl::encoding::DefaultFuchsiaResourceDialect,
942                0x24d2340905f7dcc6,
943            >(_buf?)?
944            .into_result::<NetworksMarker>("watch_properties")?;
945            Ok(_response.map(|x| x.updates))
946        }
947        self.client
948            .send_query_and_decode::<NetworksWatchPropertiesRequest, NetworksWatchPropertiesResult>(
949                &mut payload,
950                0x24d2340905f7dcc6,
951                fidl::encoding::DynamicFlags::FLEXIBLE,
952                _decode,
953            )
954    }
955}
956
957pub struct NetworksEventStream {
958    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
959}
960
961impl std::marker::Unpin for NetworksEventStream {}
962
963impl futures::stream::FusedStream for NetworksEventStream {
964    fn is_terminated(&self) -> bool {
965        self.event_receiver.is_terminated()
966    }
967}
968
969impl futures::Stream for NetworksEventStream {
970    type Item = Result<NetworksEvent, fidl::Error>;
971
972    fn poll_next(
973        mut self: std::pin::Pin<&mut Self>,
974        cx: &mut std::task::Context<'_>,
975    ) -> std::task::Poll<Option<Self::Item>> {
976        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
977            &mut self.event_receiver,
978            cx
979        )?) {
980            Some(buf) => std::task::Poll::Ready(Some(NetworksEvent::decode(buf))),
981            None => std::task::Poll::Ready(None),
982        }
983    }
984}
985
986#[derive(Debug)]
987pub enum NetworksEvent {
988    #[non_exhaustive]
989    _UnknownEvent {
990        /// Ordinal of the event that was sent.
991        ordinal: u64,
992    },
993}
994
995impl NetworksEvent {
996    /// Decodes a message buffer as a [`NetworksEvent`].
997    fn decode(
998        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
999    ) -> Result<NetworksEvent, fidl::Error> {
1000        let (bytes, _handles) = buf.split_mut();
1001        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1002        debug_assert_eq!(tx_header.tx_id, 0);
1003        match tx_header.ordinal {
1004            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1005                Ok(NetworksEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1006            }
1007            _ => Err(fidl::Error::UnknownOrdinal {
1008                ordinal: tx_header.ordinal,
1009                protocol_name: <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1010            }),
1011        }
1012    }
1013}
1014
1015/// A Stream of incoming requests for fuchsia.net.policy.properties/Networks.
1016pub struct NetworksRequestStream {
1017    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1018    is_terminated: bool,
1019}
1020
1021impl std::marker::Unpin for NetworksRequestStream {}
1022
1023impl futures::stream::FusedStream for NetworksRequestStream {
1024    fn is_terminated(&self) -> bool {
1025        self.is_terminated
1026    }
1027}
1028
1029impl fidl::endpoints::RequestStream for NetworksRequestStream {
1030    type Protocol = NetworksMarker;
1031    type ControlHandle = NetworksControlHandle;
1032
1033    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1034        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1035    }
1036
1037    fn control_handle(&self) -> Self::ControlHandle {
1038        NetworksControlHandle { inner: self.inner.clone() }
1039    }
1040
1041    fn into_inner(
1042        self,
1043    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1044    {
1045        (self.inner, self.is_terminated)
1046    }
1047
1048    fn from_inner(
1049        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1050        is_terminated: bool,
1051    ) -> Self {
1052        Self { inner, is_terminated }
1053    }
1054}
1055
1056impl futures::Stream for NetworksRequestStream {
1057    type Item = Result<NetworksRequest, fidl::Error>;
1058
1059    fn poll_next(
1060        mut self: std::pin::Pin<&mut Self>,
1061        cx: &mut std::task::Context<'_>,
1062    ) -> std::task::Poll<Option<Self::Item>> {
1063        let this = &mut *self;
1064        if this.inner.check_shutdown(cx) {
1065            this.is_terminated = true;
1066            return std::task::Poll::Ready(None);
1067        }
1068        if this.is_terminated {
1069            panic!("polled NetworksRequestStream after completion");
1070        }
1071        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1072            |bytes, handles| {
1073                match this.inner.channel().read_etc(cx, bytes, handles) {
1074                    std::task::Poll::Ready(Ok(())) => {}
1075                    std::task::Poll::Pending => return std::task::Poll::Pending,
1076                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1077                        this.is_terminated = true;
1078                        return std::task::Poll::Ready(None);
1079                    }
1080                    std::task::Poll::Ready(Err(e)) => {
1081                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1082                            e.into(),
1083                        ))));
1084                    }
1085                }
1086
1087                // A message has been received from the channel
1088                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1089
1090                std::task::Poll::Ready(Some(match header.ordinal {
1091                    0x346880b2d7db0f98 => {
1092                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1093                        let mut req = fidl::new_empty!(
1094                            fidl::encoding::EmptyPayload,
1095                            fidl::encoding::DefaultFuchsiaResourceDialect
1096                        );
1097                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1098                        let control_handle = NetworksControlHandle { inner: this.inner.clone() };
1099                        Ok(NetworksRequest::WatchDefault {
1100                            responder: NetworksWatchDefaultResponder {
1101                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1102                                tx_id: header.tx_id,
1103                            },
1104                        })
1105                    }
1106                    0x24d2340905f7dcc6 => {
1107                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1108                        let mut req = fidl::new_empty!(
1109                            NetworksWatchPropertiesRequest,
1110                            fidl::encoding::DefaultFuchsiaResourceDialect
1111                        );
1112                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworksWatchPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
1113                        let control_handle = NetworksControlHandle { inner: this.inner.clone() };
1114                        Ok(NetworksRequest::WatchProperties {
1115                            payload: req,
1116                            responder: NetworksWatchPropertiesResponder {
1117                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1118                                tx_id: header.tx_id,
1119                            },
1120                        })
1121                    }
1122                    _ if header.tx_id == 0
1123                        && header
1124                            .dynamic_flags()
1125                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1126                    {
1127                        Ok(NetworksRequest::_UnknownMethod {
1128                            ordinal: header.ordinal,
1129                            control_handle: NetworksControlHandle { inner: this.inner.clone() },
1130                            method_type: fidl::MethodType::OneWay,
1131                        })
1132                    }
1133                    _ if header
1134                        .dynamic_flags()
1135                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1136                    {
1137                        this.inner.send_framework_err(
1138                            fidl::encoding::FrameworkErr::UnknownMethod,
1139                            header.tx_id,
1140                            header.ordinal,
1141                            header.dynamic_flags(),
1142                            (bytes, handles),
1143                        )?;
1144                        Ok(NetworksRequest::_UnknownMethod {
1145                            ordinal: header.ordinal,
1146                            control_handle: NetworksControlHandle { inner: this.inner.clone() },
1147                            method_type: fidl::MethodType::TwoWay,
1148                        })
1149                    }
1150                    _ => Err(fidl::Error::UnknownOrdinal {
1151                        ordinal: header.ordinal,
1152                        protocol_name:
1153                            <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1154                    }),
1155                }))
1156            },
1157        )
1158    }
1159}
1160
1161/// Protocol for acquiring [`NetworkToken`]s, and querying properties of that
1162/// network.
1163#[derive(Debug)]
1164pub enum NetworksRequest {
1165    /// Watches for changes in the default network.
1166    ///
1167    /// The first call always returns a [`NetworkToken`] representing the
1168    /// current default network, or if one is not present, blocks until a
1169    /// default network is set. Subsequent calls will block until the default
1170    /// network has changed, or has been lost, returning a new [`NetworkToken`]
1171    /// for the updated default network, or [`no_default_network`] if the
1172    /// network is lost.
1173    ///
1174    /// Only one call to this method should be pending per connection.
1175    WatchDefault { responder: NetworksWatchDefaultResponder },
1176    /// Watches for changes in requested properties for the given [`NetworkToken`]
1177    ///
1178    /// The first call will always return a snapshot of all requested
1179    /// properties. Subsequent calls will block until any property changes, at
1180    /// which point the changed property or properties will be sent. If the set
1181    /// of requested [`properties`] changes on a subsequent call, the previously
1182    /// unreported property will be sent immediately, before future calls will
1183    /// return to the hanging get pattern. If the network represented by
1184    /// `network` is no longer the default network, the connection will be
1185    /// closed with `DEFAULT_NETWORK_CHANGED`.
1186    ///
1187    /// Only one call to this method should be pending per [`NetworkToken`] per connection.
1188    WatchProperties {
1189        payload: NetworksWatchPropertiesRequest,
1190        responder: NetworksWatchPropertiesResponder,
1191    },
1192    /// An interaction was received which does not match any known method.
1193    #[non_exhaustive]
1194    _UnknownMethod {
1195        /// Ordinal of the method that was called.
1196        ordinal: u64,
1197        control_handle: NetworksControlHandle,
1198        method_type: fidl::MethodType,
1199    },
1200}
1201
1202impl NetworksRequest {
1203    #[allow(irrefutable_let_patterns)]
1204    pub fn into_watch_default(self) -> Option<(NetworksWatchDefaultResponder)> {
1205        if let NetworksRequest::WatchDefault { responder } = self {
1206            Some((responder))
1207        } else {
1208            None
1209        }
1210    }
1211
1212    #[allow(irrefutable_let_patterns)]
1213    pub fn into_watch_properties(
1214        self,
1215    ) -> Option<(NetworksWatchPropertiesRequest, NetworksWatchPropertiesResponder)> {
1216        if let NetworksRequest::WatchProperties { payload, responder } = self {
1217            Some((payload, responder))
1218        } else {
1219            None
1220        }
1221    }
1222
1223    /// Name of the method defined in FIDL
1224    pub fn method_name(&self) -> &'static str {
1225        match *self {
1226            NetworksRequest::WatchDefault { .. } => "watch_default",
1227            NetworksRequest::WatchProperties { .. } => "watch_properties",
1228            NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1229                "unknown one-way method"
1230            }
1231            NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1232                "unknown two-way method"
1233            }
1234        }
1235    }
1236}
1237
1238#[derive(Debug, Clone)]
1239pub struct NetworksControlHandle {
1240    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1241}
1242
1243impl fidl::endpoints::ControlHandle for NetworksControlHandle {
1244    fn shutdown(&self) {
1245        self.inner.shutdown()
1246    }
1247
1248    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1249        self.inner.shutdown_with_epitaph(status)
1250    }
1251
1252    fn is_closed(&self) -> bool {
1253        self.inner.channel().is_closed()
1254    }
1255    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1256        self.inner.channel().on_closed()
1257    }
1258
1259    #[cfg(target_os = "fuchsia")]
1260    fn signal_peer(
1261        &self,
1262        clear_mask: zx::Signals,
1263        set_mask: zx::Signals,
1264    ) -> Result<(), zx_status::Status> {
1265        use fidl::Peered;
1266        self.inner.channel().signal_peer(clear_mask, set_mask)
1267    }
1268}
1269
1270impl NetworksControlHandle {}
1271
1272#[must_use = "FIDL methods require a response to be sent"]
1273#[derive(Debug)]
1274pub struct NetworksWatchDefaultResponder {
1275    control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
1276    tx_id: u32,
1277}
1278
1279/// Set the the channel to be shutdown (see [`NetworksControlHandle::shutdown`])
1280/// if the responder is dropped without sending a response, so that the client
1281/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1282impl std::ops::Drop for NetworksWatchDefaultResponder {
1283    fn drop(&mut self) {
1284        self.control_handle.shutdown();
1285        // Safety: drops once, never accessed again
1286        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1287    }
1288}
1289
1290impl fidl::endpoints::Responder for NetworksWatchDefaultResponder {
1291    type ControlHandle = NetworksControlHandle;
1292
1293    fn control_handle(&self) -> &NetworksControlHandle {
1294        &self.control_handle
1295    }
1296
1297    fn drop_without_shutdown(mut self) {
1298        // Safety: drops once, never accessed again due to mem::forget
1299        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1300        // Prevent Drop from running (which would shut down the channel)
1301        std::mem::forget(self);
1302    }
1303}
1304
1305impl NetworksWatchDefaultResponder {
1306    /// Sends a response to the FIDL transaction.
1307    ///
1308    /// Sets the channel to shutdown if an error occurs.
1309    pub fn send(self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
1310        let _result = self.send_raw(payload);
1311        if _result.is_err() {
1312            self.control_handle.shutdown();
1313        }
1314        self.drop_without_shutdown();
1315        _result
1316    }
1317
1318    /// Similar to "send" but does not shutdown the channel if an error occurs.
1319    pub fn send_no_shutdown_on_err(
1320        self,
1321        mut payload: NetworksWatchDefaultResponse,
1322    ) -> Result<(), fidl::Error> {
1323        let _result = self.send_raw(payload);
1324        self.drop_without_shutdown();
1325        _result
1326    }
1327
1328    fn send_raw(&self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
1329        self.control_handle
1330            .inner
1331            .send::<fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>>(
1332                fidl::encoding::Flexible::new(&mut payload),
1333                self.tx_id,
1334                0x346880b2d7db0f98,
1335                fidl::encoding::DynamicFlags::FLEXIBLE,
1336            )
1337    }
1338}
1339
1340#[must_use = "FIDL methods require a response to be sent"]
1341#[derive(Debug)]
1342pub struct NetworksWatchPropertiesResponder {
1343    control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
1344    tx_id: u32,
1345}
1346
1347/// Set the the channel to be shutdown (see [`NetworksControlHandle::shutdown`])
1348/// if the responder is dropped without sending a response, so that the client
1349/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1350impl std::ops::Drop for NetworksWatchPropertiesResponder {
1351    fn drop(&mut self) {
1352        self.control_handle.shutdown();
1353        // Safety: drops once, never accessed again
1354        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1355    }
1356}
1357
1358impl fidl::endpoints::Responder for NetworksWatchPropertiesResponder {
1359    type ControlHandle = NetworksControlHandle;
1360
1361    fn control_handle(&self) -> &NetworksControlHandle {
1362        &self.control_handle
1363    }
1364
1365    fn drop_without_shutdown(mut self) {
1366        // Safety: drops once, never accessed again due to mem::forget
1367        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1368        // Prevent Drop from running (which would shut down the channel)
1369        std::mem::forget(self);
1370    }
1371}
1372
1373impl NetworksWatchPropertiesResponder {
1374    /// Sends a response to the FIDL transaction.
1375    ///
1376    /// Sets the channel to shutdown if an error occurs.
1377    pub fn send(
1378        self,
1379        mut result: Result<&[PropertyUpdate], WatchError>,
1380    ) -> Result<(), fidl::Error> {
1381        let _result = self.send_raw(result);
1382        if _result.is_err() {
1383            self.control_handle.shutdown();
1384        }
1385        self.drop_without_shutdown();
1386        _result
1387    }
1388
1389    /// Similar to "send" but does not shutdown the channel if an error occurs.
1390    pub fn send_no_shutdown_on_err(
1391        self,
1392        mut result: Result<&[PropertyUpdate], WatchError>,
1393    ) -> Result<(), fidl::Error> {
1394        let _result = self.send_raw(result);
1395        self.drop_without_shutdown();
1396        _result
1397    }
1398
1399    fn send_raw(
1400        &self,
1401        mut result: Result<&[PropertyUpdate], WatchError>,
1402    ) -> Result<(), fidl::Error> {
1403        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1404            NetworksWatchPropertiesResponse,
1405            WatchError,
1406        >>(
1407            fidl::encoding::FlexibleResult::new(result.map(|updates| (updates,))),
1408            self.tx_id,
1409            0x24d2340905f7dcc6,
1410            fidl::encoding::DynamicFlags::FLEXIBLE,
1411        )
1412    }
1413}
1414
1415mod internal {
1416    use super::*;
1417
1418    impl fidl::encoding::ResourceTypeMarker for NetworkToken {
1419        type Borrowed<'a> = &'a mut Self;
1420        fn take_or_borrow<'a>(
1421            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1422        ) -> Self::Borrowed<'a> {
1423            value
1424        }
1425    }
1426
1427    unsafe impl fidl::encoding::TypeMarker for NetworkToken {
1428        type Owned = Self;
1429
1430        #[inline(always)]
1431        fn inline_align(_context: fidl::encoding::Context) -> usize {
1432            4
1433        }
1434
1435        #[inline(always)]
1436        fn inline_size(_context: fidl::encoding::Context) -> usize {
1437            4
1438        }
1439    }
1440
1441    unsafe impl fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>
1442        for &mut NetworkToken
1443    {
1444        #[inline]
1445        unsafe fn encode(
1446            self,
1447            encoder: &mut fidl::encoding::Encoder<
1448                '_,
1449                fidl::encoding::DefaultFuchsiaResourceDialect,
1450            >,
1451            offset: usize,
1452            _depth: fidl::encoding::Depth,
1453        ) -> fidl::Result<()> {
1454            encoder.debug_check_bounds::<NetworkToken>(offset);
1455            // Delegate to tuple encoding.
1456            fidl::encoding::Encode::<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1457                (
1458                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
1459                ),
1460                encoder, offset, _depth
1461            )
1462        }
1463    }
1464    unsafe impl<
1465        T0: fidl::encoding::Encode<
1466                fidl::encoding::HandleType<
1467                    fidl::EventPair,
1468                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1469                    2147483648,
1470                >,
1471                fidl::encoding::DefaultFuchsiaResourceDialect,
1472            >,
1473    > fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0,)
1474    {
1475        #[inline]
1476        unsafe fn encode(
1477            self,
1478            encoder: &mut fidl::encoding::Encoder<
1479                '_,
1480                fidl::encoding::DefaultFuchsiaResourceDialect,
1481            >,
1482            offset: usize,
1483            depth: fidl::encoding::Depth,
1484        ) -> fidl::Result<()> {
1485            encoder.debug_check_bounds::<NetworkToken>(offset);
1486            // Zero out padding regions. There's no need to apply masks
1487            // because the unmasked parts will be overwritten by fields.
1488            // Write the fields.
1489            self.0.encode(encoder, offset + 0, depth)?;
1490            Ok(())
1491        }
1492    }
1493
1494    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NetworkToken {
1495        #[inline(always)]
1496        fn new_empty() -> Self {
1497            Self {
1498                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1499            }
1500        }
1501
1502        #[inline]
1503        unsafe fn decode(
1504            &mut self,
1505            decoder: &mut fidl::encoding::Decoder<
1506                '_,
1507                fidl::encoding::DefaultFuchsiaResourceDialect,
1508            >,
1509            offset: usize,
1510            _depth: fidl::encoding::Depth,
1511        ) -> fidl::Result<()> {
1512            decoder.debug_check_bounds::<Self>(offset);
1513            // Verify that padding bytes are zero.
1514            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
1515            Ok(())
1516        }
1517    }
1518
1519    impl fidl::encoding::ResourceTypeMarker for NetworkTokenResolverResolveTokenRequest {
1520        type Borrowed<'a> = &'a mut Self;
1521        fn take_or_borrow<'a>(
1522            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1523        ) -> Self::Borrowed<'a> {
1524            value
1525        }
1526    }
1527
1528    unsafe impl fidl::encoding::TypeMarker for NetworkTokenResolverResolveTokenRequest {
1529        type Owned = Self;
1530
1531        #[inline(always)]
1532        fn inline_align(_context: fidl::encoding::Context) -> usize {
1533            4
1534        }
1535
1536        #[inline(always)]
1537        fn inline_size(_context: fidl::encoding::Context) -> usize {
1538            4
1539        }
1540    }
1541
1542    unsafe impl
1543        fidl::encoding::Encode<
1544            NetworkTokenResolverResolveTokenRequest,
1545            fidl::encoding::DefaultFuchsiaResourceDialect,
1546        > for &mut NetworkTokenResolverResolveTokenRequest
1547    {
1548        #[inline]
1549        unsafe fn encode(
1550            self,
1551            encoder: &mut fidl::encoding::Encoder<
1552                '_,
1553                fidl::encoding::DefaultFuchsiaResourceDialect,
1554            >,
1555            offset: usize,
1556            _depth: fidl::encoding::Depth,
1557        ) -> fidl::Result<()> {
1558            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenRequest>(offset);
1559            // Delegate to tuple encoding.
1560            fidl::encoding::Encode::<
1561                NetworkTokenResolverResolveTokenRequest,
1562                fidl::encoding::DefaultFuchsiaResourceDialect,
1563            >::encode(
1564                (<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1565                    &mut self.token,
1566                ),),
1567                encoder,
1568                offset,
1569                _depth,
1570            )
1571        }
1572    }
1573    unsafe impl<
1574        T0: fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>,
1575    >
1576        fidl::encoding::Encode<
1577            NetworkTokenResolverResolveTokenRequest,
1578            fidl::encoding::DefaultFuchsiaResourceDialect,
1579        > for (T0,)
1580    {
1581        #[inline]
1582        unsafe fn encode(
1583            self,
1584            encoder: &mut fidl::encoding::Encoder<
1585                '_,
1586                fidl::encoding::DefaultFuchsiaResourceDialect,
1587            >,
1588            offset: usize,
1589            depth: fidl::encoding::Depth,
1590        ) -> fidl::Result<()> {
1591            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenRequest>(offset);
1592            // Zero out padding regions. There's no need to apply masks
1593            // because the unmasked parts will be overwritten by fields.
1594            // Write the fields.
1595            self.0.encode(encoder, offset + 0, depth)?;
1596            Ok(())
1597        }
1598    }
1599
1600    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1601        for NetworkTokenResolverResolveTokenRequest
1602    {
1603        #[inline(always)]
1604        fn new_empty() -> Self {
1605            Self {
1606                token: fidl::new_empty!(
1607                    NetworkToken,
1608                    fidl::encoding::DefaultFuchsiaResourceDialect
1609                ),
1610            }
1611        }
1612
1613        #[inline]
1614        unsafe fn decode(
1615            &mut self,
1616            decoder: &mut fidl::encoding::Decoder<
1617                '_,
1618                fidl::encoding::DefaultFuchsiaResourceDialect,
1619            >,
1620            offset: usize,
1621            _depth: fidl::encoding::Depth,
1622        ) -> fidl::Result<()> {
1623            decoder.debug_check_bounds::<Self>(offset);
1624            // Verify that padding bytes are zero.
1625            fidl::decode!(
1626                NetworkToken,
1627                fidl::encoding::DefaultFuchsiaResourceDialect,
1628                &mut self.token,
1629                decoder,
1630                offset + 0,
1631                _depth
1632            )?;
1633            Ok(())
1634        }
1635    }
1636
1637    impl fidl::encoding::ResourceTypeMarker for NetworkTokenResolverResolveTokenResponse {
1638        type Borrowed<'a> = &'a mut Self;
1639        fn take_or_borrow<'a>(
1640            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1641        ) -> Self::Borrowed<'a> {
1642            value
1643        }
1644    }
1645
1646    unsafe impl fidl::encoding::TypeMarker for NetworkTokenResolverResolveTokenResponse {
1647        type Owned = Self;
1648
1649        #[inline(always)]
1650        fn inline_align(_context: fidl::encoding::Context) -> usize {
1651            4
1652        }
1653
1654        #[inline(always)]
1655        fn inline_size(_context: fidl::encoding::Context) -> usize {
1656            4
1657        }
1658    }
1659
1660    unsafe impl
1661        fidl::encoding::Encode<
1662            NetworkTokenResolverResolveTokenResponse,
1663            fidl::encoding::DefaultFuchsiaResourceDialect,
1664        > for &mut NetworkTokenResolverResolveTokenResponse
1665    {
1666        #[inline]
1667        unsafe fn encode(
1668            self,
1669            encoder: &mut fidl::encoding::Encoder<
1670                '_,
1671                fidl::encoding::DefaultFuchsiaResourceDialect,
1672            >,
1673            offset: usize,
1674            _depth: fidl::encoding::Depth,
1675        ) -> fidl::Result<()> {
1676            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenResponse>(offset);
1677            // Delegate to tuple encoding.
1678            fidl::encoding::Encode::<
1679                NetworkTokenResolverResolveTokenResponse,
1680                fidl::encoding::DefaultFuchsiaResourceDialect,
1681            >::encode(
1682                (<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1683                    &mut self.resolved_token,
1684                ),),
1685                encoder,
1686                offset,
1687                _depth,
1688            )
1689        }
1690    }
1691    unsafe impl<
1692        T0: fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>,
1693    >
1694        fidl::encoding::Encode<
1695            NetworkTokenResolverResolveTokenResponse,
1696            fidl::encoding::DefaultFuchsiaResourceDialect,
1697        > for (T0,)
1698    {
1699        #[inline]
1700        unsafe fn encode(
1701            self,
1702            encoder: &mut fidl::encoding::Encoder<
1703                '_,
1704                fidl::encoding::DefaultFuchsiaResourceDialect,
1705            >,
1706            offset: usize,
1707            depth: fidl::encoding::Depth,
1708        ) -> fidl::Result<()> {
1709            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenResponse>(offset);
1710            // Zero out padding regions. There's no need to apply masks
1711            // because the unmasked parts will be overwritten by fields.
1712            // Write the fields.
1713            self.0.encode(encoder, offset + 0, depth)?;
1714            Ok(())
1715        }
1716    }
1717
1718    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1719        for NetworkTokenResolverResolveTokenResponse
1720    {
1721        #[inline(always)]
1722        fn new_empty() -> Self {
1723            Self {
1724                resolved_token: fidl::new_empty!(
1725                    NetworkToken,
1726                    fidl::encoding::DefaultFuchsiaResourceDialect
1727                ),
1728            }
1729        }
1730
1731        #[inline]
1732        unsafe fn decode(
1733            &mut self,
1734            decoder: &mut fidl::encoding::Decoder<
1735                '_,
1736                fidl::encoding::DefaultFuchsiaResourceDialect,
1737            >,
1738            offset: usize,
1739            _depth: fidl::encoding::Depth,
1740        ) -> fidl::Result<()> {
1741            decoder.debug_check_bounds::<Self>(offset);
1742            // Verify that padding bytes are zero.
1743            fidl::decode!(
1744                NetworkToken,
1745                fidl::encoding::DefaultFuchsiaResourceDialect,
1746                &mut self.resolved_token,
1747                decoder,
1748                offset + 0,
1749                _depth
1750            )?;
1751            Ok(())
1752        }
1753    }
1754
1755    impl NetworksWatchPropertiesRequest {
1756        #[inline(always)]
1757        fn max_ordinal_present(&self) -> u64 {
1758            if let Some(_) = self.properties {
1759                return 2;
1760            }
1761            if let Some(_) = self.network {
1762                return 1;
1763            }
1764            0
1765        }
1766    }
1767
1768    impl fidl::encoding::ResourceTypeMarker for NetworksWatchPropertiesRequest {
1769        type Borrowed<'a> = &'a mut Self;
1770        fn take_or_borrow<'a>(
1771            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1772        ) -> Self::Borrowed<'a> {
1773            value
1774        }
1775    }
1776
1777    unsafe impl fidl::encoding::TypeMarker for NetworksWatchPropertiesRequest {
1778        type Owned = Self;
1779
1780        #[inline(always)]
1781        fn inline_align(_context: fidl::encoding::Context) -> usize {
1782            8
1783        }
1784
1785        #[inline(always)]
1786        fn inline_size(_context: fidl::encoding::Context) -> usize {
1787            16
1788        }
1789    }
1790
1791    unsafe impl
1792        fidl::encoding::Encode<
1793            NetworksWatchPropertiesRequest,
1794            fidl::encoding::DefaultFuchsiaResourceDialect,
1795        > for &mut NetworksWatchPropertiesRequest
1796    {
1797        unsafe fn encode(
1798            self,
1799            encoder: &mut fidl::encoding::Encoder<
1800                '_,
1801                fidl::encoding::DefaultFuchsiaResourceDialect,
1802            >,
1803            offset: usize,
1804            mut depth: fidl::encoding::Depth,
1805        ) -> fidl::Result<()> {
1806            encoder.debug_check_bounds::<NetworksWatchPropertiesRequest>(offset);
1807            // Vector header
1808            let max_ordinal: u64 = self.max_ordinal_present();
1809            encoder.write_num(max_ordinal, offset);
1810            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1811            // Calling encoder.out_of_line_offset(0) is not allowed.
1812            if max_ordinal == 0 {
1813                return Ok(());
1814            }
1815            depth.increment()?;
1816            let envelope_size = 8;
1817            let bytes_len = max_ordinal as usize * envelope_size;
1818            #[allow(unused_variables)]
1819            let offset = encoder.out_of_line_offset(bytes_len);
1820            let mut _prev_end_offset: usize = 0;
1821            if 1 > max_ordinal {
1822                return Ok(());
1823            }
1824
1825            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1826            // are envelope_size bytes.
1827            let cur_offset: usize = (1 - 1) * envelope_size;
1828
1829            // Zero reserved fields.
1830            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1831
1832            // Safety:
1833            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1834            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1835            //   envelope_size bytes, there is always sufficient room.
1836            fidl::encoding::encode_in_envelope_optional::<
1837                NetworkToken,
1838                fidl::encoding::DefaultFuchsiaResourceDialect,
1839            >(
1840                self.network
1841                    .as_mut()
1842                    .map(<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1843                encoder,
1844                offset + cur_offset,
1845                depth,
1846            )?;
1847
1848            _prev_end_offset = cur_offset + envelope_size;
1849            if 2 > max_ordinal {
1850                return Ok(());
1851            }
1852
1853            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1854            // are envelope_size bytes.
1855            let cur_offset: usize = (2 - 1) * envelope_size;
1856
1857            // Zero reserved fields.
1858            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1859
1860            // Safety:
1861            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1862            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1863            //   envelope_size bytes, there is always sufficient room.
1864            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Property>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1865            self.properties.as_ref().map(<fidl::encoding::UnboundedVector<Property> as fidl::encoding::ValueTypeMarker>::borrow),
1866            encoder, offset + cur_offset, depth
1867        )?;
1868
1869            _prev_end_offset = cur_offset + envelope_size;
1870
1871            Ok(())
1872        }
1873    }
1874
1875    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1876        for NetworksWatchPropertiesRequest
1877    {
1878        #[inline(always)]
1879        fn new_empty() -> Self {
1880            Self::default()
1881        }
1882
1883        unsafe fn decode(
1884            &mut self,
1885            decoder: &mut fidl::encoding::Decoder<
1886                '_,
1887                fidl::encoding::DefaultFuchsiaResourceDialect,
1888            >,
1889            offset: usize,
1890            mut depth: fidl::encoding::Depth,
1891        ) -> fidl::Result<()> {
1892            decoder.debug_check_bounds::<Self>(offset);
1893            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1894                None => return Err(fidl::Error::NotNullable),
1895                Some(len) => len,
1896            };
1897            // Calling decoder.out_of_line_offset(0) is not allowed.
1898            if len == 0 {
1899                return Ok(());
1900            };
1901            depth.increment()?;
1902            let envelope_size = 8;
1903            let bytes_len = len * envelope_size;
1904            let offset = decoder.out_of_line_offset(bytes_len)?;
1905            // Decode the envelope for each type.
1906            let mut _next_ordinal_to_read = 0;
1907            let mut next_offset = offset;
1908            let end_offset = offset + bytes_len;
1909            _next_ordinal_to_read += 1;
1910            if next_offset >= end_offset {
1911                return Ok(());
1912            }
1913
1914            // Decode unknown envelopes for gaps in ordinals.
1915            while _next_ordinal_to_read < 1 {
1916                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1917                _next_ordinal_to_read += 1;
1918                next_offset += envelope_size;
1919            }
1920
1921            let next_out_of_line = decoder.next_out_of_line();
1922            let handles_before = decoder.remaining_handles();
1923            if let Some((inlined, num_bytes, num_handles)) =
1924                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1925            {
1926                let member_inline_size =
1927                    <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1928                if inlined != (member_inline_size <= 4) {
1929                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1930                }
1931                let inner_offset;
1932                let mut inner_depth = depth.clone();
1933                if inlined {
1934                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1935                    inner_offset = next_offset;
1936                } else {
1937                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1938                    inner_depth.increment()?;
1939                }
1940                let val_ref = self.network.get_or_insert_with(|| {
1941                    fidl::new_empty!(NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect)
1942                });
1943                fidl::decode!(
1944                    NetworkToken,
1945                    fidl::encoding::DefaultFuchsiaResourceDialect,
1946                    val_ref,
1947                    decoder,
1948                    inner_offset,
1949                    inner_depth
1950                )?;
1951                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1952                {
1953                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1954                }
1955                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1956                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1957                }
1958            }
1959
1960            next_offset += envelope_size;
1961            _next_ordinal_to_read += 1;
1962            if next_offset >= end_offset {
1963                return Ok(());
1964            }
1965
1966            // Decode unknown envelopes for gaps in ordinals.
1967            while _next_ordinal_to_read < 2 {
1968                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1969                _next_ordinal_to_read += 1;
1970                next_offset += envelope_size;
1971            }
1972
1973            let next_out_of_line = decoder.next_out_of_line();
1974            let handles_before = decoder.remaining_handles();
1975            if let Some((inlined, num_bytes, num_handles)) =
1976                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1977            {
1978                let member_inline_size = <fidl::encoding::UnboundedVector<Property> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1979                if inlined != (member_inline_size <= 4) {
1980                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1981                }
1982                let inner_offset;
1983                let mut inner_depth = depth.clone();
1984                if inlined {
1985                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1986                    inner_offset = next_offset;
1987                } else {
1988                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1989                    inner_depth.increment()?;
1990                }
1991                let val_ref = self.properties.get_or_insert_with(|| {
1992                    fidl::new_empty!(
1993                        fidl::encoding::UnboundedVector<Property>,
1994                        fidl::encoding::DefaultFuchsiaResourceDialect
1995                    )
1996                });
1997                fidl::decode!(
1998                    fidl::encoding::UnboundedVector<Property>,
1999                    fidl::encoding::DefaultFuchsiaResourceDialect,
2000                    val_ref,
2001                    decoder,
2002                    inner_offset,
2003                    inner_depth
2004                )?;
2005                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2006                {
2007                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2008                }
2009                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2010                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2011                }
2012            }
2013
2014            next_offset += envelope_size;
2015
2016            // Decode the remaining unknown envelopes.
2017            while next_offset < end_offset {
2018                _next_ordinal_to_read += 1;
2019                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2020                next_offset += envelope_size;
2021            }
2022
2023            Ok(())
2024        }
2025    }
2026
2027    impl fidl::encoding::ResourceTypeMarker for NetworksWatchDefaultResponse {
2028        type Borrowed<'a> = &'a mut Self;
2029        fn take_or_borrow<'a>(
2030            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2031        ) -> Self::Borrowed<'a> {
2032            value
2033        }
2034    }
2035
2036    unsafe impl fidl::encoding::TypeMarker for NetworksWatchDefaultResponse {
2037        type Owned = Self;
2038
2039        #[inline(always)]
2040        fn inline_align(_context: fidl::encoding::Context) -> usize {
2041            8
2042        }
2043
2044        #[inline(always)]
2045        fn inline_size(_context: fidl::encoding::Context) -> usize {
2046            16
2047        }
2048    }
2049
2050    unsafe impl
2051        fidl::encoding::Encode<
2052            NetworksWatchDefaultResponse,
2053            fidl::encoding::DefaultFuchsiaResourceDialect,
2054        > for &mut NetworksWatchDefaultResponse
2055    {
2056        #[inline]
2057        unsafe fn encode(
2058            self,
2059            encoder: &mut fidl::encoding::Encoder<
2060                '_,
2061                fidl::encoding::DefaultFuchsiaResourceDialect,
2062            >,
2063            offset: usize,
2064            _depth: fidl::encoding::Depth,
2065        ) -> fidl::Result<()> {
2066            encoder.debug_check_bounds::<NetworksWatchDefaultResponse>(offset);
2067            encoder.write_num::<u64>(self.ordinal(), offset);
2068            match self {
2069                NetworksWatchDefaultResponse::Network(ref mut val) => {
2070                    fidl::encoding::encode_in_envelope::<
2071                        NetworkToken,
2072                        fidl::encoding::DefaultFuchsiaResourceDialect,
2073                    >(
2074                        <NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2075                        encoder,
2076                        offset + 8,
2077                        _depth,
2078                    )
2079                }
2080                NetworksWatchDefaultResponse::NoDefaultNetwork(ref val) => {
2081                    fidl::encoding::encode_in_envelope::<
2082                        Empty,
2083                        fidl::encoding::DefaultFuchsiaResourceDialect,
2084                    >(
2085                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2086                        encoder,
2087                        offset + 8,
2088                        _depth,
2089                    )
2090                }
2091                NetworksWatchDefaultResponse::__SourceBreaking { .. } => {
2092                    Err(fidl::Error::UnknownUnionTag)
2093                }
2094            }
2095        }
2096    }
2097
2098    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2099        for NetworksWatchDefaultResponse
2100    {
2101        #[inline(always)]
2102        fn new_empty() -> Self {
2103            Self::__SourceBreaking { unknown_ordinal: 0 }
2104        }
2105
2106        #[inline]
2107        unsafe fn decode(
2108            &mut self,
2109            decoder: &mut fidl::encoding::Decoder<
2110                '_,
2111                fidl::encoding::DefaultFuchsiaResourceDialect,
2112            >,
2113            offset: usize,
2114            mut depth: fidl::encoding::Depth,
2115        ) -> fidl::Result<()> {
2116            decoder.debug_check_bounds::<Self>(offset);
2117            #[allow(unused_variables)]
2118            let next_out_of_line = decoder.next_out_of_line();
2119            let handles_before = decoder.remaining_handles();
2120            let (ordinal, inlined, num_bytes, num_handles) =
2121                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2122
2123            let member_inline_size = match ordinal {
2124                1 => <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2125                2 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2126                0 => return Err(fidl::Error::UnknownUnionTag),
2127                _ => num_bytes as usize,
2128            };
2129
2130            if inlined != (member_inline_size <= 4) {
2131                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2132            }
2133            let _inner_offset;
2134            if inlined {
2135                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2136                _inner_offset = offset + 8;
2137            } else {
2138                depth.increment()?;
2139                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2140            }
2141            match ordinal {
2142                1 => {
2143                    #[allow(irrefutable_let_patterns)]
2144                    if let NetworksWatchDefaultResponse::Network(_) = self {
2145                        // Do nothing, read the value into the object
2146                    } else {
2147                        // Initialize `self` to the right variant
2148                        *self = NetworksWatchDefaultResponse::Network(fidl::new_empty!(
2149                            NetworkToken,
2150                            fidl::encoding::DefaultFuchsiaResourceDialect
2151                        ));
2152                    }
2153                    #[allow(irrefutable_let_patterns)]
2154                    if let NetworksWatchDefaultResponse::Network(ref mut val) = self {
2155                        fidl::decode!(
2156                            NetworkToken,
2157                            fidl::encoding::DefaultFuchsiaResourceDialect,
2158                            val,
2159                            decoder,
2160                            _inner_offset,
2161                            depth
2162                        )?;
2163                    } else {
2164                        unreachable!()
2165                    }
2166                }
2167                2 => {
2168                    #[allow(irrefutable_let_patterns)]
2169                    if let NetworksWatchDefaultResponse::NoDefaultNetwork(_) = self {
2170                        // Do nothing, read the value into the object
2171                    } else {
2172                        // Initialize `self` to the right variant
2173                        *self = NetworksWatchDefaultResponse::NoDefaultNetwork(fidl::new_empty!(
2174                            Empty,
2175                            fidl::encoding::DefaultFuchsiaResourceDialect
2176                        ));
2177                    }
2178                    #[allow(irrefutable_let_patterns)]
2179                    if let NetworksWatchDefaultResponse::NoDefaultNetwork(ref mut val) = self {
2180                        fidl::decode!(
2181                            Empty,
2182                            fidl::encoding::DefaultFuchsiaResourceDialect,
2183                            val,
2184                            decoder,
2185                            _inner_offset,
2186                            depth
2187                        )?;
2188                    } else {
2189                        unreachable!()
2190                    }
2191                }
2192                #[allow(deprecated)]
2193                ordinal => {
2194                    for _ in 0..num_handles {
2195                        decoder.drop_next_handle()?;
2196                    }
2197                    *self =
2198                        NetworksWatchDefaultResponse::__SourceBreaking { unknown_ordinal: ordinal };
2199                }
2200            }
2201            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2202                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2203            }
2204            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2205                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2206            }
2207            Ok(())
2208        }
2209    }
2210}