Skip to main content

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