Skip to main content

fidl_fuchsia_hardware_reset/
fidl_fuchsia_hardware_reset.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_reset_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ResetMarker;
16
17impl fidl::endpoints::ProtocolMarker for ResetMarker {
18    type Proxy = ResetProxy;
19    type RequestStream = ResetRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ResetSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) Reset";
24}
25pub type ResetAssertResult = Result<(), i32>;
26pub type ResetDeassertResult = Result<(), i32>;
27pub type ResetToggleResult = Result<(), i32>;
28pub type ResetToggleWithTimeoutResult = Result<(), i32>;
29pub type ResetStatusResult = Result<bool, i32>;
30
31pub trait ResetProxyInterface: Send + Sync {
32    type AssertResponseFut: std::future::Future<Output = Result<ResetAssertResult, fidl::Error>>
33        + Send;
34    fn r#assert(&self) -> Self::AssertResponseFut;
35    type DeassertResponseFut: std::future::Future<Output = Result<ResetDeassertResult, fidl::Error>>
36        + Send;
37    fn r#deassert(&self) -> Self::DeassertResponseFut;
38    type ToggleResponseFut: std::future::Future<Output = Result<ResetToggleResult, fidl::Error>>
39        + Send;
40    fn r#toggle(&self) -> Self::ToggleResponseFut;
41    type ToggleWithTimeoutResponseFut: std::future::Future<Output = Result<ResetToggleWithTimeoutResult, fidl::Error>>
42        + Send;
43    fn r#toggle_with_timeout(&self, timeout: i64) -> Self::ToggleWithTimeoutResponseFut;
44    type StatusResponseFut: std::future::Future<Output = Result<ResetStatusResult, fidl::Error>>
45        + Send;
46    fn r#status(&self) -> Self::StatusResponseFut;
47}
48#[derive(Debug)]
49#[cfg(target_os = "fuchsia")]
50pub struct ResetSynchronousProxy {
51    client: fidl::client::sync::Client,
52}
53
54#[cfg(target_os = "fuchsia")]
55impl fidl::endpoints::SynchronousProxy for ResetSynchronousProxy {
56    type Proxy = ResetProxy;
57    type Protocol = ResetMarker;
58
59    fn from_channel(inner: fidl::Channel) -> Self {
60        Self::new(inner)
61    }
62
63    fn into_channel(self) -> fidl::Channel {
64        self.client.into_channel()
65    }
66
67    fn as_channel(&self) -> &fidl::Channel {
68        self.client.as_channel()
69    }
70}
71
72#[cfg(target_os = "fuchsia")]
73impl ResetSynchronousProxy {
74    pub fn new(channel: fidl::Channel) -> Self {
75        Self { client: fidl::client::sync::Client::new(channel) }
76    }
77
78    pub fn into_channel(self) -> fidl::Channel {
79        self.client.into_channel()
80    }
81
82    /// Waits until an event arrives and returns it. It is safe for other
83    /// threads to make concurrent requests while waiting for an event.
84    pub fn wait_for_event(
85        &self,
86        deadline: zx::MonotonicInstant,
87    ) -> Result<ResetEvent, fidl::Error> {
88        ResetEvent::decode(self.client.wait_for_event::<ResetMarker>(deadline)?)
89    }
90
91    /// Asserts the reset pin and leaves it asserted until `Deassert` is called.
92    pub fn r#assert(
93        &self,
94        ___deadline: zx::MonotonicInstant,
95    ) -> Result<ResetAssertResult, fidl::Error> {
96        let _response = self.client.send_query::<
97            fidl::encoding::EmptyPayload,
98            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
99            ResetMarker,
100        >(
101            (),
102            0x3df7a39abeb8835b,
103            fidl::encoding::DynamicFlags::FLEXIBLE,
104            ___deadline,
105        )?
106        .into_result::<ResetMarker>("assert")?;
107        Ok(_response.map(|x| x))
108    }
109
110    /// Deasserts the reset pin.
111    pub fn r#deassert(
112        &self,
113        ___deadline: zx::MonotonicInstant,
114    ) -> Result<ResetDeassertResult, fidl::Error> {
115        let _response = self.client.send_query::<
116            fidl::encoding::EmptyPayload,
117            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
118            ResetMarker,
119        >(
120            (),
121            0x1e8cf05b7fefc0c0,
122            fidl::encoding::DynamicFlags::FLEXIBLE,
123            ___deadline,
124        )?
125        .into_result::<ResetMarker>("deassert")?;
126        Ok(_response.map(|x| x))
127    }
128
129    /// These methods assert the pin, wait a predetermined amount of time, and then deassert the
130    /// pin. The difference between `Toggle` and `ToggleWithTimeout` is that `Toggle` defers to the
131    /// Reset driver to choose the timeout duration and `ToggleWithTimeout` allows the client to
132    /// specify the timeout.
133    pub fn r#toggle(
134        &self,
135        ___deadline: zx::MonotonicInstant,
136    ) -> Result<ResetToggleResult, fidl::Error> {
137        let _response = self.client.send_query::<
138            fidl::encoding::EmptyPayload,
139            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
140            ResetMarker,
141        >(
142            (),
143            0x63f4eba9c118cca1,
144            fidl::encoding::DynamicFlags::FLEXIBLE,
145            ___deadline,
146        )?
147        .into_result::<ResetMarker>("toggle")?;
148        Ok(_response.map(|x| x))
149    }
150
151    pub fn r#toggle_with_timeout(
152        &self,
153        mut timeout: i64,
154        ___deadline: zx::MonotonicInstant,
155    ) -> Result<ResetToggleWithTimeoutResult, fidl::Error> {
156        let _response = self.client.send_query::<
157            ResetToggleWithTimeoutRequest,
158            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
159            ResetMarker,
160        >(
161            (timeout,),
162            0x26320a0dd06a3f3c,
163            fidl::encoding::DynamicFlags::FLEXIBLE,
164            ___deadline,
165        )?
166        .into_result::<ResetMarker>("toggle_with_timeout")?;
167        Ok(_response.map(|x| x))
168    }
169
170    pub fn r#status(
171        &self,
172        ___deadline: zx::MonotonicInstant,
173    ) -> Result<ResetStatusResult, fidl::Error> {
174        let _response = self.client.send_query::<
175            fidl::encoding::EmptyPayload,
176            fidl::encoding::FlexibleResultType<ResetStatusResponse, i32>,
177            ResetMarker,
178        >(
179            (),
180            0x511e9132f7f6af47,
181            fidl::encoding::DynamicFlags::FLEXIBLE,
182            ___deadline,
183        )?
184        .into_result::<ResetMarker>("status")?;
185        Ok(_response.map(|x| x.asserted))
186    }
187}
188
189#[cfg(target_os = "fuchsia")]
190impl From<ResetSynchronousProxy> for zx::NullableHandle {
191    fn from(value: ResetSynchronousProxy) -> Self {
192        value.into_channel().into()
193    }
194}
195
196#[cfg(target_os = "fuchsia")]
197impl From<fidl::Channel> for ResetSynchronousProxy {
198    fn from(value: fidl::Channel) -> Self {
199        Self::new(value)
200    }
201}
202
203#[cfg(target_os = "fuchsia")]
204impl fidl::endpoints::FromClient for ResetSynchronousProxy {
205    type Protocol = ResetMarker;
206
207    fn from_client(value: fidl::endpoints::ClientEnd<ResetMarker>) -> Self {
208        Self::new(value.into_channel())
209    }
210}
211
212#[derive(Debug, Clone)]
213pub struct ResetProxy {
214    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
215}
216
217impl fidl::endpoints::Proxy for ResetProxy {
218    type Protocol = ResetMarker;
219
220    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
221        Self::new(inner)
222    }
223
224    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
225        self.client.into_channel().map_err(|client| Self { client })
226    }
227
228    fn as_channel(&self) -> &::fidl::AsyncChannel {
229        self.client.as_channel()
230    }
231}
232
233impl ResetProxy {
234    /// Create a new Proxy for fuchsia.hardware.reset/Reset.
235    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
236        let protocol_name = <ResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
237        Self { client: fidl::client::Client::new(channel, protocol_name) }
238    }
239
240    /// Get a Stream of events from the remote end of the protocol.
241    ///
242    /// # Panics
243    ///
244    /// Panics if the event stream was already taken.
245    pub fn take_event_stream(&self) -> ResetEventStream {
246        ResetEventStream { event_receiver: self.client.take_event_receiver() }
247    }
248
249    /// Asserts the reset pin and leaves it asserted until `Deassert` is called.
250    pub fn r#assert(
251        &self,
252    ) -> fidl::client::QueryResponseFut<
253        ResetAssertResult,
254        fidl::encoding::DefaultFuchsiaResourceDialect,
255    > {
256        ResetProxyInterface::r#assert(self)
257    }
258
259    /// Deasserts the reset pin.
260    pub fn r#deassert(
261        &self,
262    ) -> fidl::client::QueryResponseFut<
263        ResetDeassertResult,
264        fidl::encoding::DefaultFuchsiaResourceDialect,
265    > {
266        ResetProxyInterface::r#deassert(self)
267    }
268
269    /// These methods assert the pin, wait a predetermined amount of time, and then deassert the
270    /// pin. The difference between `Toggle` and `ToggleWithTimeout` is that `Toggle` defers to the
271    /// Reset driver to choose the timeout duration and `ToggleWithTimeout` allows the client to
272    /// specify the timeout.
273    pub fn r#toggle(
274        &self,
275    ) -> fidl::client::QueryResponseFut<
276        ResetToggleResult,
277        fidl::encoding::DefaultFuchsiaResourceDialect,
278    > {
279        ResetProxyInterface::r#toggle(self)
280    }
281
282    pub fn r#toggle_with_timeout(
283        &self,
284        mut timeout: i64,
285    ) -> fidl::client::QueryResponseFut<
286        ResetToggleWithTimeoutResult,
287        fidl::encoding::DefaultFuchsiaResourceDialect,
288    > {
289        ResetProxyInterface::r#toggle_with_timeout(self, timeout)
290    }
291
292    pub fn r#status(
293        &self,
294    ) -> fidl::client::QueryResponseFut<
295        ResetStatusResult,
296        fidl::encoding::DefaultFuchsiaResourceDialect,
297    > {
298        ResetProxyInterface::r#status(self)
299    }
300}
301
302impl ResetProxyInterface for ResetProxy {
303    type AssertResponseFut = fidl::client::QueryResponseFut<
304        ResetAssertResult,
305        fidl::encoding::DefaultFuchsiaResourceDialect,
306    >;
307    fn r#assert(&self) -> Self::AssertResponseFut {
308        fn _decode(
309            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
310        ) -> Result<ResetAssertResult, fidl::Error> {
311            let _response = fidl::client::decode_transaction_body::<
312                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
313                fidl::encoding::DefaultFuchsiaResourceDialect,
314                0x3df7a39abeb8835b,
315            >(_buf?)?
316            .into_result::<ResetMarker>("assert")?;
317            Ok(_response.map(|x| x))
318        }
319        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ResetAssertResult>(
320            (),
321            0x3df7a39abeb8835b,
322            fidl::encoding::DynamicFlags::FLEXIBLE,
323            _decode,
324        )
325    }
326
327    type DeassertResponseFut = fidl::client::QueryResponseFut<
328        ResetDeassertResult,
329        fidl::encoding::DefaultFuchsiaResourceDialect,
330    >;
331    fn r#deassert(&self) -> Self::DeassertResponseFut {
332        fn _decode(
333            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
334        ) -> Result<ResetDeassertResult, fidl::Error> {
335            let _response = fidl::client::decode_transaction_body::<
336                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
337                fidl::encoding::DefaultFuchsiaResourceDialect,
338                0x1e8cf05b7fefc0c0,
339            >(_buf?)?
340            .into_result::<ResetMarker>("deassert")?;
341            Ok(_response.map(|x| x))
342        }
343        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ResetDeassertResult>(
344            (),
345            0x1e8cf05b7fefc0c0,
346            fidl::encoding::DynamicFlags::FLEXIBLE,
347            _decode,
348        )
349    }
350
351    type ToggleResponseFut = fidl::client::QueryResponseFut<
352        ResetToggleResult,
353        fidl::encoding::DefaultFuchsiaResourceDialect,
354    >;
355    fn r#toggle(&self) -> Self::ToggleResponseFut {
356        fn _decode(
357            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
358        ) -> Result<ResetToggleResult, fidl::Error> {
359            let _response = fidl::client::decode_transaction_body::<
360                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
361                fidl::encoding::DefaultFuchsiaResourceDialect,
362                0x63f4eba9c118cca1,
363            >(_buf?)?
364            .into_result::<ResetMarker>("toggle")?;
365            Ok(_response.map(|x| x))
366        }
367        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ResetToggleResult>(
368            (),
369            0x63f4eba9c118cca1,
370            fidl::encoding::DynamicFlags::FLEXIBLE,
371            _decode,
372        )
373    }
374
375    type ToggleWithTimeoutResponseFut = fidl::client::QueryResponseFut<
376        ResetToggleWithTimeoutResult,
377        fidl::encoding::DefaultFuchsiaResourceDialect,
378    >;
379    fn r#toggle_with_timeout(&self, mut timeout: i64) -> Self::ToggleWithTimeoutResponseFut {
380        fn _decode(
381            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
382        ) -> Result<ResetToggleWithTimeoutResult, fidl::Error> {
383            let _response = fidl::client::decode_transaction_body::<
384                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
385                fidl::encoding::DefaultFuchsiaResourceDialect,
386                0x26320a0dd06a3f3c,
387            >(_buf?)?
388            .into_result::<ResetMarker>("toggle_with_timeout")?;
389            Ok(_response.map(|x| x))
390        }
391        self.client
392            .send_query_and_decode::<ResetToggleWithTimeoutRequest, ResetToggleWithTimeoutResult>(
393                (timeout,),
394                0x26320a0dd06a3f3c,
395                fidl::encoding::DynamicFlags::FLEXIBLE,
396                _decode,
397            )
398    }
399
400    type StatusResponseFut = fidl::client::QueryResponseFut<
401        ResetStatusResult,
402        fidl::encoding::DefaultFuchsiaResourceDialect,
403    >;
404    fn r#status(&self) -> Self::StatusResponseFut {
405        fn _decode(
406            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
407        ) -> Result<ResetStatusResult, fidl::Error> {
408            let _response = fidl::client::decode_transaction_body::<
409                fidl::encoding::FlexibleResultType<ResetStatusResponse, i32>,
410                fidl::encoding::DefaultFuchsiaResourceDialect,
411                0x511e9132f7f6af47,
412            >(_buf?)?
413            .into_result::<ResetMarker>("status")?;
414            Ok(_response.map(|x| x.asserted))
415        }
416        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ResetStatusResult>(
417            (),
418            0x511e9132f7f6af47,
419            fidl::encoding::DynamicFlags::FLEXIBLE,
420            _decode,
421        )
422    }
423}
424
425pub struct ResetEventStream {
426    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
427}
428
429impl std::marker::Unpin for ResetEventStream {}
430
431impl futures::stream::FusedStream for ResetEventStream {
432    fn is_terminated(&self) -> bool {
433        self.event_receiver.is_terminated()
434    }
435}
436
437impl futures::Stream for ResetEventStream {
438    type Item = Result<ResetEvent, fidl::Error>;
439
440    fn poll_next(
441        mut self: std::pin::Pin<&mut Self>,
442        cx: &mut std::task::Context<'_>,
443    ) -> std::task::Poll<Option<Self::Item>> {
444        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
445            &mut self.event_receiver,
446            cx
447        )?) {
448            Some(buf) => std::task::Poll::Ready(Some(ResetEvent::decode(buf))),
449            None => std::task::Poll::Ready(None),
450        }
451    }
452}
453
454#[derive(Debug)]
455pub enum ResetEvent {
456    #[non_exhaustive]
457    _UnknownEvent {
458        /// Ordinal of the event that was sent.
459        ordinal: u64,
460    },
461}
462
463impl ResetEvent {
464    /// Decodes a message buffer as a [`ResetEvent`].
465    fn decode(
466        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
467    ) -> Result<ResetEvent, fidl::Error> {
468        let (bytes, _handles) = buf.split_mut();
469        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
470        debug_assert_eq!(tx_header.tx_id, 0);
471        match tx_header.ordinal {
472            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
473                Ok(ResetEvent::_UnknownEvent { ordinal: tx_header.ordinal })
474            }
475            _ => Err(fidl::Error::UnknownOrdinal {
476                ordinal: tx_header.ordinal,
477                protocol_name: <ResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
478            }),
479        }
480    }
481}
482
483/// A Stream of incoming requests for fuchsia.hardware.reset/Reset.
484pub struct ResetRequestStream {
485    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
486    is_terminated: bool,
487}
488
489impl std::marker::Unpin for ResetRequestStream {}
490
491impl futures::stream::FusedStream for ResetRequestStream {
492    fn is_terminated(&self) -> bool {
493        self.is_terminated
494    }
495}
496
497impl fidl::endpoints::RequestStream for ResetRequestStream {
498    type Protocol = ResetMarker;
499    type ControlHandle = ResetControlHandle;
500
501    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
502        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
503    }
504
505    fn control_handle(&self) -> Self::ControlHandle {
506        ResetControlHandle { inner: self.inner.clone() }
507    }
508
509    fn into_inner(
510        self,
511    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
512    {
513        (self.inner, self.is_terminated)
514    }
515
516    fn from_inner(
517        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
518        is_terminated: bool,
519    ) -> Self {
520        Self { inner, is_terminated }
521    }
522}
523
524impl futures::Stream for ResetRequestStream {
525    type Item = Result<ResetRequest, fidl::Error>;
526
527    fn poll_next(
528        mut self: std::pin::Pin<&mut Self>,
529        cx: &mut std::task::Context<'_>,
530    ) -> std::task::Poll<Option<Self::Item>> {
531        let this = &mut *self;
532        if this.inner.check_shutdown(cx) {
533            this.is_terminated = true;
534            return std::task::Poll::Ready(None);
535        }
536        if this.is_terminated {
537            panic!("polled ResetRequestStream after completion");
538        }
539        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
540            |bytes, handles| {
541                match this.inner.channel().read_etc(cx, bytes, handles) {
542                    std::task::Poll::Ready(Ok(())) => {}
543                    std::task::Poll::Pending => return std::task::Poll::Pending,
544                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
545                        this.is_terminated = true;
546                        return std::task::Poll::Ready(None);
547                    }
548                    std::task::Poll::Ready(Err(e)) => {
549                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
550                            e.into(),
551                        ))));
552                    }
553                }
554
555                // A message has been received from the channel
556                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
557
558                std::task::Poll::Ready(Some(match header.ordinal {
559                    0x3df7a39abeb8835b => {
560                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
561                        let mut req = fidl::new_empty!(
562                            fidl::encoding::EmptyPayload,
563                            fidl::encoding::DefaultFuchsiaResourceDialect
564                        );
565                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
566                        let control_handle = ResetControlHandle { inner: this.inner.clone() };
567                        Ok(ResetRequest::Assert {
568                            responder: ResetAssertResponder {
569                                control_handle: std::mem::ManuallyDrop::new(control_handle),
570                                tx_id: header.tx_id,
571                            },
572                        })
573                    }
574                    0x1e8cf05b7fefc0c0 => {
575                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
576                        let mut req = fidl::new_empty!(
577                            fidl::encoding::EmptyPayload,
578                            fidl::encoding::DefaultFuchsiaResourceDialect
579                        );
580                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
581                        let control_handle = ResetControlHandle { inner: this.inner.clone() };
582                        Ok(ResetRequest::Deassert {
583                            responder: ResetDeassertResponder {
584                                control_handle: std::mem::ManuallyDrop::new(control_handle),
585                                tx_id: header.tx_id,
586                            },
587                        })
588                    }
589                    0x63f4eba9c118cca1 => {
590                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
591                        let mut req = fidl::new_empty!(
592                            fidl::encoding::EmptyPayload,
593                            fidl::encoding::DefaultFuchsiaResourceDialect
594                        );
595                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
596                        let control_handle = ResetControlHandle { inner: this.inner.clone() };
597                        Ok(ResetRequest::Toggle {
598                            responder: ResetToggleResponder {
599                                control_handle: std::mem::ManuallyDrop::new(control_handle),
600                                tx_id: header.tx_id,
601                            },
602                        })
603                    }
604                    0x26320a0dd06a3f3c => {
605                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
606                        let mut req = fidl::new_empty!(
607                            ResetToggleWithTimeoutRequest,
608                            fidl::encoding::DefaultFuchsiaResourceDialect
609                        );
610                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ResetToggleWithTimeoutRequest>(&header, _body_bytes, handles, &mut req)?;
611                        let control_handle = ResetControlHandle { inner: this.inner.clone() };
612                        Ok(ResetRequest::ToggleWithTimeout {
613                            timeout: req.timeout,
614
615                            responder: ResetToggleWithTimeoutResponder {
616                                control_handle: std::mem::ManuallyDrop::new(control_handle),
617                                tx_id: header.tx_id,
618                            },
619                        })
620                    }
621                    0x511e9132f7f6af47 => {
622                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
623                        let mut req = fidl::new_empty!(
624                            fidl::encoding::EmptyPayload,
625                            fidl::encoding::DefaultFuchsiaResourceDialect
626                        );
627                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
628                        let control_handle = ResetControlHandle { inner: this.inner.clone() };
629                        Ok(ResetRequest::Status {
630                            responder: ResetStatusResponder {
631                                control_handle: std::mem::ManuallyDrop::new(control_handle),
632                                tx_id: header.tx_id,
633                            },
634                        })
635                    }
636                    _ if header.tx_id == 0
637                        && header
638                            .dynamic_flags()
639                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
640                    {
641                        Ok(ResetRequest::_UnknownMethod {
642                            ordinal: header.ordinal,
643                            control_handle: ResetControlHandle { inner: this.inner.clone() },
644                            method_type: fidl::MethodType::OneWay,
645                        })
646                    }
647                    _ if header
648                        .dynamic_flags()
649                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
650                    {
651                        this.inner.send_framework_err(
652                            fidl::encoding::FrameworkErr::UnknownMethod,
653                            header.tx_id,
654                            header.ordinal,
655                            header.dynamic_flags(),
656                            (bytes, handles),
657                        )?;
658                        Ok(ResetRequest::_UnknownMethod {
659                            ordinal: header.ordinal,
660                            control_handle: ResetControlHandle { inner: this.inner.clone() },
661                            method_type: fidl::MethodType::TwoWay,
662                        })
663                    }
664                    _ => Err(fidl::Error::UnknownOrdinal {
665                        ordinal: header.ordinal,
666                        protocol_name: <ResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
667                    }),
668                }))
669            },
670        )
671    }
672}
673
674#[derive(Debug)]
675pub enum ResetRequest {
676    /// Asserts the reset pin and leaves it asserted until `Deassert` is called.
677    Assert {
678        responder: ResetAssertResponder,
679    },
680    /// Deasserts the reset pin.
681    Deassert {
682        responder: ResetDeassertResponder,
683    },
684    /// These methods assert the pin, wait a predetermined amount of time, and then deassert the
685    /// pin. The difference between `Toggle` and `ToggleWithTimeout` is that `Toggle` defers to the
686    /// Reset driver to choose the timeout duration and `ToggleWithTimeout` allows the client to
687    /// specify the timeout.
688    Toggle {
689        responder: ResetToggleResponder,
690    },
691    ToggleWithTimeout {
692        timeout: i64,
693        responder: ResetToggleWithTimeoutResponder,
694    },
695    Status {
696        responder: ResetStatusResponder,
697    },
698    /// An interaction was received which does not match any known method.
699    #[non_exhaustive]
700    _UnknownMethod {
701        /// Ordinal of the method that was called.
702        ordinal: u64,
703        control_handle: ResetControlHandle,
704        method_type: fidl::MethodType,
705    },
706}
707
708impl ResetRequest {
709    #[allow(irrefutable_let_patterns)]
710    pub fn into_assert(self) -> Option<(ResetAssertResponder)> {
711        if let ResetRequest::Assert { responder } = self { Some((responder)) } else { None }
712    }
713
714    #[allow(irrefutable_let_patterns)]
715    pub fn into_deassert(self) -> Option<(ResetDeassertResponder)> {
716        if let ResetRequest::Deassert { responder } = self { Some((responder)) } else { None }
717    }
718
719    #[allow(irrefutable_let_patterns)]
720    pub fn into_toggle(self) -> Option<(ResetToggleResponder)> {
721        if let ResetRequest::Toggle { responder } = self { Some((responder)) } else { None }
722    }
723
724    #[allow(irrefutable_let_patterns)]
725    pub fn into_toggle_with_timeout(self) -> Option<(i64, ResetToggleWithTimeoutResponder)> {
726        if let ResetRequest::ToggleWithTimeout { timeout, responder } = self {
727            Some((timeout, responder))
728        } else {
729            None
730        }
731    }
732
733    #[allow(irrefutable_let_patterns)]
734    pub fn into_status(self) -> Option<(ResetStatusResponder)> {
735        if let ResetRequest::Status { responder } = self { Some((responder)) } else { None }
736    }
737
738    /// Name of the method defined in FIDL
739    pub fn method_name(&self) -> &'static str {
740        match *self {
741            ResetRequest::Assert { .. } => "assert",
742            ResetRequest::Deassert { .. } => "deassert",
743            ResetRequest::Toggle { .. } => "toggle",
744            ResetRequest::ToggleWithTimeout { .. } => "toggle_with_timeout",
745            ResetRequest::Status { .. } => "status",
746            ResetRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
747                "unknown one-way method"
748            }
749            ResetRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
750                "unknown two-way method"
751            }
752        }
753    }
754}
755
756#[derive(Debug, Clone)]
757pub struct ResetControlHandle {
758    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
759}
760
761impl ResetControlHandle {
762    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
763        self.inner.shutdown_with_epitaph(status.into())
764    }
765}
766
767impl fidl::endpoints::ControlHandle for ResetControlHandle {
768    fn shutdown(&self) {
769        self.inner.shutdown()
770    }
771
772    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
773        self.inner.shutdown_with_epitaph(status)
774    }
775
776    fn is_closed(&self) -> bool {
777        self.inner.channel().is_closed()
778    }
779    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
780        self.inner.channel().on_closed()
781    }
782
783    #[cfg(target_os = "fuchsia")]
784    fn signal_peer(
785        &self,
786        clear_mask: zx::Signals,
787        set_mask: zx::Signals,
788    ) -> Result<(), zx_status::Status> {
789        use fidl::Peered;
790        self.inner.channel().signal_peer(clear_mask, set_mask)
791    }
792}
793
794impl ResetControlHandle {}
795
796#[must_use = "FIDL methods require a response to be sent"]
797#[derive(Debug)]
798pub struct ResetAssertResponder {
799    control_handle: std::mem::ManuallyDrop<ResetControlHandle>,
800    tx_id: u32,
801}
802
803/// Set the the channel to be shutdown (see [`ResetControlHandle::shutdown`])
804/// if the responder is dropped without sending a response, so that the client
805/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
806impl std::ops::Drop for ResetAssertResponder {
807    fn drop(&mut self) {
808        self.control_handle.shutdown();
809        // Safety: drops once, never accessed again
810        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
811    }
812}
813
814impl fidl::endpoints::Responder for ResetAssertResponder {
815    type ControlHandle = ResetControlHandle;
816
817    fn control_handle(&self) -> &ResetControlHandle {
818        &self.control_handle
819    }
820
821    fn drop_without_shutdown(mut self) {
822        // Safety: drops once, never accessed again due to mem::forget
823        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
824        // Prevent Drop from running (which would shut down the channel)
825        std::mem::forget(self);
826    }
827}
828
829impl ResetAssertResponder {
830    /// Sends a response to the FIDL transaction.
831    ///
832    /// Sets the channel to shutdown if an error occurs.
833    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
834        let _result = self.send_raw(result);
835        if _result.is_err() {
836            self.control_handle.shutdown();
837        }
838        self.drop_without_shutdown();
839        _result
840    }
841
842    /// Similar to "send" but does not shutdown the channel if an error occurs.
843    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
844        let _result = self.send_raw(result);
845        self.drop_without_shutdown();
846        _result
847    }
848
849    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
850        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
851            fidl::encoding::EmptyStruct,
852            i32,
853        >>(
854            fidl::encoding::FlexibleResult::new(result),
855            self.tx_id,
856            0x3df7a39abeb8835b,
857            fidl::encoding::DynamicFlags::FLEXIBLE,
858        )
859    }
860}
861
862#[must_use = "FIDL methods require a response to be sent"]
863#[derive(Debug)]
864pub struct ResetDeassertResponder {
865    control_handle: std::mem::ManuallyDrop<ResetControlHandle>,
866    tx_id: u32,
867}
868
869/// Set the the channel to be shutdown (see [`ResetControlHandle::shutdown`])
870/// if the responder is dropped without sending a response, so that the client
871/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
872impl std::ops::Drop for ResetDeassertResponder {
873    fn drop(&mut self) {
874        self.control_handle.shutdown();
875        // Safety: drops once, never accessed again
876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877    }
878}
879
880impl fidl::endpoints::Responder for ResetDeassertResponder {
881    type ControlHandle = ResetControlHandle;
882
883    fn control_handle(&self) -> &ResetControlHandle {
884        &self.control_handle
885    }
886
887    fn drop_without_shutdown(mut self) {
888        // Safety: drops once, never accessed again due to mem::forget
889        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
890        // Prevent Drop from running (which would shut down the channel)
891        std::mem::forget(self);
892    }
893}
894
895impl ResetDeassertResponder {
896    /// Sends a response to the FIDL transaction.
897    ///
898    /// Sets the channel to shutdown if an error occurs.
899    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
900        let _result = self.send_raw(result);
901        if _result.is_err() {
902            self.control_handle.shutdown();
903        }
904        self.drop_without_shutdown();
905        _result
906    }
907
908    /// Similar to "send" but does not shutdown the channel if an error occurs.
909    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
910        let _result = self.send_raw(result);
911        self.drop_without_shutdown();
912        _result
913    }
914
915    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
916        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
917            fidl::encoding::EmptyStruct,
918            i32,
919        >>(
920            fidl::encoding::FlexibleResult::new(result),
921            self.tx_id,
922            0x1e8cf05b7fefc0c0,
923            fidl::encoding::DynamicFlags::FLEXIBLE,
924        )
925    }
926}
927
928#[must_use = "FIDL methods require a response to be sent"]
929#[derive(Debug)]
930pub struct ResetToggleResponder {
931    control_handle: std::mem::ManuallyDrop<ResetControlHandle>,
932    tx_id: u32,
933}
934
935/// Set the the channel to be shutdown (see [`ResetControlHandle::shutdown`])
936/// if the responder is dropped without sending a response, so that the client
937/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
938impl std::ops::Drop for ResetToggleResponder {
939    fn drop(&mut self) {
940        self.control_handle.shutdown();
941        // Safety: drops once, never accessed again
942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
943    }
944}
945
946impl fidl::endpoints::Responder for ResetToggleResponder {
947    type ControlHandle = ResetControlHandle;
948
949    fn control_handle(&self) -> &ResetControlHandle {
950        &self.control_handle
951    }
952
953    fn drop_without_shutdown(mut self) {
954        // Safety: drops once, never accessed again due to mem::forget
955        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
956        // Prevent Drop from running (which would shut down the channel)
957        std::mem::forget(self);
958    }
959}
960
961impl ResetToggleResponder {
962    /// Sends a response to the FIDL transaction.
963    ///
964    /// Sets the channel to shutdown if an error occurs.
965    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
966        let _result = self.send_raw(result);
967        if _result.is_err() {
968            self.control_handle.shutdown();
969        }
970        self.drop_without_shutdown();
971        _result
972    }
973
974    /// Similar to "send" but does not shutdown the channel if an error occurs.
975    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
976        let _result = self.send_raw(result);
977        self.drop_without_shutdown();
978        _result
979    }
980
981    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
982        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
983            fidl::encoding::EmptyStruct,
984            i32,
985        >>(
986            fidl::encoding::FlexibleResult::new(result),
987            self.tx_id,
988            0x63f4eba9c118cca1,
989            fidl::encoding::DynamicFlags::FLEXIBLE,
990        )
991    }
992}
993
994#[must_use = "FIDL methods require a response to be sent"]
995#[derive(Debug)]
996pub struct ResetToggleWithTimeoutResponder {
997    control_handle: std::mem::ManuallyDrop<ResetControlHandle>,
998    tx_id: u32,
999}
1000
1001/// Set the the channel to be shutdown (see [`ResetControlHandle::shutdown`])
1002/// if the responder is dropped without sending a response, so that the client
1003/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1004impl std::ops::Drop for ResetToggleWithTimeoutResponder {
1005    fn drop(&mut self) {
1006        self.control_handle.shutdown();
1007        // Safety: drops once, never accessed again
1008        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1009    }
1010}
1011
1012impl fidl::endpoints::Responder for ResetToggleWithTimeoutResponder {
1013    type ControlHandle = ResetControlHandle;
1014
1015    fn control_handle(&self) -> &ResetControlHandle {
1016        &self.control_handle
1017    }
1018
1019    fn drop_without_shutdown(mut self) {
1020        // Safety: drops once, never accessed again due to mem::forget
1021        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1022        // Prevent Drop from running (which would shut down the channel)
1023        std::mem::forget(self);
1024    }
1025}
1026
1027impl ResetToggleWithTimeoutResponder {
1028    /// Sends a response to the FIDL transaction.
1029    ///
1030    /// Sets the channel to shutdown if an error occurs.
1031    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1032        let _result = self.send_raw(result);
1033        if _result.is_err() {
1034            self.control_handle.shutdown();
1035        }
1036        self.drop_without_shutdown();
1037        _result
1038    }
1039
1040    /// Similar to "send" but does not shutdown the channel if an error occurs.
1041    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1042        let _result = self.send_raw(result);
1043        self.drop_without_shutdown();
1044        _result
1045    }
1046
1047    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1048        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1049            fidl::encoding::EmptyStruct,
1050            i32,
1051        >>(
1052            fidl::encoding::FlexibleResult::new(result),
1053            self.tx_id,
1054            0x26320a0dd06a3f3c,
1055            fidl::encoding::DynamicFlags::FLEXIBLE,
1056        )
1057    }
1058}
1059
1060#[must_use = "FIDL methods require a response to be sent"]
1061#[derive(Debug)]
1062pub struct ResetStatusResponder {
1063    control_handle: std::mem::ManuallyDrop<ResetControlHandle>,
1064    tx_id: u32,
1065}
1066
1067/// Set the the channel to be shutdown (see [`ResetControlHandle::shutdown`])
1068/// if the responder is dropped without sending a response, so that the client
1069/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1070impl std::ops::Drop for ResetStatusResponder {
1071    fn drop(&mut self) {
1072        self.control_handle.shutdown();
1073        // Safety: drops once, never accessed again
1074        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1075    }
1076}
1077
1078impl fidl::endpoints::Responder for ResetStatusResponder {
1079    type ControlHandle = ResetControlHandle;
1080
1081    fn control_handle(&self) -> &ResetControlHandle {
1082        &self.control_handle
1083    }
1084
1085    fn drop_without_shutdown(mut self) {
1086        // Safety: drops once, never accessed again due to mem::forget
1087        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1088        // Prevent Drop from running (which would shut down the channel)
1089        std::mem::forget(self);
1090    }
1091}
1092
1093impl ResetStatusResponder {
1094    /// Sends a response to the FIDL transaction.
1095    ///
1096    /// Sets the channel to shutdown if an error occurs.
1097    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
1098        let _result = self.send_raw(result);
1099        if _result.is_err() {
1100            self.control_handle.shutdown();
1101        }
1102        self.drop_without_shutdown();
1103        _result
1104    }
1105
1106    /// Similar to "send" but does not shutdown the channel if an error occurs.
1107    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
1108        let _result = self.send_raw(result);
1109        self.drop_without_shutdown();
1110        _result
1111    }
1112
1113    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
1114        self.control_handle
1115            .inner
1116            .send::<fidl::encoding::FlexibleResultType<ResetStatusResponse, i32>>(
1117                fidl::encoding::FlexibleResult::new(result.map(|asserted| (asserted,))),
1118                self.tx_id,
1119                0x511e9132f7f6af47,
1120                fidl::encoding::DynamicFlags::FLEXIBLE,
1121            )
1122    }
1123}
1124
1125#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1126pub struct ServiceMarker;
1127
1128#[cfg(target_os = "fuchsia")]
1129impl fidl::endpoints::ServiceMarker for ServiceMarker {
1130    type Proxy = ServiceProxy;
1131    type Request = ServiceRequest;
1132    const SERVICE_NAME: &'static str = "fuchsia.hardware.reset.Service";
1133}
1134
1135/// A request for one of the member protocols of Service.
1136///
1137#[cfg(target_os = "fuchsia")]
1138pub enum ServiceRequest {
1139    Reset(ResetRequestStream),
1140}
1141
1142#[cfg(target_os = "fuchsia")]
1143impl fidl::endpoints::ServiceRequest for ServiceRequest {
1144    type Service = ServiceMarker;
1145
1146    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1147        match name {
1148            "reset" => Self::Reset(
1149                <ResetRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1150            ),
1151            _ => panic!("no such member protocol name for service Service"),
1152        }
1153    }
1154
1155    fn member_names() -> &'static [&'static str] {
1156        &["reset"]
1157    }
1158}
1159#[cfg(target_os = "fuchsia")]
1160pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1161
1162#[cfg(target_os = "fuchsia")]
1163impl fidl::endpoints::ServiceProxy for ServiceProxy {
1164    type Service = ServiceMarker;
1165
1166    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1167        Self(opener)
1168    }
1169}
1170
1171#[cfg(target_os = "fuchsia")]
1172impl ServiceProxy {
1173    pub fn connect_to_reset(&self) -> Result<ResetProxy, fidl::Error> {
1174        let (proxy, server_end) = fidl::endpoints::create_proxy::<ResetMarker>();
1175        self.connect_channel_to_reset(server_end)?;
1176        Ok(proxy)
1177    }
1178
1179    /// Like `connect_to_reset`, but returns a sync proxy.
1180    /// See [`Self::connect_to_reset`] for more details.
1181    pub fn connect_to_reset_sync(&self) -> Result<ResetSynchronousProxy, fidl::Error> {
1182        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ResetMarker>();
1183        self.connect_channel_to_reset(server_end)?;
1184        Ok(proxy)
1185    }
1186
1187    /// Like `connect_to_reset`, but accepts a server end.
1188    /// See [`Self::connect_to_reset`] for more details.
1189    pub fn connect_channel_to_reset(
1190        &self,
1191        server_end: fidl::endpoints::ServerEnd<ResetMarker>,
1192    ) -> Result<(), fidl::Error> {
1193        self.0.open_member("reset", server_end.into_channel())
1194    }
1195
1196    pub fn instance_name(&self) -> &str {
1197        self.0.instance_name()
1198    }
1199}
1200
1201mod internal {
1202    use super::*;
1203}