Skip to main content

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