fidl_fuchsia_vsock/
fidl_fuchsia_vsock.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_vsock__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct AcceptorAcceptResponse {
16    pub con: Option<Box<ConnectionTransport>>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for AcceptorAcceptResponse {}
20
21/// Collection of objects that represent an open connection.
22#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub struct ConnectionTransport {
24    /// `data` socket that is ultimately given to the underlying vsock driver and
25    /// is where all incoming data can be received from.
26    pub data: fidl::Socket,
27    /// `Connection` interface that is retained by a vsock service that can be
28    /// used to manipulate the state of a connection or perform more complex
29    /// operations than just sending and receiving on a socket.
30    pub con: fidl::endpoints::ServerEnd<ConnectionMarker>,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ConnectionTransport {}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36pub struct ConnectorBindRequest {
37    pub remote_cid: u32,
38    pub local_port: u32,
39    pub listener: fidl::endpoints::ServerEnd<ListenerMarker>,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ConnectorBindRequest {}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct ConnectorConnectRequest {
46    pub remote_cid: u32,
47    pub remote_port: u32,
48    pub con: ConnectionTransport,
49}
50
51impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ConnectorConnectRequest {}
52
53#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
54pub struct ConnectorListenRequest {
55    pub local_port: u32,
56    pub acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
57}
58
59impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ConnectorListenRequest {}
60
61#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
62pub struct ListenerAcceptRequest {
63    pub con: ConnectionTransport,
64}
65
66impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ListenerAcceptRequest {}
67
68#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
69pub struct AcceptorMarker;
70
71impl fidl::endpoints::ProtocolMarker for AcceptorMarker {
72    type Proxy = AcceptorProxy;
73    type RequestStream = AcceptorRequestStream;
74    #[cfg(target_os = "fuchsia")]
75    type SynchronousProxy = AcceptorSynchronousProxy;
76
77    const DEBUG_NAME: &'static str = "(anonymous) Acceptor";
78}
79
80pub trait AcceptorProxyInterface: Send + Sync {
81    type AcceptResponseFut: std::future::Future<Output = Result<Option<Box<ConnectionTransport>>, fidl::Error>>
82        + Send;
83    fn r#accept(&self, addr: &fidl_fuchsia_hardware_vsock::Addr) -> Self::AcceptResponseFut;
84}
85#[derive(Debug)]
86#[cfg(target_os = "fuchsia")]
87pub struct AcceptorSynchronousProxy {
88    client: fidl::client::sync::Client,
89}
90
91#[cfg(target_os = "fuchsia")]
92impl fidl::endpoints::SynchronousProxy for AcceptorSynchronousProxy {
93    type Proxy = AcceptorProxy;
94    type Protocol = AcceptorMarker;
95
96    fn from_channel(inner: fidl::Channel) -> Self {
97        Self::new(inner)
98    }
99
100    fn into_channel(self) -> fidl::Channel {
101        self.client.into_channel()
102    }
103
104    fn as_channel(&self) -> &fidl::Channel {
105        self.client.as_channel()
106    }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl AcceptorSynchronousProxy {
111    pub fn new(channel: fidl::Channel) -> Self {
112        let protocol_name = <AcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
113        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
114    }
115
116    pub fn into_channel(self) -> fidl::Channel {
117        self.client.into_channel()
118    }
119
120    /// Waits until an event arrives and returns it. It is safe for other
121    /// threads to make concurrent requests while waiting for an event.
122    pub fn wait_for_event(
123        &self,
124        deadline: zx::MonotonicInstant,
125    ) -> Result<AcceptorEvent, fidl::Error> {
126        AcceptorEvent::decode(self.client.wait_for_event(deadline)?)
127    }
128
129    /// The response is either a `ConnectionTransport` to indicate that the connection
130    /// is accepted, or none to indicate that it should be rejected.
131    pub fn r#accept(
132        &self,
133        mut addr: &fidl_fuchsia_hardware_vsock::Addr,
134        ___deadline: zx::MonotonicInstant,
135    ) -> Result<Option<Box<ConnectionTransport>>, fidl::Error> {
136        let _response = self.client.send_query::<AcceptorAcceptRequest, AcceptorAcceptResponse>(
137            (addr,),
138            0x21fd057ad9c9f443,
139            fidl::encoding::DynamicFlags::empty(),
140            ___deadline,
141        )?;
142        Ok(_response.con)
143    }
144}
145
146#[cfg(target_os = "fuchsia")]
147impl From<AcceptorSynchronousProxy> for zx::Handle {
148    fn from(value: AcceptorSynchronousProxy) -> Self {
149        value.into_channel().into()
150    }
151}
152
153#[cfg(target_os = "fuchsia")]
154impl From<fidl::Channel> for AcceptorSynchronousProxy {
155    fn from(value: fidl::Channel) -> Self {
156        Self::new(value)
157    }
158}
159
160#[cfg(target_os = "fuchsia")]
161impl fidl::endpoints::FromClient for AcceptorSynchronousProxy {
162    type Protocol = AcceptorMarker;
163
164    fn from_client(value: fidl::endpoints::ClientEnd<AcceptorMarker>) -> Self {
165        Self::new(value.into_channel())
166    }
167}
168
169#[derive(Debug, Clone)]
170pub struct AcceptorProxy {
171    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
172}
173
174impl fidl::endpoints::Proxy for AcceptorProxy {
175    type Protocol = AcceptorMarker;
176
177    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
178        Self::new(inner)
179    }
180
181    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
182        self.client.into_channel().map_err(|client| Self { client })
183    }
184
185    fn as_channel(&self) -> &::fidl::AsyncChannel {
186        self.client.as_channel()
187    }
188}
189
190impl AcceptorProxy {
191    /// Create a new Proxy for fuchsia.vsock/Acceptor.
192    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
193        let protocol_name = <AcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
194        Self { client: fidl::client::Client::new(channel, protocol_name) }
195    }
196
197    /// Get a Stream of events from the remote end of the protocol.
198    ///
199    /// # Panics
200    ///
201    /// Panics if the event stream was already taken.
202    pub fn take_event_stream(&self) -> AcceptorEventStream {
203        AcceptorEventStream { event_receiver: self.client.take_event_receiver() }
204    }
205
206    /// The response is either a `ConnectionTransport` to indicate that the connection
207    /// is accepted, or none to indicate that it should be rejected.
208    pub fn r#accept(
209        &self,
210        mut addr: &fidl_fuchsia_hardware_vsock::Addr,
211    ) -> fidl::client::QueryResponseFut<
212        Option<Box<ConnectionTransport>>,
213        fidl::encoding::DefaultFuchsiaResourceDialect,
214    > {
215        AcceptorProxyInterface::r#accept(self, addr)
216    }
217}
218
219impl AcceptorProxyInterface for AcceptorProxy {
220    type AcceptResponseFut = fidl::client::QueryResponseFut<
221        Option<Box<ConnectionTransport>>,
222        fidl::encoding::DefaultFuchsiaResourceDialect,
223    >;
224    fn r#accept(&self, mut addr: &fidl_fuchsia_hardware_vsock::Addr) -> Self::AcceptResponseFut {
225        fn _decode(
226            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
227        ) -> Result<Option<Box<ConnectionTransport>>, fidl::Error> {
228            let _response = fidl::client::decode_transaction_body::<
229                AcceptorAcceptResponse,
230                fidl::encoding::DefaultFuchsiaResourceDialect,
231                0x21fd057ad9c9f443,
232            >(_buf?)?;
233            Ok(_response.con)
234        }
235        self.client
236            .send_query_and_decode::<AcceptorAcceptRequest, Option<Box<ConnectionTransport>>>(
237                (addr,),
238                0x21fd057ad9c9f443,
239                fidl::encoding::DynamicFlags::empty(),
240                _decode,
241            )
242    }
243}
244
245pub struct AcceptorEventStream {
246    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
247}
248
249impl std::marker::Unpin for AcceptorEventStream {}
250
251impl futures::stream::FusedStream for AcceptorEventStream {
252    fn is_terminated(&self) -> bool {
253        self.event_receiver.is_terminated()
254    }
255}
256
257impl futures::Stream for AcceptorEventStream {
258    type Item = Result<AcceptorEvent, fidl::Error>;
259
260    fn poll_next(
261        mut self: std::pin::Pin<&mut Self>,
262        cx: &mut std::task::Context<'_>,
263    ) -> std::task::Poll<Option<Self::Item>> {
264        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
265            &mut self.event_receiver,
266            cx
267        )?) {
268            Some(buf) => std::task::Poll::Ready(Some(AcceptorEvent::decode(buf))),
269            None => std::task::Poll::Ready(None),
270        }
271    }
272}
273
274#[derive(Debug)]
275pub enum AcceptorEvent {}
276
277impl AcceptorEvent {
278    /// Decodes a message buffer as a [`AcceptorEvent`].
279    fn decode(
280        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
281    ) -> Result<AcceptorEvent, fidl::Error> {
282        let (bytes, _handles) = buf.split_mut();
283        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
284        debug_assert_eq!(tx_header.tx_id, 0);
285        match tx_header.ordinal {
286            _ => Err(fidl::Error::UnknownOrdinal {
287                ordinal: tx_header.ordinal,
288                protocol_name: <AcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
289            }),
290        }
291    }
292}
293
294/// A Stream of incoming requests for fuchsia.vsock/Acceptor.
295pub struct AcceptorRequestStream {
296    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
297    is_terminated: bool,
298}
299
300impl std::marker::Unpin for AcceptorRequestStream {}
301
302impl futures::stream::FusedStream for AcceptorRequestStream {
303    fn is_terminated(&self) -> bool {
304        self.is_terminated
305    }
306}
307
308impl fidl::endpoints::RequestStream for AcceptorRequestStream {
309    type Protocol = AcceptorMarker;
310    type ControlHandle = AcceptorControlHandle;
311
312    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
313        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
314    }
315
316    fn control_handle(&self) -> Self::ControlHandle {
317        AcceptorControlHandle { inner: self.inner.clone() }
318    }
319
320    fn into_inner(
321        self,
322    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
323    {
324        (self.inner, self.is_terminated)
325    }
326
327    fn from_inner(
328        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
329        is_terminated: bool,
330    ) -> Self {
331        Self { inner, is_terminated }
332    }
333}
334
335impl futures::Stream for AcceptorRequestStream {
336    type Item = Result<AcceptorRequest, fidl::Error>;
337
338    fn poll_next(
339        mut self: std::pin::Pin<&mut Self>,
340        cx: &mut std::task::Context<'_>,
341    ) -> std::task::Poll<Option<Self::Item>> {
342        let this = &mut *self;
343        if this.inner.check_shutdown(cx) {
344            this.is_terminated = true;
345            return std::task::Poll::Ready(None);
346        }
347        if this.is_terminated {
348            panic!("polled AcceptorRequestStream after completion");
349        }
350        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
351            |bytes, handles| {
352                match this.inner.channel().read_etc(cx, bytes, handles) {
353                    std::task::Poll::Ready(Ok(())) => {}
354                    std::task::Poll::Pending => return std::task::Poll::Pending,
355                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
356                        this.is_terminated = true;
357                        return std::task::Poll::Ready(None);
358                    }
359                    std::task::Poll::Ready(Err(e)) => {
360                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
361                            e.into(),
362                        ))));
363                    }
364                }
365
366                // A message has been received from the channel
367                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
368
369                std::task::Poll::Ready(Some(match header.ordinal {
370                    0x21fd057ad9c9f443 => {
371                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
372                        let mut req = fidl::new_empty!(
373                            AcceptorAcceptRequest,
374                            fidl::encoding::DefaultFuchsiaResourceDialect
375                        );
376                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AcceptorAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
377                        let control_handle = AcceptorControlHandle { inner: this.inner.clone() };
378                        Ok(AcceptorRequest::Accept {
379                            addr: req.addr,
380
381                            responder: AcceptorAcceptResponder {
382                                control_handle: std::mem::ManuallyDrop::new(control_handle),
383                                tx_id: header.tx_id,
384                            },
385                        })
386                    }
387                    _ => Err(fidl::Error::UnknownOrdinal {
388                        ordinal: header.ordinal,
389                        protocol_name:
390                            <AcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
391                    }),
392                }))
393            },
394        )
395    }
396}
397
398/// Interface presented by a listener to accept or reject connections
399#[derive(Debug)]
400pub enum AcceptorRequest {
401    /// The response is either a `ConnectionTransport` to indicate that the connection
402    /// is accepted, or none to indicate that it should be rejected.
403    Accept { addr: fidl_fuchsia_hardware_vsock::Addr, responder: AcceptorAcceptResponder },
404}
405
406impl AcceptorRequest {
407    #[allow(irrefutable_let_patterns)]
408    pub fn into_accept(
409        self,
410    ) -> Option<(fidl_fuchsia_hardware_vsock::Addr, AcceptorAcceptResponder)> {
411        if let AcceptorRequest::Accept { addr, responder } = self {
412            Some((addr, responder))
413        } else {
414            None
415        }
416    }
417
418    /// Name of the method defined in FIDL
419    pub fn method_name(&self) -> &'static str {
420        match *self {
421            AcceptorRequest::Accept { .. } => "accept",
422        }
423    }
424}
425
426#[derive(Debug, Clone)]
427pub struct AcceptorControlHandle {
428    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
429}
430
431impl fidl::endpoints::ControlHandle for AcceptorControlHandle {
432    fn shutdown(&self) {
433        self.inner.shutdown()
434    }
435    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
436        self.inner.shutdown_with_epitaph(status)
437    }
438
439    fn is_closed(&self) -> bool {
440        self.inner.channel().is_closed()
441    }
442    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
443        self.inner.channel().on_closed()
444    }
445
446    #[cfg(target_os = "fuchsia")]
447    fn signal_peer(
448        &self,
449        clear_mask: zx::Signals,
450        set_mask: zx::Signals,
451    ) -> Result<(), zx_status::Status> {
452        use fidl::Peered;
453        self.inner.channel().signal_peer(clear_mask, set_mask)
454    }
455}
456
457impl AcceptorControlHandle {}
458
459#[must_use = "FIDL methods require a response to be sent"]
460#[derive(Debug)]
461pub struct AcceptorAcceptResponder {
462    control_handle: std::mem::ManuallyDrop<AcceptorControlHandle>,
463    tx_id: u32,
464}
465
466/// Set the the channel to be shutdown (see [`AcceptorControlHandle::shutdown`])
467/// if the responder is dropped without sending a response, so that the client
468/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
469impl std::ops::Drop for AcceptorAcceptResponder {
470    fn drop(&mut self) {
471        self.control_handle.shutdown();
472        // Safety: drops once, never accessed again
473        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
474    }
475}
476
477impl fidl::endpoints::Responder for AcceptorAcceptResponder {
478    type ControlHandle = AcceptorControlHandle;
479
480    fn control_handle(&self) -> &AcceptorControlHandle {
481        &self.control_handle
482    }
483
484    fn drop_without_shutdown(mut self) {
485        // Safety: drops once, never accessed again due to mem::forget
486        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
487        // Prevent Drop from running (which would shut down the channel)
488        std::mem::forget(self);
489    }
490}
491
492impl AcceptorAcceptResponder {
493    /// Sends a response to the FIDL transaction.
494    ///
495    /// Sets the channel to shutdown if an error occurs.
496    pub fn send(self, mut con: Option<ConnectionTransport>) -> Result<(), fidl::Error> {
497        let _result = self.send_raw(con);
498        if _result.is_err() {
499            self.control_handle.shutdown();
500        }
501        self.drop_without_shutdown();
502        _result
503    }
504
505    /// Similar to "send" but does not shutdown the channel if an error occurs.
506    pub fn send_no_shutdown_on_err(
507        self,
508        mut con: Option<ConnectionTransport>,
509    ) -> Result<(), fidl::Error> {
510        let _result = self.send_raw(con);
511        self.drop_without_shutdown();
512        _result
513    }
514
515    fn send_raw(&self, mut con: Option<ConnectionTransport>) -> Result<(), fidl::Error> {
516        self.control_handle.inner.send::<AcceptorAcceptResponse>(
517            (con.as_mut(),),
518            self.tx_id,
519            0x21fd057ad9c9f443,
520            fidl::encoding::DynamicFlags::empty(),
521        )
522    }
523}
524
525#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
526pub struct ConnectionMarker;
527
528impl fidl::endpoints::ProtocolMarker for ConnectionMarker {
529    type Proxy = ConnectionProxy;
530    type RequestStream = ConnectionRequestStream;
531    #[cfg(target_os = "fuchsia")]
532    type SynchronousProxy = ConnectionSynchronousProxy;
533
534    const DEBUG_NAME: &'static str = "(anonymous) Connection";
535}
536
537pub trait ConnectionProxyInterface: Send + Sync {
538    fn r#shutdown(&self) -> Result<(), fidl::Error>;
539}
540#[derive(Debug)]
541#[cfg(target_os = "fuchsia")]
542pub struct ConnectionSynchronousProxy {
543    client: fidl::client::sync::Client,
544}
545
546#[cfg(target_os = "fuchsia")]
547impl fidl::endpoints::SynchronousProxy for ConnectionSynchronousProxy {
548    type Proxy = ConnectionProxy;
549    type Protocol = ConnectionMarker;
550
551    fn from_channel(inner: fidl::Channel) -> Self {
552        Self::new(inner)
553    }
554
555    fn into_channel(self) -> fidl::Channel {
556        self.client.into_channel()
557    }
558
559    fn as_channel(&self) -> &fidl::Channel {
560        self.client.as_channel()
561    }
562}
563
564#[cfg(target_os = "fuchsia")]
565impl ConnectionSynchronousProxy {
566    pub fn new(channel: fidl::Channel) -> Self {
567        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
568        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
569    }
570
571    pub fn into_channel(self) -> fidl::Channel {
572        self.client.into_channel()
573    }
574
575    /// Waits until an event arrives and returns it. It is safe for other
576    /// threads to make concurrent requests while waiting for an event.
577    pub fn wait_for_event(
578        &self,
579        deadline: zx::MonotonicInstant,
580    ) -> Result<ConnectionEvent, fidl::Error> {
581        ConnectionEvent::decode(self.client.wait_for_event(deadline)?)
582    }
583
584    /// Trigger asynchronous shutdown. The underlying channel will be closed
585    /// once shutdown is complete. Shutdown has an implicit barrier as any already
586    /// queued sends will complete, but any additional sends will generate errors
587    pub fn r#shutdown(&self) -> Result<(), fidl::Error> {
588        self.client.send::<fidl::encoding::EmptyPayload>(
589            (),
590            0x40da7ca487466971,
591            fidl::encoding::DynamicFlags::empty(),
592        )
593    }
594}
595
596#[cfg(target_os = "fuchsia")]
597impl From<ConnectionSynchronousProxy> for zx::Handle {
598    fn from(value: ConnectionSynchronousProxy) -> Self {
599        value.into_channel().into()
600    }
601}
602
603#[cfg(target_os = "fuchsia")]
604impl From<fidl::Channel> for ConnectionSynchronousProxy {
605    fn from(value: fidl::Channel) -> Self {
606        Self::new(value)
607    }
608}
609
610#[cfg(target_os = "fuchsia")]
611impl fidl::endpoints::FromClient for ConnectionSynchronousProxy {
612    type Protocol = ConnectionMarker;
613
614    fn from_client(value: fidl::endpoints::ClientEnd<ConnectionMarker>) -> Self {
615        Self::new(value.into_channel())
616    }
617}
618
619#[derive(Debug, Clone)]
620pub struct ConnectionProxy {
621    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
622}
623
624impl fidl::endpoints::Proxy for ConnectionProxy {
625    type Protocol = ConnectionMarker;
626
627    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
628        Self::new(inner)
629    }
630
631    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
632        self.client.into_channel().map_err(|client| Self { client })
633    }
634
635    fn as_channel(&self) -> &::fidl::AsyncChannel {
636        self.client.as_channel()
637    }
638}
639
640impl ConnectionProxy {
641    /// Create a new Proxy for fuchsia.vsock/Connection.
642    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
643        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
644        Self { client: fidl::client::Client::new(channel, protocol_name) }
645    }
646
647    /// Get a Stream of events from the remote end of the protocol.
648    ///
649    /// # Panics
650    ///
651    /// Panics if the event stream was already taken.
652    pub fn take_event_stream(&self) -> ConnectionEventStream {
653        ConnectionEventStream { event_receiver: self.client.take_event_receiver() }
654    }
655
656    /// Trigger asynchronous shutdown. The underlying channel will be closed
657    /// once shutdown is complete. Shutdown has an implicit barrier as any already
658    /// queued sends will complete, but any additional sends will generate errors
659    pub fn r#shutdown(&self) -> Result<(), fidl::Error> {
660        ConnectionProxyInterface::r#shutdown(self)
661    }
662}
663
664impl ConnectionProxyInterface for ConnectionProxy {
665    fn r#shutdown(&self) -> Result<(), fidl::Error> {
666        self.client.send::<fidl::encoding::EmptyPayload>(
667            (),
668            0x40da7ca487466971,
669            fidl::encoding::DynamicFlags::empty(),
670        )
671    }
672}
673
674pub struct ConnectionEventStream {
675    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
676}
677
678impl std::marker::Unpin for ConnectionEventStream {}
679
680impl futures::stream::FusedStream for ConnectionEventStream {
681    fn is_terminated(&self) -> bool {
682        self.event_receiver.is_terminated()
683    }
684}
685
686impl futures::Stream for ConnectionEventStream {
687    type Item = Result<ConnectionEvent, fidl::Error>;
688
689    fn poll_next(
690        mut self: std::pin::Pin<&mut Self>,
691        cx: &mut std::task::Context<'_>,
692    ) -> std::task::Poll<Option<Self::Item>> {
693        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
694            &mut self.event_receiver,
695            cx
696        )?) {
697            Some(buf) => std::task::Poll::Ready(Some(ConnectionEvent::decode(buf))),
698            None => std::task::Poll::Ready(None),
699        }
700    }
701}
702
703#[derive(Debug)]
704pub enum ConnectionEvent {}
705
706impl ConnectionEvent {
707    /// Decodes a message buffer as a [`ConnectionEvent`].
708    fn decode(
709        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
710    ) -> Result<ConnectionEvent, fidl::Error> {
711        let (bytes, _handles) = buf.split_mut();
712        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
713        debug_assert_eq!(tx_header.tx_id, 0);
714        match tx_header.ordinal {
715            _ => Err(fidl::Error::UnknownOrdinal {
716                ordinal: tx_header.ordinal,
717                protocol_name: <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
718            }),
719        }
720    }
721}
722
723/// A Stream of incoming requests for fuchsia.vsock/Connection.
724pub struct ConnectionRequestStream {
725    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
726    is_terminated: bool,
727}
728
729impl std::marker::Unpin for ConnectionRequestStream {}
730
731impl futures::stream::FusedStream for ConnectionRequestStream {
732    fn is_terminated(&self) -> bool {
733        self.is_terminated
734    }
735}
736
737impl fidl::endpoints::RequestStream for ConnectionRequestStream {
738    type Protocol = ConnectionMarker;
739    type ControlHandle = ConnectionControlHandle;
740
741    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
742        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
743    }
744
745    fn control_handle(&self) -> Self::ControlHandle {
746        ConnectionControlHandle { inner: self.inner.clone() }
747    }
748
749    fn into_inner(
750        self,
751    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
752    {
753        (self.inner, self.is_terminated)
754    }
755
756    fn from_inner(
757        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
758        is_terminated: bool,
759    ) -> Self {
760        Self { inner, is_terminated }
761    }
762}
763
764impl futures::Stream for ConnectionRequestStream {
765    type Item = Result<ConnectionRequest, fidl::Error>;
766
767    fn poll_next(
768        mut self: std::pin::Pin<&mut Self>,
769        cx: &mut std::task::Context<'_>,
770    ) -> std::task::Poll<Option<Self::Item>> {
771        let this = &mut *self;
772        if this.inner.check_shutdown(cx) {
773            this.is_terminated = true;
774            return std::task::Poll::Ready(None);
775        }
776        if this.is_terminated {
777            panic!("polled ConnectionRequestStream after completion");
778        }
779        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
780            |bytes, handles| {
781                match this.inner.channel().read_etc(cx, bytes, handles) {
782                    std::task::Poll::Ready(Ok(())) => {}
783                    std::task::Poll::Pending => return std::task::Poll::Pending,
784                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
785                        this.is_terminated = true;
786                        return std::task::Poll::Ready(None);
787                    }
788                    std::task::Poll::Ready(Err(e)) => {
789                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
790                            e.into(),
791                        ))));
792                    }
793                }
794
795                // A message has been received from the channel
796                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
797
798                std::task::Poll::Ready(Some(match header.ordinal {
799                    0x40da7ca487466971 => {
800                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
801                        let mut req = fidl::new_empty!(
802                            fidl::encoding::EmptyPayload,
803                            fidl::encoding::DefaultFuchsiaResourceDialect
804                        );
805                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
806                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
807                        Ok(ConnectionRequest::Shutdown { control_handle })
808                    }
809                    _ => Err(fidl::Error::UnknownOrdinal {
810                        ordinal: header.ordinal,
811                        protocol_name:
812                            <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
813                    }),
814                }))
815            },
816        )
817    }
818}
819
820/// Interface for manipulating the state of an active connection.
821#[derive(Debug)]
822pub enum ConnectionRequest {
823    /// Trigger asynchronous shutdown. The underlying channel will be closed
824    /// once shutdown is complete. Shutdown has an implicit barrier as any already
825    /// queued sends will complete, but any additional sends will generate errors
826    Shutdown { control_handle: ConnectionControlHandle },
827}
828
829impl ConnectionRequest {
830    #[allow(irrefutable_let_patterns)]
831    pub fn into_shutdown(self) -> Option<(ConnectionControlHandle)> {
832        if let ConnectionRequest::Shutdown { control_handle } = self {
833            Some((control_handle))
834        } else {
835            None
836        }
837    }
838
839    /// Name of the method defined in FIDL
840    pub fn method_name(&self) -> &'static str {
841        match *self {
842            ConnectionRequest::Shutdown { .. } => "shutdown",
843        }
844    }
845}
846
847#[derive(Debug, Clone)]
848pub struct ConnectionControlHandle {
849    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
850}
851
852impl fidl::endpoints::ControlHandle for ConnectionControlHandle {
853    fn shutdown(&self) {
854        self.inner.shutdown()
855    }
856    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
857        self.inner.shutdown_with_epitaph(status)
858    }
859
860    fn is_closed(&self) -> bool {
861        self.inner.channel().is_closed()
862    }
863    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
864        self.inner.channel().on_closed()
865    }
866
867    #[cfg(target_os = "fuchsia")]
868    fn signal_peer(
869        &self,
870        clear_mask: zx::Signals,
871        set_mask: zx::Signals,
872    ) -> Result<(), zx_status::Status> {
873        use fidl::Peered;
874        self.inner.channel().signal_peer(clear_mask, set_mask)
875    }
876}
877
878impl ConnectionControlHandle {}
879
880#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
881pub struct ConnectorMarker;
882
883impl fidl::endpoints::ProtocolMarker for ConnectorMarker {
884    type Proxy = ConnectorProxy;
885    type RequestStream = ConnectorRequestStream;
886    #[cfg(target_os = "fuchsia")]
887    type SynchronousProxy = ConnectorSynchronousProxy;
888
889    const DEBUG_NAME: &'static str = "fuchsia.vsock.Connector";
890}
891impl fidl::endpoints::DiscoverableProtocolMarker for ConnectorMarker {}
892pub type ConnectorConnectResult = Result<u32, i32>;
893pub type ConnectorListenResult = Result<(), i32>;
894pub type ConnectorBindResult = Result<(), i32>;
895
896pub trait ConnectorProxyInterface: Send + Sync {
897    type ConnectResponseFut: std::future::Future<Output = Result<ConnectorConnectResult, fidl::Error>>
898        + Send;
899    fn r#connect(
900        &self,
901        remote_cid: u32,
902        remote_port: u32,
903        con: ConnectionTransport,
904    ) -> Self::ConnectResponseFut;
905    type ListenResponseFut: std::future::Future<Output = Result<ConnectorListenResult, fidl::Error>>
906        + Send;
907    fn r#listen(
908        &self,
909        local_port: u32,
910        acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
911    ) -> Self::ListenResponseFut;
912    type BindResponseFut: std::future::Future<Output = Result<ConnectorBindResult, fidl::Error>>
913        + Send;
914    fn r#bind(
915        &self,
916        remote_cid: u32,
917        local_port: u32,
918        listener: fidl::endpoints::ServerEnd<ListenerMarker>,
919    ) -> Self::BindResponseFut;
920    type GetCidResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
921    fn r#get_cid(&self) -> Self::GetCidResponseFut;
922}
923#[derive(Debug)]
924#[cfg(target_os = "fuchsia")]
925pub struct ConnectorSynchronousProxy {
926    client: fidl::client::sync::Client,
927}
928
929#[cfg(target_os = "fuchsia")]
930impl fidl::endpoints::SynchronousProxy for ConnectorSynchronousProxy {
931    type Proxy = ConnectorProxy;
932    type Protocol = ConnectorMarker;
933
934    fn from_channel(inner: fidl::Channel) -> Self {
935        Self::new(inner)
936    }
937
938    fn into_channel(self) -> fidl::Channel {
939        self.client.into_channel()
940    }
941
942    fn as_channel(&self) -> &fidl::Channel {
943        self.client.as_channel()
944    }
945}
946
947#[cfg(target_os = "fuchsia")]
948impl ConnectorSynchronousProxy {
949    pub fn new(channel: fidl::Channel) -> Self {
950        let protocol_name = <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
951        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
952    }
953
954    pub fn into_channel(self) -> fidl::Channel {
955        self.client.into_channel()
956    }
957
958    /// Waits until an event arrives and returns it. It is safe for other
959    /// threads to make concurrent requests while waiting for an event.
960    pub fn wait_for_event(
961        &self,
962        deadline: zx::MonotonicInstant,
963    ) -> Result<ConnectorEvent, fidl::Error> {
964        ConnectorEvent::decode(self.client.wait_for_event(deadline)?)
965    }
966
967    /// Attempt to establish a connection to the specified remote cid/port pair.
968    /// No local port is specified as an ephemeral one will automatically be allocated.
969    pub fn r#connect(
970        &self,
971        mut remote_cid: u32,
972        mut remote_port: u32,
973        mut con: ConnectionTransport,
974        ___deadline: zx::MonotonicInstant,
975    ) -> Result<ConnectorConnectResult, fidl::Error> {
976        let _response = self.client.send_query::<
977            ConnectorConnectRequest,
978            fidl::encoding::ResultType<ConnectorConnectResponse, i32>,
979        >(
980            (remote_cid, remote_port, &mut con,),
981            0xdf55c5e6a6a4117,
982            fidl::encoding::DynamicFlags::empty(),
983            ___deadline,
984        )?;
985        Ok(_response.map(|x| x.local_port))
986    }
987
988    /// Registers a listener for a local port. There can only be one listener for
989    /// a single port at a time.
990    pub fn r#listen(
991        &self,
992        mut local_port: u32,
993        mut acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
994        ___deadline: zx::MonotonicInstant,
995    ) -> Result<ConnectorListenResult, fidl::Error> {
996        let _response = self.client.send_query::<
997            ConnectorListenRequest,
998            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
999        >(
1000            (local_port, acceptor,),
1001            0x17c1371908bacf73,
1002            fidl::encoding::DynamicFlags::empty(),
1003            ___deadline,
1004        )?;
1005        Ok(_response.map(|x| x))
1006    }
1007
1008    /// Registers a listener for a local port. There can only be one listener for
1009    /// a single port at a time.
1010    pub fn r#bind(
1011        &self,
1012        mut remote_cid: u32,
1013        mut local_port: u32,
1014        mut listener: fidl::endpoints::ServerEnd<ListenerMarker>,
1015        ___deadline: zx::MonotonicInstant,
1016    ) -> Result<ConnectorBindResult, fidl::Error> {
1017        let _response = self.client.send_query::<
1018            ConnectorBindRequest,
1019            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1020        >(
1021            (remote_cid, local_port, listener,),
1022            0x6e50cd8c895f2e0,
1023            fidl::encoding::DynamicFlags::empty(),
1024            ___deadline,
1025        )?;
1026        Ok(_response.map(|x| x))
1027    }
1028
1029    /// Query the current context id of the system. The local CID is should not
1030    /// necessary in interactions with the same device; instead you may pass
1031    /// `VMADDR_CID_LOCAL`, which will alias to local CID this returns. The cid returned
1032    /// by this method is useful for debugging or if you have some other communication
1033    /// channel to a different host and you would like to send them your CID to then
1034    /// establish a vsock connection on.
1035    pub fn r#get_cid(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
1036        let _response =
1037            self.client.send_query::<fidl::encoding::EmptyPayload, ConnectorGetCidResponse>(
1038                (),
1039                0x60b3cfa0b40bdd7c,
1040                fidl::encoding::DynamicFlags::empty(),
1041                ___deadline,
1042            )?;
1043        Ok(_response.local_cid)
1044    }
1045}
1046
1047#[cfg(target_os = "fuchsia")]
1048impl From<ConnectorSynchronousProxy> for zx::Handle {
1049    fn from(value: ConnectorSynchronousProxy) -> Self {
1050        value.into_channel().into()
1051    }
1052}
1053
1054#[cfg(target_os = "fuchsia")]
1055impl From<fidl::Channel> for ConnectorSynchronousProxy {
1056    fn from(value: fidl::Channel) -> Self {
1057        Self::new(value)
1058    }
1059}
1060
1061#[cfg(target_os = "fuchsia")]
1062impl fidl::endpoints::FromClient for ConnectorSynchronousProxy {
1063    type Protocol = ConnectorMarker;
1064
1065    fn from_client(value: fidl::endpoints::ClientEnd<ConnectorMarker>) -> Self {
1066        Self::new(value.into_channel())
1067    }
1068}
1069
1070#[derive(Debug, Clone)]
1071pub struct ConnectorProxy {
1072    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1073}
1074
1075impl fidl::endpoints::Proxy for ConnectorProxy {
1076    type Protocol = ConnectorMarker;
1077
1078    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1079        Self::new(inner)
1080    }
1081
1082    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1083        self.client.into_channel().map_err(|client| Self { client })
1084    }
1085
1086    fn as_channel(&self) -> &::fidl::AsyncChannel {
1087        self.client.as_channel()
1088    }
1089}
1090
1091impl ConnectorProxy {
1092    /// Create a new Proxy for fuchsia.vsock/Connector.
1093    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1094        let protocol_name = <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1095        Self { client: fidl::client::Client::new(channel, protocol_name) }
1096    }
1097
1098    /// Get a Stream of events from the remote end of the protocol.
1099    ///
1100    /// # Panics
1101    ///
1102    /// Panics if the event stream was already taken.
1103    pub fn take_event_stream(&self) -> ConnectorEventStream {
1104        ConnectorEventStream { event_receiver: self.client.take_event_receiver() }
1105    }
1106
1107    /// Attempt to establish a connection to the specified remote cid/port pair.
1108    /// No local port is specified as an ephemeral one will automatically be allocated.
1109    pub fn r#connect(
1110        &self,
1111        mut remote_cid: u32,
1112        mut remote_port: u32,
1113        mut con: ConnectionTransport,
1114    ) -> fidl::client::QueryResponseFut<
1115        ConnectorConnectResult,
1116        fidl::encoding::DefaultFuchsiaResourceDialect,
1117    > {
1118        ConnectorProxyInterface::r#connect(self, remote_cid, remote_port, con)
1119    }
1120
1121    /// Registers a listener for a local port. There can only be one listener for
1122    /// a single port at a time.
1123    pub fn r#listen(
1124        &self,
1125        mut local_port: u32,
1126        mut acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
1127    ) -> fidl::client::QueryResponseFut<
1128        ConnectorListenResult,
1129        fidl::encoding::DefaultFuchsiaResourceDialect,
1130    > {
1131        ConnectorProxyInterface::r#listen(self, local_port, acceptor)
1132    }
1133
1134    /// Registers a listener for a local port. There can only be one listener for
1135    /// a single port at a time.
1136    pub fn r#bind(
1137        &self,
1138        mut remote_cid: u32,
1139        mut local_port: u32,
1140        mut listener: fidl::endpoints::ServerEnd<ListenerMarker>,
1141    ) -> fidl::client::QueryResponseFut<
1142        ConnectorBindResult,
1143        fidl::encoding::DefaultFuchsiaResourceDialect,
1144    > {
1145        ConnectorProxyInterface::r#bind(self, remote_cid, local_port, listener)
1146    }
1147
1148    /// Query the current context id of the system. The local CID is should not
1149    /// necessary in interactions with the same device; instead you may pass
1150    /// `VMADDR_CID_LOCAL`, which will alias to local CID this returns. The cid returned
1151    /// by this method is useful for debugging or if you have some other communication
1152    /// channel to a different host and you would like to send them your CID to then
1153    /// establish a vsock connection on.
1154    pub fn r#get_cid(
1155        &self,
1156    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
1157        ConnectorProxyInterface::r#get_cid(self)
1158    }
1159}
1160
1161impl ConnectorProxyInterface for ConnectorProxy {
1162    type ConnectResponseFut = fidl::client::QueryResponseFut<
1163        ConnectorConnectResult,
1164        fidl::encoding::DefaultFuchsiaResourceDialect,
1165    >;
1166    fn r#connect(
1167        &self,
1168        mut remote_cid: u32,
1169        mut remote_port: u32,
1170        mut con: ConnectionTransport,
1171    ) -> Self::ConnectResponseFut {
1172        fn _decode(
1173            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1174        ) -> Result<ConnectorConnectResult, fidl::Error> {
1175            let _response = fidl::client::decode_transaction_body::<
1176                fidl::encoding::ResultType<ConnectorConnectResponse, i32>,
1177                fidl::encoding::DefaultFuchsiaResourceDialect,
1178                0xdf55c5e6a6a4117,
1179            >(_buf?)?;
1180            Ok(_response.map(|x| x.local_port))
1181        }
1182        self.client.send_query_and_decode::<ConnectorConnectRequest, ConnectorConnectResult>(
1183            (remote_cid, remote_port, &mut con),
1184            0xdf55c5e6a6a4117,
1185            fidl::encoding::DynamicFlags::empty(),
1186            _decode,
1187        )
1188    }
1189
1190    type ListenResponseFut = fidl::client::QueryResponseFut<
1191        ConnectorListenResult,
1192        fidl::encoding::DefaultFuchsiaResourceDialect,
1193    >;
1194    fn r#listen(
1195        &self,
1196        mut local_port: u32,
1197        mut acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
1198    ) -> Self::ListenResponseFut {
1199        fn _decode(
1200            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1201        ) -> Result<ConnectorListenResult, fidl::Error> {
1202            let _response = fidl::client::decode_transaction_body::<
1203                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1204                fidl::encoding::DefaultFuchsiaResourceDialect,
1205                0x17c1371908bacf73,
1206            >(_buf?)?;
1207            Ok(_response.map(|x| x))
1208        }
1209        self.client.send_query_and_decode::<ConnectorListenRequest, ConnectorListenResult>(
1210            (local_port, acceptor),
1211            0x17c1371908bacf73,
1212            fidl::encoding::DynamicFlags::empty(),
1213            _decode,
1214        )
1215    }
1216
1217    type BindResponseFut = fidl::client::QueryResponseFut<
1218        ConnectorBindResult,
1219        fidl::encoding::DefaultFuchsiaResourceDialect,
1220    >;
1221    fn r#bind(
1222        &self,
1223        mut remote_cid: u32,
1224        mut local_port: u32,
1225        mut listener: fidl::endpoints::ServerEnd<ListenerMarker>,
1226    ) -> Self::BindResponseFut {
1227        fn _decode(
1228            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1229        ) -> Result<ConnectorBindResult, fidl::Error> {
1230            let _response = fidl::client::decode_transaction_body::<
1231                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1232                fidl::encoding::DefaultFuchsiaResourceDialect,
1233                0x6e50cd8c895f2e0,
1234            >(_buf?)?;
1235            Ok(_response.map(|x| x))
1236        }
1237        self.client.send_query_and_decode::<ConnectorBindRequest, ConnectorBindResult>(
1238            (remote_cid, local_port, listener),
1239            0x6e50cd8c895f2e0,
1240            fidl::encoding::DynamicFlags::empty(),
1241            _decode,
1242        )
1243    }
1244
1245    type GetCidResponseFut =
1246        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1247    fn r#get_cid(&self) -> Self::GetCidResponseFut {
1248        fn _decode(
1249            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1250        ) -> Result<u32, fidl::Error> {
1251            let _response = fidl::client::decode_transaction_body::<
1252                ConnectorGetCidResponse,
1253                fidl::encoding::DefaultFuchsiaResourceDialect,
1254                0x60b3cfa0b40bdd7c,
1255            >(_buf?)?;
1256            Ok(_response.local_cid)
1257        }
1258        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
1259            (),
1260            0x60b3cfa0b40bdd7c,
1261            fidl::encoding::DynamicFlags::empty(),
1262            _decode,
1263        )
1264    }
1265}
1266
1267pub struct ConnectorEventStream {
1268    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1269}
1270
1271impl std::marker::Unpin for ConnectorEventStream {}
1272
1273impl futures::stream::FusedStream for ConnectorEventStream {
1274    fn is_terminated(&self) -> bool {
1275        self.event_receiver.is_terminated()
1276    }
1277}
1278
1279impl futures::Stream for ConnectorEventStream {
1280    type Item = Result<ConnectorEvent, fidl::Error>;
1281
1282    fn poll_next(
1283        mut self: std::pin::Pin<&mut Self>,
1284        cx: &mut std::task::Context<'_>,
1285    ) -> std::task::Poll<Option<Self::Item>> {
1286        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1287            &mut self.event_receiver,
1288            cx
1289        )?) {
1290            Some(buf) => std::task::Poll::Ready(Some(ConnectorEvent::decode(buf))),
1291            None => std::task::Poll::Ready(None),
1292        }
1293    }
1294}
1295
1296#[derive(Debug)]
1297pub enum ConnectorEvent {}
1298
1299impl ConnectorEvent {
1300    /// Decodes a message buffer as a [`ConnectorEvent`].
1301    fn decode(
1302        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1303    ) -> Result<ConnectorEvent, fidl::Error> {
1304        let (bytes, _handles) = buf.split_mut();
1305        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1306        debug_assert_eq!(tx_header.tx_id, 0);
1307        match tx_header.ordinal {
1308            _ => Err(fidl::Error::UnknownOrdinal {
1309                ordinal: tx_header.ordinal,
1310                protocol_name: <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1311            }),
1312        }
1313    }
1314}
1315
1316/// A Stream of incoming requests for fuchsia.vsock/Connector.
1317pub struct ConnectorRequestStream {
1318    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1319    is_terminated: bool,
1320}
1321
1322impl std::marker::Unpin for ConnectorRequestStream {}
1323
1324impl futures::stream::FusedStream for ConnectorRequestStream {
1325    fn is_terminated(&self) -> bool {
1326        self.is_terminated
1327    }
1328}
1329
1330impl fidl::endpoints::RequestStream for ConnectorRequestStream {
1331    type Protocol = ConnectorMarker;
1332    type ControlHandle = ConnectorControlHandle;
1333
1334    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1335        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1336    }
1337
1338    fn control_handle(&self) -> Self::ControlHandle {
1339        ConnectorControlHandle { inner: self.inner.clone() }
1340    }
1341
1342    fn into_inner(
1343        self,
1344    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1345    {
1346        (self.inner, self.is_terminated)
1347    }
1348
1349    fn from_inner(
1350        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1351        is_terminated: bool,
1352    ) -> Self {
1353        Self { inner, is_terminated }
1354    }
1355}
1356
1357impl futures::Stream for ConnectorRequestStream {
1358    type Item = Result<ConnectorRequest, fidl::Error>;
1359
1360    fn poll_next(
1361        mut self: std::pin::Pin<&mut Self>,
1362        cx: &mut std::task::Context<'_>,
1363    ) -> std::task::Poll<Option<Self::Item>> {
1364        let this = &mut *self;
1365        if this.inner.check_shutdown(cx) {
1366            this.is_terminated = true;
1367            return std::task::Poll::Ready(None);
1368        }
1369        if this.is_terminated {
1370            panic!("polled ConnectorRequestStream after completion");
1371        }
1372        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1373            |bytes, handles| {
1374                match this.inner.channel().read_etc(cx, bytes, handles) {
1375                    std::task::Poll::Ready(Ok(())) => {}
1376                    std::task::Poll::Pending => return std::task::Poll::Pending,
1377                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1378                        this.is_terminated = true;
1379                        return std::task::Poll::Ready(None);
1380                    }
1381                    std::task::Poll::Ready(Err(e)) => {
1382                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1383                            e.into(),
1384                        ))));
1385                    }
1386                }
1387
1388                // A message has been received from the channel
1389                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1390
1391                std::task::Poll::Ready(Some(match header.ordinal {
1392                    0xdf55c5e6a6a4117 => {
1393                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1394                        let mut req = fidl::new_empty!(
1395                            ConnectorConnectRequest,
1396                            fidl::encoding::DefaultFuchsiaResourceDialect
1397                        );
1398                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1399                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
1400                        Ok(ConnectorRequest::Connect {
1401                            remote_cid: req.remote_cid,
1402                            remote_port: req.remote_port,
1403                            con: req.con,
1404
1405                            responder: ConnectorConnectResponder {
1406                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1407                                tx_id: header.tx_id,
1408                            },
1409                        })
1410                    }
1411                    0x17c1371908bacf73 => {
1412                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1413                        let mut req = fidl::new_empty!(
1414                            ConnectorListenRequest,
1415                            fidl::encoding::DefaultFuchsiaResourceDialect
1416                        );
1417                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorListenRequest>(&header, _body_bytes, handles, &mut req)?;
1418                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
1419                        Ok(ConnectorRequest::Listen {
1420                            local_port: req.local_port,
1421                            acceptor: req.acceptor,
1422
1423                            responder: ConnectorListenResponder {
1424                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1425                                tx_id: header.tx_id,
1426                            },
1427                        })
1428                    }
1429                    0x6e50cd8c895f2e0 => {
1430                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1431                        let mut req = fidl::new_empty!(
1432                            ConnectorBindRequest,
1433                            fidl::encoding::DefaultFuchsiaResourceDialect
1434                        );
1435                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorBindRequest>(&header, _body_bytes, handles, &mut req)?;
1436                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
1437                        Ok(ConnectorRequest::Bind {
1438                            remote_cid: req.remote_cid,
1439                            local_port: req.local_port,
1440                            listener: req.listener,
1441
1442                            responder: ConnectorBindResponder {
1443                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1444                                tx_id: header.tx_id,
1445                            },
1446                        })
1447                    }
1448                    0x60b3cfa0b40bdd7c => {
1449                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1450                        let mut req = fidl::new_empty!(
1451                            fidl::encoding::EmptyPayload,
1452                            fidl::encoding::DefaultFuchsiaResourceDialect
1453                        );
1454                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1455                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
1456                        Ok(ConnectorRequest::GetCid {
1457                            responder: ConnectorGetCidResponder {
1458                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1459                                tx_id: header.tx_id,
1460                            },
1461                        })
1462                    }
1463                    _ => Err(fidl::Error::UnknownOrdinal {
1464                        ordinal: header.ordinal,
1465                        protocol_name:
1466                            <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1467                    }),
1468                }))
1469            },
1470        )
1471    }
1472}
1473
1474/// Exposed by a service that can act as a bridge to the underlying vsock driver and
1475/// provides the ability for listeners to be multiplexed by port and manages dynamic
1476/// port allocation for outbound connections.
1477#[derive(Debug)]
1478pub enum ConnectorRequest {
1479    /// Attempt to establish a connection to the specified remote cid/port pair.
1480    /// No local port is specified as an ephemeral one will automatically be allocated.
1481    Connect {
1482        remote_cid: u32,
1483        remote_port: u32,
1484        con: ConnectionTransport,
1485        responder: ConnectorConnectResponder,
1486    },
1487    /// Registers a listener for a local port. There can only be one listener for
1488    /// a single port at a time.
1489    Listen {
1490        local_port: u32,
1491        acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
1492        responder: ConnectorListenResponder,
1493    },
1494    /// Registers a listener for a local port. There can only be one listener for
1495    /// a single port at a time.
1496    Bind {
1497        remote_cid: u32,
1498        local_port: u32,
1499        listener: fidl::endpoints::ServerEnd<ListenerMarker>,
1500        responder: ConnectorBindResponder,
1501    },
1502    /// Query the current context id of the system. The local CID is should not
1503    /// necessary in interactions with the same device; instead you may pass
1504    /// `VMADDR_CID_LOCAL`, which will alias to local CID this returns. The cid returned
1505    /// by this method is useful for debugging or if you have some other communication
1506    /// channel to a different host and you would like to send them your CID to then
1507    /// establish a vsock connection on.
1508    GetCid { responder: ConnectorGetCidResponder },
1509}
1510
1511impl ConnectorRequest {
1512    #[allow(irrefutable_let_patterns)]
1513    pub fn into_connect(
1514        self,
1515    ) -> Option<(u32, u32, ConnectionTransport, ConnectorConnectResponder)> {
1516        if let ConnectorRequest::Connect { remote_cid, remote_port, con, responder } = self {
1517            Some((remote_cid, remote_port, con, responder))
1518        } else {
1519            None
1520        }
1521    }
1522
1523    #[allow(irrefutable_let_patterns)]
1524    pub fn into_listen(
1525        self,
1526    ) -> Option<(u32, fidl::endpoints::ClientEnd<AcceptorMarker>, ConnectorListenResponder)> {
1527        if let ConnectorRequest::Listen { local_port, acceptor, responder } = self {
1528            Some((local_port, acceptor, responder))
1529        } else {
1530            None
1531        }
1532    }
1533
1534    #[allow(irrefutable_let_patterns)]
1535    pub fn into_bind(
1536        self,
1537    ) -> Option<(u32, u32, fidl::endpoints::ServerEnd<ListenerMarker>, ConnectorBindResponder)>
1538    {
1539        if let ConnectorRequest::Bind { remote_cid, local_port, listener, responder } = self {
1540            Some((remote_cid, local_port, listener, responder))
1541        } else {
1542            None
1543        }
1544    }
1545
1546    #[allow(irrefutable_let_patterns)]
1547    pub fn into_get_cid(self) -> Option<(ConnectorGetCidResponder)> {
1548        if let ConnectorRequest::GetCid { responder } = self { Some((responder)) } else { None }
1549    }
1550
1551    /// Name of the method defined in FIDL
1552    pub fn method_name(&self) -> &'static str {
1553        match *self {
1554            ConnectorRequest::Connect { .. } => "connect",
1555            ConnectorRequest::Listen { .. } => "listen",
1556            ConnectorRequest::Bind { .. } => "bind",
1557            ConnectorRequest::GetCid { .. } => "get_cid",
1558        }
1559    }
1560}
1561
1562#[derive(Debug, Clone)]
1563pub struct ConnectorControlHandle {
1564    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1565}
1566
1567impl fidl::endpoints::ControlHandle for ConnectorControlHandle {
1568    fn shutdown(&self) {
1569        self.inner.shutdown()
1570    }
1571    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1572        self.inner.shutdown_with_epitaph(status)
1573    }
1574
1575    fn is_closed(&self) -> bool {
1576        self.inner.channel().is_closed()
1577    }
1578    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1579        self.inner.channel().on_closed()
1580    }
1581
1582    #[cfg(target_os = "fuchsia")]
1583    fn signal_peer(
1584        &self,
1585        clear_mask: zx::Signals,
1586        set_mask: zx::Signals,
1587    ) -> Result<(), zx_status::Status> {
1588        use fidl::Peered;
1589        self.inner.channel().signal_peer(clear_mask, set_mask)
1590    }
1591}
1592
1593impl ConnectorControlHandle {}
1594
1595#[must_use = "FIDL methods require a response to be sent"]
1596#[derive(Debug)]
1597pub struct ConnectorConnectResponder {
1598    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1599    tx_id: u32,
1600}
1601
1602/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1603/// if the responder is dropped without sending a response, so that the client
1604/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1605impl std::ops::Drop for ConnectorConnectResponder {
1606    fn drop(&mut self) {
1607        self.control_handle.shutdown();
1608        // Safety: drops once, never accessed again
1609        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1610    }
1611}
1612
1613impl fidl::endpoints::Responder for ConnectorConnectResponder {
1614    type ControlHandle = ConnectorControlHandle;
1615
1616    fn control_handle(&self) -> &ConnectorControlHandle {
1617        &self.control_handle
1618    }
1619
1620    fn drop_without_shutdown(mut self) {
1621        // Safety: drops once, never accessed again due to mem::forget
1622        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1623        // Prevent Drop from running (which would shut down the channel)
1624        std::mem::forget(self);
1625    }
1626}
1627
1628impl ConnectorConnectResponder {
1629    /// Sends a response to the FIDL transaction.
1630    ///
1631    /// Sets the channel to shutdown if an error occurs.
1632    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1633        let _result = self.send_raw(result);
1634        if _result.is_err() {
1635            self.control_handle.shutdown();
1636        }
1637        self.drop_without_shutdown();
1638        _result
1639    }
1640
1641    /// Similar to "send" but does not shutdown the channel if an error occurs.
1642    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1643        let _result = self.send_raw(result);
1644        self.drop_without_shutdown();
1645        _result
1646    }
1647
1648    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1649        self.control_handle.inner.send::<fidl::encoding::ResultType<ConnectorConnectResponse, i32>>(
1650            result.map(|local_port| (local_port,)),
1651            self.tx_id,
1652            0xdf55c5e6a6a4117,
1653            fidl::encoding::DynamicFlags::empty(),
1654        )
1655    }
1656}
1657
1658#[must_use = "FIDL methods require a response to be sent"]
1659#[derive(Debug)]
1660pub struct ConnectorListenResponder {
1661    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1662    tx_id: u32,
1663}
1664
1665/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1666/// if the responder is dropped without sending a response, so that the client
1667/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1668impl std::ops::Drop for ConnectorListenResponder {
1669    fn drop(&mut self) {
1670        self.control_handle.shutdown();
1671        // Safety: drops once, never accessed again
1672        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1673    }
1674}
1675
1676impl fidl::endpoints::Responder for ConnectorListenResponder {
1677    type ControlHandle = ConnectorControlHandle;
1678
1679    fn control_handle(&self) -> &ConnectorControlHandle {
1680        &self.control_handle
1681    }
1682
1683    fn drop_without_shutdown(mut self) {
1684        // Safety: drops once, never accessed again due to mem::forget
1685        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1686        // Prevent Drop from running (which would shut down the channel)
1687        std::mem::forget(self);
1688    }
1689}
1690
1691impl ConnectorListenResponder {
1692    /// Sends a response to the FIDL transaction.
1693    ///
1694    /// Sets the channel to shutdown if an error occurs.
1695    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1696        let _result = self.send_raw(result);
1697        if _result.is_err() {
1698            self.control_handle.shutdown();
1699        }
1700        self.drop_without_shutdown();
1701        _result
1702    }
1703
1704    /// Similar to "send" but does not shutdown the channel if an error occurs.
1705    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1706        let _result = self.send_raw(result);
1707        self.drop_without_shutdown();
1708        _result
1709    }
1710
1711    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1712        self.control_handle
1713            .inner
1714            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1715                result,
1716                self.tx_id,
1717                0x17c1371908bacf73,
1718                fidl::encoding::DynamicFlags::empty(),
1719            )
1720    }
1721}
1722
1723#[must_use = "FIDL methods require a response to be sent"]
1724#[derive(Debug)]
1725pub struct ConnectorBindResponder {
1726    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1727    tx_id: u32,
1728}
1729
1730/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1731/// if the responder is dropped without sending a response, so that the client
1732/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1733impl std::ops::Drop for ConnectorBindResponder {
1734    fn drop(&mut self) {
1735        self.control_handle.shutdown();
1736        // Safety: drops once, never accessed again
1737        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1738    }
1739}
1740
1741impl fidl::endpoints::Responder for ConnectorBindResponder {
1742    type ControlHandle = ConnectorControlHandle;
1743
1744    fn control_handle(&self) -> &ConnectorControlHandle {
1745        &self.control_handle
1746    }
1747
1748    fn drop_without_shutdown(mut self) {
1749        // Safety: drops once, never accessed again due to mem::forget
1750        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1751        // Prevent Drop from running (which would shut down the channel)
1752        std::mem::forget(self);
1753    }
1754}
1755
1756impl ConnectorBindResponder {
1757    /// Sends a response to the FIDL transaction.
1758    ///
1759    /// Sets the channel to shutdown if an error occurs.
1760    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1761        let _result = self.send_raw(result);
1762        if _result.is_err() {
1763            self.control_handle.shutdown();
1764        }
1765        self.drop_without_shutdown();
1766        _result
1767    }
1768
1769    /// Similar to "send" but does not shutdown the channel if an error occurs.
1770    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1771        let _result = self.send_raw(result);
1772        self.drop_without_shutdown();
1773        _result
1774    }
1775
1776    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1777        self.control_handle
1778            .inner
1779            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1780                result,
1781                self.tx_id,
1782                0x6e50cd8c895f2e0,
1783                fidl::encoding::DynamicFlags::empty(),
1784            )
1785    }
1786}
1787
1788#[must_use = "FIDL methods require a response to be sent"]
1789#[derive(Debug)]
1790pub struct ConnectorGetCidResponder {
1791    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1792    tx_id: u32,
1793}
1794
1795/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1796/// if the responder is dropped without sending a response, so that the client
1797/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1798impl std::ops::Drop for ConnectorGetCidResponder {
1799    fn drop(&mut self) {
1800        self.control_handle.shutdown();
1801        // Safety: drops once, never accessed again
1802        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1803    }
1804}
1805
1806impl fidl::endpoints::Responder for ConnectorGetCidResponder {
1807    type ControlHandle = ConnectorControlHandle;
1808
1809    fn control_handle(&self) -> &ConnectorControlHandle {
1810        &self.control_handle
1811    }
1812
1813    fn drop_without_shutdown(mut self) {
1814        // Safety: drops once, never accessed again due to mem::forget
1815        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1816        // Prevent Drop from running (which would shut down the channel)
1817        std::mem::forget(self);
1818    }
1819}
1820
1821impl ConnectorGetCidResponder {
1822    /// Sends a response to the FIDL transaction.
1823    ///
1824    /// Sets the channel to shutdown if an error occurs.
1825    pub fn send(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1826        let _result = self.send_raw(local_cid);
1827        if _result.is_err() {
1828            self.control_handle.shutdown();
1829        }
1830        self.drop_without_shutdown();
1831        _result
1832    }
1833
1834    /// Similar to "send" but does not shutdown the channel if an error occurs.
1835    pub fn send_no_shutdown_on_err(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1836        let _result = self.send_raw(local_cid);
1837        self.drop_without_shutdown();
1838        _result
1839    }
1840
1841    fn send_raw(&self, mut local_cid: u32) -> Result<(), fidl::Error> {
1842        self.control_handle.inner.send::<ConnectorGetCidResponse>(
1843            (local_cid,),
1844            self.tx_id,
1845            0x60b3cfa0b40bdd7c,
1846            fidl::encoding::DynamicFlags::empty(),
1847        )
1848    }
1849}
1850
1851#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1852pub struct ListenerMarker;
1853
1854impl fidl::endpoints::ProtocolMarker for ListenerMarker {
1855    type Proxy = ListenerProxy;
1856    type RequestStream = ListenerRequestStream;
1857    #[cfg(target_os = "fuchsia")]
1858    type SynchronousProxy = ListenerSynchronousProxy;
1859
1860    const DEBUG_NAME: &'static str = "(anonymous) Listener";
1861}
1862pub type ListenerListenResult = Result<(), i32>;
1863pub type ListenerAcceptResult = Result<fidl_fuchsia_hardware_vsock::Addr, i32>;
1864
1865pub trait ListenerProxyInterface: Send + Sync {
1866    type ListenResponseFut: std::future::Future<Output = Result<ListenerListenResult, fidl::Error>>
1867        + Send;
1868    fn r#listen(&self, backlog: u32) -> Self::ListenResponseFut;
1869    type AcceptResponseFut: std::future::Future<Output = Result<ListenerAcceptResult, fidl::Error>>
1870        + Send;
1871    fn r#accept(&self, con: ConnectionTransport) -> Self::AcceptResponseFut;
1872}
1873#[derive(Debug)]
1874#[cfg(target_os = "fuchsia")]
1875pub struct ListenerSynchronousProxy {
1876    client: fidl::client::sync::Client,
1877}
1878
1879#[cfg(target_os = "fuchsia")]
1880impl fidl::endpoints::SynchronousProxy for ListenerSynchronousProxy {
1881    type Proxy = ListenerProxy;
1882    type Protocol = ListenerMarker;
1883
1884    fn from_channel(inner: fidl::Channel) -> Self {
1885        Self::new(inner)
1886    }
1887
1888    fn into_channel(self) -> fidl::Channel {
1889        self.client.into_channel()
1890    }
1891
1892    fn as_channel(&self) -> &fidl::Channel {
1893        self.client.as_channel()
1894    }
1895}
1896
1897#[cfg(target_os = "fuchsia")]
1898impl ListenerSynchronousProxy {
1899    pub fn new(channel: fidl::Channel) -> Self {
1900        let protocol_name = <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1901        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1902    }
1903
1904    pub fn into_channel(self) -> fidl::Channel {
1905        self.client.into_channel()
1906    }
1907
1908    /// Waits until an event arrives and returns it. It is safe for other
1909    /// threads to make concurrent requests while waiting for an event.
1910    pub fn wait_for_event(
1911        &self,
1912        deadline: zx::MonotonicInstant,
1913    ) -> Result<ListenerEvent, fidl::Error> {
1914        ListenerEvent::decode(self.client.wait_for_event(deadline)?)
1915    }
1916
1917    /// Registers a listener for a local port. There can only be one listener for
1918    /// a single port at a time. The channel will have `SIGNAL_STREAM_INCOMING` asserted
1919    /// by the server when there is a connection ready to accept.
1920    pub fn r#listen(
1921        &self,
1922        mut backlog: u32,
1923        ___deadline: zx::MonotonicInstant,
1924    ) -> Result<ListenerListenResult, fidl::Error> {
1925        let _response = self.client.send_query::<
1926            ListenerListenRequest,
1927            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1928        >(
1929            (backlog,),
1930            0x53042f6a15d94464,
1931            fidl::encoding::DynamicFlags::empty(),
1932            ___deadline,
1933        )?;
1934        Ok(_response.map(|x| x))
1935    }
1936
1937    /// Accept a pending connection from the queue after `Listen` was invoked and
1938    /// `SIGNAL_STREAM_INCOMING` was signaled.
1939    pub fn r#accept(
1940        &self,
1941        mut con: ConnectionTransport,
1942        ___deadline: zx::MonotonicInstant,
1943    ) -> Result<ListenerAcceptResult, fidl::Error> {
1944        let _response = self.client.send_query::<
1945            ListenerAcceptRequest,
1946            fidl::encoding::ResultType<ListenerAcceptResponse, i32>,
1947        >(
1948            (&mut con,),
1949            0x4b71e6389d92d322,
1950            fidl::encoding::DynamicFlags::empty(),
1951            ___deadline,
1952        )?;
1953        Ok(_response.map(|x| x.addr))
1954    }
1955}
1956
1957#[cfg(target_os = "fuchsia")]
1958impl From<ListenerSynchronousProxy> for zx::Handle {
1959    fn from(value: ListenerSynchronousProxy) -> Self {
1960        value.into_channel().into()
1961    }
1962}
1963
1964#[cfg(target_os = "fuchsia")]
1965impl From<fidl::Channel> for ListenerSynchronousProxy {
1966    fn from(value: fidl::Channel) -> Self {
1967        Self::new(value)
1968    }
1969}
1970
1971#[cfg(target_os = "fuchsia")]
1972impl fidl::endpoints::FromClient for ListenerSynchronousProxy {
1973    type Protocol = ListenerMarker;
1974
1975    fn from_client(value: fidl::endpoints::ClientEnd<ListenerMarker>) -> Self {
1976        Self::new(value.into_channel())
1977    }
1978}
1979
1980#[derive(Debug, Clone)]
1981pub struct ListenerProxy {
1982    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1983}
1984
1985impl fidl::endpoints::Proxy for ListenerProxy {
1986    type Protocol = ListenerMarker;
1987
1988    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1989        Self::new(inner)
1990    }
1991
1992    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1993        self.client.into_channel().map_err(|client| Self { client })
1994    }
1995
1996    fn as_channel(&self) -> &::fidl::AsyncChannel {
1997        self.client.as_channel()
1998    }
1999}
2000
2001impl ListenerProxy {
2002    /// Create a new Proxy for fuchsia.vsock/Listener.
2003    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2004        let protocol_name = <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2005        Self { client: fidl::client::Client::new(channel, protocol_name) }
2006    }
2007
2008    /// Get a Stream of events from the remote end of the protocol.
2009    ///
2010    /// # Panics
2011    ///
2012    /// Panics if the event stream was already taken.
2013    pub fn take_event_stream(&self) -> ListenerEventStream {
2014        ListenerEventStream { event_receiver: self.client.take_event_receiver() }
2015    }
2016
2017    /// Registers a listener for a local port. There can only be one listener for
2018    /// a single port at a time. The channel will have `SIGNAL_STREAM_INCOMING` asserted
2019    /// by the server when there is a connection ready to accept.
2020    pub fn r#listen(
2021        &self,
2022        mut backlog: u32,
2023    ) -> fidl::client::QueryResponseFut<
2024        ListenerListenResult,
2025        fidl::encoding::DefaultFuchsiaResourceDialect,
2026    > {
2027        ListenerProxyInterface::r#listen(self, backlog)
2028    }
2029
2030    /// Accept a pending connection from the queue after `Listen` was invoked and
2031    /// `SIGNAL_STREAM_INCOMING` was signaled.
2032    pub fn r#accept(
2033        &self,
2034        mut con: ConnectionTransport,
2035    ) -> fidl::client::QueryResponseFut<
2036        ListenerAcceptResult,
2037        fidl::encoding::DefaultFuchsiaResourceDialect,
2038    > {
2039        ListenerProxyInterface::r#accept(self, con)
2040    }
2041}
2042
2043impl ListenerProxyInterface for ListenerProxy {
2044    type ListenResponseFut = fidl::client::QueryResponseFut<
2045        ListenerListenResult,
2046        fidl::encoding::DefaultFuchsiaResourceDialect,
2047    >;
2048    fn r#listen(&self, mut backlog: u32) -> Self::ListenResponseFut {
2049        fn _decode(
2050            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2051        ) -> Result<ListenerListenResult, fidl::Error> {
2052            let _response = fidl::client::decode_transaction_body::<
2053                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2054                fidl::encoding::DefaultFuchsiaResourceDialect,
2055                0x53042f6a15d94464,
2056            >(_buf?)?;
2057            Ok(_response.map(|x| x))
2058        }
2059        self.client.send_query_and_decode::<ListenerListenRequest, ListenerListenResult>(
2060            (backlog,),
2061            0x53042f6a15d94464,
2062            fidl::encoding::DynamicFlags::empty(),
2063            _decode,
2064        )
2065    }
2066
2067    type AcceptResponseFut = fidl::client::QueryResponseFut<
2068        ListenerAcceptResult,
2069        fidl::encoding::DefaultFuchsiaResourceDialect,
2070    >;
2071    fn r#accept(&self, mut con: ConnectionTransport) -> Self::AcceptResponseFut {
2072        fn _decode(
2073            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2074        ) -> Result<ListenerAcceptResult, fidl::Error> {
2075            let _response = fidl::client::decode_transaction_body::<
2076                fidl::encoding::ResultType<ListenerAcceptResponse, i32>,
2077                fidl::encoding::DefaultFuchsiaResourceDialect,
2078                0x4b71e6389d92d322,
2079            >(_buf?)?;
2080            Ok(_response.map(|x| x.addr))
2081        }
2082        self.client.send_query_and_decode::<ListenerAcceptRequest, ListenerAcceptResult>(
2083            (&mut con,),
2084            0x4b71e6389d92d322,
2085            fidl::encoding::DynamicFlags::empty(),
2086            _decode,
2087        )
2088    }
2089}
2090
2091pub struct ListenerEventStream {
2092    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2093}
2094
2095impl std::marker::Unpin for ListenerEventStream {}
2096
2097impl futures::stream::FusedStream for ListenerEventStream {
2098    fn is_terminated(&self) -> bool {
2099        self.event_receiver.is_terminated()
2100    }
2101}
2102
2103impl futures::Stream for ListenerEventStream {
2104    type Item = Result<ListenerEvent, fidl::Error>;
2105
2106    fn poll_next(
2107        mut self: std::pin::Pin<&mut Self>,
2108        cx: &mut std::task::Context<'_>,
2109    ) -> std::task::Poll<Option<Self::Item>> {
2110        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2111            &mut self.event_receiver,
2112            cx
2113        )?) {
2114            Some(buf) => std::task::Poll::Ready(Some(ListenerEvent::decode(buf))),
2115            None => std::task::Poll::Ready(None),
2116        }
2117    }
2118}
2119
2120#[derive(Debug)]
2121pub enum ListenerEvent {}
2122
2123impl ListenerEvent {
2124    /// Decodes a message buffer as a [`ListenerEvent`].
2125    fn decode(
2126        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2127    ) -> Result<ListenerEvent, fidl::Error> {
2128        let (bytes, _handles) = buf.split_mut();
2129        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2130        debug_assert_eq!(tx_header.tx_id, 0);
2131        match tx_header.ordinal {
2132            _ => Err(fidl::Error::UnknownOrdinal {
2133                ordinal: tx_header.ordinal,
2134                protocol_name: <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2135            }),
2136        }
2137    }
2138}
2139
2140/// A Stream of incoming requests for fuchsia.vsock/Listener.
2141pub struct ListenerRequestStream {
2142    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2143    is_terminated: bool,
2144}
2145
2146impl std::marker::Unpin for ListenerRequestStream {}
2147
2148impl futures::stream::FusedStream for ListenerRequestStream {
2149    fn is_terminated(&self) -> bool {
2150        self.is_terminated
2151    }
2152}
2153
2154impl fidl::endpoints::RequestStream for ListenerRequestStream {
2155    type Protocol = ListenerMarker;
2156    type ControlHandle = ListenerControlHandle;
2157
2158    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2159        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2160    }
2161
2162    fn control_handle(&self) -> Self::ControlHandle {
2163        ListenerControlHandle { inner: self.inner.clone() }
2164    }
2165
2166    fn into_inner(
2167        self,
2168    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2169    {
2170        (self.inner, self.is_terminated)
2171    }
2172
2173    fn from_inner(
2174        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2175        is_terminated: bool,
2176    ) -> Self {
2177        Self { inner, is_terminated }
2178    }
2179}
2180
2181impl futures::Stream for ListenerRequestStream {
2182    type Item = Result<ListenerRequest, fidl::Error>;
2183
2184    fn poll_next(
2185        mut self: std::pin::Pin<&mut Self>,
2186        cx: &mut std::task::Context<'_>,
2187    ) -> std::task::Poll<Option<Self::Item>> {
2188        let this = &mut *self;
2189        if this.inner.check_shutdown(cx) {
2190            this.is_terminated = true;
2191            return std::task::Poll::Ready(None);
2192        }
2193        if this.is_terminated {
2194            panic!("polled ListenerRequestStream after completion");
2195        }
2196        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2197            |bytes, handles| {
2198                match this.inner.channel().read_etc(cx, bytes, handles) {
2199                    std::task::Poll::Ready(Ok(())) => {}
2200                    std::task::Poll::Pending => return std::task::Poll::Pending,
2201                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2202                        this.is_terminated = true;
2203                        return std::task::Poll::Ready(None);
2204                    }
2205                    std::task::Poll::Ready(Err(e)) => {
2206                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2207                            e.into(),
2208                        ))));
2209                    }
2210                }
2211
2212                // A message has been received from the channel
2213                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2214
2215                std::task::Poll::Ready(Some(match header.ordinal {
2216                    0x53042f6a15d94464 => {
2217                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2218                        let mut req = fidl::new_empty!(
2219                            ListenerListenRequest,
2220                            fidl::encoding::DefaultFuchsiaResourceDialect
2221                        );
2222                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ListenerListenRequest>(&header, _body_bytes, handles, &mut req)?;
2223                        let control_handle = ListenerControlHandle { inner: this.inner.clone() };
2224                        Ok(ListenerRequest::Listen {
2225                            backlog: req.backlog,
2226
2227                            responder: ListenerListenResponder {
2228                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2229                                tx_id: header.tx_id,
2230                            },
2231                        })
2232                    }
2233                    0x4b71e6389d92d322 => {
2234                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2235                        let mut req = fidl::new_empty!(
2236                            ListenerAcceptRequest,
2237                            fidl::encoding::DefaultFuchsiaResourceDialect
2238                        );
2239                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ListenerAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
2240                        let control_handle = ListenerControlHandle { inner: this.inner.clone() };
2241                        Ok(ListenerRequest::Accept {
2242                            con: req.con,
2243
2244                            responder: ListenerAcceptResponder {
2245                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2246                                tx_id: header.tx_id,
2247                            },
2248                        })
2249                    }
2250                    _ => Err(fidl::Error::UnknownOrdinal {
2251                        ordinal: header.ordinal,
2252                        protocol_name:
2253                            <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2254                    }),
2255                }))
2256            },
2257        )
2258    }
2259}
2260
2261/// Interface presented by a listener to accept connections.
2262#[derive(Debug)]
2263pub enum ListenerRequest {
2264    /// Registers a listener for a local port. There can only be one listener for
2265    /// a single port at a time. The channel will have `SIGNAL_STREAM_INCOMING` asserted
2266    /// by the server when there is a connection ready to accept.
2267    Listen { backlog: u32, responder: ListenerListenResponder },
2268    /// Accept a pending connection from the queue after `Listen` was invoked and
2269    /// `SIGNAL_STREAM_INCOMING` was signaled.
2270    Accept { con: ConnectionTransport, responder: ListenerAcceptResponder },
2271}
2272
2273impl ListenerRequest {
2274    #[allow(irrefutable_let_patterns)]
2275    pub fn into_listen(self) -> Option<(u32, ListenerListenResponder)> {
2276        if let ListenerRequest::Listen { backlog, responder } = self {
2277            Some((backlog, responder))
2278        } else {
2279            None
2280        }
2281    }
2282
2283    #[allow(irrefutable_let_patterns)]
2284    pub fn into_accept(self) -> Option<(ConnectionTransport, ListenerAcceptResponder)> {
2285        if let ListenerRequest::Accept { con, responder } = self {
2286            Some((con, responder))
2287        } else {
2288            None
2289        }
2290    }
2291
2292    /// Name of the method defined in FIDL
2293    pub fn method_name(&self) -> &'static str {
2294        match *self {
2295            ListenerRequest::Listen { .. } => "listen",
2296            ListenerRequest::Accept { .. } => "accept",
2297        }
2298    }
2299}
2300
2301#[derive(Debug, Clone)]
2302pub struct ListenerControlHandle {
2303    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2304}
2305
2306impl fidl::endpoints::ControlHandle for ListenerControlHandle {
2307    fn shutdown(&self) {
2308        self.inner.shutdown()
2309    }
2310    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2311        self.inner.shutdown_with_epitaph(status)
2312    }
2313
2314    fn is_closed(&self) -> bool {
2315        self.inner.channel().is_closed()
2316    }
2317    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2318        self.inner.channel().on_closed()
2319    }
2320
2321    #[cfg(target_os = "fuchsia")]
2322    fn signal_peer(
2323        &self,
2324        clear_mask: zx::Signals,
2325        set_mask: zx::Signals,
2326    ) -> Result<(), zx_status::Status> {
2327        use fidl::Peered;
2328        self.inner.channel().signal_peer(clear_mask, set_mask)
2329    }
2330}
2331
2332impl ListenerControlHandle {}
2333
2334#[must_use = "FIDL methods require a response to be sent"]
2335#[derive(Debug)]
2336pub struct ListenerListenResponder {
2337    control_handle: std::mem::ManuallyDrop<ListenerControlHandle>,
2338    tx_id: u32,
2339}
2340
2341/// Set the the channel to be shutdown (see [`ListenerControlHandle::shutdown`])
2342/// if the responder is dropped without sending a response, so that the client
2343/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2344impl std::ops::Drop for ListenerListenResponder {
2345    fn drop(&mut self) {
2346        self.control_handle.shutdown();
2347        // Safety: drops once, never accessed again
2348        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2349    }
2350}
2351
2352impl fidl::endpoints::Responder for ListenerListenResponder {
2353    type ControlHandle = ListenerControlHandle;
2354
2355    fn control_handle(&self) -> &ListenerControlHandle {
2356        &self.control_handle
2357    }
2358
2359    fn drop_without_shutdown(mut self) {
2360        // Safety: drops once, never accessed again due to mem::forget
2361        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2362        // Prevent Drop from running (which would shut down the channel)
2363        std::mem::forget(self);
2364    }
2365}
2366
2367impl ListenerListenResponder {
2368    /// Sends a response to the FIDL transaction.
2369    ///
2370    /// Sets the channel to shutdown if an error occurs.
2371    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2372        let _result = self.send_raw(result);
2373        if _result.is_err() {
2374            self.control_handle.shutdown();
2375        }
2376        self.drop_without_shutdown();
2377        _result
2378    }
2379
2380    /// Similar to "send" but does not shutdown the channel if an error occurs.
2381    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2382        let _result = self.send_raw(result);
2383        self.drop_without_shutdown();
2384        _result
2385    }
2386
2387    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2388        self.control_handle
2389            .inner
2390            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2391                result,
2392                self.tx_id,
2393                0x53042f6a15d94464,
2394                fidl::encoding::DynamicFlags::empty(),
2395            )
2396    }
2397}
2398
2399#[must_use = "FIDL methods require a response to be sent"]
2400#[derive(Debug)]
2401pub struct ListenerAcceptResponder {
2402    control_handle: std::mem::ManuallyDrop<ListenerControlHandle>,
2403    tx_id: u32,
2404}
2405
2406/// Set the the channel to be shutdown (see [`ListenerControlHandle::shutdown`])
2407/// if the responder is dropped without sending a response, so that the client
2408/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2409impl std::ops::Drop for ListenerAcceptResponder {
2410    fn drop(&mut self) {
2411        self.control_handle.shutdown();
2412        // Safety: drops once, never accessed again
2413        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2414    }
2415}
2416
2417impl fidl::endpoints::Responder for ListenerAcceptResponder {
2418    type ControlHandle = ListenerControlHandle;
2419
2420    fn control_handle(&self) -> &ListenerControlHandle {
2421        &self.control_handle
2422    }
2423
2424    fn drop_without_shutdown(mut self) {
2425        // Safety: drops once, never accessed again due to mem::forget
2426        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2427        // Prevent Drop from running (which would shut down the channel)
2428        std::mem::forget(self);
2429    }
2430}
2431
2432impl ListenerAcceptResponder {
2433    /// Sends a response to the FIDL transaction.
2434    ///
2435    /// Sets the channel to shutdown if an error occurs.
2436    pub fn send(
2437        self,
2438        mut result: Result<&fidl_fuchsia_hardware_vsock::Addr, i32>,
2439    ) -> Result<(), fidl::Error> {
2440        let _result = self.send_raw(result);
2441        if _result.is_err() {
2442            self.control_handle.shutdown();
2443        }
2444        self.drop_without_shutdown();
2445        _result
2446    }
2447
2448    /// Similar to "send" but does not shutdown the channel if an error occurs.
2449    pub fn send_no_shutdown_on_err(
2450        self,
2451        mut result: Result<&fidl_fuchsia_hardware_vsock::Addr, i32>,
2452    ) -> Result<(), fidl::Error> {
2453        let _result = self.send_raw(result);
2454        self.drop_without_shutdown();
2455        _result
2456    }
2457
2458    fn send_raw(
2459        &self,
2460        mut result: Result<&fidl_fuchsia_hardware_vsock::Addr, i32>,
2461    ) -> Result<(), fidl::Error> {
2462        self.control_handle.inner.send::<fidl::encoding::ResultType<ListenerAcceptResponse, i32>>(
2463            result.map(|addr| (addr,)),
2464            self.tx_id,
2465            0x4b71e6389d92d322,
2466            fidl::encoding::DynamicFlags::empty(),
2467        )
2468    }
2469}
2470
2471mod internal {
2472    use super::*;
2473
2474    impl fidl::encoding::ResourceTypeMarker for AcceptorAcceptResponse {
2475        type Borrowed<'a> = &'a mut Self;
2476        fn take_or_borrow<'a>(
2477            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2478        ) -> Self::Borrowed<'a> {
2479            value
2480        }
2481    }
2482
2483    unsafe impl fidl::encoding::TypeMarker for AcceptorAcceptResponse {
2484        type Owned = Self;
2485
2486        #[inline(always)]
2487        fn inline_align(_context: fidl::encoding::Context) -> usize {
2488            8
2489        }
2490
2491        #[inline(always)]
2492        fn inline_size(_context: fidl::encoding::Context) -> usize {
2493            8
2494        }
2495    }
2496
2497    unsafe impl
2498        fidl::encoding::Encode<
2499            AcceptorAcceptResponse,
2500            fidl::encoding::DefaultFuchsiaResourceDialect,
2501        > for &mut AcceptorAcceptResponse
2502    {
2503        #[inline]
2504        unsafe fn encode(
2505            self,
2506            encoder: &mut fidl::encoding::Encoder<
2507                '_,
2508                fidl::encoding::DefaultFuchsiaResourceDialect,
2509            >,
2510            offset: usize,
2511            _depth: fidl::encoding::Depth,
2512        ) -> fidl::Result<()> {
2513            encoder.debug_check_bounds::<AcceptorAcceptResponse>(offset);
2514            // Delegate to tuple encoding.
2515            fidl::encoding::Encode::<AcceptorAcceptResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2516                (
2517                    <fidl::encoding::Boxed<ConnectionTransport> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.con),
2518                ),
2519                encoder, offset, _depth
2520            )
2521        }
2522    }
2523    unsafe impl<
2524        T0: fidl::encoding::Encode<
2525                fidl::encoding::Boxed<ConnectionTransport>,
2526                fidl::encoding::DefaultFuchsiaResourceDialect,
2527            >,
2528    >
2529        fidl::encoding::Encode<
2530            AcceptorAcceptResponse,
2531            fidl::encoding::DefaultFuchsiaResourceDialect,
2532        > for (T0,)
2533    {
2534        #[inline]
2535        unsafe fn encode(
2536            self,
2537            encoder: &mut fidl::encoding::Encoder<
2538                '_,
2539                fidl::encoding::DefaultFuchsiaResourceDialect,
2540            >,
2541            offset: usize,
2542            depth: fidl::encoding::Depth,
2543        ) -> fidl::Result<()> {
2544            encoder.debug_check_bounds::<AcceptorAcceptResponse>(offset);
2545            // Zero out padding regions. There's no need to apply masks
2546            // because the unmasked parts will be overwritten by fields.
2547            // Write the fields.
2548            self.0.encode(encoder, offset + 0, depth)?;
2549            Ok(())
2550        }
2551    }
2552
2553    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2554        for AcceptorAcceptResponse
2555    {
2556        #[inline(always)]
2557        fn new_empty() -> Self {
2558            Self {
2559                con: fidl::new_empty!(
2560                    fidl::encoding::Boxed<ConnectionTransport>,
2561                    fidl::encoding::DefaultFuchsiaResourceDialect
2562                ),
2563            }
2564        }
2565
2566        #[inline]
2567        unsafe fn decode(
2568            &mut self,
2569            decoder: &mut fidl::encoding::Decoder<
2570                '_,
2571                fidl::encoding::DefaultFuchsiaResourceDialect,
2572            >,
2573            offset: usize,
2574            _depth: fidl::encoding::Depth,
2575        ) -> fidl::Result<()> {
2576            decoder.debug_check_bounds::<Self>(offset);
2577            // Verify that padding bytes are zero.
2578            fidl::decode!(
2579                fidl::encoding::Boxed<ConnectionTransport>,
2580                fidl::encoding::DefaultFuchsiaResourceDialect,
2581                &mut self.con,
2582                decoder,
2583                offset + 0,
2584                _depth
2585            )?;
2586            Ok(())
2587        }
2588    }
2589
2590    impl fidl::encoding::ResourceTypeMarker for ConnectionTransport {
2591        type Borrowed<'a> = &'a mut Self;
2592        fn take_or_borrow<'a>(
2593            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2594        ) -> Self::Borrowed<'a> {
2595            value
2596        }
2597    }
2598
2599    unsafe impl fidl::encoding::TypeMarker for ConnectionTransport {
2600        type Owned = Self;
2601
2602        #[inline(always)]
2603        fn inline_align(_context: fidl::encoding::Context) -> usize {
2604            4
2605        }
2606
2607        #[inline(always)]
2608        fn inline_size(_context: fidl::encoding::Context) -> usize {
2609            8
2610        }
2611    }
2612
2613    unsafe impl
2614        fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>
2615        for &mut ConnectionTransport
2616    {
2617        #[inline]
2618        unsafe fn encode(
2619            self,
2620            encoder: &mut fidl::encoding::Encoder<
2621                '_,
2622                fidl::encoding::DefaultFuchsiaResourceDialect,
2623            >,
2624            offset: usize,
2625            _depth: fidl::encoding::Depth,
2626        ) -> fidl::Result<()> {
2627            encoder.debug_check_bounds::<ConnectionTransport>(offset);
2628            // Delegate to tuple encoding.
2629            fidl::encoding::Encode::<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2630                (
2631                    <fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.data),
2632                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.con),
2633                ),
2634                encoder, offset, _depth
2635            )
2636        }
2637    }
2638    unsafe impl<
2639        T0: fidl::encoding::Encode<
2640                fidl::encoding::HandleType<
2641                    fidl::Socket,
2642                    { fidl::ObjectType::SOCKET.into_raw() },
2643                    2147483648,
2644                >,
2645                fidl::encoding::DefaultFuchsiaResourceDialect,
2646            >,
2647        T1: fidl::encoding::Encode<
2648                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
2649                fidl::encoding::DefaultFuchsiaResourceDialect,
2650            >,
2651    > fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>
2652        for (T0, T1)
2653    {
2654        #[inline]
2655        unsafe fn encode(
2656            self,
2657            encoder: &mut fidl::encoding::Encoder<
2658                '_,
2659                fidl::encoding::DefaultFuchsiaResourceDialect,
2660            >,
2661            offset: usize,
2662            depth: fidl::encoding::Depth,
2663        ) -> fidl::Result<()> {
2664            encoder.debug_check_bounds::<ConnectionTransport>(offset);
2665            // Zero out padding regions. There's no need to apply masks
2666            // because the unmasked parts will be overwritten by fields.
2667            // Write the fields.
2668            self.0.encode(encoder, offset + 0, depth)?;
2669            self.1.encode(encoder, offset + 4, depth)?;
2670            Ok(())
2671        }
2672    }
2673
2674    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2675        for ConnectionTransport
2676    {
2677        #[inline(always)]
2678        fn new_empty() -> Self {
2679            Self {
2680                data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2681                con: fidl::new_empty!(
2682                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
2683                    fidl::encoding::DefaultFuchsiaResourceDialect
2684                ),
2685            }
2686        }
2687
2688        #[inline]
2689        unsafe fn decode(
2690            &mut self,
2691            decoder: &mut fidl::encoding::Decoder<
2692                '_,
2693                fidl::encoding::DefaultFuchsiaResourceDialect,
2694            >,
2695            offset: usize,
2696            _depth: fidl::encoding::Depth,
2697        ) -> fidl::Result<()> {
2698            decoder.debug_check_bounds::<Self>(offset);
2699            // Verify that padding bytes are zero.
2700            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 0, _depth)?;
2701            fidl::decode!(
2702                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
2703                fidl::encoding::DefaultFuchsiaResourceDialect,
2704                &mut self.con,
2705                decoder,
2706                offset + 4,
2707                _depth
2708            )?;
2709            Ok(())
2710        }
2711    }
2712
2713    impl fidl::encoding::ResourceTypeMarker for ConnectorBindRequest {
2714        type Borrowed<'a> = &'a mut Self;
2715        fn take_or_borrow<'a>(
2716            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2717        ) -> Self::Borrowed<'a> {
2718            value
2719        }
2720    }
2721
2722    unsafe impl fidl::encoding::TypeMarker for ConnectorBindRequest {
2723        type Owned = Self;
2724
2725        #[inline(always)]
2726        fn inline_align(_context: fidl::encoding::Context) -> usize {
2727            4
2728        }
2729
2730        #[inline(always)]
2731        fn inline_size(_context: fidl::encoding::Context) -> usize {
2732            12
2733        }
2734    }
2735
2736    unsafe impl
2737        fidl::encoding::Encode<ConnectorBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2738        for &mut ConnectorBindRequest
2739    {
2740        #[inline]
2741        unsafe fn encode(
2742            self,
2743            encoder: &mut fidl::encoding::Encoder<
2744                '_,
2745                fidl::encoding::DefaultFuchsiaResourceDialect,
2746            >,
2747            offset: usize,
2748            _depth: fidl::encoding::Depth,
2749        ) -> fidl::Result<()> {
2750            encoder.debug_check_bounds::<ConnectorBindRequest>(offset);
2751            // Delegate to tuple encoding.
2752            fidl::encoding::Encode::<ConnectorBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2753                (
2754                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_cid),
2755                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.local_port),
2756                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listener),
2757                ),
2758                encoder, offset, _depth
2759            )
2760        }
2761    }
2762    unsafe impl<
2763        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2764        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2765        T2: fidl::encoding::Encode<
2766                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>>,
2767                fidl::encoding::DefaultFuchsiaResourceDialect,
2768            >,
2769    >
2770        fidl::encoding::Encode<ConnectorBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2771        for (T0, T1, T2)
2772    {
2773        #[inline]
2774        unsafe fn encode(
2775            self,
2776            encoder: &mut fidl::encoding::Encoder<
2777                '_,
2778                fidl::encoding::DefaultFuchsiaResourceDialect,
2779            >,
2780            offset: usize,
2781            depth: fidl::encoding::Depth,
2782        ) -> fidl::Result<()> {
2783            encoder.debug_check_bounds::<ConnectorBindRequest>(offset);
2784            // Zero out padding regions. There's no need to apply masks
2785            // because the unmasked parts will be overwritten by fields.
2786            // Write the fields.
2787            self.0.encode(encoder, offset + 0, depth)?;
2788            self.1.encode(encoder, offset + 4, depth)?;
2789            self.2.encode(encoder, offset + 8, depth)?;
2790            Ok(())
2791        }
2792    }
2793
2794    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2795        for ConnectorBindRequest
2796    {
2797        #[inline(always)]
2798        fn new_empty() -> Self {
2799            Self {
2800                remote_cid: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2801                local_port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2802                listener: fidl::new_empty!(
2803                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>>,
2804                    fidl::encoding::DefaultFuchsiaResourceDialect
2805                ),
2806            }
2807        }
2808
2809        #[inline]
2810        unsafe fn decode(
2811            &mut self,
2812            decoder: &mut fidl::encoding::Decoder<
2813                '_,
2814                fidl::encoding::DefaultFuchsiaResourceDialect,
2815            >,
2816            offset: usize,
2817            _depth: fidl::encoding::Depth,
2818        ) -> fidl::Result<()> {
2819            decoder.debug_check_bounds::<Self>(offset);
2820            // Verify that padding bytes are zero.
2821            fidl::decode!(
2822                u32,
2823                fidl::encoding::DefaultFuchsiaResourceDialect,
2824                &mut self.remote_cid,
2825                decoder,
2826                offset + 0,
2827                _depth
2828            )?;
2829            fidl::decode!(
2830                u32,
2831                fidl::encoding::DefaultFuchsiaResourceDialect,
2832                &mut self.local_port,
2833                decoder,
2834                offset + 4,
2835                _depth
2836            )?;
2837            fidl::decode!(
2838                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>>,
2839                fidl::encoding::DefaultFuchsiaResourceDialect,
2840                &mut self.listener,
2841                decoder,
2842                offset + 8,
2843                _depth
2844            )?;
2845            Ok(())
2846        }
2847    }
2848
2849    impl fidl::encoding::ResourceTypeMarker for ConnectorConnectRequest {
2850        type Borrowed<'a> = &'a mut Self;
2851        fn take_or_borrow<'a>(
2852            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2853        ) -> Self::Borrowed<'a> {
2854            value
2855        }
2856    }
2857
2858    unsafe impl fidl::encoding::TypeMarker for ConnectorConnectRequest {
2859        type Owned = Self;
2860
2861        #[inline(always)]
2862        fn inline_align(_context: fidl::encoding::Context) -> usize {
2863            4
2864        }
2865
2866        #[inline(always)]
2867        fn inline_size(_context: fidl::encoding::Context) -> usize {
2868            16
2869        }
2870    }
2871
2872    unsafe impl
2873        fidl::encoding::Encode<
2874            ConnectorConnectRequest,
2875            fidl::encoding::DefaultFuchsiaResourceDialect,
2876        > for &mut ConnectorConnectRequest
2877    {
2878        #[inline]
2879        unsafe fn encode(
2880            self,
2881            encoder: &mut fidl::encoding::Encoder<
2882                '_,
2883                fidl::encoding::DefaultFuchsiaResourceDialect,
2884            >,
2885            offset: usize,
2886            _depth: fidl::encoding::Depth,
2887        ) -> fidl::Result<()> {
2888            encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
2889            // Delegate to tuple encoding.
2890            fidl::encoding::Encode::<
2891                ConnectorConnectRequest,
2892                fidl::encoding::DefaultFuchsiaResourceDialect,
2893            >::encode(
2894                (
2895                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_cid),
2896                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_port),
2897                    <ConnectionTransport as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2898                        &mut self.con,
2899                    ),
2900                ),
2901                encoder,
2902                offset,
2903                _depth,
2904            )
2905        }
2906    }
2907    unsafe impl<
2908        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2909        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2910        T2: fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>,
2911    >
2912        fidl::encoding::Encode<
2913            ConnectorConnectRequest,
2914            fidl::encoding::DefaultFuchsiaResourceDialect,
2915        > for (T0, T1, T2)
2916    {
2917        #[inline]
2918        unsafe fn encode(
2919            self,
2920            encoder: &mut fidl::encoding::Encoder<
2921                '_,
2922                fidl::encoding::DefaultFuchsiaResourceDialect,
2923            >,
2924            offset: usize,
2925            depth: fidl::encoding::Depth,
2926        ) -> fidl::Result<()> {
2927            encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
2928            // Zero out padding regions. There's no need to apply masks
2929            // because the unmasked parts will be overwritten by fields.
2930            // Write the fields.
2931            self.0.encode(encoder, offset + 0, depth)?;
2932            self.1.encode(encoder, offset + 4, depth)?;
2933            self.2.encode(encoder, offset + 8, depth)?;
2934            Ok(())
2935        }
2936    }
2937
2938    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2939        for ConnectorConnectRequest
2940    {
2941        #[inline(always)]
2942        fn new_empty() -> Self {
2943            Self {
2944                remote_cid: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2945                remote_port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2946                con: fidl::new_empty!(
2947                    ConnectionTransport,
2948                    fidl::encoding::DefaultFuchsiaResourceDialect
2949                ),
2950            }
2951        }
2952
2953        #[inline]
2954        unsafe fn decode(
2955            &mut self,
2956            decoder: &mut fidl::encoding::Decoder<
2957                '_,
2958                fidl::encoding::DefaultFuchsiaResourceDialect,
2959            >,
2960            offset: usize,
2961            _depth: fidl::encoding::Depth,
2962        ) -> fidl::Result<()> {
2963            decoder.debug_check_bounds::<Self>(offset);
2964            // Verify that padding bytes are zero.
2965            fidl::decode!(
2966                u32,
2967                fidl::encoding::DefaultFuchsiaResourceDialect,
2968                &mut self.remote_cid,
2969                decoder,
2970                offset + 0,
2971                _depth
2972            )?;
2973            fidl::decode!(
2974                u32,
2975                fidl::encoding::DefaultFuchsiaResourceDialect,
2976                &mut self.remote_port,
2977                decoder,
2978                offset + 4,
2979                _depth
2980            )?;
2981            fidl::decode!(
2982                ConnectionTransport,
2983                fidl::encoding::DefaultFuchsiaResourceDialect,
2984                &mut self.con,
2985                decoder,
2986                offset + 8,
2987                _depth
2988            )?;
2989            Ok(())
2990        }
2991    }
2992
2993    impl fidl::encoding::ResourceTypeMarker for ConnectorListenRequest {
2994        type Borrowed<'a> = &'a mut Self;
2995        fn take_or_borrow<'a>(
2996            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2997        ) -> Self::Borrowed<'a> {
2998            value
2999        }
3000    }
3001
3002    unsafe impl fidl::encoding::TypeMarker for ConnectorListenRequest {
3003        type Owned = Self;
3004
3005        #[inline(always)]
3006        fn inline_align(_context: fidl::encoding::Context) -> usize {
3007            4
3008        }
3009
3010        #[inline(always)]
3011        fn inline_size(_context: fidl::encoding::Context) -> usize {
3012            8
3013        }
3014    }
3015
3016    unsafe impl
3017        fidl::encoding::Encode<
3018            ConnectorListenRequest,
3019            fidl::encoding::DefaultFuchsiaResourceDialect,
3020        > for &mut ConnectorListenRequest
3021    {
3022        #[inline]
3023        unsafe fn encode(
3024            self,
3025            encoder: &mut fidl::encoding::Encoder<
3026                '_,
3027                fidl::encoding::DefaultFuchsiaResourceDialect,
3028            >,
3029            offset: usize,
3030            _depth: fidl::encoding::Depth,
3031        ) -> fidl::Result<()> {
3032            encoder.debug_check_bounds::<ConnectorListenRequest>(offset);
3033            // Delegate to tuple encoding.
3034            fidl::encoding::Encode::<ConnectorListenRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3035                (
3036                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.local_port),
3037                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.acceptor),
3038                ),
3039                encoder, offset, _depth
3040            )
3041        }
3042    }
3043    unsafe impl<
3044        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
3045        T1: fidl::encoding::Encode<
3046                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>>,
3047                fidl::encoding::DefaultFuchsiaResourceDialect,
3048            >,
3049    >
3050        fidl::encoding::Encode<
3051            ConnectorListenRequest,
3052            fidl::encoding::DefaultFuchsiaResourceDialect,
3053        > for (T0, T1)
3054    {
3055        #[inline]
3056        unsafe fn encode(
3057            self,
3058            encoder: &mut fidl::encoding::Encoder<
3059                '_,
3060                fidl::encoding::DefaultFuchsiaResourceDialect,
3061            >,
3062            offset: usize,
3063            depth: fidl::encoding::Depth,
3064        ) -> fidl::Result<()> {
3065            encoder.debug_check_bounds::<ConnectorListenRequest>(offset);
3066            // Zero out padding regions. There's no need to apply masks
3067            // because the unmasked parts will be overwritten by fields.
3068            // Write the fields.
3069            self.0.encode(encoder, offset + 0, depth)?;
3070            self.1.encode(encoder, offset + 4, depth)?;
3071            Ok(())
3072        }
3073    }
3074
3075    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3076        for ConnectorListenRequest
3077    {
3078        #[inline(always)]
3079        fn new_empty() -> Self {
3080            Self {
3081                local_port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
3082                acceptor: fidl::new_empty!(
3083                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>>,
3084                    fidl::encoding::DefaultFuchsiaResourceDialect
3085                ),
3086            }
3087        }
3088
3089        #[inline]
3090        unsafe fn decode(
3091            &mut self,
3092            decoder: &mut fidl::encoding::Decoder<
3093                '_,
3094                fidl::encoding::DefaultFuchsiaResourceDialect,
3095            >,
3096            offset: usize,
3097            _depth: fidl::encoding::Depth,
3098        ) -> fidl::Result<()> {
3099            decoder.debug_check_bounds::<Self>(offset);
3100            // Verify that padding bytes are zero.
3101            fidl::decode!(
3102                u32,
3103                fidl::encoding::DefaultFuchsiaResourceDialect,
3104                &mut self.local_port,
3105                decoder,
3106                offset + 0,
3107                _depth
3108            )?;
3109            fidl::decode!(
3110                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>>,
3111                fidl::encoding::DefaultFuchsiaResourceDialect,
3112                &mut self.acceptor,
3113                decoder,
3114                offset + 4,
3115                _depth
3116            )?;
3117            Ok(())
3118        }
3119    }
3120
3121    impl fidl::encoding::ResourceTypeMarker for ListenerAcceptRequest {
3122        type Borrowed<'a> = &'a mut Self;
3123        fn take_or_borrow<'a>(
3124            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3125        ) -> Self::Borrowed<'a> {
3126            value
3127        }
3128    }
3129
3130    unsafe impl fidl::encoding::TypeMarker for ListenerAcceptRequest {
3131        type Owned = Self;
3132
3133        #[inline(always)]
3134        fn inline_align(_context: fidl::encoding::Context) -> usize {
3135            4
3136        }
3137
3138        #[inline(always)]
3139        fn inline_size(_context: fidl::encoding::Context) -> usize {
3140            8
3141        }
3142    }
3143
3144    unsafe impl
3145        fidl::encoding::Encode<ListenerAcceptRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3146        for &mut ListenerAcceptRequest
3147    {
3148        #[inline]
3149        unsafe fn encode(
3150            self,
3151            encoder: &mut fidl::encoding::Encoder<
3152                '_,
3153                fidl::encoding::DefaultFuchsiaResourceDialect,
3154            >,
3155            offset: usize,
3156            _depth: fidl::encoding::Depth,
3157        ) -> fidl::Result<()> {
3158            encoder.debug_check_bounds::<ListenerAcceptRequest>(offset);
3159            // Delegate to tuple encoding.
3160            fidl::encoding::Encode::<
3161                ListenerAcceptRequest,
3162                fidl::encoding::DefaultFuchsiaResourceDialect,
3163            >::encode(
3164                (<ConnectionTransport as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3165                    &mut self.con,
3166                ),),
3167                encoder,
3168                offset,
3169                _depth,
3170            )
3171        }
3172    }
3173    unsafe impl<
3174        T0: fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>,
3175    >
3176        fidl::encoding::Encode<ListenerAcceptRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3177        for (T0,)
3178    {
3179        #[inline]
3180        unsafe fn encode(
3181            self,
3182            encoder: &mut fidl::encoding::Encoder<
3183                '_,
3184                fidl::encoding::DefaultFuchsiaResourceDialect,
3185            >,
3186            offset: usize,
3187            depth: fidl::encoding::Depth,
3188        ) -> fidl::Result<()> {
3189            encoder.debug_check_bounds::<ListenerAcceptRequest>(offset);
3190            // Zero out padding regions. There's no need to apply masks
3191            // because the unmasked parts will be overwritten by fields.
3192            // Write the fields.
3193            self.0.encode(encoder, offset + 0, depth)?;
3194            Ok(())
3195        }
3196    }
3197
3198    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3199        for ListenerAcceptRequest
3200    {
3201        #[inline(always)]
3202        fn new_empty() -> Self {
3203            Self {
3204                con: fidl::new_empty!(
3205                    ConnectionTransport,
3206                    fidl::encoding::DefaultFuchsiaResourceDialect
3207                ),
3208            }
3209        }
3210
3211        #[inline]
3212        unsafe fn decode(
3213            &mut self,
3214            decoder: &mut fidl::encoding::Decoder<
3215                '_,
3216                fidl::encoding::DefaultFuchsiaResourceDialect,
3217            >,
3218            offset: usize,
3219            _depth: fidl::encoding::Depth,
3220        ) -> fidl::Result<()> {
3221            decoder.debug_check_bounds::<Self>(offset);
3222            // Verify that padding bytes are zero.
3223            fidl::decode!(
3224                ConnectionTransport,
3225                fidl::encoding::DefaultFuchsiaResourceDialect,
3226                &mut self.con,
3227                decoder,
3228                offset + 0,
3229                _depth
3230            )?;
3231            Ok(())
3232        }
3233    }
3234}