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        Self { client: fidl::client::sync::Client::new(channel) }
170    }
171
172    pub fn into_channel(self) -> fidl::Channel {
173        self.client.into_channel()
174    }
175
176    /// Waits until an event arrives and returns it. It is safe for other
177    /// threads to make concurrent requests while waiting for an event.
178    pub fn wait_for_event(
179        &self,
180        deadline: zx::MonotonicInstant,
181    ) -> Result<NetworkTokenResolverEvent, fidl::Error> {
182        NetworkTokenResolverEvent::decode(
183            self.client.wait_for_event::<NetworkTokenResolverMarker>(deadline)?,
184        )
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            >, NetworkTokenResolverMarker>(
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        Self { client: fidl::client::sync::Client::new(channel) }
726    }
727
728    pub fn into_channel(self) -> fidl::Channel {
729        self.client.into_channel()
730    }
731
732    /// Waits until an event arrives and returns it. It is safe for other
733    /// threads to make concurrent requests while waiting for an event.
734    pub fn wait_for_event(
735        &self,
736        deadline: zx::MonotonicInstant,
737    ) -> Result<NetworksEvent, fidl::Error> {
738        NetworksEvent::decode(self.client.wait_for_event::<NetworksMarker>(deadline)?)
739    }
740
741    /// Watches for changes in the default network.
742    ///
743    /// The first call always returns a [`NetworkToken`] representing the
744    /// current default network, or if one is not present, blocks until a
745    /// default network is set. Subsequent calls will block until the default
746    /// network has changed, or has been lost, returning a new [`NetworkToken`]
747    /// for the updated default network, or [`no_default_network`] if the
748    /// network is lost.
749    ///
750    /// Only one call to this method should be pending per connection.
751    pub fn r#watch_default(
752        &self,
753        ___deadline: zx::MonotonicInstant,
754    ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
755        let _response = self.client.send_query::<
756            fidl::encoding::EmptyPayload,
757            fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
758            NetworksMarker,
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            NetworksMarker,
790        >(
791            &mut payload,
792            0x24d2340905f7dcc6,
793            fidl::encoding::DynamicFlags::FLEXIBLE,
794            ___deadline,
795        )?
796        .into_result::<NetworksMarker>("watch_properties")?;
797        Ok(_response.map(|x| x.updates))
798    }
799}
800
801#[cfg(target_os = "fuchsia")]
802impl From<NetworksSynchronousProxy> for zx::NullableHandle {
803    fn from(value: NetworksSynchronousProxy) -> Self {
804        value.into_channel().into()
805    }
806}
807
808#[cfg(target_os = "fuchsia")]
809impl From<fidl::Channel> for NetworksSynchronousProxy {
810    fn from(value: fidl::Channel) -> Self {
811        Self::new(value)
812    }
813}
814
815#[cfg(target_os = "fuchsia")]
816impl fidl::endpoints::FromClient for NetworksSynchronousProxy {
817    type Protocol = NetworksMarker;
818
819    fn from_client(value: fidl::endpoints::ClientEnd<NetworksMarker>) -> Self {
820        Self::new(value.into_channel())
821    }
822}
823
824#[derive(Debug, Clone)]
825pub struct NetworksProxy {
826    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
827}
828
829impl fidl::endpoints::Proxy for NetworksProxy {
830    type Protocol = NetworksMarker;
831
832    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
833        Self::new(inner)
834    }
835
836    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
837        self.client.into_channel().map_err(|client| Self { client })
838    }
839
840    fn as_channel(&self) -> &::fidl::AsyncChannel {
841        self.client.as_channel()
842    }
843}
844
845impl NetworksProxy {
846    /// Create a new Proxy for fuchsia.net.policy.properties/Networks.
847    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
848        let protocol_name = <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
849        Self { client: fidl::client::Client::new(channel, protocol_name) }
850    }
851
852    /// Get a Stream of events from the remote end of the protocol.
853    ///
854    /// # Panics
855    ///
856    /// Panics if the event stream was already taken.
857    pub fn take_event_stream(&self) -> NetworksEventStream {
858        NetworksEventStream { event_receiver: self.client.take_event_receiver() }
859    }
860
861    /// Watches for changes in the default network.
862    ///
863    /// The first call always returns a [`NetworkToken`] representing the
864    /// current default network, or if one is not present, blocks until a
865    /// default network is set. Subsequent calls will block until the default
866    /// network has changed, or has been lost, returning a new [`NetworkToken`]
867    /// for the updated default network, or [`no_default_network`] if the
868    /// network is lost.
869    ///
870    /// Only one call to this method should be pending per connection.
871    pub fn r#watch_default(
872        &self,
873    ) -> fidl::client::QueryResponseFut<
874        NetworksWatchDefaultResponse,
875        fidl::encoding::DefaultFuchsiaResourceDialect,
876    > {
877        NetworksProxyInterface::r#watch_default(self)
878    }
879
880    /// Watches for changes in requested properties for the given [`NetworkToken`]
881    ///
882    /// The first call will always return a snapshot of all requested
883    /// properties. Subsequent calls will block until any property changes, at
884    /// which point the changed property or properties will be sent. If the set
885    /// of requested [`properties`] changes on a subsequent call, the previously
886    /// unreported property will be sent immediately, before future calls will
887    /// return to the hanging get pattern. If the network represented by
888    /// `network` is no longer the default network, the connection will be
889    /// closed with `DEFAULT_NETWORK_CHANGED`.
890    ///
891    /// Only one call to this method should be pending per [`NetworkToken`] per connection.
892    pub fn r#watch_properties(
893        &self,
894        mut payload: NetworksWatchPropertiesRequest,
895    ) -> fidl::client::QueryResponseFut<
896        NetworksWatchPropertiesResult,
897        fidl::encoding::DefaultFuchsiaResourceDialect,
898    > {
899        NetworksProxyInterface::r#watch_properties(self, payload)
900    }
901}
902
903impl NetworksProxyInterface for NetworksProxy {
904    type WatchDefaultResponseFut = fidl::client::QueryResponseFut<
905        NetworksWatchDefaultResponse,
906        fidl::encoding::DefaultFuchsiaResourceDialect,
907    >;
908    fn r#watch_default(&self) -> Self::WatchDefaultResponseFut {
909        fn _decode(
910            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
911        ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
912            let _response = fidl::client::decode_transaction_body::<
913                fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
914                fidl::encoding::DefaultFuchsiaResourceDialect,
915                0x346880b2d7db0f98,
916            >(_buf?)?
917            .into_result::<NetworksMarker>("watch_default")?;
918            Ok(_response)
919        }
920        self.client
921            .send_query_and_decode::<fidl::encoding::EmptyPayload, NetworksWatchDefaultResponse>(
922                (),
923                0x346880b2d7db0f98,
924                fidl::encoding::DynamicFlags::FLEXIBLE,
925                _decode,
926            )
927    }
928
929    type WatchPropertiesResponseFut = fidl::client::QueryResponseFut<
930        NetworksWatchPropertiesResult,
931        fidl::encoding::DefaultFuchsiaResourceDialect,
932    >;
933    fn r#watch_properties(
934        &self,
935        mut payload: NetworksWatchPropertiesRequest,
936    ) -> Self::WatchPropertiesResponseFut {
937        fn _decode(
938            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
939        ) -> Result<NetworksWatchPropertiesResult, fidl::Error> {
940            let _response = fidl::client::decode_transaction_body::<
941                fidl::encoding::FlexibleResultType<NetworksWatchPropertiesResponse, WatchError>,
942                fidl::encoding::DefaultFuchsiaResourceDialect,
943                0x24d2340905f7dcc6,
944            >(_buf?)?
945            .into_result::<NetworksMarker>("watch_properties")?;
946            Ok(_response.map(|x| x.updates))
947        }
948        self.client
949            .send_query_and_decode::<NetworksWatchPropertiesRequest, NetworksWatchPropertiesResult>(
950                &mut payload,
951                0x24d2340905f7dcc6,
952                fidl::encoding::DynamicFlags::FLEXIBLE,
953                _decode,
954            )
955    }
956}
957
958pub struct NetworksEventStream {
959    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
960}
961
962impl std::marker::Unpin for NetworksEventStream {}
963
964impl futures::stream::FusedStream for NetworksEventStream {
965    fn is_terminated(&self) -> bool {
966        self.event_receiver.is_terminated()
967    }
968}
969
970impl futures::Stream for NetworksEventStream {
971    type Item = Result<NetworksEvent, fidl::Error>;
972
973    fn poll_next(
974        mut self: std::pin::Pin<&mut Self>,
975        cx: &mut std::task::Context<'_>,
976    ) -> std::task::Poll<Option<Self::Item>> {
977        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
978            &mut self.event_receiver,
979            cx
980        )?) {
981            Some(buf) => std::task::Poll::Ready(Some(NetworksEvent::decode(buf))),
982            None => std::task::Poll::Ready(None),
983        }
984    }
985}
986
987#[derive(Debug)]
988pub enum NetworksEvent {
989    #[non_exhaustive]
990    _UnknownEvent {
991        /// Ordinal of the event that was sent.
992        ordinal: u64,
993    },
994}
995
996impl NetworksEvent {
997    /// Decodes a message buffer as a [`NetworksEvent`].
998    fn decode(
999        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1000    ) -> Result<NetworksEvent, fidl::Error> {
1001        let (bytes, _handles) = buf.split_mut();
1002        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1003        debug_assert_eq!(tx_header.tx_id, 0);
1004        match tx_header.ordinal {
1005            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1006                Ok(NetworksEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1007            }
1008            _ => Err(fidl::Error::UnknownOrdinal {
1009                ordinal: tx_header.ordinal,
1010                protocol_name: <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1011            }),
1012        }
1013    }
1014}
1015
1016/// A Stream of incoming requests for fuchsia.net.policy.properties/Networks.
1017pub struct NetworksRequestStream {
1018    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1019    is_terminated: bool,
1020}
1021
1022impl std::marker::Unpin for NetworksRequestStream {}
1023
1024impl futures::stream::FusedStream for NetworksRequestStream {
1025    fn is_terminated(&self) -> bool {
1026        self.is_terminated
1027    }
1028}
1029
1030impl fidl::endpoints::RequestStream for NetworksRequestStream {
1031    type Protocol = NetworksMarker;
1032    type ControlHandle = NetworksControlHandle;
1033
1034    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1035        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1036    }
1037
1038    fn control_handle(&self) -> Self::ControlHandle {
1039        NetworksControlHandle { inner: self.inner.clone() }
1040    }
1041
1042    fn into_inner(
1043        self,
1044    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1045    {
1046        (self.inner, self.is_terminated)
1047    }
1048
1049    fn from_inner(
1050        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1051        is_terminated: bool,
1052    ) -> Self {
1053        Self { inner, is_terminated }
1054    }
1055}
1056
1057impl futures::Stream for NetworksRequestStream {
1058    type Item = Result<NetworksRequest, fidl::Error>;
1059
1060    fn poll_next(
1061        mut self: std::pin::Pin<&mut Self>,
1062        cx: &mut std::task::Context<'_>,
1063    ) -> std::task::Poll<Option<Self::Item>> {
1064        let this = &mut *self;
1065        if this.inner.check_shutdown(cx) {
1066            this.is_terminated = true;
1067            return std::task::Poll::Ready(None);
1068        }
1069        if this.is_terminated {
1070            panic!("polled NetworksRequestStream after completion");
1071        }
1072        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1073            |bytes, handles| {
1074                match this.inner.channel().read_etc(cx, bytes, handles) {
1075                    std::task::Poll::Ready(Ok(())) => {}
1076                    std::task::Poll::Pending => return std::task::Poll::Pending,
1077                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1078                        this.is_terminated = true;
1079                        return std::task::Poll::Ready(None);
1080                    }
1081                    std::task::Poll::Ready(Err(e)) => {
1082                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1083                            e.into(),
1084                        ))));
1085                    }
1086                }
1087
1088                // A message has been received from the channel
1089                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1090
1091                std::task::Poll::Ready(Some(match header.ordinal {
1092                    0x346880b2d7db0f98 => {
1093                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1094                        let mut req = fidl::new_empty!(
1095                            fidl::encoding::EmptyPayload,
1096                            fidl::encoding::DefaultFuchsiaResourceDialect
1097                        );
1098                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1099                        let control_handle = NetworksControlHandle { inner: this.inner.clone() };
1100                        Ok(NetworksRequest::WatchDefault {
1101                            responder: NetworksWatchDefaultResponder {
1102                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1103                                tx_id: header.tx_id,
1104                            },
1105                        })
1106                    }
1107                    0x24d2340905f7dcc6 => {
1108                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1109                        let mut req = fidl::new_empty!(
1110                            NetworksWatchPropertiesRequest,
1111                            fidl::encoding::DefaultFuchsiaResourceDialect
1112                        );
1113                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworksWatchPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
1114                        let control_handle = NetworksControlHandle { inner: this.inner.clone() };
1115                        Ok(NetworksRequest::WatchProperties {
1116                            payload: req,
1117                            responder: NetworksWatchPropertiesResponder {
1118                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1119                                tx_id: header.tx_id,
1120                            },
1121                        })
1122                    }
1123                    _ if header.tx_id == 0
1124                        && header
1125                            .dynamic_flags()
1126                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1127                    {
1128                        Ok(NetworksRequest::_UnknownMethod {
1129                            ordinal: header.ordinal,
1130                            control_handle: NetworksControlHandle { inner: this.inner.clone() },
1131                            method_type: fidl::MethodType::OneWay,
1132                        })
1133                    }
1134                    _ if header
1135                        .dynamic_flags()
1136                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1137                    {
1138                        this.inner.send_framework_err(
1139                            fidl::encoding::FrameworkErr::UnknownMethod,
1140                            header.tx_id,
1141                            header.ordinal,
1142                            header.dynamic_flags(),
1143                            (bytes, handles),
1144                        )?;
1145                        Ok(NetworksRequest::_UnknownMethod {
1146                            ordinal: header.ordinal,
1147                            control_handle: NetworksControlHandle { inner: this.inner.clone() },
1148                            method_type: fidl::MethodType::TwoWay,
1149                        })
1150                    }
1151                    _ => Err(fidl::Error::UnknownOrdinal {
1152                        ordinal: header.ordinal,
1153                        protocol_name:
1154                            <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1155                    }),
1156                }))
1157            },
1158        )
1159    }
1160}
1161
1162/// Protocol for acquiring [`NetworkToken`]s, and querying properties of that
1163/// network.
1164#[derive(Debug)]
1165pub enum NetworksRequest {
1166    /// Watches for changes in the default network.
1167    ///
1168    /// The first call always returns a [`NetworkToken`] representing the
1169    /// current default network, or if one is not present, blocks until a
1170    /// default network is set. Subsequent calls will block until the default
1171    /// network has changed, or has been lost, returning a new [`NetworkToken`]
1172    /// for the updated default network, or [`no_default_network`] if the
1173    /// network is lost.
1174    ///
1175    /// Only one call to this method should be pending per connection.
1176    WatchDefault { responder: NetworksWatchDefaultResponder },
1177    /// Watches for changes in requested properties for the given [`NetworkToken`]
1178    ///
1179    /// The first call will always return a snapshot of all requested
1180    /// properties. Subsequent calls will block until any property changes, at
1181    /// which point the changed property or properties will be sent. If the set
1182    /// of requested [`properties`] changes on a subsequent call, the previously
1183    /// unreported property will be sent immediately, before future calls will
1184    /// return to the hanging get pattern. If the network represented by
1185    /// `network` is no longer the default network, the connection will be
1186    /// closed with `DEFAULT_NETWORK_CHANGED`.
1187    ///
1188    /// Only one call to this method should be pending per [`NetworkToken`] per connection.
1189    WatchProperties {
1190        payload: NetworksWatchPropertiesRequest,
1191        responder: NetworksWatchPropertiesResponder,
1192    },
1193    /// An interaction was received which does not match any known method.
1194    #[non_exhaustive]
1195    _UnknownMethod {
1196        /// Ordinal of the method that was called.
1197        ordinal: u64,
1198        control_handle: NetworksControlHandle,
1199        method_type: fidl::MethodType,
1200    },
1201}
1202
1203impl NetworksRequest {
1204    #[allow(irrefutable_let_patterns)]
1205    pub fn into_watch_default(self) -> Option<(NetworksWatchDefaultResponder)> {
1206        if let NetworksRequest::WatchDefault { responder } = self {
1207            Some((responder))
1208        } else {
1209            None
1210        }
1211    }
1212
1213    #[allow(irrefutable_let_patterns)]
1214    pub fn into_watch_properties(
1215        self,
1216    ) -> Option<(NetworksWatchPropertiesRequest, NetworksWatchPropertiesResponder)> {
1217        if let NetworksRequest::WatchProperties { payload, responder } = self {
1218            Some((payload, responder))
1219        } else {
1220            None
1221        }
1222    }
1223
1224    /// Name of the method defined in FIDL
1225    pub fn method_name(&self) -> &'static str {
1226        match *self {
1227            NetworksRequest::WatchDefault { .. } => "watch_default",
1228            NetworksRequest::WatchProperties { .. } => "watch_properties",
1229            NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1230                "unknown one-way method"
1231            }
1232            NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1233                "unknown two-way method"
1234            }
1235        }
1236    }
1237}
1238
1239#[derive(Debug, Clone)]
1240pub struct NetworksControlHandle {
1241    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1242}
1243
1244impl fidl::endpoints::ControlHandle for NetworksControlHandle {
1245    fn shutdown(&self) {
1246        self.inner.shutdown()
1247    }
1248
1249    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1250        self.inner.shutdown_with_epitaph(status)
1251    }
1252
1253    fn is_closed(&self) -> bool {
1254        self.inner.channel().is_closed()
1255    }
1256    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1257        self.inner.channel().on_closed()
1258    }
1259
1260    #[cfg(target_os = "fuchsia")]
1261    fn signal_peer(
1262        &self,
1263        clear_mask: zx::Signals,
1264        set_mask: zx::Signals,
1265    ) -> Result<(), zx_status::Status> {
1266        use fidl::Peered;
1267        self.inner.channel().signal_peer(clear_mask, set_mask)
1268    }
1269}
1270
1271impl NetworksControlHandle {}
1272
1273#[must_use = "FIDL methods require a response to be sent"]
1274#[derive(Debug)]
1275pub struct NetworksWatchDefaultResponder {
1276    control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
1277    tx_id: u32,
1278}
1279
1280/// Set the the channel to be shutdown (see [`NetworksControlHandle::shutdown`])
1281/// if the responder is dropped without sending a response, so that the client
1282/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1283impl std::ops::Drop for NetworksWatchDefaultResponder {
1284    fn drop(&mut self) {
1285        self.control_handle.shutdown();
1286        // Safety: drops once, never accessed again
1287        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1288    }
1289}
1290
1291impl fidl::endpoints::Responder for NetworksWatchDefaultResponder {
1292    type ControlHandle = NetworksControlHandle;
1293
1294    fn control_handle(&self) -> &NetworksControlHandle {
1295        &self.control_handle
1296    }
1297
1298    fn drop_without_shutdown(mut self) {
1299        // Safety: drops once, never accessed again due to mem::forget
1300        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1301        // Prevent Drop from running (which would shut down the channel)
1302        std::mem::forget(self);
1303    }
1304}
1305
1306impl NetworksWatchDefaultResponder {
1307    /// Sends a response to the FIDL transaction.
1308    ///
1309    /// Sets the channel to shutdown if an error occurs.
1310    pub fn send(self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
1311        let _result = self.send_raw(payload);
1312        if _result.is_err() {
1313            self.control_handle.shutdown();
1314        }
1315        self.drop_without_shutdown();
1316        _result
1317    }
1318
1319    /// Similar to "send" but does not shutdown the channel if an error occurs.
1320    pub fn send_no_shutdown_on_err(
1321        self,
1322        mut payload: NetworksWatchDefaultResponse,
1323    ) -> Result<(), fidl::Error> {
1324        let _result = self.send_raw(payload);
1325        self.drop_without_shutdown();
1326        _result
1327    }
1328
1329    fn send_raw(&self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
1330        self.control_handle
1331            .inner
1332            .send::<fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>>(
1333                fidl::encoding::Flexible::new(&mut payload),
1334                self.tx_id,
1335                0x346880b2d7db0f98,
1336                fidl::encoding::DynamicFlags::FLEXIBLE,
1337            )
1338    }
1339}
1340
1341#[must_use = "FIDL methods require a response to be sent"]
1342#[derive(Debug)]
1343pub struct NetworksWatchPropertiesResponder {
1344    control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
1345    tx_id: u32,
1346}
1347
1348/// Set the the channel to be shutdown (see [`NetworksControlHandle::shutdown`])
1349/// if the responder is dropped without sending a response, so that the client
1350/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1351impl std::ops::Drop for NetworksWatchPropertiesResponder {
1352    fn drop(&mut self) {
1353        self.control_handle.shutdown();
1354        // Safety: drops once, never accessed again
1355        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1356    }
1357}
1358
1359impl fidl::endpoints::Responder for NetworksWatchPropertiesResponder {
1360    type ControlHandle = NetworksControlHandle;
1361
1362    fn control_handle(&self) -> &NetworksControlHandle {
1363        &self.control_handle
1364    }
1365
1366    fn drop_without_shutdown(mut self) {
1367        // Safety: drops once, never accessed again due to mem::forget
1368        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1369        // Prevent Drop from running (which would shut down the channel)
1370        std::mem::forget(self);
1371    }
1372}
1373
1374impl NetworksWatchPropertiesResponder {
1375    /// Sends a response to the FIDL transaction.
1376    ///
1377    /// Sets the channel to shutdown if an error occurs.
1378    pub fn send(
1379        self,
1380        mut result: Result<&[PropertyUpdate], WatchError>,
1381    ) -> Result<(), fidl::Error> {
1382        let _result = self.send_raw(result);
1383        if _result.is_err() {
1384            self.control_handle.shutdown();
1385        }
1386        self.drop_without_shutdown();
1387        _result
1388    }
1389
1390    /// Similar to "send" but does not shutdown the channel if an error occurs.
1391    pub fn send_no_shutdown_on_err(
1392        self,
1393        mut result: Result<&[PropertyUpdate], WatchError>,
1394    ) -> Result<(), fidl::Error> {
1395        let _result = self.send_raw(result);
1396        self.drop_without_shutdown();
1397        _result
1398    }
1399
1400    fn send_raw(
1401        &self,
1402        mut result: Result<&[PropertyUpdate], WatchError>,
1403    ) -> Result<(), fidl::Error> {
1404        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1405            NetworksWatchPropertiesResponse,
1406            WatchError,
1407        >>(
1408            fidl::encoding::FlexibleResult::new(result.map(|updates| (updates,))),
1409            self.tx_id,
1410            0x24d2340905f7dcc6,
1411            fidl::encoding::DynamicFlags::FLEXIBLE,
1412        )
1413    }
1414}
1415
1416mod internal {
1417    use super::*;
1418
1419    impl fidl::encoding::ResourceTypeMarker for NetworkToken {
1420        type Borrowed<'a> = &'a mut Self;
1421        fn take_or_borrow<'a>(
1422            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1423        ) -> Self::Borrowed<'a> {
1424            value
1425        }
1426    }
1427
1428    unsafe impl fidl::encoding::TypeMarker for NetworkToken {
1429        type Owned = Self;
1430
1431        #[inline(always)]
1432        fn inline_align(_context: fidl::encoding::Context) -> usize {
1433            4
1434        }
1435
1436        #[inline(always)]
1437        fn inline_size(_context: fidl::encoding::Context) -> usize {
1438            4
1439        }
1440    }
1441
1442    unsafe impl fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>
1443        for &mut NetworkToken
1444    {
1445        #[inline]
1446        unsafe fn encode(
1447            self,
1448            encoder: &mut fidl::encoding::Encoder<
1449                '_,
1450                fidl::encoding::DefaultFuchsiaResourceDialect,
1451            >,
1452            offset: usize,
1453            _depth: fidl::encoding::Depth,
1454        ) -> fidl::Result<()> {
1455            encoder.debug_check_bounds::<NetworkToken>(offset);
1456            // Delegate to tuple encoding.
1457            fidl::encoding::Encode::<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1458                (
1459                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
1460                ),
1461                encoder, offset, _depth
1462            )
1463        }
1464    }
1465    unsafe impl<
1466        T0: fidl::encoding::Encode<
1467                fidl::encoding::HandleType<
1468                    fidl::EventPair,
1469                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1470                    2147483648,
1471                >,
1472                fidl::encoding::DefaultFuchsiaResourceDialect,
1473            >,
1474    > fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0,)
1475    {
1476        #[inline]
1477        unsafe fn encode(
1478            self,
1479            encoder: &mut fidl::encoding::Encoder<
1480                '_,
1481                fidl::encoding::DefaultFuchsiaResourceDialect,
1482            >,
1483            offset: usize,
1484            depth: fidl::encoding::Depth,
1485        ) -> fidl::Result<()> {
1486            encoder.debug_check_bounds::<NetworkToken>(offset);
1487            // Zero out padding regions. There's no need to apply masks
1488            // because the unmasked parts will be overwritten by fields.
1489            // Write the fields.
1490            self.0.encode(encoder, offset + 0, depth)?;
1491            Ok(())
1492        }
1493    }
1494
1495    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NetworkToken {
1496        #[inline(always)]
1497        fn new_empty() -> Self {
1498            Self {
1499                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1500            }
1501        }
1502
1503        #[inline]
1504        unsafe fn decode(
1505            &mut self,
1506            decoder: &mut fidl::encoding::Decoder<
1507                '_,
1508                fidl::encoding::DefaultFuchsiaResourceDialect,
1509            >,
1510            offset: usize,
1511            _depth: fidl::encoding::Depth,
1512        ) -> fidl::Result<()> {
1513            decoder.debug_check_bounds::<Self>(offset);
1514            // Verify that padding bytes are zero.
1515            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
1516            Ok(())
1517        }
1518    }
1519
1520    impl fidl::encoding::ResourceTypeMarker for NetworkTokenResolverResolveTokenRequest {
1521        type Borrowed<'a> = &'a mut Self;
1522        fn take_or_borrow<'a>(
1523            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1524        ) -> Self::Borrowed<'a> {
1525            value
1526        }
1527    }
1528
1529    unsafe impl fidl::encoding::TypeMarker for NetworkTokenResolverResolveTokenRequest {
1530        type Owned = Self;
1531
1532        #[inline(always)]
1533        fn inline_align(_context: fidl::encoding::Context) -> usize {
1534            4
1535        }
1536
1537        #[inline(always)]
1538        fn inline_size(_context: fidl::encoding::Context) -> usize {
1539            4
1540        }
1541    }
1542
1543    unsafe impl
1544        fidl::encoding::Encode<
1545            NetworkTokenResolverResolveTokenRequest,
1546            fidl::encoding::DefaultFuchsiaResourceDialect,
1547        > for &mut NetworkTokenResolverResolveTokenRequest
1548    {
1549        #[inline]
1550        unsafe fn encode(
1551            self,
1552            encoder: &mut fidl::encoding::Encoder<
1553                '_,
1554                fidl::encoding::DefaultFuchsiaResourceDialect,
1555            >,
1556            offset: usize,
1557            _depth: fidl::encoding::Depth,
1558        ) -> fidl::Result<()> {
1559            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenRequest>(offset);
1560            // Delegate to tuple encoding.
1561            fidl::encoding::Encode::<
1562                NetworkTokenResolverResolveTokenRequest,
1563                fidl::encoding::DefaultFuchsiaResourceDialect,
1564            >::encode(
1565                (<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1566                    &mut self.token,
1567                ),),
1568                encoder,
1569                offset,
1570                _depth,
1571            )
1572        }
1573    }
1574    unsafe impl<
1575        T0: fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>,
1576    >
1577        fidl::encoding::Encode<
1578            NetworkTokenResolverResolveTokenRequest,
1579            fidl::encoding::DefaultFuchsiaResourceDialect,
1580        > for (T0,)
1581    {
1582        #[inline]
1583        unsafe fn encode(
1584            self,
1585            encoder: &mut fidl::encoding::Encoder<
1586                '_,
1587                fidl::encoding::DefaultFuchsiaResourceDialect,
1588            >,
1589            offset: usize,
1590            depth: fidl::encoding::Depth,
1591        ) -> fidl::Result<()> {
1592            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenRequest>(offset);
1593            // Zero out padding regions. There's no need to apply masks
1594            // because the unmasked parts will be overwritten by fields.
1595            // Write the fields.
1596            self.0.encode(encoder, offset + 0, depth)?;
1597            Ok(())
1598        }
1599    }
1600
1601    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1602        for NetworkTokenResolverResolveTokenRequest
1603    {
1604        #[inline(always)]
1605        fn new_empty() -> Self {
1606            Self {
1607                token: fidl::new_empty!(
1608                    NetworkToken,
1609                    fidl::encoding::DefaultFuchsiaResourceDialect
1610                ),
1611            }
1612        }
1613
1614        #[inline]
1615        unsafe fn decode(
1616            &mut self,
1617            decoder: &mut fidl::encoding::Decoder<
1618                '_,
1619                fidl::encoding::DefaultFuchsiaResourceDialect,
1620            >,
1621            offset: usize,
1622            _depth: fidl::encoding::Depth,
1623        ) -> fidl::Result<()> {
1624            decoder.debug_check_bounds::<Self>(offset);
1625            // Verify that padding bytes are zero.
1626            fidl::decode!(
1627                NetworkToken,
1628                fidl::encoding::DefaultFuchsiaResourceDialect,
1629                &mut self.token,
1630                decoder,
1631                offset + 0,
1632                _depth
1633            )?;
1634            Ok(())
1635        }
1636    }
1637
1638    impl fidl::encoding::ResourceTypeMarker for NetworkTokenResolverResolveTokenResponse {
1639        type Borrowed<'a> = &'a mut Self;
1640        fn take_or_borrow<'a>(
1641            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1642        ) -> Self::Borrowed<'a> {
1643            value
1644        }
1645    }
1646
1647    unsafe impl fidl::encoding::TypeMarker for NetworkTokenResolverResolveTokenResponse {
1648        type Owned = Self;
1649
1650        #[inline(always)]
1651        fn inline_align(_context: fidl::encoding::Context) -> usize {
1652            4
1653        }
1654
1655        #[inline(always)]
1656        fn inline_size(_context: fidl::encoding::Context) -> usize {
1657            4
1658        }
1659    }
1660
1661    unsafe impl
1662        fidl::encoding::Encode<
1663            NetworkTokenResolverResolveTokenResponse,
1664            fidl::encoding::DefaultFuchsiaResourceDialect,
1665        > for &mut NetworkTokenResolverResolveTokenResponse
1666    {
1667        #[inline]
1668        unsafe fn encode(
1669            self,
1670            encoder: &mut fidl::encoding::Encoder<
1671                '_,
1672                fidl::encoding::DefaultFuchsiaResourceDialect,
1673            >,
1674            offset: usize,
1675            _depth: fidl::encoding::Depth,
1676        ) -> fidl::Result<()> {
1677            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenResponse>(offset);
1678            // Delegate to tuple encoding.
1679            fidl::encoding::Encode::<
1680                NetworkTokenResolverResolveTokenResponse,
1681                fidl::encoding::DefaultFuchsiaResourceDialect,
1682            >::encode(
1683                (<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1684                    &mut self.resolved_token,
1685                ),),
1686                encoder,
1687                offset,
1688                _depth,
1689            )
1690        }
1691    }
1692    unsafe impl<
1693        T0: fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>,
1694    >
1695        fidl::encoding::Encode<
1696            NetworkTokenResolverResolveTokenResponse,
1697            fidl::encoding::DefaultFuchsiaResourceDialect,
1698        > for (T0,)
1699    {
1700        #[inline]
1701        unsafe fn encode(
1702            self,
1703            encoder: &mut fidl::encoding::Encoder<
1704                '_,
1705                fidl::encoding::DefaultFuchsiaResourceDialect,
1706            >,
1707            offset: usize,
1708            depth: fidl::encoding::Depth,
1709        ) -> fidl::Result<()> {
1710            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenResponse>(offset);
1711            // Zero out padding regions. There's no need to apply masks
1712            // because the unmasked parts will be overwritten by fields.
1713            // Write the fields.
1714            self.0.encode(encoder, offset + 0, depth)?;
1715            Ok(())
1716        }
1717    }
1718
1719    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1720        for NetworkTokenResolverResolveTokenResponse
1721    {
1722        #[inline(always)]
1723        fn new_empty() -> Self {
1724            Self {
1725                resolved_token: fidl::new_empty!(
1726                    NetworkToken,
1727                    fidl::encoding::DefaultFuchsiaResourceDialect
1728                ),
1729            }
1730        }
1731
1732        #[inline]
1733        unsafe fn decode(
1734            &mut self,
1735            decoder: &mut fidl::encoding::Decoder<
1736                '_,
1737                fidl::encoding::DefaultFuchsiaResourceDialect,
1738            >,
1739            offset: usize,
1740            _depth: fidl::encoding::Depth,
1741        ) -> fidl::Result<()> {
1742            decoder.debug_check_bounds::<Self>(offset);
1743            // Verify that padding bytes are zero.
1744            fidl::decode!(
1745                NetworkToken,
1746                fidl::encoding::DefaultFuchsiaResourceDialect,
1747                &mut self.resolved_token,
1748                decoder,
1749                offset + 0,
1750                _depth
1751            )?;
1752            Ok(())
1753        }
1754    }
1755
1756    impl NetworksWatchPropertiesRequest {
1757        #[inline(always)]
1758        fn max_ordinal_present(&self) -> u64 {
1759            if let Some(_) = self.properties {
1760                return 2;
1761            }
1762            if let Some(_) = self.network {
1763                return 1;
1764            }
1765            0
1766        }
1767    }
1768
1769    impl fidl::encoding::ResourceTypeMarker for NetworksWatchPropertiesRequest {
1770        type Borrowed<'a> = &'a mut Self;
1771        fn take_or_borrow<'a>(
1772            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1773        ) -> Self::Borrowed<'a> {
1774            value
1775        }
1776    }
1777
1778    unsafe impl fidl::encoding::TypeMarker for NetworksWatchPropertiesRequest {
1779        type Owned = Self;
1780
1781        #[inline(always)]
1782        fn inline_align(_context: fidl::encoding::Context) -> usize {
1783            8
1784        }
1785
1786        #[inline(always)]
1787        fn inline_size(_context: fidl::encoding::Context) -> usize {
1788            16
1789        }
1790    }
1791
1792    unsafe impl
1793        fidl::encoding::Encode<
1794            NetworksWatchPropertiesRequest,
1795            fidl::encoding::DefaultFuchsiaResourceDialect,
1796        > for &mut NetworksWatchPropertiesRequest
1797    {
1798        unsafe fn encode(
1799            self,
1800            encoder: &mut fidl::encoding::Encoder<
1801                '_,
1802                fidl::encoding::DefaultFuchsiaResourceDialect,
1803            >,
1804            offset: usize,
1805            mut depth: fidl::encoding::Depth,
1806        ) -> fidl::Result<()> {
1807            encoder.debug_check_bounds::<NetworksWatchPropertiesRequest>(offset);
1808            // Vector header
1809            let max_ordinal: u64 = self.max_ordinal_present();
1810            encoder.write_num(max_ordinal, offset);
1811            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1812            // Calling encoder.out_of_line_offset(0) is not allowed.
1813            if max_ordinal == 0 {
1814                return Ok(());
1815            }
1816            depth.increment()?;
1817            let envelope_size = 8;
1818            let bytes_len = max_ordinal as usize * envelope_size;
1819            #[allow(unused_variables)]
1820            let offset = encoder.out_of_line_offset(bytes_len);
1821            let mut _prev_end_offset: usize = 0;
1822            if 1 > max_ordinal {
1823                return Ok(());
1824            }
1825
1826            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1827            // are envelope_size bytes.
1828            let cur_offset: usize = (1 - 1) * envelope_size;
1829
1830            // Zero reserved fields.
1831            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1832
1833            // Safety:
1834            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1835            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1836            //   envelope_size bytes, there is always sufficient room.
1837            fidl::encoding::encode_in_envelope_optional::<
1838                NetworkToken,
1839                fidl::encoding::DefaultFuchsiaResourceDialect,
1840            >(
1841                self.network
1842                    .as_mut()
1843                    .map(<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1844                encoder,
1845                offset + cur_offset,
1846                depth,
1847            )?;
1848
1849            _prev_end_offset = cur_offset + envelope_size;
1850            if 2 > max_ordinal {
1851                return Ok(());
1852            }
1853
1854            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1855            // are envelope_size bytes.
1856            let cur_offset: usize = (2 - 1) * envelope_size;
1857
1858            // Zero reserved fields.
1859            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1860
1861            // Safety:
1862            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1863            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1864            //   envelope_size bytes, there is always sufficient room.
1865            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Property>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1866            self.properties.as_ref().map(<fidl::encoding::UnboundedVector<Property> as fidl::encoding::ValueTypeMarker>::borrow),
1867            encoder, offset + cur_offset, depth
1868        )?;
1869
1870            _prev_end_offset = cur_offset + envelope_size;
1871
1872            Ok(())
1873        }
1874    }
1875
1876    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1877        for NetworksWatchPropertiesRequest
1878    {
1879        #[inline(always)]
1880        fn new_empty() -> Self {
1881            Self::default()
1882        }
1883
1884        unsafe fn decode(
1885            &mut self,
1886            decoder: &mut fidl::encoding::Decoder<
1887                '_,
1888                fidl::encoding::DefaultFuchsiaResourceDialect,
1889            >,
1890            offset: usize,
1891            mut depth: fidl::encoding::Depth,
1892        ) -> fidl::Result<()> {
1893            decoder.debug_check_bounds::<Self>(offset);
1894            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1895                None => return Err(fidl::Error::NotNullable),
1896                Some(len) => len,
1897            };
1898            // Calling decoder.out_of_line_offset(0) is not allowed.
1899            if len == 0 {
1900                return Ok(());
1901            };
1902            depth.increment()?;
1903            let envelope_size = 8;
1904            let bytes_len = len * envelope_size;
1905            let offset = decoder.out_of_line_offset(bytes_len)?;
1906            // Decode the envelope for each type.
1907            let mut _next_ordinal_to_read = 0;
1908            let mut next_offset = offset;
1909            let end_offset = offset + bytes_len;
1910            _next_ordinal_to_read += 1;
1911            if next_offset >= end_offset {
1912                return Ok(());
1913            }
1914
1915            // Decode unknown envelopes for gaps in ordinals.
1916            while _next_ordinal_to_read < 1 {
1917                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1918                _next_ordinal_to_read += 1;
1919                next_offset += envelope_size;
1920            }
1921
1922            let next_out_of_line = decoder.next_out_of_line();
1923            let handles_before = decoder.remaining_handles();
1924            if let Some((inlined, num_bytes, num_handles)) =
1925                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1926            {
1927                let member_inline_size =
1928                    <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1929                if inlined != (member_inline_size <= 4) {
1930                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1931                }
1932                let inner_offset;
1933                let mut inner_depth = depth.clone();
1934                if inlined {
1935                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1936                    inner_offset = next_offset;
1937                } else {
1938                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1939                    inner_depth.increment()?;
1940                }
1941                let val_ref = self.network.get_or_insert_with(|| {
1942                    fidl::new_empty!(NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect)
1943                });
1944                fidl::decode!(
1945                    NetworkToken,
1946                    fidl::encoding::DefaultFuchsiaResourceDialect,
1947                    val_ref,
1948                    decoder,
1949                    inner_offset,
1950                    inner_depth
1951                )?;
1952                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1953                {
1954                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1955                }
1956                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1957                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1958                }
1959            }
1960
1961            next_offset += envelope_size;
1962            _next_ordinal_to_read += 1;
1963            if next_offset >= end_offset {
1964                return Ok(());
1965            }
1966
1967            // Decode unknown envelopes for gaps in ordinals.
1968            while _next_ordinal_to_read < 2 {
1969                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1970                _next_ordinal_to_read += 1;
1971                next_offset += envelope_size;
1972            }
1973
1974            let next_out_of_line = decoder.next_out_of_line();
1975            let handles_before = decoder.remaining_handles();
1976            if let Some((inlined, num_bytes, num_handles)) =
1977                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1978            {
1979                let member_inline_size = <fidl::encoding::UnboundedVector<Property> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1980                if inlined != (member_inline_size <= 4) {
1981                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1982                }
1983                let inner_offset;
1984                let mut inner_depth = depth.clone();
1985                if inlined {
1986                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1987                    inner_offset = next_offset;
1988                } else {
1989                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1990                    inner_depth.increment()?;
1991                }
1992                let val_ref = self.properties.get_or_insert_with(|| {
1993                    fidl::new_empty!(
1994                        fidl::encoding::UnboundedVector<Property>,
1995                        fidl::encoding::DefaultFuchsiaResourceDialect
1996                    )
1997                });
1998                fidl::decode!(
1999                    fidl::encoding::UnboundedVector<Property>,
2000                    fidl::encoding::DefaultFuchsiaResourceDialect,
2001                    val_ref,
2002                    decoder,
2003                    inner_offset,
2004                    inner_depth
2005                )?;
2006                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2007                {
2008                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2009                }
2010                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2011                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2012                }
2013            }
2014
2015            next_offset += envelope_size;
2016
2017            // Decode the remaining unknown envelopes.
2018            while next_offset < end_offset {
2019                _next_ordinal_to_read += 1;
2020                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2021                next_offset += envelope_size;
2022            }
2023
2024            Ok(())
2025        }
2026    }
2027
2028    impl fidl::encoding::ResourceTypeMarker for NetworksWatchDefaultResponse {
2029        type Borrowed<'a> = &'a mut Self;
2030        fn take_or_borrow<'a>(
2031            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2032        ) -> Self::Borrowed<'a> {
2033            value
2034        }
2035    }
2036
2037    unsafe impl fidl::encoding::TypeMarker for NetworksWatchDefaultResponse {
2038        type Owned = Self;
2039
2040        #[inline(always)]
2041        fn inline_align(_context: fidl::encoding::Context) -> usize {
2042            8
2043        }
2044
2045        #[inline(always)]
2046        fn inline_size(_context: fidl::encoding::Context) -> usize {
2047            16
2048        }
2049    }
2050
2051    unsafe impl
2052        fidl::encoding::Encode<
2053            NetworksWatchDefaultResponse,
2054            fidl::encoding::DefaultFuchsiaResourceDialect,
2055        > for &mut NetworksWatchDefaultResponse
2056    {
2057        #[inline]
2058        unsafe fn encode(
2059            self,
2060            encoder: &mut fidl::encoding::Encoder<
2061                '_,
2062                fidl::encoding::DefaultFuchsiaResourceDialect,
2063            >,
2064            offset: usize,
2065            _depth: fidl::encoding::Depth,
2066        ) -> fidl::Result<()> {
2067            encoder.debug_check_bounds::<NetworksWatchDefaultResponse>(offset);
2068            encoder.write_num::<u64>(self.ordinal(), offset);
2069            match self {
2070                NetworksWatchDefaultResponse::Network(ref mut val) => {
2071                    fidl::encoding::encode_in_envelope::<
2072                        NetworkToken,
2073                        fidl::encoding::DefaultFuchsiaResourceDialect,
2074                    >(
2075                        <NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2076                        encoder,
2077                        offset + 8,
2078                        _depth,
2079                    )
2080                }
2081                NetworksWatchDefaultResponse::NoDefaultNetwork(ref val) => {
2082                    fidl::encoding::encode_in_envelope::<
2083                        Empty,
2084                        fidl::encoding::DefaultFuchsiaResourceDialect,
2085                    >(
2086                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2087                        encoder,
2088                        offset + 8,
2089                        _depth,
2090                    )
2091                }
2092                NetworksWatchDefaultResponse::__SourceBreaking { .. } => {
2093                    Err(fidl::Error::UnknownUnionTag)
2094                }
2095            }
2096        }
2097    }
2098
2099    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2100        for NetworksWatchDefaultResponse
2101    {
2102        #[inline(always)]
2103        fn new_empty() -> Self {
2104            Self::__SourceBreaking { unknown_ordinal: 0 }
2105        }
2106
2107        #[inline]
2108        unsafe fn decode(
2109            &mut self,
2110            decoder: &mut fidl::encoding::Decoder<
2111                '_,
2112                fidl::encoding::DefaultFuchsiaResourceDialect,
2113            >,
2114            offset: usize,
2115            mut depth: fidl::encoding::Depth,
2116        ) -> fidl::Result<()> {
2117            decoder.debug_check_bounds::<Self>(offset);
2118            #[allow(unused_variables)]
2119            let next_out_of_line = decoder.next_out_of_line();
2120            let handles_before = decoder.remaining_handles();
2121            let (ordinal, inlined, num_bytes, num_handles) =
2122                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2123
2124            let member_inline_size = match ordinal {
2125                1 => <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2126                2 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2127                0 => return Err(fidl::Error::UnknownUnionTag),
2128                _ => num_bytes as usize,
2129            };
2130
2131            if inlined != (member_inline_size <= 4) {
2132                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2133            }
2134            let _inner_offset;
2135            if inlined {
2136                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2137                _inner_offset = offset + 8;
2138            } else {
2139                depth.increment()?;
2140                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2141            }
2142            match ordinal {
2143                1 => {
2144                    #[allow(irrefutable_let_patterns)]
2145                    if let NetworksWatchDefaultResponse::Network(_) = self {
2146                        // Do nothing, read the value into the object
2147                    } else {
2148                        // Initialize `self` to the right variant
2149                        *self = NetworksWatchDefaultResponse::Network(fidl::new_empty!(
2150                            NetworkToken,
2151                            fidl::encoding::DefaultFuchsiaResourceDialect
2152                        ));
2153                    }
2154                    #[allow(irrefutable_let_patterns)]
2155                    if let NetworksWatchDefaultResponse::Network(ref mut val) = self {
2156                        fidl::decode!(
2157                            NetworkToken,
2158                            fidl::encoding::DefaultFuchsiaResourceDialect,
2159                            val,
2160                            decoder,
2161                            _inner_offset,
2162                            depth
2163                        )?;
2164                    } else {
2165                        unreachable!()
2166                    }
2167                }
2168                2 => {
2169                    #[allow(irrefutable_let_patterns)]
2170                    if let NetworksWatchDefaultResponse::NoDefaultNetwork(_) = self {
2171                        // Do nothing, read the value into the object
2172                    } else {
2173                        // Initialize `self` to the right variant
2174                        *self = NetworksWatchDefaultResponse::NoDefaultNetwork(fidl::new_empty!(
2175                            Empty,
2176                            fidl::encoding::DefaultFuchsiaResourceDialect
2177                        ));
2178                    }
2179                    #[allow(irrefutable_let_patterns)]
2180                    if let NetworksWatchDefaultResponse::NoDefaultNetwork(ref mut val) = self {
2181                        fidl::decode!(
2182                            Empty,
2183                            fidl::encoding::DefaultFuchsiaResourceDialect,
2184                            val,
2185                            decoder,
2186                            _inner_offset,
2187                            depth
2188                        )?;
2189                    } else {
2190                        unreachable!()
2191                    }
2192                }
2193                #[allow(deprecated)]
2194                ordinal => {
2195                    for _ in 0..num_handles {
2196                        decoder.drop_next_handle()?;
2197                    }
2198                    *self =
2199                        NetworksWatchDefaultResponse::__SourceBreaking { unknown_ordinal: ordinal };
2200                }
2201            }
2202            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2203                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2204            }
2205            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2206                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2207            }
2208            Ok(())
2209        }
2210    }
2211}