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