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