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