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 DnsServerWatcherControlHandle {
307    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
308        self.inner.shutdown_with_epitaph(status.into())
309    }
310}
311
312impl fdomain_client::fidl::ControlHandle for DnsServerWatcherControlHandle {
313    fn shutdown(&self) {
314        self.inner.shutdown()
315    }
316
317    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
318        self.inner.shutdown_with_epitaph(status)
319    }
320
321    fn is_closed(&self) -> bool {
322        self.inner.channel().is_closed()
323    }
324    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
325        self.inner.channel().on_closed()
326    }
327}
328
329impl DnsServerWatcherControlHandle {}
330
331#[must_use = "FIDL methods require a response to be sent"]
332#[derive(Debug)]
333pub struct DnsServerWatcherWatchServersResponder {
334    control_handle: std::mem::ManuallyDrop<DnsServerWatcherControlHandle>,
335    tx_id: u32,
336}
337
338/// Set the the channel to be shutdown (see [`DnsServerWatcherControlHandle::shutdown`])
339/// if the responder is dropped without sending a response, so that the client
340/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
341impl std::ops::Drop for DnsServerWatcherWatchServersResponder {
342    fn drop(&mut self) {
343        self.control_handle.shutdown();
344        // Safety: drops once, never accessed again
345        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
346    }
347}
348
349impl fdomain_client::fidl::Responder for DnsServerWatcherWatchServersResponder {
350    type ControlHandle = DnsServerWatcherControlHandle;
351
352    fn control_handle(&self) -> &DnsServerWatcherControlHandle {
353        &self.control_handle
354    }
355
356    fn drop_without_shutdown(mut self) {
357        // Safety: drops once, never accessed again due to mem::forget
358        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
359        // Prevent Drop from running (which would shut down the channel)
360        std::mem::forget(self);
361    }
362}
363
364impl DnsServerWatcherWatchServersResponder {
365    /// Sends a response to the FIDL transaction.
366    ///
367    /// Sets the channel to shutdown if an error occurs.
368    pub fn send(self, mut servers: &[DnsServer_]) -> Result<(), fidl::Error> {
369        let _result = self.send_raw(servers);
370        if _result.is_err() {
371            self.control_handle.shutdown();
372        }
373        self.drop_without_shutdown();
374        _result
375    }
376
377    /// Similar to "send" but does not shutdown the channel if an error occurs.
378    pub fn send_no_shutdown_on_err(self, mut servers: &[DnsServer_]) -> Result<(), fidl::Error> {
379        let _result = self.send_raw(servers);
380        self.drop_without_shutdown();
381        _result
382    }
383
384    fn send_raw(&self, mut servers: &[DnsServer_]) -> Result<(), fidl::Error> {
385        self.control_handle.inner.send::<DnsServerWatcherWatchServersResponse>(
386            (servers,),
387            self.tx_id,
388            0x5748907e7f11b632,
389            fidl::encoding::DynamicFlags::empty(),
390        )
391    }
392}
393
394#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
395pub struct LookupMarker;
396
397impl fdomain_client::fidl::ProtocolMarker for LookupMarker {
398    type Proxy = LookupProxy;
399    type RequestStream = LookupRequestStream;
400
401    const DEBUG_NAME: &'static str = "fuchsia.net.name.Lookup";
402}
403impl fdomain_client::fidl::DiscoverableProtocolMarker for LookupMarker {}
404pub type LookupLookupIpResult = Result<LookupResult, LookupError>;
405pub type LookupLookupHostnameResult = Result<String, LookupError>;
406
407pub trait LookupProxyInterface: Send + Sync {
408    type LookupIpResponseFut: std::future::Future<Output = Result<LookupLookupIpResult, fidl::Error>>
409        + Send;
410    fn r#lookup_ip(&self, hostname: &str, options: &LookupIpOptions) -> Self::LookupIpResponseFut;
411    type LookupHostnameResponseFut: std::future::Future<Output = Result<LookupLookupHostnameResult, fidl::Error>>
412        + Send;
413    fn r#lookup_hostname(
414        &self,
415        addr: &fdomain_fuchsia_net::IpAddress,
416    ) -> Self::LookupHostnameResponseFut;
417}
418
419#[derive(Debug, Clone)]
420pub struct LookupProxy {
421    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
422}
423
424impl fdomain_client::fidl::Proxy for LookupProxy {
425    type Protocol = LookupMarker;
426
427    fn from_channel(inner: fdomain_client::Channel) -> Self {
428        Self::new(inner)
429    }
430
431    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
432        self.client.into_channel().map_err(|client| Self { client })
433    }
434
435    fn as_channel(&self) -> &fdomain_client::Channel {
436        self.client.as_channel()
437    }
438}
439
440impl LookupProxy {
441    /// Create a new Proxy for fuchsia.net.name/Lookup.
442    pub fn new(channel: fdomain_client::Channel) -> Self {
443        let protocol_name = <LookupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
444        Self { client: fidl::client::Client::new(channel, protocol_name) }
445    }
446
447    /// Get a Stream of events from the remote end of the protocol.
448    ///
449    /// # Panics
450    ///
451    /// Panics if the event stream was already taken.
452    pub fn take_event_stream(&self) -> LookupEventStream {
453        LookupEventStream { event_receiver: self.client.take_event_receiver() }
454    }
455
456    /// Lookup a list of IP addresses by hostname.
457    pub fn r#lookup_ip(
458        &self,
459        mut hostname: &str,
460        mut options: &LookupIpOptions,
461    ) -> fidl::client::QueryResponseFut<
462        LookupLookupIpResult,
463        fdomain_client::fidl::FDomainResourceDialect,
464    > {
465        LookupProxyInterface::r#lookup_ip(self, hostname, options)
466    }
467
468    /// Look up a hostname by IP address.
469    pub fn r#lookup_hostname(
470        &self,
471        mut addr: &fdomain_fuchsia_net::IpAddress,
472    ) -> fidl::client::QueryResponseFut<
473        LookupLookupHostnameResult,
474        fdomain_client::fidl::FDomainResourceDialect,
475    > {
476        LookupProxyInterface::r#lookup_hostname(self, addr)
477    }
478}
479
480impl LookupProxyInterface for LookupProxy {
481    type LookupIpResponseFut = fidl::client::QueryResponseFut<
482        LookupLookupIpResult,
483        fdomain_client::fidl::FDomainResourceDialect,
484    >;
485    fn r#lookup_ip(
486        &self,
487        mut hostname: &str,
488        mut options: &LookupIpOptions,
489    ) -> Self::LookupIpResponseFut {
490        fn _decode(
491            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
492        ) -> Result<LookupLookupIpResult, fidl::Error> {
493            let _response = fidl::client::decode_transaction_body::<
494                fidl::encoding::ResultType<LookupLookupIpResponse, LookupError>,
495                fdomain_client::fidl::FDomainResourceDialect,
496                0x59247caf7560c1d0,
497            >(_buf?)?;
498            Ok(_response.map(|x| x.result))
499        }
500        self.client.send_query_and_decode::<LookupLookupIpRequest, LookupLookupIpResult>(
501            (hostname, options),
502            0x59247caf7560c1d0,
503            fidl::encoding::DynamicFlags::empty(),
504            _decode,
505        )
506    }
507
508    type LookupHostnameResponseFut = fidl::client::QueryResponseFut<
509        LookupLookupHostnameResult,
510        fdomain_client::fidl::FDomainResourceDialect,
511    >;
512    fn r#lookup_hostname(
513        &self,
514        mut addr: &fdomain_fuchsia_net::IpAddress,
515    ) -> Self::LookupHostnameResponseFut {
516        fn _decode(
517            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
518        ) -> Result<LookupLookupHostnameResult, fidl::Error> {
519            let _response = fidl::client::decode_transaction_body::<
520                fidl::encoding::ResultType<LookupLookupHostnameResponse, LookupError>,
521                fdomain_client::fidl::FDomainResourceDialect,
522                0x1b456b0e84888324,
523            >(_buf?)?;
524            Ok(_response.map(|x| x.hostname))
525        }
526        self.client
527            .send_query_and_decode::<LookupLookupHostnameRequest, LookupLookupHostnameResult>(
528                (addr,),
529                0x1b456b0e84888324,
530                fidl::encoding::DynamicFlags::empty(),
531                _decode,
532            )
533    }
534}
535
536pub struct LookupEventStream {
537    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
538}
539
540impl std::marker::Unpin for LookupEventStream {}
541
542impl futures::stream::FusedStream for LookupEventStream {
543    fn is_terminated(&self) -> bool {
544        self.event_receiver.is_terminated()
545    }
546}
547
548impl futures::Stream for LookupEventStream {
549    type Item = Result<LookupEvent, fidl::Error>;
550
551    fn poll_next(
552        mut self: std::pin::Pin<&mut Self>,
553        cx: &mut std::task::Context<'_>,
554    ) -> std::task::Poll<Option<Self::Item>> {
555        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
556            &mut self.event_receiver,
557            cx
558        )?) {
559            Some(buf) => std::task::Poll::Ready(Some(LookupEvent::decode(buf))),
560            None => std::task::Poll::Ready(None),
561        }
562    }
563}
564
565#[derive(Debug)]
566pub enum LookupEvent {}
567
568impl LookupEvent {
569    /// Decodes a message buffer as a [`LookupEvent`].
570    fn decode(
571        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
572    ) -> Result<LookupEvent, fidl::Error> {
573        let (bytes, _handles) = buf.split_mut();
574        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
575        debug_assert_eq!(tx_header.tx_id, 0);
576        match tx_header.ordinal {
577            _ => Err(fidl::Error::UnknownOrdinal {
578                ordinal: tx_header.ordinal,
579                protocol_name: <LookupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
580            }),
581        }
582    }
583}
584
585/// A Stream of incoming requests for fuchsia.net.name/Lookup.
586pub struct LookupRequestStream {
587    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
588    is_terminated: bool,
589}
590
591impl std::marker::Unpin for LookupRequestStream {}
592
593impl futures::stream::FusedStream for LookupRequestStream {
594    fn is_terminated(&self) -> bool {
595        self.is_terminated
596    }
597}
598
599impl fdomain_client::fidl::RequestStream for LookupRequestStream {
600    type Protocol = LookupMarker;
601    type ControlHandle = LookupControlHandle;
602
603    fn from_channel(channel: fdomain_client::Channel) -> Self {
604        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
605    }
606
607    fn control_handle(&self) -> Self::ControlHandle {
608        LookupControlHandle { inner: self.inner.clone() }
609    }
610
611    fn into_inner(
612        self,
613    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
614    {
615        (self.inner, self.is_terminated)
616    }
617
618    fn from_inner(
619        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
620        is_terminated: bool,
621    ) -> Self {
622        Self { inner, is_terminated }
623    }
624}
625
626impl futures::Stream for LookupRequestStream {
627    type Item = Result<LookupRequest, fidl::Error>;
628
629    fn poll_next(
630        mut self: std::pin::Pin<&mut Self>,
631        cx: &mut std::task::Context<'_>,
632    ) -> std::task::Poll<Option<Self::Item>> {
633        let this = &mut *self;
634        if this.inner.check_shutdown(cx) {
635            this.is_terminated = true;
636            return std::task::Poll::Ready(None);
637        }
638        if this.is_terminated {
639            panic!("polled LookupRequestStream after completion");
640        }
641        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
642            |bytes, handles| {
643                match this.inner.channel().read_etc(cx, bytes, handles) {
644                    std::task::Poll::Ready(Ok(())) => {}
645                    std::task::Poll::Pending => return std::task::Poll::Pending,
646                    std::task::Poll::Ready(Err(None)) => {
647                        this.is_terminated = true;
648                        return std::task::Poll::Ready(None);
649                    }
650                    std::task::Poll::Ready(Err(Some(e))) => {
651                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
652                            e.into(),
653                        ))));
654                    }
655                }
656
657                // A message has been received from the channel
658                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
659
660                std::task::Poll::Ready(Some(match header.ordinal {
661                    0x59247caf7560c1d0 => {
662                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
663                        let mut req = fidl::new_empty!(
664                            LookupLookupIpRequest,
665                            fdomain_client::fidl::FDomainResourceDialect
666                        );
667                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LookupLookupIpRequest>(&header, _body_bytes, handles, &mut req)?;
668                        let control_handle = LookupControlHandle { inner: this.inner.clone() };
669                        Ok(LookupRequest::LookupIp {
670                            hostname: req.hostname,
671                            options: req.options,
672
673                            responder: LookupLookupIpResponder {
674                                control_handle: std::mem::ManuallyDrop::new(control_handle),
675                                tx_id: header.tx_id,
676                            },
677                        })
678                    }
679                    0x1b456b0e84888324 => {
680                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
681                        let mut req = fidl::new_empty!(
682                            LookupLookupHostnameRequest,
683                            fdomain_client::fidl::FDomainResourceDialect
684                        );
685                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LookupLookupHostnameRequest>(&header, _body_bytes, handles, &mut req)?;
686                        let control_handle = LookupControlHandle { inner: this.inner.clone() };
687                        Ok(LookupRequest::LookupHostname {
688                            addr: req.addr,
689
690                            responder: LookupLookupHostnameResponder {
691                                control_handle: std::mem::ManuallyDrop::new(control_handle),
692                                tx_id: header.tx_id,
693                            },
694                        })
695                    }
696                    _ => Err(fidl::Error::UnknownOrdinal {
697                        ordinal: header.ordinal,
698                        protocol_name:
699                            <LookupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
700                    }),
701                }))
702            },
703        )
704    }
705}
706
707/// Provides name and address resolution.
708#[derive(Debug)]
709pub enum LookupRequest {
710    /// Lookup a list of IP addresses by hostname.
711    LookupIp { hostname: String, options: LookupIpOptions, responder: LookupLookupIpResponder },
712    /// Look up a hostname by IP address.
713    LookupHostname {
714        addr: fdomain_fuchsia_net::IpAddress,
715        responder: LookupLookupHostnameResponder,
716    },
717}
718
719impl LookupRequest {
720    #[allow(irrefutable_let_patterns)]
721    pub fn into_lookup_ip(self) -> Option<(String, LookupIpOptions, LookupLookupIpResponder)> {
722        if let LookupRequest::LookupIp { hostname, options, responder } = self {
723            Some((hostname, options, responder))
724        } else {
725            None
726        }
727    }
728
729    #[allow(irrefutable_let_patterns)]
730    pub fn into_lookup_hostname(
731        self,
732    ) -> Option<(fdomain_fuchsia_net::IpAddress, LookupLookupHostnameResponder)> {
733        if let LookupRequest::LookupHostname { addr, responder } = self {
734            Some((addr, responder))
735        } else {
736            None
737        }
738    }
739
740    /// Name of the method defined in FIDL
741    pub fn method_name(&self) -> &'static str {
742        match *self {
743            LookupRequest::LookupIp { .. } => "lookup_ip",
744            LookupRequest::LookupHostname { .. } => "lookup_hostname",
745        }
746    }
747}
748
749#[derive(Debug, Clone)]
750pub struct LookupControlHandle {
751    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
752}
753
754impl LookupControlHandle {
755    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
756        self.inner.shutdown_with_epitaph(status.into())
757    }
758}
759
760impl fdomain_client::fidl::ControlHandle for LookupControlHandle {
761    fn shutdown(&self) {
762        self.inner.shutdown()
763    }
764
765    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
766        self.inner.shutdown_with_epitaph(status)
767    }
768
769    fn is_closed(&self) -> bool {
770        self.inner.channel().is_closed()
771    }
772    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
773        self.inner.channel().on_closed()
774    }
775}
776
777impl LookupControlHandle {}
778
779#[must_use = "FIDL methods require a response to be sent"]
780#[derive(Debug)]
781pub struct LookupLookupIpResponder {
782    control_handle: std::mem::ManuallyDrop<LookupControlHandle>,
783    tx_id: u32,
784}
785
786/// Set the the channel to be shutdown (see [`LookupControlHandle::shutdown`])
787/// if the responder is dropped without sending a response, so that the client
788/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
789impl std::ops::Drop for LookupLookupIpResponder {
790    fn drop(&mut self) {
791        self.control_handle.shutdown();
792        // Safety: drops once, never accessed again
793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
794    }
795}
796
797impl fdomain_client::fidl::Responder for LookupLookupIpResponder {
798    type ControlHandle = LookupControlHandle;
799
800    fn control_handle(&self) -> &LookupControlHandle {
801        &self.control_handle
802    }
803
804    fn drop_without_shutdown(mut self) {
805        // Safety: drops once, never accessed again due to mem::forget
806        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
807        // Prevent Drop from running (which would shut down the channel)
808        std::mem::forget(self);
809    }
810}
811
812impl LookupLookupIpResponder {
813    /// Sends a response to the FIDL transaction.
814    ///
815    /// Sets the channel to shutdown if an error occurs.
816    pub fn send(self, mut result: Result<&LookupResult, LookupError>) -> Result<(), fidl::Error> {
817        let _result = self.send_raw(result);
818        if _result.is_err() {
819            self.control_handle.shutdown();
820        }
821        self.drop_without_shutdown();
822        _result
823    }
824
825    /// Similar to "send" but does not shutdown the channel if an error occurs.
826    pub fn send_no_shutdown_on_err(
827        self,
828        mut result: Result<&LookupResult, LookupError>,
829    ) -> Result<(), fidl::Error> {
830        let _result = self.send_raw(result);
831        self.drop_without_shutdown();
832        _result
833    }
834
835    fn send_raw(&self, mut result: Result<&LookupResult, LookupError>) -> Result<(), fidl::Error> {
836        self.control_handle
837            .inner
838            .send::<fidl::encoding::ResultType<LookupLookupIpResponse, LookupError>>(
839                result.map(|result| (result,)),
840                self.tx_id,
841                0x59247caf7560c1d0,
842                fidl::encoding::DynamicFlags::empty(),
843            )
844    }
845}
846
847#[must_use = "FIDL methods require a response to be sent"]
848#[derive(Debug)]
849pub struct LookupLookupHostnameResponder {
850    control_handle: std::mem::ManuallyDrop<LookupControlHandle>,
851    tx_id: u32,
852}
853
854/// Set the the channel to be shutdown (see [`LookupControlHandle::shutdown`])
855/// if the responder is dropped without sending a response, so that the client
856/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
857impl std::ops::Drop for LookupLookupHostnameResponder {
858    fn drop(&mut self) {
859        self.control_handle.shutdown();
860        // Safety: drops once, never accessed again
861        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
862    }
863}
864
865impl fdomain_client::fidl::Responder for LookupLookupHostnameResponder {
866    type ControlHandle = LookupControlHandle;
867
868    fn control_handle(&self) -> &LookupControlHandle {
869        &self.control_handle
870    }
871
872    fn drop_without_shutdown(mut self) {
873        // Safety: drops once, never accessed again due to mem::forget
874        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
875        // Prevent Drop from running (which would shut down the channel)
876        std::mem::forget(self);
877    }
878}
879
880impl LookupLookupHostnameResponder {
881    /// Sends a response to the FIDL transaction.
882    ///
883    /// Sets the channel to shutdown if an error occurs.
884    pub fn send(self, mut result: Result<&str, LookupError>) -> Result<(), fidl::Error> {
885        let _result = self.send_raw(result);
886        if _result.is_err() {
887            self.control_handle.shutdown();
888        }
889        self.drop_without_shutdown();
890        _result
891    }
892
893    /// Similar to "send" but does not shutdown the channel if an error occurs.
894    pub fn send_no_shutdown_on_err(
895        self,
896        mut result: Result<&str, LookupError>,
897    ) -> Result<(), fidl::Error> {
898        let _result = self.send_raw(result);
899        self.drop_without_shutdown();
900        _result
901    }
902
903    fn send_raw(&self, mut result: Result<&str, LookupError>) -> Result<(), fidl::Error> {
904        self.control_handle.inner.send::<fidl::encoding::ResultType<
905            LookupLookupHostnameResponse,
906            LookupError,
907        >>(
908            result.map(|hostname| (hostname,)),
909            self.tx_id,
910            0x1b456b0e84888324,
911            fidl::encoding::DynamicFlags::empty(),
912        )
913    }
914}
915
916#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
917pub struct LookupAdminMarker;
918
919impl fdomain_client::fidl::ProtocolMarker for LookupAdminMarker {
920    type Proxy = LookupAdminProxy;
921    type RequestStream = LookupAdminRequestStream;
922
923    const DEBUG_NAME: &'static str = "fuchsia.net.name.LookupAdmin";
924}
925impl fdomain_client::fidl::DiscoverableProtocolMarker for LookupAdminMarker {}
926pub type LookupAdminSetDnsServersResult = Result<(), i32>;
927
928pub trait LookupAdminProxyInterface: Send + Sync {
929    type SetDnsServersResponseFut: std::future::Future<Output = Result<LookupAdminSetDnsServersResult, fidl::Error>>
930        + Send;
931    fn r#set_dns_servers(
932        &self,
933        servers: &[fdomain_fuchsia_net::SocketAddress],
934    ) -> Self::SetDnsServersResponseFut;
935    type GetDnsServersResponseFut: std::future::Future<Output = Result<Vec<fdomain_fuchsia_net::SocketAddress>, fidl::Error>>
936        + Send;
937    fn r#get_dns_servers(&self) -> Self::GetDnsServersResponseFut;
938}
939
940#[derive(Debug, Clone)]
941pub struct LookupAdminProxy {
942    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
943}
944
945impl fdomain_client::fidl::Proxy for LookupAdminProxy {
946    type Protocol = LookupAdminMarker;
947
948    fn from_channel(inner: fdomain_client::Channel) -> Self {
949        Self::new(inner)
950    }
951
952    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
953        self.client.into_channel().map_err(|client| Self { client })
954    }
955
956    fn as_channel(&self) -> &fdomain_client::Channel {
957        self.client.as_channel()
958    }
959}
960
961impl LookupAdminProxy {
962    /// Create a new Proxy for fuchsia.net.name/LookupAdmin.
963    pub fn new(channel: fdomain_client::Channel) -> Self {
964        let protocol_name = <LookupAdminMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
965        Self { client: fidl::client::Client::new(channel, protocol_name) }
966    }
967
968    /// Get a Stream of events from the remote end of the protocol.
969    ///
970    /// # Panics
971    ///
972    /// Panics if the event stream was already taken.
973    pub fn take_event_stream(&self) -> LookupAdminEventStream {
974        LookupAdminEventStream { event_receiver: self.client.take_event_receiver() }
975    }
976
977    /// Sets the DNS servers to `servers`
978    ///
979    /// + request `servers` The list of servers to use for domain name resolution, in priority
980    /// order. An empty list means no servers will be used and name resolution may fail. Each
981    /// `SocketAddress` in `servers` must be a valid unicast socket address. The list of servers
982    /// will be deduplicated.
983    /// * error Returns `ZX_ERR_INVALID_ARGS` if any of the provided addresses does not meet the
984    /// conditions above.
985    pub fn r#set_dns_servers(
986        &self,
987        mut servers: &[fdomain_fuchsia_net::SocketAddress],
988    ) -> fidl::client::QueryResponseFut<
989        LookupAdminSetDnsServersResult,
990        fdomain_client::fidl::FDomainResourceDialect,
991    > {
992        LookupAdminProxyInterface::r#set_dns_servers(self, servers)
993    }
994
995    /// Gets the DNS servers currently in use to resolve name lookups.
996    /// - response `servers` The list of servers in use by `LookupAdmin`, in priority order.
997    pub fn r#get_dns_servers(
998        &self,
999    ) -> fidl::client::QueryResponseFut<
1000        Vec<fdomain_fuchsia_net::SocketAddress>,
1001        fdomain_client::fidl::FDomainResourceDialect,
1002    > {
1003        LookupAdminProxyInterface::r#get_dns_servers(self)
1004    }
1005}
1006
1007impl LookupAdminProxyInterface for LookupAdminProxy {
1008    type SetDnsServersResponseFut = fidl::client::QueryResponseFut<
1009        LookupAdminSetDnsServersResult,
1010        fdomain_client::fidl::FDomainResourceDialect,
1011    >;
1012    fn r#set_dns_servers(
1013        &self,
1014        mut servers: &[fdomain_fuchsia_net::SocketAddress],
1015    ) -> Self::SetDnsServersResponseFut {
1016        fn _decode(
1017            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1018        ) -> Result<LookupAdminSetDnsServersResult, fidl::Error> {
1019            let _response = fidl::client::decode_transaction_body::<
1020                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1021                fdomain_client::fidl::FDomainResourceDialect,
1022                0x55e2b9fcc777be96,
1023            >(_buf?)?;
1024            Ok(_response.map(|x| x))
1025        }
1026        self.client.send_query_and_decode::<
1027            LookupAdminSetDnsServersRequest,
1028            LookupAdminSetDnsServersResult,
1029        >(
1030            (servers,),
1031            0x55e2b9fcc777be96,
1032            fidl::encoding::DynamicFlags::empty(),
1033            _decode,
1034        )
1035    }
1036
1037    type GetDnsServersResponseFut = fidl::client::QueryResponseFut<
1038        Vec<fdomain_fuchsia_net::SocketAddress>,
1039        fdomain_client::fidl::FDomainResourceDialect,
1040    >;
1041    fn r#get_dns_servers(&self) -> Self::GetDnsServersResponseFut {
1042        fn _decode(
1043            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1044        ) -> Result<Vec<fdomain_fuchsia_net::SocketAddress>, fidl::Error> {
1045            let _response = fidl::client::decode_transaction_body::<
1046                LookupAdminGetDnsServersResponse,
1047                fdomain_client::fidl::FDomainResourceDialect,
1048                0x614303bf6e72f80f,
1049            >(_buf?)?;
1050            Ok(_response.servers)
1051        }
1052        self.client.send_query_and_decode::<
1053            fidl::encoding::EmptyPayload,
1054            Vec<fdomain_fuchsia_net::SocketAddress>,
1055        >(
1056            (),
1057            0x614303bf6e72f80f,
1058            fidl::encoding::DynamicFlags::empty(),
1059            _decode,
1060        )
1061    }
1062}
1063
1064pub struct LookupAdminEventStream {
1065    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1066}
1067
1068impl std::marker::Unpin for LookupAdminEventStream {}
1069
1070impl futures::stream::FusedStream for LookupAdminEventStream {
1071    fn is_terminated(&self) -> bool {
1072        self.event_receiver.is_terminated()
1073    }
1074}
1075
1076impl futures::Stream for LookupAdminEventStream {
1077    type Item = Result<LookupAdminEvent, fidl::Error>;
1078
1079    fn poll_next(
1080        mut self: std::pin::Pin<&mut Self>,
1081        cx: &mut std::task::Context<'_>,
1082    ) -> std::task::Poll<Option<Self::Item>> {
1083        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1084            &mut self.event_receiver,
1085            cx
1086        )?) {
1087            Some(buf) => std::task::Poll::Ready(Some(LookupAdminEvent::decode(buf))),
1088            None => std::task::Poll::Ready(None),
1089        }
1090    }
1091}
1092
1093#[derive(Debug)]
1094pub enum LookupAdminEvent {}
1095
1096impl LookupAdminEvent {
1097    /// Decodes a message buffer as a [`LookupAdminEvent`].
1098    fn decode(
1099        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1100    ) -> Result<LookupAdminEvent, fidl::Error> {
1101        let (bytes, _handles) = buf.split_mut();
1102        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1103        debug_assert_eq!(tx_header.tx_id, 0);
1104        match tx_header.ordinal {
1105            _ => Err(fidl::Error::UnknownOrdinal {
1106                ordinal: tx_header.ordinal,
1107                protocol_name:
1108                    <LookupAdminMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1109            }),
1110        }
1111    }
1112}
1113
1114/// A Stream of incoming requests for fuchsia.net.name/LookupAdmin.
1115pub struct LookupAdminRequestStream {
1116    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1117    is_terminated: bool,
1118}
1119
1120impl std::marker::Unpin for LookupAdminRequestStream {}
1121
1122impl futures::stream::FusedStream for LookupAdminRequestStream {
1123    fn is_terminated(&self) -> bool {
1124        self.is_terminated
1125    }
1126}
1127
1128impl fdomain_client::fidl::RequestStream for LookupAdminRequestStream {
1129    type Protocol = LookupAdminMarker;
1130    type ControlHandle = LookupAdminControlHandle;
1131
1132    fn from_channel(channel: fdomain_client::Channel) -> Self {
1133        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1134    }
1135
1136    fn control_handle(&self) -> Self::ControlHandle {
1137        LookupAdminControlHandle { inner: self.inner.clone() }
1138    }
1139
1140    fn into_inner(
1141        self,
1142    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1143    {
1144        (self.inner, self.is_terminated)
1145    }
1146
1147    fn from_inner(
1148        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1149        is_terminated: bool,
1150    ) -> Self {
1151        Self { inner, is_terminated }
1152    }
1153}
1154
1155impl futures::Stream for LookupAdminRequestStream {
1156    type Item = Result<LookupAdminRequest, fidl::Error>;
1157
1158    fn poll_next(
1159        mut self: std::pin::Pin<&mut Self>,
1160        cx: &mut std::task::Context<'_>,
1161    ) -> std::task::Poll<Option<Self::Item>> {
1162        let this = &mut *self;
1163        if this.inner.check_shutdown(cx) {
1164            this.is_terminated = true;
1165            return std::task::Poll::Ready(None);
1166        }
1167        if this.is_terminated {
1168            panic!("polled LookupAdminRequestStream after completion");
1169        }
1170        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1171            |bytes, handles| {
1172                match this.inner.channel().read_etc(cx, bytes, handles) {
1173                    std::task::Poll::Ready(Ok(())) => {}
1174                    std::task::Poll::Pending => return std::task::Poll::Pending,
1175                    std::task::Poll::Ready(Err(None)) => {
1176                        this.is_terminated = true;
1177                        return std::task::Poll::Ready(None);
1178                    }
1179                    std::task::Poll::Ready(Err(Some(e))) => {
1180                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1181                            e.into(),
1182                        ))));
1183                    }
1184                }
1185
1186                // A message has been received from the channel
1187                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1188
1189                std::task::Poll::Ready(Some(match header.ordinal {
1190                    0x55e2b9fcc777be96 => {
1191                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1192                        let mut req = fidl::new_empty!(
1193                            LookupAdminSetDnsServersRequest,
1194                            fdomain_client::fidl::FDomainResourceDialect
1195                        );
1196                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LookupAdminSetDnsServersRequest>(&header, _body_bytes, handles, &mut req)?;
1197                        let control_handle = LookupAdminControlHandle { inner: this.inner.clone() };
1198                        Ok(LookupAdminRequest::SetDnsServers {
1199                            servers: req.servers,
1200
1201                            responder: LookupAdminSetDnsServersResponder {
1202                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1203                                tx_id: header.tx_id,
1204                            },
1205                        })
1206                    }
1207                    0x614303bf6e72f80f => {
1208                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1209                        let mut req = fidl::new_empty!(
1210                            fidl::encoding::EmptyPayload,
1211                            fdomain_client::fidl::FDomainResourceDialect
1212                        );
1213                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1214                        let control_handle = LookupAdminControlHandle { inner: this.inner.clone() };
1215                        Ok(LookupAdminRequest::GetDnsServers {
1216                            responder: LookupAdminGetDnsServersResponder {
1217                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1218                                tx_id: header.tx_id,
1219                            },
1220                        })
1221                    }
1222                    _ => Err(fidl::Error::UnknownOrdinal {
1223                        ordinal: header.ordinal,
1224                        protocol_name:
1225                            <LookupAdminMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1226                    }),
1227                }))
1228            },
1229        )
1230    }
1231}
1232
1233/// Provides administration controls over name resolution settings.
1234#[derive(Debug)]
1235pub enum LookupAdminRequest {
1236    /// Sets the DNS servers to `servers`
1237    ///
1238    /// + request `servers` The list of servers to use for domain name resolution, in priority
1239    /// order. An empty list means no servers will be used and name resolution may fail. Each
1240    /// `SocketAddress` in `servers` must be a valid unicast socket address. The list of servers
1241    /// will be deduplicated.
1242    /// * error Returns `ZX_ERR_INVALID_ARGS` if any of the provided addresses does not meet the
1243    /// conditions above.
1244    SetDnsServers {
1245        servers: Vec<fdomain_fuchsia_net::SocketAddress>,
1246        responder: LookupAdminSetDnsServersResponder,
1247    },
1248    /// Gets the DNS servers currently in use to resolve name lookups.
1249    /// - response `servers` The list of servers in use by `LookupAdmin`, in priority order.
1250    GetDnsServers { responder: LookupAdminGetDnsServersResponder },
1251}
1252
1253impl LookupAdminRequest {
1254    #[allow(irrefutable_let_patterns)]
1255    pub fn into_set_dns_servers(
1256        self,
1257    ) -> Option<(Vec<fdomain_fuchsia_net::SocketAddress>, LookupAdminSetDnsServersResponder)> {
1258        if let LookupAdminRequest::SetDnsServers { servers, responder } = self {
1259            Some((servers, responder))
1260        } else {
1261            None
1262        }
1263    }
1264
1265    #[allow(irrefutable_let_patterns)]
1266    pub fn into_get_dns_servers(self) -> Option<(LookupAdminGetDnsServersResponder)> {
1267        if let LookupAdminRequest::GetDnsServers { responder } = self {
1268            Some((responder))
1269        } else {
1270            None
1271        }
1272    }
1273
1274    /// Name of the method defined in FIDL
1275    pub fn method_name(&self) -> &'static str {
1276        match *self {
1277            LookupAdminRequest::SetDnsServers { .. } => "set_dns_servers",
1278            LookupAdminRequest::GetDnsServers { .. } => "get_dns_servers",
1279        }
1280    }
1281}
1282
1283#[derive(Debug, Clone)]
1284pub struct LookupAdminControlHandle {
1285    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1286}
1287
1288impl LookupAdminControlHandle {
1289    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1290        self.inner.shutdown_with_epitaph(status.into())
1291    }
1292}
1293
1294impl fdomain_client::fidl::ControlHandle for LookupAdminControlHandle {
1295    fn shutdown(&self) {
1296        self.inner.shutdown()
1297    }
1298
1299    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1300        self.inner.shutdown_with_epitaph(status)
1301    }
1302
1303    fn is_closed(&self) -> bool {
1304        self.inner.channel().is_closed()
1305    }
1306    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1307        self.inner.channel().on_closed()
1308    }
1309}
1310
1311impl LookupAdminControlHandle {}
1312
1313#[must_use = "FIDL methods require a response to be sent"]
1314#[derive(Debug)]
1315pub struct LookupAdminSetDnsServersResponder {
1316    control_handle: std::mem::ManuallyDrop<LookupAdminControlHandle>,
1317    tx_id: u32,
1318}
1319
1320/// Set the the channel to be shutdown (see [`LookupAdminControlHandle::shutdown`])
1321/// if the responder is dropped without sending a response, so that the client
1322/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1323impl std::ops::Drop for LookupAdminSetDnsServersResponder {
1324    fn drop(&mut self) {
1325        self.control_handle.shutdown();
1326        // Safety: drops once, never accessed again
1327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1328    }
1329}
1330
1331impl fdomain_client::fidl::Responder for LookupAdminSetDnsServersResponder {
1332    type ControlHandle = LookupAdminControlHandle;
1333
1334    fn control_handle(&self) -> &LookupAdminControlHandle {
1335        &self.control_handle
1336    }
1337
1338    fn drop_without_shutdown(mut self) {
1339        // Safety: drops once, never accessed again due to mem::forget
1340        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1341        // Prevent Drop from running (which would shut down the channel)
1342        std::mem::forget(self);
1343    }
1344}
1345
1346impl LookupAdminSetDnsServersResponder {
1347    /// Sends a response to the FIDL transaction.
1348    ///
1349    /// Sets the channel to shutdown if an error occurs.
1350    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1351        let _result = self.send_raw(result);
1352        if _result.is_err() {
1353            self.control_handle.shutdown();
1354        }
1355        self.drop_without_shutdown();
1356        _result
1357    }
1358
1359    /// Similar to "send" but does not shutdown the channel if an error occurs.
1360    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1361        let _result = self.send_raw(result);
1362        self.drop_without_shutdown();
1363        _result
1364    }
1365
1366    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1367        self.control_handle
1368            .inner
1369            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1370                result,
1371                self.tx_id,
1372                0x55e2b9fcc777be96,
1373                fidl::encoding::DynamicFlags::empty(),
1374            )
1375    }
1376}
1377
1378#[must_use = "FIDL methods require a response to be sent"]
1379#[derive(Debug)]
1380pub struct LookupAdminGetDnsServersResponder {
1381    control_handle: std::mem::ManuallyDrop<LookupAdminControlHandle>,
1382    tx_id: u32,
1383}
1384
1385/// Set the the channel to be shutdown (see [`LookupAdminControlHandle::shutdown`])
1386/// if the responder is dropped without sending a response, so that the client
1387/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1388impl std::ops::Drop for LookupAdminGetDnsServersResponder {
1389    fn drop(&mut self) {
1390        self.control_handle.shutdown();
1391        // Safety: drops once, never accessed again
1392        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1393    }
1394}
1395
1396impl fdomain_client::fidl::Responder for LookupAdminGetDnsServersResponder {
1397    type ControlHandle = LookupAdminControlHandle;
1398
1399    fn control_handle(&self) -> &LookupAdminControlHandle {
1400        &self.control_handle
1401    }
1402
1403    fn drop_without_shutdown(mut self) {
1404        // Safety: drops once, never accessed again due to mem::forget
1405        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1406        // Prevent Drop from running (which would shut down the channel)
1407        std::mem::forget(self);
1408    }
1409}
1410
1411impl LookupAdminGetDnsServersResponder {
1412    /// Sends a response to the FIDL transaction.
1413    ///
1414    /// Sets the channel to shutdown if an error occurs.
1415    pub fn send(
1416        self,
1417        mut servers: &[fdomain_fuchsia_net::SocketAddress],
1418    ) -> Result<(), fidl::Error> {
1419        let _result = self.send_raw(servers);
1420        if _result.is_err() {
1421            self.control_handle.shutdown();
1422        }
1423        self.drop_without_shutdown();
1424        _result
1425    }
1426
1427    /// Similar to "send" but does not shutdown the channel if an error occurs.
1428    pub fn send_no_shutdown_on_err(
1429        self,
1430        mut servers: &[fdomain_fuchsia_net::SocketAddress],
1431    ) -> Result<(), fidl::Error> {
1432        let _result = self.send_raw(servers);
1433        self.drop_without_shutdown();
1434        _result
1435    }
1436
1437    fn send_raw(
1438        &self,
1439        mut servers: &[fdomain_fuchsia_net::SocketAddress],
1440    ) -> Result<(), fidl::Error> {
1441        self.control_handle.inner.send::<LookupAdminGetDnsServersResponse>(
1442            (servers,),
1443            self.tx_id,
1444            0x614303bf6e72f80f,
1445            fidl::encoding::DynamicFlags::empty(),
1446        )
1447    }
1448}
1449
1450mod internal {
1451    use super::*;
1452}