Skip to main content

fidl_fuchsia_hardware_vsock/
fidl_fuchsia_hardware_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_hardware_vsock_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceSendRequestRequest {
16    pub addr: Addr,
17    pub data: fidl::Socket,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceSendRequestRequest {}
21
22#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub struct DeviceSendResponseRequest {
24    pub addr: Addr,
25    pub data: fidl::Socket,
26}
27
28impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceSendResponseRequest {}
29
30#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
31pub struct DeviceStartRequest {
32    pub cb: fidl::endpoints::ClientEnd<CallbacksMarker>,
33}
34
35impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceStartRequest {}
36
37#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
38pub struct CallbacksMarker;
39
40impl fidl::endpoints::ProtocolMarker for CallbacksMarker {
41    type Proxy = CallbacksProxy;
42    type RequestStream = CallbacksRequestStream;
43    #[cfg(target_os = "fuchsia")]
44    type SynchronousProxy = CallbacksSynchronousProxy;
45
46    const DEBUG_NAME: &'static str = "(anonymous) Callbacks";
47}
48
49pub trait CallbacksProxyInterface: Send + Sync {
50    fn r#request(&self, addr: &Addr) -> Result<(), fidl::Error>;
51    fn r#response(&self, addr: &Addr) -> Result<(), fidl::Error>;
52    fn r#rst(&self, addr: &Addr) -> Result<(), fidl::Error>;
53    fn r#shutdown(&self, addr: &Addr) -> Result<(), fidl::Error>;
54    type TransportResetResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
55    fn r#transport_reset(&self, new_cid: u32) -> Self::TransportResetResponseFut;
56}
57#[derive(Debug)]
58#[cfg(target_os = "fuchsia")]
59pub struct CallbacksSynchronousProxy {
60    client: fidl::client::sync::Client,
61}
62
63#[cfg(target_os = "fuchsia")]
64impl fidl::endpoints::SynchronousProxy for CallbacksSynchronousProxy {
65    type Proxy = CallbacksProxy;
66    type Protocol = CallbacksMarker;
67
68    fn from_channel(inner: fidl::Channel) -> Self {
69        Self::new(inner)
70    }
71
72    fn into_channel(self) -> fidl::Channel {
73        self.client.into_channel()
74    }
75
76    fn as_channel(&self) -> &fidl::Channel {
77        self.client.as_channel()
78    }
79}
80
81#[cfg(target_os = "fuchsia")]
82impl CallbacksSynchronousProxy {
83    pub fn new(channel: fidl::Channel) -> Self {
84        Self { client: fidl::client::sync::Client::new(channel) }
85    }
86
87    pub fn into_channel(self) -> fidl::Channel {
88        self.client.into_channel()
89    }
90
91    /// Waits until an event arrives and returns it. It is safe for other
92    /// threads to make concurrent requests while waiting for an event.
93    pub fn wait_for_event(
94        &self,
95        deadline: zx::MonotonicInstant,
96    ) -> Result<CallbacksEvent, fidl::Error> {
97        CallbacksEvent::decode(self.client.wait_for_event::<CallbacksMarker>(deadline)?)
98    }
99
100    pub fn r#request(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
101        self.client.send::<CallbacksRequestRequest>(
102            (addr,),
103            0x685918e57418eda8,
104            fidl::encoding::DynamicFlags::empty(),
105        )
106    }
107
108    pub fn r#response(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
109        self.client.send::<CallbacksResponseRequest>(
110            (addr,),
111            0x951dfbcb98699cc,
112            fidl::encoding::DynamicFlags::empty(),
113        )
114    }
115
116    pub fn r#rst(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
117        self.client.send::<CallbacksRstRequest>(
118            (addr,),
119            0x7d6b0a28c75d5568,
120            fidl::encoding::DynamicFlags::empty(),
121        )
122    }
123
124    pub fn r#shutdown(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
125        self.client.send::<CallbacksShutdownRequest>(
126            (addr,),
127            0x6021a72c49ab97cb,
128            fidl::encoding::DynamicFlags::empty(),
129        )
130    }
131
132    pub fn r#transport_reset(
133        &self,
134        mut new_cid: u32,
135        ___deadline: zx::MonotonicInstant,
136    ) -> Result<(), fidl::Error> {
137        let _response = self.client.send_query::<
138            CallbacksTransportResetRequest,
139            fidl::encoding::EmptyPayload,
140            CallbacksMarker,
141        >(
142            (new_cid,),
143            0x23ba142d8c6a537,
144            fidl::encoding::DynamicFlags::empty(),
145            ___deadline,
146        )?;
147        Ok(_response)
148    }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl From<CallbacksSynchronousProxy> for zx::NullableHandle {
153    fn from(value: CallbacksSynchronousProxy) -> Self {
154        value.into_channel().into()
155    }
156}
157
158#[cfg(target_os = "fuchsia")]
159impl From<fidl::Channel> for CallbacksSynchronousProxy {
160    fn from(value: fidl::Channel) -> Self {
161        Self::new(value)
162    }
163}
164
165#[cfg(target_os = "fuchsia")]
166impl fidl::endpoints::FromClient for CallbacksSynchronousProxy {
167    type Protocol = CallbacksMarker;
168
169    fn from_client(value: fidl::endpoints::ClientEnd<CallbacksMarker>) -> Self {
170        Self::new(value.into_channel())
171    }
172}
173
174#[derive(Debug, Clone)]
175pub struct CallbacksProxy {
176    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
177}
178
179impl fidl::endpoints::Proxy for CallbacksProxy {
180    type Protocol = CallbacksMarker;
181
182    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
183        Self::new(inner)
184    }
185
186    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
187        self.client.into_channel().map_err(|client| Self { client })
188    }
189
190    fn as_channel(&self) -> &::fidl::AsyncChannel {
191        self.client.as_channel()
192    }
193}
194
195impl CallbacksProxy {
196    /// Create a new Proxy for fuchsia.hardware.vsock/Callbacks.
197    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
198        let protocol_name = <CallbacksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
199        Self { client: fidl::client::Client::new(channel, protocol_name) }
200    }
201
202    /// Get a Stream of events from the remote end of the protocol.
203    ///
204    /// # Panics
205    ///
206    /// Panics if the event stream was already taken.
207    pub fn take_event_stream(&self) -> CallbacksEventStream {
208        CallbacksEventStream { event_receiver: self.client.take_event_receiver() }
209    }
210
211    pub fn r#request(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
212        CallbacksProxyInterface::r#request(self, addr)
213    }
214
215    pub fn r#response(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
216        CallbacksProxyInterface::r#response(self, addr)
217    }
218
219    pub fn r#rst(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
220        CallbacksProxyInterface::r#rst(self, addr)
221    }
222
223    pub fn r#shutdown(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
224        CallbacksProxyInterface::r#shutdown(self, addr)
225    }
226
227    pub fn r#transport_reset(
228        &self,
229        mut new_cid: u32,
230    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
231        CallbacksProxyInterface::r#transport_reset(self, new_cid)
232    }
233}
234
235impl CallbacksProxyInterface for CallbacksProxy {
236    fn r#request(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
237        self.client.send::<CallbacksRequestRequest>(
238            (addr,),
239            0x685918e57418eda8,
240            fidl::encoding::DynamicFlags::empty(),
241        )
242    }
243
244    fn r#response(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
245        self.client.send::<CallbacksResponseRequest>(
246            (addr,),
247            0x951dfbcb98699cc,
248            fidl::encoding::DynamicFlags::empty(),
249        )
250    }
251
252    fn r#rst(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
253        self.client.send::<CallbacksRstRequest>(
254            (addr,),
255            0x7d6b0a28c75d5568,
256            fidl::encoding::DynamicFlags::empty(),
257        )
258    }
259
260    fn r#shutdown(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
261        self.client.send::<CallbacksShutdownRequest>(
262            (addr,),
263            0x6021a72c49ab97cb,
264            fidl::encoding::DynamicFlags::empty(),
265        )
266    }
267
268    type TransportResetResponseFut =
269        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
270    fn r#transport_reset(&self, mut new_cid: u32) -> Self::TransportResetResponseFut {
271        fn _decode(
272            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
273        ) -> Result<(), fidl::Error> {
274            let _response = fidl::client::decode_transaction_body::<
275                fidl::encoding::EmptyPayload,
276                fidl::encoding::DefaultFuchsiaResourceDialect,
277                0x23ba142d8c6a537,
278            >(_buf?)?;
279            Ok(_response)
280        }
281        self.client.send_query_and_decode::<CallbacksTransportResetRequest, ()>(
282            (new_cid,),
283            0x23ba142d8c6a537,
284            fidl::encoding::DynamicFlags::empty(),
285            _decode,
286        )
287    }
288}
289
290pub struct CallbacksEventStream {
291    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
292}
293
294impl std::marker::Unpin for CallbacksEventStream {}
295
296impl futures::stream::FusedStream for CallbacksEventStream {
297    fn is_terminated(&self) -> bool {
298        self.event_receiver.is_terminated()
299    }
300}
301
302impl futures::Stream for CallbacksEventStream {
303    type Item = Result<CallbacksEvent, fidl::Error>;
304
305    fn poll_next(
306        mut self: std::pin::Pin<&mut Self>,
307        cx: &mut std::task::Context<'_>,
308    ) -> std::task::Poll<Option<Self::Item>> {
309        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
310            &mut self.event_receiver,
311            cx
312        )?) {
313            Some(buf) => std::task::Poll::Ready(Some(CallbacksEvent::decode(buf))),
314            None => std::task::Poll::Ready(None),
315        }
316    }
317}
318
319#[derive(Debug)]
320pub enum CallbacksEvent {}
321
322impl CallbacksEvent {
323    /// Decodes a message buffer as a [`CallbacksEvent`].
324    fn decode(
325        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
326    ) -> Result<CallbacksEvent, fidl::Error> {
327        let (bytes, _handles) = buf.split_mut();
328        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
329        debug_assert_eq!(tx_header.tx_id, 0);
330        match tx_header.ordinal {
331            _ => Err(fidl::Error::UnknownOrdinal {
332                ordinal: tx_header.ordinal,
333                protocol_name: <CallbacksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
334            }),
335        }
336    }
337}
338
339/// A Stream of incoming requests for fuchsia.hardware.vsock/Callbacks.
340pub struct CallbacksRequestStream {
341    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
342    is_terminated: bool,
343}
344
345impl std::marker::Unpin for CallbacksRequestStream {}
346
347impl futures::stream::FusedStream for CallbacksRequestStream {
348    fn is_terminated(&self) -> bool {
349        self.is_terminated
350    }
351}
352
353impl fidl::endpoints::RequestStream for CallbacksRequestStream {
354    type Protocol = CallbacksMarker;
355    type ControlHandle = CallbacksControlHandle;
356
357    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
358        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
359    }
360
361    fn control_handle(&self) -> Self::ControlHandle {
362        CallbacksControlHandle { inner: self.inner.clone() }
363    }
364
365    fn into_inner(
366        self,
367    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
368    {
369        (self.inner, self.is_terminated)
370    }
371
372    fn from_inner(
373        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
374        is_terminated: bool,
375    ) -> Self {
376        Self { inner, is_terminated }
377    }
378}
379
380impl futures::Stream for CallbacksRequestStream {
381    type Item = Result<CallbacksRequest, fidl::Error>;
382
383    fn poll_next(
384        mut self: std::pin::Pin<&mut Self>,
385        cx: &mut std::task::Context<'_>,
386    ) -> std::task::Poll<Option<Self::Item>> {
387        let this = &mut *self;
388        if this.inner.check_shutdown(cx) {
389            this.is_terminated = true;
390            return std::task::Poll::Ready(None);
391        }
392        if this.is_terminated {
393            panic!("polled CallbacksRequestStream after completion");
394        }
395        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
396            |bytes, handles| {
397                match this.inner.channel().read_etc(cx, bytes, handles) {
398                    std::task::Poll::Ready(Ok(())) => {}
399                    std::task::Poll::Pending => return std::task::Poll::Pending,
400                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
401                        this.is_terminated = true;
402                        return std::task::Poll::Ready(None);
403                    }
404                    std::task::Poll::Ready(Err(e)) => {
405                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
406                            e.into(),
407                        ))));
408                    }
409                }
410
411                // A message has been received from the channel
412                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
413
414                std::task::Poll::Ready(Some(match header.ordinal {
415                    0x685918e57418eda8 => {
416                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
417                        let mut req = fidl::new_empty!(
418                            CallbacksRequestRequest,
419                            fidl::encoding::DefaultFuchsiaResourceDialect
420                        );
421                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksRequestRequest>(&header, _body_bytes, handles, &mut req)?;
422                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
423                        Ok(CallbacksRequest::Request { addr: req.addr, control_handle })
424                    }
425                    0x951dfbcb98699cc => {
426                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
427                        let mut req = fidl::new_empty!(
428                            CallbacksResponseRequest,
429                            fidl::encoding::DefaultFuchsiaResourceDialect
430                        );
431                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksResponseRequest>(&header, _body_bytes, handles, &mut req)?;
432                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
433                        Ok(CallbacksRequest::Response { addr: req.addr, control_handle })
434                    }
435                    0x7d6b0a28c75d5568 => {
436                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
437                        let mut req = fidl::new_empty!(
438                            CallbacksRstRequest,
439                            fidl::encoding::DefaultFuchsiaResourceDialect
440                        );
441                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksRstRequest>(&header, _body_bytes, handles, &mut req)?;
442                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
443                        Ok(CallbacksRequest::Rst { addr: req.addr, control_handle })
444                    }
445                    0x6021a72c49ab97cb => {
446                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
447                        let mut req = fidl::new_empty!(
448                            CallbacksShutdownRequest,
449                            fidl::encoding::DefaultFuchsiaResourceDialect
450                        );
451                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksShutdownRequest>(&header, _body_bytes, handles, &mut req)?;
452                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
453                        Ok(CallbacksRequest::Shutdown { addr: req.addr, control_handle })
454                    }
455                    0x23ba142d8c6a537 => {
456                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
457                        let mut req = fidl::new_empty!(
458                            CallbacksTransportResetRequest,
459                            fidl::encoding::DefaultFuchsiaResourceDialect
460                        );
461                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksTransportResetRequest>(&header, _body_bytes, handles, &mut req)?;
462                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
463                        Ok(CallbacksRequest::TransportReset {
464                            new_cid: req.new_cid,
465
466                            responder: CallbacksTransportResetResponder {
467                                control_handle: std::mem::ManuallyDrop::new(control_handle),
468                                tx_id: header.tx_id,
469                            },
470                        })
471                    }
472                    _ => Err(fidl::Error::UnknownOrdinal {
473                        ordinal: header.ordinal,
474                        protocol_name:
475                            <CallbacksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
476                    }),
477                }))
478            },
479        )
480    }
481}
482
483#[derive(Debug)]
484pub enum CallbacksRequest {
485    Request { addr: Addr, control_handle: CallbacksControlHandle },
486    Response { addr: Addr, control_handle: CallbacksControlHandle },
487    Rst { addr: Addr, control_handle: CallbacksControlHandle },
488    Shutdown { addr: Addr, control_handle: CallbacksControlHandle },
489    TransportReset { new_cid: u32, responder: CallbacksTransportResetResponder },
490}
491
492impl CallbacksRequest {
493    #[allow(irrefutable_let_patterns)]
494    pub fn into_request(self) -> Option<(Addr, CallbacksControlHandle)> {
495        if let CallbacksRequest::Request { addr, control_handle } = self {
496            Some((addr, control_handle))
497        } else {
498            None
499        }
500    }
501
502    #[allow(irrefutable_let_patterns)]
503    pub fn into_response(self) -> Option<(Addr, CallbacksControlHandle)> {
504        if let CallbacksRequest::Response { addr, control_handle } = self {
505            Some((addr, control_handle))
506        } else {
507            None
508        }
509    }
510
511    #[allow(irrefutable_let_patterns)]
512    pub fn into_rst(self) -> Option<(Addr, CallbacksControlHandle)> {
513        if let CallbacksRequest::Rst { addr, control_handle } = self {
514            Some((addr, control_handle))
515        } else {
516            None
517        }
518    }
519
520    #[allow(irrefutable_let_patterns)]
521    pub fn into_shutdown(self) -> Option<(Addr, CallbacksControlHandle)> {
522        if let CallbacksRequest::Shutdown { addr, control_handle } = self {
523            Some((addr, control_handle))
524        } else {
525            None
526        }
527    }
528
529    #[allow(irrefutable_let_patterns)]
530    pub fn into_transport_reset(self) -> Option<(u32, CallbacksTransportResetResponder)> {
531        if let CallbacksRequest::TransportReset { new_cid, responder } = self {
532            Some((new_cid, responder))
533        } else {
534            None
535        }
536    }
537
538    /// Name of the method defined in FIDL
539    pub fn method_name(&self) -> &'static str {
540        match *self {
541            CallbacksRequest::Request { .. } => "request",
542            CallbacksRequest::Response { .. } => "response",
543            CallbacksRequest::Rst { .. } => "rst",
544            CallbacksRequest::Shutdown { .. } => "shutdown",
545            CallbacksRequest::TransportReset { .. } => "transport_reset",
546        }
547    }
548}
549
550#[derive(Debug, Clone)]
551pub struct CallbacksControlHandle {
552    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
553}
554
555impl CallbacksControlHandle {
556    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
557        self.inner.shutdown_with_epitaph(status.into())
558    }
559}
560
561impl fidl::endpoints::ControlHandle for CallbacksControlHandle {
562    fn shutdown(&self) {
563        self.inner.shutdown()
564    }
565
566    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
567        self.inner.shutdown_with_epitaph(status)
568    }
569
570    fn is_closed(&self) -> bool {
571        self.inner.channel().is_closed()
572    }
573    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
574        self.inner.channel().on_closed()
575    }
576
577    #[cfg(target_os = "fuchsia")]
578    fn signal_peer(
579        &self,
580        clear_mask: zx::Signals,
581        set_mask: zx::Signals,
582    ) -> Result<(), zx_status::Status> {
583        use fidl::Peered;
584        self.inner.channel().signal_peer(clear_mask, set_mask)
585    }
586}
587
588impl CallbacksControlHandle {}
589
590#[must_use = "FIDL methods require a response to be sent"]
591#[derive(Debug)]
592pub struct CallbacksTransportResetResponder {
593    control_handle: std::mem::ManuallyDrop<CallbacksControlHandle>,
594    tx_id: u32,
595}
596
597/// Set the the channel to be shutdown (see [`CallbacksControlHandle::shutdown`])
598/// if the responder is dropped without sending a response, so that the client
599/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
600impl std::ops::Drop for CallbacksTransportResetResponder {
601    fn drop(&mut self) {
602        self.control_handle.shutdown();
603        // Safety: drops once, never accessed again
604        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
605    }
606}
607
608impl fidl::endpoints::Responder for CallbacksTransportResetResponder {
609    type ControlHandle = CallbacksControlHandle;
610
611    fn control_handle(&self) -> &CallbacksControlHandle {
612        &self.control_handle
613    }
614
615    fn drop_without_shutdown(mut self) {
616        // Safety: drops once, never accessed again due to mem::forget
617        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
618        // Prevent Drop from running (which would shut down the channel)
619        std::mem::forget(self);
620    }
621}
622
623impl CallbacksTransportResetResponder {
624    /// Sends a response to the FIDL transaction.
625    ///
626    /// Sets the channel to shutdown if an error occurs.
627    pub fn send(self) -> Result<(), fidl::Error> {
628        let _result = self.send_raw();
629        if _result.is_err() {
630            self.control_handle.shutdown();
631        }
632        self.drop_without_shutdown();
633        _result
634    }
635
636    /// Similar to "send" but does not shutdown the channel if an error occurs.
637    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
638        let _result = self.send_raw();
639        self.drop_without_shutdown();
640        _result
641    }
642
643    fn send_raw(&self) -> Result<(), fidl::Error> {
644        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
645            (),
646            self.tx_id,
647            0x23ba142d8c6a537,
648            fidl::encoding::DynamicFlags::empty(),
649        )
650    }
651}
652
653#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
654pub struct DeviceMarker;
655
656impl fidl::endpoints::ProtocolMarker for DeviceMarker {
657    type Proxy = DeviceProxy;
658    type RequestStream = DeviceRequestStream;
659    #[cfg(target_os = "fuchsia")]
660    type SynchronousProxy = DeviceSynchronousProxy;
661
662    const DEBUG_NAME: &'static str = "fuchsia.hardware.vsock.Device";
663}
664impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
665pub type DeviceStartResult = Result<(), i32>;
666pub type DeviceSendRequestResult = Result<(), i32>;
667pub type DeviceSendShutdownResult = Result<(), i32>;
668pub type DeviceSendRstResult = Result<(), i32>;
669pub type DeviceSendResponseResult = Result<(), i32>;
670
671pub trait DeviceProxyInterface: Send + Sync {
672    type StartResponseFut: std::future::Future<Output = Result<DeviceStartResult, fidl::Error>>
673        + Send;
674    fn r#start(&self, cb: fidl::endpoints::ClientEnd<CallbacksMarker>) -> Self::StartResponseFut;
675    type SendRequestResponseFut: std::future::Future<Output = Result<DeviceSendRequestResult, fidl::Error>>
676        + Send;
677    fn r#send_request(&self, addr: &Addr, data: fidl::Socket) -> Self::SendRequestResponseFut;
678    type SendShutdownResponseFut: std::future::Future<Output = Result<DeviceSendShutdownResult, fidl::Error>>
679        + Send;
680    fn r#send_shutdown(&self, addr: &Addr) -> Self::SendShutdownResponseFut;
681    type SendRstResponseFut: std::future::Future<Output = Result<DeviceSendRstResult, fidl::Error>>
682        + Send;
683    fn r#send_rst(&self, addr: &Addr) -> Self::SendRstResponseFut;
684    type SendResponseResponseFut: std::future::Future<Output = Result<DeviceSendResponseResult, fidl::Error>>
685        + Send;
686    fn r#send_response(&self, addr: &Addr, data: fidl::Socket) -> Self::SendResponseResponseFut;
687    type GetCidResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
688    fn r#get_cid(&self) -> Self::GetCidResponseFut;
689}
690#[derive(Debug)]
691#[cfg(target_os = "fuchsia")]
692pub struct DeviceSynchronousProxy {
693    client: fidl::client::sync::Client,
694}
695
696#[cfg(target_os = "fuchsia")]
697impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
698    type Proxy = DeviceProxy;
699    type Protocol = DeviceMarker;
700
701    fn from_channel(inner: fidl::Channel) -> Self {
702        Self::new(inner)
703    }
704
705    fn into_channel(self) -> fidl::Channel {
706        self.client.into_channel()
707    }
708
709    fn as_channel(&self) -> &fidl::Channel {
710        self.client.as_channel()
711    }
712}
713
714#[cfg(target_os = "fuchsia")]
715impl DeviceSynchronousProxy {
716    pub fn new(channel: fidl::Channel) -> Self {
717        Self { client: fidl::client::sync::Client::new(channel) }
718    }
719
720    pub fn into_channel(self) -> fidl::Channel {
721        self.client.into_channel()
722    }
723
724    /// Waits until an event arrives and returns it. It is safe for other
725    /// threads to make concurrent requests while waiting for an event.
726    pub fn wait_for_event(
727        &self,
728        deadline: zx::MonotonicInstant,
729    ) -> Result<DeviceEvent, fidl::Error> {
730        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
731    }
732
733    pub fn r#start(
734        &self,
735        mut cb: fidl::endpoints::ClientEnd<CallbacksMarker>,
736        ___deadline: zx::MonotonicInstant,
737    ) -> Result<DeviceStartResult, fidl::Error> {
738        let _response = self.client.send_query::<
739            DeviceStartRequest,
740            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
741            DeviceMarker,
742        >(
743            (cb,),
744            0x3bc3faaec6158f27,
745            fidl::encoding::DynamicFlags::empty(),
746            ___deadline,
747        )?;
748        Ok(_response.map(|x| x))
749    }
750
751    pub fn r#send_request(
752        &self,
753        mut addr: &Addr,
754        mut data: fidl::Socket,
755        ___deadline: zx::MonotonicInstant,
756    ) -> Result<DeviceSendRequestResult, fidl::Error> {
757        let _response = self.client.send_query::<
758            DeviceSendRequestRequest,
759            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
760            DeviceMarker,
761        >(
762            (addr, data,),
763            0x2dc165540021f74d,
764            fidl::encoding::DynamicFlags::empty(),
765            ___deadline,
766        )?;
767        Ok(_response.map(|x| x))
768    }
769
770    pub fn r#send_shutdown(
771        &self,
772        mut addr: &Addr,
773        ___deadline: zx::MonotonicInstant,
774    ) -> Result<DeviceSendShutdownResult, fidl::Error> {
775        let _response = self.client.send_query::<
776            DeviceSendShutdownRequest,
777            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
778            DeviceMarker,
779        >(
780            (addr,),
781            0x57cdc7b234933b44,
782            fidl::encoding::DynamicFlags::empty(),
783            ___deadline,
784        )?;
785        Ok(_response.map(|x| x))
786    }
787
788    pub fn r#send_rst(
789        &self,
790        mut addr: &Addr,
791        ___deadline: zx::MonotonicInstant,
792    ) -> Result<DeviceSendRstResult, fidl::Error> {
793        let _response = self.client.send_query::<
794            DeviceSendRstRequest,
795            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
796            DeviceMarker,
797        >(
798            (addr,),
799            0x334e890ef7cd737c,
800            fidl::encoding::DynamicFlags::empty(),
801            ___deadline,
802        )?;
803        Ok(_response.map(|x| x))
804    }
805
806    pub fn r#send_response(
807        &self,
808        mut addr: &Addr,
809        mut data: fidl::Socket,
810        ___deadline: zx::MonotonicInstant,
811    ) -> Result<DeviceSendResponseResult, fidl::Error> {
812        let _response = self.client.send_query::<
813            DeviceSendResponseRequest,
814            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
815            DeviceMarker,
816        >(
817            (addr, data,),
818            0x487a35133ffe0672,
819            fidl::encoding::DynamicFlags::empty(),
820            ___deadline,
821        )?;
822        Ok(_response.map(|x| x))
823    }
824
825    pub fn r#get_cid(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
826        let _response = self
827            .client
828            .send_query::<fidl::encoding::EmptyPayload, DeviceGetCidResponse, DeviceMarker>(
829                (),
830                0x7cf0847a452feafe,
831                fidl::encoding::DynamicFlags::empty(),
832                ___deadline,
833            )?;
834        Ok(_response.local_cid)
835    }
836}
837
838#[cfg(target_os = "fuchsia")]
839impl From<DeviceSynchronousProxy> for zx::NullableHandle {
840    fn from(value: DeviceSynchronousProxy) -> Self {
841        value.into_channel().into()
842    }
843}
844
845#[cfg(target_os = "fuchsia")]
846impl From<fidl::Channel> for DeviceSynchronousProxy {
847    fn from(value: fidl::Channel) -> Self {
848        Self::new(value)
849    }
850}
851
852#[cfg(target_os = "fuchsia")]
853impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
854    type Protocol = DeviceMarker;
855
856    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
857        Self::new(value.into_channel())
858    }
859}
860
861#[derive(Debug, Clone)]
862pub struct DeviceProxy {
863    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
864}
865
866impl fidl::endpoints::Proxy for DeviceProxy {
867    type Protocol = DeviceMarker;
868
869    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
870        Self::new(inner)
871    }
872
873    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
874        self.client.into_channel().map_err(|client| Self { client })
875    }
876
877    fn as_channel(&self) -> &::fidl::AsyncChannel {
878        self.client.as_channel()
879    }
880}
881
882impl DeviceProxy {
883    /// Create a new Proxy for fuchsia.hardware.vsock/Device.
884    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
885        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
886        Self { client: fidl::client::Client::new(channel, protocol_name) }
887    }
888
889    /// Get a Stream of events from the remote end of the protocol.
890    ///
891    /// # Panics
892    ///
893    /// Panics if the event stream was already taken.
894    pub fn take_event_stream(&self) -> DeviceEventStream {
895        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
896    }
897
898    pub fn r#start(
899        &self,
900        mut cb: fidl::endpoints::ClientEnd<CallbacksMarker>,
901    ) -> fidl::client::QueryResponseFut<
902        DeviceStartResult,
903        fidl::encoding::DefaultFuchsiaResourceDialect,
904    > {
905        DeviceProxyInterface::r#start(self, cb)
906    }
907
908    pub fn r#send_request(
909        &self,
910        mut addr: &Addr,
911        mut data: fidl::Socket,
912    ) -> fidl::client::QueryResponseFut<
913        DeviceSendRequestResult,
914        fidl::encoding::DefaultFuchsiaResourceDialect,
915    > {
916        DeviceProxyInterface::r#send_request(self, addr, data)
917    }
918
919    pub fn r#send_shutdown(
920        &self,
921        mut addr: &Addr,
922    ) -> fidl::client::QueryResponseFut<
923        DeviceSendShutdownResult,
924        fidl::encoding::DefaultFuchsiaResourceDialect,
925    > {
926        DeviceProxyInterface::r#send_shutdown(self, addr)
927    }
928
929    pub fn r#send_rst(
930        &self,
931        mut addr: &Addr,
932    ) -> fidl::client::QueryResponseFut<
933        DeviceSendRstResult,
934        fidl::encoding::DefaultFuchsiaResourceDialect,
935    > {
936        DeviceProxyInterface::r#send_rst(self, addr)
937    }
938
939    pub fn r#send_response(
940        &self,
941        mut addr: &Addr,
942        mut data: fidl::Socket,
943    ) -> fidl::client::QueryResponseFut<
944        DeviceSendResponseResult,
945        fidl::encoding::DefaultFuchsiaResourceDialect,
946    > {
947        DeviceProxyInterface::r#send_response(self, addr, data)
948    }
949
950    pub fn r#get_cid(
951        &self,
952    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
953        DeviceProxyInterface::r#get_cid(self)
954    }
955}
956
957impl DeviceProxyInterface for DeviceProxy {
958    type StartResponseFut = fidl::client::QueryResponseFut<
959        DeviceStartResult,
960        fidl::encoding::DefaultFuchsiaResourceDialect,
961    >;
962    fn r#start(
963        &self,
964        mut cb: fidl::endpoints::ClientEnd<CallbacksMarker>,
965    ) -> Self::StartResponseFut {
966        fn _decode(
967            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
968        ) -> Result<DeviceStartResult, fidl::Error> {
969            let _response = fidl::client::decode_transaction_body::<
970                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
971                fidl::encoding::DefaultFuchsiaResourceDialect,
972                0x3bc3faaec6158f27,
973            >(_buf?)?;
974            Ok(_response.map(|x| x))
975        }
976        self.client.send_query_and_decode::<DeviceStartRequest, DeviceStartResult>(
977            (cb,),
978            0x3bc3faaec6158f27,
979            fidl::encoding::DynamicFlags::empty(),
980            _decode,
981        )
982    }
983
984    type SendRequestResponseFut = fidl::client::QueryResponseFut<
985        DeviceSendRequestResult,
986        fidl::encoding::DefaultFuchsiaResourceDialect,
987    >;
988    fn r#send_request(
989        &self,
990        mut addr: &Addr,
991        mut data: fidl::Socket,
992    ) -> Self::SendRequestResponseFut {
993        fn _decode(
994            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
995        ) -> Result<DeviceSendRequestResult, fidl::Error> {
996            let _response = fidl::client::decode_transaction_body::<
997                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
998                fidl::encoding::DefaultFuchsiaResourceDialect,
999                0x2dc165540021f74d,
1000            >(_buf?)?;
1001            Ok(_response.map(|x| x))
1002        }
1003        self.client.send_query_and_decode::<DeviceSendRequestRequest, DeviceSendRequestResult>(
1004            (addr, data),
1005            0x2dc165540021f74d,
1006            fidl::encoding::DynamicFlags::empty(),
1007            _decode,
1008        )
1009    }
1010
1011    type SendShutdownResponseFut = fidl::client::QueryResponseFut<
1012        DeviceSendShutdownResult,
1013        fidl::encoding::DefaultFuchsiaResourceDialect,
1014    >;
1015    fn r#send_shutdown(&self, mut addr: &Addr) -> Self::SendShutdownResponseFut {
1016        fn _decode(
1017            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1018        ) -> Result<DeviceSendShutdownResult, fidl::Error> {
1019            let _response = fidl::client::decode_transaction_body::<
1020                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1021                fidl::encoding::DefaultFuchsiaResourceDialect,
1022                0x57cdc7b234933b44,
1023            >(_buf?)?;
1024            Ok(_response.map(|x| x))
1025        }
1026        self.client.send_query_and_decode::<DeviceSendShutdownRequest, DeviceSendShutdownResult>(
1027            (addr,),
1028            0x57cdc7b234933b44,
1029            fidl::encoding::DynamicFlags::empty(),
1030            _decode,
1031        )
1032    }
1033
1034    type SendRstResponseFut = fidl::client::QueryResponseFut<
1035        DeviceSendRstResult,
1036        fidl::encoding::DefaultFuchsiaResourceDialect,
1037    >;
1038    fn r#send_rst(&self, mut addr: &Addr) -> Self::SendRstResponseFut {
1039        fn _decode(
1040            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1041        ) -> Result<DeviceSendRstResult, fidl::Error> {
1042            let _response = fidl::client::decode_transaction_body::<
1043                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1044                fidl::encoding::DefaultFuchsiaResourceDialect,
1045                0x334e890ef7cd737c,
1046            >(_buf?)?;
1047            Ok(_response.map(|x| x))
1048        }
1049        self.client.send_query_and_decode::<DeviceSendRstRequest, DeviceSendRstResult>(
1050            (addr,),
1051            0x334e890ef7cd737c,
1052            fidl::encoding::DynamicFlags::empty(),
1053            _decode,
1054        )
1055    }
1056
1057    type SendResponseResponseFut = fidl::client::QueryResponseFut<
1058        DeviceSendResponseResult,
1059        fidl::encoding::DefaultFuchsiaResourceDialect,
1060    >;
1061    fn r#send_response(
1062        &self,
1063        mut addr: &Addr,
1064        mut data: fidl::Socket,
1065    ) -> Self::SendResponseResponseFut {
1066        fn _decode(
1067            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1068        ) -> Result<DeviceSendResponseResult, fidl::Error> {
1069            let _response = fidl::client::decode_transaction_body::<
1070                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1071                fidl::encoding::DefaultFuchsiaResourceDialect,
1072                0x487a35133ffe0672,
1073            >(_buf?)?;
1074            Ok(_response.map(|x| x))
1075        }
1076        self.client.send_query_and_decode::<DeviceSendResponseRequest, DeviceSendResponseResult>(
1077            (addr, data),
1078            0x487a35133ffe0672,
1079            fidl::encoding::DynamicFlags::empty(),
1080            _decode,
1081        )
1082    }
1083
1084    type GetCidResponseFut =
1085        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1086    fn r#get_cid(&self) -> Self::GetCidResponseFut {
1087        fn _decode(
1088            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1089        ) -> Result<u32, fidl::Error> {
1090            let _response = fidl::client::decode_transaction_body::<
1091                DeviceGetCidResponse,
1092                fidl::encoding::DefaultFuchsiaResourceDialect,
1093                0x7cf0847a452feafe,
1094            >(_buf?)?;
1095            Ok(_response.local_cid)
1096        }
1097        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
1098            (),
1099            0x7cf0847a452feafe,
1100            fidl::encoding::DynamicFlags::empty(),
1101            _decode,
1102        )
1103    }
1104}
1105
1106pub struct DeviceEventStream {
1107    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1108}
1109
1110impl std::marker::Unpin for DeviceEventStream {}
1111
1112impl futures::stream::FusedStream for DeviceEventStream {
1113    fn is_terminated(&self) -> bool {
1114        self.event_receiver.is_terminated()
1115    }
1116}
1117
1118impl futures::Stream for DeviceEventStream {
1119    type Item = Result<DeviceEvent, fidl::Error>;
1120
1121    fn poll_next(
1122        mut self: std::pin::Pin<&mut Self>,
1123        cx: &mut std::task::Context<'_>,
1124    ) -> std::task::Poll<Option<Self::Item>> {
1125        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1126            &mut self.event_receiver,
1127            cx
1128        )?) {
1129            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1130            None => std::task::Poll::Ready(None),
1131        }
1132    }
1133}
1134
1135#[derive(Debug)]
1136pub enum DeviceEvent {}
1137
1138impl DeviceEvent {
1139    /// Decodes a message buffer as a [`DeviceEvent`].
1140    fn decode(
1141        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1142    ) -> Result<DeviceEvent, fidl::Error> {
1143        let (bytes, _handles) = buf.split_mut();
1144        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1145        debug_assert_eq!(tx_header.tx_id, 0);
1146        match tx_header.ordinal {
1147            _ => Err(fidl::Error::UnknownOrdinal {
1148                ordinal: tx_header.ordinal,
1149                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1150            }),
1151        }
1152    }
1153}
1154
1155/// A Stream of incoming requests for fuchsia.hardware.vsock/Device.
1156pub struct DeviceRequestStream {
1157    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1158    is_terminated: bool,
1159}
1160
1161impl std::marker::Unpin for DeviceRequestStream {}
1162
1163impl futures::stream::FusedStream for DeviceRequestStream {
1164    fn is_terminated(&self) -> bool {
1165        self.is_terminated
1166    }
1167}
1168
1169impl fidl::endpoints::RequestStream for DeviceRequestStream {
1170    type Protocol = DeviceMarker;
1171    type ControlHandle = DeviceControlHandle;
1172
1173    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1174        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1175    }
1176
1177    fn control_handle(&self) -> Self::ControlHandle {
1178        DeviceControlHandle { inner: self.inner.clone() }
1179    }
1180
1181    fn into_inner(
1182        self,
1183    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1184    {
1185        (self.inner, self.is_terminated)
1186    }
1187
1188    fn from_inner(
1189        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1190        is_terminated: bool,
1191    ) -> Self {
1192        Self { inner, is_terminated }
1193    }
1194}
1195
1196impl futures::Stream for DeviceRequestStream {
1197    type Item = Result<DeviceRequest, fidl::Error>;
1198
1199    fn poll_next(
1200        mut self: std::pin::Pin<&mut Self>,
1201        cx: &mut std::task::Context<'_>,
1202    ) -> std::task::Poll<Option<Self::Item>> {
1203        let this = &mut *self;
1204        if this.inner.check_shutdown(cx) {
1205            this.is_terminated = true;
1206            return std::task::Poll::Ready(None);
1207        }
1208        if this.is_terminated {
1209            panic!("polled DeviceRequestStream after completion");
1210        }
1211        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1212            |bytes, handles| {
1213                match this.inner.channel().read_etc(cx, bytes, handles) {
1214                    std::task::Poll::Ready(Ok(())) => {}
1215                    std::task::Poll::Pending => return std::task::Poll::Pending,
1216                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1217                        this.is_terminated = true;
1218                        return std::task::Poll::Ready(None);
1219                    }
1220                    std::task::Poll::Ready(Err(e)) => {
1221                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1222                            e.into(),
1223                        ))));
1224                    }
1225                }
1226
1227                // A message has been received from the channel
1228                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1229
1230                std::task::Poll::Ready(Some(match header.ordinal {
1231                    0x3bc3faaec6158f27 => {
1232                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1233                        let mut req = fidl::new_empty!(
1234                            DeviceStartRequest,
1235                            fidl::encoding::DefaultFuchsiaResourceDialect
1236                        );
1237                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStartRequest>(&header, _body_bytes, handles, &mut req)?;
1238                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1239                        Ok(DeviceRequest::Start {
1240                            cb: req.cb,
1241
1242                            responder: DeviceStartResponder {
1243                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1244                                tx_id: header.tx_id,
1245                            },
1246                        })
1247                    }
1248                    0x2dc165540021f74d => {
1249                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1250                        let mut req = fidl::new_empty!(
1251                            DeviceSendRequestRequest,
1252                            fidl::encoding::DefaultFuchsiaResourceDialect
1253                        );
1254                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSendRequestRequest>(&header, _body_bytes, handles, &mut req)?;
1255                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1256                        Ok(DeviceRequest::SendRequest {
1257                            addr: req.addr,
1258                            data: req.data,
1259
1260                            responder: DeviceSendRequestResponder {
1261                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1262                                tx_id: header.tx_id,
1263                            },
1264                        })
1265                    }
1266                    0x57cdc7b234933b44 => {
1267                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1268                        let mut req = fidl::new_empty!(
1269                            DeviceSendShutdownRequest,
1270                            fidl::encoding::DefaultFuchsiaResourceDialect
1271                        );
1272                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSendShutdownRequest>(&header, _body_bytes, handles, &mut req)?;
1273                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1274                        Ok(DeviceRequest::SendShutdown {
1275                            addr: req.addr,
1276
1277                            responder: DeviceSendShutdownResponder {
1278                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1279                                tx_id: header.tx_id,
1280                            },
1281                        })
1282                    }
1283                    0x334e890ef7cd737c => {
1284                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1285                        let mut req = fidl::new_empty!(
1286                            DeviceSendRstRequest,
1287                            fidl::encoding::DefaultFuchsiaResourceDialect
1288                        );
1289                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSendRstRequest>(&header, _body_bytes, handles, &mut req)?;
1290                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1291                        Ok(DeviceRequest::SendRst {
1292                            addr: req.addr,
1293
1294                            responder: DeviceSendRstResponder {
1295                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1296                                tx_id: header.tx_id,
1297                            },
1298                        })
1299                    }
1300                    0x487a35133ffe0672 => {
1301                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1302                        let mut req = fidl::new_empty!(
1303                            DeviceSendResponseRequest,
1304                            fidl::encoding::DefaultFuchsiaResourceDialect
1305                        );
1306                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSendResponseRequest>(&header, _body_bytes, handles, &mut req)?;
1307                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1308                        Ok(DeviceRequest::SendResponse {
1309                            addr: req.addr,
1310                            data: req.data,
1311
1312                            responder: DeviceSendResponseResponder {
1313                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1314                                tx_id: header.tx_id,
1315                            },
1316                        })
1317                    }
1318                    0x7cf0847a452feafe => {
1319                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1320                        let mut req = fidl::new_empty!(
1321                            fidl::encoding::EmptyPayload,
1322                            fidl::encoding::DefaultFuchsiaResourceDialect
1323                        );
1324                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1325                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1326                        Ok(DeviceRequest::GetCid {
1327                            responder: DeviceGetCidResponder {
1328                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1329                                tx_id: header.tx_id,
1330                            },
1331                        })
1332                    }
1333                    _ => Err(fidl::Error::UnknownOrdinal {
1334                        ordinal: header.ordinal,
1335                        protocol_name:
1336                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1337                    }),
1338                }))
1339            },
1340        )
1341    }
1342}
1343
1344#[derive(Debug)]
1345pub enum DeviceRequest {
1346    Start { cb: fidl::endpoints::ClientEnd<CallbacksMarker>, responder: DeviceStartResponder },
1347    SendRequest { addr: Addr, data: fidl::Socket, responder: DeviceSendRequestResponder },
1348    SendShutdown { addr: Addr, responder: DeviceSendShutdownResponder },
1349    SendRst { addr: Addr, responder: DeviceSendRstResponder },
1350    SendResponse { addr: Addr, data: fidl::Socket, responder: DeviceSendResponseResponder },
1351    GetCid { responder: DeviceGetCidResponder },
1352}
1353
1354impl DeviceRequest {
1355    #[allow(irrefutable_let_patterns)]
1356    pub fn into_start(
1357        self,
1358    ) -> Option<(fidl::endpoints::ClientEnd<CallbacksMarker>, DeviceStartResponder)> {
1359        if let DeviceRequest::Start { cb, responder } = self { Some((cb, responder)) } else { None }
1360    }
1361
1362    #[allow(irrefutable_let_patterns)]
1363    pub fn into_send_request(self) -> Option<(Addr, fidl::Socket, DeviceSendRequestResponder)> {
1364        if let DeviceRequest::SendRequest { addr, data, responder } = self {
1365            Some((addr, data, responder))
1366        } else {
1367            None
1368        }
1369    }
1370
1371    #[allow(irrefutable_let_patterns)]
1372    pub fn into_send_shutdown(self) -> Option<(Addr, DeviceSendShutdownResponder)> {
1373        if let DeviceRequest::SendShutdown { addr, responder } = self {
1374            Some((addr, responder))
1375        } else {
1376            None
1377        }
1378    }
1379
1380    #[allow(irrefutable_let_patterns)]
1381    pub fn into_send_rst(self) -> Option<(Addr, DeviceSendRstResponder)> {
1382        if let DeviceRequest::SendRst { addr, responder } = self {
1383            Some((addr, responder))
1384        } else {
1385            None
1386        }
1387    }
1388
1389    #[allow(irrefutable_let_patterns)]
1390    pub fn into_send_response(self) -> Option<(Addr, fidl::Socket, DeviceSendResponseResponder)> {
1391        if let DeviceRequest::SendResponse { addr, data, responder } = self {
1392            Some((addr, data, responder))
1393        } else {
1394            None
1395        }
1396    }
1397
1398    #[allow(irrefutable_let_patterns)]
1399    pub fn into_get_cid(self) -> Option<(DeviceGetCidResponder)> {
1400        if let DeviceRequest::GetCid { responder } = self { Some((responder)) } else { None }
1401    }
1402
1403    /// Name of the method defined in FIDL
1404    pub fn method_name(&self) -> &'static str {
1405        match *self {
1406            DeviceRequest::Start { .. } => "start",
1407            DeviceRequest::SendRequest { .. } => "send_request",
1408            DeviceRequest::SendShutdown { .. } => "send_shutdown",
1409            DeviceRequest::SendRst { .. } => "send_rst",
1410            DeviceRequest::SendResponse { .. } => "send_response",
1411            DeviceRequest::GetCid { .. } => "get_cid",
1412        }
1413    }
1414}
1415
1416#[derive(Debug, Clone)]
1417pub struct DeviceControlHandle {
1418    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1419}
1420
1421impl DeviceControlHandle {
1422    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1423        self.inner.shutdown_with_epitaph(status.into())
1424    }
1425}
1426
1427impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1428    fn shutdown(&self) {
1429        self.inner.shutdown()
1430    }
1431
1432    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1433        self.inner.shutdown_with_epitaph(status)
1434    }
1435
1436    fn is_closed(&self) -> bool {
1437        self.inner.channel().is_closed()
1438    }
1439    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1440        self.inner.channel().on_closed()
1441    }
1442
1443    #[cfg(target_os = "fuchsia")]
1444    fn signal_peer(
1445        &self,
1446        clear_mask: zx::Signals,
1447        set_mask: zx::Signals,
1448    ) -> Result<(), zx_status::Status> {
1449        use fidl::Peered;
1450        self.inner.channel().signal_peer(clear_mask, set_mask)
1451    }
1452}
1453
1454impl DeviceControlHandle {}
1455
1456#[must_use = "FIDL methods require a response to be sent"]
1457#[derive(Debug)]
1458pub struct DeviceStartResponder {
1459    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1460    tx_id: u32,
1461}
1462
1463/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1464/// if the responder is dropped without sending a response, so that the client
1465/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1466impl std::ops::Drop for DeviceStartResponder {
1467    fn drop(&mut self) {
1468        self.control_handle.shutdown();
1469        // Safety: drops once, never accessed again
1470        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1471    }
1472}
1473
1474impl fidl::endpoints::Responder for DeviceStartResponder {
1475    type ControlHandle = DeviceControlHandle;
1476
1477    fn control_handle(&self) -> &DeviceControlHandle {
1478        &self.control_handle
1479    }
1480
1481    fn drop_without_shutdown(mut self) {
1482        // Safety: drops once, never accessed again due to mem::forget
1483        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1484        // Prevent Drop from running (which would shut down the channel)
1485        std::mem::forget(self);
1486    }
1487}
1488
1489impl DeviceStartResponder {
1490    /// Sends a response to the FIDL transaction.
1491    ///
1492    /// Sets the channel to shutdown if an error occurs.
1493    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1494        let _result = self.send_raw(result);
1495        if _result.is_err() {
1496            self.control_handle.shutdown();
1497        }
1498        self.drop_without_shutdown();
1499        _result
1500    }
1501
1502    /// Similar to "send" but does not shutdown the channel if an error occurs.
1503    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1504        let _result = self.send_raw(result);
1505        self.drop_without_shutdown();
1506        _result
1507    }
1508
1509    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1510        self.control_handle
1511            .inner
1512            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1513                result,
1514                self.tx_id,
1515                0x3bc3faaec6158f27,
1516                fidl::encoding::DynamicFlags::empty(),
1517            )
1518    }
1519}
1520
1521#[must_use = "FIDL methods require a response to be sent"]
1522#[derive(Debug)]
1523pub struct DeviceSendRequestResponder {
1524    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1525    tx_id: u32,
1526}
1527
1528/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1529/// if the responder is dropped without sending a response, so that the client
1530/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1531impl std::ops::Drop for DeviceSendRequestResponder {
1532    fn drop(&mut self) {
1533        self.control_handle.shutdown();
1534        // Safety: drops once, never accessed again
1535        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1536    }
1537}
1538
1539impl fidl::endpoints::Responder for DeviceSendRequestResponder {
1540    type ControlHandle = DeviceControlHandle;
1541
1542    fn control_handle(&self) -> &DeviceControlHandle {
1543        &self.control_handle
1544    }
1545
1546    fn drop_without_shutdown(mut self) {
1547        // Safety: drops once, never accessed again due to mem::forget
1548        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1549        // Prevent Drop from running (which would shut down the channel)
1550        std::mem::forget(self);
1551    }
1552}
1553
1554impl DeviceSendRequestResponder {
1555    /// Sends a response to the FIDL transaction.
1556    ///
1557    /// Sets the channel to shutdown if an error occurs.
1558    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1559        let _result = self.send_raw(result);
1560        if _result.is_err() {
1561            self.control_handle.shutdown();
1562        }
1563        self.drop_without_shutdown();
1564        _result
1565    }
1566
1567    /// Similar to "send" but does not shutdown the channel if an error occurs.
1568    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1569        let _result = self.send_raw(result);
1570        self.drop_without_shutdown();
1571        _result
1572    }
1573
1574    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1575        self.control_handle
1576            .inner
1577            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1578                result,
1579                self.tx_id,
1580                0x2dc165540021f74d,
1581                fidl::encoding::DynamicFlags::empty(),
1582            )
1583    }
1584}
1585
1586#[must_use = "FIDL methods require a response to be sent"]
1587#[derive(Debug)]
1588pub struct DeviceSendShutdownResponder {
1589    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1590    tx_id: u32,
1591}
1592
1593/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1594/// if the responder is dropped without sending a response, so that the client
1595/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1596impl std::ops::Drop for DeviceSendShutdownResponder {
1597    fn drop(&mut self) {
1598        self.control_handle.shutdown();
1599        // Safety: drops once, never accessed again
1600        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1601    }
1602}
1603
1604impl fidl::endpoints::Responder for DeviceSendShutdownResponder {
1605    type ControlHandle = DeviceControlHandle;
1606
1607    fn control_handle(&self) -> &DeviceControlHandle {
1608        &self.control_handle
1609    }
1610
1611    fn drop_without_shutdown(mut self) {
1612        // Safety: drops once, never accessed again due to mem::forget
1613        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1614        // Prevent Drop from running (which would shut down the channel)
1615        std::mem::forget(self);
1616    }
1617}
1618
1619impl DeviceSendShutdownResponder {
1620    /// Sends a response to the FIDL transaction.
1621    ///
1622    /// Sets the channel to shutdown if an error occurs.
1623    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1624        let _result = self.send_raw(result);
1625        if _result.is_err() {
1626            self.control_handle.shutdown();
1627        }
1628        self.drop_without_shutdown();
1629        _result
1630    }
1631
1632    /// Similar to "send" but does not shutdown the channel if an error occurs.
1633    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1634        let _result = self.send_raw(result);
1635        self.drop_without_shutdown();
1636        _result
1637    }
1638
1639    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1640        self.control_handle
1641            .inner
1642            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1643                result,
1644                self.tx_id,
1645                0x57cdc7b234933b44,
1646                fidl::encoding::DynamicFlags::empty(),
1647            )
1648    }
1649}
1650
1651#[must_use = "FIDL methods require a response to be sent"]
1652#[derive(Debug)]
1653pub struct DeviceSendRstResponder {
1654    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1655    tx_id: u32,
1656}
1657
1658/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1659/// if the responder is dropped without sending a response, so that the client
1660/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1661impl std::ops::Drop for DeviceSendRstResponder {
1662    fn drop(&mut self) {
1663        self.control_handle.shutdown();
1664        // Safety: drops once, never accessed again
1665        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1666    }
1667}
1668
1669impl fidl::endpoints::Responder for DeviceSendRstResponder {
1670    type ControlHandle = DeviceControlHandle;
1671
1672    fn control_handle(&self) -> &DeviceControlHandle {
1673        &self.control_handle
1674    }
1675
1676    fn drop_without_shutdown(mut self) {
1677        // Safety: drops once, never accessed again due to mem::forget
1678        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1679        // Prevent Drop from running (which would shut down the channel)
1680        std::mem::forget(self);
1681    }
1682}
1683
1684impl DeviceSendRstResponder {
1685    /// Sends a response to the FIDL transaction.
1686    ///
1687    /// Sets the channel to shutdown if an error occurs.
1688    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1689        let _result = self.send_raw(result);
1690        if _result.is_err() {
1691            self.control_handle.shutdown();
1692        }
1693        self.drop_without_shutdown();
1694        _result
1695    }
1696
1697    /// Similar to "send" but does not shutdown the channel if an error occurs.
1698    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1699        let _result = self.send_raw(result);
1700        self.drop_without_shutdown();
1701        _result
1702    }
1703
1704    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1705        self.control_handle
1706            .inner
1707            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1708                result,
1709                self.tx_id,
1710                0x334e890ef7cd737c,
1711                fidl::encoding::DynamicFlags::empty(),
1712            )
1713    }
1714}
1715
1716#[must_use = "FIDL methods require a response to be sent"]
1717#[derive(Debug)]
1718pub struct DeviceSendResponseResponder {
1719    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1720    tx_id: u32,
1721}
1722
1723/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1724/// if the responder is dropped without sending a response, so that the client
1725/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1726impl std::ops::Drop for DeviceSendResponseResponder {
1727    fn drop(&mut self) {
1728        self.control_handle.shutdown();
1729        // Safety: drops once, never accessed again
1730        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1731    }
1732}
1733
1734impl fidl::endpoints::Responder for DeviceSendResponseResponder {
1735    type ControlHandle = DeviceControlHandle;
1736
1737    fn control_handle(&self) -> &DeviceControlHandle {
1738        &self.control_handle
1739    }
1740
1741    fn drop_without_shutdown(mut self) {
1742        // Safety: drops once, never accessed again due to mem::forget
1743        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1744        // Prevent Drop from running (which would shut down the channel)
1745        std::mem::forget(self);
1746    }
1747}
1748
1749impl DeviceSendResponseResponder {
1750    /// Sends a response to the FIDL transaction.
1751    ///
1752    /// Sets the channel to shutdown if an error occurs.
1753    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1754        let _result = self.send_raw(result);
1755        if _result.is_err() {
1756            self.control_handle.shutdown();
1757        }
1758        self.drop_without_shutdown();
1759        _result
1760    }
1761
1762    /// Similar to "send" but does not shutdown the channel if an error occurs.
1763    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1764        let _result = self.send_raw(result);
1765        self.drop_without_shutdown();
1766        _result
1767    }
1768
1769    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1770        self.control_handle
1771            .inner
1772            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1773                result,
1774                self.tx_id,
1775                0x487a35133ffe0672,
1776                fidl::encoding::DynamicFlags::empty(),
1777            )
1778    }
1779}
1780
1781#[must_use = "FIDL methods require a response to be sent"]
1782#[derive(Debug)]
1783pub struct DeviceGetCidResponder {
1784    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1785    tx_id: u32,
1786}
1787
1788/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1789/// if the responder is dropped without sending a response, so that the client
1790/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1791impl std::ops::Drop for DeviceGetCidResponder {
1792    fn drop(&mut self) {
1793        self.control_handle.shutdown();
1794        // Safety: drops once, never accessed again
1795        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1796    }
1797}
1798
1799impl fidl::endpoints::Responder for DeviceGetCidResponder {
1800    type ControlHandle = DeviceControlHandle;
1801
1802    fn control_handle(&self) -> &DeviceControlHandle {
1803        &self.control_handle
1804    }
1805
1806    fn drop_without_shutdown(mut self) {
1807        // Safety: drops once, never accessed again due to mem::forget
1808        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1809        // Prevent Drop from running (which would shut down the channel)
1810        std::mem::forget(self);
1811    }
1812}
1813
1814impl DeviceGetCidResponder {
1815    /// Sends a response to the FIDL transaction.
1816    ///
1817    /// Sets the channel to shutdown if an error occurs.
1818    pub fn send(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1819        let _result = self.send_raw(local_cid);
1820        if _result.is_err() {
1821            self.control_handle.shutdown();
1822        }
1823        self.drop_without_shutdown();
1824        _result
1825    }
1826
1827    /// Similar to "send" but does not shutdown the channel if an error occurs.
1828    pub fn send_no_shutdown_on_err(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1829        let _result = self.send_raw(local_cid);
1830        self.drop_without_shutdown();
1831        _result
1832    }
1833
1834    fn send_raw(&self, mut local_cid: u32) -> Result<(), fidl::Error> {
1835        self.control_handle.inner.send::<DeviceGetCidResponse>(
1836            (local_cid,),
1837            self.tx_id,
1838            0x7cf0847a452feafe,
1839            fidl::encoding::DynamicFlags::empty(),
1840        )
1841    }
1842}
1843
1844#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1845pub struct ServiceMarker;
1846
1847#[cfg(target_os = "fuchsia")]
1848impl fidl::endpoints::ServiceMarker for ServiceMarker {
1849    type Proxy = ServiceProxy;
1850    type Request = ServiceRequest;
1851    const SERVICE_NAME: &'static str = "fuchsia.hardware.vsock.Service";
1852}
1853
1854/// A request for one of the member protocols of Service.
1855///
1856#[cfg(target_os = "fuchsia")]
1857pub enum ServiceRequest {
1858    Device(DeviceRequestStream),
1859}
1860
1861#[cfg(target_os = "fuchsia")]
1862impl fidl::endpoints::ServiceRequest for ServiceRequest {
1863    type Service = ServiceMarker;
1864
1865    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1866        match name {
1867            "device" => Self::Device(
1868                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1869            ),
1870            _ => panic!("no such member protocol name for service Service"),
1871        }
1872    }
1873
1874    fn member_names() -> &'static [&'static str] {
1875        &["device"]
1876    }
1877}
1878#[cfg(target_os = "fuchsia")]
1879pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1880
1881#[cfg(target_os = "fuchsia")]
1882impl fidl::endpoints::ServiceProxy for ServiceProxy {
1883    type Service = ServiceMarker;
1884
1885    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1886        Self(opener)
1887    }
1888}
1889
1890#[cfg(target_os = "fuchsia")]
1891impl ServiceProxy {
1892    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1893        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1894        self.connect_channel_to_device(server_end)?;
1895        Ok(proxy)
1896    }
1897
1898    /// Like `connect_to_device`, but returns a sync proxy.
1899    /// See [`Self::connect_to_device`] for more details.
1900    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1901        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1902        self.connect_channel_to_device(server_end)?;
1903        Ok(proxy)
1904    }
1905
1906    /// Like `connect_to_device`, but accepts a server end.
1907    /// See [`Self::connect_to_device`] for more details.
1908    pub fn connect_channel_to_device(
1909        &self,
1910        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1911    ) -> Result<(), fidl::Error> {
1912        self.0.open_member("device", server_end.into_channel())
1913    }
1914
1915    pub fn instance_name(&self) -> &str {
1916        self.0.instance_name()
1917    }
1918}
1919
1920mod internal {
1921    use super::*;
1922
1923    impl fidl::encoding::ResourceTypeMarker for DeviceSendRequestRequest {
1924        type Borrowed<'a> = &'a mut Self;
1925        fn take_or_borrow<'a>(
1926            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1927        ) -> Self::Borrowed<'a> {
1928            value
1929        }
1930    }
1931
1932    unsafe impl fidl::encoding::TypeMarker for DeviceSendRequestRequest {
1933        type Owned = Self;
1934
1935        #[inline(always)]
1936        fn inline_align(_context: fidl::encoding::Context) -> usize {
1937            4
1938        }
1939
1940        #[inline(always)]
1941        fn inline_size(_context: fidl::encoding::Context) -> usize {
1942            16
1943        }
1944    }
1945
1946    unsafe impl
1947        fidl::encoding::Encode<
1948            DeviceSendRequestRequest,
1949            fidl::encoding::DefaultFuchsiaResourceDialect,
1950        > for &mut DeviceSendRequestRequest
1951    {
1952        #[inline]
1953        unsafe fn encode(
1954            self,
1955            encoder: &mut fidl::encoding::Encoder<
1956                '_,
1957                fidl::encoding::DefaultFuchsiaResourceDialect,
1958            >,
1959            offset: usize,
1960            _depth: fidl::encoding::Depth,
1961        ) -> fidl::Result<()> {
1962            encoder.debug_check_bounds::<DeviceSendRequestRequest>(offset);
1963            // Delegate to tuple encoding.
1964            fidl::encoding::Encode::<
1965                DeviceSendRequestRequest,
1966                fidl::encoding::DefaultFuchsiaResourceDialect,
1967            >::encode(
1968                (
1969                    <Addr as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
1970                    <fidl::encoding::HandleType<
1971                        fidl::Socket,
1972                        { fidl::ObjectType::SOCKET.into_raw() },
1973                        2147483648,
1974                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1975                        &mut self.data
1976                    ),
1977                ),
1978                encoder,
1979                offset,
1980                _depth,
1981            )
1982        }
1983    }
1984    unsafe impl<
1985        T0: fidl::encoding::Encode<Addr, fidl::encoding::DefaultFuchsiaResourceDialect>,
1986        T1: fidl::encoding::Encode<
1987                fidl::encoding::HandleType<
1988                    fidl::Socket,
1989                    { fidl::ObjectType::SOCKET.into_raw() },
1990                    2147483648,
1991                >,
1992                fidl::encoding::DefaultFuchsiaResourceDialect,
1993            >,
1994    >
1995        fidl::encoding::Encode<
1996            DeviceSendRequestRequest,
1997            fidl::encoding::DefaultFuchsiaResourceDialect,
1998        > for (T0, T1)
1999    {
2000        #[inline]
2001        unsafe fn encode(
2002            self,
2003            encoder: &mut fidl::encoding::Encoder<
2004                '_,
2005                fidl::encoding::DefaultFuchsiaResourceDialect,
2006            >,
2007            offset: usize,
2008            depth: fidl::encoding::Depth,
2009        ) -> fidl::Result<()> {
2010            encoder.debug_check_bounds::<DeviceSendRequestRequest>(offset);
2011            // Zero out padding regions. There's no need to apply masks
2012            // because the unmasked parts will be overwritten by fields.
2013            // Write the fields.
2014            self.0.encode(encoder, offset + 0, depth)?;
2015            self.1.encode(encoder, offset + 12, depth)?;
2016            Ok(())
2017        }
2018    }
2019
2020    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2021        for DeviceSendRequestRequest
2022    {
2023        #[inline(always)]
2024        fn new_empty() -> Self {
2025            Self {
2026                addr: fidl::new_empty!(Addr, fidl::encoding::DefaultFuchsiaResourceDialect),
2027                data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2028            }
2029        }
2030
2031        #[inline]
2032        unsafe fn decode(
2033            &mut self,
2034            decoder: &mut fidl::encoding::Decoder<
2035                '_,
2036                fidl::encoding::DefaultFuchsiaResourceDialect,
2037            >,
2038            offset: usize,
2039            _depth: fidl::encoding::Depth,
2040        ) -> fidl::Result<()> {
2041            decoder.debug_check_bounds::<Self>(offset);
2042            // Verify that padding bytes are zero.
2043            fidl::decode!(
2044                Addr,
2045                fidl::encoding::DefaultFuchsiaResourceDialect,
2046                &mut self.addr,
2047                decoder,
2048                offset + 0,
2049                _depth
2050            )?;
2051            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 12, _depth)?;
2052            Ok(())
2053        }
2054    }
2055
2056    impl fidl::encoding::ResourceTypeMarker for DeviceSendResponseRequest {
2057        type Borrowed<'a> = &'a mut Self;
2058        fn take_or_borrow<'a>(
2059            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2060        ) -> Self::Borrowed<'a> {
2061            value
2062        }
2063    }
2064
2065    unsafe impl fidl::encoding::TypeMarker for DeviceSendResponseRequest {
2066        type Owned = Self;
2067
2068        #[inline(always)]
2069        fn inline_align(_context: fidl::encoding::Context) -> usize {
2070            4
2071        }
2072
2073        #[inline(always)]
2074        fn inline_size(_context: fidl::encoding::Context) -> usize {
2075            16
2076        }
2077    }
2078
2079    unsafe impl
2080        fidl::encoding::Encode<
2081            DeviceSendResponseRequest,
2082            fidl::encoding::DefaultFuchsiaResourceDialect,
2083        > for &mut DeviceSendResponseRequest
2084    {
2085        #[inline]
2086        unsafe fn encode(
2087            self,
2088            encoder: &mut fidl::encoding::Encoder<
2089                '_,
2090                fidl::encoding::DefaultFuchsiaResourceDialect,
2091            >,
2092            offset: usize,
2093            _depth: fidl::encoding::Depth,
2094        ) -> fidl::Result<()> {
2095            encoder.debug_check_bounds::<DeviceSendResponseRequest>(offset);
2096            // Delegate to tuple encoding.
2097            fidl::encoding::Encode::<
2098                DeviceSendResponseRequest,
2099                fidl::encoding::DefaultFuchsiaResourceDialect,
2100            >::encode(
2101                (
2102                    <Addr as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
2103                    <fidl::encoding::HandleType<
2104                        fidl::Socket,
2105                        { fidl::ObjectType::SOCKET.into_raw() },
2106                        2147483648,
2107                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2108                        &mut self.data
2109                    ),
2110                ),
2111                encoder,
2112                offset,
2113                _depth,
2114            )
2115        }
2116    }
2117    unsafe impl<
2118        T0: fidl::encoding::Encode<Addr, fidl::encoding::DefaultFuchsiaResourceDialect>,
2119        T1: fidl::encoding::Encode<
2120                fidl::encoding::HandleType<
2121                    fidl::Socket,
2122                    { fidl::ObjectType::SOCKET.into_raw() },
2123                    2147483648,
2124                >,
2125                fidl::encoding::DefaultFuchsiaResourceDialect,
2126            >,
2127    >
2128        fidl::encoding::Encode<
2129            DeviceSendResponseRequest,
2130            fidl::encoding::DefaultFuchsiaResourceDialect,
2131        > for (T0, T1)
2132    {
2133        #[inline]
2134        unsafe fn encode(
2135            self,
2136            encoder: &mut fidl::encoding::Encoder<
2137                '_,
2138                fidl::encoding::DefaultFuchsiaResourceDialect,
2139            >,
2140            offset: usize,
2141            depth: fidl::encoding::Depth,
2142        ) -> fidl::Result<()> {
2143            encoder.debug_check_bounds::<DeviceSendResponseRequest>(offset);
2144            // Zero out padding regions. There's no need to apply masks
2145            // because the unmasked parts will be overwritten by fields.
2146            // Write the fields.
2147            self.0.encode(encoder, offset + 0, depth)?;
2148            self.1.encode(encoder, offset + 12, depth)?;
2149            Ok(())
2150        }
2151    }
2152
2153    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2154        for DeviceSendResponseRequest
2155    {
2156        #[inline(always)]
2157        fn new_empty() -> Self {
2158            Self {
2159                addr: fidl::new_empty!(Addr, fidl::encoding::DefaultFuchsiaResourceDialect),
2160                data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2161            }
2162        }
2163
2164        #[inline]
2165        unsafe fn decode(
2166            &mut self,
2167            decoder: &mut fidl::encoding::Decoder<
2168                '_,
2169                fidl::encoding::DefaultFuchsiaResourceDialect,
2170            >,
2171            offset: usize,
2172            _depth: fidl::encoding::Depth,
2173        ) -> fidl::Result<()> {
2174            decoder.debug_check_bounds::<Self>(offset);
2175            // Verify that padding bytes are zero.
2176            fidl::decode!(
2177                Addr,
2178                fidl::encoding::DefaultFuchsiaResourceDialect,
2179                &mut self.addr,
2180                decoder,
2181                offset + 0,
2182                _depth
2183            )?;
2184            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 12, _depth)?;
2185            Ok(())
2186        }
2187    }
2188
2189    impl fidl::encoding::ResourceTypeMarker for DeviceStartRequest {
2190        type Borrowed<'a> = &'a mut Self;
2191        fn take_or_borrow<'a>(
2192            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2193        ) -> Self::Borrowed<'a> {
2194            value
2195        }
2196    }
2197
2198    unsafe impl fidl::encoding::TypeMarker for DeviceStartRequest {
2199        type Owned = Self;
2200
2201        #[inline(always)]
2202        fn inline_align(_context: fidl::encoding::Context) -> usize {
2203            4
2204        }
2205
2206        #[inline(always)]
2207        fn inline_size(_context: fidl::encoding::Context) -> usize {
2208            4
2209        }
2210    }
2211
2212    unsafe impl
2213        fidl::encoding::Encode<DeviceStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2214        for &mut DeviceStartRequest
2215    {
2216        #[inline]
2217        unsafe fn encode(
2218            self,
2219            encoder: &mut fidl::encoding::Encoder<
2220                '_,
2221                fidl::encoding::DefaultFuchsiaResourceDialect,
2222            >,
2223            offset: usize,
2224            _depth: fidl::encoding::Depth,
2225        ) -> fidl::Result<()> {
2226            encoder.debug_check_bounds::<DeviceStartRequest>(offset);
2227            // Delegate to tuple encoding.
2228            fidl::encoding::Encode::<DeviceStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2229                (
2230                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.cb),
2231                ),
2232                encoder, offset, _depth
2233            )
2234        }
2235    }
2236    unsafe impl<
2237        T0: fidl::encoding::Encode<
2238                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>>,
2239                fidl::encoding::DefaultFuchsiaResourceDialect,
2240            >,
2241    > fidl::encoding::Encode<DeviceStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2242        for (T0,)
2243    {
2244        #[inline]
2245        unsafe fn encode(
2246            self,
2247            encoder: &mut fidl::encoding::Encoder<
2248                '_,
2249                fidl::encoding::DefaultFuchsiaResourceDialect,
2250            >,
2251            offset: usize,
2252            depth: fidl::encoding::Depth,
2253        ) -> fidl::Result<()> {
2254            encoder.debug_check_bounds::<DeviceStartRequest>(offset);
2255            // Zero out padding regions. There's no need to apply masks
2256            // because the unmasked parts will be overwritten by fields.
2257            // Write the fields.
2258            self.0.encode(encoder, offset + 0, depth)?;
2259            Ok(())
2260        }
2261    }
2262
2263    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2264        for DeviceStartRequest
2265    {
2266        #[inline(always)]
2267        fn new_empty() -> Self {
2268            Self {
2269                cb: fidl::new_empty!(
2270                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>>,
2271                    fidl::encoding::DefaultFuchsiaResourceDialect
2272                ),
2273            }
2274        }
2275
2276        #[inline]
2277        unsafe fn decode(
2278            &mut self,
2279            decoder: &mut fidl::encoding::Decoder<
2280                '_,
2281                fidl::encoding::DefaultFuchsiaResourceDialect,
2282            >,
2283            offset: usize,
2284            _depth: fidl::encoding::Depth,
2285        ) -> fidl::Result<()> {
2286            decoder.debug_check_bounds::<Self>(offset);
2287            // Verify that padding bytes are zero.
2288            fidl::decode!(
2289                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>>,
2290                fidl::encoding::DefaultFuchsiaResourceDialect,
2291                &mut self.cb,
2292                decoder,
2293                offset + 0,
2294                _depth
2295            )?;
2296            Ok(())
2297        }
2298    }
2299}