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