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