fidl_fuchsia_hardware_adb/
fidl_fuchsia_hardware_adb.rs

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