Skip to main content

fidl_fuchsia_hardware_vsock/
fidl_fuchsia_hardware_vsock.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_vsock__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceSendRequestRequest {
16    pub addr: Addr,
17    pub data: fidl::Socket,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceSendRequestRequest {}
21
22#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub struct DeviceSendResponseRequest {
24    pub addr: Addr,
25    pub data: fidl::Socket,
26}
27
28impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceSendResponseRequest {}
29
30#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
31pub struct DeviceStartRequest {
32    pub cb: fidl::endpoints::ClientEnd<CallbacksMarker>,
33}
34
35impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceStartRequest {}
36
37#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
38pub struct CallbacksMarker;
39
40impl fidl::endpoints::ProtocolMarker for CallbacksMarker {
41    type Proxy = CallbacksProxy;
42    type RequestStream = CallbacksRequestStream;
43    #[cfg(target_os = "fuchsia")]
44    type SynchronousProxy = CallbacksSynchronousProxy;
45
46    const DEBUG_NAME: &'static str = "(anonymous) Callbacks";
47}
48
49pub trait CallbacksProxyInterface: Send + Sync {
50    fn r#request(&self, addr: &Addr) -> Result<(), fidl::Error>;
51    fn r#response(&self, addr: &Addr) -> Result<(), fidl::Error>;
52    fn r#rst(&self, addr: &Addr) -> Result<(), fidl::Error>;
53    fn r#shutdown(&self, addr: &Addr) -> Result<(), fidl::Error>;
54    type TransportResetResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
55    fn r#transport_reset(&self, new_cid: u32) -> Self::TransportResetResponseFut;
56}
57#[derive(Debug)]
58#[cfg(target_os = "fuchsia")]
59pub struct CallbacksSynchronousProxy {
60    client: fidl::client::sync::Client,
61}
62
63#[cfg(target_os = "fuchsia")]
64impl fidl::endpoints::SynchronousProxy for CallbacksSynchronousProxy {
65    type Proxy = CallbacksProxy;
66    type Protocol = CallbacksMarker;
67
68    fn from_channel(inner: fidl::Channel) -> Self {
69        Self::new(inner)
70    }
71
72    fn into_channel(self) -> fidl::Channel {
73        self.client.into_channel()
74    }
75
76    fn as_channel(&self) -> &fidl::Channel {
77        self.client.as_channel()
78    }
79}
80
81#[cfg(target_os = "fuchsia")]
82impl CallbacksSynchronousProxy {
83    pub fn new(channel: fidl::Channel) -> Self {
84        Self { client: fidl::client::sync::Client::new(channel) }
85    }
86
87    pub fn into_channel(self) -> fidl::Channel {
88        self.client.into_channel()
89    }
90
91    /// Waits until an event arrives and returns it. It is safe for other
92    /// threads to make concurrent requests while waiting for an event.
93    pub fn wait_for_event(
94        &self,
95        deadline: zx::MonotonicInstant,
96    ) -> Result<CallbacksEvent, fidl::Error> {
97        CallbacksEvent::decode(self.client.wait_for_event::<CallbacksMarker>(deadline)?)
98    }
99
100    pub fn r#request(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
101        self.client.send::<CallbacksRequestRequest>(
102            (addr,),
103            0x685918e57418eda8,
104            fidl::encoding::DynamicFlags::empty(),
105        )
106    }
107
108    pub fn r#response(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
109        self.client.send::<CallbacksResponseRequest>(
110            (addr,),
111            0x951dfbcb98699cc,
112            fidl::encoding::DynamicFlags::empty(),
113        )
114    }
115
116    pub fn r#rst(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
117        self.client.send::<CallbacksRstRequest>(
118            (addr,),
119            0x7d6b0a28c75d5568,
120            fidl::encoding::DynamicFlags::empty(),
121        )
122    }
123
124    pub fn r#shutdown(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
125        self.client.send::<CallbacksShutdownRequest>(
126            (addr,),
127            0x6021a72c49ab97cb,
128            fidl::encoding::DynamicFlags::empty(),
129        )
130    }
131
132    pub fn r#transport_reset(
133        &self,
134        mut new_cid: u32,
135        ___deadline: zx::MonotonicInstant,
136    ) -> Result<(), fidl::Error> {
137        let _response = self.client.send_query::<
138            CallbacksTransportResetRequest,
139            fidl::encoding::EmptyPayload,
140            CallbacksMarker,
141        >(
142            (new_cid,),
143            0x23ba142d8c6a537,
144            fidl::encoding::DynamicFlags::empty(),
145            ___deadline,
146        )?;
147        Ok(_response)
148    }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl From<CallbacksSynchronousProxy> for zx::NullableHandle {
153    fn from(value: CallbacksSynchronousProxy) -> Self {
154        value.into_channel().into()
155    }
156}
157
158#[cfg(target_os = "fuchsia")]
159impl From<fidl::Channel> for CallbacksSynchronousProxy {
160    fn from(value: fidl::Channel) -> Self {
161        Self::new(value)
162    }
163}
164
165#[cfg(target_os = "fuchsia")]
166impl fidl::endpoints::FromClient for CallbacksSynchronousProxy {
167    type Protocol = CallbacksMarker;
168
169    fn from_client(value: fidl::endpoints::ClientEnd<CallbacksMarker>) -> Self {
170        Self::new(value.into_channel())
171    }
172}
173
174#[derive(Debug, Clone)]
175pub struct CallbacksProxy {
176    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
177}
178
179impl fidl::endpoints::Proxy for CallbacksProxy {
180    type Protocol = CallbacksMarker;
181
182    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
183        Self::new(inner)
184    }
185
186    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
187        self.client.into_channel().map_err(|client| Self { client })
188    }
189
190    fn as_channel(&self) -> &::fidl::AsyncChannel {
191        self.client.as_channel()
192    }
193}
194
195impl CallbacksProxy {
196    /// Create a new Proxy for fuchsia.hardware.vsock/Callbacks.
197    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
198        let protocol_name = <CallbacksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
199        Self { client: fidl::client::Client::new(channel, protocol_name) }
200    }
201
202    /// Get a Stream of events from the remote end of the protocol.
203    ///
204    /// # Panics
205    ///
206    /// Panics if the event stream was already taken.
207    pub fn take_event_stream(&self) -> CallbacksEventStream {
208        CallbacksEventStream { event_receiver: self.client.take_event_receiver() }
209    }
210
211    pub fn r#request(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
212        CallbacksProxyInterface::r#request(self, addr)
213    }
214
215    pub fn r#response(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
216        CallbacksProxyInterface::r#response(self, addr)
217    }
218
219    pub fn r#rst(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
220        CallbacksProxyInterface::r#rst(self, addr)
221    }
222
223    pub fn r#shutdown(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
224        CallbacksProxyInterface::r#shutdown(self, addr)
225    }
226
227    pub fn r#transport_reset(
228        &self,
229        mut new_cid: u32,
230    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
231        CallbacksProxyInterface::r#transport_reset(self, new_cid)
232    }
233}
234
235impl CallbacksProxyInterface for CallbacksProxy {
236    fn r#request(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
237        self.client.send::<CallbacksRequestRequest>(
238            (addr,),
239            0x685918e57418eda8,
240            fidl::encoding::DynamicFlags::empty(),
241        )
242    }
243
244    fn r#response(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
245        self.client.send::<CallbacksResponseRequest>(
246            (addr,),
247            0x951dfbcb98699cc,
248            fidl::encoding::DynamicFlags::empty(),
249        )
250    }
251
252    fn r#rst(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
253        self.client.send::<CallbacksRstRequest>(
254            (addr,),
255            0x7d6b0a28c75d5568,
256            fidl::encoding::DynamicFlags::empty(),
257        )
258    }
259
260    fn r#shutdown(&self, mut addr: &Addr) -> Result<(), fidl::Error> {
261        self.client.send::<CallbacksShutdownRequest>(
262            (addr,),
263            0x6021a72c49ab97cb,
264            fidl::encoding::DynamicFlags::empty(),
265        )
266    }
267
268    type TransportResetResponseFut =
269        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
270    fn r#transport_reset(&self, mut new_cid: u32) -> Self::TransportResetResponseFut {
271        fn _decode(
272            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
273        ) -> Result<(), fidl::Error> {
274            let _response = fidl::client::decode_transaction_body::<
275                fidl::encoding::EmptyPayload,
276                fidl::encoding::DefaultFuchsiaResourceDialect,
277                0x23ba142d8c6a537,
278            >(_buf?)?;
279            Ok(_response)
280        }
281        self.client.send_query_and_decode::<CallbacksTransportResetRequest, ()>(
282            (new_cid,),
283            0x23ba142d8c6a537,
284            fidl::encoding::DynamicFlags::empty(),
285            _decode,
286        )
287    }
288}
289
290pub struct CallbacksEventStream {
291    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
292}
293
294impl std::marker::Unpin for CallbacksEventStream {}
295
296impl futures::stream::FusedStream for CallbacksEventStream {
297    fn is_terminated(&self) -> bool {
298        self.event_receiver.is_terminated()
299    }
300}
301
302impl futures::Stream for CallbacksEventStream {
303    type Item = Result<CallbacksEvent, fidl::Error>;
304
305    fn poll_next(
306        mut self: std::pin::Pin<&mut Self>,
307        cx: &mut std::task::Context<'_>,
308    ) -> std::task::Poll<Option<Self::Item>> {
309        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
310            &mut self.event_receiver,
311            cx
312        )?) {
313            Some(buf) => std::task::Poll::Ready(Some(CallbacksEvent::decode(buf))),
314            None => std::task::Poll::Ready(None),
315        }
316    }
317}
318
319#[derive(Debug)]
320pub enum CallbacksEvent {}
321
322impl CallbacksEvent {
323    /// Decodes a message buffer as a [`CallbacksEvent`].
324    fn decode(
325        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
326    ) -> Result<CallbacksEvent, fidl::Error> {
327        let (bytes, _handles) = buf.split_mut();
328        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
329        debug_assert_eq!(tx_header.tx_id, 0);
330        match tx_header.ordinal {
331            _ => Err(fidl::Error::UnknownOrdinal {
332                ordinal: tx_header.ordinal,
333                protocol_name: <CallbacksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
334            }),
335        }
336    }
337}
338
339/// A Stream of incoming requests for fuchsia.hardware.vsock/Callbacks.
340pub struct CallbacksRequestStream {
341    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
342    is_terminated: bool,
343}
344
345impl std::marker::Unpin for CallbacksRequestStream {}
346
347impl futures::stream::FusedStream for CallbacksRequestStream {
348    fn is_terminated(&self) -> bool {
349        self.is_terminated
350    }
351}
352
353impl fidl::endpoints::RequestStream for CallbacksRequestStream {
354    type Protocol = CallbacksMarker;
355    type ControlHandle = CallbacksControlHandle;
356
357    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
358        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
359    }
360
361    fn control_handle(&self) -> Self::ControlHandle {
362        CallbacksControlHandle { inner: self.inner.clone() }
363    }
364
365    fn into_inner(
366        self,
367    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
368    {
369        (self.inner, self.is_terminated)
370    }
371
372    fn from_inner(
373        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
374        is_terminated: bool,
375    ) -> Self {
376        Self { inner, is_terminated }
377    }
378}
379
380impl futures::Stream for CallbacksRequestStream {
381    type Item = Result<CallbacksRequest, fidl::Error>;
382
383    fn poll_next(
384        mut self: std::pin::Pin<&mut Self>,
385        cx: &mut std::task::Context<'_>,
386    ) -> std::task::Poll<Option<Self::Item>> {
387        let this = &mut *self;
388        if this.inner.check_shutdown(cx) {
389            this.is_terminated = true;
390            return std::task::Poll::Ready(None);
391        }
392        if this.is_terminated {
393            panic!("polled CallbacksRequestStream after completion");
394        }
395        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
396            |bytes, handles| {
397                match this.inner.channel().read_etc(cx, bytes, handles) {
398                    std::task::Poll::Ready(Ok(())) => {}
399                    std::task::Poll::Pending => return std::task::Poll::Pending,
400                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
401                        this.is_terminated = true;
402                        return std::task::Poll::Ready(None);
403                    }
404                    std::task::Poll::Ready(Err(e)) => {
405                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
406                            e.into(),
407                        ))));
408                    }
409                }
410
411                // A message has been received from the channel
412                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
413
414                std::task::Poll::Ready(Some(match header.ordinal {
415                    0x685918e57418eda8 => {
416                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
417                        let mut req = fidl::new_empty!(
418                            CallbacksRequestRequest,
419                            fidl::encoding::DefaultFuchsiaResourceDialect
420                        );
421                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksRequestRequest>(&header, _body_bytes, handles, &mut req)?;
422                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
423                        Ok(CallbacksRequest::Request { addr: req.addr, control_handle })
424                    }
425                    0x951dfbcb98699cc => {
426                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
427                        let mut req = fidl::new_empty!(
428                            CallbacksResponseRequest,
429                            fidl::encoding::DefaultFuchsiaResourceDialect
430                        );
431                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksResponseRequest>(&header, _body_bytes, handles, &mut req)?;
432                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
433                        Ok(CallbacksRequest::Response { addr: req.addr, control_handle })
434                    }
435                    0x7d6b0a28c75d5568 => {
436                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
437                        let mut req = fidl::new_empty!(
438                            CallbacksRstRequest,
439                            fidl::encoding::DefaultFuchsiaResourceDialect
440                        );
441                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksRstRequest>(&header, _body_bytes, handles, &mut req)?;
442                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
443                        Ok(CallbacksRequest::Rst { addr: req.addr, control_handle })
444                    }
445                    0x6021a72c49ab97cb => {
446                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
447                        let mut req = fidl::new_empty!(
448                            CallbacksShutdownRequest,
449                            fidl::encoding::DefaultFuchsiaResourceDialect
450                        );
451                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksShutdownRequest>(&header, _body_bytes, handles, &mut req)?;
452                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
453                        Ok(CallbacksRequest::Shutdown { addr: req.addr, control_handle })
454                    }
455                    0x23ba142d8c6a537 => {
456                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
457                        let mut req = fidl::new_empty!(
458                            CallbacksTransportResetRequest,
459                            fidl::encoding::DefaultFuchsiaResourceDialect
460                        );
461                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbacksTransportResetRequest>(&header, _body_bytes, handles, &mut req)?;
462                        let control_handle = CallbacksControlHandle { inner: this.inner.clone() };
463                        Ok(CallbacksRequest::TransportReset {
464                            new_cid: req.new_cid,
465
466                            responder: CallbacksTransportResetResponder {
467                                control_handle: std::mem::ManuallyDrop::new(control_handle),
468                                tx_id: header.tx_id,
469                            },
470                        })
471                    }
472                    _ => Err(fidl::Error::UnknownOrdinal {
473                        ordinal: header.ordinal,
474                        protocol_name:
475                            <CallbacksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
476                    }),
477                }))
478            },
479        )
480    }
481}
482
483#[derive(Debug)]
484pub enum CallbacksRequest {
485    Request { addr: Addr, control_handle: CallbacksControlHandle },
486    Response { addr: Addr, control_handle: CallbacksControlHandle },
487    Rst { addr: Addr, control_handle: CallbacksControlHandle },
488    Shutdown { addr: Addr, control_handle: CallbacksControlHandle },
489    TransportReset { new_cid: u32, responder: CallbacksTransportResetResponder },
490}
491
492impl CallbacksRequest {
493    #[allow(irrefutable_let_patterns)]
494    pub fn into_request(self) -> Option<(Addr, CallbacksControlHandle)> {
495        if let CallbacksRequest::Request { addr, control_handle } = self {
496            Some((addr, control_handle))
497        } else {
498            None
499        }
500    }
501
502    #[allow(irrefutable_let_patterns)]
503    pub fn into_response(self) -> Option<(Addr, CallbacksControlHandle)> {
504        if let CallbacksRequest::Response { addr, control_handle } = self {
505            Some((addr, control_handle))
506        } else {
507            None
508        }
509    }
510
511    #[allow(irrefutable_let_patterns)]
512    pub fn into_rst(self) -> Option<(Addr, CallbacksControlHandle)> {
513        if let CallbacksRequest::Rst { addr, control_handle } = self {
514            Some((addr, control_handle))
515        } else {
516            None
517        }
518    }
519
520    #[allow(irrefutable_let_patterns)]
521    pub fn into_shutdown(self) -> Option<(Addr, CallbacksControlHandle)> {
522        if let CallbacksRequest::Shutdown { addr, control_handle } = self {
523            Some((addr, control_handle))
524        } else {
525            None
526        }
527    }
528
529    #[allow(irrefutable_let_patterns)]
530    pub fn into_transport_reset(self) -> Option<(u32, CallbacksTransportResetResponder)> {
531        if let CallbacksRequest::TransportReset { new_cid, responder } = self {
532            Some((new_cid, responder))
533        } else {
534            None
535        }
536    }
537
538    /// Name of the method defined in FIDL
539    pub fn method_name(&self) -> &'static str {
540        match *self {
541            CallbacksRequest::Request { .. } => "request",
542            CallbacksRequest::Response { .. } => "response",
543            CallbacksRequest::Rst { .. } => "rst",
544            CallbacksRequest::Shutdown { .. } => "shutdown",
545            CallbacksRequest::TransportReset { .. } => "transport_reset",
546        }
547    }
548}
549
550#[derive(Debug, Clone)]
551pub struct CallbacksControlHandle {
552    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
553}
554
555impl fidl::endpoints::ControlHandle for CallbacksControlHandle {
556    fn shutdown(&self) {
557        self.inner.shutdown()
558    }
559
560    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
561        self.inner.shutdown_with_epitaph(status)
562    }
563
564    fn is_closed(&self) -> bool {
565        self.inner.channel().is_closed()
566    }
567    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
568        self.inner.channel().on_closed()
569    }
570
571    #[cfg(target_os = "fuchsia")]
572    fn signal_peer(
573        &self,
574        clear_mask: zx::Signals,
575        set_mask: zx::Signals,
576    ) -> Result<(), zx_status::Status> {
577        use fidl::Peered;
578        self.inner.channel().signal_peer(clear_mask, set_mask)
579    }
580}
581
582impl CallbacksControlHandle {}
583
584#[must_use = "FIDL methods require a response to be sent"]
585#[derive(Debug)]
586pub struct CallbacksTransportResetResponder {
587    control_handle: std::mem::ManuallyDrop<CallbacksControlHandle>,
588    tx_id: u32,
589}
590
591/// Set the the channel to be shutdown (see [`CallbacksControlHandle::shutdown`])
592/// if the responder is dropped without sending a response, so that the client
593/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
594impl std::ops::Drop for CallbacksTransportResetResponder {
595    fn drop(&mut self) {
596        self.control_handle.shutdown();
597        // Safety: drops once, never accessed again
598        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
599    }
600}
601
602impl fidl::endpoints::Responder for CallbacksTransportResetResponder {
603    type ControlHandle = CallbacksControlHandle;
604
605    fn control_handle(&self) -> &CallbacksControlHandle {
606        &self.control_handle
607    }
608
609    fn drop_without_shutdown(mut self) {
610        // Safety: drops once, never accessed again due to mem::forget
611        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
612        // Prevent Drop from running (which would shut down the channel)
613        std::mem::forget(self);
614    }
615}
616
617impl CallbacksTransportResetResponder {
618    /// Sends a response to the FIDL transaction.
619    ///
620    /// Sets the channel to shutdown if an error occurs.
621    pub fn send(self) -> Result<(), fidl::Error> {
622        let _result = self.send_raw();
623        if _result.is_err() {
624            self.control_handle.shutdown();
625        }
626        self.drop_without_shutdown();
627        _result
628    }
629
630    /// Similar to "send" but does not shutdown the channel if an error occurs.
631    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
632        let _result = self.send_raw();
633        self.drop_without_shutdown();
634        _result
635    }
636
637    fn send_raw(&self) -> Result<(), fidl::Error> {
638        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
639            (),
640            self.tx_id,
641            0x23ba142d8c6a537,
642            fidl::encoding::DynamicFlags::empty(),
643        )
644    }
645}
646
647#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
648pub struct DeviceMarker;
649
650impl fidl::endpoints::ProtocolMarker for DeviceMarker {
651    type Proxy = DeviceProxy;
652    type RequestStream = DeviceRequestStream;
653    #[cfg(target_os = "fuchsia")]
654    type SynchronousProxy = DeviceSynchronousProxy;
655
656    const DEBUG_NAME: &'static str = "fuchsia.hardware.vsock.Device";
657}
658impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
659pub type DeviceStartResult = Result<(), i32>;
660pub type DeviceSendRequestResult = Result<(), i32>;
661pub type DeviceSendShutdownResult = Result<(), i32>;
662pub type DeviceSendRstResult = Result<(), i32>;
663pub type DeviceSendResponseResult = Result<(), i32>;
664
665pub trait DeviceProxyInterface: Send + Sync {
666    type StartResponseFut: std::future::Future<Output = Result<DeviceStartResult, fidl::Error>>
667        + Send;
668    fn r#start(&self, cb: fidl::endpoints::ClientEnd<CallbacksMarker>) -> Self::StartResponseFut;
669    type SendRequestResponseFut: std::future::Future<Output = Result<DeviceSendRequestResult, fidl::Error>>
670        + Send;
671    fn r#send_request(&self, addr: &Addr, data: fidl::Socket) -> Self::SendRequestResponseFut;
672    type SendShutdownResponseFut: std::future::Future<Output = Result<DeviceSendShutdownResult, fidl::Error>>
673        + Send;
674    fn r#send_shutdown(&self, addr: &Addr) -> Self::SendShutdownResponseFut;
675    type SendRstResponseFut: std::future::Future<Output = Result<DeviceSendRstResult, fidl::Error>>
676        + Send;
677    fn r#send_rst(&self, addr: &Addr) -> Self::SendRstResponseFut;
678    type SendResponseResponseFut: std::future::Future<Output = Result<DeviceSendResponseResult, fidl::Error>>
679        + Send;
680    fn r#send_response(&self, addr: &Addr, data: fidl::Socket) -> Self::SendResponseResponseFut;
681    type GetCidResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
682    fn r#get_cid(&self) -> Self::GetCidResponseFut;
683}
684#[derive(Debug)]
685#[cfg(target_os = "fuchsia")]
686pub struct DeviceSynchronousProxy {
687    client: fidl::client::sync::Client,
688}
689
690#[cfg(target_os = "fuchsia")]
691impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
692    type Proxy = DeviceProxy;
693    type Protocol = DeviceMarker;
694
695    fn from_channel(inner: fidl::Channel) -> Self {
696        Self::new(inner)
697    }
698
699    fn into_channel(self) -> fidl::Channel {
700        self.client.into_channel()
701    }
702
703    fn as_channel(&self) -> &fidl::Channel {
704        self.client.as_channel()
705    }
706}
707
708#[cfg(target_os = "fuchsia")]
709impl DeviceSynchronousProxy {
710    pub fn new(channel: fidl::Channel) -> Self {
711        Self { client: fidl::client::sync::Client::new(channel) }
712    }
713
714    pub fn into_channel(self) -> fidl::Channel {
715        self.client.into_channel()
716    }
717
718    /// Waits until an event arrives and returns it. It is safe for other
719    /// threads to make concurrent requests while waiting for an event.
720    pub fn wait_for_event(
721        &self,
722        deadline: zx::MonotonicInstant,
723    ) -> Result<DeviceEvent, fidl::Error> {
724        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
725    }
726
727    pub fn r#start(
728        &self,
729        mut cb: fidl::endpoints::ClientEnd<CallbacksMarker>,
730        ___deadline: zx::MonotonicInstant,
731    ) -> Result<DeviceStartResult, fidl::Error> {
732        let _response = self.client.send_query::<
733            DeviceStartRequest,
734            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
735            DeviceMarker,
736        >(
737            (cb,),
738            0x3bc3faaec6158f27,
739            fidl::encoding::DynamicFlags::empty(),
740            ___deadline,
741        )?;
742        Ok(_response.map(|x| x))
743    }
744
745    pub fn r#send_request(
746        &self,
747        mut addr: &Addr,
748        mut data: fidl::Socket,
749        ___deadline: zx::MonotonicInstant,
750    ) -> Result<DeviceSendRequestResult, fidl::Error> {
751        let _response = self.client.send_query::<
752            DeviceSendRequestRequest,
753            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
754            DeviceMarker,
755        >(
756            (addr, data,),
757            0x2dc165540021f74d,
758            fidl::encoding::DynamicFlags::empty(),
759            ___deadline,
760        )?;
761        Ok(_response.map(|x| x))
762    }
763
764    pub fn r#send_shutdown(
765        &self,
766        mut addr: &Addr,
767        ___deadline: zx::MonotonicInstant,
768    ) -> Result<DeviceSendShutdownResult, fidl::Error> {
769        let _response = self.client.send_query::<
770            DeviceSendShutdownRequest,
771            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
772            DeviceMarker,
773        >(
774            (addr,),
775            0x57cdc7b234933b44,
776            fidl::encoding::DynamicFlags::empty(),
777            ___deadline,
778        )?;
779        Ok(_response.map(|x| x))
780    }
781
782    pub fn r#send_rst(
783        &self,
784        mut addr: &Addr,
785        ___deadline: zx::MonotonicInstant,
786    ) -> Result<DeviceSendRstResult, fidl::Error> {
787        let _response = self.client.send_query::<
788            DeviceSendRstRequest,
789            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
790            DeviceMarker,
791        >(
792            (addr,),
793            0x334e890ef7cd737c,
794            fidl::encoding::DynamicFlags::empty(),
795            ___deadline,
796        )?;
797        Ok(_response.map(|x| x))
798    }
799
800    pub fn r#send_response(
801        &self,
802        mut addr: &Addr,
803        mut data: fidl::Socket,
804        ___deadline: zx::MonotonicInstant,
805    ) -> Result<DeviceSendResponseResult, fidl::Error> {
806        let _response = self.client.send_query::<
807            DeviceSendResponseRequest,
808            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
809            DeviceMarker,
810        >(
811            (addr, data,),
812            0x487a35133ffe0672,
813            fidl::encoding::DynamicFlags::empty(),
814            ___deadline,
815        )?;
816        Ok(_response.map(|x| x))
817    }
818
819    pub fn r#get_cid(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
820        let _response = self
821            .client
822            .send_query::<fidl::encoding::EmptyPayload, DeviceGetCidResponse, DeviceMarker>(
823                (),
824                0x7cf0847a452feafe,
825                fidl::encoding::DynamicFlags::empty(),
826                ___deadline,
827            )?;
828        Ok(_response.local_cid)
829    }
830}
831
832#[cfg(target_os = "fuchsia")]
833impl From<DeviceSynchronousProxy> for zx::NullableHandle {
834    fn from(value: DeviceSynchronousProxy) -> Self {
835        value.into_channel().into()
836    }
837}
838
839#[cfg(target_os = "fuchsia")]
840impl From<fidl::Channel> for DeviceSynchronousProxy {
841    fn from(value: fidl::Channel) -> Self {
842        Self::new(value)
843    }
844}
845
846#[cfg(target_os = "fuchsia")]
847impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
848    type Protocol = DeviceMarker;
849
850    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
851        Self::new(value.into_channel())
852    }
853}
854
855#[derive(Debug, Clone)]
856pub struct DeviceProxy {
857    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
858}
859
860impl fidl::endpoints::Proxy for DeviceProxy {
861    type Protocol = DeviceMarker;
862
863    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
864        Self::new(inner)
865    }
866
867    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
868        self.client.into_channel().map_err(|client| Self { client })
869    }
870
871    fn as_channel(&self) -> &::fidl::AsyncChannel {
872        self.client.as_channel()
873    }
874}
875
876impl DeviceProxy {
877    /// Create a new Proxy for fuchsia.hardware.vsock/Device.
878    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
879        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
880        Self { client: fidl::client::Client::new(channel, protocol_name) }
881    }
882
883    /// Get a Stream of events from the remote end of the protocol.
884    ///
885    /// # Panics
886    ///
887    /// Panics if the event stream was already taken.
888    pub fn take_event_stream(&self) -> DeviceEventStream {
889        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
890    }
891
892    pub fn r#start(
893        &self,
894        mut cb: fidl::endpoints::ClientEnd<CallbacksMarker>,
895    ) -> fidl::client::QueryResponseFut<
896        DeviceStartResult,
897        fidl::encoding::DefaultFuchsiaResourceDialect,
898    > {
899        DeviceProxyInterface::r#start(self, cb)
900    }
901
902    pub fn r#send_request(
903        &self,
904        mut addr: &Addr,
905        mut data: fidl::Socket,
906    ) -> fidl::client::QueryResponseFut<
907        DeviceSendRequestResult,
908        fidl::encoding::DefaultFuchsiaResourceDialect,
909    > {
910        DeviceProxyInterface::r#send_request(self, addr, data)
911    }
912
913    pub fn r#send_shutdown(
914        &self,
915        mut addr: &Addr,
916    ) -> fidl::client::QueryResponseFut<
917        DeviceSendShutdownResult,
918        fidl::encoding::DefaultFuchsiaResourceDialect,
919    > {
920        DeviceProxyInterface::r#send_shutdown(self, addr)
921    }
922
923    pub fn r#send_rst(
924        &self,
925        mut addr: &Addr,
926    ) -> fidl::client::QueryResponseFut<
927        DeviceSendRstResult,
928        fidl::encoding::DefaultFuchsiaResourceDialect,
929    > {
930        DeviceProxyInterface::r#send_rst(self, addr)
931    }
932
933    pub fn r#send_response(
934        &self,
935        mut addr: &Addr,
936        mut data: fidl::Socket,
937    ) -> fidl::client::QueryResponseFut<
938        DeviceSendResponseResult,
939        fidl::encoding::DefaultFuchsiaResourceDialect,
940    > {
941        DeviceProxyInterface::r#send_response(self, addr, data)
942    }
943
944    pub fn r#get_cid(
945        &self,
946    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
947        DeviceProxyInterface::r#get_cid(self)
948    }
949}
950
951impl DeviceProxyInterface for DeviceProxy {
952    type StartResponseFut = fidl::client::QueryResponseFut<
953        DeviceStartResult,
954        fidl::encoding::DefaultFuchsiaResourceDialect,
955    >;
956    fn r#start(
957        &self,
958        mut cb: fidl::endpoints::ClientEnd<CallbacksMarker>,
959    ) -> Self::StartResponseFut {
960        fn _decode(
961            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
962        ) -> Result<DeviceStartResult, fidl::Error> {
963            let _response = fidl::client::decode_transaction_body::<
964                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
965                fidl::encoding::DefaultFuchsiaResourceDialect,
966                0x3bc3faaec6158f27,
967            >(_buf?)?;
968            Ok(_response.map(|x| x))
969        }
970        self.client.send_query_and_decode::<DeviceStartRequest, DeviceStartResult>(
971            (cb,),
972            0x3bc3faaec6158f27,
973            fidl::encoding::DynamicFlags::empty(),
974            _decode,
975        )
976    }
977
978    type SendRequestResponseFut = fidl::client::QueryResponseFut<
979        DeviceSendRequestResult,
980        fidl::encoding::DefaultFuchsiaResourceDialect,
981    >;
982    fn r#send_request(
983        &self,
984        mut addr: &Addr,
985        mut data: fidl::Socket,
986    ) -> Self::SendRequestResponseFut {
987        fn _decode(
988            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
989        ) -> Result<DeviceSendRequestResult, fidl::Error> {
990            let _response = fidl::client::decode_transaction_body::<
991                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
992                fidl::encoding::DefaultFuchsiaResourceDialect,
993                0x2dc165540021f74d,
994            >(_buf?)?;
995            Ok(_response.map(|x| x))
996        }
997        self.client.send_query_and_decode::<DeviceSendRequestRequest, DeviceSendRequestResult>(
998            (addr, data),
999            0x2dc165540021f74d,
1000            fidl::encoding::DynamicFlags::empty(),
1001            _decode,
1002        )
1003    }
1004
1005    type SendShutdownResponseFut = fidl::client::QueryResponseFut<
1006        DeviceSendShutdownResult,
1007        fidl::encoding::DefaultFuchsiaResourceDialect,
1008    >;
1009    fn r#send_shutdown(&self, mut addr: &Addr) -> Self::SendShutdownResponseFut {
1010        fn _decode(
1011            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1012        ) -> Result<DeviceSendShutdownResult, fidl::Error> {
1013            let _response = fidl::client::decode_transaction_body::<
1014                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1015                fidl::encoding::DefaultFuchsiaResourceDialect,
1016                0x57cdc7b234933b44,
1017            >(_buf?)?;
1018            Ok(_response.map(|x| x))
1019        }
1020        self.client.send_query_and_decode::<DeviceSendShutdownRequest, DeviceSendShutdownResult>(
1021            (addr,),
1022            0x57cdc7b234933b44,
1023            fidl::encoding::DynamicFlags::empty(),
1024            _decode,
1025        )
1026    }
1027
1028    type SendRstResponseFut = fidl::client::QueryResponseFut<
1029        DeviceSendRstResult,
1030        fidl::encoding::DefaultFuchsiaResourceDialect,
1031    >;
1032    fn r#send_rst(&self, mut addr: &Addr) -> Self::SendRstResponseFut {
1033        fn _decode(
1034            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1035        ) -> Result<DeviceSendRstResult, fidl::Error> {
1036            let _response = fidl::client::decode_transaction_body::<
1037                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1038                fidl::encoding::DefaultFuchsiaResourceDialect,
1039                0x334e890ef7cd737c,
1040            >(_buf?)?;
1041            Ok(_response.map(|x| x))
1042        }
1043        self.client.send_query_and_decode::<DeviceSendRstRequest, DeviceSendRstResult>(
1044            (addr,),
1045            0x334e890ef7cd737c,
1046            fidl::encoding::DynamicFlags::empty(),
1047            _decode,
1048        )
1049    }
1050
1051    type SendResponseResponseFut = fidl::client::QueryResponseFut<
1052        DeviceSendResponseResult,
1053        fidl::encoding::DefaultFuchsiaResourceDialect,
1054    >;
1055    fn r#send_response(
1056        &self,
1057        mut addr: &Addr,
1058        mut data: fidl::Socket,
1059    ) -> Self::SendResponseResponseFut {
1060        fn _decode(
1061            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1062        ) -> Result<DeviceSendResponseResult, fidl::Error> {
1063            let _response = fidl::client::decode_transaction_body::<
1064                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1065                fidl::encoding::DefaultFuchsiaResourceDialect,
1066                0x487a35133ffe0672,
1067            >(_buf?)?;
1068            Ok(_response.map(|x| x))
1069        }
1070        self.client.send_query_and_decode::<DeviceSendResponseRequest, DeviceSendResponseResult>(
1071            (addr, data),
1072            0x487a35133ffe0672,
1073            fidl::encoding::DynamicFlags::empty(),
1074            _decode,
1075        )
1076    }
1077
1078    type GetCidResponseFut =
1079        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1080    fn r#get_cid(&self) -> Self::GetCidResponseFut {
1081        fn _decode(
1082            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1083        ) -> Result<u32, fidl::Error> {
1084            let _response = fidl::client::decode_transaction_body::<
1085                DeviceGetCidResponse,
1086                fidl::encoding::DefaultFuchsiaResourceDialect,
1087                0x7cf0847a452feafe,
1088            >(_buf?)?;
1089            Ok(_response.local_cid)
1090        }
1091        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
1092            (),
1093            0x7cf0847a452feafe,
1094            fidl::encoding::DynamicFlags::empty(),
1095            _decode,
1096        )
1097    }
1098}
1099
1100pub struct DeviceEventStream {
1101    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1102}
1103
1104impl std::marker::Unpin for DeviceEventStream {}
1105
1106impl futures::stream::FusedStream for DeviceEventStream {
1107    fn is_terminated(&self) -> bool {
1108        self.event_receiver.is_terminated()
1109    }
1110}
1111
1112impl futures::Stream for DeviceEventStream {
1113    type Item = Result<DeviceEvent, fidl::Error>;
1114
1115    fn poll_next(
1116        mut self: std::pin::Pin<&mut Self>,
1117        cx: &mut std::task::Context<'_>,
1118    ) -> std::task::Poll<Option<Self::Item>> {
1119        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1120            &mut self.event_receiver,
1121            cx
1122        )?) {
1123            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1124            None => std::task::Poll::Ready(None),
1125        }
1126    }
1127}
1128
1129#[derive(Debug)]
1130pub enum DeviceEvent {}
1131
1132impl DeviceEvent {
1133    /// Decodes a message buffer as a [`DeviceEvent`].
1134    fn decode(
1135        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1136    ) -> Result<DeviceEvent, fidl::Error> {
1137        let (bytes, _handles) = buf.split_mut();
1138        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1139        debug_assert_eq!(tx_header.tx_id, 0);
1140        match tx_header.ordinal {
1141            _ => Err(fidl::Error::UnknownOrdinal {
1142                ordinal: tx_header.ordinal,
1143                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1144            }),
1145        }
1146    }
1147}
1148
1149/// A Stream of incoming requests for fuchsia.hardware.vsock/Device.
1150pub struct DeviceRequestStream {
1151    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1152    is_terminated: bool,
1153}
1154
1155impl std::marker::Unpin for DeviceRequestStream {}
1156
1157impl futures::stream::FusedStream for DeviceRequestStream {
1158    fn is_terminated(&self) -> bool {
1159        self.is_terminated
1160    }
1161}
1162
1163impl fidl::endpoints::RequestStream for DeviceRequestStream {
1164    type Protocol = DeviceMarker;
1165    type ControlHandle = DeviceControlHandle;
1166
1167    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1168        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1169    }
1170
1171    fn control_handle(&self) -> Self::ControlHandle {
1172        DeviceControlHandle { inner: self.inner.clone() }
1173    }
1174
1175    fn into_inner(
1176        self,
1177    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1178    {
1179        (self.inner, self.is_terminated)
1180    }
1181
1182    fn from_inner(
1183        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1184        is_terminated: bool,
1185    ) -> Self {
1186        Self { inner, is_terminated }
1187    }
1188}
1189
1190impl futures::Stream for DeviceRequestStream {
1191    type Item = Result<DeviceRequest, fidl::Error>;
1192
1193    fn poll_next(
1194        mut self: std::pin::Pin<&mut Self>,
1195        cx: &mut std::task::Context<'_>,
1196    ) -> std::task::Poll<Option<Self::Item>> {
1197        let this = &mut *self;
1198        if this.inner.check_shutdown(cx) {
1199            this.is_terminated = true;
1200            return std::task::Poll::Ready(None);
1201        }
1202        if this.is_terminated {
1203            panic!("polled DeviceRequestStream after completion");
1204        }
1205        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1206            |bytes, handles| {
1207                match this.inner.channel().read_etc(cx, bytes, handles) {
1208                    std::task::Poll::Ready(Ok(())) => {}
1209                    std::task::Poll::Pending => return std::task::Poll::Pending,
1210                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1211                        this.is_terminated = true;
1212                        return std::task::Poll::Ready(None);
1213                    }
1214                    std::task::Poll::Ready(Err(e)) => {
1215                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1216                            e.into(),
1217                        ))));
1218                    }
1219                }
1220
1221                // A message has been received from the channel
1222                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1223
1224                std::task::Poll::Ready(Some(match header.ordinal {
1225                    0x3bc3faaec6158f27 => {
1226                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1227                        let mut req = fidl::new_empty!(
1228                            DeviceStartRequest,
1229                            fidl::encoding::DefaultFuchsiaResourceDialect
1230                        );
1231                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStartRequest>(&header, _body_bytes, handles, &mut req)?;
1232                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1233                        Ok(DeviceRequest::Start {
1234                            cb: req.cb,
1235
1236                            responder: DeviceStartResponder {
1237                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1238                                tx_id: header.tx_id,
1239                            },
1240                        })
1241                    }
1242                    0x2dc165540021f74d => {
1243                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1244                        let mut req = fidl::new_empty!(
1245                            DeviceSendRequestRequest,
1246                            fidl::encoding::DefaultFuchsiaResourceDialect
1247                        );
1248                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSendRequestRequest>(&header, _body_bytes, handles, &mut req)?;
1249                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1250                        Ok(DeviceRequest::SendRequest {
1251                            addr: req.addr,
1252                            data: req.data,
1253
1254                            responder: DeviceSendRequestResponder {
1255                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1256                                tx_id: header.tx_id,
1257                            },
1258                        })
1259                    }
1260                    0x57cdc7b234933b44 => {
1261                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1262                        let mut req = fidl::new_empty!(
1263                            DeviceSendShutdownRequest,
1264                            fidl::encoding::DefaultFuchsiaResourceDialect
1265                        );
1266                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSendShutdownRequest>(&header, _body_bytes, handles, &mut req)?;
1267                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1268                        Ok(DeviceRequest::SendShutdown {
1269                            addr: req.addr,
1270
1271                            responder: DeviceSendShutdownResponder {
1272                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1273                                tx_id: header.tx_id,
1274                            },
1275                        })
1276                    }
1277                    0x334e890ef7cd737c => {
1278                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1279                        let mut req = fidl::new_empty!(
1280                            DeviceSendRstRequest,
1281                            fidl::encoding::DefaultFuchsiaResourceDialect
1282                        );
1283                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSendRstRequest>(&header, _body_bytes, handles, &mut req)?;
1284                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1285                        Ok(DeviceRequest::SendRst {
1286                            addr: req.addr,
1287
1288                            responder: DeviceSendRstResponder {
1289                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1290                                tx_id: header.tx_id,
1291                            },
1292                        })
1293                    }
1294                    0x487a35133ffe0672 => {
1295                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1296                        let mut req = fidl::new_empty!(
1297                            DeviceSendResponseRequest,
1298                            fidl::encoding::DefaultFuchsiaResourceDialect
1299                        );
1300                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSendResponseRequest>(&header, _body_bytes, handles, &mut req)?;
1301                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1302                        Ok(DeviceRequest::SendResponse {
1303                            addr: req.addr,
1304                            data: req.data,
1305
1306                            responder: DeviceSendResponseResponder {
1307                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1308                                tx_id: header.tx_id,
1309                            },
1310                        })
1311                    }
1312                    0x7cf0847a452feafe => {
1313                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1314                        let mut req = fidl::new_empty!(
1315                            fidl::encoding::EmptyPayload,
1316                            fidl::encoding::DefaultFuchsiaResourceDialect
1317                        );
1318                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1319                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1320                        Ok(DeviceRequest::GetCid {
1321                            responder: DeviceGetCidResponder {
1322                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1323                                tx_id: header.tx_id,
1324                            },
1325                        })
1326                    }
1327                    _ => Err(fidl::Error::UnknownOrdinal {
1328                        ordinal: header.ordinal,
1329                        protocol_name:
1330                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1331                    }),
1332                }))
1333            },
1334        )
1335    }
1336}
1337
1338#[derive(Debug)]
1339pub enum DeviceRequest {
1340    Start { cb: fidl::endpoints::ClientEnd<CallbacksMarker>, responder: DeviceStartResponder },
1341    SendRequest { addr: Addr, data: fidl::Socket, responder: DeviceSendRequestResponder },
1342    SendShutdown { addr: Addr, responder: DeviceSendShutdownResponder },
1343    SendRst { addr: Addr, responder: DeviceSendRstResponder },
1344    SendResponse { addr: Addr, data: fidl::Socket, responder: DeviceSendResponseResponder },
1345    GetCid { responder: DeviceGetCidResponder },
1346}
1347
1348impl DeviceRequest {
1349    #[allow(irrefutable_let_patterns)]
1350    pub fn into_start(
1351        self,
1352    ) -> Option<(fidl::endpoints::ClientEnd<CallbacksMarker>, DeviceStartResponder)> {
1353        if let DeviceRequest::Start { cb, responder } = self { Some((cb, responder)) } else { None }
1354    }
1355
1356    #[allow(irrefutable_let_patterns)]
1357    pub fn into_send_request(self) -> Option<(Addr, fidl::Socket, DeviceSendRequestResponder)> {
1358        if let DeviceRequest::SendRequest { addr, data, responder } = self {
1359            Some((addr, data, responder))
1360        } else {
1361            None
1362        }
1363    }
1364
1365    #[allow(irrefutable_let_patterns)]
1366    pub fn into_send_shutdown(self) -> Option<(Addr, DeviceSendShutdownResponder)> {
1367        if let DeviceRequest::SendShutdown { addr, responder } = self {
1368            Some((addr, responder))
1369        } else {
1370            None
1371        }
1372    }
1373
1374    #[allow(irrefutable_let_patterns)]
1375    pub fn into_send_rst(self) -> Option<(Addr, DeviceSendRstResponder)> {
1376        if let DeviceRequest::SendRst { addr, responder } = self {
1377            Some((addr, responder))
1378        } else {
1379            None
1380        }
1381    }
1382
1383    #[allow(irrefutable_let_patterns)]
1384    pub fn into_send_response(self) -> Option<(Addr, fidl::Socket, DeviceSendResponseResponder)> {
1385        if let DeviceRequest::SendResponse { addr, data, responder } = self {
1386            Some((addr, data, responder))
1387        } else {
1388            None
1389        }
1390    }
1391
1392    #[allow(irrefutable_let_patterns)]
1393    pub fn into_get_cid(self) -> Option<(DeviceGetCidResponder)> {
1394        if let DeviceRequest::GetCid { responder } = self { Some((responder)) } else { None }
1395    }
1396
1397    /// Name of the method defined in FIDL
1398    pub fn method_name(&self) -> &'static str {
1399        match *self {
1400            DeviceRequest::Start { .. } => "start",
1401            DeviceRequest::SendRequest { .. } => "send_request",
1402            DeviceRequest::SendShutdown { .. } => "send_shutdown",
1403            DeviceRequest::SendRst { .. } => "send_rst",
1404            DeviceRequest::SendResponse { .. } => "send_response",
1405            DeviceRequest::GetCid { .. } => "get_cid",
1406        }
1407    }
1408}
1409
1410#[derive(Debug, Clone)]
1411pub struct DeviceControlHandle {
1412    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1413}
1414
1415impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1416    fn shutdown(&self) {
1417        self.inner.shutdown()
1418    }
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    > fidl::encoding::Encode<DeviceStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2230        for (T0,)
2231    {
2232        #[inline]
2233        unsafe fn encode(
2234            self,
2235            encoder: &mut fidl::encoding::Encoder<
2236                '_,
2237                fidl::encoding::DefaultFuchsiaResourceDialect,
2238            >,
2239            offset: usize,
2240            depth: fidl::encoding::Depth,
2241        ) -> fidl::Result<()> {
2242            encoder.debug_check_bounds::<DeviceStartRequest>(offset);
2243            // Zero out padding regions. There's no need to apply masks
2244            // because the unmasked parts will be overwritten by fields.
2245            // Write the fields.
2246            self.0.encode(encoder, offset + 0, depth)?;
2247            Ok(())
2248        }
2249    }
2250
2251    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2252        for DeviceStartRequest
2253    {
2254        #[inline(always)]
2255        fn new_empty() -> Self {
2256            Self {
2257                cb: fidl::new_empty!(
2258                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>>,
2259                    fidl::encoding::DefaultFuchsiaResourceDialect
2260                ),
2261            }
2262        }
2263
2264        #[inline]
2265        unsafe fn decode(
2266            &mut self,
2267            decoder: &mut fidl::encoding::Decoder<
2268                '_,
2269                fidl::encoding::DefaultFuchsiaResourceDialect,
2270            >,
2271            offset: usize,
2272            _depth: fidl::encoding::Depth,
2273        ) -> fidl::Result<()> {
2274            decoder.debug_check_bounds::<Self>(offset);
2275            // Verify that padding bytes are zero.
2276            fidl::decode!(
2277                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbacksMarker>>,
2278                fidl::encoding::DefaultFuchsiaResourceDialect,
2279                &mut self.cb,
2280                decoder,
2281                offset + 0,
2282                _depth
2283            )?;
2284            Ok(())
2285        }
2286    }
2287}