fidl_fuchsia_hardware_overnet/
fidl_fuchsia_hardware_overnet.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_overnet_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct CallbackNewLinkRequest {
16    pub socket: fidl::Socket,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CallbackNewLinkRequest {}
20
21#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub struct DeviceSetCallbackRequest {
23    pub callback: fidl::endpoints::ClientEnd<CallbackMarker>,
24}
25
26impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceSetCallbackRequest {}
27
28#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
29pub struct UsbSetCallbackRequest {
30    pub callback: fidl::endpoints::ClientEnd<CallbackMarker>,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for UsbSetCallbackRequest {}
34
35#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
36pub struct CallbackMarker;
37
38impl fidl::endpoints::ProtocolMarker for CallbackMarker {
39    type Proxy = CallbackProxy;
40    type RequestStream = CallbackRequestStream;
41    #[cfg(target_os = "fuchsia")]
42    type SynchronousProxy = CallbackSynchronousProxy;
43
44    const DEBUG_NAME: &'static str = "(anonymous) Callback";
45}
46
47pub trait CallbackProxyInterface: Send + Sync {
48    type NewLinkResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
49    fn r#new_link(&self, socket: fidl::Socket) -> Self::NewLinkResponseFut;
50}
51#[derive(Debug)]
52#[cfg(target_os = "fuchsia")]
53pub struct CallbackSynchronousProxy {
54    client: fidl::client::sync::Client,
55}
56
57#[cfg(target_os = "fuchsia")]
58impl fidl::endpoints::SynchronousProxy for CallbackSynchronousProxy {
59    type Proxy = CallbackProxy;
60    type Protocol = CallbackMarker;
61
62    fn from_channel(inner: fidl::Channel) -> Self {
63        Self::new(inner)
64    }
65
66    fn into_channel(self) -> fidl::Channel {
67        self.client.into_channel()
68    }
69
70    fn as_channel(&self) -> &fidl::Channel {
71        self.client.as_channel()
72    }
73}
74
75#[cfg(target_os = "fuchsia")]
76impl CallbackSynchronousProxy {
77    pub fn new(channel: fidl::Channel) -> Self {
78        let protocol_name = <CallbackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
79        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
80    }
81
82    pub fn into_channel(self) -> fidl::Channel {
83        self.client.into_channel()
84    }
85
86    /// Waits until an event arrives and returns it. It is safe for other
87    /// threads to make concurrent requests while waiting for an event.
88    pub fn wait_for_event(
89        &self,
90        deadline: zx::MonotonicInstant,
91    ) -> Result<CallbackEvent, fidl::Error> {
92        CallbackEvent::decode(self.client.wait_for_event(deadline)?)
93    }
94
95    pub fn r#new_link(
96        &self,
97        mut socket: fidl::Socket,
98        ___deadline: zx::MonotonicInstant,
99    ) -> Result<(), fidl::Error> {
100        let _response =
101            self.client.send_query::<CallbackNewLinkRequest, fidl::encoding::EmptyPayload>(
102                (socket,),
103                0x70409481ebe346e5,
104                fidl::encoding::DynamicFlags::empty(),
105                ___deadline,
106            )?;
107        Ok(_response)
108    }
109}
110
111#[derive(Debug, Clone)]
112pub struct CallbackProxy {
113    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
114}
115
116impl fidl::endpoints::Proxy for CallbackProxy {
117    type Protocol = CallbackMarker;
118
119    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
120        Self::new(inner)
121    }
122
123    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
124        self.client.into_channel().map_err(|client| Self { client })
125    }
126
127    fn as_channel(&self) -> &::fidl::AsyncChannel {
128        self.client.as_channel()
129    }
130}
131
132impl CallbackProxy {
133    /// Create a new Proxy for fuchsia.hardware.overnet/Callback.
134    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
135        let protocol_name = <CallbackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
136        Self { client: fidl::client::Client::new(channel, protocol_name) }
137    }
138
139    /// Get a Stream of events from the remote end of the protocol.
140    ///
141    /// # Panics
142    ///
143    /// Panics if the event stream was already taken.
144    pub fn take_event_stream(&self) -> CallbackEventStream {
145        CallbackEventStream { event_receiver: self.client.take_event_receiver() }
146    }
147
148    pub fn r#new_link(
149        &self,
150        mut socket: fidl::Socket,
151    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
152        CallbackProxyInterface::r#new_link(self, socket)
153    }
154}
155
156impl CallbackProxyInterface for CallbackProxy {
157    type NewLinkResponseFut =
158        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
159    fn r#new_link(&self, mut socket: fidl::Socket) -> Self::NewLinkResponseFut {
160        fn _decode(
161            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
162        ) -> Result<(), fidl::Error> {
163            let _response = fidl::client::decode_transaction_body::<
164                fidl::encoding::EmptyPayload,
165                fidl::encoding::DefaultFuchsiaResourceDialect,
166                0x70409481ebe346e5,
167            >(_buf?)?;
168            Ok(_response)
169        }
170        self.client.send_query_and_decode::<CallbackNewLinkRequest, ()>(
171            (socket,),
172            0x70409481ebe346e5,
173            fidl::encoding::DynamicFlags::empty(),
174            _decode,
175        )
176    }
177}
178
179pub struct CallbackEventStream {
180    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
181}
182
183impl std::marker::Unpin for CallbackEventStream {}
184
185impl futures::stream::FusedStream for CallbackEventStream {
186    fn is_terminated(&self) -> bool {
187        self.event_receiver.is_terminated()
188    }
189}
190
191impl futures::Stream for CallbackEventStream {
192    type Item = Result<CallbackEvent, fidl::Error>;
193
194    fn poll_next(
195        mut self: std::pin::Pin<&mut Self>,
196        cx: &mut std::task::Context<'_>,
197    ) -> std::task::Poll<Option<Self::Item>> {
198        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
199            &mut self.event_receiver,
200            cx
201        )?) {
202            Some(buf) => std::task::Poll::Ready(Some(CallbackEvent::decode(buf))),
203            None => std::task::Poll::Ready(None),
204        }
205    }
206}
207
208#[derive(Debug)]
209pub enum CallbackEvent {}
210
211impl CallbackEvent {
212    /// Decodes a message buffer as a [`CallbackEvent`].
213    fn decode(
214        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
215    ) -> Result<CallbackEvent, fidl::Error> {
216        let (bytes, _handles) = buf.split_mut();
217        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
218        debug_assert_eq!(tx_header.tx_id, 0);
219        match tx_header.ordinal {
220            _ => Err(fidl::Error::UnknownOrdinal {
221                ordinal: tx_header.ordinal,
222                protocol_name: <CallbackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
223            }),
224        }
225    }
226}
227
228/// A Stream of incoming requests for fuchsia.hardware.overnet/Callback.
229pub struct CallbackRequestStream {
230    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
231    is_terminated: bool,
232}
233
234impl std::marker::Unpin for CallbackRequestStream {}
235
236impl futures::stream::FusedStream for CallbackRequestStream {
237    fn is_terminated(&self) -> bool {
238        self.is_terminated
239    }
240}
241
242impl fidl::endpoints::RequestStream for CallbackRequestStream {
243    type Protocol = CallbackMarker;
244    type ControlHandle = CallbackControlHandle;
245
246    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
247        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
248    }
249
250    fn control_handle(&self) -> Self::ControlHandle {
251        CallbackControlHandle { inner: self.inner.clone() }
252    }
253
254    fn into_inner(
255        self,
256    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
257    {
258        (self.inner, self.is_terminated)
259    }
260
261    fn from_inner(
262        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
263        is_terminated: bool,
264    ) -> Self {
265        Self { inner, is_terminated }
266    }
267}
268
269impl futures::Stream for CallbackRequestStream {
270    type Item = Result<CallbackRequest, fidl::Error>;
271
272    fn poll_next(
273        mut self: std::pin::Pin<&mut Self>,
274        cx: &mut std::task::Context<'_>,
275    ) -> std::task::Poll<Option<Self::Item>> {
276        let this = &mut *self;
277        if this.inner.check_shutdown(cx) {
278            this.is_terminated = true;
279            return std::task::Poll::Ready(None);
280        }
281        if this.is_terminated {
282            panic!("polled CallbackRequestStream after completion");
283        }
284        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
285            |bytes, handles| {
286                match this.inner.channel().read_etc(cx, bytes, handles) {
287                    std::task::Poll::Ready(Ok(())) => {}
288                    std::task::Poll::Pending => return std::task::Poll::Pending,
289                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
290                        this.is_terminated = true;
291                        return std::task::Poll::Ready(None);
292                    }
293                    std::task::Poll::Ready(Err(e)) => {
294                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
295                            e.into(),
296                        ))))
297                    }
298                }
299
300                // A message has been received from the channel
301                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
302
303                std::task::Poll::Ready(Some(match header.ordinal {
304                    0x70409481ebe346e5 => {
305                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
306                        let mut req = fidl::new_empty!(
307                            CallbackNewLinkRequest,
308                            fidl::encoding::DefaultFuchsiaResourceDialect
309                        );
310                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallbackNewLinkRequest>(&header, _body_bytes, handles, &mut req)?;
311                        let control_handle = CallbackControlHandle { inner: this.inner.clone() };
312                        Ok(CallbackRequest::NewLink {
313                            socket: req.socket,
314
315                            responder: CallbackNewLinkResponder {
316                                control_handle: std::mem::ManuallyDrop::new(control_handle),
317                                tx_id: header.tx_id,
318                            },
319                        })
320                    }
321                    _ => Err(fidl::Error::UnknownOrdinal {
322                        ordinal: header.ordinal,
323                        protocol_name:
324                            <CallbackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
325                    }),
326                }))
327            },
328        )
329    }
330}
331
332#[derive(Debug)]
333pub enum CallbackRequest {
334    NewLink { socket: fidl::Socket, responder: CallbackNewLinkResponder },
335}
336
337impl CallbackRequest {
338    #[allow(irrefutable_let_patterns)]
339    pub fn into_new_link(self) -> Option<(fidl::Socket, CallbackNewLinkResponder)> {
340        if let CallbackRequest::NewLink { socket, responder } = self {
341            Some((socket, responder))
342        } else {
343            None
344        }
345    }
346
347    /// Name of the method defined in FIDL
348    pub fn method_name(&self) -> &'static str {
349        match *self {
350            CallbackRequest::NewLink { .. } => "new_link",
351        }
352    }
353}
354
355#[derive(Debug, Clone)]
356pub struct CallbackControlHandle {
357    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
358}
359
360impl fidl::endpoints::ControlHandle for CallbackControlHandle {
361    fn shutdown(&self) {
362        self.inner.shutdown()
363    }
364    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
365        self.inner.shutdown_with_epitaph(status)
366    }
367
368    fn is_closed(&self) -> bool {
369        self.inner.channel().is_closed()
370    }
371    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
372        self.inner.channel().on_closed()
373    }
374
375    #[cfg(target_os = "fuchsia")]
376    fn signal_peer(
377        &self,
378        clear_mask: zx::Signals,
379        set_mask: zx::Signals,
380    ) -> Result<(), zx_status::Status> {
381        use fidl::Peered;
382        self.inner.channel().signal_peer(clear_mask, set_mask)
383    }
384}
385
386impl CallbackControlHandle {}
387
388#[must_use = "FIDL methods require a response to be sent"]
389#[derive(Debug)]
390pub struct CallbackNewLinkResponder {
391    control_handle: std::mem::ManuallyDrop<CallbackControlHandle>,
392    tx_id: u32,
393}
394
395/// Set the the channel to be shutdown (see [`CallbackControlHandle::shutdown`])
396/// if the responder is dropped without sending a response, so that the client
397/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
398impl std::ops::Drop for CallbackNewLinkResponder {
399    fn drop(&mut self) {
400        self.control_handle.shutdown();
401        // Safety: drops once, never accessed again
402        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
403    }
404}
405
406impl fidl::endpoints::Responder for CallbackNewLinkResponder {
407    type ControlHandle = CallbackControlHandle;
408
409    fn control_handle(&self) -> &CallbackControlHandle {
410        &self.control_handle
411    }
412
413    fn drop_without_shutdown(mut self) {
414        // Safety: drops once, never accessed again due to mem::forget
415        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
416        // Prevent Drop from running (which would shut down the channel)
417        std::mem::forget(self);
418    }
419}
420
421impl CallbackNewLinkResponder {
422    /// Sends a response to the FIDL transaction.
423    ///
424    /// Sets the channel to shutdown if an error occurs.
425    pub fn send(self) -> Result<(), fidl::Error> {
426        let _result = self.send_raw();
427        if _result.is_err() {
428            self.control_handle.shutdown();
429        }
430        self.drop_without_shutdown();
431        _result
432    }
433
434    /// Similar to "send" but does not shutdown the channel if an error occurs.
435    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
436        let _result = self.send_raw();
437        self.drop_without_shutdown();
438        _result
439    }
440
441    fn send_raw(&self) -> Result<(), fidl::Error> {
442        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
443            (),
444            self.tx_id,
445            0x70409481ebe346e5,
446            fidl::encoding::DynamicFlags::empty(),
447        )
448    }
449}
450
451#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
452pub struct DeviceMarker;
453
454impl fidl::endpoints::ProtocolMarker for DeviceMarker {
455    type Proxy = DeviceProxy;
456    type RequestStream = DeviceRequestStream;
457    #[cfg(target_os = "fuchsia")]
458    type SynchronousProxy = DeviceSynchronousProxy;
459
460    const DEBUG_NAME: &'static str = "(anonymous) Device";
461}
462
463pub trait DeviceProxyInterface: Send + Sync {
464    type SetCallbackResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
465    fn r#set_callback(
466        &self,
467        callback: fidl::endpoints::ClientEnd<CallbackMarker>,
468    ) -> Self::SetCallbackResponseFut;
469}
470#[derive(Debug)]
471#[cfg(target_os = "fuchsia")]
472pub struct DeviceSynchronousProxy {
473    client: fidl::client::sync::Client,
474}
475
476#[cfg(target_os = "fuchsia")]
477impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
478    type Proxy = DeviceProxy;
479    type Protocol = DeviceMarker;
480
481    fn from_channel(inner: fidl::Channel) -> Self {
482        Self::new(inner)
483    }
484
485    fn into_channel(self) -> fidl::Channel {
486        self.client.into_channel()
487    }
488
489    fn as_channel(&self) -> &fidl::Channel {
490        self.client.as_channel()
491    }
492}
493
494#[cfg(target_os = "fuchsia")]
495impl DeviceSynchronousProxy {
496    pub fn new(channel: fidl::Channel) -> Self {
497        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
498        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
499    }
500
501    pub fn into_channel(self) -> fidl::Channel {
502        self.client.into_channel()
503    }
504
505    /// Waits until an event arrives and returns it. It is safe for other
506    /// threads to make concurrent requests while waiting for an event.
507    pub fn wait_for_event(
508        &self,
509        deadline: zx::MonotonicInstant,
510    ) -> Result<DeviceEvent, fidl::Error> {
511        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
512    }
513
514    pub fn r#set_callback(
515        &self,
516        mut callback: fidl::endpoints::ClientEnd<CallbackMarker>,
517        ___deadline: zx::MonotonicInstant,
518    ) -> Result<(), fidl::Error> {
519        let _response =
520            self.client.send_query::<DeviceSetCallbackRequest, fidl::encoding::EmptyPayload>(
521                (callback,),
522                0x4a3aeb347fde77c7,
523                fidl::encoding::DynamicFlags::empty(),
524                ___deadline,
525            )?;
526        Ok(_response)
527    }
528}
529
530#[derive(Debug, Clone)]
531pub struct DeviceProxy {
532    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
533}
534
535impl fidl::endpoints::Proxy for DeviceProxy {
536    type Protocol = DeviceMarker;
537
538    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
539        Self::new(inner)
540    }
541
542    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
543        self.client.into_channel().map_err(|client| Self { client })
544    }
545
546    fn as_channel(&self) -> &::fidl::AsyncChannel {
547        self.client.as_channel()
548    }
549}
550
551impl DeviceProxy {
552    /// Create a new Proxy for fuchsia.hardware.overnet/Device.
553    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
554        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
555        Self { client: fidl::client::Client::new(channel, protocol_name) }
556    }
557
558    /// Get a Stream of events from the remote end of the protocol.
559    ///
560    /// # Panics
561    ///
562    /// Panics if the event stream was already taken.
563    pub fn take_event_stream(&self) -> DeviceEventStream {
564        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
565    }
566
567    pub fn r#set_callback(
568        &self,
569        mut callback: fidl::endpoints::ClientEnd<CallbackMarker>,
570    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
571        DeviceProxyInterface::r#set_callback(self, callback)
572    }
573}
574
575impl DeviceProxyInterface for DeviceProxy {
576    type SetCallbackResponseFut =
577        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
578    fn r#set_callback(
579        &self,
580        mut callback: fidl::endpoints::ClientEnd<CallbackMarker>,
581    ) -> Self::SetCallbackResponseFut {
582        fn _decode(
583            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
584        ) -> Result<(), fidl::Error> {
585            let _response = fidl::client::decode_transaction_body::<
586                fidl::encoding::EmptyPayload,
587                fidl::encoding::DefaultFuchsiaResourceDialect,
588                0x4a3aeb347fde77c7,
589            >(_buf?)?;
590            Ok(_response)
591        }
592        self.client.send_query_and_decode::<DeviceSetCallbackRequest, ()>(
593            (callback,),
594            0x4a3aeb347fde77c7,
595            fidl::encoding::DynamicFlags::empty(),
596            _decode,
597        )
598    }
599}
600
601pub struct DeviceEventStream {
602    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
603}
604
605impl std::marker::Unpin for DeviceEventStream {}
606
607impl futures::stream::FusedStream for DeviceEventStream {
608    fn is_terminated(&self) -> bool {
609        self.event_receiver.is_terminated()
610    }
611}
612
613impl futures::Stream for DeviceEventStream {
614    type Item = Result<DeviceEvent, fidl::Error>;
615
616    fn poll_next(
617        mut self: std::pin::Pin<&mut Self>,
618        cx: &mut std::task::Context<'_>,
619    ) -> std::task::Poll<Option<Self::Item>> {
620        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
621            &mut self.event_receiver,
622            cx
623        )?) {
624            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
625            None => std::task::Poll::Ready(None),
626        }
627    }
628}
629
630#[derive(Debug)]
631pub enum DeviceEvent {}
632
633impl DeviceEvent {
634    /// Decodes a message buffer as a [`DeviceEvent`].
635    fn decode(
636        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
637    ) -> Result<DeviceEvent, fidl::Error> {
638        let (bytes, _handles) = buf.split_mut();
639        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
640        debug_assert_eq!(tx_header.tx_id, 0);
641        match tx_header.ordinal {
642            _ => Err(fidl::Error::UnknownOrdinal {
643                ordinal: tx_header.ordinal,
644                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
645            }),
646        }
647    }
648}
649
650/// A Stream of incoming requests for fuchsia.hardware.overnet/Device.
651pub struct DeviceRequestStream {
652    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
653    is_terminated: bool,
654}
655
656impl std::marker::Unpin for DeviceRequestStream {}
657
658impl futures::stream::FusedStream for DeviceRequestStream {
659    fn is_terminated(&self) -> bool {
660        self.is_terminated
661    }
662}
663
664impl fidl::endpoints::RequestStream for DeviceRequestStream {
665    type Protocol = DeviceMarker;
666    type ControlHandle = DeviceControlHandle;
667
668    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
669        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
670    }
671
672    fn control_handle(&self) -> Self::ControlHandle {
673        DeviceControlHandle { inner: self.inner.clone() }
674    }
675
676    fn into_inner(
677        self,
678    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
679    {
680        (self.inner, self.is_terminated)
681    }
682
683    fn from_inner(
684        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
685        is_terminated: bool,
686    ) -> Self {
687        Self { inner, is_terminated }
688    }
689}
690
691impl futures::Stream for DeviceRequestStream {
692    type Item = Result<DeviceRequest, fidl::Error>;
693
694    fn poll_next(
695        mut self: std::pin::Pin<&mut Self>,
696        cx: &mut std::task::Context<'_>,
697    ) -> std::task::Poll<Option<Self::Item>> {
698        let this = &mut *self;
699        if this.inner.check_shutdown(cx) {
700            this.is_terminated = true;
701            return std::task::Poll::Ready(None);
702        }
703        if this.is_terminated {
704            panic!("polled DeviceRequestStream after completion");
705        }
706        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
707            |bytes, handles| {
708                match this.inner.channel().read_etc(cx, bytes, handles) {
709                    std::task::Poll::Ready(Ok(())) => {}
710                    std::task::Poll::Pending => return std::task::Poll::Pending,
711                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
712                        this.is_terminated = true;
713                        return std::task::Poll::Ready(None);
714                    }
715                    std::task::Poll::Ready(Err(e)) => {
716                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
717                            e.into(),
718                        ))))
719                    }
720                }
721
722                // A message has been received from the channel
723                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
724
725                std::task::Poll::Ready(Some(match header.ordinal {
726                    0x4a3aeb347fde77c7 => {
727                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
728                        let mut req = fidl::new_empty!(
729                            DeviceSetCallbackRequest,
730                            fidl::encoding::DefaultFuchsiaResourceDialect
731                        );
732                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetCallbackRequest>(&header, _body_bytes, handles, &mut req)?;
733                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
734                        Ok(DeviceRequest::SetCallback {
735                            callback: req.callback,
736
737                            responder: DeviceSetCallbackResponder {
738                                control_handle: std::mem::ManuallyDrop::new(control_handle),
739                                tx_id: header.tx_id,
740                            },
741                        })
742                    }
743                    _ => Err(fidl::Error::UnknownOrdinal {
744                        ordinal: header.ordinal,
745                        protocol_name:
746                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
747                    }),
748                }))
749            },
750        )
751    }
752}
753
754#[derive(Debug)]
755pub enum DeviceRequest {
756    SetCallback {
757        callback: fidl::endpoints::ClientEnd<CallbackMarker>,
758        responder: DeviceSetCallbackResponder,
759    },
760}
761
762impl DeviceRequest {
763    #[allow(irrefutable_let_patterns)]
764    pub fn into_set_callback(
765        self,
766    ) -> Option<(fidl::endpoints::ClientEnd<CallbackMarker>, DeviceSetCallbackResponder)> {
767        if let DeviceRequest::SetCallback { callback, responder } = self {
768            Some((callback, responder))
769        } else {
770            None
771        }
772    }
773
774    /// Name of the method defined in FIDL
775    pub fn method_name(&self) -> &'static str {
776        match *self {
777            DeviceRequest::SetCallback { .. } => "set_callback",
778        }
779    }
780}
781
782#[derive(Debug, Clone)]
783pub struct DeviceControlHandle {
784    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
785}
786
787impl fidl::endpoints::ControlHandle for DeviceControlHandle {
788    fn shutdown(&self) {
789        self.inner.shutdown()
790    }
791    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
792        self.inner.shutdown_with_epitaph(status)
793    }
794
795    fn is_closed(&self) -> bool {
796        self.inner.channel().is_closed()
797    }
798    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
799        self.inner.channel().on_closed()
800    }
801
802    #[cfg(target_os = "fuchsia")]
803    fn signal_peer(
804        &self,
805        clear_mask: zx::Signals,
806        set_mask: zx::Signals,
807    ) -> Result<(), zx_status::Status> {
808        use fidl::Peered;
809        self.inner.channel().signal_peer(clear_mask, set_mask)
810    }
811}
812
813impl DeviceControlHandle {}
814
815#[must_use = "FIDL methods require a response to be sent"]
816#[derive(Debug)]
817pub struct DeviceSetCallbackResponder {
818    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
819    tx_id: u32,
820}
821
822/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
823/// if the responder is dropped without sending a response, so that the client
824/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
825impl std::ops::Drop for DeviceSetCallbackResponder {
826    fn drop(&mut self) {
827        self.control_handle.shutdown();
828        // Safety: drops once, never accessed again
829        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
830    }
831}
832
833impl fidl::endpoints::Responder for DeviceSetCallbackResponder {
834    type ControlHandle = DeviceControlHandle;
835
836    fn control_handle(&self) -> &DeviceControlHandle {
837        &self.control_handle
838    }
839
840    fn drop_without_shutdown(mut self) {
841        // Safety: drops once, never accessed again due to mem::forget
842        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
843        // Prevent Drop from running (which would shut down the channel)
844        std::mem::forget(self);
845    }
846}
847
848impl DeviceSetCallbackResponder {
849    /// Sends a response to the FIDL transaction.
850    ///
851    /// Sets the channel to shutdown if an error occurs.
852    pub fn send(self) -> Result<(), fidl::Error> {
853        let _result = self.send_raw();
854        if _result.is_err() {
855            self.control_handle.shutdown();
856        }
857        self.drop_without_shutdown();
858        _result
859    }
860
861    /// Similar to "send" but does not shutdown the channel if an error occurs.
862    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
863        let _result = self.send_raw();
864        self.drop_without_shutdown();
865        _result
866    }
867
868    fn send_raw(&self) -> Result<(), fidl::Error> {
869        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
870            (),
871            self.tx_id,
872            0x4a3aeb347fde77c7,
873            fidl::encoding::DynamicFlags::empty(),
874        )
875    }
876}
877
878#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
879pub struct UsbMarker;
880
881impl fidl::endpoints::ProtocolMarker for UsbMarker {
882    type Proxy = UsbProxy;
883    type RequestStream = UsbRequestStream;
884    #[cfg(target_os = "fuchsia")]
885    type SynchronousProxy = UsbSynchronousProxy;
886
887    const DEBUG_NAME: &'static str = "(anonymous) Usb";
888}
889
890pub trait UsbProxyInterface: Send + Sync {
891    type SetCallbackResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
892    fn r#set_callback(
893        &self,
894        callback: fidl::endpoints::ClientEnd<CallbackMarker>,
895    ) -> Self::SetCallbackResponseFut;
896}
897#[derive(Debug)]
898#[cfg(target_os = "fuchsia")]
899pub struct UsbSynchronousProxy {
900    client: fidl::client::sync::Client,
901}
902
903#[cfg(target_os = "fuchsia")]
904impl fidl::endpoints::SynchronousProxy for UsbSynchronousProxy {
905    type Proxy = UsbProxy;
906    type Protocol = UsbMarker;
907
908    fn from_channel(inner: fidl::Channel) -> Self {
909        Self::new(inner)
910    }
911
912    fn into_channel(self) -> fidl::Channel {
913        self.client.into_channel()
914    }
915
916    fn as_channel(&self) -> &fidl::Channel {
917        self.client.as_channel()
918    }
919}
920
921#[cfg(target_os = "fuchsia")]
922impl UsbSynchronousProxy {
923    pub fn new(channel: fidl::Channel) -> Self {
924        let protocol_name = <UsbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
925        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
926    }
927
928    pub fn into_channel(self) -> fidl::Channel {
929        self.client.into_channel()
930    }
931
932    /// Waits until an event arrives and returns it. It is safe for other
933    /// threads to make concurrent requests while waiting for an event.
934    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<UsbEvent, fidl::Error> {
935        UsbEvent::decode(self.client.wait_for_event(deadline)?)
936    }
937
938    pub fn r#set_callback(
939        &self,
940        mut callback: fidl::endpoints::ClientEnd<CallbackMarker>,
941        ___deadline: zx::MonotonicInstant,
942    ) -> Result<(), fidl::Error> {
943        let _response =
944            self.client.send_query::<UsbSetCallbackRequest, fidl::encoding::EmptyPayload>(
945                (callback,),
946                0x2c87fd21b8c05e0b,
947                fidl::encoding::DynamicFlags::empty(),
948                ___deadline,
949            )?;
950        Ok(_response)
951    }
952}
953
954#[derive(Debug, Clone)]
955pub struct UsbProxy {
956    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
957}
958
959impl fidl::endpoints::Proxy for UsbProxy {
960    type Protocol = UsbMarker;
961
962    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
963        Self::new(inner)
964    }
965
966    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
967        self.client.into_channel().map_err(|client| Self { client })
968    }
969
970    fn as_channel(&self) -> &::fidl::AsyncChannel {
971        self.client.as_channel()
972    }
973}
974
975impl UsbProxy {
976    /// Create a new Proxy for fuchsia.hardware.overnet/Usb.
977    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
978        let protocol_name = <UsbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
979        Self { client: fidl::client::Client::new(channel, protocol_name) }
980    }
981
982    /// Get a Stream of events from the remote end of the protocol.
983    ///
984    /// # Panics
985    ///
986    /// Panics if the event stream was already taken.
987    pub fn take_event_stream(&self) -> UsbEventStream {
988        UsbEventStream { event_receiver: self.client.take_event_receiver() }
989    }
990
991    pub fn r#set_callback(
992        &self,
993        mut callback: fidl::endpoints::ClientEnd<CallbackMarker>,
994    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
995        UsbProxyInterface::r#set_callback(self, callback)
996    }
997}
998
999impl UsbProxyInterface for UsbProxy {
1000    type SetCallbackResponseFut =
1001        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1002    fn r#set_callback(
1003        &self,
1004        mut callback: fidl::endpoints::ClientEnd<CallbackMarker>,
1005    ) -> Self::SetCallbackResponseFut {
1006        fn _decode(
1007            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1008        ) -> Result<(), fidl::Error> {
1009            let _response = fidl::client::decode_transaction_body::<
1010                fidl::encoding::EmptyPayload,
1011                fidl::encoding::DefaultFuchsiaResourceDialect,
1012                0x2c87fd21b8c05e0b,
1013            >(_buf?)?;
1014            Ok(_response)
1015        }
1016        self.client.send_query_and_decode::<UsbSetCallbackRequest, ()>(
1017            (callback,),
1018            0x2c87fd21b8c05e0b,
1019            fidl::encoding::DynamicFlags::empty(),
1020            _decode,
1021        )
1022    }
1023}
1024
1025pub struct UsbEventStream {
1026    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1027}
1028
1029impl std::marker::Unpin for UsbEventStream {}
1030
1031impl futures::stream::FusedStream for UsbEventStream {
1032    fn is_terminated(&self) -> bool {
1033        self.event_receiver.is_terminated()
1034    }
1035}
1036
1037impl futures::Stream for UsbEventStream {
1038    type Item = Result<UsbEvent, fidl::Error>;
1039
1040    fn poll_next(
1041        mut self: std::pin::Pin<&mut Self>,
1042        cx: &mut std::task::Context<'_>,
1043    ) -> std::task::Poll<Option<Self::Item>> {
1044        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1045            &mut self.event_receiver,
1046            cx
1047        )?) {
1048            Some(buf) => std::task::Poll::Ready(Some(UsbEvent::decode(buf))),
1049            None => std::task::Poll::Ready(None),
1050        }
1051    }
1052}
1053
1054#[derive(Debug)]
1055pub enum UsbEvent {}
1056
1057impl UsbEvent {
1058    /// Decodes a message buffer as a [`UsbEvent`].
1059    fn decode(
1060        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1061    ) -> Result<UsbEvent, fidl::Error> {
1062        let (bytes, _handles) = buf.split_mut();
1063        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1064        debug_assert_eq!(tx_header.tx_id, 0);
1065        match tx_header.ordinal {
1066            _ => Err(fidl::Error::UnknownOrdinal {
1067                ordinal: tx_header.ordinal,
1068                protocol_name: <UsbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1069            }),
1070        }
1071    }
1072}
1073
1074/// A Stream of incoming requests for fuchsia.hardware.overnet/Usb.
1075pub struct UsbRequestStream {
1076    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1077    is_terminated: bool,
1078}
1079
1080impl std::marker::Unpin for UsbRequestStream {}
1081
1082impl futures::stream::FusedStream for UsbRequestStream {
1083    fn is_terminated(&self) -> bool {
1084        self.is_terminated
1085    }
1086}
1087
1088impl fidl::endpoints::RequestStream for UsbRequestStream {
1089    type Protocol = UsbMarker;
1090    type ControlHandle = UsbControlHandle;
1091
1092    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1093        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1094    }
1095
1096    fn control_handle(&self) -> Self::ControlHandle {
1097        UsbControlHandle { inner: self.inner.clone() }
1098    }
1099
1100    fn into_inner(
1101        self,
1102    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1103    {
1104        (self.inner, self.is_terminated)
1105    }
1106
1107    fn from_inner(
1108        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1109        is_terminated: bool,
1110    ) -> Self {
1111        Self { inner, is_terminated }
1112    }
1113}
1114
1115impl futures::Stream for UsbRequestStream {
1116    type Item = Result<UsbRequest, fidl::Error>;
1117
1118    fn poll_next(
1119        mut self: std::pin::Pin<&mut Self>,
1120        cx: &mut std::task::Context<'_>,
1121    ) -> std::task::Poll<Option<Self::Item>> {
1122        let this = &mut *self;
1123        if this.inner.check_shutdown(cx) {
1124            this.is_terminated = true;
1125            return std::task::Poll::Ready(None);
1126        }
1127        if this.is_terminated {
1128            panic!("polled UsbRequestStream after completion");
1129        }
1130        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1131            |bytes, handles| {
1132                match this.inner.channel().read_etc(cx, bytes, handles) {
1133                    std::task::Poll::Ready(Ok(())) => {}
1134                    std::task::Poll::Pending => return std::task::Poll::Pending,
1135                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1136                        this.is_terminated = true;
1137                        return std::task::Poll::Ready(None);
1138                    }
1139                    std::task::Poll::Ready(Err(e)) => {
1140                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1141                            e.into(),
1142                        ))))
1143                    }
1144                }
1145
1146                // A message has been received from the channel
1147                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1148
1149                std::task::Poll::Ready(Some(match header.ordinal {
1150                    0x2c87fd21b8c05e0b => {
1151                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1152                        let mut req = fidl::new_empty!(
1153                            UsbSetCallbackRequest,
1154                            fidl::encoding::DefaultFuchsiaResourceDialect
1155                        );
1156                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbSetCallbackRequest>(&header, _body_bytes, handles, &mut req)?;
1157                        let control_handle = UsbControlHandle { inner: this.inner.clone() };
1158                        Ok(UsbRequest::SetCallback {
1159                            callback: req.callback,
1160
1161                            responder: UsbSetCallbackResponder {
1162                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1163                                tx_id: header.tx_id,
1164                            },
1165                        })
1166                    }
1167                    _ => Err(fidl::Error::UnknownOrdinal {
1168                        ordinal: header.ordinal,
1169                        protocol_name: <UsbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1170                    }),
1171                }))
1172            },
1173        )
1174    }
1175}
1176
1177#[derive(Debug)]
1178pub enum UsbRequest {
1179    SetCallback {
1180        callback: fidl::endpoints::ClientEnd<CallbackMarker>,
1181        responder: UsbSetCallbackResponder,
1182    },
1183}
1184
1185impl UsbRequest {
1186    #[allow(irrefutable_let_patterns)]
1187    pub fn into_set_callback(
1188        self,
1189    ) -> Option<(fidl::endpoints::ClientEnd<CallbackMarker>, UsbSetCallbackResponder)> {
1190        if let UsbRequest::SetCallback { callback, responder } = self {
1191            Some((callback, responder))
1192        } else {
1193            None
1194        }
1195    }
1196
1197    /// Name of the method defined in FIDL
1198    pub fn method_name(&self) -> &'static str {
1199        match *self {
1200            UsbRequest::SetCallback { .. } => "set_callback",
1201        }
1202    }
1203}
1204
1205#[derive(Debug, Clone)]
1206pub struct UsbControlHandle {
1207    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1208}
1209
1210impl fidl::endpoints::ControlHandle for UsbControlHandle {
1211    fn shutdown(&self) {
1212        self.inner.shutdown()
1213    }
1214    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1215        self.inner.shutdown_with_epitaph(status)
1216    }
1217
1218    fn is_closed(&self) -> bool {
1219        self.inner.channel().is_closed()
1220    }
1221    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1222        self.inner.channel().on_closed()
1223    }
1224
1225    #[cfg(target_os = "fuchsia")]
1226    fn signal_peer(
1227        &self,
1228        clear_mask: zx::Signals,
1229        set_mask: zx::Signals,
1230    ) -> Result<(), zx_status::Status> {
1231        use fidl::Peered;
1232        self.inner.channel().signal_peer(clear_mask, set_mask)
1233    }
1234}
1235
1236impl UsbControlHandle {}
1237
1238#[must_use = "FIDL methods require a response to be sent"]
1239#[derive(Debug)]
1240pub struct UsbSetCallbackResponder {
1241    control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
1242    tx_id: u32,
1243}
1244
1245/// Set the the channel to be shutdown (see [`UsbControlHandle::shutdown`])
1246/// if the responder is dropped without sending a response, so that the client
1247/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1248impl std::ops::Drop for UsbSetCallbackResponder {
1249    fn drop(&mut self) {
1250        self.control_handle.shutdown();
1251        // Safety: drops once, never accessed again
1252        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1253    }
1254}
1255
1256impl fidl::endpoints::Responder for UsbSetCallbackResponder {
1257    type ControlHandle = UsbControlHandle;
1258
1259    fn control_handle(&self) -> &UsbControlHandle {
1260        &self.control_handle
1261    }
1262
1263    fn drop_without_shutdown(mut self) {
1264        // Safety: drops once, never accessed again due to mem::forget
1265        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1266        // Prevent Drop from running (which would shut down the channel)
1267        std::mem::forget(self);
1268    }
1269}
1270
1271impl UsbSetCallbackResponder {
1272    /// Sends a response to the FIDL transaction.
1273    ///
1274    /// Sets the channel to shutdown if an error occurs.
1275    pub fn send(self) -> Result<(), fidl::Error> {
1276        let _result = self.send_raw();
1277        if _result.is_err() {
1278            self.control_handle.shutdown();
1279        }
1280        self.drop_without_shutdown();
1281        _result
1282    }
1283
1284    /// Similar to "send" but does not shutdown the channel if an error occurs.
1285    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1286        let _result = self.send_raw();
1287        self.drop_without_shutdown();
1288        _result
1289    }
1290
1291    fn send_raw(&self) -> Result<(), fidl::Error> {
1292        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1293            (),
1294            self.tx_id,
1295            0x2c87fd21b8c05e0b,
1296            fidl::encoding::DynamicFlags::empty(),
1297        )
1298    }
1299}
1300
1301#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1302pub struct ServiceMarker;
1303
1304#[cfg(target_os = "fuchsia")]
1305impl fidl::endpoints::ServiceMarker for ServiceMarker {
1306    type Proxy = ServiceProxy;
1307    type Request = ServiceRequest;
1308    const SERVICE_NAME: &'static str = "fuchsia.hardware.overnet.Service";
1309}
1310
1311/// A request for one of the member protocols of Service.
1312///
1313#[cfg(target_os = "fuchsia")]
1314pub enum ServiceRequest {
1315    Device(DeviceRequestStream),
1316}
1317
1318#[cfg(target_os = "fuchsia")]
1319impl fidl::endpoints::ServiceRequest for ServiceRequest {
1320    type Service = ServiceMarker;
1321
1322    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1323        match name {
1324            "device" => Self::Device(
1325                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1326            ),
1327            _ => panic!("no such member protocol name for service Service"),
1328        }
1329    }
1330
1331    fn member_names() -> &'static [&'static str] {
1332        &["device"]
1333    }
1334}
1335#[cfg(target_os = "fuchsia")]
1336pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1337
1338#[cfg(target_os = "fuchsia")]
1339impl fidl::endpoints::ServiceProxy for ServiceProxy {
1340    type Service = ServiceMarker;
1341
1342    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1343        Self(opener)
1344    }
1345}
1346
1347#[cfg(target_os = "fuchsia")]
1348impl ServiceProxy {
1349    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1350        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1351        self.connect_channel_to_device(server_end)?;
1352        Ok(proxy)
1353    }
1354
1355    /// Like `connect_to_device`, but returns a sync proxy.
1356    /// See [`Self::connect_to_device`] for more details.
1357    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1358        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1359        self.connect_channel_to_device(server_end)?;
1360        Ok(proxy)
1361    }
1362
1363    /// Like `connect_to_device`, but accepts a server end.
1364    /// See [`Self::connect_to_device`] for more details.
1365    pub fn connect_channel_to_device(
1366        &self,
1367        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1368    ) -> Result<(), fidl::Error> {
1369        self.0.open_member("device", server_end.into_channel())
1370    }
1371
1372    pub fn instance_name(&self) -> &str {
1373        self.0.instance_name()
1374    }
1375}
1376
1377#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1378pub struct UsbServiceMarker;
1379
1380#[cfg(target_os = "fuchsia")]
1381impl fidl::endpoints::ServiceMarker for UsbServiceMarker {
1382    type Proxy = UsbServiceProxy;
1383    type Request = UsbServiceRequest;
1384    const SERVICE_NAME: &'static str = "fuchsia.hardware.overnet.UsbService";
1385}
1386
1387/// A request for one of the member protocols of UsbService.
1388///
1389#[cfg(target_os = "fuchsia")]
1390pub enum UsbServiceRequest {
1391    Device(UsbRequestStream),
1392}
1393
1394#[cfg(target_os = "fuchsia")]
1395impl fidl::endpoints::ServiceRequest for UsbServiceRequest {
1396    type Service = UsbServiceMarker;
1397
1398    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1399        match name {
1400            "device" => Self::Device(
1401                <UsbRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1402            ),
1403            _ => panic!("no such member protocol name for service UsbService"),
1404        }
1405    }
1406
1407    fn member_names() -> &'static [&'static str] {
1408        &["device"]
1409    }
1410}
1411#[cfg(target_os = "fuchsia")]
1412pub struct UsbServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1413
1414#[cfg(target_os = "fuchsia")]
1415impl fidl::endpoints::ServiceProxy for UsbServiceProxy {
1416    type Service = UsbServiceMarker;
1417
1418    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1419        Self(opener)
1420    }
1421}
1422
1423#[cfg(target_os = "fuchsia")]
1424impl UsbServiceProxy {
1425    pub fn connect_to_device(&self) -> Result<UsbProxy, fidl::Error> {
1426        let (proxy, server_end) = fidl::endpoints::create_proxy::<UsbMarker>();
1427        self.connect_channel_to_device(server_end)?;
1428        Ok(proxy)
1429    }
1430
1431    /// Like `connect_to_device`, but returns a sync proxy.
1432    /// See [`Self::connect_to_device`] for more details.
1433    pub fn connect_to_device_sync(&self) -> Result<UsbSynchronousProxy, fidl::Error> {
1434        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<UsbMarker>();
1435        self.connect_channel_to_device(server_end)?;
1436        Ok(proxy)
1437    }
1438
1439    /// Like `connect_to_device`, but accepts a server end.
1440    /// See [`Self::connect_to_device`] for more details.
1441    pub fn connect_channel_to_device(
1442        &self,
1443        server_end: fidl::endpoints::ServerEnd<UsbMarker>,
1444    ) -> Result<(), fidl::Error> {
1445        self.0.open_member("device", server_end.into_channel())
1446    }
1447
1448    pub fn instance_name(&self) -> &str {
1449        self.0.instance_name()
1450    }
1451}
1452
1453mod internal {
1454    use super::*;
1455
1456    impl fidl::encoding::ResourceTypeMarker for CallbackNewLinkRequest {
1457        type Borrowed<'a> = &'a mut Self;
1458        fn take_or_borrow<'a>(
1459            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1460        ) -> Self::Borrowed<'a> {
1461            value
1462        }
1463    }
1464
1465    unsafe impl fidl::encoding::TypeMarker for CallbackNewLinkRequest {
1466        type Owned = Self;
1467
1468        #[inline(always)]
1469        fn inline_align(_context: fidl::encoding::Context) -> usize {
1470            4
1471        }
1472
1473        #[inline(always)]
1474        fn inline_size(_context: fidl::encoding::Context) -> usize {
1475            4
1476        }
1477    }
1478
1479    unsafe impl
1480        fidl::encoding::Encode<
1481            CallbackNewLinkRequest,
1482            fidl::encoding::DefaultFuchsiaResourceDialect,
1483        > for &mut CallbackNewLinkRequest
1484    {
1485        #[inline]
1486        unsafe fn encode(
1487            self,
1488            encoder: &mut fidl::encoding::Encoder<
1489                '_,
1490                fidl::encoding::DefaultFuchsiaResourceDialect,
1491            >,
1492            offset: usize,
1493            _depth: fidl::encoding::Depth,
1494        ) -> fidl::Result<()> {
1495            encoder.debug_check_bounds::<CallbackNewLinkRequest>(offset);
1496            // Delegate to tuple encoding.
1497            fidl::encoding::Encode::<
1498                CallbackNewLinkRequest,
1499                fidl::encoding::DefaultFuchsiaResourceDialect,
1500            >::encode(
1501                (<fidl::encoding::HandleType<
1502                    fidl::Socket,
1503                    { fidl::ObjectType::SOCKET.into_raw() },
1504                    2147483648,
1505                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1506                    &mut self.socket
1507                ),),
1508                encoder,
1509                offset,
1510                _depth,
1511            )
1512        }
1513    }
1514    unsafe impl<
1515            T0: fidl::encoding::Encode<
1516                fidl::encoding::HandleType<
1517                    fidl::Socket,
1518                    { fidl::ObjectType::SOCKET.into_raw() },
1519                    2147483648,
1520                >,
1521                fidl::encoding::DefaultFuchsiaResourceDialect,
1522            >,
1523        >
1524        fidl::encoding::Encode<
1525            CallbackNewLinkRequest,
1526            fidl::encoding::DefaultFuchsiaResourceDialect,
1527        > for (T0,)
1528    {
1529        #[inline]
1530        unsafe fn encode(
1531            self,
1532            encoder: &mut fidl::encoding::Encoder<
1533                '_,
1534                fidl::encoding::DefaultFuchsiaResourceDialect,
1535            >,
1536            offset: usize,
1537            depth: fidl::encoding::Depth,
1538        ) -> fidl::Result<()> {
1539            encoder.debug_check_bounds::<CallbackNewLinkRequest>(offset);
1540            // Zero out padding regions. There's no need to apply masks
1541            // because the unmasked parts will be overwritten by fields.
1542            // Write the fields.
1543            self.0.encode(encoder, offset + 0, depth)?;
1544            Ok(())
1545        }
1546    }
1547
1548    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1549        for CallbackNewLinkRequest
1550    {
1551        #[inline(always)]
1552        fn new_empty() -> Self {
1553            Self {
1554                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1555            }
1556        }
1557
1558        #[inline]
1559        unsafe fn decode(
1560            &mut self,
1561            decoder: &mut fidl::encoding::Decoder<
1562                '_,
1563                fidl::encoding::DefaultFuchsiaResourceDialect,
1564            >,
1565            offset: usize,
1566            _depth: fidl::encoding::Depth,
1567        ) -> fidl::Result<()> {
1568            decoder.debug_check_bounds::<Self>(offset);
1569            // Verify that padding bytes are zero.
1570            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
1571            Ok(())
1572        }
1573    }
1574
1575    impl fidl::encoding::ResourceTypeMarker for DeviceSetCallbackRequest {
1576        type Borrowed<'a> = &'a mut Self;
1577        fn take_or_borrow<'a>(
1578            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1579        ) -> Self::Borrowed<'a> {
1580            value
1581        }
1582    }
1583
1584    unsafe impl fidl::encoding::TypeMarker for DeviceSetCallbackRequest {
1585        type Owned = Self;
1586
1587        #[inline(always)]
1588        fn inline_align(_context: fidl::encoding::Context) -> usize {
1589            4
1590        }
1591
1592        #[inline(always)]
1593        fn inline_size(_context: fidl::encoding::Context) -> usize {
1594            4
1595        }
1596    }
1597
1598    unsafe impl
1599        fidl::encoding::Encode<
1600            DeviceSetCallbackRequest,
1601            fidl::encoding::DefaultFuchsiaResourceDialect,
1602        > for &mut DeviceSetCallbackRequest
1603    {
1604        #[inline]
1605        unsafe fn encode(
1606            self,
1607            encoder: &mut fidl::encoding::Encoder<
1608                '_,
1609                fidl::encoding::DefaultFuchsiaResourceDialect,
1610            >,
1611            offset: usize,
1612            _depth: fidl::encoding::Depth,
1613        ) -> fidl::Result<()> {
1614            encoder.debug_check_bounds::<DeviceSetCallbackRequest>(offset);
1615            // Delegate to tuple encoding.
1616            fidl::encoding::Encode::<DeviceSetCallbackRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1617                (
1618                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbackMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.callback),
1619                ),
1620                encoder, offset, _depth
1621            )
1622        }
1623    }
1624    unsafe impl<
1625            T0: fidl::encoding::Encode<
1626                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbackMarker>>,
1627                fidl::encoding::DefaultFuchsiaResourceDialect,
1628            >,
1629        >
1630        fidl::encoding::Encode<
1631            DeviceSetCallbackRequest,
1632            fidl::encoding::DefaultFuchsiaResourceDialect,
1633        > for (T0,)
1634    {
1635        #[inline]
1636        unsafe fn encode(
1637            self,
1638            encoder: &mut fidl::encoding::Encoder<
1639                '_,
1640                fidl::encoding::DefaultFuchsiaResourceDialect,
1641            >,
1642            offset: usize,
1643            depth: fidl::encoding::Depth,
1644        ) -> fidl::Result<()> {
1645            encoder.debug_check_bounds::<DeviceSetCallbackRequest>(offset);
1646            // Zero out padding regions. There's no need to apply masks
1647            // because the unmasked parts will be overwritten by fields.
1648            // Write the fields.
1649            self.0.encode(encoder, offset + 0, depth)?;
1650            Ok(())
1651        }
1652    }
1653
1654    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1655        for DeviceSetCallbackRequest
1656    {
1657        #[inline(always)]
1658        fn new_empty() -> Self {
1659            Self {
1660                callback: fidl::new_empty!(
1661                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbackMarker>>,
1662                    fidl::encoding::DefaultFuchsiaResourceDialect
1663                ),
1664            }
1665        }
1666
1667        #[inline]
1668        unsafe fn decode(
1669            &mut self,
1670            decoder: &mut fidl::encoding::Decoder<
1671                '_,
1672                fidl::encoding::DefaultFuchsiaResourceDialect,
1673            >,
1674            offset: usize,
1675            _depth: fidl::encoding::Depth,
1676        ) -> fidl::Result<()> {
1677            decoder.debug_check_bounds::<Self>(offset);
1678            // Verify that padding bytes are zero.
1679            fidl::decode!(
1680                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbackMarker>>,
1681                fidl::encoding::DefaultFuchsiaResourceDialect,
1682                &mut self.callback,
1683                decoder,
1684                offset + 0,
1685                _depth
1686            )?;
1687            Ok(())
1688        }
1689    }
1690
1691    impl fidl::encoding::ResourceTypeMarker for UsbSetCallbackRequest {
1692        type Borrowed<'a> = &'a mut Self;
1693        fn take_or_borrow<'a>(
1694            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1695        ) -> Self::Borrowed<'a> {
1696            value
1697        }
1698    }
1699
1700    unsafe impl fidl::encoding::TypeMarker for UsbSetCallbackRequest {
1701        type Owned = Self;
1702
1703        #[inline(always)]
1704        fn inline_align(_context: fidl::encoding::Context) -> usize {
1705            4
1706        }
1707
1708        #[inline(always)]
1709        fn inline_size(_context: fidl::encoding::Context) -> usize {
1710            4
1711        }
1712    }
1713
1714    unsafe impl
1715        fidl::encoding::Encode<UsbSetCallbackRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1716        for &mut UsbSetCallbackRequest
1717    {
1718        #[inline]
1719        unsafe fn encode(
1720            self,
1721            encoder: &mut fidl::encoding::Encoder<
1722                '_,
1723                fidl::encoding::DefaultFuchsiaResourceDialect,
1724            >,
1725            offset: usize,
1726            _depth: fidl::encoding::Depth,
1727        ) -> fidl::Result<()> {
1728            encoder.debug_check_bounds::<UsbSetCallbackRequest>(offset);
1729            // Delegate to tuple encoding.
1730            fidl::encoding::Encode::<UsbSetCallbackRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1731                (
1732                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbackMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.callback),
1733                ),
1734                encoder, offset, _depth
1735            )
1736        }
1737    }
1738    unsafe impl<
1739            T0: fidl::encoding::Encode<
1740                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbackMarker>>,
1741                fidl::encoding::DefaultFuchsiaResourceDialect,
1742            >,
1743        >
1744        fidl::encoding::Encode<UsbSetCallbackRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1745        for (T0,)
1746    {
1747        #[inline]
1748        unsafe fn encode(
1749            self,
1750            encoder: &mut fidl::encoding::Encoder<
1751                '_,
1752                fidl::encoding::DefaultFuchsiaResourceDialect,
1753            >,
1754            offset: usize,
1755            depth: fidl::encoding::Depth,
1756        ) -> fidl::Result<()> {
1757            encoder.debug_check_bounds::<UsbSetCallbackRequest>(offset);
1758            // Zero out padding regions. There's no need to apply masks
1759            // because the unmasked parts will be overwritten by fields.
1760            // Write the fields.
1761            self.0.encode(encoder, offset + 0, depth)?;
1762            Ok(())
1763        }
1764    }
1765
1766    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1767        for UsbSetCallbackRequest
1768    {
1769        #[inline(always)]
1770        fn new_empty() -> Self {
1771            Self {
1772                callback: fidl::new_empty!(
1773                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbackMarker>>,
1774                    fidl::encoding::DefaultFuchsiaResourceDialect
1775                ),
1776            }
1777        }
1778
1779        #[inline]
1780        unsafe fn decode(
1781            &mut self,
1782            decoder: &mut fidl::encoding::Decoder<
1783                '_,
1784                fidl::encoding::DefaultFuchsiaResourceDialect,
1785            >,
1786            offset: usize,
1787            _depth: fidl::encoding::Depth,
1788        ) -> fidl::Result<()> {
1789            decoder.debug_check_bounds::<Self>(offset);
1790            // Verify that padding bytes are zero.
1791            fidl::decode!(
1792                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallbackMarker>>,
1793                fidl::encoding::DefaultFuchsiaResourceDialect,
1794                &mut self.callback,
1795                decoder,
1796                offset + 0,
1797                _depth
1798            )?;
1799            Ok(())
1800        }
1801    }
1802}