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 { Some((cb, responder)) } else { None }
1347    }
1348
1349    #[allow(irrefutable_let_patterns)]
1350    pub fn into_send_request(self) -> Option<(Addr, fidl::Socket, DeviceSendRequestResponder)> {
1351        if let DeviceRequest::SendRequest { addr, data, responder } = self {
1352            Some((addr, data, responder))
1353        } else {
1354            None
1355        }
1356    }
1357
1358    #[allow(irrefutable_let_patterns)]
1359    pub fn into_send_shutdown(self) -> Option<(Addr, DeviceSendShutdownResponder)> {
1360        if let DeviceRequest::SendShutdown { addr, responder } = self {
1361            Some((addr, responder))
1362        } else {
1363            None
1364        }
1365    }
1366
1367    #[allow(irrefutable_let_patterns)]
1368    pub fn into_send_rst(self) -> Option<(Addr, DeviceSendRstResponder)> {
1369        if let DeviceRequest::SendRst { addr, responder } = self {
1370            Some((addr, responder))
1371        } else {
1372            None
1373        }
1374    }
1375
1376    #[allow(irrefutable_let_patterns)]
1377    pub fn into_send_response(self) -> Option<(Addr, fidl::Socket, DeviceSendResponseResponder)> {
1378        if let DeviceRequest::SendResponse { addr, data, responder } = self {
1379            Some((addr, data, responder))
1380        } else {
1381            None
1382        }
1383    }
1384
1385    #[allow(irrefutable_let_patterns)]
1386    pub fn into_get_cid(self) -> Option<(DeviceGetCidResponder)> {
1387        if let DeviceRequest::GetCid { responder } = self { Some((responder)) } else { None }
1388    }
1389
1390    /// Name of the method defined in FIDL
1391    pub fn method_name(&self) -> &'static str {
1392        match *self {
1393            DeviceRequest::Start { .. } => "start",
1394            DeviceRequest::SendRequest { .. } => "send_request",
1395            DeviceRequest::SendShutdown { .. } => "send_shutdown",
1396            DeviceRequest::SendRst { .. } => "send_rst",
1397            DeviceRequest::SendResponse { .. } => "send_response",
1398            DeviceRequest::GetCid { .. } => "get_cid",
1399        }
1400    }
1401}
1402
1403#[derive(Debug, Clone)]
1404pub struct DeviceControlHandle {
1405    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1406}
1407
1408impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1409    fn shutdown(&self) {
1410        self.inner.shutdown()
1411    }
1412    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1413        self.inner.shutdown_with_epitaph(status)
1414    }
1415
1416    fn is_closed(&self) -> bool {
1417        self.inner.channel().is_closed()
1418    }
1419    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1420        self.inner.channel().on_closed()
1421    }
1422
1423    #[cfg(target_os = "fuchsia")]
1424    fn signal_peer(
1425        &self,
1426        clear_mask: zx::Signals,
1427        set_mask: zx::Signals,
1428    ) -> Result<(), zx_status::Status> {
1429        use fidl::Peered;
1430        self.inner.channel().signal_peer(clear_mask, set_mask)
1431    }
1432}
1433
1434impl DeviceControlHandle {}
1435
1436#[must_use = "FIDL methods require a response to be sent"]
1437#[derive(Debug)]
1438pub struct DeviceStartResponder {
1439    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1440    tx_id: u32,
1441}
1442
1443/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1444/// if the responder is dropped without sending a response, so that the client
1445/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1446impl std::ops::Drop for DeviceStartResponder {
1447    fn drop(&mut self) {
1448        self.control_handle.shutdown();
1449        // Safety: drops once, never accessed again
1450        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1451    }
1452}
1453
1454impl fidl::endpoints::Responder for DeviceStartResponder {
1455    type ControlHandle = DeviceControlHandle;
1456
1457    fn control_handle(&self) -> &DeviceControlHandle {
1458        &self.control_handle
1459    }
1460
1461    fn drop_without_shutdown(mut self) {
1462        // Safety: drops once, never accessed again due to mem::forget
1463        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1464        // Prevent Drop from running (which would shut down the channel)
1465        std::mem::forget(self);
1466    }
1467}
1468
1469impl DeviceStartResponder {
1470    /// Sends a response to the FIDL transaction.
1471    ///
1472    /// Sets the channel to shutdown if an error occurs.
1473    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1474        let _result = self.send_raw(result);
1475        if _result.is_err() {
1476            self.control_handle.shutdown();
1477        }
1478        self.drop_without_shutdown();
1479        _result
1480    }
1481
1482    /// Similar to "send" but does not shutdown the channel if an error occurs.
1483    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1484        let _result = self.send_raw(result);
1485        self.drop_without_shutdown();
1486        _result
1487    }
1488
1489    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1490        self.control_handle
1491            .inner
1492            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1493                result,
1494                self.tx_id,
1495                0x3bc3faaec6158f27,
1496                fidl::encoding::DynamicFlags::empty(),
1497            )
1498    }
1499}
1500
1501#[must_use = "FIDL methods require a response to be sent"]
1502#[derive(Debug)]
1503pub struct DeviceSendRequestResponder {
1504    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1505    tx_id: u32,
1506}
1507
1508/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1509/// if the responder is dropped without sending a response, so that the client
1510/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1511impl std::ops::Drop for DeviceSendRequestResponder {
1512    fn drop(&mut self) {
1513        self.control_handle.shutdown();
1514        // Safety: drops once, never accessed again
1515        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1516    }
1517}
1518
1519impl fidl::endpoints::Responder for DeviceSendRequestResponder {
1520    type ControlHandle = DeviceControlHandle;
1521
1522    fn control_handle(&self) -> &DeviceControlHandle {
1523        &self.control_handle
1524    }
1525
1526    fn drop_without_shutdown(mut self) {
1527        // Safety: drops once, never accessed again due to mem::forget
1528        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1529        // Prevent Drop from running (which would shut down the channel)
1530        std::mem::forget(self);
1531    }
1532}
1533
1534impl DeviceSendRequestResponder {
1535    /// Sends a response to the FIDL transaction.
1536    ///
1537    /// Sets the channel to shutdown if an error occurs.
1538    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1539        let _result = self.send_raw(result);
1540        if _result.is_err() {
1541            self.control_handle.shutdown();
1542        }
1543        self.drop_without_shutdown();
1544        _result
1545    }
1546
1547    /// Similar to "send" but does not shutdown the channel if an error occurs.
1548    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1549        let _result = self.send_raw(result);
1550        self.drop_without_shutdown();
1551        _result
1552    }
1553
1554    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1555        self.control_handle
1556            .inner
1557            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1558                result,
1559                self.tx_id,
1560                0x2dc165540021f74d,
1561                fidl::encoding::DynamicFlags::empty(),
1562            )
1563    }
1564}
1565
1566#[must_use = "FIDL methods require a response to be sent"]
1567#[derive(Debug)]
1568pub struct DeviceSendShutdownResponder {
1569    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1570    tx_id: u32,
1571}
1572
1573/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1574/// if the responder is dropped without sending a response, so that the client
1575/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1576impl std::ops::Drop for DeviceSendShutdownResponder {
1577    fn drop(&mut self) {
1578        self.control_handle.shutdown();
1579        // Safety: drops once, never accessed again
1580        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1581    }
1582}
1583
1584impl fidl::endpoints::Responder for DeviceSendShutdownResponder {
1585    type ControlHandle = DeviceControlHandle;
1586
1587    fn control_handle(&self) -> &DeviceControlHandle {
1588        &self.control_handle
1589    }
1590
1591    fn drop_without_shutdown(mut self) {
1592        // Safety: drops once, never accessed again due to mem::forget
1593        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1594        // Prevent Drop from running (which would shut down the channel)
1595        std::mem::forget(self);
1596    }
1597}
1598
1599impl DeviceSendShutdownResponder {
1600    /// Sends a response to the FIDL transaction.
1601    ///
1602    /// Sets the channel to shutdown if an error occurs.
1603    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1604        let _result = self.send_raw(result);
1605        if _result.is_err() {
1606            self.control_handle.shutdown();
1607        }
1608        self.drop_without_shutdown();
1609        _result
1610    }
1611
1612    /// Similar to "send" but does not shutdown the channel if an error occurs.
1613    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1614        let _result = self.send_raw(result);
1615        self.drop_without_shutdown();
1616        _result
1617    }
1618
1619    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1620        self.control_handle
1621            .inner
1622            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1623                result,
1624                self.tx_id,
1625                0x57cdc7b234933b44,
1626                fidl::encoding::DynamicFlags::empty(),
1627            )
1628    }
1629}
1630
1631#[must_use = "FIDL methods require a response to be sent"]
1632#[derive(Debug)]
1633pub struct DeviceSendRstResponder {
1634    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1635    tx_id: u32,
1636}
1637
1638/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1639/// if the responder is dropped without sending a response, so that the client
1640/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1641impl std::ops::Drop for DeviceSendRstResponder {
1642    fn drop(&mut self) {
1643        self.control_handle.shutdown();
1644        // Safety: drops once, never accessed again
1645        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1646    }
1647}
1648
1649impl fidl::endpoints::Responder for DeviceSendRstResponder {
1650    type ControlHandle = DeviceControlHandle;
1651
1652    fn control_handle(&self) -> &DeviceControlHandle {
1653        &self.control_handle
1654    }
1655
1656    fn drop_without_shutdown(mut self) {
1657        // Safety: drops once, never accessed again due to mem::forget
1658        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1659        // Prevent Drop from running (which would shut down the channel)
1660        std::mem::forget(self);
1661    }
1662}
1663
1664impl DeviceSendRstResponder {
1665    /// Sends a response to the FIDL transaction.
1666    ///
1667    /// Sets the channel to shutdown if an error occurs.
1668    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1669        let _result = self.send_raw(result);
1670        if _result.is_err() {
1671            self.control_handle.shutdown();
1672        }
1673        self.drop_without_shutdown();
1674        _result
1675    }
1676
1677    /// Similar to "send" but does not shutdown the channel if an error occurs.
1678    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1679        let _result = self.send_raw(result);
1680        self.drop_without_shutdown();
1681        _result
1682    }
1683
1684    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1685        self.control_handle
1686            .inner
1687            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1688                result,
1689                self.tx_id,
1690                0x334e890ef7cd737c,
1691                fidl::encoding::DynamicFlags::empty(),
1692            )
1693    }
1694}
1695
1696#[must_use = "FIDL methods require a response to be sent"]
1697#[derive(Debug)]
1698pub struct DeviceSendResponseResponder {
1699    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1700    tx_id: u32,
1701}
1702
1703/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1704/// if the responder is dropped without sending a response, so that the client
1705/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1706impl std::ops::Drop for DeviceSendResponseResponder {
1707    fn drop(&mut self) {
1708        self.control_handle.shutdown();
1709        // Safety: drops once, never accessed again
1710        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1711    }
1712}
1713
1714impl fidl::endpoints::Responder for DeviceSendResponseResponder {
1715    type ControlHandle = DeviceControlHandle;
1716
1717    fn control_handle(&self) -> &DeviceControlHandle {
1718        &self.control_handle
1719    }
1720
1721    fn drop_without_shutdown(mut self) {
1722        // Safety: drops once, never accessed again due to mem::forget
1723        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1724        // Prevent Drop from running (which would shut down the channel)
1725        std::mem::forget(self);
1726    }
1727}
1728
1729impl DeviceSendResponseResponder {
1730    /// Sends a response to the FIDL transaction.
1731    ///
1732    /// Sets the channel to shutdown if an error occurs.
1733    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1734        let _result = self.send_raw(result);
1735        if _result.is_err() {
1736            self.control_handle.shutdown();
1737        }
1738        self.drop_without_shutdown();
1739        _result
1740    }
1741
1742    /// Similar to "send" but does not shutdown the channel if an error occurs.
1743    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1744        let _result = self.send_raw(result);
1745        self.drop_without_shutdown();
1746        _result
1747    }
1748
1749    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1750        self.control_handle
1751            .inner
1752            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1753                result,
1754                self.tx_id,
1755                0x487a35133ffe0672,
1756                fidl::encoding::DynamicFlags::empty(),
1757            )
1758    }
1759}
1760
1761#[must_use = "FIDL methods require a response to be sent"]
1762#[derive(Debug)]
1763pub struct DeviceGetCidResponder {
1764    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1765    tx_id: u32,
1766}
1767
1768/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1769/// if the responder is dropped without sending a response, so that the client
1770/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1771impl std::ops::Drop for DeviceGetCidResponder {
1772    fn drop(&mut self) {
1773        self.control_handle.shutdown();
1774        // Safety: drops once, never accessed again
1775        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1776    }
1777}
1778
1779impl fidl::endpoints::Responder for DeviceGetCidResponder {
1780    type ControlHandle = DeviceControlHandle;
1781
1782    fn control_handle(&self) -> &DeviceControlHandle {
1783        &self.control_handle
1784    }
1785
1786    fn drop_without_shutdown(mut self) {
1787        // Safety: drops once, never accessed again due to mem::forget
1788        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1789        // Prevent Drop from running (which would shut down the channel)
1790        std::mem::forget(self);
1791    }
1792}
1793
1794impl DeviceGetCidResponder {
1795    /// Sends a response to the FIDL transaction.
1796    ///
1797    /// Sets the channel to shutdown if an error occurs.
1798    pub fn send(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1799        let _result = self.send_raw(local_cid);
1800        if _result.is_err() {
1801            self.control_handle.shutdown();
1802        }
1803        self.drop_without_shutdown();
1804        _result
1805    }
1806
1807    /// Similar to "send" but does not shutdown the channel if an error occurs.
1808    pub fn send_no_shutdown_on_err(self, mut local_cid: u32) -> Result<(), fidl::Error> {
1809        let _result = self.send_raw(local_cid);
1810        self.drop_without_shutdown();
1811        _result
1812    }
1813
1814    fn send_raw(&self, mut local_cid: u32) -> Result<(), fidl::Error> {
1815        self.control_handle.inner.send::<DeviceGetCidResponse>(
1816            (local_cid,),
1817            self.tx_id,
1818            0x7cf0847a452feafe,
1819            fidl::encoding::DynamicFlags::empty(),
1820        )
1821    }
1822}
1823
1824#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1825pub struct ServiceMarker;
1826
1827#[cfg(target_os = "fuchsia")]
1828impl fidl::endpoints::ServiceMarker for ServiceMarker {
1829    type Proxy = ServiceProxy;
1830    type Request = ServiceRequest;
1831    const SERVICE_NAME: &'static str = "fuchsia.hardware.vsock.Service";
1832}
1833
1834/// A request for one of the member protocols of Service.
1835///
1836#[cfg(target_os = "fuchsia")]
1837pub enum ServiceRequest {
1838    Device(DeviceRequestStream),
1839}
1840
1841#[cfg(target_os = "fuchsia")]
1842impl fidl::endpoints::ServiceRequest for ServiceRequest {
1843    type Service = ServiceMarker;
1844
1845    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1846        match name {
1847            "device" => Self::Device(
1848                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1849            ),
1850            _ => panic!("no such member protocol name for service Service"),
1851        }
1852    }
1853
1854    fn member_names() -> &'static [&'static str] {
1855        &["device"]
1856    }
1857}
1858#[cfg(target_os = "fuchsia")]
1859pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1860
1861#[cfg(target_os = "fuchsia")]
1862impl fidl::endpoints::ServiceProxy for ServiceProxy {
1863    type Service = ServiceMarker;
1864
1865    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1866        Self(opener)
1867    }
1868}
1869
1870#[cfg(target_os = "fuchsia")]
1871impl ServiceProxy {
1872    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1873        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1874        self.connect_channel_to_device(server_end)?;
1875        Ok(proxy)
1876    }
1877
1878    /// Like `connect_to_device`, but returns a sync proxy.
1879    /// See [`Self::connect_to_device`] for more details.
1880    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1881        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1882        self.connect_channel_to_device(server_end)?;
1883        Ok(proxy)
1884    }
1885
1886    /// Like `connect_to_device`, but accepts a server end.
1887    /// See [`Self::connect_to_device`] for more details.
1888    pub fn connect_channel_to_device(
1889        &self,
1890        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1891    ) -> Result<(), fidl::Error> {
1892        self.0.open_member("device", server_end.into_channel())
1893    }
1894
1895    pub fn instance_name(&self) -> &str {
1896        self.0.instance_name()
1897    }
1898}
1899
1900mod internal {
1901    use super::*;
1902
1903    impl fidl::encoding::ResourceTypeMarker for DeviceSendRequestRequest {
1904        type Borrowed<'a> = &'a mut Self;
1905        fn take_or_borrow<'a>(
1906            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1907        ) -> Self::Borrowed<'a> {
1908            value
1909        }
1910    }
1911
1912    unsafe impl fidl::encoding::TypeMarker for DeviceSendRequestRequest {
1913        type Owned = Self;
1914
1915        #[inline(always)]
1916        fn inline_align(_context: fidl::encoding::Context) -> usize {
1917            4
1918        }
1919
1920        #[inline(always)]
1921        fn inline_size(_context: fidl::encoding::Context) -> usize {
1922            16
1923        }
1924    }
1925
1926    unsafe impl
1927        fidl::encoding::Encode<
1928            DeviceSendRequestRequest,
1929            fidl::encoding::DefaultFuchsiaResourceDialect,
1930        > for &mut DeviceSendRequestRequest
1931    {
1932        #[inline]
1933        unsafe fn encode(
1934            self,
1935            encoder: &mut fidl::encoding::Encoder<
1936                '_,
1937                fidl::encoding::DefaultFuchsiaResourceDialect,
1938            >,
1939            offset: usize,
1940            _depth: fidl::encoding::Depth,
1941        ) -> fidl::Result<()> {
1942            encoder.debug_check_bounds::<DeviceSendRequestRequest>(offset);
1943            // Delegate to tuple encoding.
1944            fidl::encoding::Encode::<
1945                DeviceSendRequestRequest,
1946                fidl::encoding::DefaultFuchsiaResourceDialect,
1947            >::encode(
1948                (
1949                    <Addr as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
1950                    <fidl::encoding::HandleType<
1951                        fidl::Socket,
1952                        { fidl::ObjectType::SOCKET.into_raw() },
1953                        2147483648,
1954                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1955                        &mut self.data
1956                    ),
1957                ),
1958                encoder,
1959                offset,
1960                _depth,
1961            )
1962        }
1963    }
1964    unsafe impl<
1965        T0: fidl::encoding::Encode<Addr, fidl::encoding::DefaultFuchsiaResourceDialect>,
1966        T1: fidl::encoding::Encode<
1967                fidl::encoding::HandleType<
1968                    fidl::Socket,
1969                    { fidl::ObjectType::SOCKET.into_raw() },
1970                    2147483648,
1971                >,
1972                fidl::encoding::DefaultFuchsiaResourceDialect,
1973            >,
1974    >
1975        fidl::encoding::Encode<
1976            DeviceSendRequestRequest,
1977            fidl::encoding::DefaultFuchsiaResourceDialect,
1978        > for (T0, T1)
1979    {
1980        #[inline]
1981        unsafe fn encode(
1982            self,
1983            encoder: &mut fidl::encoding::Encoder<
1984                '_,
1985                fidl::encoding::DefaultFuchsiaResourceDialect,
1986            >,
1987            offset: usize,
1988            depth: fidl::encoding::Depth,
1989        ) -> fidl::Result<()> {
1990            encoder.debug_check_bounds::<DeviceSendRequestRequest>(offset);
1991            // Zero out padding regions. There's no need to apply masks
1992            // because the unmasked parts will be overwritten by fields.
1993            // Write the fields.
1994            self.0.encode(encoder, offset + 0, depth)?;
1995            self.1.encode(encoder, offset + 12, depth)?;
1996            Ok(())
1997        }
1998    }
1999
2000    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2001        for DeviceSendRequestRequest
2002    {
2003        #[inline(always)]
2004        fn new_empty() -> Self {
2005            Self {
2006                addr: fidl::new_empty!(Addr, fidl::encoding::DefaultFuchsiaResourceDialect),
2007                data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2008            }
2009        }
2010
2011        #[inline]
2012        unsafe fn decode(
2013            &mut self,
2014            decoder: &mut fidl::encoding::Decoder<
2015                '_,
2016                fidl::encoding::DefaultFuchsiaResourceDialect,
2017            >,
2018            offset: usize,
2019            _depth: fidl::encoding::Depth,
2020        ) -> fidl::Result<()> {
2021            decoder.debug_check_bounds::<Self>(offset);
2022            // Verify that padding bytes are zero.
2023            fidl::decode!(
2024                Addr,
2025                fidl::encoding::DefaultFuchsiaResourceDialect,
2026                &mut self.addr,
2027                decoder,
2028                offset + 0,
2029                _depth
2030            )?;
2031            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 12, _depth)?;
2032            Ok(())
2033        }
2034    }
2035
2036    impl fidl::encoding::ResourceTypeMarker for DeviceSendResponseRequest {
2037        type Borrowed<'a> = &'a mut Self;
2038        fn take_or_borrow<'a>(
2039            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2040        ) -> Self::Borrowed<'a> {
2041            value
2042        }
2043    }
2044
2045    unsafe impl fidl::encoding::TypeMarker for DeviceSendResponseRequest {
2046        type Owned = Self;
2047
2048        #[inline(always)]
2049        fn inline_align(_context: fidl::encoding::Context) -> usize {
2050            4
2051        }
2052
2053        #[inline(always)]
2054        fn inline_size(_context: fidl::encoding::Context) -> usize {
2055            16
2056        }
2057    }
2058
2059    unsafe impl
2060        fidl::encoding::Encode<
2061            DeviceSendResponseRequest,
2062            fidl::encoding::DefaultFuchsiaResourceDialect,
2063        > for &mut DeviceSendResponseRequest
2064    {
2065        #[inline]
2066        unsafe fn encode(
2067            self,
2068            encoder: &mut fidl::encoding::Encoder<
2069                '_,
2070                fidl::encoding::DefaultFuchsiaResourceDialect,
2071            >,
2072            offset: usize,
2073            _depth: fidl::encoding::Depth,
2074        ) -> fidl::Result<()> {
2075            encoder.debug_check_bounds::<DeviceSendResponseRequest>(offset);
2076            // Delegate to tuple encoding.
2077            fidl::encoding::Encode::<
2078                DeviceSendResponseRequest,
2079                fidl::encoding::DefaultFuchsiaResourceDialect,
2080            >::encode(
2081                (
2082                    <Addr as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
2083                    <fidl::encoding::HandleType<
2084                        fidl::Socket,
2085                        { fidl::ObjectType::SOCKET.into_raw() },
2086                        2147483648,
2087                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2088                        &mut self.data
2089                    ),
2090                ),
2091                encoder,
2092                offset,
2093                _depth,
2094            )
2095        }
2096    }
2097    unsafe impl<
2098        T0: fidl::encoding::Encode<Addr, fidl::encoding::DefaultFuchsiaResourceDialect>,
2099        T1: fidl::encoding::Encode<
2100                fidl::encoding::HandleType<
2101                    fidl::Socket,
2102                    { fidl::ObjectType::SOCKET.into_raw() },
2103                    2147483648,
2104                >,
2105                fidl::encoding::DefaultFuchsiaResourceDialect,
2106            >,
2107    >
2108        fidl::encoding::Encode<
2109            DeviceSendResponseRequest,
2110            fidl::encoding::DefaultFuchsiaResourceDialect,
2111        > for (T0, T1)
2112    {
2113        #[inline]
2114        unsafe fn encode(
2115            self,
2116            encoder: &mut fidl::encoding::Encoder<
2117                '_,
2118                fidl::encoding::DefaultFuchsiaResourceDialect,
2119            >,
2120            offset: usize,
2121            depth: fidl::encoding::Depth,
2122        ) -> fidl::Result<()> {
2123            encoder.debug_check_bounds::<DeviceSendResponseRequest>(offset);
2124            // Zero out padding regions. There's no need to apply masks
2125            // because the unmasked parts will be overwritten by fields.
2126            // Write the fields.
2127            self.0.encode(encoder, offset + 0, depth)?;
2128            self.1.encode(encoder, offset + 12, depth)?;
2129            Ok(())
2130        }
2131    }
2132
2133    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2134        for DeviceSendResponseRequest
2135    {
2136        #[inline(always)]
2137        fn new_empty() -> Self {
2138            Self {
2139                addr: fidl::new_empty!(Addr, fidl::encoding::DefaultFuchsiaResourceDialect),
2140                data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2141            }
2142        }
2143
2144        #[inline]
2145        unsafe fn decode(
2146            &mut self,
2147            decoder: &mut fidl::encoding::Decoder<
2148                '_,
2149                fidl::encoding::DefaultFuchsiaResourceDialect,
2150            >,
2151            offset: usize,
2152            _depth: fidl::encoding::Depth,
2153        ) -> fidl::Result<()> {
2154            decoder.debug_check_bounds::<Self>(offset);
2155            // Verify that padding bytes are zero.
2156            fidl::decode!(
2157                Addr,
2158                fidl::encoding::DefaultFuchsiaResourceDialect,
2159                &mut self.addr,
2160                decoder,
2161                offset + 0,
2162                _depth
2163            )?;
2164            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 12, _depth)?;
2165            Ok(())
2166        }
2167    }
2168
2169    impl fidl::encoding::ResourceTypeMarker for DeviceStartRequest {
2170        type Borrowed<'a> = &'a mut Self;
2171        fn take_or_borrow<'a>(
2172            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2173        ) -> Self::Borrowed<'a> {
2174            value
2175        }
2176    }
2177
2178    unsafe impl fidl::encoding::TypeMarker for DeviceStartRequest {
2179        type Owned = Self;
2180
2181        #[inline(always)]
2182        fn inline_align(_context: fidl::encoding::Context) -> usize {
2183            4
2184        }
2185
2186        #[inline(always)]
2187        fn inline_size(_context: fidl::encoding::Context) -> usize {
2188            4
2189        }
2190    }
2191
2192    unsafe impl
2193        fidl::encoding::Encode<DeviceStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2194        for &mut DeviceStartRequest
2195    {
2196        #[inline]
2197        unsafe fn encode(
2198            self,
2199            encoder: &mut fidl::encoding::Encoder<
2200                '_,
2201                fidl::encoding::DefaultFuchsiaResourceDialect,
2202            >,
2203            offset: usize,
2204            _depth: fidl::encoding::Depth,
2205        ) -> fidl::Result<()> {
2206            encoder.debug_check_bounds::<DeviceStartRequest>(offset);
2207            // Delegate to tuple encoding.
2208            fidl::encoding::Encode::<DeviceStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2209                (
2210                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.cb),
2211                ),
2212                encoder, offset, _depth
2213            )
2214        }
2215    }
2216    unsafe impl<
2217        T0: fidl::encoding::Encode<
2218                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>>,
2219                fidl::encoding::DefaultFuchsiaResourceDialect,
2220            >,
2221    > fidl::encoding::Encode<DeviceStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2222        for (T0,)
2223    {
2224        #[inline]
2225        unsafe fn encode(
2226            self,
2227            encoder: &mut fidl::encoding::Encoder<
2228                '_,
2229                fidl::encoding::DefaultFuchsiaResourceDialect,
2230            >,
2231            offset: usize,
2232            depth: fidl::encoding::Depth,
2233        ) -> fidl::Result<()> {
2234            encoder.debug_check_bounds::<DeviceStartRequest>(offset);
2235            // Zero out padding regions. There's no need to apply masks
2236            // because the unmasked parts will be overwritten by fields.
2237            // Write the fields.
2238            self.0.encode(encoder, offset + 0, depth)?;
2239            Ok(())
2240        }
2241    }
2242
2243    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2244        for DeviceStartRequest
2245    {
2246        #[inline(always)]
2247        fn new_empty() -> Self {
2248            Self {
2249                cb: fidl::new_empty!(
2250                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>>,
2251                    fidl::encoding::DefaultFuchsiaResourceDialect
2252                ),
2253            }
2254        }
2255
2256        #[inline]
2257        unsafe fn decode(
2258            &mut self,
2259            decoder: &mut fidl::encoding::Decoder<
2260                '_,
2261                fidl::encoding::DefaultFuchsiaResourceDialect,
2262            >,
2263            offset: usize,
2264            _depth: fidl::encoding::Depth,
2265        ) -> fidl::Result<()> {
2266            decoder.debug_check_bounds::<Self>(offset);
2267            // Verify that padding bytes are zero.
2268            fidl::decode!(
2269                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>>,
2270                fidl::encoding::DefaultFuchsiaResourceDialect,
2271                &mut self.cb,
2272                decoder,
2273                offset + 0,
2274                _depth
2275            )?;
2276            Ok(())
2277        }
2278    }
2279}