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