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