Skip to main content

fidl_fuchsia_net_mdns/
fidl_fuchsia_net_mdns.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_mdns__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct HostNameSubscriberSubscribeToHostNameRequest {
16    pub host: String,
17    pub options: HostNameSubscriptionOptions,
18    pub listener: fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22    for HostNameSubscriberSubscribeToHostNameRequest
23{
24}
25
26#[derive(Debug, PartialEq)]
27pub struct ProxyHostPublisherPublishProxyHostRequest {
28    pub host: String,
29    pub addresses: Vec<fidl_fuchsia_net::IpAddress>,
30    pub options: ProxyHostPublicationOptions,
31    pub service_instance_publisher: fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
32}
33
34impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
35    for ProxyHostPublisherPublishProxyHostRequest
36{
37}
38
39#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
40pub struct PublisherPublishServiceInstanceRequest {
41    pub service: String,
42    pub instance: String,
43    pub media: Media,
44    pub perform_probe: bool,
45    pub publication_responder: fidl::endpoints::ClientEnd<PublicationResponder_Marker>,
46}
47
48impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
49    for PublisherPublishServiceInstanceRequest
50{
51}
52
53#[derive(Debug, PartialEq)]
54pub struct ServiceInstancePublisherPublishServiceInstanceRequest {
55    pub service: String,
56    pub instance: String,
57    pub options: ServiceInstancePublicationOptions,
58    pub publication_responder:
59        fidl::endpoints::ClientEnd<ServiceInstancePublicationResponder_Marker>,
60}
61
62impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
63    for ServiceInstancePublisherPublishServiceInstanceRequest
64{
65}
66
67#[derive(Debug, PartialEq)]
68pub struct ServiceSubscriber2SubscribeToAllServicesRequest {
69    pub options: ServiceSubscriptionOptions,
70    pub listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
71}
72
73impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
74    for ServiceSubscriber2SubscribeToAllServicesRequest
75{
76}
77
78#[derive(Debug, PartialEq)]
79pub struct ServiceSubscriber2SubscribeToServiceRequest {
80    pub service: String,
81    pub options: ServiceSubscriptionOptions,
82    pub listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
83}
84
85impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
86    for ServiceSubscriber2SubscribeToServiceRequest
87{
88}
89
90#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
91pub struct SubscriberSubscribeToServiceRequest {
92    pub service: String,
93    pub subscriber: fidl::endpoints::ClientEnd<ServiceSubscriberMarker>,
94}
95
96impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
97    for SubscriberSubscribeToServiceRequest
98{
99}
100
101#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
102pub struct HostNameResolverMarker;
103
104impl fidl::endpoints::ProtocolMarker for HostNameResolverMarker {
105    type Proxy = HostNameResolverProxy;
106    type RequestStream = HostNameResolverRequestStream;
107    #[cfg(target_os = "fuchsia")]
108    type SynchronousProxy = HostNameResolverSynchronousProxy;
109
110    const DEBUG_NAME: &'static str = "fuchsia.net.mdns.HostNameResolver";
111}
112impl fidl::endpoints::DiscoverableProtocolMarker for HostNameResolverMarker {}
113
114pub trait HostNameResolverProxyInterface: Send + Sync {
115    type ResolveHostNameResponseFut: std::future::Future<Output = Result<Vec<HostAddress>, fidl::Error>>
116        + Send;
117    fn r#resolve_host_name(
118        &self,
119        host: &str,
120        timeout: i64,
121        options: &HostNameResolutionOptions,
122    ) -> Self::ResolveHostNameResponseFut;
123}
124#[derive(Debug)]
125#[cfg(target_os = "fuchsia")]
126pub struct HostNameResolverSynchronousProxy {
127    client: fidl::client::sync::Client,
128}
129
130#[cfg(target_os = "fuchsia")]
131impl fidl::endpoints::SynchronousProxy for HostNameResolverSynchronousProxy {
132    type Proxy = HostNameResolverProxy;
133    type Protocol = HostNameResolverMarker;
134
135    fn from_channel(inner: fidl::Channel) -> Self {
136        Self::new(inner)
137    }
138
139    fn into_channel(self) -> fidl::Channel {
140        self.client.into_channel()
141    }
142
143    fn as_channel(&self) -> &fidl::Channel {
144        self.client.as_channel()
145    }
146}
147
148#[cfg(target_os = "fuchsia")]
149impl HostNameResolverSynchronousProxy {
150    pub fn new(channel: fidl::Channel) -> Self {
151        Self { client: fidl::client::sync::Client::new(channel) }
152    }
153
154    pub fn into_channel(self) -> fidl::Channel {
155        self.client.into_channel()
156    }
157
158    /// Waits until an event arrives and returns it. It is safe for other
159    /// threads to make concurrent requests while waiting for an event.
160    pub fn wait_for_event(
161        &self,
162        deadline: zx::MonotonicInstant,
163    ) -> Result<HostNameResolverEvent, fidl::Error> {
164        HostNameResolverEvent::decode(
165            self.client.wait_for_event::<HostNameResolverMarker>(deadline)?,
166        )
167    }
168
169    /// Gets the addresses for the specified host.
170    ///
171    /// + request `host` the simple name of the host.
172    /// + request `timeout` specifies how long the service should wait before giving up when
173    ///   waiting for a response to a resolution query. In typical use, a timeout of two or three
174    ///   seconds is recommended.
175    /// + request `options` options to be applied to the resolution.
176    /// - response `addresses` the addresses of the specified host, if it was found, an empty vector
177    ///   if not.
178    pub fn r#resolve_host_name(
179        &self,
180        mut host: &str,
181        mut timeout: i64,
182        mut options: &HostNameResolutionOptions,
183        ___deadline: zx::MonotonicInstant,
184    ) -> Result<Vec<HostAddress>, fidl::Error> {
185        let _response = self.client.send_query::<
186            HostNameResolverResolveHostNameRequest,
187            HostNameResolverResolveHostNameResponse,
188            HostNameResolverMarker,
189        >(
190            (host, timeout, options,),
191            0x54f422692b53c46d,
192            fidl::encoding::DynamicFlags::empty(),
193            ___deadline,
194        )?;
195        Ok(_response.addresses)
196    }
197}
198
199#[cfg(target_os = "fuchsia")]
200impl From<HostNameResolverSynchronousProxy> for zx::NullableHandle {
201    fn from(value: HostNameResolverSynchronousProxy) -> Self {
202        value.into_channel().into()
203    }
204}
205
206#[cfg(target_os = "fuchsia")]
207impl From<fidl::Channel> for HostNameResolverSynchronousProxy {
208    fn from(value: fidl::Channel) -> Self {
209        Self::new(value)
210    }
211}
212
213#[cfg(target_os = "fuchsia")]
214impl fidl::endpoints::FromClient for HostNameResolverSynchronousProxy {
215    type Protocol = HostNameResolverMarker;
216
217    fn from_client(value: fidl::endpoints::ClientEnd<HostNameResolverMarker>) -> Self {
218        Self::new(value.into_channel())
219    }
220}
221
222#[derive(Debug, Clone)]
223pub struct HostNameResolverProxy {
224    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
225}
226
227impl fidl::endpoints::Proxy for HostNameResolverProxy {
228    type Protocol = HostNameResolverMarker;
229
230    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
231        Self::new(inner)
232    }
233
234    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
235        self.client.into_channel().map_err(|client| Self { client })
236    }
237
238    fn as_channel(&self) -> &::fidl::AsyncChannel {
239        self.client.as_channel()
240    }
241}
242
243impl HostNameResolverProxy {
244    /// Create a new Proxy for fuchsia.net.mdns/HostNameResolver.
245    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
246        let protocol_name = <HostNameResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
247        Self { client: fidl::client::Client::new(channel, protocol_name) }
248    }
249
250    /// Get a Stream of events from the remote end of the protocol.
251    ///
252    /// # Panics
253    ///
254    /// Panics if the event stream was already taken.
255    pub fn take_event_stream(&self) -> HostNameResolverEventStream {
256        HostNameResolverEventStream { event_receiver: self.client.take_event_receiver() }
257    }
258
259    /// Gets the addresses for the specified host.
260    ///
261    /// + request `host` the simple name of the host.
262    /// + request `timeout` specifies how long the service should wait before giving up when
263    ///   waiting for a response to a resolution query. In typical use, a timeout of two or three
264    ///   seconds is recommended.
265    /// + request `options` options to be applied to the resolution.
266    /// - response `addresses` the addresses of the specified host, if it was found, an empty vector
267    ///   if not.
268    pub fn r#resolve_host_name(
269        &self,
270        mut host: &str,
271        mut timeout: i64,
272        mut options: &HostNameResolutionOptions,
273    ) -> fidl::client::QueryResponseFut<
274        Vec<HostAddress>,
275        fidl::encoding::DefaultFuchsiaResourceDialect,
276    > {
277        HostNameResolverProxyInterface::r#resolve_host_name(self, host, timeout, options)
278    }
279}
280
281impl HostNameResolverProxyInterface for HostNameResolverProxy {
282    type ResolveHostNameResponseFut = fidl::client::QueryResponseFut<
283        Vec<HostAddress>,
284        fidl::encoding::DefaultFuchsiaResourceDialect,
285    >;
286    fn r#resolve_host_name(
287        &self,
288        mut host: &str,
289        mut timeout: i64,
290        mut options: &HostNameResolutionOptions,
291    ) -> Self::ResolveHostNameResponseFut {
292        fn _decode(
293            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
294        ) -> Result<Vec<HostAddress>, fidl::Error> {
295            let _response = fidl::client::decode_transaction_body::<
296                HostNameResolverResolveHostNameResponse,
297                fidl::encoding::DefaultFuchsiaResourceDialect,
298                0x54f422692b53c46d,
299            >(_buf?)?;
300            Ok(_response.addresses)
301        }
302        self.client
303            .send_query_and_decode::<HostNameResolverResolveHostNameRequest, Vec<HostAddress>>(
304                (host, timeout, options),
305                0x54f422692b53c46d,
306                fidl::encoding::DynamicFlags::empty(),
307                _decode,
308            )
309    }
310}
311
312pub struct HostNameResolverEventStream {
313    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
314}
315
316impl std::marker::Unpin for HostNameResolverEventStream {}
317
318impl futures::stream::FusedStream for HostNameResolverEventStream {
319    fn is_terminated(&self) -> bool {
320        self.event_receiver.is_terminated()
321    }
322}
323
324impl futures::Stream for HostNameResolverEventStream {
325    type Item = Result<HostNameResolverEvent, fidl::Error>;
326
327    fn poll_next(
328        mut self: std::pin::Pin<&mut Self>,
329        cx: &mut std::task::Context<'_>,
330    ) -> std::task::Poll<Option<Self::Item>> {
331        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
332            &mut self.event_receiver,
333            cx
334        )?) {
335            Some(buf) => std::task::Poll::Ready(Some(HostNameResolverEvent::decode(buf))),
336            None => std::task::Poll::Ready(None),
337        }
338    }
339}
340
341#[derive(Debug)]
342pub enum HostNameResolverEvent {}
343
344impl HostNameResolverEvent {
345    /// Decodes a message buffer as a [`HostNameResolverEvent`].
346    fn decode(
347        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
348    ) -> Result<HostNameResolverEvent, fidl::Error> {
349        let (bytes, _handles) = buf.split_mut();
350        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
351        debug_assert_eq!(tx_header.tx_id, 0);
352        match tx_header.ordinal {
353            _ => Err(fidl::Error::UnknownOrdinal {
354                ordinal: tx_header.ordinal,
355                protocol_name:
356                    <HostNameResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
357            }),
358        }
359    }
360}
361
362/// A Stream of incoming requests for fuchsia.net.mdns/HostNameResolver.
363pub struct HostNameResolverRequestStream {
364    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
365    is_terminated: bool,
366}
367
368impl std::marker::Unpin for HostNameResolverRequestStream {}
369
370impl futures::stream::FusedStream for HostNameResolverRequestStream {
371    fn is_terminated(&self) -> bool {
372        self.is_terminated
373    }
374}
375
376impl fidl::endpoints::RequestStream for HostNameResolverRequestStream {
377    type Protocol = HostNameResolverMarker;
378    type ControlHandle = HostNameResolverControlHandle;
379
380    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
381        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
382    }
383
384    fn control_handle(&self) -> Self::ControlHandle {
385        HostNameResolverControlHandle { inner: self.inner.clone() }
386    }
387
388    fn into_inner(
389        self,
390    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
391    {
392        (self.inner, self.is_terminated)
393    }
394
395    fn from_inner(
396        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
397        is_terminated: bool,
398    ) -> Self {
399        Self { inner, is_terminated }
400    }
401}
402
403impl futures::Stream for HostNameResolverRequestStream {
404    type Item = Result<HostNameResolverRequest, fidl::Error>;
405
406    fn poll_next(
407        mut self: std::pin::Pin<&mut Self>,
408        cx: &mut std::task::Context<'_>,
409    ) -> std::task::Poll<Option<Self::Item>> {
410        let this = &mut *self;
411        if this.inner.check_shutdown(cx) {
412            this.is_terminated = true;
413            return std::task::Poll::Ready(None);
414        }
415        if this.is_terminated {
416            panic!("polled HostNameResolverRequestStream after completion");
417        }
418        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
419            |bytes, handles| {
420                match this.inner.channel().read_etc(cx, bytes, handles) {
421                    std::task::Poll::Ready(Ok(())) => {}
422                    std::task::Poll::Pending => return std::task::Poll::Pending,
423                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
424                        this.is_terminated = true;
425                        return std::task::Poll::Ready(None);
426                    }
427                    std::task::Poll::Ready(Err(e)) => {
428                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
429                            e.into(),
430                        ))));
431                    }
432                }
433
434                // A message has been received from the channel
435                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
436
437                std::task::Poll::Ready(Some(match header.ordinal {
438                    0x54f422692b53c46d => {
439                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
440                        let mut req = fidl::new_empty!(
441                            HostNameResolverResolveHostNameRequest,
442                            fidl::encoding::DefaultFuchsiaResourceDialect
443                        );
444                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostNameResolverResolveHostNameRequest>(&header, _body_bytes, handles, &mut req)?;
445                        let control_handle =
446                            HostNameResolverControlHandle { inner: this.inner.clone() };
447                        Ok(HostNameResolverRequest::ResolveHostName {
448                            host: req.host,
449                            timeout: req.timeout,
450                            options: req.options,
451
452                            responder: HostNameResolverResolveHostNameResponder {
453                                control_handle: std::mem::ManuallyDrop::new(control_handle),
454                                tx_id: header.tx_id,
455                            },
456                        })
457                    }
458                    _ => Err(fidl::Error::UnknownOrdinal {
459                        ordinal: header.ordinal,
460                        protocol_name:
461                            <HostNameResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
462                    }),
463                }))
464            },
465        )
466    }
467}
468
469/// Discoverable protocol for resolving host names to IP addresses.
470#[derive(Debug)]
471pub enum HostNameResolverRequest {
472    /// Gets the addresses for the specified host.
473    ///
474    /// + request `host` the simple name of the host.
475    /// + request `timeout` specifies how long the service should wait before giving up when
476    ///   waiting for a response to a resolution query. In typical use, a timeout of two or three
477    ///   seconds is recommended.
478    /// + request `options` options to be applied to the resolution.
479    /// - response `addresses` the addresses of the specified host, if it was found, an empty vector
480    ///   if not.
481    ResolveHostName {
482        host: String,
483        timeout: i64,
484        options: HostNameResolutionOptions,
485        responder: HostNameResolverResolveHostNameResponder,
486    },
487}
488
489impl HostNameResolverRequest {
490    #[allow(irrefutable_let_patterns)]
491    pub fn into_resolve_host_name(
492        self,
493    ) -> Option<(String, i64, HostNameResolutionOptions, HostNameResolverResolveHostNameResponder)>
494    {
495        if let HostNameResolverRequest::ResolveHostName { host, timeout, options, responder } = self
496        {
497            Some((host, timeout, options, responder))
498        } else {
499            None
500        }
501    }
502
503    /// Name of the method defined in FIDL
504    pub fn method_name(&self) -> &'static str {
505        match *self {
506            HostNameResolverRequest::ResolveHostName { .. } => "resolve_host_name",
507        }
508    }
509}
510
511#[derive(Debug, Clone)]
512pub struct HostNameResolverControlHandle {
513    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
514}
515
516impl fidl::endpoints::ControlHandle for HostNameResolverControlHandle {
517    fn shutdown(&self) {
518        self.inner.shutdown()
519    }
520
521    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
522        self.inner.shutdown_with_epitaph(status)
523    }
524
525    fn is_closed(&self) -> bool {
526        self.inner.channel().is_closed()
527    }
528    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
529        self.inner.channel().on_closed()
530    }
531
532    #[cfg(target_os = "fuchsia")]
533    fn signal_peer(
534        &self,
535        clear_mask: zx::Signals,
536        set_mask: zx::Signals,
537    ) -> Result<(), zx_status::Status> {
538        use fidl::Peered;
539        self.inner.channel().signal_peer(clear_mask, set_mask)
540    }
541}
542
543impl HostNameResolverControlHandle {}
544
545#[must_use = "FIDL methods require a response to be sent"]
546#[derive(Debug)]
547pub struct HostNameResolverResolveHostNameResponder {
548    control_handle: std::mem::ManuallyDrop<HostNameResolverControlHandle>,
549    tx_id: u32,
550}
551
552/// Set the the channel to be shutdown (see [`HostNameResolverControlHandle::shutdown`])
553/// if the responder is dropped without sending a response, so that the client
554/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
555impl std::ops::Drop for HostNameResolverResolveHostNameResponder {
556    fn drop(&mut self) {
557        self.control_handle.shutdown();
558        // Safety: drops once, never accessed again
559        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
560    }
561}
562
563impl fidl::endpoints::Responder for HostNameResolverResolveHostNameResponder {
564    type ControlHandle = HostNameResolverControlHandle;
565
566    fn control_handle(&self) -> &HostNameResolverControlHandle {
567        &self.control_handle
568    }
569
570    fn drop_without_shutdown(mut self) {
571        // Safety: drops once, never accessed again due to mem::forget
572        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
573        // Prevent Drop from running (which would shut down the channel)
574        std::mem::forget(self);
575    }
576}
577
578impl HostNameResolverResolveHostNameResponder {
579    /// Sends a response to the FIDL transaction.
580    ///
581    /// Sets the channel to shutdown if an error occurs.
582    pub fn send(self, mut addresses: &[HostAddress]) -> Result<(), fidl::Error> {
583        let _result = self.send_raw(addresses);
584        if _result.is_err() {
585            self.control_handle.shutdown();
586        }
587        self.drop_without_shutdown();
588        _result
589    }
590
591    /// Similar to "send" but does not shutdown the channel if an error occurs.
592    pub fn send_no_shutdown_on_err(self, mut addresses: &[HostAddress]) -> Result<(), fidl::Error> {
593        let _result = self.send_raw(addresses);
594        self.drop_without_shutdown();
595        _result
596    }
597
598    fn send_raw(&self, mut addresses: &[HostAddress]) -> Result<(), fidl::Error> {
599        self.control_handle.inner.send::<HostNameResolverResolveHostNameResponse>(
600            (addresses,),
601            self.tx_id,
602            0x54f422692b53c46d,
603            fidl::encoding::DynamicFlags::empty(),
604        )
605    }
606}
607
608#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
609pub struct HostNameSubscriberMarker;
610
611impl fidl::endpoints::ProtocolMarker for HostNameSubscriberMarker {
612    type Proxy = HostNameSubscriberProxy;
613    type RequestStream = HostNameSubscriberRequestStream;
614    #[cfg(target_os = "fuchsia")]
615    type SynchronousProxy = HostNameSubscriberSynchronousProxy;
616
617    const DEBUG_NAME: &'static str = "fuchsia.net.mdns.HostNameSubscriber";
618}
619impl fidl::endpoints::DiscoverableProtocolMarker for HostNameSubscriberMarker {}
620
621pub trait HostNameSubscriberProxyInterface: Send + Sync {
622    fn r#subscribe_to_host_name(
623        &self,
624        host: &str,
625        options: &HostNameSubscriptionOptions,
626        listener: fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
627    ) -> Result<(), fidl::Error>;
628}
629#[derive(Debug)]
630#[cfg(target_os = "fuchsia")]
631pub struct HostNameSubscriberSynchronousProxy {
632    client: fidl::client::sync::Client,
633}
634
635#[cfg(target_os = "fuchsia")]
636impl fidl::endpoints::SynchronousProxy for HostNameSubscriberSynchronousProxy {
637    type Proxy = HostNameSubscriberProxy;
638    type Protocol = HostNameSubscriberMarker;
639
640    fn from_channel(inner: fidl::Channel) -> Self {
641        Self::new(inner)
642    }
643
644    fn into_channel(self) -> fidl::Channel {
645        self.client.into_channel()
646    }
647
648    fn as_channel(&self) -> &fidl::Channel {
649        self.client.as_channel()
650    }
651}
652
653#[cfg(target_os = "fuchsia")]
654impl HostNameSubscriberSynchronousProxy {
655    pub fn new(channel: fidl::Channel) -> Self {
656        Self { client: fidl::client::sync::Client::new(channel) }
657    }
658
659    pub fn into_channel(self) -> fidl::Channel {
660        self.client.into_channel()
661    }
662
663    /// Waits until an event arrives and returns it. It is safe for other
664    /// threads to make concurrent requests while waiting for an event.
665    pub fn wait_for_event(
666        &self,
667        deadline: zx::MonotonicInstant,
668    ) -> Result<HostNameSubscriberEvent, fidl::Error> {
669        HostNameSubscriberEvent::decode(
670            self.client.wait_for_event::<HostNameSubscriberMarker>(deadline)?,
671        )
672    }
673
674    /// Gets the addresses for the specified host.
675    ///
676    /// + request `host` the simple name of the host.
677    /// + request `options` options to be applied to the subscription.
678    /// + request `listener` client end of the `HostNameSubscriptionListener` channel.
679    pub fn r#subscribe_to_host_name(
680        &self,
681        mut host: &str,
682        mut options: &HostNameSubscriptionOptions,
683        mut listener: fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
684    ) -> Result<(), fidl::Error> {
685        self.client.send::<HostNameSubscriberSubscribeToHostNameRequest>(
686            (host, options, listener),
687            0x23b6c5f4954f40ea,
688            fidl::encoding::DynamicFlags::empty(),
689        )
690    }
691}
692
693#[cfg(target_os = "fuchsia")]
694impl From<HostNameSubscriberSynchronousProxy> for zx::NullableHandle {
695    fn from(value: HostNameSubscriberSynchronousProxy) -> Self {
696        value.into_channel().into()
697    }
698}
699
700#[cfg(target_os = "fuchsia")]
701impl From<fidl::Channel> for HostNameSubscriberSynchronousProxy {
702    fn from(value: fidl::Channel) -> Self {
703        Self::new(value)
704    }
705}
706
707#[cfg(target_os = "fuchsia")]
708impl fidl::endpoints::FromClient for HostNameSubscriberSynchronousProxy {
709    type Protocol = HostNameSubscriberMarker;
710
711    fn from_client(value: fidl::endpoints::ClientEnd<HostNameSubscriberMarker>) -> Self {
712        Self::new(value.into_channel())
713    }
714}
715
716#[derive(Debug, Clone)]
717pub struct HostNameSubscriberProxy {
718    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
719}
720
721impl fidl::endpoints::Proxy for HostNameSubscriberProxy {
722    type Protocol = HostNameSubscriberMarker;
723
724    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
725        Self::new(inner)
726    }
727
728    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
729        self.client.into_channel().map_err(|client| Self { client })
730    }
731
732    fn as_channel(&self) -> &::fidl::AsyncChannel {
733        self.client.as_channel()
734    }
735}
736
737impl HostNameSubscriberProxy {
738    /// Create a new Proxy for fuchsia.net.mdns/HostNameSubscriber.
739    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
740        let protocol_name =
741            <HostNameSubscriberMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
742        Self { client: fidl::client::Client::new(channel, protocol_name) }
743    }
744
745    /// Get a Stream of events from the remote end of the protocol.
746    ///
747    /// # Panics
748    ///
749    /// Panics if the event stream was already taken.
750    pub fn take_event_stream(&self) -> HostNameSubscriberEventStream {
751        HostNameSubscriberEventStream { event_receiver: self.client.take_event_receiver() }
752    }
753
754    /// Gets the addresses for the specified host.
755    ///
756    /// + request `host` the simple name of the host.
757    /// + request `options` options to be applied to the subscription.
758    /// + request `listener` client end of the `HostNameSubscriptionListener` channel.
759    pub fn r#subscribe_to_host_name(
760        &self,
761        mut host: &str,
762        mut options: &HostNameSubscriptionOptions,
763        mut listener: fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
764    ) -> Result<(), fidl::Error> {
765        HostNameSubscriberProxyInterface::r#subscribe_to_host_name(self, host, options, listener)
766    }
767}
768
769impl HostNameSubscriberProxyInterface for HostNameSubscriberProxy {
770    fn r#subscribe_to_host_name(
771        &self,
772        mut host: &str,
773        mut options: &HostNameSubscriptionOptions,
774        mut listener: fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
775    ) -> Result<(), fidl::Error> {
776        self.client.send::<HostNameSubscriberSubscribeToHostNameRequest>(
777            (host, options, listener),
778            0x23b6c5f4954f40ea,
779            fidl::encoding::DynamicFlags::empty(),
780        )
781    }
782}
783
784pub struct HostNameSubscriberEventStream {
785    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
786}
787
788impl std::marker::Unpin for HostNameSubscriberEventStream {}
789
790impl futures::stream::FusedStream for HostNameSubscriberEventStream {
791    fn is_terminated(&self) -> bool {
792        self.event_receiver.is_terminated()
793    }
794}
795
796impl futures::Stream for HostNameSubscriberEventStream {
797    type Item = Result<HostNameSubscriberEvent, fidl::Error>;
798
799    fn poll_next(
800        mut self: std::pin::Pin<&mut Self>,
801        cx: &mut std::task::Context<'_>,
802    ) -> std::task::Poll<Option<Self::Item>> {
803        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
804            &mut self.event_receiver,
805            cx
806        )?) {
807            Some(buf) => std::task::Poll::Ready(Some(HostNameSubscriberEvent::decode(buf))),
808            None => std::task::Poll::Ready(None),
809        }
810    }
811}
812
813#[derive(Debug)]
814pub enum HostNameSubscriberEvent {}
815
816impl HostNameSubscriberEvent {
817    /// Decodes a message buffer as a [`HostNameSubscriberEvent`].
818    fn decode(
819        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
820    ) -> Result<HostNameSubscriberEvent, fidl::Error> {
821        let (bytes, _handles) = buf.split_mut();
822        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
823        debug_assert_eq!(tx_header.tx_id, 0);
824        match tx_header.ordinal {
825            _ => Err(fidl::Error::UnknownOrdinal {
826                ordinal: tx_header.ordinal,
827                protocol_name:
828                    <HostNameSubscriberMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
829            }),
830        }
831    }
832}
833
834/// A Stream of incoming requests for fuchsia.net.mdns/HostNameSubscriber.
835pub struct HostNameSubscriberRequestStream {
836    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
837    is_terminated: bool,
838}
839
840impl std::marker::Unpin for HostNameSubscriberRequestStream {}
841
842impl futures::stream::FusedStream for HostNameSubscriberRequestStream {
843    fn is_terminated(&self) -> bool {
844        self.is_terminated
845    }
846}
847
848impl fidl::endpoints::RequestStream for HostNameSubscriberRequestStream {
849    type Protocol = HostNameSubscriberMarker;
850    type ControlHandle = HostNameSubscriberControlHandle;
851
852    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
853        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
854    }
855
856    fn control_handle(&self) -> Self::ControlHandle {
857        HostNameSubscriberControlHandle { inner: self.inner.clone() }
858    }
859
860    fn into_inner(
861        self,
862    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
863    {
864        (self.inner, self.is_terminated)
865    }
866
867    fn from_inner(
868        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
869        is_terminated: bool,
870    ) -> Self {
871        Self { inner, is_terminated }
872    }
873}
874
875impl futures::Stream for HostNameSubscriberRequestStream {
876    type Item = Result<HostNameSubscriberRequest, fidl::Error>;
877
878    fn poll_next(
879        mut self: std::pin::Pin<&mut Self>,
880        cx: &mut std::task::Context<'_>,
881    ) -> std::task::Poll<Option<Self::Item>> {
882        let this = &mut *self;
883        if this.inner.check_shutdown(cx) {
884            this.is_terminated = true;
885            return std::task::Poll::Ready(None);
886        }
887        if this.is_terminated {
888            panic!("polled HostNameSubscriberRequestStream after completion");
889        }
890        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
891            |bytes, handles| {
892                match this.inner.channel().read_etc(cx, bytes, handles) {
893                    std::task::Poll::Ready(Ok(())) => {}
894                    std::task::Poll::Pending => return std::task::Poll::Pending,
895                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
896                        this.is_terminated = true;
897                        return std::task::Poll::Ready(None);
898                    }
899                    std::task::Poll::Ready(Err(e)) => {
900                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
901                            e.into(),
902                        ))));
903                    }
904                }
905
906                // A message has been received from the channel
907                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
908
909                std::task::Poll::Ready(Some(match header.ordinal {
910                0x23b6c5f4954f40ea => {
911                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
912                    let mut req = fidl::new_empty!(HostNameSubscriberSubscribeToHostNameRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
913                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostNameSubscriberSubscribeToHostNameRequest>(&header, _body_bytes, handles, &mut req)?;
914                    let control_handle = HostNameSubscriberControlHandle {
915                        inner: this.inner.clone(),
916                    };
917                    Ok(HostNameSubscriberRequest::SubscribeToHostName {host: req.host,
918options: req.options,
919listener: req.listener,
920
921                        control_handle,
922                    })
923                }
924                _ => Err(fidl::Error::UnknownOrdinal {
925                    ordinal: header.ordinal,
926                    protocol_name: <HostNameSubscriberMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
927                }),
928            }))
929            },
930        )
931    }
932}
933
934/// Discoverable protocol for subscribing to address changes for given host names.
935#[derive(Debug)]
936pub enum HostNameSubscriberRequest {
937    /// Gets the addresses for the specified host.
938    ///
939    /// + request `host` the simple name of the host.
940    /// + request `options` options to be applied to the subscription.
941    /// + request `listener` client end of the `HostNameSubscriptionListener` channel.
942    SubscribeToHostName {
943        host: String,
944        options: HostNameSubscriptionOptions,
945        listener: fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
946        control_handle: HostNameSubscriberControlHandle,
947    },
948}
949
950impl HostNameSubscriberRequest {
951    #[allow(irrefutable_let_patterns)]
952    pub fn into_subscribe_to_host_name(
953        self,
954    ) -> Option<(
955        String,
956        HostNameSubscriptionOptions,
957        fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
958        HostNameSubscriberControlHandle,
959    )> {
960        if let HostNameSubscriberRequest::SubscribeToHostName {
961            host,
962            options,
963            listener,
964            control_handle,
965        } = self
966        {
967            Some((host, options, listener, control_handle))
968        } else {
969            None
970        }
971    }
972
973    /// Name of the method defined in FIDL
974    pub fn method_name(&self) -> &'static str {
975        match *self {
976            HostNameSubscriberRequest::SubscribeToHostName { .. } => "subscribe_to_host_name",
977        }
978    }
979}
980
981#[derive(Debug, Clone)]
982pub struct HostNameSubscriberControlHandle {
983    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
984}
985
986impl fidl::endpoints::ControlHandle for HostNameSubscriberControlHandle {
987    fn shutdown(&self) {
988        self.inner.shutdown()
989    }
990
991    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
992        self.inner.shutdown_with_epitaph(status)
993    }
994
995    fn is_closed(&self) -> bool {
996        self.inner.channel().is_closed()
997    }
998    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
999        self.inner.channel().on_closed()
1000    }
1001
1002    #[cfg(target_os = "fuchsia")]
1003    fn signal_peer(
1004        &self,
1005        clear_mask: zx::Signals,
1006        set_mask: zx::Signals,
1007    ) -> Result<(), zx_status::Status> {
1008        use fidl::Peered;
1009        self.inner.channel().signal_peer(clear_mask, set_mask)
1010    }
1011}
1012
1013impl HostNameSubscriberControlHandle {}
1014
1015#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1016pub struct HostNameSubscriptionListenerMarker;
1017
1018impl fidl::endpoints::ProtocolMarker for HostNameSubscriptionListenerMarker {
1019    type Proxy = HostNameSubscriptionListenerProxy;
1020    type RequestStream = HostNameSubscriptionListenerRequestStream;
1021    #[cfg(target_os = "fuchsia")]
1022    type SynchronousProxy = HostNameSubscriptionListenerSynchronousProxy;
1023
1024    const DEBUG_NAME: &'static str = "(anonymous) HostNameSubscriptionListener";
1025}
1026
1027pub trait HostNameSubscriptionListenerProxyInterface: Send + Sync {
1028    type OnAddressesChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1029    fn r#on_addresses_changed(
1030        &self,
1031        addresses: &[HostAddress],
1032    ) -> Self::OnAddressesChangedResponseFut;
1033}
1034#[derive(Debug)]
1035#[cfg(target_os = "fuchsia")]
1036pub struct HostNameSubscriptionListenerSynchronousProxy {
1037    client: fidl::client::sync::Client,
1038}
1039
1040#[cfg(target_os = "fuchsia")]
1041impl fidl::endpoints::SynchronousProxy for HostNameSubscriptionListenerSynchronousProxy {
1042    type Proxy = HostNameSubscriptionListenerProxy;
1043    type Protocol = HostNameSubscriptionListenerMarker;
1044
1045    fn from_channel(inner: fidl::Channel) -> Self {
1046        Self::new(inner)
1047    }
1048
1049    fn into_channel(self) -> fidl::Channel {
1050        self.client.into_channel()
1051    }
1052
1053    fn as_channel(&self) -> &fidl::Channel {
1054        self.client.as_channel()
1055    }
1056}
1057
1058#[cfg(target_os = "fuchsia")]
1059impl HostNameSubscriptionListenerSynchronousProxy {
1060    pub fn new(channel: fidl::Channel) -> Self {
1061        Self { client: fidl::client::sync::Client::new(channel) }
1062    }
1063
1064    pub fn into_channel(self) -> fidl::Channel {
1065        self.client.into_channel()
1066    }
1067
1068    /// Waits until an event arrives and returns it. It is safe for other
1069    /// threads to make concurrent requests while waiting for an event.
1070    pub fn wait_for_event(
1071        &self,
1072        deadline: zx::MonotonicInstant,
1073    ) -> Result<HostNameSubscriptionListenerEvent, fidl::Error> {
1074        HostNameSubscriptionListenerEvent::decode(
1075            self.client.wait_for_event::<HostNameSubscriptionListenerMarker>(deadline)?,
1076        )
1077    }
1078
1079    /// Notifies the subscriber that the addresses associated with a host name have changed.
1080    pub fn r#on_addresses_changed(
1081        &self,
1082        mut addresses: &[HostAddress],
1083        ___deadline: zx::MonotonicInstant,
1084    ) -> Result<(), fidl::Error> {
1085        let _response = self.client.send_query::<
1086            HostNameSubscriptionListenerOnAddressesChangedRequest,
1087            fidl::encoding::EmptyPayload,
1088            HostNameSubscriptionListenerMarker,
1089        >(
1090            (addresses,),
1091            0x44f5e70b2e8c1472,
1092            fidl::encoding::DynamicFlags::empty(),
1093            ___deadline,
1094        )?;
1095        Ok(_response)
1096    }
1097}
1098
1099#[cfg(target_os = "fuchsia")]
1100impl From<HostNameSubscriptionListenerSynchronousProxy> for zx::NullableHandle {
1101    fn from(value: HostNameSubscriptionListenerSynchronousProxy) -> Self {
1102        value.into_channel().into()
1103    }
1104}
1105
1106#[cfg(target_os = "fuchsia")]
1107impl From<fidl::Channel> for HostNameSubscriptionListenerSynchronousProxy {
1108    fn from(value: fidl::Channel) -> Self {
1109        Self::new(value)
1110    }
1111}
1112
1113#[cfg(target_os = "fuchsia")]
1114impl fidl::endpoints::FromClient for HostNameSubscriptionListenerSynchronousProxy {
1115    type Protocol = HostNameSubscriptionListenerMarker;
1116
1117    fn from_client(value: fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>) -> Self {
1118        Self::new(value.into_channel())
1119    }
1120}
1121
1122#[derive(Debug, Clone)]
1123pub struct HostNameSubscriptionListenerProxy {
1124    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1125}
1126
1127impl fidl::endpoints::Proxy for HostNameSubscriptionListenerProxy {
1128    type Protocol = HostNameSubscriptionListenerMarker;
1129
1130    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1131        Self::new(inner)
1132    }
1133
1134    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1135        self.client.into_channel().map_err(|client| Self { client })
1136    }
1137
1138    fn as_channel(&self) -> &::fidl::AsyncChannel {
1139        self.client.as_channel()
1140    }
1141}
1142
1143impl HostNameSubscriptionListenerProxy {
1144    /// Create a new Proxy for fuchsia.net.mdns/HostNameSubscriptionListener.
1145    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1146        let protocol_name =
1147            <HostNameSubscriptionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1148        Self { client: fidl::client::Client::new(channel, protocol_name) }
1149    }
1150
1151    /// Get a Stream of events from the remote end of the protocol.
1152    ///
1153    /// # Panics
1154    ///
1155    /// Panics if the event stream was already taken.
1156    pub fn take_event_stream(&self) -> HostNameSubscriptionListenerEventStream {
1157        HostNameSubscriptionListenerEventStream {
1158            event_receiver: self.client.take_event_receiver(),
1159        }
1160    }
1161
1162    /// Notifies the subscriber that the addresses associated with a host name have changed.
1163    pub fn r#on_addresses_changed(
1164        &self,
1165        mut addresses: &[HostAddress],
1166    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1167        HostNameSubscriptionListenerProxyInterface::r#on_addresses_changed(self, addresses)
1168    }
1169}
1170
1171impl HostNameSubscriptionListenerProxyInterface for HostNameSubscriptionListenerProxy {
1172    type OnAddressesChangedResponseFut =
1173        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1174    fn r#on_addresses_changed(
1175        &self,
1176        mut addresses: &[HostAddress],
1177    ) -> Self::OnAddressesChangedResponseFut {
1178        fn _decode(
1179            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1180        ) -> Result<(), fidl::Error> {
1181            let _response = fidl::client::decode_transaction_body::<
1182                fidl::encoding::EmptyPayload,
1183                fidl::encoding::DefaultFuchsiaResourceDialect,
1184                0x44f5e70b2e8c1472,
1185            >(_buf?)?;
1186            Ok(_response)
1187        }
1188        self.client
1189            .send_query_and_decode::<HostNameSubscriptionListenerOnAddressesChangedRequest, ()>(
1190                (addresses,),
1191                0x44f5e70b2e8c1472,
1192                fidl::encoding::DynamicFlags::empty(),
1193                _decode,
1194            )
1195    }
1196}
1197
1198pub struct HostNameSubscriptionListenerEventStream {
1199    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1200}
1201
1202impl std::marker::Unpin for HostNameSubscriptionListenerEventStream {}
1203
1204impl futures::stream::FusedStream for HostNameSubscriptionListenerEventStream {
1205    fn is_terminated(&self) -> bool {
1206        self.event_receiver.is_terminated()
1207    }
1208}
1209
1210impl futures::Stream for HostNameSubscriptionListenerEventStream {
1211    type Item = Result<HostNameSubscriptionListenerEvent, fidl::Error>;
1212
1213    fn poll_next(
1214        mut self: std::pin::Pin<&mut Self>,
1215        cx: &mut std::task::Context<'_>,
1216    ) -> std::task::Poll<Option<Self::Item>> {
1217        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1218            &mut self.event_receiver,
1219            cx
1220        )?) {
1221            Some(buf) => {
1222                std::task::Poll::Ready(Some(HostNameSubscriptionListenerEvent::decode(buf)))
1223            }
1224            None => std::task::Poll::Ready(None),
1225        }
1226    }
1227}
1228
1229#[derive(Debug)]
1230pub enum HostNameSubscriptionListenerEvent {}
1231
1232impl HostNameSubscriptionListenerEvent {
1233    /// Decodes a message buffer as a [`HostNameSubscriptionListenerEvent`].
1234    fn decode(
1235        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1236    ) -> Result<HostNameSubscriptionListenerEvent, fidl::Error> {
1237        let (bytes, _handles) = buf.split_mut();
1238        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1239        debug_assert_eq!(tx_header.tx_id, 0);
1240        match tx_header.ordinal {
1241            _ => Err(fidl::Error::UnknownOrdinal {
1242                ordinal: tx_header.ordinal,
1243                protocol_name: <HostNameSubscriptionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1244            })
1245        }
1246    }
1247}
1248
1249/// A Stream of incoming requests for fuchsia.net.mdns/HostNameSubscriptionListener.
1250pub struct HostNameSubscriptionListenerRequestStream {
1251    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1252    is_terminated: bool,
1253}
1254
1255impl std::marker::Unpin for HostNameSubscriptionListenerRequestStream {}
1256
1257impl futures::stream::FusedStream for HostNameSubscriptionListenerRequestStream {
1258    fn is_terminated(&self) -> bool {
1259        self.is_terminated
1260    }
1261}
1262
1263impl fidl::endpoints::RequestStream for HostNameSubscriptionListenerRequestStream {
1264    type Protocol = HostNameSubscriptionListenerMarker;
1265    type ControlHandle = HostNameSubscriptionListenerControlHandle;
1266
1267    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1268        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1269    }
1270
1271    fn control_handle(&self) -> Self::ControlHandle {
1272        HostNameSubscriptionListenerControlHandle { inner: self.inner.clone() }
1273    }
1274
1275    fn into_inner(
1276        self,
1277    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1278    {
1279        (self.inner, self.is_terminated)
1280    }
1281
1282    fn from_inner(
1283        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1284        is_terminated: bool,
1285    ) -> Self {
1286        Self { inner, is_terminated }
1287    }
1288}
1289
1290impl futures::Stream for HostNameSubscriptionListenerRequestStream {
1291    type Item = Result<HostNameSubscriptionListenerRequest, fidl::Error>;
1292
1293    fn poll_next(
1294        mut self: std::pin::Pin<&mut Self>,
1295        cx: &mut std::task::Context<'_>,
1296    ) -> std::task::Poll<Option<Self::Item>> {
1297        let this = &mut *self;
1298        if this.inner.check_shutdown(cx) {
1299            this.is_terminated = true;
1300            return std::task::Poll::Ready(None);
1301        }
1302        if this.is_terminated {
1303            panic!("polled HostNameSubscriptionListenerRequestStream after completion");
1304        }
1305        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1306            |bytes, handles| {
1307                match this.inner.channel().read_etc(cx, bytes, handles) {
1308                    std::task::Poll::Ready(Ok(())) => {}
1309                    std::task::Poll::Pending => return std::task::Poll::Pending,
1310                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1311                        this.is_terminated = true;
1312                        return std::task::Poll::Ready(None);
1313                    }
1314                    std::task::Poll::Ready(Err(e)) => {
1315                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1316                            e.into(),
1317                        ))));
1318                    }
1319                }
1320
1321                // A message has been received from the channel
1322                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1323
1324                std::task::Poll::Ready(Some(match header.ordinal {
1325                0x44f5e70b2e8c1472 => {
1326                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1327                    let mut req = fidl::new_empty!(HostNameSubscriptionListenerOnAddressesChangedRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1328                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostNameSubscriptionListenerOnAddressesChangedRequest>(&header, _body_bytes, handles, &mut req)?;
1329                    let control_handle = HostNameSubscriptionListenerControlHandle {
1330                        inner: this.inner.clone(),
1331                    };
1332                    Ok(HostNameSubscriptionListenerRequest::OnAddressesChanged {addresses: req.addresses,
1333
1334                        responder: HostNameSubscriptionListenerOnAddressesChangedResponder {
1335                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1336                            tx_id: header.tx_id,
1337                        },
1338                    })
1339                }
1340                _ => Err(fidl::Error::UnknownOrdinal {
1341                    ordinal: header.ordinal,
1342                    protocol_name: <HostNameSubscriptionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1343                }),
1344            }))
1345            },
1346        )
1347    }
1348}
1349
1350/// Client-implemented interface for subscribers. Method replies are used to
1351/// throttle traffic. The service won't necessarily wait for a reply before
1352/// calling another method.
1353#[derive(Debug)]
1354pub enum HostNameSubscriptionListenerRequest {
1355    /// Notifies the subscriber that the addresses associated with a host name have changed.
1356    OnAddressesChanged {
1357        addresses: Vec<HostAddress>,
1358        responder: HostNameSubscriptionListenerOnAddressesChangedResponder,
1359    },
1360}
1361
1362impl HostNameSubscriptionListenerRequest {
1363    #[allow(irrefutable_let_patterns)]
1364    pub fn into_on_addresses_changed(
1365        self,
1366    ) -> Option<(Vec<HostAddress>, HostNameSubscriptionListenerOnAddressesChangedResponder)> {
1367        if let HostNameSubscriptionListenerRequest::OnAddressesChanged { addresses, responder } =
1368            self
1369        {
1370            Some((addresses, responder))
1371        } else {
1372            None
1373        }
1374    }
1375
1376    /// Name of the method defined in FIDL
1377    pub fn method_name(&self) -> &'static str {
1378        match *self {
1379            HostNameSubscriptionListenerRequest::OnAddressesChanged { .. } => {
1380                "on_addresses_changed"
1381            }
1382        }
1383    }
1384}
1385
1386#[derive(Debug, Clone)]
1387pub struct HostNameSubscriptionListenerControlHandle {
1388    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1389}
1390
1391impl fidl::endpoints::ControlHandle for HostNameSubscriptionListenerControlHandle {
1392    fn shutdown(&self) {
1393        self.inner.shutdown()
1394    }
1395
1396    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1397        self.inner.shutdown_with_epitaph(status)
1398    }
1399
1400    fn is_closed(&self) -> bool {
1401        self.inner.channel().is_closed()
1402    }
1403    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1404        self.inner.channel().on_closed()
1405    }
1406
1407    #[cfg(target_os = "fuchsia")]
1408    fn signal_peer(
1409        &self,
1410        clear_mask: zx::Signals,
1411        set_mask: zx::Signals,
1412    ) -> Result<(), zx_status::Status> {
1413        use fidl::Peered;
1414        self.inner.channel().signal_peer(clear_mask, set_mask)
1415    }
1416}
1417
1418impl HostNameSubscriptionListenerControlHandle {}
1419
1420#[must_use = "FIDL methods require a response to be sent"]
1421#[derive(Debug)]
1422pub struct HostNameSubscriptionListenerOnAddressesChangedResponder {
1423    control_handle: std::mem::ManuallyDrop<HostNameSubscriptionListenerControlHandle>,
1424    tx_id: u32,
1425}
1426
1427/// Set the the channel to be shutdown (see [`HostNameSubscriptionListenerControlHandle::shutdown`])
1428/// if the responder is dropped without sending a response, so that the client
1429/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1430impl std::ops::Drop for HostNameSubscriptionListenerOnAddressesChangedResponder {
1431    fn drop(&mut self) {
1432        self.control_handle.shutdown();
1433        // Safety: drops once, never accessed again
1434        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1435    }
1436}
1437
1438impl fidl::endpoints::Responder for HostNameSubscriptionListenerOnAddressesChangedResponder {
1439    type ControlHandle = HostNameSubscriptionListenerControlHandle;
1440
1441    fn control_handle(&self) -> &HostNameSubscriptionListenerControlHandle {
1442        &self.control_handle
1443    }
1444
1445    fn drop_without_shutdown(mut self) {
1446        // Safety: drops once, never accessed again due to mem::forget
1447        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1448        // Prevent Drop from running (which would shut down the channel)
1449        std::mem::forget(self);
1450    }
1451}
1452
1453impl HostNameSubscriptionListenerOnAddressesChangedResponder {
1454    /// Sends a response to the FIDL transaction.
1455    ///
1456    /// Sets the channel to shutdown if an error occurs.
1457    pub fn send(self) -> Result<(), fidl::Error> {
1458        let _result = self.send_raw();
1459        if _result.is_err() {
1460            self.control_handle.shutdown();
1461        }
1462        self.drop_without_shutdown();
1463        _result
1464    }
1465
1466    /// Similar to "send" but does not shutdown the channel if an error occurs.
1467    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1468        let _result = self.send_raw();
1469        self.drop_without_shutdown();
1470        _result
1471    }
1472
1473    fn send_raw(&self) -> Result<(), fidl::Error> {
1474        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1475            (),
1476            self.tx_id,
1477            0x44f5e70b2e8c1472,
1478            fidl::encoding::DynamicFlags::empty(),
1479        )
1480    }
1481}
1482
1483#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1484pub struct ProxyHostPublisherMarker;
1485
1486impl fidl::endpoints::ProtocolMarker for ProxyHostPublisherMarker {
1487    type Proxy = ProxyHostPublisherProxy;
1488    type RequestStream = ProxyHostPublisherRequestStream;
1489    #[cfg(target_os = "fuchsia")]
1490    type SynchronousProxy = ProxyHostPublisherSynchronousProxy;
1491
1492    const DEBUG_NAME: &'static str = "fuchsia.net.mdns.ProxyHostPublisher";
1493}
1494impl fidl::endpoints::DiscoverableProtocolMarker for ProxyHostPublisherMarker {}
1495pub type ProxyHostPublisherPublishProxyHostResult = Result<(), PublishProxyHostError>;
1496
1497pub trait ProxyHostPublisherProxyInterface: Send + Sync {
1498    type PublishProxyHostResponseFut: std::future::Future<Output = Result<ProxyHostPublisherPublishProxyHostResult, fidl::Error>>
1499        + Send;
1500    fn r#publish_proxy_host(
1501        &self,
1502        host: &str,
1503        addresses: &[fidl_fuchsia_net::IpAddress],
1504        options: &ProxyHostPublicationOptions,
1505        service_instance_publisher: fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
1506    ) -> Self::PublishProxyHostResponseFut;
1507}
1508#[derive(Debug)]
1509#[cfg(target_os = "fuchsia")]
1510pub struct ProxyHostPublisherSynchronousProxy {
1511    client: fidl::client::sync::Client,
1512}
1513
1514#[cfg(target_os = "fuchsia")]
1515impl fidl::endpoints::SynchronousProxy for ProxyHostPublisherSynchronousProxy {
1516    type Proxy = ProxyHostPublisherProxy;
1517    type Protocol = ProxyHostPublisherMarker;
1518
1519    fn from_channel(inner: fidl::Channel) -> Self {
1520        Self::new(inner)
1521    }
1522
1523    fn into_channel(self) -> fidl::Channel {
1524        self.client.into_channel()
1525    }
1526
1527    fn as_channel(&self) -> &fidl::Channel {
1528        self.client.as_channel()
1529    }
1530}
1531
1532#[cfg(target_os = "fuchsia")]
1533impl ProxyHostPublisherSynchronousProxy {
1534    pub fn new(channel: fidl::Channel) -> Self {
1535        Self { client: fidl::client::sync::Client::new(channel) }
1536    }
1537
1538    pub fn into_channel(self) -> fidl::Channel {
1539        self.client.into_channel()
1540    }
1541
1542    /// Waits until an event arrives and returns it. It is safe for other
1543    /// threads to make concurrent requests while waiting for an event.
1544    pub fn wait_for_event(
1545        &self,
1546        deadline: zx::MonotonicInstant,
1547    ) -> Result<ProxyHostPublisherEvent, fidl::Error> {
1548        ProxyHostPublisherEvent::decode(
1549            self.client.wait_for_event::<ProxyHostPublisherMarker>(deadline)?,
1550        )
1551    }
1552
1553    /// Publishes a host name on behalf of a remote host and provides a `ServiceInstancePublisher`
1554    /// for publishing service instances on behalf of that host.
1555    ///
1556    /// + request `host` host name to publish.
1557    /// + request `addresses` addresses to publish for the host name.
1558    /// + request `options` options to be applied to the publication.
1559    /// + request `service_instance_publisher` server end of the `ServiceInstancePublisher` for
1560    ///   the proxied host.
1561    ///
1562    /// This method causes the service to publish the host name at the specified addresses. The
1563    /// actual host must not be present on any relevant links or there will be a conflict. If
1564    /// the `perform_probe` option is true or not supplied (true by default), a probe will occur
1565    /// to verify that the host name isn't otherwise published.
1566    ///
1567    /// The proxy host created by this method persists until the `ServiceInstancePublisher`
1568    /// channel is closed.
1569    pub fn r#publish_proxy_host(
1570        &self,
1571        mut host: &str,
1572        mut addresses: &[fidl_fuchsia_net::IpAddress],
1573        mut options: &ProxyHostPublicationOptions,
1574        mut service_instance_publisher: fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
1575        ___deadline: zx::MonotonicInstant,
1576    ) -> Result<ProxyHostPublisherPublishProxyHostResult, fidl::Error> {
1577        let _response = self.client.send_query::<
1578            ProxyHostPublisherPublishProxyHostRequest,
1579            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PublishProxyHostError>,
1580            ProxyHostPublisherMarker,
1581        >(
1582            (host, addresses, options, service_instance_publisher,),
1583            0x639bfff950f973c2,
1584            fidl::encoding::DynamicFlags::empty(),
1585            ___deadline,
1586        )?;
1587        Ok(_response.map(|x| x))
1588    }
1589}
1590
1591#[cfg(target_os = "fuchsia")]
1592impl From<ProxyHostPublisherSynchronousProxy> for zx::NullableHandle {
1593    fn from(value: ProxyHostPublisherSynchronousProxy) -> Self {
1594        value.into_channel().into()
1595    }
1596}
1597
1598#[cfg(target_os = "fuchsia")]
1599impl From<fidl::Channel> for ProxyHostPublisherSynchronousProxy {
1600    fn from(value: fidl::Channel) -> Self {
1601        Self::new(value)
1602    }
1603}
1604
1605#[cfg(target_os = "fuchsia")]
1606impl fidl::endpoints::FromClient for ProxyHostPublisherSynchronousProxy {
1607    type Protocol = ProxyHostPublisherMarker;
1608
1609    fn from_client(value: fidl::endpoints::ClientEnd<ProxyHostPublisherMarker>) -> Self {
1610        Self::new(value.into_channel())
1611    }
1612}
1613
1614#[derive(Debug, Clone)]
1615pub struct ProxyHostPublisherProxy {
1616    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1617}
1618
1619impl fidl::endpoints::Proxy for ProxyHostPublisherProxy {
1620    type Protocol = ProxyHostPublisherMarker;
1621
1622    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1623        Self::new(inner)
1624    }
1625
1626    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1627        self.client.into_channel().map_err(|client| Self { client })
1628    }
1629
1630    fn as_channel(&self) -> &::fidl::AsyncChannel {
1631        self.client.as_channel()
1632    }
1633}
1634
1635impl ProxyHostPublisherProxy {
1636    /// Create a new Proxy for fuchsia.net.mdns/ProxyHostPublisher.
1637    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1638        let protocol_name =
1639            <ProxyHostPublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1640        Self { client: fidl::client::Client::new(channel, protocol_name) }
1641    }
1642
1643    /// Get a Stream of events from the remote end of the protocol.
1644    ///
1645    /// # Panics
1646    ///
1647    /// Panics if the event stream was already taken.
1648    pub fn take_event_stream(&self) -> ProxyHostPublisherEventStream {
1649        ProxyHostPublisherEventStream { event_receiver: self.client.take_event_receiver() }
1650    }
1651
1652    /// Publishes a host name on behalf of a remote host and provides a `ServiceInstancePublisher`
1653    /// for publishing service instances on behalf of that host.
1654    ///
1655    /// + request `host` host name to publish.
1656    /// + request `addresses` addresses to publish for the host name.
1657    /// + request `options` options to be applied to the publication.
1658    /// + request `service_instance_publisher` server end of the `ServiceInstancePublisher` for
1659    ///   the proxied host.
1660    ///
1661    /// This method causes the service to publish the host name at the specified addresses. The
1662    /// actual host must not be present on any relevant links or there will be a conflict. If
1663    /// the `perform_probe` option is true or not supplied (true by default), a probe will occur
1664    /// to verify that the host name isn't otherwise published.
1665    ///
1666    /// The proxy host created by this method persists until the `ServiceInstancePublisher`
1667    /// channel is closed.
1668    pub fn r#publish_proxy_host(
1669        &self,
1670        mut host: &str,
1671        mut addresses: &[fidl_fuchsia_net::IpAddress],
1672        mut options: &ProxyHostPublicationOptions,
1673        mut service_instance_publisher: fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
1674    ) -> fidl::client::QueryResponseFut<
1675        ProxyHostPublisherPublishProxyHostResult,
1676        fidl::encoding::DefaultFuchsiaResourceDialect,
1677    > {
1678        ProxyHostPublisherProxyInterface::r#publish_proxy_host(
1679            self,
1680            host,
1681            addresses,
1682            options,
1683            service_instance_publisher,
1684        )
1685    }
1686}
1687
1688impl ProxyHostPublisherProxyInterface for ProxyHostPublisherProxy {
1689    type PublishProxyHostResponseFut = fidl::client::QueryResponseFut<
1690        ProxyHostPublisherPublishProxyHostResult,
1691        fidl::encoding::DefaultFuchsiaResourceDialect,
1692    >;
1693    fn r#publish_proxy_host(
1694        &self,
1695        mut host: &str,
1696        mut addresses: &[fidl_fuchsia_net::IpAddress],
1697        mut options: &ProxyHostPublicationOptions,
1698        mut service_instance_publisher: fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
1699    ) -> Self::PublishProxyHostResponseFut {
1700        fn _decode(
1701            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1702        ) -> Result<ProxyHostPublisherPublishProxyHostResult, fidl::Error> {
1703            let _response = fidl::client::decode_transaction_body::<
1704                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PublishProxyHostError>,
1705                fidl::encoding::DefaultFuchsiaResourceDialect,
1706                0x639bfff950f973c2,
1707            >(_buf?)?;
1708            Ok(_response.map(|x| x))
1709        }
1710        self.client.send_query_and_decode::<
1711            ProxyHostPublisherPublishProxyHostRequest,
1712            ProxyHostPublisherPublishProxyHostResult,
1713        >(
1714            (host, addresses, options, service_instance_publisher,),
1715            0x639bfff950f973c2,
1716            fidl::encoding::DynamicFlags::empty(),
1717            _decode,
1718        )
1719    }
1720}
1721
1722pub struct ProxyHostPublisherEventStream {
1723    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1724}
1725
1726impl std::marker::Unpin for ProxyHostPublisherEventStream {}
1727
1728impl futures::stream::FusedStream for ProxyHostPublisherEventStream {
1729    fn is_terminated(&self) -> bool {
1730        self.event_receiver.is_terminated()
1731    }
1732}
1733
1734impl futures::Stream for ProxyHostPublisherEventStream {
1735    type Item = Result<ProxyHostPublisherEvent, fidl::Error>;
1736
1737    fn poll_next(
1738        mut self: std::pin::Pin<&mut Self>,
1739        cx: &mut std::task::Context<'_>,
1740    ) -> std::task::Poll<Option<Self::Item>> {
1741        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1742            &mut self.event_receiver,
1743            cx
1744        )?) {
1745            Some(buf) => std::task::Poll::Ready(Some(ProxyHostPublisherEvent::decode(buf))),
1746            None => std::task::Poll::Ready(None),
1747        }
1748    }
1749}
1750
1751#[derive(Debug)]
1752pub enum ProxyHostPublisherEvent {}
1753
1754impl ProxyHostPublisherEvent {
1755    /// Decodes a message buffer as a [`ProxyHostPublisherEvent`].
1756    fn decode(
1757        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1758    ) -> Result<ProxyHostPublisherEvent, fidl::Error> {
1759        let (bytes, _handles) = buf.split_mut();
1760        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1761        debug_assert_eq!(tx_header.tx_id, 0);
1762        match tx_header.ordinal {
1763            _ => Err(fidl::Error::UnknownOrdinal {
1764                ordinal: tx_header.ordinal,
1765                protocol_name:
1766                    <ProxyHostPublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1767            }),
1768        }
1769    }
1770}
1771
1772/// A Stream of incoming requests for fuchsia.net.mdns/ProxyHostPublisher.
1773pub struct ProxyHostPublisherRequestStream {
1774    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1775    is_terminated: bool,
1776}
1777
1778impl std::marker::Unpin for ProxyHostPublisherRequestStream {}
1779
1780impl futures::stream::FusedStream for ProxyHostPublisherRequestStream {
1781    fn is_terminated(&self) -> bool {
1782        self.is_terminated
1783    }
1784}
1785
1786impl fidl::endpoints::RequestStream for ProxyHostPublisherRequestStream {
1787    type Protocol = ProxyHostPublisherMarker;
1788    type ControlHandle = ProxyHostPublisherControlHandle;
1789
1790    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1791        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1792    }
1793
1794    fn control_handle(&self) -> Self::ControlHandle {
1795        ProxyHostPublisherControlHandle { inner: self.inner.clone() }
1796    }
1797
1798    fn into_inner(
1799        self,
1800    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1801    {
1802        (self.inner, self.is_terminated)
1803    }
1804
1805    fn from_inner(
1806        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1807        is_terminated: bool,
1808    ) -> Self {
1809        Self { inner, is_terminated }
1810    }
1811}
1812
1813impl futures::Stream for ProxyHostPublisherRequestStream {
1814    type Item = Result<ProxyHostPublisherRequest, fidl::Error>;
1815
1816    fn poll_next(
1817        mut self: std::pin::Pin<&mut Self>,
1818        cx: &mut std::task::Context<'_>,
1819    ) -> std::task::Poll<Option<Self::Item>> {
1820        let this = &mut *self;
1821        if this.inner.check_shutdown(cx) {
1822            this.is_terminated = true;
1823            return std::task::Poll::Ready(None);
1824        }
1825        if this.is_terminated {
1826            panic!("polled ProxyHostPublisherRequestStream after completion");
1827        }
1828        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1829            |bytes, handles| {
1830                match this.inner.channel().read_etc(cx, bytes, handles) {
1831                    std::task::Poll::Ready(Ok(())) => {}
1832                    std::task::Poll::Pending => return std::task::Poll::Pending,
1833                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1834                        this.is_terminated = true;
1835                        return std::task::Poll::Ready(None);
1836                    }
1837                    std::task::Poll::Ready(Err(e)) => {
1838                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1839                            e.into(),
1840                        ))));
1841                    }
1842                }
1843
1844                // A message has been received from the channel
1845                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1846
1847                std::task::Poll::Ready(Some(match header.ordinal {
1848                0x639bfff950f973c2 => {
1849                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1850                    let mut req = fidl::new_empty!(ProxyHostPublisherPublishProxyHostRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1851                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProxyHostPublisherPublishProxyHostRequest>(&header, _body_bytes, handles, &mut req)?;
1852                    let control_handle = ProxyHostPublisherControlHandle {
1853                        inner: this.inner.clone(),
1854                    };
1855                    Ok(ProxyHostPublisherRequest::PublishProxyHost {host: req.host,
1856addresses: req.addresses,
1857options: req.options,
1858service_instance_publisher: req.service_instance_publisher,
1859
1860                        responder: ProxyHostPublisherPublishProxyHostResponder {
1861                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1862                            tx_id: header.tx_id,
1863                        },
1864                    })
1865                }
1866                _ => Err(fidl::Error::UnknownOrdinal {
1867                    ordinal: header.ordinal,
1868                    protocol_name: <ProxyHostPublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1869                }),
1870            }))
1871            },
1872        )
1873    }
1874}
1875
1876/// Discoverable protocol for publishing on behalf of another host.
1877#[derive(Debug)]
1878pub enum ProxyHostPublisherRequest {
1879    /// Publishes a host name on behalf of a remote host and provides a `ServiceInstancePublisher`
1880    /// for publishing service instances on behalf of that host.
1881    ///
1882    /// + request `host` host name to publish.
1883    /// + request `addresses` addresses to publish for the host name.
1884    /// + request `options` options to be applied to the publication.
1885    /// + request `service_instance_publisher` server end of the `ServiceInstancePublisher` for
1886    ///   the proxied host.
1887    ///
1888    /// This method causes the service to publish the host name at the specified addresses. The
1889    /// actual host must not be present on any relevant links or there will be a conflict. If
1890    /// the `perform_probe` option is true or not supplied (true by default), a probe will occur
1891    /// to verify that the host name isn't otherwise published.
1892    ///
1893    /// The proxy host created by this method persists until the `ServiceInstancePublisher`
1894    /// channel is closed.
1895    PublishProxyHost {
1896        host: String,
1897        addresses: Vec<fidl_fuchsia_net::IpAddress>,
1898        options: ProxyHostPublicationOptions,
1899        service_instance_publisher: fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
1900        responder: ProxyHostPublisherPublishProxyHostResponder,
1901    },
1902}
1903
1904impl ProxyHostPublisherRequest {
1905    #[allow(irrefutable_let_patterns)]
1906    pub fn into_publish_proxy_host(
1907        self,
1908    ) -> Option<(
1909        String,
1910        Vec<fidl_fuchsia_net::IpAddress>,
1911        ProxyHostPublicationOptions,
1912        fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
1913        ProxyHostPublisherPublishProxyHostResponder,
1914    )> {
1915        if let ProxyHostPublisherRequest::PublishProxyHost {
1916            host,
1917            addresses,
1918            options,
1919            service_instance_publisher,
1920            responder,
1921        } = self
1922        {
1923            Some((host, addresses, options, service_instance_publisher, responder))
1924        } else {
1925            None
1926        }
1927    }
1928
1929    /// Name of the method defined in FIDL
1930    pub fn method_name(&self) -> &'static str {
1931        match *self {
1932            ProxyHostPublisherRequest::PublishProxyHost { .. } => "publish_proxy_host",
1933        }
1934    }
1935}
1936
1937#[derive(Debug, Clone)]
1938pub struct ProxyHostPublisherControlHandle {
1939    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1940}
1941
1942impl fidl::endpoints::ControlHandle for ProxyHostPublisherControlHandle {
1943    fn shutdown(&self) {
1944        self.inner.shutdown()
1945    }
1946
1947    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1948        self.inner.shutdown_with_epitaph(status)
1949    }
1950
1951    fn is_closed(&self) -> bool {
1952        self.inner.channel().is_closed()
1953    }
1954    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1955        self.inner.channel().on_closed()
1956    }
1957
1958    #[cfg(target_os = "fuchsia")]
1959    fn signal_peer(
1960        &self,
1961        clear_mask: zx::Signals,
1962        set_mask: zx::Signals,
1963    ) -> Result<(), zx_status::Status> {
1964        use fidl::Peered;
1965        self.inner.channel().signal_peer(clear_mask, set_mask)
1966    }
1967}
1968
1969impl ProxyHostPublisherControlHandle {}
1970
1971#[must_use = "FIDL methods require a response to be sent"]
1972#[derive(Debug)]
1973pub struct ProxyHostPublisherPublishProxyHostResponder {
1974    control_handle: std::mem::ManuallyDrop<ProxyHostPublisherControlHandle>,
1975    tx_id: u32,
1976}
1977
1978/// Set the the channel to be shutdown (see [`ProxyHostPublisherControlHandle::shutdown`])
1979/// if the responder is dropped without sending a response, so that the client
1980/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1981impl std::ops::Drop for ProxyHostPublisherPublishProxyHostResponder {
1982    fn drop(&mut self) {
1983        self.control_handle.shutdown();
1984        // Safety: drops once, never accessed again
1985        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1986    }
1987}
1988
1989impl fidl::endpoints::Responder for ProxyHostPublisherPublishProxyHostResponder {
1990    type ControlHandle = ProxyHostPublisherControlHandle;
1991
1992    fn control_handle(&self) -> &ProxyHostPublisherControlHandle {
1993        &self.control_handle
1994    }
1995
1996    fn drop_without_shutdown(mut self) {
1997        // Safety: drops once, never accessed again due to mem::forget
1998        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1999        // Prevent Drop from running (which would shut down the channel)
2000        std::mem::forget(self);
2001    }
2002}
2003
2004impl ProxyHostPublisherPublishProxyHostResponder {
2005    /// Sends a response to the FIDL transaction.
2006    ///
2007    /// Sets the channel to shutdown if an error occurs.
2008    pub fn send(self, mut result: Result<(), PublishProxyHostError>) -> Result<(), fidl::Error> {
2009        let _result = self.send_raw(result);
2010        if _result.is_err() {
2011            self.control_handle.shutdown();
2012        }
2013        self.drop_without_shutdown();
2014        _result
2015    }
2016
2017    /// Similar to "send" but does not shutdown the channel if an error occurs.
2018    pub fn send_no_shutdown_on_err(
2019        self,
2020        mut result: Result<(), PublishProxyHostError>,
2021    ) -> Result<(), fidl::Error> {
2022        let _result = self.send_raw(result);
2023        self.drop_without_shutdown();
2024        _result
2025    }
2026
2027    fn send_raw(&self, mut result: Result<(), PublishProxyHostError>) -> Result<(), fidl::Error> {
2028        self.control_handle.inner.send::<fidl::encoding::ResultType<
2029            fidl::encoding::EmptyStruct,
2030            PublishProxyHostError,
2031        >>(
2032            result,
2033            self.tx_id,
2034            0x639bfff950f973c2,
2035            fidl::encoding::DynamicFlags::empty(),
2036        )
2037    }
2038}
2039
2040#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2041pub struct PublicationResponder_Marker;
2042
2043impl fidl::endpoints::ProtocolMarker for PublicationResponder_Marker {
2044    type Proxy = PublicationResponder_Proxy;
2045    type RequestStream = PublicationResponder_RequestStream;
2046    #[cfg(target_os = "fuchsia")]
2047    type SynchronousProxy = PublicationResponder_SynchronousProxy;
2048
2049    const DEBUG_NAME: &'static str = "(anonymous) PublicationResponder_";
2050}
2051
2052pub trait PublicationResponder_ProxyInterface: Send + Sync {
2053    type OnPublicationResponseFut: std::future::Future<Output = Result<Option<Box<Publication>>, fidl::Error>>
2054        + Send;
2055    fn r#on_publication(
2056        &self,
2057        publication_cause: PublicationCause,
2058        subtype: Option<&str>,
2059        source_addresses: &[fidl_fuchsia_net::IpAddress],
2060    ) -> Self::OnPublicationResponseFut;
2061}
2062#[derive(Debug)]
2063#[cfg(target_os = "fuchsia")]
2064pub struct PublicationResponder_SynchronousProxy {
2065    client: fidl::client::sync::Client,
2066}
2067
2068#[cfg(target_os = "fuchsia")]
2069impl fidl::endpoints::SynchronousProxy for PublicationResponder_SynchronousProxy {
2070    type Proxy = PublicationResponder_Proxy;
2071    type Protocol = PublicationResponder_Marker;
2072
2073    fn from_channel(inner: fidl::Channel) -> Self {
2074        Self::new(inner)
2075    }
2076
2077    fn into_channel(self) -> fidl::Channel {
2078        self.client.into_channel()
2079    }
2080
2081    fn as_channel(&self) -> &fidl::Channel {
2082        self.client.as_channel()
2083    }
2084}
2085
2086#[cfg(target_os = "fuchsia")]
2087impl PublicationResponder_SynchronousProxy {
2088    pub fn new(channel: fidl::Channel) -> Self {
2089        Self { client: fidl::client::sync::Client::new(channel) }
2090    }
2091
2092    pub fn into_channel(self) -> fidl::Channel {
2093        self.client.into_channel()
2094    }
2095
2096    /// Waits until an event arrives and returns it. It is safe for other
2097    /// threads to make concurrent requests while waiting for an event.
2098    pub fn wait_for_event(
2099        &self,
2100        deadline: zx::MonotonicInstant,
2101    ) -> Result<PublicationResponder_Event, fidl::Error> {
2102        PublicationResponder_Event::decode(
2103            self.client.wait_for_event::<PublicationResponder_Marker>(deadline)?,
2104        )
2105    }
2106
2107    /// Provides instance information for initial announcements and query
2108    /// responses relating to the service instance specified in
2109    /// `ServiceInstancePublisher.PublishServiceInstance`.  If the publication relates to a
2110    /// subtype of the service, `subtype` contains the subtype, otherwise
2111    /// it is null. If `publication` is null, no announcement or response is
2112    /// transmitted. Strings in `text` are transmitted in the TXT record.
2113    pub fn r#on_publication(
2114        &self,
2115        mut publication_cause: PublicationCause,
2116        mut subtype: Option<&str>,
2117        mut source_addresses: &[fidl_fuchsia_net::IpAddress],
2118        ___deadline: zx::MonotonicInstant,
2119    ) -> Result<Option<Box<Publication>>, fidl::Error> {
2120        let _response = self.client.send_query::<
2121            PublicationResponderOnPublicationRequest,
2122            PublicationResponderOnPublicationResponse,
2123            PublicationResponder_Marker,
2124        >(
2125            (publication_cause, subtype, source_addresses,),
2126            0x71d805aee2907d06,
2127            fidl::encoding::DynamicFlags::empty(),
2128            ___deadline,
2129        )?;
2130        Ok(_response.publication)
2131    }
2132}
2133
2134#[cfg(target_os = "fuchsia")]
2135impl From<PublicationResponder_SynchronousProxy> for zx::NullableHandle {
2136    fn from(value: PublicationResponder_SynchronousProxy) -> Self {
2137        value.into_channel().into()
2138    }
2139}
2140
2141#[cfg(target_os = "fuchsia")]
2142impl From<fidl::Channel> for PublicationResponder_SynchronousProxy {
2143    fn from(value: fidl::Channel) -> Self {
2144        Self::new(value)
2145    }
2146}
2147
2148#[cfg(target_os = "fuchsia")]
2149impl fidl::endpoints::FromClient for PublicationResponder_SynchronousProxy {
2150    type Protocol = PublicationResponder_Marker;
2151
2152    fn from_client(value: fidl::endpoints::ClientEnd<PublicationResponder_Marker>) -> Self {
2153        Self::new(value.into_channel())
2154    }
2155}
2156
2157#[derive(Debug, Clone)]
2158pub struct PublicationResponder_Proxy {
2159    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2160}
2161
2162impl fidl::endpoints::Proxy for PublicationResponder_Proxy {
2163    type Protocol = PublicationResponder_Marker;
2164
2165    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2166        Self::new(inner)
2167    }
2168
2169    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2170        self.client.into_channel().map_err(|client| Self { client })
2171    }
2172
2173    fn as_channel(&self) -> &::fidl::AsyncChannel {
2174        self.client.as_channel()
2175    }
2176}
2177
2178impl PublicationResponder_Proxy {
2179    /// Create a new Proxy for fuchsia.net.mdns/PublicationResponder.
2180    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2181        let protocol_name =
2182            <PublicationResponder_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2183        Self { client: fidl::client::Client::new(channel, protocol_name) }
2184    }
2185
2186    /// Get a Stream of events from the remote end of the protocol.
2187    ///
2188    /// # Panics
2189    ///
2190    /// Panics if the event stream was already taken.
2191    pub fn take_event_stream(&self) -> PublicationResponder_EventStream {
2192        PublicationResponder_EventStream { event_receiver: self.client.take_event_receiver() }
2193    }
2194
2195    /// Provides instance information for initial announcements and query
2196    /// responses relating to the service instance specified in
2197    /// `ServiceInstancePublisher.PublishServiceInstance`.  If the publication relates to a
2198    /// subtype of the service, `subtype` contains the subtype, otherwise
2199    /// it is null. If `publication` is null, no announcement or response is
2200    /// transmitted. Strings in `text` are transmitted in the TXT record.
2201    pub fn r#on_publication(
2202        &self,
2203        mut publication_cause: PublicationCause,
2204        mut subtype: Option<&str>,
2205        mut source_addresses: &[fidl_fuchsia_net::IpAddress],
2206    ) -> fidl::client::QueryResponseFut<
2207        Option<Box<Publication>>,
2208        fidl::encoding::DefaultFuchsiaResourceDialect,
2209    > {
2210        PublicationResponder_ProxyInterface::r#on_publication(
2211            self,
2212            publication_cause,
2213            subtype,
2214            source_addresses,
2215        )
2216    }
2217}
2218
2219impl PublicationResponder_ProxyInterface for PublicationResponder_Proxy {
2220    type OnPublicationResponseFut = fidl::client::QueryResponseFut<
2221        Option<Box<Publication>>,
2222        fidl::encoding::DefaultFuchsiaResourceDialect,
2223    >;
2224    fn r#on_publication(
2225        &self,
2226        mut publication_cause: PublicationCause,
2227        mut subtype: Option<&str>,
2228        mut source_addresses: &[fidl_fuchsia_net::IpAddress],
2229    ) -> Self::OnPublicationResponseFut {
2230        fn _decode(
2231            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2232        ) -> Result<Option<Box<Publication>>, fidl::Error> {
2233            let _response = fidl::client::decode_transaction_body::<
2234                PublicationResponderOnPublicationResponse,
2235                fidl::encoding::DefaultFuchsiaResourceDialect,
2236                0x71d805aee2907d06,
2237            >(_buf?)?;
2238            Ok(_response.publication)
2239        }
2240        self.client.send_query_and_decode::<
2241            PublicationResponderOnPublicationRequest,
2242            Option<Box<Publication>>,
2243        >(
2244            (publication_cause, subtype, source_addresses,),
2245            0x71d805aee2907d06,
2246            fidl::encoding::DynamicFlags::empty(),
2247            _decode,
2248        )
2249    }
2250}
2251
2252pub struct PublicationResponder_EventStream {
2253    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2254}
2255
2256impl std::marker::Unpin for PublicationResponder_EventStream {}
2257
2258impl futures::stream::FusedStream for PublicationResponder_EventStream {
2259    fn is_terminated(&self) -> bool {
2260        self.event_receiver.is_terminated()
2261    }
2262}
2263
2264impl futures::Stream for PublicationResponder_EventStream {
2265    type Item = Result<PublicationResponder_Event, fidl::Error>;
2266
2267    fn poll_next(
2268        mut self: std::pin::Pin<&mut Self>,
2269        cx: &mut std::task::Context<'_>,
2270    ) -> std::task::Poll<Option<Self::Item>> {
2271        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2272            &mut self.event_receiver,
2273            cx
2274        )?) {
2275            Some(buf) => std::task::Poll::Ready(Some(PublicationResponder_Event::decode(buf))),
2276            None => std::task::Poll::Ready(None),
2277        }
2278    }
2279}
2280
2281#[derive(Debug)]
2282pub enum PublicationResponder_Event {
2283    SetSubtypes { subtypes: Vec<String> },
2284    Reannounce {},
2285}
2286
2287impl PublicationResponder_Event {
2288    #[allow(irrefutable_let_patterns)]
2289    pub fn into_set_subtypes(self) -> Option<Vec<String>> {
2290        if let PublicationResponder_Event::SetSubtypes { subtypes } = self {
2291            Some((subtypes))
2292        } else {
2293            None
2294        }
2295    }
2296    #[allow(irrefutable_let_patterns)]
2297    pub fn into_reannounce(self) -> Option<()> {
2298        if let PublicationResponder_Event::Reannounce {} = self { Some(()) } else { None }
2299    }
2300
2301    /// Decodes a message buffer as a [`PublicationResponder_Event`].
2302    fn decode(
2303        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2304    ) -> Result<PublicationResponder_Event, fidl::Error> {
2305        let (bytes, _handles) = buf.split_mut();
2306        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2307        debug_assert_eq!(tx_header.tx_id, 0);
2308        match tx_header.ordinal {
2309            0x5593e156370b19df => {
2310                let mut out = fidl::new_empty!(
2311                    PublicationResponderSetSubtypesRequest,
2312                    fidl::encoding::DefaultFuchsiaResourceDialect
2313                );
2314                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PublicationResponderSetSubtypesRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2315                Ok((PublicationResponder_Event::SetSubtypes { subtypes: out.subtypes }))
2316            }
2317            0x2550cc2a43aa838b => {
2318                let mut out = fidl::new_empty!(
2319                    fidl::encoding::EmptyPayload,
2320                    fidl::encoding::DefaultFuchsiaResourceDialect
2321                );
2322                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2323                Ok((PublicationResponder_Event::Reannounce {}))
2324            }
2325            _ => Err(fidl::Error::UnknownOrdinal {
2326                ordinal: tx_header.ordinal,
2327                protocol_name:
2328                    <PublicationResponder_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2329            }),
2330        }
2331    }
2332}
2333
2334/// A Stream of incoming requests for fuchsia.net.mdns/PublicationResponder.
2335pub struct PublicationResponder_RequestStream {
2336    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2337    is_terminated: bool,
2338}
2339
2340impl std::marker::Unpin for PublicationResponder_RequestStream {}
2341
2342impl futures::stream::FusedStream for PublicationResponder_RequestStream {
2343    fn is_terminated(&self) -> bool {
2344        self.is_terminated
2345    }
2346}
2347
2348impl fidl::endpoints::RequestStream for PublicationResponder_RequestStream {
2349    type Protocol = PublicationResponder_Marker;
2350    type ControlHandle = PublicationResponder_ControlHandle;
2351
2352    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2353        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2354    }
2355
2356    fn control_handle(&self) -> Self::ControlHandle {
2357        PublicationResponder_ControlHandle { inner: self.inner.clone() }
2358    }
2359
2360    fn into_inner(
2361        self,
2362    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2363    {
2364        (self.inner, self.is_terminated)
2365    }
2366
2367    fn from_inner(
2368        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2369        is_terminated: bool,
2370    ) -> Self {
2371        Self { inner, is_terminated }
2372    }
2373}
2374
2375impl futures::Stream for PublicationResponder_RequestStream {
2376    type Item = Result<PublicationResponder_Request, fidl::Error>;
2377
2378    fn poll_next(
2379        mut self: std::pin::Pin<&mut Self>,
2380        cx: &mut std::task::Context<'_>,
2381    ) -> std::task::Poll<Option<Self::Item>> {
2382        let this = &mut *self;
2383        if this.inner.check_shutdown(cx) {
2384            this.is_terminated = true;
2385            return std::task::Poll::Ready(None);
2386        }
2387        if this.is_terminated {
2388            panic!("polled PublicationResponder_RequestStream after completion");
2389        }
2390        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2391            |bytes, handles| {
2392                match this.inner.channel().read_etc(cx, bytes, handles) {
2393                    std::task::Poll::Ready(Ok(())) => {}
2394                    std::task::Poll::Pending => return std::task::Poll::Pending,
2395                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2396                        this.is_terminated = true;
2397                        return std::task::Poll::Ready(None);
2398                    }
2399                    std::task::Poll::Ready(Err(e)) => {
2400                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2401                            e.into(),
2402                        ))));
2403                    }
2404                }
2405
2406                // A message has been received from the channel
2407                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2408
2409                std::task::Poll::Ready(Some(match header.ordinal {
2410                0x71d805aee2907d06 => {
2411                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2412                    let mut req = fidl::new_empty!(PublicationResponderOnPublicationRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2413                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PublicationResponderOnPublicationRequest>(&header, _body_bytes, handles, &mut req)?;
2414                    let control_handle = PublicationResponder_ControlHandle {
2415                        inner: this.inner.clone(),
2416                    };
2417                    Ok(PublicationResponder_Request::OnPublication {publication_cause: req.publication_cause,
2418subtype: req.subtype,
2419source_addresses: req.source_addresses,
2420
2421                        responder: PublicationResponder_OnPublicationResponder {
2422                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2423                            tx_id: header.tx_id,
2424                        },
2425                    })
2426                }
2427                _ => Err(fidl::Error::UnknownOrdinal {
2428                    ordinal: header.ordinal,
2429                    protocol_name: <PublicationResponder_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2430                }),
2431            }))
2432            },
2433        )
2434    }
2435}
2436
2437/// Client-supplied publication responder interface.
2438#[derive(Debug)]
2439pub enum PublicationResponder_Request {
2440    /// Provides instance information for initial announcements and query
2441    /// responses relating to the service instance specified in
2442    /// `ServiceInstancePublisher.PublishServiceInstance`.  If the publication relates to a
2443    /// subtype of the service, `subtype` contains the subtype, otherwise
2444    /// it is null. If `publication` is null, no announcement or response is
2445    /// transmitted. Strings in `text` are transmitted in the TXT record.
2446    OnPublication {
2447        publication_cause: PublicationCause,
2448        subtype: Option<String>,
2449        source_addresses: Vec<fidl_fuchsia_net::IpAddress>,
2450        responder: PublicationResponder_OnPublicationResponder,
2451    },
2452}
2453
2454impl PublicationResponder_Request {
2455    #[allow(irrefutable_let_patterns)]
2456    pub fn into_on_publication(
2457        self,
2458    ) -> Option<(
2459        PublicationCause,
2460        Option<String>,
2461        Vec<fidl_fuchsia_net::IpAddress>,
2462        PublicationResponder_OnPublicationResponder,
2463    )> {
2464        if let PublicationResponder_Request::OnPublication {
2465            publication_cause,
2466            subtype,
2467            source_addresses,
2468            responder,
2469        } = self
2470        {
2471            Some((publication_cause, subtype, source_addresses, responder))
2472        } else {
2473            None
2474        }
2475    }
2476
2477    /// Name of the method defined in FIDL
2478    pub fn method_name(&self) -> &'static str {
2479        match *self {
2480            PublicationResponder_Request::OnPublication { .. } => "on_publication",
2481        }
2482    }
2483}
2484
2485#[derive(Debug, Clone)]
2486pub struct PublicationResponder_ControlHandle {
2487    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2488}
2489
2490impl fidl::endpoints::ControlHandle for PublicationResponder_ControlHandle {
2491    fn shutdown(&self) {
2492        self.inner.shutdown()
2493    }
2494
2495    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2496        self.inner.shutdown_with_epitaph(status)
2497    }
2498
2499    fn is_closed(&self) -> bool {
2500        self.inner.channel().is_closed()
2501    }
2502    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2503        self.inner.channel().on_closed()
2504    }
2505
2506    #[cfg(target_os = "fuchsia")]
2507    fn signal_peer(
2508        &self,
2509        clear_mask: zx::Signals,
2510        set_mask: zx::Signals,
2511    ) -> Result<(), zx_status::Status> {
2512        use fidl::Peered;
2513        self.inner.channel().signal_peer(clear_mask, set_mask)
2514    }
2515}
2516
2517impl PublicationResponder_ControlHandle {
2518    pub fn send_set_subtypes(&self, mut subtypes: &[String]) -> Result<(), fidl::Error> {
2519        self.inner.send::<PublicationResponderSetSubtypesRequest>(
2520            (subtypes,),
2521            0,
2522            0x5593e156370b19df,
2523            fidl::encoding::DynamicFlags::empty(),
2524        )
2525    }
2526
2527    pub fn send_reannounce(&self) -> Result<(), fidl::Error> {
2528        self.inner.send::<fidl::encoding::EmptyPayload>(
2529            (),
2530            0,
2531            0x2550cc2a43aa838b,
2532            fidl::encoding::DynamicFlags::empty(),
2533        )
2534    }
2535}
2536
2537#[must_use = "FIDL methods require a response to be sent"]
2538#[derive(Debug)]
2539pub struct PublicationResponder_OnPublicationResponder {
2540    control_handle: std::mem::ManuallyDrop<PublicationResponder_ControlHandle>,
2541    tx_id: u32,
2542}
2543
2544/// Set the the channel to be shutdown (see [`PublicationResponder_ControlHandle::shutdown`])
2545/// if the responder is dropped without sending a response, so that the client
2546/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2547impl std::ops::Drop for PublicationResponder_OnPublicationResponder {
2548    fn drop(&mut self) {
2549        self.control_handle.shutdown();
2550        // Safety: drops once, never accessed again
2551        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2552    }
2553}
2554
2555impl fidl::endpoints::Responder for PublicationResponder_OnPublicationResponder {
2556    type ControlHandle = PublicationResponder_ControlHandle;
2557
2558    fn control_handle(&self) -> &PublicationResponder_ControlHandle {
2559        &self.control_handle
2560    }
2561
2562    fn drop_without_shutdown(mut self) {
2563        // Safety: drops once, never accessed again due to mem::forget
2564        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2565        // Prevent Drop from running (which would shut down the channel)
2566        std::mem::forget(self);
2567    }
2568}
2569
2570impl PublicationResponder_OnPublicationResponder {
2571    /// Sends a response to the FIDL transaction.
2572    ///
2573    /// Sets the channel to shutdown if an error occurs.
2574    pub fn send(self, mut publication: Option<&Publication>) -> Result<(), fidl::Error> {
2575        let _result = self.send_raw(publication);
2576        if _result.is_err() {
2577            self.control_handle.shutdown();
2578        }
2579        self.drop_without_shutdown();
2580        _result
2581    }
2582
2583    /// Similar to "send" but does not shutdown the channel if an error occurs.
2584    pub fn send_no_shutdown_on_err(
2585        self,
2586        mut publication: Option<&Publication>,
2587    ) -> Result<(), fidl::Error> {
2588        let _result = self.send_raw(publication);
2589        self.drop_without_shutdown();
2590        _result
2591    }
2592
2593    fn send_raw(&self, mut publication: Option<&Publication>) -> Result<(), fidl::Error> {
2594        self.control_handle.inner.send::<PublicationResponderOnPublicationResponse>(
2595            (publication,),
2596            self.tx_id,
2597            0x71d805aee2907d06,
2598            fidl::encoding::DynamicFlags::empty(),
2599        )
2600    }
2601}
2602
2603#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2604pub struct PublisherMarker;
2605
2606impl fidl::endpoints::ProtocolMarker for PublisherMarker {
2607    type Proxy = PublisherProxy;
2608    type RequestStream = PublisherRequestStream;
2609    #[cfg(target_os = "fuchsia")]
2610    type SynchronousProxy = PublisherSynchronousProxy;
2611
2612    const DEBUG_NAME: &'static str = "fuchsia.net.mdns.Publisher";
2613}
2614impl fidl::endpoints::DiscoverableProtocolMarker for PublisherMarker {}
2615pub type PublisherPublishServiceInstanceResult = Result<(), Error>;
2616
2617pub trait PublisherProxyInterface: Send + Sync {
2618    type PublishServiceInstanceResponseFut: std::future::Future<Output = Result<PublisherPublishServiceInstanceResult, fidl::Error>>
2619        + Send;
2620    fn r#publish_service_instance(
2621        &self,
2622        service: &str,
2623        instance: &str,
2624        media: Media,
2625        perform_probe: bool,
2626        publication_responder: fidl::endpoints::ClientEnd<PublicationResponder_Marker>,
2627    ) -> Self::PublishServiceInstanceResponseFut;
2628}
2629#[derive(Debug)]
2630#[cfg(target_os = "fuchsia")]
2631pub struct PublisherSynchronousProxy {
2632    client: fidl::client::sync::Client,
2633}
2634
2635#[cfg(target_os = "fuchsia")]
2636impl fidl::endpoints::SynchronousProxy for PublisherSynchronousProxy {
2637    type Proxy = PublisherProxy;
2638    type Protocol = PublisherMarker;
2639
2640    fn from_channel(inner: fidl::Channel) -> Self {
2641        Self::new(inner)
2642    }
2643
2644    fn into_channel(self) -> fidl::Channel {
2645        self.client.into_channel()
2646    }
2647
2648    fn as_channel(&self) -> &fidl::Channel {
2649        self.client.as_channel()
2650    }
2651}
2652
2653#[cfg(target_os = "fuchsia")]
2654impl PublisherSynchronousProxy {
2655    pub fn new(channel: fidl::Channel) -> Self {
2656        Self { client: fidl::client::sync::Client::new(channel) }
2657    }
2658
2659    pub fn into_channel(self) -> fidl::Channel {
2660        self.client.into_channel()
2661    }
2662
2663    /// Waits until an event arrives and returns it. It is safe for other
2664    /// threads to make concurrent requests while waiting for an event.
2665    pub fn wait_for_event(
2666        &self,
2667        deadline: zx::MonotonicInstant,
2668    ) -> Result<PublisherEvent, fidl::Error> {
2669        PublisherEvent::decode(self.client.wait_for_event::<PublisherMarker>(deadline)?)
2670    }
2671
2672    /// Publishes a service instance. `publication_responder` is consulted via its
2673    /// `OnPublication` method for initial announcements and to answer queries.
2674    /// The service is published until the `publication_responder` channel closes. In
2675    /// addition to announcements and queries for the service type, all queries
2676    /// for subtypes are answered subject to filtering through the responder.
2677    /// `perform_probe` indicates whether a probe for a conflicting instance
2678    /// should be performed before publishing the instance. This value should
2679    /// be `true` unless the instance name is known to be unique.
2680    ///
2681    /// If a service with the same service and instance names is already published, the
2682    /// old publication will be terminated, and the responder channel for the old
2683    /// publication will be closed.
2684    pub fn r#publish_service_instance(
2685        &self,
2686        mut service: &str,
2687        mut instance: &str,
2688        mut media: Media,
2689        mut perform_probe: bool,
2690        mut publication_responder: fidl::endpoints::ClientEnd<PublicationResponder_Marker>,
2691        ___deadline: zx::MonotonicInstant,
2692    ) -> Result<PublisherPublishServiceInstanceResult, fidl::Error> {
2693        let _response = self.client.send_query::<
2694            PublisherPublishServiceInstanceRequest,
2695            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2696            PublisherMarker,
2697        >(
2698            (service, instance, media, perform_probe, publication_responder,),
2699            0x3712171c42878797,
2700            fidl::encoding::DynamicFlags::empty(),
2701            ___deadline,
2702        )?;
2703        Ok(_response.map(|x| x))
2704    }
2705}
2706
2707#[cfg(target_os = "fuchsia")]
2708impl From<PublisherSynchronousProxy> for zx::NullableHandle {
2709    fn from(value: PublisherSynchronousProxy) -> Self {
2710        value.into_channel().into()
2711    }
2712}
2713
2714#[cfg(target_os = "fuchsia")]
2715impl From<fidl::Channel> for PublisherSynchronousProxy {
2716    fn from(value: fidl::Channel) -> Self {
2717        Self::new(value)
2718    }
2719}
2720
2721#[cfg(target_os = "fuchsia")]
2722impl fidl::endpoints::FromClient for PublisherSynchronousProxy {
2723    type Protocol = PublisherMarker;
2724
2725    fn from_client(value: fidl::endpoints::ClientEnd<PublisherMarker>) -> Self {
2726        Self::new(value.into_channel())
2727    }
2728}
2729
2730#[derive(Debug, Clone)]
2731pub struct PublisherProxy {
2732    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2733}
2734
2735impl fidl::endpoints::Proxy for PublisherProxy {
2736    type Protocol = PublisherMarker;
2737
2738    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2739        Self::new(inner)
2740    }
2741
2742    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2743        self.client.into_channel().map_err(|client| Self { client })
2744    }
2745
2746    fn as_channel(&self) -> &::fidl::AsyncChannel {
2747        self.client.as_channel()
2748    }
2749}
2750
2751impl PublisherProxy {
2752    /// Create a new Proxy for fuchsia.net.mdns/Publisher.
2753    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2754        let protocol_name = <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2755        Self { client: fidl::client::Client::new(channel, protocol_name) }
2756    }
2757
2758    /// Get a Stream of events from the remote end of the protocol.
2759    ///
2760    /// # Panics
2761    ///
2762    /// Panics if the event stream was already taken.
2763    pub fn take_event_stream(&self) -> PublisherEventStream {
2764        PublisherEventStream { event_receiver: self.client.take_event_receiver() }
2765    }
2766
2767    /// Publishes a service instance. `publication_responder` is consulted via its
2768    /// `OnPublication` method for initial announcements and to answer queries.
2769    /// The service is published until the `publication_responder` channel closes. In
2770    /// addition to announcements and queries for the service type, all queries
2771    /// for subtypes are answered subject to filtering through the responder.
2772    /// `perform_probe` indicates whether a probe for a conflicting instance
2773    /// should be performed before publishing the instance. This value should
2774    /// be `true` unless the instance name is known to be unique.
2775    ///
2776    /// If a service with the same service and instance names is already published, the
2777    /// old publication will be terminated, and the responder channel for the old
2778    /// publication will be closed.
2779    pub fn r#publish_service_instance(
2780        &self,
2781        mut service: &str,
2782        mut instance: &str,
2783        mut media: Media,
2784        mut perform_probe: bool,
2785        mut publication_responder: fidl::endpoints::ClientEnd<PublicationResponder_Marker>,
2786    ) -> fidl::client::QueryResponseFut<
2787        PublisherPublishServiceInstanceResult,
2788        fidl::encoding::DefaultFuchsiaResourceDialect,
2789    > {
2790        PublisherProxyInterface::r#publish_service_instance(
2791            self,
2792            service,
2793            instance,
2794            media,
2795            perform_probe,
2796            publication_responder,
2797        )
2798    }
2799}
2800
2801impl PublisherProxyInterface for PublisherProxy {
2802    type PublishServiceInstanceResponseFut = fidl::client::QueryResponseFut<
2803        PublisherPublishServiceInstanceResult,
2804        fidl::encoding::DefaultFuchsiaResourceDialect,
2805    >;
2806    fn r#publish_service_instance(
2807        &self,
2808        mut service: &str,
2809        mut instance: &str,
2810        mut media: Media,
2811        mut perform_probe: bool,
2812        mut publication_responder: fidl::endpoints::ClientEnd<PublicationResponder_Marker>,
2813    ) -> Self::PublishServiceInstanceResponseFut {
2814        fn _decode(
2815            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2816        ) -> Result<PublisherPublishServiceInstanceResult, fidl::Error> {
2817            let _response = fidl::client::decode_transaction_body::<
2818                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2819                fidl::encoding::DefaultFuchsiaResourceDialect,
2820                0x3712171c42878797,
2821            >(_buf?)?;
2822            Ok(_response.map(|x| x))
2823        }
2824        self.client.send_query_and_decode::<
2825            PublisherPublishServiceInstanceRequest,
2826            PublisherPublishServiceInstanceResult,
2827        >(
2828            (service, instance, media, perform_probe, publication_responder,),
2829            0x3712171c42878797,
2830            fidl::encoding::DynamicFlags::empty(),
2831            _decode,
2832        )
2833    }
2834}
2835
2836pub struct PublisherEventStream {
2837    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2838}
2839
2840impl std::marker::Unpin for PublisherEventStream {}
2841
2842impl futures::stream::FusedStream for PublisherEventStream {
2843    fn is_terminated(&self) -> bool {
2844        self.event_receiver.is_terminated()
2845    }
2846}
2847
2848impl futures::Stream for PublisherEventStream {
2849    type Item = Result<PublisherEvent, fidl::Error>;
2850
2851    fn poll_next(
2852        mut self: std::pin::Pin<&mut Self>,
2853        cx: &mut std::task::Context<'_>,
2854    ) -> std::task::Poll<Option<Self::Item>> {
2855        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2856            &mut self.event_receiver,
2857            cx
2858        )?) {
2859            Some(buf) => std::task::Poll::Ready(Some(PublisherEvent::decode(buf))),
2860            None => std::task::Poll::Ready(None),
2861        }
2862    }
2863}
2864
2865#[derive(Debug)]
2866pub enum PublisherEvent {}
2867
2868impl PublisherEvent {
2869    /// Decodes a message buffer as a [`PublisherEvent`].
2870    fn decode(
2871        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2872    ) -> Result<PublisherEvent, fidl::Error> {
2873        let (bytes, _handles) = buf.split_mut();
2874        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2875        debug_assert_eq!(tx_header.tx_id, 0);
2876        match tx_header.ordinal {
2877            _ => Err(fidl::Error::UnknownOrdinal {
2878                ordinal: tx_header.ordinal,
2879                protocol_name: <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2880            }),
2881        }
2882    }
2883}
2884
2885/// A Stream of incoming requests for fuchsia.net.mdns/Publisher.
2886pub struct PublisherRequestStream {
2887    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2888    is_terminated: bool,
2889}
2890
2891impl std::marker::Unpin for PublisherRequestStream {}
2892
2893impl futures::stream::FusedStream for PublisherRequestStream {
2894    fn is_terminated(&self) -> bool {
2895        self.is_terminated
2896    }
2897}
2898
2899impl fidl::endpoints::RequestStream for PublisherRequestStream {
2900    type Protocol = PublisherMarker;
2901    type ControlHandle = PublisherControlHandle;
2902
2903    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2904        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2905    }
2906
2907    fn control_handle(&self) -> Self::ControlHandle {
2908        PublisherControlHandle { inner: self.inner.clone() }
2909    }
2910
2911    fn into_inner(
2912        self,
2913    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2914    {
2915        (self.inner, self.is_terminated)
2916    }
2917
2918    fn from_inner(
2919        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2920        is_terminated: bool,
2921    ) -> Self {
2922        Self { inner, is_terminated }
2923    }
2924}
2925
2926impl futures::Stream for PublisherRequestStream {
2927    type Item = Result<PublisherRequest, fidl::Error>;
2928
2929    fn poll_next(
2930        mut self: std::pin::Pin<&mut Self>,
2931        cx: &mut std::task::Context<'_>,
2932    ) -> std::task::Poll<Option<Self::Item>> {
2933        let this = &mut *self;
2934        if this.inner.check_shutdown(cx) {
2935            this.is_terminated = true;
2936            return std::task::Poll::Ready(None);
2937        }
2938        if this.is_terminated {
2939            panic!("polled PublisherRequestStream after completion");
2940        }
2941        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2942            |bytes, handles| {
2943                match this.inner.channel().read_etc(cx, bytes, handles) {
2944                    std::task::Poll::Ready(Ok(())) => {}
2945                    std::task::Poll::Pending => return std::task::Poll::Pending,
2946                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2947                        this.is_terminated = true;
2948                        return std::task::Poll::Ready(None);
2949                    }
2950                    std::task::Poll::Ready(Err(e)) => {
2951                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2952                            e.into(),
2953                        ))));
2954                    }
2955                }
2956
2957                // A message has been received from the channel
2958                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2959
2960                std::task::Poll::Ready(Some(match header.ordinal {
2961                    0x3712171c42878797 => {
2962                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2963                        let mut req = fidl::new_empty!(
2964                            PublisherPublishServiceInstanceRequest,
2965                            fidl::encoding::DefaultFuchsiaResourceDialect
2966                        );
2967                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PublisherPublishServiceInstanceRequest>(&header, _body_bytes, handles, &mut req)?;
2968                        let control_handle = PublisherControlHandle { inner: this.inner.clone() };
2969                        Ok(PublisherRequest::PublishServiceInstance {
2970                            service: req.service,
2971                            instance: req.instance,
2972                            media: req.media,
2973                            perform_probe: req.perform_probe,
2974                            publication_responder: req.publication_responder,
2975
2976                            responder: PublisherPublishServiceInstanceResponder {
2977                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2978                                tx_id: header.tx_id,
2979                            },
2980                        })
2981                    }
2982                    _ => Err(fidl::Error::UnknownOrdinal {
2983                        ordinal: header.ordinal,
2984                        protocol_name:
2985                            <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2986                    }),
2987                }))
2988            },
2989        )
2990    }
2991}
2992
2993/// Discoverable protocol for publishing service instances.
2994/// Deprecated: use ServiceInstancePublisher.
2995#[derive(Debug)]
2996pub enum PublisherRequest {
2997    /// Publishes a service instance. `publication_responder` is consulted via its
2998    /// `OnPublication` method for initial announcements and to answer queries.
2999    /// The service is published until the `publication_responder` channel closes. In
3000    /// addition to announcements and queries for the service type, all queries
3001    /// for subtypes are answered subject to filtering through the responder.
3002    /// `perform_probe` indicates whether a probe for a conflicting instance
3003    /// should be performed before publishing the instance. This value should
3004    /// be `true` unless the instance name is known to be unique.
3005    ///
3006    /// If a service with the same service and instance names is already published, the
3007    /// old publication will be terminated, and the responder channel for the old
3008    /// publication will be closed.
3009    PublishServiceInstance {
3010        service: String,
3011        instance: String,
3012        media: Media,
3013        perform_probe: bool,
3014        publication_responder: fidl::endpoints::ClientEnd<PublicationResponder_Marker>,
3015        responder: PublisherPublishServiceInstanceResponder,
3016    },
3017}
3018
3019impl PublisherRequest {
3020    #[allow(irrefutable_let_patterns)]
3021    pub fn into_publish_service_instance(
3022        self,
3023    ) -> Option<(
3024        String,
3025        String,
3026        Media,
3027        bool,
3028        fidl::endpoints::ClientEnd<PublicationResponder_Marker>,
3029        PublisherPublishServiceInstanceResponder,
3030    )> {
3031        if let PublisherRequest::PublishServiceInstance {
3032            service,
3033            instance,
3034            media,
3035            perform_probe,
3036            publication_responder,
3037            responder,
3038        } = self
3039        {
3040            Some((service, instance, media, perform_probe, publication_responder, responder))
3041        } else {
3042            None
3043        }
3044    }
3045
3046    /// Name of the method defined in FIDL
3047    pub fn method_name(&self) -> &'static str {
3048        match *self {
3049            PublisherRequest::PublishServiceInstance { .. } => "publish_service_instance",
3050        }
3051    }
3052}
3053
3054#[derive(Debug, Clone)]
3055pub struct PublisherControlHandle {
3056    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3057}
3058
3059impl fidl::endpoints::ControlHandle for PublisherControlHandle {
3060    fn shutdown(&self) {
3061        self.inner.shutdown()
3062    }
3063
3064    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3065        self.inner.shutdown_with_epitaph(status)
3066    }
3067
3068    fn is_closed(&self) -> bool {
3069        self.inner.channel().is_closed()
3070    }
3071    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3072        self.inner.channel().on_closed()
3073    }
3074
3075    #[cfg(target_os = "fuchsia")]
3076    fn signal_peer(
3077        &self,
3078        clear_mask: zx::Signals,
3079        set_mask: zx::Signals,
3080    ) -> Result<(), zx_status::Status> {
3081        use fidl::Peered;
3082        self.inner.channel().signal_peer(clear_mask, set_mask)
3083    }
3084}
3085
3086impl PublisherControlHandle {}
3087
3088#[must_use = "FIDL methods require a response to be sent"]
3089#[derive(Debug)]
3090pub struct PublisherPublishServiceInstanceResponder {
3091    control_handle: std::mem::ManuallyDrop<PublisherControlHandle>,
3092    tx_id: u32,
3093}
3094
3095/// Set the the channel to be shutdown (see [`PublisherControlHandle::shutdown`])
3096/// if the responder is dropped without sending a response, so that the client
3097/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3098impl std::ops::Drop for PublisherPublishServiceInstanceResponder {
3099    fn drop(&mut self) {
3100        self.control_handle.shutdown();
3101        // Safety: drops once, never accessed again
3102        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3103    }
3104}
3105
3106impl fidl::endpoints::Responder for PublisherPublishServiceInstanceResponder {
3107    type ControlHandle = PublisherControlHandle;
3108
3109    fn control_handle(&self) -> &PublisherControlHandle {
3110        &self.control_handle
3111    }
3112
3113    fn drop_without_shutdown(mut self) {
3114        // Safety: drops once, never accessed again due to mem::forget
3115        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3116        // Prevent Drop from running (which would shut down the channel)
3117        std::mem::forget(self);
3118    }
3119}
3120
3121impl PublisherPublishServiceInstanceResponder {
3122    /// Sends a response to the FIDL transaction.
3123    ///
3124    /// Sets the channel to shutdown if an error occurs.
3125    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3126        let _result = self.send_raw(result);
3127        if _result.is_err() {
3128            self.control_handle.shutdown();
3129        }
3130        self.drop_without_shutdown();
3131        _result
3132    }
3133
3134    /// Similar to "send" but does not shutdown the channel if an error occurs.
3135    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3136        let _result = self.send_raw(result);
3137        self.drop_without_shutdown();
3138        _result
3139    }
3140
3141    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3142        self.control_handle
3143            .inner
3144            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
3145                result,
3146                self.tx_id,
3147                0x3712171c42878797,
3148                fidl::encoding::DynamicFlags::empty(),
3149            )
3150    }
3151}
3152
3153#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3154pub struct ResolverMarker;
3155
3156impl fidl::endpoints::ProtocolMarker for ResolverMarker {
3157    type Proxy = ResolverProxy;
3158    type RequestStream = ResolverRequestStream;
3159    #[cfg(target_os = "fuchsia")]
3160    type SynchronousProxy = ResolverSynchronousProxy;
3161
3162    const DEBUG_NAME: &'static str = "fuchsia.net.mdns.Resolver";
3163}
3164impl fidl::endpoints::DiscoverableProtocolMarker for ResolverMarker {}
3165
3166pub trait ResolverProxyInterface: Send + Sync {
3167    type ResolveHostNameResponseFut: std::future::Future<
3168            Output = Result<
3169                (
3170                    Option<Box<fidl_fuchsia_net::Ipv4Address>>,
3171                    Option<Box<fidl_fuchsia_net::Ipv6Address>>,
3172                ),
3173                fidl::Error,
3174            >,
3175        > + Send;
3176    fn r#resolve_host_name(&self, host: &str, timeout: i64) -> Self::ResolveHostNameResponseFut;
3177}
3178#[derive(Debug)]
3179#[cfg(target_os = "fuchsia")]
3180pub struct ResolverSynchronousProxy {
3181    client: fidl::client::sync::Client,
3182}
3183
3184#[cfg(target_os = "fuchsia")]
3185impl fidl::endpoints::SynchronousProxy for ResolverSynchronousProxy {
3186    type Proxy = ResolverProxy;
3187    type Protocol = ResolverMarker;
3188
3189    fn from_channel(inner: fidl::Channel) -> Self {
3190        Self::new(inner)
3191    }
3192
3193    fn into_channel(self) -> fidl::Channel {
3194        self.client.into_channel()
3195    }
3196
3197    fn as_channel(&self) -> &fidl::Channel {
3198        self.client.as_channel()
3199    }
3200}
3201
3202#[cfg(target_os = "fuchsia")]
3203impl ResolverSynchronousProxy {
3204    pub fn new(channel: fidl::Channel) -> Self {
3205        Self { client: fidl::client::sync::Client::new(channel) }
3206    }
3207
3208    pub fn into_channel(self) -> fidl::Channel {
3209        self.client.into_channel()
3210    }
3211
3212    /// Waits until an event arrives and returns it. It is safe for other
3213    /// threads to make concurrent requests while waiting for an event.
3214    pub fn wait_for_event(
3215        &self,
3216        deadline: zx::MonotonicInstant,
3217    ) -> Result<ResolverEvent, fidl::Error> {
3218        ResolverEvent::decode(self.client.wait_for_event::<ResolverMarker>(deadline)?)
3219    }
3220
3221    /// Gets the addresses for the specified host. `timeout` specifies how long
3222    /// the service should wait before giving up when waiting for a response to
3223    /// a resolution query. In typical use, a timeout of two or three seconds
3224    /// is recommended.
3225    ///
3226    /// A successful resolution may return one or both addresses. An
3227    /// unsuccessful resolution is indicated when both addresses are null.
3228    pub fn r#resolve_host_name(
3229        &self,
3230        mut host: &str,
3231        mut timeout: i64,
3232        ___deadline: zx::MonotonicInstant,
3233    ) -> Result<
3234        (Option<Box<fidl_fuchsia_net::Ipv4Address>>, Option<Box<fidl_fuchsia_net::Ipv6Address>>),
3235        fidl::Error,
3236    > {
3237        let _response = self.client.send_query::<
3238            ResolverResolveHostNameRequest,
3239            ResolverResolveHostNameResponse,
3240            ResolverMarker,
3241        >(
3242            (host, timeout,),
3243            0x3c8b2b50aad28e4a,
3244            fidl::encoding::DynamicFlags::empty(),
3245            ___deadline,
3246        )?;
3247        Ok((_response.v4_address, _response.v6_address))
3248    }
3249}
3250
3251#[cfg(target_os = "fuchsia")]
3252impl From<ResolverSynchronousProxy> for zx::NullableHandle {
3253    fn from(value: ResolverSynchronousProxy) -> Self {
3254        value.into_channel().into()
3255    }
3256}
3257
3258#[cfg(target_os = "fuchsia")]
3259impl From<fidl::Channel> for ResolverSynchronousProxy {
3260    fn from(value: fidl::Channel) -> Self {
3261        Self::new(value)
3262    }
3263}
3264
3265#[cfg(target_os = "fuchsia")]
3266impl fidl::endpoints::FromClient for ResolverSynchronousProxy {
3267    type Protocol = ResolverMarker;
3268
3269    fn from_client(value: fidl::endpoints::ClientEnd<ResolverMarker>) -> Self {
3270        Self::new(value.into_channel())
3271    }
3272}
3273
3274#[derive(Debug, Clone)]
3275pub struct ResolverProxy {
3276    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3277}
3278
3279impl fidl::endpoints::Proxy for ResolverProxy {
3280    type Protocol = ResolverMarker;
3281
3282    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3283        Self::new(inner)
3284    }
3285
3286    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3287        self.client.into_channel().map_err(|client| Self { client })
3288    }
3289
3290    fn as_channel(&self) -> &::fidl::AsyncChannel {
3291        self.client.as_channel()
3292    }
3293}
3294
3295impl ResolverProxy {
3296    /// Create a new Proxy for fuchsia.net.mdns/Resolver.
3297    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3298        let protocol_name = <ResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3299        Self { client: fidl::client::Client::new(channel, protocol_name) }
3300    }
3301
3302    /// Get a Stream of events from the remote end of the protocol.
3303    ///
3304    /// # Panics
3305    ///
3306    /// Panics if the event stream was already taken.
3307    pub fn take_event_stream(&self) -> ResolverEventStream {
3308        ResolverEventStream { event_receiver: self.client.take_event_receiver() }
3309    }
3310
3311    /// Gets the addresses for the specified host. `timeout` specifies how long
3312    /// the service should wait before giving up when waiting for a response to
3313    /// a resolution query. In typical use, a timeout of two or three seconds
3314    /// is recommended.
3315    ///
3316    /// A successful resolution may return one or both addresses. An
3317    /// unsuccessful resolution is indicated when both addresses are null.
3318    pub fn r#resolve_host_name(
3319        &self,
3320        mut host: &str,
3321        mut timeout: i64,
3322    ) -> fidl::client::QueryResponseFut<
3323        (Option<Box<fidl_fuchsia_net::Ipv4Address>>, Option<Box<fidl_fuchsia_net::Ipv6Address>>),
3324        fidl::encoding::DefaultFuchsiaResourceDialect,
3325    > {
3326        ResolverProxyInterface::r#resolve_host_name(self, host, timeout)
3327    }
3328}
3329
3330impl ResolverProxyInterface for ResolverProxy {
3331    type ResolveHostNameResponseFut = fidl::client::QueryResponseFut<
3332        (Option<Box<fidl_fuchsia_net::Ipv4Address>>, Option<Box<fidl_fuchsia_net::Ipv6Address>>),
3333        fidl::encoding::DefaultFuchsiaResourceDialect,
3334    >;
3335    fn r#resolve_host_name(
3336        &self,
3337        mut host: &str,
3338        mut timeout: i64,
3339    ) -> Self::ResolveHostNameResponseFut {
3340        fn _decode(
3341            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3342        ) -> Result<
3343            (
3344                Option<Box<fidl_fuchsia_net::Ipv4Address>>,
3345                Option<Box<fidl_fuchsia_net::Ipv6Address>>,
3346            ),
3347            fidl::Error,
3348        > {
3349            let _response = fidl::client::decode_transaction_body::<
3350                ResolverResolveHostNameResponse,
3351                fidl::encoding::DefaultFuchsiaResourceDialect,
3352                0x3c8b2b50aad28e4a,
3353            >(_buf?)?;
3354            Ok((_response.v4_address, _response.v6_address))
3355        }
3356        self.client.send_query_and_decode::<ResolverResolveHostNameRequest, (
3357            Option<Box<fidl_fuchsia_net::Ipv4Address>>,
3358            Option<Box<fidl_fuchsia_net::Ipv6Address>>,
3359        )>(
3360            (host, timeout),
3361            0x3c8b2b50aad28e4a,
3362            fidl::encoding::DynamicFlags::empty(),
3363            _decode,
3364        )
3365    }
3366}
3367
3368pub struct ResolverEventStream {
3369    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3370}
3371
3372impl std::marker::Unpin for ResolverEventStream {}
3373
3374impl futures::stream::FusedStream for ResolverEventStream {
3375    fn is_terminated(&self) -> bool {
3376        self.event_receiver.is_terminated()
3377    }
3378}
3379
3380impl futures::Stream for ResolverEventStream {
3381    type Item = Result<ResolverEvent, fidl::Error>;
3382
3383    fn poll_next(
3384        mut self: std::pin::Pin<&mut Self>,
3385        cx: &mut std::task::Context<'_>,
3386    ) -> std::task::Poll<Option<Self::Item>> {
3387        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3388            &mut self.event_receiver,
3389            cx
3390        )?) {
3391            Some(buf) => std::task::Poll::Ready(Some(ResolverEvent::decode(buf))),
3392            None => std::task::Poll::Ready(None),
3393        }
3394    }
3395}
3396
3397#[derive(Debug)]
3398pub enum ResolverEvent {}
3399
3400impl ResolverEvent {
3401    /// Decodes a message buffer as a [`ResolverEvent`].
3402    fn decode(
3403        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3404    ) -> Result<ResolverEvent, fidl::Error> {
3405        let (bytes, _handles) = buf.split_mut();
3406        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3407        debug_assert_eq!(tx_header.tx_id, 0);
3408        match tx_header.ordinal {
3409            _ => Err(fidl::Error::UnknownOrdinal {
3410                ordinal: tx_header.ordinal,
3411                protocol_name: <ResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3412            }),
3413        }
3414    }
3415}
3416
3417/// A Stream of incoming requests for fuchsia.net.mdns/Resolver.
3418pub struct ResolverRequestStream {
3419    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3420    is_terminated: bool,
3421}
3422
3423impl std::marker::Unpin for ResolverRequestStream {}
3424
3425impl futures::stream::FusedStream for ResolverRequestStream {
3426    fn is_terminated(&self) -> bool {
3427        self.is_terminated
3428    }
3429}
3430
3431impl fidl::endpoints::RequestStream for ResolverRequestStream {
3432    type Protocol = ResolverMarker;
3433    type ControlHandle = ResolverControlHandle;
3434
3435    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3436        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3437    }
3438
3439    fn control_handle(&self) -> Self::ControlHandle {
3440        ResolverControlHandle { inner: self.inner.clone() }
3441    }
3442
3443    fn into_inner(
3444        self,
3445    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3446    {
3447        (self.inner, self.is_terminated)
3448    }
3449
3450    fn from_inner(
3451        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3452        is_terminated: bool,
3453    ) -> Self {
3454        Self { inner, is_terminated }
3455    }
3456}
3457
3458impl futures::Stream for ResolverRequestStream {
3459    type Item = Result<ResolverRequest, fidl::Error>;
3460
3461    fn poll_next(
3462        mut self: std::pin::Pin<&mut Self>,
3463        cx: &mut std::task::Context<'_>,
3464    ) -> std::task::Poll<Option<Self::Item>> {
3465        let this = &mut *self;
3466        if this.inner.check_shutdown(cx) {
3467            this.is_terminated = true;
3468            return std::task::Poll::Ready(None);
3469        }
3470        if this.is_terminated {
3471            panic!("polled ResolverRequestStream after completion");
3472        }
3473        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3474            |bytes, handles| {
3475                match this.inner.channel().read_etc(cx, bytes, handles) {
3476                    std::task::Poll::Ready(Ok(())) => {}
3477                    std::task::Poll::Pending => return std::task::Poll::Pending,
3478                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3479                        this.is_terminated = true;
3480                        return std::task::Poll::Ready(None);
3481                    }
3482                    std::task::Poll::Ready(Err(e)) => {
3483                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3484                            e.into(),
3485                        ))));
3486                    }
3487                }
3488
3489                // A message has been received from the channel
3490                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3491
3492                std::task::Poll::Ready(Some(match header.ordinal {
3493                    0x3c8b2b50aad28e4a => {
3494                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3495                        let mut req = fidl::new_empty!(
3496                            ResolverResolveHostNameRequest,
3497                            fidl::encoding::DefaultFuchsiaResourceDialect
3498                        );
3499                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ResolverResolveHostNameRequest>(&header, _body_bytes, handles, &mut req)?;
3500                        let control_handle = ResolverControlHandle { inner: this.inner.clone() };
3501                        Ok(ResolverRequest::ResolveHostName {
3502                            host: req.host,
3503                            timeout: req.timeout,
3504
3505                            responder: ResolverResolveHostNameResponder {
3506                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3507                                tx_id: header.tx_id,
3508                            },
3509                        })
3510                    }
3511                    _ => Err(fidl::Error::UnknownOrdinal {
3512                        ordinal: header.ordinal,
3513                        protocol_name:
3514                            <ResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3515                    }),
3516                }))
3517            },
3518        )
3519    }
3520}
3521
3522/// Discoverable protocol for resolving host names to IP addresses.
3523/// Deprecated: use HostNameResolver.
3524#[derive(Debug)]
3525pub enum ResolverRequest {
3526    /// Gets the addresses for the specified host. `timeout` specifies how long
3527    /// the service should wait before giving up when waiting for a response to
3528    /// a resolution query. In typical use, a timeout of two or three seconds
3529    /// is recommended.
3530    ///
3531    /// A successful resolution may return one or both addresses. An
3532    /// unsuccessful resolution is indicated when both addresses are null.
3533    ResolveHostName { host: String, timeout: i64, responder: ResolverResolveHostNameResponder },
3534}
3535
3536impl ResolverRequest {
3537    #[allow(irrefutable_let_patterns)]
3538    pub fn into_resolve_host_name(self) -> Option<(String, i64, ResolverResolveHostNameResponder)> {
3539        if let ResolverRequest::ResolveHostName { host, timeout, responder } = self {
3540            Some((host, timeout, responder))
3541        } else {
3542            None
3543        }
3544    }
3545
3546    /// Name of the method defined in FIDL
3547    pub fn method_name(&self) -> &'static str {
3548        match *self {
3549            ResolverRequest::ResolveHostName { .. } => "resolve_host_name",
3550        }
3551    }
3552}
3553
3554#[derive(Debug, Clone)]
3555pub struct ResolverControlHandle {
3556    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3557}
3558
3559impl fidl::endpoints::ControlHandle for ResolverControlHandle {
3560    fn shutdown(&self) {
3561        self.inner.shutdown()
3562    }
3563
3564    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3565        self.inner.shutdown_with_epitaph(status)
3566    }
3567
3568    fn is_closed(&self) -> bool {
3569        self.inner.channel().is_closed()
3570    }
3571    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3572        self.inner.channel().on_closed()
3573    }
3574
3575    #[cfg(target_os = "fuchsia")]
3576    fn signal_peer(
3577        &self,
3578        clear_mask: zx::Signals,
3579        set_mask: zx::Signals,
3580    ) -> Result<(), zx_status::Status> {
3581        use fidl::Peered;
3582        self.inner.channel().signal_peer(clear_mask, set_mask)
3583    }
3584}
3585
3586impl ResolverControlHandle {}
3587
3588#[must_use = "FIDL methods require a response to be sent"]
3589#[derive(Debug)]
3590pub struct ResolverResolveHostNameResponder {
3591    control_handle: std::mem::ManuallyDrop<ResolverControlHandle>,
3592    tx_id: u32,
3593}
3594
3595/// Set the the channel to be shutdown (see [`ResolverControlHandle::shutdown`])
3596/// if the responder is dropped without sending a response, so that the client
3597/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3598impl std::ops::Drop for ResolverResolveHostNameResponder {
3599    fn drop(&mut self) {
3600        self.control_handle.shutdown();
3601        // Safety: drops once, never accessed again
3602        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3603    }
3604}
3605
3606impl fidl::endpoints::Responder for ResolverResolveHostNameResponder {
3607    type ControlHandle = ResolverControlHandle;
3608
3609    fn control_handle(&self) -> &ResolverControlHandle {
3610        &self.control_handle
3611    }
3612
3613    fn drop_without_shutdown(mut self) {
3614        // Safety: drops once, never accessed again due to mem::forget
3615        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3616        // Prevent Drop from running (which would shut down the channel)
3617        std::mem::forget(self);
3618    }
3619}
3620
3621impl ResolverResolveHostNameResponder {
3622    /// Sends a response to the FIDL transaction.
3623    ///
3624    /// Sets the channel to shutdown if an error occurs.
3625    pub fn send(
3626        self,
3627        mut v4_address: Option<&fidl_fuchsia_net::Ipv4Address>,
3628        mut v6_address: Option<&fidl_fuchsia_net::Ipv6Address>,
3629    ) -> Result<(), fidl::Error> {
3630        let _result = self.send_raw(v4_address, v6_address);
3631        if _result.is_err() {
3632            self.control_handle.shutdown();
3633        }
3634        self.drop_without_shutdown();
3635        _result
3636    }
3637
3638    /// Similar to "send" but does not shutdown the channel if an error occurs.
3639    pub fn send_no_shutdown_on_err(
3640        self,
3641        mut v4_address: Option<&fidl_fuchsia_net::Ipv4Address>,
3642        mut v6_address: Option<&fidl_fuchsia_net::Ipv6Address>,
3643    ) -> Result<(), fidl::Error> {
3644        let _result = self.send_raw(v4_address, v6_address);
3645        self.drop_without_shutdown();
3646        _result
3647    }
3648
3649    fn send_raw(
3650        &self,
3651        mut v4_address: Option<&fidl_fuchsia_net::Ipv4Address>,
3652        mut v6_address: Option<&fidl_fuchsia_net::Ipv6Address>,
3653    ) -> Result<(), fidl::Error> {
3654        self.control_handle.inner.send::<ResolverResolveHostNameResponse>(
3655            (v4_address, v6_address),
3656            self.tx_id,
3657            0x3c8b2b50aad28e4a,
3658            fidl::encoding::DynamicFlags::empty(),
3659        )
3660    }
3661}
3662
3663#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3664pub struct ServiceInstancePublicationResponder_Marker;
3665
3666impl fidl::endpoints::ProtocolMarker for ServiceInstancePublicationResponder_Marker {
3667    type Proxy = ServiceInstancePublicationResponder_Proxy;
3668    type RequestStream = ServiceInstancePublicationResponder_RequestStream;
3669    #[cfg(target_os = "fuchsia")]
3670    type SynchronousProxy = ServiceInstancePublicationResponder_SynchronousProxy;
3671
3672    const DEBUG_NAME: &'static str = "(anonymous) ServiceInstancePublicationResponder_";
3673}
3674pub type ServiceInstancePublicationResponderOnPublicationResult =
3675    Result<ServiceInstancePublication, OnPublicationError>;
3676
3677pub trait ServiceInstancePublicationResponder_ProxyInterface: Send + Sync {
3678    type OnPublicationResponseFut: std::future::Future<
3679            Output = Result<ServiceInstancePublicationResponderOnPublicationResult, fidl::Error>,
3680        > + Send;
3681    fn r#on_publication(
3682        &self,
3683        publication_cause: ServiceInstancePublicationCause,
3684        subtype: Option<&str>,
3685        source_addresses: &[fidl_fuchsia_net::IpAddress],
3686    ) -> Self::OnPublicationResponseFut;
3687}
3688#[derive(Debug)]
3689#[cfg(target_os = "fuchsia")]
3690pub struct ServiceInstancePublicationResponder_SynchronousProxy {
3691    client: fidl::client::sync::Client,
3692}
3693
3694#[cfg(target_os = "fuchsia")]
3695impl fidl::endpoints::SynchronousProxy for ServiceInstancePublicationResponder_SynchronousProxy {
3696    type Proxy = ServiceInstancePublicationResponder_Proxy;
3697    type Protocol = ServiceInstancePublicationResponder_Marker;
3698
3699    fn from_channel(inner: fidl::Channel) -> Self {
3700        Self::new(inner)
3701    }
3702
3703    fn into_channel(self) -> fidl::Channel {
3704        self.client.into_channel()
3705    }
3706
3707    fn as_channel(&self) -> &fidl::Channel {
3708        self.client.as_channel()
3709    }
3710}
3711
3712#[cfg(target_os = "fuchsia")]
3713impl ServiceInstancePublicationResponder_SynchronousProxy {
3714    pub fn new(channel: fidl::Channel) -> Self {
3715        Self { client: fidl::client::sync::Client::new(channel) }
3716    }
3717
3718    pub fn into_channel(self) -> fidl::Channel {
3719        self.client.into_channel()
3720    }
3721
3722    /// Waits until an event arrives and returns it. It is safe for other
3723    /// threads to make concurrent requests while waiting for an event.
3724    pub fn wait_for_event(
3725        &self,
3726        deadline: zx::MonotonicInstant,
3727    ) -> Result<ServiceInstancePublicationResponder_Event, fidl::Error> {
3728        ServiceInstancePublicationResponder_Event::decode(
3729            self.client.wait_for_event::<ServiceInstancePublicationResponder_Marker>(deadline)?,
3730        )
3731    }
3732
3733    /// Provides instance information for initial announcements and query
3734    /// responses relating to the service instance specified in
3735    /// `ServiceInstancePublisher.PublishServiceInstance`.
3736    ///
3737    /// + request `publication_cause` the action that motivates this publication.
3738    /// + request `subtype` the subtype if the publication relates to a subtype of the service,
3739    ///   otherwise null.
3740    /// + request `source_addresses` addresses from which queries arrived, if applicable.
3741    /// - response `publication` the desired publication. Strings in `publication.text` are sent
3742    ///   in the TXT resource.
3743    /// * error indicates the publication should not be sent.
3744    ///
3745    /// If no publication should be sent, this method should return a `DO_NOT_RESPOND` error.
3746    pub fn r#on_publication(
3747        &self,
3748        mut publication_cause: ServiceInstancePublicationCause,
3749        mut subtype: Option<&str>,
3750        mut source_addresses: &[fidl_fuchsia_net::IpAddress],
3751        ___deadline: zx::MonotonicInstant,
3752    ) -> Result<ServiceInstancePublicationResponderOnPublicationResult, fidl::Error> {
3753        let _response = self.client.send_query::<
3754            ServiceInstancePublicationResponderOnPublicationRequest,
3755            fidl::encoding::ResultType<ServiceInstancePublicationResponderOnPublicationResponse, OnPublicationError>,
3756            ServiceInstancePublicationResponder_Marker,
3757        >(
3758            (publication_cause, subtype, source_addresses,),
3759            0x71753d79b12571ca,
3760            fidl::encoding::DynamicFlags::empty(),
3761            ___deadline,
3762        )?;
3763        Ok(_response.map(|x| x.publication))
3764    }
3765}
3766
3767#[cfg(target_os = "fuchsia")]
3768impl From<ServiceInstancePublicationResponder_SynchronousProxy> for zx::NullableHandle {
3769    fn from(value: ServiceInstancePublicationResponder_SynchronousProxy) -> Self {
3770        value.into_channel().into()
3771    }
3772}
3773
3774#[cfg(target_os = "fuchsia")]
3775impl From<fidl::Channel> for ServiceInstancePublicationResponder_SynchronousProxy {
3776    fn from(value: fidl::Channel) -> Self {
3777        Self::new(value)
3778    }
3779}
3780
3781#[cfg(target_os = "fuchsia")]
3782impl fidl::endpoints::FromClient for ServiceInstancePublicationResponder_SynchronousProxy {
3783    type Protocol = ServiceInstancePublicationResponder_Marker;
3784
3785    fn from_client(
3786        value: fidl::endpoints::ClientEnd<ServiceInstancePublicationResponder_Marker>,
3787    ) -> Self {
3788        Self::new(value.into_channel())
3789    }
3790}
3791
3792#[derive(Debug, Clone)]
3793pub struct ServiceInstancePublicationResponder_Proxy {
3794    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3795}
3796
3797impl fidl::endpoints::Proxy for ServiceInstancePublicationResponder_Proxy {
3798    type Protocol = ServiceInstancePublicationResponder_Marker;
3799
3800    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3801        Self::new(inner)
3802    }
3803
3804    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3805        self.client.into_channel().map_err(|client| Self { client })
3806    }
3807
3808    fn as_channel(&self) -> &::fidl::AsyncChannel {
3809        self.client.as_channel()
3810    }
3811}
3812
3813impl ServiceInstancePublicationResponder_Proxy {
3814    /// Create a new Proxy for fuchsia.net.mdns/ServiceInstancePublicationResponder.
3815    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3816        let protocol_name = <ServiceInstancePublicationResponder_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3817        Self { client: fidl::client::Client::new(channel, protocol_name) }
3818    }
3819
3820    /// Get a Stream of events from the remote end of the protocol.
3821    ///
3822    /// # Panics
3823    ///
3824    /// Panics if the event stream was already taken.
3825    pub fn take_event_stream(&self) -> ServiceInstancePublicationResponder_EventStream {
3826        ServiceInstancePublicationResponder_EventStream {
3827            event_receiver: self.client.take_event_receiver(),
3828        }
3829    }
3830
3831    /// Provides instance information for initial announcements and query
3832    /// responses relating to the service instance specified in
3833    /// `ServiceInstancePublisher.PublishServiceInstance`.
3834    ///
3835    /// + request `publication_cause` the action that motivates this publication.
3836    /// + request `subtype` the subtype if the publication relates to a subtype of the service,
3837    ///   otherwise null.
3838    /// + request `source_addresses` addresses from which queries arrived, if applicable.
3839    /// - response `publication` the desired publication. Strings in `publication.text` are sent
3840    ///   in the TXT resource.
3841    /// * error indicates the publication should not be sent.
3842    ///
3843    /// If no publication should be sent, this method should return a `DO_NOT_RESPOND` error.
3844    pub fn r#on_publication(
3845        &self,
3846        mut publication_cause: ServiceInstancePublicationCause,
3847        mut subtype: Option<&str>,
3848        mut source_addresses: &[fidl_fuchsia_net::IpAddress],
3849    ) -> fidl::client::QueryResponseFut<
3850        ServiceInstancePublicationResponderOnPublicationResult,
3851        fidl::encoding::DefaultFuchsiaResourceDialect,
3852    > {
3853        ServiceInstancePublicationResponder_ProxyInterface::r#on_publication(
3854            self,
3855            publication_cause,
3856            subtype,
3857            source_addresses,
3858        )
3859    }
3860}
3861
3862impl ServiceInstancePublicationResponder_ProxyInterface
3863    for ServiceInstancePublicationResponder_Proxy
3864{
3865    type OnPublicationResponseFut = fidl::client::QueryResponseFut<
3866        ServiceInstancePublicationResponderOnPublicationResult,
3867        fidl::encoding::DefaultFuchsiaResourceDialect,
3868    >;
3869    fn r#on_publication(
3870        &self,
3871        mut publication_cause: ServiceInstancePublicationCause,
3872        mut subtype: Option<&str>,
3873        mut source_addresses: &[fidl_fuchsia_net::IpAddress],
3874    ) -> Self::OnPublicationResponseFut {
3875        fn _decode(
3876            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3877        ) -> Result<ServiceInstancePublicationResponderOnPublicationResult, fidl::Error> {
3878            let _response = fidl::client::decode_transaction_body::<
3879                fidl::encoding::ResultType<
3880                    ServiceInstancePublicationResponderOnPublicationResponse,
3881                    OnPublicationError,
3882                >,
3883                fidl::encoding::DefaultFuchsiaResourceDialect,
3884                0x71753d79b12571ca,
3885            >(_buf?)?;
3886            Ok(_response.map(|x| x.publication))
3887        }
3888        self.client.send_query_and_decode::<
3889            ServiceInstancePublicationResponderOnPublicationRequest,
3890            ServiceInstancePublicationResponderOnPublicationResult,
3891        >(
3892            (publication_cause, subtype, source_addresses,),
3893            0x71753d79b12571ca,
3894            fidl::encoding::DynamicFlags::empty(),
3895            _decode,
3896        )
3897    }
3898}
3899
3900pub struct ServiceInstancePublicationResponder_EventStream {
3901    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3902}
3903
3904impl std::marker::Unpin for ServiceInstancePublicationResponder_EventStream {}
3905
3906impl futures::stream::FusedStream for ServiceInstancePublicationResponder_EventStream {
3907    fn is_terminated(&self) -> bool {
3908        self.event_receiver.is_terminated()
3909    }
3910}
3911
3912impl futures::Stream for ServiceInstancePublicationResponder_EventStream {
3913    type Item = Result<ServiceInstancePublicationResponder_Event, fidl::Error>;
3914
3915    fn poll_next(
3916        mut self: std::pin::Pin<&mut Self>,
3917        cx: &mut std::task::Context<'_>,
3918    ) -> std::task::Poll<Option<Self::Item>> {
3919        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3920            &mut self.event_receiver,
3921            cx
3922        )?) {
3923            Some(buf) => {
3924                std::task::Poll::Ready(Some(ServiceInstancePublicationResponder_Event::decode(buf)))
3925            }
3926            None => std::task::Poll::Ready(None),
3927        }
3928    }
3929}
3930
3931#[derive(Debug)]
3932pub enum ServiceInstancePublicationResponder_Event {
3933    SetSubtypes { subtypes: Vec<String> },
3934    Reannounce {},
3935}
3936
3937impl ServiceInstancePublicationResponder_Event {
3938    #[allow(irrefutable_let_patterns)]
3939    pub fn into_set_subtypes(self) -> Option<Vec<String>> {
3940        if let ServiceInstancePublicationResponder_Event::SetSubtypes { subtypes } = self {
3941            Some((subtypes))
3942        } else {
3943            None
3944        }
3945    }
3946    #[allow(irrefutable_let_patterns)]
3947    pub fn into_reannounce(self) -> Option<()> {
3948        if let ServiceInstancePublicationResponder_Event::Reannounce {} = self {
3949            Some(())
3950        } else {
3951            None
3952        }
3953    }
3954
3955    /// Decodes a message buffer as a [`ServiceInstancePublicationResponder_Event`].
3956    fn decode(
3957        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3958    ) -> Result<ServiceInstancePublicationResponder_Event, fidl::Error> {
3959        let (bytes, _handles) = buf.split_mut();
3960        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3961        debug_assert_eq!(tx_header.tx_id, 0);
3962        match tx_header.ordinal {
3963            0x217fed6e404312a9 => {
3964                let mut out = fidl::new_empty!(ServiceInstancePublicationResponderSetSubtypesRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
3965                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceInstancePublicationResponderSetSubtypesRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3966                Ok((
3967                    ServiceInstancePublicationResponder_Event::SetSubtypes {subtypes: out.subtypes,
3968
3969                    }
3970                ))
3971            }
3972            0x1b48d9ed30dce1a8 => {
3973                let mut out = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
3974                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3975                Ok((
3976                    ServiceInstancePublicationResponder_Event::Reannounce {
3977                    }
3978                ))
3979            }
3980            _ => Err(fidl::Error::UnknownOrdinal {
3981                ordinal: tx_header.ordinal,
3982                protocol_name: <ServiceInstancePublicationResponder_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3983            })
3984        }
3985    }
3986}
3987
3988/// A Stream of incoming requests for fuchsia.net.mdns/ServiceInstancePublicationResponder.
3989pub struct ServiceInstancePublicationResponder_RequestStream {
3990    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3991    is_terminated: bool,
3992}
3993
3994impl std::marker::Unpin for ServiceInstancePublicationResponder_RequestStream {}
3995
3996impl futures::stream::FusedStream for ServiceInstancePublicationResponder_RequestStream {
3997    fn is_terminated(&self) -> bool {
3998        self.is_terminated
3999    }
4000}
4001
4002impl fidl::endpoints::RequestStream for ServiceInstancePublicationResponder_RequestStream {
4003    type Protocol = ServiceInstancePublicationResponder_Marker;
4004    type ControlHandle = ServiceInstancePublicationResponder_ControlHandle;
4005
4006    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4007        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4008    }
4009
4010    fn control_handle(&self) -> Self::ControlHandle {
4011        ServiceInstancePublicationResponder_ControlHandle { inner: self.inner.clone() }
4012    }
4013
4014    fn into_inner(
4015        self,
4016    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4017    {
4018        (self.inner, self.is_terminated)
4019    }
4020
4021    fn from_inner(
4022        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4023        is_terminated: bool,
4024    ) -> Self {
4025        Self { inner, is_terminated }
4026    }
4027}
4028
4029impl futures::Stream for ServiceInstancePublicationResponder_RequestStream {
4030    type Item = Result<ServiceInstancePublicationResponder_Request, fidl::Error>;
4031
4032    fn poll_next(
4033        mut self: std::pin::Pin<&mut Self>,
4034        cx: &mut std::task::Context<'_>,
4035    ) -> std::task::Poll<Option<Self::Item>> {
4036        let this = &mut *self;
4037        if this.inner.check_shutdown(cx) {
4038            this.is_terminated = true;
4039            return std::task::Poll::Ready(None);
4040        }
4041        if this.is_terminated {
4042            panic!("polled ServiceInstancePublicationResponder_RequestStream after completion");
4043        }
4044        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4045            |bytes, handles| {
4046                match this.inner.channel().read_etc(cx, bytes, handles) {
4047                    std::task::Poll::Ready(Ok(())) => {}
4048                    std::task::Poll::Pending => return std::task::Poll::Pending,
4049                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4050                        this.is_terminated = true;
4051                        return std::task::Poll::Ready(None);
4052                    }
4053                    std::task::Poll::Ready(Err(e)) => {
4054                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4055                            e.into(),
4056                        ))));
4057                    }
4058                }
4059
4060                // A message has been received from the channel
4061                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4062
4063                std::task::Poll::Ready(Some(match header.ordinal {
4064                0x71753d79b12571ca => {
4065                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4066                    let mut req = fidl::new_empty!(ServiceInstancePublicationResponderOnPublicationRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4067                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceInstancePublicationResponderOnPublicationRequest>(&header, _body_bytes, handles, &mut req)?;
4068                    let control_handle = ServiceInstancePublicationResponder_ControlHandle {
4069                        inner: this.inner.clone(),
4070                    };
4071                    Ok(ServiceInstancePublicationResponder_Request::OnPublication {publication_cause: req.publication_cause,
4072subtype: req.subtype,
4073source_addresses: req.source_addresses,
4074
4075                        responder: ServiceInstancePublicationResponder_OnPublicationResponder {
4076                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4077                            tx_id: header.tx_id,
4078                        },
4079                    })
4080                }
4081                _ => Err(fidl::Error::UnknownOrdinal {
4082                    ordinal: header.ordinal,
4083                    protocol_name: <ServiceInstancePublicationResponder_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4084                }),
4085            }))
4086            },
4087        )
4088    }
4089}
4090
4091/// Client-supplied publication responder interface.
4092#[derive(Debug)]
4093pub enum ServiceInstancePublicationResponder_Request {
4094    /// Provides instance information for initial announcements and query
4095    /// responses relating to the service instance specified in
4096    /// `ServiceInstancePublisher.PublishServiceInstance`.
4097    ///
4098    /// + request `publication_cause` the action that motivates this publication.
4099    /// + request `subtype` the subtype if the publication relates to a subtype of the service,
4100    ///   otherwise null.
4101    /// + request `source_addresses` addresses from which queries arrived, if applicable.
4102    /// - response `publication` the desired publication. Strings in `publication.text` are sent
4103    ///   in the TXT resource.
4104    /// * error indicates the publication should not be sent.
4105    ///
4106    /// If no publication should be sent, this method should return a `DO_NOT_RESPOND` error.
4107    OnPublication {
4108        publication_cause: ServiceInstancePublicationCause,
4109        subtype: Option<String>,
4110        source_addresses: Vec<fidl_fuchsia_net::IpAddress>,
4111        responder: ServiceInstancePublicationResponder_OnPublicationResponder,
4112    },
4113}
4114
4115impl ServiceInstancePublicationResponder_Request {
4116    #[allow(irrefutable_let_patterns)]
4117    pub fn into_on_publication(
4118        self,
4119    ) -> Option<(
4120        ServiceInstancePublicationCause,
4121        Option<String>,
4122        Vec<fidl_fuchsia_net::IpAddress>,
4123        ServiceInstancePublicationResponder_OnPublicationResponder,
4124    )> {
4125        if let ServiceInstancePublicationResponder_Request::OnPublication {
4126            publication_cause,
4127            subtype,
4128            source_addresses,
4129            responder,
4130        } = self
4131        {
4132            Some((publication_cause, subtype, source_addresses, responder))
4133        } else {
4134            None
4135        }
4136    }
4137
4138    /// Name of the method defined in FIDL
4139    pub fn method_name(&self) -> &'static str {
4140        match *self {
4141            ServiceInstancePublicationResponder_Request::OnPublication { .. } => "on_publication",
4142        }
4143    }
4144}
4145
4146#[derive(Debug, Clone)]
4147pub struct ServiceInstancePublicationResponder_ControlHandle {
4148    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4149}
4150
4151impl fidl::endpoints::ControlHandle for ServiceInstancePublicationResponder_ControlHandle {
4152    fn shutdown(&self) {
4153        self.inner.shutdown()
4154    }
4155
4156    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4157        self.inner.shutdown_with_epitaph(status)
4158    }
4159
4160    fn is_closed(&self) -> bool {
4161        self.inner.channel().is_closed()
4162    }
4163    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4164        self.inner.channel().on_closed()
4165    }
4166
4167    #[cfg(target_os = "fuchsia")]
4168    fn signal_peer(
4169        &self,
4170        clear_mask: zx::Signals,
4171        set_mask: zx::Signals,
4172    ) -> Result<(), zx_status::Status> {
4173        use fidl::Peered;
4174        self.inner.channel().signal_peer(clear_mask, set_mask)
4175    }
4176}
4177
4178impl ServiceInstancePublicationResponder_ControlHandle {
4179    pub fn send_set_subtypes(&self, mut subtypes: &[String]) -> Result<(), fidl::Error> {
4180        self.inner.send::<ServiceInstancePublicationResponderSetSubtypesRequest>(
4181            (subtypes,),
4182            0,
4183            0x217fed6e404312a9,
4184            fidl::encoding::DynamicFlags::empty(),
4185        )
4186    }
4187
4188    pub fn send_reannounce(&self) -> Result<(), fidl::Error> {
4189        self.inner.send::<fidl::encoding::EmptyPayload>(
4190            (),
4191            0,
4192            0x1b48d9ed30dce1a8,
4193            fidl::encoding::DynamicFlags::empty(),
4194        )
4195    }
4196}
4197
4198#[must_use = "FIDL methods require a response to be sent"]
4199#[derive(Debug)]
4200pub struct ServiceInstancePublicationResponder_OnPublicationResponder {
4201    control_handle: std::mem::ManuallyDrop<ServiceInstancePublicationResponder_ControlHandle>,
4202    tx_id: u32,
4203}
4204
4205/// Set the the channel to be shutdown (see [`ServiceInstancePublicationResponder_ControlHandle::shutdown`])
4206/// if the responder is dropped without sending a response, so that the client
4207/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4208impl std::ops::Drop for ServiceInstancePublicationResponder_OnPublicationResponder {
4209    fn drop(&mut self) {
4210        self.control_handle.shutdown();
4211        // Safety: drops once, never accessed again
4212        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4213    }
4214}
4215
4216impl fidl::endpoints::Responder for ServiceInstancePublicationResponder_OnPublicationResponder {
4217    type ControlHandle = ServiceInstancePublicationResponder_ControlHandle;
4218
4219    fn control_handle(&self) -> &ServiceInstancePublicationResponder_ControlHandle {
4220        &self.control_handle
4221    }
4222
4223    fn drop_without_shutdown(mut self) {
4224        // Safety: drops once, never accessed again due to mem::forget
4225        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4226        // Prevent Drop from running (which would shut down the channel)
4227        std::mem::forget(self);
4228    }
4229}
4230
4231impl ServiceInstancePublicationResponder_OnPublicationResponder {
4232    /// Sends a response to the FIDL transaction.
4233    ///
4234    /// Sets the channel to shutdown if an error occurs.
4235    pub fn send(
4236        self,
4237        mut result: Result<&ServiceInstancePublication, OnPublicationError>,
4238    ) -> Result<(), fidl::Error> {
4239        let _result = self.send_raw(result);
4240        if _result.is_err() {
4241            self.control_handle.shutdown();
4242        }
4243        self.drop_without_shutdown();
4244        _result
4245    }
4246
4247    /// Similar to "send" but does not shutdown the channel if an error occurs.
4248    pub fn send_no_shutdown_on_err(
4249        self,
4250        mut result: Result<&ServiceInstancePublication, OnPublicationError>,
4251    ) -> Result<(), fidl::Error> {
4252        let _result = self.send_raw(result);
4253        self.drop_without_shutdown();
4254        _result
4255    }
4256
4257    fn send_raw(
4258        &self,
4259        mut result: Result<&ServiceInstancePublication, OnPublicationError>,
4260    ) -> Result<(), fidl::Error> {
4261        self.control_handle.inner.send::<fidl::encoding::ResultType<
4262            ServiceInstancePublicationResponderOnPublicationResponse,
4263            OnPublicationError,
4264        >>(
4265            result.map(|publication| (publication,)),
4266            self.tx_id,
4267            0x71753d79b12571ca,
4268            fidl::encoding::DynamicFlags::empty(),
4269        )
4270    }
4271}
4272
4273#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4274pub struct ServiceInstancePublisherMarker;
4275
4276impl fidl::endpoints::ProtocolMarker for ServiceInstancePublisherMarker {
4277    type Proxy = ServiceInstancePublisherProxy;
4278    type RequestStream = ServiceInstancePublisherRequestStream;
4279    #[cfg(target_os = "fuchsia")]
4280    type SynchronousProxy = ServiceInstancePublisherSynchronousProxy;
4281
4282    const DEBUG_NAME: &'static str = "fuchsia.net.mdns.ServiceInstancePublisher";
4283}
4284impl fidl::endpoints::DiscoverableProtocolMarker for ServiceInstancePublisherMarker {}
4285pub type ServiceInstancePublisherPublishServiceInstanceResult =
4286    Result<(), PublishServiceInstanceError>;
4287
4288pub trait ServiceInstancePublisherProxyInterface: Send + Sync {
4289    type PublishServiceInstanceResponseFut: std::future::Future<
4290            Output = Result<ServiceInstancePublisherPublishServiceInstanceResult, fidl::Error>,
4291        > + Send;
4292    fn r#publish_service_instance(
4293        &self,
4294        service: &str,
4295        instance: &str,
4296        options: &ServiceInstancePublicationOptions,
4297        publication_responder: fidl::endpoints::ClientEnd<
4298            ServiceInstancePublicationResponder_Marker,
4299        >,
4300    ) -> Self::PublishServiceInstanceResponseFut;
4301}
4302#[derive(Debug)]
4303#[cfg(target_os = "fuchsia")]
4304pub struct ServiceInstancePublisherSynchronousProxy {
4305    client: fidl::client::sync::Client,
4306}
4307
4308#[cfg(target_os = "fuchsia")]
4309impl fidl::endpoints::SynchronousProxy for ServiceInstancePublisherSynchronousProxy {
4310    type Proxy = ServiceInstancePublisherProxy;
4311    type Protocol = ServiceInstancePublisherMarker;
4312
4313    fn from_channel(inner: fidl::Channel) -> Self {
4314        Self::new(inner)
4315    }
4316
4317    fn into_channel(self) -> fidl::Channel {
4318        self.client.into_channel()
4319    }
4320
4321    fn as_channel(&self) -> &fidl::Channel {
4322        self.client.as_channel()
4323    }
4324}
4325
4326#[cfg(target_os = "fuchsia")]
4327impl ServiceInstancePublisherSynchronousProxy {
4328    pub fn new(channel: fidl::Channel) -> Self {
4329        Self { client: fidl::client::sync::Client::new(channel) }
4330    }
4331
4332    pub fn into_channel(self) -> fidl::Channel {
4333        self.client.into_channel()
4334    }
4335
4336    /// Waits until an event arrives and returns it. It is safe for other
4337    /// threads to make concurrent requests while waiting for an event.
4338    pub fn wait_for_event(
4339        &self,
4340        deadline: zx::MonotonicInstant,
4341    ) -> Result<ServiceInstancePublisherEvent, fidl::Error> {
4342        ServiceInstancePublisherEvent::decode(
4343            self.client.wait_for_event::<ServiceInstancePublisherMarker>(deadline)?,
4344        )
4345    }
4346
4347    /// Publishes a service instance. `publication_responder` is consulted via its
4348    /// `OnPublication` method for initial announcements and to answer queries.
4349    /// The service is published until the `publication_responder` channel closes. In
4350    /// addition to announcements and queries for the service type, all queries
4351    /// for subtypes are answered subject to filtering through the responder.
4352    ///
4353    /// + request `service` name of the type of service to be published. For example, cast uses
4354    ///   '_googlecast._tcp.'.
4355    /// + request `instance` name of the instance to be published. This is often a descriptive name
4356    ///   such as `Office Printer` or a name containing a large random number.
4357    /// + request `options` options to be applied to the publication.
4358    /// + request `publication_responder` client end of the `ServiceInstancePublicationResponder`
4359    ///   channel consulted when formulating service instance announcements and query responses.
4360    /// * error reason the requested operation failed.
4361    ///
4362    /// If a service with the same service and instance names is already published, the
4363    /// old publication will be terminated, and the responder channel for the old
4364    /// publication will be closed.
4365    pub fn r#publish_service_instance(
4366        &self,
4367        mut service: &str,
4368        mut instance: &str,
4369        mut options: &ServiceInstancePublicationOptions,
4370        mut publication_responder: fidl::endpoints::ClientEnd<
4371            ServiceInstancePublicationResponder_Marker,
4372        >,
4373        ___deadline: zx::MonotonicInstant,
4374    ) -> Result<ServiceInstancePublisherPublishServiceInstanceResult, fidl::Error> {
4375        let _response = self.client.send_query::<
4376            ServiceInstancePublisherPublishServiceInstanceRequest,
4377            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PublishServiceInstanceError>,
4378            ServiceInstancePublisherMarker,
4379        >(
4380            (service, instance, options, publication_responder,),
4381            0x25d5fd0912cb5a9e,
4382            fidl::encoding::DynamicFlags::empty(),
4383            ___deadline,
4384        )?;
4385        Ok(_response.map(|x| x))
4386    }
4387}
4388
4389#[cfg(target_os = "fuchsia")]
4390impl From<ServiceInstancePublisherSynchronousProxy> for zx::NullableHandle {
4391    fn from(value: ServiceInstancePublisherSynchronousProxy) -> Self {
4392        value.into_channel().into()
4393    }
4394}
4395
4396#[cfg(target_os = "fuchsia")]
4397impl From<fidl::Channel> for ServiceInstancePublisherSynchronousProxy {
4398    fn from(value: fidl::Channel) -> Self {
4399        Self::new(value)
4400    }
4401}
4402
4403#[cfg(target_os = "fuchsia")]
4404impl fidl::endpoints::FromClient for ServiceInstancePublisherSynchronousProxy {
4405    type Protocol = ServiceInstancePublisherMarker;
4406
4407    fn from_client(value: fidl::endpoints::ClientEnd<ServiceInstancePublisherMarker>) -> Self {
4408        Self::new(value.into_channel())
4409    }
4410}
4411
4412#[derive(Debug, Clone)]
4413pub struct ServiceInstancePublisherProxy {
4414    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4415}
4416
4417impl fidl::endpoints::Proxy for ServiceInstancePublisherProxy {
4418    type Protocol = ServiceInstancePublisherMarker;
4419
4420    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4421        Self::new(inner)
4422    }
4423
4424    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4425        self.client.into_channel().map_err(|client| Self { client })
4426    }
4427
4428    fn as_channel(&self) -> &::fidl::AsyncChannel {
4429        self.client.as_channel()
4430    }
4431}
4432
4433impl ServiceInstancePublisherProxy {
4434    /// Create a new Proxy for fuchsia.net.mdns/ServiceInstancePublisher.
4435    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4436        let protocol_name =
4437            <ServiceInstancePublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4438        Self { client: fidl::client::Client::new(channel, protocol_name) }
4439    }
4440
4441    /// Get a Stream of events from the remote end of the protocol.
4442    ///
4443    /// # Panics
4444    ///
4445    /// Panics if the event stream was already taken.
4446    pub fn take_event_stream(&self) -> ServiceInstancePublisherEventStream {
4447        ServiceInstancePublisherEventStream { event_receiver: self.client.take_event_receiver() }
4448    }
4449
4450    /// Publishes a service instance. `publication_responder` is consulted via its
4451    /// `OnPublication` method for initial announcements and to answer queries.
4452    /// The service is published until the `publication_responder` channel closes. In
4453    /// addition to announcements and queries for the service type, all queries
4454    /// for subtypes are answered subject to filtering through the responder.
4455    ///
4456    /// + request `service` name of the type of service to be published. For example, cast uses
4457    ///   '_googlecast._tcp.'.
4458    /// + request `instance` name of the instance to be published. This is often a descriptive name
4459    ///   such as `Office Printer` or a name containing a large random number.
4460    /// + request `options` options to be applied to the publication.
4461    /// + request `publication_responder` client end of the `ServiceInstancePublicationResponder`
4462    ///   channel consulted when formulating service instance announcements and query responses.
4463    /// * error reason the requested operation failed.
4464    ///
4465    /// If a service with the same service and instance names is already published, the
4466    /// old publication will be terminated, and the responder channel for the old
4467    /// publication will be closed.
4468    pub fn r#publish_service_instance(
4469        &self,
4470        mut service: &str,
4471        mut instance: &str,
4472        mut options: &ServiceInstancePublicationOptions,
4473        mut publication_responder: fidl::endpoints::ClientEnd<
4474            ServiceInstancePublicationResponder_Marker,
4475        >,
4476    ) -> fidl::client::QueryResponseFut<
4477        ServiceInstancePublisherPublishServiceInstanceResult,
4478        fidl::encoding::DefaultFuchsiaResourceDialect,
4479    > {
4480        ServiceInstancePublisherProxyInterface::r#publish_service_instance(
4481            self,
4482            service,
4483            instance,
4484            options,
4485            publication_responder,
4486        )
4487    }
4488}
4489
4490impl ServiceInstancePublisherProxyInterface for ServiceInstancePublisherProxy {
4491    type PublishServiceInstanceResponseFut = fidl::client::QueryResponseFut<
4492        ServiceInstancePublisherPublishServiceInstanceResult,
4493        fidl::encoding::DefaultFuchsiaResourceDialect,
4494    >;
4495    fn r#publish_service_instance(
4496        &self,
4497        mut service: &str,
4498        mut instance: &str,
4499        mut options: &ServiceInstancePublicationOptions,
4500        mut publication_responder: fidl::endpoints::ClientEnd<
4501            ServiceInstancePublicationResponder_Marker,
4502        >,
4503    ) -> Self::PublishServiceInstanceResponseFut {
4504        fn _decode(
4505            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4506        ) -> Result<ServiceInstancePublisherPublishServiceInstanceResult, fidl::Error> {
4507            let _response = fidl::client::decode_transaction_body::<
4508                fidl::encoding::ResultType<
4509                    fidl::encoding::EmptyStruct,
4510                    PublishServiceInstanceError,
4511                >,
4512                fidl::encoding::DefaultFuchsiaResourceDialect,
4513                0x25d5fd0912cb5a9e,
4514            >(_buf?)?;
4515            Ok(_response.map(|x| x))
4516        }
4517        self.client.send_query_and_decode::<
4518            ServiceInstancePublisherPublishServiceInstanceRequest,
4519            ServiceInstancePublisherPublishServiceInstanceResult,
4520        >(
4521            (service, instance, options, publication_responder,),
4522            0x25d5fd0912cb5a9e,
4523            fidl::encoding::DynamicFlags::empty(),
4524            _decode,
4525        )
4526    }
4527}
4528
4529pub struct ServiceInstancePublisherEventStream {
4530    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4531}
4532
4533impl std::marker::Unpin for ServiceInstancePublisherEventStream {}
4534
4535impl futures::stream::FusedStream for ServiceInstancePublisherEventStream {
4536    fn is_terminated(&self) -> bool {
4537        self.event_receiver.is_terminated()
4538    }
4539}
4540
4541impl futures::Stream for ServiceInstancePublisherEventStream {
4542    type Item = Result<ServiceInstancePublisherEvent, fidl::Error>;
4543
4544    fn poll_next(
4545        mut self: std::pin::Pin<&mut Self>,
4546        cx: &mut std::task::Context<'_>,
4547    ) -> std::task::Poll<Option<Self::Item>> {
4548        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4549            &mut self.event_receiver,
4550            cx
4551        )?) {
4552            Some(buf) => std::task::Poll::Ready(Some(ServiceInstancePublisherEvent::decode(buf))),
4553            None => std::task::Poll::Ready(None),
4554        }
4555    }
4556}
4557
4558#[derive(Debug)]
4559pub enum ServiceInstancePublisherEvent {}
4560
4561impl ServiceInstancePublisherEvent {
4562    /// Decodes a message buffer as a [`ServiceInstancePublisherEvent`].
4563    fn decode(
4564        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4565    ) -> Result<ServiceInstancePublisherEvent, fidl::Error> {
4566        let (bytes, _handles) = buf.split_mut();
4567        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4568        debug_assert_eq!(tx_header.tx_id, 0);
4569        match tx_header.ordinal {
4570            _ => Err(fidl::Error::UnknownOrdinal {
4571                ordinal: tx_header.ordinal,
4572                protocol_name:
4573                    <ServiceInstancePublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4574            }),
4575        }
4576    }
4577}
4578
4579/// A Stream of incoming requests for fuchsia.net.mdns/ServiceInstancePublisher.
4580pub struct ServiceInstancePublisherRequestStream {
4581    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4582    is_terminated: bool,
4583}
4584
4585impl std::marker::Unpin for ServiceInstancePublisherRequestStream {}
4586
4587impl futures::stream::FusedStream for ServiceInstancePublisherRequestStream {
4588    fn is_terminated(&self) -> bool {
4589        self.is_terminated
4590    }
4591}
4592
4593impl fidl::endpoints::RequestStream for ServiceInstancePublisherRequestStream {
4594    type Protocol = ServiceInstancePublisherMarker;
4595    type ControlHandle = ServiceInstancePublisherControlHandle;
4596
4597    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4598        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4599    }
4600
4601    fn control_handle(&self) -> Self::ControlHandle {
4602        ServiceInstancePublisherControlHandle { inner: self.inner.clone() }
4603    }
4604
4605    fn into_inner(
4606        self,
4607    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4608    {
4609        (self.inner, self.is_terminated)
4610    }
4611
4612    fn from_inner(
4613        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4614        is_terminated: bool,
4615    ) -> Self {
4616        Self { inner, is_terminated }
4617    }
4618}
4619
4620impl futures::Stream for ServiceInstancePublisherRequestStream {
4621    type Item = Result<ServiceInstancePublisherRequest, fidl::Error>;
4622
4623    fn poll_next(
4624        mut self: std::pin::Pin<&mut Self>,
4625        cx: &mut std::task::Context<'_>,
4626    ) -> std::task::Poll<Option<Self::Item>> {
4627        let this = &mut *self;
4628        if this.inner.check_shutdown(cx) {
4629            this.is_terminated = true;
4630            return std::task::Poll::Ready(None);
4631        }
4632        if this.is_terminated {
4633            panic!("polled ServiceInstancePublisherRequestStream after completion");
4634        }
4635        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4636            |bytes, handles| {
4637                match this.inner.channel().read_etc(cx, bytes, handles) {
4638                    std::task::Poll::Ready(Ok(())) => {}
4639                    std::task::Poll::Pending => return std::task::Poll::Pending,
4640                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4641                        this.is_terminated = true;
4642                        return std::task::Poll::Ready(None);
4643                    }
4644                    std::task::Poll::Ready(Err(e)) => {
4645                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4646                            e.into(),
4647                        ))));
4648                    }
4649                }
4650
4651                // A message has been received from the channel
4652                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4653
4654                std::task::Poll::Ready(Some(match header.ordinal {
4655                0x25d5fd0912cb5a9e => {
4656                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4657                    let mut req = fidl::new_empty!(ServiceInstancePublisherPublishServiceInstanceRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4658                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceInstancePublisherPublishServiceInstanceRequest>(&header, _body_bytes, handles, &mut req)?;
4659                    let control_handle = ServiceInstancePublisherControlHandle {
4660                        inner: this.inner.clone(),
4661                    };
4662                    Ok(ServiceInstancePublisherRequest::PublishServiceInstance {service: req.service,
4663instance: req.instance,
4664options: req.options,
4665publication_responder: req.publication_responder,
4666
4667                        responder: ServiceInstancePublisherPublishServiceInstanceResponder {
4668                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4669                            tx_id: header.tx_id,
4670                        },
4671                    })
4672                }
4673                _ => Err(fidl::Error::UnknownOrdinal {
4674                    ordinal: header.ordinal,
4675                    protocol_name: <ServiceInstancePublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4676                }),
4677            }))
4678            },
4679        )
4680    }
4681}
4682
4683/// Discoverable protocol for publishing service instances.
4684#[derive(Debug)]
4685pub enum ServiceInstancePublisherRequest {
4686    /// Publishes a service instance. `publication_responder` is consulted via its
4687    /// `OnPublication` method for initial announcements and to answer queries.
4688    /// The service is published until the `publication_responder` channel closes. In
4689    /// addition to announcements and queries for the service type, all queries
4690    /// for subtypes are answered subject to filtering through the responder.
4691    ///
4692    /// + request `service` name of the type of service to be published. For example, cast uses
4693    ///   '_googlecast._tcp.'.
4694    /// + request `instance` name of the instance to be published. This is often a descriptive name
4695    ///   such as `Office Printer` or a name containing a large random number.
4696    /// + request `options` options to be applied to the publication.
4697    /// + request `publication_responder` client end of the `ServiceInstancePublicationResponder`
4698    ///   channel consulted when formulating service instance announcements and query responses.
4699    /// * error reason the requested operation failed.
4700    ///
4701    /// If a service with the same service and instance names is already published, the
4702    /// old publication will be terminated, and the responder channel for the old
4703    /// publication will be closed.
4704    PublishServiceInstance {
4705        service: String,
4706        instance: String,
4707        options: ServiceInstancePublicationOptions,
4708        publication_responder:
4709            fidl::endpoints::ClientEnd<ServiceInstancePublicationResponder_Marker>,
4710        responder: ServiceInstancePublisherPublishServiceInstanceResponder,
4711    },
4712}
4713
4714impl ServiceInstancePublisherRequest {
4715    #[allow(irrefutable_let_patterns)]
4716    pub fn into_publish_service_instance(
4717        self,
4718    ) -> Option<(
4719        String,
4720        String,
4721        ServiceInstancePublicationOptions,
4722        fidl::endpoints::ClientEnd<ServiceInstancePublicationResponder_Marker>,
4723        ServiceInstancePublisherPublishServiceInstanceResponder,
4724    )> {
4725        if let ServiceInstancePublisherRequest::PublishServiceInstance {
4726            service,
4727            instance,
4728            options,
4729            publication_responder,
4730            responder,
4731        } = self
4732        {
4733            Some((service, instance, options, publication_responder, responder))
4734        } else {
4735            None
4736        }
4737    }
4738
4739    /// Name of the method defined in FIDL
4740    pub fn method_name(&self) -> &'static str {
4741        match *self {
4742            ServiceInstancePublisherRequest::PublishServiceInstance { .. } => {
4743                "publish_service_instance"
4744            }
4745        }
4746    }
4747}
4748
4749#[derive(Debug, Clone)]
4750pub struct ServiceInstancePublisherControlHandle {
4751    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4752}
4753
4754impl fidl::endpoints::ControlHandle for ServiceInstancePublisherControlHandle {
4755    fn shutdown(&self) {
4756        self.inner.shutdown()
4757    }
4758
4759    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4760        self.inner.shutdown_with_epitaph(status)
4761    }
4762
4763    fn is_closed(&self) -> bool {
4764        self.inner.channel().is_closed()
4765    }
4766    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4767        self.inner.channel().on_closed()
4768    }
4769
4770    #[cfg(target_os = "fuchsia")]
4771    fn signal_peer(
4772        &self,
4773        clear_mask: zx::Signals,
4774        set_mask: zx::Signals,
4775    ) -> Result<(), zx_status::Status> {
4776        use fidl::Peered;
4777        self.inner.channel().signal_peer(clear_mask, set_mask)
4778    }
4779}
4780
4781impl ServiceInstancePublisherControlHandle {}
4782
4783#[must_use = "FIDL methods require a response to be sent"]
4784#[derive(Debug)]
4785pub struct ServiceInstancePublisherPublishServiceInstanceResponder {
4786    control_handle: std::mem::ManuallyDrop<ServiceInstancePublisherControlHandle>,
4787    tx_id: u32,
4788}
4789
4790/// Set the the channel to be shutdown (see [`ServiceInstancePublisherControlHandle::shutdown`])
4791/// if the responder is dropped without sending a response, so that the client
4792/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4793impl std::ops::Drop for ServiceInstancePublisherPublishServiceInstanceResponder {
4794    fn drop(&mut self) {
4795        self.control_handle.shutdown();
4796        // Safety: drops once, never accessed again
4797        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4798    }
4799}
4800
4801impl fidl::endpoints::Responder for ServiceInstancePublisherPublishServiceInstanceResponder {
4802    type ControlHandle = ServiceInstancePublisherControlHandle;
4803
4804    fn control_handle(&self) -> &ServiceInstancePublisherControlHandle {
4805        &self.control_handle
4806    }
4807
4808    fn drop_without_shutdown(mut self) {
4809        // Safety: drops once, never accessed again due to mem::forget
4810        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4811        // Prevent Drop from running (which would shut down the channel)
4812        std::mem::forget(self);
4813    }
4814}
4815
4816impl ServiceInstancePublisherPublishServiceInstanceResponder {
4817    /// Sends a response to the FIDL transaction.
4818    ///
4819    /// Sets the channel to shutdown if an error occurs.
4820    pub fn send(
4821        self,
4822        mut result: Result<(), PublishServiceInstanceError>,
4823    ) -> Result<(), fidl::Error> {
4824        let _result = self.send_raw(result);
4825        if _result.is_err() {
4826            self.control_handle.shutdown();
4827        }
4828        self.drop_without_shutdown();
4829        _result
4830    }
4831
4832    /// Similar to "send" but does not shutdown the channel if an error occurs.
4833    pub fn send_no_shutdown_on_err(
4834        self,
4835        mut result: Result<(), PublishServiceInstanceError>,
4836    ) -> Result<(), fidl::Error> {
4837        let _result = self.send_raw(result);
4838        self.drop_without_shutdown();
4839        _result
4840    }
4841
4842    fn send_raw(
4843        &self,
4844        mut result: Result<(), PublishServiceInstanceError>,
4845    ) -> Result<(), fidl::Error> {
4846        self.control_handle.inner.send::<fidl::encoding::ResultType<
4847            fidl::encoding::EmptyStruct,
4848            PublishServiceInstanceError,
4849        >>(
4850            result,
4851            self.tx_id,
4852            0x25d5fd0912cb5a9e,
4853            fidl::encoding::DynamicFlags::empty(),
4854        )
4855    }
4856}
4857
4858#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4859pub struct ServiceInstanceResolverMarker;
4860
4861impl fidl::endpoints::ProtocolMarker for ServiceInstanceResolverMarker {
4862    type Proxy = ServiceInstanceResolverProxy;
4863    type RequestStream = ServiceInstanceResolverRequestStream;
4864    #[cfg(target_os = "fuchsia")]
4865    type SynchronousProxy = ServiceInstanceResolverSynchronousProxy;
4866
4867    const DEBUG_NAME: &'static str = "fuchsia.net.mdns.ServiceInstanceResolver";
4868}
4869impl fidl::endpoints::DiscoverableProtocolMarker for ServiceInstanceResolverMarker {}
4870
4871pub trait ServiceInstanceResolverProxyInterface: Send + Sync {
4872    type ResolveServiceInstanceResponseFut: std::future::Future<Output = Result<ServiceInstance, fidl::Error>>
4873        + Send;
4874    fn r#resolve_service_instance(
4875        &self,
4876        service: &str,
4877        instance: &str,
4878        timeout: i64,
4879        options: &ServiceInstanceResolutionOptions,
4880    ) -> Self::ResolveServiceInstanceResponseFut;
4881}
4882#[derive(Debug)]
4883#[cfg(target_os = "fuchsia")]
4884pub struct ServiceInstanceResolverSynchronousProxy {
4885    client: fidl::client::sync::Client,
4886}
4887
4888#[cfg(target_os = "fuchsia")]
4889impl fidl::endpoints::SynchronousProxy for ServiceInstanceResolverSynchronousProxy {
4890    type Proxy = ServiceInstanceResolverProxy;
4891    type Protocol = ServiceInstanceResolverMarker;
4892
4893    fn from_channel(inner: fidl::Channel) -> Self {
4894        Self::new(inner)
4895    }
4896
4897    fn into_channel(self) -> fidl::Channel {
4898        self.client.into_channel()
4899    }
4900
4901    fn as_channel(&self) -> &fidl::Channel {
4902        self.client.as_channel()
4903    }
4904}
4905
4906#[cfg(target_os = "fuchsia")]
4907impl ServiceInstanceResolverSynchronousProxy {
4908    pub fn new(channel: fidl::Channel) -> Self {
4909        Self { client: fidl::client::sync::Client::new(channel) }
4910    }
4911
4912    pub fn into_channel(self) -> fidl::Channel {
4913        self.client.into_channel()
4914    }
4915
4916    /// Waits until an event arrives and returns it. It is safe for other
4917    /// threads to make concurrent requests while waiting for an event.
4918    pub fn wait_for_event(
4919        &self,
4920        deadline: zx::MonotonicInstant,
4921    ) -> Result<ServiceInstanceResolverEvent, fidl::Error> {
4922        ServiceInstanceResolverEvent::decode(
4923            self.client.wait_for_event::<ServiceInstanceResolverMarker>(deadline)?,
4924        )
4925    }
4926
4927    /// Resolves a specific service instance by sending an SRV query and returns
4928    /// the endpoints, target and text records.
4929    ///
4930    /// + request `service` name of the type of service to be resolved. For example, cast uses
4931    ///   '_googlecast._tcp.'.
4932    /// + request `instance` name of the instance to be resolved. This is often a descriptive name
4933    ///   such as `Office Printer` or a name containing a large random number.
4934    /// + request `timeout` specifies how long the service should wait before giving up when
4935    ///   waiting for a response to a resolution query.
4936    /// + request `options` options to be applied to the resolution.
4937    ///
4938    /// A successful resolution will return target and at least one endpoint.
4939    /// Unsuccessful resolution occurs when either the service instance doesn't respond or
4940    /// there is no endpoint (IP & port).
4941    pub fn r#resolve_service_instance(
4942        &self,
4943        mut service: &str,
4944        mut instance: &str,
4945        mut timeout: i64,
4946        mut options: &ServiceInstanceResolutionOptions,
4947        ___deadline: zx::MonotonicInstant,
4948    ) -> Result<ServiceInstance, fidl::Error> {
4949        let _response = self.client.send_query::<
4950            ServiceInstanceResolverResolveServiceInstanceRequest,
4951            ServiceInstanceResolverResolveServiceInstanceResponse,
4952            ServiceInstanceResolverMarker,
4953        >(
4954            (service, instance, timeout, options,),
4955            0x1a0d0c9fc6f2fd7,
4956            fidl::encoding::DynamicFlags::empty(),
4957            ___deadline,
4958        )?;
4959        Ok(_response.instance)
4960    }
4961}
4962
4963#[cfg(target_os = "fuchsia")]
4964impl From<ServiceInstanceResolverSynchronousProxy> for zx::NullableHandle {
4965    fn from(value: ServiceInstanceResolverSynchronousProxy) -> Self {
4966        value.into_channel().into()
4967    }
4968}
4969
4970#[cfg(target_os = "fuchsia")]
4971impl From<fidl::Channel> for ServiceInstanceResolverSynchronousProxy {
4972    fn from(value: fidl::Channel) -> Self {
4973        Self::new(value)
4974    }
4975}
4976
4977#[cfg(target_os = "fuchsia")]
4978impl fidl::endpoints::FromClient for ServiceInstanceResolverSynchronousProxy {
4979    type Protocol = ServiceInstanceResolverMarker;
4980
4981    fn from_client(value: fidl::endpoints::ClientEnd<ServiceInstanceResolverMarker>) -> Self {
4982        Self::new(value.into_channel())
4983    }
4984}
4985
4986#[derive(Debug, Clone)]
4987pub struct ServiceInstanceResolverProxy {
4988    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4989}
4990
4991impl fidl::endpoints::Proxy for ServiceInstanceResolverProxy {
4992    type Protocol = ServiceInstanceResolverMarker;
4993
4994    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4995        Self::new(inner)
4996    }
4997
4998    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4999        self.client.into_channel().map_err(|client| Self { client })
5000    }
5001
5002    fn as_channel(&self) -> &::fidl::AsyncChannel {
5003        self.client.as_channel()
5004    }
5005}
5006
5007impl ServiceInstanceResolverProxy {
5008    /// Create a new Proxy for fuchsia.net.mdns/ServiceInstanceResolver.
5009    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5010        let protocol_name =
5011            <ServiceInstanceResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5012        Self { client: fidl::client::Client::new(channel, protocol_name) }
5013    }
5014
5015    /// Get a Stream of events from the remote end of the protocol.
5016    ///
5017    /// # Panics
5018    ///
5019    /// Panics if the event stream was already taken.
5020    pub fn take_event_stream(&self) -> ServiceInstanceResolverEventStream {
5021        ServiceInstanceResolverEventStream { event_receiver: self.client.take_event_receiver() }
5022    }
5023
5024    /// Resolves a specific service instance by sending an SRV query and returns
5025    /// the endpoints, target and text records.
5026    ///
5027    /// + request `service` name of the type of service to be resolved. For example, cast uses
5028    ///   '_googlecast._tcp.'.
5029    /// + request `instance` name of the instance to be resolved. This is often a descriptive name
5030    ///   such as `Office Printer` or a name containing a large random number.
5031    /// + request `timeout` specifies how long the service should wait before giving up when
5032    ///   waiting for a response to a resolution query.
5033    /// + request `options` options to be applied to the resolution.
5034    ///
5035    /// A successful resolution will return target and at least one endpoint.
5036    /// Unsuccessful resolution occurs when either the service instance doesn't respond or
5037    /// there is no endpoint (IP & port).
5038    pub fn r#resolve_service_instance(
5039        &self,
5040        mut service: &str,
5041        mut instance: &str,
5042        mut timeout: i64,
5043        mut options: &ServiceInstanceResolutionOptions,
5044    ) -> fidl::client::QueryResponseFut<
5045        ServiceInstance,
5046        fidl::encoding::DefaultFuchsiaResourceDialect,
5047    > {
5048        ServiceInstanceResolverProxyInterface::r#resolve_service_instance(
5049            self, service, instance, timeout, options,
5050        )
5051    }
5052}
5053
5054impl ServiceInstanceResolverProxyInterface for ServiceInstanceResolverProxy {
5055    type ResolveServiceInstanceResponseFut = fidl::client::QueryResponseFut<
5056        ServiceInstance,
5057        fidl::encoding::DefaultFuchsiaResourceDialect,
5058    >;
5059    fn r#resolve_service_instance(
5060        &self,
5061        mut service: &str,
5062        mut instance: &str,
5063        mut timeout: i64,
5064        mut options: &ServiceInstanceResolutionOptions,
5065    ) -> Self::ResolveServiceInstanceResponseFut {
5066        fn _decode(
5067            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5068        ) -> Result<ServiceInstance, fidl::Error> {
5069            let _response = fidl::client::decode_transaction_body::<
5070                ServiceInstanceResolverResolveServiceInstanceResponse,
5071                fidl::encoding::DefaultFuchsiaResourceDialect,
5072                0x1a0d0c9fc6f2fd7,
5073            >(_buf?)?;
5074            Ok(_response.instance)
5075        }
5076        self.client.send_query_and_decode::<
5077            ServiceInstanceResolverResolveServiceInstanceRequest,
5078            ServiceInstance,
5079        >(
5080            (service, instance, timeout, options,),
5081            0x1a0d0c9fc6f2fd7,
5082            fidl::encoding::DynamicFlags::empty(),
5083            _decode,
5084        )
5085    }
5086}
5087
5088pub struct ServiceInstanceResolverEventStream {
5089    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5090}
5091
5092impl std::marker::Unpin for ServiceInstanceResolverEventStream {}
5093
5094impl futures::stream::FusedStream for ServiceInstanceResolverEventStream {
5095    fn is_terminated(&self) -> bool {
5096        self.event_receiver.is_terminated()
5097    }
5098}
5099
5100impl futures::Stream for ServiceInstanceResolverEventStream {
5101    type Item = Result<ServiceInstanceResolverEvent, fidl::Error>;
5102
5103    fn poll_next(
5104        mut self: std::pin::Pin<&mut Self>,
5105        cx: &mut std::task::Context<'_>,
5106    ) -> std::task::Poll<Option<Self::Item>> {
5107        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5108            &mut self.event_receiver,
5109            cx
5110        )?) {
5111            Some(buf) => std::task::Poll::Ready(Some(ServiceInstanceResolverEvent::decode(buf))),
5112            None => std::task::Poll::Ready(None),
5113        }
5114    }
5115}
5116
5117#[derive(Debug)]
5118pub enum ServiceInstanceResolverEvent {}
5119
5120impl ServiceInstanceResolverEvent {
5121    /// Decodes a message buffer as a [`ServiceInstanceResolverEvent`].
5122    fn decode(
5123        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5124    ) -> Result<ServiceInstanceResolverEvent, fidl::Error> {
5125        let (bytes, _handles) = buf.split_mut();
5126        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5127        debug_assert_eq!(tx_header.tx_id, 0);
5128        match tx_header.ordinal {
5129            _ => Err(fidl::Error::UnknownOrdinal {
5130                ordinal: tx_header.ordinal,
5131                protocol_name:
5132                    <ServiceInstanceResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5133            }),
5134        }
5135    }
5136}
5137
5138/// A Stream of incoming requests for fuchsia.net.mdns/ServiceInstanceResolver.
5139pub struct ServiceInstanceResolverRequestStream {
5140    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5141    is_terminated: bool,
5142}
5143
5144impl std::marker::Unpin for ServiceInstanceResolverRequestStream {}
5145
5146impl futures::stream::FusedStream for ServiceInstanceResolverRequestStream {
5147    fn is_terminated(&self) -> bool {
5148        self.is_terminated
5149    }
5150}
5151
5152impl fidl::endpoints::RequestStream for ServiceInstanceResolverRequestStream {
5153    type Protocol = ServiceInstanceResolverMarker;
5154    type ControlHandle = ServiceInstanceResolverControlHandle;
5155
5156    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5157        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5158    }
5159
5160    fn control_handle(&self) -> Self::ControlHandle {
5161        ServiceInstanceResolverControlHandle { inner: self.inner.clone() }
5162    }
5163
5164    fn into_inner(
5165        self,
5166    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5167    {
5168        (self.inner, self.is_terminated)
5169    }
5170
5171    fn from_inner(
5172        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5173        is_terminated: bool,
5174    ) -> Self {
5175        Self { inner, is_terminated }
5176    }
5177}
5178
5179impl futures::Stream for ServiceInstanceResolverRequestStream {
5180    type Item = Result<ServiceInstanceResolverRequest, fidl::Error>;
5181
5182    fn poll_next(
5183        mut self: std::pin::Pin<&mut Self>,
5184        cx: &mut std::task::Context<'_>,
5185    ) -> std::task::Poll<Option<Self::Item>> {
5186        let this = &mut *self;
5187        if this.inner.check_shutdown(cx) {
5188            this.is_terminated = true;
5189            return std::task::Poll::Ready(None);
5190        }
5191        if this.is_terminated {
5192            panic!("polled ServiceInstanceResolverRequestStream after completion");
5193        }
5194        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5195            |bytes, handles| {
5196                match this.inner.channel().read_etc(cx, bytes, handles) {
5197                    std::task::Poll::Ready(Ok(())) => {}
5198                    std::task::Poll::Pending => return std::task::Poll::Pending,
5199                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5200                        this.is_terminated = true;
5201                        return std::task::Poll::Ready(None);
5202                    }
5203                    std::task::Poll::Ready(Err(e)) => {
5204                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5205                            e.into(),
5206                        ))));
5207                    }
5208                }
5209
5210                // A message has been received from the channel
5211                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5212
5213                std::task::Poll::Ready(Some(match header.ordinal {
5214                0x1a0d0c9fc6f2fd7 => {
5215                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5216                    let mut req = fidl::new_empty!(ServiceInstanceResolverResolveServiceInstanceRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5217                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceInstanceResolverResolveServiceInstanceRequest>(&header, _body_bytes, handles, &mut req)?;
5218                    let control_handle = ServiceInstanceResolverControlHandle {
5219                        inner: this.inner.clone(),
5220                    };
5221                    Ok(ServiceInstanceResolverRequest::ResolveServiceInstance {service: req.service,
5222instance: req.instance,
5223timeout: req.timeout,
5224options: req.options,
5225
5226                        responder: ServiceInstanceResolverResolveServiceInstanceResponder {
5227                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5228                            tx_id: header.tx_id,
5229                        },
5230                    })
5231                }
5232                _ => Err(fidl::Error::UnknownOrdinal {
5233                    ordinal: header.ordinal,
5234                    protocol_name: <ServiceInstanceResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5235                }),
5236            }))
5237            },
5238        )
5239    }
5240}
5241
5242/// Discoverable protocol for resolving service instances.
5243#[derive(Debug)]
5244pub enum ServiceInstanceResolverRequest {
5245    /// Resolves a specific service instance by sending an SRV query and returns
5246    /// the endpoints, target and text records.
5247    ///
5248    /// + request `service` name of the type of service to be resolved. For example, cast uses
5249    ///   '_googlecast._tcp.'.
5250    /// + request `instance` name of the instance to be resolved. This is often a descriptive name
5251    ///   such as `Office Printer` or a name containing a large random number.
5252    /// + request `timeout` specifies how long the service should wait before giving up when
5253    ///   waiting for a response to a resolution query.
5254    /// + request `options` options to be applied to the resolution.
5255    ///
5256    /// A successful resolution will return target and at least one endpoint.
5257    /// Unsuccessful resolution occurs when either the service instance doesn't respond or
5258    /// there is no endpoint (IP & port).
5259    ResolveServiceInstance {
5260        service: String,
5261        instance: String,
5262        timeout: i64,
5263        options: ServiceInstanceResolutionOptions,
5264        responder: ServiceInstanceResolverResolveServiceInstanceResponder,
5265    },
5266}
5267
5268impl ServiceInstanceResolverRequest {
5269    #[allow(irrefutable_let_patterns)]
5270    pub fn into_resolve_service_instance(
5271        self,
5272    ) -> Option<(
5273        String,
5274        String,
5275        i64,
5276        ServiceInstanceResolutionOptions,
5277        ServiceInstanceResolverResolveServiceInstanceResponder,
5278    )> {
5279        if let ServiceInstanceResolverRequest::ResolveServiceInstance {
5280            service,
5281            instance,
5282            timeout,
5283            options,
5284            responder,
5285        } = self
5286        {
5287            Some((service, instance, timeout, options, responder))
5288        } else {
5289            None
5290        }
5291    }
5292
5293    /// Name of the method defined in FIDL
5294    pub fn method_name(&self) -> &'static str {
5295        match *self {
5296            ServiceInstanceResolverRequest::ResolveServiceInstance { .. } => {
5297                "resolve_service_instance"
5298            }
5299        }
5300    }
5301}
5302
5303#[derive(Debug, Clone)]
5304pub struct ServiceInstanceResolverControlHandle {
5305    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5306}
5307
5308impl fidl::endpoints::ControlHandle for ServiceInstanceResolverControlHandle {
5309    fn shutdown(&self) {
5310        self.inner.shutdown()
5311    }
5312
5313    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5314        self.inner.shutdown_with_epitaph(status)
5315    }
5316
5317    fn is_closed(&self) -> bool {
5318        self.inner.channel().is_closed()
5319    }
5320    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5321        self.inner.channel().on_closed()
5322    }
5323
5324    #[cfg(target_os = "fuchsia")]
5325    fn signal_peer(
5326        &self,
5327        clear_mask: zx::Signals,
5328        set_mask: zx::Signals,
5329    ) -> Result<(), zx_status::Status> {
5330        use fidl::Peered;
5331        self.inner.channel().signal_peer(clear_mask, set_mask)
5332    }
5333}
5334
5335impl ServiceInstanceResolverControlHandle {}
5336
5337#[must_use = "FIDL methods require a response to be sent"]
5338#[derive(Debug)]
5339pub struct ServiceInstanceResolverResolveServiceInstanceResponder {
5340    control_handle: std::mem::ManuallyDrop<ServiceInstanceResolverControlHandle>,
5341    tx_id: u32,
5342}
5343
5344/// Set the the channel to be shutdown (see [`ServiceInstanceResolverControlHandle::shutdown`])
5345/// if the responder is dropped without sending a response, so that the client
5346/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5347impl std::ops::Drop for ServiceInstanceResolverResolveServiceInstanceResponder {
5348    fn drop(&mut self) {
5349        self.control_handle.shutdown();
5350        // Safety: drops once, never accessed again
5351        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5352    }
5353}
5354
5355impl fidl::endpoints::Responder for ServiceInstanceResolverResolveServiceInstanceResponder {
5356    type ControlHandle = ServiceInstanceResolverControlHandle;
5357
5358    fn control_handle(&self) -> &ServiceInstanceResolverControlHandle {
5359        &self.control_handle
5360    }
5361
5362    fn drop_without_shutdown(mut self) {
5363        // Safety: drops once, never accessed again due to mem::forget
5364        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5365        // Prevent Drop from running (which would shut down the channel)
5366        std::mem::forget(self);
5367    }
5368}
5369
5370impl ServiceInstanceResolverResolveServiceInstanceResponder {
5371    /// Sends a response to the FIDL transaction.
5372    ///
5373    /// Sets the channel to shutdown if an error occurs.
5374    pub fn send(self, mut instance: &ServiceInstance) -> Result<(), fidl::Error> {
5375        let _result = self.send_raw(instance);
5376        if _result.is_err() {
5377            self.control_handle.shutdown();
5378        }
5379        self.drop_without_shutdown();
5380        _result
5381    }
5382
5383    /// Similar to "send" but does not shutdown the channel if an error occurs.
5384    pub fn send_no_shutdown_on_err(
5385        self,
5386        mut instance: &ServiceInstance,
5387    ) -> Result<(), fidl::Error> {
5388        let _result = self.send_raw(instance);
5389        self.drop_without_shutdown();
5390        _result
5391    }
5392
5393    fn send_raw(&self, mut instance: &ServiceInstance) -> Result<(), fidl::Error> {
5394        self.control_handle.inner.send::<ServiceInstanceResolverResolveServiceInstanceResponse>(
5395            (instance,),
5396            self.tx_id,
5397            0x1a0d0c9fc6f2fd7,
5398            fidl::encoding::DynamicFlags::empty(),
5399        )
5400    }
5401}
5402
5403#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5404pub struct ServiceSubscriberMarker;
5405
5406impl fidl::endpoints::ProtocolMarker for ServiceSubscriberMarker {
5407    type Proxy = ServiceSubscriberProxy;
5408    type RequestStream = ServiceSubscriberRequestStream;
5409    #[cfg(target_os = "fuchsia")]
5410    type SynchronousProxy = ServiceSubscriberSynchronousProxy;
5411
5412    const DEBUG_NAME: &'static str = "(anonymous) ServiceSubscriber";
5413}
5414
5415pub trait ServiceSubscriberProxyInterface: Send + Sync {
5416    type OnInstanceDiscoveredResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
5417        + Send;
5418    fn r#on_instance_discovered(
5419        &self,
5420        instance: &ServiceInstance,
5421    ) -> Self::OnInstanceDiscoveredResponseFut;
5422    type OnInstanceChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5423    fn r#on_instance_changed(
5424        &self,
5425        instance: &ServiceInstance,
5426    ) -> Self::OnInstanceChangedResponseFut;
5427    type OnInstanceLostResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5428    fn r#on_instance_lost(&self, service: &str, instance: &str) -> Self::OnInstanceLostResponseFut;
5429    type OnQueryResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5430    fn r#on_query(&self, resource_type: ResourceType) -> Self::OnQueryResponseFut;
5431}
5432#[derive(Debug)]
5433#[cfg(target_os = "fuchsia")]
5434pub struct ServiceSubscriberSynchronousProxy {
5435    client: fidl::client::sync::Client,
5436}
5437
5438#[cfg(target_os = "fuchsia")]
5439impl fidl::endpoints::SynchronousProxy for ServiceSubscriberSynchronousProxy {
5440    type Proxy = ServiceSubscriberProxy;
5441    type Protocol = ServiceSubscriberMarker;
5442
5443    fn from_channel(inner: fidl::Channel) -> Self {
5444        Self::new(inner)
5445    }
5446
5447    fn into_channel(self) -> fidl::Channel {
5448        self.client.into_channel()
5449    }
5450
5451    fn as_channel(&self) -> &fidl::Channel {
5452        self.client.as_channel()
5453    }
5454}
5455
5456#[cfg(target_os = "fuchsia")]
5457impl ServiceSubscriberSynchronousProxy {
5458    pub fn new(channel: fidl::Channel) -> Self {
5459        Self { client: fidl::client::sync::Client::new(channel) }
5460    }
5461
5462    pub fn into_channel(self) -> fidl::Channel {
5463        self.client.into_channel()
5464    }
5465
5466    /// Waits until an event arrives and returns it. It is safe for other
5467    /// threads to make concurrent requests while waiting for an event.
5468    pub fn wait_for_event(
5469        &self,
5470        deadline: zx::MonotonicInstant,
5471    ) -> Result<ServiceSubscriberEvent, fidl::Error> {
5472        ServiceSubscriberEvent::decode(
5473            self.client.wait_for_event::<ServiceSubscriberMarker>(deadline)?,
5474        )
5475    }
5476
5477    /// Notifies the subscriber that a service instance has been discovered.
5478    pub fn r#on_instance_discovered(
5479        &self,
5480        mut instance: &ServiceInstance,
5481        ___deadline: zx::MonotonicInstant,
5482    ) -> Result<(), fidl::Error> {
5483        let _response = self.client.send_query::<
5484            ServiceSubscriberOnInstanceDiscoveredRequest,
5485            fidl::encoding::EmptyPayload,
5486            ServiceSubscriberMarker,
5487        >(
5488            (instance,),
5489            0x74aa039fd81dcab2,
5490            fidl::encoding::DynamicFlags::empty(),
5491            ___deadline,
5492        )?;
5493        Ok(_response)
5494    }
5495
5496    /// Notifies the subscriber that addresses or text for a known service
5497    /// instance have changed.
5498    pub fn r#on_instance_changed(
5499        &self,
5500        mut instance: &ServiceInstance,
5501        ___deadline: zx::MonotonicInstant,
5502    ) -> Result<(), fidl::Error> {
5503        let _response = self.client.send_query::<
5504            ServiceSubscriberOnInstanceChangedRequest,
5505            fidl::encoding::EmptyPayload,
5506            ServiceSubscriberMarker,
5507        >(
5508            (instance,),
5509            0x24da258aad929434,
5510            fidl::encoding::DynamicFlags::empty(),
5511            ___deadline,
5512        )?;
5513        Ok(_response)
5514    }
5515
5516    /// Notifies the subscriber that a known service instance has been lost.
5517    pub fn r#on_instance_lost(
5518        &self,
5519        mut service: &str,
5520        mut instance: &str,
5521        ___deadline: zx::MonotonicInstant,
5522    ) -> Result<(), fidl::Error> {
5523        let _response = self.client.send_query::<
5524            ServiceSubscriberOnInstanceLostRequest,
5525            fidl::encoding::EmptyPayload,
5526            ServiceSubscriberMarker,
5527        >(
5528            (service, instance,),
5529            0x5beddb781791773f,
5530            fidl::encoding::DynamicFlags::empty(),
5531            ___deadline,
5532        )?;
5533        Ok(_response)
5534    }
5535
5536    /// Notifies the subscriber that a PTR query has been sent.
5537    pub fn r#on_query(
5538        &self,
5539        mut resource_type: ResourceType,
5540        ___deadline: zx::MonotonicInstant,
5541    ) -> Result<(), fidl::Error> {
5542        let _response = self.client.send_query::<
5543            ServiceSubscriberOnQueryRequest,
5544            fidl::encoding::EmptyPayload,
5545            ServiceSubscriberMarker,
5546        >(
5547            (resource_type,),
5548            0x1d0496189fdb23f5,
5549            fidl::encoding::DynamicFlags::empty(),
5550            ___deadline,
5551        )?;
5552        Ok(_response)
5553    }
5554}
5555
5556#[cfg(target_os = "fuchsia")]
5557impl From<ServiceSubscriberSynchronousProxy> for zx::NullableHandle {
5558    fn from(value: ServiceSubscriberSynchronousProxy) -> Self {
5559        value.into_channel().into()
5560    }
5561}
5562
5563#[cfg(target_os = "fuchsia")]
5564impl From<fidl::Channel> for ServiceSubscriberSynchronousProxy {
5565    fn from(value: fidl::Channel) -> Self {
5566        Self::new(value)
5567    }
5568}
5569
5570#[cfg(target_os = "fuchsia")]
5571impl fidl::endpoints::FromClient for ServiceSubscriberSynchronousProxy {
5572    type Protocol = ServiceSubscriberMarker;
5573
5574    fn from_client(value: fidl::endpoints::ClientEnd<ServiceSubscriberMarker>) -> Self {
5575        Self::new(value.into_channel())
5576    }
5577}
5578
5579#[derive(Debug, Clone)]
5580pub struct ServiceSubscriberProxy {
5581    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5582}
5583
5584impl fidl::endpoints::Proxy for ServiceSubscriberProxy {
5585    type Protocol = ServiceSubscriberMarker;
5586
5587    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5588        Self::new(inner)
5589    }
5590
5591    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5592        self.client.into_channel().map_err(|client| Self { client })
5593    }
5594
5595    fn as_channel(&self) -> &::fidl::AsyncChannel {
5596        self.client.as_channel()
5597    }
5598}
5599
5600impl ServiceSubscriberProxy {
5601    /// Create a new Proxy for fuchsia.net.mdns/ServiceSubscriber.
5602    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5603        let protocol_name =
5604            <ServiceSubscriberMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5605        Self { client: fidl::client::Client::new(channel, protocol_name) }
5606    }
5607
5608    /// Get a Stream of events from the remote end of the protocol.
5609    ///
5610    /// # Panics
5611    ///
5612    /// Panics if the event stream was already taken.
5613    pub fn take_event_stream(&self) -> ServiceSubscriberEventStream {
5614        ServiceSubscriberEventStream { event_receiver: self.client.take_event_receiver() }
5615    }
5616
5617    /// Notifies the subscriber that a service instance has been discovered.
5618    pub fn r#on_instance_discovered(
5619        &self,
5620        mut instance: &ServiceInstance,
5621    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5622        ServiceSubscriberProxyInterface::r#on_instance_discovered(self, instance)
5623    }
5624
5625    /// Notifies the subscriber that addresses or text for a known service
5626    /// instance have changed.
5627    pub fn r#on_instance_changed(
5628        &self,
5629        mut instance: &ServiceInstance,
5630    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5631        ServiceSubscriberProxyInterface::r#on_instance_changed(self, instance)
5632    }
5633
5634    /// Notifies the subscriber that a known service instance has been lost.
5635    pub fn r#on_instance_lost(
5636        &self,
5637        mut service: &str,
5638        mut instance: &str,
5639    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5640        ServiceSubscriberProxyInterface::r#on_instance_lost(self, service, instance)
5641    }
5642
5643    /// Notifies the subscriber that a PTR query has been sent.
5644    pub fn r#on_query(
5645        &self,
5646        mut resource_type: ResourceType,
5647    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5648        ServiceSubscriberProxyInterface::r#on_query(self, resource_type)
5649    }
5650}
5651
5652impl ServiceSubscriberProxyInterface for ServiceSubscriberProxy {
5653    type OnInstanceDiscoveredResponseFut =
5654        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5655    fn r#on_instance_discovered(
5656        &self,
5657        mut instance: &ServiceInstance,
5658    ) -> Self::OnInstanceDiscoveredResponseFut {
5659        fn _decode(
5660            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5661        ) -> Result<(), fidl::Error> {
5662            let _response = fidl::client::decode_transaction_body::<
5663                fidl::encoding::EmptyPayload,
5664                fidl::encoding::DefaultFuchsiaResourceDialect,
5665                0x74aa039fd81dcab2,
5666            >(_buf?)?;
5667            Ok(_response)
5668        }
5669        self.client.send_query_and_decode::<ServiceSubscriberOnInstanceDiscoveredRequest, ()>(
5670            (instance,),
5671            0x74aa039fd81dcab2,
5672            fidl::encoding::DynamicFlags::empty(),
5673            _decode,
5674        )
5675    }
5676
5677    type OnInstanceChangedResponseFut =
5678        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5679    fn r#on_instance_changed(
5680        &self,
5681        mut instance: &ServiceInstance,
5682    ) -> Self::OnInstanceChangedResponseFut {
5683        fn _decode(
5684            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5685        ) -> Result<(), fidl::Error> {
5686            let _response = fidl::client::decode_transaction_body::<
5687                fidl::encoding::EmptyPayload,
5688                fidl::encoding::DefaultFuchsiaResourceDialect,
5689                0x24da258aad929434,
5690            >(_buf?)?;
5691            Ok(_response)
5692        }
5693        self.client.send_query_and_decode::<ServiceSubscriberOnInstanceChangedRequest, ()>(
5694            (instance,),
5695            0x24da258aad929434,
5696            fidl::encoding::DynamicFlags::empty(),
5697            _decode,
5698        )
5699    }
5700
5701    type OnInstanceLostResponseFut =
5702        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5703    fn r#on_instance_lost(
5704        &self,
5705        mut service: &str,
5706        mut instance: &str,
5707    ) -> Self::OnInstanceLostResponseFut {
5708        fn _decode(
5709            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5710        ) -> Result<(), fidl::Error> {
5711            let _response = fidl::client::decode_transaction_body::<
5712                fidl::encoding::EmptyPayload,
5713                fidl::encoding::DefaultFuchsiaResourceDialect,
5714                0x5beddb781791773f,
5715            >(_buf?)?;
5716            Ok(_response)
5717        }
5718        self.client.send_query_and_decode::<ServiceSubscriberOnInstanceLostRequest, ()>(
5719            (service, instance),
5720            0x5beddb781791773f,
5721            fidl::encoding::DynamicFlags::empty(),
5722            _decode,
5723        )
5724    }
5725
5726    type OnQueryResponseFut =
5727        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5728    fn r#on_query(&self, mut resource_type: ResourceType) -> Self::OnQueryResponseFut {
5729        fn _decode(
5730            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5731        ) -> Result<(), fidl::Error> {
5732            let _response = fidl::client::decode_transaction_body::<
5733                fidl::encoding::EmptyPayload,
5734                fidl::encoding::DefaultFuchsiaResourceDialect,
5735                0x1d0496189fdb23f5,
5736            >(_buf?)?;
5737            Ok(_response)
5738        }
5739        self.client.send_query_and_decode::<ServiceSubscriberOnQueryRequest, ()>(
5740            (resource_type,),
5741            0x1d0496189fdb23f5,
5742            fidl::encoding::DynamicFlags::empty(),
5743            _decode,
5744        )
5745    }
5746}
5747
5748pub struct ServiceSubscriberEventStream {
5749    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5750}
5751
5752impl std::marker::Unpin for ServiceSubscriberEventStream {}
5753
5754impl futures::stream::FusedStream for ServiceSubscriberEventStream {
5755    fn is_terminated(&self) -> bool {
5756        self.event_receiver.is_terminated()
5757    }
5758}
5759
5760impl futures::Stream for ServiceSubscriberEventStream {
5761    type Item = Result<ServiceSubscriberEvent, fidl::Error>;
5762
5763    fn poll_next(
5764        mut self: std::pin::Pin<&mut Self>,
5765        cx: &mut std::task::Context<'_>,
5766    ) -> std::task::Poll<Option<Self::Item>> {
5767        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5768            &mut self.event_receiver,
5769            cx
5770        )?) {
5771            Some(buf) => std::task::Poll::Ready(Some(ServiceSubscriberEvent::decode(buf))),
5772            None => std::task::Poll::Ready(None),
5773        }
5774    }
5775}
5776
5777#[derive(Debug)]
5778pub enum ServiceSubscriberEvent {}
5779
5780impl ServiceSubscriberEvent {
5781    /// Decodes a message buffer as a [`ServiceSubscriberEvent`].
5782    fn decode(
5783        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5784    ) -> Result<ServiceSubscriberEvent, fidl::Error> {
5785        let (bytes, _handles) = buf.split_mut();
5786        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5787        debug_assert_eq!(tx_header.tx_id, 0);
5788        match tx_header.ordinal {
5789            _ => Err(fidl::Error::UnknownOrdinal {
5790                ordinal: tx_header.ordinal,
5791                protocol_name:
5792                    <ServiceSubscriberMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5793            }),
5794        }
5795    }
5796}
5797
5798/// A Stream of incoming requests for fuchsia.net.mdns/ServiceSubscriber.
5799pub struct ServiceSubscriberRequestStream {
5800    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5801    is_terminated: bool,
5802}
5803
5804impl std::marker::Unpin for ServiceSubscriberRequestStream {}
5805
5806impl futures::stream::FusedStream for ServiceSubscriberRequestStream {
5807    fn is_terminated(&self) -> bool {
5808        self.is_terminated
5809    }
5810}
5811
5812impl fidl::endpoints::RequestStream for ServiceSubscriberRequestStream {
5813    type Protocol = ServiceSubscriberMarker;
5814    type ControlHandle = ServiceSubscriberControlHandle;
5815
5816    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5817        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5818    }
5819
5820    fn control_handle(&self) -> Self::ControlHandle {
5821        ServiceSubscriberControlHandle { inner: self.inner.clone() }
5822    }
5823
5824    fn into_inner(
5825        self,
5826    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5827    {
5828        (self.inner, self.is_terminated)
5829    }
5830
5831    fn from_inner(
5832        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5833        is_terminated: bool,
5834    ) -> Self {
5835        Self { inner, is_terminated }
5836    }
5837}
5838
5839impl futures::Stream for ServiceSubscriberRequestStream {
5840    type Item = Result<ServiceSubscriberRequest, fidl::Error>;
5841
5842    fn poll_next(
5843        mut self: std::pin::Pin<&mut Self>,
5844        cx: &mut std::task::Context<'_>,
5845    ) -> std::task::Poll<Option<Self::Item>> {
5846        let this = &mut *self;
5847        if this.inner.check_shutdown(cx) {
5848            this.is_terminated = true;
5849            return std::task::Poll::Ready(None);
5850        }
5851        if this.is_terminated {
5852            panic!("polled ServiceSubscriberRequestStream after completion");
5853        }
5854        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5855            |bytes, handles| {
5856                match this.inner.channel().read_etc(cx, bytes, handles) {
5857                    std::task::Poll::Ready(Ok(())) => {}
5858                    std::task::Poll::Pending => return std::task::Poll::Pending,
5859                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5860                        this.is_terminated = true;
5861                        return std::task::Poll::Ready(None);
5862                    }
5863                    std::task::Poll::Ready(Err(e)) => {
5864                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5865                            e.into(),
5866                        ))));
5867                    }
5868                }
5869
5870                // A message has been received from the channel
5871                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5872
5873                std::task::Poll::Ready(Some(match header.ordinal {
5874                    0x74aa039fd81dcab2 => {
5875                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5876                        let mut req = fidl::new_empty!(
5877                            ServiceSubscriberOnInstanceDiscoveredRequest,
5878                            fidl::encoding::DefaultFuchsiaResourceDialect
5879                        );
5880                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriberOnInstanceDiscoveredRequest>(&header, _body_bytes, handles, &mut req)?;
5881                        let control_handle =
5882                            ServiceSubscriberControlHandle { inner: this.inner.clone() };
5883                        Ok(ServiceSubscriberRequest::OnInstanceDiscovered {
5884                            instance: req.instance,
5885
5886                            responder: ServiceSubscriberOnInstanceDiscoveredResponder {
5887                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5888                                tx_id: header.tx_id,
5889                            },
5890                        })
5891                    }
5892                    0x24da258aad929434 => {
5893                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5894                        let mut req = fidl::new_empty!(
5895                            ServiceSubscriberOnInstanceChangedRequest,
5896                            fidl::encoding::DefaultFuchsiaResourceDialect
5897                        );
5898                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriberOnInstanceChangedRequest>(&header, _body_bytes, handles, &mut req)?;
5899                        let control_handle =
5900                            ServiceSubscriberControlHandle { inner: this.inner.clone() };
5901                        Ok(ServiceSubscriberRequest::OnInstanceChanged {
5902                            instance: req.instance,
5903
5904                            responder: ServiceSubscriberOnInstanceChangedResponder {
5905                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5906                                tx_id: header.tx_id,
5907                            },
5908                        })
5909                    }
5910                    0x5beddb781791773f => {
5911                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5912                        let mut req = fidl::new_empty!(
5913                            ServiceSubscriberOnInstanceLostRequest,
5914                            fidl::encoding::DefaultFuchsiaResourceDialect
5915                        );
5916                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriberOnInstanceLostRequest>(&header, _body_bytes, handles, &mut req)?;
5917                        let control_handle =
5918                            ServiceSubscriberControlHandle { inner: this.inner.clone() };
5919                        Ok(ServiceSubscriberRequest::OnInstanceLost {
5920                            service: req.service,
5921                            instance: req.instance,
5922
5923                            responder: ServiceSubscriberOnInstanceLostResponder {
5924                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5925                                tx_id: header.tx_id,
5926                            },
5927                        })
5928                    }
5929                    0x1d0496189fdb23f5 => {
5930                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5931                        let mut req = fidl::new_empty!(
5932                            ServiceSubscriberOnQueryRequest,
5933                            fidl::encoding::DefaultFuchsiaResourceDialect
5934                        );
5935                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriberOnQueryRequest>(&header, _body_bytes, handles, &mut req)?;
5936                        let control_handle =
5937                            ServiceSubscriberControlHandle { inner: this.inner.clone() };
5938                        Ok(ServiceSubscriberRequest::OnQuery {
5939                            resource_type: req.resource_type,
5940
5941                            responder: ServiceSubscriberOnQueryResponder {
5942                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5943                                tx_id: header.tx_id,
5944                            },
5945                        })
5946                    }
5947                    _ => Err(fidl::Error::UnknownOrdinal {
5948                        ordinal: header.ordinal,
5949                        protocol_name:
5950                            <ServiceSubscriberMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5951                    }),
5952                }))
5953            },
5954        )
5955    }
5956}
5957
5958/// Client-implemented interface for subscribers. Method replies are used to
5959/// throttle traffic. The service won't necessarily wait for a reply before
5960/// calling another method.
5961#[derive(Debug)]
5962pub enum ServiceSubscriberRequest {
5963    /// Notifies the subscriber that a service instance has been discovered.
5964    OnInstanceDiscovered {
5965        instance: ServiceInstance,
5966        responder: ServiceSubscriberOnInstanceDiscoveredResponder,
5967    },
5968    /// Notifies the subscriber that addresses or text for a known service
5969    /// instance have changed.
5970    OnInstanceChanged {
5971        instance: ServiceInstance,
5972        responder: ServiceSubscriberOnInstanceChangedResponder,
5973    },
5974    /// Notifies the subscriber that a known service instance has been lost.
5975    OnInstanceLost {
5976        service: String,
5977        instance: String,
5978        responder: ServiceSubscriberOnInstanceLostResponder,
5979    },
5980    /// Notifies the subscriber that a PTR query has been sent.
5981    OnQuery { resource_type: ResourceType, responder: ServiceSubscriberOnQueryResponder },
5982}
5983
5984impl ServiceSubscriberRequest {
5985    #[allow(irrefutable_let_patterns)]
5986    pub fn into_on_instance_discovered(
5987        self,
5988    ) -> Option<(ServiceInstance, ServiceSubscriberOnInstanceDiscoveredResponder)> {
5989        if let ServiceSubscriberRequest::OnInstanceDiscovered { instance, responder } = self {
5990            Some((instance, responder))
5991        } else {
5992            None
5993        }
5994    }
5995
5996    #[allow(irrefutable_let_patterns)]
5997    pub fn into_on_instance_changed(
5998        self,
5999    ) -> Option<(ServiceInstance, ServiceSubscriberOnInstanceChangedResponder)> {
6000        if let ServiceSubscriberRequest::OnInstanceChanged { instance, responder } = self {
6001            Some((instance, responder))
6002        } else {
6003            None
6004        }
6005    }
6006
6007    #[allow(irrefutable_let_patterns)]
6008    pub fn into_on_instance_lost(
6009        self,
6010    ) -> Option<(String, String, ServiceSubscriberOnInstanceLostResponder)> {
6011        if let ServiceSubscriberRequest::OnInstanceLost { service, instance, responder } = self {
6012            Some((service, instance, responder))
6013        } else {
6014            None
6015        }
6016    }
6017
6018    #[allow(irrefutable_let_patterns)]
6019    pub fn into_on_query(self) -> Option<(ResourceType, ServiceSubscriberOnQueryResponder)> {
6020        if let ServiceSubscriberRequest::OnQuery { resource_type, responder } = self {
6021            Some((resource_type, responder))
6022        } else {
6023            None
6024        }
6025    }
6026
6027    /// Name of the method defined in FIDL
6028    pub fn method_name(&self) -> &'static str {
6029        match *self {
6030            ServiceSubscriberRequest::OnInstanceDiscovered { .. } => "on_instance_discovered",
6031            ServiceSubscriberRequest::OnInstanceChanged { .. } => "on_instance_changed",
6032            ServiceSubscriberRequest::OnInstanceLost { .. } => "on_instance_lost",
6033            ServiceSubscriberRequest::OnQuery { .. } => "on_query",
6034        }
6035    }
6036}
6037
6038#[derive(Debug, Clone)]
6039pub struct ServiceSubscriberControlHandle {
6040    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6041}
6042
6043impl fidl::endpoints::ControlHandle for ServiceSubscriberControlHandle {
6044    fn shutdown(&self) {
6045        self.inner.shutdown()
6046    }
6047
6048    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6049        self.inner.shutdown_with_epitaph(status)
6050    }
6051
6052    fn is_closed(&self) -> bool {
6053        self.inner.channel().is_closed()
6054    }
6055    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6056        self.inner.channel().on_closed()
6057    }
6058
6059    #[cfg(target_os = "fuchsia")]
6060    fn signal_peer(
6061        &self,
6062        clear_mask: zx::Signals,
6063        set_mask: zx::Signals,
6064    ) -> Result<(), zx_status::Status> {
6065        use fidl::Peered;
6066        self.inner.channel().signal_peer(clear_mask, set_mask)
6067    }
6068}
6069
6070impl ServiceSubscriberControlHandle {}
6071
6072#[must_use = "FIDL methods require a response to be sent"]
6073#[derive(Debug)]
6074pub struct ServiceSubscriberOnInstanceDiscoveredResponder {
6075    control_handle: std::mem::ManuallyDrop<ServiceSubscriberControlHandle>,
6076    tx_id: u32,
6077}
6078
6079/// Set the the channel to be shutdown (see [`ServiceSubscriberControlHandle::shutdown`])
6080/// if the responder is dropped without sending a response, so that the client
6081/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6082impl std::ops::Drop for ServiceSubscriberOnInstanceDiscoveredResponder {
6083    fn drop(&mut self) {
6084        self.control_handle.shutdown();
6085        // Safety: drops once, never accessed again
6086        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6087    }
6088}
6089
6090impl fidl::endpoints::Responder for ServiceSubscriberOnInstanceDiscoveredResponder {
6091    type ControlHandle = ServiceSubscriberControlHandle;
6092
6093    fn control_handle(&self) -> &ServiceSubscriberControlHandle {
6094        &self.control_handle
6095    }
6096
6097    fn drop_without_shutdown(mut self) {
6098        // Safety: drops once, never accessed again due to mem::forget
6099        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6100        // Prevent Drop from running (which would shut down the channel)
6101        std::mem::forget(self);
6102    }
6103}
6104
6105impl ServiceSubscriberOnInstanceDiscoveredResponder {
6106    /// Sends a response to the FIDL transaction.
6107    ///
6108    /// Sets the channel to shutdown if an error occurs.
6109    pub fn send(self) -> Result<(), fidl::Error> {
6110        let _result = self.send_raw();
6111        if _result.is_err() {
6112            self.control_handle.shutdown();
6113        }
6114        self.drop_without_shutdown();
6115        _result
6116    }
6117
6118    /// Similar to "send" but does not shutdown the channel if an error occurs.
6119    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6120        let _result = self.send_raw();
6121        self.drop_without_shutdown();
6122        _result
6123    }
6124
6125    fn send_raw(&self) -> Result<(), fidl::Error> {
6126        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6127            (),
6128            self.tx_id,
6129            0x74aa039fd81dcab2,
6130            fidl::encoding::DynamicFlags::empty(),
6131        )
6132    }
6133}
6134
6135#[must_use = "FIDL methods require a response to be sent"]
6136#[derive(Debug)]
6137pub struct ServiceSubscriberOnInstanceChangedResponder {
6138    control_handle: std::mem::ManuallyDrop<ServiceSubscriberControlHandle>,
6139    tx_id: u32,
6140}
6141
6142/// Set the the channel to be shutdown (see [`ServiceSubscriberControlHandle::shutdown`])
6143/// if the responder is dropped without sending a response, so that the client
6144/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6145impl std::ops::Drop for ServiceSubscriberOnInstanceChangedResponder {
6146    fn drop(&mut self) {
6147        self.control_handle.shutdown();
6148        // Safety: drops once, never accessed again
6149        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6150    }
6151}
6152
6153impl fidl::endpoints::Responder for ServiceSubscriberOnInstanceChangedResponder {
6154    type ControlHandle = ServiceSubscriberControlHandle;
6155
6156    fn control_handle(&self) -> &ServiceSubscriberControlHandle {
6157        &self.control_handle
6158    }
6159
6160    fn drop_without_shutdown(mut self) {
6161        // Safety: drops once, never accessed again due to mem::forget
6162        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6163        // Prevent Drop from running (which would shut down the channel)
6164        std::mem::forget(self);
6165    }
6166}
6167
6168impl ServiceSubscriberOnInstanceChangedResponder {
6169    /// Sends a response to the FIDL transaction.
6170    ///
6171    /// Sets the channel to shutdown if an error occurs.
6172    pub fn send(self) -> Result<(), fidl::Error> {
6173        let _result = self.send_raw();
6174        if _result.is_err() {
6175            self.control_handle.shutdown();
6176        }
6177        self.drop_without_shutdown();
6178        _result
6179    }
6180
6181    /// Similar to "send" but does not shutdown the channel if an error occurs.
6182    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6183        let _result = self.send_raw();
6184        self.drop_without_shutdown();
6185        _result
6186    }
6187
6188    fn send_raw(&self) -> Result<(), fidl::Error> {
6189        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6190            (),
6191            self.tx_id,
6192            0x24da258aad929434,
6193            fidl::encoding::DynamicFlags::empty(),
6194        )
6195    }
6196}
6197
6198#[must_use = "FIDL methods require a response to be sent"]
6199#[derive(Debug)]
6200pub struct ServiceSubscriberOnInstanceLostResponder {
6201    control_handle: std::mem::ManuallyDrop<ServiceSubscriberControlHandle>,
6202    tx_id: u32,
6203}
6204
6205/// Set the the channel to be shutdown (see [`ServiceSubscriberControlHandle::shutdown`])
6206/// if the responder is dropped without sending a response, so that the client
6207/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6208impl std::ops::Drop for ServiceSubscriberOnInstanceLostResponder {
6209    fn drop(&mut self) {
6210        self.control_handle.shutdown();
6211        // Safety: drops once, never accessed again
6212        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6213    }
6214}
6215
6216impl fidl::endpoints::Responder for ServiceSubscriberOnInstanceLostResponder {
6217    type ControlHandle = ServiceSubscriberControlHandle;
6218
6219    fn control_handle(&self) -> &ServiceSubscriberControlHandle {
6220        &self.control_handle
6221    }
6222
6223    fn drop_without_shutdown(mut self) {
6224        // Safety: drops once, never accessed again due to mem::forget
6225        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6226        // Prevent Drop from running (which would shut down the channel)
6227        std::mem::forget(self);
6228    }
6229}
6230
6231impl ServiceSubscriberOnInstanceLostResponder {
6232    /// Sends a response to the FIDL transaction.
6233    ///
6234    /// Sets the channel to shutdown if an error occurs.
6235    pub fn send(self) -> Result<(), fidl::Error> {
6236        let _result = self.send_raw();
6237        if _result.is_err() {
6238            self.control_handle.shutdown();
6239        }
6240        self.drop_without_shutdown();
6241        _result
6242    }
6243
6244    /// Similar to "send" but does not shutdown the channel if an error occurs.
6245    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6246        let _result = self.send_raw();
6247        self.drop_without_shutdown();
6248        _result
6249    }
6250
6251    fn send_raw(&self) -> Result<(), fidl::Error> {
6252        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6253            (),
6254            self.tx_id,
6255            0x5beddb781791773f,
6256            fidl::encoding::DynamicFlags::empty(),
6257        )
6258    }
6259}
6260
6261#[must_use = "FIDL methods require a response to be sent"]
6262#[derive(Debug)]
6263pub struct ServiceSubscriberOnQueryResponder {
6264    control_handle: std::mem::ManuallyDrop<ServiceSubscriberControlHandle>,
6265    tx_id: u32,
6266}
6267
6268/// Set the the channel to be shutdown (see [`ServiceSubscriberControlHandle::shutdown`])
6269/// if the responder is dropped without sending a response, so that the client
6270/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6271impl std::ops::Drop for ServiceSubscriberOnQueryResponder {
6272    fn drop(&mut self) {
6273        self.control_handle.shutdown();
6274        // Safety: drops once, never accessed again
6275        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6276    }
6277}
6278
6279impl fidl::endpoints::Responder for ServiceSubscriberOnQueryResponder {
6280    type ControlHandle = ServiceSubscriberControlHandle;
6281
6282    fn control_handle(&self) -> &ServiceSubscriberControlHandle {
6283        &self.control_handle
6284    }
6285
6286    fn drop_without_shutdown(mut self) {
6287        // Safety: drops once, never accessed again due to mem::forget
6288        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6289        // Prevent Drop from running (which would shut down the channel)
6290        std::mem::forget(self);
6291    }
6292}
6293
6294impl ServiceSubscriberOnQueryResponder {
6295    /// Sends a response to the FIDL transaction.
6296    ///
6297    /// Sets the channel to shutdown if an error occurs.
6298    pub fn send(self) -> Result<(), fidl::Error> {
6299        let _result = self.send_raw();
6300        if _result.is_err() {
6301            self.control_handle.shutdown();
6302        }
6303        self.drop_without_shutdown();
6304        _result
6305    }
6306
6307    /// Similar to "send" but does not shutdown the channel if an error occurs.
6308    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6309        let _result = self.send_raw();
6310        self.drop_without_shutdown();
6311        _result
6312    }
6313
6314    fn send_raw(&self) -> Result<(), fidl::Error> {
6315        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6316            (),
6317            self.tx_id,
6318            0x1d0496189fdb23f5,
6319            fidl::encoding::DynamicFlags::empty(),
6320        )
6321    }
6322}
6323
6324#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6325pub struct ServiceSubscriber2Marker;
6326
6327impl fidl::endpoints::ProtocolMarker for ServiceSubscriber2Marker {
6328    type Proxy = ServiceSubscriber2Proxy;
6329    type RequestStream = ServiceSubscriber2RequestStream;
6330    #[cfg(target_os = "fuchsia")]
6331    type SynchronousProxy = ServiceSubscriber2SynchronousProxy;
6332
6333    const DEBUG_NAME: &'static str = "fuchsia.net.mdns.ServiceSubscriber2";
6334}
6335impl fidl::endpoints::DiscoverableProtocolMarker for ServiceSubscriber2Marker {}
6336
6337pub trait ServiceSubscriber2ProxyInterface: Send + Sync {
6338    fn r#subscribe_to_service(
6339        &self,
6340        service: &str,
6341        options: &ServiceSubscriptionOptions,
6342        listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6343    ) -> Result<(), fidl::Error>;
6344    fn r#subscribe_to_all_services(
6345        &self,
6346        options: &ServiceSubscriptionOptions,
6347        listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6348    ) -> Result<(), fidl::Error>;
6349}
6350#[derive(Debug)]
6351#[cfg(target_os = "fuchsia")]
6352pub struct ServiceSubscriber2SynchronousProxy {
6353    client: fidl::client::sync::Client,
6354}
6355
6356#[cfg(target_os = "fuchsia")]
6357impl fidl::endpoints::SynchronousProxy for ServiceSubscriber2SynchronousProxy {
6358    type Proxy = ServiceSubscriber2Proxy;
6359    type Protocol = ServiceSubscriber2Marker;
6360
6361    fn from_channel(inner: fidl::Channel) -> Self {
6362        Self::new(inner)
6363    }
6364
6365    fn into_channel(self) -> fidl::Channel {
6366        self.client.into_channel()
6367    }
6368
6369    fn as_channel(&self) -> &fidl::Channel {
6370        self.client.as_channel()
6371    }
6372}
6373
6374#[cfg(target_os = "fuchsia")]
6375impl ServiceSubscriber2SynchronousProxy {
6376    pub fn new(channel: fidl::Channel) -> Self {
6377        Self { client: fidl::client::sync::Client::new(channel) }
6378    }
6379
6380    pub fn into_channel(self) -> fidl::Channel {
6381        self.client.into_channel()
6382    }
6383
6384    /// Waits until an event arrives and returns it. It is safe for other
6385    /// threads to make concurrent requests while waiting for an event.
6386    pub fn wait_for_event(
6387        &self,
6388        deadline: zx::MonotonicInstant,
6389    ) -> Result<ServiceSubscriber2Event, fidl::Error> {
6390        ServiceSubscriber2Event::decode(
6391            self.client.wait_for_event::<ServiceSubscriber2Marker>(deadline)?,
6392        )
6393    }
6394
6395    /// Subscribes to a service. The subscription lasts until `subscriber` is unbound.
6396    ///
6397    /// + request `service` name of the type of service to which to subscribe. For example, cast
6398    ///   uses '_googlecast._tcp.'. If this value is not a valid service name, `subscriber` is
6399    ///   closed immediately and an error message is logged.
6400    /// + request `options` options to be applied to the subscription.
6401    /// + request `listener` client end of the `ServiceSubscriptionListener` channel.
6402    pub fn r#subscribe_to_service(
6403        &self,
6404        mut service: &str,
6405        mut options: &ServiceSubscriptionOptions,
6406        mut listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6407    ) -> Result<(), fidl::Error> {
6408        self.client.send::<ServiceSubscriber2SubscribeToServiceRequest>(
6409            (service, options, listener),
6410            0x78f713d88dcf34aa,
6411            fidl::encoding::DynamicFlags::empty(),
6412        )
6413    }
6414
6415    /// Subscribes to all services. The subscription lasts until `subscriber` is unbound.
6416    ///
6417    /// + request `options` options to be applied to the subscription.
6418    /// + request `listener` client end of the `ServiceSubscriptionListener` channel.
6419    pub fn r#subscribe_to_all_services(
6420        &self,
6421        mut options: &ServiceSubscriptionOptions,
6422        mut listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6423    ) -> Result<(), fidl::Error> {
6424        self.client.send::<ServiceSubscriber2SubscribeToAllServicesRequest>(
6425            (options, listener),
6426            0x7c5192d46e380468,
6427            fidl::encoding::DynamicFlags::empty(),
6428        )
6429    }
6430}
6431
6432#[cfg(target_os = "fuchsia")]
6433impl From<ServiceSubscriber2SynchronousProxy> for zx::NullableHandle {
6434    fn from(value: ServiceSubscriber2SynchronousProxy) -> Self {
6435        value.into_channel().into()
6436    }
6437}
6438
6439#[cfg(target_os = "fuchsia")]
6440impl From<fidl::Channel> for ServiceSubscriber2SynchronousProxy {
6441    fn from(value: fidl::Channel) -> Self {
6442        Self::new(value)
6443    }
6444}
6445
6446#[cfg(target_os = "fuchsia")]
6447impl fidl::endpoints::FromClient for ServiceSubscriber2SynchronousProxy {
6448    type Protocol = ServiceSubscriber2Marker;
6449
6450    fn from_client(value: fidl::endpoints::ClientEnd<ServiceSubscriber2Marker>) -> Self {
6451        Self::new(value.into_channel())
6452    }
6453}
6454
6455#[derive(Debug, Clone)]
6456pub struct ServiceSubscriber2Proxy {
6457    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6458}
6459
6460impl fidl::endpoints::Proxy for ServiceSubscriber2Proxy {
6461    type Protocol = ServiceSubscriber2Marker;
6462
6463    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6464        Self::new(inner)
6465    }
6466
6467    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6468        self.client.into_channel().map_err(|client| Self { client })
6469    }
6470
6471    fn as_channel(&self) -> &::fidl::AsyncChannel {
6472        self.client.as_channel()
6473    }
6474}
6475
6476impl ServiceSubscriber2Proxy {
6477    /// Create a new Proxy for fuchsia.net.mdns/ServiceSubscriber2.
6478    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6479        let protocol_name =
6480            <ServiceSubscriber2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6481        Self { client: fidl::client::Client::new(channel, protocol_name) }
6482    }
6483
6484    /// Get a Stream of events from the remote end of the protocol.
6485    ///
6486    /// # Panics
6487    ///
6488    /// Panics if the event stream was already taken.
6489    pub fn take_event_stream(&self) -> ServiceSubscriber2EventStream {
6490        ServiceSubscriber2EventStream { event_receiver: self.client.take_event_receiver() }
6491    }
6492
6493    /// Subscribes to a service. The subscription lasts until `subscriber` is unbound.
6494    ///
6495    /// + request `service` name of the type of service to which to subscribe. For example, cast
6496    ///   uses '_googlecast._tcp.'. If this value is not a valid service name, `subscriber` is
6497    ///   closed immediately and an error message is logged.
6498    /// + request `options` options to be applied to the subscription.
6499    /// + request `listener` client end of the `ServiceSubscriptionListener` channel.
6500    pub fn r#subscribe_to_service(
6501        &self,
6502        mut service: &str,
6503        mut options: &ServiceSubscriptionOptions,
6504        mut listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6505    ) -> Result<(), fidl::Error> {
6506        ServiceSubscriber2ProxyInterface::r#subscribe_to_service(self, service, options, listener)
6507    }
6508
6509    /// Subscribes to all services. The subscription lasts until `subscriber` is unbound.
6510    ///
6511    /// + request `options` options to be applied to the subscription.
6512    /// + request `listener` client end of the `ServiceSubscriptionListener` channel.
6513    pub fn r#subscribe_to_all_services(
6514        &self,
6515        mut options: &ServiceSubscriptionOptions,
6516        mut listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6517    ) -> Result<(), fidl::Error> {
6518        ServiceSubscriber2ProxyInterface::r#subscribe_to_all_services(self, options, listener)
6519    }
6520}
6521
6522impl ServiceSubscriber2ProxyInterface for ServiceSubscriber2Proxy {
6523    fn r#subscribe_to_service(
6524        &self,
6525        mut service: &str,
6526        mut options: &ServiceSubscriptionOptions,
6527        mut listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6528    ) -> Result<(), fidl::Error> {
6529        self.client.send::<ServiceSubscriber2SubscribeToServiceRequest>(
6530            (service, options, listener),
6531            0x78f713d88dcf34aa,
6532            fidl::encoding::DynamicFlags::empty(),
6533        )
6534    }
6535
6536    fn r#subscribe_to_all_services(
6537        &self,
6538        mut options: &ServiceSubscriptionOptions,
6539        mut listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6540    ) -> Result<(), fidl::Error> {
6541        self.client.send::<ServiceSubscriber2SubscribeToAllServicesRequest>(
6542            (options, listener),
6543            0x7c5192d46e380468,
6544            fidl::encoding::DynamicFlags::empty(),
6545        )
6546    }
6547}
6548
6549pub struct ServiceSubscriber2EventStream {
6550    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6551}
6552
6553impl std::marker::Unpin for ServiceSubscriber2EventStream {}
6554
6555impl futures::stream::FusedStream for ServiceSubscriber2EventStream {
6556    fn is_terminated(&self) -> bool {
6557        self.event_receiver.is_terminated()
6558    }
6559}
6560
6561impl futures::Stream for ServiceSubscriber2EventStream {
6562    type Item = Result<ServiceSubscriber2Event, fidl::Error>;
6563
6564    fn poll_next(
6565        mut self: std::pin::Pin<&mut Self>,
6566        cx: &mut std::task::Context<'_>,
6567    ) -> std::task::Poll<Option<Self::Item>> {
6568        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6569            &mut self.event_receiver,
6570            cx
6571        )?) {
6572            Some(buf) => std::task::Poll::Ready(Some(ServiceSubscriber2Event::decode(buf))),
6573            None => std::task::Poll::Ready(None),
6574        }
6575    }
6576}
6577
6578#[derive(Debug)]
6579pub enum ServiceSubscriber2Event {}
6580
6581impl ServiceSubscriber2Event {
6582    /// Decodes a message buffer as a [`ServiceSubscriber2Event`].
6583    fn decode(
6584        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6585    ) -> Result<ServiceSubscriber2Event, fidl::Error> {
6586        let (bytes, _handles) = buf.split_mut();
6587        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6588        debug_assert_eq!(tx_header.tx_id, 0);
6589        match tx_header.ordinal {
6590            _ => Err(fidl::Error::UnknownOrdinal {
6591                ordinal: tx_header.ordinal,
6592                protocol_name:
6593                    <ServiceSubscriber2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6594            }),
6595        }
6596    }
6597}
6598
6599/// A Stream of incoming requests for fuchsia.net.mdns/ServiceSubscriber2.
6600pub struct ServiceSubscriber2RequestStream {
6601    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6602    is_terminated: bool,
6603}
6604
6605impl std::marker::Unpin for ServiceSubscriber2RequestStream {}
6606
6607impl futures::stream::FusedStream for ServiceSubscriber2RequestStream {
6608    fn is_terminated(&self) -> bool {
6609        self.is_terminated
6610    }
6611}
6612
6613impl fidl::endpoints::RequestStream for ServiceSubscriber2RequestStream {
6614    type Protocol = ServiceSubscriber2Marker;
6615    type ControlHandle = ServiceSubscriber2ControlHandle;
6616
6617    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6618        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6619    }
6620
6621    fn control_handle(&self) -> Self::ControlHandle {
6622        ServiceSubscriber2ControlHandle { inner: self.inner.clone() }
6623    }
6624
6625    fn into_inner(
6626        self,
6627    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6628    {
6629        (self.inner, self.is_terminated)
6630    }
6631
6632    fn from_inner(
6633        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6634        is_terminated: bool,
6635    ) -> Self {
6636        Self { inner, is_terminated }
6637    }
6638}
6639
6640impl futures::Stream for ServiceSubscriber2RequestStream {
6641    type Item = Result<ServiceSubscriber2Request, fidl::Error>;
6642
6643    fn poll_next(
6644        mut self: std::pin::Pin<&mut Self>,
6645        cx: &mut std::task::Context<'_>,
6646    ) -> std::task::Poll<Option<Self::Item>> {
6647        let this = &mut *self;
6648        if this.inner.check_shutdown(cx) {
6649            this.is_terminated = true;
6650            return std::task::Poll::Ready(None);
6651        }
6652        if this.is_terminated {
6653            panic!("polled ServiceSubscriber2RequestStream after completion");
6654        }
6655        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6656            |bytes, handles| {
6657                match this.inner.channel().read_etc(cx, bytes, handles) {
6658                    std::task::Poll::Ready(Ok(())) => {}
6659                    std::task::Poll::Pending => return std::task::Poll::Pending,
6660                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6661                        this.is_terminated = true;
6662                        return std::task::Poll::Ready(None);
6663                    }
6664                    std::task::Poll::Ready(Err(e)) => {
6665                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6666                            e.into(),
6667                        ))));
6668                    }
6669                }
6670
6671                // A message has been received from the channel
6672                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6673
6674                std::task::Poll::Ready(Some(match header.ordinal {
6675                0x78f713d88dcf34aa => {
6676                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6677                    let mut req = fidl::new_empty!(ServiceSubscriber2SubscribeToServiceRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
6678                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriber2SubscribeToServiceRequest>(&header, _body_bytes, handles, &mut req)?;
6679                    let control_handle = ServiceSubscriber2ControlHandle {
6680                        inner: this.inner.clone(),
6681                    };
6682                    Ok(ServiceSubscriber2Request::SubscribeToService {service: req.service,
6683options: req.options,
6684listener: req.listener,
6685
6686                        control_handle,
6687                    })
6688                }
6689                0x7c5192d46e380468 => {
6690                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6691                    let mut req = fidl::new_empty!(ServiceSubscriber2SubscribeToAllServicesRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
6692                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriber2SubscribeToAllServicesRequest>(&header, _body_bytes, handles, &mut req)?;
6693                    let control_handle = ServiceSubscriber2ControlHandle {
6694                        inner: this.inner.clone(),
6695                    };
6696                    Ok(ServiceSubscriber2Request::SubscribeToAllServices {options: req.options,
6697listener: req.listener,
6698
6699                        control_handle,
6700                    })
6701                }
6702                _ => Err(fidl::Error::UnknownOrdinal {
6703                    ordinal: header.ordinal,
6704                    protocol_name: <ServiceSubscriber2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6705                }),
6706            }))
6707            },
6708        )
6709    }
6710}
6711
6712/// Discoverable protocol for finding service instances.
6713#[derive(Debug)]
6714pub enum ServiceSubscriber2Request {
6715    /// Subscribes to a service. The subscription lasts until `subscriber` is unbound.
6716    ///
6717    /// + request `service` name of the type of service to which to subscribe. For example, cast
6718    ///   uses '_googlecast._tcp.'. If this value is not a valid service name, `subscriber` is
6719    ///   closed immediately and an error message is logged.
6720    /// + request `options` options to be applied to the subscription.
6721    /// + request `listener` client end of the `ServiceSubscriptionListener` channel.
6722    SubscribeToService {
6723        service: String,
6724        options: ServiceSubscriptionOptions,
6725        listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6726        control_handle: ServiceSubscriber2ControlHandle,
6727    },
6728    /// Subscribes to all services. The subscription lasts until `subscriber` is unbound.
6729    ///
6730    /// + request `options` options to be applied to the subscription.
6731    /// + request `listener` client end of the `ServiceSubscriptionListener` channel.
6732    SubscribeToAllServices {
6733        options: ServiceSubscriptionOptions,
6734        listener: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6735        control_handle: ServiceSubscriber2ControlHandle,
6736    },
6737}
6738
6739impl ServiceSubscriber2Request {
6740    #[allow(irrefutable_let_patterns)]
6741    pub fn into_subscribe_to_service(
6742        self,
6743    ) -> Option<(
6744        String,
6745        ServiceSubscriptionOptions,
6746        fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6747        ServiceSubscriber2ControlHandle,
6748    )> {
6749        if let ServiceSubscriber2Request::SubscribeToService {
6750            service,
6751            options,
6752            listener,
6753            control_handle,
6754        } = self
6755        {
6756            Some((service, options, listener, control_handle))
6757        } else {
6758            None
6759        }
6760    }
6761
6762    #[allow(irrefutable_let_patterns)]
6763    pub fn into_subscribe_to_all_services(
6764        self,
6765    ) -> Option<(
6766        ServiceSubscriptionOptions,
6767        fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
6768        ServiceSubscriber2ControlHandle,
6769    )> {
6770        if let ServiceSubscriber2Request::SubscribeToAllServices {
6771            options,
6772            listener,
6773            control_handle,
6774        } = self
6775        {
6776            Some((options, listener, control_handle))
6777        } else {
6778            None
6779        }
6780    }
6781
6782    /// Name of the method defined in FIDL
6783    pub fn method_name(&self) -> &'static str {
6784        match *self {
6785            ServiceSubscriber2Request::SubscribeToService { .. } => "subscribe_to_service",
6786            ServiceSubscriber2Request::SubscribeToAllServices { .. } => "subscribe_to_all_services",
6787        }
6788    }
6789}
6790
6791#[derive(Debug, Clone)]
6792pub struct ServiceSubscriber2ControlHandle {
6793    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6794}
6795
6796impl fidl::endpoints::ControlHandle for ServiceSubscriber2ControlHandle {
6797    fn shutdown(&self) {
6798        self.inner.shutdown()
6799    }
6800
6801    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6802        self.inner.shutdown_with_epitaph(status)
6803    }
6804
6805    fn is_closed(&self) -> bool {
6806        self.inner.channel().is_closed()
6807    }
6808    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6809        self.inner.channel().on_closed()
6810    }
6811
6812    #[cfg(target_os = "fuchsia")]
6813    fn signal_peer(
6814        &self,
6815        clear_mask: zx::Signals,
6816        set_mask: zx::Signals,
6817    ) -> Result<(), zx_status::Status> {
6818        use fidl::Peered;
6819        self.inner.channel().signal_peer(clear_mask, set_mask)
6820    }
6821}
6822
6823impl ServiceSubscriber2ControlHandle {}
6824
6825#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6826pub struct ServiceSubscriptionListenerMarker;
6827
6828impl fidl::endpoints::ProtocolMarker for ServiceSubscriptionListenerMarker {
6829    type Proxy = ServiceSubscriptionListenerProxy;
6830    type RequestStream = ServiceSubscriptionListenerRequestStream;
6831    #[cfg(target_os = "fuchsia")]
6832    type SynchronousProxy = ServiceSubscriptionListenerSynchronousProxy;
6833
6834    const DEBUG_NAME: &'static str = "(anonymous) ServiceSubscriptionListener";
6835}
6836
6837pub trait ServiceSubscriptionListenerProxyInterface: Send + Sync {
6838    type OnInstanceDiscoveredResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
6839        + Send;
6840    fn r#on_instance_discovered(
6841        &self,
6842        instance: &ServiceInstance,
6843    ) -> Self::OnInstanceDiscoveredResponseFut;
6844    type OnInstanceChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6845    fn r#on_instance_changed(
6846        &self,
6847        instance: &ServiceInstance,
6848    ) -> Self::OnInstanceChangedResponseFut;
6849    type OnInstanceLostResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6850    fn r#on_instance_lost(&self, service: &str, instance: &str) -> Self::OnInstanceLostResponseFut;
6851    type OnQueryResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6852    fn r#on_query(&self, resource_type: ResourceType) -> Self::OnQueryResponseFut;
6853}
6854#[derive(Debug)]
6855#[cfg(target_os = "fuchsia")]
6856pub struct ServiceSubscriptionListenerSynchronousProxy {
6857    client: fidl::client::sync::Client,
6858}
6859
6860#[cfg(target_os = "fuchsia")]
6861impl fidl::endpoints::SynchronousProxy for ServiceSubscriptionListenerSynchronousProxy {
6862    type Proxy = ServiceSubscriptionListenerProxy;
6863    type Protocol = ServiceSubscriptionListenerMarker;
6864
6865    fn from_channel(inner: fidl::Channel) -> Self {
6866        Self::new(inner)
6867    }
6868
6869    fn into_channel(self) -> fidl::Channel {
6870        self.client.into_channel()
6871    }
6872
6873    fn as_channel(&self) -> &fidl::Channel {
6874        self.client.as_channel()
6875    }
6876}
6877
6878#[cfg(target_os = "fuchsia")]
6879impl ServiceSubscriptionListenerSynchronousProxy {
6880    pub fn new(channel: fidl::Channel) -> Self {
6881        Self { client: fidl::client::sync::Client::new(channel) }
6882    }
6883
6884    pub fn into_channel(self) -> fidl::Channel {
6885        self.client.into_channel()
6886    }
6887
6888    /// Waits until an event arrives and returns it. It is safe for other
6889    /// threads to make concurrent requests while waiting for an event.
6890    pub fn wait_for_event(
6891        &self,
6892        deadline: zx::MonotonicInstant,
6893    ) -> Result<ServiceSubscriptionListenerEvent, fidl::Error> {
6894        ServiceSubscriptionListenerEvent::decode(
6895            self.client.wait_for_event::<ServiceSubscriptionListenerMarker>(deadline)?,
6896        )
6897    }
6898
6899    /// Notifies the subscriber that a service instance has been discovered.
6900    pub fn r#on_instance_discovered(
6901        &self,
6902        mut instance: &ServiceInstance,
6903        ___deadline: zx::MonotonicInstant,
6904    ) -> Result<(), fidl::Error> {
6905        let _response = self.client.send_query::<
6906            ServiceSubscriptionListenerOnInstanceDiscoveredRequest,
6907            fidl::encoding::EmptyPayload,
6908            ServiceSubscriptionListenerMarker,
6909        >(
6910            (instance,),
6911            0x82f861e0b26a186,
6912            fidl::encoding::DynamicFlags::empty(),
6913            ___deadline,
6914        )?;
6915        Ok(_response)
6916    }
6917
6918    /// Notifies the subscriber that addresses or text for a known service
6919    /// instance have changed.
6920    pub fn r#on_instance_changed(
6921        &self,
6922        mut instance: &ServiceInstance,
6923        ___deadline: zx::MonotonicInstant,
6924    ) -> Result<(), fidl::Error> {
6925        let _response = self.client.send_query::<
6926            ServiceSubscriptionListenerOnInstanceChangedRequest,
6927            fidl::encoding::EmptyPayload,
6928            ServiceSubscriptionListenerMarker,
6929        >(
6930            (instance,),
6931            0x7da325aa758d8929,
6932            fidl::encoding::DynamicFlags::empty(),
6933            ___deadline,
6934        )?;
6935        Ok(_response)
6936    }
6937
6938    /// Notifies the subscriber that a known service instance has been lost.
6939    pub fn r#on_instance_lost(
6940        &self,
6941        mut service: &str,
6942        mut instance: &str,
6943        ___deadline: zx::MonotonicInstant,
6944    ) -> Result<(), fidl::Error> {
6945        let _response = self.client.send_query::<
6946            ServiceSubscriptionListenerOnInstanceLostRequest,
6947            fidl::encoding::EmptyPayload,
6948            ServiceSubscriptionListenerMarker,
6949        >(
6950            (service, instance,),
6951            0x2ecb2f1600c5c6dc,
6952            fidl::encoding::DynamicFlags::empty(),
6953            ___deadline,
6954        )?;
6955        Ok(_response)
6956    }
6957
6958    /// Notifies the subscriber that a PTR query has been sent.
6959    pub fn r#on_query(
6960        &self,
6961        mut resource_type: ResourceType,
6962        ___deadline: zx::MonotonicInstant,
6963    ) -> Result<(), fidl::Error> {
6964        let _response = self.client.send_query::<
6965            ServiceSubscriptionListenerOnQueryRequest,
6966            fidl::encoding::EmptyPayload,
6967            ServiceSubscriptionListenerMarker,
6968        >(
6969            (resource_type,),
6970            0x4f4eb8e3d10db611,
6971            fidl::encoding::DynamicFlags::empty(),
6972            ___deadline,
6973        )?;
6974        Ok(_response)
6975    }
6976}
6977
6978#[cfg(target_os = "fuchsia")]
6979impl From<ServiceSubscriptionListenerSynchronousProxy> for zx::NullableHandle {
6980    fn from(value: ServiceSubscriptionListenerSynchronousProxy) -> Self {
6981        value.into_channel().into()
6982    }
6983}
6984
6985#[cfg(target_os = "fuchsia")]
6986impl From<fidl::Channel> for ServiceSubscriptionListenerSynchronousProxy {
6987    fn from(value: fidl::Channel) -> Self {
6988        Self::new(value)
6989    }
6990}
6991
6992#[cfg(target_os = "fuchsia")]
6993impl fidl::endpoints::FromClient for ServiceSubscriptionListenerSynchronousProxy {
6994    type Protocol = ServiceSubscriptionListenerMarker;
6995
6996    fn from_client(value: fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>) -> Self {
6997        Self::new(value.into_channel())
6998    }
6999}
7000
7001#[derive(Debug, Clone)]
7002pub struct ServiceSubscriptionListenerProxy {
7003    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7004}
7005
7006impl fidl::endpoints::Proxy for ServiceSubscriptionListenerProxy {
7007    type Protocol = ServiceSubscriptionListenerMarker;
7008
7009    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7010        Self::new(inner)
7011    }
7012
7013    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7014        self.client.into_channel().map_err(|client| Self { client })
7015    }
7016
7017    fn as_channel(&self) -> &::fidl::AsyncChannel {
7018        self.client.as_channel()
7019    }
7020}
7021
7022impl ServiceSubscriptionListenerProxy {
7023    /// Create a new Proxy for fuchsia.net.mdns/ServiceSubscriptionListener.
7024    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7025        let protocol_name =
7026            <ServiceSubscriptionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7027        Self { client: fidl::client::Client::new(channel, protocol_name) }
7028    }
7029
7030    /// Get a Stream of events from the remote end of the protocol.
7031    ///
7032    /// # Panics
7033    ///
7034    /// Panics if the event stream was already taken.
7035    pub fn take_event_stream(&self) -> ServiceSubscriptionListenerEventStream {
7036        ServiceSubscriptionListenerEventStream { event_receiver: self.client.take_event_receiver() }
7037    }
7038
7039    /// Notifies the subscriber that a service instance has been discovered.
7040    pub fn r#on_instance_discovered(
7041        &self,
7042        mut instance: &ServiceInstance,
7043    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7044        ServiceSubscriptionListenerProxyInterface::r#on_instance_discovered(self, instance)
7045    }
7046
7047    /// Notifies the subscriber that addresses or text for a known service
7048    /// instance have changed.
7049    pub fn r#on_instance_changed(
7050        &self,
7051        mut instance: &ServiceInstance,
7052    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7053        ServiceSubscriptionListenerProxyInterface::r#on_instance_changed(self, instance)
7054    }
7055
7056    /// Notifies the subscriber that a known service instance has been lost.
7057    pub fn r#on_instance_lost(
7058        &self,
7059        mut service: &str,
7060        mut instance: &str,
7061    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7062        ServiceSubscriptionListenerProxyInterface::r#on_instance_lost(self, service, instance)
7063    }
7064
7065    /// Notifies the subscriber that a PTR query has been sent.
7066    pub fn r#on_query(
7067        &self,
7068        mut resource_type: ResourceType,
7069    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7070        ServiceSubscriptionListenerProxyInterface::r#on_query(self, resource_type)
7071    }
7072}
7073
7074impl ServiceSubscriptionListenerProxyInterface for ServiceSubscriptionListenerProxy {
7075    type OnInstanceDiscoveredResponseFut =
7076        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7077    fn r#on_instance_discovered(
7078        &self,
7079        mut instance: &ServiceInstance,
7080    ) -> Self::OnInstanceDiscoveredResponseFut {
7081        fn _decode(
7082            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7083        ) -> Result<(), fidl::Error> {
7084            let _response = fidl::client::decode_transaction_body::<
7085                fidl::encoding::EmptyPayload,
7086                fidl::encoding::DefaultFuchsiaResourceDialect,
7087                0x82f861e0b26a186,
7088            >(_buf?)?;
7089            Ok(_response)
7090        }
7091        self.client
7092            .send_query_and_decode::<ServiceSubscriptionListenerOnInstanceDiscoveredRequest, ()>(
7093                (instance,),
7094                0x82f861e0b26a186,
7095                fidl::encoding::DynamicFlags::empty(),
7096                _decode,
7097            )
7098    }
7099
7100    type OnInstanceChangedResponseFut =
7101        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7102    fn r#on_instance_changed(
7103        &self,
7104        mut instance: &ServiceInstance,
7105    ) -> Self::OnInstanceChangedResponseFut {
7106        fn _decode(
7107            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7108        ) -> Result<(), fidl::Error> {
7109            let _response = fidl::client::decode_transaction_body::<
7110                fidl::encoding::EmptyPayload,
7111                fidl::encoding::DefaultFuchsiaResourceDialect,
7112                0x7da325aa758d8929,
7113            >(_buf?)?;
7114            Ok(_response)
7115        }
7116        self.client
7117            .send_query_and_decode::<ServiceSubscriptionListenerOnInstanceChangedRequest, ()>(
7118                (instance,),
7119                0x7da325aa758d8929,
7120                fidl::encoding::DynamicFlags::empty(),
7121                _decode,
7122            )
7123    }
7124
7125    type OnInstanceLostResponseFut =
7126        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7127    fn r#on_instance_lost(
7128        &self,
7129        mut service: &str,
7130        mut instance: &str,
7131    ) -> Self::OnInstanceLostResponseFut {
7132        fn _decode(
7133            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7134        ) -> Result<(), fidl::Error> {
7135            let _response = fidl::client::decode_transaction_body::<
7136                fidl::encoding::EmptyPayload,
7137                fidl::encoding::DefaultFuchsiaResourceDialect,
7138                0x2ecb2f1600c5c6dc,
7139            >(_buf?)?;
7140            Ok(_response)
7141        }
7142        self.client.send_query_and_decode::<ServiceSubscriptionListenerOnInstanceLostRequest, ()>(
7143            (service, instance),
7144            0x2ecb2f1600c5c6dc,
7145            fidl::encoding::DynamicFlags::empty(),
7146            _decode,
7147        )
7148    }
7149
7150    type OnQueryResponseFut =
7151        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7152    fn r#on_query(&self, mut resource_type: ResourceType) -> Self::OnQueryResponseFut {
7153        fn _decode(
7154            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7155        ) -> Result<(), fidl::Error> {
7156            let _response = fidl::client::decode_transaction_body::<
7157                fidl::encoding::EmptyPayload,
7158                fidl::encoding::DefaultFuchsiaResourceDialect,
7159                0x4f4eb8e3d10db611,
7160            >(_buf?)?;
7161            Ok(_response)
7162        }
7163        self.client.send_query_and_decode::<ServiceSubscriptionListenerOnQueryRequest, ()>(
7164            (resource_type,),
7165            0x4f4eb8e3d10db611,
7166            fidl::encoding::DynamicFlags::empty(),
7167            _decode,
7168        )
7169    }
7170}
7171
7172pub struct ServiceSubscriptionListenerEventStream {
7173    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7174}
7175
7176impl std::marker::Unpin for ServiceSubscriptionListenerEventStream {}
7177
7178impl futures::stream::FusedStream for ServiceSubscriptionListenerEventStream {
7179    fn is_terminated(&self) -> bool {
7180        self.event_receiver.is_terminated()
7181    }
7182}
7183
7184impl futures::Stream for ServiceSubscriptionListenerEventStream {
7185    type Item = Result<ServiceSubscriptionListenerEvent, fidl::Error>;
7186
7187    fn poll_next(
7188        mut self: std::pin::Pin<&mut Self>,
7189        cx: &mut std::task::Context<'_>,
7190    ) -> std::task::Poll<Option<Self::Item>> {
7191        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7192            &mut self.event_receiver,
7193            cx
7194        )?) {
7195            Some(buf) => {
7196                std::task::Poll::Ready(Some(ServiceSubscriptionListenerEvent::decode(buf)))
7197            }
7198            None => std::task::Poll::Ready(None),
7199        }
7200    }
7201}
7202
7203#[derive(Debug)]
7204pub enum ServiceSubscriptionListenerEvent {}
7205
7206impl ServiceSubscriptionListenerEvent {
7207    /// Decodes a message buffer as a [`ServiceSubscriptionListenerEvent`].
7208    fn decode(
7209        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7210    ) -> Result<ServiceSubscriptionListenerEvent, fidl::Error> {
7211        let (bytes, _handles) = buf.split_mut();
7212        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7213        debug_assert_eq!(tx_header.tx_id, 0);
7214        match tx_header.ordinal {
7215            _ => Err(fidl::Error::UnknownOrdinal {
7216                ordinal: tx_header.ordinal,
7217                protocol_name: <ServiceSubscriptionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7218            })
7219        }
7220    }
7221}
7222
7223/// A Stream of incoming requests for fuchsia.net.mdns/ServiceSubscriptionListener.
7224pub struct ServiceSubscriptionListenerRequestStream {
7225    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7226    is_terminated: bool,
7227}
7228
7229impl std::marker::Unpin for ServiceSubscriptionListenerRequestStream {}
7230
7231impl futures::stream::FusedStream for ServiceSubscriptionListenerRequestStream {
7232    fn is_terminated(&self) -> bool {
7233        self.is_terminated
7234    }
7235}
7236
7237impl fidl::endpoints::RequestStream for ServiceSubscriptionListenerRequestStream {
7238    type Protocol = ServiceSubscriptionListenerMarker;
7239    type ControlHandle = ServiceSubscriptionListenerControlHandle;
7240
7241    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7242        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7243    }
7244
7245    fn control_handle(&self) -> Self::ControlHandle {
7246        ServiceSubscriptionListenerControlHandle { inner: self.inner.clone() }
7247    }
7248
7249    fn into_inner(
7250        self,
7251    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7252    {
7253        (self.inner, self.is_terminated)
7254    }
7255
7256    fn from_inner(
7257        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7258        is_terminated: bool,
7259    ) -> Self {
7260        Self { inner, is_terminated }
7261    }
7262}
7263
7264impl futures::Stream for ServiceSubscriptionListenerRequestStream {
7265    type Item = Result<ServiceSubscriptionListenerRequest, fidl::Error>;
7266
7267    fn poll_next(
7268        mut self: std::pin::Pin<&mut Self>,
7269        cx: &mut std::task::Context<'_>,
7270    ) -> std::task::Poll<Option<Self::Item>> {
7271        let this = &mut *self;
7272        if this.inner.check_shutdown(cx) {
7273            this.is_terminated = true;
7274            return std::task::Poll::Ready(None);
7275        }
7276        if this.is_terminated {
7277            panic!("polled ServiceSubscriptionListenerRequestStream after completion");
7278        }
7279        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7280            |bytes, handles| {
7281                match this.inner.channel().read_etc(cx, bytes, handles) {
7282                    std::task::Poll::Ready(Ok(())) => {}
7283                    std::task::Poll::Pending => return std::task::Poll::Pending,
7284                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7285                        this.is_terminated = true;
7286                        return std::task::Poll::Ready(None);
7287                    }
7288                    std::task::Poll::Ready(Err(e)) => {
7289                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7290                            e.into(),
7291                        ))));
7292                    }
7293                }
7294
7295                // A message has been received from the channel
7296                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7297
7298                std::task::Poll::Ready(Some(match header.ordinal {
7299                0x82f861e0b26a186 => {
7300                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7301                    let mut req = fidl::new_empty!(ServiceSubscriptionListenerOnInstanceDiscoveredRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7302                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriptionListenerOnInstanceDiscoveredRequest>(&header, _body_bytes, handles, &mut req)?;
7303                    let control_handle = ServiceSubscriptionListenerControlHandle {
7304                        inner: this.inner.clone(),
7305                    };
7306                    Ok(ServiceSubscriptionListenerRequest::OnInstanceDiscovered {instance: req.instance,
7307
7308                        responder: ServiceSubscriptionListenerOnInstanceDiscoveredResponder {
7309                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7310                            tx_id: header.tx_id,
7311                        },
7312                    })
7313                }
7314                0x7da325aa758d8929 => {
7315                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7316                    let mut req = fidl::new_empty!(ServiceSubscriptionListenerOnInstanceChangedRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7317                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriptionListenerOnInstanceChangedRequest>(&header, _body_bytes, handles, &mut req)?;
7318                    let control_handle = ServiceSubscriptionListenerControlHandle {
7319                        inner: this.inner.clone(),
7320                    };
7321                    Ok(ServiceSubscriptionListenerRequest::OnInstanceChanged {instance: req.instance,
7322
7323                        responder: ServiceSubscriptionListenerOnInstanceChangedResponder {
7324                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7325                            tx_id: header.tx_id,
7326                        },
7327                    })
7328                }
7329                0x2ecb2f1600c5c6dc => {
7330                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7331                    let mut req = fidl::new_empty!(ServiceSubscriptionListenerOnInstanceLostRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7332                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriptionListenerOnInstanceLostRequest>(&header, _body_bytes, handles, &mut req)?;
7333                    let control_handle = ServiceSubscriptionListenerControlHandle {
7334                        inner: this.inner.clone(),
7335                    };
7336                    Ok(ServiceSubscriptionListenerRequest::OnInstanceLost {service: req.service,
7337instance: req.instance,
7338
7339                        responder: ServiceSubscriptionListenerOnInstanceLostResponder {
7340                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7341                            tx_id: header.tx_id,
7342                        },
7343                    })
7344                }
7345                0x4f4eb8e3d10db611 => {
7346                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7347                    let mut req = fidl::new_empty!(ServiceSubscriptionListenerOnQueryRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7348                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServiceSubscriptionListenerOnQueryRequest>(&header, _body_bytes, handles, &mut req)?;
7349                    let control_handle = ServiceSubscriptionListenerControlHandle {
7350                        inner: this.inner.clone(),
7351                    };
7352                    Ok(ServiceSubscriptionListenerRequest::OnQuery {resource_type: req.resource_type,
7353
7354                        responder: ServiceSubscriptionListenerOnQueryResponder {
7355                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7356                            tx_id: header.tx_id,
7357                        },
7358                    })
7359                }
7360                _ => Err(fidl::Error::UnknownOrdinal {
7361                    ordinal: header.ordinal,
7362                    protocol_name: <ServiceSubscriptionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7363                }),
7364            }))
7365            },
7366        )
7367    }
7368}
7369
7370/// Client-implemented interface for subscribers. Method replies are used to
7371/// throttle traffic. The service won't necessarily wait for a reply before
7372/// calling another method.
7373#[derive(Debug)]
7374pub enum ServiceSubscriptionListenerRequest {
7375    /// Notifies the subscriber that a service instance has been discovered.
7376    OnInstanceDiscovered {
7377        instance: ServiceInstance,
7378        responder: ServiceSubscriptionListenerOnInstanceDiscoveredResponder,
7379    },
7380    /// Notifies the subscriber that addresses or text for a known service
7381    /// instance have changed.
7382    OnInstanceChanged {
7383        instance: ServiceInstance,
7384        responder: ServiceSubscriptionListenerOnInstanceChangedResponder,
7385    },
7386    /// Notifies the subscriber that a known service instance has been lost.
7387    OnInstanceLost {
7388        service: String,
7389        instance: String,
7390        responder: ServiceSubscriptionListenerOnInstanceLostResponder,
7391    },
7392    /// Notifies the subscriber that a PTR query has been sent.
7393    OnQuery { resource_type: ResourceType, responder: ServiceSubscriptionListenerOnQueryResponder },
7394}
7395
7396impl ServiceSubscriptionListenerRequest {
7397    #[allow(irrefutable_let_patterns)]
7398    pub fn into_on_instance_discovered(
7399        self,
7400    ) -> Option<(ServiceInstance, ServiceSubscriptionListenerOnInstanceDiscoveredResponder)> {
7401        if let ServiceSubscriptionListenerRequest::OnInstanceDiscovered { instance, responder } =
7402            self
7403        {
7404            Some((instance, responder))
7405        } else {
7406            None
7407        }
7408    }
7409
7410    #[allow(irrefutable_let_patterns)]
7411    pub fn into_on_instance_changed(
7412        self,
7413    ) -> Option<(ServiceInstance, ServiceSubscriptionListenerOnInstanceChangedResponder)> {
7414        if let ServiceSubscriptionListenerRequest::OnInstanceChanged { instance, responder } = self
7415        {
7416            Some((instance, responder))
7417        } else {
7418            None
7419        }
7420    }
7421
7422    #[allow(irrefutable_let_patterns)]
7423    pub fn into_on_instance_lost(
7424        self,
7425    ) -> Option<(String, String, ServiceSubscriptionListenerOnInstanceLostResponder)> {
7426        if let ServiceSubscriptionListenerRequest::OnInstanceLost { service, instance, responder } =
7427            self
7428        {
7429            Some((service, instance, responder))
7430        } else {
7431            None
7432        }
7433    }
7434
7435    #[allow(irrefutable_let_patterns)]
7436    pub fn into_on_query(
7437        self,
7438    ) -> Option<(ResourceType, ServiceSubscriptionListenerOnQueryResponder)> {
7439        if let ServiceSubscriptionListenerRequest::OnQuery { resource_type, responder } = self {
7440            Some((resource_type, responder))
7441        } else {
7442            None
7443        }
7444    }
7445
7446    /// Name of the method defined in FIDL
7447    pub fn method_name(&self) -> &'static str {
7448        match *self {
7449            ServiceSubscriptionListenerRequest::OnInstanceDiscovered { .. } => {
7450                "on_instance_discovered"
7451            }
7452            ServiceSubscriptionListenerRequest::OnInstanceChanged { .. } => "on_instance_changed",
7453            ServiceSubscriptionListenerRequest::OnInstanceLost { .. } => "on_instance_lost",
7454            ServiceSubscriptionListenerRequest::OnQuery { .. } => "on_query",
7455        }
7456    }
7457}
7458
7459#[derive(Debug, Clone)]
7460pub struct ServiceSubscriptionListenerControlHandle {
7461    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7462}
7463
7464impl fidl::endpoints::ControlHandle for ServiceSubscriptionListenerControlHandle {
7465    fn shutdown(&self) {
7466        self.inner.shutdown()
7467    }
7468
7469    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7470        self.inner.shutdown_with_epitaph(status)
7471    }
7472
7473    fn is_closed(&self) -> bool {
7474        self.inner.channel().is_closed()
7475    }
7476    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7477        self.inner.channel().on_closed()
7478    }
7479
7480    #[cfg(target_os = "fuchsia")]
7481    fn signal_peer(
7482        &self,
7483        clear_mask: zx::Signals,
7484        set_mask: zx::Signals,
7485    ) -> Result<(), zx_status::Status> {
7486        use fidl::Peered;
7487        self.inner.channel().signal_peer(clear_mask, set_mask)
7488    }
7489}
7490
7491impl ServiceSubscriptionListenerControlHandle {}
7492
7493#[must_use = "FIDL methods require a response to be sent"]
7494#[derive(Debug)]
7495pub struct ServiceSubscriptionListenerOnInstanceDiscoveredResponder {
7496    control_handle: std::mem::ManuallyDrop<ServiceSubscriptionListenerControlHandle>,
7497    tx_id: u32,
7498}
7499
7500/// Set the the channel to be shutdown (see [`ServiceSubscriptionListenerControlHandle::shutdown`])
7501/// if the responder is dropped without sending a response, so that the client
7502/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7503impl std::ops::Drop for ServiceSubscriptionListenerOnInstanceDiscoveredResponder {
7504    fn drop(&mut self) {
7505        self.control_handle.shutdown();
7506        // Safety: drops once, never accessed again
7507        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7508    }
7509}
7510
7511impl fidl::endpoints::Responder for ServiceSubscriptionListenerOnInstanceDiscoveredResponder {
7512    type ControlHandle = ServiceSubscriptionListenerControlHandle;
7513
7514    fn control_handle(&self) -> &ServiceSubscriptionListenerControlHandle {
7515        &self.control_handle
7516    }
7517
7518    fn drop_without_shutdown(mut self) {
7519        // Safety: drops once, never accessed again due to mem::forget
7520        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7521        // Prevent Drop from running (which would shut down the channel)
7522        std::mem::forget(self);
7523    }
7524}
7525
7526impl ServiceSubscriptionListenerOnInstanceDiscoveredResponder {
7527    /// Sends a response to the FIDL transaction.
7528    ///
7529    /// Sets the channel to shutdown if an error occurs.
7530    pub fn send(self) -> Result<(), fidl::Error> {
7531        let _result = self.send_raw();
7532        if _result.is_err() {
7533            self.control_handle.shutdown();
7534        }
7535        self.drop_without_shutdown();
7536        _result
7537    }
7538
7539    /// Similar to "send" but does not shutdown the channel if an error occurs.
7540    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7541        let _result = self.send_raw();
7542        self.drop_without_shutdown();
7543        _result
7544    }
7545
7546    fn send_raw(&self) -> Result<(), fidl::Error> {
7547        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7548            (),
7549            self.tx_id,
7550            0x82f861e0b26a186,
7551            fidl::encoding::DynamicFlags::empty(),
7552        )
7553    }
7554}
7555
7556#[must_use = "FIDL methods require a response to be sent"]
7557#[derive(Debug)]
7558pub struct ServiceSubscriptionListenerOnInstanceChangedResponder {
7559    control_handle: std::mem::ManuallyDrop<ServiceSubscriptionListenerControlHandle>,
7560    tx_id: u32,
7561}
7562
7563/// Set the the channel to be shutdown (see [`ServiceSubscriptionListenerControlHandle::shutdown`])
7564/// if the responder is dropped without sending a response, so that the client
7565/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7566impl std::ops::Drop for ServiceSubscriptionListenerOnInstanceChangedResponder {
7567    fn drop(&mut self) {
7568        self.control_handle.shutdown();
7569        // Safety: drops once, never accessed again
7570        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7571    }
7572}
7573
7574impl fidl::endpoints::Responder for ServiceSubscriptionListenerOnInstanceChangedResponder {
7575    type ControlHandle = ServiceSubscriptionListenerControlHandle;
7576
7577    fn control_handle(&self) -> &ServiceSubscriptionListenerControlHandle {
7578        &self.control_handle
7579    }
7580
7581    fn drop_without_shutdown(mut self) {
7582        // Safety: drops once, never accessed again due to mem::forget
7583        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7584        // Prevent Drop from running (which would shut down the channel)
7585        std::mem::forget(self);
7586    }
7587}
7588
7589impl ServiceSubscriptionListenerOnInstanceChangedResponder {
7590    /// Sends a response to the FIDL transaction.
7591    ///
7592    /// Sets the channel to shutdown if an error occurs.
7593    pub fn send(self) -> Result<(), fidl::Error> {
7594        let _result = self.send_raw();
7595        if _result.is_err() {
7596            self.control_handle.shutdown();
7597        }
7598        self.drop_without_shutdown();
7599        _result
7600    }
7601
7602    /// Similar to "send" but does not shutdown the channel if an error occurs.
7603    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7604        let _result = self.send_raw();
7605        self.drop_without_shutdown();
7606        _result
7607    }
7608
7609    fn send_raw(&self) -> Result<(), fidl::Error> {
7610        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7611            (),
7612            self.tx_id,
7613            0x7da325aa758d8929,
7614            fidl::encoding::DynamicFlags::empty(),
7615        )
7616    }
7617}
7618
7619#[must_use = "FIDL methods require a response to be sent"]
7620#[derive(Debug)]
7621pub struct ServiceSubscriptionListenerOnInstanceLostResponder {
7622    control_handle: std::mem::ManuallyDrop<ServiceSubscriptionListenerControlHandle>,
7623    tx_id: u32,
7624}
7625
7626/// Set the the channel to be shutdown (see [`ServiceSubscriptionListenerControlHandle::shutdown`])
7627/// if the responder is dropped without sending a response, so that the client
7628/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7629impl std::ops::Drop for ServiceSubscriptionListenerOnInstanceLostResponder {
7630    fn drop(&mut self) {
7631        self.control_handle.shutdown();
7632        // Safety: drops once, never accessed again
7633        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7634    }
7635}
7636
7637impl fidl::endpoints::Responder for ServiceSubscriptionListenerOnInstanceLostResponder {
7638    type ControlHandle = ServiceSubscriptionListenerControlHandle;
7639
7640    fn control_handle(&self) -> &ServiceSubscriptionListenerControlHandle {
7641        &self.control_handle
7642    }
7643
7644    fn drop_without_shutdown(mut self) {
7645        // Safety: drops once, never accessed again due to mem::forget
7646        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7647        // Prevent Drop from running (which would shut down the channel)
7648        std::mem::forget(self);
7649    }
7650}
7651
7652impl ServiceSubscriptionListenerOnInstanceLostResponder {
7653    /// Sends a response to the FIDL transaction.
7654    ///
7655    /// Sets the channel to shutdown if an error occurs.
7656    pub fn send(self) -> Result<(), fidl::Error> {
7657        let _result = self.send_raw();
7658        if _result.is_err() {
7659            self.control_handle.shutdown();
7660        }
7661        self.drop_without_shutdown();
7662        _result
7663    }
7664
7665    /// Similar to "send" but does not shutdown the channel if an error occurs.
7666    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7667        let _result = self.send_raw();
7668        self.drop_without_shutdown();
7669        _result
7670    }
7671
7672    fn send_raw(&self) -> Result<(), fidl::Error> {
7673        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7674            (),
7675            self.tx_id,
7676            0x2ecb2f1600c5c6dc,
7677            fidl::encoding::DynamicFlags::empty(),
7678        )
7679    }
7680}
7681
7682#[must_use = "FIDL methods require a response to be sent"]
7683#[derive(Debug)]
7684pub struct ServiceSubscriptionListenerOnQueryResponder {
7685    control_handle: std::mem::ManuallyDrop<ServiceSubscriptionListenerControlHandle>,
7686    tx_id: u32,
7687}
7688
7689/// Set the the channel to be shutdown (see [`ServiceSubscriptionListenerControlHandle::shutdown`])
7690/// if the responder is dropped without sending a response, so that the client
7691/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7692impl std::ops::Drop for ServiceSubscriptionListenerOnQueryResponder {
7693    fn drop(&mut self) {
7694        self.control_handle.shutdown();
7695        // Safety: drops once, never accessed again
7696        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7697    }
7698}
7699
7700impl fidl::endpoints::Responder for ServiceSubscriptionListenerOnQueryResponder {
7701    type ControlHandle = ServiceSubscriptionListenerControlHandle;
7702
7703    fn control_handle(&self) -> &ServiceSubscriptionListenerControlHandle {
7704        &self.control_handle
7705    }
7706
7707    fn drop_without_shutdown(mut self) {
7708        // Safety: drops once, never accessed again due to mem::forget
7709        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7710        // Prevent Drop from running (which would shut down the channel)
7711        std::mem::forget(self);
7712    }
7713}
7714
7715impl ServiceSubscriptionListenerOnQueryResponder {
7716    /// Sends a response to the FIDL transaction.
7717    ///
7718    /// Sets the channel to shutdown if an error occurs.
7719    pub fn send(self) -> Result<(), fidl::Error> {
7720        let _result = self.send_raw();
7721        if _result.is_err() {
7722            self.control_handle.shutdown();
7723        }
7724        self.drop_without_shutdown();
7725        _result
7726    }
7727
7728    /// Similar to "send" but does not shutdown the channel if an error occurs.
7729    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7730        let _result = self.send_raw();
7731        self.drop_without_shutdown();
7732        _result
7733    }
7734
7735    fn send_raw(&self) -> Result<(), fidl::Error> {
7736        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7737            (),
7738            self.tx_id,
7739            0x4f4eb8e3d10db611,
7740            fidl::encoding::DynamicFlags::empty(),
7741        )
7742    }
7743}
7744
7745#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7746pub struct SubscriberMarker;
7747
7748impl fidl::endpoints::ProtocolMarker for SubscriberMarker {
7749    type Proxy = SubscriberProxy;
7750    type RequestStream = SubscriberRequestStream;
7751    #[cfg(target_os = "fuchsia")]
7752    type SynchronousProxy = SubscriberSynchronousProxy;
7753
7754    const DEBUG_NAME: &'static str = "fuchsia.net.mdns.Subscriber";
7755}
7756impl fidl::endpoints::DiscoverableProtocolMarker for SubscriberMarker {}
7757
7758pub trait SubscriberProxyInterface: Send + Sync {
7759    fn r#subscribe_to_service(
7760        &self,
7761        service: &str,
7762        subscriber: fidl::endpoints::ClientEnd<ServiceSubscriberMarker>,
7763    ) -> Result<(), fidl::Error>;
7764}
7765#[derive(Debug)]
7766#[cfg(target_os = "fuchsia")]
7767pub struct SubscriberSynchronousProxy {
7768    client: fidl::client::sync::Client,
7769}
7770
7771#[cfg(target_os = "fuchsia")]
7772impl fidl::endpoints::SynchronousProxy for SubscriberSynchronousProxy {
7773    type Proxy = SubscriberProxy;
7774    type Protocol = SubscriberMarker;
7775
7776    fn from_channel(inner: fidl::Channel) -> Self {
7777        Self::new(inner)
7778    }
7779
7780    fn into_channel(self) -> fidl::Channel {
7781        self.client.into_channel()
7782    }
7783
7784    fn as_channel(&self) -> &fidl::Channel {
7785        self.client.as_channel()
7786    }
7787}
7788
7789#[cfg(target_os = "fuchsia")]
7790impl SubscriberSynchronousProxy {
7791    pub fn new(channel: fidl::Channel) -> Self {
7792        Self { client: fidl::client::sync::Client::new(channel) }
7793    }
7794
7795    pub fn into_channel(self) -> fidl::Channel {
7796        self.client.into_channel()
7797    }
7798
7799    /// Waits until an event arrives and returns it. It is safe for other
7800    /// threads to make concurrent requests while waiting for an event.
7801    pub fn wait_for_event(
7802        &self,
7803        deadline: zx::MonotonicInstant,
7804    ) -> Result<SubscriberEvent, fidl::Error> {
7805        SubscriberEvent::decode(self.client.wait_for_event::<SubscriberMarker>(deadline)?)
7806    }
7807
7808    /// Subscribes to a service. The subscription lasts until `subscriber` is
7809    /// unbound.
7810    pub fn r#subscribe_to_service(
7811        &self,
7812        mut service: &str,
7813        mut subscriber: fidl::endpoints::ClientEnd<ServiceSubscriberMarker>,
7814    ) -> Result<(), fidl::Error> {
7815        self.client.send::<SubscriberSubscribeToServiceRequest>(
7816            (service, subscriber),
7817            0x3a1a3b02c1809e3f,
7818            fidl::encoding::DynamicFlags::empty(),
7819        )
7820    }
7821}
7822
7823#[cfg(target_os = "fuchsia")]
7824impl From<SubscriberSynchronousProxy> for zx::NullableHandle {
7825    fn from(value: SubscriberSynchronousProxy) -> Self {
7826        value.into_channel().into()
7827    }
7828}
7829
7830#[cfg(target_os = "fuchsia")]
7831impl From<fidl::Channel> for SubscriberSynchronousProxy {
7832    fn from(value: fidl::Channel) -> Self {
7833        Self::new(value)
7834    }
7835}
7836
7837#[cfg(target_os = "fuchsia")]
7838impl fidl::endpoints::FromClient for SubscriberSynchronousProxy {
7839    type Protocol = SubscriberMarker;
7840
7841    fn from_client(value: fidl::endpoints::ClientEnd<SubscriberMarker>) -> Self {
7842        Self::new(value.into_channel())
7843    }
7844}
7845
7846#[derive(Debug, Clone)]
7847pub struct SubscriberProxy {
7848    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7849}
7850
7851impl fidl::endpoints::Proxy for SubscriberProxy {
7852    type Protocol = SubscriberMarker;
7853
7854    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7855        Self::new(inner)
7856    }
7857
7858    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7859        self.client.into_channel().map_err(|client| Self { client })
7860    }
7861
7862    fn as_channel(&self) -> &::fidl::AsyncChannel {
7863        self.client.as_channel()
7864    }
7865}
7866
7867impl SubscriberProxy {
7868    /// Create a new Proxy for fuchsia.net.mdns/Subscriber.
7869    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7870        let protocol_name = <SubscriberMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7871        Self { client: fidl::client::Client::new(channel, protocol_name) }
7872    }
7873
7874    /// Get a Stream of events from the remote end of the protocol.
7875    ///
7876    /// # Panics
7877    ///
7878    /// Panics if the event stream was already taken.
7879    pub fn take_event_stream(&self) -> SubscriberEventStream {
7880        SubscriberEventStream { event_receiver: self.client.take_event_receiver() }
7881    }
7882
7883    /// Subscribes to a service. The subscription lasts until `subscriber` is
7884    /// unbound.
7885    pub fn r#subscribe_to_service(
7886        &self,
7887        mut service: &str,
7888        mut subscriber: fidl::endpoints::ClientEnd<ServiceSubscriberMarker>,
7889    ) -> Result<(), fidl::Error> {
7890        SubscriberProxyInterface::r#subscribe_to_service(self, service, subscriber)
7891    }
7892}
7893
7894impl SubscriberProxyInterface for SubscriberProxy {
7895    fn r#subscribe_to_service(
7896        &self,
7897        mut service: &str,
7898        mut subscriber: fidl::endpoints::ClientEnd<ServiceSubscriberMarker>,
7899    ) -> Result<(), fidl::Error> {
7900        self.client.send::<SubscriberSubscribeToServiceRequest>(
7901            (service, subscriber),
7902            0x3a1a3b02c1809e3f,
7903            fidl::encoding::DynamicFlags::empty(),
7904        )
7905    }
7906}
7907
7908pub struct SubscriberEventStream {
7909    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7910}
7911
7912impl std::marker::Unpin for SubscriberEventStream {}
7913
7914impl futures::stream::FusedStream for SubscriberEventStream {
7915    fn is_terminated(&self) -> bool {
7916        self.event_receiver.is_terminated()
7917    }
7918}
7919
7920impl futures::Stream for SubscriberEventStream {
7921    type Item = Result<SubscriberEvent, fidl::Error>;
7922
7923    fn poll_next(
7924        mut self: std::pin::Pin<&mut Self>,
7925        cx: &mut std::task::Context<'_>,
7926    ) -> std::task::Poll<Option<Self::Item>> {
7927        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7928            &mut self.event_receiver,
7929            cx
7930        )?) {
7931            Some(buf) => std::task::Poll::Ready(Some(SubscriberEvent::decode(buf))),
7932            None => std::task::Poll::Ready(None),
7933        }
7934    }
7935}
7936
7937#[derive(Debug)]
7938pub enum SubscriberEvent {}
7939
7940impl SubscriberEvent {
7941    /// Decodes a message buffer as a [`SubscriberEvent`].
7942    fn decode(
7943        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7944    ) -> Result<SubscriberEvent, fidl::Error> {
7945        let (bytes, _handles) = buf.split_mut();
7946        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7947        debug_assert_eq!(tx_header.tx_id, 0);
7948        match tx_header.ordinal {
7949            _ => Err(fidl::Error::UnknownOrdinal {
7950                ordinal: tx_header.ordinal,
7951                protocol_name: <SubscriberMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7952            }),
7953        }
7954    }
7955}
7956
7957/// A Stream of incoming requests for fuchsia.net.mdns/Subscriber.
7958pub struct SubscriberRequestStream {
7959    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7960    is_terminated: bool,
7961}
7962
7963impl std::marker::Unpin for SubscriberRequestStream {}
7964
7965impl futures::stream::FusedStream for SubscriberRequestStream {
7966    fn is_terminated(&self) -> bool {
7967        self.is_terminated
7968    }
7969}
7970
7971impl fidl::endpoints::RequestStream for SubscriberRequestStream {
7972    type Protocol = SubscriberMarker;
7973    type ControlHandle = SubscriberControlHandle;
7974
7975    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7976        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7977    }
7978
7979    fn control_handle(&self) -> Self::ControlHandle {
7980        SubscriberControlHandle { inner: self.inner.clone() }
7981    }
7982
7983    fn into_inner(
7984        self,
7985    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7986    {
7987        (self.inner, self.is_terminated)
7988    }
7989
7990    fn from_inner(
7991        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7992        is_terminated: bool,
7993    ) -> Self {
7994        Self { inner, is_terminated }
7995    }
7996}
7997
7998impl futures::Stream for SubscriberRequestStream {
7999    type Item = Result<SubscriberRequest, fidl::Error>;
8000
8001    fn poll_next(
8002        mut self: std::pin::Pin<&mut Self>,
8003        cx: &mut std::task::Context<'_>,
8004    ) -> std::task::Poll<Option<Self::Item>> {
8005        let this = &mut *self;
8006        if this.inner.check_shutdown(cx) {
8007            this.is_terminated = true;
8008            return std::task::Poll::Ready(None);
8009        }
8010        if this.is_terminated {
8011            panic!("polled SubscriberRequestStream after completion");
8012        }
8013        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8014            |bytes, handles| {
8015                match this.inner.channel().read_etc(cx, bytes, handles) {
8016                    std::task::Poll::Ready(Ok(())) => {}
8017                    std::task::Poll::Pending => return std::task::Poll::Pending,
8018                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8019                        this.is_terminated = true;
8020                        return std::task::Poll::Ready(None);
8021                    }
8022                    std::task::Poll::Ready(Err(e)) => {
8023                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8024                            e.into(),
8025                        ))));
8026                    }
8027                }
8028
8029                // A message has been received from the channel
8030                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8031
8032                std::task::Poll::Ready(Some(match header.ordinal {
8033                    0x3a1a3b02c1809e3f => {
8034                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8035                        let mut req = fidl::new_empty!(
8036                            SubscriberSubscribeToServiceRequest,
8037                            fidl::encoding::DefaultFuchsiaResourceDialect
8038                        );
8039                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SubscriberSubscribeToServiceRequest>(&header, _body_bytes, handles, &mut req)?;
8040                        let control_handle = SubscriberControlHandle { inner: this.inner.clone() };
8041                        Ok(SubscriberRequest::SubscribeToService {
8042                            service: req.service,
8043                            subscriber: req.subscriber,
8044
8045                            control_handle,
8046                        })
8047                    }
8048                    _ => Err(fidl::Error::UnknownOrdinal {
8049                        ordinal: header.ordinal,
8050                        protocol_name:
8051                            <SubscriberMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8052                    }),
8053                }))
8054            },
8055        )
8056    }
8057}
8058
8059/// Discoverable protocol for finding service instances.
8060/// Deprecated: use ServiceInstanceSubscriber.
8061#[derive(Debug)]
8062pub enum SubscriberRequest {
8063    /// Subscribes to a service. The subscription lasts until `subscriber` is
8064    /// unbound.
8065    SubscribeToService {
8066        service: String,
8067        subscriber: fidl::endpoints::ClientEnd<ServiceSubscriberMarker>,
8068        control_handle: SubscriberControlHandle,
8069    },
8070}
8071
8072impl SubscriberRequest {
8073    #[allow(irrefutable_let_patterns)]
8074    pub fn into_subscribe_to_service(
8075        self,
8076    ) -> Option<(
8077        String,
8078        fidl::endpoints::ClientEnd<ServiceSubscriberMarker>,
8079        SubscriberControlHandle,
8080    )> {
8081        if let SubscriberRequest::SubscribeToService { service, subscriber, control_handle } = self
8082        {
8083            Some((service, subscriber, control_handle))
8084        } else {
8085            None
8086        }
8087    }
8088
8089    /// Name of the method defined in FIDL
8090    pub fn method_name(&self) -> &'static str {
8091        match *self {
8092            SubscriberRequest::SubscribeToService { .. } => "subscribe_to_service",
8093        }
8094    }
8095}
8096
8097#[derive(Debug, Clone)]
8098pub struct SubscriberControlHandle {
8099    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8100}
8101
8102impl fidl::endpoints::ControlHandle for SubscriberControlHandle {
8103    fn shutdown(&self) {
8104        self.inner.shutdown()
8105    }
8106
8107    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8108        self.inner.shutdown_with_epitaph(status)
8109    }
8110
8111    fn is_closed(&self) -> bool {
8112        self.inner.channel().is_closed()
8113    }
8114    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8115        self.inner.channel().on_closed()
8116    }
8117
8118    #[cfg(target_os = "fuchsia")]
8119    fn signal_peer(
8120        &self,
8121        clear_mask: zx::Signals,
8122        set_mask: zx::Signals,
8123    ) -> Result<(), zx_status::Status> {
8124        use fidl::Peered;
8125        self.inner.channel().signal_peer(clear_mask, set_mask)
8126    }
8127}
8128
8129impl SubscriberControlHandle {}
8130
8131mod internal {
8132    use super::*;
8133
8134    impl fidl::encoding::ResourceTypeMarker for HostNameSubscriberSubscribeToHostNameRequest {
8135        type Borrowed<'a> = &'a mut Self;
8136        fn take_or_borrow<'a>(
8137            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8138        ) -> Self::Borrowed<'a> {
8139            value
8140        }
8141    }
8142
8143    unsafe impl fidl::encoding::TypeMarker for HostNameSubscriberSubscribeToHostNameRequest {
8144        type Owned = Self;
8145
8146        #[inline(always)]
8147        fn inline_align(_context: fidl::encoding::Context) -> usize {
8148            8
8149        }
8150
8151        #[inline(always)]
8152        fn inline_size(_context: fidl::encoding::Context) -> usize {
8153            40
8154        }
8155    }
8156
8157    unsafe impl
8158        fidl::encoding::Encode<
8159            HostNameSubscriberSubscribeToHostNameRequest,
8160            fidl::encoding::DefaultFuchsiaResourceDialect,
8161        > for &mut HostNameSubscriberSubscribeToHostNameRequest
8162    {
8163        #[inline]
8164        unsafe fn encode(
8165            self,
8166            encoder: &mut fidl::encoding::Encoder<
8167                '_,
8168                fidl::encoding::DefaultFuchsiaResourceDialect,
8169            >,
8170            offset: usize,
8171            _depth: fidl::encoding::Depth,
8172        ) -> fidl::Result<()> {
8173            encoder.debug_check_bounds::<HostNameSubscriberSubscribeToHostNameRequest>(offset);
8174            // Delegate to tuple encoding.
8175            fidl::encoding::Encode::<
8176                HostNameSubscriberSubscribeToHostNameRequest,
8177                fidl::encoding::DefaultFuchsiaResourceDialect,
8178            >::encode(
8179                (
8180                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
8181                        &self.host,
8182                    ),
8183                    <HostNameSubscriptionOptions as fidl::encoding::ValueTypeMarker>::borrow(
8184                        &self.options,
8185                    ),
8186                    <fidl::encoding::Endpoint<
8187                        fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
8188                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8189                        &mut self.listener
8190                    ),
8191                ),
8192                encoder,
8193                offset,
8194                _depth,
8195            )
8196        }
8197    }
8198    unsafe impl<
8199        T0: fidl::encoding::Encode<
8200                fidl::encoding::BoundedString<255>,
8201                fidl::encoding::DefaultFuchsiaResourceDialect,
8202            >,
8203        T1: fidl::encoding::Encode<
8204                HostNameSubscriptionOptions,
8205                fidl::encoding::DefaultFuchsiaResourceDialect,
8206            >,
8207        T2: fidl::encoding::Encode<
8208                fidl::encoding::Endpoint<
8209                    fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
8210                >,
8211                fidl::encoding::DefaultFuchsiaResourceDialect,
8212            >,
8213    >
8214        fidl::encoding::Encode<
8215            HostNameSubscriberSubscribeToHostNameRequest,
8216            fidl::encoding::DefaultFuchsiaResourceDialect,
8217        > for (T0, T1, T2)
8218    {
8219        #[inline]
8220        unsafe fn encode(
8221            self,
8222            encoder: &mut fidl::encoding::Encoder<
8223                '_,
8224                fidl::encoding::DefaultFuchsiaResourceDialect,
8225            >,
8226            offset: usize,
8227            depth: fidl::encoding::Depth,
8228        ) -> fidl::Result<()> {
8229            encoder.debug_check_bounds::<HostNameSubscriberSubscribeToHostNameRequest>(offset);
8230            // Zero out padding regions. There's no need to apply masks
8231            // because the unmasked parts will be overwritten by fields.
8232            unsafe {
8233                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
8234                (ptr as *mut u64).write_unaligned(0);
8235            }
8236            // Write the fields.
8237            self.0.encode(encoder, offset + 0, depth)?;
8238            self.1.encode(encoder, offset + 16, depth)?;
8239            self.2.encode(encoder, offset + 32, depth)?;
8240            Ok(())
8241        }
8242    }
8243
8244    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8245        for HostNameSubscriberSubscribeToHostNameRequest
8246    {
8247        #[inline(always)]
8248        fn new_empty() -> Self {
8249            Self {
8250                host: fidl::new_empty!(
8251                    fidl::encoding::BoundedString<255>,
8252                    fidl::encoding::DefaultFuchsiaResourceDialect
8253                ),
8254                options: fidl::new_empty!(
8255                    HostNameSubscriptionOptions,
8256                    fidl::encoding::DefaultFuchsiaResourceDialect
8257                ),
8258                listener: fidl::new_empty!(
8259                    fidl::encoding::Endpoint<
8260                        fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
8261                    >,
8262                    fidl::encoding::DefaultFuchsiaResourceDialect
8263                ),
8264            }
8265        }
8266
8267        #[inline]
8268        unsafe fn decode(
8269            &mut self,
8270            decoder: &mut fidl::encoding::Decoder<
8271                '_,
8272                fidl::encoding::DefaultFuchsiaResourceDialect,
8273            >,
8274            offset: usize,
8275            _depth: fidl::encoding::Depth,
8276        ) -> fidl::Result<()> {
8277            decoder.debug_check_bounds::<Self>(offset);
8278            // Verify that padding bytes are zero.
8279            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
8280            let padval = unsafe { (ptr as *const u64).read_unaligned() };
8281            let mask = 0xffffffff00000000u64;
8282            let maskedval = padval & mask;
8283            if maskedval != 0 {
8284                return Err(fidl::Error::NonZeroPadding {
8285                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
8286                });
8287            }
8288            fidl::decode!(
8289                fidl::encoding::BoundedString<255>,
8290                fidl::encoding::DefaultFuchsiaResourceDialect,
8291                &mut self.host,
8292                decoder,
8293                offset + 0,
8294                _depth
8295            )?;
8296            fidl::decode!(
8297                HostNameSubscriptionOptions,
8298                fidl::encoding::DefaultFuchsiaResourceDialect,
8299                &mut self.options,
8300                decoder,
8301                offset + 16,
8302                _depth
8303            )?;
8304            fidl::decode!(
8305                fidl::encoding::Endpoint<
8306                    fidl::endpoints::ClientEnd<HostNameSubscriptionListenerMarker>,
8307                >,
8308                fidl::encoding::DefaultFuchsiaResourceDialect,
8309                &mut self.listener,
8310                decoder,
8311                offset + 32,
8312                _depth
8313            )?;
8314            Ok(())
8315        }
8316    }
8317
8318    impl fidl::encoding::ResourceTypeMarker for ProxyHostPublisherPublishProxyHostRequest {
8319        type Borrowed<'a> = &'a mut Self;
8320        fn take_or_borrow<'a>(
8321            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8322        ) -> Self::Borrowed<'a> {
8323            value
8324        }
8325    }
8326
8327    unsafe impl fidl::encoding::TypeMarker for ProxyHostPublisherPublishProxyHostRequest {
8328        type Owned = Self;
8329
8330        #[inline(always)]
8331        fn inline_align(_context: fidl::encoding::Context) -> usize {
8332            8
8333        }
8334
8335        #[inline(always)]
8336        fn inline_size(_context: fidl::encoding::Context) -> usize {
8337            56
8338        }
8339    }
8340
8341    unsafe impl
8342        fidl::encoding::Encode<
8343            ProxyHostPublisherPublishProxyHostRequest,
8344            fidl::encoding::DefaultFuchsiaResourceDialect,
8345        > for &mut ProxyHostPublisherPublishProxyHostRequest
8346    {
8347        #[inline]
8348        unsafe fn encode(
8349            self,
8350            encoder: &mut fidl::encoding::Encoder<
8351                '_,
8352                fidl::encoding::DefaultFuchsiaResourceDialect,
8353            >,
8354            offset: usize,
8355            _depth: fidl::encoding::Depth,
8356        ) -> fidl::Result<()> {
8357            encoder.debug_check_bounds::<ProxyHostPublisherPublishProxyHostRequest>(offset);
8358            // Delegate to tuple encoding.
8359            fidl::encoding::Encode::<ProxyHostPublisherPublishProxyHostRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8360                (
8361                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.host),
8362                    <fidl::encoding::Vector<fidl_fuchsia_net::IpAddress, 64> as fidl::encoding::ValueTypeMarker>::borrow(&self.addresses),
8363                    <ProxyHostPublicationOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
8364                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.service_instance_publisher),
8365                ),
8366                encoder, offset, _depth
8367            )
8368        }
8369    }
8370    unsafe impl<
8371        T0: fidl::encoding::Encode<
8372                fidl::encoding::BoundedString<255>,
8373                fidl::encoding::DefaultFuchsiaResourceDialect,
8374            >,
8375        T1: fidl::encoding::Encode<
8376                fidl::encoding::Vector<fidl_fuchsia_net::IpAddress, 64>,
8377                fidl::encoding::DefaultFuchsiaResourceDialect,
8378            >,
8379        T2: fidl::encoding::Encode<
8380                ProxyHostPublicationOptions,
8381                fidl::encoding::DefaultFuchsiaResourceDialect,
8382            >,
8383        T3: fidl::encoding::Encode<
8384                fidl::encoding::Endpoint<
8385                    fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
8386                >,
8387                fidl::encoding::DefaultFuchsiaResourceDialect,
8388            >,
8389    >
8390        fidl::encoding::Encode<
8391            ProxyHostPublisherPublishProxyHostRequest,
8392            fidl::encoding::DefaultFuchsiaResourceDialect,
8393        > for (T0, T1, T2, T3)
8394    {
8395        #[inline]
8396        unsafe fn encode(
8397            self,
8398            encoder: &mut fidl::encoding::Encoder<
8399                '_,
8400                fidl::encoding::DefaultFuchsiaResourceDialect,
8401            >,
8402            offset: usize,
8403            depth: fidl::encoding::Depth,
8404        ) -> fidl::Result<()> {
8405            encoder.debug_check_bounds::<ProxyHostPublisherPublishProxyHostRequest>(offset);
8406            // Zero out padding regions. There's no need to apply masks
8407            // because the unmasked parts will be overwritten by fields.
8408            unsafe {
8409                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(48);
8410                (ptr as *mut u64).write_unaligned(0);
8411            }
8412            // Write the fields.
8413            self.0.encode(encoder, offset + 0, depth)?;
8414            self.1.encode(encoder, offset + 16, depth)?;
8415            self.2.encode(encoder, offset + 32, depth)?;
8416            self.3.encode(encoder, offset + 48, depth)?;
8417            Ok(())
8418        }
8419    }
8420
8421    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8422        for ProxyHostPublisherPublishProxyHostRequest
8423    {
8424        #[inline(always)]
8425        fn new_empty() -> Self {
8426            Self {
8427                host: fidl::new_empty!(
8428                    fidl::encoding::BoundedString<255>,
8429                    fidl::encoding::DefaultFuchsiaResourceDialect
8430                ),
8431                addresses: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_net::IpAddress, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
8432                options: fidl::new_empty!(
8433                    ProxyHostPublicationOptions,
8434                    fidl::encoding::DefaultFuchsiaResourceDialect
8435                ),
8436                service_instance_publisher: fidl::new_empty!(
8437                    fidl::encoding::Endpoint<
8438                        fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
8439                    >,
8440                    fidl::encoding::DefaultFuchsiaResourceDialect
8441                ),
8442            }
8443        }
8444
8445        #[inline]
8446        unsafe fn decode(
8447            &mut self,
8448            decoder: &mut fidl::encoding::Decoder<
8449                '_,
8450                fidl::encoding::DefaultFuchsiaResourceDialect,
8451            >,
8452            offset: usize,
8453            _depth: fidl::encoding::Depth,
8454        ) -> fidl::Result<()> {
8455            decoder.debug_check_bounds::<Self>(offset);
8456            // Verify that padding bytes are zero.
8457            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(48) };
8458            let padval = unsafe { (ptr as *const u64).read_unaligned() };
8459            let mask = 0xffffffff00000000u64;
8460            let maskedval = padval & mask;
8461            if maskedval != 0 {
8462                return Err(fidl::Error::NonZeroPadding {
8463                    padding_start: offset + 48 + ((mask as u64).trailing_zeros() / 8) as usize,
8464                });
8465            }
8466            fidl::decode!(
8467                fidl::encoding::BoundedString<255>,
8468                fidl::encoding::DefaultFuchsiaResourceDialect,
8469                &mut self.host,
8470                decoder,
8471                offset + 0,
8472                _depth
8473            )?;
8474            fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_net::IpAddress, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.addresses, decoder, offset + 16, _depth)?;
8475            fidl::decode!(
8476                ProxyHostPublicationOptions,
8477                fidl::encoding::DefaultFuchsiaResourceDialect,
8478                &mut self.options,
8479                decoder,
8480                offset + 32,
8481                _depth
8482            )?;
8483            fidl::decode!(
8484                fidl::encoding::Endpoint<
8485                    fidl::endpoints::ServerEnd<ServiceInstancePublisherMarker>,
8486                >,
8487                fidl::encoding::DefaultFuchsiaResourceDialect,
8488                &mut self.service_instance_publisher,
8489                decoder,
8490                offset + 48,
8491                _depth
8492            )?;
8493            Ok(())
8494        }
8495    }
8496
8497    impl fidl::encoding::ResourceTypeMarker for PublisherPublishServiceInstanceRequest {
8498        type Borrowed<'a> = &'a mut Self;
8499        fn take_or_borrow<'a>(
8500            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8501        ) -> Self::Borrowed<'a> {
8502            value
8503        }
8504    }
8505
8506    unsafe impl fidl::encoding::TypeMarker for PublisherPublishServiceInstanceRequest {
8507        type Owned = Self;
8508
8509        #[inline(always)]
8510        fn inline_align(_context: fidl::encoding::Context) -> usize {
8511            8
8512        }
8513
8514        #[inline(always)]
8515        fn inline_size(_context: fidl::encoding::Context) -> usize {
8516            48
8517        }
8518    }
8519
8520    unsafe impl
8521        fidl::encoding::Encode<
8522            PublisherPublishServiceInstanceRequest,
8523            fidl::encoding::DefaultFuchsiaResourceDialect,
8524        > for &mut PublisherPublishServiceInstanceRequest
8525    {
8526        #[inline]
8527        unsafe fn encode(
8528            self,
8529            encoder: &mut fidl::encoding::Encoder<
8530                '_,
8531                fidl::encoding::DefaultFuchsiaResourceDialect,
8532            >,
8533            offset: usize,
8534            _depth: fidl::encoding::Depth,
8535        ) -> fidl::Result<()> {
8536            encoder.debug_check_bounds::<PublisherPublishServiceInstanceRequest>(offset);
8537            // Delegate to tuple encoding.
8538            fidl::encoding::Encode::<
8539                PublisherPublishServiceInstanceRequest,
8540                fidl::encoding::DefaultFuchsiaResourceDialect,
8541            >::encode(
8542                (
8543                    <fidl::encoding::BoundedString<22> as fidl::encoding::ValueTypeMarker>::borrow(
8544                        &self.service,
8545                    ),
8546                    <fidl::encoding::BoundedString<63> as fidl::encoding::ValueTypeMarker>::borrow(
8547                        &self.instance,
8548                    ),
8549                    <Media as fidl::encoding::ValueTypeMarker>::borrow(&self.media),
8550                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.perform_probe),
8551                    <fidl::encoding::Endpoint<
8552                        fidl::endpoints::ClientEnd<PublicationResponder_Marker>,
8553                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8554                        &mut self.publication_responder,
8555                    ),
8556                ),
8557                encoder,
8558                offset,
8559                _depth,
8560            )
8561        }
8562    }
8563    unsafe impl<
8564        T0: fidl::encoding::Encode<
8565                fidl::encoding::BoundedString<22>,
8566                fidl::encoding::DefaultFuchsiaResourceDialect,
8567            >,
8568        T1: fidl::encoding::Encode<
8569                fidl::encoding::BoundedString<63>,
8570                fidl::encoding::DefaultFuchsiaResourceDialect,
8571            >,
8572        T2: fidl::encoding::Encode<Media, fidl::encoding::DefaultFuchsiaResourceDialect>,
8573        T3: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
8574        T4: fidl::encoding::Encode<
8575                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PublicationResponder_Marker>>,
8576                fidl::encoding::DefaultFuchsiaResourceDialect,
8577            >,
8578    >
8579        fidl::encoding::Encode<
8580            PublisherPublishServiceInstanceRequest,
8581            fidl::encoding::DefaultFuchsiaResourceDialect,
8582        > for (T0, T1, T2, T3, T4)
8583    {
8584        #[inline]
8585        unsafe fn encode(
8586            self,
8587            encoder: &mut fidl::encoding::Encoder<
8588                '_,
8589                fidl::encoding::DefaultFuchsiaResourceDialect,
8590            >,
8591            offset: usize,
8592            depth: fidl::encoding::Depth,
8593        ) -> fidl::Result<()> {
8594            encoder.debug_check_bounds::<PublisherPublishServiceInstanceRequest>(offset);
8595            // Zero out padding regions. There's no need to apply masks
8596            // because the unmasked parts will be overwritten by fields.
8597            unsafe {
8598                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
8599                (ptr as *mut u64).write_unaligned(0);
8600            }
8601            unsafe {
8602                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
8603                (ptr as *mut u64).write_unaligned(0);
8604            }
8605            // Write the fields.
8606            self.0.encode(encoder, offset + 0, depth)?;
8607            self.1.encode(encoder, offset + 16, depth)?;
8608            self.2.encode(encoder, offset + 32, depth)?;
8609            self.3.encode(encoder, offset + 36, depth)?;
8610            self.4.encode(encoder, offset + 40, depth)?;
8611            Ok(())
8612        }
8613    }
8614
8615    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8616        for PublisherPublishServiceInstanceRequest
8617    {
8618        #[inline(always)]
8619        fn new_empty() -> Self {
8620            Self {
8621                service: fidl::new_empty!(
8622                    fidl::encoding::BoundedString<22>,
8623                    fidl::encoding::DefaultFuchsiaResourceDialect
8624                ),
8625                instance: fidl::new_empty!(
8626                    fidl::encoding::BoundedString<63>,
8627                    fidl::encoding::DefaultFuchsiaResourceDialect
8628                ),
8629                media: fidl::new_empty!(Media, fidl::encoding::DefaultFuchsiaResourceDialect),
8630                perform_probe: fidl::new_empty!(
8631                    bool,
8632                    fidl::encoding::DefaultFuchsiaResourceDialect
8633                ),
8634                publication_responder: fidl::new_empty!(
8635                    fidl::encoding::Endpoint<
8636                        fidl::endpoints::ClientEnd<PublicationResponder_Marker>,
8637                    >,
8638                    fidl::encoding::DefaultFuchsiaResourceDialect
8639                ),
8640            }
8641        }
8642
8643        #[inline]
8644        unsafe fn decode(
8645            &mut self,
8646            decoder: &mut fidl::encoding::Decoder<
8647                '_,
8648                fidl::encoding::DefaultFuchsiaResourceDialect,
8649            >,
8650            offset: usize,
8651            _depth: fidl::encoding::Depth,
8652        ) -> fidl::Result<()> {
8653            decoder.debug_check_bounds::<Self>(offset);
8654            // Verify that padding bytes are zero.
8655            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
8656            let padval = unsafe { (ptr as *const u64).read_unaligned() };
8657            let mask = 0xffffff0000000000u64;
8658            let maskedval = padval & mask;
8659            if maskedval != 0 {
8660                return Err(fidl::Error::NonZeroPadding {
8661                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
8662                });
8663            }
8664            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
8665            let padval = unsafe { (ptr as *const u64).read_unaligned() };
8666            let mask = 0xffffffff00000000u64;
8667            let maskedval = padval & mask;
8668            if maskedval != 0 {
8669                return Err(fidl::Error::NonZeroPadding {
8670                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
8671                });
8672            }
8673            fidl::decode!(
8674                fidl::encoding::BoundedString<22>,
8675                fidl::encoding::DefaultFuchsiaResourceDialect,
8676                &mut self.service,
8677                decoder,
8678                offset + 0,
8679                _depth
8680            )?;
8681            fidl::decode!(
8682                fidl::encoding::BoundedString<63>,
8683                fidl::encoding::DefaultFuchsiaResourceDialect,
8684                &mut self.instance,
8685                decoder,
8686                offset + 16,
8687                _depth
8688            )?;
8689            fidl::decode!(
8690                Media,
8691                fidl::encoding::DefaultFuchsiaResourceDialect,
8692                &mut self.media,
8693                decoder,
8694                offset + 32,
8695                _depth
8696            )?;
8697            fidl::decode!(
8698                bool,
8699                fidl::encoding::DefaultFuchsiaResourceDialect,
8700                &mut self.perform_probe,
8701                decoder,
8702                offset + 36,
8703                _depth
8704            )?;
8705            fidl::decode!(
8706                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PublicationResponder_Marker>>,
8707                fidl::encoding::DefaultFuchsiaResourceDialect,
8708                &mut self.publication_responder,
8709                decoder,
8710                offset + 40,
8711                _depth
8712            )?;
8713            Ok(())
8714        }
8715    }
8716
8717    impl fidl::encoding::ResourceTypeMarker for ServiceInstancePublisherPublishServiceInstanceRequest {
8718        type Borrowed<'a> = &'a mut Self;
8719        fn take_or_borrow<'a>(
8720            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8721        ) -> Self::Borrowed<'a> {
8722            value
8723        }
8724    }
8725
8726    unsafe impl fidl::encoding::TypeMarker for ServiceInstancePublisherPublishServiceInstanceRequest {
8727        type Owned = Self;
8728
8729        #[inline(always)]
8730        fn inline_align(_context: fidl::encoding::Context) -> usize {
8731            8
8732        }
8733
8734        #[inline(always)]
8735        fn inline_size(_context: fidl::encoding::Context) -> usize {
8736            56
8737        }
8738    }
8739
8740    unsafe impl
8741        fidl::encoding::Encode<
8742            ServiceInstancePublisherPublishServiceInstanceRequest,
8743            fidl::encoding::DefaultFuchsiaResourceDialect,
8744        > for &mut ServiceInstancePublisherPublishServiceInstanceRequest
8745    {
8746        #[inline]
8747        unsafe fn encode(
8748            self,
8749            encoder: &mut fidl::encoding::Encoder<
8750                '_,
8751                fidl::encoding::DefaultFuchsiaResourceDialect,
8752            >,
8753            offset: usize,
8754            _depth: fidl::encoding::Depth,
8755        ) -> fidl::Result<()> {
8756            encoder.debug_check_bounds::<ServiceInstancePublisherPublishServiceInstanceRequest>(
8757                offset,
8758            );
8759            // Delegate to tuple encoding.
8760            fidl::encoding::Encode::<
8761                ServiceInstancePublisherPublishServiceInstanceRequest,
8762                fidl::encoding::DefaultFuchsiaResourceDialect,
8763            >::encode(
8764                (
8765                    <fidl::encoding::BoundedString<22> as fidl::encoding::ValueTypeMarker>::borrow(
8766                        &self.service,
8767                    ),
8768                    <fidl::encoding::BoundedString<63> as fidl::encoding::ValueTypeMarker>::borrow(
8769                        &self.instance,
8770                    ),
8771                    <ServiceInstancePublicationOptions as fidl::encoding::ValueTypeMarker>::borrow(
8772                        &self.options,
8773                    ),
8774                    <fidl::encoding::Endpoint<
8775                        fidl::endpoints::ClientEnd<ServiceInstancePublicationResponder_Marker>,
8776                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8777                        &mut self.publication_responder,
8778                    ),
8779                ),
8780                encoder,
8781                offset,
8782                _depth,
8783            )
8784        }
8785    }
8786    unsafe impl<
8787        T0: fidl::encoding::Encode<
8788                fidl::encoding::BoundedString<22>,
8789                fidl::encoding::DefaultFuchsiaResourceDialect,
8790            >,
8791        T1: fidl::encoding::Encode<
8792                fidl::encoding::BoundedString<63>,
8793                fidl::encoding::DefaultFuchsiaResourceDialect,
8794            >,
8795        T2: fidl::encoding::Encode<
8796                ServiceInstancePublicationOptions,
8797                fidl::encoding::DefaultFuchsiaResourceDialect,
8798            >,
8799        T3: fidl::encoding::Encode<
8800                fidl::encoding::Endpoint<
8801                    fidl::endpoints::ClientEnd<ServiceInstancePublicationResponder_Marker>,
8802                >,
8803                fidl::encoding::DefaultFuchsiaResourceDialect,
8804            >,
8805    >
8806        fidl::encoding::Encode<
8807            ServiceInstancePublisherPublishServiceInstanceRequest,
8808            fidl::encoding::DefaultFuchsiaResourceDialect,
8809        > for (T0, T1, T2, T3)
8810    {
8811        #[inline]
8812        unsafe fn encode(
8813            self,
8814            encoder: &mut fidl::encoding::Encoder<
8815                '_,
8816                fidl::encoding::DefaultFuchsiaResourceDialect,
8817            >,
8818            offset: usize,
8819            depth: fidl::encoding::Depth,
8820        ) -> fidl::Result<()> {
8821            encoder.debug_check_bounds::<ServiceInstancePublisherPublishServiceInstanceRequest>(
8822                offset,
8823            );
8824            // Zero out padding regions. There's no need to apply masks
8825            // because the unmasked parts will be overwritten by fields.
8826            unsafe {
8827                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(48);
8828                (ptr as *mut u64).write_unaligned(0);
8829            }
8830            // Write the fields.
8831            self.0.encode(encoder, offset + 0, depth)?;
8832            self.1.encode(encoder, offset + 16, depth)?;
8833            self.2.encode(encoder, offset + 32, depth)?;
8834            self.3.encode(encoder, offset + 48, depth)?;
8835            Ok(())
8836        }
8837    }
8838
8839    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8840        for ServiceInstancePublisherPublishServiceInstanceRequest
8841    {
8842        #[inline(always)]
8843        fn new_empty() -> Self {
8844            Self {
8845                service: fidl::new_empty!(
8846                    fidl::encoding::BoundedString<22>,
8847                    fidl::encoding::DefaultFuchsiaResourceDialect
8848                ),
8849                instance: fidl::new_empty!(
8850                    fidl::encoding::BoundedString<63>,
8851                    fidl::encoding::DefaultFuchsiaResourceDialect
8852                ),
8853                options: fidl::new_empty!(
8854                    ServiceInstancePublicationOptions,
8855                    fidl::encoding::DefaultFuchsiaResourceDialect
8856                ),
8857                publication_responder: fidl::new_empty!(
8858                    fidl::encoding::Endpoint<
8859                        fidl::endpoints::ClientEnd<ServiceInstancePublicationResponder_Marker>,
8860                    >,
8861                    fidl::encoding::DefaultFuchsiaResourceDialect
8862                ),
8863            }
8864        }
8865
8866        #[inline]
8867        unsafe fn decode(
8868            &mut self,
8869            decoder: &mut fidl::encoding::Decoder<
8870                '_,
8871                fidl::encoding::DefaultFuchsiaResourceDialect,
8872            >,
8873            offset: usize,
8874            _depth: fidl::encoding::Depth,
8875        ) -> fidl::Result<()> {
8876            decoder.debug_check_bounds::<Self>(offset);
8877            // Verify that padding bytes are zero.
8878            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(48) };
8879            let padval = unsafe { (ptr as *const u64).read_unaligned() };
8880            let mask = 0xffffffff00000000u64;
8881            let maskedval = padval & mask;
8882            if maskedval != 0 {
8883                return Err(fidl::Error::NonZeroPadding {
8884                    padding_start: offset + 48 + ((mask as u64).trailing_zeros() / 8) as usize,
8885                });
8886            }
8887            fidl::decode!(
8888                fidl::encoding::BoundedString<22>,
8889                fidl::encoding::DefaultFuchsiaResourceDialect,
8890                &mut self.service,
8891                decoder,
8892                offset + 0,
8893                _depth
8894            )?;
8895            fidl::decode!(
8896                fidl::encoding::BoundedString<63>,
8897                fidl::encoding::DefaultFuchsiaResourceDialect,
8898                &mut self.instance,
8899                decoder,
8900                offset + 16,
8901                _depth
8902            )?;
8903            fidl::decode!(
8904                ServiceInstancePublicationOptions,
8905                fidl::encoding::DefaultFuchsiaResourceDialect,
8906                &mut self.options,
8907                decoder,
8908                offset + 32,
8909                _depth
8910            )?;
8911            fidl::decode!(
8912                fidl::encoding::Endpoint<
8913                    fidl::endpoints::ClientEnd<ServiceInstancePublicationResponder_Marker>,
8914                >,
8915                fidl::encoding::DefaultFuchsiaResourceDialect,
8916                &mut self.publication_responder,
8917                decoder,
8918                offset + 48,
8919                _depth
8920            )?;
8921            Ok(())
8922        }
8923    }
8924
8925    impl fidl::encoding::ResourceTypeMarker for ServiceSubscriber2SubscribeToAllServicesRequest {
8926        type Borrowed<'a> = &'a mut Self;
8927        fn take_or_borrow<'a>(
8928            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8929        ) -> Self::Borrowed<'a> {
8930            value
8931        }
8932    }
8933
8934    unsafe impl fidl::encoding::TypeMarker for ServiceSubscriber2SubscribeToAllServicesRequest {
8935        type Owned = Self;
8936
8937        #[inline(always)]
8938        fn inline_align(_context: fidl::encoding::Context) -> usize {
8939            8
8940        }
8941
8942        #[inline(always)]
8943        fn inline_size(_context: fidl::encoding::Context) -> usize {
8944            24
8945        }
8946    }
8947
8948    unsafe impl
8949        fidl::encoding::Encode<
8950            ServiceSubscriber2SubscribeToAllServicesRequest,
8951            fidl::encoding::DefaultFuchsiaResourceDialect,
8952        > for &mut ServiceSubscriber2SubscribeToAllServicesRequest
8953    {
8954        #[inline]
8955        unsafe fn encode(
8956            self,
8957            encoder: &mut fidl::encoding::Encoder<
8958                '_,
8959                fidl::encoding::DefaultFuchsiaResourceDialect,
8960            >,
8961            offset: usize,
8962            _depth: fidl::encoding::Depth,
8963        ) -> fidl::Result<()> {
8964            encoder.debug_check_bounds::<ServiceSubscriber2SubscribeToAllServicesRequest>(offset);
8965            // Delegate to tuple encoding.
8966            fidl::encoding::Encode::<
8967                ServiceSubscriber2SubscribeToAllServicesRequest,
8968                fidl::encoding::DefaultFuchsiaResourceDialect,
8969            >::encode(
8970                (
8971                    <ServiceSubscriptionOptions as fidl::encoding::ValueTypeMarker>::borrow(
8972                        &self.options,
8973                    ),
8974                    <fidl::encoding::Endpoint<
8975                        fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
8976                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8977                        &mut self.listener
8978                    ),
8979                ),
8980                encoder,
8981                offset,
8982                _depth,
8983            )
8984        }
8985    }
8986    unsafe impl<
8987        T0: fidl::encoding::Encode<
8988                ServiceSubscriptionOptions,
8989                fidl::encoding::DefaultFuchsiaResourceDialect,
8990            >,
8991        T1: fidl::encoding::Encode<
8992                fidl::encoding::Endpoint<
8993                    fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
8994                >,
8995                fidl::encoding::DefaultFuchsiaResourceDialect,
8996            >,
8997    >
8998        fidl::encoding::Encode<
8999            ServiceSubscriber2SubscribeToAllServicesRequest,
9000            fidl::encoding::DefaultFuchsiaResourceDialect,
9001        > for (T0, T1)
9002    {
9003        #[inline]
9004        unsafe fn encode(
9005            self,
9006            encoder: &mut fidl::encoding::Encoder<
9007                '_,
9008                fidl::encoding::DefaultFuchsiaResourceDialect,
9009            >,
9010            offset: usize,
9011            depth: fidl::encoding::Depth,
9012        ) -> fidl::Result<()> {
9013            encoder.debug_check_bounds::<ServiceSubscriber2SubscribeToAllServicesRequest>(offset);
9014            // Zero out padding regions. There's no need to apply masks
9015            // because the unmasked parts will be overwritten by fields.
9016            unsafe {
9017                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9018                (ptr as *mut u64).write_unaligned(0);
9019            }
9020            // Write the fields.
9021            self.0.encode(encoder, offset + 0, depth)?;
9022            self.1.encode(encoder, offset + 16, depth)?;
9023            Ok(())
9024        }
9025    }
9026
9027    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9028        for ServiceSubscriber2SubscribeToAllServicesRequest
9029    {
9030        #[inline(always)]
9031        fn new_empty() -> Self {
9032            Self {
9033                options: fidl::new_empty!(
9034                    ServiceSubscriptionOptions,
9035                    fidl::encoding::DefaultFuchsiaResourceDialect
9036                ),
9037                listener: fidl::new_empty!(
9038                    fidl::encoding::Endpoint<
9039                        fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
9040                    >,
9041                    fidl::encoding::DefaultFuchsiaResourceDialect
9042                ),
9043            }
9044        }
9045
9046        #[inline]
9047        unsafe fn decode(
9048            &mut self,
9049            decoder: &mut fidl::encoding::Decoder<
9050                '_,
9051                fidl::encoding::DefaultFuchsiaResourceDialect,
9052            >,
9053            offset: usize,
9054            _depth: fidl::encoding::Depth,
9055        ) -> fidl::Result<()> {
9056            decoder.debug_check_bounds::<Self>(offset);
9057            // Verify that padding bytes are zero.
9058            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9059            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9060            let mask = 0xffffffff00000000u64;
9061            let maskedval = padval & mask;
9062            if maskedval != 0 {
9063                return Err(fidl::Error::NonZeroPadding {
9064                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9065                });
9066            }
9067            fidl::decode!(
9068                ServiceSubscriptionOptions,
9069                fidl::encoding::DefaultFuchsiaResourceDialect,
9070                &mut self.options,
9071                decoder,
9072                offset + 0,
9073                _depth
9074            )?;
9075            fidl::decode!(
9076                fidl::encoding::Endpoint<
9077                    fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
9078                >,
9079                fidl::encoding::DefaultFuchsiaResourceDialect,
9080                &mut self.listener,
9081                decoder,
9082                offset + 16,
9083                _depth
9084            )?;
9085            Ok(())
9086        }
9087    }
9088
9089    impl fidl::encoding::ResourceTypeMarker for ServiceSubscriber2SubscribeToServiceRequest {
9090        type Borrowed<'a> = &'a mut Self;
9091        fn take_or_borrow<'a>(
9092            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9093        ) -> Self::Borrowed<'a> {
9094            value
9095        }
9096    }
9097
9098    unsafe impl fidl::encoding::TypeMarker for ServiceSubscriber2SubscribeToServiceRequest {
9099        type Owned = Self;
9100
9101        #[inline(always)]
9102        fn inline_align(_context: fidl::encoding::Context) -> usize {
9103            8
9104        }
9105
9106        #[inline(always)]
9107        fn inline_size(_context: fidl::encoding::Context) -> usize {
9108            40
9109        }
9110    }
9111
9112    unsafe impl
9113        fidl::encoding::Encode<
9114            ServiceSubscriber2SubscribeToServiceRequest,
9115            fidl::encoding::DefaultFuchsiaResourceDialect,
9116        > for &mut ServiceSubscriber2SubscribeToServiceRequest
9117    {
9118        #[inline]
9119        unsafe fn encode(
9120            self,
9121            encoder: &mut fidl::encoding::Encoder<
9122                '_,
9123                fidl::encoding::DefaultFuchsiaResourceDialect,
9124            >,
9125            offset: usize,
9126            _depth: fidl::encoding::Depth,
9127        ) -> fidl::Result<()> {
9128            encoder.debug_check_bounds::<ServiceSubscriber2SubscribeToServiceRequest>(offset);
9129            // Delegate to tuple encoding.
9130            fidl::encoding::Encode::<
9131                ServiceSubscriber2SubscribeToServiceRequest,
9132                fidl::encoding::DefaultFuchsiaResourceDialect,
9133            >::encode(
9134                (
9135                    <fidl::encoding::BoundedString<22> as fidl::encoding::ValueTypeMarker>::borrow(
9136                        &self.service,
9137                    ),
9138                    <ServiceSubscriptionOptions as fidl::encoding::ValueTypeMarker>::borrow(
9139                        &self.options,
9140                    ),
9141                    <fidl::encoding::Endpoint<
9142                        fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
9143                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9144                        &mut self.listener
9145                    ),
9146                ),
9147                encoder,
9148                offset,
9149                _depth,
9150            )
9151        }
9152    }
9153    unsafe impl<
9154        T0: fidl::encoding::Encode<
9155                fidl::encoding::BoundedString<22>,
9156                fidl::encoding::DefaultFuchsiaResourceDialect,
9157            >,
9158        T1: fidl::encoding::Encode<
9159                ServiceSubscriptionOptions,
9160                fidl::encoding::DefaultFuchsiaResourceDialect,
9161            >,
9162        T2: fidl::encoding::Encode<
9163                fidl::encoding::Endpoint<
9164                    fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
9165                >,
9166                fidl::encoding::DefaultFuchsiaResourceDialect,
9167            >,
9168    >
9169        fidl::encoding::Encode<
9170            ServiceSubscriber2SubscribeToServiceRequest,
9171            fidl::encoding::DefaultFuchsiaResourceDialect,
9172        > for (T0, T1, T2)
9173    {
9174        #[inline]
9175        unsafe fn encode(
9176            self,
9177            encoder: &mut fidl::encoding::Encoder<
9178                '_,
9179                fidl::encoding::DefaultFuchsiaResourceDialect,
9180            >,
9181            offset: usize,
9182            depth: fidl::encoding::Depth,
9183        ) -> fidl::Result<()> {
9184            encoder.debug_check_bounds::<ServiceSubscriber2SubscribeToServiceRequest>(offset);
9185            // Zero out padding regions. There's no need to apply masks
9186            // because the unmasked parts will be overwritten by fields.
9187            unsafe {
9188                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
9189                (ptr as *mut u64).write_unaligned(0);
9190            }
9191            // Write the fields.
9192            self.0.encode(encoder, offset + 0, depth)?;
9193            self.1.encode(encoder, offset + 16, depth)?;
9194            self.2.encode(encoder, offset + 32, depth)?;
9195            Ok(())
9196        }
9197    }
9198
9199    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9200        for ServiceSubscriber2SubscribeToServiceRequest
9201    {
9202        #[inline(always)]
9203        fn new_empty() -> Self {
9204            Self {
9205                service: fidl::new_empty!(
9206                    fidl::encoding::BoundedString<22>,
9207                    fidl::encoding::DefaultFuchsiaResourceDialect
9208                ),
9209                options: fidl::new_empty!(
9210                    ServiceSubscriptionOptions,
9211                    fidl::encoding::DefaultFuchsiaResourceDialect
9212                ),
9213                listener: fidl::new_empty!(
9214                    fidl::encoding::Endpoint<
9215                        fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
9216                    >,
9217                    fidl::encoding::DefaultFuchsiaResourceDialect
9218                ),
9219            }
9220        }
9221
9222        #[inline]
9223        unsafe fn decode(
9224            &mut self,
9225            decoder: &mut fidl::encoding::Decoder<
9226                '_,
9227                fidl::encoding::DefaultFuchsiaResourceDialect,
9228            >,
9229            offset: usize,
9230            _depth: fidl::encoding::Depth,
9231        ) -> fidl::Result<()> {
9232            decoder.debug_check_bounds::<Self>(offset);
9233            // Verify that padding bytes are zero.
9234            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
9235            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9236            let mask = 0xffffffff00000000u64;
9237            let maskedval = padval & mask;
9238            if maskedval != 0 {
9239                return Err(fidl::Error::NonZeroPadding {
9240                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
9241                });
9242            }
9243            fidl::decode!(
9244                fidl::encoding::BoundedString<22>,
9245                fidl::encoding::DefaultFuchsiaResourceDialect,
9246                &mut self.service,
9247                decoder,
9248                offset + 0,
9249                _depth
9250            )?;
9251            fidl::decode!(
9252                ServiceSubscriptionOptions,
9253                fidl::encoding::DefaultFuchsiaResourceDialect,
9254                &mut self.options,
9255                decoder,
9256                offset + 16,
9257                _depth
9258            )?;
9259            fidl::decode!(
9260                fidl::encoding::Endpoint<
9261                    fidl::endpoints::ClientEnd<ServiceSubscriptionListenerMarker>,
9262                >,
9263                fidl::encoding::DefaultFuchsiaResourceDialect,
9264                &mut self.listener,
9265                decoder,
9266                offset + 32,
9267                _depth
9268            )?;
9269            Ok(())
9270        }
9271    }
9272
9273    impl fidl::encoding::ResourceTypeMarker for SubscriberSubscribeToServiceRequest {
9274        type Borrowed<'a> = &'a mut Self;
9275        fn take_or_borrow<'a>(
9276            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9277        ) -> Self::Borrowed<'a> {
9278            value
9279        }
9280    }
9281
9282    unsafe impl fidl::encoding::TypeMarker for SubscriberSubscribeToServiceRequest {
9283        type Owned = Self;
9284
9285        #[inline(always)]
9286        fn inline_align(_context: fidl::encoding::Context) -> usize {
9287            8
9288        }
9289
9290        #[inline(always)]
9291        fn inline_size(_context: fidl::encoding::Context) -> usize {
9292            24
9293        }
9294    }
9295
9296    unsafe impl
9297        fidl::encoding::Encode<
9298            SubscriberSubscribeToServiceRequest,
9299            fidl::encoding::DefaultFuchsiaResourceDialect,
9300        > for &mut SubscriberSubscribeToServiceRequest
9301    {
9302        #[inline]
9303        unsafe fn encode(
9304            self,
9305            encoder: &mut fidl::encoding::Encoder<
9306                '_,
9307                fidl::encoding::DefaultFuchsiaResourceDialect,
9308            >,
9309            offset: usize,
9310            _depth: fidl::encoding::Depth,
9311        ) -> fidl::Result<()> {
9312            encoder.debug_check_bounds::<SubscriberSubscribeToServiceRequest>(offset);
9313            // Delegate to tuple encoding.
9314            fidl::encoding::Encode::<SubscriberSubscribeToServiceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9315                (
9316                    <fidl::encoding::BoundedString<22> as fidl::encoding::ValueTypeMarker>::borrow(&self.service),
9317                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ServiceSubscriberMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.subscriber),
9318                ),
9319                encoder, offset, _depth
9320            )
9321        }
9322    }
9323    unsafe impl<
9324        T0: fidl::encoding::Encode<
9325                fidl::encoding::BoundedString<22>,
9326                fidl::encoding::DefaultFuchsiaResourceDialect,
9327            >,
9328        T1: fidl::encoding::Encode<
9329                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ServiceSubscriberMarker>>,
9330                fidl::encoding::DefaultFuchsiaResourceDialect,
9331            >,
9332    >
9333        fidl::encoding::Encode<
9334            SubscriberSubscribeToServiceRequest,
9335            fidl::encoding::DefaultFuchsiaResourceDialect,
9336        > for (T0, T1)
9337    {
9338        #[inline]
9339        unsafe fn encode(
9340            self,
9341            encoder: &mut fidl::encoding::Encoder<
9342                '_,
9343                fidl::encoding::DefaultFuchsiaResourceDialect,
9344            >,
9345            offset: usize,
9346            depth: fidl::encoding::Depth,
9347        ) -> fidl::Result<()> {
9348            encoder.debug_check_bounds::<SubscriberSubscribeToServiceRequest>(offset);
9349            // Zero out padding regions. There's no need to apply masks
9350            // because the unmasked parts will be overwritten by fields.
9351            unsafe {
9352                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9353                (ptr as *mut u64).write_unaligned(0);
9354            }
9355            // Write the fields.
9356            self.0.encode(encoder, offset + 0, depth)?;
9357            self.1.encode(encoder, offset + 16, depth)?;
9358            Ok(())
9359        }
9360    }
9361
9362    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9363        for SubscriberSubscribeToServiceRequest
9364    {
9365        #[inline(always)]
9366        fn new_empty() -> Self {
9367            Self {
9368                service: fidl::new_empty!(
9369                    fidl::encoding::BoundedString<22>,
9370                    fidl::encoding::DefaultFuchsiaResourceDialect
9371                ),
9372                subscriber: fidl::new_empty!(
9373                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ServiceSubscriberMarker>>,
9374                    fidl::encoding::DefaultFuchsiaResourceDialect
9375                ),
9376            }
9377        }
9378
9379        #[inline]
9380        unsafe fn decode(
9381            &mut self,
9382            decoder: &mut fidl::encoding::Decoder<
9383                '_,
9384                fidl::encoding::DefaultFuchsiaResourceDialect,
9385            >,
9386            offset: usize,
9387            _depth: fidl::encoding::Depth,
9388        ) -> fidl::Result<()> {
9389            decoder.debug_check_bounds::<Self>(offset);
9390            // Verify that padding bytes are zero.
9391            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9392            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9393            let mask = 0xffffffff00000000u64;
9394            let maskedval = padval & mask;
9395            if maskedval != 0 {
9396                return Err(fidl::Error::NonZeroPadding {
9397                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9398                });
9399            }
9400            fidl::decode!(
9401                fidl::encoding::BoundedString<22>,
9402                fidl::encoding::DefaultFuchsiaResourceDialect,
9403                &mut self.service,
9404                decoder,
9405                offset + 0,
9406                _depth
9407            )?;
9408            fidl::decode!(
9409                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ServiceSubscriberMarker>>,
9410                fidl::encoding::DefaultFuchsiaResourceDialect,
9411                &mut self.subscriber,
9412                decoder,
9413                offset + 16,
9414                _depth
9415            )?;
9416            Ok(())
9417        }
9418    }
9419}