fidl_fuchsia_hardware_hrtimer/
fidl_fuchsia_hardware_hrtimer.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_hrtimer__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceSetEventRequest {
16    pub id: u64,
17    pub event: fidl::Event,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceSetEventRequest {}
21
22#[derive(Debug, PartialEq)]
23pub struct DeviceStartAndWait2Request {
24    pub id: u64,
25    pub resolution: Resolution,
26    pub ticks: u64,
27    pub setup_keep_alive: fidl::EventPair,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for DeviceStartAndWait2Request
32{
33}
34
35#[derive(Debug, PartialEq)]
36pub struct DeviceStartAndWaitRequest {
37    pub id: u64,
38    pub resolution: Resolution,
39    pub ticks: u64,
40    pub setup_event: fidl::Event,
41}
42
43impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceStartAndWaitRequest {}
44
45#[derive(Debug, PartialEq)]
46pub struct DeviceGetPropertiesResponse {
47    pub properties: Properties,
48}
49
50impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
51    for DeviceGetPropertiesResponse
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct DeviceStartAndWait2Response {
57    pub expiration_keep_alive: fidl::EventPair,
58}
59
60impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
61    for DeviceStartAndWait2Response
62{
63}
64
65#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
66pub struct DeviceStartAndWaitResponse {
67    pub keep_alive: fidl::EventPair,
68}
69
70impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
71    for DeviceStartAndWaitResponse
72{
73}
74
75/// Driver properties.
76#[derive(Debug, Default, PartialEq)]
77pub struct Properties {
78    /// Retrieves the supported timers properties.
79    ///
80    /// Optional.
81    pub timers_properties: Option<Vec<TimerProperties>>,
82    #[doc(hidden)]
83    pub __source_breaking: fidl::marker::SourceBreaking,
84}
85
86impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Properties {}
87
88#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
89pub struct DeviceMarker;
90
91impl fidl::endpoints::ProtocolMarker for DeviceMarker {
92    type Proxy = DeviceProxy;
93    type RequestStream = DeviceRequestStream;
94    #[cfg(target_os = "fuchsia")]
95    type SynchronousProxy = DeviceSynchronousProxy;
96
97    const DEBUG_NAME: &'static str = "fuchsia.hardware.hrtimer.Device";
98}
99impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
100pub type DeviceStartResult = Result<(), DriverError>;
101pub type DeviceReadTimerResult = Result<u64, DriverError>;
102pub type DeviceReadClockResult = Result<u64, DriverError>;
103pub type DeviceStopResult = Result<(), DriverError>;
104pub type DeviceGetTicksLeftResult = Result<u64, DriverError>;
105pub type DeviceSetEventResult = Result<(), DriverError>;
106pub type DeviceStartAndWaitResult = Result<fidl::EventPair, DriverError>;
107pub type DeviceStartAndWait2Result = Result<fidl::EventPair, DriverError>;
108
109pub trait DeviceProxyInterface: Send + Sync {
110    type StartResponseFut: std::future::Future<Output = Result<DeviceStartResult, fidl::Error>>
111        + Send;
112    fn r#start(&self, id: u64, resolution: &Resolution, ticks: u64) -> Self::StartResponseFut;
113    type ReadTimerResponseFut: std::future::Future<Output = Result<DeviceReadTimerResult, fidl::Error>>
114        + Send;
115    fn r#read_timer(&self, id: u64, resolution: &Resolution) -> Self::ReadTimerResponseFut;
116    type ReadClockResponseFut: std::future::Future<Output = Result<DeviceReadClockResult, fidl::Error>>
117        + Send;
118    fn r#read_clock(&self, id: u64, resolution: &Resolution) -> Self::ReadClockResponseFut;
119    type StopResponseFut: std::future::Future<Output = Result<DeviceStopResult, fidl::Error>> + Send;
120    fn r#stop(&self, id: u64) -> Self::StopResponseFut;
121    type GetTicksLeftResponseFut: std::future::Future<Output = Result<DeviceGetTicksLeftResult, fidl::Error>>
122        + Send;
123    fn r#get_ticks_left(&self, id: u64) -> Self::GetTicksLeftResponseFut;
124    type SetEventResponseFut: std::future::Future<Output = Result<DeviceSetEventResult, fidl::Error>>
125        + Send;
126    fn r#set_event(&self, id: u64, event: fidl::Event) -> Self::SetEventResponseFut;
127    type StartAndWaitResponseFut: std::future::Future<Output = Result<DeviceStartAndWaitResult, fidl::Error>>
128        + Send;
129    fn r#start_and_wait(
130        &self,
131        id: u64,
132        resolution: &Resolution,
133        ticks: u64,
134        setup_event: fidl::Event,
135    ) -> Self::StartAndWaitResponseFut;
136    type StartAndWait2ResponseFut: std::future::Future<Output = Result<DeviceStartAndWait2Result, fidl::Error>>
137        + Send;
138    fn r#start_and_wait2(
139        &self,
140        id: u64,
141        resolution: &Resolution,
142        ticks: u64,
143        setup_keep_alive: fidl::EventPair,
144    ) -> Self::StartAndWait2ResponseFut;
145    type GetPropertiesResponseFut: std::future::Future<Output = Result<Properties, fidl::Error>>
146        + Send;
147    fn r#get_properties(&self) -> Self::GetPropertiesResponseFut;
148}
149#[derive(Debug)]
150#[cfg(target_os = "fuchsia")]
151pub struct DeviceSynchronousProxy {
152    client: fidl::client::sync::Client,
153}
154
155#[cfg(target_os = "fuchsia")]
156impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
157    type Proxy = DeviceProxy;
158    type Protocol = DeviceMarker;
159
160    fn from_channel(inner: fidl::Channel) -> Self {
161        Self::new(inner)
162    }
163
164    fn into_channel(self) -> fidl::Channel {
165        self.client.into_channel()
166    }
167
168    fn as_channel(&self) -> &fidl::Channel {
169        self.client.as_channel()
170    }
171}
172
173#[cfg(target_os = "fuchsia")]
174impl DeviceSynchronousProxy {
175    pub fn new(channel: fidl::Channel) -> Self {
176        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
177        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
178    }
179
180    pub fn into_channel(self) -> fidl::Channel {
181        self.client.into_channel()
182    }
183
184    /// Waits until an event arrives and returns it. It is safe for other
185    /// threads to make concurrent requests while waiting for an event.
186    pub fn wait_for_event(
187        &self,
188        deadline: zx::MonotonicInstant,
189    ) -> Result<DeviceEvent, fidl::Error> {
190        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
191    }
192
193    /// Start the timer `id` to expire after `ticks`.
194    ///
195    /// If `ticks` is 0 then the timer will expire in 0 ticks (immediately).
196    /// If the timer `id` was already started, then the previous `Start` is canceled and the driver
197    /// will restart the timer. Note that this may race with the expiration of the previous timer,
198    /// for instance the notification process may be already started and a new `Start` call won't
199    /// be able to stop a notification that is already in flight.
200    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
201    /// If the specified `resolution` is not supported per the `resolutions` provided by
202    /// `GetProperties`, then this call will return `INVALID_ARGS`.
203    /// If the specified `ticks` is beyond the range supported for the timer as provided by
204    /// `GetProperties`, then this call will return `INVALID_ARGS`.
205    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
206    pub fn r#start(
207        &self,
208        mut id: u64,
209        mut resolution: &Resolution,
210        mut ticks: u64,
211        ___deadline: zx::MonotonicInstant,
212    ) -> Result<DeviceStartResult, fidl::Error> {
213        let _response = self.client.send_query::<
214            DeviceStartRequest,
215            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
216        >(
217            (id, resolution, ticks,),
218            0x5a0a193b0467cc8a,
219            fidl::encoding::DynamicFlags::FLEXIBLE,
220            ___deadline,
221        )?
222        .into_result::<DeviceMarker>("start")?;
223        Ok(_response.map(|x| x))
224    }
225
226    /// Read the current timer's set or timeout value.
227    ///
228    /// The returned ticks are in time-units relative to the given resolution.
229    /// Use `GetProperties()` to determine the available resolution(s).
230    ///
231    /// Errors:
232    ///   BAD_STATE: no readable timer currently exists.
233    ///   INVALID_ARGS: `id` or `resolution` are invalid or unsupported values.
234    ///   NOT_SUPPORTED: if `supports_read` is false, or the method is otherwise
235    ///     not implemented.
236    ///   INTERNAL_ERROR: internal runtime error.
237    pub fn r#read_timer(
238        &self,
239        mut id: u64,
240        mut resolution: &Resolution,
241        ___deadline: zx::MonotonicInstant,
242    ) -> Result<DeviceReadTimerResult, fidl::Error> {
243        let _response = self.client.send_query::<
244            DeviceReadTimerRequest,
245            fidl::encoding::FlexibleResultType<DeviceReadTimerResponse, DriverError>,
246        >(
247            (id, resolution,),
248            0x4430d0e336ffb5e9,
249            fidl::encoding::DynamicFlags::FLEXIBLE,
250            ___deadline,
251        )?
252        .into_result::<DeviceMarker>("read_timer")?;
253        Ok(_response.map(|x| x.ticks))
254    }
255
256    /// Read the current timer's clock value.
257    ///
258    /// The returned ticks are in time-units relative to the given resolution.
259    /// Use `GetProperties()` to determine the available resolution(s).
260    ///
261    /// Errors:
262    ///   BAD_STATE: no clock is currently running.
263    ///   INVALID_ARGS: `id` or `resolution` are invalid or unsupported values.
264    ///   NOT_SUPPORTED: if `supports_read` is false, or the method is otherwise
265    ///     not implemented.
266    ///   INTERNAL_ERROR: internal runtime error.
267    pub fn r#read_clock(
268        &self,
269        mut id: u64,
270        mut resolution: &Resolution,
271        ___deadline: zx::MonotonicInstant,
272    ) -> Result<DeviceReadClockResult, fidl::Error> {
273        let _response = self.client.send_query::<
274            DeviceReadClockRequest,
275            fidl::encoding::FlexibleResultType<DeviceReadClockResponse, DriverError>,
276        >(
277            (id, resolution,),
278            0x49aae10e0fb621ab,
279            fidl::encoding::DynamicFlags::FLEXIBLE,
280            ___deadline,
281        )?
282        .into_result::<DeviceMarker>("read_clock")?;
283        Ok(_response.map(|x| x.ticks))
284    }
285
286    /// Stops the timer `id`.
287    ///
288    /// Note that this may race with the expiration of the timer, for instance notification via
289    /// an event set with `SetEvent` may be already in flight.
290    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
291    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
292    pub fn r#stop(
293        &self,
294        mut id: u64,
295        ___deadline: zx::MonotonicInstant,
296    ) -> Result<DeviceStopResult, fidl::Error> {
297        let _response = self.client.send_query::<
298            DeviceStopRequest,
299            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
300        >(
301            (id,),
302            0x77e4cd1c3841a0e2,
303            fidl::encoding::DynamicFlags::FLEXIBLE,
304            ___deadline,
305        )?
306        .into_result::<DeviceMarker>("stop")?;
307        Ok(_response.map(|x| x))
308    }
309
310    /// Get the current time in ticks left in timer `id` until expiration.
311    ///
312    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
313    pub fn r#get_ticks_left(
314        &self,
315        mut id: u64,
316        ___deadline: zx::MonotonicInstant,
317    ) -> Result<DeviceGetTicksLeftResult, fidl::Error> {
318        let _response = self.client.send_query::<
319            DeviceGetTicksLeftRequest,
320            fidl::encoding::FlexibleResultType<DeviceGetTicksLeftResponse, DriverError>,
321        >(
322            (id,),
323            0xde2a48ae7d4b4ea,
324            fidl::encoding::DynamicFlags::FLEXIBLE,
325            ___deadline,
326        )?
327        .into_result::<DeviceMarker>("get_ticks_left")?;
328        Ok(_response.map(|x| x.ticks))
329    }
330
331    /// Sets a Zircon Event to be notified of the timer expiration.
332    ///
333    /// The timer expiration will be notified via the ZX_EVENT_SIGNALED signal.
334    /// The client is responsible for clearing the ZX_EVENT_SIGNALED signal.
335    /// Any previously event set for the specific `id` is replaced. Note that this may race with
336    /// the event signaling from the expiration of a timer already started.
337    /// To guarantee that an event is delivered upon timer expiration, this method must be
338    /// called before calling `Start`.
339    ///
340    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
341    /// If this method is not supported for the given `id`, then this call will return
342    /// `NOT_SUPPORTED`.
343    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
344    pub fn r#set_event(
345        &self,
346        mut id: u64,
347        mut event: fidl::Event,
348        ___deadline: zx::MonotonicInstant,
349    ) -> Result<DeviceSetEventResult, fidl::Error> {
350        let _response = self.client.send_query::<
351            DeviceSetEventRequest,
352            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
353        >(
354            (id, event,),
355            0x1027024d25ffa820,
356            fidl::encoding::DynamicFlags::FLEXIBLE,
357            ___deadline,
358        )?
359        .into_result::<DeviceMarker>("set_event")?;
360        Ok(_response.map(|x| x))
361    }
362
363    /// Start the timer `id` to expire after `ticks` and waits until the timer expires with
364    /// support for preventing suspension via the Power Framework.
365    ///
366    /// The driver will signal the `setup_event` event once the timer has been setup using the
367    /// ZX_EVENT_SIGNALED signal. This allows a client to know that it is safe to allow the
368    /// system to suspend. The client is responsible for clearing this event.
369    ///
370    /// The driver will not respond to this call (hang) until the timer has triggered.
371    /// Calling `Stop` on the timer will abort this call and return `CANCELED`. Note that this
372    /// may race with the expiration of the timer.
373    ///
374    /// A driver supporting this call must be able to get a lease on a power element that keeps
375    /// the system from suspending. This lease is returned to the client via the `keep_alive`
376    /// LeaseToken channel field. When `keep_alive` is closed, then the driver lease keeping the
377    /// system from suspending will be dropped. Hence, to guarantee that the system is not
378    /// suspended by the Power Framework a client must either keep this `keep_alive` token for
379    /// as long as the system needs to not suspend, or a client must get its own lease from the
380    /// Power Framework to prevent suspension before it drops `keep_alive`.
381    ///
382    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
383    /// If this method is not supported for the given `id`, then this call will return
384    /// `NOT_SUPPORTED`.
385    /// If the driver does not have a `keep_alive` token to provide to the client, then this
386    /// call will return `BAD_STATE`.
387    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
388    pub fn r#start_and_wait(
389        &self,
390        mut id: u64,
391        mut resolution: &Resolution,
392        mut ticks: u64,
393        mut setup_event: fidl::Event,
394        ___deadline: zx::MonotonicInstant,
395    ) -> Result<DeviceStartAndWaitResult, fidl::Error> {
396        let _response = self.client.send_query::<
397            DeviceStartAndWaitRequest,
398            fidl::encoding::FlexibleResultType<DeviceStartAndWaitResponse, DriverError>,
399        >(
400            (id, resolution, ticks, setup_event,),
401            0x716f415cdf234e0f,
402            fidl::encoding::DynamicFlags::FLEXIBLE,
403            ___deadline,
404        )?
405        .into_result::<DeviceMarker>("start_and_wait")?;
406        Ok(_response.map(|x| x.keep_alive))
407    }
408
409    /// Start timer `id` and wait for it to expire after `ticks` ticks.
410    ///
411    /// The driver will not respond to this call (hang) until the timer has triggered.
412    /// Calling `Stop` on the timer will abort this call and return `CANCELED`. Note that this
413    /// may race with the expiration of the timer.
414    ///
415    /// This method keeps the system awake (prevents suspension) while the timer is setup using the
416    /// mandatory passed-in `setup_keep_alive` `LeaseToken`.
417    /// When the timer expires this method returns a second `expiration_keep_alive`
418    /// `LeaseToken` to prevent suspension at the time of expiration.
419    /// These keep alive wake lease tokens are provided by the Power Framework's System Activity
420    /// Governor. A driver supporting this call must be able to get `expiration_keep_alive` from
421    /// System Activity Governor.
422    ///
423    /// When `expiration_keep_alive` is closed, then this driver created wake lease keeping the
424    /// system from suspending at the time of the timer expiration is dropped. Hence, to guarantee
425    /// that the system is not suspended by the Power Framework a client must either keep this
426    /// `expiration_keep_alive` for as long as the system needs to stay awake, or a client must
427    /// get its own wake lease from the Power Framework before it drops `expiration_keep_alive` to
428    /// prevent suspension.
429    ///
430    /// Errors:
431    ///
432    /// * INVALID_ARGS: The specified `id` is invalid.
433    /// * NOT_SUPPORTED: This method is not supported for the given `id`.
434    /// * BAD_STATE: The driver is in a bad state, for instance it does not have an
435    ///   `expiration_keep_alive` token to provide to the client.
436    /// * INTERNAL_ERROR: The driver encountered an internal error.
437    pub fn r#start_and_wait2(
438        &self,
439        mut id: u64,
440        mut resolution: &Resolution,
441        mut ticks: u64,
442        mut setup_keep_alive: fidl::EventPair,
443        ___deadline: zx::MonotonicInstant,
444    ) -> Result<DeviceStartAndWait2Result, fidl::Error> {
445        let _response = self.client.send_query::<
446            DeviceStartAndWait2Request,
447            fidl::encoding::FlexibleResultType<DeviceStartAndWait2Response, DriverError>,
448        >(
449            (id, resolution, ticks, setup_keep_alive,),
450            0x5f2aaf21254d3238,
451            fidl::encoding::DynamicFlags::FLEXIBLE,
452            ___deadline,
453        )?
454        .into_result::<DeviceMarker>("start_and_wait2")?;
455        Ok(_response.map(|x| x.expiration_keep_alive))
456    }
457
458    /// Get driver properties.
459    pub fn r#get_properties(
460        &self,
461        ___deadline: zx::MonotonicInstant,
462    ) -> Result<Properties, fidl::Error> {
463        let _response = self.client.send_query::<
464            fidl::encoding::EmptyPayload,
465            fidl::encoding::FlexibleType<DeviceGetPropertiesResponse>,
466        >(
467            (),
468            0x6bc22ab4c9396cbb,
469            fidl::encoding::DynamicFlags::FLEXIBLE,
470            ___deadline,
471        )?
472        .into_result::<DeviceMarker>("get_properties")?;
473        Ok(_response.properties)
474    }
475}
476
477#[cfg(target_os = "fuchsia")]
478impl From<DeviceSynchronousProxy> for zx::NullableHandle {
479    fn from(value: DeviceSynchronousProxy) -> Self {
480        value.into_channel().into()
481    }
482}
483
484#[cfg(target_os = "fuchsia")]
485impl From<fidl::Channel> for DeviceSynchronousProxy {
486    fn from(value: fidl::Channel) -> Self {
487        Self::new(value)
488    }
489}
490
491#[cfg(target_os = "fuchsia")]
492impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
493    type Protocol = DeviceMarker;
494
495    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
496        Self::new(value.into_channel())
497    }
498}
499
500#[derive(Debug, Clone)]
501pub struct DeviceProxy {
502    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
503}
504
505impl fidl::endpoints::Proxy for DeviceProxy {
506    type Protocol = DeviceMarker;
507
508    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
509        Self::new(inner)
510    }
511
512    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
513        self.client.into_channel().map_err(|client| Self { client })
514    }
515
516    fn as_channel(&self) -> &::fidl::AsyncChannel {
517        self.client.as_channel()
518    }
519}
520
521impl DeviceProxy {
522    /// Create a new Proxy for fuchsia.hardware.hrtimer/Device.
523    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
524        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
525        Self { client: fidl::client::Client::new(channel, protocol_name) }
526    }
527
528    /// Get a Stream of events from the remote end of the protocol.
529    ///
530    /// # Panics
531    ///
532    /// Panics if the event stream was already taken.
533    pub fn take_event_stream(&self) -> DeviceEventStream {
534        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
535    }
536
537    /// Start the timer `id` to expire after `ticks`.
538    ///
539    /// If `ticks` is 0 then the timer will expire in 0 ticks (immediately).
540    /// If the timer `id` was already started, then the previous `Start` is canceled and the driver
541    /// will restart the timer. Note that this may race with the expiration of the previous timer,
542    /// for instance the notification process may be already started and a new `Start` call won't
543    /// be able to stop a notification that is already in flight.
544    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
545    /// If the specified `resolution` is not supported per the `resolutions` provided by
546    /// `GetProperties`, then this call will return `INVALID_ARGS`.
547    /// If the specified `ticks` is beyond the range supported for the timer as provided by
548    /// `GetProperties`, then this call will return `INVALID_ARGS`.
549    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
550    pub fn r#start(
551        &self,
552        mut id: u64,
553        mut resolution: &Resolution,
554        mut ticks: u64,
555    ) -> fidl::client::QueryResponseFut<
556        DeviceStartResult,
557        fidl::encoding::DefaultFuchsiaResourceDialect,
558    > {
559        DeviceProxyInterface::r#start(self, id, resolution, ticks)
560    }
561
562    /// Read the current timer's set or timeout value.
563    ///
564    /// The returned ticks are in time-units relative to the given resolution.
565    /// Use `GetProperties()` to determine the available resolution(s).
566    ///
567    /// Errors:
568    ///   BAD_STATE: no readable timer currently exists.
569    ///   INVALID_ARGS: `id` or `resolution` are invalid or unsupported values.
570    ///   NOT_SUPPORTED: if `supports_read` is false, or the method is otherwise
571    ///     not implemented.
572    ///   INTERNAL_ERROR: internal runtime error.
573    pub fn r#read_timer(
574        &self,
575        mut id: u64,
576        mut resolution: &Resolution,
577    ) -> fidl::client::QueryResponseFut<
578        DeviceReadTimerResult,
579        fidl::encoding::DefaultFuchsiaResourceDialect,
580    > {
581        DeviceProxyInterface::r#read_timer(self, id, resolution)
582    }
583
584    /// Read the current timer's clock value.
585    ///
586    /// The returned ticks are in time-units relative to the given resolution.
587    /// Use `GetProperties()` to determine the available resolution(s).
588    ///
589    /// Errors:
590    ///   BAD_STATE: no clock is currently running.
591    ///   INVALID_ARGS: `id` or `resolution` are invalid or unsupported values.
592    ///   NOT_SUPPORTED: if `supports_read` is false, or the method is otherwise
593    ///     not implemented.
594    ///   INTERNAL_ERROR: internal runtime error.
595    pub fn r#read_clock(
596        &self,
597        mut id: u64,
598        mut resolution: &Resolution,
599    ) -> fidl::client::QueryResponseFut<
600        DeviceReadClockResult,
601        fidl::encoding::DefaultFuchsiaResourceDialect,
602    > {
603        DeviceProxyInterface::r#read_clock(self, id, resolution)
604    }
605
606    /// Stops the timer `id`.
607    ///
608    /// Note that this may race with the expiration of the timer, for instance notification via
609    /// an event set with `SetEvent` may be already in flight.
610    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
611    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
612    pub fn r#stop(
613        &self,
614        mut id: u64,
615    ) -> fidl::client::QueryResponseFut<
616        DeviceStopResult,
617        fidl::encoding::DefaultFuchsiaResourceDialect,
618    > {
619        DeviceProxyInterface::r#stop(self, id)
620    }
621
622    /// Get the current time in ticks left in timer `id` until expiration.
623    ///
624    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
625    pub fn r#get_ticks_left(
626        &self,
627        mut id: u64,
628    ) -> fidl::client::QueryResponseFut<
629        DeviceGetTicksLeftResult,
630        fidl::encoding::DefaultFuchsiaResourceDialect,
631    > {
632        DeviceProxyInterface::r#get_ticks_left(self, id)
633    }
634
635    /// Sets a Zircon Event to be notified of the timer expiration.
636    ///
637    /// The timer expiration will be notified via the ZX_EVENT_SIGNALED signal.
638    /// The client is responsible for clearing the ZX_EVENT_SIGNALED signal.
639    /// Any previously event set for the specific `id` is replaced. Note that this may race with
640    /// the event signaling from the expiration of a timer already started.
641    /// To guarantee that an event is delivered upon timer expiration, this method must be
642    /// called before calling `Start`.
643    ///
644    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
645    /// If this method is not supported for the given `id`, then this call will return
646    /// `NOT_SUPPORTED`.
647    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
648    pub fn r#set_event(
649        &self,
650        mut id: u64,
651        mut event: fidl::Event,
652    ) -> fidl::client::QueryResponseFut<
653        DeviceSetEventResult,
654        fidl::encoding::DefaultFuchsiaResourceDialect,
655    > {
656        DeviceProxyInterface::r#set_event(self, id, event)
657    }
658
659    /// Start the timer `id` to expire after `ticks` and waits until the timer expires with
660    /// support for preventing suspension via the Power Framework.
661    ///
662    /// The driver will signal the `setup_event` event once the timer has been setup using the
663    /// ZX_EVENT_SIGNALED signal. This allows a client to know that it is safe to allow the
664    /// system to suspend. The client is responsible for clearing this event.
665    ///
666    /// The driver will not respond to this call (hang) until the timer has triggered.
667    /// Calling `Stop` on the timer will abort this call and return `CANCELED`. Note that this
668    /// may race with the expiration of the timer.
669    ///
670    /// A driver supporting this call must be able to get a lease on a power element that keeps
671    /// the system from suspending. This lease is returned to the client via the `keep_alive`
672    /// LeaseToken channel field. When `keep_alive` is closed, then the driver lease keeping the
673    /// system from suspending will be dropped. Hence, to guarantee that the system is not
674    /// suspended by the Power Framework a client must either keep this `keep_alive` token for
675    /// as long as the system needs to not suspend, or a client must get its own lease from the
676    /// Power Framework to prevent suspension before it drops `keep_alive`.
677    ///
678    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
679    /// If this method is not supported for the given `id`, then this call will return
680    /// `NOT_SUPPORTED`.
681    /// If the driver does not have a `keep_alive` token to provide to the client, then this
682    /// call will return `BAD_STATE`.
683    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
684    pub fn r#start_and_wait(
685        &self,
686        mut id: u64,
687        mut resolution: &Resolution,
688        mut ticks: u64,
689        mut setup_event: fidl::Event,
690    ) -> fidl::client::QueryResponseFut<
691        DeviceStartAndWaitResult,
692        fidl::encoding::DefaultFuchsiaResourceDialect,
693    > {
694        DeviceProxyInterface::r#start_and_wait(self, id, resolution, ticks, setup_event)
695    }
696
697    /// Start timer `id` and wait for it to expire after `ticks` ticks.
698    ///
699    /// The driver will not respond to this call (hang) until the timer has triggered.
700    /// Calling `Stop` on the timer will abort this call and return `CANCELED`. Note that this
701    /// may race with the expiration of the timer.
702    ///
703    /// This method keeps the system awake (prevents suspension) while the timer is setup using the
704    /// mandatory passed-in `setup_keep_alive` `LeaseToken`.
705    /// When the timer expires this method returns a second `expiration_keep_alive`
706    /// `LeaseToken` to prevent suspension at the time of expiration.
707    /// These keep alive wake lease tokens are provided by the Power Framework's System Activity
708    /// Governor. A driver supporting this call must be able to get `expiration_keep_alive` from
709    /// System Activity Governor.
710    ///
711    /// When `expiration_keep_alive` is closed, then this driver created wake lease keeping the
712    /// system from suspending at the time of the timer expiration is dropped. Hence, to guarantee
713    /// that the system is not suspended by the Power Framework a client must either keep this
714    /// `expiration_keep_alive` for as long as the system needs to stay awake, or a client must
715    /// get its own wake lease from the Power Framework before it drops `expiration_keep_alive` to
716    /// prevent suspension.
717    ///
718    /// Errors:
719    ///
720    /// * INVALID_ARGS: The specified `id` is invalid.
721    /// * NOT_SUPPORTED: This method is not supported for the given `id`.
722    /// * BAD_STATE: The driver is in a bad state, for instance it does not have an
723    ///   `expiration_keep_alive` token to provide to the client.
724    /// * INTERNAL_ERROR: The driver encountered an internal error.
725    pub fn r#start_and_wait2(
726        &self,
727        mut id: u64,
728        mut resolution: &Resolution,
729        mut ticks: u64,
730        mut setup_keep_alive: fidl::EventPair,
731    ) -> fidl::client::QueryResponseFut<
732        DeviceStartAndWait2Result,
733        fidl::encoding::DefaultFuchsiaResourceDialect,
734    > {
735        DeviceProxyInterface::r#start_and_wait2(self, id, resolution, ticks, setup_keep_alive)
736    }
737
738    /// Get driver properties.
739    pub fn r#get_properties(
740        &self,
741    ) -> fidl::client::QueryResponseFut<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>
742    {
743        DeviceProxyInterface::r#get_properties(self)
744    }
745}
746
747impl DeviceProxyInterface for DeviceProxy {
748    type StartResponseFut = fidl::client::QueryResponseFut<
749        DeviceStartResult,
750        fidl::encoding::DefaultFuchsiaResourceDialect,
751    >;
752    fn r#start(
753        &self,
754        mut id: u64,
755        mut resolution: &Resolution,
756        mut ticks: u64,
757    ) -> Self::StartResponseFut {
758        fn _decode(
759            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
760        ) -> Result<DeviceStartResult, fidl::Error> {
761            let _response = fidl::client::decode_transaction_body::<
762                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
763                fidl::encoding::DefaultFuchsiaResourceDialect,
764                0x5a0a193b0467cc8a,
765            >(_buf?)?
766            .into_result::<DeviceMarker>("start")?;
767            Ok(_response.map(|x| x))
768        }
769        self.client.send_query_and_decode::<DeviceStartRequest, DeviceStartResult>(
770            (id, resolution, ticks),
771            0x5a0a193b0467cc8a,
772            fidl::encoding::DynamicFlags::FLEXIBLE,
773            _decode,
774        )
775    }
776
777    type ReadTimerResponseFut = fidl::client::QueryResponseFut<
778        DeviceReadTimerResult,
779        fidl::encoding::DefaultFuchsiaResourceDialect,
780    >;
781    fn r#read_timer(&self, mut id: u64, mut resolution: &Resolution) -> Self::ReadTimerResponseFut {
782        fn _decode(
783            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
784        ) -> Result<DeviceReadTimerResult, fidl::Error> {
785            let _response = fidl::client::decode_transaction_body::<
786                fidl::encoding::FlexibleResultType<DeviceReadTimerResponse, DriverError>,
787                fidl::encoding::DefaultFuchsiaResourceDialect,
788                0x4430d0e336ffb5e9,
789            >(_buf?)?
790            .into_result::<DeviceMarker>("read_timer")?;
791            Ok(_response.map(|x| x.ticks))
792        }
793        self.client.send_query_and_decode::<DeviceReadTimerRequest, DeviceReadTimerResult>(
794            (id, resolution),
795            0x4430d0e336ffb5e9,
796            fidl::encoding::DynamicFlags::FLEXIBLE,
797            _decode,
798        )
799    }
800
801    type ReadClockResponseFut = fidl::client::QueryResponseFut<
802        DeviceReadClockResult,
803        fidl::encoding::DefaultFuchsiaResourceDialect,
804    >;
805    fn r#read_clock(&self, mut id: u64, mut resolution: &Resolution) -> Self::ReadClockResponseFut {
806        fn _decode(
807            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
808        ) -> Result<DeviceReadClockResult, fidl::Error> {
809            let _response = fidl::client::decode_transaction_body::<
810                fidl::encoding::FlexibleResultType<DeviceReadClockResponse, DriverError>,
811                fidl::encoding::DefaultFuchsiaResourceDialect,
812                0x49aae10e0fb621ab,
813            >(_buf?)?
814            .into_result::<DeviceMarker>("read_clock")?;
815            Ok(_response.map(|x| x.ticks))
816        }
817        self.client.send_query_and_decode::<DeviceReadClockRequest, DeviceReadClockResult>(
818            (id, resolution),
819            0x49aae10e0fb621ab,
820            fidl::encoding::DynamicFlags::FLEXIBLE,
821            _decode,
822        )
823    }
824
825    type StopResponseFut = fidl::client::QueryResponseFut<
826        DeviceStopResult,
827        fidl::encoding::DefaultFuchsiaResourceDialect,
828    >;
829    fn r#stop(&self, mut id: u64) -> Self::StopResponseFut {
830        fn _decode(
831            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
832        ) -> Result<DeviceStopResult, fidl::Error> {
833            let _response = fidl::client::decode_transaction_body::<
834                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
835                fidl::encoding::DefaultFuchsiaResourceDialect,
836                0x77e4cd1c3841a0e2,
837            >(_buf?)?
838            .into_result::<DeviceMarker>("stop")?;
839            Ok(_response.map(|x| x))
840        }
841        self.client.send_query_and_decode::<DeviceStopRequest, DeviceStopResult>(
842            (id,),
843            0x77e4cd1c3841a0e2,
844            fidl::encoding::DynamicFlags::FLEXIBLE,
845            _decode,
846        )
847    }
848
849    type GetTicksLeftResponseFut = fidl::client::QueryResponseFut<
850        DeviceGetTicksLeftResult,
851        fidl::encoding::DefaultFuchsiaResourceDialect,
852    >;
853    fn r#get_ticks_left(&self, mut id: u64) -> Self::GetTicksLeftResponseFut {
854        fn _decode(
855            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
856        ) -> Result<DeviceGetTicksLeftResult, fidl::Error> {
857            let _response = fidl::client::decode_transaction_body::<
858                fidl::encoding::FlexibleResultType<DeviceGetTicksLeftResponse, DriverError>,
859                fidl::encoding::DefaultFuchsiaResourceDialect,
860                0xde2a48ae7d4b4ea,
861            >(_buf?)?
862            .into_result::<DeviceMarker>("get_ticks_left")?;
863            Ok(_response.map(|x| x.ticks))
864        }
865        self.client.send_query_and_decode::<DeviceGetTicksLeftRequest, DeviceGetTicksLeftResult>(
866            (id,),
867            0xde2a48ae7d4b4ea,
868            fidl::encoding::DynamicFlags::FLEXIBLE,
869            _decode,
870        )
871    }
872
873    type SetEventResponseFut = fidl::client::QueryResponseFut<
874        DeviceSetEventResult,
875        fidl::encoding::DefaultFuchsiaResourceDialect,
876    >;
877    fn r#set_event(&self, mut id: u64, mut event: fidl::Event) -> Self::SetEventResponseFut {
878        fn _decode(
879            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
880        ) -> Result<DeviceSetEventResult, fidl::Error> {
881            let _response = fidl::client::decode_transaction_body::<
882                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
883                fidl::encoding::DefaultFuchsiaResourceDialect,
884                0x1027024d25ffa820,
885            >(_buf?)?
886            .into_result::<DeviceMarker>("set_event")?;
887            Ok(_response.map(|x| x))
888        }
889        self.client.send_query_and_decode::<DeviceSetEventRequest, DeviceSetEventResult>(
890            (id, event),
891            0x1027024d25ffa820,
892            fidl::encoding::DynamicFlags::FLEXIBLE,
893            _decode,
894        )
895    }
896
897    type StartAndWaitResponseFut = fidl::client::QueryResponseFut<
898        DeviceStartAndWaitResult,
899        fidl::encoding::DefaultFuchsiaResourceDialect,
900    >;
901    fn r#start_and_wait(
902        &self,
903        mut id: u64,
904        mut resolution: &Resolution,
905        mut ticks: u64,
906        mut setup_event: fidl::Event,
907    ) -> Self::StartAndWaitResponseFut {
908        fn _decode(
909            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
910        ) -> Result<DeviceStartAndWaitResult, fidl::Error> {
911            let _response = fidl::client::decode_transaction_body::<
912                fidl::encoding::FlexibleResultType<DeviceStartAndWaitResponse, DriverError>,
913                fidl::encoding::DefaultFuchsiaResourceDialect,
914                0x716f415cdf234e0f,
915            >(_buf?)?
916            .into_result::<DeviceMarker>("start_and_wait")?;
917            Ok(_response.map(|x| x.keep_alive))
918        }
919        self.client.send_query_and_decode::<DeviceStartAndWaitRequest, DeviceStartAndWaitResult>(
920            (id, resolution, ticks, setup_event),
921            0x716f415cdf234e0f,
922            fidl::encoding::DynamicFlags::FLEXIBLE,
923            _decode,
924        )
925    }
926
927    type StartAndWait2ResponseFut = fidl::client::QueryResponseFut<
928        DeviceStartAndWait2Result,
929        fidl::encoding::DefaultFuchsiaResourceDialect,
930    >;
931    fn r#start_and_wait2(
932        &self,
933        mut id: u64,
934        mut resolution: &Resolution,
935        mut ticks: u64,
936        mut setup_keep_alive: fidl::EventPair,
937    ) -> Self::StartAndWait2ResponseFut {
938        fn _decode(
939            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
940        ) -> Result<DeviceStartAndWait2Result, fidl::Error> {
941            let _response = fidl::client::decode_transaction_body::<
942                fidl::encoding::FlexibleResultType<DeviceStartAndWait2Response, DriverError>,
943                fidl::encoding::DefaultFuchsiaResourceDialect,
944                0x5f2aaf21254d3238,
945            >(_buf?)?
946            .into_result::<DeviceMarker>("start_and_wait2")?;
947            Ok(_response.map(|x| x.expiration_keep_alive))
948        }
949        self.client.send_query_and_decode::<DeviceStartAndWait2Request, DeviceStartAndWait2Result>(
950            (id, resolution, ticks, setup_keep_alive),
951            0x5f2aaf21254d3238,
952            fidl::encoding::DynamicFlags::FLEXIBLE,
953            _decode,
954        )
955    }
956
957    type GetPropertiesResponseFut =
958        fidl::client::QueryResponseFut<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>;
959    fn r#get_properties(&self) -> Self::GetPropertiesResponseFut {
960        fn _decode(
961            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
962        ) -> Result<Properties, fidl::Error> {
963            let _response = fidl::client::decode_transaction_body::<
964                fidl::encoding::FlexibleType<DeviceGetPropertiesResponse>,
965                fidl::encoding::DefaultFuchsiaResourceDialect,
966                0x6bc22ab4c9396cbb,
967            >(_buf?)?
968            .into_result::<DeviceMarker>("get_properties")?;
969            Ok(_response.properties)
970        }
971        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Properties>(
972            (),
973            0x6bc22ab4c9396cbb,
974            fidl::encoding::DynamicFlags::FLEXIBLE,
975            _decode,
976        )
977    }
978}
979
980pub struct DeviceEventStream {
981    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
982}
983
984impl std::marker::Unpin for DeviceEventStream {}
985
986impl futures::stream::FusedStream for DeviceEventStream {
987    fn is_terminated(&self) -> bool {
988        self.event_receiver.is_terminated()
989    }
990}
991
992impl futures::Stream for DeviceEventStream {
993    type Item = Result<DeviceEvent, fidl::Error>;
994
995    fn poll_next(
996        mut self: std::pin::Pin<&mut Self>,
997        cx: &mut std::task::Context<'_>,
998    ) -> std::task::Poll<Option<Self::Item>> {
999        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1000            &mut self.event_receiver,
1001            cx
1002        )?) {
1003            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1004            None => std::task::Poll::Ready(None),
1005        }
1006    }
1007}
1008
1009#[derive(Debug)]
1010pub enum DeviceEvent {
1011    #[non_exhaustive]
1012    _UnknownEvent {
1013        /// Ordinal of the event that was sent.
1014        ordinal: u64,
1015    },
1016}
1017
1018impl DeviceEvent {
1019    /// Decodes a message buffer as a [`DeviceEvent`].
1020    fn decode(
1021        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1022    ) -> Result<DeviceEvent, fidl::Error> {
1023        let (bytes, _handles) = buf.split_mut();
1024        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1025        debug_assert_eq!(tx_header.tx_id, 0);
1026        match tx_header.ordinal {
1027            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1028                Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1029            }
1030            _ => Err(fidl::Error::UnknownOrdinal {
1031                ordinal: tx_header.ordinal,
1032                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1033            }),
1034        }
1035    }
1036}
1037
1038/// A Stream of incoming requests for fuchsia.hardware.hrtimer/Device.
1039pub struct DeviceRequestStream {
1040    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1041    is_terminated: bool,
1042}
1043
1044impl std::marker::Unpin for DeviceRequestStream {}
1045
1046impl futures::stream::FusedStream for DeviceRequestStream {
1047    fn is_terminated(&self) -> bool {
1048        self.is_terminated
1049    }
1050}
1051
1052impl fidl::endpoints::RequestStream for DeviceRequestStream {
1053    type Protocol = DeviceMarker;
1054    type ControlHandle = DeviceControlHandle;
1055
1056    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1057        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1058    }
1059
1060    fn control_handle(&self) -> Self::ControlHandle {
1061        DeviceControlHandle { inner: self.inner.clone() }
1062    }
1063
1064    fn into_inner(
1065        self,
1066    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1067    {
1068        (self.inner, self.is_terminated)
1069    }
1070
1071    fn from_inner(
1072        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1073        is_terminated: bool,
1074    ) -> Self {
1075        Self { inner, is_terminated }
1076    }
1077}
1078
1079impl futures::Stream for DeviceRequestStream {
1080    type Item = Result<DeviceRequest, fidl::Error>;
1081
1082    fn poll_next(
1083        mut self: std::pin::Pin<&mut Self>,
1084        cx: &mut std::task::Context<'_>,
1085    ) -> std::task::Poll<Option<Self::Item>> {
1086        let this = &mut *self;
1087        if this.inner.check_shutdown(cx) {
1088            this.is_terminated = true;
1089            return std::task::Poll::Ready(None);
1090        }
1091        if this.is_terminated {
1092            panic!("polled DeviceRequestStream after completion");
1093        }
1094        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1095            |bytes, handles| {
1096                match this.inner.channel().read_etc(cx, bytes, handles) {
1097                    std::task::Poll::Ready(Ok(())) => {}
1098                    std::task::Poll::Pending => return std::task::Poll::Pending,
1099                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1100                        this.is_terminated = true;
1101                        return std::task::Poll::Ready(None);
1102                    }
1103                    std::task::Poll::Ready(Err(e)) => {
1104                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1105                            e.into(),
1106                        ))));
1107                    }
1108                }
1109
1110                // A message has been received from the channel
1111                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1112
1113                std::task::Poll::Ready(Some(match header.ordinal {
1114                    0x5a0a193b0467cc8a => {
1115                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1116                        let mut req = fidl::new_empty!(
1117                            DeviceStartRequest,
1118                            fidl::encoding::DefaultFuchsiaResourceDialect
1119                        );
1120                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStartRequest>(&header, _body_bytes, handles, &mut req)?;
1121                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1122                        Ok(DeviceRequest::Start {
1123                            id: req.id,
1124                            resolution: req.resolution,
1125                            ticks: req.ticks,
1126
1127                            responder: DeviceStartResponder {
1128                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1129                                tx_id: header.tx_id,
1130                            },
1131                        })
1132                    }
1133                    0x4430d0e336ffb5e9 => {
1134                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1135                        let mut req = fidl::new_empty!(
1136                            DeviceReadTimerRequest,
1137                            fidl::encoding::DefaultFuchsiaResourceDialect
1138                        );
1139                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceReadTimerRequest>(&header, _body_bytes, handles, &mut req)?;
1140                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1141                        Ok(DeviceRequest::ReadTimer {
1142                            id: req.id,
1143                            resolution: req.resolution,
1144
1145                            responder: DeviceReadTimerResponder {
1146                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1147                                tx_id: header.tx_id,
1148                            },
1149                        })
1150                    }
1151                    0x49aae10e0fb621ab => {
1152                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1153                        let mut req = fidl::new_empty!(
1154                            DeviceReadClockRequest,
1155                            fidl::encoding::DefaultFuchsiaResourceDialect
1156                        );
1157                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceReadClockRequest>(&header, _body_bytes, handles, &mut req)?;
1158                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1159                        Ok(DeviceRequest::ReadClock {
1160                            id: req.id,
1161                            resolution: req.resolution,
1162
1163                            responder: DeviceReadClockResponder {
1164                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1165                                tx_id: header.tx_id,
1166                            },
1167                        })
1168                    }
1169                    0x77e4cd1c3841a0e2 => {
1170                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1171                        let mut req = fidl::new_empty!(
1172                            DeviceStopRequest,
1173                            fidl::encoding::DefaultFuchsiaResourceDialect
1174                        );
1175                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStopRequest>(&header, _body_bytes, handles, &mut req)?;
1176                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1177                        Ok(DeviceRequest::Stop {
1178                            id: req.id,
1179
1180                            responder: DeviceStopResponder {
1181                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1182                                tx_id: header.tx_id,
1183                            },
1184                        })
1185                    }
1186                    0xde2a48ae7d4b4ea => {
1187                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1188                        let mut req = fidl::new_empty!(
1189                            DeviceGetTicksLeftRequest,
1190                            fidl::encoding::DefaultFuchsiaResourceDialect
1191                        );
1192                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetTicksLeftRequest>(&header, _body_bytes, handles, &mut req)?;
1193                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1194                        Ok(DeviceRequest::GetTicksLeft {
1195                            id: req.id,
1196
1197                            responder: DeviceGetTicksLeftResponder {
1198                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1199                                tx_id: header.tx_id,
1200                            },
1201                        })
1202                    }
1203                    0x1027024d25ffa820 => {
1204                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1205                        let mut req = fidl::new_empty!(
1206                            DeviceSetEventRequest,
1207                            fidl::encoding::DefaultFuchsiaResourceDialect
1208                        );
1209                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetEventRequest>(&header, _body_bytes, handles, &mut req)?;
1210                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1211                        Ok(DeviceRequest::SetEvent {
1212                            id: req.id,
1213                            event: req.event,
1214
1215                            responder: DeviceSetEventResponder {
1216                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1217                                tx_id: header.tx_id,
1218                            },
1219                        })
1220                    }
1221                    0x716f415cdf234e0f => {
1222                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1223                        let mut req = fidl::new_empty!(
1224                            DeviceStartAndWaitRequest,
1225                            fidl::encoding::DefaultFuchsiaResourceDialect
1226                        );
1227                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStartAndWaitRequest>(&header, _body_bytes, handles, &mut req)?;
1228                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1229                        Ok(DeviceRequest::StartAndWait {
1230                            id: req.id,
1231                            resolution: req.resolution,
1232                            ticks: req.ticks,
1233                            setup_event: req.setup_event,
1234
1235                            responder: DeviceStartAndWaitResponder {
1236                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1237                                tx_id: header.tx_id,
1238                            },
1239                        })
1240                    }
1241                    0x5f2aaf21254d3238 => {
1242                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1243                        let mut req = fidl::new_empty!(
1244                            DeviceStartAndWait2Request,
1245                            fidl::encoding::DefaultFuchsiaResourceDialect
1246                        );
1247                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStartAndWait2Request>(&header, _body_bytes, handles, &mut req)?;
1248                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1249                        Ok(DeviceRequest::StartAndWait2 {
1250                            id: req.id,
1251                            resolution: req.resolution,
1252                            ticks: req.ticks,
1253                            setup_keep_alive: req.setup_keep_alive,
1254
1255                            responder: DeviceStartAndWait2Responder {
1256                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1257                                tx_id: header.tx_id,
1258                            },
1259                        })
1260                    }
1261                    0x6bc22ab4c9396cbb => {
1262                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1263                        let mut req = fidl::new_empty!(
1264                            fidl::encoding::EmptyPayload,
1265                            fidl::encoding::DefaultFuchsiaResourceDialect
1266                        );
1267                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1268                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1269                        Ok(DeviceRequest::GetProperties {
1270                            responder: DeviceGetPropertiesResponder {
1271                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1272                                tx_id: header.tx_id,
1273                            },
1274                        })
1275                    }
1276                    _ if header.tx_id == 0
1277                        && header
1278                            .dynamic_flags()
1279                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1280                    {
1281                        Ok(DeviceRequest::_UnknownMethod {
1282                            ordinal: header.ordinal,
1283                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
1284                            method_type: fidl::MethodType::OneWay,
1285                        })
1286                    }
1287                    _ if header
1288                        .dynamic_flags()
1289                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1290                    {
1291                        this.inner.send_framework_err(
1292                            fidl::encoding::FrameworkErr::UnknownMethod,
1293                            header.tx_id,
1294                            header.ordinal,
1295                            header.dynamic_flags(),
1296                            (bytes, handles),
1297                        )?;
1298                        Ok(DeviceRequest::_UnknownMethod {
1299                            ordinal: header.ordinal,
1300                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
1301                            method_type: fidl::MethodType::TwoWay,
1302                        })
1303                    }
1304                    _ => Err(fidl::Error::UnknownOrdinal {
1305                        ordinal: header.ordinal,
1306                        protocol_name:
1307                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1308                    }),
1309                }))
1310            },
1311        )
1312    }
1313}
1314
1315/// A driver providing high resolution timers support.
1316/// This API is intended for timers that are provided by hardware separate from the CPU
1317/// For instance this driver may abstract hardware provided by an SoC.
1318#[derive(Debug)]
1319pub enum DeviceRequest {
1320    /// Start the timer `id` to expire after `ticks`.
1321    ///
1322    /// If `ticks` is 0 then the timer will expire in 0 ticks (immediately).
1323    /// If the timer `id` was already started, then the previous `Start` is canceled and the driver
1324    /// will restart the timer. Note that this may race with the expiration of the previous timer,
1325    /// for instance the notification process may be already started and a new `Start` call won't
1326    /// be able to stop a notification that is already in flight.
1327    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
1328    /// If the specified `resolution` is not supported per the `resolutions` provided by
1329    /// `GetProperties`, then this call will return `INVALID_ARGS`.
1330    /// If the specified `ticks` is beyond the range supported for the timer as provided by
1331    /// `GetProperties`, then this call will return `INVALID_ARGS`.
1332    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
1333    Start { id: u64, resolution: Resolution, ticks: u64, responder: DeviceStartResponder },
1334    /// Read the current timer's set or timeout value.
1335    ///
1336    /// The returned ticks are in time-units relative to the given resolution.
1337    /// Use `GetProperties()` to determine the available resolution(s).
1338    ///
1339    /// Errors:
1340    ///   BAD_STATE: no readable timer currently exists.
1341    ///   INVALID_ARGS: `id` or `resolution` are invalid or unsupported values.
1342    ///   NOT_SUPPORTED: if `supports_read` is false, or the method is otherwise
1343    ///     not implemented.
1344    ///   INTERNAL_ERROR: internal runtime error.
1345    ReadTimer { id: u64, resolution: Resolution, responder: DeviceReadTimerResponder },
1346    /// Read the current timer's clock value.
1347    ///
1348    /// The returned ticks are in time-units relative to the given resolution.
1349    /// Use `GetProperties()` to determine the available resolution(s).
1350    ///
1351    /// Errors:
1352    ///   BAD_STATE: no clock is currently running.
1353    ///   INVALID_ARGS: `id` or `resolution` are invalid or unsupported values.
1354    ///   NOT_SUPPORTED: if `supports_read` is false, or the method is otherwise
1355    ///     not implemented.
1356    ///   INTERNAL_ERROR: internal runtime error.
1357    ReadClock { id: u64, resolution: Resolution, responder: DeviceReadClockResponder },
1358    /// Stops the timer `id`.
1359    ///
1360    /// Note that this may race with the expiration of the timer, for instance notification via
1361    /// an event set with `SetEvent` may be already in flight.
1362    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
1363    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
1364    Stop { id: u64, responder: DeviceStopResponder },
1365    /// Get the current time in ticks left in timer `id` until expiration.
1366    ///
1367    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
1368    GetTicksLeft { id: u64, responder: DeviceGetTicksLeftResponder },
1369    /// Sets a Zircon Event to be notified of the timer expiration.
1370    ///
1371    /// The timer expiration will be notified via the ZX_EVENT_SIGNALED signal.
1372    /// The client is responsible for clearing the ZX_EVENT_SIGNALED signal.
1373    /// Any previously event set for the specific `id` is replaced. Note that this may race with
1374    /// the event signaling from the expiration of a timer already started.
1375    /// To guarantee that an event is delivered upon timer expiration, this method must be
1376    /// called before calling `Start`.
1377    ///
1378    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
1379    /// If this method is not supported for the given `id`, then this call will return
1380    /// `NOT_SUPPORTED`.
1381    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
1382    SetEvent { id: u64, event: fidl::Event, responder: DeviceSetEventResponder },
1383    /// Start the timer `id` to expire after `ticks` and waits until the timer expires with
1384    /// support for preventing suspension via the Power Framework.
1385    ///
1386    /// The driver will signal the `setup_event` event once the timer has been setup using the
1387    /// ZX_EVENT_SIGNALED signal. This allows a client to know that it is safe to allow the
1388    /// system to suspend. The client is responsible for clearing this event.
1389    ///
1390    /// The driver will not respond to this call (hang) until the timer has triggered.
1391    /// Calling `Stop` on the timer will abort this call and return `CANCELED`. Note that this
1392    /// may race with the expiration of the timer.
1393    ///
1394    /// A driver supporting this call must be able to get a lease on a power element that keeps
1395    /// the system from suspending. This lease is returned to the client via the `keep_alive`
1396    /// LeaseToken channel field. When `keep_alive` is closed, then the driver lease keeping the
1397    /// system from suspending will be dropped. Hence, to guarantee that the system is not
1398    /// suspended by the Power Framework a client must either keep this `keep_alive` token for
1399    /// as long as the system needs to not suspend, or a client must get its own lease from the
1400    /// Power Framework to prevent suspension before it drops `keep_alive`.
1401    ///
1402    /// If the specified `id` is invalid, then this call will return `INVALID_ARGS`.
1403    /// If this method is not supported for the given `id`, then this call will return
1404    /// `NOT_SUPPORTED`.
1405    /// If the driver does not have a `keep_alive` token to provide to the client, then this
1406    /// call will return `BAD_STATE`.
1407    /// If the driver encounters an internal error, then this call will return `INTERNAL_ERROR`.
1408    StartAndWait {
1409        id: u64,
1410        resolution: Resolution,
1411        ticks: u64,
1412        setup_event: fidl::Event,
1413        responder: DeviceStartAndWaitResponder,
1414    },
1415    /// Start timer `id` and wait for it to expire after `ticks` ticks.
1416    ///
1417    /// The driver will not respond to this call (hang) until the timer has triggered.
1418    /// Calling `Stop` on the timer will abort this call and return `CANCELED`. Note that this
1419    /// may race with the expiration of the timer.
1420    ///
1421    /// This method keeps the system awake (prevents suspension) while the timer is setup using the
1422    /// mandatory passed-in `setup_keep_alive` `LeaseToken`.
1423    /// When the timer expires this method returns a second `expiration_keep_alive`
1424    /// `LeaseToken` to prevent suspension at the time of expiration.
1425    /// These keep alive wake lease tokens are provided by the Power Framework's System Activity
1426    /// Governor. A driver supporting this call must be able to get `expiration_keep_alive` from
1427    /// System Activity Governor.
1428    ///
1429    /// When `expiration_keep_alive` is closed, then this driver created wake lease keeping the
1430    /// system from suspending at the time of the timer expiration is dropped. Hence, to guarantee
1431    /// that the system is not suspended by the Power Framework a client must either keep this
1432    /// `expiration_keep_alive` for as long as the system needs to stay awake, or a client must
1433    /// get its own wake lease from the Power Framework before it drops `expiration_keep_alive` to
1434    /// prevent suspension.
1435    ///
1436    /// Errors:
1437    ///
1438    /// * INVALID_ARGS: The specified `id` is invalid.
1439    /// * NOT_SUPPORTED: This method is not supported for the given `id`.
1440    /// * BAD_STATE: The driver is in a bad state, for instance it does not have an
1441    ///   `expiration_keep_alive` token to provide to the client.
1442    /// * INTERNAL_ERROR: The driver encountered an internal error.
1443    StartAndWait2 {
1444        id: u64,
1445        resolution: Resolution,
1446        ticks: u64,
1447        setup_keep_alive: fidl::EventPair,
1448        responder: DeviceStartAndWait2Responder,
1449    },
1450    /// Get driver properties.
1451    GetProperties { responder: DeviceGetPropertiesResponder },
1452    /// An interaction was received which does not match any known method.
1453    #[non_exhaustive]
1454    _UnknownMethod {
1455        /// Ordinal of the method that was called.
1456        ordinal: u64,
1457        control_handle: DeviceControlHandle,
1458        method_type: fidl::MethodType,
1459    },
1460}
1461
1462impl DeviceRequest {
1463    #[allow(irrefutable_let_patterns)]
1464    pub fn into_start(self) -> Option<(u64, Resolution, u64, DeviceStartResponder)> {
1465        if let DeviceRequest::Start { id, resolution, ticks, responder } = self {
1466            Some((id, resolution, ticks, responder))
1467        } else {
1468            None
1469        }
1470    }
1471
1472    #[allow(irrefutable_let_patterns)]
1473    pub fn into_read_timer(self) -> Option<(u64, Resolution, DeviceReadTimerResponder)> {
1474        if let DeviceRequest::ReadTimer { id, resolution, responder } = self {
1475            Some((id, resolution, responder))
1476        } else {
1477            None
1478        }
1479    }
1480
1481    #[allow(irrefutable_let_patterns)]
1482    pub fn into_read_clock(self) -> Option<(u64, Resolution, DeviceReadClockResponder)> {
1483        if let DeviceRequest::ReadClock { id, resolution, responder } = self {
1484            Some((id, resolution, responder))
1485        } else {
1486            None
1487        }
1488    }
1489
1490    #[allow(irrefutable_let_patterns)]
1491    pub fn into_stop(self) -> Option<(u64, DeviceStopResponder)> {
1492        if let DeviceRequest::Stop { id, responder } = self { Some((id, responder)) } else { None }
1493    }
1494
1495    #[allow(irrefutable_let_patterns)]
1496    pub fn into_get_ticks_left(self) -> Option<(u64, DeviceGetTicksLeftResponder)> {
1497        if let DeviceRequest::GetTicksLeft { id, responder } = self {
1498            Some((id, responder))
1499        } else {
1500            None
1501        }
1502    }
1503
1504    #[allow(irrefutable_let_patterns)]
1505    pub fn into_set_event(self) -> Option<(u64, fidl::Event, DeviceSetEventResponder)> {
1506        if let DeviceRequest::SetEvent { id, event, responder } = self {
1507            Some((id, event, responder))
1508        } else {
1509            None
1510        }
1511    }
1512
1513    #[allow(irrefutable_let_patterns)]
1514    pub fn into_start_and_wait(
1515        self,
1516    ) -> Option<(u64, Resolution, u64, fidl::Event, DeviceStartAndWaitResponder)> {
1517        if let DeviceRequest::StartAndWait { id, resolution, ticks, setup_event, responder } = self
1518        {
1519            Some((id, resolution, ticks, setup_event, responder))
1520        } else {
1521            None
1522        }
1523    }
1524
1525    #[allow(irrefutable_let_patterns)]
1526    pub fn into_start_and_wait2(
1527        self,
1528    ) -> Option<(u64, Resolution, u64, fidl::EventPair, DeviceStartAndWait2Responder)> {
1529        if let DeviceRequest::StartAndWait2 { id, resolution, ticks, setup_keep_alive, responder } =
1530            self
1531        {
1532            Some((id, resolution, ticks, setup_keep_alive, responder))
1533        } else {
1534            None
1535        }
1536    }
1537
1538    #[allow(irrefutable_let_patterns)]
1539    pub fn into_get_properties(self) -> Option<(DeviceGetPropertiesResponder)> {
1540        if let DeviceRequest::GetProperties { responder } = self { Some((responder)) } else { None }
1541    }
1542
1543    /// Name of the method defined in FIDL
1544    pub fn method_name(&self) -> &'static str {
1545        match *self {
1546            DeviceRequest::Start { .. } => "start",
1547            DeviceRequest::ReadTimer { .. } => "read_timer",
1548            DeviceRequest::ReadClock { .. } => "read_clock",
1549            DeviceRequest::Stop { .. } => "stop",
1550            DeviceRequest::GetTicksLeft { .. } => "get_ticks_left",
1551            DeviceRequest::SetEvent { .. } => "set_event",
1552            DeviceRequest::StartAndWait { .. } => "start_and_wait",
1553            DeviceRequest::StartAndWait2 { .. } => "start_and_wait2",
1554            DeviceRequest::GetProperties { .. } => "get_properties",
1555            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1556                "unknown one-way method"
1557            }
1558            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1559                "unknown two-way method"
1560            }
1561        }
1562    }
1563}
1564
1565#[derive(Debug, Clone)]
1566pub struct DeviceControlHandle {
1567    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1568}
1569
1570impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1571    fn shutdown(&self) {
1572        self.inner.shutdown()
1573    }
1574
1575    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1576        self.inner.shutdown_with_epitaph(status)
1577    }
1578
1579    fn is_closed(&self) -> bool {
1580        self.inner.channel().is_closed()
1581    }
1582    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1583        self.inner.channel().on_closed()
1584    }
1585
1586    #[cfg(target_os = "fuchsia")]
1587    fn signal_peer(
1588        &self,
1589        clear_mask: zx::Signals,
1590        set_mask: zx::Signals,
1591    ) -> Result<(), zx_status::Status> {
1592        use fidl::Peered;
1593        self.inner.channel().signal_peer(clear_mask, set_mask)
1594    }
1595}
1596
1597impl DeviceControlHandle {}
1598
1599#[must_use = "FIDL methods require a response to be sent"]
1600#[derive(Debug)]
1601pub struct DeviceStartResponder {
1602    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1603    tx_id: u32,
1604}
1605
1606/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1607/// if the responder is dropped without sending a response, so that the client
1608/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1609impl std::ops::Drop for DeviceStartResponder {
1610    fn drop(&mut self) {
1611        self.control_handle.shutdown();
1612        // Safety: drops once, never accessed again
1613        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1614    }
1615}
1616
1617impl fidl::endpoints::Responder for DeviceStartResponder {
1618    type ControlHandle = DeviceControlHandle;
1619
1620    fn control_handle(&self) -> &DeviceControlHandle {
1621        &self.control_handle
1622    }
1623
1624    fn drop_without_shutdown(mut self) {
1625        // Safety: drops once, never accessed again due to mem::forget
1626        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1627        // Prevent Drop from running (which would shut down the channel)
1628        std::mem::forget(self);
1629    }
1630}
1631
1632impl DeviceStartResponder {
1633    /// Sends a response to the FIDL transaction.
1634    ///
1635    /// Sets the channel to shutdown if an error occurs.
1636    pub fn send(self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1637        let _result = self.send_raw(result);
1638        if _result.is_err() {
1639            self.control_handle.shutdown();
1640        }
1641        self.drop_without_shutdown();
1642        _result
1643    }
1644
1645    /// Similar to "send" but does not shutdown the channel if an error occurs.
1646    pub fn send_no_shutdown_on_err(
1647        self,
1648        mut result: Result<(), DriverError>,
1649    ) -> Result<(), fidl::Error> {
1650        let _result = self.send_raw(result);
1651        self.drop_without_shutdown();
1652        _result
1653    }
1654
1655    fn send_raw(&self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1656        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1657            fidl::encoding::EmptyStruct,
1658            DriverError,
1659        >>(
1660            fidl::encoding::FlexibleResult::new(result),
1661            self.tx_id,
1662            0x5a0a193b0467cc8a,
1663            fidl::encoding::DynamicFlags::FLEXIBLE,
1664        )
1665    }
1666}
1667
1668#[must_use = "FIDL methods require a response to be sent"]
1669#[derive(Debug)]
1670pub struct DeviceReadTimerResponder {
1671    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1672    tx_id: u32,
1673}
1674
1675/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1676/// if the responder is dropped without sending a response, so that the client
1677/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1678impl std::ops::Drop for DeviceReadTimerResponder {
1679    fn drop(&mut self) {
1680        self.control_handle.shutdown();
1681        // Safety: drops once, never accessed again
1682        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1683    }
1684}
1685
1686impl fidl::endpoints::Responder for DeviceReadTimerResponder {
1687    type ControlHandle = DeviceControlHandle;
1688
1689    fn control_handle(&self) -> &DeviceControlHandle {
1690        &self.control_handle
1691    }
1692
1693    fn drop_without_shutdown(mut self) {
1694        // Safety: drops once, never accessed again due to mem::forget
1695        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1696        // Prevent Drop from running (which would shut down the channel)
1697        std::mem::forget(self);
1698    }
1699}
1700
1701impl DeviceReadTimerResponder {
1702    /// Sends a response to the FIDL transaction.
1703    ///
1704    /// Sets the channel to shutdown if an error occurs.
1705    pub fn send(self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1706        let _result = self.send_raw(result);
1707        if _result.is_err() {
1708            self.control_handle.shutdown();
1709        }
1710        self.drop_without_shutdown();
1711        _result
1712    }
1713
1714    /// Similar to "send" but does not shutdown the channel if an error occurs.
1715    pub fn send_no_shutdown_on_err(
1716        self,
1717        mut result: Result<u64, DriverError>,
1718    ) -> Result<(), fidl::Error> {
1719        let _result = self.send_raw(result);
1720        self.drop_without_shutdown();
1721        _result
1722    }
1723
1724    fn send_raw(&self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1725        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1726            DeviceReadTimerResponse,
1727            DriverError,
1728        >>(
1729            fidl::encoding::FlexibleResult::new(result.map(|ticks| (ticks,))),
1730            self.tx_id,
1731            0x4430d0e336ffb5e9,
1732            fidl::encoding::DynamicFlags::FLEXIBLE,
1733        )
1734    }
1735}
1736
1737#[must_use = "FIDL methods require a response to be sent"]
1738#[derive(Debug)]
1739pub struct DeviceReadClockResponder {
1740    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1741    tx_id: u32,
1742}
1743
1744/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1745/// if the responder is dropped without sending a response, so that the client
1746/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1747impl std::ops::Drop for DeviceReadClockResponder {
1748    fn drop(&mut self) {
1749        self.control_handle.shutdown();
1750        // Safety: drops once, never accessed again
1751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1752    }
1753}
1754
1755impl fidl::endpoints::Responder for DeviceReadClockResponder {
1756    type ControlHandle = DeviceControlHandle;
1757
1758    fn control_handle(&self) -> &DeviceControlHandle {
1759        &self.control_handle
1760    }
1761
1762    fn drop_without_shutdown(mut self) {
1763        // Safety: drops once, never accessed again due to mem::forget
1764        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1765        // Prevent Drop from running (which would shut down the channel)
1766        std::mem::forget(self);
1767    }
1768}
1769
1770impl DeviceReadClockResponder {
1771    /// Sends a response to the FIDL transaction.
1772    ///
1773    /// Sets the channel to shutdown if an error occurs.
1774    pub fn send(self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1775        let _result = self.send_raw(result);
1776        if _result.is_err() {
1777            self.control_handle.shutdown();
1778        }
1779        self.drop_without_shutdown();
1780        _result
1781    }
1782
1783    /// Similar to "send" but does not shutdown the channel if an error occurs.
1784    pub fn send_no_shutdown_on_err(
1785        self,
1786        mut result: Result<u64, DriverError>,
1787    ) -> Result<(), fidl::Error> {
1788        let _result = self.send_raw(result);
1789        self.drop_without_shutdown();
1790        _result
1791    }
1792
1793    fn send_raw(&self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1794        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1795            DeviceReadClockResponse,
1796            DriverError,
1797        >>(
1798            fidl::encoding::FlexibleResult::new(result.map(|ticks| (ticks,))),
1799            self.tx_id,
1800            0x49aae10e0fb621ab,
1801            fidl::encoding::DynamicFlags::FLEXIBLE,
1802        )
1803    }
1804}
1805
1806#[must_use = "FIDL methods require a response to be sent"]
1807#[derive(Debug)]
1808pub struct DeviceStopResponder {
1809    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1810    tx_id: u32,
1811}
1812
1813/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1814/// if the responder is dropped without sending a response, so that the client
1815/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1816impl std::ops::Drop for DeviceStopResponder {
1817    fn drop(&mut self) {
1818        self.control_handle.shutdown();
1819        // Safety: drops once, never accessed again
1820        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1821    }
1822}
1823
1824impl fidl::endpoints::Responder for DeviceStopResponder {
1825    type ControlHandle = DeviceControlHandle;
1826
1827    fn control_handle(&self) -> &DeviceControlHandle {
1828        &self.control_handle
1829    }
1830
1831    fn drop_without_shutdown(mut self) {
1832        // Safety: drops once, never accessed again due to mem::forget
1833        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1834        // Prevent Drop from running (which would shut down the channel)
1835        std::mem::forget(self);
1836    }
1837}
1838
1839impl DeviceStopResponder {
1840    /// Sends a response to the FIDL transaction.
1841    ///
1842    /// Sets the channel to shutdown if an error occurs.
1843    pub fn send(self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1844        let _result = self.send_raw(result);
1845        if _result.is_err() {
1846            self.control_handle.shutdown();
1847        }
1848        self.drop_without_shutdown();
1849        _result
1850    }
1851
1852    /// Similar to "send" but does not shutdown the channel if an error occurs.
1853    pub fn send_no_shutdown_on_err(
1854        self,
1855        mut result: Result<(), DriverError>,
1856    ) -> Result<(), fidl::Error> {
1857        let _result = self.send_raw(result);
1858        self.drop_without_shutdown();
1859        _result
1860    }
1861
1862    fn send_raw(&self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1863        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1864            fidl::encoding::EmptyStruct,
1865            DriverError,
1866        >>(
1867            fidl::encoding::FlexibleResult::new(result),
1868            self.tx_id,
1869            0x77e4cd1c3841a0e2,
1870            fidl::encoding::DynamicFlags::FLEXIBLE,
1871        )
1872    }
1873}
1874
1875#[must_use = "FIDL methods require a response to be sent"]
1876#[derive(Debug)]
1877pub struct DeviceGetTicksLeftResponder {
1878    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1879    tx_id: u32,
1880}
1881
1882/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1883/// if the responder is dropped without sending a response, so that the client
1884/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1885impl std::ops::Drop for DeviceGetTicksLeftResponder {
1886    fn drop(&mut self) {
1887        self.control_handle.shutdown();
1888        // Safety: drops once, never accessed again
1889        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1890    }
1891}
1892
1893impl fidl::endpoints::Responder for DeviceGetTicksLeftResponder {
1894    type ControlHandle = DeviceControlHandle;
1895
1896    fn control_handle(&self) -> &DeviceControlHandle {
1897        &self.control_handle
1898    }
1899
1900    fn drop_without_shutdown(mut self) {
1901        // Safety: drops once, never accessed again due to mem::forget
1902        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1903        // Prevent Drop from running (which would shut down the channel)
1904        std::mem::forget(self);
1905    }
1906}
1907
1908impl DeviceGetTicksLeftResponder {
1909    /// Sends a response to the FIDL transaction.
1910    ///
1911    /// Sets the channel to shutdown if an error occurs.
1912    pub fn send(self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1913        let _result = self.send_raw(result);
1914        if _result.is_err() {
1915            self.control_handle.shutdown();
1916        }
1917        self.drop_without_shutdown();
1918        _result
1919    }
1920
1921    /// Similar to "send" but does not shutdown the channel if an error occurs.
1922    pub fn send_no_shutdown_on_err(
1923        self,
1924        mut result: Result<u64, DriverError>,
1925    ) -> Result<(), fidl::Error> {
1926        let _result = self.send_raw(result);
1927        self.drop_without_shutdown();
1928        _result
1929    }
1930
1931    fn send_raw(&self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1932        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1933            DeviceGetTicksLeftResponse,
1934            DriverError,
1935        >>(
1936            fidl::encoding::FlexibleResult::new(result.map(|ticks| (ticks,))),
1937            self.tx_id,
1938            0xde2a48ae7d4b4ea,
1939            fidl::encoding::DynamicFlags::FLEXIBLE,
1940        )
1941    }
1942}
1943
1944#[must_use = "FIDL methods require a response to be sent"]
1945#[derive(Debug)]
1946pub struct DeviceSetEventResponder {
1947    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1948    tx_id: u32,
1949}
1950
1951/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1952/// if the responder is dropped without sending a response, so that the client
1953/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1954impl std::ops::Drop for DeviceSetEventResponder {
1955    fn drop(&mut self) {
1956        self.control_handle.shutdown();
1957        // Safety: drops once, never accessed again
1958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1959    }
1960}
1961
1962impl fidl::endpoints::Responder for DeviceSetEventResponder {
1963    type ControlHandle = DeviceControlHandle;
1964
1965    fn control_handle(&self) -> &DeviceControlHandle {
1966        &self.control_handle
1967    }
1968
1969    fn drop_without_shutdown(mut self) {
1970        // Safety: drops once, never accessed again due to mem::forget
1971        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1972        // Prevent Drop from running (which would shut down the channel)
1973        std::mem::forget(self);
1974    }
1975}
1976
1977impl DeviceSetEventResponder {
1978    /// Sends a response to the FIDL transaction.
1979    ///
1980    /// Sets the channel to shutdown if an error occurs.
1981    pub fn send(self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1982        let _result = self.send_raw(result);
1983        if _result.is_err() {
1984            self.control_handle.shutdown();
1985        }
1986        self.drop_without_shutdown();
1987        _result
1988    }
1989
1990    /// Similar to "send" but does not shutdown the channel if an error occurs.
1991    pub fn send_no_shutdown_on_err(
1992        self,
1993        mut result: Result<(), DriverError>,
1994    ) -> Result<(), fidl::Error> {
1995        let _result = self.send_raw(result);
1996        self.drop_without_shutdown();
1997        _result
1998    }
1999
2000    fn send_raw(&self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
2001        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2002            fidl::encoding::EmptyStruct,
2003            DriverError,
2004        >>(
2005            fidl::encoding::FlexibleResult::new(result),
2006            self.tx_id,
2007            0x1027024d25ffa820,
2008            fidl::encoding::DynamicFlags::FLEXIBLE,
2009        )
2010    }
2011}
2012
2013#[must_use = "FIDL methods require a response to be sent"]
2014#[derive(Debug)]
2015pub struct DeviceStartAndWaitResponder {
2016    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2017    tx_id: u32,
2018}
2019
2020/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2021/// if the responder is dropped without sending a response, so that the client
2022/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2023impl std::ops::Drop for DeviceStartAndWaitResponder {
2024    fn drop(&mut self) {
2025        self.control_handle.shutdown();
2026        // Safety: drops once, never accessed again
2027        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2028    }
2029}
2030
2031impl fidl::endpoints::Responder for DeviceStartAndWaitResponder {
2032    type ControlHandle = DeviceControlHandle;
2033
2034    fn control_handle(&self) -> &DeviceControlHandle {
2035        &self.control_handle
2036    }
2037
2038    fn drop_without_shutdown(mut self) {
2039        // Safety: drops once, never accessed again due to mem::forget
2040        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2041        // Prevent Drop from running (which would shut down the channel)
2042        std::mem::forget(self);
2043    }
2044}
2045
2046impl DeviceStartAndWaitResponder {
2047    /// Sends a response to the FIDL transaction.
2048    ///
2049    /// Sets the channel to shutdown if an error occurs.
2050    pub fn send(self, mut result: Result<fidl::EventPair, DriverError>) -> Result<(), fidl::Error> {
2051        let _result = self.send_raw(result);
2052        if _result.is_err() {
2053            self.control_handle.shutdown();
2054        }
2055        self.drop_without_shutdown();
2056        _result
2057    }
2058
2059    /// Similar to "send" but does not shutdown the channel if an error occurs.
2060    pub fn send_no_shutdown_on_err(
2061        self,
2062        mut result: Result<fidl::EventPair, DriverError>,
2063    ) -> Result<(), fidl::Error> {
2064        let _result = self.send_raw(result);
2065        self.drop_without_shutdown();
2066        _result
2067    }
2068
2069    fn send_raw(
2070        &self,
2071        mut result: Result<fidl::EventPair, DriverError>,
2072    ) -> Result<(), fidl::Error> {
2073        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2074            DeviceStartAndWaitResponse,
2075            DriverError,
2076        >>(
2077            fidl::encoding::FlexibleResult::new(result.map(|keep_alive| (keep_alive,))),
2078            self.tx_id,
2079            0x716f415cdf234e0f,
2080            fidl::encoding::DynamicFlags::FLEXIBLE,
2081        )
2082    }
2083}
2084
2085#[must_use = "FIDL methods require a response to be sent"]
2086#[derive(Debug)]
2087pub struct DeviceStartAndWait2Responder {
2088    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2089    tx_id: u32,
2090}
2091
2092/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2093/// if the responder is dropped without sending a response, so that the client
2094/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2095impl std::ops::Drop for DeviceStartAndWait2Responder {
2096    fn drop(&mut self) {
2097        self.control_handle.shutdown();
2098        // Safety: drops once, never accessed again
2099        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2100    }
2101}
2102
2103impl fidl::endpoints::Responder for DeviceStartAndWait2Responder {
2104    type ControlHandle = DeviceControlHandle;
2105
2106    fn control_handle(&self) -> &DeviceControlHandle {
2107        &self.control_handle
2108    }
2109
2110    fn drop_without_shutdown(mut self) {
2111        // Safety: drops once, never accessed again due to mem::forget
2112        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2113        // Prevent Drop from running (which would shut down the channel)
2114        std::mem::forget(self);
2115    }
2116}
2117
2118impl DeviceStartAndWait2Responder {
2119    /// Sends a response to the FIDL transaction.
2120    ///
2121    /// Sets the channel to shutdown if an error occurs.
2122    pub fn send(self, mut result: Result<fidl::EventPair, DriverError>) -> Result<(), fidl::Error> {
2123        let _result = self.send_raw(result);
2124        if _result.is_err() {
2125            self.control_handle.shutdown();
2126        }
2127        self.drop_without_shutdown();
2128        _result
2129    }
2130
2131    /// Similar to "send" but does not shutdown the channel if an error occurs.
2132    pub fn send_no_shutdown_on_err(
2133        self,
2134        mut result: Result<fidl::EventPair, DriverError>,
2135    ) -> Result<(), fidl::Error> {
2136        let _result = self.send_raw(result);
2137        self.drop_without_shutdown();
2138        _result
2139    }
2140
2141    fn send_raw(
2142        &self,
2143        mut result: Result<fidl::EventPair, DriverError>,
2144    ) -> Result<(), fidl::Error> {
2145        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2146            DeviceStartAndWait2Response,
2147            DriverError,
2148        >>(
2149            fidl::encoding::FlexibleResult::new(
2150                result.map(|expiration_keep_alive| (expiration_keep_alive,)),
2151            ),
2152            self.tx_id,
2153            0x5f2aaf21254d3238,
2154            fidl::encoding::DynamicFlags::FLEXIBLE,
2155        )
2156    }
2157}
2158
2159#[must_use = "FIDL methods require a response to be sent"]
2160#[derive(Debug)]
2161pub struct DeviceGetPropertiesResponder {
2162    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2163    tx_id: u32,
2164}
2165
2166/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2167/// if the responder is dropped without sending a response, so that the client
2168/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2169impl std::ops::Drop for DeviceGetPropertiesResponder {
2170    fn drop(&mut self) {
2171        self.control_handle.shutdown();
2172        // Safety: drops once, never accessed again
2173        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2174    }
2175}
2176
2177impl fidl::endpoints::Responder for DeviceGetPropertiesResponder {
2178    type ControlHandle = DeviceControlHandle;
2179
2180    fn control_handle(&self) -> &DeviceControlHandle {
2181        &self.control_handle
2182    }
2183
2184    fn drop_without_shutdown(mut self) {
2185        // Safety: drops once, never accessed again due to mem::forget
2186        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2187        // Prevent Drop from running (which would shut down the channel)
2188        std::mem::forget(self);
2189    }
2190}
2191
2192impl DeviceGetPropertiesResponder {
2193    /// Sends a response to the FIDL transaction.
2194    ///
2195    /// Sets the channel to shutdown if an error occurs.
2196    pub fn send(self, mut properties: Properties) -> Result<(), fidl::Error> {
2197        let _result = self.send_raw(properties);
2198        if _result.is_err() {
2199            self.control_handle.shutdown();
2200        }
2201        self.drop_without_shutdown();
2202        _result
2203    }
2204
2205    /// Similar to "send" but does not shutdown the channel if an error occurs.
2206    pub fn send_no_shutdown_on_err(self, mut properties: Properties) -> Result<(), fidl::Error> {
2207        let _result = self.send_raw(properties);
2208        self.drop_without_shutdown();
2209        _result
2210    }
2211
2212    fn send_raw(&self, mut properties: Properties) -> Result<(), fidl::Error> {
2213        self.control_handle.inner.send::<fidl::encoding::FlexibleType<DeviceGetPropertiesResponse>>(
2214            fidl::encoding::Flexible::new((&mut properties,)),
2215            self.tx_id,
2216            0x6bc22ab4c9396cbb,
2217            fidl::encoding::DynamicFlags::FLEXIBLE,
2218        )
2219    }
2220}
2221
2222#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2223pub struct ServiceMarker;
2224
2225#[cfg(target_os = "fuchsia")]
2226impl fidl::endpoints::ServiceMarker for ServiceMarker {
2227    type Proxy = ServiceProxy;
2228    type Request = ServiceRequest;
2229    const SERVICE_NAME: &'static str = "fuchsia.hardware.hrtimer.Service";
2230}
2231
2232/// A request for one of the member protocols of Service.
2233///
2234#[cfg(target_os = "fuchsia")]
2235pub enum ServiceRequest {
2236    Device(DeviceRequestStream),
2237}
2238
2239#[cfg(target_os = "fuchsia")]
2240impl fidl::endpoints::ServiceRequest for ServiceRequest {
2241    type Service = ServiceMarker;
2242
2243    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2244        match name {
2245            "device" => Self::Device(
2246                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2247            ),
2248            _ => panic!("no such member protocol name for service Service"),
2249        }
2250    }
2251
2252    fn member_names() -> &'static [&'static str] {
2253        &["device"]
2254    }
2255}
2256#[cfg(target_os = "fuchsia")]
2257pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2258
2259#[cfg(target_os = "fuchsia")]
2260impl fidl::endpoints::ServiceProxy for ServiceProxy {
2261    type Service = ServiceMarker;
2262
2263    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2264        Self(opener)
2265    }
2266}
2267
2268#[cfg(target_os = "fuchsia")]
2269impl ServiceProxy {
2270    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
2271        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
2272        self.connect_channel_to_device(server_end)?;
2273        Ok(proxy)
2274    }
2275
2276    /// Like `connect_to_device`, but returns a sync proxy.
2277    /// See [`Self::connect_to_device`] for more details.
2278    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
2279        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
2280        self.connect_channel_to_device(server_end)?;
2281        Ok(proxy)
2282    }
2283
2284    /// Like `connect_to_device`, but accepts a server end.
2285    /// See [`Self::connect_to_device`] for more details.
2286    pub fn connect_channel_to_device(
2287        &self,
2288        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
2289    ) -> Result<(), fidl::Error> {
2290        self.0.open_member("device", server_end.into_channel())
2291    }
2292
2293    pub fn instance_name(&self) -> &str {
2294        self.0.instance_name()
2295    }
2296}
2297
2298mod internal {
2299    use super::*;
2300
2301    impl fidl::encoding::ResourceTypeMarker for DeviceSetEventRequest {
2302        type Borrowed<'a> = &'a mut Self;
2303        fn take_or_borrow<'a>(
2304            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2305        ) -> Self::Borrowed<'a> {
2306            value
2307        }
2308    }
2309
2310    unsafe impl fidl::encoding::TypeMarker for DeviceSetEventRequest {
2311        type Owned = Self;
2312
2313        #[inline(always)]
2314        fn inline_align(_context: fidl::encoding::Context) -> usize {
2315            8
2316        }
2317
2318        #[inline(always)]
2319        fn inline_size(_context: fidl::encoding::Context) -> usize {
2320            16
2321        }
2322    }
2323
2324    unsafe impl
2325        fidl::encoding::Encode<DeviceSetEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2326        for &mut DeviceSetEventRequest
2327    {
2328        #[inline]
2329        unsafe fn encode(
2330            self,
2331            encoder: &mut fidl::encoding::Encoder<
2332                '_,
2333                fidl::encoding::DefaultFuchsiaResourceDialect,
2334            >,
2335            offset: usize,
2336            _depth: fidl::encoding::Depth,
2337        ) -> fidl::Result<()> {
2338            encoder.debug_check_bounds::<DeviceSetEventRequest>(offset);
2339            // Delegate to tuple encoding.
2340            fidl::encoding::Encode::<
2341                DeviceSetEventRequest,
2342                fidl::encoding::DefaultFuchsiaResourceDialect,
2343            >::encode(
2344                (
2345                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2346                    <fidl::encoding::HandleType<
2347                        fidl::Event,
2348                        { fidl::ObjectType::EVENT.into_raw() },
2349                        2147483648,
2350                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2351                        &mut self.event
2352                    ),
2353                ),
2354                encoder,
2355                offset,
2356                _depth,
2357            )
2358        }
2359    }
2360    unsafe impl<
2361        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2362        T1: fidl::encoding::Encode<
2363                fidl::encoding::HandleType<
2364                    fidl::Event,
2365                    { fidl::ObjectType::EVENT.into_raw() },
2366                    2147483648,
2367                >,
2368                fidl::encoding::DefaultFuchsiaResourceDialect,
2369            >,
2370    >
2371        fidl::encoding::Encode<DeviceSetEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2372        for (T0, T1)
2373    {
2374        #[inline]
2375        unsafe fn encode(
2376            self,
2377            encoder: &mut fidl::encoding::Encoder<
2378                '_,
2379                fidl::encoding::DefaultFuchsiaResourceDialect,
2380            >,
2381            offset: usize,
2382            depth: fidl::encoding::Depth,
2383        ) -> fidl::Result<()> {
2384            encoder.debug_check_bounds::<DeviceSetEventRequest>(offset);
2385            // Zero out padding regions. There's no need to apply masks
2386            // because the unmasked parts will be overwritten by fields.
2387            unsafe {
2388                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
2389                (ptr as *mut u64).write_unaligned(0);
2390            }
2391            // Write the fields.
2392            self.0.encode(encoder, offset + 0, depth)?;
2393            self.1.encode(encoder, offset + 8, depth)?;
2394            Ok(())
2395        }
2396    }
2397
2398    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2399        for DeviceSetEventRequest
2400    {
2401        #[inline(always)]
2402        fn new_empty() -> Self {
2403            Self {
2404                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2405                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2406            }
2407        }
2408
2409        #[inline]
2410        unsafe fn decode(
2411            &mut self,
2412            decoder: &mut fidl::encoding::Decoder<
2413                '_,
2414                fidl::encoding::DefaultFuchsiaResourceDialect,
2415            >,
2416            offset: usize,
2417            _depth: fidl::encoding::Depth,
2418        ) -> fidl::Result<()> {
2419            decoder.debug_check_bounds::<Self>(offset);
2420            // Verify that padding bytes are zero.
2421            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
2422            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2423            let mask = 0xffffffff00000000u64;
2424            let maskedval = padval & mask;
2425            if maskedval != 0 {
2426                return Err(fidl::Error::NonZeroPadding {
2427                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
2428                });
2429            }
2430            fidl::decode!(
2431                u64,
2432                fidl::encoding::DefaultFuchsiaResourceDialect,
2433                &mut self.id,
2434                decoder,
2435                offset + 0,
2436                _depth
2437            )?;
2438            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 8, _depth)?;
2439            Ok(())
2440        }
2441    }
2442
2443    impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWait2Request {
2444        type Borrowed<'a> = &'a mut Self;
2445        fn take_or_borrow<'a>(
2446            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2447        ) -> Self::Borrowed<'a> {
2448            value
2449        }
2450    }
2451
2452    unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWait2Request {
2453        type Owned = Self;
2454
2455        #[inline(always)]
2456        fn inline_align(_context: fidl::encoding::Context) -> usize {
2457            8
2458        }
2459
2460        #[inline(always)]
2461        fn inline_size(_context: fidl::encoding::Context) -> usize {
2462            40
2463        }
2464    }
2465
2466    unsafe impl
2467        fidl::encoding::Encode<
2468            DeviceStartAndWait2Request,
2469            fidl::encoding::DefaultFuchsiaResourceDialect,
2470        > for &mut DeviceStartAndWait2Request
2471    {
2472        #[inline]
2473        unsafe fn encode(
2474            self,
2475            encoder: &mut fidl::encoding::Encoder<
2476                '_,
2477                fidl::encoding::DefaultFuchsiaResourceDialect,
2478            >,
2479            offset: usize,
2480            _depth: fidl::encoding::Depth,
2481        ) -> fidl::Result<()> {
2482            encoder.debug_check_bounds::<DeviceStartAndWait2Request>(offset);
2483            // Delegate to tuple encoding.
2484            fidl::encoding::Encode::<
2485                DeviceStartAndWait2Request,
2486                fidl::encoding::DefaultFuchsiaResourceDialect,
2487            >::encode(
2488                (
2489                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2490                    <Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
2491                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ticks),
2492                    <fidl::encoding::HandleType<
2493                        fidl::EventPair,
2494                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2495                        16387,
2496                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2497                        &mut self.setup_keep_alive,
2498                    ),
2499                ),
2500                encoder,
2501                offset,
2502                _depth,
2503            )
2504        }
2505    }
2506    unsafe impl<
2507        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2508        T1: fidl::encoding::Encode<Resolution, fidl::encoding::DefaultFuchsiaResourceDialect>,
2509        T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2510        T3: fidl::encoding::Encode<
2511                fidl::encoding::HandleType<
2512                    fidl::EventPair,
2513                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2514                    16387,
2515                >,
2516                fidl::encoding::DefaultFuchsiaResourceDialect,
2517            >,
2518    >
2519        fidl::encoding::Encode<
2520            DeviceStartAndWait2Request,
2521            fidl::encoding::DefaultFuchsiaResourceDialect,
2522        > for (T0, T1, T2, T3)
2523    {
2524        #[inline]
2525        unsafe fn encode(
2526            self,
2527            encoder: &mut fidl::encoding::Encoder<
2528                '_,
2529                fidl::encoding::DefaultFuchsiaResourceDialect,
2530            >,
2531            offset: usize,
2532            depth: fidl::encoding::Depth,
2533        ) -> fidl::Result<()> {
2534            encoder.debug_check_bounds::<DeviceStartAndWait2Request>(offset);
2535            // Zero out padding regions. There's no need to apply masks
2536            // because the unmasked parts will be overwritten by fields.
2537            unsafe {
2538                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
2539                (ptr as *mut u64).write_unaligned(0);
2540            }
2541            // Write the fields.
2542            self.0.encode(encoder, offset + 0, depth)?;
2543            self.1.encode(encoder, offset + 8, depth)?;
2544            self.2.encode(encoder, offset + 24, depth)?;
2545            self.3.encode(encoder, offset + 32, depth)?;
2546            Ok(())
2547        }
2548    }
2549
2550    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2551        for DeviceStartAndWait2Request
2552    {
2553        #[inline(always)]
2554        fn new_empty() -> Self {
2555            Self {
2556                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2557                resolution: fidl::new_empty!(
2558                    Resolution,
2559                    fidl::encoding::DefaultFuchsiaResourceDialect
2560                ),
2561                ticks: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2562                setup_keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
2563            }
2564        }
2565
2566        #[inline]
2567        unsafe fn decode(
2568            &mut self,
2569            decoder: &mut fidl::encoding::Decoder<
2570                '_,
2571                fidl::encoding::DefaultFuchsiaResourceDialect,
2572            >,
2573            offset: usize,
2574            _depth: fidl::encoding::Depth,
2575        ) -> fidl::Result<()> {
2576            decoder.debug_check_bounds::<Self>(offset);
2577            // Verify that padding bytes are zero.
2578            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
2579            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2580            let mask = 0xffffffff00000000u64;
2581            let maskedval = padval & mask;
2582            if maskedval != 0 {
2583                return Err(fidl::Error::NonZeroPadding {
2584                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
2585                });
2586            }
2587            fidl::decode!(
2588                u64,
2589                fidl::encoding::DefaultFuchsiaResourceDialect,
2590                &mut self.id,
2591                decoder,
2592                offset + 0,
2593                _depth
2594            )?;
2595            fidl::decode!(
2596                Resolution,
2597                fidl::encoding::DefaultFuchsiaResourceDialect,
2598                &mut self.resolution,
2599                decoder,
2600                offset + 8,
2601                _depth
2602            )?;
2603            fidl::decode!(
2604                u64,
2605                fidl::encoding::DefaultFuchsiaResourceDialect,
2606                &mut self.ticks,
2607                decoder,
2608                offset + 24,
2609                _depth
2610            )?;
2611            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.setup_keep_alive, decoder, offset + 32, _depth)?;
2612            Ok(())
2613        }
2614    }
2615
2616    impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWaitRequest {
2617        type Borrowed<'a> = &'a mut Self;
2618        fn take_or_borrow<'a>(
2619            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2620        ) -> Self::Borrowed<'a> {
2621            value
2622        }
2623    }
2624
2625    unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWaitRequest {
2626        type Owned = Self;
2627
2628        #[inline(always)]
2629        fn inline_align(_context: fidl::encoding::Context) -> usize {
2630            8
2631        }
2632
2633        #[inline(always)]
2634        fn inline_size(_context: fidl::encoding::Context) -> usize {
2635            40
2636        }
2637    }
2638
2639    unsafe impl
2640        fidl::encoding::Encode<
2641            DeviceStartAndWaitRequest,
2642            fidl::encoding::DefaultFuchsiaResourceDialect,
2643        > for &mut DeviceStartAndWaitRequest
2644    {
2645        #[inline]
2646        unsafe fn encode(
2647            self,
2648            encoder: &mut fidl::encoding::Encoder<
2649                '_,
2650                fidl::encoding::DefaultFuchsiaResourceDialect,
2651            >,
2652            offset: usize,
2653            _depth: fidl::encoding::Depth,
2654        ) -> fidl::Result<()> {
2655            encoder.debug_check_bounds::<DeviceStartAndWaitRequest>(offset);
2656            // Delegate to tuple encoding.
2657            fidl::encoding::Encode::<
2658                DeviceStartAndWaitRequest,
2659                fidl::encoding::DefaultFuchsiaResourceDialect,
2660            >::encode(
2661                (
2662                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2663                    <Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
2664                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ticks),
2665                    <fidl::encoding::HandleType<
2666                        fidl::Event,
2667                        { fidl::ObjectType::EVENT.into_raw() },
2668                        2147483648,
2669                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2670                        &mut self.setup_event
2671                    ),
2672                ),
2673                encoder,
2674                offset,
2675                _depth,
2676            )
2677        }
2678    }
2679    unsafe impl<
2680        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2681        T1: fidl::encoding::Encode<Resolution, fidl::encoding::DefaultFuchsiaResourceDialect>,
2682        T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2683        T3: fidl::encoding::Encode<
2684                fidl::encoding::HandleType<
2685                    fidl::Event,
2686                    { fidl::ObjectType::EVENT.into_raw() },
2687                    2147483648,
2688                >,
2689                fidl::encoding::DefaultFuchsiaResourceDialect,
2690            >,
2691    >
2692        fidl::encoding::Encode<
2693            DeviceStartAndWaitRequest,
2694            fidl::encoding::DefaultFuchsiaResourceDialect,
2695        > for (T0, T1, T2, T3)
2696    {
2697        #[inline]
2698        unsafe fn encode(
2699            self,
2700            encoder: &mut fidl::encoding::Encoder<
2701                '_,
2702                fidl::encoding::DefaultFuchsiaResourceDialect,
2703            >,
2704            offset: usize,
2705            depth: fidl::encoding::Depth,
2706        ) -> fidl::Result<()> {
2707            encoder.debug_check_bounds::<DeviceStartAndWaitRequest>(offset);
2708            // Zero out padding regions. There's no need to apply masks
2709            // because the unmasked parts will be overwritten by fields.
2710            unsafe {
2711                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
2712                (ptr as *mut u64).write_unaligned(0);
2713            }
2714            // Write the fields.
2715            self.0.encode(encoder, offset + 0, depth)?;
2716            self.1.encode(encoder, offset + 8, depth)?;
2717            self.2.encode(encoder, offset + 24, depth)?;
2718            self.3.encode(encoder, offset + 32, depth)?;
2719            Ok(())
2720        }
2721    }
2722
2723    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2724        for DeviceStartAndWaitRequest
2725    {
2726        #[inline(always)]
2727        fn new_empty() -> Self {
2728            Self {
2729                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2730                resolution: fidl::new_empty!(
2731                    Resolution,
2732                    fidl::encoding::DefaultFuchsiaResourceDialect
2733                ),
2734                ticks: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2735                setup_event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2736            }
2737        }
2738
2739        #[inline]
2740        unsafe fn decode(
2741            &mut self,
2742            decoder: &mut fidl::encoding::Decoder<
2743                '_,
2744                fidl::encoding::DefaultFuchsiaResourceDialect,
2745            >,
2746            offset: usize,
2747            _depth: fidl::encoding::Depth,
2748        ) -> fidl::Result<()> {
2749            decoder.debug_check_bounds::<Self>(offset);
2750            // Verify that padding bytes are zero.
2751            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
2752            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2753            let mask = 0xffffffff00000000u64;
2754            let maskedval = padval & mask;
2755            if maskedval != 0 {
2756                return Err(fidl::Error::NonZeroPadding {
2757                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
2758                });
2759            }
2760            fidl::decode!(
2761                u64,
2762                fidl::encoding::DefaultFuchsiaResourceDialect,
2763                &mut self.id,
2764                decoder,
2765                offset + 0,
2766                _depth
2767            )?;
2768            fidl::decode!(
2769                Resolution,
2770                fidl::encoding::DefaultFuchsiaResourceDialect,
2771                &mut self.resolution,
2772                decoder,
2773                offset + 8,
2774                _depth
2775            )?;
2776            fidl::decode!(
2777                u64,
2778                fidl::encoding::DefaultFuchsiaResourceDialect,
2779                &mut self.ticks,
2780                decoder,
2781                offset + 24,
2782                _depth
2783            )?;
2784            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.setup_event, decoder, offset + 32, _depth)?;
2785            Ok(())
2786        }
2787    }
2788
2789    impl fidl::encoding::ResourceTypeMarker for DeviceGetPropertiesResponse {
2790        type Borrowed<'a> = &'a mut Self;
2791        fn take_or_borrow<'a>(
2792            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2793        ) -> Self::Borrowed<'a> {
2794            value
2795        }
2796    }
2797
2798    unsafe impl fidl::encoding::TypeMarker for DeviceGetPropertiesResponse {
2799        type Owned = Self;
2800
2801        #[inline(always)]
2802        fn inline_align(_context: fidl::encoding::Context) -> usize {
2803            8
2804        }
2805
2806        #[inline(always)]
2807        fn inline_size(_context: fidl::encoding::Context) -> usize {
2808            16
2809        }
2810    }
2811
2812    unsafe impl
2813        fidl::encoding::Encode<
2814            DeviceGetPropertiesResponse,
2815            fidl::encoding::DefaultFuchsiaResourceDialect,
2816        > for &mut DeviceGetPropertiesResponse
2817    {
2818        #[inline]
2819        unsafe fn encode(
2820            self,
2821            encoder: &mut fidl::encoding::Encoder<
2822                '_,
2823                fidl::encoding::DefaultFuchsiaResourceDialect,
2824            >,
2825            offset: usize,
2826            _depth: fidl::encoding::Depth,
2827        ) -> fidl::Result<()> {
2828            encoder.debug_check_bounds::<DeviceGetPropertiesResponse>(offset);
2829            // Delegate to tuple encoding.
2830            fidl::encoding::Encode::<
2831                DeviceGetPropertiesResponse,
2832                fidl::encoding::DefaultFuchsiaResourceDialect,
2833            >::encode(
2834                (<Properties as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2835                    &mut self.properties,
2836                ),),
2837                encoder,
2838                offset,
2839                _depth,
2840            )
2841        }
2842    }
2843    unsafe impl<
2844        T0: fidl::encoding::Encode<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>,
2845    >
2846        fidl::encoding::Encode<
2847            DeviceGetPropertiesResponse,
2848            fidl::encoding::DefaultFuchsiaResourceDialect,
2849        > for (T0,)
2850    {
2851        #[inline]
2852        unsafe fn encode(
2853            self,
2854            encoder: &mut fidl::encoding::Encoder<
2855                '_,
2856                fidl::encoding::DefaultFuchsiaResourceDialect,
2857            >,
2858            offset: usize,
2859            depth: fidl::encoding::Depth,
2860        ) -> fidl::Result<()> {
2861            encoder.debug_check_bounds::<DeviceGetPropertiesResponse>(offset);
2862            // Zero out padding regions. There's no need to apply masks
2863            // because the unmasked parts will be overwritten by fields.
2864            // Write the fields.
2865            self.0.encode(encoder, offset + 0, depth)?;
2866            Ok(())
2867        }
2868    }
2869
2870    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2871        for DeviceGetPropertiesResponse
2872    {
2873        #[inline(always)]
2874        fn new_empty() -> Self {
2875            Self {
2876                properties: fidl::new_empty!(
2877                    Properties,
2878                    fidl::encoding::DefaultFuchsiaResourceDialect
2879                ),
2880            }
2881        }
2882
2883        #[inline]
2884        unsafe fn decode(
2885            &mut self,
2886            decoder: &mut fidl::encoding::Decoder<
2887                '_,
2888                fidl::encoding::DefaultFuchsiaResourceDialect,
2889            >,
2890            offset: usize,
2891            _depth: fidl::encoding::Depth,
2892        ) -> fidl::Result<()> {
2893            decoder.debug_check_bounds::<Self>(offset);
2894            // Verify that padding bytes are zero.
2895            fidl::decode!(
2896                Properties,
2897                fidl::encoding::DefaultFuchsiaResourceDialect,
2898                &mut self.properties,
2899                decoder,
2900                offset + 0,
2901                _depth
2902            )?;
2903            Ok(())
2904        }
2905    }
2906
2907    impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWait2Response {
2908        type Borrowed<'a> = &'a mut Self;
2909        fn take_or_borrow<'a>(
2910            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2911        ) -> Self::Borrowed<'a> {
2912            value
2913        }
2914    }
2915
2916    unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWait2Response {
2917        type Owned = Self;
2918
2919        #[inline(always)]
2920        fn inline_align(_context: fidl::encoding::Context) -> usize {
2921            4
2922        }
2923
2924        #[inline(always)]
2925        fn inline_size(_context: fidl::encoding::Context) -> usize {
2926            4
2927        }
2928    }
2929
2930    unsafe impl
2931        fidl::encoding::Encode<
2932            DeviceStartAndWait2Response,
2933            fidl::encoding::DefaultFuchsiaResourceDialect,
2934        > for &mut DeviceStartAndWait2Response
2935    {
2936        #[inline]
2937        unsafe fn encode(
2938            self,
2939            encoder: &mut fidl::encoding::Encoder<
2940                '_,
2941                fidl::encoding::DefaultFuchsiaResourceDialect,
2942            >,
2943            offset: usize,
2944            _depth: fidl::encoding::Depth,
2945        ) -> fidl::Result<()> {
2946            encoder.debug_check_bounds::<DeviceStartAndWait2Response>(offset);
2947            // Delegate to tuple encoding.
2948            fidl::encoding::Encode::<
2949                DeviceStartAndWait2Response,
2950                fidl::encoding::DefaultFuchsiaResourceDialect,
2951            >::encode(
2952                (<fidl::encoding::HandleType<
2953                    fidl::EventPair,
2954                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2955                    16387,
2956                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2957                    &mut self.expiration_keep_alive,
2958                ),),
2959                encoder,
2960                offset,
2961                _depth,
2962            )
2963        }
2964    }
2965    unsafe impl<
2966        T0: fidl::encoding::Encode<
2967                fidl::encoding::HandleType<
2968                    fidl::EventPair,
2969                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2970                    16387,
2971                >,
2972                fidl::encoding::DefaultFuchsiaResourceDialect,
2973            >,
2974    >
2975        fidl::encoding::Encode<
2976            DeviceStartAndWait2Response,
2977            fidl::encoding::DefaultFuchsiaResourceDialect,
2978        > for (T0,)
2979    {
2980        #[inline]
2981        unsafe fn encode(
2982            self,
2983            encoder: &mut fidl::encoding::Encoder<
2984                '_,
2985                fidl::encoding::DefaultFuchsiaResourceDialect,
2986            >,
2987            offset: usize,
2988            depth: fidl::encoding::Depth,
2989        ) -> fidl::Result<()> {
2990            encoder.debug_check_bounds::<DeviceStartAndWait2Response>(offset);
2991            // Zero out padding regions. There's no need to apply masks
2992            // because the unmasked parts will be overwritten by fields.
2993            // Write the fields.
2994            self.0.encode(encoder, offset + 0, depth)?;
2995            Ok(())
2996        }
2997    }
2998
2999    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3000        for DeviceStartAndWait2Response
3001    {
3002        #[inline(always)]
3003        fn new_empty() -> Self {
3004            Self {
3005                expiration_keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3006            }
3007        }
3008
3009        #[inline]
3010        unsafe fn decode(
3011            &mut self,
3012            decoder: &mut fidl::encoding::Decoder<
3013                '_,
3014                fidl::encoding::DefaultFuchsiaResourceDialect,
3015            >,
3016            offset: usize,
3017            _depth: fidl::encoding::Depth,
3018        ) -> fidl::Result<()> {
3019            decoder.debug_check_bounds::<Self>(offset);
3020            // Verify that padding bytes are zero.
3021            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.expiration_keep_alive, decoder, offset + 0, _depth)?;
3022            Ok(())
3023        }
3024    }
3025
3026    impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWaitResponse {
3027        type Borrowed<'a> = &'a mut Self;
3028        fn take_or_borrow<'a>(
3029            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3030        ) -> Self::Borrowed<'a> {
3031            value
3032        }
3033    }
3034
3035    unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWaitResponse {
3036        type Owned = Self;
3037
3038        #[inline(always)]
3039        fn inline_align(_context: fidl::encoding::Context) -> usize {
3040            4
3041        }
3042
3043        #[inline(always)]
3044        fn inline_size(_context: fidl::encoding::Context) -> usize {
3045            4
3046        }
3047    }
3048
3049    unsafe impl
3050        fidl::encoding::Encode<
3051            DeviceStartAndWaitResponse,
3052            fidl::encoding::DefaultFuchsiaResourceDialect,
3053        > for &mut DeviceStartAndWaitResponse
3054    {
3055        #[inline]
3056        unsafe fn encode(
3057            self,
3058            encoder: &mut fidl::encoding::Encoder<
3059                '_,
3060                fidl::encoding::DefaultFuchsiaResourceDialect,
3061            >,
3062            offset: usize,
3063            _depth: fidl::encoding::Depth,
3064        ) -> fidl::Result<()> {
3065            encoder.debug_check_bounds::<DeviceStartAndWaitResponse>(offset);
3066            // Delegate to tuple encoding.
3067            fidl::encoding::Encode::<
3068                DeviceStartAndWaitResponse,
3069                fidl::encoding::DefaultFuchsiaResourceDialect,
3070            >::encode(
3071                (<fidl::encoding::HandleType<
3072                    fidl::EventPair,
3073                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3074                    16387,
3075                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3076                    &mut self.keep_alive
3077                ),),
3078                encoder,
3079                offset,
3080                _depth,
3081            )
3082        }
3083    }
3084    unsafe impl<
3085        T0: fidl::encoding::Encode<
3086                fidl::encoding::HandleType<
3087                    fidl::EventPair,
3088                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3089                    16387,
3090                >,
3091                fidl::encoding::DefaultFuchsiaResourceDialect,
3092            >,
3093    >
3094        fidl::encoding::Encode<
3095            DeviceStartAndWaitResponse,
3096            fidl::encoding::DefaultFuchsiaResourceDialect,
3097        > for (T0,)
3098    {
3099        #[inline]
3100        unsafe fn encode(
3101            self,
3102            encoder: &mut fidl::encoding::Encoder<
3103                '_,
3104                fidl::encoding::DefaultFuchsiaResourceDialect,
3105            >,
3106            offset: usize,
3107            depth: fidl::encoding::Depth,
3108        ) -> fidl::Result<()> {
3109            encoder.debug_check_bounds::<DeviceStartAndWaitResponse>(offset);
3110            // Zero out padding regions. There's no need to apply masks
3111            // because the unmasked parts will be overwritten by fields.
3112            // Write the fields.
3113            self.0.encode(encoder, offset + 0, depth)?;
3114            Ok(())
3115        }
3116    }
3117
3118    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3119        for DeviceStartAndWaitResponse
3120    {
3121        #[inline(always)]
3122        fn new_empty() -> Self {
3123            Self {
3124                keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3125            }
3126        }
3127
3128        #[inline]
3129        unsafe fn decode(
3130            &mut self,
3131            decoder: &mut fidl::encoding::Decoder<
3132                '_,
3133                fidl::encoding::DefaultFuchsiaResourceDialect,
3134            >,
3135            offset: usize,
3136            _depth: fidl::encoding::Depth,
3137        ) -> fidl::Result<()> {
3138            decoder.debug_check_bounds::<Self>(offset);
3139            // Verify that padding bytes are zero.
3140            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.keep_alive, decoder, offset + 0, _depth)?;
3141            Ok(())
3142        }
3143    }
3144
3145    impl Properties {
3146        #[inline(always)]
3147        fn max_ordinal_present(&self) -> u64 {
3148            if let Some(_) = self.timers_properties {
3149                return 1;
3150            }
3151            0
3152        }
3153    }
3154
3155    impl fidl::encoding::ResourceTypeMarker for Properties {
3156        type Borrowed<'a> = &'a mut Self;
3157        fn take_or_borrow<'a>(
3158            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3159        ) -> Self::Borrowed<'a> {
3160            value
3161        }
3162    }
3163
3164    unsafe impl fidl::encoding::TypeMarker for Properties {
3165        type Owned = Self;
3166
3167        #[inline(always)]
3168        fn inline_align(_context: fidl::encoding::Context) -> usize {
3169            8
3170        }
3171
3172        #[inline(always)]
3173        fn inline_size(_context: fidl::encoding::Context) -> usize {
3174            16
3175        }
3176    }
3177
3178    unsafe impl fidl::encoding::Encode<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>
3179        for &mut Properties
3180    {
3181        unsafe fn encode(
3182            self,
3183            encoder: &mut fidl::encoding::Encoder<
3184                '_,
3185                fidl::encoding::DefaultFuchsiaResourceDialect,
3186            >,
3187            offset: usize,
3188            mut depth: fidl::encoding::Depth,
3189        ) -> fidl::Result<()> {
3190            encoder.debug_check_bounds::<Properties>(offset);
3191            // Vector header
3192            let max_ordinal: u64 = self.max_ordinal_present();
3193            encoder.write_num(max_ordinal, offset);
3194            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3195            // Calling encoder.out_of_line_offset(0) is not allowed.
3196            if max_ordinal == 0 {
3197                return Ok(());
3198            }
3199            depth.increment()?;
3200            let envelope_size = 8;
3201            let bytes_len = max_ordinal as usize * envelope_size;
3202            #[allow(unused_variables)]
3203            let offset = encoder.out_of_line_offset(bytes_len);
3204            let mut _prev_end_offset: usize = 0;
3205            if 1 > max_ordinal {
3206                return Ok(());
3207            }
3208
3209            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3210            // are envelope_size bytes.
3211            let cur_offset: usize = (1 - 1) * envelope_size;
3212
3213            // Zero reserved fields.
3214            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3215
3216            // Safety:
3217            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3218            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3219            //   envelope_size bytes, there is always sufficient room.
3220            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<TimerProperties, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3221            self.timers_properties.as_ref().map(<fidl::encoding::Vector<TimerProperties, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3222            encoder, offset + cur_offset, depth
3223        )?;
3224
3225            _prev_end_offset = cur_offset + envelope_size;
3226
3227            Ok(())
3228        }
3229    }
3230
3231    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Properties {
3232        #[inline(always)]
3233        fn new_empty() -> Self {
3234            Self::default()
3235        }
3236
3237        unsafe fn decode(
3238            &mut self,
3239            decoder: &mut fidl::encoding::Decoder<
3240                '_,
3241                fidl::encoding::DefaultFuchsiaResourceDialect,
3242            >,
3243            offset: usize,
3244            mut depth: fidl::encoding::Depth,
3245        ) -> fidl::Result<()> {
3246            decoder.debug_check_bounds::<Self>(offset);
3247            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3248                None => return Err(fidl::Error::NotNullable),
3249                Some(len) => len,
3250            };
3251            // Calling decoder.out_of_line_offset(0) is not allowed.
3252            if len == 0 {
3253                return Ok(());
3254            };
3255            depth.increment()?;
3256            let envelope_size = 8;
3257            let bytes_len = len * envelope_size;
3258            let offset = decoder.out_of_line_offset(bytes_len)?;
3259            // Decode the envelope for each type.
3260            let mut _next_ordinal_to_read = 0;
3261            let mut next_offset = offset;
3262            let end_offset = offset + bytes_len;
3263            _next_ordinal_to_read += 1;
3264            if next_offset >= end_offset {
3265                return Ok(());
3266            }
3267
3268            // Decode unknown envelopes for gaps in ordinals.
3269            while _next_ordinal_to_read < 1 {
3270                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3271                _next_ordinal_to_read += 1;
3272                next_offset += envelope_size;
3273            }
3274
3275            let next_out_of_line = decoder.next_out_of_line();
3276            let handles_before = decoder.remaining_handles();
3277            if let Some((inlined, num_bytes, num_handles)) =
3278                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3279            {
3280                let member_inline_size = <fidl::encoding::Vector<TimerProperties, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3281                if inlined != (member_inline_size <= 4) {
3282                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3283                }
3284                let inner_offset;
3285                let mut inner_depth = depth.clone();
3286                if inlined {
3287                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3288                    inner_offset = next_offset;
3289                } else {
3290                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3291                    inner_depth.increment()?;
3292                }
3293                let val_ref =
3294                self.timers_properties.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<TimerProperties, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
3295                fidl::decode!(fidl::encoding::Vector<TimerProperties, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3296                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3297                {
3298                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3299                }
3300                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3301                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3302                }
3303            }
3304
3305            next_offset += envelope_size;
3306
3307            // Decode the remaining unknown envelopes.
3308            while next_offset < end_offset {
3309                _next_ordinal_to_read += 1;
3310                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3311                next_offset += envelope_size;
3312            }
3313
3314            Ok(())
3315        }
3316    }
3317}