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 {
1549            Some((responder))
1550        } else {
1551            None
1552        }
1553    }
1554
1555    /// Name of the method defined in FIDL
1556    pub fn method_name(&self) -> &'static str {
1557        match *self {
1558            ConnectorRequest::Connect { .. } => "connect",
1559            ConnectorRequest::Listen { .. } => "listen",
1560            ConnectorRequest::Bind { .. } => "bind",
1561            ConnectorRequest::GetCid { .. } => "get_cid",
1562        }
1563    }
1564}
1565
1566#[derive(Debug, Clone)]
1567pub struct ConnectorControlHandle {
1568    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1569}
1570
1571impl fidl::endpoints::ControlHandle for ConnectorControlHandle {
1572    fn shutdown(&self) {
1573        self.inner.shutdown()
1574    }
1575    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1576        self.inner.shutdown_with_epitaph(status)
1577    }
1578
1579    fn is_closed(&self) -> bool {
1580        self.inner.channel().is_closed()
1581    }
1582    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1583        self.inner.channel().on_closed()
1584    }
1585
1586    #[cfg(target_os = "fuchsia")]
1587    fn signal_peer(
1588        &self,
1589        clear_mask: zx::Signals,
1590        set_mask: zx::Signals,
1591    ) -> Result<(), zx_status::Status> {
1592        use fidl::Peered;
1593        self.inner.channel().signal_peer(clear_mask, set_mask)
1594    }
1595}
1596
1597impl ConnectorControlHandle {}
1598
1599#[must_use = "FIDL methods require a response to be sent"]
1600#[derive(Debug)]
1601pub struct ConnectorConnectResponder {
1602    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1603    tx_id: u32,
1604}
1605
1606/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1607/// if the responder is dropped without sending a response, so that the client
1608/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1609impl std::ops::Drop for ConnectorConnectResponder {
1610    fn drop(&mut self) {
1611        self.control_handle.shutdown();
1612        // Safety: drops once, never accessed again
1613        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1614    }
1615}
1616
1617impl fidl::endpoints::Responder for ConnectorConnectResponder {
1618    type ControlHandle = ConnectorControlHandle;
1619
1620    fn control_handle(&self) -> &ConnectorControlHandle {
1621        &self.control_handle
1622    }
1623
1624    fn drop_without_shutdown(mut self) {
1625        // Safety: drops once, never accessed again due to mem::forget
1626        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1627        // Prevent Drop from running (which would shut down the channel)
1628        std::mem::forget(self);
1629    }
1630}
1631
1632impl ConnectorConnectResponder {
1633    /// Sends a response to the FIDL transaction.
1634    ///
1635    /// Sets the channel to shutdown if an error occurs.
1636    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1637        let _result = self.send_raw(result);
1638        if _result.is_err() {
1639            self.control_handle.shutdown();
1640        }
1641        self.drop_without_shutdown();
1642        _result
1643    }
1644
1645    /// Similar to "send" but does not shutdown the channel if an error occurs.
1646    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1647        let _result = self.send_raw(result);
1648        self.drop_without_shutdown();
1649        _result
1650    }
1651
1652    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1653        self.control_handle.inner.send::<fidl::encoding::ResultType<ConnectorConnectResponse, i32>>(
1654            result.map(|local_port| (local_port,)),
1655            self.tx_id,
1656            0xdf55c5e6a6a4117,
1657            fidl::encoding::DynamicFlags::empty(),
1658        )
1659    }
1660}
1661
1662#[must_use = "FIDL methods require a response to be sent"]
1663#[derive(Debug)]
1664pub struct ConnectorListenResponder {
1665    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1666    tx_id: u32,
1667}
1668
1669/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1670/// if the responder is dropped without sending a response, so that the client
1671/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1672impl std::ops::Drop for ConnectorListenResponder {
1673    fn drop(&mut self) {
1674        self.control_handle.shutdown();
1675        // Safety: drops once, never accessed again
1676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1677    }
1678}
1679
1680impl fidl::endpoints::Responder for ConnectorListenResponder {
1681    type ControlHandle = ConnectorControlHandle;
1682
1683    fn control_handle(&self) -> &ConnectorControlHandle {
1684        &self.control_handle
1685    }
1686
1687    fn drop_without_shutdown(mut self) {
1688        // Safety: drops once, never accessed again due to mem::forget
1689        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1690        // Prevent Drop from running (which would shut down the channel)
1691        std::mem::forget(self);
1692    }
1693}
1694
1695impl ConnectorListenResponder {
1696    /// Sends a response to the FIDL transaction.
1697    ///
1698    /// Sets the channel to shutdown if an error occurs.
1699    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1700        let _result = self.send_raw(result);
1701        if _result.is_err() {
1702            self.control_handle.shutdown();
1703        }
1704        self.drop_without_shutdown();
1705        _result
1706    }
1707
1708    /// Similar to "send" but does not shutdown the channel if an error occurs.
1709    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1710        let _result = self.send_raw(result);
1711        self.drop_without_shutdown();
1712        _result
1713    }
1714
1715    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1716        self.control_handle
1717            .inner
1718            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1719                result,
1720                self.tx_id,
1721                0x17c1371908bacf73,
1722                fidl::encoding::DynamicFlags::empty(),
1723            )
1724    }
1725}
1726
1727#[must_use = "FIDL methods require a response to be sent"]
1728#[derive(Debug)]
1729pub struct ConnectorBindResponder {
1730    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1731    tx_id: u32,
1732}
1733
1734/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1735/// if the responder is dropped without sending a response, so that the client
1736/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1737impl std::ops::Drop for ConnectorBindResponder {
1738    fn drop(&mut self) {
1739        self.control_handle.shutdown();
1740        // Safety: drops once, never accessed again
1741        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1742    }
1743}
1744
1745impl fidl::endpoints::Responder for ConnectorBindResponder {
1746    type ControlHandle = ConnectorControlHandle;
1747
1748    fn control_handle(&self) -> &ConnectorControlHandle {
1749        &self.control_handle
1750    }
1751
1752    fn drop_without_shutdown(mut self) {
1753        // Safety: drops once, never accessed again due to mem::forget
1754        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1755        // Prevent Drop from running (which would shut down the channel)
1756        std::mem::forget(self);
1757    }
1758}
1759
1760impl ConnectorBindResponder {
1761    /// Sends a response to the FIDL transaction.
1762    ///
1763    /// Sets the channel to shutdown if an error occurs.
1764    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1765        let _result = self.send_raw(result);
1766        if _result.is_err() {
1767            self.control_handle.shutdown();
1768        }
1769        self.drop_without_shutdown();
1770        _result
1771    }
1772
1773    /// Similar to "send" but does not shutdown the channel if an error occurs.
1774    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1775        let _result = self.send_raw(result);
1776        self.drop_without_shutdown();
1777        _result
1778    }
1779
1780    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1781        self.control_handle
1782            .inner
1783            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1784                result,
1785                self.tx_id,
1786                0x6e50cd8c895f2e0,
1787                fidl::encoding::DynamicFlags::empty(),
1788            )
1789    }
1790}
1791
1792#[must_use = "FIDL methods require a response to be sent"]
1793#[derive(Debug)]
1794pub struct ConnectorGetCidResponder {
1795    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1796    tx_id: u32,
1797}
1798
1799/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1800/// if the responder is dropped without sending a response, so that the client
1801/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1802impl std::ops::Drop for ConnectorGetCidResponder {
1803    fn drop(&mut self) {
1804        self.control_handle.shutdown();
1805        // Safety: drops once, never accessed again
1806        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1807    }
1808}
1809
1810impl fidl::endpoints::Responder for ConnectorGetCidResponder {
1811    type ControlHandle = ConnectorControlHandle;
1812
1813    fn control_handle(&self) -> &ConnectorControlHandle {
1814        &self.control_handle
1815    }
1816
1817    fn drop_without_shutdown(mut self) {
1818        // Safety: drops once, never accessed again due to mem::forget
1819        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1820        // Prevent Drop from running (which would shut down the channel)
1821        std::mem::forget(self);
1822    }
1823}
1824
1825impl ConnectorGetCidResponder {
1826    /// Sends a response to the FIDL transaction.
1827    ///
1828    /// Sets the channel to shutdown if an error occurs.
1829    pub fn send(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1830        let _result = self.send_raw(local_cid);
1831        if _result.is_err() {
1832            self.control_handle.shutdown();
1833        }
1834        self.drop_without_shutdown();
1835        _result
1836    }
1837
1838    /// Similar to "send" but does not shutdown the channel if an error occurs.
1839    pub fn send_no_shutdown_on_err(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1840        let _result = self.send_raw(local_cid);
1841        self.drop_without_shutdown();
1842        _result
1843    }
1844
1845    fn send_raw(&self, mut local_cid: u32) -> Result<(), fidl::Error> {
1846        self.control_handle.inner.send::<ConnectorGetCidResponse>(
1847            (local_cid,),
1848            self.tx_id,
1849            0x60b3cfa0b40bdd7c,
1850            fidl::encoding::DynamicFlags::empty(),
1851        )
1852    }
1853}
1854
1855#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1856pub struct ListenerMarker;
1857
1858impl fidl::endpoints::ProtocolMarker for ListenerMarker {
1859    type Proxy = ListenerProxy;
1860    type RequestStream = ListenerRequestStream;
1861    #[cfg(target_os = "fuchsia")]
1862    type SynchronousProxy = ListenerSynchronousProxy;
1863
1864    const DEBUG_NAME: &'static str = "(anonymous) Listener";
1865}
1866pub type ListenerListenResult = Result<(), i32>;
1867pub type ListenerAcceptResult = Result<fidl_fuchsia_hardware_vsock::Addr, i32>;
1868
1869pub trait ListenerProxyInterface: Send + Sync {
1870    type ListenResponseFut: std::future::Future<Output = Result<ListenerListenResult, fidl::Error>>
1871        + Send;
1872    fn r#listen(&self, backlog: u32) -> Self::ListenResponseFut;
1873    type AcceptResponseFut: std::future::Future<Output = Result<ListenerAcceptResult, fidl::Error>>
1874        + Send;
1875    fn r#accept(&self, con: ConnectionTransport) -> Self::AcceptResponseFut;
1876}
1877#[derive(Debug)]
1878#[cfg(target_os = "fuchsia")]
1879pub struct ListenerSynchronousProxy {
1880    client: fidl::client::sync::Client,
1881}
1882
1883#[cfg(target_os = "fuchsia")]
1884impl fidl::endpoints::SynchronousProxy for ListenerSynchronousProxy {
1885    type Proxy = ListenerProxy;
1886    type Protocol = ListenerMarker;
1887
1888    fn from_channel(inner: fidl::Channel) -> Self {
1889        Self::new(inner)
1890    }
1891
1892    fn into_channel(self) -> fidl::Channel {
1893        self.client.into_channel()
1894    }
1895
1896    fn as_channel(&self) -> &fidl::Channel {
1897        self.client.as_channel()
1898    }
1899}
1900
1901#[cfg(target_os = "fuchsia")]
1902impl ListenerSynchronousProxy {
1903    pub fn new(channel: fidl::Channel) -> Self {
1904        let protocol_name = <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1905        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1906    }
1907
1908    pub fn into_channel(self) -> fidl::Channel {
1909        self.client.into_channel()
1910    }
1911
1912    /// Waits until an event arrives and returns it. It is safe for other
1913    /// threads to make concurrent requests while waiting for an event.
1914    pub fn wait_for_event(
1915        &self,
1916        deadline: zx::MonotonicInstant,
1917    ) -> Result<ListenerEvent, fidl::Error> {
1918        ListenerEvent::decode(self.client.wait_for_event(deadline)?)
1919    }
1920
1921    /// Registers a listener for a local port. There can only be one listener for
1922    /// a single port at a time. The channel will have `SIGNAL_STREAM_INCOMING` asserted
1923    /// by the server when there is a connection ready to accept.
1924    pub fn r#listen(
1925        &self,
1926        mut backlog: u32,
1927        ___deadline: zx::MonotonicInstant,
1928    ) -> Result<ListenerListenResult, fidl::Error> {
1929        let _response = self.client.send_query::<
1930            ListenerListenRequest,
1931            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1932        >(
1933            (backlog,),
1934            0x53042f6a15d94464,
1935            fidl::encoding::DynamicFlags::empty(),
1936            ___deadline,
1937        )?;
1938        Ok(_response.map(|x| x))
1939    }
1940
1941    /// Accept a pending connection from the queue after `Listen` was invoked and
1942    /// `SIGNAL_STREAM_INCOMING` was signaled.
1943    pub fn r#accept(
1944        &self,
1945        mut con: ConnectionTransport,
1946        ___deadline: zx::MonotonicInstant,
1947    ) -> Result<ListenerAcceptResult, fidl::Error> {
1948        let _response = self.client.send_query::<
1949            ListenerAcceptRequest,
1950            fidl::encoding::ResultType<ListenerAcceptResponse, i32>,
1951        >(
1952            (&mut con,),
1953            0x4b71e6389d92d322,
1954            fidl::encoding::DynamicFlags::empty(),
1955            ___deadline,
1956        )?;
1957        Ok(_response.map(|x| x.addr))
1958    }
1959}
1960
1961#[cfg(target_os = "fuchsia")]
1962impl From<ListenerSynchronousProxy> for zx::Handle {
1963    fn from(value: ListenerSynchronousProxy) -> Self {
1964        value.into_channel().into()
1965    }
1966}
1967
1968#[cfg(target_os = "fuchsia")]
1969impl From<fidl::Channel> for ListenerSynchronousProxy {
1970    fn from(value: fidl::Channel) -> Self {
1971        Self::new(value)
1972    }
1973}
1974
1975#[cfg(target_os = "fuchsia")]
1976impl fidl::endpoints::FromClient for ListenerSynchronousProxy {
1977    type Protocol = ListenerMarker;
1978
1979    fn from_client(value: fidl::endpoints::ClientEnd<ListenerMarker>) -> Self {
1980        Self::new(value.into_channel())
1981    }
1982}
1983
1984#[derive(Debug, Clone)]
1985pub struct ListenerProxy {
1986    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1987}
1988
1989impl fidl::endpoints::Proxy for ListenerProxy {
1990    type Protocol = ListenerMarker;
1991
1992    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1993        Self::new(inner)
1994    }
1995
1996    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1997        self.client.into_channel().map_err(|client| Self { client })
1998    }
1999
2000    fn as_channel(&self) -> &::fidl::AsyncChannel {
2001        self.client.as_channel()
2002    }
2003}
2004
2005impl ListenerProxy {
2006    /// Create a new Proxy for fuchsia.vsock/Listener.
2007    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2008        let protocol_name = <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2009        Self { client: fidl::client::Client::new(channel, protocol_name) }
2010    }
2011
2012    /// Get a Stream of events from the remote end of the protocol.
2013    ///
2014    /// # Panics
2015    ///
2016    /// Panics if the event stream was already taken.
2017    pub fn take_event_stream(&self) -> ListenerEventStream {
2018        ListenerEventStream { event_receiver: self.client.take_event_receiver() }
2019    }
2020
2021    /// Registers a listener for a local port. There can only be one listener for
2022    /// a single port at a time. The channel will have `SIGNAL_STREAM_INCOMING` asserted
2023    /// by the server when there is a connection ready to accept.
2024    pub fn r#listen(
2025        &self,
2026        mut backlog: u32,
2027    ) -> fidl::client::QueryResponseFut<
2028        ListenerListenResult,
2029        fidl::encoding::DefaultFuchsiaResourceDialect,
2030    > {
2031        ListenerProxyInterface::r#listen(self, backlog)
2032    }
2033
2034    /// Accept a pending connection from the queue after `Listen` was invoked and
2035    /// `SIGNAL_STREAM_INCOMING` was signaled.
2036    pub fn r#accept(
2037        &self,
2038        mut con: ConnectionTransport,
2039    ) -> fidl::client::QueryResponseFut<
2040        ListenerAcceptResult,
2041        fidl::encoding::DefaultFuchsiaResourceDialect,
2042    > {
2043        ListenerProxyInterface::r#accept(self, con)
2044    }
2045}
2046
2047impl ListenerProxyInterface for ListenerProxy {
2048    type ListenResponseFut = fidl::client::QueryResponseFut<
2049        ListenerListenResult,
2050        fidl::encoding::DefaultFuchsiaResourceDialect,
2051    >;
2052    fn r#listen(&self, mut backlog: u32) -> Self::ListenResponseFut {
2053        fn _decode(
2054            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2055        ) -> Result<ListenerListenResult, fidl::Error> {
2056            let _response = fidl::client::decode_transaction_body::<
2057                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2058                fidl::encoding::DefaultFuchsiaResourceDialect,
2059                0x53042f6a15d94464,
2060            >(_buf?)?;
2061            Ok(_response.map(|x| x))
2062        }
2063        self.client.send_query_and_decode::<ListenerListenRequest, ListenerListenResult>(
2064            (backlog,),
2065            0x53042f6a15d94464,
2066            fidl::encoding::DynamicFlags::empty(),
2067            _decode,
2068        )
2069    }
2070
2071    type AcceptResponseFut = fidl::client::QueryResponseFut<
2072        ListenerAcceptResult,
2073        fidl::encoding::DefaultFuchsiaResourceDialect,
2074    >;
2075    fn r#accept(&self, mut con: ConnectionTransport) -> Self::AcceptResponseFut {
2076        fn _decode(
2077            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2078        ) -> Result<ListenerAcceptResult, fidl::Error> {
2079            let _response = fidl::client::decode_transaction_body::<
2080                fidl::encoding::ResultType<ListenerAcceptResponse, i32>,
2081                fidl::encoding::DefaultFuchsiaResourceDialect,
2082                0x4b71e6389d92d322,
2083            >(_buf?)?;
2084            Ok(_response.map(|x| x.addr))
2085        }
2086        self.client.send_query_and_decode::<ListenerAcceptRequest, ListenerAcceptResult>(
2087            (&mut con,),
2088            0x4b71e6389d92d322,
2089            fidl::encoding::DynamicFlags::empty(),
2090            _decode,
2091        )
2092    }
2093}
2094
2095pub struct ListenerEventStream {
2096    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2097}
2098
2099impl std::marker::Unpin for ListenerEventStream {}
2100
2101impl futures::stream::FusedStream for ListenerEventStream {
2102    fn is_terminated(&self) -> bool {
2103        self.event_receiver.is_terminated()
2104    }
2105}
2106
2107impl futures::Stream for ListenerEventStream {
2108    type Item = Result<ListenerEvent, fidl::Error>;
2109
2110    fn poll_next(
2111        mut self: std::pin::Pin<&mut Self>,
2112        cx: &mut std::task::Context<'_>,
2113    ) -> std::task::Poll<Option<Self::Item>> {
2114        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2115            &mut self.event_receiver,
2116            cx
2117        )?) {
2118            Some(buf) => std::task::Poll::Ready(Some(ListenerEvent::decode(buf))),
2119            None => std::task::Poll::Ready(None),
2120        }
2121    }
2122}
2123
2124#[derive(Debug)]
2125pub enum ListenerEvent {}
2126
2127impl ListenerEvent {
2128    /// Decodes a message buffer as a [`ListenerEvent`].
2129    fn decode(
2130        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2131    ) -> Result<ListenerEvent, fidl::Error> {
2132        let (bytes, _handles) = buf.split_mut();
2133        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2134        debug_assert_eq!(tx_header.tx_id, 0);
2135        match tx_header.ordinal {
2136            _ => Err(fidl::Error::UnknownOrdinal {
2137                ordinal: tx_header.ordinal,
2138                protocol_name: <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2139            }),
2140        }
2141    }
2142}
2143
2144/// A Stream of incoming requests for fuchsia.vsock/Listener.
2145pub struct ListenerRequestStream {
2146    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2147    is_terminated: bool,
2148}
2149
2150impl std::marker::Unpin for ListenerRequestStream {}
2151
2152impl futures::stream::FusedStream for ListenerRequestStream {
2153    fn is_terminated(&self) -> bool {
2154        self.is_terminated
2155    }
2156}
2157
2158impl fidl::endpoints::RequestStream for ListenerRequestStream {
2159    type Protocol = ListenerMarker;
2160    type ControlHandle = ListenerControlHandle;
2161
2162    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2163        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2164    }
2165
2166    fn control_handle(&self) -> Self::ControlHandle {
2167        ListenerControlHandle { inner: self.inner.clone() }
2168    }
2169
2170    fn into_inner(
2171        self,
2172    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2173    {
2174        (self.inner, self.is_terminated)
2175    }
2176
2177    fn from_inner(
2178        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2179        is_terminated: bool,
2180    ) -> Self {
2181        Self { inner, is_terminated }
2182    }
2183}
2184
2185impl futures::Stream for ListenerRequestStream {
2186    type Item = Result<ListenerRequest, fidl::Error>;
2187
2188    fn poll_next(
2189        mut self: std::pin::Pin<&mut Self>,
2190        cx: &mut std::task::Context<'_>,
2191    ) -> std::task::Poll<Option<Self::Item>> {
2192        let this = &mut *self;
2193        if this.inner.check_shutdown(cx) {
2194            this.is_terminated = true;
2195            return std::task::Poll::Ready(None);
2196        }
2197        if this.is_terminated {
2198            panic!("polled ListenerRequestStream after completion");
2199        }
2200        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2201            |bytes, handles| {
2202                match this.inner.channel().read_etc(cx, bytes, handles) {
2203                    std::task::Poll::Ready(Ok(())) => {}
2204                    std::task::Poll::Pending => return std::task::Poll::Pending,
2205                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2206                        this.is_terminated = true;
2207                        return std::task::Poll::Ready(None);
2208                    }
2209                    std::task::Poll::Ready(Err(e)) => {
2210                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2211                            e.into(),
2212                        ))))
2213                    }
2214                }
2215
2216                // A message has been received from the channel
2217                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2218
2219                std::task::Poll::Ready(Some(match header.ordinal {
2220                    0x53042f6a15d94464 => {
2221                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2222                        let mut req = fidl::new_empty!(
2223                            ListenerListenRequest,
2224                            fidl::encoding::DefaultFuchsiaResourceDialect
2225                        );
2226                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ListenerListenRequest>(&header, _body_bytes, handles, &mut req)?;
2227                        let control_handle = ListenerControlHandle { inner: this.inner.clone() };
2228                        Ok(ListenerRequest::Listen {
2229                            backlog: req.backlog,
2230
2231                            responder: ListenerListenResponder {
2232                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2233                                tx_id: header.tx_id,
2234                            },
2235                        })
2236                    }
2237                    0x4b71e6389d92d322 => {
2238                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2239                        let mut req = fidl::new_empty!(
2240                            ListenerAcceptRequest,
2241                            fidl::encoding::DefaultFuchsiaResourceDialect
2242                        );
2243                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ListenerAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
2244                        let control_handle = ListenerControlHandle { inner: this.inner.clone() };
2245                        Ok(ListenerRequest::Accept {
2246                            con: req.con,
2247
2248                            responder: ListenerAcceptResponder {
2249                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2250                                tx_id: header.tx_id,
2251                            },
2252                        })
2253                    }
2254                    _ => Err(fidl::Error::UnknownOrdinal {
2255                        ordinal: header.ordinal,
2256                        protocol_name:
2257                            <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2258                    }),
2259                }))
2260            },
2261        )
2262    }
2263}
2264
2265/// Interface presented by a listener to accept connections.
2266#[derive(Debug)]
2267pub enum ListenerRequest {
2268    /// Registers a listener for a local port. There can only be one listener for
2269    /// a single port at a time. The channel will have `SIGNAL_STREAM_INCOMING` asserted
2270    /// by the server when there is a connection ready to accept.
2271    Listen { backlog: u32, responder: ListenerListenResponder },
2272    /// Accept a pending connection from the queue after `Listen` was invoked and
2273    /// `SIGNAL_STREAM_INCOMING` was signaled.
2274    Accept { con: ConnectionTransport, responder: ListenerAcceptResponder },
2275}
2276
2277impl ListenerRequest {
2278    #[allow(irrefutable_let_patterns)]
2279    pub fn into_listen(self) -> Option<(u32, ListenerListenResponder)> {
2280        if let ListenerRequest::Listen { backlog, responder } = self {
2281            Some((backlog, responder))
2282        } else {
2283            None
2284        }
2285    }
2286
2287    #[allow(irrefutable_let_patterns)]
2288    pub fn into_accept(self) -> Option<(ConnectionTransport, ListenerAcceptResponder)> {
2289        if let ListenerRequest::Accept { con, responder } = self {
2290            Some((con, responder))
2291        } else {
2292            None
2293        }
2294    }
2295
2296    /// Name of the method defined in FIDL
2297    pub fn method_name(&self) -> &'static str {
2298        match *self {
2299            ListenerRequest::Listen { .. } => "listen",
2300            ListenerRequest::Accept { .. } => "accept",
2301        }
2302    }
2303}
2304
2305#[derive(Debug, Clone)]
2306pub struct ListenerControlHandle {
2307    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2308}
2309
2310impl fidl::endpoints::ControlHandle for ListenerControlHandle {
2311    fn shutdown(&self) {
2312        self.inner.shutdown()
2313    }
2314    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2315        self.inner.shutdown_with_epitaph(status)
2316    }
2317
2318    fn is_closed(&self) -> bool {
2319        self.inner.channel().is_closed()
2320    }
2321    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2322        self.inner.channel().on_closed()
2323    }
2324
2325    #[cfg(target_os = "fuchsia")]
2326    fn signal_peer(
2327        &self,
2328        clear_mask: zx::Signals,
2329        set_mask: zx::Signals,
2330    ) -> Result<(), zx_status::Status> {
2331        use fidl::Peered;
2332        self.inner.channel().signal_peer(clear_mask, set_mask)
2333    }
2334}
2335
2336impl ListenerControlHandle {}
2337
2338#[must_use = "FIDL methods require a response to be sent"]
2339#[derive(Debug)]
2340pub struct ListenerListenResponder {
2341    control_handle: std::mem::ManuallyDrop<ListenerControlHandle>,
2342    tx_id: u32,
2343}
2344
2345/// Set the the channel to be shutdown (see [`ListenerControlHandle::shutdown`])
2346/// if the responder is dropped without sending a response, so that the client
2347/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2348impl std::ops::Drop for ListenerListenResponder {
2349    fn drop(&mut self) {
2350        self.control_handle.shutdown();
2351        // Safety: drops once, never accessed again
2352        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2353    }
2354}
2355
2356impl fidl::endpoints::Responder for ListenerListenResponder {
2357    type ControlHandle = ListenerControlHandle;
2358
2359    fn control_handle(&self) -> &ListenerControlHandle {
2360        &self.control_handle
2361    }
2362
2363    fn drop_without_shutdown(mut self) {
2364        // Safety: drops once, never accessed again due to mem::forget
2365        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2366        // Prevent Drop from running (which would shut down the channel)
2367        std::mem::forget(self);
2368    }
2369}
2370
2371impl ListenerListenResponder {
2372    /// Sends a response to the FIDL transaction.
2373    ///
2374    /// Sets the channel to shutdown if an error occurs.
2375    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2376        let _result = self.send_raw(result);
2377        if _result.is_err() {
2378            self.control_handle.shutdown();
2379        }
2380        self.drop_without_shutdown();
2381        _result
2382    }
2383
2384    /// Similar to "send" but does not shutdown the channel if an error occurs.
2385    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2386        let _result = self.send_raw(result);
2387        self.drop_without_shutdown();
2388        _result
2389    }
2390
2391    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2392        self.control_handle
2393            .inner
2394            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2395                result,
2396                self.tx_id,
2397                0x53042f6a15d94464,
2398                fidl::encoding::DynamicFlags::empty(),
2399            )
2400    }
2401}
2402
2403#[must_use = "FIDL methods require a response to be sent"]
2404#[derive(Debug)]
2405pub struct ListenerAcceptResponder {
2406    control_handle: std::mem::ManuallyDrop<ListenerControlHandle>,
2407    tx_id: u32,
2408}
2409
2410/// Set the the channel to be shutdown (see [`ListenerControlHandle::shutdown`])
2411/// if the responder is dropped without sending a response, so that the client
2412/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2413impl std::ops::Drop for ListenerAcceptResponder {
2414    fn drop(&mut self) {
2415        self.control_handle.shutdown();
2416        // Safety: drops once, never accessed again
2417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2418    }
2419}
2420
2421impl fidl::endpoints::Responder for ListenerAcceptResponder {
2422    type ControlHandle = ListenerControlHandle;
2423
2424    fn control_handle(&self) -> &ListenerControlHandle {
2425        &self.control_handle
2426    }
2427
2428    fn drop_without_shutdown(mut self) {
2429        // Safety: drops once, never accessed again due to mem::forget
2430        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2431        // Prevent Drop from running (which would shut down the channel)
2432        std::mem::forget(self);
2433    }
2434}
2435
2436impl ListenerAcceptResponder {
2437    /// Sends a response to the FIDL transaction.
2438    ///
2439    /// Sets the channel to shutdown if an error occurs.
2440    pub fn send(
2441        self,
2442        mut result: Result<&fidl_fuchsia_hardware_vsock::Addr, i32>,
2443    ) -> Result<(), fidl::Error> {
2444        let _result = self.send_raw(result);
2445        if _result.is_err() {
2446            self.control_handle.shutdown();
2447        }
2448        self.drop_without_shutdown();
2449        _result
2450    }
2451
2452    /// Similar to "send" but does not shutdown the channel if an error occurs.
2453    pub fn send_no_shutdown_on_err(
2454        self,
2455        mut result: Result<&fidl_fuchsia_hardware_vsock::Addr, i32>,
2456    ) -> Result<(), fidl::Error> {
2457        let _result = self.send_raw(result);
2458        self.drop_without_shutdown();
2459        _result
2460    }
2461
2462    fn send_raw(
2463        &self,
2464        mut result: Result<&fidl_fuchsia_hardware_vsock::Addr, i32>,
2465    ) -> Result<(), fidl::Error> {
2466        self.control_handle.inner.send::<fidl::encoding::ResultType<ListenerAcceptResponse, i32>>(
2467            result.map(|addr| (addr,)),
2468            self.tx_id,
2469            0x4b71e6389d92d322,
2470            fidl::encoding::DynamicFlags::empty(),
2471        )
2472    }
2473}
2474
2475mod internal {
2476    use super::*;
2477
2478    impl fidl::encoding::ResourceTypeMarker for AcceptorAcceptResponse {
2479        type Borrowed<'a> = &'a mut Self;
2480        fn take_or_borrow<'a>(
2481            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2482        ) -> Self::Borrowed<'a> {
2483            value
2484        }
2485    }
2486
2487    unsafe impl fidl::encoding::TypeMarker for AcceptorAcceptResponse {
2488        type Owned = Self;
2489
2490        #[inline(always)]
2491        fn inline_align(_context: fidl::encoding::Context) -> usize {
2492            8
2493        }
2494
2495        #[inline(always)]
2496        fn inline_size(_context: fidl::encoding::Context) -> usize {
2497            8
2498        }
2499    }
2500
2501    unsafe impl
2502        fidl::encoding::Encode<
2503            AcceptorAcceptResponse,
2504            fidl::encoding::DefaultFuchsiaResourceDialect,
2505        > for &mut AcceptorAcceptResponse
2506    {
2507        #[inline]
2508        unsafe fn encode(
2509            self,
2510            encoder: &mut fidl::encoding::Encoder<
2511                '_,
2512                fidl::encoding::DefaultFuchsiaResourceDialect,
2513            >,
2514            offset: usize,
2515            _depth: fidl::encoding::Depth,
2516        ) -> fidl::Result<()> {
2517            encoder.debug_check_bounds::<AcceptorAcceptResponse>(offset);
2518            // Delegate to tuple encoding.
2519            fidl::encoding::Encode::<AcceptorAcceptResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2520                (
2521                    <fidl::encoding::Boxed<ConnectionTransport> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.con),
2522                ),
2523                encoder, offset, _depth
2524            )
2525        }
2526    }
2527    unsafe impl<
2528            T0: fidl::encoding::Encode<
2529                fidl::encoding::Boxed<ConnectionTransport>,
2530                fidl::encoding::DefaultFuchsiaResourceDialect,
2531            >,
2532        >
2533        fidl::encoding::Encode<
2534            AcceptorAcceptResponse,
2535            fidl::encoding::DefaultFuchsiaResourceDialect,
2536        > for (T0,)
2537    {
2538        #[inline]
2539        unsafe fn encode(
2540            self,
2541            encoder: &mut fidl::encoding::Encoder<
2542                '_,
2543                fidl::encoding::DefaultFuchsiaResourceDialect,
2544            >,
2545            offset: usize,
2546            depth: fidl::encoding::Depth,
2547        ) -> fidl::Result<()> {
2548            encoder.debug_check_bounds::<AcceptorAcceptResponse>(offset);
2549            // Zero out padding regions. There's no need to apply masks
2550            // because the unmasked parts will be overwritten by fields.
2551            // Write the fields.
2552            self.0.encode(encoder, offset + 0, depth)?;
2553            Ok(())
2554        }
2555    }
2556
2557    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2558        for AcceptorAcceptResponse
2559    {
2560        #[inline(always)]
2561        fn new_empty() -> Self {
2562            Self {
2563                con: fidl::new_empty!(
2564                    fidl::encoding::Boxed<ConnectionTransport>,
2565                    fidl::encoding::DefaultFuchsiaResourceDialect
2566                ),
2567            }
2568        }
2569
2570        #[inline]
2571        unsafe fn decode(
2572            &mut self,
2573            decoder: &mut fidl::encoding::Decoder<
2574                '_,
2575                fidl::encoding::DefaultFuchsiaResourceDialect,
2576            >,
2577            offset: usize,
2578            _depth: fidl::encoding::Depth,
2579        ) -> fidl::Result<()> {
2580            decoder.debug_check_bounds::<Self>(offset);
2581            // Verify that padding bytes are zero.
2582            fidl::decode!(
2583                fidl::encoding::Boxed<ConnectionTransport>,
2584                fidl::encoding::DefaultFuchsiaResourceDialect,
2585                &mut self.con,
2586                decoder,
2587                offset + 0,
2588                _depth
2589            )?;
2590            Ok(())
2591        }
2592    }
2593
2594    impl fidl::encoding::ResourceTypeMarker for ConnectionTransport {
2595        type Borrowed<'a> = &'a mut Self;
2596        fn take_or_borrow<'a>(
2597            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2598        ) -> Self::Borrowed<'a> {
2599            value
2600        }
2601    }
2602
2603    unsafe impl fidl::encoding::TypeMarker for ConnectionTransport {
2604        type Owned = Self;
2605
2606        #[inline(always)]
2607        fn inline_align(_context: fidl::encoding::Context) -> usize {
2608            4
2609        }
2610
2611        #[inline(always)]
2612        fn inline_size(_context: fidl::encoding::Context) -> usize {
2613            8
2614        }
2615    }
2616
2617    unsafe impl
2618        fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>
2619        for &mut ConnectionTransport
2620    {
2621        #[inline]
2622        unsafe fn encode(
2623            self,
2624            encoder: &mut fidl::encoding::Encoder<
2625                '_,
2626                fidl::encoding::DefaultFuchsiaResourceDialect,
2627            >,
2628            offset: usize,
2629            _depth: fidl::encoding::Depth,
2630        ) -> fidl::Result<()> {
2631            encoder.debug_check_bounds::<ConnectionTransport>(offset);
2632            // Delegate to tuple encoding.
2633            fidl::encoding::Encode::<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2634                (
2635                    <fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.data),
2636                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.con),
2637                ),
2638                encoder, offset, _depth
2639            )
2640        }
2641    }
2642    unsafe impl<
2643            T0: fidl::encoding::Encode<
2644                fidl::encoding::HandleType<
2645                    fidl::Socket,
2646                    { fidl::ObjectType::SOCKET.into_raw() },
2647                    2147483648,
2648                >,
2649                fidl::encoding::DefaultFuchsiaResourceDialect,
2650            >,
2651            T1: fidl::encoding::Encode<
2652                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
2653                fidl::encoding::DefaultFuchsiaResourceDialect,
2654            >,
2655        >
2656        fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>
2657        for (T0, T1)
2658    {
2659        #[inline]
2660        unsafe fn encode(
2661            self,
2662            encoder: &mut fidl::encoding::Encoder<
2663                '_,
2664                fidl::encoding::DefaultFuchsiaResourceDialect,
2665            >,
2666            offset: usize,
2667            depth: fidl::encoding::Depth,
2668        ) -> fidl::Result<()> {
2669            encoder.debug_check_bounds::<ConnectionTransport>(offset);
2670            // Zero out padding regions. There's no need to apply masks
2671            // because the unmasked parts will be overwritten by fields.
2672            // Write the fields.
2673            self.0.encode(encoder, offset + 0, depth)?;
2674            self.1.encode(encoder, offset + 4, depth)?;
2675            Ok(())
2676        }
2677    }
2678
2679    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2680        for ConnectionTransport
2681    {
2682        #[inline(always)]
2683        fn new_empty() -> Self {
2684            Self {
2685                data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2686                con: fidl::new_empty!(
2687                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
2688                    fidl::encoding::DefaultFuchsiaResourceDialect
2689                ),
2690            }
2691        }
2692
2693        #[inline]
2694        unsafe fn decode(
2695            &mut self,
2696            decoder: &mut fidl::encoding::Decoder<
2697                '_,
2698                fidl::encoding::DefaultFuchsiaResourceDialect,
2699            >,
2700            offset: usize,
2701            _depth: fidl::encoding::Depth,
2702        ) -> fidl::Result<()> {
2703            decoder.debug_check_bounds::<Self>(offset);
2704            // Verify that padding bytes are zero.
2705            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 0, _depth)?;
2706            fidl::decode!(
2707                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
2708                fidl::encoding::DefaultFuchsiaResourceDialect,
2709                &mut self.con,
2710                decoder,
2711                offset + 4,
2712                _depth
2713            )?;
2714            Ok(())
2715        }
2716    }
2717
2718    impl fidl::encoding::ResourceTypeMarker for ConnectorBindRequest {
2719        type Borrowed<'a> = &'a mut Self;
2720        fn take_or_borrow<'a>(
2721            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2722        ) -> Self::Borrowed<'a> {
2723            value
2724        }
2725    }
2726
2727    unsafe impl fidl::encoding::TypeMarker for ConnectorBindRequest {
2728        type Owned = Self;
2729
2730        #[inline(always)]
2731        fn inline_align(_context: fidl::encoding::Context) -> usize {
2732            4
2733        }
2734
2735        #[inline(always)]
2736        fn inline_size(_context: fidl::encoding::Context) -> usize {
2737            12
2738        }
2739    }
2740
2741    unsafe impl
2742        fidl::encoding::Encode<ConnectorBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2743        for &mut ConnectorBindRequest
2744    {
2745        #[inline]
2746        unsafe fn encode(
2747            self,
2748            encoder: &mut fidl::encoding::Encoder<
2749                '_,
2750                fidl::encoding::DefaultFuchsiaResourceDialect,
2751            >,
2752            offset: usize,
2753            _depth: fidl::encoding::Depth,
2754        ) -> fidl::Result<()> {
2755            encoder.debug_check_bounds::<ConnectorBindRequest>(offset);
2756            // Delegate to tuple encoding.
2757            fidl::encoding::Encode::<ConnectorBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2758                (
2759                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_cid),
2760                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.local_port),
2761                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listener),
2762                ),
2763                encoder, offset, _depth
2764            )
2765        }
2766    }
2767    unsafe impl<
2768            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2769            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2770            T2: fidl::encoding::Encode<
2771                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>>,
2772                fidl::encoding::DefaultFuchsiaResourceDialect,
2773            >,
2774        >
2775        fidl::encoding::Encode<ConnectorBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2776        for (T0, T1, T2)
2777    {
2778        #[inline]
2779        unsafe fn encode(
2780            self,
2781            encoder: &mut fidl::encoding::Encoder<
2782                '_,
2783                fidl::encoding::DefaultFuchsiaResourceDialect,
2784            >,
2785            offset: usize,
2786            depth: fidl::encoding::Depth,
2787        ) -> fidl::Result<()> {
2788            encoder.debug_check_bounds::<ConnectorBindRequest>(offset);
2789            // Zero out padding regions. There's no need to apply masks
2790            // because the unmasked parts will be overwritten by fields.
2791            // Write the fields.
2792            self.0.encode(encoder, offset + 0, depth)?;
2793            self.1.encode(encoder, offset + 4, depth)?;
2794            self.2.encode(encoder, offset + 8, depth)?;
2795            Ok(())
2796        }
2797    }
2798
2799    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2800        for ConnectorBindRequest
2801    {
2802        #[inline(always)]
2803        fn new_empty() -> Self {
2804            Self {
2805                remote_cid: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2806                local_port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2807                listener: fidl::new_empty!(
2808                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>>,
2809                    fidl::encoding::DefaultFuchsiaResourceDialect
2810                ),
2811            }
2812        }
2813
2814        #[inline]
2815        unsafe fn decode(
2816            &mut self,
2817            decoder: &mut fidl::encoding::Decoder<
2818                '_,
2819                fidl::encoding::DefaultFuchsiaResourceDialect,
2820            >,
2821            offset: usize,
2822            _depth: fidl::encoding::Depth,
2823        ) -> fidl::Result<()> {
2824            decoder.debug_check_bounds::<Self>(offset);
2825            // Verify that padding bytes are zero.
2826            fidl::decode!(
2827                u32,
2828                fidl::encoding::DefaultFuchsiaResourceDialect,
2829                &mut self.remote_cid,
2830                decoder,
2831                offset + 0,
2832                _depth
2833            )?;
2834            fidl::decode!(
2835                u32,
2836                fidl::encoding::DefaultFuchsiaResourceDialect,
2837                &mut self.local_port,
2838                decoder,
2839                offset + 4,
2840                _depth
2841            )?;
2842            fidl::decode!(
2843                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>>,
2844                fidl::encoding::DefaultFuchsiaResourceDialect,
2845                &mut self.listener,
2846                decoder,
2847                offset + 8,
2848                _depth
2849            )?;
2850            Ok(())
2851        }
2852    }
2853
2854    impl fidl::encoding::ResourceTypeMarker for ConnectorConnectRequest {
2855        type Borrowed<'a> = &'a mut Self;
2856        fn take_or_borrow<'a>(
2857            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2858        ) -> Self::Borrowed<'a> {
2859            value
2860        }
2861    }
2862
2863    unsafe impl fidl::encoding::TypeMarker for ConnectorConnectRequest {
2864        type Owned = Self;
2865
2866        #[inline(always)]
2867        fn inline_align(_context: fidl::encoding::Context) -> usize {
2868            4
2869        }
2870
2871        #[inline(always)]
2872        fn inline_size(_context: fidl::encoding::Context) -> usize {
2873            16
2874        }
2875    }
2876
2877    unsafe impl
2878        fidl::encoding::Encode<
2879            ConnectorConnectRequest,
2880            fidl::encoding::DefaultFuchsiaResourceDialect,
2881        > for &mut ConnectorConnectRequest
2882    {
2883        #[inline]
2884        unsafe fn encode(
2885            self,
2886            encoder: &mut fidl::encoding::Encoder<
2887                '_,
2888                fidl::encoding::DefaultFuchsiaResourceDialect,
2889            >,
2890            offset: usize,
2891            _depth: fidl::encoding::Depth,
2892        ) -> fidl::Result<()> {
2893            encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
2894            // Delegate to tuple encoding.
2895            fidl::encoding::Encode::<
2896                ConnectorConnectRequest,
2897                fidl::encoding::DefaultFuchsiaResourceDialect,
2898            >::encode(
2899                (
2900                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_cid),
2901                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_port),
2902                    <ConnectionTransport as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2903                        &mut self.con,
2904                    ),
2905                ),
2906                encoder,
2907                offset,
2908                _depth,
2909            )
2910        }
2911    }
2912    unsafe impl<
2913            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2914            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2915            T2: fidl::encoding::Encode<
2916                ConnectionTransport,
2917                fidl::encoding::DefaultFuchsiaResourceDialect,
2918            >,
2919        >
2920        fidl::encoding::Encode<
2921            ConnectorConnectRequest,
2922            fidl::encoding::DefaultFuchsiaResourceDialect,
2923        > for (T0, T1, T2)
2924    {
2925        #[inline]
2926        unsafe fn encode(
2927            self,
2928            encoder: &mut fidl::encoding::Encoder<
2929                '_,
2930                fidl::encoding::DefaultFuchsiaResourceDialect,
2931            >,
2932            offset: usize,
2933            depth: fidl::encoding::Depth,
2934        ) -> fidl::Result<()> {
2935            encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
2936            // Zero out padding regions. There's no need to apply masks
2937            // because the unmasked parts will be overwritten by fields.
2938            // Write the fields.
2939            self.0.encode(encoder, offset + 0, depth)?;
2940            self.1.encode(encoder, offset + 4, depth)?;
2941            self.2.encode(encoder, offset + 8, depth)?;
2942            Ok(())
2943        }
2944    }
2945
2946    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2947        for ConnectorConnectRequest
2948    {
2949        #[inline(always)]
2950        fn new_empty() -> Self {
2951            Self {
2952                remote_cid: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2953                remote_port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2954                con: fidl::new_empty!(
2955                    ConnectionTransport,
2956                    fidl::encoding::DefaultFuchsiaResourceDialect
2957                ),
2958            }
2959        }
2960
2961        #[inline]
2962        unsafe fn decode(
2963            &mut self,
2964            decoder: &mut fidl::encoding::Decoder<
2965                '_,
2966                fidl::encoding::DefaultFuchsiaResourceDialect,
2967            >,
2968            offset: usize,
2969            _depth: fidl::encoding::Depth,
2970        ) -> fidl::Result<()> {
2971            decoder.debug_check_bounds::<Self>(offset);
2972            // Verify that padding bytes are zero.
2973            fidl::decode!(
2974                u32,
2975                fidl::encoding::DefaultFuchsiaResourceDialect,
2976                &mut self.remote_cid,
2977                decoder,
2978                offset + 0,
2979                _depth
2980            )?;
2981            fidl::decode!(
2982                u32,
2983                fidl::encoding::DefaultFuchsiaResourceDialect,
2984                &mut self.remote_port,
2985                decoder,
2986                offset + 4,
2987                _depth
2988            )?;
2989            fidl::decode!(
2990                ConnectionTransport,
2991                fidl::encoding::DefaultFuchsiaResourceDialect,
2992                &mut self.con,
2993                decoder,
2994                offset + 8,
2995                _depth
2996            )?;
2997            Ok(())
2998        }
2999    }
3000
3001    impl fidl::encoding::ResourceTypeMarker for ConnectorListenRequest {
3002        type Borrowed<'a> = &'a mut Self;
3003        fn take_or_borrow<'a>(
3004            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3005        ) -> Self::Borrowed<'a> {
3006            value
3007        }
3008    }
3009
3010    unsafe impl fidl::encoding::TypeMarker for ConnectorListenRequest {
3011        type Owned = Self;
3012
3013        #[inline(always)]
3014        fn inline_align(_context: fidl::encoding::Context) -> usize {
3015            4
3016        }
3017
3018        #[inline(always)]
3019        fn inline_size(_context: fidl::encoding::Context) -> usize {
3020            8
3021        }
3022    }
3023
3024    unsafe impl
3025        fidl::encoding::Encode<
3026            ConnectorListenRequest,
3027            fidl::encoding::DefaultFuchsiaResourceDialect,
3028        > for &mut ConnectorListenRequest
3029    {
3030        #[inline]
3031        unsafe fn encode(
3032            self,
3033            encoder: &mut fidl::encoding::Encoder<
3034                '_,
3035                fidl::encoding::DefaultFuchsiaResourceDialect,
3036            >,
3037            offset: usize,
3038            _depth: fidl::encoding::Depth,
3039        ) -> fidl::Result<()> {
3040            encoder.debug_check_bounds::<ConnectorListenRequest>(offset);
3041            // Delegate to tuple encoding.
3042            fidl::encoding::Encode::<ConnectorListenRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3043                (
3044                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.local_port),
3045                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.acceptor),
3046                ),
3047                encoder, offset, _depth
3048            )
3049        }
3050    }
3051    unsafe impl<
3052            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
3053            T1: fidl::encoding::Encode<
3054                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>>,
3055                fidl::encoding::DefaultFuchsiaResourceDialect,
3056            >,
3057        >
3058        fidl::encoding::Encode<
3059            ConnectorListenRequest,
3060            fidl::encoding::DefaultFuchsiaResourceDialect,
3061        > for (T0, T1)
3062    {
3063        #[inline]
3064        unsafe fn encode(
3065            self,
3066            encoder: &mut fidl::encoding::Encoder<
3067                '_,
3068                fidl::encoding::DefaultFuchsiaResourceDialect,
3069            >,
3070            offset: usize,
3071            depth: fidl::encoding::Depth,
3072        ) -> fidl::Result<()> {
3073            encoder.debug_check_bounds::<ConnectorListenRequest>(offset);
3074            // Zero out padding regions. There's no need to apply masks
3075            // because the unmasked parts will be overwritten by fields.
3076            // Write the fields.
3077            self.0.encode(encoder, offset + 0, depth)?;
3078            self.1.encode(encoder, offset + 4, depth)?;
3079            Ok(())
3080        }
3081    }
3082
3083    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3084        for ConnectorListenRequest
3085    {
3086        #[inline(always)]
3087        fn new_empty() -> Self {
3088            Self {
3089                local_port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
3090                acceptor: fidl::new_empty!(
3091                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>>,
3092                    fidl::encoding::DefaultFuchsiaResourceDialect
3093                ),
3094            }
3095        }
3096
3097        #[inline]
3098        unsafe fn decode(
3099            &mut self,
3100            decoder: &mut fidl::encoding::Decoder<
3101                '_,
3102                fidl::encoding::DefaultFuchsiaResourceDialect,
3103            >,
3104            offset: usize,
3105            _depth: fidl::encoding::Depth,
3106        ) -> fidl::Result<()> {
3107            decoder.debug_check_bounds::<Self>(offset);
3108            // Verify that padding bytes are zero.
3109            fidl::decode!(
3110                u32,
3111                fidl::encoding::DefaultFuchsiaResourceDialect,
3112                &mut self.local_port,
3113                decoder,
3114                offset + 0,
3115                _depth
3116            )?;
3117            fidl::decode!(
3118                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>>,
3119                fidl::encoding::DefaultFuchsiaResourceDialect,
3120                &mut self.acceptor,
3121                decoder,
3122                offset + 4,
3123                _depth
3124            )?;
3125            Ok(())
3126        }
3127    }
3128
3129    impl fidl::encoding::ResourceTypeMarker for ListenerAcceptRequest {
3130        type Borrowed<'a> = &'a mut Self;
3131        fn take_or_borrow<'a>(
3132            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3133        ) -> Self::Borrowed<'a> {
3134            value
3135        }
3136    }
3137
3138    unsafe impl fidl::encoding::TypeMarker for ListenerAcceptRequest {
3139        type Owned = Self;
3140
3141        #[inline(always)]
3142        fn inline_align(_context: fidl::encoding::Context) -> usize {
3143            4
3144        }
3145
3146        #[inline(always)]
3147        fn inline_size(_context: fidl::encoding::Context) -> usize {
3148            8
3149        }
3150    }
3151
3152    unsafe impl
3153        fidl::encoding::Encode<ListenerAcceptRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3154        for &mut ListenerAcceptRequest
3155    {
3156        #[inline]
3157        unsafe fn encode(
3158            self,
3159            encoder: &mut fidl::encoding::Encoder<
3160                '_,
3161                fidl::encoding::DefaultFuchsiaResourceDialect,
3162            >,
3163            offset: usize,
3164            _depth: fidl::encoding::Depth,
3165        ) -> fidl::Result<()> {
3166            encoder.debug_check_bounds::<ListenerAcceptRequest>(offset);
3167            // Delegate to tuple encoding.
3168            fidl::encoding::Encode::<
3169                ListenerAcceptRequest,
3170                fidl::encoding::DefaultFuchsiaResourceDialect,
3171            >::encode(
3172                (<ConnectionTransport as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3173                    &mut self.con,
3174                ),),
3175                encoder,
3176                offset,
3177                _depth,
3178            )
3179        }
3180    }
3181    unsafe impl<
3182            T0: fidl::encoding::Encode<
3183                ConnectionTransport,
3184                fidl::encoding::DefaultFuchsiaResourceDialect,
3185            >,
3186        >
3187        fidl::encoding::Encode<ListenerAcceptRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3188        for (T0,)
3189    {
3190        #[inline]
3191        unsafe fn encode(
3192            self,
3193            encoder: &mut fidl::encoding::Encoder<
3194                '_,
3195                fidl::encoding::DefaultFuchsiaResourceDialect,
3196            >,
3197            offset: usize,
3198            depth: fidl::encoding::Depth,
3199        ) -> fidl::Result<()> {
3200            encoder.debug_check_bounds::<ListenerAcceptRequest>(offset);
3201            // Zero out padding regions. There's no need to apply masks
3202            // because the unmasked parts will be overwritten by fields.
3203            // Write the fields.
3204            self.0.encode(encoder, offset + 0, depth)?;
3205            Ok(())
3206        }
3207    }
3208
3209    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3210        for ListenerAcceptRequest
3211    {
3212        #[inline(always)]
3213        fn new_empty() -> Self {
3214            Self {
3215                con: fidl::new_empty!(
3216                    ConnectionTransport,
3217                    fidl::encoding::DefaultFuchsiaResourceDialect
3218                ),
3219            }
3220        }
3221
3222        #[inline]
3223        unsafe fn decode(
3224            &mut self,
3225            decoder: &mut fidl::encoding::Decoder<
3226                '_,
3227                fidl::encoding::DefaultFuchsiaResourceDialect,
3228            >,
3229            offset: usize,
3230            _depth: fidl::encoding::Depth,
3231        ) -> fidl::Result<()> {
3232            decoder.debug_check_bounds::<Self>(offset);
3233            // Verify that padding bytes are zero.
3234            fidl::decode!(
3235                ConnectionTransport,
3236                fidl::encoding::DefaultFuchsiaResourceDialect,
3237                &mut self.con,
3238                decoder,
3239                offset + 0,
3240                _depth
3241            )?;
3242            Ok(())
3243        }
3244    }
3245}