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 DeviceControlHandle {
484    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
485        self.inner.shutdown_with_epitaph(status.into())
486    }
487}
488
489impl fidl::endpoints::ControlHandle for DeviceControlHandle {
490    fn shutdown(&self) {
491        self.inner.shutdown()
492    }
493
494    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
495        self.inner.shutdown_with_epitaph(status)
496    }
497
498    fn is_closed(&self) -> bool {
499        self.inner.channel().is_closed()
500    }
501    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
502        self.inner.channel().on_closed()
503    }
504
505    #[cfg(target_os = "fuchsia")]
506    fn signal_peer(
507        &self,
508        clear_mask: zx::Signals,
509        set_mask: zx::Signals,
510    ) -> Result<(), zx_status::Status> {
511        use fidl::Peered;
512        self.inner.channel().signal_peer(clear_mask, set_mask)
513    }
514}
515
516impl DeviceControlHandle {}
517
518#[must_use = "FIDL methods require a response to be sent"]
519#[derive(Debug)]
520pub struct DeviceStartAdbResponder {
521    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
522    tx_id: u32,
523}
524
525/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
526/// if the responder is dropped without sending a response, so that the client
527/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
528impl std::ops::Drop for DeviceStartAdbResponder {
529    fn drop(&mut self) {
530        self.control_handle.shutdown();
531        // Safety: drops once, never accessed again
532        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
533    }
534}
535
536impl fidl::endpoints::Responder for DeviceStartAdbResponder {
537    type ControlHandle = DeviceControlHandle;
538
539    fn control_handle(&self) -> &DeviceControlHandle {
540        &self.control_handle
541    }
542
543    fn drop_without_shutdown(mut self) {
544        // Safety: drops once, never accessed again due to mem::forget
545        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
546        // Prevent Drop from running (which would shut down the channel)
547        std::mem::forget(self);
548    }
549}
550
551impl DeviceStartAdbResponder {
552    /// Sends a response to the FIDL transaction.
553    ///
554    /// Sets the channel to shutdown if an error occurs.
555    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
556        let _result = self.send_raw(result);
557        if _result.is_err() {
558            self.control_handle.shutdown();
559        }
560        self.drop_without_shutdown();
561        _result
562    }
563
564    /// Similar to "send" but does not shutdown the channel if an error occurs.
565    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
566        let _result = self.send_raw(result);
567        self.drop_without_shutdown();
568        _result
569    }
570
571    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
572        self.control_handle
573            .inner
574            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
575                result,
576                self.tx_id,
577                0x286c2e31de2159a5,
578                fidl::encoding::DynamicFlags::empty(),
579            )
580    }
581}
582
583#[must_use = "FIDL methods require a response to be sent"]
584#[derive(Debug)]
585pub struct DeviceStopAdbResponder {
586    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
587    tx_id: u32,
588}
589
590/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
591/// if the responder is dropped without sending a response, so that the client
592/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
593impl std::ops::Drop for DeviceStopAdbResponder {
594    fn drop(&mut self) {
595        self.control_handle.shutdown();
596        // Safety: drops once, never accessed again
597        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
598    }
599}
600
601impl fidl::endpoints::Responder for DeviceStopAdbResponder {
602    type ControlHandle = DeviceControlHandle;
603
604    fn control_handle(&self) -> &DeviceControlHandle {
605        &self.control_handle
606    }
607
608    fn drop_without_shutdown(mut self) {
609        // Safety: drops once, never accessed again due to mem::forget
610        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
611        // Prevent Drop from running (which would shut down the channel)
612        std::mem::forget(self);
613    }
614}
615
616impl DeviceStopAdbResponder {
617    /// Sends a response to the FIDL transaction.
618    ///
619    /// Sets the channel to shutdown if an error occurs.
620    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
621        let _result = self.send_raw(result);
622        if _result.is_err() {
623            self.control_handle.shutdown();
624        }
625        self.drop_without_shutdown();
626        _result
627    }
628
629    /// Similar to "send" but does not shutdown the channel if an error occurs.
630    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
631        let _result = self.send_raw(result);
632        self.drop_without_shutdown();
633        _result
634    }
635
636    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
637        self.control_handle
638            .inner
639            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
640                result,
641                self.tx_id,
642                0x6d7d1816750fd3d0,
643                fidl::encoding::DynamicFlags::empty(),
644            )
645    }
646}
647
648#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
649pub struct ProviderMarker;
650
651impl fidl::endpoints::ProtocolMarker for ProviderMarker {
652    type Proxy = ProviderProxy;
653    type RequestStream = ProviderRequestStream;
654    #[cfg(target_os = "fuchsia")]
655    type SynchronousProxy = ProviderSynchronousProxy;
656
657    const DEBUG_NAME: &'static str = "fuchsia.hardware.adb.Provider";
658}
659impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
660pub type ProviderConnectToServiceResult = Result<(), i32>;
661
662pub trait ProviderProxyInterface: Send + Sync {
663    type ConnectToServiceResponseFut: std::future::Future<Output = Result<ProviderConnectToServiceResult, fidl::Error>>
664        + Send;
665    fn r#connect_to_service(
666        &self,
667        socket: fidl::Socket,
668        args: Option<&str>,
669    ) -> Self::ConnectToServiceResponseFut;
670}
671#[derive(Debug)]
672#[cfg(target_os = "fuchsia")]
673pub struct ProviderSynchronousProxy {
674    client: fidl::client::sync::Client,
675}
676
677#[cfg(target_os = "fuchsia")]
678impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
679    type Proxy = ProviderProxy;
680    type Protocol = ProviderMarker;
681
682    fn from_channel(inner: fidl::Channel) -> Self {
683        Self::new(inner)
684    }
685
686    fn into_channel(self) -> fidl::Channel {
687        self.client.into_channel()
688    }
689
690    fn as_channel(&self) -> &fidl::Channel {
691        self.client.as_channel()
692    }
693}
694
695#[cfg(target_os = "fuchsia")]
696impl ProviderSynchronousProxy {
697    pub fn new(channel: fidl::Channel) -> Self {
698        Self { client: fidl::client::sync::Client::new(channel) }
699    }
700
701    pub fn into_channel(self) -> fidl::Channel {
702        self.client.into_channel()
703    }
704
705    /// Waits until an event arrives and returns it. It is safe for other
706    /// threads to make concurrent requests while waiting for an event.
707    pub fn wait_for_event(
708        &self,
709        deadline: zx::MonotonicInstant,
710    ) -> Result<ProviderEvent, fidl::Error> {
711        ProviderEvent::decode(self.client.wait_for_event::<ProviderMarker>(deadline)?)
712    }
713
714    /// Connect `socket` to the service (called in response to adb OPEN message).
715    /// `args` provides additional arguments passed by the client if any.
716    pub fn r#connect_to_service(
717        &self,
718        mut socket: fidl::Socket,
719        mut args: Option<&str>,
720        ___deadline: zx::MonotonicInstant,
721    ) -> Result<ProviderConnectToServiceResult, fidl::Error> {
722        let _response = self.client.send_query::<
723            ProviderConnectToServiceRequest,
724            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
725            ProviderMarker,
726        >(
727            (socket, args,),
728            0x303e4a312d85292b,
729            fidl::encoding::DynamicFlags::empty(),
730            ___deadline,
731        )?;
732        Ok(_response.map(|x| x))
733    }
734}
735
736#[cfg(target_os = "fuchsia")]
737impl From<ProviderSynchronousProxy> for zx::NullableHandle {
738    fn from(value: ProviderSynchronousProxy) -> Self {
739        value.into_channel().into()
740    }
741}
742
743#[cfg(target_os = "fuchsia")]
744impl From<fidl::Channel> for ProviderSynchronousProxy {
745    fn from(value: fidl::Channel) -> Self {
746        Self::new(value)
747    }
748}
749
750#[cfg(target_os = "fuchsia")]
751impl fidl::endpoints::FromClient for ProviderSynchronousProxy {
752    type Protocol = ProviderMarker;
753
754    fn from_client(value: fidl::endpoints::ClientEnd<ProviderMarker>) -> Self {
755        Self::new(value.into_channel())
756    }
757}
758
759#[derive(Debug, Clone)]
760pub struct ProviderProxy {
761    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
762}
763
764impl fidl::endpoints::Proxy for ProviderProxy {
765    type Protocol = ProviderMarker;
766
767    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
768        Self::new(inner)
769    }
770
771    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
772        self.client.into_channel().map_err(|client| Self { client })
773    }
774
775    fn as_channel(&self) -> &::fidl::AsyncChannel {
776        self.client.as_channel()
777    }
778}
779
780impl ProviderProxy {
781    /// Create a new Proxy for fuchsia.hardware.adb/Provider.
782    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
783        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
784        Self { client: fidl::client::Client::new(channel, protocol_name) }
785    }
786
787    /// Get a Stream of events from the remote end of the protocol.
788    ///
789    /// # Panics
790    ///
791    /// Panics if the event stream was already taken.
792    pub fn take_event_stream(&self) -> ProviderEventStream {
793        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
794    }
795
796    /// Connect `socket` to the service (called in response to adb OPEN message).
797    /// `args` provides additional arguments passed by the client if any.
798    pub fn r#connect_to_service(
799        &self,
800        mut socket: fidl::Socket,
801        mut args: Option<&str>,
802    ) -> fidl::client::QueryResponseFut<
803        ProviderConnectToServiceResult,
804        fidl::encoding::DefaultFuchsiaResourceDialect,
805    > {
806        ProviderProxyInterface::r#connect_to_service(self, socket, args)
807    }
808}
809
810impl ProviderProxyInterface for ProviderProxy {
811    type ConnectToServiceResponseFut = fidl::client::QueryResponseFut<
812        ProviderConnectToServiceResult,
813        fidl::encoding::DefaultFuchsiaResourceDialect,
814    >;
815    fn r#connect_to_service(
816        &self,
817        mut socket: fidl::Socket,
818        mut args: Option<&str>,
819    ) -> Self::ConnectToServiceResponseFut {
820        fn _decode(
821            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
822        ) -> Result<ProviderConnectToServiceResult, fidl::Error> {
823            let _response = fidl::client::decode_transaction_body::<
824                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
825                fidl::encoding::DefaultFuchsiaResourceDialect,
826                0x303e4a312d85292b,
827            >(_buf?)?;
828            Ok(_response.map(|x| x))
829        }
830        self.client.send_query_and_decode::<
831            ProviderConnectToServiceRequest,
832            ProviderConnectToServiceResult,
833        >(
834            (socket, args,),
835            0x303e4a312d85292b,
836            fidl::encoding::DynamicFlags::empty(),
837            _decode,
838        )
839    }
840}
841
842pub struct ProviderEventStream {
843    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
844}
845
846impl std::marker::Unpin for ProviderEventStream {}
847
848impl futures::stream::FusedStream for ProviderEventStream {
849    fn is_terminated(&self) -> bool {
850        self.event_receiver.is_terminated()
851    }
852}
853
854impl futures::Stream for ProviderEventStream {
855    type Item = Result<ProviderEvent, fidl::Error>;
856
857    fn poll_next(
858        mut self: std::pin::Pin<&mut Self>,
859        cx: &mut std::task::Context<'_>,
860    ) -> std::task::Poll<Option<Self::Item>> {
861        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
862            &mut self.event_receiver,
863            cx
864        )?) {
865            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
866            None => std::task::Poll::Ready(None),
867        }
868    }
869}
870
871#[derive(Debug)]
872pub enum ProviderEvent {}
873
874impl ProviderEvent {
875    /// Decodes a message buffer as a [`ProviderEvent`].
876    fn decode(
877        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
878    ) -> Result<ProviderEvent, fidl::Error> {
879        let (bytes, _handles) = buf.split_mut();
880        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
881        debug_assert_eq!(tx_header.tx_id, 0);
882        match tx_header.ordinal {
883            _ => Err(fidl::Error::UnknownOrdinal {
884                ordinal: tx_header.ordinal,
885                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
886            }),
887        }
888    }
889}
890
891/// A Stream of incoming requests for fuchsia.hardware.adb/Provider.
892pub struct ProviderRequestStream {
893    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
894    is_terminated: bool,
895}
896
897impl std::marker::Unpin for ProviderRequestStream {}
898
899impl futures::stream::FusedStream for ProviderRequestStream {
900    fn is_terminated(&self) -> bool {
901        self.is_terminated
902    }
903}
904
905impl fidl::endpoints::RequestStream for ProviderRequestStream {
906    type Protocol = ProviderMarker;
907    type ControlHandle = ProviderControlHandle;
908
909    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
910        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
911    }
912
913    fn control_handle(&self) -> Self::ControlHandle {
914        ProviderControlHandle { inner: self.inner.clone() }
915    }
916
917    fn into_inner(
918        self,
919    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
920    {
921        (self.inner, self.is_terminated)
922    }
923
924    fn from_inner(
925        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
926        is_terminated: bool,
927    ) -> Self {
928        Self { inner, is_terminated }
929    }
930}
931
932impl futures::Stream for ProviderRequestStream {
933    type Item = Result<ProviderRequest, fidl::Error>;
934
935    fn poll_next(
936        mut self: std::pin::Pin<&mut Self>,
937        cx: &mut std::task::Context<'_>,
938    ) -> std::task::Poll<Option<Self::Item>> {
939        let this = &mut *self;
940        if this.inner.check_shutdown(cx) {
941            this.is_terminated = true;
942            return std::task::Poll::Ready(None);
943        }
944        if this.is_terminated {
945            panic!("polled ProviderRequestStream after completion");
946        }
947        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
948            |bytes, handles| {
949                match this.inner.channel().read_etc(cx, bytes, handles) {
950                    std::task::Poll::Ready(Ok(())) => {}
951                    std::task::Poll::Pending => return std::task::Poll::Pending,
952                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
953                        this.is_terminated = true;
954                        return std::task::Poll::Ready(None);
955                    }
956                    std::task::Poll::Ready(Err(e)) => {
957                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
958                            e.into(),
959                        ))));
960                    }
961                }
962
963                // A message has been received from the channel
964                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
965
966                std::task::Poll::Ready(Some(match header.ordinal {
967                    0x303e4a312d85292b => {
968                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
969                        let mut req = fidl::new_empty!(
970                            ProviderConnectToServiceRequest,
971                            fidl::encoding::DefaultFuchsiaResourceDialect
972                        );
973                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderConnectToServiceRequest>(&header, _body_bytes, handles, &mut req)?;
974                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
975                        Ok(ProviderRequest::ConnectToService {
976                            socket: req.socket,
977                            args: req.args,
978
979                            responder: ProviderConnectToServiceResponder {
980                                control_handle: std::mem::ManuallyDrop::new(control_handle),
981                                tx_id: header.tx_id,
982                            },
983                        })
984                    }
985                    _ => Err(fidl::Error::UnknownOrdinal {
986                        ordinal: header.ordinal,
987                        protocol_name:
988                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
989                    }),
990                }))
991            },
992        )
993    }
994}
995
996/// A Provider is a provider for one service which interacts with the adb component to implement
997/// a particular service such as shell, file-sync, or ffx.
998/// The interaction between the adb component and a service Provider (e.g. shell) is as follows:
999///    - adb component is started eagerly by core.cml. Note that the adb component does not
1000///      implement any adb FIDL protocols.
1001///    - When a request for a service (e.g. shell) comes in, adb daemon starts up a lazy
1002///      component for the corresponding requested service (adb-shell-component) exposing the
1003///      Provider protocol and calls ConnectToService, creating a connection between the adb
1004///      component and the service provider component (adb-shell-component) through the socket.
1005///    - If the service (adb-shell-component) has already been started, it opens that service
1006///      and hands it the socket.
1007///    - adb component and service Provider component (adb-shell) communicate over the socket.
1008#[derive(Debug)]
1009pub enum ProviderRequest {
1010    /// Connect `socket` to the service (called in response to adb OPEN message).
1011    /// `args` provides additional arguments passed by the client if any.
1012    ConnectToService {
1013        socket: fidl::Socket,
1014        args: Option<String>,
1015        responder: ProviderConnectToServiceResponder,
1016    },
1017}
1018
1019impl ProviderRequest {
1020    #[allow(irrefutable_let_patterns)]
1021    pub fn into_connect_to_service(
1022        self,
1023    ) -> Option<(fidl::Socket, Option<String>, ProviderConnectToServiceResponder)> {
1024        if let ProviderRequest::ConnectToService { socket, args, responder } = self {
1025            Some((socket, args, responder))
1026        } else {
1027            None
1028        }
1029    }
1030
1031    /// Name of the method defined in FIDL
1032    pub fn method_name(&self) -> &'static str {
1033        match *self {
1034            ProviderRequest::ConnectToService { .. } => "connect_to_service",
1035        }
1036    }
1037}
1038
1039#[derive(Debug, Clone)]
1040pub struct ProviderControlHandle {
1041    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1042}
1043
1044impl ProviderControlHandle {
1045    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1046        self.inner.shutdown_with_epitaph(status.into())
1047    }
1048}
1049
1050impl fidl::endpoints::ControlHandle for ProviderControlHandle {
1051    fn shutdown(&self) {
1052        self.inner.shutdown()
1053    }
1054
1055    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1056        self.inner.shutdown_with_epitaph(status)
1057    }
1058
1059    fn is_closed(&self) -> bool {
1060        self.inner.channel().is_closed()
1061    }
1062    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1063        self.inner.channel().on_closed()
1064    }
1065
1066    #[cfg(target_os = "fuchsia")]
1067    fn signal_peer(
1068        &self,
1069        clear_mask: zx::Signals,
1070        set_mask: zx::Signals,
1071    ) -> Result<(), zx_status::Status> {
1072        use fidl::Peered;
1073        self.inner.channel().signal_peer(clear_mask, set_mask)
1074    }
1075}
1076
1077impl ProviderControlHandle {}
1078
1079#[must_use = "FIDL methods require a response to be sent"]
1080#[derive(Debug)]
1081pub struct ProviderConnectToServiceResponder {
1082    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
1083    tx_id: u32,
1084}
1085
1086/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
1087/// if the responder is dropped without sending a response, so that the client
1088/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1089impl std::ops::Drop for ProviderConnectToServiceResponder {
1090    fn drop(&mut self) {
1091        self.control_handle.shutdown();
1092        // Safety: drops once, never accessed again
1093        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1094    }
1095}
1096
1097impl fidl::endpoints::Responder for ProviderConnectToServiceResponder {
1098    type ControlHandle = ProviderControlHandle;
1099
1100    fn control_handle(&self) -> &ProviderControlHandle {
1101        &self.control_handle
1102    }
1103
1104    fn drop_without_shutdown(mut self) {
1105        // Safety: drops once, never accessed again due to mem::forget
1106        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1107        // Prevent Drop from running (which would shut down the channel)
1108        std::mem::forget(self);
1109    }
1110}
1111
1112impl ProviderConnectToServiceResponder {
1113    /// Sends a response to the FIDL transaction.
1114    ///
1115    /// Sets the channel to shutdown if an error occurs.
1116    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1117        let _result = self.send_raw(result);
1118        if _result.is_err() {
1119            self.control_handle.shutdown();
1120        }
1121        self.drop_without_shutdown();
1122        _result
1123    }
1124
1125    /// Similar to "send" but does not shutdown the channel if an error occurs.
1126    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1127        let _result = self.send_raw(result);
1128        self.drop_without_shutdown();
1129        _result
1130    }
1131
1132    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1133        self.control_handle
1134            .inner
1135            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1136                result,
1137                self.tx_id,
1138                0x303e4a312d85292b,
1139                fidl::encoding::DynamicFlags::empty(),
1140            )
1141    }
1142}
1143
1144#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1145pub struct StateControllerMarker;
1146
1147impl fidl::endpoints::ProtocolMarker for StateControllerMarker {
1148    type Proxy = StateControllerProxy;
1149    type RequestStream = StateControllerRequestStream;
1150    #[cfg(target_os = "fuchsia")]
1151    type SynchronousProxy = StateControllerSynchronousProxy;
1152
1153    const DEBUG_NAME: &'static str = "fuchsia.hardware.adb.StateController";
1154}
1155impl fidl::endpoints::DiscoverableProtocolMarker for StateControllerMarker {}
1156pub type StateControllerSetSystemTypeResult = Result<(), i32>;
1157
1158pub trait StateControllerProxyInterface: Send + Sync {
1159    type SetSystemTypeResponseFut: std::future::Future<Output = Result<StateControllerSetSystemTypeResult, fidl::Error>>
1160        + Send;
1161    fn r#set_system_type(&self, system_type: SystemType) -> Self::SetSystemTypeResponseFut;
1162}
1163#[derive(Debug)]
1164#[cfg(target_os = "fuchsia")]
1165pub struct StateControllerSynchronousProxy {
1166    client: fidl::client::sync::Client,
1167}
1168
1169#[cfg(target_os = "fuchsia")]
1170impl fidl::endpoints::SynchronousProxy for StateControllerSynchronousProxy {
1171    type Proxy = StateControllerProxy;
1172    type Protocol = StateControllerMarker;
1173
1174    fn from_channel(inner: fidl::Channel) -> Self {
1175        Self::new(inner)
1176    }
1177
1178    fn into_channel(self) -> fidl::Channel {
1179        self.client.into_channel()
1180    }
1181
1182    fn as_channel(&self) -> &fidl::Channel {
1183        self.client.as_channel()
1184    }
1185}
1186
1187#[cfg(target_os = "fuchsia")]
1188impl StateControllerSynchronousProxy {
1189    pub fn new(channel: fidl::Channel) -> Self {
1190        Self { client: fidl::client::sync::Client::new(channel) }
1191    }
1192
1193    pub fn into_channel(self) -> fidl::Channel {
1194        self.client.into_channel()
1195    }
1196
1197    /// Waits until an event arrives and returns it. It is safe for other
1198    /// threads to make concurrent requests while waiting for an event.
1199    pub fn wait_for_event(
1200        &self,
1201        deadline: zx::MonotonicInstant,
1202    ) -> Result<StateControllerEvent, fidl::Error> {
1203        StateControllerEvent::decode(self.client.wait_for_event::<StateControllerMarker>(deadline)?)
1204    }
1205
1206    /// Set the current system type of ADB (e.g. device, recovery, sideload).
1207    /// This method updates the system type string sent to the host and initiates a reset
1208    /// of the USB ADB connection so that the host can discover the device again with the
1209    /// new system type state.
1210    pub fn r#set_system_type(
1211        &self,
1212        mut system_type: SystemType,
1213        ___deadline: zx::MonotonicInstant,
1214    ) -> Result<StateControllerSetSystemTypeResult, fidl::Error> {
1215        let _response = self.client.send_query::<
1216            StateControllerSetSystemTypeRequest,
1217            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1218            StateControllerMarker,
1219        >(
1220            (system_type,),
1221            0xa40a1100522d82e,
1222            fidl::encoding::DynamicFlags::FLEXIBLE,
1223            ___deadline,
1224        )?
1225        .into_result::<StateControllerMarker>("set_system_type")?;
1226        Ok(_response.map(|x| x))
1227    }
1228}
1229
1230#[cfg(target_os = "fuchsia")]
1231impl From<StateControllerSynchronousProxy> for zx::NullableHandle {
1232    fn from(value: StateControllerSynchronousProxy) -> Self {
1233        value.into_channel().into()
1234    }
1235}
1236
1237#[cfg(target_os = "fuchsia")]
1238impl From<fidl::Channel> for StateControllerSynchronousProxy {
1239    fn from(value: fidl::Channel) -> Self {
1240        Self::new(value)
1241    }
1242}
1243
1244#[cfg(target_os = "fuchsia")]
1245impl fidl::endpoints::FromClient for StateControllerSynchronousProxy {
1246    type Protocol = StateControllerMarker;
1247
1248    fn from_client(value: fidl::endpoints::ClientEnd<StateControllerMarker>) -> Self {
1249        Self::new(value.into_channel())
1250    }
1251}
1252
1253#[derive(Debug, Clone)]
1254pub struct StateControllerProxy {
1255    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1256}
1257
1258impl fidl::endpoints::Proxy for StateControllerProxy {
1259    type Protocol = StateControllerMarker;
1260
1261    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1262        Self::new(inner)
1263    }
1264
1265    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1266        self.client.into_channel().map_err(|client| Self { client })
1267    }
1268
1269    fn as_channel(&self) -> &::fidl::AsyncChannel {
1270        self.client.as_channel()
1271    }
1272}
1273
1274impl StateControllerProxy {
1275    /// Create a new Proxy for fuchsia.hardware.adb/StateController.
1276    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1277        let protocol_name = <StateControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1278        Self { client: fidl::client::Client::new(channel, protocol_name) }
1279    }
1280
1281    /// Get a Stream of events from the remote end of the protocol.
1282    ///
1283    /// # Panics
1284    ///
1285    /// Panics if the event stream was already taken.
1286    pub fn take_event_stream(&self) -> StateControllerEventStream {
1287        StateControllerEventStream { event_receiver: self.client.take_event_receiver() }
1288    }
1289
1290    /// Set the current system type of ADB (e.g. device, recovery, sideload).
1291    /// This method updates the system type string sent to the host and initiates a reset
1292    /// of the USB ADB connection so that the host can discover the device again with the
1293    /// new system type state.
1294    pub fn r#set_system_type(
1295        &self,
1296        mut system_type: SystemType,
1297    ) -> fidl::client::QueryResponseFut<
1298        StateControllerSetSystemTypeResult,
1299        fidl::encoding::DefaultFuchsiaResourceDialect,
1300    > {
1301        StateControllerProxyInterface::r#set_system_type(self, system_type)
1302    }
1303}
1304
1305impl StateControllerProxyInterface for StateControllerProxy {
1306    type SetSystemTypeResponseFut = fidl::client::QueryResponseFut<
1307        StateControllerSetSystemTypeResult,
1308        fidl::encoding::DefaultFuchsiaResourceDialect,
1309    >;
1310    fn r#set_system_type(&self, mut system_type: SystemType) -> Self::SetSystemTypeResponseFut {
1311        fn _decode(
1312            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1313        ) -> Result<StateControllerSetSystemTypeResult, fidl::Error> {
1314            let _response = fidl::client::decode_transaction_body::<
1315                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1316                fidl::encoding::DefaultFuchsiaResourceDialect,
1317                0xa40a1100522d82e,
1318            >(_buf?)?
1319            .into_result::<StateControllerMarker>("set_system_type")?;
1320            Ok(_response.map(|x| x))
1321        }
1322        self.client.send_query_and_decode::<
1323            StateControllerSetSystemTypeRequest,
1324            StateControllerSetSystemTypeResult,
1325        >(
1326            (system_type,),
1327            0xa40a1100522d82e,
1328            fidl::encoding::DynamicFlags::FLEXIBLE,
1329            _decode,
1330        )
1331    }
1332}
1333
1334pub struct StateControllerEventStream {
1335    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1336}
1337
1338impl std::marker::Unpin for StateControllerEventStream {}
1339
1340impl futures::stream::FusedStream for StateControllerEventStream {
1341    fn is_terminated(&self) -> bool {
1342        self.event_receiver.is_terminated()
1343    }
1344}
1345
1346impl futures::Stream for StateControllerEventStream {
1347    type Item = Result<StateControllerEvent, fidl::Error>;
1348
1349    fn poll_next(
1350        mut self: std::pin::Pin<&mut Self>,
1351        cx: &mut std::task::Context<'_>,
1352    ) -> std::task::Poll<Option<Self::Item>> {
1353        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1354            &mut self.event_receiver,
1355            cx
1356        )?) {
1357            Some(buf) => std::task::Poll::Ready(Some(StateControllerEvent::decode(buf))),
1358            None => std::task::Poll::Ready(None),
1359        }
1360    }
1361}
1362
1363#[derive(Debug)]
1364pub enum StateControllerEvent {
1365    #[non_exhaustive]
1366    _UnknownEvent {
1367        /// Ordinal of the event that was sent.
1368        ordinal: u64,
1369    },
1370}
1371
1372impl StateControllerEvent {
1373    /// Decodes a message buffer as a [`StateControllerEvent`].
1374    fn decode(
1375        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1376    ) -> Result<StateControllerEvent, fidl::Error> {
1377        let (bytes, _handles) = buf.split_mut();
1378        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1379        debug_assert_eq!(tx_header.tx_id, 0);
1380        match tx_header.ordinal {
1381            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1382                Ok(StateControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1383            }
1384            _ => Err(fidl::Error::UnknownOrdinal {
1385                ordinal: tx_header.ordinal,
1386                protocol_name:
1387                    <StateControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1388            }),
1389        }
1390    }
1391}
1392
1393/// A Stream of incoming requests for fuchsia.hardware.adb/StateController.
1394pub struct StateControllerRequestStream {
1395    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1396    is_terminated: bool,
1397}
1398
1399impl std::marker::Unpin for StateControllerRequestStream {}
1400
1401impl futures::stream::FusedStream for StateControllerRequestStream {
1402    fn is_terminated(&self) -> bool {
1403        self.is_terminated
1404    }
1405}
1406
1407impl fidl::endpoints::RequestStream for StateControllerRequestStream {
1408    type Protocol = StateControllerMarker;
1409    type ControlHandle = StateControllerControlHandle;
1410
1411    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1412        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1413    }
1414
1415    fn control_handle(&self) -> Self::ControlHandle {
1416        StateControllerControlHandle { inner: self.inner.clone() }
1417    }
1418
1419    fn into_inner(
1420        self,
1421    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1422    {
1423        (self.inner, self.is_terminated)
1424    }
1425
1426    fn from_inner(
1427        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1428        is_terminated: bool,
1429    ) -> Self {
1430        Self { inner, is_terminated }
1431    }
1432}
1433
1434impl futures::Stream for StateControllerRequestStream {
1435    type Item = Result<StateControllerRequest, fidl::Error>;
1436
1437    fn poll_next(
1438        mut self: std::pin::Pin<&mut Self>,
1439        cx: &mut std::task::Context<'_>,
1440    ) -> std::task::Poll<Option<Self::Item>> {
1441        let this = &mut *self;
1442        if this.inner.check_shutdown(cx) {
1443            this.is_terminated = true;
1444            return std::task::Poll::Ready(None);
1445        }
1446        if this.is_terminated {
1447            panic!("polled StateControllerRequestStream after completion");
1448        }
1449        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1450            |bytes, handles| {
1451                match this.inner.channel().read_etc(cx, bytes, handles) {
1452                    std::task::Poll::Ready(Ok(())) => {}
1453                    std::task::Poll::Pending => return std::task::Poll::Pending,
1454                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1455                        this.is_terminated = true;
1456                        return std::task::Poll::Ready(None);
1457                    }
1458                    std::task::Poll::Ready(Err(e)) => {
1459                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1460                            e.into(),
1461                        ))));
1462                    }
1463                }
1464
1465                // A message has been received from the channel
1466                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1467
1468                std::task::Poll::Ready(Some(match header.ordinal {
1469                    0xa40a1100522d82e => {
1470                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1471                        let mut req = fidl::new_empty!(
1472                            StateControllerSetSystemTypeRequest,
1473                            fidl::encoding::DefaultFuchsiaResourceDialect
1474                        );
1475                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateControllerSetSystemTypeRequest>(&header, _body_bytes, handles, &mut req)?;
1476                        let control_handle =
1477                            StateControllerControlHandle { inner: this.inner.clone() };
1478                        Ok(StateControllerRequest::SetSystemType {
1479                            system_type: req.system_type,
1480
1481                            responder: StateControllerSetSystemTypeResponder {
1482                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1483                                tx_id: header.tx_id,
1484                            },
1485                        })
1486                    }
1487                    _ if header.tx_id == 0
1488                        && header
1489                            .dynamic_flags()
1490                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1491                    {
1492                        Ok(StateControllerRequest::_UnknownMethod {
1493                            ordinal: header.ordinal,
1494                            control_handle: StateControllerControlHandle {
1495                                inner: this.inner.clone(),
1496                            },
1497                            method_type: fidl::MethodType::OneWay,
1498                        })
1499                    }
1500                    _ if header
1501                        .dynamic_flags()
1502                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1503                    {
1504                        this.inner.send_framework_err(
1505                            fidl::encoding::FrameworkErr::UnknownMethod,
1506                            header.tx_id,
1507                            header.ordinal,
1508                            header.dynamic_flags(),
1509                            (bytes, handles),
1510                        )?;
1511                        Ok(StateControllerRequest::_UnknownMethod {
1512                            ordinal: header.ordinal,
1513                            control_handle: StateControllerControlHandle {
1514                                inner: this.inner.clone(),
1515                            },
1516                            method_type: fidl::MethodType::TwoWay,
1517                        })
1518                    }
1519                    _ => Err(fidl::Error::UnknownOrdinal {
1520                        ordinal: header.ordinal,
1521                        protocol_name:
1522                            <StateControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1523                    }),
1524                }))
1525            },
1526        )
1527    }
1528}
1529
1530/// Control the state of ADB.
1531#[derive(Debug)]
1532pub enum StateControllerRequest {
1533    /// Set the current system type of ADB (e.g. device, recovery, sideload).
1534    /// This method updates the system type string sent to the host and initiates a reset
1535    /// of the USB ADB connection so that the host can discover the device again with the
1536    /// new system type state.
1537    SetSystemType { system_type: SystemType, responder: StateControllerSetSystemTypeResponder },
1538    /// An interaction was received which does not match any known method.
1539    #[non_exhaustive]
1540    _UnknownMethod {
1541        /// Ordinal of the method that was called.
1542        ordinal: u64,
1543        control_handle: StateControllerControlHandle,
1544        method_type: fidl::MethodType,
1545    },
1546}
1547
1548impl StateControllerRequest {
1549    #[allow(irrefutable_let_patterns)]
1550    pub fn into_set_system_type(
1551        self,
1552    ) -> Option<(SystemType, StateControllerSetSystemTypeResponder)> {
1553        if let StateControllerRequest::SetSystemType { system_type, responder } = self {
1554            Some((system_type, responder))
1555        } else {
1556            None
1557        }
1558    }
1559
1560    /// Name of the method defined in FIDL
1561    pub fn method_name(&self) -> &'static str {
1562        match *self {
1563            StateControllerRequest::SetSystemType { .. } => "set_system_type",
1564            StateControllerRequest::_UnknownMethod {
1565                method_type: fidl::MethodType::OneWay,
1566                ..
1567            } => "unknown one-way method",
1568            StateControllerRequest::_UnknownMethod {
1569                method_type: fidl::MethodType::TwoWay,
1570                ..
1571            } => "unknown two-way method",
1572        }
1573    }
1574}
1575
1576#[derive(Debug, Clone)]
1577pub struct StateControllerControlHandle {
1578    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1579}
1580
1581impl StateControllerControlHandle {
1582    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1583        self.inner.shutdown_with_epitaph(status.into())
1584    }
1585}
1586
1587impl fidl::endpoints::ControlHandle for StateControllerControlHandle {
1588    fn shutdown(&self) {
1589        self.inner.shutdown()
1590    }
1591
1592    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1593        self.inner.shutdown_with_epitaph(status)
1594    }
1595
1596    fn is_closed(&self) -> bool {
1597        self.inner.channel().is_closed()
1598    }
1599    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1600        self.inner.channel().on_closed()
1601    }
1602
1603    #[cfg(target_os = "fuchsia")]
1604    fn signal_peer(
1605        &self,
1606        clear_mask: zx::Signals,
1607        set_mask: zx::Signals,
1608    ) -> Result<(), zx_status::Status> {
1609        use fidl::Peered;
1610        self.inner.channel().signal_peer(clear_mask, set_mask)
1611    }
1612}
1613
1614impl StateControllerControlHandle {}
1615
1616#[must_use = "FIDL methods require a response to be sent"]
1617#[derive(Debug)]
1618pub struct StateControllerSetSystemTypeResponder {
1619    control_handle: std::mem::ManuallyDrop<StateControllerControlHandle>,
1620    tx_id: u32,
1621}
1622
1623/// Set the the channel to be shutdown (see [`StateControllerControlHandle::shutdown`])
1624/// if the responder is dropped without sending a response, so that the client
1625/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1626impl std::ops::Drop for StateControllerSetSystemTypeResponder {
1627    fn drop(&mut self) {
1628        self.control_handle.shutdown();
1629        // Safety: drops once, never accessed again
1630        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1631    }
1632}
1633
1634impl fidl::endpoints::Responder for StateControllerSetSystemTypeResponder {
1635    type ControlHandle = StateControllerControlHandle;
1636
1637    fn control_handle(&self) -> &StateControllerControlHandle {
1638        &self.control_handle
1639    }
1640
1641    fn drop_without_shutdown(mut self) {
1642        // Safety: drops once, never accessed again due to mem::forget
1643        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1644        // Prevent Drop from running (which would shut down the channel)
1645        std::mem::forget(self);
1646    }
1647}
1648
1649impl StateControllerSetSystemTypeResponder {
1650    /// Sends a response to the FIDL transaction.
1651    ///
1652    /// Sets the channel to shutdown if an error occurs.
1653    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1654        let _result = self.send_raw(result);
1655        if _result.is_err() {
1656            self.control_handle.shutdown();
1657        }
1658        self.drop_without_shutdown();
1659        _result
1660    }
1661
1662    /// Similar to "send" but does not shutdown the channel if an error occurs.
1663    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1664        let _result = self.send_raw(result);
1665        self.drop_without_shutdown();
1666        _result
1667    }
1668
1669    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1670        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1671            fidl::encoding::EmptyStruct,
1672            i32,
1673        >>(
1674            fidl::encoding::FlexibleResult::new(result),
1675            self.tx_id,
1676            0xa40a1100522d82e,
1677            fidl::encoding::DynamicFlags::FLEXIBLE,
1678        )
1679    }
1680}
1681
1682#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1683pub struct UsbAdbImpl_Marker;
1684
1685impl fidl::endpoints::ProtocolMarker for UsbAdbImpl_Marker {
1686    type Proxy = UsbAdbImpl_Proxy;
1687    type RequestStream = UsbAdbImpl_RequestStream;
1688    #[cfg(target_os = "fuchsia")]
1689    type SynchronousProxy = UsbAdbImpl_SynchronousProxy;
1690
1691    const DEBUG_NAME: &'static str = "(anonymous) UsbAdbImpl_";
1692}
1693pub type UsbAdbImplQueueTxResult = Result<(), i32>;
1694pub type UsbAdbImplReceiveResult = Result<Vec<u8>, i32>;
1695
1696pub trait UsbAdbImpl_ProxyInterface: Send + Sync {
1697    type QueueTxResponseFut: std::future::Future<Output = Result<UsbAdbImplQueueTxResult, fidl::Error>>
1698        + Send;
1699    fn r#queue_tx(&self, data: &[u8]) -> Self::QueueTxResponseFut;
1700    type ReceiveResponseFut: std::future::Future<Output = Result<UsbAdbImplReceiveResult, fidl::Error>>
1701        + Send;
1702    fn r#receive(&self) -> Self::ReceiveResponseFut;
1703}
1704#[derive(Debug)]
1705#[cfg(target_os = "fuchsia")]
1706pub struct UsbAdbImpl_SynchronousProxy {
1707    client: fidl::client::sync::Client,
1708}
1709
1710#[cfg(target_os = "fuchsia")]
1711impl fidl::endpoints::SynchronousProxy for UsbAdbImpl_SynchronousProxy {
1712    type Proxy = UsbAdbImpl_Proxy;
1713    type Protocol = UsbAdbImpl_Marker;
1714
1715    fn from_channel(inner: fidl::Channel) -> Self {
1716        Self::new(inner)
1717    }
1718
1719    fn into_channel(self) -> fidl::Channel {
1720        self.client.into_channel()
1721    }
1722
1723    fn as_channel(&self) -> &fidl::Channel {
1724        self.client.as_channel()
1725    }
1726}
1727
1728#[cfg(target_os = "fuchsia")]
1729impl UsbAdbImpl_SynchronousProxy {
1730    pub fn new(channel: fidl::Channel) -> Self {
1731        Self { client: fidl::client::sync::Client::new(channel) }
1732    }
1733
1734    pub fn into_channel(self) -> fidl::Channel {
1735        self.client.into_channel()
1736    }
1737
1738    /// Waits until an event arrives and returns it. It is safe for other
1739    /// threads to make concurrent requests while waiting for an event.
1740    pub fn wait_for_event(
1741        &self,
1742        deadline: zx::MonotonicInstant,
1743    ) -> Result<UsbAdbImpl_Event, fidl::Error> {
1744        UsbAdbImpl_Event::decode(self.client.wait_for_event::<UsbAdbImpl_Marker>(deadline)?)
1745    }
1746
1747    /// Request transmission of the packet in |data|.
1748    ///
1749    /// Return status indicates transmission result:
1750    ///   ZX_OK: Packet has been transmitted over USB to the host.
1751    ///   ZX_ERR_INVALID_ARGS: |data| is empty.
1752    ///   ZX_ERR_BAD_STATE: USB ADB device is not in an online or waiting state (e.g. stopping).
1753    ///   ZX_ERR_IO: Low-level transport error submitting request to the USB endpoint.
1754    ///   ZX_ERR_CANCELED: Transmission was canceled prior to completion (e.g. driver reset or teardown).
1755    pub fn r#queue_tx(
1756        &self,
1757        mut data: &[u8],
1758        ___deadline: zx::MonotonicInstant,
1759    ) -> Result<UsbAdbImplQueueTxResult, fidl::Error> {
1760        let _response = self.client.send_query::<
1761            UsbAdbImplQueueTxRequest,
1762            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1763            UsbAdbImpl_Marker,
1764        >(
1765            (data,),
1766            0x4c0af0efa9701dc9,
1767            fidl::encoding::DynamicFlags::empty(),
1768            ___deadline,
1769        )?;
1770        Ok(_response.map(|x| x))
1771    }
1772
1773    /// Request to receive data. This method ensures flow control by allowing the client to queue
1774    /// |Receive| requests proactively. The driver will complete the requests only when data is
1775    /// available.
1776    ///
1777    /// Return data or error.
1778    ///    ZX_OK: Success. data is valid.
1779    ///    ZX_ERR_BAD_STATE: Subsequent requests will not succeed as well.
1780    /// Other error codes are from underlying subsystem and the caller should retry |Receive| in
1781    /// that case.
1782    pub fn r#receive(
1783        &self,
1784        ___deadline: zx::MonotonicInstant,
1785    ) -> Result<UsbAdbImplReceiveResult, fidl::Error> {
1786        let _response = self.client.send_query::<
1787            fidl::encoding::EmptyPayload,
1788            fidl::encoding::ResultType<UsbAdbImplReceiveResponse, i32>,
1789            UsbAdbImpl_Marker,
1790        >(
1791            (),
1792            0x68382fff953be5c4,
1793            fidl::encoding::DynamicFlags::empty(),
1794            ___deadline,
1795        )?;
1796        Ok(_response.map(|x| x.data))
1797    }
1798}
1799
1800#[cfg(target_os = "fuchsia")]
1801impl From<UsbAdbImpl_SynchronousProxy> for zx::NullableHandle {
1802    fn from(value: UsbAdbImpl_SynchronousProxy) -> Self {
1803        value.into_channel().into()
1804    }
1805}
1806
1807#[cfg(target_os = "fuchsia")]
1808impl From<fidl::Channel> for UsbAdbImpl_SynchronousProxy {
1809    fn from(value: fidl::Channel) -> Self {
1810        Self::new(value)
1811    }
1812}
1813
1814#[cfg(target_os = "fuchsia")]
1815impl fidl::endpoints::FromClient for UsbAdbImpl_SynchronousProxy {
1816    type Protocol = UsbAdbImpl_Marker;
1817
1818    fn from_client(value: fidl::endpoints::ClientEnd<UsbAdbImpl_Marker>) -> Self {
1819        Self::new(value.into_channel())
1820    }
1821}
1822
1823#[derive(Debug, Clone)]
1824pub struct UsbAdbImpl_Proxy {
1825    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1826}
1827
1828impl fidl::endpoints::Proxy for UsbAdbImpl_Proxy {
1829    type Protocol = UsbAdbImpl_Marker;
1830
1831    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1832        Self::new(inner)
1833    }
1834
1835    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1836        self.client.into_channel().map_err(|client| Self { client })
1837    }
1838
1839    fn as_channel(&self) -> &::fidl::AsyncChannel {
1840        self.client.as_channel()
1841    }
1842}
1843
1844impl UsbAdbImpl_Proxy {
1845    /// Create a new Proxy for fuchsia.hardware.adb/UsbAdbImpl.
1846    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1847        let protocol_name = <UsbAdbImpl_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1848        Self { client: fidl::client::Client::new(channel, protocol_name) }
1849    }
1850
1851    /// Get a Stream of events from the remote end of the protocol.
1852    ///
1853    /// # Panics
1854    ///
1855    /// Panics if the event stream was already taken.
1856    pub fn take_event_stream(&self) -> UsbAdbImpl_EventStream {
1857        UsbAdbImpl_EventStream { event_receiver: self.client.take_event_receiver() }
1858    }
1859
1860    /// Request transmission of the packet in |data|.
1861    ///
1862    /// Return status indicates transmission result:
1863    ///   ZX_OK: Packet has been transmitted over USB to the host.
1864    ///   ZX_ERR_INVALID_ARGS: |data| is empty.
1865    ///   ZX_ERR_BAD_STATE: USB ADB device is not in an online or waiting state (e.g. stopping).
1866    ///   ZX_ERR_IO: Low-level transport error submitting request to the USB endpoint.
1867    ///   ZX_ERR_CANCELED: Transmission was canceled prior to completion (e.g. driver reset or teardown).
1868    pub fn r#queue_tx(
1869        &self,
1870        mut data: &[u8],
1871    ) -> fidl::client::QueryResponseFut<
1872        UsbAdbImplQueueTxResult,
1873        fidl::encoding::DefaultFuchsiaResourceDialect,
1874    > {
1875        UsbAdbImpl_ProxyInterface::r#queue_tx(self, data)
1876    }
1877
1878    /// Request to receive data. This method ensures flow control by allowing the client to queue
1879    /// |Receive| requests proactively. The driver will complete the requests only when data is
1880    /// available.
1881    ///
1882    /// Return data or error.
1883    ///    ZX_OK: Success. data is valid.
1884    ///    ZX_ERR_BAD_STATE: Subsequent requests will not succeed as well.
1885    /// Other error codes are from underlying subsystem and the caller should retry |Receive| in
1886    /// that case.
1887    pub fn r#receive(
1888        &self,
1889    ) -> fidl::client::QueryResponseFut<
1890        UsbAdbImplReceiveResult,
1891        fidl::encoding::DefaultFuchsiaResourceDialect,
1892    > {
1893        UsbAdbImpl_ProxyInterface::r#receive(self)
1894    }
1895}
1896
1897impl UsbAdbImpl_ProxyInterface for UsbAdbImpl_Proxy {
1898    type QueueTxResponseFut = fidl::client::QueryResponseFut<
1899        UsbAdbImplQueueTxResult,
1900        fidl::encoding::DefaultFuchsiaResourceDialect,
1901    >;
1902    fn r#queue_tx(&self, mut data: &[u8]) -> Self::QueueTxResponseFut {
1903        fn _decode(
1904            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1905        ) -> Result<UsbAdbImplQueueTxResult, fidl::Error> {
1906            let _response = fidl::client::decode_transaction_body::<
1907                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1908                fidl::encoding::DefaultFuchsiaResourceDialect,
1909                0x4c0af0efa9701dc9,
1910            >(_buf?)?;
1911            Ok(_response.map(|x| x))
1912        }
1913        self.client.send_query_and_decode::<UsbAdbImplQueueTxRequest, UsbAdbImplQueueTxResult>(
1914            (data,),
1915            0x4c0af0efa9701dc9,
1916            fidl::encoding::DynamicFlags::empty(),
1917            _decode,
1918        )
1919    }
1920
1921    type ReceiveResponseFut = fidl::client::QueryResponseFut<
1922        UsbAdbImplReceiveResult,
1923        fidl::encoding::DefaultFuchsiaResourceDialect,
1924    >;
1925    fn r#receive(&self) -> Self::ReceiveResponseFut {
1926        fn _decode(
1927            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1928        ) -> Result<UsbAdbImplReceiveResult, fidl::Error> {
1929            let _response = fidl::client::decode_transaction_body::<
1930                fidl::encoding::ResultType<UsbAdbImplReceiveResponse, i32>,
1931                fidl::encoding::DefaultFuchsiaResourceDialect,
1932                0x68382fff953be5c4,
1933            >(_buf?)?;
1934            Ok(_response.map(|x| x.data))
1935        }
1936        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, UsbAdbImplReceiveResult>(
1937            (),
1938            0x68382fff953be5c4,
1939            fidl::encoding::DynamicFlags::empty(),
1940            _decode,
1941        )
1942    }
1943}
1944
1945pub struct UsbAdbImpl_EventStream {
1946    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1947}
1948
1949impl std::marker::Unpin for UsbAdbImpl_EventStream {}
1950
1951impl futures::stream::FusedStream for UsbAdbImpl_EventStream {
1952    fn is_terminated(&self) -> bool {
1953        self.event_receiver.is_terminated()
1954    }
1955}
1956
1957impl futures::Stream for UsbAdbImpl_EventStream {
1958    type Item = Result<UsbAdbImpl_Event, fidl::Error>;
1959
1960    fn poll_next(
1961        mut self: std::pin::Pin<&mut Self>,
1962        cx: &mut std::task::Context<'_>,
1963    ) -> std::task::Poll<Option<Self::Item>> {
1964        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1965            &mut self.event_receiver,
1966            cx
1967        )?) {
1968            Some(buf) => std::task::Poll::Ready(Some(UsbAdbImpl_Event::decode(buf))),
1969            None => std::task::Poll::Ready(None),
1970        }
1971    }
1972}
1973
1974#[derive(Debug)]
1975pub enum UsbAdbImpl_Event {
1976    OnStatusChanged { status: StatusFlags },
1977}
1978
1979impl UsbAdbImpl_Event {
1980    #[allow(irrefutable_let_patterns)]
1981    pub fn into_on_status_changed(self) -> Option<StatusFlags> {
1982        if let UsbAdbImpl_Event::OnStatusChanged { status } = self { Some((status)) } else { None }
1983    }
1984
1985    /// Decodes a message buffer as a [`UsbAdbImpl_Event`].
1986    fn decode(
1987        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1988    ) -> Result<UsbAdbImpl_Event, fidl::Error> {
1989        let (bytes, _handles) = buf.split_mut();
1990        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1991        debug_assert_eq!(tx_header.tx_id, 0);
1992        match tx_header.ordinal {
1993            0x2f2926086c0a5b6e => {
1994                let mut out = fidl::new_empty!(
1995                    UsbAdbImplOnStatusChangedRequest,
1996                    fidl::encoding::DefaultFuchsiaResourceDialect
1997                );
1998                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbAdbImplOnStatusChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1999                Ok((UsbAdbImpl_Event::OnStatusChanged { status: out.status }))
2000            }
2001            _ => Err(fidl::Error::UnknownOrdinal {
2002                ordinal: tx_header.ordinal,
2003                protocol_name: <UsbAdbImpl_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2004            }),
2005        }
2006    }
2007}
2008
2009/// A Stream of incoming requests for fuchsia.hardware.adb/UsbAdbImpl.
2010pub struct UsbAdbImpl_RequestStream {
2011    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2012    is_terminated: bool,
2013}
2014
2015impl std::marker::Unpin for UsbAdbImpl_RequestStream {}
2016
2017impl futures::stream::FusedStream for UsbAdbImpl_RequestStream {
2018    fn is_terminated(&self) -> bool {
2019        self.is_terminated
2020    }
2021}
2022
2023impl fidl::endpoints::RequestStream for UsbAdbImpl_RequestStream {
2024    type Protocol = UsbAdbImpl_Marker;
2025    type ControlHandle = UsbAdbImpl_ControlHandle;
2026
2027    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2028        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2029    }
2030
2031    fn control_handle(&self) -> Self::ControlHandle {
2032        UsbAdbImpl_ControlHandle { inner: self.inner.clone() }
2033    }
2034
2035    fn into_inner(
2036        self,
2037    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2038    {
2039        (self.inner, self.is_terminated)
2040    }
2041
2042    fn from_inner(
2043        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2044        is_terminated: bool,
2045    ) -> Self {
2046        Self { inner, is_terminated }
2047    }
2048}
2049
2050impl futures::Stream for UsbAdbImpl_RequestStream {
2051    type Item = Result<UsbAdbImpl_Request, fidl::Error>;
2052
2053    fn poll_next(
2054        mut self: std::pin::Pin<&mut Self>,
2055        cx: &mut std::task::Context<'_>,
2056    ) -> std::task::Poll<Option<Self::Item>> {
2057        let this = &mut *self;
2058        if this.inner.check_shutdown(cx) {
2059            this.is_terminated = true;
2060            return std::task::Poll::Ready(None);
2061        }
2062        if this.is_terminated {
2063            panic!("polled UsbAdbImpl_RequestStream after completion");
2064        }
2065        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2066            |bytes, handles| {
2067                match this.inner.channel().read_etc(cx, bytes, handles) {
2068                    std::task::Poll::Ready(Ok(())) => {}
2069                    std::task::Poll::Pending => return std::task::Poll::Pending,
2070                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2071                        this.is_terminated = true;
2072                        return std::task::Poll::Ready(None);
2073                    }
2074                    std::task::Poll::Ready(Err(e)) => {
2075                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2076                            e.into(),
2077                        ))));
2078                    }
2079                }
2080
2081                // A message has been received from the channel
2082                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2083
2084                std::task::Poll::Ready(Some(match header.ordinal {
2085                    0x4c0af0efa9701dc9 => {
2086                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2087                        let mut req = fidl::new_empty!(
2088                            UsbAdbImplQueueTxRequest,
2089                            fidl::encoding::DefaultFuchsiaResourceDialect
2090                        );
2091                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbAdbImplQueueTxRequest>(&header, _body_bytes, handles, &mut req)?;
2092                        let control_handle = UsbAdbImpl_ControlHandle { inner: this.inner.clone() };
2093                        Ok(UsbAdbImpl_Request::QueueTx {
2094                            data: req.data,
2095
2096                            responder: UsbAdbImpl_QueueTxResponder {
2097                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2098                                tx_id: header.tx_id,
2099                            },
2100                        })
2101                    }
2102                    0x68382fff953be5c4 => {
2103                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2104                        let mut req = fidl::new_empty!(
2105                            fidl::encoding::EmptyPayload,
2106                            fidl::encoding::DefaultFuchsiaResourceDialect
2107                        );
2108                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2109                        let control_handle = UsbAdbImpl_ControlHandle { inner: this.inner.clone() };
2110                        Ok(UsbAdbImpl_Request::Receive {
2111                            responder: UsbAdbImpl_ReceiveResponder {
2112                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2113                                tx_id: header.tx_id,
2114                            },
2115                        })
2116                    }
2117                    _ => Err(fidl::Error::UnknownOrdinal {
2118                        ordinal: header.ordinal,
2119                        protocol_name:
2120                            <UsbAdbImpl_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2121                    }),
2122                }))
2123            },
2124        )
2125    }
2126}
2127
2128/// USB ADB implementation protocol. The USB ADB driver would start serving this interface on the
2129/// server endpoint passed to a driver during Device::Start.
2130#[derive(Debug)]
2131pub enum UsbAdbImpl_Request {
2132    /// Request transmission of the packet in |data|.
2133    ///
2134    /// Return status indicates transmission result:
2135    ///   ZX_OK: Packet has been transmitted over USB to the host.
2136    ///   ZX_ERR_INVALID_ARGS: |data| is empty.
2137    ///   ZX_ERR_BAD_STATE: USB ADB device is not in an online or waiting state (e.g. stopping).
2138    ///   ZX_ERR_IO: Low-level transport error submitting request to the USB endpoint.
2139    ///   ZX_ERR_CANCELED: Transmission was canceled prior to completion (e.g. driver reset or teardown).
2140    QueueTx { data: Vec<u8>, responder: UsbAdbImpl_QueueTxResponder },
2141    /// Request to receive data. This method ensures flow control by allowing the client to queue
2142    /// |Receive| requests proactively. The driver will complete the requests only when data is
2143    /// available.
2144    ///
2145    /// Return data or error.
2146    ///    ZX_OK: Success. data is valid.
2147    ///    ZX_ERR_BAD_STATE: Subsequent requests will not succeed as well.
2148    /// Other error codes are from underlying subsystem and the caller should retry |Receive| in
2149    /// that case.
2150    Receive { responder: UsbAdbImpl_ReceiveResponder },
2151}
2152
2153impl UsbAdbImpl_Request {
2154    #[allow(irrefutable_let_patterns)]
2155    pub fn into_queue_tx(self) -> Option<(Vec<u8>, UsbAdbImpl_QueueTxResponder)> {
2156        if let UsbAdbImpl_Request::QueueTx { data, responder } = self {
2157            Some((data, responder))
2158        } else {
2159            None
2160        }
2161    }
2162
2163    #[allow(irrefutable_let_patterns)]
2164    pub fn into_receive(self) -> Option<(UsbAdbImpl_ReceiveResponder)> {
2165        if let UsbAdbImpl_Request::Receive { responder } = self { Some((responder)) } else { None }
2166    }
2167
2168    /// Name of the method defined in FIDL
2169    pub fn method_name(&self) -> &'static str {
2170        match *self {
2171            UsbAdbImpl_Request::QueueTx { .. } => "queue_tx",
2172            UsbAdbImpl_Request::Receive { .. } => "receive",
2173        }
2174    }
2175}
2176
2177#[derive(Debug, Clone)]
2178pub struct UsbAdbImpl_ControlHandle {
2179    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2180}
2181
2182impl UsbAdbImpl_ControlHandle {
2183    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2184        self.inner.shutdown_with_epitaph(status.into())
2185    }
2186}
2187
2188impl fidl::endpoints::ControlHandle for UsbAdbImpl_ControlHandle {
2189    fn shutdown(&self) {
2190        self.inner.shutdown()
2191    }
2192
2193    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2194        self.inner.shutdown_with_epitaph(status)
2195    }
2196
2197    fn is_closed(&self) -> bool {
2198        self.inner.channel().is_closed()
2199    }
2200    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2201        self.inner.channel().on_closed()
2202    }
2203
2204    #[cfg(target_os = "fuchsia")]
2205    fn signal_peer(
2206        &self,
2207        clear_mask: zx::Signals,
2208        set_mask: zx::Signals,
2209    ) -> Result<(), zx_status::Status> {
2210        use fidl::Peered;
2211        self.inner.channel().signal_peer(clear_mask, set_mask)
2212    }
2213}
2214
2215impl UsbAdbImpl_ControlHandle {
2216    pub fn send_on_status_changed(&self, mut status: StatusFlags) -> Result<(), fidl::Error> {
2217        self.inner.send::<UsbAdbImplOnStatusChangedRequest>(
2218            (status,),
2219            0,
2220            0x2f2926086c0a5b6e,
2221            fidl::encoding::DynamicFlags::empty(),
2222        )
2223    }
2224}
2225
2226#[must_use = "FIDL methods require a response to be sent"]
2227#[derive(Debug)]
2228pub struct UsbAdbImpl_QueueTxResponder {
2229    control_handle: std::mem::ManuallyDrop<UsbAdbImpl_ControlHandle>,
2230    tx_id: u32,
2231}
2232
2233/// Set the the channel to be shutdown (see [`UsbAdbImpl_ControlHandle::shutdown`])
2234/// if the responder is dropped without sending a response, so that the client
2235/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2236impl std::ops::Drop for UsbAdbImpl_QueueTxResponder {
2237    fn drop(&mut self) {
2238        self.control_handle.shutdown();
2239        // Safety: drops once, never accessed again
2240        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2241    }
2242}
2243
2244impl fidl::endpoints::Responder for UsbAdbImpl_QueueTxResponder {
2245    type ControlHandle = UsbAdbImpl_ControlHandle;
2246
2247    fn control_handle(&self) -> &UsbAdbImpl_ControlHandle {
2248        &self.control_handle
2249    }
2250
2251    fn drop_without_shutdown(mut self) {
2252        // Safety: drops once, never accessed again due to mem::forget
2253        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2254        // Prevent Drop from running (which would shut down the channel)
2255        std::mem::forget(self);
2256    }
2257}
2258
2259impl UsbAdbImpl_QueueTxResponder {
2260    /// Sends a response to the FIDL transaction.
2261    ///
2262    /// Sets the channel to shutdown if an error occurs.
2263    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2264        let _result = self.send_raw(result);
2265        if _result.is_err() {
2266            self.control_handle.shutdown();
2267        }
2268        self.drop_without_shutdown();
2269        _result
2270    }
2271
2272    /// Similar to "send" but does not shutdown the channel if an error occurs.
2273    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2274        let _result = self.send_raw(result);
2275        self.drop_without_shutdown();
2276        _result
2277    }
2278
2279    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2280        self.control_handle
2281            .inner
2282            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2283                result,
2284                self.tx_id,
2285                0x4c0af0efa9701dc9,
2286                fidl::encoding::DynamicFlags::empty(),
2287            )
2288    }
2289}
2290
2291#[must_use = "FIDL methods require a response to be sent"]
2292#[derive(Debug)]
2293pub struct UsbAdbImpl_ReceiveResponder {
2294    control_handle: std::mem::ManuallyDrop<UsbAdbImpl_ControlHandle>,
2295    tx_id: u32,
2296}
2297
2298/// Set the the channel to be shutdown (see [`UsbAdbImpl_ControlHandle::shutdown`])
2299/// if the responder is dropped without sending a response, so that the client
2300/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2301impl std::ops::Drop for UsbAdbImpl_ReceiveResponder {
2302    fn drop(&mut self) {
2303        self.control_handle.shutdown();
2304        // Safety: drops once, never accessed again
2305        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2306    }
2307}
2308
2309impl fidl::endpoints::Responder for UsbAdbImpl_ReceiveResponder {
2310    type ControlHandle = UsbAdbImpl_ControlHandle;
2311
2312    fn control_handle(&self) -> &UsbAdbImpl_ControlHandle {
2313        &self.control_handle
2314    }
2315
2316    fn drop_without_shutdown(mut self) {
2317        // Safety: drops once, never accessed again due to mem::forget
2318        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2319        // Prevent Drop from running (which would shut down the channel)
2320        std::mem::forget(self);
2321    }
2322}
2323
2324impl UsbAdbImpl_ReceiveResponder {
2325    /// Sends a response to the FIDL transaction.
2326    ///
2327    /// Sets the channel to shutdown if an error occurs.
2328    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2329        let _result = self.send_raw(result);
2330        if _result.is_err() {
2331            self.control_handle.shutdown();
2332        }
2333        self.drop_without_shutdown();
2334        _result
2335    }
2336
2337    /// Similar to "send" but does not shutdown the channel if an error occurs.
2338    pub fn send_no_shutdown_on_err(
2339        self,
2340        mut result: Result<&[u8], i32>,
2341    ) -> Result<(), fidl::Error> {
2342        let _result = self.send_raw(result);
2343        self.drop_without_shutdown();
2344        _result
2345    }
2346
2347    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2348        self.control_handle
2349            .inner
2350            .send::<fidl::encoding::ResultType<UsbAdbImplReceiveResponse, i32>>(
2351                result.map(|data| (data,)),
2352                self.tx_id,
2353                0x68382fff953be5c4,
2354                fidl::encoding::DynamicFlags::empty(),
2355            )
2356    }
2357}
2358
2359#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2360pub struct ServiceMarker;
2361
2362#[cfg(target_os = "fuchsia")]
2363impl fidl::endpoints::ServiceMarker for ServiceMarker {
2364    type Proxy = ServiceProxy;
2365    type Request = ServiceRequest;
2366    const SERVICE_NAME: &'static str = "fuchsia.hardware.adb.Service";
2367}
2368
2369/// A request for one of the member protocols of Service.
2370///
2371#[cfg(target_os = "fuchsia")]
2372pub enum ServiceRequest {
2373    Adb(DeviceRequestStream),
2374}
2375
2376#[cfg(target_os = "fuchsia")]
2377impl fidl::endpoints::ServiceRequest for ServiceRequest {
2378    type Service = ServiceMarker;
2379
2380    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2381        match name {
2382            "adb" => Self::Adb(
2383                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2384            ),
2385            _ => panic!("no such member protocol name for service Service"),
2386        }
2387    }
2388
2389    fn member_names() -> &'static [&'static str] {
2390        &["adb"]
2391    }
2392}
2393#[cfg(target_os = "fuchsia")]
2394pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2395
2396#[cfg(target_os = "fuchsia")]
2397impl fidl::endpoints::ServiceProxy for ServiceProxy {
2398    type Service = ServiceMarker;
2399
2400    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2401        Self(opener)
2402    }
2403}
2404
2405#[cfg(target_os = "fuchsia")]
2406impl ServiceProxy {
2407    pub fn connect_to_adb(&self) -> Result<DeviceProxy, fidl::Error> {
2408        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
2409        self.connect_channel_to_adb(server_end)?;
2410        Ok(proxy)
2411    }
2412
2413    /// Like `connect_to_adb`, but returns a sync proxy.
2414    /// See [`Self::connect_to_adb`] for more details.
2415    pub fn connect_to_adb_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
2416        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
2417        self.connect_channel_to_adb(server_end)?;
2418        Ok(proxy)
2419    }
2420
2421    /// Like `connect_to_adb`, but accepts a server end.
2422    /// See [`Self::connect_to_adb`] for more details.
2423    pub fn connect_channel_to_adb(
2424        &self,
2425        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
2426    ) -> Result<(), fidl::Error> {
2427        self.0.open_member("adb", server_end.into_channel())
2428    }
2429
2430    pub fn instance_name(&self) -> &str {
2431        self.0.instance_name()
2432    }
2433}
2434
2435mod internal {
2436    use super::*;
2437
2438    impl fidl::encoding::ResourceTypeMarker for DeviceStartAdbRequest {
2439        type Borrowed<'a> = &'a mut Self;
2440        fn take_or_borrow<'a>(
2441            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2442        ) -> Self::Borrowed<'a> {
2443            value
2444        }
2445    }
2446
2447    unsafe impl fidl::encoding::TypeMarker for DeviceStartAdbRequest {
2448        type Owned = Self;
2449
2450        #[inline(always)]
2451        fn inline_align(_context: fidl::encoding::Context) -> usize {
2452            4
2453        }
2454
2455        #[inline(always)]
2456        fn inline_size(_context: fidl::encoding::Context) -> usize {
2457            4
2458        }
2459    }
2460
2461    unsafe impl
2462        fidl::encoding::Encode<DeviceStartAdbRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2463        for &mut DeviceStartAdbRequest
2464    {
2465        #[inline]
2466        unsafe fn encode(
2467            self,
2468            encoder: &mut fidl::encoding::Encoder<
2469                '_,
2470                fidl::encoding::DefaultFuchsiaResourceDialect,
2471            >,
2472            offset: usize,
2473            _depth: fidl::encoding::Depth,
2474        ) -> fidl::Result<()> {
2475            encoder.debug_check_bounds::<DeviceStartAdbRequest>(offset);
2476            // Delegate to tuple encoding.
2477            fidl::encoding::Encode::<DeviceStartAdbRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2478                (
2479                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.interface),
2480                ),
2481                encoder, offset, _depth
2482            )
2483        }
2484    }
2485    unsafe impl<
2486        T0: fidl::encoding::Encode<
2487                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>>,
2488                fidl::encoding::DefaultFuchsiaResourceDialect,
2489            >,
2490    >
2491        fidl::encoding::Encode<DeviceStartAdbRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2492        for (T0,)
2493    {
2494        #[inline]
2495        unsafe fn encode(
2496            self,
2497            encoder: &mut fidl::encoding::Encoder<
2498                '_,
2499                fidl::encoding::DefaultFuchsiaResourceDialect,
2500            >,
2501            offset: usize,
2502            depth: fidl::encoding::Depth,
2503        ) -> fidl::Result<()> {
2504            encoder.debug_check_bounds::<DeviceStartAdbRequest>(offset);
2505            // Zero out padding regions. There's no need to apply masks
2506            // because the unmasked parts will be overwritten by fields.
2507            // Write the fields.
2508            self.0.encode(encoder, offset + 0, depth)?;
2509            Ok(())
2510        }
2511    }
2512
2513    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2514        for DeviceStartAdbRequest
2515    {
2516        #[inline(always)]
2517        fn new_empty() -> Self {
2518            Self {
2519                interface: fidl::new_empty!(
2520                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>>,
2521                    fidl::encoding::DefaultFuchsiaResourceDialect
2522                ),
2523            }
2524        }
2525
2526        #[inline]
2527        unsafe fn decode(
2528            &mut self,
2529            decoder: &mut fidl::encoding::Decoder<
2530                '_,
2531                fidl::encoding::DefaultFuchsiaResourceDialect,
2532            >,
2533            offset: usize,
2534            _depth: fidl::encoding::Depth,
2535        ) -> fidl::Result<()> {
2536            decoder.debug_check_bounds::<Self>(offset);
2537            // Verify that padding bytes are zero.
2538            fidl::decode!(
2539                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<UsbAdbImpl_Marker>>,
2540                fidl::encoding::DefaultFuchsiaResourceDialect,
2541                &mut self.interface,
2542                decoder,
2543                offset + 0,
2544                _depth
2545            )?;
2546            Ok(())
2547        }
2548    }
2549
2550    impl fidl::encoding::ResourceTypeMarker for ProviderConnectToServiceRequest {
2551        type Borrowed<'a> = &'a mut Self;
2552        fn take_or_borrow<'a>(
2553            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2554        ) -> Self::Borrowed<'a> {
2555            value
2556        }
2557    }
2558
2559    unsafe impl fidl::encoding::TypeMarker for ProviderConnectToServiceRequest {
2560        type Owned = Self;
2561
2562        #[inline(always)]
2563        fn inline_align(_context: fidl::encoding::Context) -> usize {
2564            8
2565        }
2566
2567        #[inline(always)]
2568        fn inline_size(_context: fidl::encoding::Context) -> usize {
2569            24
2570        }
2571    }
2572
2573    unsafe impl
2574        fidl::encoding::Encode<
2575            ProviderConnectToServiceRequest,
2576            fidl::encoding::DefaultFuchsiaResourceDialect,
2577        > for &mut ProviderConnectToServiceRequest
2578    {
2579        #[inline]
2580        unsafe fn encode(
2581            self,
2582            encoder: &mut fidl::encoding::Encoder<
2583                '_,
2584                fidl::encoding::DefaultFuchsiaResourceDialect,
2585            >,
2586            offset: usize,
2587            _depth: fidl::encoding::Depth,
2588        ) -> fidl::Result<()> {
2589            encoder.debug_check_bounds::<ProviderConnectToServiceRequest>(offset);
2590            // Delegate to tuple encoding.
2591            fidl::encoding::Encode::<ProviderConnectToServiceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2592                (
2593                    <fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.socket),
2594                    <fidl::encoding::Optional<fidl::encoding::BoundedString<1024>> as fidl::encoding::ValueTypeMarker>::borrow(&self.args),
2595                ),
2596                encoder, offset, _depth
2597            )
2598        }
2599    }
2600    unsafe impl<
2601        T0: fidl::encoding::Encode<
2602                fidl::encoding::HandleType<
2603                    fidl::Socket,
2604                    { fidl::ObjectType::SOCKET.into_raw() },
2605                    2147483648,
2606                >,
2607                fidl::encoding::DefaultFuchsiaResourceDialect,
2608            >,
2609        T1: fidl::encoding::Encode<
2610                fidl::encoding::Optional<fidl::encoding::BoundedString<1024>>,
2611                fidl::encoding::DefaultFuchsiaResourceDialect,
2612            >,
2613    >
2614        fidl::encoding::Encode<
2615            ProviderConnectToServiceRequest,
2616            fidl::encoding::DefaultFuchsiaResourceDialect,
2617        > for (T0, T1)
2618    {
2619        #[inline]
2620        unsafe fn encode(
2621            self,
2622            encoder: &mut fidl::encoding::Encoder<
2623                '_,
2624                fidl::encoding::DefaultFuchsiaResourceDialect,
2625            >,
2626            offset: usize,
2627            depth: fidl::encoding::Depth,
2628        ) -> fidl::Result<()> {
2629            encoder.debug_check_bounds::<ProviderConnectToServiceRequest>(offset);
2630            // Zero out padding regions. There's no need to apply masks
2631            // because the unmasked parts will be overwritten by fields.
2632            unsafe {
2633                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2634                (ptr as *mut u64).write_unaligned(0);
2635            }
2636            // Write the fields.
2637            self.0.encode(encoder, offset + 0, depth)?;
2638            self.1.encode(encoder, offset + 8, depth)?;
2639            Ok(())
2640        }
2641    }
2642
2643    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2644        for ProviderConnectToServiceRequest
2645    {
2646        #[inline(always)]
2647        fn new_empty() -> Self {
2648            Self {
2649                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2650                args: fidl::new_empty!(
2651                    fidl::encoding::Optional<fidl::encoding::BoundedString<1024>>,
2652                    fidl::encoding::DefaultFuchsiaResourceDialect
2653                ),
2654            }
2655        }
2656
2657        #[inline]
2658        unsafe fn decode(
2659            &mut self,
2660            decoder: &mut fidl::encoding::Decoder<
2661                '_,
2662                fidl::encoding::DefaultFuchsiaResourceDialect,
2663            >,
2664            offset: usize,
2665            _depth: fidl::encoding::Depth,
2666        ) -> fidl::Result<()> {
2667            decoder.debug_check_bounds::<Self>(offset);
2668            // Verify that padding bytes are zero.
2669            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2670            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2671            let mask = 0xffffffff00000000u64;
2672            let maskedval = padval & mask;
2673            if maskedval != 0 {
2674                return Err(fidl::Error::NonZeroPadding {
2675                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2676                });
2677            }
2678            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
2679            fidl::decode!(
2680                fidl::encoding::Optional<fidl::encoding::BoundedString<1024>>,
2681                fidl::encoding::DefaultFuchsiaResourceDialect,
2682                &mut self.args,
2683                decoder,
2684                offset + 8,
2685                _depth
2686            )?;
2687            Ok(())
2688        }
2689    }
2690}