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