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