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, Eq, Hash, Ord, PartialEq, PartialOrd)]
69pub struct ProviderStreamSocketRequest {
70    pub server: fidl::endpoints::ServerEnd<StreamSocketMarker>,
71    pub data: fidl::Socket,
72}
73
74impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
75    for ProviderStreamSocketRequest
76{
77}
78
79#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
80pub struct StreamSocketAcceptRequest {
81    pub want_addr: bool,
82}
83
84impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for StreamSocketAcceptRequest {}
85
86#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
87#[repr(C)]
88pub struct StreamSocketConnectRequest {
89    pub remote_address: VsockAddress,
90}
91
92impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
93    for StreamSocketConnectRequest
94{
95}
96
97#[derive(Debug, Default, PartialEq)]
98pub struct StreamSocketAcceptResponse {
99    pub socket: Option<fidl::endpoints::ClientEnd<StreamSocketMarker>>,
100    pub data: Option<fidl::Socket>,
101    pub addr: Option<VsockAddress>,
102    #[doc(hidden)]
103    pub __source_breaking: fidl::marker::SourceBreaking,
104}
105
106impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
107    for StreamSocketAcceptResponse
108{
109}
110
111#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
112pub struct AcceptorMarker;
113
114impl fidl::endpoints::ProtocolMarker for AcceptorMarker {
115    type Proxy = AcceptorProxy;
116    type RequestStream = AcceptorRequestStream;
117    #[cfg(target_os = "fuchsia")]
118    type SynchronousProxy = AcceptorSynchronousProxy;
119
120    const DEBUG_NAME: &'static str = "(anonymous) Acceptor";
121}
122
123pub trait AcceptorProxyInterface: Send + Sync {
124    type AcceptResponseFut: std::future::Future<Output = Result<Option<Box<ConnectionTransport>>, fidl::Error>>
125        + Send;
126    fn r#accept(&self, addr: &fidl_fuchsia_hardware_vsock::Addr) -> Self::AcceptResponseFut;
127}
128#[derive(Debug)]
129#[cfg(target_os = "fuchsia")]
130pub struct AcceptorSynchronousProxy {
131    client: fidl::client::sync::Client,
132}
133
134#[cfg(target_os = "fuchsia")]
135impl fidl::endpoints::SynchronousProxy for AcceptorSynchronousProxy {
136    type Proxy = AcceptorProxy;
137    type Protocol = AcceptorMarker;
138
139    fn from_channel(inner: fidl::Channel) -> Self {
140        Self::new(inner)
141    }
142
143    fn into_channel(self) -> fidl::Channel {
144        self.client.into_channel()
145    }
146
147    fn as_channel(&self) -> &fidl::Channel {
148        self.client.as_channel()
149    }
150}
151
152#[cfg(target_os = "fuchsia")]
153impl AcceptorSynchronousProxy {
154    pub fn new(channel: fidl::Channel) -> Self {
155        let protocol_name = <AcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
156        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
157    }
158
159    pub fn into_channel(self) -> fidl::Channel {
160        self.client.into_channel()
161    }
162
163    /// Waits until an event arrives and returns it. It is safe for other
164    /// threads to make concurrent requests while waiting for an event.
165    pub fn wait_for_event(
166        &self,
167        deadline: zx::MonotonicInstant,
168    ) -> Result<AcceptorEvent, fidl::Error> {
169        AcceptorEvent::decode(self.client.wait_for_event(deadline)?)
170    }
171
172    /// The response is either a `ConnectionTransport` to indicate that the connection
173    /// is accepted, or none to indicate that it should be rejected.
174    pub fn r#accept(
175        &self,
176        mut addr: &fidl_fuchsia_hardware_vsock::Addr,
177        ___deadline: zx::MonotonicInstant,
178    ) -> Result<Option<Box<ConnectionTransport>>, fidl::Error> {
179        let _response = self.client.send_query::<AcceptorAcceptRequest, AcceptorAcceptResponse>(
180            (addr,),
181            0x21fd057ad9c9f443,
182            fidl::encoding::DynamicFlags::empty(),
183            ___deadline,
184        )?;
185        Ok(_response.con)
186    }
187}
188
189#[cfg(target_os = "fuchsia")]
190impl From<AcceptorSynchronousProxy> for zx::NullableHandle {
191    fn from(value: AcceptorSynchronousProxy) -> Self {
192        value.into_channel().into()
193    }
194}
195
196#[cfg(target_os = "fuchsia")]
197impl From<fidl::Channel> for AcceptorSynchronousProxy {
198    fn from(value: fidl::Channel) -> Self {
199        Self::new(value)
200    }
201}
202
203#[cfg(target_os = "fuchsia")]
204impl fidl::endpoints::FromClient for AcceptorSynchronousProxy {
205    type Protocol = AcceptorMarker;
206
207    fn from_client(value: fidl::endpoints::ClientEnd<AcceptorMarker>) -> Self {
208        Self::new(value.into_channel())
209    }
210}
211
212#[derive(Debug, Clone)]
213pub struct AcceptorProxy {
214    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
215}
216
217impl fidl::endpoints::Proxy for AcceptorProxy {
218    type Protocol = AcceptorMarker;
219
220    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
221        Self::new(inner)
222    }
223
224    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
225        self.client.into_channel().map_err(|client| Self { client })
226    }
227
228    fn as_channel(&self) -> &::fidl::AsyncChannel {
229        self.client.as_channel()
230    }
231}
232
233impl AcceptorProxy {
234    /// Create a new Proxy for fuchsia.vsock/Acceptor.
235    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
236        let protocol_name = <AcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
237        Self { client: fidl::client::Client::new(channel, protocol_name) }
238    }
239
240    /// Get a Stream of events from the remote end of the protocol.
241    ///
242    /// # Panics
243    ///
244    /// Panics if the event stream was already taken.
245    pub fn take_event_stream(&self) -> AcceptorEventStream {
246        AcceptorEventStream { event_receiver: self.client.take_event_receiver() }
247    }
248
249    /// The response is either a `ConnectionTransport` to indicate that the connection
250    /// is accepted, or none to indicate that it should be rejected.
251    pub fn r#accept(
252        &self,
253        mut addr: &fidl_fuchsia_hardware_vsock::Addr,
254    ) -> fidl::client::QueryResponseFut<
255        Option<Box<ConnectionTransport>>,
256        fidl::encoding::DefaultFuchsiaResourceDialect,
257    > {
258        AcceptorProxyInterface::r#accept(self, addr)
259    }
260}
261
262impl AcceptorProxyInterface for AcceptorProxy {
263    type AcceptResponseFut = fidl::client::QueryResponseFut<
264        Option<Box<ConnectionTransport>>,
265        fidl::encoding::DefaultFuchsiaResourceDialect,
266    >;
267    fn r#accept(&self, mut addr: &fidl_fuchsia_hardware_vsock::Addr) -> Self::AcceptResponseFut {
268        fn _decode(
269            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
270        ) -> Result<Option<Box<ConnectionTransport>>, fidl::Error> {
271            let _response = fidl::client::decode_transaction_body::<
272                AcceptorAcceptResponse,
273                fidl::encoding::DefaultFuchsiaResourceDialect,
274                0x21fd057ad9c9f443,
275            >(_buf?)?;
276            Ok(_response.con)
277        }
278        self.client
279            .send_query_and_decode::<AcceptorAcceptRequest, Option<Box<ConnectionTransport>>>(
280                (addr,),
281                0x21fd057ad9c9f443,
282                fidl::encoding::DynamicFlags::empty(),
283                _decode,
284            )
285    }
286}
287
288pub struct AcceptorEventStream {
289    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
290}
291
292impl std::marker::Unpin for AcceptorEventStream {}
293
294impl futures::stream::FusedStream for AcceptorEventStream {
295    fn is_terminated(&self) -> bool {
296        self.event_receiver.is_terminated()
297    }
298}
299
300impl futures::Stream for AcceptorEventStream {
301    type Item = Result<AcceptorEvent, fidl::Error>;
302
303    fn poll_next(
304        mut self: std::pin::Pin<&mut Self>,
305        cx: &mut std::task::Context<'_>,
306    ) -> std::task::Poll<Option<Self::Item>> {
307        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
308            &mut self.event_receiver,
309            cx
310        )?) {
311            Some(buf) => std::task::Poll::Ready(Some(AcceptorEvent::decode(buf))),
312            None => std::task::Poll::Ready(None),
313        }
314    }
315}
316
317#[derive(Debug)]
318pub enum AcceptorEvent {}
319
320impl AcceptorEvent {
321    /// Decodes a message buffer as a [`AcceptorEvent`].
322    fn decode(
323        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
324    ) -> Result<AcceptorEvent, fidl::Error> {
325        let (bytes, _handles) = buf.split_mut();
326        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
327        debug_assert_eq!(tx_header.tx_id, 0);
328        match tx_header.ordinal {
329            _ => Err(fidl::Error::UnknownOrdinal {
330                ordinal: tx_header.ordinal,
331                protocol_name: <AcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
332            }),
333        }
334    }
335}
336
337/// A Stream of incoming requests for fuchsia.vsock/Acceptor.
338pub struct AcceptorRequestStream {
339    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
340    is_terminated: bool,
341}
342
343impl std::marker::Unpin for AcceptorRequestStream {}
344
345impl futures::stream::FusedStream for AcceptorRequestStream {
346    fn is_terminated(&self) -> bool {
347        self.is_terminated
348    }
349}
350
351impl fidl::endpoints::RequestStream for AcceptorRequestStream {
352    type Protocol = AcceptorMarker;
353    type ControlHandle = AcceptorControlHandle;
354
355    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
356        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
357    }
358
359    fn control_handle(&self) -> Self::ControlHandle {
360        AcceptorControlHandle { inner: self.inner.clone() }
361    }
362
363    fn into_inner(
364        self,
365    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
366    {
367        (self.inner, self.is_terminated)
368    }
369
370    fn from_inner(
371        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
372        is_terminated: bool,
373    ) -> Self {
374        Self { inner, is_terminated }
375    }
376}
377
378impl futures::Stream for AcceptorRequestStream {
379    type Item = Result<AcceptorRequest, fidl::Error>;
380
381    fn poll_next(
382        mut self: std::pin::Pin<&mut Self>,
383        cx: &mut std::task::Context<'_>,
384    ) -> std::task::Poll<Option<Self::Item>> {
385        let this = &mut *self;
386        if this.inner.check_shutdown(cx) {
387            this.is_terminated = true;
388            return std::task::Poll::Ready(None);
389        }
390        if this.is_terminated {
391            panic!("polled AcceptorRequestStream after completion");
392        }
393        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
394            |bytes, handles| {
395                match this.inner.channel().read_etc(cx, bytes, handles) {
396                    std::task::Poll::Ready(Ok(())) => {}
397                    std::task::Poll::Pending => return std::task::Poll::Pending,
398                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
399                        this.is_terminated = true;
400                        return std::task::Poll::Ready(None);
401                    }
402                    std::task::Poll::Ready(Err(e)) => {
403                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
404                            e.into(),
405                        ))));
406                    }
407                }
408
409                // A message has been received from the channel
410                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
411
412                std::task::Poll::Ready(Some(match header.ordinal {
413                    0x21fd057ad9c9f443 => {
414                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
415                        let mut req = fidl::new_empty!(
416                            AcceptorAcceptRequest,
417                            fidl::encoding::DefaultFuchsiaResourceDialect
418                        );
419                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AcceptorAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
420                        let control_handle = AcceptorControlHandle { inner: this.inner.clone() };
421                        Ok(AcceptorRequest::Accept {
422                            addr: req.addr,
423
424                            responder: AcceptorAcceptResponder {
425                                control_handle: std::mem::ManuallyDrop::new(control_handle),
426                                tx_id: header.tx_id,
427                            },
428                        })
429                    }
430                    _ => Err(fidl::Error::UnknownOrdinal {
431                        ordinal: header.ordinal,
432                        protocol_name:
433                            <AcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
434                    }),
435                }))
436            },
437        )
438    }
439}
440
441/// Interface presented by a listener to accept or reject connections
442#[derive(Debug)]
443pub enum AcceptorRequest {
444    /// The response is either a `ConnectionTransport` to indicate that the connection
445    /// is accepted, or none to indicate that it should be rejected.
446    Accept { addr: fidl_fuchsia_hardware_vsock::Addr, responder: AcceptorAcceptResponder },
447}
448
449impl AcceptorRequest {
450    #[allow(irrefutable_let_patterns)]
451    pub fn into_accept(
452        self,
453    ) -> Option<(fidl_fuchsia_hardware_vsock::Addr, AcceptorAcceptResponder)> {
454        if let AcceptorRequest::Accept { addr, responder } = self {
455            Some((addr, responder))
456        } else {
457            None
458        }
459    }
460
461    /// Name of the method defined in FIDL
462    pub fn method_name(&self) -> &'static str {
463        match *self {
464            AcceptorRequest::Accept { .. } => "accept",
465        }
466    }
467}
468
469#[derive(Debug, Clone)]
470pub struct AcceptorControlHandle {
471    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
472}
473
474impl fidl::endpoints::ControlHandle for AcceptorControlHandle {
475    fn shutdown(&self) {
476        self.inner.shutdown()
477    }
478
479    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
480        self.inner.shutdown_with_epitaph(status)
481    }
482
483    fn is_closed(&self) -> bool {
484        self.inner.channel().is_closed()
485    }
486    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
487        self.inner.channel().on_closed()
488    }
489
490    #[cfg(target_os = "fuchsia")]
491    fn signal_peer(
492        &self,
493        clear_mask: zx::Signals,
494        set_mask: zx::Signals,
495    ) -> Result<(), zx_status::Status> {
496        use fidl::Peered;
497        self.inner.channel().signal_peer(clear_mask, set_mask)
498    }
499}
500
501impl AcceptorControlHandle {}
502
503#[must_use = "FIDL methods require a response to be sent"]
504#[derive(Debug)]
505pub struct AcceptorAcceptResponder {
506    control_handle: std::mem::ManuallyDrop<AcceptorControlHandle>,
507    tx_id: u32,
508}
509
510/// Set the the channel to be shutdown (see [`AcceptorControlHandle::shutdown`])
511/// if the responder is dropped without sending a response, so that the client
512/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
513impl std::ops::Drop for AcceptorAcceptResponder {
514    fn drop(&mut self) {
515        self.control_handle.shutdown();
516        // Safety: drops once, never accessed again
517        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
518    }
519}
520
521impl fidl::endpoints::Responder for AcceptorAcceptResponder {
522    type ControlHandle = AcceptorControlHandle;
523
524    fn control_handle(&self) -> &AcceptorControlHandle {
525        &self.control_handle
526    }
527
528    fn drop_without_shutdown(mut self) {
529        // Safety: drops once, never accessed again due to mem::forget
530        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
531        // Prevent Drop from running (which would shut down the channel)
532        std::mem::forget(self);
533    }
534}
535
536impl AcceptorAcceptResponder {
537    /// Sends a response to the FIDL transaction.
538    ///
539    /// Sets the channel to shutdown if an error occurs.
540    pub fn send(self, mut con: Option<ConnectionTransport>) -> Result<(), fidl::Error> {
541        let _result = self.send_raw(con);
542        if _result.is_err() {
543            self.control_handle.shutdown();
544        }
545        self.drop_without_shutdown();
546        _result
547    }
548
549    /// Similar to "send" but does not shutdown the channel if an error occurs.
550    pub fn send_no_shutdown_on_err(
551        self,
552        mut con: Option<ConnectionTransport>,
553    ) -> Result<(), fidl::Error> {
554        let _result = self.send_raw(con);
555        self.drop_without_shutdown();
556        _result
557    }
558
559    fn send_raw(&self, mut con: Option<ConnectionTransport>) -> Result<(), fidl::Error> {
560        self.control_handle.inner.send::<AcceptorAcceptResponse>(
561            (con.as_mut(),),
562            self.tx_id,
563            0x21fd057ad9c9f443,
564            fidl::encoding::DynamicFlags::empty(),
565        )
566    }
567}
568
569#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
570pub struct ConnectionMarker;
571
572impl fidl::endpoints::ProtocolMarker for ConnectionMarker {
573    type Proxy = ConnectionProxy;
574    type RequestStream = ConnectionRequestStream;
575    #[cfg(target_os = "fuchsia")]
576    type SynchronousProxy = ConnectionSynchronousProxy;
577
578    const DEBUG_NAME: &'static str = "(anonymous) Connection";
579}
580
581pub trait ConnectionProxyInterface: Send + Sync {
582    fn r#shutdown(&self) -> Result<(), fidl::Error>;
583}
584#[derive(Debug)]
585#[cfg(target_os = "fuchsia")]
586pub struct ConnectionSynchronousProxy {
587    client: fidl::client::sync::Client,
588}
589
590#[cfg(target_os = "fuchsia")]
591impl fidl::endpoints::SynchronousProxy for ConnectionSynchronousProxy {
592    type Proxy = ConnectionProxy;
593    type Protocol = ConnectionMarker;
594
595    fn from_channel(inner: fidl::Channel) -> Self {
596        Self::new(inner)
597    }
598
599    fn into_channel(self) -> fidl::Channel {
600        self.client.into_channel()
601    }
602
603    fn as_channel(&self) -> &fidl::Channel {
604        self.client.as_channel()
605    }
606}
607
608#[cfg(target_os = "fuchsia")]
609impl ConnectionSynchronousProxy {
610    pub fn new(channel: fidl::Channel) -> Self {
611        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
612        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
613    }
614
615    pub fn into_channel(self) -> fidl::Channel {
616        self.client.into_channel()
617    }
618
619    /// Waits until an event arrives and returns it. It is safe for other
620    /// threads to make concurrent requests while waiting for an event.
621    pub fn wait_for_event(
622        &self,
623        deadline: zx::MonotonicInstant,
624    ) -> Result<ConnectionEvent, fidl::Error> {
625        ConnectionEvent::decode(self.client.wait_for_event(deadline)?)
626    }
627
628    /// Trigger asynchronous shutdown. The underlying channel will be closed
629    /// once shutdown is complete. Shutdown has an implicit barrier as any already
630    /// queued sends will complete, but any additional sends will generate errors
631    pub fn r#shutdown(&self) -> Result<(), fidl::Error> {
632        self.client.send::<fidl::encoding::EmptyPayload>(
633            (),
634            0x40da7ca487466971,
635            fidl::encoding::DynamicFlags::empty(),
636        )
637    }
638}
639
640#[cfg(target_os = "fuchsia")]
641impl From<ConnectionSynchronousProxy> for zx::NullableHandle {
642    fn from(value: ConnectionSynchronousProxy) -> Self {
643        value.into_channel().into()
644    }
645}
646
647#[cfg(target_os = "fuchsia")]
648impl From<fidl::Channel> for ConnectionSynchronousProxy {
649    fn from(value: fidl::Channel) -> Self {
650        Self::new(value)
651    }
652}
653
654#[cfg(target_os = "fuchsia")]
655impl fidl::endpoints::FromClient for ConnectionSynchronousProxy {
656    type Protocol = ConnectionMarker;
657
658    fn from_client(value: fidl::endpoints::ClientEnd<ConnectionMarker>) -> Self {
659        Self::new(value.into_channel())
660    }
661}
662
663#[derive(Debug, Clone)]
664pub struct ConnectionProxy {
665    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
666}
667
668impl fidl::endpoints::Proxy for ConnectionProxy {
669    type Protocol = ConnectionMarker;
670
671    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
672        Self::new(inner)
673    }
674
675    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
676        self.client.into_channel().map_err(|client| Self { client })
677    }
678
679    fn as_channel(&self) -> &::fidl::AsyncChannel {
680        self.client.as_channel()
681    }
682}
683
684impl ConnectionProxy {
685    /// Create a new Proxy for fuchsia.vsock/Connection.
686    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
687        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
688        Self { client: fidl::client::Client::new(channel, protocol_name) }
689    }
690
691    /// Get a Stream of events from the remote end of the protocol.
692    ///
693    /// # Panics
694    ///
695    /// Panics if the event stream was already taken.
696    pub fn take_event_stream(&self) -> ConnectionEventStream {
697        ConnectionEventStream { event_receiver: self.client.take_event_receiver() }
698    }
699
700    /// Trigger asynchronous shutdown. The underlying channel will be closed
701    /// once shutdown is complete. Shutdown has an implicit barrier as any already
702    /// queued sends will complete, but any additional sends will generate errors
703    pub fn r#shutdown(&self) -> Result<(), fidl::Error> {
704        ConnectionProxyInterface::r#shutdown(self)
705    }
706}
707
708impl ConnectionProxyInterface for ConnectionProxy {
709    fn r#shutdown(&self) -> Result<(), fidl::Error> {
710        self.client.send::<fidl::encoding::EmptyPayload>(
711            (),
712            0x40da7ca487466971,
713            fidl::encoding::DynamicFlags::empty(),
714        )
715    }
716}
717
718pub struct ConnectionEventStream {
719    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
720}
721
722impl std::marker::Unpin for ConnectionEventStream {}
723
724impl futures::stream::FusedStream for ConnectionEventStream {
725    fn is_terminated(&self) -> bool {
726        self.event_receiver.is_terminated()
727    }
728}
729
730impl futures::Stream for ConnectionEventStream {
731    type Item = Result<ConnectionEvent, fidl::Error>;
732
733    fn poll_next(
734        mut self: std::pin::Pin<&mut Self>,
735        cx: &mut std::task::Context<'_>,
736    ) -> std::task::Poll<Option<Self::Item>> {
737        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
738            &mut self.event_receiver,
739            cx
740        )?) {
741            Some(buf) => std::task::Poll::Ready(Some(ConnectionEvent::decode(buf))),
742            None => std::task::Poll::Ready(None),
743        }
744    }
745}
746
747#[derive(Debug)]
748pub enum ConnectionEvent {}
749
750impl ConnectionEvent {
751    /// Decodes a message buffer as a [`ConnectionEvent`].
752    fn decode(
753        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
754    ) -> Result<ConnectionEvent, fidl::Error> {
755        let (bytes, _handles) = buf.split_mut();
756        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
757        debug_assert_eq!(tx_header.tx_id, 0);
758        match tx_header.ordinal {
759            _ => Err(fidl::Error::UnknownOrdinal {
760                ordinal: tx_header.ordinal,
761                protocol_name: <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
762            }),
763        }
764    }
765}
766
767/// A Stream of incoming requests for fuchsia.vsock/Connection.
768pub struct ConnectionRequestStream {
769    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
770    is_terminated: bool,
771}
772
773impl std::marker::Unpin for ConnectionRequestStream {}
774
775impl futures::stream::FusedStream for ConnectionRequestStream {
776    fn is_terminated(&self) -> bool {
777        self.is_terminated
778    }
779}
780
781impl fidl::endpoints::RequestStream for ConnectionRequestStream {
782    type Protocol = ConnectionMarker;
783    type ControlHandle = ConnectionControlHandle;
784
785    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
786        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
787    }
788
789    fn control_handle(&self) -> Self::ControlHandle {
790        ConnectionControlHandle { inner: self.inner.clone() }
791    }
792
793    fn into_inner(
794        self,
795    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
796    {
797        (self.inner, self.is_terminated)
798    }
799
800    fn from_inner(
801        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
802        is_terminated: bool,
803    ) -> Self {
804        Self { inner, is_terminated }
805    }
806}
807
808impl futures::Stream for ConnectionRequestStream {
809    type Item = Result<ConnectionRequest, fidl::Error>;
810
811    fn poll_next(
812        mut self: std::pin::Pin<&mut Self>,
813        cx: &mut std::task::Context<'_>,
814    ) -> std::task::Poll<Option<Self::Item>> {
815        let this = &mut *self;
816        if this.inner.check_shutdown(cx) {
817            this.is_terminated = true;
818            return std::task::Poll::Ready(None);
819        }
820        if this.is_terminated {
821            panic!("polled ConnectionRequestStream after completion");
822        }
823        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
824            |bytes, handles| {
825                match this.inner.channel().read_etc(cx, bytes, handles) {
826                    std::task::Poll::Ready(Ok(())) => {}
827                    std::task::Poll::Pending => return std::task::Poll::Pending,
828                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
829                        this.is_terminated = true;
830                        return std::task::Poll::Ready(None);
831                    }
832                    std::task::Poll::Ready(Err(e)) => {
833                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
834                            e.into(),
835                        ))));
836                    }
837                }
838
839                // A message has been received from the channel
840                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
841
842                std::task::Poll::Ready(Some(match header.ordinal {
843                    0x40da7ca487466971 => {
844                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
845                        let mut req = fidl::new_empty!(
846                            fidl::encoding::EmptyPayload,
847                            fidl::encoding::DefaultFuchsiaResourceDialect
848                        );
849                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
850                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
851                        Ok(ConnectionRequest::Shutdown { control_handle })
852                    }
853                    _ => Err(fidl::Error::UnknownOrdinal {
854                        ordinal: header.ordinal,
855                        protocol_name:
856                            <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
857                    }),
858                }))
859            },
860        )
861    }
862}
863
864/// Interface for manipulating the state of an active connection.
865#[derive(Debug)]
866pub enum ConnectionRequest {
867    /// Trigger asynchronous shutdown. The underlying channel will be closed
868    /// once shutdown is complete. Shutdown has an implicit barrier as any already
869    /// queued sends will complete, but any additional sends will generate errors
870    Shutdown { control_handle: ConnectionControlHandle },
871}
872
873impl ConnectionRequest {
874    #[allow(irrefutable_let_patterns)]
875    pub fn into_shutdown(self) -> Option<(ConnectionControlHandle)> {
876        if let ConnectionRequest::Shutdown { control_handle } = self {
877            Some((control_handle))
878        } else {
879            None
880        }
881    }
882
883    /// Name of the method defined in FIDL
884    pub fn method_name(&self) -> &'static str {
885        match *self {
886            ConnectionRequest::Shutdown { .. } => "shutdown",
887        }
888    }
889}
890
891#[derive(Debug, Clone)]
892pub struct ConnectionControlHandle {
893    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
894}
895
896impl fidl::endpoints::ControlHandle for ConnectionControlHandle {
897    fn shutdown(&self) {
898        self.inner.shutdown()
899    }
900
901    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
902        self.inner.shutdown_with_epitaph(status)
903    }
904
905    fn is_closed(&self) -> bool {
906        self.inner.channel().is_closed()
907    }
908    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
909        self.inner.channel().on_closed()
910    }
911
912    #[cfg(target_os = "fuchsia")]
913    fn signal_peer(
914        &self,
915        clear_mask: zx::Signals,
916        set_mask: zx::Signals,
917    ) -> Result<(), zx_status::Status> {
918        use fidl::Peered;
919        self.inner.channel().signal_peer(clear_mask, set_mask)
920    }
921}
922
923impl ConnectionControlHandle {}
924
925#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
926pub struct ConnectorMarker;
927
928impl fidl::endpoints::ProtocolMarker for ConnectorMarker {
929    type Proxy = ConnectorProxy;
930    type RequestStream = ConnectorRequestStream;
931    #[cfg(target_os = "fuchsia")]
932    type SynchronousProxy = ConnectorSynchronousProxy;
933
934    const DEBUG_NAME: &'static str = "fuchsia.vsock.Connector";
935}
936impl fidl::endpoints::DiscoverableProtocolMarker for ConnectorMarker {}
937pub type ConnectorConnectResult = Result<u32, i32>;
938pub type ConnectorListenResult = Result<(), i32>;
939pub type ConnectorBindResult = Result<(), i32>;
940
941pub trait ConnectorProxyInterface: Send + Sync {
942    type ConnectResponseFut: std::future::Future<Output = Result<ConnectorConnectResult, fidl::Error>>
943        + Send;
944    fn r#connect(
945        &self,
946        remote_cid: u32,
947        remote_port: u32,
948        con: ConnectionTransport,
949    ) -> Self::ConnectResponseFut;
950    type ListenResponseFut: std::future::Future<Output = Result<ConnectorListenResult, fidl::Error>>
951        + Send;
952    fn r#listen(
953        &self,
954        local_port: u32,
955        acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
956    ) -> Self::ListenResponseFut;
957    type BindResponseFut: std::future::Future<Output = Result<ConnectorBindResult, fidl::Error>>
958        + Send;
959    fn r#bind(
960        &self,
961        remote_cid: u32,
962        local_port: u32,
963        listener: fidl::endpoints::ServerEnd<ListenerMarker>,
964    ) -> Self::BindResponseFut;
965    type GetCidResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
966    fn r#get_cid(&self) -> Self::GetCidResponseFut;
967}
968#[derive(Debug)]
969#[cfg(target_os = "fuchsia")]
970pub struct ConnectorSynchronousProxy {
971    client: fidl::client::sync::Client,
972}
973
974#[cfg(target_os = "fuchsia")]
975impl fidl::endpoints::SynchronousProxy for ConnectorSynchronousProxy {
976    type Proxy = ConnectorProxy;
977    type Protocol = ConnectorMarker;
978
979    fn from_channel(inner: fidl::Channel) -> Self {
980        Self::new(inner)
981    }
982
983    fn into_channel(self) -> fidl::Channel {
984        self.client.into_channel()
985    }
986
987    fn as_channel(&self) -> &fidl::Channel {
988        self.client.as_channel()
989    }
990}
991
992#[cfg(target_os = "fuchsia")]
993impl ConnectorSynchronousProxy {
994    pub fn new(channel: fidl::Channel) -> Self {
995        let protocol_name = <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
996        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
997    }
998
999    pub fn into_channel(self) -> fidl::Channel {
1000        self.client.into_channel()
1001    }
1002
1003    /// Waits until an event arrives and returns it. It is safe for other
1004    /// threads to make concurrent requests while waiting for an event.
1005    pub fn wait_for_event(
1006        &self,
1007        deadline: zx::MonotonicInstant,
1008    ) -> Result<ConnectorEvent, fidl::Error> {
1009        ConnectorEvent::decode(self.client.wait_for_event(deadline)?)
1010    }
1011
1012    /// Attempt to establish a connection to the specified remote cid/port pair.
1013    /// No local port is specified as an ephemeral one will automatically be allocated.
1014    pub fn r#connect(
1015        &self,
1016        mut remote_cid: u32,
1017        mut remote_port: u32,
1018        mut con: ConnectionTransport,
1019        ___deadline: zx::MonotonicInstant,
1020    ) -> Result<ConnectorConnectResult, fidl::Error> {
1021        let _response = self.client.send_query::<
1022            ConnectorConnectRequest,
1023            fidl::encoding::ResultType<ConnectorConnectResponse, i32>,
1024        >(
1025            (remote_cid, remote_port, &mut con,),
1026            0xdf55c5e6a6a4117,
1027            fidl::encoding::DynamicFlags::empty(),
1028            ___deadline,
1029        )?;
1030        Ok(_response.map(|x| x.local_port))
1031    }
1032
1033    /// Registers a listener for a local port. There can only be one listener for
1034    /// a single port at a time.
1035    pub fn r#listen(
1036        &self,
1037        mut local_port: u32,
1038        mut acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
1039        ___deadline: zx::MonotonicInstant,
1040    ) -> Result<ConnectorListenResult, fidl::Error> {
1041        let _response = self.client.send_query::<
1042            ConnectorListenRequest,
1043            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1044        >(
1045            (local_port, acceptor,),
1046            0x17c1371908bacf73,
1047            fidl::encoding::DynamicFlags::empty(),
1048            ___deadline,
1049        )?;
1050        Ok(_response.map(|x| x))
1051    }
1052
1053    /// Registers a listener for a local port. There can only be one listener for
1054    /// a single port at a time.
1055    pub fn r#bind(
1056        &self,
1057        mut remote_cid: u32,
1058        mut local_port: u32,
1059        mut listener: fidl::endpoints::ServerEnd<ListenerMarker>,
1060        ___deadline: zx::MonotonicInstant,
1061    ) -> Result<ConnectorBindResult, fidl::Error> {
1062        let _response = self.client.send_query::<
1063            ConnectorBindRequest,
1064            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1065        >(
1066            (remote_cid, local_port, listener,),
1067            0x6e50cd8c895f2e0,
1068            fidl::encoding::DynamicFlags::empty(),
1069            ___deadline,
1070        )?;
1071        Ok(_response.map(|x| x))
1072    }
1073
1074    /// Query the current context id of the system. The local CID is should not
1075    /// necessary in interactions with the same device; instead you may pass
1076    /// `VMADDR_CID_LOCAL`, which will alias to local CID this returns. The cid returned
1077    /// by this method is useful for debugging or if you have some other communication
1078    /// channel to a different host and you would like to send them your CID to then
1079    /// establish a vsock connection on.
1080    pub fn r#get_cid(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
1081        let _response =
1082            self.client.send_query::<fidl::encoding::EmptyPayload, ConnectorGetCidResponse>(
1083                (),
1084                0x60b3cfa0b40bdd7c,
1085                fidl::encoding::DynamicFlags::empty(),
1086                ___deadline,
1087            )?;
1088        Ok(_response.local_cid)
1089    }
1090}
1091
1092#[cfg(target_os = "fuchsia")]
1093impl From<ConnectorSynchronousProxy> for zx::NullableHandle {
1094    fn from(value: ConnectorSynchronousProxy) -> Self {
1095        value.into_channel().into()
1096    }
1097}
1098
1099#[cfg(target_os = "fuchsia")]
1100impl From<fidl::Channel> for ConnectorSynchronousProxy {
1101    fn from(value: fidl::Channel) -> Self {
1102        Self::new(value)
1103    }
1104}
1105
1106#[cfg(target_os = "fuchsia")]
1107impl fidl::endpoints::FromClient for ConnectorSynchronousProxy {
1108    type Protocol = ConnectorMarker;
1109
1110    fn from_client(value: fidl::endpoints::ClientEnd<ConnectorMarker>) -> Self {
1111        Self::new(value.into_channel())
1112    }
1113}
1114
1115#[derive(Debug, Clone)]
1116pub struct ConnectorProxy {
1117    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1118}
1119
1120impl fidl::endpoints::Proxy for ConnectorProxy {
1121    type Protocol = ConnectorMarker;
1122
1123    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1124        Self::new(inner)
1125    }
1126
1127    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1128        self.client.into_channel().map_err(|client| Self { client })
1129    }
1130
1131    fn as_channel(&self) -> &::fidl::AsyncChannel {
1132        self.client.as_channel()
1133    }
1134}
1135
1136impl ConnectorProxy {
1137    /// Create a new Proxy for fuchsia.vsock/Connector.
1138    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1139        let protocol_name = <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1140        Self { client: fidl::client::Client::new(channel, protocol_name) }
1141    }
1142
1143    /// Get a Stream of events from the remote end of the protocol.
1144    ///
1145    /// # Panics
1146    ///
1147    /// Panics if the event stream was already taken.
1148    pub fn take_event_stream(&self) -> ConnectorEventStream {
1149        ConnectorEventStream { event_receiver: self.client.take_event_receiver() }
1150    }
1151
1152    /// Attempt to establish a connection to the specified remote cid/port pair.
1153    /// No local port is specified as an ephemeral one will automatically be allocated.
1154    pub fn r#connect(
1155        &self,
1156        mut remote_cid: u32,
1157        mut remote_port: u32,
1158        mut con: ConnectionTransport,
1159    ) -> fidl::client::QueryResponseFut<
1160        ConnectorConnectResult,
1161        fidl::encoding::DefaultFuchsiaResourceDialect,
1162    > {
1163        ConnectorProxyInterface::r#connect(self, remote_cid, remote_port, con)
1164    }
1165
1166    /// Registers a listener for a local port. There can only be one listener for
1167    /// a single port at a time.
1168    pub fn r#listen(
1169        &self,
1170        mut local_port: u32,
1171        mut acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
1172    ) -> fidl::client::QueryResponseFut<
1173        ConnectorListenResult,
1174        fidl::encoding::DefaultFuchsiaResourceDialect,
1175    > {
1176        ConnectorProxyInterface::r#listen(self, local_port, acceptor)
1177    }
1178
1179    /// Registers a listener for a local port. There can only be one listener for
1180    /// a single port at a time.
1181    pub fn r#bind(
1182        &self,
1183        mut remote_cid: u32,
1184        mut local_port: u32,
1185        mut listener: fidl::endpoints::ServerEnd<ListenerMarker>,
1186    ) -> fidl::client::QueryResponseFut<
1187        ConnectorBindResult,
1188        fidl::encoding::DefaultFuchsiaResourceDialect,
1189    > {
1190        ConnectorProxyInterface::r#bind(self, remote_cid, local_port, listener)
1191    }
1192
1193    /// Query the current context id of the system. The local CID is should not
1194    /// necessary in interactions with the same device; instead you may pass
1195    /// `VMADDR_CID_LOCAL`, which will alias to local CID this returns. The cid returned
1196    /// by this method is useful for debugging or if you have some other communication
1197    /// channel to a different host and you would like to send them your CID to then
1198    /// establish a vsock connection on.
1199    pub fn r#get_cid(
1200        &self,
1201    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
1202        ConnectorProxyInterface::r#get_cid(self)
1203    }
1204}
1205
1206impl ConnectorProxyInterface for ConnectorProxy {
1207    type ConnectResponseFut = fidl::client::QueryResponseFut<
1208        ConnectorConnectResult,
1209        fidl::encoding::DefaultFuchsiaResourceDialect,
1210    >;
1211    fn r#connect(
1212        &self,
1213        mut remote_cid: u32,
1214        mut remote_port: u32,
1215        mut con: ConnectionTransport,
1216    ) -> Self::ConnectResponseFut {
1217        fn _decode(
1218            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1219        ) -> Result<ConnectorConnectResult, fidl::Error> {
1220            let _response = fidl::client::decode_transaction_body::<
1221                fidl::encoding::ResultType<ConnectorConnectResponse, i32>,
1222                fidl::encoding::DefaultFuchsiaResourceDialect,
1223                0xdf55c5e6a6a4117,
1224            >(_buf?)?;
1225            Ok(_response.map(|x| x.local_port))
1226        }
1227        self.client.send_query_and_decode::<ConnectorConnectRequest, ConnectorConnectResult>(
1228            (remote_cid, remote_port, &mut con),
1229            0xdf55c5e6a6a4117,
1230            fidl::encoding::DynamicFlags::empty(),
1231            _decode,
1232        )
1233    }
1234
1235    type ListenResponseFut = fidl::client::QueryResponseFut<
1236        ConnectorListenResult,
1237        fidl::encoding::DefaultFuchsiaResourceDialect,
1238    >;
1239    fn r#listen(
1240        &self,
1241        mut local_port: u32,
1242        mut acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
1243    ) -> Self::ListenResponseFut {
1244        fn _decode(
1245            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1246        ) -> Result<ConnectorListenResult, fidl::Error> {
1247            let _response = fidl::client::decode_transaction_body::<
1248                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1249                fidl::encoding::DefaultFuchsiaResourceDialect,
1250                0x17c1371908bacf73,
1251            >(_buf?)?;
1252            Ok(_response.map(|x| x))
1253        }
1254        self.client.send_query_and_decode::<ConnectorListenRequest, ConnectorListenResult>(
1255            (local_port, acceptor),
1256            0x17c1371908bacf73,
1257            fidl::encoding::DynamicFlags::empty(),
1258            _decode,
1259        )
1260    }
1261
1262    type BindResponseFut = fidl::client::QueryResponseFut<
1263        ConnectorBindResult,
1264        fidl::encoding::DefaultFuchsiaResourceDialect,
1265    >;
1266    fn r#bind(
1267        &self,
1268        mut remote_cid: u32,
1269        mut local_port: u32,
1270        mut listener: fidl::endpoints::ServerEnd<ListenerMarker>,
1271    ) -> Self::BindResponseFut {
1272        fn _decode(
1273            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1274        ) -> Result<ConnectorBindResult, fidl::Error> {
1275            let _response = fidl::client::decode_transaction_body::<
1276                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1277                fidl::encoding::DefaultFuchsiaResourceDialect,
1278                0x6e50cd8c895f2e0,
1279            >(_buf?)?;
1280            Ok(_response.map(|x| x))
1281        }
1282        self.client.send_query_and_decode::<ConnectorBindRequest, ConnectorBindResult>(
1283            (remote_cid, local_port, listener),
1284            0x6e50cd8c895f2e0,
1285            fidl::encoding::DynamicFlags::empty(),
1286            _decode,
1287        )
1288    }
1289
1290    type GetCidResponseFut =
1291        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1292    fn r#get_cid(&self) -> Self::GetCidResponseFut {
1293        fn _decode(
1294            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1295        ) -> Result<u32, fidl::Error> {
1296            let _response = fidl::client::decode_transaction_body::<
1297                ConnectorGetCidResponse,
1298                fidl::encoding::DefaultFuchsiaResourceDialect,
1299                0x60b3cfa0b40bdd7c,
1300            >(_buf?)?;
1301            Ok(_response.local_cid)
1302        }
1303        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
1304            (),
1305            0x60b3cfa0b40bdd7c,
1306            fidl::encoding::DynamicFlags::empty(),
1307            _decode,
1308        )
1309    }
1310}
1311
1312pub struct ConnectorEventStream {
1313    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1314}
1315
1316impl std::marker::Unpin for ConnectorEventStream {}
1317
1318impl futures::stream::FusedStream for ConnectorEventStream {
1319    fn is_terminated(&self) -> bool {
1320        self.event_receiver.is_terminated()
1321    }
1322}
1323
1324impl futures::Stream for ConnectorEventStream {
1325    type Item = Result<ConnectorEvent, fidl::Error>;
1326
1327    fn poll_next(
1328        mut self: std::pin::Pin<&mut Self>,
1329        cx: &mut std::task::Context<'_>,
1330    ) -> std::task::Poll<Option<Self::Item>> {
1331        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1332            &mut self.event_receiver,
1333            cx
1334        )?) {
1335            Some(buf) => std::task::Poll::Ready(Some(ConnectorEvent::decode(buf))),
1336            None => std::task::Poll::Ready(None),
1337        }
1338    }
1339}
1340
1341#[derive(Debug)]
1342pub enum ConnectorEvent {}
1343
1344impl ConnectorEvent {
1345    /// Decodes a message buffer as a [`ConnectorEvent`].
1346    fn decode(
1347        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1348    ) -> Result<ConnectorEvent, fidl::Error> {
1349        let (bytes, _handles) = buf.split_mut();
1350        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1351        debug_assert_eq!(tx_header.tx_id, 0);
1352        match tx_header.ordinal {
1353            _ => Err(fidl::Error::UnknownOrdinal {
1354                ordinal: tx_header.ordinal,
1355                protocol_name: <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1356            }),
1357        }
1358    }
1359}
1360
1361/// A Stream of incoming requests for fuchsia.vsock/Connector.
1362pub struct ConnectorRequestStream {
1363    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1364    is_terminated: bool,
1365}
1366
1367impl std::marker::Unpin for ConnectorRequestStream {}
1368
1369impl futures::stream::FusedStream for ConnectorRequestStream {
1370    fn is_terminated(&self) -> bool {
1371        self.is_terminated
1372    }
1373}
1374
1375impl fidl::endpoints::RequestStream for ConnectorRequestStream {
1376    type Protocol = ConnectorMarker;
1377    type ControlHandle = ConnectorControlHandle;
1378
1379    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1380        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1381    }
1382
1383    fn control_handle(&self) -> Self::ControlHandle {
1384        ConnectorControlHandle { inner: self.inner.clone() }
1385    }
1386
1387    fn into_inner(
1388        self,
1389    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1390    {
1391        (self.inner, self.is_terminated)
1392    }
1393
1394    fn from_inner(
1395        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1396        is_terminated: bool,
1397    ) -> Self {
1398        Self { inner, is_terminated }
1399    }
1400}
1401
1402impl futures::Stream for ConnectorRequestStream {
1403    type Item = Result<ConnectorRequest, fidl::Error>;
1404
1405    fn poll_next(
1406        mut self: std::pin::Pin<&mut Self>,
1407        cx: &mut std::task::Context<'_>,
1408    ) -> std::task::Poll<Option<Self::Item>> {
1409        let this = &mut *self;
1410        if this.inner.check_shutdown(cx) {
1411            this.is_terminated = true;
1412            return std::task::Poll::Ready(None);
1413        }
1414        if this.is_terminated {
1415            panic!("polled ConnectorRequestStream after completion");
1416        }
1417        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1418            |bytes, handles| {
1419                match this.inner.channel().read_etc(cx, bytes, handles) {
1420                    std::task::Poll::Ready(Ok(())) => {}
1421                    std::task::Poll::Pending => return std::task::Poll::Pending,
1422                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1423                        this.is_terminated = true;
1424                        return std::task::Poll::Ready(None);
1425                    }
1426                    std::task::Poll::Ready(Err(e)) => {
1427                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1428                            e.into(),
1429                        ))));
1430                    }
1431                }
1432
1433                // A message has been received from the channel
1434                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1435
1436                std::task::Poll::Ready(Some(match header.ordinal {
1437                    0xdf55c5e6a6a4117 => {
1438                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1439                        let mut req = fidl::new_empty!(
1440                            ConnectorConnectRequest,
1441                            fidl::encoding::DefaultFuchsiaResourceDialect
1442                        );
1443                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1444                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
1445                        Ok(ConnectorRequest::Connect {
1446                            remote_cid: req.remote_cid,
1447                            remote_port: req.remote_port,
1448                            con: req.con,
1449
1450                            responder: ConnectorConnectResponder {
1451                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1452                                tx_id: header.tx_id,
1453                            },
1454                        })
1455                    }
1456                    0x17c1371908bacf73 => {
1457                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1458                        let mut req = fidl::new_empty!(
1459                            ConnectorListenRequest,
1460                            fidl::encoding::DefaultFuchsiaResourceDialect
1461                        );
1462                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorListenRequest>(&header, _body_bytes, handles, &mut req)?;
1463                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
1464                        Ok(ConnectorRequest::Listen {
1465                            local_port: req.local_port,
1466                            acceptor: req.acceptor,
1467
1468                            responder: ConnectorListenResponder {
1469                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1470                                tx_id: header.tx_id,
1471                            },
1472                        })
1473                    }
1474                    0x6e50cd8c895f2e0 => {
1475                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1476                        let mut req = fidl::new_empty!(
1477                            ConnectorBindRequest,
1478                            fidl::encoding::DefaultFuchsiaResourceDialect
1479                        );
1480                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorBindRequest>(&header, _body_bytes, handles, &mut req)?;
1481                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
1482                        Ok(ConnectorRequest::Bind {
1483                            remote_cid: req.remote_cid,
1484                            local_port: req.local_port,
1485                            listener: req.listener,
1486
1487                            responder: ConnectorBindResponder {
1488                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1489                                tx_id: header.tx_id,
1490                            },
1491                        })
1492                    }
1493                    0x60b3cfa0b40bdd7c => {
1494                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1495                        let mut req = fidl::new_empty!(
1496                            fidl::encoding::EmptyPayload,
1497                            fidl::encoding::DefaultFuchsiaResourceDialect
1498                        );
1499                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1500                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
1501                        Ok(ConnectorRequest::GetCid {
1502                            responder: ConnectorGetCidResponder {
1503                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1504                                tx_id: header.tx_id,
1505                            },
1506                        })
1507                    }
1508                    _ => Err(fidl::Error::UnknownOrdinal {
1509                        ordinal: header.ordinal,
1510                        protocol_name:
1511                            <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1512                    }),
1513                }))
1514            },
1515        )
1516    }
1517}
1518
1519/// Exposed by a service that can act as a bridge to the underlying vsock driver and
1520/// provides the ability for listeners to be multiplexed by port and manages dynamic
1521/// port allocation for outbound connections.
1522#[derive(Debug)]
1523pub enum ConnectorRequest {
1524    /// Attempt to establish a connection to the specified remote cid/port pair.
1525    /// No local port is specified as an ephemeral one will automatically be allocated.
1526    Connect {
1527        remote_cid: u32,
1528        remote_port: u32,
1529        con: ConnectionTransport,
1530        responder: ConnectorConnectResponder,
1531    },
1532    /// Registers a listener for a local port. There can only be one listener for
1533    /// a single port at a time.
1534    Listen {
1535        local_port: u32,
1536        acceptor: fidl::endpoints::ClientEnd<AcceptorMarker>,
1537        responder: ConnectorListenResponder,
1538    },
1539    /// Registers a listener for a local port. There can only be one listener for
1540    /// a single port at a time.
1541    Bind {
1542        remote_cid: u32,
1543        local_port: u32,
1544        listener: fidl::endpoints::ServerEnd<ListenerMarker>,
1545        responder: ConnectorBindResponder,
1546    },
1547    /// Query the current context id of the system. The local CID is should not
1548    /// necessary in interactions with the same device; instead you may pass
1549    /// `VMADDR_CID_LOCAL`, which will alias to local CID this returns. The cid returned
1550    /// by this method is useful for debugging or if you have some other communication
1551    /// channel to a different host and you would like to send them your CID to then
1552    /// establish a vsock connection on.
1553    GetCid { responder: ConnectorGetCidResponder },
1554}
1555
1556impl ConnectorRequest {
1557    #[allow(irrefutable_let_patterns)]
1558    pub fn into_connect(
1559        self,
1560    ) -> Option<(u32, u32, ConnectionTransport, ConnectorConnectResponder)> {
1561        if let ConnectorRequest::Connect { remote_cid, remote_port, con, responder } = self {
1562            Some((remote_cid, remote_port, con, responder))
1563        } else {
1564            None
1565        }
1566    }
1567
1568    #[allow(irrefutable_let_patterns)]
1569    pub fn into_listen(
1570        self,
1571    ) -> Option<(u32, fidl::endpoints::ClientEnd<AcceptorMarker>, ConnectorListenResponder)> {
1572        if let ConnectorRequest::Listen { local_port, acceptor, responder } = self {
1573            Some((local_port, acceptor, responder))
1574        } else {
1575            None
1576        }
1577    }
1578
1579    #[allow(irrefutable_let_patterns)]
1580    pub fn into_bind(
1581        self,
1582    ) -> Option<(u32, u32, fidl::endpoints::ServerEnd<ListenerMarker>, ConnectorBindResponder)>
1583    {
1584        if let ConnectorRequest::Bind { remote_cid, local_port, listener, responder } = self {
1585            Some((remote_cid, local_port, listener, responder))
1586        } else {
1587            None
1588        }
1589    }
1590
1591    #[allow(irrefutable_let_patterns)]
1592    pub fn into_get_cid(self) -> Option<(ConnectorGetCidResponder)> {
1593        if let ConnectorRequest::GetCid { responder } = self { Some((responder)) } else { None }
1594    }
1595
1596    /// Name of the method defined in FIDL
1597    pub fn method_name(&self) -> &'static str {
1598        match *self {
1599            ConnectorRequest::Connect { .. } => "connect",
1600            ConnectorRequest::Listen { .. } => "listen",
1601            ConnectorRequest::Bind { .. } => "bind",
1602            ConnectorRequest::GetCid { .. } => "get_cid",
1603        }
1604    }
1605}
1606
1607#[derive(Debug, Clone)]
1608pub struct ConnectorControlHandle {
1609    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1610}
1611
1612impl fidl::endpoints::ControlHandle for ConnectorControlHandle {
1613    fn shutdown(&self) {
1614        self.inner.shutdown()
1615    }
1616
1617    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1618        self.inner.shutdown_with_epitaph(status)
1619    }
1620
1621    fn is_closed(&self) -> bool {
1622        self.inner.channel().is_closed()
1623    }
1624    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1625        self.inner.channel().on_closed()
1626    }
1627
1628    #[cfg(target_os = "fuchsia")]
1629    fn signal_peer(
1630        &self,
1631        clear_mask: zx::Signals,
1632        set_mask: zx::Signals,
1633    ) -> Result<(), zx_status::Status> {
1634        use fidl::Peered;
1635        self.inner.channel().signal_peer(clear_mask, set_mask)
1636    }
1637}
1638
1639impl ConnectorControlHandle {}
1640
1641#[must_use = "FIDL methods require a response to be sent"]
1642#[derive(Debug)]
1643pub struct ConnectorConnectResponder {
1644    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1645    tx_id: u32,
1646}
1647
1648/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1649/// if the responder is dropped without sending a response, so that the client
1650/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1651impl std::ops::Drop for ConnectorConnectResponder {
1652    fn drop(&mut self) {
1653        self.control_handle.shutdown();
1654        // Safety: drops once, never accessed again
1655        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1656    }
1657}
1658
1659impl fidl::endpoints::Responder for ConnectorConnectResponder {
1660    type ControlHandle = ConnectorControlHandle;
1661
1662    fn control_handle(&self) -> &ConnectorControlHandle {
1663        &self.control_handle
1664    }
1665
1666    fn drop_without_shutdown(mut self) {
1667        // Safety: drops once, never accessed again due to mem::forget
1668        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1669        // Prevent Drop from running (which would shut down the channel)
1670        std::mem::forget(self);
1671    }
1672}
1673
1674impl ConnectorConnectResponder {
1675    /// Sends a response to the FIDL transaction.
1676    ///
1677    /// Sets the channel to shutdown if an error occurs.
1678    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1679        let _result = self.send_raw(result);
1680        if _result.is_err() {
1681            self.control_handle.shutdown();
1682        }
1683        self.drop_without_shutdown();
1684        _result
1685    }
1686
1687    /// Similar to "send" but does not shutdown the channel if an error occurs.
1688    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1689        let _result = self.send_raw(result);
1690        self.drop_without_shutdown();
1691        _result
1692    }
1693
1694    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1695        self.control_handle.inner.send::<fidl::encoding::ResultType<ConnectorConnectResponse, i32>>(
1696            result.map(|local_port| (local_port,)),
1697            self.tx_id,
1698            0xdf55c5e6a6a4117,
1699            fidl::encoding::DynamicFlags::empty(),
1700        )
1701    }
1702}
1703
1704#[must_use = "FIDL methods require a response to be sent"]
1705#[derive(Debug)]
1706pub struct ConnectorListenResponder {
1707    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1708    tx_id: u32,
1709}
1710
1711/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1712/// if the responder is dropped without sending a response, so that the client
1713/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1714impl std::ops::Drop for ConnectorListenResponder {
1715    fn drop(&mut self) {
1716        self.control_handle.shutdown();
1717        // Safety: drops once, never accessed again
1718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1719    }
1720}
1721
1722impl fidl::endpoints::Responder for ConnectorListenResponder {
1723    type ControlHandle = ConnectorControlHandle;
1724
1725    fn control_handle(&self) -> &ConnectorControlHandle {
1726        &self.control_handle
1727    }
1728
1729    fn drop_without_shutdown(mut self) {
1730        // Safety: drops once, never accessed again due to mem::forget
1731        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1732        // Prevent Drop from running (which would shut down the channel)
1733        std::mem::forget(self);
1734    }
1735}
1736
1737impl ConnectorListenResponder {
1738    /// Sends a response to the FIDL transaction.
1739    ///
1740    /// Sets the channel to shutdown if an error occurs.
1741    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1742        let _result = self.send_raw(result);
1743        if _result.is_err() {
1744            self.control_handle.shutdown();
1745        }
1746        self.drop_without_shutdown();
1747        _result
1748    }
1749
1750    /// Similar to "send" but does not shutdown the channel if an error occurs.
1751    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1752        let _result = self.send_raw(result);
1753        self.drop_without_shutdown();
1754        _result
1755    }
1756
1757    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1758        self.control_handle
1759            .inner
1760            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1761                result,
1762                self.tx_id,
1763                0x17c1371908bacf73,
1764                fidl::encoding::DynamicFlags::empty(),
1765            )
1766    }
1767}
1768
1769#[must_use = "FIDL methods require a response to be sent"]
1770#[derive(Debug)]
1771pub struct ConnectorBindResponder {
1772    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1773    tx_id: u32,
1774}
1775
1776/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1777/// if the responder is dropped without sending a response, so that the client
1778/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1779impl std::ops::Drop for ConnectorBindResponder {
1780    fn drop(&mut self) {
1781        self.control_handle.shutdown();
1782        // Safety: drops once, never accessed again
1783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1784    }
1785}
1786
1787impl fidl::endpoints::Responder for ConnectorBindResponder {
1788    type ControlHandle = ConnectorControlHandle;
1789
1790    fn control_handle(&self) -> &ConnectorControlHandle {
1791        &self.control_handle
1792    }
1793
1794    fn drop_without_shutdown(mut self) {
1795        // Safety: drops once, never accessed again due to mem::forget
1796        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1797        // Prevent Drop from running (which would shut down the channel)
1798        std::mem::forget(self);
1799    }
1800}
1801
1802impl ConnectorBindResponder {
1803    /// Sends a response to the FIDL transaction.
1804    ///
1805    /// Sets the channel to shutdown if an error occurs.
1806    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1807        let _result = self.send_raw(result);
1808        if _result.is_err() {
1809            self.control_handle.shutdown();
1810        }
1811        self.drop_without_shutdown();
1812        _result
1813    }
1814
1815    /// Similar to "send" but does not shutdown the channel if an error occurs.
1816    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1817        let _result = self.send_raw(result);
1818        self.drop_without_shutdown();
1819        _result
1820    }
1821
1822    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1823        self.control_handle
1824            .inner
1825            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1826                result,
1827                self.tx_id,
1828                0x6e50cd8c895f2e0,
1829                fidl::encoding::DynamicFlags::empty(),
1830            )
1831    }
1832}
1833
1834#[must_use = "FIDL methods require a response to be sent"]
1835#[derive(Debug)]
1836pub struct ConnectorGetCidResponder {
1837    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
1838    tx_id: u32,
1839}
1840
1841/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
1842/// if the responder is dropped without sending a response, so that the client
1843/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1844impl std::ops::Drop for ConnectorGetCidResponder {
1845    fn drop(&mut self) {
1846        self.control_handle.shutdown();
1847        // Safety: drops once, never accessed again
1848        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1849    }
1850}
1851
1852impl fidl::endpoints::Responder for ConnectorGetCidResponder {
1853    type ControlHandle = ConnectorControlHandle;
1854
1855    fn control_handle(&self) -> &ConnectorControlHandle {
1856        &self.control_handle
1857    }
1858
1859    fn drop_without_shutdown(mut self) {
1860        // Safety: drops once, never accessed again due to mem::forget
1861        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1862        // Prevent Drop from running (which would shut down the channel)
1863        std::mem::forget(self);
1864    }
1865}
1866
1867impl ConnectorGetCidResponder {
1868    /// Sends a response to the FIDL transaction.
1869    ///
1870    /// Sets the channel to shutdown if an error occurs.
1871    pub fn send(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1872        let _result = self.send_raw(local_cid);
1873        if _result.is_err() {
1874            self.control_handle.shutdown();
1875        }
1876        self.drop_without_shutdown();
1877        _result
1878    }
1879
1880    /// Similar to "send" but does not shutdown the channel if an error occurs.
1881    pub fn send_no_shutdown_on_err(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1882        let _result = self.send_raw(local_cid);
1883        self.drop_without_shutdown();
1884        _result
1885    }
1886
1887    fn send_raw(&self, mut local_cid: u32) -> Result<(), fidl::Error> {
1888        self.control_handle.inner.send::<ConnectorGetCidResponse>(
1889            (local_cid,),
1890            self.tx_id,
1891            0x60b3cfa0b40bdd7c,
1892            fidl::encoding::DynamicFlags::empty(),
1893        )
1894    }
1895}
1896
1897#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1898pub struct ListenerMarker;
1899
1900impl fidl::endpoints::ProtocolMarker for ListenerMarker {
1901    type Proxy = ListenerProxy;
1902    type RequestStream = ListenerRequestStream;
1903    #[cfg(target_os = "fuchsia")]
1904    type SynchronousProxy = ListenerSynchronousProxy;
1905
1906    const DEBUG_NAME: &'static str = "(anonymous) Listener";
1907}
1908pub type ListenerListenResult = Result<(), i32>;
1909pub type ListenerAcceptResult = Result<fidl_fuchsia_hardware_vsock::Addr, i32>;
1910
1911pub trait ListenerProxyInterface: Send + Sync {
1912    type ListenResponseFut: std::future::Future<Output = Result<ListenerListenResult, fidl::Error>>
1913        + Send;
1914    fn r#listen(&self, backlog: u32) -> Self::ListenResponseFut;
1915    type AcceptResponseFut: std::future::Future<Output = Result<ListenerAcceptResult, fidl::Error>>
1916        + Send;
1917    fn r#accept(&self, con: ConnectionTransport) -> Self::AcceptResponseFut;
1918}
1919#[derive(Debug)]
1920#[cfg(target_os = "fuchsia")]
1921pub struct ListenerSynchronousProxy {
1922    client: fidl::client::sync::Client,
1923}
1924
1925#[cfg(target_os = "fuchsia")]
1926impl fidl::endpoints::SynchronousProxy for ListenerSynchronousProxy {
1927    type Proxy = ListenerProxy;
1928    type Protocol = ListenerMarker;
1929
1930    fn from_channel(inner: fidl::Channel) -> Self {
1931        Self::new(inner)
1932    }
1933
1934    fn into_channel(self) -> fidl::Channel {
1935        self.client.into_channel()
1936    }
1937
1938    fn as_channel(&self) -> &fidl::Channel {
1939        self.client.as_channel()
1940    }
1941}
1942
1943#[cfg(target_os = "fuchsia")]
1944impl ListenerSynchronousProxy {
1945    pub fn new(channel: fidl::Channel) -> Self {
1946        let protocol_name = <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1947        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1948    }
1949
1950    pub fn into_channel(self) -> fidl::Channel {
1951        self.client.into_channel()
1952    }
1953
1954    /// Waits until an event arrives and returns it. It is safe for other
1955    /// threads to make concurrent requests while waiting for an event.
1956    pub fn wait_for_event(
1957        &self,
1958        deadline: zx::MonotonicInstant,
1959    ) -> Result<ListenerEvent, fidl::Error> {
1960        ListenerEvent::decode(self.client.wait_for_event(deadline)?)
1961    }
1962
1963    /// Registers a listener for a local port. There can only be one listener for
1964    /// a single port at a time. The channel will have `SIGNAL_STREAM_INCOMING` asserted
1965    /// by the server when there is a connection ready to accept.
1966    pub fn r#listen(
1967        &self,
1968        mut backlog: u32,
1969        ___deadline: zx::MonotonicInstant,
1970    ) -> Result<ListenerListenResult, fidl::Error> {
1971        let _response = self.client.send_query::<
1972            ListenerListenRequest,
1973            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1974        >(
1975            (backlog,),
1976            0x53042f6a15d94464,
1977            fidl::encoding::DynamicFlags::empty(),
1978            ___deadline,
1979        )?;
1980        Ok(_response.map(|x| x))
1981    }
1982
1983    /// Accept a pending connection from the queue after `Listen` was invoked and
1984    /// `SIGNAL_STREAM_INCOMING` was signaled.
1985    pub fn r#accept(
1986        &self,
1987        mut con: ConnectionTransport,
1988        ___deadline: zx::MonotonicInstant,
1989    ) -> Result<ListenerAcceptResult, fidl::Error> {
1990        let _response = self.client.send_query::<
1991            ListenerAcceptRequest,
1992            fidl::encoding::ResultType<ListenerAcceptResponse, i32>,
1993        >(
1994            (&mut con,),
1995            0x4b71e6389d92d322,
1996            fidl::encoding::DynamicFlags::empty(),
1997            ___deadline,
1998        )?;
1999        Ok(_response.map(|x| x.addr))
2000    }
2001}
2002
2003#[cfg(target_os = "fuchsia")]
2004impl From<ListenerSynchronousProxy> for zx::NullableHandle {
2005    fn from(value: ListenerSynchronousProxy) -> Self {
2006        value.into_channel().into()
2007    }
2008}
2009
2010#[cfg(target_os = "fuchsia")]
2011impl From<fidl::Channel> for ListenerSynchronousProxy {
2012    fn from(value: fidl::Channel) -> Self {
2013        Self::new(value)
2014    }
2015}
2016
2017#[cfg(target_os = "fuchsia")]
2018impl fidl::endpoints::FromClient for ListenerSynchronousProxy {
2019    type Protocol = ListenerMarker;
2020
2021    fn from_client(value: fidl::endpoints::ClientEnd<ListenerMarker>) -> Self {
2022        Self::new(value.into_channel())
2023    }
2024}
2025
2026#[derive(Debug, Clone)]
2027pub struct ListenerProxy {
2028    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2029}
2030
2031impl fidl::endpoints::Proxy for ListenerProxy {
2032    type Protocol = ListenerMarker;
2033
2034    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2035        Self::new(inner)
2036    }
2037
2038    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2039        self.client.into_channel().map_err(|client| Self { client })
2040    }
2041
2042    fn as_channel(&self) -> &::fidl::AsyncChannel {
2043        self.client.as_channel()
2044    }
2045}
2046
2047impl ListenerProxy {
2048    /// Create a new Proxy for fuchsia.vsock/Listener.
2049    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2050        let protocol_name = <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2051        Self { client: fidl::client::Client::new(channel, protocol_name) }
2052    }
2053
2054    /// Get a Stream of events from the remote end of the protocol.
2055    ///
2056    /// # Panics
2057    ///
2058    /// Panics if the event stream was already taken.
2059    pub fn take_event_stream(&self) -> ListenerEventStream {
2060        ListenerEventStream { event_receiver: self.client.take_event_receiver() }
2061    }
2062
2063    /// Registers a listener for a local port. There can only be one listener for
2064    /// a single port at a time. The channel will have `SIGNAL_STREAM_INCOMING` asserted
2065    /// by the server when there is a connection ready to accept.
2066    pub fn r#listen(
2067        &self,
2068        mut backlog: u32,
2069    ) -> fidl::client::QueryResponseFut<
2070        ListenerListenResult,
2071        fidl::encoding::DefaultFuchsiaResourceDialect,
2072    > {
2073        ListenerProxyInterface::r#listen(self, backlog)
2074    }
2075
2076    /// Accept a pending connection from the queue after `Listen` was invoked and
2077    /// `SIGNAL_STREAM_INCOMING` was signaled.
2078    pub fn r#accept(
2079        &self,
2080        mut con: ConnectionTransport,
2081    ) -> fidl::client::QueryResponseFut<
2082        ListenerAcceptResult,
2083        fidl::encoding::DefaultFuchsiaResourceDialect,
2084    > {
2085        ListenerProxyInterface::r#accept(self, con)
2086    }
2087}
2088
2089impl ListenerProxyInterface for ListenerProxy {
2090    type ListenResponseFut = fidl::client::QueryResponseFut<
2091        ListenerListenResult,
2092        fidl::encoding::DefaultFuchsiaResourceDialect,
2093    >;
2094    fn r#listen(&self, mut backlog: u32) -> Self::ListenResponseFut {
2095        fn _decode(
2096            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2097        ) -> Result<ListenerListenResult, fidl::Error> {
2098            let _response = fidl::client::decode_transaction_body::<
2099                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2100                fidl::encoding::DefaultFuchsiaResourceDialect,
2101                0x53042f6a15d94464,
2102            >(_buf?)?;
2103            Ok(_response.map(|x| x))
2104        }
2105        self.client.send_query_and_decode::<ListenerListenRequest, ListenerListenResult>(
2106            (backlog,),
2107            0x53042f6a15d94464,
2108            fidl::encoding::DynamicFlags::empty(),
2109            _decode,
2110        )
2111    }
2112
2113    type AcceptResponseFut = fidl::client::QueryResponseFut<
2114        ListenerAcceptResult,
2115        fidl::encoding::DefaultFuchsiaResourceDialect,
2116    >;
2117    fn r#accept(&self, mut con: ConnectionTransport) -> Self::AcceptResponseFut {
2118        fn _decode(
2119            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2120        ) -> Result<ListenerAcceptResult, fidl::Error> {
2121            let _response = fidl::client::decode_transaction_body::<
2122                fidl::encoding::ResultType<ListenerAcceptResponse, i32>,
2123                fidl::encoding::DefaultFuchsiaResourceDialect,
2124                0x4b71e6389d92d322,
2125            >(_buf?)?;
2126            Ok(_response.map(|x| x.addr))
2127        }
2128        self.client.send_query_and_decode::<ListenerAcceptRequest, ListenerAcceptResult>(
2129            (&mut con,),
2130            0x4b71e6389d92d322,
2131            fidl::encoding::DynamicFlags::empty(),
2132            _decode,
2133        )
2134    }
2135}
2136
2137pub struct ListenerEventStream {
2138    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2139}
2140
2141impl std::marker::Unpin for ListenerEventStream {}
2142
2143impl futures::stream::FusedStream for ListenerEventStream {
2144    fn is_terminated(&self) -> bool {
2145        self.event_receiver.is_terminated()
2146    }
2147}
2148
2149impl futures::Stream for ListenerEventStream {
2150    type Item = Result<ListenerEvent, 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        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2157            &mut self.event_receiver,
2158            cx
2159        )?) {
2160            Some(buf) => std::task::Poll::Ready(Some(ListenerEvent::decode(buf))),
2161            None => std::task::Poll::Ready(None),
2162        }
2163    }
2164}
2165
2166#[derive(Debug)]
2167pub enum ListenerEvent {}
2168
2169impl ListenerEvent {
2170    /// Decodes a message buffer as a [`ListenerEvent`].
2171    fn decode(
2172        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2173    ) -> Result<ListenerEvent, fidl::Error> {
2174        let (bytes, _handles) = buf.split_mut();
2175        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2176        debug_assert_eq!(tx_header.tx_id, 0);
2177        match tx_header.ordinal {
2178            _ => Err(fidl::Error::UnknownOrdinal {
2179                ordinal: tx_header.ordinal,
2180                protocol_name: <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2181            }),
2182        }
2183    }
2184}
2185
2186/// A Stream of incoming requests for fuchsia.vsock/Listener.
2187pub struct ListenerRequestStream {
2188    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2189    is_terminated: bool,
2190}
2191
2192impl std::marker::Unpin for ListenerRequestStream {}
2193
2194impl futures::stream::FusedStream for ListenerRequestStream {
2195    fn is_terminated(&self) -> bool {
2196        self.is_terminated
2197    }
2198}
2199
2200impl fidl::endpoints::RequestStream for ListenerRequestStream {
2201    type Protocol = ListenerMarker;
2202    type ControlHandle = ListenerControlHandle;
2203
2204    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2205        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2206    }
2207
2208    fn control_handle(&self) -> Self::ControlHandle {
2209        ListenerControlHandle { inner: self.inner.clone() }
2210    }
2211
2212    fn into_inner(
2213        self,
2214    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2215    {
2216        (self.inner, self.is_terminated)
2217    }
2218
2219    fn from_inner(
2220        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2221        is_terminated: bool,
2222    ) -> Self {
2223        Self { inner, is_terminated }
2224    }
2225}
2226
2227impl futures::Stream for ListenerRequestStream {
2228    type Item = Result<ListenerRequest, fidl::Error>;
2229
2230    fn poll_next(
2231        mut self: std::pin::Pin<&mut Self>,
2232        cx: &mut std::task::Context<'_>,
2233    ) -> std::task::Poll<Option<Self::Item>> {
2234        let this = &mut *self;
2235        if this.inner.check_shutdown(cx) {
2236            this.is_terminated = true;
2237            return std::task::Poll::Ready(None);
2238        }
2239        if this.is_terminated {
2240            panic!("polled ListenerRequestStream after completion");
2241        }
2242        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2243            |bytes, handles| {
2244                match this.inner.channel().read_etc(cx, bytes, handles) {
2245                    std::task::Poll::Ready(Ok(())) => {}
2246                    std::task::Poll::Pending => return std::task::Poll::Pending,
2247                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2248                        this.is_terminated = true;
2249                        return std::task::Poll::Ready(None);
2250                    }
2251                    std::task::Poll::Ready(Err(e)) => {
2252                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2253                            e.into(),
2254                        ))));
2255                    }
2256                }
2257
2258                // A message has been received from the channel
2259                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2260
2261                std::task::Poll::Ready(Some(match header.ordinal {
2262                    0x53042f6a15d94464 => {
2263                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2264                        let mut req = fidl::new_empty!(
2265                            ListenerListenRequest,
2266                            fidl::encoding::DefaultFuchsiaResourceDialect
2267                        );
2268                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ListenerListenRequest>(&header, _body_bytes, handles, &mut req)?;
2269                        let control_handle = ListenerControlHandle { inner: this.inner.clone() };
2270                        Ok(ListenerRequest::Listen {
2271                            backlog: req.backlog,
2272
2273                            responder: ListenerListenResponder {
2274                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2275                                tx_id: header.tx_id,
2276                            },
2277                        })
2278                    }
2279                    0x4b71e6389d92d322 => {
2280                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2281                        let mut req = fidl::new_empty!(
2282                            ListenerAcceptRequest,
2283                            fidl::encoding::DefaultFuchsiaResourceDialect
2284                        );
2285                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ListenerAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
2286                        let control_handle = ListenerControlHandle { inner: this.inner.clone() };
2287                        Ok(ListenerRequest::Accept {
2288                            con: req.con,
2289
2290                            responder: ListenerAcceptResponder {
2291                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2292                                tx_id: header.tx_id,
2293                            },
2294                        })
2295                    }
2296                    _ => Err(fidl::Error::UnknownOrdinal {
2297                        ordinal: header.ordinal,
2298                        protocol_name:
2299                            <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2300                    }),
2301                }))
2302            },
2303        )
2304    }
2305}
2306
2307/// Interface presented by a listener to accept connections.
2308#[derive(Debug)]
2309pub enum ListenerRequest {
2310    /// Registers a listener for a local port. There can only be one listener for
2311    /// a single port at a time. The channel will have `SIGNAL_STREAM_INCOMING` asserted
2312    /// by the server when there is a connection ready to accept.
2313    Listen { backlog: u32, responder: ListenerListenResponder },
2314    /// Accept a pending connection from the queue after `Listen` was invoked and
2315    /// `SIGNAL_STREAM_INCOMING` was signaled.
2316    Accept { con: ConnectionTransport, responder: ListenerAcceptResponder },
2317}
2318
2319impl ListenerRequest {
2320    #[allow(irrefutable_let_patterns)]
2321    pub fn into_listen(self) -> Option<(u32, ListenerListenResponder)> {
2322        if let ListenerRequest::Listen { backlog, responder } = self {
2323            Some((backlog, responder))
2324        } else {
2325            None
2326        }
2327    }
2328
2329    #[allow(irrefutable_let_patterns)]
2330    pub fn into_accept(self) -> Option<(ConnectionTransport, ListenerAcceptResponder)> {
2331        if let ListenerRequest::Accept { con, responder } = self {
2332            Some((con, responder))
2333        } else {
2334            None
2335        }
2336    }
2337
2338    /// Name of the method defined in FIDL
2339    pub fn method_name(&self) -> &'static str {
2340        match *self {
2341            ListenerRequest::Listen { .. } => "listen",
2342            ListenerRequest::Accept { .. } => "accept",
2343        }
2344    }
2345}
2346
2347#[derive(Debug, Clone)]
2348pub struct ListenerControlHandle {
2349    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2350}
2351
2352impl fidl::endpoints::ControlHandle for ListenerControlHandle {
2353    fn shutdown(&self) {
2354        self.inner.shutdown()
2355    }
2356
2357    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2358        self.inner.shutdown_with_epitaph(status)
2359    }
2360
2361    fn is_closed(&self) -> bool {
2362        self.inner.channel().is_closed()
2363    }
2364    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2365        self.inner.channel().on_closed()
2366    }
2367
2368    #[cfg(target_os = "fuchsia")]
2369    fn signal_peer(
2370        &self,
2371        clear_mask: zx::Signals,
2372        set_mask: zx::Signals,
2373    ) -> Result<(), zx_status::Status> {
2374        use fidl::Peered;
2375        self.inner.channel().signal_peer(clear_mask, set_mask)
2376    }
2377}
2378
2379impl ListenerControlHandle {}
2380
2381#[must_use = "FIDL methods require a response to be sent"]
2382#[derive(Debug)]
2383pub struct ListenerListenResponder {
2384    control_handle: std::mem::ManuallyDrop<ListenerControlHandle>,
2385    tx_id: u32,
2386}
2387
2388/// Set the the channel to be shutdown (see [`ListenerControlHandle::shutdown`])
2389/// if the responder is dropped without sending a response, so that the client
2390/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2391impl std::ops::Drop for ListenerListenResponder {
2392    fn drop(&mut self) {
2393        self.control_handle.shutdown();
2394        // Safety: drops once, never accessed again
2395        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2396    }
2397}
2398
2399impl fidl::endpoints::Responder for ListenerListenResponder {
2400    type ControlHandle = ListenerControlHandle;
2401
2402    fn control_handle(&self) -> &ListenerControlHandle {
2403        &self.control_handle
2404    }
2405
2406    fn drop_without_shutdown(mut self) {
2407        // Safety: drops once, never accessed again due to mem::forget
2408        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2409        // Prevent Drop from running (which would shut down the channel)
2410        std::mem::forget(self);
2411    }
2412}
2413
2414impl ListenerListenResponder {
2415    /// Sends a response to the FIDL transaction.
2416    ///
2417    /// Sets the channel to shutdown if an error occurs.
2418    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2419        let _result = self.send_raw(result);
2420        if _result.is_err() {
2421            self.control_handle.shutdown();
2422        }
2423        self.drop_without_shutdown();
2424        _result
2425    }
2426
2427    /// Similar to "send" but does not shutdown the channel if an error occurs.
2428    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2429        let _result = self.send_raw(result);
2430        self.drop_without_shutdown();
2431        _result
2432    }
2433
2434    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2435        self.control_handle
2436            .inner
2437            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2438                result,
2439                self.tx_id,
2440                0x53042f6a15d94464,
2441                fidl::encoding::DynamicFlags::empty(),
2442            )
2443    }
2444}
2445
2446#[must_use = "FIDL methods require a response to be sent"]
2447#[derive(Debug)]
2448pub struct ListenerAcceptResponder {
2449    control_handle: std::mem::ManuallyDrop<ListenerControlHandle>,
2450    tx_id: u32,
2451}
2452
2453/// Set the the channel to be shutdown (see [`ListenerControlHandle::shutdown`])
2454/// if the responder is dropped without sending a response, so that the client
2455/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2456impl std::ops::Drop for ListenerAcceptResponder {
2457    fn drop(&mut self) {
2458        self.control_handle.shutdown();
2459        // Safety: drops once, never accessed again
2460        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2461    }
2462}
2463
2464impl fidl::endpoints::Responder for ListenerAcceptResponder {
2465    type ControlHandle = ListenerControlHandle;
2466
2467    fn control_handle(&self) -> &ListenerControlHandle {
2468        &self.control_handle
2469    }
2470
2471    fn drop_without_shutdown(mut self) {
2472        // Safety: drops once, never accessed again due to mem::forget
2473        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2474        // Prevent Drop from running (which would shut down the channel)
2475        std::mem::forget(self);
2476    }
2477}
2478
2479impl ListenerAcceptResponder {
2480    /// Sends a response to the FIDL transaction.
2481    ///
2482    /// Sets the channel to shutdown if an error occurs.
2483    pub fn send(
2484        self,
2485        mut result: Result<&fidl_fuchsia_hardware_vsock::Addr, i32>,
2486    ) -> Result<(), fidl::Error> {
2487        let _result = self.send_raw(result);
2488        if _result.is_err() {
2489            self.control_handle.shutdown();
2490        }
2491        self.drop_without_shutdown();
2492        _result
2493    }
2494
2495    /// Similar to "send" but does not shutdown the channel if an error occurs.
2496    pub fn send_no_shutdown_on_err(
2497        self,
2498        mut result: Result<&fidl_fuchsia_hardware_vsock::Addr, i32>,
2499    ) -> Result<(), fidl::Error> {
2500        let _result = self.send_raw(result);
2501        self.drop_without_shutdown();
2502        _result
2503    }
2504
2505    fn send_raw(
2506        &self,
2507        mut result: Result<&fidl_fuchsia_hardware_vsock::Addr, i32>,
2508    ) -> Result<(), fidl::Error> {
2509        self.control_handle.inner.send::<fidl::encoding::ResultType<ListenerAcceptResponse, i32>>(
2510            result.map(|addr| (addr,)),
2511            self.tx_id,
2512            0x4b71e6389d92d322,
2513            fidl::encoding::DynamicFlags::empty(),
2514        )
2515    }
2516}
2517
2518#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2519pub struct ProviderMarker;
2520
2521impl fidl::endpoints::ProtocolMarker for ProviderMarker {
2522    type Proxy = ProviderProxy;
2523    type RequestStream = ProviderRequestStream;
2524    #[cfg(target_os = "fuchsia")]
2525    type SynchronousProxy = ProviderSynchronousProxy;
2526
2527    const DEBUG_NAME: &'static str = "fuchsia.vsock.Provider";
2528}
2529impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
2530pub type ProviderStreamSocketResult = Result<(), i32>;
2531
2532pub trait ProviderProxyInterface: Send + Sync {
2533    type StreamSocketResponseFut: std::future::Future<Output = Result<ProviderStreamSocketResult, fidl::Error>>
2534        + Send;
2535    fn r#stream_socket(
2536        &self,
2537        server: fidl::endpoints::ServerEnd<StreamSocketMarker>,
2538        data: fidl::Socket,
2539    ) -> Self::StreamSocketResponseFut;
2540    type GetCidResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
2541    fn r#get_cid(&self) -> Self::GetCidResponseFut;
2542}
2543#[derive(Debug)]
2544#[cfg(target_os = "fuchsia")]
2545pub struct ProviderSynchronousProxy {
2546    client: fidl::client::sync::Client,
2547}
2548
2549#[cfg(target_os = "fuchsia")]
2550impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
2551    type Proxy = ProviderProxy;
2552    type Protocol = ProviderMarker;
2553
2554    fn from_channel(inner: fidl::Channel) -> Self {
2555        Self::new(inner)
2556    }
2557
2558    fn into_channel(self) -> fidl::Channel {
2559        self.client.into_channel()
2560    }
2561
2562    fn as_channel(&self) -> &fidl::Channel {
2563        self.client.as_channel()
2564    }
2565}
2566
2567#[cfg(target_os = "fuchsia")]
2568impl ProviderSynchronousProxy {
2569    pub fn new(channel: fidl::Channel) -> Self {
2570        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2571        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2572    }
2573
2574    pub fn into_channel(self) -> fidl::Channel {
2575        self.client.into_channel()
2576    }
2577
2578    /// Waits until an event arrives and returns it. It is safe for other
2579    /// threads to make concurrent requests while waiting for an event.
2580    pub fn wait_for_event(
2581        &self,
2582        deadline: zx::MonotonicInstant,
2583    ) -> Result<ProviderEvent, fidl::Error> {
2584        ProviderEvent::decode(self.client.wait_for_event(deadline)?)
2585    }
2586
2587    /// Create a new virtio socket in stream mode.
2588    pub fn r#stream_socket(
2589        &self,
2590        mut server: fidl::endpoints::ServerEnd<StreamSocketMarker>,
2591        mut data: fidl::Socket,
2592        ___deadline: zx::MonotonicInstant,
2593    ) -> Result<ProviderStreamSocketResult, fidl::Error> {
2594        let _response = self.client.send_query::<
2595            ProviderStreamSocketRequest,
2596            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2597        >(
2598            (server, data,),
2599            0x638e6822e8c0c333,
2600            fidl::encoding::DynamicFlags::FLEXIBLE,
2601            ___deadline,
2602        )?
2603        .into_result::<ProviderMarker>("stream_socket")?;
2604        Ok(_response.map(|x| x))
2605    }
2606
2607    /// Query the current context id of the system. The local CID is should not
2608    /// necessary in interactions with the same device; instead you may pass
2609    /// `VMADDR_CID_LOCAL`, which will alias to local CID this returns. The cid returned
2610    /// by this method is useful for debugging or if you have some other communication
2611    /// channel to a different host and you would like to send them your CID to then
2612    /// establish a vsock connection on.
2613    pub fn r#get_cid(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
2614        let _response =
2615            self.client.send_query::<fidl::encoding::EmptyPayload, ProviderGetCidResponse>(
2616                (),
2617                0x7152b198ab4348df,
2618                fidl::encoding::DynamicFlags::empty(),
2619                ___deadline,
2620            )?;
2621        Ok(_response.local_cid)
2622    }
2623}
2624
2625#[cfg(target_os = "fuchsia")]
2626impl From<ProviderSynchronousProxy> for zx::NullableHandle {
2627    fn from(value: ProviderSynchronousProxy) -> Self {
2628        value.into_channel().into()
2629    }
2630}
2631
2632#[cfg(target_os = "fuchsia")]
2633impl From<fidl::Channel> for ProviderSynchronousProxy {
2634    fn from(value: fidl::Channel) -> Self {
2635        Self::new(value)
2636    }
2637}
2638
2639#[cfg(target_os = "fuchsia")]
2640impl fidl::endpoints::FromClient for ProviderSynchronousProxy {
2641    type Protocol = ProviderMarker;
2642
2643    fn from_client(value: fidl::endpoints::ClientEnd<ProviderMarker>) -> Self {
2644        Self::new(value.into_channel())
2645    }
2646}
2647
2648#[derive(Debug, Clone)]
2649pub struct ProviderProxy {
2650    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2651}
2652
2653impl fidl::endpoints::Proxy for ProviderProxy {
2654    type Protocol = ProviderMarker;
2655
2656    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2657        Self::new(inner)
2658    }
2659
2660    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2661        self.client.into_channel().map_err(|client| Self { client })
2662    }
2663
2664    fn as_channel(&self) -> &::fidl::AsyncChannel {
2665        self.client.as_channel()
2666    }
2667}
2668
2669impl ProviderProxy {
2670    /// Create a new Proxy for fuchsia.vsock/Provider.
2671    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2672        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2673        Self { client: fidl::client::Client::new(channel, protocol_name) }
2674    }
2675
2676    /// Get a Stream of events from the remote end of the protocol.
2677    ///
2678    /// # Panics
2679    ///
2680    /// Panics if the event stream was already taken.
2681    pub fn take_event_stream(&self) -> ProviderEventStream {
2682        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
2683    }
2684
2685    /// Create a new virtio socket in stream mode.
2686    pub fn r#stream_socket(
2687        &self,
2688        mut server: fidl::endpoints::ServerEnd<StreamSocketMarker>,
2689        mut data: fidl::Socket,
2690    ) -> fidl::client::QueryResponseFut<
2691        ProviderStreamSocketResult,
2692        fidl::encoding::DefaultFuchsiaResourceDialect,
2693    > {
2694        ProviderProxyInterface::r#stream_socket(self, server, data)
2695    }
2696
2697    /// Query the current context id of the system. The local CID is should not
2698    /// necessary in interactions with the same device; instead you may pass
2699    /// `VMADDR_CID_LOCAL`, which will alias to local CID this returns. The cid returned
2700    /// by this method is useful for debugging or if you have some other communication
2701    /// channel to a different host and you would like to send them your CID to then
2702    /// establish a vsock connection on.
2703    pub fn r#get_cid(
2704        &self,
2705    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
2706        ProviderProxyInterface::r#get_cid(self)
2707    }
2708}
2709
2710impl ProviderProxyInterface for ProviderProxy {
2711    type StreamSocketResponseFut = fidl::client::QueryResponseFut<
2712        ProviderStreamSocketResult,
2713        fidl::encoding::DefaultFuchsiaResourceDialect,
2714    >;
2715    fn r#stream_socket(
2716        &self,
2717        mut server: fidl::endpoints::ServerEnd<StreamSocketMarker>,
2718        mut data: fidl::Socket,
2719    ) -> Self::StreamSocketResponseFut {
2720        fn _decode(
2721            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2722        ) -> Result<ProviderStreamSocketResult, fidl::Error> {
2723            let _response = fidl::client::decode_transaction_body::<
2724                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2725                fidl::encoding::DefaultFuchsiaResourceDialect,
2726                0x638e6822e8c0c333,
2727            >(_buf?)?
2728            .into_result::<ProviderMarker>("stream_socket")?;
2729            Ok(_response.map(|x| x))
2730        }
2731        self.client
2732            .send_query_and_decode::<ProviderStreamSocketRequest, ProviderStreamSocketResult>(
2733                (server, data),
2734                0x638e6822e8c0c333,
2735                fidl::encoding::DynamicFlags::FLEXIBLE,
2736                _decode,
2737            )
2738    }
2739
2740    type GetCidResponseFut =
2741        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
2742    fn r#get_cid(&self) -> Self::GetCidResponseFut {
2743        fn _decode(
2744            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2745        ) -> Result<u32, fidl::Error> {
2746            let _response = fidl::client::decode_transaction_body::<
2747                ProviderGetCidResponse,
2748                fidl::encoding::DefaultFuchsiaResourceDialect,
2749                0x7152b198ab4348df,
2750            >(_buf?)?;
2751            Ok(_response.local_cid)
2752        }
2753        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
2754            (),
2755            0x7152b198ab4348df,
2756            fidl::encoding::DynamicFlags::empty(),
2757            _decode,
2758        )
2759    }
2760}
2761
2762pub struct ProviderEventStream {
2763    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2764}
2765
2766impl std::marker::Unpin for ProviderEventStream {}
2767
2768impl futures::stream::FusedStream for ProviderEventStream {
2769    fn is_terminated(&self) -> bool {
2770        self.event_receiver.is_terminated()
2771    }
2772}
2773
2774impl futures::Stream for ProviderEventStream {
2775    type Item = Result<ProviderEvent, fidl::Error>;
2776
2777    fn poll_next(
2778        mut self: std::pin::Pin<&mut Self>,
2779        cx: &mut std::task::Context<'_>,
2780    ) -> std::task::Poll<Option<Self::Item>> {
2781        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2782            &mut self.event_receiver,
2783            cx
2784        )?) {
2785            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
2786            None => std::task::Poll::Ready(None),
2787        }
2788    }
2789}
2790
2791#[derive(Debug)]
2792pub enum ProviderEvent {
2793    #[non_exhaustive]
2794    _UnknownEvent {
2795        /// Ordinal of the event that was sent.
2796        ordinal: u64,
2797    },
2798}
2799
2800impl ProviderEvent {
2801    /// Decodes a message buffer as a [`ProviderEvent`].
2802    fn decode(
2803        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2804    ) -> Result<ProviderEvent, fidl::Error> {
2805        let (bytes, _handles) = buf.split_mut();
2806        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2807        debug_assert_eq!(tx_header.tx_id, 0);
2808        match tx_header.ordinal {
2809            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2810                Ok(ProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2811            }
2812            _ => Err(fidl::Error::UnknownOrdinal {
2813                ordinal: tx_header.ordinal,
2814                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2815            }),
2816        }
2817    }
2818}
2819
2820/// A Stream of incoming requests for fuchsia.vsock/Provider.
2821pub struct ProviderRequestStream {
2822    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2823    is_terminated: bool,
2824}
2825
2826impl std::marker::Unpin for ProviderRequestStream {}
2827
2828impl futures::stream::FusedStream for ProviderRequestStream {
2829    fn is_terminated(&self) -> bool {
2830        self.is_terminated
2831    }
2832}
2833
2834impl fidl::endpoints::RequestStream for ProviderRequestStream {
2835    type Protocol = ProviderMarker;
2836    type ControlHandle = ProviderControlHandle;
2837
2838    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2839        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2840    }
2841
2842    fn control_handle(&self) -> Self::ControlHandle {
2843        ProviderControlHandle { inner: self.inner.clone() }
2844    }
2845
2846    fn into_inner(
2847        self,
2848    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2849    {
2850        (self.inner, self.is_terminated)
2851    }
2852
2853    fn from_inner(
2854        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2855        is_terminated: bool,
2856    ) -> Self {
2857        Self { inner, is_terminated }
2858    }
2859}
2860
2861impl futures::Stream for ProviderRequestStream {
2862    type Item = Result<ProviderRequest, fidl::Error>;
2863
2864    fn poll_next(
2865        mut self: std::pin::Pin<&mut Self>,
2866        cx: &mut std::task::Context<'_>,
2867    ) -> std::task::Poll<Option<Self::Item>> {
2868        let this = &mut *self;
2869        if this.inner.check_shutdown(cx) {
2870            this.is_terminated = true;
2871            return std::task::Poll::Ready(None);
2872        }
2873        if this.is_terminated {
2874            panic!("polled ProviderRequestStream after completion");
2875        }
2876        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2877            |bytes, handles| {
2878                match this.inner.channel().read_etc(cx, bytes, handles) {
2879                    std::task::Poll::Ready(Ok(())) => {}
2880                    std::task::Poll::Pending => return std::task::Poll::Pending,
2881                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2882                        this.is_terminated = true;
2883                        return std::task::Poll::Ready(None);
2884                    }
2885                    std::task::Poll::Ready(Err(e)) => {
2886                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2887                            e.into(),
2888                        ))));
2889                    }
2890                }
2891
2892                // A message has been received from the channel
2893                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2894
2895                std::task::Poll::Ready(Some(match header.ordinal {
2896                    0x638e6822e8c0c333 => {
2897                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2898                        let mut req = fidl::new_empty!(
2899                            ProviderStreamSocketRequest,
2900                            fidl::encoding::DefaultFuchsiaResourceDialect
2901                        );
2902                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderStreamSocketRequest>(&header, _body_bytes, handles, &mut req)?;
2903                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
2904                        Ok(ProviderRequest::StreamSocket {
2905                            server: req.server,
2906                            data: req.data,
2907
2908                            responder: ProviderStreamSocketResponder {
2909                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2910                                tx_id: header.tx_id,
2911                            },
2912                        })
2913                    }
2914                    0x7152b198ab4348df => {
2915                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2916                        let mut req = fidl::new_empty!(
2917                            fidl::encoding::EmptyPayload,
2918                            fidl::encoding::DefaultFuchsiaResourceDialect
2919                        );
2920                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2921                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
2922                        Ok(ProviderRequest::GetCid {
2923                            responder: ProviderGetCidResponder {
2924                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2925                                tx_id: header.tx_id,
2926                            },
2927                        })
2928                    }
2929                    _ if header.tx_id == 0
2930                        && header
2931                            .dynamic_flags()
2932                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2933                    {
2934                        Ok(ProviderRequest::_UnknownMethod {
2935                            ordinal: header.ordinal,
2936                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
2937                            method_type: fidl::MethodType::OneWay,
2938                        })
2939                    }
2940                    _ if header
2941                        .dynamic_flags()
2942                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2943                    {
2944                        this.inner.send_framework_err(
2945                            fidl::encoding::FrameworkErr::UnknownMethod,
2946                            header.tx_id,
2947                            header.ordinal,
2948                            header.dynamic_flags(),
2949                            (bytes, handles),
2950                        )?;
2951                        Ok(ProviderRequest::_UnknownMethod {
2952                            ordinal: header.ordinal,
2953                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
2954                            method_type: fidl::MethodType::TwoWay,
2955                        })
2956                    }
2957                    _ => Err(fidl::Error::UnknownOrdinal {
2958                        ordinal: header.ordinal,
2959                        protocol_name:
2960                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2961                    }),
2962                }))
2963            },
2964        )
2965    }
2966}
2967
2968#[derive(Debug)]
2969pub enum ProviderRequest {
2970    /// Create a new virtio socket in stream mode.
2971    StreamSocket {
2972        server: fidl::endpoints::ServerEnd<StreamSocketMarker>,
2973        data: fidl::Socket,
2974        responder: ProviderStreamSocketResponder,
2975    },
2976    /// Query the current context id of the system. The local CID is should not
2977    /// necessary in interactions with the same device; instead you may pass
2978    /// `VMADDR_CID_LOCAL`, which will alias to local CID this returns. The cid returned
2979    /// by this method is useful for debugging or if you have some other communication
2980    /// channel to a different host and you would like to send them your CID to then
2981    /// establish a vsock connection on.
2982    GetCid { responder: ProviderGetCidResponder },
2983    /// An interaction was received which does not match any known method.
2984    #[non_exhaustive]
2985    _UnknownMethod {
2986        /// Ordinal of the method that was called.
2987        ordinal: u64,
2988        control_handle: ProviderControlHandle,
2989        method_type: fidl::MethodType,
2990    },
2991}
2992
2993impl ProviderRequest {
2994    #[allow(irrefutable_let_patterns)]
2995    pub fn into_stream_socket(
2996        self,
2997    ) -> Option<(
2998        fidl::endpoints::ServerEnd<StreamSocketMarker>,
2999        fidl::Socket,
3000        ProviderStreamSocketResponder,
3001    )> {
3002        if let ProviderRequest::StreamSocket { server, data, responder } = self {
3003            Some((server, data, responder))
3004        } else {
3005            None
3006        }
3007    }
3008
3009    #[allow(irrefutable_let_patterns)]
3010    pub fn into_get_cid(self) -> Option<(ProviderGetCidResponder)> {
3011        if let ProviderRequest::GetCid { responder } = self { Some((responder)) } else { None }
3012    }
3013
3014    /// Name of the method defined in FIDL
3015    pub fn method_name(&self) -> &'static str {
3016        match *self {
3017            ProviderRequest::StreamSocket { .. } => "stream_socket",
3018            ProviderRequest::GetCid { .. } => "get_cid",
3019            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
3020                "unknown one-way method"
3021            }
3022            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
3023                "unknown two-way method"
3024            }
3025        }
3026    }
3027}
3028
3029#[derive(Debug, Clone)]
3030pub struct ProviderControlHandle {
3031    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3032}
3033
3034impl fidl::endpoints::ControlHandle for ProviderControlHandle {
3035    fn shutdown(&self) {
3036        self.inner.shutdown()
3037    }
3038
3039    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3040        self.inner.shutdown_with_epitaph(status)
3041    }
3042
3043    fn is_closed(&self) -> bool {
3044        self.inner.channel().is_closed()
3045    }
3046    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3047        self.inner.channel().on_closed()
3048    }
3049
3050    #[cfg(target_os = "fuchsia")]
3051    fn signal_peer(
3052        &self,
3053        clear_mask: zx::Signals,
3054        set_mask: zx::Signals,
3055    ) -> Result<(), zx_status::Status> {
3056        use fidl::Peered;
3057        self.inner.channel().signal_peer(clear_mask, set_mask)
3058    }
3059}
3060
3061impl ProviderControlHandle {}
3062
3063#[must_use = "FIDL methods require a response to be sent"]
3064#[derive(Debug)]
3065pub struct ProviderStreamSocketResponder {
3066    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
3067    tx_id: u32,
3068}
3069
3070/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
3071/// if the responder is dropped without sending a response, so that the client
3072/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3073impl std::ops::Drop for ProviderStreamSocketResponder {
3074    fn drop(&mut self) {
3075        self.control_handle.shutdown();
3076        // Safety: drops once, never accessed again
3077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3078    }
3079}
3080
3081impl fidl::endpoints::Responder for ProviderStreamSocketResponder {
3082    type ControlHandle = ProviderControlHandle;
3083
3084    fn control_handle(&self) -> &ProviderControlHandle {
3085        &self.control_handle
3086    }
3087
3088    fn drop_without_shutdown(mut self) {
3089        // Safety: drops once, never accessed again due to mem::forget
3090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3091        // Prevent Drop from running (which would shut down the channel)
3092        std::mem::forget(self);
3093    }
3094}
3095
3096impl ProviderStreamSocketResponder {
3097    /// Sends a response to the FIDL transaction.
3098    ///
3099    /// Sets the channel to shutdown if an error occurs.
3100    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3101        let _result = self.send_raw(result);
3102        if _result.is_err() {
3103            self.control_handle.shutdown();
3104        }
3105        self.drop_without_shutdown();
3106        _result
3107    }
3108
3109    /// Similar to "send" but does not shutdown the channel if an error occurs.
3110    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3111        let _result = self.send_raw(result);
3112        self.drop_without_shutdown();
3113        _result
3114    }
3115
3116    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3117        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3118            fidl::encoding::EmptyStruct,
3119            i32,
3120        >>(
3121            fidl::encoding::FlexibleResult::new(result),
3122            self.tx_id,
3123            0x638e6822e8c0c333,
3124            fidl::encoding::DynamicFlags::FLEXIBLE,
3125        )
3126    }
3127}
3128
3129#[must_use = "FIDL methods require a response to be sent"]
3130#[derive(Debug)]
3131pub struct ProviderGetCidResponder {
3132    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
3133    tx_id: u32,
3134}
3135
3136/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
3137/// if the responder is dropped without sending a response, so that the client
3138/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3139impl std::ops::Drop for ProviderGetCidResponder {
3140    fn drop(&mut self) {
3141        self.control_handle.shutdown();
3142        // Safety: drops once, never accessed again
3143        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3144    }
3145}
3146
3147impl fidl::endpoints::Responder for ProviderGetCidResponder {
3148    type ControlHandle = ProviderControlHandle;
3149
3150    fn control_handle(&self) -> &ProviderControlHandle {
3151        &self.control_handle
3152    }
3153
3154    fn drop_without_shutdown(mut self) {
3155        // Safety: drops once, never accessed again due to mem::forget
3156        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3157        // Prevent Drop from running (which would shut down the channel)
3158        std::mem::forget(self);
3159    }
3160}
3161
3162impl ProviderGetCidResponder {
3163    /// Sends a response to the FIDL transaction.
3164    ///
3165    /// Sets the channel to shutdown if an error occurs.
3166    pub fn send(self, mut local_cid: u32) -> Result<(), fidl::Error> {
3167        let _result = self.send_raw(local_cid);
3168        if _result.is_err() {
3169            self.control_handle.shutdown();
3170        }
3171        self.drop_without_shutdown();
3172        _result
3173    }
3174
3175    /// Similar to "send" but does not shutdown the channel if an error occurs.
3176    pub fn send_no_shutdown_on_err(self, mut local_cid: u32) -> Result<(), fidl::Error> {
3177        let _result = self.send_raw(local_cid);
3178        self.drop_without_shutdown();
3179        _result
3180    }
3181
3182    fn send_raw(&self, mut local_cid: u32) -> Result<(), fidl::Error> {
3183        self.control_handle.inner.send::<ProviderGetCidResponse>(
3184            (local_cid,),
3185            self.tx_id,
3186            0x7152b198ab4348df,
3187            fidl::encoding::DynamicFlags::empty(),
3188        )
3189    }
3190}
3191
3192#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3193pub struct StreamSocketMarker;
3194
3195impl fidl::endpoints::ProtocolMarker for StreamSocketMarker {
3196    type Proxy = StreamSocketProxy;
3197    type RequestStream = StreamSocketRequestStream;
3198    #[cfg(target_os = "fuchsia")]
3199    type SynchronousProxy = StreamSocketSynchronousProxy;
3200
3201    const DEBUG_NAME: &'static str = "(anonymous) StreamSocket";
3202}
3203pub type StreamSocketBindResult = Result<(), Error>;
3204pub type StreamSocketConnectResult = Result<(), Error>;
3205pub type StreamSocketListenResult = Result<(), Error>;
3206pub type StreamSocketAcceptResult = Result<StreamSocketAcceptResponse, Error>;
3207pub type StreamSocketGetSockNameResult = Result<VsockAddress, Error>;
3208pub type StreamSocketGetPeerNameResult = Result<VsockAddress, Error>;
3209pub type StreamSocketGetErrorResult = Result<(), Error>;
3210
3211pub trait StreamSocketProxyInterface: Send + Sync {
3212    type CloseResponseFut: std::future::Future<
3213            Output = Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error>,
3214        > + Send;
3215    fn r#close(&self) -> Self::CloseResponseFut;
3216    type BindResponseFut: std::future::Future<Output = Result<StreamSocketBindResult, fidl::Error>>
3217        + Send;
3218    fn r#bind(&self, addr: &VsockAddress) -> Self::BindResponseFut;
3219    type ConnectResponseFut: std::future::Future<Output = Result<StreamSocketConnectResult, fidl::Error>>
3220        + Send;
3221    fn r#connect(&self, remote_address: &VsockAddress) -> Self::ConnectResponseFut;
3222    type ListenResponseFut: std::future::Future<Output = Result<StreamSocketListenResult, fidl::Error>>
3223        + Send;
3224    fn r#listen(&self, backlog: i32) -> Self::ListenResponseFut;
3225    type AcceptResponseFut: std::future::Future<Output = Result<StreamSocketAcceptResult, fidl::Error>>
3226        + Send;
3227    fn r#accept(&self, want_addr: bool) -> Self::AcceptResponseFut;
3228    type GetSockNameResponseFut: std::future::Future<Output = Result<StreamSocketGetSockNameResult, fidl::Error>>
3229        + Send;
3230    fn r#get_sock_name(&self) -> Self::GetSockNameResponseFut;
3231    type GetPeerNameResponseFut: std::future::Future<Output = Result<StreamSocketGetPeerNameResult, fidl::Error>>
3232        + Send;
3233    fn r#get_peer_name(&self) -> Self::GetPeerNameResponseFut;
3234    type GetErrorResponseFut: std::future::Future<Output = Result<StreamSocketGetErrorResult, fidl::Error>>
3235        + Send;
3236    fn r#get_error(&self) -> Self::GetErrorResponseFut;
3237}
3238#[derive(Debug)]
3239#[cfg(target_os = "fuchsia")]
3240pub struct StreamSocketSynchronousProxy {
3241    client: fidl::client::sync::Client,
3242}
3243
3244#[cfg(target_os = "fuchsia")]
3245impl fidl::endpoints::SynchronousProxy for StreamSocketSynchronousProxy {
3246    type Proxy = StreamSocketProxy;
3247    type Protocol = StreamSocketMarker;
3248
3249    fn from_channel(inner: fidl::Channel) -> Self {
3250        Self::new(inner)
3251    }
3252
3253    fn into_channel(self) -> fidl::Channel {
3254        self.client.into_channel()
3255    }
3256
3257    fn as_channel(&self) -> &fidl::Channel {
3258        self.client.as_channel()
3259    }
3260}
3261
3262#[cfg(target_os = "fuchsia")]
3263impl StreamSocketSynchronousProxy {
3264    pub fn new(channel: fidl::Channel) -> Self {
3265        let protocol_name = <StreamSocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3266        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3267    }
3268
3269    pub fn into_channel(self) -> fidl::Channel {
3270        self.client.into_channel()
3271    }
3272
3273    /// Waits until an event arrives and returns it. It is safe for other
3274    /// threads to make concurrent requests while waiting for an event.
3275    pub fn wait_for_event(
3276        &self,
3277        deadline: zx::MonotonicInstant,
3278    ) -> Result<StreamSocketEvent, fidl::Error> {
3279        StreamSocketEvent::decode(self.client.wait_for_event(deadline)?)
3280    }
3281
3282    /// Terminates the connection.
3283    ///
3284    /// After calling `Close`, the client must not send any other requests.
3285    ///
3286    /// Servers, after sending the status response, should close the connection
3287    /// regardless of status and without sending an epitaph.
3288    ///
3289    /// Closing the client end of the channel should be semantically equivalent
3290    /// to calling `Close` without knowing when the close has completed or its
3291    /// status.
3292    pub fn r#close(
3293        &self,
3294        ___deadline: zx::MonotonicInstant,
3295    ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
3296        let _response = self.client.send_query::<
3297            fidl::encoding::EmptyPayload,
3298            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3299        >(
3300            (),
3301            0x5ac5d459ad7f657e,
3302            fidl::encoding::DynamicFlags::empty(),
3303            ___deadline,
3304        )?;
3305        Ok(_response.map(|x| x))
3306    }
3307
3308    /// Bind this socket to a specific address.
3309    pub fn r#bind(
3310        &self,
3311        mut addr: &VsockAddress,
3312        ___deadline: zx::MonotonicInstant,
3313    ) -> Result<StreamSocketBindResult, fidl::Error> {
3314        let _response = self.client.send_query::<
3315            StreamSocketBindRequest,
3316            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3317        >(
3318            (addr,),
3319            0x72dc3c63cf24329,
3320            fidl::encoding::DynamicFlags::FLEXIBLE,
3321            ___deadline,
3322        )?
3323        .into_result::<StreamSocketMarker>("bind")?;
3324        Ok(_response.map(|x| x))
3325    }
3326
3327    /// Initiate a connection to |remote_address|.
3328    /// When the connection attempt completes the signal SIGNAL_STREAM_CONNECTED
3329    /// will be asserted on the data plane zx.Handle:SOCKET.
3330    pub fn r#connect(
3331        &self,
3332        mut remote_address: &VsockAddress,
3333        ___deadline: zx::MonotonicInstant,
3334    ) -> Result<StreamSocketConnectResult, fidl::Error> {
3335        let _response = self.client.send_query::<
3336            StreamSocketConnectRequest,
3337            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3338        >(
3339            (remote_address,),
3340            0x50822e8e18b27e75,
3341            fidl::encoding::DynamicFlags::FLEXIBLE,
3342            ___deadline,
3343        )?
3344        .into_result::<StreamSocketMarker>("connect")?;
3345        Ok(_response.map(|x| x))
3346    }
3347
3348    /// Places this socket into listening mode with a specified backlog.
3349    /// When a new connection is available the signal SIGNAL_STREAM_INCOMING
3350    /// will be asserted on the data plane zx.Handle:SOCKET.
3351    pub fn r#listen(
3352        &self,
3353        mut backlog: i32,
3354        ___deadline: zx::MonotonicInstant,
3355    ) -> Result<StreamSocketListenResult, fidl::Error> {
3356        let _response = self.client.send_query::<
3357            StreamSocketListenRequest,
3358            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3359        >(
3360            (backlog,),
3361            0x4a5b1f2bc958287f,
3362            fidl::encoding::DynamicFlags::FLEXIBLE,
3363            ___deadline,
3364        )?
3365        .into_result::<StreamSocketMarker>("listen")?;
3366        Ok(_response.map(|x| x))
3367    }
3368
3369    /// Accepts a connection from this socket's listen backlog and binds it to
3370    /// |socket| with data plane |data|.
3371    /// If |want_addr| is true, returns the address of the accepted socket.
3372    /// When this call returns, if SIGNAL_STREAM_INCOMING is asserted another
3373    /// incoming connection is available.
3374    pub fn r#accept(
3375        &self,
3376        mut want_addr: bool,
3377        ___deadline: zx::MonotonicInstant,
3378    ) -> Result<StreamSocketAcceptResult, fidl::Error> {
3379        let _response = self.client.send_query::<
3380            StreamSocketAcceptRequest,
3381            fidl::encoding::FlexibleResultType<StreamSocketAcceptResponse, Error>,
3382        >(
3383            (want_addr,),
3384            0x10d5fe50cbe19aea,
3385            fidl::encoding::DynamicFlags::FLEXIBLE,
3386            ___deadline,
3387        )?
3388        .into_result::<StreamSocketMarker>("accept")?;
3389        Ok(_response.map(|x| x))
3390    }
3391
3392    /// Retrieves the local socket address.
3393    pub fn r#get_sock_name(
3394        &self,
3395        ___deadline: zx::MonotonicInstant,
3396    ) -> Result<StreamSocketGetSockNameResult, fidl::Error> {
3397        let _response = self.client.send_query::<
3398            fidl::encoding::EmptyPayload,
3399            fidl::encoding::FlexibleResultType<StreamSocketGetSockNameResponse, Error>,
3400        >(
3401            (),
3402            0x2011f4a50477ec73,
3403            fidl::encoding::DynamicFlags::FLEXIBLE,
3404            ___deadline,
3405        )?
3406        .into_result::<StreamSocketMarker>("get_sock_name")?;
3407        Ok(_response.map(|x| x.addr))
3408    }
3409
3410    /// Retrieves the remote socket address.
3411    pub fn r#get_peer_name(
3412        &self,
3413        ___deadline: zx::MonotonicInstant,
3414    ) -> Result<StreamSocketGetPeerNameResult, fidl::Error> {
3415        let _response = self.client.send_query::<
3416            fidl::encoding::EmptyPayload,
3417            fidl::encoding::FlexibleResultType<StreamSocketGetPeerNameResponse, Error>,
3418        >(
3419            (),
3420            0x6165feb6a459fb8,
3421            fidl::encoding::DynamicFlags::FLEXIBLE,
3422            ___deadline,
3423        )?
3424        .into_result::<StreamSocketMarker>("get_peer_name")?;
3425        Ok(_response.map(|x| x.addr))
3426    }
3427
3428    /// Get `SOL_SOCKET` -> `SO_ERROR`
3429    pub fn r#get_error(
3430        &self,
3431        ___deadline: zx::MonotonicInstant,
3432    ) -> Result<StreamSocketGetErrorResult, fidl::Error> {
3433        let _response = self.client.send_query::<
3434            fidl::encoding::EmptyPayload,
3435            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3436        >(
3437            (),
3438            0x18b3da9cea924b38,
3439            fidl::encoding::DynamicFlags::FLEXIBLE,
3440            ___deadline,
3441        )?
3442        .into_result::<StreamSocketMarker>("get_error")?;
3443        Ok(_response.map(|x| x))
3444    }
3445}
3446
3447#[cfg(target_os = "fuchsia")]
3448impl From<StreamSocketSynchronousProxy> for zx::NullableHandle {
3449    fn from(value: StreamSocketSynchronousProxy) -> Self {
3450        value.into_channel().into()
3451    }
3452}
3453
3454#[cfg(target_os = "fuchsia")]
3455impl From<fidl::Channel> for StreamSocketSynchronousProxy {
3456    fn from(value: fidl::Channel) -> Self {
3457        Self::new(value)
3458    }
3459}
3460
3461#[cfg(target_os = "fuchsia")]
3462impl fidl::endpoints::FromClient for StreamSocketSynchronousProxy {
3463    type Protocol = StreamSocketMarker;
3464
3465    fn from_client(value: fidl::endpoints::ClientEnd<StreamSocketMarker>) -> Self {
3466        Self::new(value.into_channel())
3467    }
3468}
3469
3470#[derive(Debug, Clone)]
3471pub struct StreamSocketProxy {
3472    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3473}
3474
3475impl fidl::endpoints::Proxy for StreamSocketProxy {
3476    type Protocol = StreamSocketMarker;
3477
3478    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3479        Self::new(inner)
3480    }
3481
3482    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3483        self.client.into_channel().map_err(|client| Self { client })
3484    }
3485
3486    fn as_channel(&self) -> &::fidl::AsyncChannel {
3487        self.client.as_channel()
3488    }
3489}
3490
3491impl StreamSocketProxy {
3492    /// Create a new Proxy for fuchsia.vsock/StreamSocket.
3493    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3494        let protocol_name = <StreamSocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3495        Self { client: fidl::client::Client::new(channel, protocol_name) }
3496    }
3497
3498    /// Get a Stream of events from the remote end of the protocol.
3499    ///
3500    /// # Panics
3501    ///
3502    /// Panics if the event stream was already taken.
3503    pub fn take_event_stream(&self) -> StreamSocketEventStream {
3504        StreamSocketEventStream { event_receiver: self.client.take_event_receiver() }
3505    }
3506
3507    /// Terminates the connection.
3508    ///
3509    /// After calling `Close`, the client must not send any other requests.
3510    ///
3511    /// Servers, after sending the status response, should close the connection
3512    /// regardless of status and without sending an epitaph.
3513    ///
3514    /// Closing the client end of the channel should be semantically equivalent
3515    /// to calling `Close` without knowing when the close has completed or its
3516    /// status.
3517    pub fn r#close(
3518        &self,
3519    ) -> fidl::client::QueryResponseFut<
3520        fidl_fuchsia_unknown::CloseableCloseResult,
3521        fidl::encoding::DefaultFuchsiaResourceDialect,
3522    > {
3523        StreamSocketProxyInterface::r#close(self)
3524    }
3525
3526    /// Bind this socket to a specific address.
3527    pub fn r#bind(
3528        &self,
3529        mut addr: &VsockAddress,
3530    ) -> fidl::client::QueryResponseFut<
3531        StreamSocketBindResult,
3532        fidl::encoding::DefaultFuchsiaResourceDialect,
3533    > {
3534        StreamSocketProxyInterface::r#bind(self, addr)
3535    }
3536
3537    /// Initiate a connection to |remote_address|.
3538    /// When the connection attempt completes the signal SIGNAL_STREAM_CONNECTED
3539    /// will be asserted on the data plane zx.Handle:SOCKET.
3540    pub fn r#connect(
3541        &self,
3542        mut remote_address: &VsockAddress,
3543    ) -> fidl::client::QueryResponseFut<
3544        StreamSocketConnectResult,
3545        fidl::encoding::DefaultFuchsiaResourceDialect,
3546    > {
3547        StreamSocketProxyInterface::r#connect(self, remote_address)
3548    }
3549
3550    /// Places this socket into listening mode with a specified backlog.
3551    /// When a new connection is available the signal SIGNAL_STREAM_INCOMING
3552    /// will be asserted on the data plane zx.Handle:SOCKET.
3553    pub fn r#listen(
3554        &self,
3555        mut backlog: i32,
3556    ) -> fidl::client::QueryResponseFut<
3557        StreamSocketListenResult,
3558        fidl::encoding::DefaultFuchsiaResourceDialect,
3559    > {
3560        StreamSocketProxyInterface::r#listen(self, backlog)
3561    }
3562
3563    /// Accepts a connection from this socket's listen backlog and binds it to
3564    /// |socket| with data plane |data|.
3565    /// If |want_addr| is true, returns the address of the accepted socket.
3566    /// When this call returns, if SIGNAL_STREAM_INCOMING is asserted another
3567    /// incoming connection is available.
3568    pub fn r#accept(
3569        &self,
3570        mut want_addr: bool,
3571    ) -> fidl::client::QueryResponseFut<
3572        StreamSocketAcceptResult,
3573        fidl::encoding::DefaultFuchsiaResourceDialect,
3574    > {
3575        StreamSocketProxyInterface::r#accept(self, want_addr)
3576    }
3577
3578    /// Retrieves the local socket address.
3579    pub fn r#get_sock_name(
3580        &self,
3581    ) -> fidl::client::QueryResponseFut<
3582        StreamSocketGetSockNameResult,
3583        fidl::encoding::DefaultFuchsiaResourceDialect,
3584    > {
3585        StreamSocketProxyInterface::r#get_sock_name(self)
3586    }
3587
3588    /// Retrieves the remote socket address.
3589    pub fn r#get_peer_name(
3590        &self,
3591    ) -> fidl::client::QueryResponseFut<
3592        StreamSocketGetPeerNameResult,
3593        fidl::encoding::DefaultFuchsiaResourceDialect,
3594    > {
3595        StreamSocketProxyInterface::r#get_peer_name(self)
3596    }
3597
3598    /// Get `SOL_SOCKET` -> `SO_ERROR`
3599    pub fn r#get_error(
3600        &self,
3601    ) -> fidl::client::QueryResponseFut<
3602        StreamSocketGetErrorResult,
3603        fidl::encoding::DefaultFuchsiaResourceDialect,
3604    > {
3605        StreamSocketProxyInterface::r#get_error(self)
3606    }
3607}
3608
3609impl StreamSocketProxyInterface for StreamSocketProxy {
3610    type CloseResponseFut = fidl::client::QueryResponseFut<
3611        fidl_fuchsia_unknown::CloseableCloseResult,
3612        fidl::encoding::DefaultFuchsiaResourceDialect,
3613    >;
3614    fn r#close(&self) -> Self::CloseResponseFut {
3615        fn _decode(
3616            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3617        ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
3618            let _response = fidl::client::decode_transaction_body::<
3619                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3620                fidl::encoding::DefaultFuchsiaResourceDialect,
3621                0x5ac5d459ad7f657e,
3622            >(_buf?)?;
3623            Ok(_response.map(|x| x))
3624        }
3625        self.client.send_query_and_decode::<
3626            fidl::encoding::EmptyPayload,
3627            fidl_fuchsia_unknown::CloseableCloseResult,
3628        >(
3629            (),
3630            0x5ac5d459ad7f657e,
3631            fidl::encoding::DynamicFlags::empty(),
3632            _decode,
3633        )
3634    }
3635
3636    type BindResponseFut = fidl::client::QueryResponseFut<
3637        StreamSocketBindResult,
3638        fidl::encoding::DefaultFuchsiaResourceDialect,
3639    >;
3640    fn r#bind(&self, mut addr: &VsockAddress) -> Self::BindResponseFut {
3641        fn _decode(
3642            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3643        ) -> Result<StreamSocketBindResult, fidl::Error> {
3644            let _response = fidl::client::decode_transaction_body::<
3645                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3646                fidl::encoding::DefaultFuchsiaResourceDialect,
3647                0x72dc3c63cf24329,
3648            >(_buf?)?
3649            .into_result::<StreamSocketMarker>("bind")?;
3650            Ok(_response.map(|x| x))
3651        }
3652        self.client.send_query_and_decode::<StreamSocketBindRequest, StreamSocketBindResult>(
3653            (addr,),
3654            0x72dc3c63cf24329,
3655            fidl::encoding::DynamicFlags::FLEXIBLE,
3656            _decode,
3657        )
3658    }
3659
3660    type ConnectResponseFut = fidl::client::QueryResponseFut<
3661        StreamSocketConnectResult,
3662        fidl::encoding::DefaultFuchsiaResourceDialect,
3663    >;
3664    fn r#connect(&self, mut remote_address: &VsockAddress) -> Self::ConnectResponseFut {
3665        fn _decode(
3666            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3667        ) -> Result<StreamSocketConnectResult, fidl::Error> {
3668            let _response = fidl::client::decode_transaction_body::<
3669                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3670                fidl::encoding::DefaultFuchsiaResourceDialect,
3671                0x50822e8e18b27e75,
3672            >(_buf?)?
3673            .into_result::<StreamSocketMarker>("connect")?;
3674            Ok(_response.map(|x| x))
3675        }
3676        self.client.send_query_and_decode::<StreamSocketConnectRequest, StreamSocketConnectResult>(
3677            (remote_address,),
3678            0x50822e8e18b27e75,
3679            fidl::encoding::DynamicFlags::FLEXIBLE,
3680            _decode,
3681        )
3682    }
3683
3684    type ListenResponseFut = fidl::client::QueryResponseFut<
3685        StreamSocketListenResult,
3686        fidl::encoding::DefaultFuchsiaResourceDialect,
3687    >;
3688    fn r#listen(&self, mut backlog: i32) -> Self::ListenResponseFut {
3689        fn _decode(
3690            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3691        ) -> Result<StreamSocketListenResult, fidl::Error> {
3692            let _response = fidl::client::decode_transaction_body::<
3693                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3694                fidl::encoding::DefaultFuchsiaResourceDialect,
3695                0x4a5b1f2bc958287f,
3696            >(_buf?)?
3697            .into_result::<StreamSocketMarker>("listen")?;
3698            Ok(_response.map(|x| x))
3699        }
3700        self.client.send_query_and_decode::<StreamSocketListenRequest, StreamSocketListenResult>(
3701            (backlog,),
3702            0x4a5b1f2bc958287f,
3703            fidl::encoding::DynamicFlags::FLEXIBLE,
3704            _decode,
3705        )
3706    }
3707
3708    type AcceptResponseFut = fidl::client::QueryResponseFut<
3709        StreamSocketAcceptResult,
3710        fidl::encoding::DefaultFuchsiaResourceDialect,
3711    >;
3712    fn r#accept(&self, mut want_addr: bool) -> Self::AcceptResponseFut {
3713        fn _decode(
3714            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3715        ) -> Result<StreamSocketAcceptResult, fidl::Error> {
3716            let _response = fidl::client::decode_transaction_body::<
3717                fidl::encoding::FlexibleResultType<StreamSocketAcceptResponse, Error>,
3718                fidl::encoding::DefaultFuchsiaResourceDialect,
3719                0x10d5fe50cbe19aea,
3720            >(_buf?)?
3721            .into_result::<StreamSocketMarker>("accept")?;
3722            Ok(_response.map(|x| x))
3723        }
3724        self.client.send_query_and_decode::<StreamSocketAcceptRequest, StreamSocketAcceptResult>(
3725            (want_addr,),
3726            0x10d5fe50cbe19aea,
3727            fidl::encoding::DynamicFlags::FLEXIBLE,
3728            _decode,
3729        )
3730    }
3731
3732    type GetSockNameResponseFut = fidl::client::QueryResponseFut<
3733        StreamSocketGetSockNameResult,
3734        fidl::encoding::DefaultFuchsiaResourceDialect,
3735    >;
3736    fn r#get_sock_name(&self) -> Self::GetSockNameResponseFut {
3737        fn _decode(
3738            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3739        ) -> Result<StreamSocketGetSockNameResult, fidl::Error> {
3740            let _response = fidl::client::decode_transaction_body::<
3741                fidl::encoding::FlexibleResultType<StreamSocketGetSockNameResponse, Error>,
3742                fidl::encoding::DefaultFuchsiaResourceDialect,
3743                0x2011f4a50477ec73,
3744            >(_buf?)?
3745            .into_result::<StreamSocketMarker>("get_sock_name")?;
3746            Ok(_response.map(|x| x.addr))
3747        }
3748        self.client
3749            .send_query_and_decode::<fidl::encoding::EmptyPayload, StreamSocketGetSockNameResult>(
3750                (),
3751                0x2011f4a50477ec73,
3752                fidl::encoding::DynamicFlags::FLEXIBLE,
3753                _decode,
3754            )
3755    }
3756
3757    type GetPeerNameResponseFut = fidl::client::QueryResponseFut<
3758        StreamSocketGetPeerNameResult,
3759        fidl::encoding::DefaultFuchsiaResourceDialect,
3760    >;
3761    fn r#get_peer_name(&self) -> Self::GetPeerNameResponseFut {
3762        fn _decode(
3763            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3764        ) -> Result<StreamSocketGetPeerNameResult, fidl::Error> {
3765            let _response = fidl::client::decode_transaction_body::<
3766                fidl::encoding::FlexibleResultType<StreamSocketGetPeerNameResponse, Error>,
3767                fidl::encoding::DefaultFuchsiaResourceDialect,
3768                0x6165feb6a459fb8,
3769            >(_buf?)?
3770            .into_result::<StreamSocketMarker>("get_peer_name")?;
3771            Ok(_response.map(|x| x.addr))
3772        }
3773        self.client
3774            .send_query_and_decode::<fidl::encoding::EmptyPayload, StreamSocketGetPeerNameResult>(
3775                (),
3776                0x6165feb6a459fb8,
3777                fidl::encoding::DynamicFlags::FLEXIBLE,
3778                _decode,
3779            )
3780    }
3781
3782    type GetErrorResponseFut = fidl::client::QueryResponseFut<
3783        StreamSocketGetErrorResult,
3784        fidl::encoding::DefaultFuchsiaResourceDialect,
3785    >;
3786    fn r#get_error(&self) -> Self::GetErrorResponseFut {
3787        fn _decode(
3788            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3789        ) -> Result<StreamSocketGetErrorResult, fidl::Error> {
3790            let _response = fidl::client::decode_transaction_body::<
3791                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3792                fidl::encoding::DefaultFuchsiaResourceDialect,
3793                0x18b3da9cea924b38,
3794            >(_buf?)?
3795            .into_result::<StreamSocketMarker>("get_error")?;
3796            Ok(_response.map(|x| x))
3797        }
3798        self.client
3799            .send_query_and_decode::<fidl::encoding::EmptyPayload, StreamSocketGetErrorResult>(
3800                (),
3801                0x18b3da9cea924b38,
3802                fidl::encoding::DynamicFlags::FLEXIBLE,
3803                _decode,
3804            )
3805    }
3806}
3807
3808pub struct StreamSocketEventStream {
3809    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3810}
3811
3812impl std::marker::Unpin for StreamSocketEventStream {}
3813
3814impl futures::stream::FusedStream for StreamSocketEventStream {
3815    fn is_terminated(&self) -> bool {
3816        self.event_receiver.is_terminated()
3817    }
3818}
3819
3820impl futures::Stream for StreamSocketEventStream {
3821    type Item = Result<StreamSocketEvent, fidl::Error>;
3822
3823    fn poll_next(
3824        mut self: std::pin::Pin<&mut Self>,
3825        cx: &mut std::task::Context<'_>,
3826    ) -> std::task::Poll<Option<Self::Item>> {
3827        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3828            &mut self.event_receiver,
3829            cx
3830        )?) {
3831            Some(buf) => std::task::Poll::Ready(Some(StreamSocketEvent::decode(buf))),
3832            None => std::task::Poll::Ready(None),
3833        }
3834    }
3835}
3836
3837#[derive(Debug)]
3838pub enum StreamSocketEvent {
3839    #[non_exhaustive]
3840    _UnknownEvent {
3841        /// Ordinal of the event that was sent.
3842        ordinal: u64,
3843    },
3844}
3845
3846impl StreamSocketEvent {
3847    /// Decodes a message buffer as a [`StreamSocketEvent`].
3848    fn decode(
3849        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3850    ) -> Result<StreamSocketEvent, fidl::Error> {
3851        let (bytes, _handles) = buf.split_mut();
3852        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3853        debug_assert_eq!(tx_header.tx_id, 0);
3854        match tx_header.ordinal {
3855            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3856                Ok(StreamSocketEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3857            }
3858            _ => Err(fidl::Error::UnknownOrdinal {
3859                ordinal: tx_header.ordinal,
3860                protocol_name: <StreamSocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3861            }),
3862        }
3863    }
3864}
3865
3866/// A Stream of incoming requests for fuchsia.vsock/StreamSocket.
3867pub struct StreamSocketRequestStream {
3868    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3869    is_terminated: bool,
3870}
3871
3872impl std::marker::Unpin for StreamSocketRequestStream {}
3873
3874impl futures::stream::FusedStream for StreamSocketRequestStream {
3875    fn is_terminated(&self) -> bool {
3876        self.is_terminated
3877    }
3878}
3879
3880impl fidl::endpoints::RequestStream for StreamSocketRequestStream {
3881    type Protocol = StreamSocketMarker;
3882    type ControlHandle = StreamSocketControlHandle;
3883
3884    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3885        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3886    }
3887
3888    fn control_handle(&self) -> Self::ControlHandle {
3889        StreamSocketControlHandle { inner: self.inner.clone() }
3890    }
3891
3892    fn into_inner(
3893        self,
3894    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3895    {
3896        (self.inner, self.is_terminated)
3897    }
3898
3899    fn from_inner(
3900        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3901        is_terminated: bool,
3902    ) -> Self {
3903        Self { inner, is_terminated }
3904    }
3905}
3906
3907impl futures::Stream for StreamSocketRequestStream {
3908    type Item = Result<StreamSocketRequest, fidl::Error>;
3909
3910    fn poll_next(
3911        mut self: std::pin::Pin<&mut Self>,
3912        cx: &mut std::task::Context<'_>,
3913    ) -> std::task::Poll<Option<Self::Item>> {
3914        let this = &mut *self;
3915        if this.inner.check_shutdown(cx) {
3916            this.is_terminated = true;
3917            return std::task::Poll::Ready(None);
3918        }
3919        if this.is_terminated {
3920            panic!("polled StreamSocketRequestStream after completion");
3921        }
3922        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3923            |bytes, handles| {
3924                match this.inner.channel().read_etc(cx, bytes, handles) {
3925                    std::task::Poll::Ready(Ok(())) => {}
3926                    std::task::Poll::Pending => return std::task::Poll::Pending,
3927                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3928                        this.is_terminated = true;
3929                        return std::task::Poll::Ready(None);
3930                    }
3931                    std::task::Poll::Ready(Err(e)) => {
3932                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3933                            e.into(),
3934                        ))));
3935                    }
3936                }
3937
3938                // A message has been received from the channel
3939                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3940
3941                std::task::Poll::Ready(Some(match header.ordinal {
3942                    0x5ac5d459ad7f657e => {
3943                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3944                        let mut req = fidl::new_empty!(
3945                            fidl::encoding::EmptyPayload,
3946                            fidl::encoding::DefaultFuchsiaResourceDialect
3947                        );
3948                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3949                        let control_handle =
3950                            StreamSocketControlHandle { inner: this.inner.clone() };
3951                        Ok(StreamSocketRequest::Close {
3952                            responder: StreamSocketCloseResponder {
3953                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3954                                tx_id: header.tx_id,
3955                            },
3956                        })
3957                    }
3958                    0x72dc3c63cf24329 => {
3959                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3960                        let mut req = fidl::new_empty!(
3961                            StreamSocketBindRequest,
3962                            fidl::encoding::DefaultFuchsiaResourceDialect
3963                        );
3964                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSocketBindRequest>(&header, _body_bytes, handles, &mut req)?;
3965                        let control_handle =
3966                            StreamSocketControlHandle { inner: this.inner.clone() };
3967                        Ok(StreamSocketRequest::Bind {
3968                            addr: req.addr,
3969
3970                            responder: StreamSocketBindResponder {
3971                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3972                                tx_id: header.tx_id,
3973                            },
3974                        })
3975                    }
3976                    0x50822e8e18b27e75 => {
3977                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3978                        let mut req = fidl::new_empty!(
3979                            StreamSocketConnectRequest,
3980                            fidl::encoding::DefaultFuchsiaResourceDialect
3981                        );
3982                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSocketConnectRequest>(&header, _body_bytes, handles, &mut req)?;
3983                        let control_handle =
3984                            StreamSocketControlHandle { inner: this.inner.clone() };
3985                        Ok(StreamSocketRequest::Connect {
3986                            remote_address: req.remote_address,
3987
3988                            responder: StreamSocketConnectResponder {
3989                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3990                                tx_id: header.tx_id,
3991                            },
3992                        })
3993                    }
3994                    0x4a5b1f2bc958287f => {
3995                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3996                        let mut req = fidl::new_empty!(
3997                            StreamSocketListenRequest,
3998                            fidl::encoding::DefaultFuchsiaResourceDialect
3999                        );
4000                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSocketListenRequest>(&header, _body_bytes, handles, &mut req)?;
4001                        let control_handle =
4002                            StreamSocketControlHandle { inner: this.inner.clone() };
4003                        Ok(StreamSocketRequest::Listen {
4004                            backlog: req.backlog,
4005
4006                            responder: StreamSocketListenResponder {
4007                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4008                                tx_id: header.tx_id,
4009                            },
4010                        })
4011                    }
4012                    0x10d5fe50cbe19aea => {
4013                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4014                        let mut req = fidl::new_empty!(
4015                            StreamSocketAcceptRequest,
4016                            fidl::encoding::DefaultFuchsiaResourceDialect
4017                        );
4018                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSocketAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
4019                        let control_handle =
4020                            StreamSocketControlHandle { inner: this.inner.clone() };
4021                        Ok(StreamSocketRequest::Accept {
4022                            want_addr: req.want_addr,
4023
4024                            responder: StreamSocketAcceptResponder {
4025                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4026                                tx_id: header.tx_id,
4027                            },
4028                        })
4029                    }
4030                    0x2011f4a50477ec73 => {
4031                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4032                        let mut req = fidl::new_empty!(
4033                            fidl::encoding::EmptyPayload,
4034                            fidl::encoding::DefaultFuchsiaResourceDialect
4035                        );
4036                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4037                        let control_handle =
4038                            StreamSocketControlHandle { inner: this.inner.clone() };
4039                        Ok(StreamSocketRequest::GetSockName {
4040                            responder: StreamSocketGetSockNameResponder {
4041                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4042                                tx_id: header.tx_id,
4043                            },
4044                        })
4045                    }
4046                    0x6165feb6a459fb8 => {
4047                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4048                        let mut req = fidl::new_empty!(
4049                            fidl::encoding::EmptyPayload,
4050                            fidl::encoding::DefaultFuchsiaResourceDialect
4051                        );
4052                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4053                        let control_handle =
4054                            StreamSocketControlHandle { inner: this.inner.clone() };
4055                        Ok(StreamSocketRequest::GetPeerName {
4056                            responder: StreamSocketGetPeerNameResponder {
4057                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4058                                tx_id: header.tx_id,
4059                            },
4060                        })
4061                    }
4062                    0x18b3da9cea924b38 => {
4063                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4064                        let mut req = fidl::new_empty!(
4065                            fidl::encoding::EmptyPayload,
4066                            fidl::encoding::DefaultFuchsiaResourceDialect
4067                        );
4068                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4069                        let control_handle =
4070                            StreamSocketControlHandle { inner: this.inner.clone() };
4071                        Ok(StreamSocketRequest::GetError {
4072                            responder: StreamSocketGetErrorResponder {
4073                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4074                                tx_id: header.tx_id,
4075                            },
4076                        })
4077                    }
4078                    _ if header.tx_id == 0
4079                        && header
4080                            .dynamic_flags()
4081                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4082                    {
4083                        Ok(StreamSocketRequest::_UnknownMethod {
4084                            ordinal: header.ordinal,
4085                            control_handle: StreamSocketControlHandle { inner: this.inner.clone() },
4086                            method_type: fidl::MethodType::OneWay,
4087                        })
4088                    }
4089                    _ if header
4090                        .dynamic_flags()
4091                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4092                    {
4093                        this.inner.send_framework_err(
4094                            fidl::encoding::FrameworkErr::UnknownMethod,
4095                            header.tx_id,
4096                            header.ordinal,
4097                            header.dynamic_flags(),
4098                            (bytes, handles),
4099                        )?;
4100                        Ok(StreamSocketRequest::_UnknownMethod {
4101                            ordinal: header.ordinal,
4102                            control_handle: StreamSocketControlHandle { inner: this.inner.clone() },
4103                            method_type: fidl::MethodType::TwoWay,
4104                        })
4105                    }
4106                    _ => Err(fidl::Error::UnknownOrdinal {
4107                        ordinal: header.ordinal,
4108                        protocol_name:
4109                            <StreamSocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4110                    }),
4111                }))
4112            },
4113        )
4114    }
4115}
4116
4117/// StreamSocket represents the control plane for a single virtio-socket stream
4118/// socket.
4119#[derive(Debug)]
4120pub enum StreamSocketRequest {
4121    /// Terminates the connection.
4122    ///
4123    /// After calling `Close`, the client must not send any other requests.
4124    ///
4125    /// Servers, after sending the status response, should close the connection
4126    /// regardless of status and without sending an epitaph.
4127    ///
4128    /// Closing the client end of the channel should be semantically equivalent
4129    /// to calling `Close` without knowing when the close has completed or its
4130    /// status.
4131    Close { responder: StreamSocketCloseResponder },
4132    /// Bind this socket to a specific address.
4133    Bind { addr: VsockAddress, responder: StreamSocketBindResponder },
4134    /// Initiate a connection to |remote_address|.
4135    /// When the connection attempt completes the signal SIGNAL_STREAM_CONNECTED
4136    /// will be asserted on the data plane zx.Handle:SOCKET.
4137    Connect { remote_address: VsockAddress, responder: StreamSocketConnectResponder },
4138    /// Places this socket into listening mode with a specified backlog.
4139    /// When a new connection is available the signal SIGNAL_STREAM_INCOMING
4140    /// will be asserted on the data plane zx.Handle:SOCKET.
4141    Listen { backlog: i32, responder: StreamSocketListenResponder },
4142    /// Accepts a connection from this socket's listen backlog and binds it to
4143    /// |socket| with data plane |data|.
4144    /// If |want_addr| is true, returns the address of the accepted socket.
4145    /// When this call returns, if SIGNAL_STREAM_INCOMING is asserted another
4146    /// incoming connection is available.
4147    Accept { want_addr: bool, responder: StreamSocketAcceptResponder },
4148    /// Retrieves the local socket address.
4149    GetSockName { responder: StreamSocketGetSockNameResponder },
4150    /// Retrieves the remote socket address.
4151    GetPeerName { responder: StreamSocketGetPeerNameResponder },
4152    /// Get `SOL_SOCKET` -> `SO_ERROR`
4153    GetError { responder: StreamSocketGetErrorResponder },
4154    /// An interaction was received which does not match any known method.
4155    #[non_exhaustive]
4156    _UnknownMethod {
4157        /// Ordinal of the method that was called.
4158        ordinal: u64,
4159        control_handle: StreamSocketControlHandle,
4160        method_type: fidl::MethodType,
4161    },
4162}
4163
4164impl StreamSocketRequest {
4165    #[allow(irrefutable_let_patterns)]
4166    pub fn into_close(self) -> Option<(StreamSocketCloseResponder)> {
4167        if let StreamSocketRequest::Close { responder } = self { Some((responder)) } else { None }
4168    }
4169
4170    #[allow(irrefutable_let_patterns)]
4171    pub fn into_bind(self) -> Option<(VsockAddress, StreamSocketBindResponder)> {
4172        if let StreamSocketRequest::Bind { addr, responder } = self {
4173            Some((addr, responder))
4174        } else {
4175            None
4176        }
4177    }
4178
4179    #[allow(irrefutable_let_patterns)]
4180    pub fn into_connect(self) -> Option<(VsockAddress, StreamSocketConnectResponder)> {
4181        if let StreamSocketRequest::Connect { remote_address, responder } = self {
4182            Some((remote_address, responder))
4183        } else {
4184            None
4185        }
4186    }
4187
4188    #[allow(irrefutable_let_patterns)]
4189    pub fn into_listen(self) -> Option<(i32, StreamSocketListenResponder)> {
4190        if let StreamSocketRequest::Listen { backlog, responder } = self {
4191            Some((backlog, responder))
4192        } else {
4193            None
4194        }
4195    }
4196
4197    #[allow(irrefutable_let_patterns)]
4198    pub fn into_accept(self) -> Option<(bool, StreamSocketAcceptResponder)> {
4199        if let StreamSocketRequest::Accept { want_addr, responder } = self {
4200            Some((want_addr, responder))
4201        } else {
4202            None
4203        }
4204    }
4205
4206    #[allow(irrefutable_let_patterns)]
4207    pub fn into_get_sock_name(self) -> Option<(StreamSocketGetSockNameResponder)> {
4208        if let StreamSocketRequest::GetSockName { responder } = self {
4209            Some((responder))
4210        } else {
4211            None
4212        }
4213    }
4214
4215    #[allow(irrefutable_let_patterns)]
4216    pub fn into_get_peer_name(self) -> Option<(StreamSocketGetPeerNameResponder)> {
4217        if let StreamSocketRequest::GetPeerName { responder } = self {
4218            Some((responder))
4219        } else {
4220            None
4221        }
4222    }
4223
4224    #[allow(irrefutable_let_patterns)]
4225    pub fn into_get_error(self) -> Option<(StreamSocketGetErrorResponder)> {
4226        if let StreamSocketRequest::GetError { responder } = self {
4227            Some((responder))
4228        } else {
4229            None
4230        }
4231    }
4232
4233    /// Name of the method defined in FIDL
4234    pub fn method_name(&self) -> &'static str {
4235        match *self {
4236            StreamSocketRequest::Close { .. } => "close",
4237            StreamSocketRequest::Bind { .. } => "bind",
4238            StreamSocketRequest::Connect { .. } => "connect",
4239            StreamSocketRequest::Listen { .. } => "listen",
4240            StreamSocketRequest::Accept { .. } => "accept",
4241            StreamSocketRequest::GetSockName { .. } => "get_sock_name",
4242            StreamSocketRequest::GetPeerName { .. } => "get_peer_name",
4243            StreamSocketRequest::GetError { .. } => "get_error",
4244            StreamSocketRequest::_UnknownMethod {
4245                method_type: fidl::MethodType::OneWay, ..
4246            } => "unknown one-way method",
4247            StreamSocketRequest::_UnknownMethod {
4248                method_type: fidl::MethodType::TwoWay, ..
4249            } => "unknown two-way method",
4250        }
4251    }
4252}
4253
4254#[derive(Debug, Clone)]
4255pub struct StreamSocketControlHandle {
4256    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4257}
4258
4259impl fidl::endpoints::ControlHandle for StreamSocketControlHandle {
4260    fn shutdown(&self) {
4261        self.inner.shutdown()
4262    }
4263
4264    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4265        self.inner.shutdown_with_epitaph(status)
4266    }
4267
4268    fn is_closed(&self) -> bool {
4269        self.inner.channel().is_closed()
4270    }
4271    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4272        self.inner.channel().on_closed()
4273    }
4274
4275    #[cfg(target_os = "fuchsia")]
4276    fn signal_peer(
4277        &self,
4278        clear_mask: zx::Signals,
4279        set_mask: zx::Signals,
4280    ) -> Result<(), zx_status::Status> {
4281        use fidl::Peered;
4282        self.inner.channel().signal_peer(clear_mask, set_mask)
4283    }
4284}
4285
4286impl StreamSocketControlHandle {}
4287
4288#[must_use = "FIDL methods require a response to be sent"]
4289#[derive(Debug)]
4290pub struct StreamSocketCloseResponder {
4291    control_handle: std::mem::ManuallyDrop<StreamSocketControlHandle>,
4292    tx_id: u32,
4293}
4294
4295/// Set the the channel to be shutdown (see [`StreamSocketControlHandle::shutdown`])
4296/// if the responder is dropped without sending a response, so that the client
4297/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4298impl std::ops::Drop for StreamSocketCloseResponder {
4299    fn drop(&mut self) {
4300        self.control_handle.shutdown();
4301        // Safety: drops once, never accessed again
4302        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4303    }
4304}
4305
4306impl fidl::endpoints::Responder for StreamSocketCloseResponder {
4307    type ControlHandle = StreamSocketControlHandle;
4308
4309    fn control_handle(&self) -> &StreamSocketControlHandle {
4310        &self.control_handle
4311    }
4312
4313    fn drop_without_shutdown(mut self) {
4314        // Safety: drops once, never accessed again due to mem::forget
4315        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4316        // Prevent Drop from running (which would shut down the channel)
4317        std::mem::forget(self);
4318    }
4319}
4320
4321impl StreamSocketCloseResponder {
4322    /// Sends a response to the FIDL transaction.
4323    ///
4324    /// Sets the channel to shutdown if an error occurs.
4325    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4326        let _result = self.send_raw(result);
4327        if _result.is_err() {
4328            self.control_handle.shutdown();
4329        }
4330        self.drop_without_shutdown();
4331        _result
4332    }
4333
4334    /// Similar to "send" but does not shutdown the channel if an error occurs.
4335    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4336        let _result = self.send_raw(result);
4337        self.drop_without_shutdown();
4338        _result
4339    }
4340
4341    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4342        self.control_handle
4343            .inner
4344            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4345                result,
4346                self.tx_id,
4347                0x5ac5d459ad7f657e,
4348                fidl::encoding::DynamicFlags::empty(),
4349            )
4350    }
4351}
4352
4353#[must_use = "FIDL methods require a response to be sent"]
4354#[derive(Debug)]
4355pub struct StreamSocketBindResponder {
4356    control_handle: std::mem::ManuallyDrop<StreamSocketControlHandle>,
4357    tx_id: u32,
4358}
4359
4360/// Set the the channel to be shutdown (see [`StreamSocketControlHandle::shutdown`])
4361/// if the responder is dropped without sending a response, so that the client
4362/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4363impl std::ops::Drop for StreamSocketBindResponder {
4364    fn drop(&mut self) {
4365        self.control_handle.shutdown();
4366        // Safety: drops once, never accessed again
4367        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4368    }
4369}
4370
4371impl fidl::endpoints::Responder for StreamSocketBindResponder {
4372    type ControlHandle = StreamSocketControlHandle;
4373
4374    fn control_handle(&self) -> &StreamSocketControlHandle {
4375        &self.control_handle
4376    }
4377
4378    fn drop_without_shutdown(mut self) {
4379        // Safety: drops once, never accessed again due to mem::forget
4380        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4381        // Prevent Drop from running (which would shut down the channel)
4382        std::mem::forget(self);
4383    }
4384}
4385
4386impl StreamSocketBindResponder {
4387    /// Sends a response to the FIDL transaction.
4388    ///
4389    /// Sets the channel to shutdown if an error occurs.
4390    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4391        let _result = self.send_raw(result);
4392        if _result.is_err() {
4393            self.control_handle.shutdown();
4394        }
4395        self.drop_without_shutdown();
4396        _result
4397    }
4398
4399    /// Similar to "send" but does not shutdown the channel if an error occurs.
4400    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4401        let _result = self.send_raw(result);
4402        self.drop_without_shutdown();
4403        _result
4404    }
4405
4406    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4407        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4408            fidl::encoding::EmptyStruct,
4409            Error,
4410        >>(
4411            fidl::encoding::FlexibleResult::new(result),
4412            self.tx_id,
4413            0x72dc3c63cf24329,
4414            fidl::encoding::DynamicFlags::FLEXIBLE,
4415        )
4416    }
4417}
4418
4419#[must_use = "FIDL methods require a response to be sent"]
4420#[derive(Debug)]
4421pub struct StreamSocketConnectResponder {
4422    control_handle: std::mem::ManuallyDrop<StreamSocketControlHandle>,
4423    tx_id: u32,
4424}
4425
4426/// Set the the channel to be shutdown (see [`StreamSocketControlHandle::shutdown`])
4427/// if the responder is dropped without sending a response, so that the client
4428/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4429impl std::ops::Drop for StreamSocketConnectResponder {
4430    fn drop(&mut self) {
4431        self.control_handle.shutdown();
4432        // Safety: drops once, never accessed again
4433        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4434    }
4435}
4436
4437impl fidl::endpoints::Responder for StreamSocketConnectResponder {
4438    type ControlHandle = StreamSocketControlHandle;
4439
4440    fn control_handle(&self) -> &StreamSocketControlHandle {
4441        &self.control_handle
4442    }
4443
4444    fn drop_without_shutdown(mut self) {
4445        // Safety: drops once, never accessed again due to mem::forget
4446        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4447        // Prevent Drop from running (which would shut down the channel)
4448        std::mem::forget(self);
4449    }
4450}
4451
4452impl StreamSocketConnectResponder {
4453    /// Sends a response to the FIDL transaction.
4454    ///
4455    /// Sets the channel to shutdown if an error occurs.
4456    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4457        let _result = self.send_raw(result);
4458        if _result.is_err() {
4459            self.control_handle.shutdown();
4460        }
4461        self.drop_without_shutdown();
4462        _result
4463    }
4464
4465    /// Similar to "send" but does not shutdown the channel if an error occurs.
4466    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4467        let _result = self.send_raw(result);
4468        self.drop_without_shutdown();
4469        _result
4470    }
4471
4472    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4473        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4474            fidl::encoding::EmptyStruct,
4475            Error,
4476        >>(
4477            fidl::encoding::FlexibleResult::new(result),
4478            self.tx_id,
4479            0x50822e8e18b27e75,
4480            fidl::encoding::DynamicFlags::FLEXIBLE,
4481        )
4482    }
4483}
4484
4485#[must_use = "FIDL methods require a response to be sent"]
4486#[derive(Debug)]
4487pub struct StreamSocketListenResponder {
4488    control_handle: std::mem::ManuallyDrop<StreamSocketControlHandle>,
4489    tx_id: u32,
4490}
4491
4492/// Set the the channel to be shutdown (see [`StreamSocketControlHandle::shutdown`])
4493/// if the responder is dropped without sending a response, so that the client
4494/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4495impl std::ops::Drop for StreamSocketListenResponder {
4496    fn drop(&mut self) {
4497        self.control_handle.shutdown();
4498        // Safety: drops once, never accessed again
4499        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4500    }
4501}
4502
4503impl fidl::endpoints::Responder for StreamSocketListenResponder {
4504    type ControlHandle = StreamSocketControlHandle;
4505
4506    fn control_handle(&self) -> &StreamSocketControlHandle {
4507        &self.control_handle
4508    }
4509
4510    fn drop_without_shutdown(mut self) {
4511        // Safety: drops once, never accessed again due to mem::forget
4512        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4513        // Prevent Drop from running (which would shut down the channel)
4514        std::mem::forget(self);
4515    }
4516}
4517
4518impl StreamSocketListenResponder {
4519    /// Sends a response to the FIDL transaction.
4520    ///
4521    /// Sets the channel to shutdown if an error occurs.
4522    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4523        let _result = self.send_raw(result);
4524        if _result.is_err() {
4525            self.control_handle.shutdown();
4526        }
4527        self.drop_without_shutdown();
4528        _result
4529    }
4530
4531    /// Similar to "send" but does not shutdown the channel if an error occurs.
4532    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4533        let _result = self.send_raw(result);
4534        self.drop_without_shutdown();
4535        _result
4536    }
4537
4538    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4539        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4540            fidl::encoding::EmptyStruct,
4541            Error,
4542        >>(
4543            fidl::encoding::FlexibleResult::new(result),
4544            self.tx_id,
4545            0x4a5b1f2bc958287f,
4546            fidl::encoding::DynamicFlags::FLEXIBLE,
4547        )
4548    }
4549}
4550
4551#[must_use = "FIDL methods require a response to be sent"]
4552#[derive(Debug)]
4553pub struct StreamSocketAcceptResponder {
4554    control_handle: std::mem::ManuallyDrop<StreamSocketControlHandle>,
4555    tx_id: u32,
4556}
4557
4558/// Set the the channel to be shutdown (see [`StreamSocketControlHandle::shutdown`])
4559/// if the responder is dropped without sending a response, so that the client
4560/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4561impl std::ops::Drop for StreamSocketAcceptResponder {
4562    fn drop(&mut self) {
4563        self.control_handle.shutdown();
4564        // Safety: drops once, never accessed again
4565        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4566    }
4567}
4568
4569impl fidl::endpoints::Responder for StreamSocketAcceptResponder {
4570    type ControlHandle = StreamSocketControlHandle;
4571
4572    fn control_handle(&self) -> &StreamSocketControlHandle {
4573        &self.control_handle
4574    }
4575
4576    fn drop_without_shutdown(mut self) {
4577        // Safety: drops once, never accessed again due to mem::forget
4578        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4579        // Prevent Drop from running (which would shut down the channel)
4580        std::mem::forget(self);
4581    }
4582}
4583
4584impl StreamSocketAcceptResponder {
4585    /// Sends a response to the FIDL transaction.
4586    ///
4587    /// Sets the channel to shutdown if an error occurs.
4588    pub fn send(
4589        self,
4590        mut result: Result<StreamSocketAcceptResponse, Error>,
4591    ) -> Result<(), fidl::Error> {
4592        let _result = self.send_raw(result);
4593        if _result.is_err() {
4594            self.control_handle.shutdown();
4595        }
4596        self.drop_without_shutdown();
4597        _result
4598    }
4599
4600    /// Similar to "send" but does not shutdown the channel if an error occurs.
4601    pub fn send_no_shutdown_on_err(
4602        self,
4603        mut result: Result<StreamSocketAcceptResponse, Error>,
4604    ) -> Result<(), fidl::Error> {
4605        let _result = self.send_raw(result);
4606        self.drop_without_shutdown();
4607        _result
4608    }
4609
4610    fn send_raw(
4611        &self,
4612        mut result: Result<StreamSocketAcceptResponse, Error>,
4613    ) -> Result<(), fidl::Error> {
4614        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4615            StreamSocketAcceptResponse,
4616            Error,
4617        >>(
4618            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4619            self.tx_id,
4620            0x10d5fe50cbe19aea,
4621            fidl::encoding::DynamicFlags::FLEXIBLE,
4622        )
4623    }
4624}
4625
4626#[must_use = "FIDL methods require a response to be sent"]
4627#[derive(Debug)]
4628pub struct StreamSocketGetSockNameResponder {
4629    control_handle: std::mem::ManuallyDrop<StreamSocketControlHandle>,
4630    tx_id: u32,
4631}
4632
4633/// Set the the channel to be shutdown (see [`StreamSocketControlHandle::shutdown`])
4634/// if the responder is dropped without sending a response, so that the client
4635/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4636impl std::ops::Drop for StreamSocketGetSockNameResponder {
4637    fn drop(&mut self) {
4638        self.control_handle.shutdown();
4639        // Safety: drops once, never accessed again
4640        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4641    }
4642}
4643
4644impl fidl::endpoints::Responder for StreamSocketGetSockNameResponder {
4645    type ControlHandle = StreamSocketControlHandle;
4646
4647    fn control_handle(&self) -> &StreamSocketControlHandle {
4648        &self.control_handle
4649    }
4650
4651    fn drop_without_shutdown(mut self) {
4652        // Safety: drops once, never accessed again due to mem::forget
4653        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4654        // Prevent Drop from running (which would shut down the channel)
4655        std::mem::forget(self);
4656    }
4657}
4658
4659impl StreamSocketGetSockNameResponder {
4660    /// Sends a response to the FIDL transaction.
4661    ///
4662    /// Sets the channel to shutdown if an error occurs.
4663    pub fn send(self, mut result: Result<&VsockAddress, Error>) -> Result<(), fidl::Error> {
4664        let _result = self.send_raw(result);
4665        if _result.is_err() {
4666            self.control_handle.shutdown();
4667        }
4668        self.drop_without_shutdown();
4669        _result
4670    }
4671
4672    /// Similar to "send" but does not shutdown the channel if an error occurs.
4673    pub fn send_no_shutdown_on_err(
4674        self,
4675        mut result: Result<&VsockAddress, Error>,
4676    ) -> Result<(), fidl::Error> {
4677        let _result = self.send_raw(result);
4678        self.drop_without_shutdown();
4679        _result
4680    }
4681
4682    fn send_raw(&self, mut result: Result<&VsockAddress, Error>) -> Result<(), fidl::Error> {
4683        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4684            StreamSocketGetSockNameResponse,
4685            Error,
4686        >>(
4687            fidl::encoding::FlexibleResult::new(result.map(|addr| (addr,))),
4688            self.tx_id,
4689            0x2011f4a50477ec73,
4690            fidl::encoding::DynamicFlags::FLEXIBLE,
4691        )
4692    }
4693}
4694
4695#[must_use = "FIDL methods require a response to be sent"]
4696#[derive(Debug)]
4697pub struct StreamSocketGetPeerNameResponder {
4698    control_handle: std::mem::ManuallyDrop<StreamSocketControlHandle>,
4699    tx_id: u32,
4700}
4701
4702/// Set the the channel to be shutdown (see [`StreamSocketControlHandle::shutdown`])
4703/// if the responder is dropped without sending a response, so that the client
4704/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4705impl std::ops::Drop for StreamSocketGetPeerNameResponder {
4706    fn drop(&mut self) {
4707        self.control_handle.shutdown();
4708        // Safety: drops once, never accessed again
4709        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4710    }
4711}
4712
4713impl fidl::endpoints::Responder for StreamSocketGetPeerNameResponder {
4714    type ControlHandle = StreamSocketControlHandle;
4715
4716    fn control_handle(&self) -> &StreamSocketControlHandle {
4717        &self.control_handle
4718    }
4719
4720    fn drop_without_shutdown(mut self) {
4721        // Safety: drops once, never accessed again due to mem::forget
4722        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4723        // Prevent Drop from running (which would shut down the channel)
4724        std::mem::forget(self);
4725    }
4726}
4727
4728impl StreamSocketGetPeerNameResponder {
4729    /// Sends a response to the FIDL transaction.
4730    ///
4731    /// Sets the channel to shutdown if an error occurs.
4732    pub fn send(self, mut result: Result<&VsockAddress, Error>) -> Result<(), fidl::Error> {
4733        let _result = self.send_raw(result);
4734        if _result.is_err() {
4735            self.control_handle.shutdown();
4736        }
4737        self.drop_without_shutdown();
4738        _result
4739    }
4740
4741    /// Similar to "send" but does not shutdown the channel if an error occurs.
4742    pub fn send_no_shutdown_on_err(
4743        self,
4744        mut result: Result<&VsockAddress, Error>,
4745    ) -> Result<(), fidl::Error> {
4746        let _result = self.send_raw(result);
4747        self.drop_without_shutdown();
4748        _result
4749    }
4750
4751    fn send_raw(&self, mut result: Result<&VsockAddress, Error>) -> Result<(), fidl::Error> {
4752        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4753            StreamSocketGetPeerNameResponse,
4754            Error,
4755        >>(
4756            fidl::encoding::FlexibleResult::new(result.map(|addr| (addr,))),
4757            self.tx_id,
4758            0x6165feb6a459fb8,
4759            fidl::encoding::DynamicFlags::FLEXIBLE,
4760        )
4761    }
4762}
4763
4764#[must_use = "FIDL methods require a response to be sent"]
4765#[derive(Debug)]
4766pub struct StreamSocketGetErrorResponder {
4767    control_handle: std::mem::ManuallyDrop<StreamSocketControlHandle>,
4768    tx_id: u32,
4769}
4770
4771/// Set the the channel to be shutdown (see [`StreamSocketControlHandle::shutdown`])
4772/// if the responder is dropped without sending a response, so that the client
4773/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4774impl std::ops::Drop for StreamSocketGetErrorResponder {
4775    fn drop(&mut self) {
4776        self.control_handle.shutdown();
4777        // Safety: drops once, never accessed again
4778        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4779    }
4780}
4781
4782impl fidl::endpoints::Responder for StreamSocketGetErrorResponder {
4783    type ControlHandle = StreamSocketControlHandle;
4784
4785    fn control_handle(&self) -> &StreamSocketControlHandle {
4786        &self.control_handle
4787    }
4788
4789    fn drop_without_shutdown(mut self) {
4790        // Safety: drops once, never accessed again due to mem::forget
4791        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4792        // Prevent Drop from running (which would shut down the channel)
4793        std::mem::forget(self);
4794    }
4795}
4796
4797impl StreamSocketGetErrorResponder {
4798    /// Sends a response to the FIDL transaction.
4799    ///
4800    /// Sets the channel to shutdown if an error occurs.
4801    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4802        let _result = self.send_raw(result);
4803        if _result.is_err() {
4804            self.control_handle.shutdown();
4805        }
4806        self.drop_without_shutdown();
4807        _result
4808    }
4809
4810    /// Similar to "send" but does not shutdown the channel if an error occurs.
4811    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4812        let _result = self.send_raw(result);
4813        self.drop_without_shutdown();
4814        _result
4815    }
4816
4817    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4818        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4819            fidl::encoding::EmptyStruct,
4820            Error,
4821        >>(
4822            fidl::encoding::FlexibleResult::new(result),
4823            self.tx_id,
4824            0x18b3da9cea924b38,
4825            fidl::encoding::DynamicFlags::FLEXIBLE,
4826        )
4827    }
4828}
4829
4830mod internal {
4831    use super::*;
4832
4833    impl fidl::encoding::ResourceTypeMarker for AcceptorAcceptResponse {
4834        type Borrowed<'a> = &'a mut Self;
4835        fn take_or_borrow<'a>(
4836            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4837        ) -> Self::Borrowed<'a> {
4838            value
4839        }
4840    }
4841
4842    unsafe impl fidl::encoding::TypeMarker for AcceptorAcceptResponse {
4843        type Owned = Self;
4844
4845        #[inline(always)]
4846        fn inline_align(_context: fidl::encoding::Context) -> usize {
4847            8
4848        }
4849
4850        #[inline(always)]
4851        fn inline_size(_context: fidl::encoding::Context) -> usize {
4852            8
4853        }
4854    }
4855
4856    unsafe impl
4857        fidl::encoding::Encode<
4858            AcceptorAcceptResponse,
4859            fidl::encoding::DefaultFuchsiaResourceDialect,
4860        > for &mut AcceptorAcceptResponse
4861    {
4862        #[inline]
4863        unsafe fn encode(
4864            self,
4865            encoder: &mut fidl::encoding::Encoder<
4866                '_,
4867                fidl::encoding::DefaultFuchsiaResourceDialect,
4868            >,
4869            offset: usize,
4870            _depth: fidl::encoding::Depth,
4871        ) -> fidl::Result<()> {
4872            encoder.debug_check_bounds::<AcceptorAcceptResponse>(offset);
4873            // Delegate to tuple encoding.
4874            fidl::encoding::Encode::<AcceptorAcceptResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4875                (
4876                    <fidl::encoding::Boxed<ConnectionTransport> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.con),
4877                ),
4878                encoder, offset, _depth
4879            )
4880        }
4881    }
4882    unsafe impl<
4883        T0: fidl::encoding::Encode<
4884                fidl::encoding::Boxed<ConnectionTransport>,
4885                fidl::encoding::DefaultFuchsiaResourceDialect,
4886            >,
4887    >
4888        fidl::encoding::Encode<
4889            AcceptorAcceptResponse,
4890            fidl::encoding::DefaultFuchsiaResourceDialect,
4891        > for (T0,)
4892    {
4893        #[inline]
4894        unsafe fn encode(
4895            self,
4896            encoder: &mut fidl::encoding::Encoder<
4897                '_,
4898                fidl::encoding::DefaultFuchsiaResourceDialect,
4899            >,
4900            offset: usize,
4901            depth: fidl::encoding::Depth,
4902        ) -> fidl::Result<()> {
4903            encoder.debug_check_bounds::<AcceptorAcceptResponse>(offset);
4904            // Zero out padding regions. There's no need to apply masks
4905            // because the unmasked parts will be overwritten by fields.
4906            // Write the fields.
4907            self.0.encode(encoder, offset + 0, depth)?;
4908            Ok(())
4909        }
4910    }
4911
4912    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4913        for AcceptorAcceptResponse
4914    {
4915        #[inline(always)]
4916        fn new_empty() -> Self {
4917            Self {
4918                con: fidl::new_empty!(
4919                    fidl::encoding::Boxed<ConnectionTransport>,
4920                    fidl::encoding::DefaultFuchsiaResourceDialect
4921                ),
4922            }
4923        }
4924
4925        #[inline]
4926        unsafe fn decode(
4927            &mut self,
4928            decoder: &mut fidl::encoding::Decoder<
4929                '_,
4930                fidl::encoding::DefaultFuchsiaResourceDialect,
4931            >,
4932            offset: usize,
4933            _depth: fidl::encoding::Depth,
4934        ) -> fidl::Result<()> {
4935            decoder.debug_check_bounds::<Self>(offset);
4936            // Verify that padding bytes are zero.
4937            fidl::decode!(
4938                fidl::encoding::Boxed<ConnectionTransport>,
4939                fidl::encoding::DefaultFuchsiaResourceDialect,
4940                &mut self.con,
4941                decoder,
4942                offset + 0,
4943                _depth
4944            )?;
4945            Ok(())
4946        }
4947    }
4948
4949    impl fidl::encoding::ResourceTypeMarker for ConnectionTransport {
4950        type Borrowed<'a> = &'a mut Self;
4951        fn take_or_borrow<'a>(
4952            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4953        ) -> Self::Borrowed<'a> {
4954            value
4955        }
4956    }
4957
4958    unsafe impl fidl::encoding::TypeMarker for ConnectionTransport {
4959        type Owned = Self;
4960
4961        #[inline(always)]
4962        fn inline_align(_context: fidl::encoding::Context) -> usize {
4963            4
4964        }
4965
4966        #[inline(always)]
4967        fn inline_size(_context: fidl::encoding::Context) -> usize {
4968            8
4969        }
4970    }
4971
4972    unsafe impl
4973        fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>
4974        for &mut ConnectionTransport
4975    {
4976        #[inline]
4977        unsafe fn encode(
4978            self,
4979            encoder: &mut fidl::encoding::Encoder<
4980                '_,
4981                fidl::encoding::DefaultFuchsiaResourceDialect,
4982            >,
4983            offset: usize,
4984            _depth: fidl::encoding::Depth,
4985        ) -> fidl::Result<()> {
4986            encoder.debug_check_bounds::<ConnectionTransport>(offset);
4987            // Delegate to tuple encoding.
4988            fidl::encoding::Encode::<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4989                (
4990                    <fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.data),
4991                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.con),
4992                ),
4993                encoder, offset, _depth
4994            )
4995        }
4996    }
4997    unsafe impl<
4998        T0: fidl::encoding::Encode<
4999                fidl::encoding::HandleType<
5000                    fidl::Socket,
5001                    { fidl::ObjectType::SOCKET.into_raw() },
5002                    2147483648,
5003                >,
5004                fidl::encoding::DefaultFuchsiaResourceDialect,
5005            >,
5006        T1: fidl::encoding::Encode<
5007                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
5008                fidl::encoding::DefaultFuchsiaResourceDialect,
5009            >,
5010    > fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>
5011        for (T0, T1)
5012    {
5013        #[inline]
5014        unsafe fn encode(
5015            self,
5016            encoder: &mut fidl::encoding::Encoder<
5017                '_,
5018                fidl::encoding::DefaultFuchsiaResourceDialect,
5019            >,
5020            offset: usize,
5021            depth: fidl::encoding::Depth,
5022        ) -> fidl::Result<()> {
5023            encoder.debug_check_bounds::<ConnectionTransport>(offset);
5024            // Zero out padding regions. There's no need to apply masks
5025            // because the unmasked parts will be overwritten by fields.
5026            // Write the fields.
5027            self.0.encode(encoder, offset + 0, depth)?;
5028            self.1.encode(encoder, offset + 4, depth)?;
5029            Ok(())
5030        }
5031    }
5032
5033    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5034        for ConnectionTransport
5035    {
5036        #[inline(always)]
5037        fn new_empty() -> Self {
5038            Self {
5039                data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
5040                con: fidl::new_empty!(
5041                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
5042                    fidl::encoding::DefaultFuchsiaResourceDialect
5043                ),
5044            }
5045        }
5046
5047        #[inline]
5048        unsafe fn decode(
5049            &mut self,
5050            decoder: &mut fidl::encoding::Decoder<
5051                '_,
5052                fidl::encoding::DefaultFuchsiaResourceDialect,
5053            >,
5054            offset: usize,
5055            _depth: fidl::encoding::Depth,
5056        ) -> fidl::Result<()> {
5057            decoder.debug_check_bounds::<Self>(offset);
5058            // Verify that padding bytes are zero.
5059            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 0, _depth)?;
5060            fidl::decode!(
5061                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
5062                fidl::encoding::DefaultFuchsiaResourceDialect,
5063                &mut self.con,
5064                decoder,
5065                offset + 4,
5066                _depth
5067            )?;
5068            Ok(())
5069        }
5070    }
5071
5072    impl fidl::encoding::ResourceTypeMarker for ConnectorBindRequest {
5073        type Borrowed<'a> = &'a mut Self;
5074        fn take_or_borrow<'a>(
5075            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5076        ) -> Self::Borrowed<'a> {
5077            value
5078        }
5079    }
5080
5081    unsafe impl fidl::encoding::TypeMarker for ConnectorBindRequest {
5082        type Owned = Self;
5083
5084        #[inline(always)]
5085        fn inline_align(_context: fidl::encoding::Context) -> usize {
5086            4
5087        }
5088
5089        #[inline(always)]
5090        fn inline_size(_context: fidl::encoding::Context) -> usize {
5091            12
5092        }
5093    }
5094
5095    unsafe impl
5096        fidl::encoding::Encode<ConnectorBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5097        for &mut ConnectorBindRequest
5098    {
5099        #[inline]
5100        unsafe fn encode(
5101            self,
5102            encoder: &mut fidl::encoding::Encoder<
5103                '_,
5104                fidl::encoding::DefaultFuchsiaResourceDialect,
5105            >,
5106            offset: usize,
5107            _depth: fidl::encoding::Depth,
5108        ) -> fidl::Result<()> {
5109            encoder.debug_check_bounds::<ConnectorBindRequest>(offset);
5110            // Delegate to tuple encoding.
5111            fidl::encoding::Encode::<ConnectorBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5112                (
5113                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_cid),
5114                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.local_port),
5115                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listener),
5116                ),
5117                encoder, offset, _depth
5118            )
5119        }
5120    }
5121    unsafe impl<
5122        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
5123        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
5124        T2: fidl::encoding::Encode<
5125                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>>,
5126                fidl::encoding::DefaultFuchsiaResourceDialect,
5127            >,
5128    >
5129        fidl::encoding::Encode<ConnectorBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5130        for (T0, T1, T2)
5131    {
5132        #[inline]
5133        unsafe fn encode(
5134            self,
5135            encoder: &mut fidl::encoding::Encoder<
5136                '_,
5137                fidl::encoding::DefaultFuchsiaResourceDialect,
5138            >,
5139            offset: usize,
5140            depth: fidl::encoding::Depth,
5141        ) -> fidl::Result<()> {
5142            encoder.debug_check_bounds::<ConnectorBindRequest>(offset);
5143            // Zero out padding regions. There's no need to apply masks
5144            // because the unmasked parts will be overwritten by fields.
5145            // Write the fields.
5146            self.0.encode(encoder, offset + 0, depth)?;
5147            self.1.encode(encoder, offset + 4, depth)?;
5148            self.2.encode(encoder, offset + 8, depth)?;
5149            Ok(())
5150        }
5151    }
5152
5153    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5154        for ConnectorBindRequest
5155    {
5156        #[inline(always)]
5157        fn new_empty() -> Self {
5158            Self {
5159                remote_cid: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
5160                local_port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
5161                listener: fidl::new_empty!(
5162                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>>,
5163                    fidl::encoding::DefaultFuchsiaResourceDialect
5164                ),
5165            }
5166        }
5167
5168        #[inline]
5169        unsafe fn decode(
5170            &mut self,
5171            decoder: &mut fidl::encoding::Decoder<
5172                '_,
5173                fidl::encoding::DefaultFuchsiaResourceDialect,
5174            >,
5175            offset: usize,
5176            _depth: fidl::encoding::Depth,
5177        ) -> fidl::Result<()> {
5178            decoder.debug_check_bounds::<Self>(offset);
5179            // Verify that padding bytes are zero.
5180            fidl::decode!(
5181                u32,
5182                fidl::encoding::DefaultFuchsiaResourceDialect,
5183                &mut self.remote_cid,
5184                decoder,
5185                offset + 0,
5186                _depth
5187            )?;
5188            fidl::decode!(
5189                u32,
5190                fidl::encoding::DefaultFuchsiaResourceDialect,
5191                &mut self.local_port,
5192                decoder,
5193                offset + 4,
5194                _depth
5195            )?;
5196            fidl::decode!(
5197                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListenerMarker>>,
5198                fidl::encoding::DefaultFuchsiaResourceDialect,
5199                &mut self.listener,
5200                decoder,
5201                offset + 8,
5202                _depth
5203            )?;
5204            Ok(())
5205        }
5206    }
5207
5208    impl fidl::encoding::ResourceTypeMarker for ConnectorConnectRequest {
5209        type Borrowed<'a> = &'a mut Self;
5210        fn take_or_borrow<'a>(
5211            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5212        ) -> Self::Borrowed<'a> {
5213            value
5214        }
5215    }
5216
5217    unsafe impl fidl::encoding::TypeMarker for ConnectorConnectRequest {
5218        type Owned = Self;
5219
5220        #[inline(always)]
5221        fn inline_align(_context: fidl::encoding::Context) -> usize {
5222            4
5223        }
5224
5225        #[inline(always)]
5226        fn inline_size(_context: fidl::encoding::Context) -> usize {
5227            16
5228        }
5229    }
5230
5231    unsafe impl
5232        fidl::encoding::Encode<
5233            ConnectorConnectRequest,
5234            fidl::encoding::DefaultFuchsiaResourceDialect,
5235        > for &mut ConnectorConnectRequest
5236    {
5237        #[inline]
5238        unsafe fn encode(
5239            self,
5240            encoder: &mut fidl::encoding::Encoder<
5241                '_,
5242                fidl::encoding::DefaultFuchsiaResourceDialect,
5243            >,
5244            offset: usize,
5245            _depth: fidl::encoding::Depth,
5246        ) -> fidl::Result<()> {
5247            encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
5248            // Delegate to tuple encoding.
5249            fidl::encoding::Encode::<
5250                ConnectorConnectRequest,
5251                fidl::encoding::DefaultFuchsiaResourceDialect,
5252            >::encode(
5253                (
5254                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_cid),
5255                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_port),
5256                    <ConnectionTransport as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5257                        &mut self.con,
5258                    ),
5259                ),
5260                encoder,
5261                offset,
5262                _depth,
5263            )
5264        }
5265    }
5266    unsafe impl<
5267        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
5268        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
5269        T2: fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>,
5270    >
5271        fidl::encoding::Encode<
5272            ConnectorConnectRequest,
5273            fidl::encoding::DefaultFuchsiaResourceDialect,
5274        > for (T0, T1, T2)
5275    {
5276        #[inline]
5277        unsafe fn encode(
5278            self,
5279            encoder: &mut fidl::encoding::Encoder<
5280                '_,
5281                fidl::encoding::DefaultFuchsiaResourceDialect,
5282            >,
5283            offset: usize,
5284            depth: fidl::encoding::Depth,
5285        ) -> fidl::Result<()> {
5286            encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
5287            // Zero out padding regions. There's no need to apply masks
5288            // because the unmasked parts will be overwritten by fields.
5289            // Write the fields.
5290            self.0.encode(encoder, offset + 0, depth)?;
5291            self.1.encode(encoder, offset + 4, depth)?;
5292            self.2.encode(encoder, offset + 8, depth)?;
5293            Ok(())
5294        }
5295    }
5296
5297    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5298        for ConnectorConnectRequest
5299    {
5300        #[inline(always)]
5301        fn new_empty() -> Self {
5302            Self {
5303                remote_cid: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
5304                remote_port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
5305                con: fidl::new_empty!(
5306                    ConnectionTransport,
5307                    fidl::encoding::DefaultFuchsiaResourceDialect
5308                ),
5309            }
5310        }
5311
5312        #[inline]
5313        unsafe fn decode(
5314            &mut self,
5315            decoder: &mut fidl::encoding::Decoder<
5316                '_,
5317                fidl::encoding::DefaultFuchsiaResourceDialect,
5318            >,
5319            offset: usize,
5320            _depth: fidl::encoding::Depth,
5321        ) -> fidl::Result<()> {
5322            decoder.debug_check_bounds::<Self>(offset);
5323            // Verify that padding bytes are zero.
5324            fidl::decode!(
5325                u32,
5326                fidl::encoding::DefaultFuchsiaResourceDialect,
5327                &mut self.remote_cid,
5328                decoder,
5329                offset + 0,
5330                _depth
5331            )?;
5332            fidl::decode!(
5333                u32,
5334                fidl::encoding::DefaultFuchsiaResourceDialect,
5335                &mut self.remote_port,
5336                decoder,
5337                offset + 4,
5338                _depth
5339            )?;
5340            fidl::decode!(
5341                ConnectionTransport,
5342                fidl::encoding::DefaultFuchsiaResourceDialect,
5343                &mut self.con,
5344                decoder,
5345                offset + 8,
5346                _depth
5347            )?;
5348            Ok(())
5349        }
5350    }
5351
5352    impl fidl::encoding::ResourceTypeMarker for ConnectorListenRequest {
5353        type Borrowed<'a> = &'a mut Self;
5354        fn take_or_borrow<'a>(
5355            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5356        ) -> Self::Borrowed<'a> {
5357            value
5358        }
5359    }
5360
5361    unsafe impl fidl::encoding::TypeMarker for ConnectorListenRequest {
5362        type Owned = Self;
5363
5364        #[inline(always)]
5365        fn inline_align(_context: fidl::encoding::Context) -> usize {
5366            4
5367        }
5368
5369        #[inline(always)]
5370        fn inline_size(_context: fidl::encoding::Context) -> usize {
5371            8
5372        }
5373    }
5374
5375    unsafe impl
5376        fidl::encoding::Encode<
5377            ConnectorListenRequest,
5378            fidl::encoding::DefaultFuchsiaResourceDialect,
5379        > for &mut ConnectorListenRequest
5380    {
5381        #[inline]
5382        unsafe fn encode(
5383            self,
5384            encoder: &mut fidl::encoding::Encoder<
5385                '_,
5386                fidl::encoding::DefaultFuchsiaResourceDialect,
5387            >,
5388            offset: usize,
5389            _depth: fidl::encoding::Depth,
5390        ) -> fidl::Result<()> {
5391            encoder.debug_check_bounds::<ConnectorListenRequest>(offset);
5392            // Delegate to tuple encoding.
5393            fidl::encoding::Encode::<ConnectorListenRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5394                (
5395                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.local_port),
5396                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.acceptor),
5397                ),
5398                encoder, offset, _depth
5399            )
5400        }
5401    }
5402    unsafe impl<
5403        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
5404        T1: fidl::encoding::Encode<
5405                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>>,
5406                fidl::encoding::DefaultFuchsiaResourceDialect,
5407            >,
5408    >
5409        fidl::encoding::Encode<
5410            ConnectorListenRequest,
5411            fidl::encoding::DefaultFuchsiaResourceDialect,
5412        > for (T0, T1)
5413    {
5414        #[inline]
5415        unsafe fn encode(
5416            self,
5417            encoder: &mut fidl::encoding::Encoder<
5418                '_,
5419                fidl::encoding::DefaultFuchsiaResourceDialect,
5420            >,
5421            offset: usize,
5422            depth: fidl::encoding::Depth,
5423        ) -> fidl::Result<()> {
5424            encoder.debug_check_bounds::<ConnectorListenRequest>(offset);
5425            // Zero out padding regions. There's no need to apply masks
5426            // because the unmasked parts will be overwritten by fields.
5427            // Write the fields.
5428            self.0.encode(encoder, offset + 0, depth)?;
5429            self.1.encode(encoder, offset + 4, depth)?;
5430            Ok(())
5431        }
5432    }
5433
5434    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5435        for ConnectorListenRequest
5436    {
5437        #[inline(always)]
5438        fn new_empty() -> Self {
5439            Self {
5440                local_port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
5441                acceptor: fidl::new_empty!(
5442                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>>,
5443                    fidl::encoding::DefaultFuchsiaResourceDialect
5444                ),
5445            }
5446        }
5447
5448        #[inline]
5449        unsafe fn decode(
5450            &mut self,
5451            decoder: &mut fidl::encoding::Decoder<
5452                '_,
5453                fidl::encoding::DefaultFuchsiaResourceDialect,
5454            >,
5455            offset: usize,
5456            _depth: fidl::encoding::Depth,
5457        ) -> fidl::Result<()> {
5458            decoder.debug_check_bounds::<Self>(offset);
5459            // Verify that padding bytes are zero.
5460            fidl::decode!(
5461                u32,
5462                fidl::encoding::DefaultFuchsiaResourceDialect,
5463                &mut self.local_port,
5464                decoder,
5465                offset + 0,
5466                _depth
5467            )?;
5468            fidl::decode!(
5469                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AcceptorMarker>>,
5470                fidl::encoding::DefaultFuchsiaResourceDialect,
5471                &mut self.acceptor,
5472                decoder,
5473                offset + 4,
5474                _depth
5475            )?;
5476            Ok(())
5477        }
5478    }
5479
5480    impl fidl::encoding::ResourceTypeMarker for ListenerAcceptRequest {
5481        type Borrowed<'a> = &'a mut Self;
5482        fn take_or_borrow<'a>(
5483            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5484        ) -> Self::Borrowed<'a> {
5485            value
5486        }
5487    }
5488
5489    unsafe impl fidl::encoding::TypeMarker for ListenerAcceptRequest {
5490        type Owned = Self;
5491
5492        #[inline(always)]
5493        fn inline_align(_context: fidl::encoding::Context) -> usize {
5494            4
5495        }
5496
5497        #[inline(always)]
5498        fn inline_size(_context: fidl::encoding::Context) -> usize {
5499            8
5500        }
5501    }
5502
5503    unsafe impl
5504        fidl::encoding::Encode<ListenerAcceptRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5505        for &mut ListenerAcceptRequest
5506    {
5507        #[inline]
5508        unsafe fn encode(
5509            self,
5510            encoder: &mut fidl::encoding::Encoder<
5511                '_,
5512                fidl::encoding::DefaultFuchsiaResourceDialect,
5513            >,
5514            offset: usize,
5515            _depth: fidl::encoding::Depth,
5516        ) -> fidl::Result<()> {
5517            encoder.debug_check_bounds::<ListenerAcceptRequest>(offset);
5518            // Delegate to tuple encoding.
5519            fidl::encoding::Encode::<
5520                ListenerAcceptRequest,
5521                fidl::encoding::DefaultFuchsiaResourceDialect,
5522            >::encode(
5523                (<ConnectionTransport as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5524                    &mut self.con,
5525                ),),
5526                encoder,
5527                offset,
5528                _depth,
5529            )
5530        }
5531    }
5532    unsafe impl<
5533        T0: fidl::encoding::Encode<ConnectionTransport, fidl::encoding::DefaultFuchsiaResourceDialect>,
5534    >
5535        fidl::encoding::Encode<ListenerAcceptRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5536        for (T0,)
5537    {
5538        #[inline]
5539        unsafe fn encode(
5540            self,
5541            encoder: &mut fidl::encoding::Encoder<
5542                '_,
5543                fidl::encoding::DefaultFuchsiaResourceDialect,
5544            >,
5545            offset: usize,
5546            depth: fidl::encoding::Depth,
5547        ) -> fidl::Result<()> {
5548            encoder.debug_check_bounds::<ListenerAcceptRequest>(offset);
5549            // Zero out padding regions. There's no need to apply masks
5550            // because the unmasked parts will be overwritten by fields.
5551            // Write the fields.
5552            self.0.encode(encoder, offset + 0, depth)?;
5553            Ok(())
5554        }
5555    }
5556
5557    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5558        for ListenerAcceptRequest
5559    {
5560        #[inline(always)]
5561        fn new_empty() -> Self {
5562            Self {
5563                con: fidl::new_empty!(
5564                    ConnectionTransport,
5565                    fidl::encoding::DefaultFuchsiaResourceDialect
5566                ),
5567            }
5568        }
5569
5570        #[inline]
5571        unsafe fn decode(
5572            &mut self,
5573            decoder: &mut fidl::encoding::Decoder<
5574                '_,
5575                fidl::encoding::DefaultFuchsiaResourceDialect,
5576            >,
5577            offset: usize,
5578            _depth: fidl::encoding::Depth,
5579        ) -> fidl::Result<()> {
5580            decoder.debug_check_bounds::<Self>(offset);
5581            // Verify that padding bytes are zero.
5582            fidl::decode!(
5583                ConnectionTransport,
5584                fidl::encoding::DefaultFuchsiaResourceDialect,
5585                &mut self.con,
5586                decoder,
5587                offset + 0,
5588                _depth
5589            )?;
5590            Ok(())
5591        }
5592    }
5593
5594    impl fidl::encoding::ResourceTypeMarker for ProviderStreamSocketRequest {
5595        type Borrowed<'a> = &'a mut Self;
5596        fn take_or_borrow<'a>(
5597            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5598        ) -> Self::Borrowed<'a> {
5599            value
5600        }
5601    }
5602
5603    unsafe impl fidl::encoding::TypeMarker for ProviderStreamSocketRequest {
5604        type Owned = Self;
5605
5606        #[inline(always)]
5607        fn inline_align(_context: fidl::encoding::Context) -> usize {
5608            4
5609        }
5610
5611        #[inline(always)]
5612        fn inline_size(_context: fidl::encoding::Context) -> usize {
5613            8
5614        }
5615    }
5616
5617    unsafe impl
5618        fidl::encoding::Encode<
5619            ProviderStreamSocketRequest,
5620            fidl::encoding::DefaultFuchsiaResourceDialect,
5621        > for &mut ProviderStreamSocketRequest
5622    {
5623        #[inline]
5624        unsafe fn encode(
5625            self,
5626            encoder: &mut fidl::encoding::Encoder<
5627                '_,
5628                fidl::encoding::DefaultFuchsiaResourceDialect,
5629            >,
5630            offset: usize,
5631            _depth: fidl::encoding::Depth,
5632        ) -> fidl::Result<()> {
5633            encoder.debug_check_bounds::<ProviderStreamSocketRequest>(offset);
5634            // Delegate to tuple encoding.
5635            fidl::encoding::Encode::<ProviderStreamSocketRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5636                (
5637                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSocketMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server),
5638                    <fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.data),
5639                ),
5640                encoder, offset, _depth
5641            )
5642        }
5643    }
5644    unsafe impl<
5645        T0: fidl::encoding::Encode<
5646                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSocketMarker>>,
5647                fidl::encoding::DefaultFuchsiaResourceDialect,
5648            >,
5649        T1: fidl::encoding::Encode<
5650                fidl::encoding::HandleType<
5651                    fidl::Socket,
5652                    { fidl::ObjectType::SOCKET.into_raw() },
5653                    2147483648,
5654                >,
5655                fidl::encoding::DefaultFuchsiaResourceDialect,
5656            >,
5657    >
5658        fidl::encoding::Encode<
5659            ProviderStreamSocketRequest,
5660            fidl::encoding::DefaultFuchsiaResourceDialect,
5661        > for (T0, T1)
5662    {
5663        #[inline]
5664        unsafe fn encode(
5665            self,
5666            encoder: &mut fidl::encoding::Encoder<
5667                '_,
5668                fidl::encoding::DefaultFuchsiaResourceDialect,
5669            >,
5670            offset: usize,
5671            depth: fidl::encoding::Depth,
5672        ) -> fidl::Result<()> {
5673            encoder.debug_check_bounds::<ProviderStreamSocketRequest>(offset);
5674            // Zero out padding regions. There's no need to apply masks
5675            // because the unmasked parts will be overwritten by fields.
5676            // Write the fields.
5677            self.0.encode(encoder, offset + 0, depth)?;
5678            self.1.encode(encoder, offset + 4, depth)?;
5679            Ok(())
5680        }
5681    }
5682
5683    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5684        for ProviderStreamSocketRequest
5685    {
5686        #[inline(always)]
5687        fn new_empty() -> Self {
5688            Self {
5689                server: fidl::new_empty!(
5690                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSocketMarker>>,
5691                    fidl::encoding::DefaultFuchsiaResourceDialect
5692                ),
5693                data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
5694            }
5695        }
5696
5697        #[inline]
5698        unsafe fn decode(
5699            &mut self,
5700            decoder: &mut fidl::encoding::Decoder<
5701                '_,
5702                fidl::encoding::DefaultFuchsiaResourceDialect,
5703            >,
5704            offset: usize,
5705            _depth: fidl::encoding::Depth,
5706        ) -> fidl::Result<()> {
5707            decoder.debug_check_bounds::<Self>(offset);
5708            // Verify that padding bytes are zero.
5709            fidl::decode!(
5710                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSocketMarker>>,
5711                fidl::encoding::DefaultFuchsiaResourceDialect,
5712                &mut self.server,
5713                decoder,
5714                offset + 0,
5715                _depth
5716            )?;
5717            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 4, _depth)?;
5718            Ok(())
5719        }
5720    }
5721
5722    impl fidl::encoding::ResourceTypeMarker for StreamSocketAcceptRequest {
5723        type Borrowed<'a> = &'a mut Self;
5724        fn take_or_borrow<'a>(
5725            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5726        ) -> Self::Borrowed<'a> {
5727            value
5728        }
5729    }
5730
5731    unsafe impl fidl::encoding::TypeMarker for StreamSocketAcceptRequest {
5732        type Owned = Self;
5733
5734        #[inline(always)]
5735        fn inline_align(_context: fidl::encoding::Context) -> usize {
5736            1
5737        }
5738
5739        #[inline(always)]
5740        fn inline_size(_context: fidl::encoding::Context) -> usize {
5741            1
5742        }
5743    }
5744
5745    unsafe impl
5746        fidl::encoding::Encode<
5747            StreamSocketAcceptRequest,
5748            fidl::encoding::DefaultFuchsiaResourceDialect,
5749        > for &mut StreamSocketAcceptRequest
5750    {
5751        #[inline]
5752        unsafe fn encode(
5753            self,
5754            encoder: &mut fidl::encoding::Encoder<
5755                '_,
5756                fidl::encoding::DefaultFuchsiaResourceDialect,
5757            >,
5758            offset: usize,
5759            _depth: fidl::encoding::Depth,
5760        ) -> fidl::Result<()> {
5761            encoder.debug_check_bounds::<StreamSocketAcceptRequest>(offset);
5762            // Delegate to tuple encoding.
5763            fidl::encoding::Encode::<
5764                StreamSocketAcceptRequest,
5765                fidl::encoding::DefaultFuchsiaResourceDialect,
5766            >::encode(
5767                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.want_addr),),
5768                encoder,
5769                offset,
5770                _depth,
5771            )
5772        }
5773    }
5774    unsafe impl<T0: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>>
5775        fidl::encoding::Encode<
5776            StreamSocketAcceptRequest,
5777            fidl::encoding::DefaultFuchsiaResourceDialect,
5778        > for (T0,)
5779    {
5780        #[inline]
5781        unsafe fn encode(
5782            self,
5783            encoder: &mut fidl::encoding::Encoder<
5784                '_,
5785                fidl::encoding::DefaultFuchsiaResourceDialect,
5786            >,
5787            offset: usize,
5788            depth: fidl::encoding::Depth,
5789        ) -> fidl::Result<()> {
5790            encoder.debug_check_bounds::<StreamSocketAcceptRequest>(offset);
5791            // Zero out padding regions. There's no need to apply masks
5792            // because the unmasked parts will be overwritten by fields.
5793            // Write the fields.
5794            self.0.encode(encoder, offset + 0, depth)?;
5795            Ok(())
5796        }
5797    }
5798
5799    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5800        for StreamSocketAcceptRequest
5801    {
5802        #[inline(always)]
5803        fn new_empty() -> Self {
5804            Self {
5805                want_addr: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
5806            }
5807        }
5808
5809        #[inline]
5810        unsafe fn decode(
5811            &mut self,
5812            decoder: &mut fidl::encoding::Decoder<
5813                '_,
5814                fidl::encoding::DefaultFuchsiaResourceDialect,
5815            >,
5816            offset: usize,
5817            _depth: fidl::encoding::Depth,
5818        ) -> fidl::Result<()> {
5819            decoder.debug_check_bounds::<Self>(offset);
5820            // Verify that padding bytes are zero.
5821            fidl::decode!(
5822                bool,
5823                fidl::encoding::DefaultFuchsiaResourceDialect,
5824                &mut self.want_addr,
5825                decoder,
5826                offset + 0,
5827                _depth
5828            )?;
5829            Ok(())
5830        }
5831    }
5832
5833    impl fidl::encoding::ResourceTypeMarker for StreamSocketConnectRequest {
5834        type Borrowed<'a> = &'a mut Self;
5835        fn take_or_borrow<'a>(
5836            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5837        ) -> Self::Borrowed<'a> {
5838            value
5839        }
5840    }
5841
5842    unsafe impl fidl::encoding::TypeMarker for StreamSocketConnectRequest {
5843        type Owned = Self;
5844
5845        #[inline(always)]
5846        fn inline_align(_context: fidl::encoding::Context) -> usize {
5847            4
5848        }
5849
5850        #[inline(always)]
5851        fn inline_size(_context: fidl::encoding::Context) -> usize {
5852            8
5853        }
5854        #[inline(always)]
5855        fn encode_is_copy() -> bool {
5856            true
5857        }
5858
5859        #[inline(always)]
5860        fn decode_is_copy() -> bool {
5861            true
5862        }
5863    }
5864
5865    unsafe impl
5866        fidl::encoding::Encode<
5867            StreamSocketConnectRequest,
5868            fidl::encoding::DefaultFuchsiaResourceDialect,
5869        > for &mut StreamSocketConnectRequest
5870    {
5871        #[inline]
5872        unsafe fn encode(
5873            self,
5874            encoder: &mut fidl::encoding::Encoder<
5875                '_,
5876                fidl::encoding::DefaultFuchsiaResourceDialect,
5877            >,
5878            offset: usize,
5879            _depth: fidl::encoding::Depth,
5880        ) -> fidl::Result<()> {
5881            encoder.debug_check_bounds::<StreamSocketConnectRequest>(offset);
5882            unsafe {
5883                // Copy the object into the buffer.
5884                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
5885                (buf_ptr as *mut StreamSocketConnectRequest)
5886                    .write_unaligned((self as *const StreamSocketConnectRequest).read());
5887                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
5888                // done second because the memcpy will write garbage to these bytes.
5889            }
5890            Ok(())
5891        }
5892    }
5893    unsafe impl<
5894        T0: fidl::encoding::Encode<VsockAddress, fidl::encoding::DefaultFuchsiaResourceDialect>,
5895    >
5896        fidl::encoding::Encode<
5897            StreamSocketConnectRequest,
5898            fidl::encoding::DefaultFuchsiaResourceDialect,
5899        > for (T0,)
5900    {
5901        #[inline]
5902        unsafe fn encode(
5903            self,
5904            encoder: &mut fidl::encoding::Encoder<
5905                '_,
5906                fidl::encoding::DefaultFuchsiaResourceDialect,
5907            >,
5908            offset: usize,
5909            depth: fidl::encoding::Depth,
5910        ) -> fidl::Result<()> {
5911            encoder.debug_check_bounds::<StreamSocketConnectRequest>(offset);
5912            // Zero out padding regions. There's no need to apply masks
5913            // because the unmasked parts will be overwritten by fields.
5914            // Write the fields.
5915            self.0.encode(encoder, offset + 0, depth)?;
5916            Ok(())
5917        }
5918    }
5919
5920    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5921        for StreamSocketConnectRequest
5922    {
5923        #[inline(always)]
5924        fn new_empty() -> Self {
5925            Self {
5926                remote_address: fidl::new_empty!(
5927                    VsockAddress,
5928                    fidl::encoding::DefaultFuchsiaResourceDialect
5929                ),
5930            }
5931        }
5932
5933        #[inline]
5934        unsafe fn decode(
5935            &mut self,
5936            decoder: &mut fidl::encoding::Decoder<
5937                '_,
5938                fidl::encoding::DefaultFuchsiaResourceDialect,
5939            >,
5940            offset: usize,
5941            _depth: fidl::encoding::Depth,
5942        ) -> fidl::Result<()> {
5943            decoder.debug_check_bounds::<Self>(offset);
5944            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
5945            // Verify that padding bytes are zero.
5946            // Copy from the buffer into the object.
5947            unsafe {
5948                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
5949            }
5950            Ok(())
5951        }
5952    }
5953
5954    impl StreamSocketAcceptResponse {
5955        #[inline(always)]
5956        fn max_ordinal_present(&self) -> u64 {
5957            if let Some(_) = self.addr {
5958                return 3;
5959            }
5960            if let Some(_) = self.data {
5961                return 2;
5962            }
5963            if let Some(_) = self.socket {
5964                return 1;
5965            }
5966            0
5967        }
5968    }
5969
5970    impl fidl::encoding::ResourceTypeMarker for StreamSocketAcceptResponse {
5971        type Borrowed<'a> = &'a mut Self;
5972        fn take_or_borrow<'a>(
5973            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5974        ) -> Self::Borrowed<'a> {
5975            value
5976        }
5977    }
5978
5979    unsafe impl fidl::encoding::TypeMarker for StreamSocketAcceptResponse {
5980        type Owned = Self;
5981
5982        #[inline(always)]
5983        fn inline_align(_context: fidl::encoding::Context) -> usize {
5984            8
5985        }
5986
5987        #[inline(always)]
5988        fn inline_size(_context: fidl::encoding::Context) -> usize {
5989            16
5990        }
5991    }
5992
5993    unsafe impl
5994        fidl::encoding::Encode<
5995            StreamSocketAcceptResponse,
5996            fidl::encoding::DefaultFuchsiaResourceDialect,
5997        > for &mut StreamSocketAcceptResponse
5998    {
5999        unsafe fn encode(
6000            self,
6001            encoder: &mut fidl::encoding::Encoder<
6002                '_,
6003                fidl::encoding::DefaultFuchsiaResourceDialect,
6004            >,
6005            offset: usize,
6006            mut depth: fidl::encoding::Depth,
6007        ) -> fidl::Result<()> {
6008            encoder.debug_check_bounds::<StreamSocketAcceptResponse>(offset);
6009            // Vector header
6010            let max_ordinal: u64 = self.max_ordinal_present();
6011            encoder.write_num(max_ordinal, offset);
6012            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6013            // Calling encoder.out_of_line_offset(0) is not allowed.
6014            if max_ordinal == 0 {
6015                return Ok(());
6016            }
6017            depth.increment()?;
6018            let envelope_size = 8;
6019            let bytes_len = max_ordinal as usize * envelope_size;
6020            #[allow(unused_variables)]
6021            let offset = encoder.out_of_line_offset(bytes_len);
6022            let mut _prev_end_offset: usize = 0;
6023            if 1 > max_ordinal {
6024                return Ok(());
6025            }
6026
6027            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6028            // are envelope_size bytes.
6029            let cur_offset: usize = (1 - 1) * envelope_size;
6030
6031            // Zero reserved fields.
6032            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6033
6034            // Safety:
6035            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6036            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6037            //   envelope_size bytes, there is always sufficient room.
6038            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<StreamSocketMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
6039            self.socket.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<StreamSocketMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
6040            encoder, offset + cur_offset, depth
6041        )?;
6042
6043            _prev_end_offset = cur_offset + envelope_size;
6044            if 2 > max_ordinal {
6045                return Ok(());
6046            }
6047
6048            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6049            // are envelope_size bytes.
6050            let cur_offset: usize = (2 - 1) * envelope_size;
6051
6052            // Zero reserved fields.
6053            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6054
6055            // Safety:
6056            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6057            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6058            //   envelope_size bytes, there is always sufficient room.
6059            fidl::encoding::encode_in_envelope_optional::<
6060                fidl::encoding::HandleType<
6061                    fidl::Socket,
6062                    { fidl::ObjectType::SOCKET.into_raw() },
6063                    2147483648,
6064                >,
6065                fidl::encoding::DefaultFuchsiaResourceDialect,
6066            >(
6067                self.data.as_mut().map(
6068                    <fidl::encoding::HandleType<
6069                        fidl::Socket,
6070                        { fidl::ObjectType::SOCKET.into_raw() },
6071                        2147483648,
6072                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
6073                ),
6074                encoder,
6075                offset + cur_offset,
6076                depth,
6077            )?;
6078
6079            _prev_end_offset = cur_offset + envelope_size;
6080            if 3 > max_ordinal {
6081                return Ok(());
6082            }
6083
6084            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6085            // are envelope_size bytes.
6086            let cur_offset: usize = (3 - 1) * envelope_size;
6087
6088            // Zero reserved fields.
6089            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6090
6091            // Safety:
6092            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6093            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6094            //   envelope_size bytes, there is always sufficient room.
6095            fidl::encoding::encode_in_envelope_optional::<
6096                VsockAddress,
6097                fidl::encoding::DefaultFuchsiaResourceDialect,
6098            >(
6099                self.addr.as_ref().map(<VsockAddress as fidl::encoding::ValueTypeMarker>::borrow),
6100                encoder,
6101                offset + cur_offset,
6102                depth,
6103            )?;
6104
6105            _prev_end_offset = cur_offset + envelope_size;
6106
6107            Ok(())
6108        }
6109    }
6110
6111    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6112        for StreamSocketAcceptResponse
6113    {
6114        #[inline(always)]
6115        fn new_empty() -> Self {
6116            Self::default()
6117        }
6118
6119        unsafe fn decode(
6120            &mut self,
6121            decoder: &mut fidl::encoding::Decoder<
6122                '_,
6123                fidl::encoding::DefaultFuchsiaResourceDialect,
6124            >,
6125            offset: usize,
6126            mut depth: fidl::encoding::Depth,
6127        ) -> fidl::Result<()> {
6128            decoder.debug_check_bounds::<Self>(offset);
6129            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6130                None => return Err(fidl::Error::NotNullable),
6131                Some(len) => len,
6132            };
6133            // Calling decoder.out_of_line_offset(0) is not allowed.
6134            if len == 0 {
6135                return Ok(());
6136            };
6137            depth.increment()?;
6138            let envelope_size = 8;
6139            let bytes_len = len * envelope_size;
6140            let offset = decoder.out_of_line_offset(bytes_len)?;
6141            // Decode the envelope for each type.
6142            let mut _next_ordinal_to_read = 0;
6143            let mut next_offset = offset;
6144            let end_offset = offset + bytes_len;
6145            _next_ordinal_to_read += 1;
6146            if next_offset >= end_offset {
6147                return Ok(());
6148            }
6149
6150            // Decode unknown envelopes for gaps in ordinals.
6151            while _next_ordinal_to_read < 1 {
6152                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6153                _next_ordinal_to_read += 1;
6154                next_offset += envelope_size;
6155            }
6156
6157            let next_out_of_line = decoder.next_out_of_line();
6158            let handles_before = decoder.remaining_handles();
6159            if let Some((inlined, num_bytes, num_handles)) =
6160                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6161            {
6162                let member_inline_size = <fidl::encoding::Endpoint<
6163                    fidl::endpoints::ClientEnd<StreamSocketMarker>,
6164                > as fidl::encoding::TypeMarker>::inline_size(
6165                    decoder.context
6166                );
6167                if inlined != (member_inline_size <= 4) {
6168                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6169                }
6170                let inner_offset;
6171                let mut inner_depth = depth.clone();
6172                if inlined {
6173                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6174                    inner_offset = next_offset;
6175                } else {
6176                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6177                    inner_depth.increment()?;
6178                }
6179                let val_ref = self.socket.get_or_insert_with(|| {
6180                    fidl::new_empty!(
6181                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<StreamSocketMarker>>,
6182                        fidl::encoding::DefaultFuchsiaResourceDialect
6183                    )
6184                });
6185                fidl::decode!(
6186                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<StreamSocketMarker>>,
6187                    fidl::encoding::DefaultFuchsiaResourceDialect,
6188                    val_ref,
6189                    decoder,
6190                    inner_offset,
6191                    inner_depth
6192                )?;
6193                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6194                {
6195                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6196                }
6197                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6198                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6199                }
6200            }
6201
6202            next_offset += envelope_size;
6203            _next_ordinal_to_read += 1;
6204            if next_offset >= end_offset {
6205                return Ok(());
6206            }
6207
6208            // Decode unknown envelopes for gaps in ordinals.
6209            while _next_ordinal_to_read < 2 {
6210                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6211                _next_ordinal_to_read += 1;
6212                next_offset += envelope_size;
6213            }
6214
6215            let next_out_of_line = decoder.next_out_of_line();
6216            let handles_before = decoder.remaining_handles();
6217            if let Some((inlined, num_bytes, num_handles)) =
6218                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6219            {
6220                let member_inline_size = <fidl::encoding::HandleType<
6221                    fidl::Socket,
6222                    { fidl::ObjectType::SOCKET.into_raw() },
6223                    2147483648,
6224                > as fidl::encoding::TypeMarker>::inline_size(
6225                    decoder.context
6226                );
6227                if inlined != (member_inline_size <= 4) {
6228                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6229                }
6230                let inner_offset;
6231                let mut inner_depth = depth.clone();
6232                if inlined {
6233                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6234                    inner_offset = next_offset;
6235                } else {
6236                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6237                    inner_depth.increment()?;
6238                }
6239                let val_ref =
6240                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
6241                fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6242                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6243                {
6244                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6245                }
6246                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6247                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6248                }
6249            }
6250
6251            next_offset += envelope_size;
6252            _next_ordinal_to_read += 1;
6253            if next_offset >= end_offset {
6254                return Ok(());
6255            }
6256
6257            // Decode unknown envelopes for gaps in ordinals.
6258            while _next_ordinal_to_read < 3 {
6259                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6260                _next_ordinal_to_read += 1;
6261                next_offset += envelope_size;
6262            }
6263
6264            let next_out_of_line = decoder.next_out_of_line();
6265            let handles_before = decoder.remaining_handles();
6266            if let Some((inlined, num_bytes, num_handles)) =
6267                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6268            {
6269                let member_inline_size =
6270                    <VsockAddress as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6271                if inlined != (member_inline_size <= 4) {
6272                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6273                }
6274                let inner_offset;
6275                let mut inner_depth = depth.clone();
6276                if inlined {
6277                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6278                    inner_offset = next_offset;
6279                } else {
6280                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6281                    inner_depth.increment()?;
6282                }
6283                let val_ref = self.addr.get_or_insert_with(|| {
6284                    fidl::new_empty!(VsockAddress, fidl::encoding::DefaultFuchsiaResourceDialect)
6285                });
6286                fidl::decode!(
6287                    VsockAddress,
6288                    fidl::encoding::DefaultFuchsiaResourceDialect,
6289                    val_ref,
6290                    decoder,
6291                    inner_offset,
6292                    inner_depth
6293                )?;
6294                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6295                {
6296                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6297                }
6298                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6299                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6300                }
6301            }
6302
6303            next_offset += envelope_size;
6304
6305            // Decode the remaining unknown envelopes.
6306            while next_offset < end_offset {
6307                _next_ordinal_to_read += 1;
6308                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6309                next_offset += envelope_size;
6310            }
6311
6312            Ok(())
6313        }
6314    }
6315}