fidl_fuchsia_vsock/
fidl_fuchsia_vsock.rs

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