fidl_fuchsia_net_name/
fidl_fuchsia_net_name.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_name_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DnsServerWatcherMarker;
16
17impl fidl::endpoints::ProtocolMarker for DnsServerWatcherMarker {
18    type Proxy = DnsServerWatcherProxy;
19    type RequestStream = DnsServerWatcherRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DnsServerWatcherSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.net.name.DnsServerWatcher";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DnsServerWatcherMarker {}
26
27pub trait DnsServerWatcherProxyInterface: Send + Sync {
28    type WatchServersResponseFut: std::future::Future<Output = Result<Vec<DnsServer_>, fidl::Error>>
29        + Send;
30    fn r#watch_servers(&self) -> Self::WatchServersResponseFut;
31}
32#[derive(Debug)]
33#[cfg(target_os = "fuchsia")]
34pub struct DnsServerWatcherSynchronousProxy {
35    client: fidl::client::sync::Client,
36}
37
38#[cfg(target_os = "fuchsia")]
39impl fidl::endpoints::SynchronousProxy for DnsServerWatcherSynchronousProxy {
40    type Proxy = DnsServerWatcherProxy;
41    type Protocol = DnsServerWatcherMarker;
42
43    fn from_channel(inner: fidl::Channel) -> Self {
44        Self::new(inner)
45    }
46
47    fn into_channel(self) -> fidl::Channel {
48        self.client.into_channel()
49    }
50
51    fn as_channel(&self) -> &fidl::Channel {
52        self.client.as_channel()
53    }
54}
55
56#[cfg(target_os = "fuchsia")]
57impl DnsServerWatcherSynchronousProxy {
58    pub fn new(channel: fidl::Channel) -> Self {
59        let protocol_name = <DnsServerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
60        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
61    }
62
63    pub fn into_channel(self) -> fidl::Channel {
64        self.client.into_channel()
65    }
66
67    /// Waits until an event arrives and returns it. It is safe for other
68    /// threads to make concurrent requests while waiting for an event.
69    pub fn wait_for_event(
70        &self,
71        deadline: zx::MonotonicInstant,
72    ) -> Result<DnsServerWatcherEvent, fidl::Error> {
73        DnsServerWatcherEvent::decode(self.client.wait_for_event(deadline)?)
74    }
75
76    /// Returns a list of DNS servers.
77    ///
78    /// First call always returns a snapshot of the current list of servers or blocks if an empty
79    /// list would be returned. Subsequent calls will block until the list of servers changes.
80    ///
81    /// The list of servers changes over time by configuration or network topology changes,
82    /// expiration, etc. Callers must repeatedly call `WatchServers` and replace any previously
83    /// returned `servers` with new ones to avoid using stale or expired entries.
84    ///
85    /// It is invalid to call this method while a previous call is pending. Doing so will cause the
86    /// server end of the protocol to be closed.
87    ///
88    /// - response `servers` The list of servers to use for DNS resolution, in priority order.
89    pub fn r#watch_servers(
90        &self,
91        ___deadline: zx::MonotonicInstant,
92    ) -> Result<Vec<DnsServer_>, fidl::Error> {
93        let _response = self
94            .client
95            .send_query::<fidl::encoding::EmptyPayload, DnsServerWatcherWatchServersResponse>(
96                (),
97                0x5748907e7f11b632,
98                fidl::encoding::DynamicFlags::empty(),
99                ___deadline,
100            )?;
101        Ok(_response.servers)
102    }
103}
104
105#[derive(Debug, Clone)]
106pub struct DnsServerWatcherProxy {
107    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
108}
109
110impl fidl::endpoints::Proxy for DnsServerWatcherProxy {
111    type Protocol = DnsServerWatcherMarker;
112
113    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
114        Self::new(inner)
115    }
116
117    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
118        self.client.into_channel().map_err(|client| Self { client })
119    }
120
121    fn as_channel(&self) -> &::fidl::AsyncChannel {
122        self.client.as_channel()
123    }
124}
125
126impl DnsServerWatcherProxy {
127    /// Create a new Proxy for fuchsia.net.name/DnsServerWatcher.
128    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
129        let protocol_name = <DnsServerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
130        Self { client: fidl::client::Client::new(channel, protocol_name) }
131    }
132
133    /// Get a Stream of events from the remote end of the protocol.
134    ///
135    /// # Panics
136    ///
137    /// Panics if the event stream was already taken.
138    pub fn take_event_stream(&self) -> DnsServerWatcherEventStream {
139        DnsServerWatcherEventStream { event_receiver: self.client.take_event_receiver() }
140    }
141
142    /// Returns a list of DNS servers.
143    ///
144    /// First call always returns a snapshot of the current list of servers or blocks if an empty
145    /// list would be returned. Subsequent calls will block until the list of servers changes.
146    ///
147    /// The list of servers changes over time by configuration or network topology changes,
148    /// expiration, etc. Callers must repeatedly call `WatchServers` and replace any previously
149    /// returned `servers` with new ones to avoid using stale or expired entries.
150    ///
151    /// It is invalid to call this method while a previous call is pending. Doing so will cause the
152    /// server end of the protocol to be closed.
153    ///
154    /// - response `servers` The list of servers to use for DNS resolution, in priority order.
155    pub fn r#watch_servers(
156        &self,
157    ) -> fidl::client::QueryResponseFut<
158        Vec<DnsServer_>,
159        fidl::encoding::DefaultFuchsiaResourceDialect,
160    > {
161        DnsServerWatcherProxyInterface::r#watch_servers(self)
162    }
163}
164
165impl DnsServerWatcherProxyInterface for DnsServerWatcherProxy {
166    type WatchServersResponseFut = fidl::client::QueryResponseFut<
167        Vec<DnsServer_>,
168        fidl::encoding::DefaultFuchsiaResourceDialect,
169    >;
170    fn r#watch_servers(&self) -> Self::WatchServersResponseFut {
171        fn _decode(
172            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
173        ) -> Result<Vec<DnsServer_>, fidl::Error> {
174            let _response = fidl::client::decode_transaction_body::<
175                DnsServerWatcherWatchServersResponse,
176                fidl::encoding::DefaultFuchsiaResourceDialect,
177                0x5748907e7f11b632,
178            >(_buf?)?;
179            Ok(_response.servers)
180        }
181        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<DnsServer_>>(
182            (),
183            0x5748907e7f11b632,
184            fidl::encoding::DynamicFlags::empty(),
185            _decode,
186        )
187    }
188}
189
190pub struct DnsServerWatcherEventStream {
191    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
192}
193
194impl std::marker::Unpin for DnsServerWatcherEventStream {}
195
196impl futures::stream::FusedStream for DnsServerWatcherEventStream {
197    fn is_terminated(&self) -> bool {
198        self.event_receiver.is_terminated()
199    }
200}
201
202impl futures::Stream for DnsServerWatcherEventStream {
203    type Item = Result<DnsServerWatcherEvent, fidl::Error>;
204
205    fn poll_next(
206        mut self: std::pin::Pin<&mut Self>,
207        cx: &mut std::task::Context<'_>,
208    ) -> std::task::Poll<Option<Self::Item>> {
209        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
210            &mut self.event_receiver,
211            cx
212        )?) {
213            Some(buf) => std::task::Poll::Ready(Some(DnsServerWatcherEvent::decode(buf))),
214            None => std::task::Poll::Ready(None),
215        }
216    }
217}
218
219#[derive(Debug)]
220pub enum DnsServerWatcherEvent {}
221
222impl DnsServerWatcherEvent {
223    /// Decodes a message buffer as a [`DnsServerWatcherEvent`].
224    fn decode(
225        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
226    ) -> Result<DnsServerWatcherEvent, fidl::Error> {
227        let (bytes, _handles) = buf.split_mut();
228        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
229        debug_assert_eq!(tx_header.tx_id, 0);
230        match tx_header.ordinal {
231            _ => Err(fidl::Error::UnknownOrdinal {
232                ordinal: tx_header.ordinal,
233                protocol_name:
234                    <DnsServerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
235            }),
236        }
237    }
238}
239
240/// A Stream of incoming requests for fuchsia.net.name/DnsServerWatcher.
241pub struct DnsServerWatcherRequestStream {
242    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
243    is_terminated: bool,
244}
245
246impl std::marker::Unpin for DnsServerWatcherRequestStream {}
247
248impl futures::stream::FusedStream for DnsServerWatcherRequestStream {
249    fn is_terminated(&self) -> bool {
250        self.is_terminated
251    }
252}
253
254impl fidl::endpoints::RequestStream for DnsServerWatcherRequestStream {
255    type Protocol = DnsServerWatcherMarker;
256    type ControlHandle = DnsServerWatcherControlHandle;
257
258    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
259        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
260    }
261
262    fn control_handle(&self) -> Self::ControlHandle {
263        DnsServerWatcherControlHandle { inner: self.inner.clone() }
264    }
265
266    fn into_inner(
267        self,
268    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
269    {
270        (self.inner, self.is_terminated)
271    }
272
273    fn from_inner(
274        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
275        is_terminated: bool,
276    ) -> Self {
277        Self { inner, is_terminated }
278    }
279}
280
281impl futures::Stream for DnsServerWatcherRequestStream {
282    type Item = Result<DnsServerWatcherRequest, fidl::Error>;
283
284    fn poll_next(
285        mut self: std::pin::Pin<&mut Self>,
286        cx: &mut std::task::Context<'_>,
287    ) -> std::task::Poll<Option<Self::Item>> {
288        let this = &mut *self;
289        if this.inner.check_shutdown(cx) {
290            this.is_terminated = true;
291            return std::task::Poll::Ready(None);
292        }
293        if this.is_terminated {
294            panic!("polled DnsServerWatcherRequestStream after completion");
295        }
296        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
297            |bytes, handles| {
298                match this.inner.channel().read_etc(cx, bytes, handles) {
299                    std::task::Poll::Ready(Ok(())) => {}
300                    std::task::Poll::Pending => return std::task::Poll::Pending,
301                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
302                        this.is_terminated = true;
303                        return std::task::Poll::Ready(None);
304                    }
305                    std::task::Poll::Ready(Err(e)) => {
306                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
307                            e.into(),
308                        ))))
309                    }
310                }
311
312                // A message has been received from the channel
313                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
314
315                std::task::Poll::Ready(Some(match header.ordinal {
316                    0x5748907e7f11b632 => {
317                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
318                        let mut req = fidl::new_empty!(
319                            fidl::encoding::EmptyPayload,
320                            fidl::encoding::DefaultFuchsiaResourceDialect
321                        );
322                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
323                        let control_handle =
324                            DnsServerWatcherControlHandle { inner: this.inner.clone() };
325                        Ok(DnsServerWatcherRequest::WatchServers {
326                            responder: DnsServerWatcherWatchServersResponder {
327                                control_handle: std::mem::ManuallyDrop::new(control_handle),
328                                tx_id: header.tx_id,
329                            },
330                        })
331                    }
332                    _ => Err(fidl::Error::UnknownOrdinal {
333                        ordinal: header.ordinal,
334                        protocol_name:
335                            <DnsServerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
336                    }),
337                }))
338            },
339        )
340    }
341}
342
343/// Provides a hanging get interface to watch for DNS servers configuration.
344#[derive(Debug)]
345pub enum DnsServerWatcherRequest {
346    /// Returns a list of DNS servers.
347    ///
348    /// First call always returns a snapshot of the current list of servers or blocks if an empty
349    /// list would be returned. Subsequent calls will block until the list of servers changes.
350    ///
351    /// The list of servers changes over time by configuration or network topology changes,
352    /// expiration, etc. Callers must repeatedly call `WatchServers` and replace any previously
353    /// returned `servers` with new ones to avoid using stale or expired entries.
354    ///
355    /// It is invalid to call this method while a previous call is pending. Doing so will cause the
356    /// server end of the protocol to be closed.
357    ///
358    /// - response `servers` The list of servers to use for DNS resolution, in priority order.
359    WatchServers { responder: DnsServerWatcherWatchServersResponder },
360}
361
362impl DnsServerWatcherRequest {
363    #[allow(irrefutable_let_patterns)]
364    pub fn into_watch_servers(self) -> Option<(DnsServerWatcherWatchServersResponder)> {
365        if let DnsServerWatcherRequest::WatchServers { responder } = self {
366            Some((responder))
367        } else {
368            None
369        }
370    }
371
372    /// Name of the method defined in FIDL
373    pub fn method_name(&self) -> &'static str {
374        match *self {
375            DnsServerWatcherRequest::WatchServers { .. } => "watch_servers",
376        }
377    }
378}
379
380#[derive(Debug, Clone)]
381pub struct DnsServerWatcherControlHandle {
382    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
383}
384
385impl fidl::endpoints::ControlHandle for DnsServerWatcherControlHandle {
386    fn shutdown(&self) {
387        self.inner.shutdown()
388    }
389    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
390        self.inner.shutdown_with_epitaph(status)
391    }
392
393    fn is_closed(&self) -> bool {
394        self.inner.channel().is_closed()
395    }
396    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
397        self.inner.channel().on_closed()
398    }
399
400    #[cfg(target_os = "fuchsia")]
401    fn signal_peer(
402        &self,
403        clear_mask: zx::Signals,
404        set_mask: zx::Signals,
405    ) -> Result<(), zx_status::Status> {
406        use fidl::Peered;
407        self.inner.channel().signal_peer(clear_mask, set_mask)
408    }
409}
410
411impl DnsServerWatcherControlHandle {}
412
413#[must_use = "FIDL methods require a response to be sent"]
414#[derive(Debug)]
415pub struct DnsServerWatcherWatchServersResponder {
416    control_handle: std::mem::ManuallyDrop<DnsServerWatcherControlHandle>,
417    tx_id: u32,
418}
419
420/// Set the the channel to be shutdown (see [`DnsServerWatcherControlHandle::shutdown`])
421/// if the responder is dropped without sending a response, so that the client
422/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
423impl std::ops::Drop for DnsServerWatcherWatchServersResponder {
424    fn drop(&mut self) {
425        self.control_handle.shutdown();
426        // Safety: drops once, never accessed again
427        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
428    }
429}
430
431impl fidl::endpoints::Responder for DnsServerWatcherWatchServersResponder {
432    type ControlHandle = DnsServerWatcherControlHandle;
433
434    fn control_handle(&self) -> &DnsServerWatcherControlHandle {
435        &self.control_handle
436    }
437
438    fn drop_without_shutdown(mut self) {
439        // Safety: drops once, never accessed again due to mem::forget
440        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
441        // Prevent Drop from running (which would shut down the channel)
442        std::mem::forget(self);
443    }
444}
445
446impl DnsServerWatcherWatchServersResponder {
447    /// Sends a response to the FIDL transaction.
448    ///
449    /// Sets the channel to shutdown if an error occurs.
450    pub fn send(self, mut servers: &[DnsServer_]) -> Result<(), fidl::Error> {
451        let _result = self.send_raw(servers);
452        if _result.is_err() {
453            self.control_handle.shutdown();
454        }
455        self.drop_without_shutdown();
456        _result
457    }
458
459    /// Similar to "send" but does not shutdown the channel if an error occurs.
460    pub fn send_no_shutdown_on_err(self, mut servers: &[DnsServer_]) -> Result<(), fidl::Error> {
461        let _result = self.send_raw(servers);
462        self.drop_without_shutdown();
463        _result
464    }
465
466    fn send_raw(&self, mut servers: &[DnsServer_]) -> Result<(), fidl::Error> {
467        self.control_handle.inner.send::<DnsServerWatcherWatchServersResponse>(
468            (servers,),
469            self.tx_id,
470            0x5748907e7f11b632,
471            fidl::encoding::DynamicFlags::empty(),
472        )
473    }
474}
475
476#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
477pub struct LookupMarker;
478
479impl fidl::endpoints::ProtocolMarker for LookupMarker {
480    type Proxy = LookupProxy;
481    type RequestStream = LookupRequestStream;
482    #[cfg(target_os = "fuchsia")]
483    type SynchronousProxy = LookupSynchronousProxy;
484
485    const DEBUG_NAME: &'static str = "fuchsia.net.name.Lookup";
486}
487impl fidl::endpoints::DiscoverableProtocolMarker for LookupMarker {}
488pub type LookupLookupIpResult = Result<LookupResult, LookupError>;
489pub type LookupLookupHostnameResult = Result<String, LookupError>;
490
491pub trait LookupProxyInterface: Send + Sync {
492    type LookupIpResponseFut: std::future::Future<Output = Result<LookupLookupIpResult, fidl::Error>>
493        + Send;
494    fn r#lookup_ip(&self, hostname: &str, options: &LookupIpOptions) -> Self::LookupIpResponseFut;
495    type LookupHostnameResponseFut: std::future::Future<Output = Result<LookupLookupHostnameResult, fidl::Error>>
496        + Send;
497    fn r#lookup_hostname(
498        &self,
499        addr: &fidl_fuchsia_net::IpAddress,
500    ) -> Self::LookupHostnameResponseFut;
501}
502#[derive(Debug)]
503#[cfg(target_os = "fuchsia")]
504pub struct LookupSynchronousProxy {
505    client: fidl::client::sync::Client,
506}
507
508#[cfg(target_os = "fuchsia")]
509impl fidl::endpoints::SynchronousProxy for LookupSynchronousProxy {
510    type Proxy = LookupProxy;
511    type Protocol = LookupMarker;
512
513    fn from_channel(inner: fidl::Channel) -> Self {
514        Self::new(inner)
515    }
516
517    fn into_channel(self) -> fidl::Channel {
518        self.client.into_channel()
519    }
520
521    fn as_channel(&self) -> &fidl::Channel {
522        self.client.as_channel()
523    }
524}
525
526#[cfg(target_os = "fuchsia")]
527impl LookupSynchronousProxy {
528    pub fn new(channel: fidl::Channel) -> Self {
529        let protocol_name = <LookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
530        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
531    }
532
533    pub fn into_channel(self) -> fidl::Channel {
534        self.client.into_channel()
535    }
536
537    /// Waits until an event arrives and returns it. It is safe for other
538    /// threads to make concurrent requests while waiting for an event.
539    pub fn wait_for_event(
540        &self,
541        deadline: zx::MonotonicInstant,
542    ) -> Result<LookupEvent, fidl::Error> {
543        LookupEvent::decode(self.client.wait_for_event(deadline)?)
544    }
545
546    /// Lookup a list of IP addresses by hostname.
547    pub fn r#lookup_ip(
548        &self,
549        mut hostname: &str,
550        mut options: &LookupIpOptions,
551        ___deadline: zx::MonotonicInstant,
552    ) -> Result<LookupLookupIpResult, fidl::Error> {
553        let _response = self.client.send_query::<
554            LookupLookupIpRequest,
555            fidl::encoding::ResultType<LookupLookupIpResponse, LookupError>,
556        >(
557            (hostname, options,),
558            0x59247caf7560c1d0,
559            fidl::encoding::DynamicFlags::empty(),
560            ___deadline,
561        )?;
562        Ok(_response.map(|x| x.result))
563    }
564
565    /// Look up a hostname by IP address.
566    pub fn r#lookup_hostname(
567        &self,
568        mut addr: &fidl_fuchsia_net::IpAddress,
569        ___deadline: zx::MonotonicInstant,
570    ) -> Result<LookupLookupHostnameResult, fidl::Error> {
571        let _response = self.client.send_query::<
572            LookupLookupHostnameRequest,
573            fidl::encoding::ResultType<LookupLookupHostnameResponse, LookupError>,
574        >(
575            (addr,),
576            0x1b456b0e84888324,
577            fidl::encoding::DynamicFlags::empty(),
578            ___deadline,
579        )?;
580        Ok(_response.map(|x| x.hostname))
581    }
582}
583
584#[derive(Debug, Clone)]
585pub struct LookupProxy {
586    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
587}
588
589impl fidl::endpoints::Proxy for LookupProxy {
590    type Protocol = LookupMarker;
591
592    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
593        Self::new(inner)
594    }
595
596    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
597        self.client.into_channel().map_err(|client| Self { client })
598    }
599
600    fn as_channel(&self) -> &::fidl::AsyncChannel {
601        self.client.as_channel()
602    }
603}
604
605impl LookupProxy {
606    /// Create a new Proxy for fuchsia.net.name/Lookup.
607    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
608        let protocol_name = <LookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
609        Self { client: fidl::client::Client::new(channel, protocol_name) }
610    }
611
612    /// Get a Stream of events from the remote end of the protocol.
613    ///
614    /// # Panics
615    ///
616    /// Panics if the event stream was already taken.
617    pub fn take_event_stream(&self) -> LookupEventStream {
618        LookupEventStream { event_receiver: self.client.take_event_receiver() }
619    }
620
621    /// Lookup a list of IP addresses by hostname.
622    pub fn r#lookup_ip(
623        &self,
624        mut hostname: &str,
625        mut options: &LookupIpOptions,
626    ) -> fidl::client::QueryResponseFut<
627        LookupLookupIpResult,
628        fidl::encoding::DefaultFuchsiaResourceDialect,
629    > {
630        LookupProxyInterface::r#lookup_ip(self, hostname, options)
631    }
632
633    /// Look up a hostname by IP address.
634    pub fn r#lookup_hostname(
635        &self,
636        mut addr: &fidl_fuchsia_net::IpAddress,
637    ) -> fidl::client::QueryResponseFut<
638        LookupLookupHostnameResult,
639        fidl::encoding::DefaultFuchsiaResourceDialect,
640    > {
641        LookupProxyInterface::r#lookup_hostname(self, addr)
642    }
643}
644
645impl LookupProxyInterface for LookupProxy {
646    type LookupIpResponseFut = fidl::client::QueryResponseFut<
647        LookupLookupIpResult,
648        fidl::encoding::DefaultFuchsiaResourceDialect,
649    >;
650    fn r#lookup_ip(
651        &self,
652        mut hostname: &str,
653        mut options: &LookupIpOptions,
654    ) -> Self::LookupIpResponseFut {
655        fn _decode(
656            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
657        ) -> Result<LookupLookupIpResult, fidl::Error> {
658            let _response = fidl::client::decode_transaction_body::<
659                fidl::encoding::ResultType<LookupLookupIpResponse, LookupError>,
660                fidl::encoding::DefaultFuchsiaResourceDialect,
661                0x59247caf7560c1d0,
662            >(_buf?)?;
663            Ok(_response.map(|x| x.result))
664        }
665        self.client.send_query_and_decode::<LookupLookupIpRequest, LookupLookupIpResult>(
666            (hostname, options),
667            0x59247caf7560c1d0,
668            fidl::encoding::DynamicFlags::empty(),
669            _decode,
670        )
671    }
672
673    type LookupHostnameResponseFut = fidl::client::QueryResponseFut<
674        LookupLookupHostnameResult,
675        fidl::encoding::DefaultFuchsiaResourceDialect,
676    >;
677    fn r#lookup_hostname(
678        &self,
679        mut addr: &fidl_fuchsia_net::IpAddress,
680    ) -> Self::LookupHostnameResponseFut {
681        fn _decode(
682            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
683        ) -> Result<LookupLookupHostnameResult, fidl::Error> {
684            let _response = fidl::client::decode_transaction_body::<
685                fidl::encoding::ResultType<LookupLookupHostnameResponse, LookupError>,
686                fidl::encoding::DefaultFuchsiaResourceDialect,
687                0x1b456b0e84888324,
688            >(_buf?)?;
689            Ok(_response.map(|x| x.hostname))
690        }
691        self.client
692            .send_query_and_decode::<LookupLookupHostnameRequest, LookupLookupHostnameResult>(
693                (addr,),
694                0x1b456b0e84888324,
695                fidl::encoding::DynamicFlags::empty(),
696                _decode,
697            )
698    }
699}
700
701pub struct LookupEventStream {
702    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
703}
704
705impl std::marker::Unpin for LookupEventStream {}
706
707impl futures::stream::FusedStream for LookupEventStream {
708    fn is_terminated(&self) -> bool {
709        self.event_receiver.is_terminated()
710    }
711}
712
713impl futures::Stream for LookupEventStream {
714    type Item = Result<LookupEvent, fidl::Error>;
715
716    fn poll_next(
717        mut self: std::pin::Pin<&mut Self>,
718        cx: &mut std::task::Context<'_>,
719    ) -> std::task::Poll<Option<Self::Item>> {
720        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
721            &mut self.event_receiver,
722            cx
723        )?) {
724            Some(buf) => std::task::Poll::Ready(Some(LookupEvent::decode(buf))),
725            None => std::task::Poll::Ready(None),
726        }
727    }
728}
729
730#[derive(Debug)]
731pub enum LookupEvent {}
732
733impl LookupEvent {
734    /// Decodes a message buffer as a [`LookupEvent`].
735    fn decode(
736        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
737    ) -> Result<LookupEvent, fidl::Error> {
738        let (bytes, _handles) = buf.split_mut();
739        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
740        debug_assert_eq!(tx_header.tx_id, 0);
741        match tx_header.ordinal {
742            _ => Err(fidl::Error::UnknownOrdinal {
743                ordinal: tx_header.ordinal,
744                protocol_name: <LookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
745            }),
746        }
747    }
748}
749
750/// A Stream of incoming requests for fuchsia.net.name/Lookup.
751pub struct LookupRequestStream {
752    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
753    is_terminated: bool,
754}
755
756impl std::marker::Unpin for LookupRequestStream {}
757
758impl futures::stream::FusedStream for LookupRequestStream {
759    fn is_terminated(&self) -> bool {
760        self.is_terminated
761    }
762}
763
764impl fidl::endpoints::RequestStream for LookupRequestStream {
765    type Protocol = LookupMarker;
766    type ControlHandle = LookupControlHandle;
767
768    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
769        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
770    }
771
772    fn control_handle(&self) -> Self::ControlHandle {
773        LookupControlHandle { inner: self.inner.clone() }
774    }
775
776    fn into_inner(
777        self,
778    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
779    {
780        (self.inner, self.is_terminated)
781    }
782
783    fn from_inner(
784        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
785        is_terminated: bool,
786    ) -> Self {
787        Self { inner, is_terminated }
788    }
789}
790
791impl futures::Stream for LookupRequestStream {
792    type Item = Result<LookupRequest, fidl::Error>;
793
794    fn poll_next(
795        mut self: std::pin::Pin<&mut Self>,
796        cx: &mut std::task::Context<'_>,
797    ) -> std::task::Poll<Option<Self::Item>> {
798        let this = &mut *self;
799        if this.inner.check_shutdown(cx) {
800            this.is_terminated = true;
801            return std::task::Poll::Ready(None);
802        }
803        if this.is_terminated {
804            panic!("polled LookupRequestStream after completion");
805        }
806        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
807            |bytes, handles| {
808                match this.inner.channel().read_etc(cx, bytes, handles) {
809                    std::task::Poll::Ready(Ok(())) => {}
810                    std::task::Poll::Pending => return std::task::Poll::Pending,
811                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
812                        this.is_terminated = true;
813                        return std::task::Poll::Ready(None);
814                    }
815                    std::task::Poll::Ready(Err(e)) => {
816                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
817                            e.into(),
818                        ))))
819                    }
820                }
821
822                // A message has been received from the channel
823                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
824
825                std::task::Poll::Ready(Some(match header.ordinal {
826                    0x59247caf7560c1d0 => {
827                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
828                        let mut req = fidl::new_empty!(
829                            LookupLookupIpRequest,
830                            fidl::encoding::DefaultFuchsiaResourceDialect
831                        );
832                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LookupLookupIpRequest>(&header, _body_bytes, handles, &mut req)?;
833                        let control_handle = LookupControlHandle { inner: this.inner.clone() };
834                        Ok(LookupRequest::LookupIp {
835                            hostname: req.hostname,
836                            options: req.options,
837
838                            responder: LookupLookupIpResponder {
839                                control_handle: std::mem::ManuallyDrop::new(control_handle),
840                                tx_id: header.tx_id,
841                            },
842                        })
843                    }
844                    0x1b456b0e84888324 => {
845                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
846                        let mut req = fidl::new_empty!(
847                            LookupLookupHostnameRequest,
848                            fidl::encoding::DefaultFuchsiaResourceDialect
849                        );
850                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LookupLookupHostnameRequest>(&header, _body_bytes, handles, &mut req)?;
851                        let control_handle = LookupControlHandle { inner: this.inner.clone() };
852                        Ok(LookupRequest::LookupHostname {
853                            addr: req.addr,
854
855                            responder: LookupLookupHostnameResponder {
856                                control_handle: std::mem::ManuallyDrop::new(control_handle),
857                                tx_id: header.tx_id,
858                            },
859                        })
860                    }
861                    _ => Err(fidl::Error::UnknownOrdinal {
862                        ordinal: header.ordinal,
863                        protocol_name:
864                            <LookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
865                    }),
866                }))
867            },
868        )
869    }
870}
871
872/// Provides name and address resolution.
873#[derive(Debug)]
874pub enum LookupRequest {
875    /// Lookup a list of IP addresses by hostname.
876    LookupIp { hostname: String, options: LookupIpOptions, responder: LookupLookupIpResponder },
877    /// Look up a hostname by IP address.
878    LookupHostname { addr: fidl_fuchsia_net::IpAddress, responder: LookupLookupHostnameResponder },
879}
880
881impl LookupRequest {
882    #[allow(irrefutable_let_patterns)]
883    pub fn into_lookup_ip(self) -> Option<(String, LookupIpOptions, LookupLookupIpResponder)> {
884        if let LookupRequest::LookupIp { hostname, options, responder } = self {
885            Some((hostname, options, responder))
886        } else {
887            None
888        }
889    }
890
891    #[allow(irrefutable_let_patterns)]
892    pub fn into_lookup_hostname(
893        self,
894    ) -> Option<(fidl_fuchsia_net::IpAddress, LookupLookupHostnameResponder)> {
895        if let LookupRequest::LookupHostname { addr, responder } = self {
896            Some((addr, responder))
897        } else {
898            None
899        }
900    }
901
902    /// Name of the method defined in FIDL
903    pub fn method_name(&self) -> &'static str {
904        match *self {
905            LookupRequest::LookupIp { .. } => "lookup_ip",
906            LookupRequest::LookupHostname { .. } => "lookup_hostname",
907        }
908    }
909}
910
911#[derive(Debug, Clone)]
912pub struct LookupControlHandle {
913    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
914}
915
916impl fidl::endpoints::ControlHandle for LookupControlHandle {
917    fn shutdown(&self) {
918        self.inner.shutdown()
919    }
920    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
921        self.inner.shutdown_with_epitaph(status)
922    }
923
924    fn is_closed(&self) -> bool {
925        self.inner.channel().is_closed()
926    }
927    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
928        self.inner.channel().on_closed()
929    }
930
931    #[cfg(target_os = "fuchsia")]
932    fn signal_peer(
933        &self,
934        clear_mask: zx::Signals,
935        set_mask: zx::Signals,
936    ) -> Result<(), zx_status::Status> {
937        use fidl::Peered;
938        self.inner.channel().signal_peer(clear_mask, set_mask)
939    }
940}
941
942impl LookupControlHandle {}
943
944#[must_use = "FIDL methods require a response to be sent"]
945#[derive(Debug)]
946pub struct LookupLookupIpResponder {
947    control_handle: std::mem::ManuallyDrop<LookupControlHandle>,
948    tx_id: u32,
949}
950
951/// Set the the channel to be shutdown (see [`LookupControlHandle::shutdown`])
952/// if the responder is dropped without sending a response, so that the client
953/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
954impl std::ops::Drop for LookupLookupIpResponder {
955    fn drop(&mut self) {
956        self.control_handle.shutdown();
957        // Safety: drops once, never accessed again
958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
959    }
960}
961
962impl fidl::endpoints::Responder for LookupLookupIpResponder {
963    type ControlHandle = LookupControlHandle;
964
965    fn control_handle(&self) -> &LookupControlHandle {
966        &self.control_handle
967    }
968
969    fn drop_without_shutdown(mut self) {
970        // Safety: drops once, never accessed again due to mem::forget
971        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
972        // Prevent Drop from running (which would shut down the channel)
973        std::mem::forget(self);
974    }
975}
976
977impl LookupLookupIpResponder {
978    /// Sends a response to the FIDL transaction.
979    ///
980    /// Sets the channel to shutdown if an error occurs.
981    pub fn send(self, mut result: Result<&LookupResult, LookupError>) -> Result<(), fidl::Error> {
982        let _result = self.send_raw(result);
983        if _result.is_err() {
984            self.control_handle.shutdown();
985        }
986        self.drop_without_shutdown();
987        _result
988    }
989
990    /// Similar to "send" but does not shutdown the channel if an error occurs.
991    pub fn send_no_shutdown_on_err(
992        self,
993        mut result: Result<&LookupResult, LookupError>,
994    ) -> Result<(), fidl::Error> {
995        let _result = self.send_raw(result);
996        self.drop_without_shutdown();
997        _result
998    }
999
1000    fn send_raw(&self, mut result: Result<&LookupResult, LookupError>) -> Result<(), fidl::Error> {
1001        self.control_handle
1002            .inner
1003            .send::<fidl::encoding::ResultType<LookupLookupIpResponse, LookupError>>(
1004                result.map(|result| (result,)),
1005                self.tx_id,
1006                0x59247caf7560c1d0,
1007                fidl::encoding::DynamicFlags::empty(),
1008            )
1009    }
1010}
1011
1012#[must_use = "FIDL methods require a response to be sent"]
1013#[derive(Debug)]
1014pub struct LookupLookupHostnameResponder {
1015    control_handle: std::mem::ManuallyDrop<LookupControlHandle>,
1016    tx_id: u32,
1017}
1018
1019/// Set the the channel to be shutdown (see [`LookupControlHandle::shutdown`])
1020/// if the responder is dropped without sending a response, so that the client
1021/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1022impl std::ops::Drop for LookupLookupHostnameResponder {
1023    fn drop(&mut self) {
1024        self.control_handle.shutdown();
1025        // Safety: drops once, never accessed again
1026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1027    }
1028}
1029
1030impl fidl::endpoints::Responder for LookupLookupHostnameResponder {
1031    type ControlHandle = LookupControlHandle;
1032
1033    fn control_handle(&self) -> &LookupControlHandle {
1034        &self.control_handle
1035    }
1036
1037    fn drop_without_shutdown(mut self) {
1038        // Safety: drops once, never accessed again due to mem::forget
1039        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1040        // Prevent Drop from running (which would shut down the channel)
1041        std::mem::forget(self);
1042    }
1043}
1044
1045impl LookupLookupHostnameResponder {
1046    /// Sends a response to the FIDL transaction.
1047    ///
1048    /// Sets the channel to shutdown if an error occurs.
1049    pub fn send(self, mut result: Result<&str, LookupError>) -> Result<(), fidl::Error> {
1050        let _result = self.send_raw(result);
1051        if _result.is_err() {
1052            self.control_handle.shutdown();
1053        }
1054        self.drop_without_shutdown();
1055        _result
1056    }
1057
1058    /// Similar to "send" but does not shutdown the channel if an error occurs.
1059    pub fn send_no_shutdown_on_err(
1060        self,
1061        mut result: Result<&str, LookupError>,
1062    ) -> Result<(), fidl::Error> {
1063        let _result = self.send_raw(result);
1064        self.drop_without_shutdown();
1065        _result
1066    }
1067
1068    fn send_raw(&self, mut result: Result<&str, LookupError>) -> Result<(), fidl::Error> {
1069        self.control_handle.inner.send::<fidl::encoding::ResultType<
1070            LookupLookupHostnameResponse,
1071            LookupError,
1072        >>(
1073            result.map(|hostname| (hostname,)),
1074            self.tx_id,
1075            0x1b456b0e84888324,
1076            fidl::encoding::DynamicFlags::empty(),
1077        )
1078    }
1079}
1080
1081#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1082pub struct LookupAdminMarker;
1083
1084impl fidl::endpoints::ProtocolMarker for LookupAdminMarker {
1085    type Proxy = LookupAdminProxy;
1086    type RequestStream = LookupAdminRequestStream;
1087    #[cfg(target_os = "fuchsia")]
1088    type SynchronousProxy = LookupAdminSynchronousProxy;
1089
1090    const DEBUG_NAME: &'static str = "fuchsia.net.name.LookupAdmin";
1091}
1092impl fidl::endpoints::DiscoverableProtocolMarker for LookupAdminMarker {}
1093pub type LookupAdminSetDnsServersResult = Result<(), i32>;
1094
1095pub trait LookupAdminProxyInterface: Send + Sync {
1096    type SetDnsServersResponseFut: std::future::Future<Output = Result<LookupAdminSetDnsServersResult, fidl::Error>>
1097        + Send;
1098    fn r#set_dns_servers(
1099        &self,
1100        servers: &[fidl_fuchsia_net::SocketAddress],
1101    ) -> Self::SetDnsServersResponseFut;
1102    type GetDnsServersResponseFut: std::future::Future<Output = Result<Vec<fidl_fuchsia_net::SocketAddress>, fidl::Error>>
1103        + Send;
1104    fn r#get_dns_servers(&self) -> Self::GetDnsServersResponseFut;
1105}
1106#[derive(Debug)]
1107#[cfg(target_os = "fuchsia")]
1108pub struct LookupAdminSynchronousProxy {
1109    client: fidl::client::sync::Client,
1110}
1111
1112#[cfg(target_os = "fuchsia")]
1113impl fidl::endpoints::SynchronousProxy for LookupAdminSynchronousProxy {
1114    type Proxy = LookupAdminProxy;
1115    type Protocol = LookupAdminMarker;
1116
1117    fn from_channel(inner: fidl::Channel) -> Self {
1118        Self::new(inner)
1119    }
1120
1121    fn into_channel(self) -> fidl::Channel {
1122        self.client.into_channel()
1123    }
1124
1125    fn as_channel(&self) -> &fidl::Channel {
1126        self.client.as_channel()
1127    }
1128}
1129
1130#[cfg(target_os = "fuchsia")]
1131impl LookupAdminSynchronousProxy {
1132    pub fn new(channel: fidl::Channel) -> Self {
1133        let protocol_name = <LookupAdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1134        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1135    }
1136
1137    pub fn into_channel(self) -> fidl::Channel {
1138        self.client.into_channel()
1139    }
1140
1141    /// Waits until an event arrives and returns it. It is safe for other
1142    /// threads to make concurrent requests while waiting for an event.
1143    pub fn wait_for_event(
1144        &self,
1145        deadline: zx::MonotonicInstant,
1146    ) -> Result<LookupAdminEvent, fidl::Error> {
1147        LookupAdminEvent::decode(self.client.wait_for_event(deadline)?)
1148    }
1149
1150    /// Sets the DNS servers to `servers`
1151    ///
1152    /// + request `servers` The list of servers to use for domain name resolution, in priority
1153    /// order. An empty list means no servers will be used and name resolution may fail. Each
1154    /// `SocketAddress` in `servers` must be a valid unicast socket address. The list of servers
1155    /// will be deduplicated.
1156    /// * error Returns `ZX_ERR_INVALID_ARGS` if any of the provided addresses does not meet the
1157    /// conditions above.
1158    pub fn r#set_dns_servers(
1159        &self,
1160        mut servers: &[fidl_fuchsia_net::SocketAddress],
1161        ___deadline: zx::MonotonicInstant,
1162    ) -> Result<LookupAdminSetDnsServersResult, fidl::Error> {
1163        let _response = self.client.send_query::<
1164            LookupAdminSetDnsServersRequest,
1165            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1166        >(
1167            (servers,),
1168            0x55e2b9fcc777be96,
1169            fidl::encoding::DynamicFlags::empty(),
1170            ___deadline,
1171        )?;
1172        Ok(_response.map(|x| x))
1173    }
1174
1175    /// Gets the DNS servers currently in use to resolve name lookups.
1176    /// - response `servers` The list of servers in use by `LookupAdmin`, in priority order.
1177    pub fn r#get_dns_servers(
1178        &self,
1179        ___deadline: zx::MonotonicInstant,
1180    ) -> Result<Vec<fidl_fuchsia_net::SocketAddress>, fidl::Error> {
1181        let _response = self
1182            .client
1183            .send_query::<fidl::encoding::EmptyPayload, LookupAdminGetDnsServersResponse>(
1184                (),
1185                0x614303bf6e72f80f,
1186                fidl::encoding::DynamicFlags::empty(),
1187                ___deadline,
1188            )?;
1189        Ok(_response.servers)
1190    }
1191}
1192
1193#[derive(Debug, Clone)]
1194pub struct LookupAdminProxy {
1195    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1196}
1197
1198impl fidl::endpoints::Proxy for LookupAdminProxy {
1199    type Protocol = LookupAdminMarker;
1200
1201    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1202        Self::new(inner)
1203    }
1204
1205    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1206        self.client.into_channel().map_err(|client| Self { client })
1207    }
1208
1209    fn as_channel(&self) -> &::fidl::AsyncChannel {
1210        self.client.as_channel()
1211    }
1212}
1213
1214impl LookupAdminProxy {
1215    /// Create a new Proxy for fuchsia.net.name/LookupAdmin.
1216    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1217        let protocol_name = <LookupAdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1218        Self { client: fidl::client::Client::new(channel, protocol_name) }
1219    }
1220
1221    /// Get a Stream of events from the remote end of the protocol.
1222    ///
1223    /// # Panics
1224    ///
1225    /// Panics if the event stream was already taken.
1226    pub fn take_event_stream(&self) -> LookupAdminEventStream {
1227        LookupAdminEventStream { event_receiver: self.client.take_event_receiver() }
1228    }
1229
1230    /// Sets the DNS servers to `servers`
1231    ///
1232    /// + request `servers` The list of servers to use for domain name resolution, in priority
1233    /// order. An empty list means no servers will be used and name resolution may fail. Each
1234    /// `SocketAddress` in `servers` must be a valid unicast socket address. The list of servers
1235    /// will be deduplicated.
1236    /// * error Returns `ZX_ERR_INVALID_ARGS` if any of the provided addresses does not meet the
1237    /// conditions above.
1238    pub fn r#set_dns_servers(
1239        &self,
1240        mut servers: &[fidl_fuchsia_net::SocketAddress],
1241    ) -> fidl::client::QueryResponseFut<
1242        LookupAdminSetDnsServersResult,
1243        fidl::encoding::DefaultFuchsiaResourceDialect,
1244    > {
1245        LookupAdminProxyInterface::r#set_dns_servers(self, servers)
1246    }
1247
1248    /// Gets the DNS servers currently in use to resolve name lookups.
1249    /// - response `servers` The list of servers in use by `LookupAdmin`, in priority order.
1250    pub fn r#get_dns_servers(
1251        &self,
1252    ) -> fidl::client::QueryResponseFut<
1253        Vec<fidl_fuchsia_net::SocketAddress>,
1254        fidl::encoding::DefaultFuchsiaResourceDialect,
1255    > {
1256        LookupAdminProxyInterface::r#get_dns_servers(self)
1257    }
1258}
1259
1260impl LookupAdminProxyInterface for LookupAdminProxy {
1261    type SetDnsServersResponseFut = fidl::client::QueryResponseFut<
1262        LookupAdminSetDnsServersResult,
1263        fidl::encoding::DefaultFuchsiaResourceDialect,
1264    >;
1265    fn r#set_dns_servers(
1266        &self,
1267        mut servers: &[fidl_fuchsia_net::SocketAddress],
1268    ) -> Self::SetDnsServersResponseFut {
1269        fn _decode(
1270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1271        ) -> Result<LookupAdminSetDnsServersResult, fidl::Error> {
1272            let _response = fidl::client::decode_transaction_body::<
1273                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1274                fidl::encoding::DefaultFuchsiaResourceDialect,
1275                0x55e2b9fcc777be96,
1276            >(_buf?)?;
1277            Ok(_response.map(|x| x))
1278        }
1279        self.client.send_query_and_decode::<
1280            LookupAdminSetDnsServersRequest,
1281            LookupAdminSetDnsServersResult,
1282        >(
1283            (servers,),
1284            0x55e2b9fcc777be96,
1285            fidl::encoding::DynamicFlags::empty(),
1286            _decode,
1287        )
1288    }
1289
1290    type GetDnsServersResponseFut = fidl::client::QueryResponseFut<
1291        Vec<fidl_fuchsia_net::SocketAddress>,
1292        fidl::encoding::DefaultFuchsiaResourceDialect,
1293    >;
1294    fn r#get_dns_servers(&self) -> Self::GetDnsServersResponseFut {
1295        fn _decode(
1296            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1297        ) -> Result<Vec<fidl_fuchsia_net::SocketAddress>, fidl::Error> {
1298            let _response = fidl::client::decode_transaction_body::<
1299                LookupAdminGetDnsServersResponse,
1300                fidl::encoding::DefaultFuchsiaResourceDialect,
1301                0x614303bf6e72f80f,
1302            >(_buf?)?;
1303            Ok(_response.servers)
1304        }
1305        self.client.send_query_and_decode::<
1306            fidl::encoding::EmptyPayload,
1307            Vec<fidl_fuchsia_net::SocketAddress>,
1308        >(
1309            (),
1310            0x614303bf6e72f80f,
1311            fidl::encoding::DynamicFlags::empty(),
1312            _decode,
1313        )
1314    }
1315}
1316
1317pub struct LookupAdminEventStream {
1318    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1319}
1320
1321impl std::marker::Unpin for LookupAdminEventStream {}
1322
1323impl futures::stream::FusedStream for LookupAdminEventStream {
1324    fn is_terminated(&self) -> bool {
1325        self.event_receiver.is_terminated()
1326    }
1327}
1328
1329impl futures::Stream for LookupAdminEventStream {
1330    type Item = Result<LookupAdminEvent, fidl::Error>;
1331
1332    fn poll_next(
1333        mut self: std::pin::Pin<&mut Self>,
1334        cx: &mut std::task::Context<'_>,
1335    ) -> std::task::Poll<Option<Self::Item>> {
1336        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1337            &mut self.event_receiver,
1338            cx
1339        )?) {
1340            Some(buf) => std::task::Poll::Ready(Some(LookupAdminEvent::decode(buf))),
1341            None => std::task::Poll::Ready(None),
1342        }
1343    }
1344}
1345
1346#[derive(Debug)]
1347pub enum LookupAdminEvent {}
1348
1349impl LookupAdminEvent {
1350    /// Decodes a message buffer as a [`LookupAdminEvent`].
1351    fn decode(
1352        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1353    ) -> Result<LookupAdminEvent, fidl::Error> {
1354        let (bytes, _handles) = buf.split_mut();
1355        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1356        debug_assert_eq!(tx_header.tx_id, 0);
1357        match tx_header.ordinal {
1358            _ => Err(fidl::Error::UnknownOrdinal {
1359                ordinal: tx_header.ordinal,
1360                protocol_name: <LookupAdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1361            }),
1362        }
1363    }
1364}
1365
1366/// A Stream of incoming requests for fuchsia.net.name/LookupAdmin.
1367pub struct LookupAdminRequestStream {
1368    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1369    is_terminated: bool,
1370}
1371
1372impl std::marker::Unpin for LookupAdminRequestStream {}
1373
1374impl futures::stream::FusedStream for LookupAdminRequestStream {
1375    fn is_terminated(&self) -> bool {
1376        self.is_terminated
1377    }
1378}
1379
1380impl fidl::endpoints::RequestStream for LookupAdminRequestStream {
1381    type Protocol = LookupAdminMarker;
1382    type ControlHandle = LookupAdminControlHandle;
1383
1384    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1385        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1386    }
1387
1388    fn control_handle(&self) -> Self::ControlHandle {
1389        LookupAdminControlHandle { inner: self.inner.clone() }
1390    }
1391
1392    fn into_inner(
1393        self,
1394    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1395    {
1396        (self.inner, self.is_terminated)
1397    }
1398
1399    fn from_inner(
1400        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1401        is_terminated: bool,
1402    ) -> Self {
1403        Self { inner, is_terminated }
1404    }
1405}
1406
1407impl futures::Stream for LookupAdminRequestStream {
1408    type Item = Result<LookupAdminRequest, fidl::Error>;
1409
1410    fn poll_next(
1411        mut self: std::pin::Pin<&mut Self>,
1412        cx: &mut std::task::Context<'_>,
1413    ) -> std::task::Poll<Option<Self::Item>> {
1414        let this = &mut *self;
1415        if this.inner.check_shutdown(cx) {
1416            this.is_terminated = true;
1417            return std::task::Poll::Ready(None);
1418        }
1419        if this.is_terminated {
1420            panic!("polled LookupAdminRequestStream after completion");
1421        }
1422        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1423            |bytes, handles| {
1424                match this.inner.channel().read_etc(cx, bytes, handles) {
1425                    std::task::Poll::Ready(Ok(())) => {}
1426                    std::task::Poll::Pending => return std::task::Poll::Pending,
1427                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1428                        this.is_terminated = true;
1429                        return std::task::Poll::Ready(None);
1430                    }
1431                    std::task::Poll::Ready(Err(e)) => {
1432                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1433                            e.into(),
1434                        ))))
1435                    }
1436                }
1437
1438                // A message has been received from the channel
1439                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1440
1441                std::task::Poll::Ready(Some(match header.ordinal {
1442                    0x55e2b9fcc777be96 => {
1443                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1444                        let mut req = fidl::new_empty!(
1445                            LookupAdminSetDnsServersRequest,
1446                            fidl::encoding::DefaultFuchsiaResourceDialect
1447                        );
1448                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LookupAdminSetDnsServersRequest>(&header, _body_bytes, handles, &mut req)?;
1449                        let control_handle = LookupAdminControlHandle { inner: this.inner.clone() };
1450                        Ok(LookupAdminRequest::SetDnsServers {
1451                            servers: req.servers,
1452
1453                            responder: LookupAdminSetDnsServersResponder {
1454                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1455                                tx_id: header.tx_id,
1456                            },
1457                        })
1458                    }
1459                    0x614303bf6e72f80f => {
1460                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1461                        let mut req = fidl::new_empty!(
1462                            fidl::encoding::EmptyPayload,
1463                            fidl::encoding::DefaultFuchsiaResourceDialect
1464                        );
1465                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1466                        let control_handle = LookupAdminControlHandle { inner: this.inner.clone() };
1467                        Ok(LookupAdminRequest::GetDnsServers {
1468                            responder: LookupAdminGetDnsServersResponder {
1469                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1470                                tx_id: header.tx_id,
1471                            },
1472                        })
1473                    }
1474                    _ => Err(fidl::Error::UnknownOrdinal {
1475                        ordinal: header.ordinal,
1476                        protocol_name:
1477                            <LookupAdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1478                    }),
1479                }))
1480            },
1481        )
1482    }
1483}
1484
1485/// Provides administration controls over name resolution settings.
1486#[derive(Debug)]
1487pub enum LookupAdminRequest {
1488    /// Sets the DNS servers to `servers`
1489    ///
1490    /// + request `servers` The list of servers to use for domain name resolution, in priority
1491    /// order. An empty list means no servers will be used and name resolution may fail. Each
1492    /// `SocketAddress` in `servers` must be a valid unicast socket address. The list of servers
1493    /// will be deduplicated.
1494    /// * error Returns `ZX_ERR_INVALID_ARGS` if any of the provided addresses does not meet the
1495    /// conditions above.
1496    SetDnsServers {
1497        servers: Vec<fidl_fuchsia_net::SocketAddress>,
1498        responder: LookupAdminSetDnsServersResponder,
1499    },
1500    /// Gets the DNS servers currently in use to resolve name lookups.
1501    /// - response `servers` The list of servers in use by `LookupAdmin`, in priority order.
1502    GetDnsServers { responder: LookupAdminGetDnsServersResponder },
1503}
1504
1505impl LookupAdminRequest {
1506    #[allow(irrefutable_let_patterns)]
1507    pub fn into_set_dns_servers(
1508        self,
1509    ) -> Option<(Vec<fidl_fuchsia_net::SocketAddress>, LookupAdminSetDnsServersResponder)> {
1510        if let LookupAdminRequest::SetDnsServers { servers, responder } = self {
1511            Some((servers, responder))
1512        } else {
1513            None
1514        }
1515    }
1516
1517    #[allow(irrefutable_let_patterns)]
1518    pub fn into_get_dns_servers(self) -> Option<(LookupAdminGetDnsServersResponder)> {
1519        if let LookupAdminRequest::GetDnsServers { responder } = self {
1520            Some((responder))
1521        } else {
1522            None
1523        }
1524    }
1525
1526    /// Name of the method defined in FIDL
1527    pub fn method_name(&self) -> &'static str {
1528        match *self {
1529            LookupAdminRequest::SetDnsServers { .. } => "set_dns_servers",
1530            LookupAdminRequest::GetDnsServers { .. } => "get_dns_servers",
1531        }
1532    }
1533}
1534
1535#[derive(Debug, Clone)]
1536pub struct LookupAdminControlHandle {
1537    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1538}
1539
1540impl fidl::endpoints::ControlHandle for LookupAdminControlHandle {
1541    fn shutdown(&self) {
1542        self.inner.shutdown()
1543    }
1544    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1545        self.inner.shutdown_with_epitaph(status)
1546    }
1547
1548    fn is_closed(&self) -> bool {
1549        self.inner.channel().is_closed()
1550    }
1551    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1552        self.inner.channel().on_closed()
1553    }
1554
1555    #[cfg(target_os = "fuchsia")]
1556    fn signal_peer(
1557        &self,
1558        clear_mask: zx::Signals,
1559        set_mask: zx::Signals,
1560    ) -> Result<(), zx_status::Status> {
1561        use fidl::Peered;
1562        self.inner.channel().signal_peer(clear_mask, set_mask)
1563    }
1564}
1565
1566impl LookupAdminControlHandle {}
1567
1568#[must_use = "FIDL methods require a response to be sent"]
1569#[derive(Debug)]
1570pub struct LookupAdminSetDnsServersResponder {
1571    control_handle: std::mem::ManuallyDrop<LookupAdminControlHandle>,
1572    tx_id: u32,
1573}
1574
1575/// Set the the channel to be shutdown (see [`LookupAdminControlHandle::shutdown`])
1576/// if the responder is dropped without sending a response, so that the client
1577/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1578impl std::ops::Drop for LookupAdminSetDnsServersResponder {
1579    fn drop(&mut self) {
1580        self.control_handle.shutdown();
1581        // Safety: drops once, never accessed again
1582        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1583    }
1584}
1585
1586impl fidl::endpoints::Responder for LookupAdminSetDnsServersResponder {
1587    type ControlHandle = LookupAdminControlHandle;
1588
1589    fn control_handle(&self) -> &LookupAdminControlHandle {
1590        &self.control_handle
1591    }
1592
1593    fn drop_without_shutdown(mut self) {
1594        // Safety: drops once, never accessed again due to mem::forget
1595        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1596        // Prevent Drop from running (which would shut down the channel)
1597        std::mem::forget(self);
1598    }
1599}
1600
1601impl LookupAdminSetDnsServersResponder {
1602    /// Sends a response to the FIDL transaction.
1603    ///
1604    /// Sets the channel to shutdown if an error occurs.
1605    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1606        let _result = self.send_raw(result);
1607        if _result.is_err() {
1608            self.control_handle.shutdown();
1609        }
1610        self.drop_without_shutdown();
1611        _result
1612    }
1613
1614    /// Similar to "send" but does not shutdown the channel if an error occurs.
1615    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1616        let _result = self.send_raw(result);
1617        self.drop_without_shutdown();
1618        _result
1619    }
1620
1621    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1622        self.control_handle
1623            .inner
1624            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1625                result,
1626                self.tx_id,
1627                0x55e2b9fcc777be96,
1628                fidl::encoding::DynamicFlags::empty(),
1629            )
1630    }
1631}
1632
1633#[must_use = "FIDL methods require a response to be sent"]
1634#[derive(Debug)]
1635pub struct LookupAdminGetDnsServersResponder {
1636    control_handle: std::mem::ManuallyDrop<LookupAdminControlHandle>,
1637    tx_id: u32,
1638}
1639
1640/// Set the the channel to be shutdown (see [`LookupAdminControlHandle::shutdown`])
1641/// if the responder is dropped without sending a response, so that the client
1642/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1643impl std::ops::Drop for LookupAdminGetDnsServersResponder {
1644    fn drop(&mut self) {
1645        self.control_handle.shutdown();
1646        // Safety: drops once, never accessed again
1647        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1648    }
1649}
1650
1651impl fidl::endpoints::Responder for LookupAdminGetDnsServersResponder {
1652    type ControlHandle = LookupAdminControlHandle;
1653
1654    fn control_handle(&self) -> &LookupAdminControlHandle {
1655        &self.control_handle
1656    }
1657
1658    fn drop_without_shutdown(mut self) {
1659        // Safety: drops once, never accessed again due to mem::forget
1660        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1661        // Prevent Drop from running (which would shut down the channel)
1662        std::mem::forget(self);
1663    }
1664}
1665
1666impl LookupAdminGetDnsServersResponder {
1667    /// Sends a response to the FIDL transaction.
1668    ///
1669    /// Sets the channel to shutdown if an error occurs.
1670    pub fn send(self, mut servers: &[fidl_fuchsia_net::SocketAddress]) -> Result<(), fidl::Error> {
1671        let _result = self.send_raw(servers);
1672        if _result.is_err() {
1673            self.control_handle.shutdown();
1674        }
1675        self.drop_without_shutdown();
1676        _result
1677    }
1678
1679    /// Similar to "send" but does not shutdown the channel if an error occurs.
1680    pub fn send_no_shutdown_on_err(
1681        self,
1682        mut servers: &[fidl_fuchsia_net::SocketAddress],
1683    ) -> Result<(), fidl::Error> {
1684        let _result = self.send_raw(servers);
1685        self.drop_without_shutdown();
1686        _result
1687    }
1688
1689    fn send_raw(&self, mut servers: &[fidl_fuchsia_net::SocketAddress]) -> Result<(), fidl::Error> {
1690        self.control_handle.inner.send::<LookupAdminGetDnsServersResponse>(
1691            (servers,),
1692            self.tx_id,
1693            0x614303bf6e72f80f,
1694            fidl::encoding::DynamicFlags::empty(),
1695        )
1696    }
1697}
1698
1699mod internal {
1700    use super::*;
1701}