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, Eq, Hash, Ord, PartialEq, PartialOrd)]
47pub struct PrivilegedNetworkLookupLookupResponse {
48    pub network: NetworkToken,
49}
50
51impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
52    for PrivilegedNetworkLookupLookupResponse
53{
54}
55
56#[derive(Debug, Default, PartialEq)]
57pub struct NetworksWatchPropertiesRequest {
58    /// A network token acquired from [`WatchDefault`] or
59    /// [`PrivilegedNetworkLookup.Lookup`].
60    /// NOTE: REQUIRED
61    pub network: Option<NetworkToken>,
62    /// The set of properties for which changes should be reported.
63    /// NOTE: REQUIRED
64    pub properties: Option<PropertyInterest>,
65    /// The server end of the `PropertyWatcher`.
66    /// NOTE: REQUIRED
67    pub watcher: Option<fidl::endpoints::ServerEnd<PropertyWatcherMarker>>,
68    #[doc(hidden)]
69    pub __source_breaking: fidl::marker::SourceBreaking,
70}
71
72impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
73    for NetworksWatchPropertiesRequest
74{
75}
76
77#[derive(Debug)]
78pub enum NetworksWatchDefaultResponse {
79    Network(NetworkToken),
80    NoDefaultNetwork(Empty),
81    #[doc(hidden)]
82    __SourceBreaking {
83        unknown_ordinal: u64,
84    },
85}
86
87/// Pattern that matches an unknown `NetworksWatchDefaultResponse` member.
88#[macro_export]
89macro_rules! NetworksWatchDefaultResponseUnknown {
90    () => {
91        _
92    };
93}
94
95// Custom PartialEq so that unknown variants are not equal to themselves.
96impl PartialEq for NetworksWatchDefaultResponse {
97    fn eq(&self, other: &Self) -> bool {
98        match (self, other) {
99            (Self::Network(x), Self::Network(y)) => *x == *y,
100            (Self::NoDefaultNetwork(x), Self::NoDefaultNetwork(y)) => *x == *y,
101            _ => false,
102        }
103    }
104}
105
106impl NetworksWatchDefaultResponse {
107    #[inline]
108    pub fn ordinal(&self) -> u64 {
109        match *self {
110            Self::Network(_) => 1,
111            Self::NoDefaultNetwork(_) => 2,
112            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
113        }
114    }
115
116    #[inline]
117    pub fn unknown_variant_for_testing() -> Self {
118        Self::__SourceBreaking { unknown_ordinal: 0 }
119    }
120
121    #[inline]
122    pub fn is_unknown(&self) -> bool {
123        match self {
124            Self::__SourceBreaking { .. } => true,
125            _ => false,
126        }
127    }
128}
129
130impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
131    for NetworksWatchDefaultResponse
132{
133}
134
135#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
136pub struct NetworkRegistryMarker;
137
138impl fidl::endpoints::ProtocolMarker for NetworkRegistryMarker {
139    type Proxy = NetworkRegistryProxy;
140    type RequestStream = NetworkRegistryRequestStream;
141    #[cfg(target_os = "fuchsia")]
142    type SynchronousProxy = NetworkRegistrySynchronousProxy;
143
144    const DEBUG_NAME: &'static str = "fuchsia.net.policy.properties.NetworkRegistry";
145}
146impl fidl::endpoints::DiscoverableProtocolMarker for NetworkRegistryMarker {}
147pub type NetworkRegistrySetDefaultResult = Result<(), NetworkRegistrySetDefaultError>;
148pub type NetworkRegistryAddResult = Result<(), NetworkRegistryAddError>;
149pub type NetworkRegistryUpdateResult = Result<(), NetworkRegistryUpdateError>;
150pub type NetworkRegistryRemoveResult = Result<(), NetworkRegistryRemoveError>;
151
152pub trait NetworkRegistryProxyInterface: Send + Sync {
153    type SetDefaultResponseFut: std::future::Future<Output = Result<NetworkRegistrySetDefaultResult, fidl::Error>>
154        + Send;
155    fn r#set_default(
156        &self,
157        network_id: &fidl_fuchsia_posix_socket::OptionalUint32,
158    ) -> Self::SetDefaultResponseFut;
159    type AddResponseFut: std::future::Future<Output = Result<NetworkRegistryAddResult, fidl::Error>>
160        + Send;
161    fn r#add(&self, network: &Network) -> Self::AddResponseFut;
162    type UpdateResponseFut: std::future::Future<Output = Result<NetworkRegistryUpdateResult, fidl::Error>>
163        + Send;
164    fn r#update(&self, network: &Network) -> Self::UpdateResponseFut;
165    type RemoveResponseFut: std::future::Future<Output = Result<NetworkRegistryRemoveResult, fidl::Error>>
166        + Send;
167    fn r#remove(&self, network_id: u32) -> Self::RemoveResponseFut;
168}
169#[derive(Debug)]
170#[cfg(target_os = "fuchsia")]
171pub struct NetworkRegistrySynchronousProxy {
172    client: fidl::client::sync::Client,
173}
174
175#[cfg(target_os = "fuchsia")]
176impl fidl::endpoints::SynchronousProxy for NetworkRegistrySynchronousProxy {
177    type Proxy = NetworkRegistryProxy;
178    type Protocol = NetworkRegistryMarker;
179
180    fn from_channel(inner: fidl::Channel) -> Self {
181        Self::new(inner)
182    }
183
184    fn into_channel(self) -> fidl::Channel {
185        self.client.into_channel()
186    }
187
188    fn as_channel(&self) -> &fidl::Channel {
189        self.client.as_channel()
190    }
191}
192
193#[cfg(target_os = "fuchsia")]
194impl NetworkRegistrySynchronousProxy {
195    pub fn new(channel: fidl::Channel) -> Self {
196        Self { client: fidl::client::sync::Client::new(channel) }
197    }
198
199    pub fn into_channel(self) -> fidl::Channel {
200        self.client.into_channel()
201    }
202
203    /// Waits until an event arrives and returns it. It is safe for other
204    /// threads to make concurrent requests while waiting for an event.
205    pub fn wait_for_event(
206        &self,
207        deadline: zx::MonotonicInstant,
208    ) -> Result<NetworkRegistryEvent, fidl::Error> {
209        NetworkRegistryEvent::decode(self.client.wait_for_event::<NetworkRegistryMarker>(deadline)?)
210    }
211
212    /// Sets the default network.
213    ///
214    /// The network must have previously been registered by a call to `Add`.
215    pub fn r#set_default(
216        &self,
217        mut network_id: &fidl_fuchsia_posix_socket::OptionalUint32,
218        ___deadline: zx::MonotonicInstant,
219    ) -> Result<NetworkRegistrySetDefaultResult, fidl::Error> {
220        let _response =
221            self.client.send_query::<NetworkRegistrySetDefaultRequest, fidl::encoding::ResultType<
222                fidl::encoding::EmptyStruct,
223                NetworkRegistrySetDefaultError,
224            >, NetworkRegistryMarker>(
225                (network_id,),
226                0x76934538265b2f00,
227                fidl::encoding::DynamicFlags::empty(),
228                ___deadline,
229            )?;
230        Ok(_response.map(|x| x))
231    }
232
233    /// Add a new network.
234    ///
235    /// This call will not return until the DNS servers have been successfully
236    /// updated in netcfg.
237    pub fn r#add(
238        &self,
239        mut network: &Network,
240        ___deadline: zx::MonotonicInstant,
241    ) -> Result<NetworkRegistryAddResult, fidl::Error> {
242        let _response =
243            self.client.send_query::<NetworkRegistryAddRequest, fidl::encoding::ResultType<
244                fidl::encoding::EmptyStruct,
245                NetworkRegistryAddError,
246            >, NetworkRegistryMarker>(
247                (network,),
248                0x31a251a7d0f8fa36,
249                fidl::encoding::DynamicFlags::empty(),
250                ___deadline,
251            )?;
252        Ok(_response.map(|x| x))
253    }
254
255    /// Update a previously Added network.
256    ///
257    /// This call will not return until the DNS servers have been
258    /// successfully updated in netcfg.
259    pub fn r#update(
260        &self,
261        mut network: &Network,
262        ___deadline: zx::MonotonicInstant,
263    ) -> Result<NetworkRegistryUpdateResult, fidl::Error> {
264        let _response =
265            self.client.send_query::<NetworkRegistryUpdateRequest, fidl::encoding::ResultType<
266                fidl::encoding::EmptyStruct,
267                NetworkRegistryUpdateError,
268            >, NetworkRegistryMarker>(
269                (network,),
270                0x727f5ca0c0b2caa4,
271                fidl::encoding::DynamicFlags::empty(),
272                ___deadline,
273            )?;
274        Ok(_response.map(|x| x))
275    }
276
277    /// Remove a previously Added network.
278    ///
279    /// This call will not return until the DNS servers have been
280    /// successfully updated in netcfg.
281    pub fn r#remove(
282        &self,
283        mut network_id: u32,
284        ___deadline: zx::MonotonicInstant,
285    ) -> Result<NetworkRegistryRemoveResult, fidl::Error> {
286        let _response =
287            self.client.send_query::<NetworkRegistryRemoveRequest, fidl::encoding::ResultType<
288                fidl::encoding::EmptyStruct,
289                NetworkRegistryRemoveError,
290            >, NetworkRegistryMarker>(
291                (network_id,),
292                0xcf5055a455ce1c0,
293                fidl::encoding::DynamicFlags::empty(),
294                ___deadline,
295            )?;
296        Ok(_response.map(|x| x))
297    }
298}
299
300#[cfg(target_os = "fuchsia")]
301impl From<NetworkRegistrySynchronousProxy> for zx::NullableHandle {
302    fn from(value: NetworkRegistrySynchronousProxy) -> Self {
303        value.into_channel().into()
304    }
305}
306
307#[cfg(target_os = "fuchsia")]
308impl From<fidl::Channel> for NetworkRegistrySynchronousProxy {
309    fn from(value: fidl::Channel) -> Self {
310        Self::new(value)
311    }
312}
313
314#[cfg(target_os = "fuchsia")]
315impl fidl::endpoints::FromClient for NetworkRegistrySynchronousProxy {
316    type Protocol = NetworkRegistryMarker;
317
318    fn from_client(value: fidl::endpoints::ClientEnd<NetworkRegistryMarker>) -> Self {
319        Self::new(value.into_channel())
320    }
321}
322
323#[derive(Debug, Clone)]
324pub struct NetworkRegistryProxy {
325    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
326}
327
328impl fidl::endpoints::Proxy for NetworkRegistryProxy {
329    type Protocol = NetworkRegistryMarker;
330
331    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
332        Self::new(inner)
333    }
334
335    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
336        self.client.into_channel().map_err(|client| Self { client })
337    }
338
339    fn as_channel(&self) -> &::fidl::AsyncChannel {
340        self.client.as_channel()
341    }
342}
343
344impl NetworkRegistryProxy {
345    /// Create a new Proxy for fuchsia.net.policy.properties/NetworkRegistry.
346    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
347        let protocol_name = <NetworkRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
348        Self { client: fidl::client::Client::new(channel, protocol_name) }
349    }
350
351    /// Get a Stream of events from the remote end of the protocol.
352    ///
353    /// # Panics
354    ///
355    /// Panics if the event stream was already taken.
356    pub fn take_event_stream(&self) -> NetworkRegistryEventStream {
357        NetworkRegistryEventStream { event_receiver: self.client.take_event_receiver() }
358    }
359
360    /// Sets the default network.
361    ///
362    /// The network must have previously been registered by a call to `Add`.
363    pub fn r#set_default(
364        &self,
365        mut network_id: &fidl_fuchsia_posix_socket::OptionalUint32,
366    ) -> fidl::client::QueryResponseFut<
367        NetworkRegistrySetDefaultResult,
368        fidl::encoding::DefaultFuchsiaResourceDialect,
369    > {
370        NetworkRegistryProxyInterface::r#set_default(self, network_id)
371    }
372
373    /// Add a new network.
374    ///
375    /// This call will not return until the DNS servers have been successfully
376    /// updated in netcfg.
377    pub fn r#add(
378        &self,
379        mut network: &Network,
380    ) -> fidl::client::QueryResponseFut<
381        NetworkRegistryAddResult,
382        fidl::encoding::DefaultFuchsiaResourceDialect,
383    > {
384        NetworkRegistryProxyInterface::r#add(self, network)
385    }
386
387    /// Update a previously Added network.
388    ///
389    /// This call will not return until the DNS servers have been
390    /// successfully updated in netcfg.
391    pub fn r#update(
392        &self,
393        mut network: &Network,
394    ) -> fidl::client::QueryResponseFut<
395        NetworkRegistryUpdateResult,
396        fidl::encoding::DefaultFuchsiaResourceDialect,
397    > {
398        NetworkRegistryProxyInterface::r#update(self, network)
399    }
400
401    /// Remove a previously Added network.
402    ///
403    /// This call will not return until the DNS servers have been
404    /// successfully updated in netcfg.
405    pub fn r#remove(
406        &self,
407        mut network_id: u32,
408    ) -> fidl::client::QueryResponseFut<
409        NetworkRegistryRemoveResult,
410        fidl::encoding::DefaultFuchsiaResourceDialect,
411    > {
412        NetworkRegistryProxyInterface::r#remove(self, network_id)
413    }
414}
415
416impl NetworkRegistryProxyInterface for NetworkRegistryProxy {
417    type SetDefaultResponseFut = fidl::client::QueryResponseFut<
418        NetworkRegistrySetDefaultResult,
419        fidl::encoding::DefaultFuchsiaResourceDialect,
420    >;
421    fn r#set_default(
422        &self,
423        mut network_id: &fidl_fuchsia_posix_socket::OptionalUint32,
424    ) -> Self::SetDefaultResponseFut {
425        fn _decode(
426            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
427        ) -> Result<NetworkRegistrySetDefaultResult, fidl::Error> {
428            let _response = fidl::client::decode_transaction_body::<
429                fidl::encoding::ResultType<
430                    fidl::encoding::EmptyStruct,
431                    NetworkRegistrySetDefaultError,
432                >,
433                fidl::encoding::DefaultFuchsiaResourceDialect,
434                0x76934538265b2f00,
435            >(_buf?)?;
436            Ok(_response.map(|x| x))
437        }
438        self.client.send_query_and_decode::<
439            NetworkRegistrySetDefaultRequest,
440            NetworkRegistrySetDefaultResult,
441        >(
442            (network_id,),
443            0x76934538265b2f00,
444            fidl::encoding::DynamicFlags::empty(),
445            _decode,
446        )
447    }
448
449    type AddResponseFut = fidl::client::QueryResponseFut<
450        NetworkRegistryAddResult,
451        fidl::encoding::DefaultFuchsiaResourceDialect,
452    >;
453    fn r#add(&self, mut network: &Network) -> Self::AddResponseFut {
454        fn _decode(
455            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
456        ) -> Result<NetworkRegistryAddResult, fidl::Error> {
457            let _response = fidl::client::decode_transaction_body::<
458                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, NetworkRegistryAddError>,
459                fidl::encoding::DefaultFuchsiaResourceDialect,
460                0x31a251a7d0f8fa36,
461            >(_buf?)?;
462            Ok(_response.map(|x| x))
463        }
464        self.client.send_query_and_decode::<NetworkRegistryAddRequest, NetworkRegistryAddResult>(
465            (network,),
466            0x31a251a7d0f8fa36,
467            fidl::encoding::DynamicFlags::empty(),
468            _decode,
469        )
470    }
471
472    type UpdateResponseFut = fidl::client::QueryResponseFut<
473        NetworkRegistryUpdateResult,
474        fidl::encoding::DefaultFuchsiaResourceDialect,
475    >;
476    fn r#update(&self, mut network: &Network) -> Self::UpdateResponseFut {
477        fn _decode(
478            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
479        ) -> Result<NetworkRegistryUpdateResult, fidl::Error> {
480            let _response = fidl::client::decode_transaction_body::<
481                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, NetworkRegistryUpdateError>,
482                fidl::encoding::DefaultFuchsiaResourceDialect,
483                0x727f5ca0c0b2caa4,
484            >(_buf?)?;
485            Ok(_response.map(|x| x))
486        }
487        self.client
488            .send_query_and_decode::<NetworkRegistryUpdateRequest, NetworkRegistryUpdateResult>(
489                (network,),
490                0x727f5ca0c0b2caa4,
491                fidl::encoding::DynamicFlags::empty(),
492                _decode,
493            )
494    }
495
496    type RemoveResponseFut = fidl::client::QueryResponseFut<
497        NetworkRegistryRemoveResult,
498        fidl::encoding::DefaultFuchsiaResourceDialect,
499    >;
500    fn r#remove(&self, mut network_id: u32) -> Self::RemoveResponseFut {
501        fn _decode(
502            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
503        ) -> Result<NetworkRegistryRemoveResult, fidl::Error> {
504            let _response = fidl::client::decode_transaction_body::<
505                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, NetworkRegistryRemoveError>,
506                fidl::encoding::DefaultFuchsiaResourceDialect,
507                0xcf5055a455ce1c0,
508            >(_buf?)?;
509            Ok(_response.map(|x| x))
510        }
511        self.client
512            .send_query_and_decode::<NetworkRegistryRemoveRequest, NetworkRegistryRemoveResult>(
513                (network_id,),
514                0xcf5055a455ce1c0,
515                fidl::encoding::DynamicFlags::empty(),
516                _decode,
517            )
518    }
519}
520
521pub struct NetworkRegistryEventStream {
522    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
523}
524
525impl std::marker::Unpin for NetworkRegistryEventStream {}
526
527impl futures::stream::FusedStream for NetworkRegistryEventStream {
528    fn is_terminated(&self) -> bool {
529        self.event_receiver.is_terminated()
530    }
531}
532
533impl futures::Stream for NetworkRegistryEventStream {
534    type Item = Result<NetworkRegistryEvent, fidl::Error>;
535
536    fn poll_next(
537        mut self: std::pin::Pin<&mut Self>,
538        cx: &mut std::task::Context<'_>,
539    ) -> std::task::Poll<Option<Self::Item>> {
540        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
541            &mut self.event_receiver,
542            cx
543        )?) {
544            Some(buf) => std::task::Poll::Ready(Some(NetworkRegistryEvent::decode(buf))),
545            None => std::task::Poll::Ready(None),
546        }
547    }
548}
549
550#[derive(Debug)]
551pub enum NetworkRegistryEvent {}
552
553impl NetworkRegistryEvent {
554    /// Decodes a message buffer as a [`NetworkRegistryEvent`].
555    fn decode(
556        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
557    ) -> Result<NetworkRegistryEvent, fidl::Error> {
558        let (bytes, _handles) = buf.split_mut();
559        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
560        debug_assert_eq!(tx_header.tx_id, 0);
561        match tx_header.ordinal {
562            _ => Err(fidl::Error::UnknownOrdinal {
563                ordinal: tx_header.ordinal,
564                protocol_name:
565                    <NetworkRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
566            }),
567        }
568    }
569}
570
571/// A Stream of incoming requests for fuchsia.net.policy.properties/NetworkRegistry.
572pub struct NetworkRegistryRequestStream {
573    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
574    is_terminated: bool,
575}
576
577impl std::marker::Unpin for NetworkRegistryRequestStream {}
578
579impl futures::stream::FusedStream for NetworkRegistryRequestStream {
580    fn is_terminated(&self) -> bool {
581        self.is_terminated
582    }
583}
584
585impl fidl::endpoints::RequestStream for NetworkRegistryRequestStream {
586    type Protocol = NetworkRegistryMarker;
587    type ControlHandle = NetworkRegistryControlHandle;
588
589    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
590        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
591    }
592
593    fn control_handle(&self) -> Self::ControlHandle {
594        NetworkRegistryControlHandle { inner: self.inner.clone() }
595    }
596
597    fn into_inner(
598        self,
599    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
600    {
601        (self.inner, self.is_terminated)
602    }
603
604    fn from_inner(
605        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
606        is_terminated: bool,
607    ) -> Self {
608        Self { inner, is_terminated }
609    }
610}
611
612impl futures::Stream for NetworkRegistryRequestStream {
613    type Item = Result<NetworkRegistryRequest, fidl::Error>;
614
615    fn poll_next(
616        mut self: std::pin::Pin<&mut Self>,
617        cx: &mut std::task::Context<'_>,
618    ) -> std::task::Poll<Option<Self::Item>> {
619        let this = &mut *self;
620        if this.inner.check_shutdown(cx) {
621            this.is_terminated = true;
622            return std::task::Poll::Ready(None);
623        }
624        if this.is_terminated {
625            panic!("polled NetworkRegistryRequestStream after completion");
626        }
627        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
628            |bytes, handles| {
629                match this.inner.channel().read_etc(cx, bytes, handles) {
630                    std::task::Poll::Ready(Ok(())) => {}
631                    std::task::Poll::Pending => return std::task::Poll::Pending,
632                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
633                        this.is_terminated = true;
634                        return std::task::Poll::Ready(None);
635                    }
636                    std::task::Poll::Ready(Err(e)) => {
637                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
638                            e.into(),
639                        ))));
640                    }
641                }
642
643                // A message has been received from the channel
644                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
645
646                std::task::Poll::Ready(Some(match header.ordinal {
647                    0x76934538265b2f00 => {
648                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
649                        let mut req = fidl::new_empty!(
650                            NetworkRegistrySetDefaultRequest,
651                            fidl::encoding::DefaultFuchsiaResourceDialect
652                        );
653                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkRegistrySetDefaultRequest>(&header, _body_bytes, handles, &mut req)?;
654                        let control_handle =
655                            NetworkRegistryControlHandle { inner: this.inner.clone() };
656                        Ok(NetworkRegistryRequest::SetDefault {
657                            network_id: req.network_id,
658
659                            responder: NetworkRegistrySetDefaultResponder {
660                                control_handle: std::mem::ManuallyDrop::new(control_handle),
661                                tx_id: header.tx_id,
662                            },
663                        })
664                    }
665                    0x31a251a7d0f8fa36 => {
666                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
667                        let mut req = fidl::new_empty!(
668                            NetworkRegistryAddRequest,
669                            fidl::encoding::DefaultFuchsiaResourceDialect
670                        );
671                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkRegistryAddRequest>(&header, _body_bytes, handles, &mut req)?;
672                        let control_handle =
673                            NetworkRegistryControlHandle { inner: this.inner.clone() };
674                        Ok(NetworkRegistryRequest::Add {
675                            network: req.network,
676
677                            responder: NetworkRegistryAddResponder {
678                                control_handle: std::mem::ManuallyDrop::new(control_handle),
679                                tx_id: header.tx_id,
680                            },
681                        })
682                    }
683                    0x727f5ca0c0b2caa4 => {
684                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
685                        let mut req = fidl::new_empty!(
686                            NetworkRegistryUpdateRequest,
687                            fidl::encoding::DefaultFuchsiaResourceDialect
688                        );
689                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkRegistryUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
690                        let control_handle =
691                            NetworkRegistryControlHandle { inner: this.inner.clone() };
692                        Ok(NetworkRegistryRequest::Update {
693                            network: req.network,
694
695                            responder: NetworkRegistryUpdateResponder {
696                                control_handle: std::mem::ManuallyDrop::new(control_handle),
697                                tx_id: header.tx_id,
698                            },
699                        })
700                    }
701                    0xcf5055a455ce1c0 => {
702                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
703                        let mut req = fidl::new_empty!(
704                            NetworkRegistryRemoveRequest,
705                            fidl::encoding::DefaultFuchsiaResourceDialect
706                        );
707                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkRegistryRemoveRequest>(&header, _body_bytes, handles, &mut req)?;
708                        let control_handle =
709                            NetworkRegistryControlHandle { inner: this.inner.clone() };
710                        Ok(NetworkRegistryRequest::Remove {
711                            network_id: req.network_id,
712
713                            responder: NetworkRegistryRemoveResponder {
714                                control_handle: std::mem::ManuallyDrop::new(control_handle),
715                                tx_id: header.tx_id,
716                            },
717                        })
718                    }
719                    _ => Err(fidl::Error::UnknownOrdinal {
720                        ordinal: header.ordinal,
721                        protocol_name:
722                            <NetworkRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
723                    }),
724                }))
725            },
726        )
727    }
728}
729
730#[derive(Debug)]
731pub enum NetworkRegistryRequest {
732    /// Sets the default network.
733    ///
734    /// The network must have previously been registered by a call to `Add`.
735    SetDefault {
736        network_id: fidl_fuchsia_posix_socket::OptionalUint32,
737        responder: NetworkRegistrySetDefaultResponder,
738    },
739    /// Add a new network.
740    ///
741    /// This call will not return until the DNS servers have been successfully
742    /// updated in netcfg.
743    Add { network: Network, responder: NetworkRegistryAddResponder },
744    /// Update a previously Added network.
745    ///
746    /// This call will not return until the DNS servers have been
747    /// successfully updated in netcfg.
748    Update { network: Network, responder: NetworkRegistryUpdateResponder },
749    /// Remove a previously Added network.
750    ///
751    /// This call will not return until the DNS servers have been
752    /// successfully updated in netcfg.
753    Remove { network_id: u32, responder: NetworkRegistryRemoveResponder },
754}
755
756impl NetworkRegistryRequest {
757    #[allow(irrefutable_let_patterns)]
758    pub fn into_set_default(
759        self,
760    ) -> Option<(fidl_fuchsia_posix_socket::OptionalUint32, NetworkRegistrySetDefaultResponder)>
761    {
762        if let NetworkRegistryRequest::SetDefault { network_id, responder } = self {
763            Some((network_id, responder))
764        } else {
765            None
766        }
767    }
768
769    #[allow(irrefutable_let_patterns)]
770    pub fn into_add(self) -> Option<(Network, NetworkRegistryAddResponder)> {
771        if let NetworkRegistryRequest::Add { network, responder } = self {
772            Some((network, responder))
773        } else {
774            None
775        }
776    }
777
778    #[allow(irrefutable_let_patterns)]
779    pub fn into_update(self) -> Option<(Network, NetworkRegistryUpdateResponder)> {
780        if let NetworkRegistryRequest::Update { network, responder } = self {
781            Some((network, responder))
782        } else {
783            None
784        }
785    }
786
787    #[allow(irrefutable_let_patterns)]
788    pub fn into_remove(self) -> Option<(u32, NetworkRegistryRemoveResponder)> {
789        if let NetworkRegistryRequest::Remove { network_id, responder } = self {
790            Some((network_id, responder))
791        } else {
792            None
793        }
794    }
795
796    /// Name of the method defined in FIDL
797    pub fn method_name(&self) -> &'static str {
798        match *self {
799            NetworkRegistryRequest::SetDefault { .. } => "set_default",
800            NetworkRegistryRequest::Add { .. } => "add",
801            NetworkRegistryRequest::Update { .. } => "update",
802            NetworkRegistryRequest::Remove { .. } => "remove",
803        }
804    }
805}
806
807#[derive(Debug, Clone)]
808pub struct NetworkRegistryControlHandle {
809    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
810}
811
812impl NetworkRegistryControlHandle {
813    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
814        self.inner.shutdown_with_epitaph(status.into())
815    }
816}
817
818impl fidl::endpoints::ControlHandle for NetworkRegistryControlHandle {
819    fn shutdown(&self) {
820        self.inner.shutdown()
821    }
822
823    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
824        self.inner.shutdown_with_epitaph(status)
825    }
826
827    fn is_closed(&self) -> bool {
828        self.inner.channel().is_closed()
829    }
830    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
831        self.inner.channel().on_closed()
832    }
833
834    #[cfg(target_os = "fuchsia")]
835    fn signal_peer(
836        &self,
837        clear_mask: zx::Signals,
838        set_mask: zx::Signals,
839    ) -> Result<(), zx_status::Status> {
840        use fidl::Peered;
841        self.inner.channel().signal_peer(clear_mask, set_mask)
842    }
843}
844
845impl NetworkRegistryControlHandle {}
846
847#[must_use = "FIDL methods require a response to be sent"]
848#[derive(Debug)]
849pub struct NetworkRegistrySetDefaultResponder {
850    control_handle: std::mem::ManuallyDrop<NetworkRegistryControlHandle>,
851    tx_id: u32,
852}
853
854/// Set the the channel to be shutdown (see [`NetworkRegistryControlHandle::shutdown`])
855/// if the responder is dropped without sending a response, so that the client
856/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
857impl std::ops::Drop for NetworkRegistrySetDefaultResponder {
858    fn drop(&mut self) {
859        self.control_handle.shutdown();
860        // Safety: drops once, never accessed again
861        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
862    }
863}
864
865impl fidl::endpoints::Responder for NetworkRegistrySetDefaultResponder {
866    type ControlHandle = NetworkRegistryControlHandle;
867
868    fn control_handle(&self) -> &NetworkRegistryControlHandle {
869        &self.control_handle
870    }
871
872    fn drop_without_shutdown(mut self) {
873        // Safety: drops once, never accessed again due to mem::forget
874        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
875        // Prevent Drop from running (which would shut down the channel)
876        std::mem::forget(self);
877    }
878}
879
880impl NetworkRegistrySetDefaultResponder {
881    /// Sends a response to the FIDL transaction.
882    ///
883    /// Sets the channel to shutdown if an error occurs.
884    pub fn send(
885        self,
886        mut result: Result<(), NetworkRegistrySetDefaultError>,
887    ) -> Result<(), fidl::Error> {
888        let _result = self.send_raw(result);
889        if _result.is_err() {
890            self.control_handle.shutdown();
891        }
892        self.drop_without_shutdown();
893        _result
894    }
895
896    /// Similar to "send" but does not shutdown the channel if an error occurs.
897    pub fn send_no_shutdown_on_err(
898        self,
899        mut result: Result<(), NetworkRegistrySetDefaultError>,
900    ) -> Result<(), fidl::Error> {
901        let _result = self.send_raw(result);
902        self.drop_without_shutdown();
903        _result
904    }
905
906    fn send_raw(
907        &self,
908        mut result: Result<(), NetworkRegistrySetDefaultError>,
909    ) -> Result<(), fidl::Error> {
910        self.control_handle.inner.send::<fidl::encoding::ResultType<
911            fidl::encoding::EmptyStruct,
912            NetworkRegistrySetDefaultError,
913        >>(
914            result,
915            self.tx_id,
916            0x76934538265b2f00,
917            fidl::encoding::DynamicFlags::empty(),
918        )
919    }
920}
921
922#[must_use = "FIDL methods require a response to be sent"]
923#[derive(Debug)]
924pub struct NetworkRegistryAddResponder {
925    control_handle: std::mem::ManuallyDrop<NetworkRegistryControlHandle>,
926    tx_id: u32,
927}
928
929/// Set the the channel to be shutdown (see [`NetworkRegistryControlHandle::shutdown`])
930/// if the responder is dropped without sending a response, so that the client
931/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
932impl std::ops::Drop for NetworkRegistryAddResponder {
933    fn drop(&mut self) {
934        self.control_handle.shutdown();
935        // Safety: drops once, never accessed again
936        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
937    }
938}
939
940impl fidl::endpoints::Responder for NetworkRegistryAddResponder {
941    type ControlHandle = NetworkRegistryControlHandle;
942
943    fn control_handle(&self) -> &NetworkRegistryControlHandle {
944        &self.control_handle
945    }
946
947    fn drop_without_shutdown(mut self) {
948        // Safety: drops once, never accessed again due to mem::forget
949        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
950        // Prevent Drop from running (which would shut down the channel)
951        std::mem::forget(self);
952    }
953}
954
955impl NetworkRegistryAddResponder {
956    /// Sends a response to the FIDL transaction.
957    ///
958    /// Sets the channel to shutdown if an error occurs.
959    pub fn send(self, mut result: Result<(), NetworkRegistryAddError>) -> Result<(), fidl::Error> {
960        let _result = self.send_raw(result);
961        if _result.is_err() {
962            self.control_handle.shutdown();
963        }
964        self.drop_without_shutdown();
965        _result
966    }
967
968    /// Similar to "send" but does not shutdown the channel if an error occurs.
969    pub fn send_no_shutdown_on_err(
970        self,
971        mut result: Result<(), NetworkRegistryAddError>,
972    ) -> Result<(), fidl::Error> {
973        let _result = self.send_raw(result);
974        self.drop_without_shutdown();
975        _result
976    }
977
978    fn send_raw(&self, mut result: Result<(), NetworkRegistryAddError>) -> Result<(), fidl::Error> {
979        self.control_handle.inner.send::<fidl::encoding::ResultType<
980            fidl::encoding::EmptyStruct,
981            NetworkRegistryAddError,
982        >>(
983            result,
984            self.tx_id,
985            0x31a251a7d0f8fa36,
986            fidl::encoding::DynamicFlags::empty(),
987        )
988    }
989}
990
991#[must_use = "FIDL methods require a response to be sent"]
992#[derive(Debug)]
993pub struct NetworkRegistryUpdateResponder {
994    control_handle: std::mem::ManuallyDrop<NetworkRegistryControlHandle>,
995    tx_id: u32,
996}
997
998/// Set the the channel to be shutdown (see [`NetworkRegistryControlHandle::shutdown`])
999/// if the responder is dropped without sending a response, so that the client
1000/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1001impl std::ops::Drop for NetworkRegistryUpdateResponder {
1002    fn drop(&mut self) {
1003        self.control_handle.shutdown();
1004        // Safety: drops once, never accessed again
1005        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1006    }
1007}
1008
1009impl fidl::endpoints::Responder for NetworkRegistryUpdateResponder {
1010    type ControlHandle = NetworkRegistryControlHandle;
1011
1012    fn control_handle(&self) -> &NetworkRegistryControlHandle {
1013        &self.control_handle
1014    }
1015
1016    fn drop_without_shutdown(mut self) {
1017        // Safety: drops once, never accessed again due to mem::forget
1018        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1019        // Prevent Drop from running (which would shut down the channel)
1020        std::mem::forget(self);
1021    }
1022}
1023
1024impl NetworkRegistryUpdateResponder {
1025    /// Sends a response to the FIDL transaction.
1026    ///
1027    /// Sets the channel to shutdown if an error occurs.
1028    pub fn send(
1029        self,
1030        mut result: Result<(), NetworkRegistryUpdateError>,
1031    ) -> Result<(), fidl::Error> {
1032        let _result = self.send_raw(result);
1033        if _result.is_err() {
1034            self.control_handle.shutdown();
1035        }
1036        self.drop_without_shutdown();
1037        _result
1038    }
1039
1040    /// Similar to "send" but does not shutdown the channel if an error occurs.
1041    pub fn send_no_shutdown_on_err(
1042        self,
1043        mut result: Result<(), NetworkRegistryUpdateError>,
1044    ) -> Result<(), fidl::Error> {
1045        let _result = self.send_raw(result);
1046        self.drop_without_shutdown();
1047        _result
1048    }
1049
1050    fn send_raw(
1051        &self,
1052        mut result: Result<(), NetworkRegistryUpdateError>,
1053    ) -> Result<(), fidl::Error> {
1054        self.control_handle.inner.send::<fidl::encoding::ResultType<
1055            fidl::encoding::EmptyStruct,
1056            NetworkRegistryUpdateError,
1057        >>(
1058            result,
1059            self.tx_id,
1060            0x727f5ca0c0b2caa4,
1061            fidl::encoding::DynamicFlags::empty(),
1062        )
1063    }
1064}
1065
1066#[must_use = "FIDL methods require a response to be sent"]
1067#[derive(Debug)]
1068pub struct NetworkRegistryRemoveResponder {
1069    control_handle: std::mem::ManuallyDrop<NetworkRegistryControlHandle>,
1070    tx_id: u32,
1071}
1072
1073/// Set the the channel to be shutdown (see [`NetworkRegistryControlHandle::shutdown`])
1074/// if the responder is dropped without sending a response, so that the client
1075/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1076impl std::ops::Drop for NetworkRegistryRemoveResponder {
1077    fn drop(&mut self) {
1078        self.control_handle.shutdown();
1079        // Safety: drops once, never accessed again
1080        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1081    }
1082}
1083
1084impl fidl::endpoints::Responder for NetworkRegistryRemoveResponder {
1085    type ControlHandle = NetworkRegistryControlHandle;
1086
1087    fn control_handle(&self) -> &NetworkRegistryControlHandle {
1088        &self.control_handle
1089    }
1090
1091    fn drop_without_shutdown(mut self) {
1092        // Safety: drops once, never accessed again due to mem::forget
1093        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1094        // Prevent Drop from running (which would shut down the channel)
1095        std::mem::forget(self);
1096    }
1097}
1098
1099impl NetworkRegistryRemoveResponder {
1100    /// Sends a response to the FIDL transaction.
1101    ///
1102    /// Sets the channel to shutdown if an error occurs.
1103    pub fn send(
1104        self,
1105        mut result: Result<(), NetworkRegistryRemoveError>,
1106    ) -> Result<(), fidl::Error> {
1107        let _result = self.send_raw(result);
1108        if _result.is_err() {
1109            self.control_handle.shutdown();
1110        }
1111        self.drop_without_shutdown();
1112        _result
1113    }
1114
1115    /// Similar to "send" but does not shutdown the channel if an error occurs.
1116    pub fn send_no_shutdown_on_err(
1117        self,
1118        mut result: Result<(), NetworkRegistryRemoveError>,
1119    ) -> Result<(), fidl::Error> {
1120        let _result = self.send_raw(result);
1121        self.drop_without_shutdown();
1122        _result
1123    }
1124
1125    fn send_raw(
1126        &self,
1127        mut result: Result<(), NetworkRegistryRemoveError>,
1128    ) -> Result<(), fidl::Error> {
1129        self.control_handle.inner.send::<fidl::encoding::ResultType<
1130            fidl::encoding::EmptyStruct,
1131            NetworkRegistryRemoveError,
1132        >>(
1133            result,
1134            self.tx_id,
1135            0xcf5055a455ce1c0,
1136            fidl::encoding::DynamicFlags::empty(),
1137        )
1138    }
1139}
1140
1141#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1142pub struct NetworkTokenResolverMarker;
1143
1144impl fidl::endpoints::ProtocolMarker for NetworkTokenResolverMarker {
1145    type Proxy = NetworkTokenResolverProxy;
1146    type RequestStream = NetworkTokenResolverRequestStream;
1147    #[cfg(target_os = "fuchsia")]
1148    type SynchronousProxy = NetworkTokenResolverSynchronousProxy;
1149
1150    const DEBUG_NAME: &'static str = "fuchsia.net.policy.properties.NetworkTokenResolver";
1151}
1152impl fidl::endpoints::DiscoverableProtocolMarker for NetworkTokenResolverMarker {}
1153pub type NetworkTokenResolverResolveTokenResult =
1154    Result<NetworkToken, NetworkTokenResolverResolveTokenError>;
1155
1156pub trait NetworkTokenResolverProxyInterface: Send + Sync {
1157    type ResolveTokenResponseFut: std::future::Future<Output = Result<NetworkTokenResolverResolveTokenResult, fidl::Error>>
1158        + Send;
1159    fn r#resolve_token(&self, token: NetworkToken) -> Self::ResolveTokenResponseFut;
1160}
1161#[derive(Debug)]
1162#[cfg(target_os = "fuchsia")]
1163pub struct NetworkTokenResolverSynchronousProxy {
1164    client: fidl::client::sync::Client,
1165}
1166
1167#[cfg(target_os = "fuchsia")]
1168impl fidl::endpoints::SynchronousProxy for NetworkTokenResolverSynchronousProxy {
1169    type Proxy = NetworkTokenResolverProxy;
1170    type Protocol = NetworkTokenResolverMarker;
1171
1172    fn from_channel(inner: fidl::Channel) -> Self {
1173        Self::new(inner)
1174    }
1175
1176    fn into_channel(self) -> fidl::Channel {
1177        self.client.into_channel()
1178    }
1179
1180    fn as_channel(&self) -> &fidl::Channel {
1181        self.client.as_channel()
1182    }
1183}
1184
1185#[cfg(target_os = "fuchsia")]
1186impl NetworkTokenResolverSynchronousProxy {
1187    pub fn new(channel: fidl::Channel) -> Self {
1188        Self { client: fidl::client::sync::Client::new(channel) }
1189    }
1190
1191    pub fn into_channel(self) -> fidl::Channel {
1192        self.client.into_channel()
1193    }
1194
1195    /// Waits until an event arrives and returns it. It is safe for other
1196    /// threads to make concurrent requests while waiting for an event.
1197    pub fn wait_for_event(
1198        &self,
1199        deadline: zx::MonotonicInstant,
1200    ) -> Result<NetworkTokenResolverEvent, fidl::Error> {
1201        NetworkTokenResolverEvent::decode(
1202            self.client.wait_for_event::<NetworkTokenResolverMarker>(deadline)?,
1203        )
1204    }
1205
1206    /// Resolves a network token to a canonical form.
1207    ///
1208    /// Since a "default network" network token is a distinct token from the
1209    /// non-default network variant, there needs to be a way to disambiguate
1210    /// the pair.
1211    ///
1212    /// Since a "default network" token (i.e. a token obtained from
1213    /// [`Networks.WatchDefault`]) is a distinct token from the non-default
1214    /// network variant, there needs to be a way to disambiguate the pair. If a
1215    /// non-default network token is passed, the same token is returned.
1216    pub fn r#resolve_token(
1217        &self,
1218        mut token: NetworkToken,
1219        ___deadline: zx::MonotonicInstant,
1220    ) -> Result<NetworkTokenResolverResolveTokenResult, fidl::Error> {
1221        let _response = self
1222            .client
1223            .send_query::<NetworkTokenResolverResolveTokenRequest, fidl::encoding::ResultType<
1224                NetworkTokenResolverResolveTokenResponse,
1225                NetworkTokenResolverResolveTokenError,
1226            >, NetworkTokenResolverMarker>(
1227                (&mut token,),
1228                0x4176f67517941bac,
1229                fidl::encoding::DynamicFlags::empty(),
1230                ___deadline,
1231            )?;
1232        Ok(_response.map(|x| x.resolved_token))
1233    }
1234}
1235
1236#[cfg(target_os = "fuchsia")]
1237impl From<NetworkTokenResolverSynchronousProxy> for zx::NullableHandle {
1238    fn from(value: NetworkTokenResolverSynchronousProxy) -> Self {
1239        value.into_channel().into()
1240    }
1241}
1242
1243#[cfg(target_os = "fuchsia")]
1244impl From<fidl::Channel> for NetworkTokenResolverSynchronousProxy {
1245    fn from(value: fidl::Channel) -> Self {
1246        Self::new(value)
1247    }
1248}
1249
1250#[cfg(target_os = "fuchsia")]
1251impl fidl::endpoints::FromClient for NetworkTokenResolverSynchronousProxy {
1252    type Protocol = NetworkTokenResolverMarker;
1253
1254    fn from_client(value: fidl::endpoints::ClientEnd<NetworkTokenResolverMarker>) -> Self {
1255        Self::new(value.into_channel())
1256    }
1257}
1258
1259#[derive(Debug, Clone)]
1260pub struct NetworkTokenResolverProxy {
1261    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1262}
1263
1264impl fidl::endpoints::Proxy for NetworkTokenResolverProxy {
1265    type Protocol = NetworkTokenResolverMarker;
1266
1267    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1268        Self::new(inner)
1269    }
1270
1271    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1272        self.client.into_channel().map_err(|client| Self { client })
1273    }
1274
1275    fn as_channel(&self) -> &::fidl::AsyncChannel {
1276        self.client.as_channel()
1277    }
1278}
1279
1280impl NetworkTokenResolverProxy {
1281    /// Create a new Proxy for fuchsia.net.policy.properties/NetworkTokenResolver.
1282    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1283        let protocol_name =
1284            <NetworkTokenResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1285        Self { client: fidl::client::Client::new(channel, protocol_name) }
1286    }
1287
1288    /// Get a Stream of events from the remote end of the protocol.
1289    ///
1290    /// # Panics
1291    ///
1292    /// Panics if the event stream was already taken.
1293    pub fn take_event_stream(&self) -> NetworkTokenResolverEventStream {
1294        NetworkTokenResolverEventStream { event_receiver: self.client.take_event_receiver() }
1295    }
1296
1297    /// Resolves a network token to a canonical form.
1298    ///
1299    /// Since a "default network" network token is a distinct token from the
1300    /// non-default network variant, there needs to be a way to disambiguate
1301    /// the pair.
1302    ///
1303    /// Since a "default network" token (i.e. a token obtained from
1304    /// [`Networks.WatchDefault`]) is a distinct token from the non-default
1305    /// network variant, there needs to be a way to disambiguate the pair. If a
1306    /// non-default network token is passed, the same token is returned.
1307    pub fn r#resolve_token(
1308        &self,
1309        mut token: NetworkToken,
1310    ) -> fidl::client::QueryResponseFut<
1311        NetworkTokenResolverResolveTokenResult,
1312        fidl::encoding::DefaultFuchsiaResourceDialect,
1313    > {
1314        NetworkTokenResolverProxyInterface::r#resolve_token(self, token)
1315    }
1316}
1317
1318impl NetworkTokenResolverProxyInterface for NetworkTokenResolverProxy {
1319    type ResolveTokenResponseFut = fidl::client::QueryResponseFut<
1320        NetworkTokenResolverResolveTokenResult,
1321        fidl::encoding::DefaultFuchsiaResourceDialect,
1322    >;
1323    fn r#resolve_token(&self, mut token: NetworkToken) -> Self::ResolveTokenResponseFut {
1324        fn _decode(
1325            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1326        ) -> Result<NetworkTokenResolverResolveTokenResult, fidl::Error> {
1327            let _response = fidl::client::decode_transaction_body::<
1328                fidl::encoding::ResultType<
1329                    NetworkTokenResolverResolveTokenResponse,
1330                    NetworkTokenResolverResolveTokenError,
1331                >,
1332                fidl::encoding::DefaultFuchsiaResourceDialect,
1333                0x4176f67517941bac,
1334            >(_buf?)?;
1335            Ok(_response.map(|x| x.resolved_token))
1336        }
1337        self.client.send_query_and_decode::<
1338            NetworkTokenResolverResolveTokenRequest,
1339            NetworkTokenResolverResolveTokenResult,
1340        >(
1341            (&mut token,),
1342            0x4176f67517941bac,
1343            fidl::encoding::DynamicFlags::empty(),
1344            _decode,
1345        )
1346    }
1347}
1348
1349pub struct NetworkTokenResolverEventStream {
1350    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1351}
1352
1353impl std::marker::Unpin for NetworkTokenResolverEventStream {}
1354
1355impl futures::stream::FusedStream for NetworkTokenResolverEventStream {
1356    fn is_terminated(&self) -> bool {
1357        self.event_receiver.is_terminated()
1358    }
1359}
1360
1361impl futures::Stream for NetworkTokenResolverEventStream {
1362    type Item = Result<NetworkTokenResolverEvent, fidl::Error>;
1363
1364    fn poll_next(
1365        mut self: std::pin::Pin<&mut Self>,
1366        cx: &mut std::task::Context<'_>,
1367    ) -> std::task::Poll<Option<Self::Item>> {
1368        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1369            &mut self.event_receiver,
1370            cx
1371        )?) {
1372            Some(buf) => std::task::Poll::Ready(Some(NetworkTokenResolverEvent::decode(buf))),
1373            None => std::task::Poll::Ready(None),
1374        }
1375    }
1376}
1377
1378#[derive(Debug)]
1379pub enum NetworkTokenResolverEvent {
1380    #[non_exhaustive]
1381    _UnknownEvent {
1382        /// Ordinal of the event that was sent.
1383        ordinal: u64,
1384    },
1385}
1386
1387impl NetworkTokenResolverEvent {
1388    /// Decodes a message buffer as a [`NetworkTokenResolverEvent`].
1389    fn decode(
1390        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1391    ) -> Result<NetworkTokenResolverEvent, fidl::Error> {
1392        let (bytes, _handles) = buf.split_mut();
1393        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1394        debug_assert_eq!(tx_header.tx_id, 0);
1395        match tx_header.ordinal {
1396            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1397                Ok(NetworkTokenResolverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1398            }
1399            _ => Err(fidl::Error::UnknownOrdinal {
1400                ordinal: tx_header.ordinal,
1401                protocol_name:
1402                    <NetworkTokenResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1403            }),
1404        }
1405    }
1406}
1407
1408/// A Stream of incoming requests for fuchsia.net.policy.properties/NetworkTokenResolver.
1409pub struct NetworkTokenResolverRequestStream {
1410    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1411    is_terminated: bool,
1412}
1413
1414impl std::marker::Unpin for NetworkTokenResolverRequestStream {}
1415
1416impl futures::stream::FusedStream for NetworkTokenResolverRequestStream {
1417    fn is_terminated(&self) -> bool {
1418        self.is_terminated
1419    }
1420}
1421
1422impl fidl::endpoints::RequestStream for NetworkTokenResolverRequestStream {
1423    type Protocol = NetworkTokenResolverMarker;
1424    type ControlHandle = NetworkTokenResolverControlHandle;
1425
1426    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1427        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1428    }
1429
1430    fn control_handle(&self) -> Self::ControlHandle {
1431        NetworkTokenResolverControlHandle { inner: self.inner.clone() }
1432    }
1433
1434    fn into_inner(
1435        self,
1436    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1437    {
1438        (self.inner, self.is_terminated)
1439    }
1440
1441    fn from_inner(
1442        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1443        is_terminated: bool,
1444    ) -> Self {
1445        Self { inner, is_terminated }
1446    }
1447}
1448
1449impl futures::Stream for NetworkTokenResolverRequestStream {
1450    type Item = Result<NetworkTokenResolverRequest, fidl::Error>;
1451
1452    fn poll_next(
1453        mut self: std::pin::Pin<&mut Self>,
1454        cx: &mut std::task::Context<'_>,
1455    ) -> std::task::Poll<Option<Self::Item>> {
1456        let this = &mut *self;
1457        if this.inner.check_shutdown(cx) {
1458            this.is_terminated = true;
1459            return std::task::Poll::Ready(None);
1460        }
1461        if this.is_terminated {
1462            panic!("polled NetworkTokenResolverRequestStream after completion");
1463        }
1464        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1465            |bytes, handles| {
1466                match this.inner.channel().read_etc(cx, bytes, handles) {
1467                    std::task::Poll::Ready(Ok(())) => {}
1468                    std::task::Poll::Pending => return std::task::Poll::Pending,
1469                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1470                        this.is_terminated = true;
1471                        return std::task::Poll::Ready(None);
1472                    }
1473                    std::task::Poll::Ready(Err(e)) => {
1474                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1475                            e.into(),
1476                        ))));
1477                    }
1478                }
1479
1480                // A message has been received from the channel
1481                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1482
1483                std::task::Poll::Ready(Some(match header.ordinal {
1484                0x4176f67517941bac => {
1485                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1486                    let mut req = fidl::new_empty!(NetworkTokenResolverResolveTokenRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1487                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkTokenResolverResolveTokenRequest>(&header, _body_bytes, handles, &mut req)?;
1488                    let control_handle = NetworkTokenResolverControlHandle {
1489                        inner: this.inner.clone(),
1490                    };
1491                    Ok(NetworkTokenResolverRequest::ResolveToken {token: req.token,
1492
1493                        responder: NetworkTokenResolverResolveTokenResponder {
1494                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1495                            tx_id: header.tx_id,
1496                        },
1497                    })
1498                }
1499                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1500                    Ok(NetworkTokenResolverRequest::_UnknownMethod {
1501                        ordinal: header.ordinal,
1502                        control_handle: NetworkTokenResolverControlHandle { inner: this.inner.clone() },
1503                        method_type: fidl::MethodType::OneWay,
1504                    })
1505                }
1506                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1507                    this.inner.send_framework_err(
1508                        fidl::encoding::FrameworkErr::UnknownMethod,
1509                        header.tx_id,
1510                        header.ordinal,
1511                        header.dynamic_flags(),
1512                        (bytes, handles),
1513                    )?;
1514                    Ok(NetworkTokenResolverRequest::_UnknownMethod {
1515                        ordinal: header.ordinal,
1516                        control_handle: NetworkTokenResolverControlHandle { inner: this.inner.clone() },
1517                        method_type: fidl::MethodType::TwoWay,
1518                    })
1519                }
1520                _ => Err(fidl::Error::UnknownOrdinal {
1521                    ordinal: header.ordinal,
1522                    protocol_name: <NetworkTokenResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1523                }),
1524            }))
1525            },
1526        )
1527    }
1528}
1529
1530/// Protocol to allow operations on `NetworkToken` objects, including resolving
1531/// `NetworkToken` to its canonical form.
1532#[derive(Debug)]
1533pub enum NetworkTokenResolverRequest {
1534    /// Resolves a network token to a canonical form.
1535    ///
1536    /// Since a "default network" network token is a distinct token from the
1537    /// non-default network variant, there needs to be a way to disambiguate
1538    /// the pair.
1539    ///
1540    /// Since a "default network" token (i.e. a token obtained from
1541    /// [`Networks.WatchDefault`]) is a distinct token from the non-default
1542    /// network variant, there needs to be a way to disambiguate the pair. If a
1543    /// non-default network token is passed, the same token is returned.
1544    ResolveToken { token: NetworkToken, responder: NetworkTokenResolverResolveTokenResponder },
1545    /// An interaction was received which does not match any known method.
1546    #[non_exhaustive]
1547    _UnknownMethod {
1548        /// Ordinal of the method that was called.
1549        ordinal: u64,
1550        control_handle: NetworkTokenResolverControlHandle,
1551        method_type: fidl::MethodType,
1552    },
1553}
1554
1555impl NetworkTokenResolverRequest {
1556    #[allow(irrefutable_let_patterns)]
1557    pub fn into_resolve_token(
1558        self,
1559    ) -> Option<(NetworkToken, NetworkTokenResolverResolveTokenResponder)> {
1560        if let NetworkTokenResolverRequest::ResolveToken { token, responder } = self {
1561            Some((token, responder))
1562        } else {
1563            None
1564        }
1565    }
1566
1567    /// Name of the method defined in FIDL
1568    pub fn method_name(&self) -> &'static str {
1569        match *self {
1570            NetworkTokenResolverRequest::ResolveToken { .. } => "resolve_token",
1571            NetworkTokenResolverRequest::_UnknownMethod {
1572                method_type: fidl::MethodType::OneWay,
1573                ..
1574            } => "unknown one-way method",
1575            NetworkTokenResolverRequest::_UnknownMethod {
1576                method_type: fidl::MethodType::TwoWay,
1577                ..
1578            } => "unknown two-way method",
1579        }
1580    }
1581}
1582
1583#[derive(Debug, Clone)]
1584pub struct NetworkTokenResolverControlHandle {
1585    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1586}
1587
1588impl NetworkTokenResolverControlHandle {
1589    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1590        self.inner.shutdown_with_epitaph(status.into())
1591    }
1592}
1593
1594impl fidl::endpoints::ControlHandle for NetworkTokenResolverControlHandle {
1595    fn shutdown(&self) {
1596        self.inner.shutdown()
1597    }
1598
1599    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1600        self.inner.shutdown_with_epitaph(status)
1601    }
1602
1603    fn is_closed(&self) -> bool {
1604        self.inner.channel().is_closed()
1605    }
1606    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1607        self.inner.channel().on_closed()
1608    }
1609
1610    #[cfg(target_os = "fuchsia")]
1611    fn signal_peer(
1612        &self,
1613        clear_mask: zx::Signals,
1614        set_mask: zx::Signals,
1615    ) -> Result<(), zx_status::Status> {
1616        use fidl::Peered;
1617        self.inner.channel().signal_peer(clear_mask, set_mask)
1618    }
1619}
1620
1621impl NetworkTokenResolverControlHandle {}
1622
1623#[must_use = "FIDL methods require a response to be sent"]
1624#[derive(Debug)]
1625pub struct NetworkTokenResolverResolveTokenResponder {
1626    control_handle: std::mem::ManuallyDrop<NetworkTokenResolverControlHandle>,
1627    tx_id: u32,
1628}
1629
1630/// Set the the channel to be shutdown (see [`NetworkTokenResolverControlHandle::shutdown`])
1631/// if the responder is dropped without sending a response, so that the client
1632/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1633impl std::ops::Drop for NetworkTokenResolverResolveTokenResponder {
1634    fn drop(&mut self) {
1635        self.control_handle.shutdown();
1636        // Safety: drops once, never accessed again
1637        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1638    }
1639}
1640
1641impl fidl::endpoints::Responder for NetworkTokenResolverResolveTokenResponder {
1642    type ControlHandle = NetworkTokenResolverControlHandle;
1643
1644    fn control_handle(&self) -> &NetworkTokenResolverControlHandle {
1645        &self.control_handle
1646    }
1647
1648    fn drop_without_shutdown(mut self) {
1649        // Safety: drops once, never accessed again due to mem::forget
1650        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1651        // Prevent Drop from running (which would shut down the channel)
1652        std::mem::forget(self);
1653    }
1654}
1655
1656impl NetworkTokenResolverResolveTokenResponder {
1657    /// Sends a response to the FIDL transaction.
1658    ///
1659    /// Sets the channel to shutdown if an error occurs.
1660    pub fn send(
1661        self,
1662        mut result: Result<NetworkToken, NetworkTokenResolverResolveTokenError>,
1663    ) -> Result<(), fidl::Error> {
1664        let _result = self.send_raw(result);
1665        if _result.is_err() {
1666            self.control_handle.shutdown();
1667        }
1668        self.drop_without_shutdown();
1669        _result
1670    }
1671
1672    /// Similar to "send" but does not shutdown the channel if an error occurs.
1673    pub fn send_no_shutdown_on_err(
1674        self,
1675        mut result: Result<NetworkToken, NetworkTokenResolverResolveTokenError>,
1676    ) -> Result<(), fidl::Error> {
1677        let _result = self.send_raw(result);
1678        self.drop_without_shutdown();
1679        _result
1680    }
1681
1682    fn send_raw(
1683        &self,
1684        mut result: Result<NetworkToken, NetworkTokenResolverResolveTokenError>,
1685    ) -> Result<(), fidl::Error> {
1686        self.control_handle.inner.send::<fidl::encoding::ResultType<
1687            NetworkTokenResolverResolveTokenResponse,
1688            NetworkTokenResolverResolveTokenError,
1689        >>(
1690            result.as_mut().map_err(|e| *e).map(|resolved_token| (resolved_token,)),
1691            self.tx_id,
1692            0x4176f67517941bac,
1693            fidl::encoding::DynamicFlags::empty(),
1694        )
1695    }
1696}
1697
1698#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1699pub struct NetworksMarker;
1700
1701impl fidl::endpoints::ProtocolMarker for NetworksMarker {
1702    type Proxy = NetworksProxy;
1703    type RequestStream = NetworksRequestStream;
1704    #[cfg(target_os = "fuchsia")]
1705    type SynchronousProxy = NetworksSynchronousProxy;
1706
1707    const DEBUG_NAME: &'static str = "fuchsia.net.policy.properties.Networks";
1708}
1709impl fidl::endpoints::DiscoverableProtocolMarker for NetworksMarker {}
1710pub type NetworksWatchPropertiesResult = Result<(), WatchError>;
1711
1712pub trait NetworksProxyInterface: Send + Sync {
1713    type WatchDefaultResponseFut: std::future::Future<Output = Result<NetworksWatchDefaultResponse, fidl::Error>>
1714        + Send;
1715    fn r#watch_default(&self) -> Self::WatchDefaultResponseFut;
1716    type WatchPropertiesResponseFut: std::future::Future<Output = Result<NetworksWatchPropertiesResult, fidl::Error>>
1717        + Send;
1718    fn r#watch_properties(
1719        &self,
1720        payload: NetworksWatchPropertiesRequest,
1721    ) -> Self::WatchPropertiesResponseFut;
1722}
1723#[derive(Debug)]
1724#[cfg(target_os = "fuchsia")]
1725pub struct NetworksSynchronousProxy {
1726    client: fidl::client::sync::Client,
1727}
1728
1729#[cfg(target_os = "fuchsia")]
1730impl fidl::endpoints::SynchronousProxy for NetworksSynchronousProxy {
1731    type Proxy = NetworksProxy;
1732    type Protocol = NetworksMarker;
1733
1734    fn from_channel(inner: fidl::Channel) -> Self {
1735        Self::new(inner)
1736    }
1737
1738    fn into_channel(self) -> fidl::Channel {
1739        self.client.into_channel()
1740    }
1741
1742    fn as_channel(&self) -> &fidl::Channel {
1743        self.client.as_channel()
1744    }
1745}
1746
1747#[cfg(target_os = "fuchsia")]
1748impl NetworksSynchronousProxy {
1749    pub fn new(channel: fidl::Channel) -> Self {
1750        Self { client: fidl::client::sync::Client::new(channel) }
1751    }
1752
1753    pub fn into_channel(self) -> fidl::Channel {
1754        self.client.into_channel()
1755    }
1756
1757    /// Waits until an event arrives and returns it. It is safe for other
1758    /// threads to make concurrent requests while waiting for an event.
1759    pub fn wait_for_event(
1760        &self,
1761        deadline: zx::MonotonicInstant,
1762    ) -> Result<NetworksEvent, fidl::Error> {
1763        NetworksEvent::decode(self.client.wait_for_event::<NetworksMarker>(deadline)?)
1764    }
1765
1766    /// Watches for changes in the default network.
1767    ///
1768    /// The first call always returns a [`NetworkToken`] representing the
1769    /// current default network, or if one is not present, blocks until a
1770    /// default network is set. Subsequent calls block until the default
1771    /// network has changed, or has been lost, returning a new [`NetworkToken`]
1772    /// for the updated default network, or [`no_default_network`] if the
1773    /// network is lost.
1774    ///
1775    /// Only one call to this method may be pending per connection.
1776    pub fn r#watch_default(
1777        &self,
1778        ___deadline: zx::MonotonicInstant,
1779    ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
1780        let _response = self.client.send_query::<
1781            fidl::encoding::EmptyPayload,
1782            fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
1783            NetworksMarker,
1784        >(
1785            (),
1786            0x346880b2d7db0f98,
1787            fidl::encoding::DynamicFlags::FLEXIBLE,
1788            ___deadline,
1789        )?
1790        .into_result::<NetworksMarker>("watch_default")?;
1791        Ok(_response)
1792    }
1793
1794    /// Registers a [`PropertyWatcher`] to watch for changes in requested
1795    /// properties for the given [`NetworkToken`].
1796    ///
1797    /// The watcher receives updates for the requested properties on the
1798    /// network represented by `network`.
1799    pub fn r#watch_properties(
1800        &self,
1801        mut payload: NetworksWatchPropertiesRequest,
1802        ___deadline: zx::MonotonicInstant,
1803    ) -> Result<NetworksWatchPropertiesResult, fidl::Error> {
1804        let _response = self.client.send_query::<
1805            NetworksWatchPropertiesRequest,
1806            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WatchError>,
1807            NetworksMarker,
1808        >(
1809            &mut payload,
1810            0x24d2340905f7dcc6,
1811            fidl::encoding::DynamicFlags::FLEXIBLE,
1812            ___deadline,
1813        )?
1814        .into_result::<NetworksMarker>("watch_properties")?;
1815        Ok(_response.map(|x| x))
1816    }
1817}
1818
1819#[cfg(target_os = "fuchsia")]
1820impl From<NetworksSynchronousProxy> for zx::NullableHandle {
1821    fn from(value: NetworksSynchronousProxy) -> Self {
1822        value.into_channel().into()
1823    }
1824}
1825
1826#[cfg(target_os = "fuchsia")]
1827impl From<fidl::Channel> for NetworksSynchronousProxy {
1828    fn from(value: fidl::Channel) -> Self {
1829        Self::new(value)
1830    }
1831}
1832
1833#[cfg(target_os = "fuchsia")]
1834impl fidl::endpoints::FromClient for NetworksSynchronousProxy {
1835    type Protocol = NetworksMarker;
1836
1837    fn from_client(value: fidl::endpoints::ClientEnd<NetworksMarker>) -> Self {
1838        Self::new(value.into_channel())
1839    }
1840}
1841
1842#[derive(Debug, Clone)]
1843pub struct NetworksProxy {
1844    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1845}
1846
1847impl fidl::endpoints::Proxy for NetworksProxy {
1848    type Protocol = NetworksMarker;
1849
1850    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1851        Self::new(inner)
1852    }
1853
1854    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1855        self.client.into_channel().map_err(|client| Self { client })
1856    }
1857
1858    fn as_channel(&self) -> &::fidl::AsyncChannel {
1859        self.client.as_channel()
1860    }
1861}
1862
1863impl NetworksProxy {
1864    /// Create a new Proxy for fuchsia.net.policy.properties/Networks.
1865    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1866        let protocol_name = <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1867        Self { client: fidl::client::Client::new(channel, protocol_name) }
1868    }
1869
1870    /// Get a Stream of events from the remote end of the protocol.
1871    ///
1872    /// # Panics
1873    ///
1874    /// Panics if the event stream was already taken.
1875    pub fn take_event_stream(&self) -> NetworksEventStream {
1876        NetworksEventStream { event_receiver: self.client.take_event_receiver() }
1877    }
1878
1879    /// Watches for changes in the default network.
1880    ///
1881    /// The first call always returns a [`NetworkToken`] representing the
1882    /// current default network, or if one is not present, blocks until a
1883    /// default network is set. Subsequent calls block until the default
1884    /// network has changed, or has been lost, returning a new [`NetworkToken`]
1885    /// for the updated default network, or [`no_default_network`] if the
1886    /// network is lost.
1887    ///
1888    /// Only one call to this method may be pending per connection.
1889    pub fn r#watch_default(
1890        &self,
1891    ) -> fidl::client::QueryResponseFut<
1892        NetworksWatchDefaultResponse,
1893        fidl::encoding::DefaultFuchsiaResourceDialect,
1894    > {
1895        NetworksProxyInterface::r#watch_default(self)
1896    }
1897
1898    /// Registers a [`PropertyWatcher`] to watch for changes in requested
1899    /// properties for the given [`NetworkToken`].
1900    ///
1901    /// The watcher receives updates for the requested properties on the
1902    /// network represented by `network`.
1903    pub fn r#watch_properties(
1904        &self,
1905        mut payload: NetworksWatchPropertiesRequest,
1906    ) -> fidl::client::QueryResponseFut<
1907        NetworksWatchPropertiesResult,
1908        fidl::encoding::DefaultFuchsiaResourceDialect,
1909    > {
1910        NetworksProxyInterface::r#watch_properties(self, payload)
1911    }
1912}
1913
1914impl NetworksProxyInterface for NetworksProxy {
1915    type WatchDefaultResponseFut = fidl::client::QueryResponseFut<
1916        NetworksWatchDefaultResponse,
1917        fidl::encoding::DefaultFuchsiaResourceDialect,
1918    >;
1919    fn r#watch_default(&self) -> Self::WatchDefaultResponseFut {
1920        fn _decode(
1921            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1922        ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
1923            let _response = fidl::client::decode_transaction_body::<
1924                fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
1925                fidl::encoding::DefaultFuchsiaResourceDialect,
1926                0x346880b2d7db0f98,
1927            >(_buf?)?
1928            .into_result::<NetworksMarker>("watch_default")?;
1929            Ok(_response)
1930        }
1931        self.client
1932            .send_query_and_decode::<fidl::encoding::EmptyPayload, NetworksWatchDefaultResponse>(
1933                (),
1934                0x346880b2d7db0f98,
1935                fidl::encoding::DynamicFlags::FLEXIBLE,
1936                _decode,
1937            )
1938    }
1939
1940    type WatchPropertiesResponseFut = fidl::client::QueryResponseFut<
1941        NetworksWatchPropertiesResult,
1942        fidl::encoding::DefaultFuchsiaResourceDialect,
1943    >;
1944    fn r#watch_properties(
1945        &self,
1946        mut payload: NetworksWatchPropertiesRequest,
1947    ) -> Self::WatchPropertiesResponseFut {
1948        fn _decode(
1949            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1950        ) -> Result<NetworksWatchPropertiesResult, fidl::Error> {
1951            let _response = fidl::client::decode_transaction_body::<
1952                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WatchError>,
1953                fidl::encoding::DefaultFuchsiaResourceDialect,
1954                0x24d2340905f7dcc6,
1955            >(_buf?)?
1956            .into_result::<NetworksMarker>("watch_properties")?;
1957            Ok(_response.map(|x| x))
1958        }
1959        self.client
1960            .send_query_and_decode::<NetworksWatchPropertiesRequest, NetworksWatchPropertiesResult>(
1961                &mut payload,
1962                0x24d2340905f7dcc6,
1963                fidl::encoding::DynamicFlags::FLEXIBLE,
1964                _decode,
1965            )
1966    }
1967}
1968
1969pub struct NetworksEventStream {
1970    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1971}
1972
1973impl std::marker::Unpin for NetworksEventStream {}
1974
1975impl futures::stream::FusedStream for NetworksEventStream {
1976    fn is_terminated(&self) -> bool {
1977        self.event_receiver.is_terminated()
1978    }
1979}
1980
1981impl futures::Stream for NetworksEventStream {
1982    type Item = Result<NetworksEvent, fidl::Error>;
1983
1984    fn poll_next(
1985        mut self: std::pin::Pin<&mut Self>,
1986        cx: &mut std::task::Context<'_>,
1987    ) -> std::task::Poll<Option<Self::Item>> {
1988        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1989            &mut self.event_receiver,
1990            cx
1991        )?) {
1992            Some(buf) => std::task::Poll::Ready(Some(NetworksEvent::decode(buf))),
1993            None => std::task::Poll::Ready(None),
1994        }
1995    }
1996}
1997
1998#[derive(Debug)]
1999pub enum NetworksEvent {
2000    #[non_exhaustive]
2001    _UnknownEvent {
2002        /// Ordinal of the event that was sent.
2003        ordinal: u64,
2004    },
2005}
2006
2007impl NetworksEvent {
2008    /// Decodes a message buffer as a [`NetworksEvent`].
2009    fn decode(
2010        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2011    ) -> Result<NetworksEvent, fidl::Error> {
2012        let (bytes, _handles) = buf.split_mut();
2013        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2014        debug_assert_eq!(tx_header.tx_id, 0);
2015        match tx_header.ordinal {
2016            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2017                Ok(NetworksEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2018            }
2019            _ => Err(fidl::Error::UnknownOrdinal {
2020                ordinal: tx_header.ordinal,
2021                protocol_name: <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2022            }),
2023        }
2024    }
2025}
2026
2027/// A Stream of incoming requests for fuchsia.net.policy.properties/Networks.
2028pub struct NetworksRequestStream {
2029    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2030    is_terminated: bool,
2031}
2032
2033impl std::marker::Unpin for NetworksRequestStream {}
2034
2035impl futures::stream::FusedStream for NetworksRequestStream {
2036    fn is_terminated(&self) -> bool {
2037        self.is_terminated
2038    }
2039}
2040
2041impl fidl::endpoints::RequestStream for NetworksRequestStream {
2042    type Protocol = NetworksMarker;
2043    type ControlHandle = NetworksControlHandle;
2044
2045    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2046        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2047    }
2048
2049    fn control_handle(&self) -> Self::ControlHandle {
2050        NetworksControlHandle { inner: self.inner.clone() }
2051    }
2052
2053    fn into_inner(
2054        self,
2055    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2056    {
2057        (self.inner, self.is_terminated)
2058    }
2059
2060    fn from_inner(
2061        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2062        is_terminated: bool,
2063    ) -> Self {
2064        Self { inner, is_terminated }
2065    }
2066}
2067
2068impl futures::Stream for NetworksRequestStream {
2069    type Item = Result<NetworksRequest, fidl::Error>;
2070
2071    fn poll_next(
2072        mut self: std::pin::Pin<&mut Self>,
2073        cx: &mut std::task::Context<'_>,
2074    ) -> std::task::Poll<Option<Self::Item>> {
2075        let this = &mut *self;
2076        if this.inner.check_shutdown(cx) {
2077            this.is_terminated = true;
2078            return std::task::Poll::Ready(None);
2079        }
2080        if this.is_terminated {
2081            panic!("polled NetworksRequestStream after completion");
2082        }
2083        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2084            |bytes, handles| {
2085                match this.inner.channel().read_etc(cx, bytes, handles) {
2086                    std::task::Poll::Ready(Ok(())) => {}
2087                    std::task::Poll::Pending => return std::task::Poll::Pending,
2088                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2089                        this.is_terminated = true;
2090                        return std::task::Poll::Ready(None);
2091                    }
2092                    std::task::Poll::Ready(Err(e)) => {
2093                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2094                            e.into(),
2095                        ))));
2096                    }
2097                }
2098
2099                // A message has been received from the channel
2100                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2101
2102                std::task::Poll::Ready(Some(match header.ordinal {
2103                    0x346880b2d7db0f98 => {
2104                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2105                        let mut req = fidl::new_empty!(
2106                            fidl::encoding::EmptyPayload,
2107                            fidl::encoding::DefaultFuchsiaResourceDialect
2108                        );
2109                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2110                        let control_handle = NetworksControlHandle { inner: this.inner.clone() };
2111                        Ok(NetworksRequest::WatchDefault {
2112                            responder: NetworksWatchDefaultResponder {
2113                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2114                                tx_id: header.tx_id,
2115                            },
2116                        })
2117                    }
2118                    0x24d2340905f7dcc6 => {
2119                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2120                        let mut req = fidl::new_empty!(
2121                            NetworksWatchPropertiesRequest,
2122                            fidl::encoding::DefaultFuchsiaResourceDialect
2123                        );
2124                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworksWatchPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
2125                        let control_handle = NetworksControlHandle { inner: this.inner.clone() };
2126                        Ok(NetworksRequest::WatchProperties {
2127                            payload: req,
2128                            responder: NetworksWatchPropertiesResponder {
2129                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2130                                tx_id: header.tx_id,
2131                            },
2132                        })
2133                    }
2134                    _ if header.tx_id == 0
2135                        && header
2136                            .dynamic_flags()
2137                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2138                    {
2139                        Ok(NetworksRequest::_UnknownMethod {
2140                            ordinal: header.ordinal,
2141                            control_handle: NetworksControlHandle { inner: this.inner.clone() },
2142                            method_type: fidl::MethodType::OneWay,
2143                        })
2144                    }
2145                    _ if header
2146                        .dynamic_flags()
2147                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2148                    {
2149                        this.inner.send_framework_err(
2150                            fidl::encoding::FrameworkErr::UnknownMethod,
2151                            header.tx_id,
2152                            header.ordinal,
2153                            header.dynamic_flags(),
2154                            (bytes, handles),
2155                        )?;
2156                        Ok(NetworksRequest::_UnknownMethod {
2157                            ordinal: header.ordinal,
2158                            control_handle: NetworksControlHandle { inner: this.inner.clone() },
2159                            method_type: fidl::MethodType::TwoWay,
2160                        })
2161                    }
2162                    _ => Err(fidl::Error::UnknownOrdinal {
2163                        ordinal: header.ordinal,
2164                        protocol_name:
2165                            <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2166                    }),
2167                }))
2168            },
2169        )
2170    }
2171}
2172
2173/// Protocol for acquiring [`NetworkToken`]s, and querying properties of that
2174/// network.
2175#[derive(Debug)]
2176pub enum NetworksRequest {
2177    /// Watches for changes in the default network.
2178    ///
2179    /// The first call always returns a [`NetworkToken`] representing the
2180    /// current default network, or if one is not present, blocks until a
2181    /// default network is set. Subsequent calls block until the default
2182    /// network has changed, or has been lost, returning a new [`NetworkToken`]
2183    /// for the updated default network, or [`no_default_network`] if the
2184    /// network is lost.
2185    ///
2186    /// Only one call to this method may be pending per connection.
2187    WatchDefault { responder: NetworksWatchDefaultResponder },
2188    /// Registers a [`PropertyWatcher`] to watch for changes in requested
2189    /// properties for the given [`NetworkToken`].
2190    ///
2191    /// The watcher receives updates for the requested properties on the
2192    /// network represented by `network`.
2193    WatchProperties {
2194        payload: NetworksWatchPropertiesRequest,
2195        responder: NetworksWatchPropertiesResponder,
2196    },
2197    /// An interaction was received which does not match any known method.
2198    #[non_exhaustive]
2199    _UnknownMethod {
2200        /// Ordinal of the method that was called.
2201        ordinal: u64,
2202        control_handle: NetworksControlHandle,
2203        method_type: fidl::MethodType,
2204    },
2205}
2206
2207impl NetworksRequest {
2208    #[allow(irrefutable_let_patterns)]
2209    pub fn into_watch_default(self) -> Option<(NetworksWatchDefaultResponder)> {
2210        if let NetworksRequest::WatchDefault { responder } = self {
2211            Some((responder))
2212        } else {
2213            None
2214        }
2215    }
2216
2217    #[allow(irrefutable_let_patterns)]
2218    pub fn into_watch_properties(
2219        self,
2220    ) -> Option<(NetworksWatchPropertiesRequest, NetworksWatchPropertiesResponder)> {
2221        if let NetworksRequest::WatchProperties { payload, responder } = self {
2222            Some((payload, responder))
2223        } else {
2224            None
2225        }
2226    }
2227
2228    /// Name of the method defined in FIDL
2229    pub fn method_name(&self) -> &'static str {
2230        match *self {
2231            NetworksRequest::WatchDefault { .. } => "watch_default",
2232            NetworksRequest::WatchProperties { .. } => "watch_properties",
2233            NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2234                "unknown one-way method"
2235            }
2236            NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2237                "unknown two-way method"
2238            }
2239        }
2240    }
2241}
2242
2243#[derive(Debug, Clone)]
2244pub struct NetworksControlHandle {
2245    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2246}
2247
2248impl NetworksControlHandle {
2249    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2250        self.inner.shutdown_with_epitaph(status.into())
2251    }
2252}
2253
2254impl fidl::endpoints::ControlHandle for NetworksControlHandle {
2255    fn shutdown(&self) {
2256        self.inner.shutdown()
2257    }
2258
2259    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2260        self.inner.shutdown_with_epitaph(status)
2261    }
2262
2263    fn is_closed(&self) -> bool {
2264        self.inner.channel().is_closed()
2265    }
2266    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2267        self.inner.channel().on_closed()
2268    }
2269
2270    #[cfg(target_os = "fuchsia")]
2271    fn signal_peer(
2272        &self,
2273        clear_mask: zx::Signals,
2274        set_mask: zx::Signals,
2275    ) -> Result<(), zx_status::Status> {
2276        use fidl::Peered;
2277        self.inner.channel().signal_peer(clear_mask, set_mask)
2278    }
2279}
2280
2281impl NetworksControlHandle {}
2282
2283#[must_use = "FIDL methods require a response to be sent"]
2284#[derive(Debug)]
2285pub struct NetworksWatchDefaultResponder {
2286    control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
2287    tx_id: u32,
2288}
2289
2290/// Set the the channel to be shutdown (see [`NetworksControlHandle::shutdown`])
2291/// if the responder is dropped without sending a response, so that the client
2292/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2293impl std::ops::Drop for NetworksWatchDefaultResponder {
2294    fn drop(&mut self) {
2295        self.control_handle.shutdown();
2296        // Safety: drops once, never accessed again
2297        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2298    }
2299}
2300
2301impl fidl::endpoints::Responder for NetworksWatchDefaultResponder {
2302    type ControlHandle = NetworksControlHandle;
2303
2304    fn control_handle(&self) -> &NetworksControlHandle {
2305        &self.control_handle
2306    }
2307
2308    fn drop_without_shutdown(mut self) {
2309        // Safety: drops once, never accessed again due to mem::forget
2310        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2311        // Prevent Drop from running (which would shut down the channel)
2312        std::mem::forget(self);
2313    }
2314}
2315
2316impl NetworksWatchDefaultResponder {
2317    /// Sends a response to the FIDL transaction.
2318    ///
2319    /// Sets the channel to shutdown if an error occurs.
2320    pub fn send(self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
2321        let _result = self.send_raw(payload);
2322        if _result.is_err() {
2323            self.control_handle.shutdown();
2324        }
2325        self.drop_without_shutdown();
2326        _result
2327    }
2328
2329    /// Similar to "send" but does not shutdown the channel if an error occurs.
2330    pub fn send_no_shutdown_on_err(
2331        self,
2332        mut payload: NetworksWatchDefaultResponse,
2333    ) -> Result<(), fidl::Error> {
2334        let _result = self.send_raw(payload);
2335        self.drop_without_shutdown();
2336        _result
2337    }
2338
2339    fn send_raw(&self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
2340        self.control_handle
2341            .inner
2342            .send::<fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>>(
2343                fidl::encoding::Flexible::new(&mut payload),
2344                self.tx_id,
2345                0x346880b2d7db0f98,
2346                fidl::encoding::DynamicFlags::FLEXIBLE,
2347            )
2348    }
2349}
2350
2351#[must_use = "FIDL methods require a response to be sent"]
2352#[derive(Debug)]
2353pub struct NetworksWatchPropertiesResponder {
2354    control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
2355    tx_id: u32,
2356}
2357
2358/// Set the the channel to be shutdown (see [`NetworksControlHandle::shutdown`])
2359/// if the responder is dropped without sending a response, so that the client
2360/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2361impl std::ops::Drop for NetworksWatchPropertiesResponder {
2362    fn drop(&mut self) {
2363        self.control_handle.shutdown();
2364        // Safety: drops once, never accessed again
2365        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2366    }
2367}
2368
2369impl fidl::endpoints::Responder for NetworksWatchPropertiesResponder {
2370    type ControlHandle = NetworksControlHandle;
2371
2372    fn control_handle(&self) -> &NetworksControlHandle {
2373        &self.control_handle
2374    }
2375
2376    fn drop_without_shutdown(mut self) {
2377        // Safety: drops once, never accessed again due to mem::forget
2378        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2379        // Prevent Drop from running (which would shut down the channel)
2380        std::mem::forget(self);
2381    }
2382}
2383
2384impl NetworksWatchPropertiesResponder {
2385    /// Sends a response to the FIDL transaction.
2386    ///
2387    /// Sets the channel to shutdown if an error occurs.
2388    pub fn send(self, mut result: Result<(), WatchError>) -> Result<(), fidl::Error> {
2389        let _result = self.send_raw(result);
2390        if _result.is_err() {
2391            self.control_handle.shutdown();
2392        }
2393        self.drop_without_shutdown();
2394        _result
2395    }
2396
2397    /// Similar to "send" but does not shutdown the channel if an error occurs.
2398    pub fn send_no_shutdown_on_err(
2399        self,
2400        mut result: Result<(), WatchError>,
2401    ) -> Result<(), fidl::Error> {
2402        let _result = self.send_raw(result);
2403        self.drop_without_shutdown();
2404        _result
2405    }
2406
2407    fn send_raw(&self, mut result: Result<(), WatchError>) -> Result<(), fidl::Error> {
2408        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2409            fidl::encoding::EmptyStruct,
2410            WatchError,
2411        >>(
2412            fidl::encoding::FlexibleResult::new(result),
2413            self.tx_id,
2414            0x24d2340905f7dcc6,
2415            fidl::encoding::DynamicFlags::FLEXIBLE,
2416        )
2417    }
2418}
2419
2420#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2421pub struct PrivilegedNetworkLookupMarker;
2422
2423impl fidl::endpoints::ProtocolMarker for PrivilegedNetworkLookupMarker {
2424    type Proxy = PrivilegedNetworkLookupProxy;
2425    type RequestStream = PrivilegedNetworkLookupRequestStream;
2426    #[cfg(target_os = "fuchsia")]
2427    type SynchronousProxy = PrivilegedNetworkLookupSynchronousProxy;
2428
2429    const DEBUG_NAME: &'static str = "fuchsia.net.policy.properties.PrivilegedNetworkLookup";
2430}
2431impl fidl::endpoints::DiscoverableProtocolMarker for PrivilegedNetworkLookupMarker {}
2432pub type PrivilegedNetworkLookupLookupResult = Result<NetworkToken, LookupError>;
2433
2434pub trait PrivilegedNetworkLookupProxyInterface: Send + Sync {
2435    type LookupResponseFut: std::future::Future<Output = Result<PrivilegedNetworkLookupLookupResult, fidl::Error>>
2436        + Send;
2437    fn r#lookup(&self, payload: &LookupRequest) -> Self::LookupResponseFut;
2438}
2439#[derive(Debug)]
2440#[cfg(target_os = "fuchsia")]
2441pub struct PrivilegedNetworkLookupSynchronousProxy {
2442    client: fidl::client::sync::Client,
2443}
2444
2445#[cfg(target_os = "fuchsia")]
2446impl fidl::endpoints::SynchronousProxy for PrivilegedNetworkLookupSynchronousProxy {
2447    type Proxy = PrivilegedNetworkLookupProxy;
2448    type Protocol = PrivilegedNetworkLookupMarker;
2449
2450    fn from_channel(inner: fidl::Channel) -> Self {
2451        Self::new(inner)
2452    }
2453
2454    fn into_channel(self) -> fidl::Channel {
2455        self.client.into_channel()
2456    }
2457
2458    fn as_channel(&self) -> &fidl::Channel {
2459        self.client.as_channel()
2460    }
2461}
2462
2463#[cfg(target_os = "fuchsia")]
2464impl PrivilegedNetworkLookupSynchronousProxy {
2465    pub fn new(channel: fidl::Channel) -> Self {
2466        Self { client: fidl::client::sync::Client::new(channel) }
2467    }
2468
2469    pub fn into_channel(self) -> fidl::Channel {
2470        self.client.into_channel()
2471    }
2472
2473    /// Waits until an event arrives and returns it. It is safe for other
2474    /// threads to make concurrent requests while waiting for an event.
2475    pub fn wait_for_event(
2476        &self,
2477        deadline: zx::MonotonicInstant,
2478    ) -> Result<PrivilegedNetworkLookupEvent, fidl::Error> {
2479        PrivilegedNetworkLookupEvent::decode(
2480            self.client.wait_for_event::<PrivilegedNetworkLookupMarker>(deadline)?,
2481        )
2482    }
2483
2484    /// Look up a network by an attribute of that network.
2485    ///
2486    /// This permits clients that have a network handle to get a [`NetworkToken`]
2487    /// for the matching network at the time of the call, regardless of whether
2488    /// that network is the default or not. Once obtained, the returned
2489    /// [`NetworkToken`] remains valid and bound to that network even if the
2490    /// network's attributes (such as its [`starnix_handle`]) later change, and
2491    /// is only invalidated when the network itself is removed.
2492    ///
2493    /// Responds immediately with either a [`NetworkToken`] or a [`NOT_FOUND`] error.
2494    pub fn r#lookup(
2495        &self,
2496        mut payload: &LookupRequest,
2497        ___deadline: zx::MonotonicInstant,
2498    ) -> Result<PrivilegedNetworkLookupLookupResult, fidl::Error> {
2499        let _response =
2500            self.client
2501                .send_query::<LookupRequest, fidl::encoding::FlexibleResultType<
2502                    PrivilegedNetworkLookupLookupResponse,
2503                    LookupError,
2504                >, PrivilegedNetworkLookupMarker>(
2505                    payload,
2506                    0x56c60798dfd78cab,
2507                    fidl::encoding::DynamicFlags::FLEXIBLE,
2508                    ___deadline,
2509                )?
2510                .into_result::<PrivilegedNetworkLookupMarker>("lookup")?;
2511        Ok(_response.map(|x| x.network))
2512    }
2513}
2514
2515#[cfg(target_os = "fuchsia")]
2516impl From<PrivilegedNetworkLookupSynchronousProxy> for zx::NullableHandle {
2517    fn from(value: PrivilegedNetworkLookupSynchronousProxy) -> Self {
2518        value.into_channel().into()
2519    }
2520}
2521
2522#[cfg(target_os = "fuchsia")]
2523impl From<fidl::Channel> for PrivilegedNetworkLookupSynchronousProxy {
2524    fn from(value: fidl::Channel) -> Self {
2525        Self::new(value)
2526    }
2527}
2528
2529#[cfg(target_os = "fuchsia")]
2530impl fidl::endpoints::FromClient for PrivilegedNetworkLookupSynchronousProxy {
2531    type Protocol = PrivilegedNetworkLookupMarker;
2532
2533    fn from_client(value: fidl::endpoints::ClientEnd<PrivilegedNetworkLookupMarker>) -> Self {
2534        Self::new(value.into_channel())
2535    }
2536}
2537
2538#[derive(Debug, Clone)]
2539pub struct PrivilegedNetworkLookupProxy {
2540    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2541}
2542
2543impl fidl::endpoints::Proxy for PrivilegedNetworkLookupProxy {
2544    type Protocol = PrivilegedNetworkLookupMarker;
2545
2546    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2547        Self::new(inner)
2548    }
2549
2550    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2551        self.client.into_channel().map_err(|client| Self { client })
2552    }
2553
2554    fn as_channel(&self) -> &::fidl::AsyncChannel {
2555        self.client.as_channel()
2556    }
2557}
2558
2559impl PrivilegedNetworkLookupProxy {
2560    /// Create a new Proxy for fuchsia.net.policy.properties/PrivilegedNetworkLookup.
2561    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2562        let protocol_name =
2563            <PrivilegedNetworkLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2564        Self { client: fidl::client::Client::new(channel, protocol_name) }
2565    }
2566
2567    /// Get a Stream of events from the remote end of the protocol.
2568    ///
2569    /// # Panics
2570    ///
2571    /// Panics if the event stream was already taken.
2572    pub fn take_event_stream(&self) -> PrivilegedNetworkLookupEventStream {
2573        PrivilegedNetworkLookupEventStream { event_receiver: self.client.take_event_receiver() }
2574    }
2575
2576    /// Look up a network by an attribute of that network.
2577    ///
2578    /// This permits clients that have a network handle to get a [`NetworkToken`]
2579    /// for the matching network at the time of the call, regardless of whether
2580    /// that network is the default or not. Once obtained, the returned
2581    /// [`NetworkToken`] remains valid and bound to that network even if the
2582    /// network's attributes (such as its [`starnix_handle`]) later change, and
2583    /// is only invalidated when the network itself is removed.
2584    ///
2585    /// Responds immediately with either a [`NetworkToken`] or a [`NOT_FOUND`] error.
2586    pub fn r#lookup(
2587        &self,
2588        mut payload: &LookupRequest,
2589    ) -> fidl::client::QueryResponseFut<
2590        PrivilegedNetworkLookupLookupResult,
2591        fidl::encoding::DefaultFuchsiaResourceDialect,
2592    > {
2593        PrivilegedNetworkLookupProxyInterface::r#lookup(self, payload)
2594    }
2595}
2596
2597impl PrivilegedNetworkLookupProxyInterface for PrivilegedNetworkLookupProxy {
2598    type LookupResponseFut = fidl::client::QueryResponseFut<
2599        PrivilegedNetworkLookupLookupResult,
2600        fidl::encoding::DefaultFuchsiaResourceDialect,
2601    >;
2602    fn r#lookup(&self, mut payload: &LookupRequest) -> Self::LookupResponseFut {
2603        fn _decode(
2604            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2605        ) -> Result<PrivilegedNetworkLookupLookupResult, fidl::Error> {
2606            let _response = fidl::client::decode_transaction_body::<
2607                fidl::encoding::FlexibleResultType<
2608                    PrivilegedNetworkLookupLookupResponse,
2609                    LookupError,
2610                >,
2611                fidl::encoding::DefaultFuchsiaResourceDialect,
2612                0x56c60798dfd78cab,
2613            >(_buf?)?
2614            .into_result::<PrivilegedNetworkLookupMarker>("lookup")?;
2615            Ok(_response.map(|x| x.network))
2616        }
2617        self.client.send_query_and_decode::<LookupRequest, PrivilegedNetworkLookupLookupResult>(
2618            payload,
2619            0x56c60798dfd78cab,
2620            fidl::encoding::DynamicFlags::FLEXIBLE,
2621            _decode,
2622        )
2623    }
2624}
2625
2626pub struct PrivilegedNetworkLookupEventStream {
2627    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2628}
2629
2630impl std::marker::Unpin for PrivilegedNetworkLookupEventStream {}
2631
2632impl futures::stream::FusedStream for PrivilegedNetworkLookupEventStream {
2633    fn is_terminated(&self) -> bool {
2634        self.event_receiver.is_terminated()
2635    }
2636}
2637
2638impl futures::Stream for PrivilegedNetworkLookupEventStream {
2639    type Item = Result<PrivilegedNetworkLookupEvent, fidl::Error>;
2640
2641    fn poll_next(
2642        mut self: std::pin::Pin<&mut Self>,
2643        cx: &mut std::task::Context<'_>,
2644    ) -> std::task::Poll<Option<Self::Item>> {
2645        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2646            &mut self.event_receiver,
2647            cx
2648        )?) {
2649            Some(buf) => std::task::Poll::Ready(Some(PrivilegedNetworkLookupEvent::decode(buf))),
2650            None => std::task::Poll::Ready(None),
2651        }
2652    }
2653}
2654
2655#[derive(Debug)]
2656pub enum PrivilegedNetworkLookupEvent {
2657    #[non_exhaustive]
2658    _UnknownEvent {
2659        /// Ordinal of the event that was sent.
2660        ordinal: u64,
2661    },
2662}
2663
2664impl PrivilegedNetworkLookupEvent {
2665    /// Decodes a message buffer as a [`PrivilegedNetworkLookupEvent`].
2666    fn decode(
2667        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2668    ) -> Result<PrivilegedNetworkLookupEvent, fidl::Error> {
2669        let (bytes, _handles) = buf.split_mut();
2670        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2671        debug_assert_eq!(tx_header.tx_id, 0);
2672        match tx_header.ordinal {
2673            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2674                Ok(PrivilegedNetworkLookupEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2675            }
2676            _ => Err(fidl::Error::UnknownOrdinal {
2677                ordinal: tx_header.ordinal,
2678                protocol_name:
2679                    <PrivilegedNetworkLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2680            }),
2681        }
2682    }
2683}
2684
2685/// A Stream of incoming requests for fuchsia.net.policy.properties/PrivilegedNetworkLookup.
2686pub struct PrivilegedNetworkLookupRequestStream {
2687    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2688    is_terminated: bool,
2689}
2690
2691impl std::marker::Unpin for PrivilegedNetworkLookupRequestStream {}
2692
2693impl futures::stream::FusedStream for PrivilegedNetworkLookupRequestStream {
2694    fn is_terminated(&self) -> bool {
2695        self.is_terminated
2696    }
2697}
2698
2699impl fidl::endpoints::RequestStream for PrivilegedNetworkLookupRequestStream {
2700    type Protocol = PrivilegedNetworkLookupMarker;
2701    type ControlHandle = PrivilegedNetworkLookupControlHandle;
2702
2703    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2704        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2705    }
2706
2707    fn control_handle(&self) -> Self::ControlHandle {
2708        PrivilegedNetworkLookupControlHandle { inner: self.inner.clone() }
2709    }
2710
2711    fn into_inner(
2712        self,
2713    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2714    {
2715        (self.inner, self.is_terminated)
2716    }
2717
2718    fn from_inner(
2719        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2720        is_terminated: bool,
2721    ) -> Self {
2722        Self { inner, is_terminated }
2723    }
2724}
2725
2726impl futures::Stream for PrivilegedNetworkLookupRequestStream {
2727    type Item = Result<PrivilegedNetworkLookupRequest, fidl::Error>;
2728
2729    fn poll_next(
2730        mut self: std::pin::Pin<&mut Self>,
2731        cx: &mut std::task::Context<'_>,
2732    ) -> std::task::Poll<Option<Self::Item>> {
2733        let this = &mut *self;
2734        if this.inner.check_shutdown(cx) {
2735            this.is_terminated = true;
2736            return std::task::Poll::Ready(None);
2737        }
2738        if this.is_terminated {
2739            panic!("polled PrivilegedNetworkLookupRequestStream after completion");
2740        }
2741        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2742            |bytes, handles| {
2743                match this.inner.channel().read_etc(cx, bytes, handles) {
2744                    std::task::Poll::Ready(Ok(())) => {}
2745                    std::task::Poll::Pending => return std::task::Poll::Pending,
2746                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2747                        this.is_terminated = true;
2748                        return std::task::Poll::Ready(None);
2749                    }
2750                    std::task::Poll::Ready(Err(e)) => {
2751                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2752                            e.into(),
2753                        ))));
2754                    }
2755                }
2756
2757                // A message has been received from the channel
2758                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2759
2760                std::task::Poll::Ready(Some(match header.ordinal {
2761                0x56c60798dfd78cab => {
2762                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2763                    let mut req = fidl::new_empty!(LookupRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2764                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LookupRequest>(&header, _body_bytes, handles, &mut req)?;
2765                    let control_handle = PrivilegedNetworkLookupControlHandle {
2766                        inner: this.inner.clone(),
2767                    };
2768                    Ok(PrivilegedNetworkLookupRequest::Lookup {payload: req,
2769                        responder: PrivilegedNetworkLookupLookupResponder {
2770                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2771                            tx_id: header.tx_id,
2772                        },
2773                    })
2774                }
2775                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2776                    Ok(PrivilegedNetworkLookupRequest::_UnknownMethod {
2777                        ordinal: header.ordinal,
2778                        control_handle: PrivilegedNetworkLookupControlHandle { inner: this.inner.clone() },
2779                        method_type: fidl::MethodType::OneWay,
2780                    })
2781                }
2782                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2783                    this.inner.send_framework_err(
2784                        fidl::encoding::FrameworkErr::UnknownMethod,
2785                        header.tx_id,
2786                        header.ordinal,
2787                        header.dynamic_flags(),
2788                        (bytes, handles),
2789                    )?;
2790                    Ok(PrivilegedNetworkLookupRequest::_UnknownMethod {
2791                        ordinal: header.ordinal,
2792                        control_handle: PrivilegedNetworkLookupControlHandle { inner: this.inner.clone() },
2793                        method_type: fidl::MethodType::TwoWay,
2794                    })
2795                }
2796                _ => Err(fidl::Error::UnknownOrdinal {
2797                    ordinal: header.ordinal,
2798                    protocol_name: <PrivilegedNetworkLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2799                }),
2800            }))
2801            },
2802        )
2803    }
2804}
2805
2806/// Privileged API for looking up networks by handles from other subsystems.
2807///
2808/// Unlike [`Networks`], this protocol is intended only for privileged system
2809/// components (such as Software Delivery) that receive out-of-band network
2810/// handles and need to resolve them to a [`NetworkToken`].
2811#[derive(Debug)]
2812pub enum PrivilegedNetworkLookupRequest {
2813    /// Look up a network by an attribute of that network.
2814    ///
2815    /// This permits clients that have a network handle to get a [`NetworkToken`]
2816    /// for the matching network at the time of the call, regardless of whether
2817    /// that network is the default or not. Once obtained, the returned
2818    /// [`NetworkToken`] remains valid and bound to that network even if the
2819    /// network's attributes (such as its [`starnix_handle`]) later change, and
2820    /// is only invalidated when the network itself is removed.
2821    ///
2822    /// Responds immediately with either a [`NetworkToken`] or a [`NOT_FOUND`] error.
2823    Lookup { payload: LookupRequest, responder: PrivilegedNetworkLookupLookupResponder },
2824    /// An interaction was received which does not match any known method.
2825    #[non_exhaustive]
2826    _UnknownMethod {
2827        /// Ordinal of the method that was called.
2828        ordinal: u64,
2829        control_handle: PrivilegedNetworkLookupControlHandle,
2830        method_type: fidl::MethodType,
2831    },
2832}
2833
2834impl PrivilegedNetworkLookupRequest {
2835    #[allow(irrefutable_let_patterns)]
2836    pub fn into_lookup(self) -> Option<(LookupRequest, PrivilegedNetworkLookupLookupResponder)> {
2837        if let PrivilegedNetworkLookupRequest::Lookup { payload, responder } = self {
2838            Some((payload, responder))
2839        } else {
2840            None
2841        }
2842    }
2843
2844    /// Name of the method defined in FIDL
2845    pub fn method_name(&self) -> &'static str {
2846        match *self {
2847            PrivilegedNetworkLookupRequest::Lookup { .. } => "lookup",
2848            PrivilegedNetworkLookupRequest::_UnknownMethod {
2849                method_type: fidl::MethodType::OneWay,
2850                ..
2851            } => "unknown one-way method",
2852            PrivilegedNetworkLookupRequest::_UnknownMethod {
2853                method_type: fidl::MethodType::TwoWay,
2854                ..
2855            } => "unknown two-way method",
2856        }
2857    }
2858}
2859
2860#[derive(Debug, Clone)]
2861pub struct PrivilegedNetworkLookupControlHandle {
2862    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2863}
2864
2865impl PrivilegedNetworkLookupControlHandle {
2866    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2867        self.inner.shutdown_with_epitaph(status.into())
2868    }
2869}
2870
2871impl fidl::endpoints::ControlHandle for PrivilegedNetworkLookupControlHandle {
2872    fn shutdown(&self) {
2873        self.inner.shutdown()
2874    }
2875
2876    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2877        self.inner.shutdown_with_epitaph(status)
2878    }
2879
2880    fn is_closed(&self) -> bool {
2881        self.inner.channel().is_closed()
2882    }
2883    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2884        self.inner.channel().on_closed()
2885    }
2886
2887    #[cfg(target_os = "fuchsia")]
2888    fn signal_peer(
2889        &self,
2890        clear_mask: zx::Signals,
2891        set_mask: zx::Signals,
2892    ) -> Result<(), zx_status::Status> {
2893        use fidl::Peered;
2894        self.inner.channel().signal_peer(clear_mask, set_mask)
2895    }
2896}
2897
2898impl PrivilegedNetworkLookupControlHandle {}
2899
2900#[must_use = "FIDL methods require a response to be sent"]
2901#[derive(Debug)]
2902pub struct PrivilegedNetworkLookupLookupResponder {
2903    control_handle: std::mem::ManuallyDrop<PrivilegedNetworkLookupControlHandle>,
2904    tx_id: u32,
2905}
2906
2907/// Set the the channel to be shutdown (see [`PrivilegedNetworkLookupControlHandle::shutdown`])
2908/// if the responder is dropped without sending a response, so that the client
2909/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2910impl std::ops::Drop for PrivilegedNetworkLookupLookupResponder {
2911    fn drop(&mut self) {
2912        self.control_handle.shutdown();
2913        // Safety: drops once, never accessed again
2914        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2915    }
2916}
2917
2918impl fidl::endpoints::Responder for PrivilegedNetworkLookupLookupResponder {
2919    type ControlHandle = PrivilegedNetworkLookupControlHandle;
2920
2921    fn control_handle(&self) -> &PrivilegedNetworkLookupControlHandle {
2922        &self.control_handle
2923    }
2924
2925    fn drop_without_shutdown(mut self) {
2926        // Safety: drops once, never accessed again due to mem::forget
2927        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2928        // Prevent Drop from running (which would shut down the channel)
2929        std::mem::forget(self);
2930    }
2931}
2932
2933impl PrivilegedNetworkLookupLookupResponder {
2934    /// Sends a response to the FIDL transaction.
2935    ///
2936    /// Sets the channel to shutdown if an error occurs.
2937    pub fn send(self, mut result: Result<NetworkToken, LookupError>) -> Result<(), fidl::Error> {
2938        let _result = self.send_raw(result);
2939        if _result.is_err() {
2940            self.control_handle.shutdown();
2941        }
2942        self.drop_without_shutdown();
2943        _result
2944    }
2945
2946    /// Similar to "send" but does not shutdown the channel if an error occurs.
2947    pub fn send_no_shutdown_on_err(
2948        self,
2949        mut result: Result<NetworkToken, LookupError>,
2950    ) -> Result<(), fidl::Error> {
2951        let _result = self.send_raw(result);
2952        self.drop_without_shutdown();
2953        _result
2954    }
2955
2956    fn send_raw(&self, mut result: Result<NetworkToken, LookupError>) -> Result<(), fidl::Error> {
2957        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2958            PrivilegedNetworkLookupLookupResponse,
2959            LookupError,
2960        >>(
2961            fidl::encoding::FlexibleResult::new(
2962                result.as_mut().map_err(|e| *e).map(|network| (network,)),
2963            ),
2964            self.tx_id,
2965            0x56c60798dfd78cab,
2966            fidl::encoding::DynamicFlags::FLEXIBLE,
2967        )
2968    }
2969}
2970
2971#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2972pub struct PropertyWatcherMarker;
2973
2974impl fidl::endpoints::ProtocolMarker for PropertyWatcherMarker {
2975    type Proxy = PropertyWatcherProxy;
2976    type RequestStream = PropertyWatcherRequestStream;
2977    #[cfg(target_os = "fuchsia")]
2978    type SynchronousProxy = PropertyWatcherSynchronousProxy;
2979
2980    const DEBUG_NAME: &'static str = "(anonymous) PropertyWatcher";
2981}
2982pub type PropertyWatcherWatchResult = Result<PropertyUpdate, PropertyWatcherError>;
2983
2984pub trait PropertyWatcherProxyInterface: Send + Sync {
2985    type WatchResponseFut: std::future::Future<Output = Result<PropertyWatcherWatchResult, fidl::Error>>
2986        + Send;
2987    fn r#watch(&self) -> Self::WatchResponseFut;
2988}
2989#[derive(Debug)]
2990#[cfg(target_os = "fuchsia")]
2991pub struct PropertyWatcherSynchronousProxy {
2992    client: fidl::client::sync::Client,
2993}
2994
2995#[cfg(target_os = "fuchsia")]
2996impl fidl::endpoints::SynchronousProxy for PropertyWatcherSynchronousProxy {
2997    type Proxy = PropertyWatcherProxy;
2998    type Protocol = PropertyWatcherMarker;
2999
3000    fn from_channel(inner: fidl::Channel) -> Self {
3001        Self::new(inner)
3002    }
3003
3004    fn into_channel(self) -> fidl::Channel {
3005        self.client.into_channel()
3006    }
3007
3008    fn as_channel(&self) -> &fidl::Channel {
3009        self.client.as_channel()
3010    }
3011}
3012
3013#[cfg(target_os = "fuchsia")]
3014impl PropertyWatcherSynchronousProxy {
3015    pub fn new(channel: fidl::Channel) -> Self {
3016        Self { client: fidl::client::sync::Client::new(channel) }
3017    }
3018
3019    pub fn into_channel(self) -> fidl::Channel {
3020        self.client.into_channel()
3021    }
3022
3023    /// Waits until an event arrives and returns it. It is safe for other
3024    /// threads to make concurrent requests while waiting for an event.
3025    pub fn wait_for_event(
3026        &self,
3027        deadline: zx::MonotonicInstant,
3028    ) -> Result<PropertyWatcherEvent, fidl::Error> {
3029        PropertyWatcherEvent::decode(self.client.wait_for_event::<PropertyWatcherMarker>(deadline)?)
3030    }
3031
3032    /// A hanging-get method that returns updates to the properties requested
3033    /// when the watcher was created via [`Networks.WatchProperties`].
3034    ///
3035    /// The first call returns a snapshot of all requested properties
3036    /// for the watched network. Subsequent calls block until a property
3037    /// has changed since the last call to `Watch` returned.
3038    ///
3039    /// Only one call to this method may be pending at a time. Concurrent calls
3040    /// on the same `PropertyWatcher` immediately closes the connection with
3041    /// an `zx.Status.ALREADY_EXISTS` epitaph.
3042    pub fn r#watch(
3043        &self,
3044        ___deadline: zx::MonotonicInstant,
3045    ) -> Result<PropertyWatcherWatchResult, fidl::Error> {
3046        let _response =
3047            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
3048                PropertyWatcherWatchResponse,
3049                PropertyWatcherError,
3050            >, PropertyWatcherMarker>(
3051                (),
3052                0xde56bd724694478,
3053                fidl::encoding::DynamicFlags::empty(),
3054                ___deadline,
3055            )?;
3056        Ok(_response.map(|x| x.updates))
3057    }
3058}
3059
3060#[cfg(target_os = "fuchsia")]
3061impl From<PropertyWatcherSynchronousProxy> for zx::NullableHandle {
3062    fn from(value: PropertyWatcherSynchronousProxy) -> Self {
3063        value.into_channel().into()
3064    }
3065}
3066
3067#[cfg(target_os = "fuchsia")]
3068impl From<fidl::Channel> for PropertyWatcherSynchronousProxy {
3069    fn from(value: fidl::Channel) -> Self {
3070        Self::new(value)
3071    }
3072}
3073
3074#[cfg(target_os = "fuchsia")]
3075impl fidl::endpoints::FromClient for PropertyWatcherSynchronousProxy {
3076    type Protocol = PropertyWatcherMarker;
3077
3078    fn from_client(value: fidl::endpoints::ClientEnd<PropertyWatcherMarker>) -> Self {
3079        Self::new(value.into_channel())
3080    }
3081}
3082
3083#[derive(Debug, Clone)]
3084pub struct PropertyWatcherProxy {
3085    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3086}
3087
3088impl fidl::endpoints::Proxy for PropertyWatcherProxy {
3089    type Protocol = PropertyWatcherMarker;
3090
3091    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3092        Self::new(inner)
3093    }
3094
3095    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3096        self.client.into_channel().map_err(|client| Self { client })
3097    }
3098
3099    fn as_channel(&self) -> &::fidl::AsyncChannel {
3100        self.client.as_channel()
3101    }
3102}
3103
3104impl PropertyWatcherProxy {
3105    /// Create a new Proxy for fuchsia.net.policy.properties/PropertyWatcher.
3106    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3107        let protocol_name = <PropertyWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3108        Self { client: fidl::client::Client::new(channel, protocol_name) }
3109    }
3110
3111    /// Get a Stream of events from the remote end of the protocol.
3112    ///
3113    /// # Panics
3114    ///
3115    /// Panics if the event stream was already taken.
3116    pub fn take_event_stream(&self) -> PropertyWatcherEventStream {
3117        PropertyWatcherEventStream { event_receiver: self.client.take_event_receiver() }
3118    }
3119
3120    /// A hanging-get method that returns updates to the properties requested
3121    /// when the watcher was created via [`Networks.WatchProperties`].
3122    ///
3123    /// The first call returns a snapshot of all requested properties
3124    /// for the watched network. Subsequent calls block until a property
3125    /// has changed since the last call to `Watch` returned.
3126    ///
3127    /// Only one call to this method may be pending at a time. Concurrent calls
3128    /// on the same `PropertyWatcher` immediately closes the connection with
3129    /// an `zx.Status.ALREADY_EXISTS` epitaph.
3130    pub fn r#watch(
3131        &self,
3132    ) -> fidl::client::QueryResponseFut<
3133        PropertyWatcherWatchResult,
3134        fidl::encoding::DefaultFuchsiaResourceDialect,
3135    > {
3136        PropertyWatcherProxyInterface::r#watch(self)
3137    }
3138}
3139
3140impl PropertyWatcherProxyInterface for PropertyWatcherProxy {
3141    type WatchResponseFut = fidl::client::QueryResponseFut<
3142        PropertyWatcherWatchResult,
3143        fidl::encoding::DefaultFuchsiaResourceDialect,
3144    >;
3145    fn r#watch(&self) -> Self::WatchResponseFut {
3146        fn _decode(
3147            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3148        ) -> Result<PropertyWatcherWatchResult, fidl::Error> {
3149            let _response = fidl::client::decode_transaction_body::<
3150                fidl::encoding::ResultType<PropertyWatcherWatchResponse, PropertyWatcherError>,
3151                fidl::encoding::DefaultFuchsiaResourceDialect,
3152                0xde56bd724694478,
3153            >(_buf?)?;
3154            Ok(_response.map(|x| x.updates))
3155        }
3156        self.client
3157            .send_query_and_decode::<fidl::encoding::EmptyPayload, PropertyWatcherWatchResult>(
3158                (),
3159                0xde56bd724694478,
3160                fidl::encoding::DynamicFlags::empty(),
3161                _decode,
3162            )
3163    }
3164}
3165
3166pub struct PropertyWatcherEventStream {
3167    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3168}
3169
3170impl std::marker::Unpin for PropertyWatcherEventStream {}
3171
3172impl futures::stream::FusedStream for PropertyWatcherEventStream {
3173    fn is_terminated(&self) -> bool {
3174        self.event_receiver.is_terminated()
3175    }
3176}
3177
3178impl futures::Stream for PropertyWatcherEventStream {
3179    type Item = Result<PropertyWatcherEvent, fidl::Error>;
3180
3181    fn poll_next(
3182        mut self: std::pin::Pin<&mut Self>,
3183        cx: &mut std::task::Context<'_>,
3184    ) -> std::task::Poll<Option<Self::Item>> {
3185        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3186            &mut self.event_receiver,
3187            cx
3188        )?) {
3189            Some(buf) => std::task::Poll::Ready(Some(PropertyWatcherEvent::decode(buf))),
3190            None => std::task::Poll::Ready(None),
3191        }
3192    }
3193}
3194
3195#[derive(Debug)]
3196pub enum PropertyWatcherEvent {}
3197
3198impl PropertyWatcherEvent {
3199    /// Decodes a message buffer as a [`PropertyWatcherEvent`].
3200    fn decode(
3201        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3202    ) -> Result<PropertyWatcherEvent, fidl::Error> {
3203        let (bytes, _handles) = buf.split_mut();
3204        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3205        debug_assert_eq!(tx_header.tx_id, 0);
3206        match tx_header.ordinal {
3207            _ => Err(fidl::Error::UnknownOrdinal {
3208                ordinal: tx_header.ordinal,
3209                protocol_name:
3210                    <PropertyWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3211            }),
3212        }
3213    }
3214}
3215
3216/// A Stream of incoming requests for fuchsia.net.policy.properties/PropertyWatcher.
3217pub struct PropertyWatcherRequestStream {
3218    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3219    is_terminated: bool,
3220}
3221
3222impl std::marker::Unpin for PropertyWatcherRequestStream {}
3223
3224impl futures::stream::FusedStream for PropertyWatcherRequestStream {
3225    fn is_terminated(&self) -> bool {
3226        self.is_terminated
3227    }
3228}
3229
3230impl fidl::endpoints::RequestStream for PropertyWatcherRequestStream {
3231    type Protocol = PropertyWatcherMarker;
3232    type ControlHandle = PropertyWatcherControlHandle;
3233
3234    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3235        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3236    }
3237
3238    fn control_handle(&self) -> Self::ControlHandle {
3239        PropertyWatcherControlHandle { inner: self.inner.clone() }
3240    }
3241
3242    fn into_inner(
3243        self,
3244    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3245    {
3246        (self.inner, self.is_terminated)
3247    }
3248
3249    fn from_inner(
3250        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3251        is_terminated: bool,
3252    ) -> Self {
3253        Self { inner, is_terminated }
3254    }
3255}
3256
3257impl futures::Stream for PropertyWatcherRequestStream {
3258    type Item = Result<PropertyWatcherRequest, fidl::Error>;
3259
3260    fn poll_next(
3261        mut self: std::pin::Pin<&mut Self>,
3262        cx: &mut std::task::Context<'_>,
3263    ) -> std::task::Poll<Option<Self::Item>> {
3264        let this = &mut *self;
3265        if this.inner.check_shutdown(cx) {
3266            this.is_terminated = true;
3267            return std::task::Poll::Ready(None);
3268        }
3269        if this.is_terminated {
3270            panic!("polled PropertyWatcherRequestStream after completion");
3271        }
3272        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3273            |bytes, handles| {
3274                match this.inner.channel().read_etc(cx, bytes, handles) {
3275                    std::task::Poll::Ready(Ok(())) => {}
3276                    std::task::Poll::Pending => return std::task::Poll::Pending,
3277                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3278                        this.is_terminated = true;
3279                        return std::task::Poll::Ready(None);
3280                    }
3281                    std::task::Poll::Ready(Err(e)) => {
3282                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3283                            e.into(),
3284                        ))));
3285                    }
3286                }
3287
3288                // A message has been received from the channel
3289                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3290
3291                std::task::Poll::Ready(Some(match header.ordinal {
3292                    0xde56bd724694478 => {
3293                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3294                        let mut req = fidl::new_empty!(
3295                            fidl::encoding::EmptyPayload,
3296                            fidl::encoding::DefaultFuchsiaResourceDialect
3297                        );
3298                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3299                        let control_handle =
3300                            PropertyWatcherControlHandle { inner: this.inner.clone() };
3301                        Ok(PropertyWatcherRequest::Watch {
3302                            responder: PropertyWatcherWatchResponder {
3303                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3304                                tx_id: header.tx_id,
3305                            },
3306                        })
3307                    }
3308                    _ => Err(fidl::Error::UnknownOrdinal {
3309                        ordinal: header.ordinal,
3310                        protocol_name:
3311                            <PropertyWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3312                    }),
3313                }))
3314            },
3315        )
3316    }
3317}
3318
3319/// A watcher for network property changes.
3320#[derive(Debug)]
3321pub enum PropertyWatcherRequest {
3322    /// A hanging-get method that returns updates to the properties requested
3323    /// when the watcher was created via [`Networks.WatchProperties`].
3324    ///
3325    /// The first call returns a snapshot of all requested properties
3326    /// for the watched network. Subsequent calls block until a property
3327    /// has changed since the last call to `Watch` returned.
3328    ///
3329    /// Only one call to this method may be pending at a time. Concurrent calls
3330    /// on the same `PropertyWatcher` immediately closes the connection with
3331    /// an `zx.Status.ALREADY_EXISTS` epitaph.
3332    Watch { responder: PropertyWatcherWatchResponder },
3333}
3334
3335impl PropertyWatcherRequest {
3336    #[allow(irrefutable_let_patterns)]
3337    pub fn into_watch(self) -> Option<(PropertyWatcherWatchResponder)> {
3338        if let PropertyWatcherRequest::Watch { responder } = self {
3339            Some((responder))
3340        } else {
3341            None
3342        }
3343    }
3344
3345    /// Name of the method defined in FIDL
3346    pub fn method_name(&self) -> &'static str {
3347        match *self {
3348            PropertyWatcherRequest::Watch { .. } => "watch",
3349        }
3350    }
3351}
3352
3353#[derive(Debug, Clone)]
3354pub struct PropertyWatcherControlHandle {
3355    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3356}
3357
3358impl PropertyWatcherControlHandle {
3359    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3360        self.inner.shutdown_with_epitaph(status.into())
3361    }
3362}
3363
3364impl fidl::endpoints::ControlHandle for PropertyWatcherControlHandle {
3365    fn shutdown(&self) {
3366        self.inner.shutdown()
3367    }
3368
3369    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3370        self.inner.shutdown_with_epitaph(status)
3371    }
3372
3373    fn is_closed(&self) -> bool {
3374        self.inner.channel().is_closed()
3375    }
3376    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3377        self.inner.channel().on_closed()
3378    }
3379
3380    #[cfg(target_os = "fuchsia")]
3381    fn signal_peer(
3382        &self,
3383        clear_mask: zx::Signals,
3384        set_mask: zx::Signals,
3385    ) -> Result<(), zx_status::Status> {
3386        use fidl::Peered;
3387        self.inner.channel().signal_peer(clear_mask, set_mask)
3388    }
3389}
3390
3391impl PropertyWatcherControlHandle {}
3392
3393#[must_use = "FIDL methods require a response to be sent"]
3394#[derive(Debug)]
3395pub struct PropertyWatcherWatchResponder {
3396    control_handle: std::mem::ManuallyDrop<PropertyWatcherControlHandle>,
3397    tx_id: u32,
3398}
3399
3400/// Set the the channel to be shutdown (see [`PropertyWatcherControlHandle::shutdown`])
3401/// if the responder is dropped without sending a response, so that the client
3402/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3403impl std::ops::Drop for PropertyWatcherWatchResponder {
3404    fn drop(&mut self) {
3405        self.control_handle.shutdown();
3406        // Safety: drops once, never accessed again
3407        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3408    }
3409}
3410
3411impl fidl::endpoints::Responder for PropertyWatcherWatchResponder {
3412    type ControlHandle = PropertyWatcherControlHandle;
3413
3414    fn control_handle(&self) -> &PropertyWatcherControlHandle {
3415        &self.control_handle
3416    }
3417
3418    fn drop_without_shutdown(mut self) {
3419        // Safety: drops once, never accessed again due to mem::forget
3420        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3421        // Prevent Drop from running (which would shut down the channel)
3422        std::mem::forget(self);
3423    }
3424}
3425
3426impl PropertyWatcherWatchResponder {
3427    /// Sends a response to the FIDL transaction.
3428    ///
3429    /// Sets the channel to shutdown if an error occurs.
3430    pub fn send(
3431        self,
3432        mut result: Result<&PropertyUpdate, PropertyWatcherError>,
3433    ) -> Result<(), fidl::Error> {
3434        let _result = self.send_raw(result);
3435        if _result.is_err() {
3436            self.control_handle.shutdown();
3437        }
3438        self.drop_without_shutdown();
3439        _result
3440    }
3441
3442    /// Similar to "send" but does not shutdown the channel if an error occurs.
3443    pub fn send_no_shutdown_on_err(
3444        self,
3445        mut result: Result<&PropertyUpdate, PropertyWatcherError>,
3446    ) -> Result<(), fidl::Error> {
3447        let _result = self.send_raw(result);
3448        self.drop_without_shutdown();
3449        _result
3450    }
3451
3452    fn send_raw(
3453        &self,
3454        mut result: Result<&PropertyUpdate, PropertyWatcherError>,
3455    ) -> Result<(), fidl::Error> {
3456        self.control_handle.inner.send::<fidl::encoding::ResultType<
3457            PropertyWatcherWatchResponse,
3458            PropertyWatcherError,
3459        >>(
3460            result.map(|updates| (updates,)),
3461            self.tx_id,
3462            0xde56bd724694478,
3463            fidl::encoding::DynamicFlags::empty(),
3464        )
3465    }
3466}
3467
3468mod internal {
3469    use super::*;
3470
3471    impl fidl::encoding::ResourceTypeMarker for NetworkToken {
3472        type Borrowed<'a> = &'a mut Self;
3473        fn take_or_borrow<'a>(
3474            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3475        ) -> Self::Borrowed<'a> {
3476            value
3477        }
3478    }
3479
3480    unsafe impl fidl::encoding::TypeMarker for NetworkToken {
3481        type Owned = Self;
3482
3483        #[inline(always)]
3484        fn inline_align(_context: fidl::encoding::Context) -> usize {
3485            4
3486        }
3487
3488        #[inline(always)]
3489        fn inline_size(_context: fidl::encoding::Context) -> usize {
3490            4
3491        }
3492    }
3493
3494    unsafe impl fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>
3495        for &mut NetworkToken
3496    {
3497        #[inline]
3498        unsafe fn encode(
3499            self,
3500            encoder: &mut fidl::encoding::Encoder<
3501                '_,
3502                fidl::encoding::DefaultFuchsiaResourceDialect,
3503            >,
3504            offset: usize,
3505            _depth: fidl::encoding::Depth,
3506        ) -> fidl::Result<()> {
3507            encoder.debug_check_bounds::<NetworkToken>(offset);
3508            // Delegate to tuple encoding.
3509            fidl::encoding::Encode::<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3510                (
3511                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
3512                ),
3513                encoder, offset, _depth
3514            )
3515        }
3516    }
3517    unsafe impl<
3518        T0: fidl::encoding::Encode<
3519                fidl::encoding::HandleType<
3520                    fidl::EventPair,
3521                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3522                    2147483648,
3523                >,
3524                fidl::encoding::DefaultFuchsiaResourceDialect,
3525            >,
3526    > fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0,)
3527    {
3528        #[inline]
3529        unsafe fn encode(
3530            self,
3531            encoder: &mut fidl::encoding::Encoder<
3532                '_,
3533                fidl::encoding::DefaultFuchsiaResourceDialect,
3534            >,
3535            offset: usize,
3536            depth: fidl::encoding::Depth,
3537        ) -> fidl::Result<()> {
3538            encoder.debug_check_bounds::<NetworkToken>(offset);
3539            // Zero out padding regions. There's no need to apply masks
3540            // because the unmasked parts will be overwritten by fields.
3541            // Write the fields.
3542            self.0.encode(encoder, offset + 0, depth)?;
3543            Ok(())
3544        }
3545    }
3546
3547    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NetworkToken {
3548        #[inline(always)]
3549        fn new_empty() -> Self {
3550            Self {
3551                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3552            }
3553        }
3554
3555        #[inline]
3556        unsafe fn decode(
3557            &mut self,
3558            decoder: &mut fidl::encoding::Decoder<
3559                '_,
3560                fidl::encoding::DefaultFuchsiaResourceDialect,
3561            >,
3562            offset: usize,
3563            _depth: fidl::encoding::Depth,
3564        ) -> fidl::Result<()> {
3565            decoder.debug_check_bounds::<Self>(offset);
3566            // Verify that padding bytes are zero.
3567            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
3568            Ok(())
3569        }
3570    }
3571
3572    impl fidl::encoding::ResourceTypeMarker for NetworkTokenResolverResolveTokenRequest {
3573        type Borrowed<'a> = &'a mut Self;
3574        fn take_or_borrow<'a>(
3575            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3576        ) -> Self::Borrowed<'a> {
3577            value
3578        }
3579    }
3580
3581    unsafe impl fidl::encoding::TypeMarker for NetworkTokenResolverResolveTokenRequest {
3582        type Owned = Self;
3583
3584        #[inline(always)]
3585        fn inline_align(_context: fidl::encoding::Context) -> usize {
3586            4
3587        }
3588
3589        #[inline(always)]
3590        fn inline_size(_context: fidl::encoding::Context) -> usize {
3591            4
3592        }
3593    }
3594
3595    unsafe impl
3596        fidl::encoding::Encode<
3597            NetworkTokenResolverResolveTokenRequest,
3598            fidl::encoding::DefaultFuchsiaResourceDialect,
3599        > for &mut NetworkTokenResolverResolveTokenRequest
3600    {
3601        #[inline]
3602        unsafe fn encode(
3603            self,
3604            encoder: &mut fidl::encoding::Encoder<
3605                '_,
3606                fidl::encoding::DefaultFuchsiaResourceDialect,
3607            >,
3608            offset: usize,
3609            _depth: fidl::encoding::Depth,
3610        ) -> fidl::Result<()> {
3611            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenRequest>(offset);
3612            // Delegate to tuple encoding.
3613            fidl::encoding::Encode::<
3614                NetworkTokenResolverResolveTokenRequest,
3615                fidl::encoding::DefaultFuchsiaResourceDialect,
3616            >::encode(
3617                (<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3618                    &mut self.token,
3619                ),),
3620                encoder,
3621                offset,
3622                _depth,
3623            )
3624        }
3625    }
3626    unsafe impl<
3627        T0: fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>,
3628    >
3629        fidl::encoding::Encode<
3630            NetworkTokenResolverResolveTokenRequest,
3631            fidl::encoding::DefaultFuchsiaResourceDialect,
3632        > for (T0,)
3633    {
3634        #[inline]
3635        unsafe fn encode(
3636            self,
3637            encoder: &mut fidl::encoding::Encoder<
3638                '_,
3639                fidl::encoding::DefaultFuchsiaResourceDialect,
3640            >,
3641            offset: usize,
3642            depth: fidl::encoding::Depth,
3643        ) -> fidl::Result<()> {
3644            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenRequest>(offset);
3645            // Zero out padding regions. There's no need to apply masks
3646            // because the unmasked parts will be overwritten by fields.
3647            // Write the fields.
3648            self.0.encode(encoder, offset + 0, depth)?;
3649            Ok(())
3650        }
3651    }
3652
3653    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3654        for NetworkTokenResolverResolveTokenRequest
3655    {
3656        #[inline(always)]
3657        fn new_empty() -> Self {
3658            Self {
3659                token: fidl::new_empty!(
3660                    NetworkToken,
3661                    fidl::encoding::DefaultFuchsiaResourceDialect
3662                ),
3663            }
3664        }
3665
3666        #[inline]
3667        unsafe fn decode(
3668            &mut self,
3669            decoder: &mut fidl::encoding::Decoder<
3670                '_,
3671                fidl::encoding::DefaultFuchsiaResourceDialect,
3672            >,
3673            offset: usize,
3674            _depth: fidl::encoding::Depth,
3675        ) -> fidl::Result<()> {
3676            decoder.debug_check_bounds::<Self>(offset);
3677            // Verify that padding bytes are zero.
3678            fidl::decode!(
3679                NetworkToken,
3680                fidl::encoding::DefaultFuchsiaResourceDialect,
3681                &mut self.token,
3682                decoder,
3683                offset + 0,
3684                _depth
3685            )?;
3686            Ok(())
3687        }
3688    }
3689
3690    impl fidl::encoding::ResourceTypeMarker for NetworkTokenResolverResolveTokenResponse {
3691        type Borrowed<'a> = &'a mut Self;
3692        fn take_or_borrow<'a>(
3693            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3694        ) -> Self::Borrowed<'a> {
3695            value
3696        }
3697    }
3698
3699    unsafe impl fidl::encoding::TypeMarker for NetworkTokenResolverResolveTokenResponse {
3700        type Owned = Self;
3701
3702        #[inline(always)]
3703        fn inline_align(_context: fidl::encoding::Context) -> usize {
3704            4
3705        }
3706
3707        #[inline(always)]
3708        fn inline_size(_context: fidl::encoding::Context) -> usize {
3709            4
3710        }
3711    }
3712
3713    unsafe impl
3714        fidl::encoding::Encode<
3715            NetworkTokenResolverResolveTokenResponse,
3716            fidl::encoding::DefaultFuchsiaResourceDialect,
3717        > for &mut NetworkTokenResolverResolveTokenResponse
3718    {
3719        #[inline]
3720        unsafe fn encode(
3721            self,
3722            encoder: &mut fidl::encoding::Encoder<
3723                '_,
3724                fidl::encoding::DefaultFuchsiaResourceDialect,
3725            >,
3726            offset: usize,
3727            _depth: fidl::encoding::Depth,
3728        ) -> fidl::Result<()> {
3729            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenResponse>(offset);
3730            // Delegate to tuple encoding.
3731            fidl::encoding::Encode::<
3732                NetworkTokenResolverResolveTokenResponse,
3733                fidl::encoding::DefaultFuchsiaResourceDialect,
3734            >::encode(
3735                (<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3736                    &mut self.resolved_token,
3737                ),),
3738                encoder,
3739                offset,
3740                _depth,
3741            )
3742        }
3743    }
3744    unsafe impl<
3745        T0: fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>,
3746    >
3747        fidl::encoding::Encode<
3748            NetworkTokenResolverResolveTokenResponse,
3749            fidl::encoding::DefaultFuchsiaResourceDialect,
3750        > for (T0,)
3751    {
3752        #[inline]
3753        unsafe fn encode(
3754            self,
3755            encoder: &mut fidl::encoding::Encoder<
3756                '_,
3757                fidl::encoding::DefaultFuchsiaResourceDialect,
3758            >,
3759            offset: usize,
3760            depth: fidl::encoding::Depth,
3761        ) -> fidl::Result<()> {
3762            encoder.debug_check_bounds::<NetworkTokenResolverResolveTokenResponse>(offset);
3763            // Zero out padding regions. There's no need to apply masks
3764            // because the unmasked parts will be overwritten by fields.
3765            // Write the fields.
3766            self.0.encode(encoder, offset + 0, depth)?;
3767            Ok(())
3768        }
3769    }
3770
3771    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3772        for NetworkTokenResolverResolveTokenResponse
3773    {
3774        #[inline(always)]
3775        fn new_empty() -> Self {
3776            Self {
3777                resolved_token: fidl::new_empty!(
3778                    NetworkToken,
3779                    fidl::encoding::DefaultFuchsiaResourceDialect
3780                ),
3781            }
3782        }
3783
3784        #[inline]
3785        unsafe fn decode(
3786            &mut self,
3787            decoder: &mut fidl::encoding::Decoder<
3788                '_,
3789                fidl::encoding::DefaultFuchsiaResourceDialect,
3790            >,
3791            offset: usize,
3792            _depth: fidl::encoding::Depth,
3793        ) -> fidl::Result<()> {
3794            decoder.debug_check_bounds::<Self>(offset);
3795            // Verify that padding bytes are zero.
3796            fidl::decode!(
3797                NetworkToken,
3798                fidl::encoding::DefaultFuchsiaResourceDialect,
3799                &mut self.resolved_token,
3800                decoder,
3801                offset + 0,
3802                _depth
3803            )?;
3804            Ok(())
3805        }
3806    }
3807
3808    impl fidl::encoding::ResourceTypeMarker for PrivilegedNetworkLookupLookupResponse {
3809        type Borrowed<'a> = &'a mut Self;
3810        fn take_or_borrow<'a>(
3811            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3812        ) -> Self::Borrowed<'a> {
3813            value
3814        }
3815    }
3816
3817    unsafe impl fidl::encoding::TypeMarker for PrivilegedNetworkLookupLookupResponse {
3818        type Owned = Self;
3819
3820        #[inline(always)]
3821        fn inline_align(_context: fidl::encoding::Context) -> usize {
3822            4
3823        }
3824
3825        #[inline(always)]
3826        fn inline_size(_context: fidl::encoding::Context) -> usize {
3827            4
3828        }
3829    }
3830
3831    unsafe impl
3832        fidl::encoding::Encode<
3833            PrivilegedNetworkLookupLookupResponse,
3834            fidl::encoding::DefaultFuchsiaResourceDialect,
3835        > for &mut PrivilegedNetworkLookupLookupResponse
3836    {
3837        #[inline]
3838        unsafe fn encode(
3839            self,
3840            encoder: &mut fidl::encoding::Encoder<
3841                '_,
3842                fidl::encoding::DefaultFuchsiaResourceDialect,
3843            >,
3844            offset: usize,
3845            _depth: fidl::encoding::Depth,
3846        ) -> fidl::Result<()> {
3847            encoder.debug_check_bounds::<PrivilegedNetworkLookupLookupResponse>(offset);
3848            // Delegate to tuple encoding.
3849            fidl::encoding::Encode::<
3850                PrivilegedNetworkLookupLookupResponse,
3851                fidl::encoding::DefaultFuchsiaResourceDialect,
3852            >::encode(
3853                (<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3854                    &mut self.network,
3855                ),),
3856                encoder,
3857                offset,
3858                _depth,
3859            )
3860        }
3861    }
3862    unsafe impl<
3863        T0: fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>,
3864    >
3865        fidl::encoding::Encode<
3866            PrivilegedNetworkLookupLookupResponse,
3867            fidl::encoding::DefaultFuchsiaResourceDialect,
3868        > for (T0,)
3869    {
3870        #[inline]
3871        unsafe fn encode(
3872            self,
3873            encoder: &mut fidl::encoding::Encoder<
3874                '_,
3875                fidl::encoding::DefaultFuchsiaResourceDialect,
3876            >,
3877            offset: usize,
3878            depth: fidl::encoding::Depth,
3879        ) -> fidl::Result<()> {
3880            encoder.debug_check_bounds::<PrivilegedNetworkLookupLookupResponse>(offset);
3881            // Zero out padding regions. There's no need to apply masks
3882            // because the unmasked parts will be overwritten by fields.
3883            // Write the fields.
3884            self.0.encode(encoder, offset + 0, depth)?;
3885            Ok(())
3886        }
3887    }
3888
3889    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3890        for PrivilegedNetworkLookupLookupResponse
3891    {
3892        #[inline(always)]
3893        fn new_empty() -> Self {
3894            Self {
3895                network: fidl::new_empty!(
3896                    NetworkToken,
3897                    fidl::encoding::DefaultFuchsiaResourceDialect
3898                ),
3899            }
3900        }
3901
3902        #[inline]
3903        unsafe fn decode(
3904            &mut self,
3905            decoder: &mut fidl::encoding::Decoder<
3906                '_,
3907                fidl::encoding::DefaultFuchsiaResourceDialect,
3908            >,
3909            offset: usize,
3910            _depth: fidl::encoding::Depth,
3911        ) -> fidl::Result<()> {
3912            decoder.debug_check_bounds::<Self>(offset);
3913            // Verify that padding bytes are zero.
3914            fidl::decode!(
3915                NetworkToken,
3916                fidl::encoding::DefaultFuchsiaResourceDialect,
3917                &mut self.network,
3918                decoder,
3919                offset + 0,
3920                _depth
3921            )?;
3922            Ok(())
3923        }
3924    }
3925
3926    impl NetworksWatchPropertiesRequest {
3927        #[inline(always)]
3928        fn max_ordinal_present(&self) -> u64 {
3929            if let Some(_) = self.watcher {
3930                return 3;
3931            }
3932            if let Some(_) = self.properties {
3933                return 2;
3934            }
3935            if let Some(_) = self.network {
3936                return 1;
3937            }
3938            0
3939        }
3940    }
3941
3942    impl fidl::encoding::ResourceTypeMarker for NetworksWatchPropertiesRequest {
3943        type Borrowed<'a> = &'a mut Self;
3944        fn take_or_borrow<'a>(
3945            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3946        ) -> Self::Borrowed<'a> {
3947            value
3948        }
3949    }
3950
3951    unsafe impl fidl::encoding::TypeMarker for NetworksWatchPropertiesRequest {
3952        type Owned = Self;
3953
3954        #[inline(always)]
3955        fn inline_align(_context: fidl::encoding::Context) -> usize {
3956            8
3957        }
3958
3959        #[inline(always)]
3960        fn inline_size(_context: fidl::encoding::Context) -> usize {
3961            16
3962        }
3963    }
3964
3965    unsafe impl
3966        fidl::encoding::Encode<
3967            NetworksWatchPropertiesRequest,
3968            fidl::encoding::DefaultFuchsiaResourceDialect,
3969        > for &mut NetworksWatchPropertiesRequest
3970    {
3971        unsafe fn encode(
3972            self,
3973            encoder: &mut fidl::encoding::Encoder<
3974                '_,
3975                fidl::encoding::DefaultFuchsiaResourceDialect,
3976            >,
3977            offset: usize,
3978            mut depth: fidl::encoding::Depth,
3979        ) -> fidl::Result<()> {
3980            encoder.debug_check_bounds::<NetworksWatchPropertiesRequest>(offset);
3981            // Vector header
3982            let max_ordinal: u64 = self.max_ordinal_present();
3983            encoder.write_num(max_ordinal, offset);
3984            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3985            // Calling encoder.out_of_line_offset(0) is not allowed.
3986            if max_ordinal == 0 {
3987                return Ok(());
3988            }
3989            depth.increment()?;
3990            let envelope_size = 8;
3991            let bytes_len = max_ordinal as usize * envelope_size;
3992            #[allow(unused_variables)]
3993            let offset = encoder.out_of_line_offset(bytes_len);
3994            let mut _prev_end_offset: usize = 0;
3995            if 1 > max_ordinal {
3996                return Ok(());
3997            }
3998
3999            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4000            // are envelope_size bytes.
4001            let cur_offset: usize = (1 - 1) * envelope_size;
4002
4003            // Zero reserved fields.
4004            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4005
4006            // Safety:
4007            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4008            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4009            //   envelope_size bytes, there is always sufficient room.
4010            fidl::encoding::encode_in_envelope_optional::<
4011                NetworkToken,
4012                fidl::encoding::DefaultFuchsiaResourceDialect,
4013            >(
4014                self.network
4015                    .as_mut()
4016                    .map(<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4017                encoder,
4018                offset + cur_offset,
4019                depth,
4020            )?;
4021
4022            _prev_end_offset = cur_offset + envelope_size;
4023            if 2 > max_ordinal {
4024                return Ok(());
4025            }
4026
4027            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4028            // are envelope_size bytes.
4029            let cur_offset: usize = (2 - 1) * envelope_size;
4030
4031            // Zero reserved fields.
4032            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4033
4034            // Safety:
4035            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4036            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4037            //   envelope_size bytes, there is always sufficient room.
4038            fidl::encoding::encode_in_envelope_optional::<
4039                PropertyInterest,
4040                fidl::encoding::DefaultFuchsiaResourceDialect,
4041            >(
4042                self.properties
4043                    .as_ref()
4044                    .map(<PropertyInterest as fidl::encoding::ValueTypeMarker>::borrow),
4045                encoder,
4046                offset + cur_offset,
4047                depth,
4048            )?;
4049
4050            _prev_end_offset = cur_offset + envelope_size;
4051            if 3 > max_ordinal {
4052                return Ok(());
4053            }
4054
4055            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4056            // are envelope_size bytes.
4057            let cur_offset: usize = (3 - 1) * envelope_size;
4058
4059            // Zero reserved fields.
4060            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4061
4062            // Safety:
4063            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4064            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4065            //   envelope_size bytes, there is always sufficient room.
4066            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PropertyWatcherMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4067            self.watcher.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PropertyWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4068            encoder, offset + cur_offset, depth
4069        )?;
4070
4071            _prev_end_offset = cur_offset + envelope_size;
4072
4073            Ok(())
4074        }
4075    }
4076
4077    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4078        for NetworksWatchPropertiesRequest
4079    {
4080        #[inline(always)]
4081        fn new_empty() -> Self {
4082            Self::default()
4083        }
4084
4085        unsafe fn decode(
4086            &mut self,
4087            decoder: &mut fidl::encoding::Decoder<
4088                '_,
4089                fidl::encoding::DefaultFuchsiaResourceDialect,
4090            >,
4091            offset: usize,
4092            mut depth: fidl::encoding::Depth,
4093        ) -> fidl::Result<()> {
4094            decoder.debug_check_bounds::<Self>(offset);
4095            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4096                None => return Err(fidl::Error::NotNullable),
4097                Some(len) => len,
4098            };
4099            // Calling decoder.out_of_line_offset(0) is not allowed.
4100            if len == 0 {
4101                return Ok(());
4102            };
4103            depth.increment()?;
4104            let envelope_size = 8;
4105            let bytes_len = len * envelope_size;
4106            let offset = decoder.out_of_line_offset(bytes_len)?;
4107            // Decode the envelope for each type.
4108            let mut _next_ordinal_to_read = 0;
4109            let mut next_offset = offset;
4110            let end_offset = offset + bytes_len;
4111            _next_ordinal_to_read += 1;
4112            if next_offset >= end_offset {
4113                return Ok(());
4114            }
4115
4116            // Decode unknown envelopes for gaps in ordinals.
4117            while _next_ordinal_to_read < 1 {
4118                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4119                _next_ordinal_to_read += 1;
4120                next_offset += envelope_size;
4121            }
4122
4123            let next_out_of_line = decoder.next_out_of_line();
4124            let handles_before = decoder.remaining_handles();
4125            if let Some((inlined, num_bytes, num_handles)) =
4126                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4127            {
4128                let member_inline_size =
4129                    <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4130                if inlined != (member_inline_size <= 4) {
4131                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4132                }
4133                let inner_offset;
4134                let mut inner_depth = depth.clone();
4135                if inlined {
4136                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4137                    inner_offset = next_offset;
4138                } else {
4139                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4140                    inner_depth.increment()?;
4141                }
4142                let val_ref = self.network.get_or_insert_with(|| {
4143                    fidl::new_empty!(NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect)
4144                });
4145                fidl::decode!(
4146                    NetworkToken,
4147                    fidl::encoding::DefaultFuchsiaResourceDialect,
4148                    val_ref,
4149                    decoder,
4150                    inner_offset,
4151                    inner_depth
4152                )?;
4153                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4154                {
4155                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4156                }
4157                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4158                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4159                }
4160            }
4161
4162            next_offset += envelope_size;
4163            _next_ordinal_to_read += 1;
4164            if next_offset >= end_offset {
4165                return Ok(());
4166            }
4167
4168            // Decode unknown envelopes for gaps in ordinals.
4169            while _next_ordinal_to_read < 2 {
4170                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4171                _next_ordinal_to_read += 1;
4172                next_offset += envelope_size;
4173            }
4174
4175            let next_out_of_line = decoder.next_out_of_line();
4176            let handles_before = decoder.remaining_handles();
4177            if let Some((inlined, num_bytes, num_handles)) =
4178                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4179            {
4180                let member_inline_size =
4181                    <PropertyInterest as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4182                if inlined != (member_inline_size <= 4) {
4183                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4184                }
4185                let inner_offset;
4186                let mut inner_depth = depth.clone();
4187                if inlined {
4188                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4189                    inner_offset = next_offset;
4190                } else {
4191                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4192                    inner_depth.increment()?;
4193                }
4194                let val_ref = self.properties.get_or_insert_with(|| {
4195                    fidl::new_empty!(
4196                        PropertyInterest,
4197                        fidl::encoding::DefaultFuchsiaResourceDialect
4198                    )
4199                });
4200                fidl::decode!(
4201                    PropertyInterest,
4202                    fidl::encoding::DefaultFuchsiaResourceDialect,
4203                    val_ref,
4204                    decoder,
4205                    inner_offset,
4206                    inner_depth
4207                )?;
4208                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4209                {
4210                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4211                }
4212                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4213                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4214                }
4215            }
4216
4217            next_offset += envelope_size;
4218            _next_ordinal_to_read += 1;
4219            if next_offset >= end_offset {
4220                return Ok(());
4221            }
4222
4223            // Decode unknown envelopes for gaps in ordinals.
4224            while _next_ordinal_to_read < 3 {
4225                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4226                _next_ordinal_to_read += 1;
4227                next_offset += envelope_size;
4228            }
4229
4230            let next_out_of_line = decoder.next_out_of_line();
4231            let handles_before = decoder.remaining_handles();
4232            if let Some((inlined, num_bytes, num_handles)) =
4233                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4234            {
4235                let member_inline_size = <fidl::encoding::Endpoint<
4236                    fidl::endpoints::ServerEnd<PropertyWatcherMarker>,
4237                > as fidl::encoding::TypeMarker>::inline_size(
4238                    decoder.context
4239                );
4240                if inlined != (member_inline_size <= 4) {
4241                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4242                }
4243                let inner_offset;
4244                let mut inner_depth = depth.clone();
4245                if inlined {
4246                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4247                    inner_offset = next_offset;
4248                } else {
4249                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4250                    inner_depth.increment()?;
4251                }
4252                let val_ref = self.watcher.get_or_insert_with(|| {
4253                    fidl::new_empty!(
4254                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PropertyWatcherMarker>>,
4255                        fidl::encoding::DefaultFuchsiaResourceDialect
4256                    )
4257                });
4258                fidl::decode!(
4259                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PropertyWatcherMarker>>,
4260                    fidl::encoding::DefaultFuchsiaResourceDialect,
4261                    val_ref,
4262                    decoder,
4263                    inner_offset,
4264                    inner_depth
4265                )?;
4266                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4267                {
4268                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4269                }
4270                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4271                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4272                }
4273            }
4274
4275            next_offset += envelope_size;
4276
4277            // Decode the remaining unknown envelopes.
4278            while next_offset < end_offset {
4279                _next_ordinal_to_read += 1;
4280                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4281                next_offset += envelope_size;
4282            }
4283
4284            Ok(())
4285        }
4286    }
4287
4288    impl fidl::encoding::ResourceTypeMarker for NetworksWatchDefaultResponse {
4289        type Borrowed<'a> = &'a mut Self;
4290        fn take_or_borrow<'a>(
4291            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4292        ) -> Self::Borrowed<'a> {
4293            value
4294        }
4295    }
4296
4297    unsafe impl fidl::encoding::TypeMarker for NetworksWatchDefaultResponse {
4298        type Owned = Self;
4299
4300        #[inline(always)]
4301        fn inline_align(_context: fidl::encoding::Context) -> usize {
4302            8
4303        }
4304
4305        #[inline(always)]
4306        fn inline_size(_context: fidl::encoding::Context) -> usize {
4307            16
4308        }
4309    }
4310
4311    unsafe impl
4312        fidl::encoding::Encode<
4313            NetworksWatchDefaultResponse,
4314            fidl::encoding::DefaultFuchsiaResourceDialect,
4315        > for &mut NetworksWatchDefaultResponse
4316    {
4317        #[inline]
4318        unsafe fn encode(
4319            self,
4320            encoder: &mut fidl::encoding::Encoder<
4321                '_,
4322                fidl::encoding::DefaultFuchsiaResourceDialect,
4323            >,
4324            offset: usize,
4325            _depth: fidl::encoding::Depth,
4326        ) -> fidl::Result<()> {
4327            encoder.debug_check_bounds::<NetworksWatchDefaultResponse>(offset);
4328            encoder.write_num::<u64>(self.ordinal(), offset);
4329            match self {
4330                NetworksWatchDefaultResponse::Network(ref mut val) => {
4331                    fidl::encoding::encode_in_envelope::<
4332                        NetworkToken,
4333                        fidl::encoding::DefaultFuchsiaResourceDialect,
4334                    >(
4335                        <NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
4336                        encoder,
4337                        offset + 8,
4338                        _depth,
4339                    )
4340                }
4341                NetworksWatchDefaultResponse::NoDefaultNetwork(ref val) => {
4342                    fidl::encoding::encode_in_envelope::<
4343                        Empty,
4344                        fidl::encoding::DefaultFuchsiaResourceDialect,
4345                    >(
4346                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
4347                        encoder,
4348                        offset + 8,
4349                        _depth,
4350                    )
4351                }
4352                NetworksWatchDefaultResponse::__SourceBreaking { .. } => {
4353                    Err(fidl::Error::UnknownUnionTag)
4354                }
4355            }
4356        }
4357    }
4358
4359    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4360        for NetworksWatchDefaultResponse
4361    {
4362        #[inline(always)]
4363        fn new_empty() -> Self {
4364            Self::__SourceBreaking { unknown_ordinal: 0 }
4365        }
4366
4367        #[inline]
4368        unsafe fn decode(
4369            &mut self,
4370            decoder: &mut fidl::encoding::Decoder<
4371                '_,
4372                fidl::encoding::DefaultFuchsiaResourceDialect,
4373            >,
4374            offset: usize,
4375            mut depth: fidl::encoding::Depth,
4376        ) -> fidl::Result<()> {
4377            decoder.debug_check_bounds::<Self>(offset);
4378            #[allow(unused_variables)]
4379            let next_out_of_line = decoder.next_out_of_line();
4380            let handles_before = decoder.remaining_handles();
4381            let (ordinal, inlined, num_bytes, num_handles) =
4382                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4383
4384            let member_inline_size = match ordinal {
4385                1 => <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4386                2 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4387                0 => return Err(fidl::Error::UnknownUnionTag),
4388                _ => num_bytes as usize,
4389            };
4390
4391            if inlined != (member_inline_size <= 4) {
4392                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4393            }
4394            let _inner_offset;
4395            if inlined {
4396                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4397                _inner_offset = offset + 8;
4398            } else {
4399                depth.increment()?;
4400                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4401            }
4402            match ordinal {
4403                1 => {
4404                    #[allow(irrefutable_let_patterns)]
4405                    if let NetworksWatchDefaultResponse::Network(_) = self {
4406                        // Do nothing, read the value into the object
4407                    } else {
4408                        // Initialize `self` to the right variant
4409                        *self = NetworksWatchDefaultResponse::Network(fidl::new_empty!(
4410                            NetworkToken,
4411                            fidl::encoding::DefaultFuchsiaResourceDialect
4412                        ));
4413                    }
4414                    #[allow(irrefutable_let_patterns)]
4415                    if let NetworksWatchDefaultResponse::Network(ref mut val) = self {
4416                        fidl::decode!(
4417                            NetworkToken,
4418                            fidl::encoding::DefaultFuchsiaResourceDialect,
4419                            val,
4420                            decoder,
4421                            _inner_offset,
4422                            depth
4423                        )?;
4424                    } else {
4425                        unreachable!()
4426                    }
4427                }
4428                2 => {
4429                    #[allow(irrefutable_let_patterns)]
4430                    if let NetworksWatchDefaultResponse::NoDefaultNetwork(_) = self {
4431                        // Do nothing, read the value into the object
4432                    } else {
4433                        // Initialize `self` to the right variant
4434                        *self = NetworksWatchDefaultResponse::NoDefaultNetwork(fidl::new_empty!(
4435                            Empty,
4436                            fidl::encoding::DefaultFuchsiaResourceDialect
4437                        ));
4438                    }
4439                    #[allow(irrefutable_let_patterns)]
4440                    if let NetworksWatchDefaultResponse::NoDefaultNetwork(ref mut val) = self {
4441                        fidl::decode!(
4442                            Empty,
4443                            fidl::encoding::DefaultFuchsiaResourceDialect,
4444                            val,
4445                            decoder,
4446                            _inner_offset,
4447                            depth
4448                        )?;
4449                    } else {
4450                        unreachable!()
4451                    }
4452                }
4453                #[allow(deprecated)]
4454                ordinal => {
4455                    for _ in 0..num_handles {
4456                        decoder.drop_next_handle()?;
4457                    }
4458                    *self =
4459                        NetworksWatchDefaultResponse::__SourceBreaking { unknown_ordinal: ordinal };
4460                }
4461            }
4462            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4463                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4464            }
4465            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4466                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4467            }
4468            Ok(())
4469        }
4470    }
4471}