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