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