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