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