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