Skip to main content

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