Skip to main content

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