fidl_fuchsia_hardware_adb/
fidl_fuchsia_hardware_adb.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_adb__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceStartAdbRequest {
16    pub interface: fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceStartAdbRequest {}
20
21#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub struct ProviderConnectToServiceRequest {
23    pub socket: fidl::Socket,
24    pub args: Option<String>,
25}
26
27impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
28    for ProviderConnectToServiceRequest
29{
30}
31
32#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
33pub struct DeviceMarker;
34
35impl fidl::endpoints::ProtocolMarker for DeviceMarker {
36    type Proxy = DeviceProxy;
37    type RequestStream = DeviceRequestStream;
38    #[cfg(target_os = "fuchsia")]
39    type SynchronousProxy = DeviceSynchronousProxy;
40
41    const DEBUG_NAME: &'static str = "fuchsia.hardware.adb.Device";
42}
43impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
44pub type DeviceStartAdbResult = Result<(), i32>;
45pub type DeviceStopAdbResult = Result<(), i32>;
46
47pub trait DeviceProxyInterface: Send + Sync {
48    type StartAdbResponseFut: std::future::Future<Output = Result<DeviceStartAdbResult, fidl::Error>>
49        + Send;
50    fn r#start_adb(
51        &self,
52        interface: fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>,
53    ) -> Self::StartAdbResponseFut;
54    type StopAdbResponseFut: std::future::Future<Output = Result<DeviceStopAdbResult, fidl::Error>>
55        + Send;
56    fn r#stop_adb(&self) -> Self::StopAdbResponseFut;
57}
58#[derive(Debug)]
59#[cfg(target_os = "fuchsia")]
60pub struct DeviceSynchronousProxy {
61    client: fidl::client::sync::Client,
62}
63
64#[cfg(target_os = "fuchsia")]
65impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
66    type Proxy = DeviceProxy;
67    type Protocol = DeviceMarker;
68
69    fn from_channel(inner: fidl::Channel) -> Self {
70        Self::new(inner)
71    }
72
73    fn into_channel(self) -> fidl::Channel {
74        self.client.into_channel()
75    }
76
77    fn as_channel(&self) -> &fidl::Channel {
78        self.client.as_channel()
79    }
80}
81
82#[cfg(target_os = "fuchsia")]
83impl DeviceSynchronousProxy {
84    pub fn new(channel: fidl::Channel) -> Self {
85        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
86        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
87    }
88
89    pub fn into_channel(self) -> fidl::Channel {
90        self.client.into_channel()
91    }
92
93    /// Waits until an event arrives and returns it. It is safe for other
94    /// threads to make concurrent requests while waiting for an event.
95    pub fn wait_for_event(
96        &self,
97        deadline: zx::MonotonicInstant,
98    ) -> Result<DeviceEvent, fidl::Error> {
99        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
100    }
101
102    /// Start USB ADB protocol with |interface|.
103    pub fn r#start_adb(
104        &self,
105        mut interface: fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>,
106        ___deadline: zx::MonotonicInstant,
107    ) -> Result<DeviceStartAdbResult, fidl::Error> {
108        let _response = self.client.send_query::<
109            DeviceStartAdbRequest,
110            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
111        >(
112            (interface,),
113            0x286c2e31de2159a5,
114            fidl::encoding::DynamicFlags::empty(),
115            ___deadline,
116        )?;
117        Ok(_response.map(|x| x))
118    }
119
120    /// Stops USB ADB protocol.
121    pub fn r#stop_adb(
122        &self,
123        ___deadline: zx::MonotonicInstant,
124    ) -> Result<DeviceStopAdbResult, fidl::Error> {
125        let _response = self.client.send_query::<
126            fidl::encoding::EmptyPayload,
127            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
128        >(
129            (),
130            0x6d7d1816750fd3d0,
131            fidl::encoding::DynamicFlags::empty(),
132            ___deadline,
133        )?;
134        Ok(_response.map(|x| x))
135    }
136}
137
138#[cfg(target_os = "fuchsia")]
139impl From<DeviceSynchronousProxy> for zx::Handle {
140    fn from(value: DeviceSynchronousProxy) -> Self {
141        value.into_channel().into()
142    }
143}
144
145#[cfg(target_os = "fuchsia")]
146impl From<fidl::Channel> for DeviceSynchronousProxy {
147    fn from(value: fidl::Channel) -> Self {
148        Self::new(value)
149    }
150}
151
152#[cfg(target_os = "fuchsia")]
153impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
154    type Protocol = DeviceMarker;
155
156    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
157        Self::new(value.into_channel())
158    }
159}
160
161#[derive(Debug, Clone)]
162pub struct DeviceProxy {
163    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
164}
165
166impl fidl::endpoints::Proxy for DeviceProxy {
167    type Protocol = DeviceMarker;
168
169    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
170        Self::new(inner)
171    }
172
173    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
174        self.client.into_channel().map_err(|client| Self { client })
175    }
176
177    fn as_channel(&self) -> &::fidl::AsyncChannel {
178        self.client.as_channel()
179    }
180}
181
182impl DeviceProxy {
183    /// Create a new Proxy for fuchsia.hardware.adb/Device.
184    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
185        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
186        Self { client: fidl::client::Client::new(channel, protocol_name) }
187    }
188
189    /// Get a Stream of events from the remote end of the protocol.
190    ///
191    /// # Panics
192    ///
193    /// Panics if the event stream was already taken.
194    pub fn take_event_stream(&self) -> DeviceEventStream {
195        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
196    }
197
198    /// Start USB ADB protocol with |interface|.
199    pub fn r#start_adb(
200        &self,
201        mut interface: fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>,
202    ) -> fidl::client::QueryResponseFut<
203        DeviceStartAdbResult,
204        fidl::encoding::DefaultFuchsiaResourceDialect,
205    > {
206        DeviceProxyInterface::r#start_adb(self, interface)
207    }
208
209    /// Stops USB ADB protocol.
210    pub fn r#stop_adb(
211        &self,
212    ) -> fidl::client::QueryResponseFut<
213        DeviceStopAdbResult,
214        fidl::encoding::DefaultFuchsiaResourceDialect,
215    > {
216        DeviceProxyInterface::r#stop_adb(self)
217    }
218}
219
220impl DeviceProxyInterface for DeviceProxy {
221    type StartAdbResponseFut = fidl::client::QueryResponseFut<
222        DeviceStartAdbResult,
223        fidl::encoding::DefaultFuchsiaResourceDialect,
224    >;
225    fn r#start_adb(
226        &self,
227        mut interface: fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>,
228    ) -> Self::StartAdbResponseFut {
229        fn _decode(
230            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
231        ) -> Result<DeviceStartAdbResult, fidl::Error> {
232            let _response = fidl::client::decode_transaction_body::<
233                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
234                fidl::encoding::DefaultFuchsiaResourceDialect,
235                0x286c2e31de2159a5,
236            >(_buf?)?;
237            Ok(_response.map(|x| x))
238        }
239        self.client.send_query_and_decode::<DeviceStartAdbRequest, DeviceStartAdbResult>(
240            (interface,),
241            0x286c2e31de2159a5,
242            fidl::encoding::DynamicFlags::empty(),
243            _decode,
244        )
245    }
246
247    type StopAdbResponseFut = fidl::client::QueryResponseFut<
248        DeviceStopAdbResult,
249        fidl::encoding::DefaultFuchsiaResourceDialect,
250    >;
251    fn r#stop_adb(&self) -> Self::StopAdbResponseFut {
252        fn _decode(
253            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
254        ) -> Result<DeviceStopAdbResult, fidl::Error> {
255            let _response = fidl::client::decode_transaction_body::<
256                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
257                fidl::encoding::DefaultFuchsiaResourceDialect,
258                0x6d7d1816750fd3d0,
259            >(_buf?)?;
260            Ok(_response.map(|x| x))
261        }
262        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceStopAdbResult>(
263            (),
264            0x6d7d1816750fd3d0,
265            fidl::encoding::DynamicFlags::empty(),
266            _decode,
267        )
268    }
269}
270
271pub struct DeviceEventStream {
272    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
273}
274
275impl std::marker::Unpin for DeviceEventStream {}
276
277impl futures::stream::FusedStream for DeviceEventStream {
278    fn is_terminated(&self) -> bool {
279        self.event_receiver.is_terminated()
280    }
281}
282
283impl futures::Stream for DeviceEventStream {
284    type Item = Result<DeviceEvent, fidl::Error>;
285
286    fn poll_next(
287        mut self: std::pin::Pin<&mut Self>,
288        cx: &mut std::task::Context<'_>,
289    ) -> std::task::Poll<Option<Self::Item>> {
290        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
291            &mut self.event_receiver,
292            cx
293        )?) {
294            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
295            None => std::task::Poll::Ready(None),
296        }
297    }
298}
299
300#[derive(Debug)]
301pub enum DeviceEvent {}
302
303impl DeviceEvent {
304    /// Decodes a message buffer as a [`DeviceEvent`].
305    fn decode(
306        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
307    ) -> Result<DeviceEvent, fidl::Error> {
308        let (bytes, _handles) = buf.split_mut();
309        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
310        debug_assert_eq!(tx_header.tx_id, 0);
311        match tx_header.ordinal {
312            _ => Err(fidl::Error::UnknownOrdinal {
313                ordinal: tx_header.ordinal,
314                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
315            }),
316        }
317    }
318}
319
320/// A Stream of incoming requests for fuchsia.hardware.adb/Device.
321pub struct DeviceRequestStream {
322    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
323    is_terminated: bool,
324}
325
326impl std::marker::Unpin for DeviceRequestStream {}
327
328impl futures::stream::FusedStream for DeviceRequestStream {
329    fn is_terminated(&self) -> bool {
330        self.is_terminated
331    }
332}
333
334impl fidl::endpoints::RequestStream for DeviceRequestStream {
335    type Protocol = DeviceMarker;
336    type ControlHandle = DeviceControlHandle;
337
338    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
339        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
340    }
341
342    fn control_handle(&self) -> Self::ControlHandle {
343        DeviceControlHandle { inner: self.inner.clone() }
344    }
345
346    fn into_inner(
347        self,
348    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
349    {
350        (self.inner, self.is_terminated)
351    }
352
353    fn from_inner(
354        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
355        is_terminated: bool,
356    ) -> Self {
357        Self { inner, is_terminated }
358    }
359}
360
361impl futures::Stream for DeviceRequestStream {
362    type Item = Result<DeviceRequest, fidl::Error>;
363
364    fn poll_next(
365        mut self: std::pin::Pin<&mut Self>,
366        cx: &mut std::task::Context<'_>,
367    ) -> std::task::Poll<Option<Self::Item>> {
368        let this = &mut *self;
369        if this.inner.check_shutdown(cx) {
370            this.is_terminated = true;
371            return std::task::Poll::Ready(None);
372        }
373        if this.is_terminated {
374            panic!("polled DeviceRequestStream after completion");
375        }
376        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
377            |bytes, handles| {
378                match this.inner.channel().read_etc(cx, bytes, handles) {
379                    std::task::Poll::Ready(Ok(())) => {}
380                    std::task::Poll::Pending => return std::task::Poll::Pending,
381                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
382                        this.is_terminated = true;
383                        return std::task::Poll::Ready(None);
384                    }
385                    std::task::Poll::Ready(Err(e)) => {
386                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
387                            e.into(),
388                        ))));
389                    }
390                }
391
392                // A message has been received from the channel
393                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
394
395                std::task::Poll::Ready(Some(match header.ordinal {
396                    0x286c2e31de2159a5 => {
397                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
398                        let mut req = fidl::new_empty!(
399                            DeviceStartAdbRequest,
400                            fidl::encoding::DefaultFuchsiaResourceDialect
401                        );
402                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStartAdbRequest>(&header, _body_bytes, handles, &mut req)?;
403                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
404                        Ok(DeviceRequest::StartAdb {
405                            interface: req.interface,
406
407                            responder: DeviceStartAdbResponder {
408                                control_handle: std::mem::ManuallyDrop::new(control_handle),
409                                tx_id: header.tx_id,
410                            },
411                        })
412                    }
413                    0x6d7d1816750fd3d0 => {
414                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
415                        let mut req = fidl::new_empty!(
416                            fidl::encoding::EmptyPayload,
417                            fidl::encoding::DefaultFuchsiaResourceDialect
418                        );
419                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
420                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
421                        Ok(DeviceRequest::StopAdb {
422                            responder: DeviceStopAdbResponder {
423                                control_handle: std::mem::ManuallyDrop::new(control_handle),
424                                tx_id: header.tx_id,
425                            },
426                        })
427                    }
428                    _ => Err(fidl::Error::UnknownOrdinal {
429                        ordinal: header.ordinal,
430                        protocol_name:
431                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
432                    }),
433                }))
434            },
435        )
436    }
437}
438
439/// Device interface for USB ADB. The device manages the USB endpoints needed for ADB.
440#[derive(Debug)]
441pub enum DeviceRequest {
442    /// Start USB ADB protocol with |interface|.
443    StartAdb {
444        interface: fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>,
445        responder: DeviceStartAdbResponder,
446    },
447    /// Stops USB ADB protocol.
448    StopAdb { responder: DeviceStopAdbResponder },
449}
450
451impl DeviceRequest {
452    #[allow(irrefutable_let_patterns)]
453    pub fn into_start_adb(
454        self,
455    ) -> Option<(fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>, DeviceStartAdbResponder)> {
456        if let DeviceRequest::StartAdb { interface, responder } = self {
457            Some((interface, responder))
458        } else {
459            None
460        }
461    }
462
463    #[allow(irrefutable_let_patterns)]
464    pub fn into_stop_adb(self) -> Option<(DeviceStopAdbResponder)> {
465        if let DeviceRequest::StopAdb { responder } = self { Some((responder)) } else { None }
466    }
467
468    /// Name of the method defined in FIDL
469    pub fn method_name(&self) -> &'static str {
470        match *self {
471            DeviceRequest::StartAdb { .. } => "start_adb",
472            DeviceRequest::StopAdb { .. } => "stop_adb",
473        }
474    }
475}
476
477#[derive(Debug, Clone)]
478pub struct DeviceControlHandle {
479    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
480}
481
482impl fidl::endpoints::ControlHandle for DeviceControlHandle {
483    fn shutdown(&self) {
484        self.inner.shutdown()
485    }
486    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
487        self.inner.shutdown_with_epitaph(status)
488    }
489
490    fn is_closed(&self) -> bool {
491        self.inner.channel().is_closed()
492    }
493    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
494        self.inner.channel().on_closed()
495    }
496
497    #[cfg(target_os = "fuchsia")]
498    fn signal_peer(
499        &self,
500        clear_mask: zx::Signals,
501        set_mask: zx::Signals,
502    ) -> Result<(), zx_status::Status> {
503        use fidl::Peered;
504        self.inner.channel().signal_peer(clear_mask, set_mask)
505    }
506}
507
508impl DeviceControlHandle {}
509
510#[must_use = "FIDL methods require a response to be sent"]
511#[derive(Debug)]
512pub struct DeviceStartAdbResponder {
513    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
514    tx_id: u32,
515}
516
517/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
518/// if the responder is dropped without sending a response, so that the client
519/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
520impl std::ops::Drop for DeviceStartAdbResponder {
521    fn drop(&mut self) {
522        self.control_handle.shutdown();
523        // Safety: drops once, never accessed again
524        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
525    }
526}
527
528impl fidl::endpoints::Responder for DeviceStartAdbResponder {
529    type ControlHandle = DeviceControlHandle;
530
531    fn control_handle(&self) -> &DeviceControlHandle {
532        &self.control_handle
533    }
534
535    fn drop_without_shutdown(mut self) {
536        // Safety: drops once, never accessed again due to mem::forget
537        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
538        // Prevent Drop from running (which would shut down the channel)
539        std::mem::forget(self);
540    }
541}
542
543impl DeviceStartAdbResponder {
544    /// Sends a response to the FIDL transaction.
545    ///
546    /// Sets the channel to shutdown if an error occurs.
547    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
548        let _result = self.send_raw(result);
549        if _result.is_err() {
550            self.control_handle.shutdown();
551        }
552        self.drop_without_shutdown();
553        _result
554    }
555
556    /// Similar to "send" but does not shutdown the channel if an error occurs.
557    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
558        let _result = self.send_raw(result);
559        self.drop_without_shutdown();
560        _result
561    }
562
563    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
564        self.control_handle
565            .inner
566            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
567                result,
568                self.tx_id,
569                0x286c2e31de2159a5,
570                fidl::encoding::DynamicFlags::empty(),
571            )
572    }
573}
574
575#[must_use = "FIDL methods require a response to be sent"]
576#[derive(Debug)]
577pub struct DeviceStopAdbResponder {
578    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
579    tx_id: u32,
580}
581
582/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
583/// if the responder is dropped without sending a response, so that the client
584/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
585impl std::ops::Drop for DeviceStopAdbResponder {
586    fn drop(&mut self) {
587        self.control_handle.shutdown();
588        // Safety: drops once, never accessed again
589        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
590    }
591}
592
593impl fidl::endpoints::Responder for DeviceStopAdbResponder {
594    type ControlHandle = DeviceControlHandle;
595
596    fn control_handle(&self) -> &DeviceControlHandle {
597        &self.control_handle
598    }
599
600    fn drop_without_shutdown(mut self) {
601        // Safety: drops once, never accessed again due to mem::forget
602        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
603        // Prevent Drop from running (which would shut down the channel)
604        std::mem::forget(self);
605    }
606}
607
608impl DeviceStopAdbResponder {
609    /// Sends a response to the FIDL transaction.
610    ///
611    /// Sets the channel to shutdown if an error occurs.
612    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
613        let _result = self.send_raw(result);
614        if _result.is_err() {
615            self.control_handle.shutdown();
616        }
617        self.drop_without_shutdown();
618        _result
619    }
620
621    /// Similar to "send" but does not shutdown the channel if an error occurs.
622    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
623        let _result = self.send_raw(result);
624        self.drop_without_shutdown();
625        _result
626    }
627
628    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
629        self.control_handle
630            .inner
631            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
632                result,
633                self.tx_id,
634                0x6d7d1816750fd3d0,
635                fidl::encoding::DynamicFlags::empty(),
636            )
637    }
638}
639
640#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
641pub struct ProviderMarker;
642
643impl fidl::endpoints::ProtocolMarker for ProviderMarker {
644    type Proxy = ProviderProxy;
645    type RequestStream = ProviderRequestStream;
646    #[cfg(target_os = "fuchsia")]
647    type SynchronousProxy = ProviderSynchronousProxy;
648
649    const DEBUG_NAME: &'static str = "fuchsia.hardware.adb.Provider";
650}
651impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
652pub type ProviderConnectToServiceResult = Result<(), i32>;
653
654pub trait ProviderProxyInterface: Send + Sync {
655    type ConnectToServiceResponseFut: std::future::Future<Output = Result<ProviderConnectToServiceResult, fidl::Error>>
656        + Send;
657    fn r#connect_to_service(
658        &self,
659        socket: fidl::Socket,
660        args: Option<&str>,
661    ) -> Self::ConnectToServiceResponseFut;
662}
663#[derive(Debug)]
664#[cfg(target_os = "fuchsia")]
665pub struct ProviderSynchronousProxy {
666    client: fidl::client::sync::Client,
667}
668
669#[cfg(target_os = "fuchsia")]
670impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
671    type Proxy = ProviderProxy;
672    type Protocol = ProviderMarker;
673
674    fn from_channel(inner: fidl::Channel) -> Self {
675        Self::new(inner)
676    }
677
678    fn into_channel(self) -> fidl::Channel {
679        self.client.into_channel()
680    }
681
682    fn as_channel(&self) -> &fidl::Channel {
683        self.client.as_channel()
684    }
685}
686
687#[cfg(target_os = "fuchsia")]
688impl ProviderSynchronousProxy {
689    pub fn new(channel: fidl::Channel) -> Self {
690        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
691        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
692    }
693
694    pub fn into_channel(self) -> fidl::Channel {
695        self.client.into_channel()
696    }
697
698    /// Waits until an event arrives and returns it. It is safe for other
699    /// threads to make concurrent requests while waiting for an event.
700    pub fn wait_for_event(
701        &self,
702        deadline: zx::MonotonicInstant,
703    ) -> Result<ProviderEvent, fidl::Error> {
704        ProviderEvent::decode(self.client.wait_for_event(deadline)?)
705    }
706
707    /// Connect `socket` to the service (called in response to adb OPEN message).
708    /// `args` provides additional arguments passed by the client if any.
709    pub fn r#connect_to_service(
710        &self,
711        mut socket: fidl::Socket,
712        mut args: Option<&str>,
713        ___deadline: zx::MonotonicInstant,
714    ) -> Result<ProviderConnectToServiceResult, fidl::Error> {
715        let _response = self.client.send_query::<
716            ProviderConnectToServiceRequest,
717            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
718        >(
719            (socket, args,),
720            0x303e4a312d85292b,
721            fidl::encoding::DynamicFlags::empty(),
722            ___deadline,
723        )?;
724        Ok(_response.map(|x| x))
725    }
726}
727
728#[cfg(target_os = "fuchsia")]
729impl From<ProviderSynchronousProxy> for zx::Handle {
730    fn from(value: ProviderSynchronousProxy) -> Self {
731        value.into_channel().into()
732    }
733}
734
735#[cfg(target_os = "fuchsia")]
736impl From<fidl::Channel> for ProviderSynchronousProxy {
737    fn from(value: fidl::Channel) -> Self {
738        Self::new(value)
739    }
740}
741
742#[cfg(target_os = "fuchsia")]
743impl fidl::endpoints::FromClient for ProviderSynchronousProxy {
744    type Protocol = ProviderMarker;
745
746    fn from_client(value: fidl::endpoints::ClientEnd<ProviderMarker>) -> Self {
747        Self::new(value.into_channel())
748    }
749}
750
751#[derive(Debug, Clone)]
752pub struct ProviderProxy {
753    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
754}
755
756impl fidl::endpoints::Proxy for ProviderProxy {
757    type Protocol = ProviderMarker;
758
759    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
760        Self::new(inner)
761    }
762
763    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
764        self.client.into_channel().map_err(|client| Self { client })
765    }
766
767    fn as_channel(&self) -> &::fidl::AsyncChannel {
768        self.client.as_channel()
769    }
770}
771
772impl ProviderProxy {
773    /// Create a new Proxy for fuchsia.hardware.adb/Provider.
774    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
775        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
776        Self { client: fidl::client::Client::new(channel, protocol_name) }
777    }
778
779    /// Get a Stream of events from the remote end of the protocol.
780    ///
781    /// # Panics
782    ///
783    /// Panics if the event stream was already taken.
784    pub fn take_event_stream(&self) -> ProviderEventStream {
785        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
786    }
787
788    /// Connect `socket` to the service (called in response to adb OPEN message).
789    /// `args` provides additional arguments passed by the client if any.
790    pub fn r#connect_to_service(
791        &self,
792        mut socket: fidl::Socket,
793        mut args: Option<&str>,
794    ) -> fidl::client::QueryResponseFut<
795        ProviderConnectToServiceResult,
796        fidl::encoding::DefaultFuchsiaResourceDialect,
797    > {
798        ProviderProxyInterface::r#connect_to_service(self, socket, args)
799    }
800}
801
802impl ProviderProxyInterface for ProviderProxy {
803    type ConnectToServiceResponseFut = fidl::client::QueryResponseFut<
804        ProviderConnectToServiceResult,
805        fidl::encoding::DefaultFuchsiaResourceDialect,
806    >;
807    fn r#connect_to_service(
808        &self,
809        mut socket: fidl::Socket,
810        mut args: Option<&str>,
811    ) -> Self::ConnectToServiceResponseFut {
812        fn _decode(
813            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
814        ) -> Result<ProviderConnectToServiceResult, fidl::Error> {
815            let _response = fidl::client::decode_transaction_body::<
816                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
817                fidl::encoding::DefaultFuchsiaResourceDialect,
818                0x303e4a312d85292b,
819            >(_buf?)?;
820            Ok(_response.map(|x| x))
821        }
822        self.client.send_query_and_decode::<
823            ProviderConnectToServiceRequest,
824            ProviderConnectToServiceResult,
825        >(
826            (socket, args,),
827            0x303e4a312d85292b,
828            fidl::encoding::DynamicFlags::empty(),
829            _decode,
830        )
831    }
832}
833
834pub struct ProviderEventStream {
835    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
836}
837
838impl std::marker::Unpin for ProviderEventStream {}
839
840impl futures::stream::FusedStream for ProviderEventStream {
841    fn is_terminated(&self) -> bool {
842        self.event_receiver.is_terminated()
843    }
844}
845
846impl futures::Stream for ProviderEventStream {
847    type Item = Result<ProviderEvent, fidl::Error>;
848
849    fn poll_next(
850        mut self: std::pin::Pin<&mut Self>,
851        cx: &mut std::task::Context<'_>,
852    ) -> std::task::Poll<Option<Self::Item>> {
853        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
854            &mut self.event_receiver,
855            cx
856        )?) {
857            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
858            None => std::task::Poll::Ready(None),
859        }
860    }
861}
862
863#[derive(Debug)]
864pub enum ProviderEvent {}
865
866impl ProviderEvent {
867    /// Decodes a message buffer as a [`ProviderEvent`].
868    fn decode(
869        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
870    ) -> Result<ProviderEvent, fidl::Error> {
871        let (bytes, _handles) = buf.split_mut();
872        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
873        debug_assert_eq!(tx_header.tx_id, 0);
874        match tx_header.ordinal {
875            _ => Err(fidl::Error::UnknownOrdinal {
876                ordinal: tx_header.ordinal,
877                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
878            }),
879        }
880    }
881}
882
883/// A Stream of incoming requests for fuchsia.hardware.adb/Provider.
884pub struct ProviderRequestStream {
885    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
886    is_terminated: bool,
887}
888
889impl std::marker::Unpin for ProviderRequestStream {}
890
891impl futures::stream::FusedStream for ProviderRequestStream {
892    fn is_terminated(&self) -> bool {
893        self.is_terminated
894    }
895}
896
897impl fidl::endpoints::RequestStream for ProviderRequestStream {
898    type Protocol = ProviderMarker;
899    type ControlHandle = ProviderControlHandle;
900
901    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
902        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
903    }
904
905    fn control_handle(&self) -> Self::ControlHandle {
906        ProviderControlHandle { inner: self.inner.clone() }
907    }
908
909    fn into_inner(
910        self,
911    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
912    {
913        (self.inner, self.is_terminated)
914    }
915
916    fn from_inner(
917        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
918        is_terminated: bool,
919    ) -> Self {
920        Self { inner, is_terminated }
921    }
922}
923
924impl futures::Stream for ProviderRequestStream {
925    type Item = Result<ProviderRequest, fidl::Error>;
926
927    fn poll_next(
928        mut self: std::pin::Pin<&mut Self>,
929        cx: &mut std::task::Context<'_>,
930    ) -> std::task::Poll<Option<Self::Item>> {
931        let this = &mut *self;
932        if this.inner.check_shutdown(cx) {
933            this.is_terminated = true;
934            return std::task::Poll::Ready(None);
935        }
936        if this.is_terminated {
937            panic!("polled ProviderRequestStream after completion");
938        }
939        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
940            |bytes, handles| {
941                match this.inner.channel().read_etc(cx, bytes, handles) {
942                    std::task::Poll::Ready(Ok(())) => {}
943                    std::task::Poll::Pending => return std::task::Poll::Pending,
944                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
945                        this.is_terminated = true;
946                        return std::task::Poll::Ready(None);
947                    }
948                    std::task::Poll::Ready(Err(e)) => {
949                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
950                            e.into(),
951                        ))));
952                    }
953                }
954
955                // A message has been received from the channel
956                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
957
958                std::task::Poll::Ready(Some(match header.ordinal {
959                    0x303e4a312d85292b => {
960                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
961                        let mut req = fidl::new_empty!(
962                            ProviderConnectToServiceRequest,
963                            fidl::encoding::DefaultFuchsiaResourceDialect
964                        );
965                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderConnectToServiceRequest>(&header, _body_bytes, handles, &mut req)?;
966                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
967                        Ok(ProviderRequest::ConnectToService {
968                            socket: req.socket,
969                            args: req.args,
970
971                            responder: ProviderConnectToServiceResponder {
972                                control_handle: std::mem::ManuallyDrop::new(control_handle),
973                                tx_id: header.tx_id,
974                            },
975                        })
976                    }
977                    _ => Err(fidl::Error::UnknownOrdinal {
978                        ordinal: header.ordinal,
979                        protocol_name:
980                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
981                    }),
982                }))
983            },
984        )
985    }
986}
987
988/// A Provider is a provider for one service which interacts with the adb component to implement
989/// a particular service such as shell, file-sync, or ffx.
990/// The interaction between the adb component and a service Provider (e.g. shell) is as follows:
991///    - adb component is started eagerly by core.cml. Note that the adb component does not
992///      implement any adb FIDL protocols.
993///    - When a request for a service (e.g. shell) comes in, adb daemon starts up a lazy
994///      component for the corresponding requested service (adb-shell-component) exposing the
995///      Provider protocol and calls ConnectToService, creating a connection between the adb
996///      component and the service provider component (adb-shell-component) through the socket.
997///    - If the service (adb-shell-component) has already been started, it opens that service
998///      and hands it the socket.
999///    - adb component and service Provider component (adb-shell) communicate over the socket.
1000#[derive(Debug)]
1001pub enum ProviderRequest {
1002    /// Connect `socket` to the service (called in response to adb OPEN message).
1003    /// `args` provides additional arguments passed by the client if any.
1004    ConnectToService {
1005        socket: fidl::Socket,
1006        args: Option<String>,
1007        responder: ProviderConnectToServiceResponder,
1008    },
1009}
1010
1011impl ProviderRequest {
1012    #[allow(irrefutable_let_patterns)]
1013    pub fn into_connect_to_service(
1014        self,
1015    ) -> Option<(fidl::Socket, Option<String>, ProviderConnectToServiceResponder)> {
1016        if let ProviderRequest::ConnectToService { socket, args, responder } = self {
1017            Some((socket, args, responder))
1018        } else {
1019            None
1020        }
1021    }
1022
1023    /// Name of the method defined in FIDL
1024    pub fn method_name(&self) -> &'static str {
1025        match *self {
1026            ProviderRequest::ConnectToService { .. } => "connect_to_service",
1027        }
1028    }
1029}
1030
1031#[derive(Debug, Clone)]
1032pub struct ProviderControlHandle {
1033    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1034}
1035
1036impl fidl::endpoints::ControlHandle for ProviderControlHandle {
1037    fn shutdown(&self) {
1038        self.inner.shutdown()
1039    }
1040    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1041        self.inner.shutdown_with_epitaph(status)
1042    }
1043
1044    fn is_closed(&self) -> bool {
1045        self.inner.channel().is_closed()
1046    }
1047    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1048        self.inner.channel().on_closed()
1049    }
1050
1051    #[cfg(target_os = "fuchsia")]
1052    fn signal_peer(
1053        &self,
1054        clear_mask: zx::Signals,
1055        set_mask: zx::Signals,
1056    ) -> Result<(), zx_status::Status> {
1057        use fidl::Peered;
1058        self.inner.channel().signal_peer(clear_mask, set_mask)
1059    }
1060}
1061
1062impl ProviderControlHandle {}
1063
1064#[must_use = "FIDL methods require a response to be sent"]
1065#[derive(Debug)]
1066pub struct ProviderConnectToServiceResponder {
1067    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
1068    tx_id: u32,
1069}
1070
1071/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
1072/// if the responder is dropped without sending a response, so that the client
1073/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1074impl std::ops::Drop for ProviderConnectToServiceResponder {
1075    fn drop(&mut self) {
1076        self.control_handle.shutdown();
1077        // Safety: drops once, never accessed again
1078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1079    }
1080}
1081
1082impl fidl::endpoints::Responder for ProviderConnectToServiceResponder {
1083    type ControlHandle = ProviderControlHandle;
1084
1085    fn control_handle(&self) -> &ProviderControlHandle {
1086        &self.control_handle
1087    }
1088
1089    fn drop_without_shutdown(mut self) {
1090        // Safety: drops once, never accessed again due to mem::forget
1091        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1092        // Prevent Drop from running (which would shut down the channel)
1093        std::mem::forget(self);
1094    }
1095}
1096
1097impl ProviderConnectToServiceResponder {
1098    /// Sends a response to the FIDL transaction.
1099    ///
1100    /// Sets the channel to shutdown if an error occurs.
1101    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1102        let _result = self.send_raw(result);
1103        if _result.is_err() {
1104            self.control_handle.shutdown();
1105        }
1106        self.drop_without_shutdown();
1107        _result
1108    }
1109
1110    /// Similar to "send" but does not shutdown the channel if an error occurs.
1111    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1112        let _result = self.send_raw(result);
1113        self.drop_without_shutdown();
1114        _result
1115    }
1116
1117    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1118        self.control_handle
1119            .inner
1120            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1121                result,
1122                self.tx_id,
1123                0x303e4a312d85292b,
1124                fidl::encoding::DynamicFlags::empty(),
1125            )
1126    }
1127}
1128
1129#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1130pub struct UsbAdbImpl_Marker;
1131
1132impl fidl::endpoints::ProtocolMarker for UsbAdbImpl_Marker {
1133    type Proxy = UsbAdbImpl_Proxy;
1134    type RequestStream = UsbAdbImpl_RequestStream;
1135    #[cfg(target_os = "fuchsia")]
1136    type SynchronousProxy = UsbAdbImpl_SynchronousProxy;
1137
1138    const DEBUG_NAME: &'static str = "(anonymous) UsbAdbImpl_";
1139}
1140pub type UsbAdbImplQueueTxResult = Result<(), i32>;
1141pub type UsbAdbImplReceiveResult = Result<Vec<u8>, i32>;
1142
1143pub trait UsbAdbImpl_ProxyInterface: Send + Sync {
1144    type QueueTxResponseFut: std::future::Future<Output = Result<UsbAdbImplQueueTxResult, fidl::Error>>
1145        + Send;
1146    fn r#queue_tx(&self, data: &[u8]) -> Self::QueueTxResponseFut;
1147    type ReceiveResponseFut: std::future::Future<Output = Result<UsbAdbImplReceiveResult, fidl::Error>>
1148        + Send;
1149    fn r#receive(&self) -> Self::ReceiveResponseFut;
1150}
1151#[derive(Debug)]
1152#[cfg(target_os = "fuchsia")]
1153pub struct UsbAdbImpl_SynchronousProxy {
1154    client: fidl::client::sync::Client,
1155}
1156
1157#[cfg(target_os = "fuchsia")]
1158impl fidl::endpoints::SynchronousProxy for UsbAdbImpl_SynchronousProxy {
1159    type Proxy = UsbAdbImpl_Proxy;
1160    type Protocol = UsbAdbImpl_Marker;
1161
1162    fn from_channel(inner: fidl::Channel) -> Self {
1163        Self::new(inner)
1164    }
1165
1166    fn into_channel(self) -> fidl::Channel {
1167        self.client.into_channel()
1168    }
1169
1170    fn as_channel(&self) -> &fidl::Channel {
1171        self.client.as_channel()
1172    }
1173}
1174
1175#[cfg(target_os = "fuchsia")]
1176impl UsbAdbImpl_SynchronousProxy {
1177    pub fn new(channel: fidl::Channel) -> Self {
1178        let protocol_name = <UsbAdbImpl_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1179        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1180    }
1181
1182    pub fn into_channel(self) -> fidl::Channel {
1183        self.client.into_channel()
1184    }
1185
1186    /// Waits until an event arrives and returns it. It is safe for other
1187    /// threads to make concurrent requests while waiting for an event.
1188    pub fn wait_for_event(
1189        &self,
1190        deadline: zx::MonotonicInstant,
1191    ) -> Result<UsbAdbImpl_Event, fidl::Error> {
1192        UsbAdbImpl_Event::decode(self.client.wait_for_event(deadline)?)
1193    }
1194
1195    /// Request transmission of the packet in |data|.
1196    ///
1197    /// Return status indicates queue state:
1198    ///   ZX_OK: Packet has been enqueued.
1199    ///   Other: Packet could not be enqueued.
1200    /// Upon a return of ZX_OK, the packet has been enqueued, but no information is returned as to
1201    /// the completion state of the transmission itself.
1202    pub fn r#queue_tx(
1203        &self,
1204        mut data: &[u8],
1205        ___deadline: zx::MonotonicInstant,
1206    ) -> Result<UsbAdbImplQueueTxResult, fidl::Error> {
1207        let _response = self.client.send_query::<
1208            UsbAdbImplQueueTxRequest,
1209            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1210        >(
1211            (data,),
1212            0x4c0af0efa9701dc9,
1213            fidl::encoding::DynamicFlags::empty(),
1214            ___deadline,
1215        )?;
1216        Ok(_response.map(|x| x))
1217    }
1218
1219    /// Request to receive data. This method ensures flow control by allowing the client to queue
1220    /// |Receive| requests proactively. The driver will complete the requests only when data is
1221    /// available.
1222    ///
1223    /// Return data or error.
1224    ///    ZX_OK: Success. data is valid.
1225    ///    ZX_ERR_BAD_STATE: Subsequent requests will not succeed as well.
1226    /// Other error codes are from underlying subsystem and the caller should retry |Receive| in
1227    /// that case.
1228    pub fn r#receive(
1229        &self,
1230        ___deadline: zx::MonotonicInstant,
1231    ) -> Result<UsbAdbImplReceiveResult, fidl::Error> {
1232        let _response = self.client.send_query::<
1233            fidl::encoding::EmptyPayload,
1234            fidl::encoding::ResultType<UsbAdbImplReceiveResponse, i32>,
1235        >(
1236            (),
1237            0x68382fff953be5c4,
1238            fidl::encoding::DynamicFlags::empty(),
1239            ___deadline,
1240        )?;
1241        Ok(_response.map(|x| x.data))
1242    }
1243}
1244
1245#[cfg(target_os = "fuchsia")]
1246impl From<UsbAdbImpl_SynchronousProxy> for zx::Handle {
1247    fn from(value: UsbAdbImpl_SynchronousProxy) -> Self {
1248        value.into_channel().into()
1249    }
1250}
1251
1252#[cfg(target_os = "fuchsia")]
1253impl From<fidl::Channel> for UsbAdbImpl_SynchronousProxy {
1254    fn from(value: fidl::Channel) -> Self {
1255        Self::new(value)
1256    }
1257}
1258
1259#[cfg(target_os = "fuchsia")]
1260impl fidl::endpoints::FromClient for UsbAdbImpl_SynchronousProxy {
1261    type Protocol = UsbAdbImpl_Marker;
1262
1263    fn from_client(value: fidl::endpoints::ClientEnd<UsbAdbImpl_Marker>) -> Self {
1264        Self::new(value.into_channel())
1265    }
1266}
1267
1268#[derive(Debug, Clone)]
1269pub struct UsbAdbImpl_Proxy {
1270    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1271}
1272
1273impl fidl::endpoints::Proxy for UsbAdbImpl_Proxy {
1274    type Protocol = UsbAdbImpl_Marker;
1275
1276    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1277        Self::new(inner)
1278    }
1279
1280    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1281        self.client.into_channel().map_err(|client| Self { client })
1282    }
1283
1284    fn as_channel(&self) -> &::fidl::AsyncChannel {
1285        self.client.as_channel()
1286    }
1287}
1288
1289impl UsbAdbImpl_Proxy {
1290    /// Create a new Proxy for fuchsia.hardware.adb/UsbAdbImpl.
1291    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1292        let protocol_name = <UsbAdbImpl_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1293        Self { client: fidl::client::Client::new(channel, protocol_name) }
1294    }
1295
1296    /// Get a Stream of events from the remote end of the protocol.
1297    ///
1298    /// # Panics
1299    ///
1300    /// Panics if the event stream was already taken.
1301    pub fn take_event_stream(&self) -> UsbAdbImpl_EventStream {
1302        UsbAdbImpl_EventStream { event_receiver: self.client.take_event_receiver() }
1303    }
1304
1305    /// Request transmission of the packet in |data|.
1306    ///
1307    /// Return status indicates queue state:
1308    ///   ZX_OK: Packet has been enqueued.
1309    ///   Other: Packet could not be enqueued.
1310    /// Upon a return of ZX_OK, the packet has been enqueued, but no information is returned as to
1311    /// the completion state of the transmission itself.
1312    pub fn r#queue_tx(
1313        &self,
1314        mut data: &[u8],
1315    ) -> fidl::client::QueryResponseFut<
1316        UsbAdbImplQueueTxResult,
1317        fidl::encoding::DefaultFuchsiaResourceDialect,
1318    > {
1319        UsbAdbImpl_ProxyInterface::r#queue_tx(self, data)
1320    }
1321
1322    /// Request to receive data. This method ensures flow control by allowing the client to queue
1323    /// |Receive| requests proactively. The driver will complete the requests only when data is
1324    /// available.
1325    ///
1326    /// Return data or error.
1327    ///    ZX_OK: Success. data is valid.
1328    ///    ZX_ERR_BAD_STATE: Subsequent requests will not succeed as well.
1329    /// Other error codes are from underlying subsystem and the caller should retry |Receive| in
1330    /// that case.
1331    pub fn r#receive(
1332        &self,
1333    ) -> fidl::client::QueryResponseFut<
1334        UsbAdbImplReceiveResult,
1335        fidl::encoding::DefaultFuchsiaResourceDialect,
1336    > {
1337        UsbAdbImpl_ProxyInterface::r#receive(self)
1338    }
1339}
1340
1341impl UsbAdbImpl_ProxyInterface for UsbAdbImpl_Proxy {
1342    type QueueTxResponseFut = fidl::client::QueryResponseFut<
1343        UsbAdbImplQueueTxResult,
1344        fidl::encoding::DefaultFuchsiaResourceDialect,
1345    >;
1346    fn r#queue_tx(&self, mut data: &[u8]) -> Self::QueueTxResponseFut {
1347        fn _decode(
1348            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1349        ) -> Result<UsbAdbImplQueueTxResult, fidl::Error> {
1350            let _response = fidl::client::decode_transaction_body::<
1351                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1352                fidl::encoding::DefaultFuchsiaResourceDialect,
1353                0x4c0af0efa9701dc9,
1354            >(_buf?)?;
1355            Ok(_response.map(|x| x))
1356        }
1357        self.client.send_query_and_decode::<UsbAdbImplQueueTxRequest, UsbAdbImplQueueTxResult>(
1358            (data,),
1359            0x4c0af0efa9701dc9,
1360            fidl::encoding::DynamicFlags::empty(),
1361            _decode,
1362        )
1363    }
1364
1365    type ReceiveResponseFut = fidl::client::QueryResponseFut<
1366        UsbAdbImplReceiveResult,
1367        fidl::encoding::DefaultFuchsiaResourceDialect,
1368    >;
1369    fn r#receive(&self) -> Self::ReceiveResponseFut {
1370        fn _decode(
1371            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1372        ) -> Result<UsbAdbImplReceiveResult, fidl::Error> {
1373            let _response = fidl::client::decode_transaction_body::<
1374                fidl::encoding::ResultType<UsbAdbImplReceiveResponse, i32>,
1375                fidl::encoding::DefaultFuchsiaResourceDialect,
1376                0x68382fff953be5c4,
1377            >(_buf?)?;
1378            Ok(_response.map(|x| x.data))
1379        }
1380        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, UsbAdbImplReceiveResult>(
1381            (),
1382            0x68382fff953be5c4,
1383            fidl::encoding::DynamicFlags::empty(),
1384            _decode,
1385        )
1386    }
1387}
1388
1389pub struct UsbAdbImpl_EventStream {
1390    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1391}
1392
1393impl std::marker::Unpin for UsbAdbImpl_EventStream {}
1394
1395impl futures::stream::FusedStream for UsbAdbImpl_EventStream {
1396    fn is_terminated(&self) -> bool {
1397        self.event_receiver.is_terminated()
1398    }
1399}
1400
1401impl futures::Stream for UsbAdbImpl_EventStream {
1402    type Item = Result<UsbAdbImpl_Event, fidl::Error>;
1403
1404    fn poll_next(
1405        mut self: std::pin::Pin<&mut Self>,
1406        cx: &mut std::task::Context<'_>,
1407    ) -> std::task::Poll<Option<Self::Item>> {
1408        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1409            &mut self.event_receiver,
1410            cx
1411        )?) {
1412            Some(buf) => std::task::Poll::Ready(Some(UsbAdbImpl_Event::decode(buf))),
1413            None => std::task::Poll::Ready(None),
1414        }
1415    }
1416}
1417
1418#[derive(Debug)]
1419pub enum UsbAdbImpl_Event {
1420    OnStatusChanged { status: StatusFlags },
1421}
1422
1423impl UsbAdbImpl_Event {
1424    #[allow(irrefutable_let_patterns)]
1425    pub fn into_on_status_changed(self) -> Option<StatusFlags> {
1426        if let UsbAdbImpl_Event::OnStatusChanged { status } = self { Some((status)) } else { None }
1427    }
1428
1429    /// Decodes a message buffer as a [`UsbAdbImpl_Event`].
1430    fn decode(
1431        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1432    ) -> Result<UsbAdbImpl_Event, fidl::Error> {
1433        let (bytes, _handles) = buf.split_mut();
1434        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1435        debug_assert_eq!(tx_header.tx_id, 0);
1436        match tx_header.ordinal {
1437            0x2f2926086c0a5b6e => {
1438                let mut out = fidl::new_empty!(
1439                    UsbAdbImplOnStatusChangedRequest,
1440                    fidl::encoding::DefaultFuchsiaResourceDialect
1441                );
1442                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbAdbImplOnStatusChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1443                Ok((UsbAdbImpl_Event::OnStatusChanged { status: out.status }))
1444            }
1445            _ => Err(fidl::Error::UnknownOrdinal {
1446                ordinal: tx_header.ordinal,
1447                protocol_name: <UsbAdbImpl_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1448            }),
1449        }
1450    }
1451}
1452
1453/// A Stream of incoming requests for fuchsia.hardware.adb/UsbAdbImpl.
1454pub struct UsbAdbImpl_RequestStream {
1455    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1456    is_terminated: bool,
1457}
1458
1459impl std::marker::Unpin for UsbAdbImpl_RequestStream {}
1460
1461impl futures::stream::FusedStream for UsbAdbImpl_RequestStream {
1462    fn is_terminated(&self) -> bool {
1463        self.is_terminated
1464    }
1465}
1466
1467impl fidl::endpoints::RequestStream for UsbAdbImpl_RequestStream {
1468    type Protocol = UsbAdbImpl_Marker;
1469    type ControlHandle = UsbAdbImpl_ControlHandle;
1470
1471    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1472        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1473    }
1474
1475    fn control_handle(&self) -> Self::ControlHandle {
1476        UsbAdbImpl_ControlHandle { inner: self.inner.clone() }
1477    }
1478
1479    fn into_inner(
1480        self,
1481    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1482    {
1483        (self.inner, self.is_terminated)
1484    }
1485
1486    fn from_inner(
1487        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1488        is_terminated: bool,
1489    ) -> Self {
1490        Self { inner, is_terminated }
1491    }
1492}
1493
1494impl futures::Stream for UsbAdbImpl_RequestStream {
1495    type Item = Result<UsbAdbImpl_Request, fidl::Error>;
1496
1497    fn poll_next(
1498        mut self: std::pin::Pin<&mut Self>,
1499        cx: &mut std::task::Context<'_>,
1500    ) -> std::task::Poll<Option<Self::Item>> {
1501        let this = &mut *self;
1502        if this.inner.check_shutdown(cx) {
1503            this.is_terminated = true;
1504            return std::task::Poll::Ready(None);
1505        }
1506        if this.is_terminated {
1507            panic!("polled UsbAdbImpl_RequestStream after completion");
1508        }
1509        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1510            |bytes, handles| {
1511                match this.inner.channel().read_etc(cx, bytes, handles) {
1512                    std::task::Poll::Ready(Ok(())) => {}
1513                    std::task::Poll::Pending => return std::task::Poll::Pending,
1514                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1515                        this.is_terminated = true;
1516                        return std::task::Poll::Ready(None);
1517                    }
1518                    std::task::Poll::Ready(Err(e)) => {
1519                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1520                            e.into(),
1521                        ))));
1522                    }
1523                }
1524
1525                // A message has been received from the channel
1526                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1527
1528                std::task::Poll::Ready(Some(match header.ordinal {
1529                    0x4c0af0efa9701dc9 => {
1530                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1531                        let mut req = fidl::new_empty!(
1532                            UsbAdbImplQueueTxRequest,
1533                            fidl::encoding::DefaultFuchsiaResourceDialect
1534                        );
1535                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbAdbImplQueueTxRequest>(&header, _body_bytes, handles, &mut req)?;
1536                        let control_handle = UsbAdbImpl_ControlHandle { inner: this.inner.clone() };
1537                        Ok(UsbAdbImpl_Request::QueueTx {
1538                            data: req.data,
1539
1540                            responder: UsbAdbImpl_QueueTxResponder {
1541                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1542                                tx_id: header.tx_id,
1543                            },
1544                        })
1545                    }
1546                    0x68382fff953be5c4 => {
1547                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1548                        let mut req = fidl::new_empty!(
1549                            fidl::encoding::EmptyPayload,
1550                            fidl::encoding::DefaultFuchsiaResourceDialect
1551                        );
1552                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1553                        let control_handle = UsbAdbImpl_ControlHandle { inner: this.inner.clone() };
1554                        Ok(UsbAdbImpl_Request::Receive {
1555                            responder: UsbAdbImpl_ReceiveResponder {
1556                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1557                                tx_id: header.tx_id,
1558                            },
1559                        })
1560                    }
1561                    _ => Err(fidl::Error::UnknownOrdinal {
1562                        ordinal: header.ordinal,
1563                        protocol_name:
1564                            <UsbAdbImpl_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1565                    }),
1566                }))
1567            },
1568        )
1569    }
1570}
1571
1572/// USB ADB implementation protocol. The USB ADB driver would start serving this interface on the
1573/// server endpoint passed to a driver during Device::Start.
1574#[derive(Debug)]
1575pub enum UsbAdbImpl_Request {
1576    /// Request transmission of the packet in |data|.
1577    ///
1578    /// Return status indicates queue state:
1579    ///   ZX_OK: Packet has been enqueued.
1580    ///   Other: Packet could not be enqueued.
1581    /// Upon a return of ZX_OK, the packet has been enqueued, but no information is returned as to
1582    /// the completion state of the transmission itself.
1583    QueueTx { data: Vec<u8>, responder: UsbAdbImpl_QueueTxResponder },
1584    /// Request to receive data. This method ensures flow control by allowing the client to queue
1585    /// |Receive| requests proactively. The driver will complete the requests only when data is
1586    /// available.
1587    ///
1588    /// Return data or error.
1589    ///    ZX_OK: Success. data is valid.
1590    ///    ZX_ERR_BAD_STATE: Subsequent requests will not succeed as well.
1591    /// Other error codes are from underlying subsystem and the caller should retry |Receive| in
1592    /// that case.
1593    Receive { responder: UsbAdbImpl_ReceiveResponder },
1594}
1595
1596impl UsbAdbImpl_Request {
1597    #[allow(irrefutable_let_patterns)]
1598    pub fn into_queue_tx(self) -> Option<(Vec<u8>, UsbAdbImpl_QueueTxResponder)> {
1599        if let UsbAdbImpl_Request::QueueTx { data, responder } = self {
1600            Some((data, responder))
1601        } else {
1602            None
1603        }
1604    }
1605
1606    #[allow(irrefutable_let_patterns)]
1607    pub fn into_receive(self) -> Option<(UsbAdbImpl_ReceiveResponder)> {
1608        if let UsbAdbImpl_Request::Receive { responder } = self { Some((responder)) } else { None }
1609    }
1610
1611    /// Name of the method defined in FIDL
1612    pub fn method_name(&self) -> &'static str {
1613        match *self {
1614            UsbAdbImpl_Request::QueueTx { .. } => "queue_tx",
1615            UsbAdbImpl_Request::Receive { .. } => "receive",
1616        }
1617    }
1618}
1619
1620#[derive(Debug, Clone)]
1621pub struct UsbAdbImpl_ControlHandle {
1622    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1623}
1624
1625impl fidl::endpoints::ControlHandle for UsbAdbImpl_ControlHandle {
1626    fn shutdown(&self) {
1627        self.inner.shutdown()
1628    }
1629    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1630        self.inner.shutdown_with_epitaph(status)
1631    }
1632
1633    fn is_closed(&self) -> bool {
1634        self.inner.channel().is_closed()
1635    }
1636    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1637        self.inner.channel().on_closed()
1638    }
1639
1640    #[cfg(target_os = "fuchsia")]
1641    fn signal_peer(
1642        &self,
1643        clear_mask: zx::Signals,
1644        set_mask: zx::Signals,
1645    ) -> Result<(), zx_status::Status> {
1646        use fidl::Peered;
1647        self.inner.channel().signal_peer(clear_mask, set_mask)
1648    }
1649}
1650
1651impl UsbAdbImpl_ControlHandle {
1652    pub fn send_on_status_changed(&self, mut status: StatusFlags) -> Result<(), fidl::Error> {
1653        self.inner.send::<UsbAdbImplOnStatusChangedRequest>(
1654            (status,),
1655            0,
1656            0x2f2926086c0a5b6e,
1657            fidl::encoding::DynamicFlags::empty(),
1658        )
1659    }
1660}
1661
1662#[must_use = "FIDL methods require a response to be sent"]
1663#[derive(Debug)]
1664pub struct UsbAdbImpl_QueueTxResponder {
1665    control_handle: std::mem::ManuallyDrop<UsbAdbImpl_ControlHandle>,
1666    tx_id: u32,
1667}
1668
1669/// Set the the channel to be shutdown (see [`UsbAdbImpl_ControlHandle::shutdown`])
1670/// if the responder is dropped without sending a response, so that the client
1671/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1672impl std::ops::Drop for UsbAdbImpl_QueueTxResponder {
1673    fn drop(&mut self) {
1674        self.control_handle.shutdown();
1675        // Safety: drops once, never accessed again
1676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1677    }
1678}
1679
1680impl fidl::endpoints::Responder for UsbAdbImpl_QueueTxResponder {
1681    type ControlHandle = UsbAdbImpl_ControlHandle;
1682
1683    fn control_handle(&self) -> &UsbAdbImpl_ControlHandle {
1684        &self.control_handle
1685    }
1686
1687    fn drop_without_shutdown(mut self) {
1688        // Safety: drops once, never accessed again due to mem::forget
1689        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1690        // Prevent Drop from running (which would shut down the channel)
1691        std::mem::forget(self);
1692    }
1693}
1694
1695impl UsbAdbImpl_QueueTxResponder {
1696    /// Sends a response to the FIDL transaction.
1697    ///
1698    /// Sets the channel to shutdown if an error occurs.
1699    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1700        let _result = self.send_raw(result);
1701        if _result.is_err() {
1702            self.control_handle.shutdown();
1703        }
1704        self.drop_without_shutdown();
1705        _result
1706    }
1707
1708    /// Similar to "send" but does not shutdown the channel if an error occurs.
1709    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1710        let _result = self.send_raw(result);
1711        self.drop_without_shutdown();
1712        _result
1713    }
1714
1715    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1716        self.control_handle
1717            .inner
1718            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1719                result,
1720                self.tx_id,
1721                0x4c0af0efa9701dc9,
1722                fidl::encoding::DynamicFlags::empty(),
1723            )
1724    }
1725}
1726
1727#[must_use = "FIDL methods require a response to be sent"]
1728#[derive(Debug)]
1729pub struct UsbAdbImpl_ReceiveResponder {
1730    control_handle: std::mem::ManuallyDrop<UsbAdbImpl_ControlHandle>,
1731    tx_id: u32,
1732}
1733
1734/// Set the the channel to be shutdown (see [`UsbAdbImpl_ControlHandle::shutdown`])
1735/// if the responder is dropped without sending a response, so that the client
1736/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1737impl std::ops::Drop for UsbAdbImpl_ReceiveResponder {
1738    fn drop(&mut self) {
1739        self.control_handle.shutdown();
1740        // Safety: drops once, never accessed again
1741        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1742    }
1743}
1744
1745impl fidl::endpoints::Responder for UsbAdbImpl_ReceiveResponder {
1746    type ControlHandle = UsbAdbImpl_ControlHandle;
1747
1748    fn control_handle(&self) -> &UsbAdbImpl_ControlHandle {
1749        &self.control_handle
1750    }
1751
1752    fn drop_without_shutdown(mut self) {
1753        // Safety: drops once, never accessed again due to mem::forget
1754        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1755        // Prevent Drop from running (which would shut down the channel)
1756        std::mem::forget(self);
1757    }
1758}
1759
1760impl UsbAdbImpl_ReceiveResponder {
1761    /// Sends a response to the FIDL transaction.
1762    ///
1763    /// Sets the channel to shutdown if an error occurs.
1764    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1765        let _result = self.send_raw(result);
1766        if _result.is_err() {
1767            self.control_handle.shutdown();
1768        }
1769        self.drop_without_shutdown();
1770        _result
1771    }
1772
1773    /// Similar to "send" but does not shutdown the channel if an error occurs.
1774    pub fn send_no_shutdown_on_err(
1775        self,
1776        mut result: Result<&[u8], i32>,
1777    ) -> Result<(), fidl::Error> {
1778        let _result = self.send_raw(result);
1779        self.drop_without_shutdown();
1780        _result
1781    }
1782
1783    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1784        self.control_handle
1785            .inner
1786            .send::<fidl::encoding::ResultType<UsbAdbImplReceiveResponse, i32>>(
1787                result.map(|data| (data,)),
1788                self.tx_id,
1789                0x68382fff953be5c4,
1790                fidl::encoding::DynamicFlags::empty(),
1791            )
1792    }
1793}
1794
1795#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1796pub struct ServiceMarker;
1797
1798#[cfg(target_os = "fuchsia")]
1799impl fidl::endpoints::ServiceMarker for ServiceMarker {
1800    type Proxy = ServiceProxy;
1801    type Request = ServiceRequest;
1802    const SERVICE_NAME: &'static str = "fuchsia.hardware.adb.Service";
1803}
1804
1805/// A request for one of the member protocols of Service.
1806///
1807#[cfg(target_os = "fuchsia")]
1808pub enum ServiceRequest {
1809    Adb(DeviceRequestStream),
1810}
1811
1812#[cfg(target_os = "fuchsia")]
1813impl fidl::endpoints::ServiceRequest for ServiceRequest {
1814    type Service = ServiceMarker;
1815
1816    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1817        match name {
1818            "adb" => Self::Adb(
1819                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1820            ),
1821            _ => panic!("no such member protocol name for service Service"),
1822        }
1823    }
1824
1825    fn member_names() -> &'static [&'static str] {
1826        &["adb"]
1827    }
1828}
1829#[cfg(target_os = "fuchsia")]
1830pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1831
1832#[cfg(target_os = "fuchsia")]
1833impl fidl::endpoints::ServiceProxy for ServiceProxy {
1834    type Service = ServiceMarker;
1835
1836    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1837        Self(opener)
1838    }
1839}
1840
1841#[cfg(target_os = "fuchsia")]
1842impl ServiceProxy {
1843    pub fn connect_to_adb(&self) -> Result<DeviceProxy, fidl::Error> {
1844        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1845        self.connect_channel_to_adb(server_end)?;
1846        Ok(proxy)
1847    }
1848
1849    /// Like `connect_to_adb`, but returns a sync proxy.
1850    /// See [`Self::connect_to_adb`] for more details.
1851    pub fn connect_to_adb_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1852        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1853        self.connect_channel_to_adb(server_end)?;
1854        Ok(proxy)
1855    }
1856
1857    /// Like `connect_to_adb`, but accepts a server end.
1858    /// See [`Self::connect_to_adb`] for more details.
1859    pub fn connect_channel_to_adb(
1860        &self,
1861        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1862    ) -> Result<(), fidl::Error> {
1863        self.0.open_member("adb", server_end.into_channel())
1864    }
1865
1866    pub fn instance_name(&self) -> &str {
1867        self.0.instance_name()
1868    }
1869}
1870
1871mod internal {
1872    use super::*;
1873
1874    impl fidl::encoding::ResourceTypeMarker for DeviceStartAdbRequest {
1875        type Borrowed<'a> = &'a mut Self;
1876        fn take_or_borrow<'a>(
1877            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1878        ) -> Self::Borrowed<'a> {
1879            value
1880        }
1881    }
1882
1883    unsafe impl fidl::encoding::TypeMarker for DeviceStartAdbRequest {
1884        type Owned = Self;
1885
1886        #[inline(always)]
1887        fn inline_align(_context: fidl::encoding::Context) -> usize {
1888            4
1889        }
1890
1891        #[inline(always)]
1892        fn inline_size(_context: fidl::encoding::Context) -> usize {
1893            4
1894        }
1895    }
1896
1897    unsafe impl
1898        fidl::encoding::Encode<DeviceStartAdbRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1899        for &mut DeviceStartAdbRequest
1900    {
1901        #[inline]
1902        unsafe fn encode(
1903            self,
1904            encoder: &mut fidl::encoding::Encoder<
1905                '_,
1906                fidl::encoding::DefaultFuchsiaResourceDialect,
1907            >,
1908            offset: usize,
1909            _depth: fidl::encoding::Depth,
1910        ) -> fidl::Result<()> {
1911            encoder.debug_check_bounds::<DeviceStartAdbRequest>(offset);
1912            // Delegate to tuple encoding.
1913            fidl::encoding::Encode::<DeviceStartAdbRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1914                (
1915                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.interface),
1916                ),
1917                encoder, offset, _depth
1918            )
1919        }
1920    }
1921    unsafe impl<
1922        T0: fidl::encoding::Encode<
1923                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>>,
1924                fidl::encoding::DefaultFuchsiaResourceDialect,
1925            >,
1926    >
1927        fidl::encoding::Encode<DeviceStartAdbRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1928        for (T0,)
1929    {
1930        #[inline]
1931        unsafe fn encode(
1932            self,
1933            encoder: &mut fidl::encoding::Encoder<
1934                '_,
1935                fidl::encoding::DefaultFuchsiaResourceDialect,
1936            >,
1937            offset: usize,
1938            depth: fidl::encoding::Depth,
1939        ) -> fidl::Result<()> {
1940            encoder.debug_check_bounds::<DeviceStartAdbRequest>(offset);
1941            // Zero out padding regions. There's no need to apply masks
1942            // because the unmasked parts will be overwritten by fields.
1943            // Write the fields.
1944            self.0.encode(encoder, offset + 0, depth)?;
1945            Ok(())
1946        }
1947    }
1948
1949    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1950        for DeviceStartAdbRequest
1951    {
1952        #[inline(always)]
1953        fn new_empty() -> Self {
1954            Self {
1955                interface: fidl::new_empty!(
1956                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>>,
1957                    fidl::encoding::DefaultFuchsiaResourceDialect
1958                ),
1959            }
1960        }
1961
1962        #[inline]
1963        unsafe fn decode(
1964            &mut self,
1965            decoder: &mut fidl::encoding::Decoder<
1966                '_,
1967                fidl::encoding::DefaultFuchsiaResourceDialect,
1968            >,
1969            offset: usize,
1970            _depth: fidl::encoding::Depth,
1971        ) -> fidl::Result<()> {
1972            decoder.debug_check_bounds::<Self>(offset);
1973            // Verify that padding bytes are zero.
1974            fidl::decode!(
1975                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>>,
1976                fidl::encoding::DefaultFuchsiaResourceDialect,
1977                &mut self.interface,
1978                decoder,
1979                offset + 0,
1980                _depth
1981            )?;
1982            Ok(())
1983        }
1984    }
1985
1986    impl fidl::encoding::ResourceTypeMarker for ProviderConnectToServiceRequest {
1987        type Borrowed<'a> = &'a mut Self;
1988        fn take_or_borrow<'a>(
1989            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1990        ) -> Self::Borrowed<'a> {
1991            value
1992        }
1993    }
1994
1995    unsafe impl fidl::encoding::TypeMarker for ProviderConnectToServiceRequest {
1996        type Owned = Self;
1997
1998        #[inline(always)]
1999        fn inline_align(_context: fidl::encoding::Context) -> usize {
2000            8
2001        }
2002
2003        #[inline(always)]
2004        fn inline_size(_context: fidl::encoding::Context) -> usize {
2005            24
2006        }
2007    }
2008
2009    unsafe impl
2010        fidl::encoding::Encode<
2011            ProviderConnectToServiceRequest,
2012            fidl::encoding::DefaultFuchsiaResourceDialect,
2013        > for &mut ProviderConnectToServiceRequest
2014    {
2015        #[inline]
2016        unsafe fn encode(
2017            self,
2018            encoder: &mut fidl::encoding::Encoder<
2019                '_,
2020                fidl::encoding::DefaultFuchsiaResourceDialect,
2021            >,
2022            offset: usize,
2023            _depth: fidl::encoding::Depth,
2024        ) -> fidl::Result<()> {
2025            encoder.debug_check_bounds::<ProviderConnectToServiceRequest>(offset);
2026            // Delegate to tuple encoding.
2027            fidl::encoding::Encode::<ProviderConnectToServiceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2028                (
2029                    <fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.socket),
2030                    <fidl::encoding::Optional<fidl::encoding::BoundedString<1024>> as fidl::encoding::ValueTypeMarker>::borrow(&self.args),
2031                ),
2032                encoder, offset, _depth
2033            )
2034        }
2035    }
2036    unsafe impl<
2037        T0: fidl::encoding::Encode<
2038                fidl::encoding::HandleType<
2039                    fidl::Socket,
2040                    { fidl::ObjectType::SOCKET.into_raw() },
2041                    2147483648,
2042                >,
2043                fidl::encoding::DefaultFuchsiaResourceDialect,
2044            >,
2045        T1: fidl::encoding::Encode<
2046                fidl::encoding::Optional<fidl::encoding::BoundedString<1024>>,
2047                fidl::encoding::DefaultFuchsiaResourceDialect,
2048            >,
2049    >
2050        fidl::encoding::Encode<
2051            ProviderConnectToServiceRequest,
2052            fidl::encoding::DefaultFuchsiaResourceDialect,
2053        > for (T0, T1)
2054    {
2055        #[inline]
2056        unsafe fn encode(
2057            self,
2058            encoder: &mut fidl::encoding::Encoder<
2059                '_,
2060                fidl::encoding::DefaultFuchsiaResourceDialect,
2061            >,
2062            offset: usize,
2063            depth: fidl::encoding::Depth,
2064        ) -> fidl::Result<()> {
2065            encoder.debug_check_bounds::<ProviderConnectToServiceRequest>(offset);
2066            // Zero out padding regions. There's no need to apply masks
2067            // because the unmasked parts will be overwritten by fields.
2068            unsafe {
2069                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2070                (ptr as *mut u64).write_unaligned(0);
2071            }
2072            // Write the fields.
2073            self.0.encode(encoder, offset + 0, depth)?;
2074            self.1.encode(encoder, offset + 8, depth)?;
2075            Ok(())
2076        }
2077    }
2078
2079    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2080        for ProviderConnectToServiceRequest
2081    {
2082        #[inline(always)]
2083        fn new_empty() -> Self {
2084            Self {
2085                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2086                args: fidl::new_empty!(
2087                    fidl::encoding::Optional<fidl::encoding::BoundedString<1024>>,
2088                    fidl::encoding::DefaultFuchsiaResourceDialect
2089                ),
2090            }
2091        }
2092
2093        #[inline]
2094        unsafe fn decode(
2095            &mut self,
2096            decoder: &mut fidl::encoding::Decoder<
2097                '_,
2098                fidl::encoding::DefaultFuchsiaResourceDialect,
2099            >,
2100            offset: usize,
2101            _depth: fidl::encoding::Depth,
2102        ) -> fidl::Result<()> {
2103            decoder.debug_check_bounds::<Self>(offset);
2104            // Verify that padding bytes are zero.
2105            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2106            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2107            let mask = 0xffffffff00000000u64;
2108            let maskedval = padval & mask;
2109            if maskedval != 0 {
2110                return Err(fidl::Error::NonZeroPadding {
2111                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2112                });
2113            }
2114            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
2115            fidl::decode!(
2116                fidl::encoding::Optional<fidl::encoding::BoundedString<1024>>,
2117                fidl::encoding::DefaultFuchsiaResourceDialect,
2118                &mut self.args,
2119                decoder,
2120                offset + 8,
2121                _depth
2122            )?;
2123            Ok(())
2124        }
2125    }
2126}