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