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::Handle {
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 {
1493            Some((id, responder))
1494        } else {
1495            None
1496        }
1497    }
1498
1499    #[allow(irrefutable_let_patterns)]
1500    pub fn into_get_ticks_left(self) -> Option<(u64, DeviceGetTicksLeftResponder)> {
1501        if let DeviceRequest::GetTicksLeft { id, responder } = self {
1502            Some((id, responder))
1503        } else {
1504            None
1505        }
1506    }
1507
1508    #[allow(irrefutable_let_patterns)]
1509    pub fn into_set_event(self) -> Option<(u64, fidl::Event, DeviceSetEventResponder)> {
1510        if let DeviceRequest::SetEvent { id, event, responder } = self {
1511            Some((id, event, responder))
1512        } else {
1513            None
1514        }
1515    }
1516
1517    #[allow(irrefutable_let_patterns)]
1518    pub fn into_start_and_wait(
1519        self,
1520    ) -> Option<(u64, Resolution, u64, fidl::Event, DeviceStartAndWaitResponder)> {
1521        if let DeviceRequest::StartAndWait { id, resolution, ticks, setup_event, responder } = self
1522        {
1523            Some((id, resolution, ticks, setup_event, responder))
1524        } else {
1525            None
1526        }
1527    }
1528
1529    #[allow(irrefutable_let_patterns)]
1530    pub fn into_start_and_wait2(
1531        self,
1532    ) -> Option<(u64, Resolution, u64, fidl::EventPair, DeviceStartAndWait2Responder)> {
1533        if let DeviceRequest::StartAndWait2 { id, resolution, ticks, setup_keep_alive, responder } =
1534            self
1535        {
1536            Some((id, resolution, ticks, setup_keep_alive, responder))
1537        } else {
1538            None
1539        }
1540    }
1541
1542    #[allow(irrefutable_let_patterns)]
1543    pub fn into_get_properties(self) -> Option<(DeviceGetPropertiesResponder)> {
1544        if let DeviceRequest::GetProperties { responder } = self {
1545            Some((responder))
1546        } else {
1547            None
1548        }
1549    }
1550
1551    /// Name of the method defined in FIDL
1552    pub fn method_name(&self) -> &'static str {
1553        match *self {
1554            DeviceRequest::Start { .. } => "start",
1555            DeviceRequest::ReadTimer { .. } => "read_timer",
1556            DeviceRequest::ReadClock { .. } => "read_clock",
1557            DeviceRequest::Stop { .. } => "stop",
1558            DeviceRequest::GetTicksLeft { .. } => "get_ticks_left",
1559            DeviceRequest::SetEvent { .. } => "set_event",
1560            DeviceRequest::StartAndWait { .. } => "start_and_wait",
1561            DeviceRequest::StartAndWait2 { .. } => "start_and_wait2",
1562            DeviceRequest::GetProperties { .. } => "get_properties",
1563            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1564                "unknown one-way method"
1565            }
1566            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1567                "unknown two-way method"
1568            }
1569        }
1570    }
1571}
1572
1573#[derive(Debug, Clone)]
1574pub struct DeviceControlHandle {
1575    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1576}
1577
1578impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1579    fn shutdown(&self) {
1580        self.inner.shutdown()
1581    }
1582    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1583        self.inner.shutdown_with_epitaph(status)
1584    }
1585
1586    fn is_closed(&self) -> bool {
1587        self.inner.channel().is_closed()
1588    }
1589    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1590        self.inner.channel().on_closed()
1591    }
1592
1593    #[cfg(target_os = "fuchsia")]
1594    fn signal_peer(
1595        &self,
1596        clear_mask: zx::Signals,
1597        set_mask: zx::Signals,
1598    ) -> Result<(), zx_status::Status> {
1599        use fidl::Peered;
1600        self.inner.channel().signal_peer(clear_mask, set_mask)
1601    }
1602}
1603
1604impl DeviceControlHandle {}
1605
1606#[must_use = "FIDL methods require a response to be sent"]
1607#[derive(Debug)]
1608pub struct DeviceStartResponder {
1609    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1610    tx_id: u32,
1611}
1612
1613/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1614/// if the responder is dropped without sending a response, so that the client
1615/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1616impl std::ops::Drop for DeviceStartResponder {
1617    fn drop(&mut self) {
1618        self.control_handle.shutdown();
1619        // Safety: drops once, never accessed again
1620        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1621    }
1622}
1623
1624impl fidl::endpoints::Responder for DeviceStartResponder {
1625    type ControlHandle = DeviceControlHandle;
1626
1627    fn control_handle(&self) -> &DeviceControlHandle {
1628        &self.control_handle
1629    }
1630
1631    fn drop_without_shutdown(mut self) {
1632        // Safety: drops once, never accessed again due to mem::forget
1633        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1634        // Prevent Drop from running (which would shut down the channel)
1635        std::mem::forget(self);
1636    }
1637}
1638
1639impl DeviceStartResponder {
1640    /// Sends a response to the FIDL transaction.
1641    ///
1642    /// Sets the channel to shutdown if an error occurs.
1643    pub fn send(self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1644        let _result = self.send_raw(result);
1645        if _result.is_err() {
1646            self.control_handle.shutdown();
1647        }
1648        self.drop_without_shutdown();
1649        _result
1650    }
1651
1652    /// Similar to "send" but does not shutdown the channel if an error occurs.
1653    pub fn send_no_shutdown_on_err(
1654        self,
1655        mut result: Result<(), DriverError>,
1656    ) -> Result<(), fidl::Error> {
1657        let _result = self.send_raw(result);
1658        self.drop_without_shutdown();
1659        _result
1660    }
1661
1662    fn send_raw(&self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1663        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1664            fidl::encoding::EmptyStruct,
1665            DriverError,
1666        >>(
1667            fidl::encoding::FlexibleResult::new(result),
1668            self.tx_id,
1669            0x5a0a193b0467cc8a,
1670            fidl::encoding::DynamicFlags::FLEXIBLE,
1671        )
1672    }
1673}
1674
1675#[must_use = "FIDL methods require a response to be sent"]
1676#[derive(Debug)]
1677pub struct DeviceReadTimerResponder {
1678    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1679    tx_id: u32,
1680}
1681
1682/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1683/// if the responder is dropped without sending a response, so that the client
1684/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1685impl std::ops::Drop for DeviceReadTimerResponder {
1686    fn drop(&mut self) {
1687        self.control_handle.shutdown();
1688        // Safety: drops once, never accessed again
1689        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1690    }
1691}
1692
1693impl fidl::endpoints::Responder for DeviceReadTimerResponder {
1694    type ControlHandle = DeviceControlHandle;
1695
1696    fn control_handle(&self) -> &DeviceControlHandle {
1697        &self.control_handle
1698    }
1699
1700    fn drop_without_shutdown(mut self) {
1701        // Safety: drops once, never accessed again due to mem::forget
1702        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1703        // Prevent Drop from running (which would shut down the channel)
1704        std::mem::forget(self);
1705    }
1706}
1707
1708impl DeviceReadTimerResponder {
1709    /// Sends a response to the FIDL transaction.
1710    ///
1711    /// Sets the channel to shutdown if an error occurs.
1712    pub fn send(self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1713        let _result = self.send_raw(result);
1714        if _result.is_err() {
1715            self.control_handle.shutdown();
1716        }
1717        self.drop_without_shutdown();
1718        _result
1719    }
1720
1721    /// Similar to "send" but does not shutdown the channel if an error occurs.
1722    pub fn send_no_shutdown_on_err(
1723        self,
1724        mut result: Result<u64, DriverError>,
1725    ) -> Result<(), fidl::Error> {
1726        let _result = self.send_raw(result);
1727        self.drop_without_shutdown();
1728        _result
1729    }
1730
1731    fn send_raw(&self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1732        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1733            DeviceReadTimerResponse,
1734            DriverError,
1735        >>(
1736            fidl::encoding::FlexibleResult::new(result.map(|ticks| (ticks,))),
1737            self.tx_id,
1738            0x4430d0e336ffb5e9,
1739            fidl::encoding::DynamicFlags::FLEXIBLE,
1740        )
1741    }
1742}
1743
1744#[must_use = "FIDL methods require a response to be sent"]
1745#[derive(Debug)]
1746pub struct DeviceReadClockResponder {
1747    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1748    tx_id: u32,
1749}
1750
1751/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1752/// if the responder is dropped without sending a response, so that the client
1753/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1754impl std::ops::Drop for DeviceReadClockResponder {
1755    fn drop(&mut self) {
1756        self.control_handle.shutdown();
1757        // Safety: drops once, never accessed again
1758        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1759    }
1760}
1761
1762impl fidl::endpoints::Responder for DeviceReadClockResponder {
1763    type ControlHandle = DeviceControlHandle;
1764
1765    fn control_handle(&self) -> &DeviceControlHandle {
1766        &self.control_handle
1767    }
1768
1769    fn drop_without_shutdown(mut self) {
1770        // Safety: drops once, never accessed again due to mem::forget
1771        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1772        // Prevent Drop from running (which would shut down the channel)
1773        std::mem::forget(self);
1774    }
1775}
1776
1777impl DeviceReadClockResponder {
1778    /// Sends a response to the FIDL transaction.
1779    ///
1780    /// Sets the channel to shutdown if an error occurs.
1781    pub fn send(self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1782        let _result = self.send_raw(result);
1783        if _result.is_err() {
1784            self.control_handle.shutdown();
1785        }
1786        self.drop_without_shutdown();
1787        _result
1788    }
1789
1790    /// Similar to "send" but does not shutdown the channel if an error occurs.
1791    pub fn send_no_shutdown_on_err(
1792        self,
1793        mut result: Result<u64, DriverError>,
1794    ) -> Result<(), fidl::Error> {
1795        let _result = self.send_raw(result);
1796        self.drop_without_shutdown();
1797        _result
1798    }
1799
1800    fn send_raw(&self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1801        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1802            DeviceReadClockResponse,
1803            DriverError,
1804        >>(
1805            fidl::encoding::FlexibleResult::new(result.map(|ticks| (ticks,))),
1806            self.tx_id,
1807            0x49aae10e0fb621ab,
1808            fidl::encoding::DynamicFlags::FLEXIBLE,
1809        )
1810    }
1811}
1812
1813#[must_use = "FIDL methods require a response to be sent"]
1814#[derive(Debug)]
1815pub struct DeviceStopResponder {
1816    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1817    tx_id: u32,
1818}
1819
1820/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1821/// if the responder is dropped without sending a response, so that the client
1822/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1823impl std::ops::Drop for DeviceStopResponder {
1824    fn drop(&mut self) {
1825        self.control_handle.shutdown();
1826        // Safety: drops once, never accessed again
1827        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1828    }
1829}
1830
1831impl fidl::endpoints::Responder for DeviceStopResponder {
1832    type ControlHandle = DeviceControlHandle;
1833
1834    fn control_handle(&self) -> &DeviceControlHandle {
1835        &self.control_handle
1836    }
1837
1838    fn drop_without_shutdown(mut self) {
1839        // Safety: drops once, never accessed again due to mem::forget
1840        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1841        // Prevent Drop from running (which would shut down the channel)
1842        std::mem::forget(self);
1843    }
1844}
1845
1846impl DeviceStopResponder {
1847    /// Sends a response to the FIDL transaction.
1848    ///
1849    /// Sets the channel to shutdown if an error occurs.
1850    pub fn send(self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1851        let _result = self.send_raw(result);
1852        if _result.is_err() {
1853            self.control_handle.shutdown();
1854        }
1855        self.drop_without_shutdown();
1856        _result
1857    }
1858
1859    /// Similar to "send" but does not shutdown the channel if an error occurs.
1860    pub fn send_no_shutdown_on_err(
1861        self,
1862        mut result: Result<(), DriverError>,
1863    ) -> Result<(), fidl::Error> {
1864        let _result = self.send_raw(result);
1865        self.drop_without_shutdown();
1866        _result
1867    }
1868
1869    fn send_raw(&self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1870        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1871            fidl::encoding::EmptyStruct,
1872            DriverError,
1873        >>(
1874            fidl::encoding::FlexibleResult::new(result),
1875            self.tx_id,
1876            0x77e4cd1c3841a0e2,
1877            fidl::encoding::DynamicFlags::FLEXIBLE,
1878        )
1879    }
1880}
1881
1882#[must_use = "FIDL methods require a response to be sent"]
1883#[derive(Debug)]
1884pub struct DeviceGetTicksLeftResponder {
1885    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1886    tx_id: u32,
1887}
1888
1889/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1890/// if the responder is dropped without sending a response, so that the client
1891/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1892impl std::ops::Drop for DeviceGetTicksLeftResponder {
1893    fn drop(&mut self) {
1894        self.control_handle.shutdown();
1895        // Safety: drops once, never accessed again
1896        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1897    }
1898}
1899
1900impl fidl::endpoints::Responder for DeviceGetTicksLeftResponder {
1901    type ControlHandle = DeviceControlHandle;
1902
1903    fn control_handle(&self) -> &DeviceControlHandle {
1904        &self.control_handle
1905    }
1906
1907    fn drop_without_shutdown(mut self) {
1908        // Safety: drops once, never accessed again due to mem::forget
1909        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1910        // Prevent Drop from running (which would shut down the channel)
1911        std::mem::forget(self);
1912    }
1913}
1914
1915impl DeviceGetTicksLeftResponder {
1916    /// Sends a response to the FIDL transaction.
1917    ///
1918    /// Sets the channel to shutdown if an error occurs.
1919    pub fn send(self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1920        let _result = self.send_raw(result);
1921        if _result.is_err() {
1922            self.control_handle.shutdown();
1923        }
1924        self.drop_without_shutdown();
1925        _result
1926    }
1927
1928    /// Similar to "send" but does not shutdown the channel if an error occurs.
1929    pub fn send_no_shutdown_on_err(
1930        self,
1931        mut result: Result<u64, DriverError>,
1932    ) -> Result<(), fidl::Error> {
1933        let _result = self.send_raw(result);
1934        self.drop_without_shutdown();
1935        _result
1936    }
1937
1938    fn send_raw(&self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
1939        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1940            DeviceGetTicksLeftResponse,
1941            DriverError,
1942        >>(
1943            fidl::encoding::FlexibleResult::new(result.map(|ticks| (ticks,))),
1944            self.tx_id,
1945            0xde2a48ae7d4b4ea,
1946            fidl::encoding::DynamicFlags::FLEXIBLE,
1947        )
1948    }
1949}
1950
1951#[must_use = "FIDL methods require a response to be sent"]
1952#[derive(Debug)]
1953pub struct DeviceSetEventResponder {
1954    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1955    tx_id: u32,
1956}
1957
1958/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1959/// if the responder is dropped without sending a response, so that the client
1960/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1961impl std::ops::Drop for DeviceSetEventResponder {
1962    fn drop(&mut self) {
1963        self.control_handle.shutdown();
1964        // Safety: drops once, never accessed again
1965        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1966    }
1967}
1968
1969impl fidl::endpoints::Responder for DeviceSetEventResponder {
1970    type ControlHandle = DeviceControlHandle;
1971
1972    fn control_handle(&self) -> &DeviceControlHandle {
1973        &self.control_handle
1974    }
1975
1976    fn drop_without_shutdown(mut self) {
1977        // Safety: drops once, never accessed again due to mem::forget
1978        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1979        // Prevent Drop from running (which would shut down the channel)
1980        std::mem::forget(self);
1981    }
1982}
1983
1984impl DeviceSetEventResponder {
1985    /// Sends a response to the FIDL transaction.
1986    ///
1987    /// Sets the channel to shutdown if an error occurs.
1988    pub fn send(self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
1989        let _result = self.send_raw(result);
1990        if _result.is_err() {
1991            self.control_handle.shutdown();
1992        }
1993        self.drop_without_shutdown();
1994        _result
1995    }
1996
1997    /// Similar to "send" but does not shutdown the channel if an error occurs.
1998    pub fn send_no_shutdown_on_err(
1999        self,
2000        mut result: Result<(), DriverError>,
2001    ) -> Result<(), fidl::Error> {
2002        let _result = self.send_raw(result);
2003        self.drop_without_shutdown();
2004        _result
2005    }
2006
2007    fn send_raw(&self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
2008        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2009            fidl::encoding::EmptyStruct,
2010            DriverError,
2011        >>(
2012            fidl::encoding::FlexibleResult::new(result),
2013            self.tx_id,
2014            0x1027024d25ffa820,
2015            fidl::encoding::DynamicFlags::FLEXIBLE,
2016        )
2017    }
2018}
2019
2020#[must_use = "FIDL methods require a response to be sent"]
2021#[derive(Debug)]
2022pub struct DeviceStartAndWaitResponder {
2023    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2024    tx_id: u32,
2025}
2026
2027/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2028/// if the responder is dropped without sending a response, so that the client
2029/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2030impl std::ops::Drop for DeviceStartAndWaitResponder {
2031    fn drop(&mut self) {
2032        self.control_handle.shutdown();
2033        // Safety: drops once, never accessed again
2034        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2035    }
2036}
2037
2038impl fidl::endpoints::Responder for DeviceStartAndWaitResponder {
2039    type ControlHandle = DeviceControlHandle;
2040
2041    fn control_handle(&self) -> &DeviceControlHandle {
2042        &self.control_handle
2043    }
2044
2045    fn drop_without_shutdown(mut self) {
2046        // Safety: drops once, never accessed again due to mem::forget
2047        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2048        // Prevent Drop from running (which would shut down the channel)
2049        std::mem::forget(self);
2050    }
2051}
2052
2053impl DeviceStartAndWaitResponder {
2054    /// Sends a response to the FIDL transaction.
2055    ///
2056    /// Sets the channel to shutdown if an error occurs.
2057    pub fn send(self, mut result: Result<fidl::EventPair, DriverError>) -> Result<(), fidl::Error> {
2058        let _result = self.send_raw(result);
2059        if _result.is_err() {
2060            self.control_handle.shutdown();
2061        }
2062        self.drop_without_shutdown();
2063        _result
2064    }
2065
2066    /// Similar to "send" but does not shutdown the channel if an error occurs.
2067    pub fn send_no_shutdown_on_err(
2068        self,
2069        mut result: Result<fidl::EventPair, DriverError>,
2070    ) -> Result<(), fidl::Error> {
2071        let _result = self.send_raw(result);
2072        self.drop_without_shutdown();
2073        _result
2074    }
2075
2076    fn send_raw(
2077        &self,
2078        mut result: Result<fidl::EventPair, DriverError>,
2079    ) -> Result<(), fidl::Error> {
2080        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2081            DeviceStartAndWaitResponse,
2082            DriverError,
2083        >>(
2084            fidl::encoding::FlexibleResult::new(result.map(|keep_alive| (keep_alive,))),
2085            self.tx_id,
2086            0x716f415cdf234e0f,
2087            fidl::encoding::DynamicFlags::FLEXIBLE,
2088        )
2089    }
2090}
2091
2092#[must_use = "FIDL methods require a response to be sent"]
2093#[derive(Debug)]
2094pub struct DeviceStartAndWait2Responder {
2095    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2096    tx_id: u32,
2097}
2098
2099/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2100/// if the responder is dropped without sending a response, so that the client
2101/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2102impl std::ops::Drop for DeviceStartAndWait2Responder {
2103    fn drop(&mut self) {
2104        self.control_handle.shutdown();
2105        // Safety: drops once, never accessed again
2106        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2107    }
2108}
2109
2110impl fidl::endpoints::Responder for DeviceStartAndWait2Responder {
2111    type ControlHandle = DeviceControlHandle;
2112
2113    fn control_handle(&self) -> &DeviceControlHandle {
2114        &self.control_handle
2115    }
2116
2117    fn drop_without_shutdown(mut self) {
2118        // Safety: drops once, never accessed again due to mem::forget
2119        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2120        // Prevent Drop from running (which would shut down the channel)
2121        std::mem::forget(self);
2122    }
2123}
2124
2125impl DeviceStartAndWait2Responder {
2126    /// Sends a response to the FIDL transaction.
2127    ///
2128    /// Sets the channel to shutdown if an error occurs.
2129    pub fn send(self, mut result: Result<fidl::EventPair, DriverError>) -> Result<(), fidl::Error> {
2130        let _result = self.send_raw(result);
2131        if _result.is_err() {
2132            self.control_handle.shutdown();
2133        }
2134        self.drop_without_shutdown();
2135        _result
2136    }
2137
2138    /// Similar to "send" but does not shutdown the channel if an error occurs.
2139    pub fn send_no_shutdown_on_err(
2140        self,
2141        mut result: Result<fidl::EventPair, DriverError>,
2142    ) -> Result<(), fidl::Error> {
2143        let _result = self.send_raw(result);
2144        self.drop_without_shutdown();
2145        _result
2146    }
2147
2148    fn send_raw(
2149        &self,
2150        mut result: Result<fidl::EventPair, DriverError>,
2151    ) -> Result<(), fidl::Error> {
2152        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2153            DeviceStartAndWait2Response,
2154            DriverError,
2155        >>(
2156            fidl::encoding::FlexibleResult::new(
2157                result.map(|expiration_keep_alive| (expiration_keep_alive,)),
2158            ),
2159            self.tx_id,
2160            0x5f2aaf21254d3238,
2161            fidl::encoding::DynamicFlags::FLEXIBLE,
2162        )
2163    }
2164}
2165
2166#[must_use = "FIDL methods require a response to be sent"]
2167#[derive(Debug)]
2168pub struct DeviceGetPropertiesResponder {
2169    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2170    tx_id: u32,
2171}
2172
2173/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2174/// if the responder is dropped without sending a response, so that the client
2175/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2176impl std::ops::Drop for DeviceGetPropertiesResponder {
2177    fn drop(&mut self) {
2178        self.control_handle.shutdown();
2179        // Safety: drops once, never accessed again
2180        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2181    }
2182}
2183
2184impl fidl::endpoints::Responder for DeviceGetPropertiesResponder {
2185    type ControlHandle = DeviceControlHandle;
2186
2187    fn control_handle(&self) -> &DeviceControlHandle {
2188        &self.control_handle
2189    }
2190
2191    fn drop_without_shutdown(mut self) {
2192        // Safety: drops once, never accessed again due to mem::forget
2193        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2194        // Prevent Drop from running (which would shut down the channel)
2195        std::mem::forget(self);
2196    }
2197}
2198
2199impl DeviceGetPropertiesResponder {
2200    /// Sends a response to the FIDL transaction.
2201    ///
2202    /// Sets the channel to shutdown if an error occurs.
2203    pub fn send(self, mut properties: Properties) -> Result<(), fidl::Error> {
2204        let _result = self.send_raw(properties);
2205        if _result.is_err() {
2206            self.control_handle.shutdown();
2207        }
2208        self.drop_without_shutdown();
2209        _result
2210    }
2211
2212    /// Similar to "send" but does not shutdown the channel if an error occurs.
2213    pub fn send_no_shutdown_on_err(self, mut properties: Properties) -> Result<(), fidl::Error> {
2214        let _result = self.send_raw(properties);
2215        self.drop_without_shutdown();
2216        _result
2217    }
2218
2219    fn send_raw(&self, mut properties: Properties) -> Result<(), fidl::Error> {
2220        self.control_handle.inner.send::<fidl::encoding::FlexibleType<DeviceGetPropertiesResponse>>(
2221            fidl::encoding::Flexible::new((&mut properties,)),
2222            self.tx_id,
2223            0x6bc22ab4c9396cbb,
2224            fidl::encoding::DynamicFlags::FLEXIBLE,
2225        )
2226    }
2227}
2228
2229#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2230pub struct ServiceMarker;
2231
2232#[cfg(target_os = "fuchsia")]
2233impl fidl::endpoints::ServiceMarker for ServiceMarker {
2234    type Proxy = ServiceProxy;
2235    type Request = ServiceRequest;
2236    const SERVICE_NAME: &'static str = "fuchsia.hardware.hrtimer.Service";
2237}
2238
2239/// A request for one of the member protocols of Service.
2240///
2241#[cfg(target_os = "fuchsia")]
2242pub enum ServiceRequest {
2243    Device(DeviceRequestStream),
2244}
2245
2246#[cfg(target_os = "fuchsia")]
2247impl fidl::endpoints::ServiceRequest for ServiceRequest {
2248    type Service = ServiceMarker;
2249
2250    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2251        match name {
2252            "device" => Self::Device(
2253                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2254            ),
2255            _ => panic!("no such member protocol name for service Service"),
2256        }
2257    }
2258
2259    fn member_names() -> &'static [&'static str] {
2260        &["device"]
2261    }
2262}
2263#[cfg(target_os = "fuchsia")]
2264pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2265
2266#[cfg(target_os = "fuchsia")]
2267impl fidl::endpoints::ServiceProxy for ServiceProxy {
2268    type Service = ServiceMarker;
2269
2270    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2271        Self(opener)
2272    }
2273}
2274
2275#[cfg(target_os = "fuchsia")]
2276impl ServiceProxy {
2277    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
2278        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
2279        self.connect_channel_to_device(server_end)?;
2280        Ok(proxy)
2281    }
2282
2283    /// Like `connect_to_device`, but returns a sync proxy.
2284    /// See [`Self::connect_to_device`] for more details.
2285    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
2286        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
2287        self.connect_channel_to_device(server_end)?;
2288        Ok(proxy)
2289    }
2290
2291    /// Like `connect_to_device`, but accepts a server end.
2292    /// See [`Self::connect_to_device`] for more details.
2293    pub fn connect_channel_to_device(
2294        &self,
2295        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
2296    ) -> Result<(), fidl::Error> {
2297        self.0.open_member("device", server_end.into_channel())
2298    }
2299
2300    pub fn instance_name(&self) -> &str {
2301        self.0.instance_name()
2302    }
2303}
2304
2305mod internal {
2306    use super::*;
2307
2308    impl fidl::encoding::ResourceTypeMarker for DeviceSetEventRequest {
2309        type Borrowed<'a> = &'a mut Self;
2310        fn take_or_borrow<'a>(
2311            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2312        ) -> Self::Borrowed<'a> {
2313            value
2314        }
2315    }
2316
2317    unsafe impl fidl::encoding::TypeMarker for DeviceSetEventRequest {
2318        type Owned = Self;
2319
2320        #[inline(always)]
2321        fn inline_align(_context: fidl::encoding::Context) -> usize {
2322            8
2323        }
2324
2325        #[inline(always)]
2326        fn inline_size(_context: fidl::encoding::Context) -> usize {
2327            16
2328        }
2329    }
2330
2331    unsafe impl
2332        fidl::encoding::Encode<DeviceSetEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2333        for &mut DeviceSetEventRequest
2334    {
2335        #[inline]
2336        unsafe fn encode(
2337            self,
2338            encoder: &mut fidl::encoding::Encoder<
2339                '_,
2340                fidl::encoding::DefaultFuchsiaResourceDialect,
2341            >,
2342            offset: usize,
2343            _depth: fidl::encoding::Depth,
2344        ) -> fidl::Result<()> {
2345            encoder.debug_check_bounds::<DeviceSetEventRequest>(offset);
2346            // Delegate to tuple encoding.
2347            fidl::encoding::Encode::<
2348                DeviceSetEventRequest,
2349                fidl::encoding::DefaultFuchsiaResourceDialect,
2350            >::encode(
2351                (
2352                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2353                    <fidl::encoding::HandleType<
2354                        fidl::Event,
2355                        { fidl::ObjectType::EVENT.into_raw() },
2356                        2147483648,
2357                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2358                        &mut self.event
2359                    ),
2360                ),
2361                encoder,
2362                offset,
2363                _depth,
2364            )
2365        }
2366    }
2367    unsafe impl<
2368            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2369            T1: fidl::encoding::Encode<
2370                fidl::encoding::HandleType<
2371                    fidl::Event,
2372                    { fidl::ObjectType::EVENT.into_raw() },
2373                    2147483648,
2374                >,
2375                fidl::encoding::DefaultFuchsiaResourceDialect,
2376            >,
2377        >
2378        fidl::encoding::Encode<DeviceSetEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2379        for (T0, T1)
2380    {
2381        #[inline]
2382        unsafe fn encode(
2383            self,
2384            encoder: &mut fidl::encoding::Encoder<
2385                '_,
2386                fidl::encoding::DefaultFuchsiaResourceDialect,
2387            >,
2388            offset: usize,
2389            depth: fidl::encoding::Depth,
2390        ) -> fidl::Result<()> {
2391            encoder.debug_check_bounds::<DeviceSetEventRequest>(offset);
2392            // Zero out padding regions. There's no need to apply masks
2393            // because the unmasked parts will be overwritten by fields.
2394            unsafe {
2395                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
2396                (ptr as *mut u64).write_unaligned(0);
2397            }
2398            // Write the fields.
2399            self.0.encode(encoder, offset + 0, depth)?;
2400            self.1.encode(encoder, offset + 8, depth)?;
2401            Ok(())
2402        }
2403    }
2404
2405    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2406        for DeviceSetEventRequest
2407    {
2408        #[inline(always)]
2409        fn new_empty() -> Self {
2410            Self {
2411                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2412                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2413            }
2414        }
2415
2416        #[inline]
2417        unsafe fn decode(
2418            &mut self,
2419            decoder: &mut fidl::encoding::Decoder<
2420                '_,
2421                fidl::encoding::DefaultFuchsiaResourceDialect,
2422            >,
2423            offset: usize,
2424            _depth: fidl::encoding::Depth,
2425        ) -> fidl::Result<()> {
2426            decoder.debug_check_bounds::<Self>(offset);
2427            // Verify that padding bytes are zero.
2428            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
2429            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2430            let mask = 0xffffffff00000000u64;
2431            let maskedval = padval & mask;
2432            if maskedval != 0 {
2433                return Err(fidl::Error::NonZeroPadding {
2434                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
2435                });
2436            }
2437            fidl::decode!(
2438                u64,
2439                fidl::encoding::DefaultFuchsiaResourceDialect,
2440                &mut self.id,
2441                decoder,
2442                offset + 0,
2443                _depth
2444            )?;
2445            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 8, _depth)?;
2446            Ok(())
2447        }
2448    }
2449
2450    impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWait2Request {
2451        type Borrowed<'a> = &'a mut Self;
2452        fn take_or_borrow<'a>(
2453            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2454        ) -> Self::Borrowed<'a> {
2455            value
2456        }
2457    }
2458
2459    unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWait2Request {
2460        type Owned = Self;
2461
2462        #[inline(always)]
2463        fn inline_align(_context: fidl::encoding::Context) -> usize {
2464            8
2465        }
2466
2467        #[inline(always)]
2468        fn inline_size(_context: fidl::encoding::Context) -> usize {
2469            40
2470        }
2471    }
2472
2473    unsafe impl
2474        fidl::encoding::Encode<
2475            DeviceStartAndWait2Request,
2476            fidl::encoding::DefaultFuchsiaResourceDialect,
2477        > for &mut DeviceStartAndWait2Request
2478    {
2479        #[inline]
2480        unsafe fn encode(
2481            self,
2482            encoder: &mut fidl::encoding::Encoder<
2483                '_,
2484                fidl::encoding::DefaultFuchsiaResourceDialect,
2485            >,
2486            offset: usize,
2487            _depth: fidl::encoding::Depth,
2488        ) -> fidl::Result<()> {
2489            encoder.debug_check_bounds::<DeviceStartAndWait2Request>(offset);
2490            // Delegate to tuple encoding.
2491            fidl::encoding::Encode::<
2492                DeviceStartAndWait2Request,
2493                fidl::encoding::DefaultFuchsiaResourceDialect,
2494            >::encode(
2495                (
2496                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2497                    <Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
2498                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ticks),
2499                    <fidl::encoding::HandleType<
2500                        fidl::EventPair,
2501                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2502                        16387,
2503                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2504                        &mut self.setup_keep_alive,
2505                    ),
2506                ),
2507                encoder,
2508                offset,
2509                _depth,
2510            )
2511        }
2512    }
2513    unsafe impl<
2514            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2515            T1: fidl::encoding::Encode<Resolution, fidl::encoding::DefaultFuchsiaResourceDialect>,
2516            T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2517            T3: fidl::encoding::Encode<
2518                fidl::encoding::HandleType<
2519                    fidl::EventPair,
2520                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2521                    16387,
2522                >,
2523                fidl::encoding::DefaultFuchsiaResourceDialect,
2524            >,
2525        >
2526        fidl::encoding::Encode<
2527            DeviceStartAndWait2Request,
2528            fidl::encoding::DefaultFuchsiaResourceDialect,
2529        > for (T0, T1, T2, T3)
2530    {
2531        #[inline]
2532        unsafe fn encode(
2533            self,
2534            encoder: &mut fidl::encoding::Encoder<
2535                '_,
2536                fidl::encoding::DefaultFuchsiaResourceDialect,
2537            >,
2538            offset: usize,
2539            depth: fidl::encoding::Depth,
2540        ) -> fidl::Result<()> {
2541            encoder.debug_check_bounds::<DeviceStartAndWait2Request>(offset);
2542            // Zero out padding regions. There's no need to apply masks
2543            // because the unmasked parts will be overwritten by fields.
2544            unsafe {
2545                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
2546                (ptr as *mut u64).write_unaligned(0);
2547            }
2548            // Write the fields.
2549            self.0.encode(encoder, offset + 0, depth)?;
2550            self.1.encode(encoder, offset + 8, depth)?;
2551            self.2.encode(encoder, offset + 24, depth)?;
2552            self.3.encode(encoder, offset + 32, depth)?;
2553            Ok(())
2554        }
2555    }
2556
2557    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2558        for DeviceStartAndWait2Request
2559    {
2560        #[inline(always)]
2561        fn new_empty() -> Self {
2562            Self {
2563                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2564                resolution: fidl::new_empty!(
2565                    Resolution,
2566                    fidl::encoding::DefaultFuchsiaResourceDialect
2567                ),
2568                ticks: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2569                setup_keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
2570            }
2571        }
2572
2573        #[inline]
2574        unsafe fn decode(
2575            &mut self,
2576            decoder: &mut fidl::encoding::Decoder<
2577                '_,
2578                fidl::encoding::DefaultFuchsiaResourceDialect,
2579            >,
2580            offset: usize,
2581            _depth: fidl::encoding::Depth,
2582        ) -> fidl::Result<()> {
2583            decoder.debug_check_bounds::<Self>(offset);
2584            // Verify that padding bytes are zero.
2585            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
2586            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2587            let mask = 0xffffffff00000000u64;
2588            let maskedval = padval & mask;
2589            if maskedval != 0 {
2590                return Err(fidl::Error::NonZeroPadding {
2591                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
2592                });
2593            }
2594            fidl::decode!(
2595                u64,
2596                fidl::encoding::DefaultFuchsiaResourceDialect,
2597                &mut self.id,
2598                decoder,
2599                offset + 0,
2600                _depth
2601            )?;
2602            fidl::decode!(
2603                Resolution,
2604                fidl::encoding::DefaultFuchsiaResourceDialect,
2605                &mut self.resolution,
2606                decoder,
2607                offset + 8,
2608                _depth
2609            )?;
2610            fidl::decode!(
2611                u64,
2612                fidl::encoding::DefaultFuchsiaResourceDialect,
2613                &mut self.ticks,
2614                decoder,
2615                offset + 24,
2616                _depth
2617            )?;
2618            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)?;
2619            Ok(())
2620        }
2621    }
2622
2623    impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWaitRequest {
2624        type Borrowed<'a> = &'a mut Self;
2625        fn take_or_borrow<'a>(
2626            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2627        ) -> Self::Borrowed<'a> {
2628            value
2629        }
2630    }
2631
2632    unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWaitRequest {
2633        type Owned = Self;
2634
2635        #[inline(always)]
2636        fn inline_align(_context: fidl::encoding::Context) -> usize {
2637            8
2638        }
2639
2640        #[inline(always)]
2641        fn inline_size(_context: fidl::encoding::Context) -> usize {
2642            40
2643        }
2644    }
2645
2646    unsafe impl
2647        fidl::encoding::Encode<
2648            DeviceStartAndWaitRequest,
2649            fidl::encoding::DefaultFuchsiaResourceDialect,
2650        > for &mut DeviceStartAndWaitRequest
2651    {
2652        #[inline]
2653        unsafe fn encode(
2654            self,
2655            encoder: &mut fidl::encoding::Encoder<
2656                '_,
2657                fidl::encoding::DefaultFuchsiaResourceDialect,
2658            >,
2659            offset: usize,
2660            _depth: fidl::encoding::Depth,
2661        ) -> fidl::Result<()> {
2662            encoder.debug_check_bounds::<DeviceStartAndWaitRequest>(offset);
2663            // Delegate to tuple encoding.
2664            fidl::encoding::Encode::<
2665                DeviceStartAndWaitRequest,
2666                fidl::encoding::DefaultFuchsiaResourceDialect,
2667            >::encode(
2668                (
2669                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2670                    <Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
2671                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ticks),
2672                    <fidl::encoding::HandleType<
2673                        fidl::Event,
2674                        { fidl::ObjectType::EVENT.into_raw() },
2675                        2147483648,
2676                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2677                        &mut self.setup_event
2678                    ),
2679                ),
2680                encoder,
2681                offset,
2682                _depth,
2683            )
2684        }
2685    }
2686    unsafe impl<
2687            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2688            T1: fidl::encoding::Encode<Resolution, fidl::encoding::DefaultFuchsiaResourceDialect>,
2689            T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2690            T3: fidl::encoding::Encode<
2691                fidl::encoding::HandleType<
2692                    fidl::Event,
2693                    { fidl::ObjectType::EVENT.into_raw() },
2694                    2147483648,
2695                >,
2696                fidl::encoding::DefaultFuchsiaResourceDialect,
2697            >,
2698        >
2699        fidl::encoding::Encode<
2700            DeviceStartAndWaitRequest,
2701            fidl::encoding::DefaultFuchsiaResourceDialect,
2702        > for (T0, T1, T2, T3)
2703    {
2704        #[inline]
2705        unsafe fn encode(
2706            self,
2707            encoder: &mut fidl::encoding::Encoder<
2708                '_,
2709                fidl::encoding::DefaultFuchsiaResourceDialect,
2710            >,
2711            offset: usize,
2712            depth: fidl::encoding::Depth,
2713        ) -> fidl::Result<()> {
2714            encoder.debug_check_bounds::<DeviceStartAndWaitRequest>(offset);
2715            // Zero out padding regions. There's no need to apply masks
2716            // because the unmasked parts will be overwritten by fields.
2717            unsafe {
2718                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
2719                (ptr as *mut u64).write_unaligned(0);
2720            }
2721            // Write the fields.
2722            self.0.encode(encoder, offset + 0, depth)?;
2723            self.1.encode(encoder, offset + 8, depth)?;
2724            self.2.encode(encoder, offset + 24, depth)?;
2725            self.3.encode(encoder, offset + 32, depth)?;
2726            Ok(())
2727        }
2728    }
2729
2730    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2731        for DeviceStartAndWaitRequest
2732    {
2733        #[inline(always)]
2734        fn new_empty() -> Self {
2735            Self {
2736                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2737                resolution: fidl::new_empty!(
2738                    Resolution,
2739                    fidl::encoding::DefaultFuchsiaResourceDialect
2740                ),
2741                ticks: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2742                setup_event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2743            }
2744        }
2745
2746        #[inline]
2747        unsafe fn decode(
2748            &mut self,
2749            decoder: &mut fidl::encoding::Decoder<
2750                '_,
2751                fidl::encoding::DefaultFuchsiaResourceDialect,
2752            >,
2753            offset: usize,
2754            _depth: fidl::encoding::Depth,
2755        ) -> fidl::Result<()> {
2756            decoder.debug_check_bounds::<Self>(offset);
2757            // Verify that padding bytes are zero.
2758            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
2759            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2760            let mask = 0xffffffff00000000u64;
2761            let maskedval = padval & mask;
2762            if maskedval != 0 {
2763                return Err(fidl::Error::NonZeroPadding {
2764                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
2765                });
2766            }
2767            fidl::decode!(
2768                u64,
2769                fidl::encoding::DefaultFuchsiaResourceDialect,
2770                &mut self.id,
2771                decoder,
2772                offset + 0,
2773                _depth
2774            )?;
2775            fidl::decode!(
2776                Resolution,
2777                fidl::encoding::DefaultFuchsiaResourceDialect,
2778                &mut self.resolution,
2779                decoder,
2780                offset + 8,
2781                _depth
2782            )?;
2783            fidl::decode!(
2784                u64,
2785                fidl::encoding::DefaultFuchsiaResourceDialect,
2786                &mut self.ticks,
2787                decoder,
2788                offset + 24,
2789                _depth
2790            )?;
2791            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.setup_event, decoder, offset + 32, _depth)?;
2792            Ok(())
2793        }
2794    }
2795
2796    impl fidl::encoding::ResourceTypeMarker for DeviceGetPropertiesResponse {
2797        type Borrowed<'a> = &'a mut Self;
2798        fn take_or_borrow<'a>(
2799            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2800        ) -> Self::Borrowed<'a> {
2801            value
2802        }
2803    }
2804
2805    unsafe impl fidl::encoding::TypeMarker for DeviceGetPropertiesResponse {
2806        type Owned = Self;
2807
2808        #[inline(always)]
2809        fn inline_align(_context: fidl::encoding::Context) -> usize {
2810            8
2811        }
2812
2813        #[inline(always)]
2814        fn inline_size(_context: fidl::encoding::Context) -> usize {
2815            16
2816        }
2817    }
2818
2819    unsafe impl
2820        fidl::encoding::Encode<
2821            DeviceGetPropertiesResponse,
2822            fidl::encoding::DefaultFuchsiaResourceDialect,
2823        > for &mut DeviceGetPropertiesResponse
2824    {
2825        #[inline]
2826        unsafe fn encode(
2827            self,
2828            encoder: &mut fidl::encoding::Encoder<
2829                '_,
2830                fidl::encoding::DefaultFuchsiaResourceDialect,
2831            >,
2832            offset: usize,
2833            _depth: fidl::encoding::Depth,
2834        ) -> fidl::Result<()> {
2835            encoder.debug_check_bounds::<DeviceGetPropertiesResponse>(offset);
2836            // Delegate to tuple encoding.
2837            fidl::encoding::Encode::<
2838                DeviceGetPropertiesResponse,
2839                fidl::encoding::DefaultFuchsiaResourceDialect,
2840            >::encode(
2841                (<Properties as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2842                    &mut self.properties,
2843                ),),
2844                encoder,
2845                offset,
2846                _depth,
2847            )
2848        }
2849    }
2850    unsafe impl<T0: fidl::encoding::Encode<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>>
2851        fidl::encoding::Encode<
2852            DeviceGetPropertiesResponse,
2853            fidl::encoding::DefaultFuchsiaResourceDialect,
2854        > for (T0,)
2855    {
2856        #[inline]
2857        unsafe fn encode(
2858            self,
2859            encoder: &mut fidl::encoding::Encoder<
2860                '_,
2861                fidl::encoding::DefaultFuchsiaResourceDialect,
2862            >,
2863            offset: usize,
2864            depth: fidl::encoding::Depth,
2865        ) -> fidl::Result<()> {
2866            encoder.debug_check_bounds::<DeviceGetPropertiesResponse>(offset);
2867            // Zero out padding regions. There's no need to apply masks
2868            // because the unmasked parts will be overwritten by fields.
2869            // Write the fields.
2870            self.0.encode(encoder, offset + 0, depth)?;
2871            Ok(())
2872        }
2873    }
2874
2875    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2876        for DeviceGetPropertiesResponse
2877    {
2878        #[inline(always)]
2879        fn new_empty() -> Self {
2880            Self {
2881                properties: fidl::new_empty!(
2882                    Properties,
2883                    fidl::encoding::DefaultFuchsiaResourceDialect
2884                ),
2885            }
2886        }
2887
2888        #[inline]
2889        unsafe fn decode(
2890            &mut self,
2891            decoder: &mut fidl::encoding::Decoder<
2892                '_,
2893                fidl::encoding::DefaultFuchsiaResourceDialect,
2894            >,
2895            offset: usize,
2896            _depth: fidl::encoding::Depth,
2897        ) -> fidl::Result<()> {
2898            decoder.debug_check_bounds::<Self>(offset);
2899            // Verify that padding bytes are zero.
2900            fidl::decode!(
2901                Properties,
2902                fidl::encoding::DefaultFuchsiaResourceDialect,
2903                &mut self.properties,
2904                decoder,
2905                offset + 0,
2906                _depth
2907            )?;
2908            Ok(())
2909        }
2910    }
2911
2912    impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWait2Response {
2913        type Borrowed<'a> = &'a mut Self;
2914        fn take_or_borrow<'a>(
2915            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2916        ) -> Self::Borrowed<'a> {
2917            value
2918        }
2919    }
2920
2921    unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWait2Response {
2922        type Owned = Self;
2923
2924        #[inline(always)]
2925        fn inline_align(_context: fidl::encoding::Context) -> usize {
2926            4
2927        }
2928
2929        #[inline(always)]
2930        fn inline_size(_context: fidl::encoding::Context) -> usize {
2931            4
2932        }
2933    }
2934
2935    unsafe impl
2936        fidl::encoding::Encode<
2937            DeviceStartAndWait2Response,
2938            fidl::encoding::DefaultFuchsiaResourceDialect,
2939        > for &mut DeviceStartAndWait2Response
2940    {
2941        #[inline]
2942        unsafe fn encode(
2943            self,
2944            encoder: &mut fidl::encoding::Encoder<
2945                '_,
2946                fidl::encoding::DefaultFuchsiaResourceDialect,
2947            >,
2948            offset: usize,
2949            _depth: fidl::encoding::Depth,
2950        ) -> fidl::Result<()> {
2951            encoder.debug_check_bounds::<DeviceStartAndWait2Response>(offset);
2952            // Delegate to tuple encoding.
2953            fidl::encoding::Encode::<
2954                DeviceStartAndWait2Response,
2955                fidl::encoding::DefaultFuchsiaResourceDialect,
2956            >::encode(
2957                (<fidl::encoding::HandleType<
2958                    fidl::EventPair,
2959                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2960                    16387,
2961                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2962                    &mut self.expiration_keep_alive,
2963                ),),
2964                encoder,
2965                offset,
2966                _depth,
2967            )
2968        }
2969    }
2970    unsafe impl<
2971            T0: fidl::encoding::Encode<
2972                fidl::encoding::HandleType<
2973                    fidl::EventPair,
2974                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2975                    16387,
2976                >,
2977                fidl::encoding::DefaultFuchsiaResourceDialect,
2978            >,
2979        >
2980        fidl::encoding::Encode<
2981            DeviceStartAndWait2Response,
2982            fidl::encoding::DefaultFuchsiaResourceDialect,
2983        > for (T0,)
2984    {
2985        #[inline]
2986        unsafe fn encode(
2987            self,
2988            encoder: &mut fidl::encoding::Encoder<
2989                '_,
2990                fidl::encoding::DefaultFuchsiaResourceDialect,
2991            >,
2992            offset: usize,
2993            depth: fidl::encoding::Depth,
2994        ) -> fidl::Result<()> {
2995            encoder.debug_check_bounds::<DeviceStartAndWait2Response>(offset);
2996            // Zero out padding regions. There's no need to apply masks
2997            // because the unmasked parts will be overwritten by fields.
2998            // Write the fields.
2999            self.0.encode(encoder, offset + 0, depth)?;
3000            Ok(())
3001        }
3002    }
3003
3004    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3005        for DeviceStartAndWait2Response
3006    {
3007        #[inline(always)]
3008        fn new_empty() -> Self {
3009            Self {
3010                expiration_keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3011            }
3012        }
3013
3014        #[inline]
3015        unsafe fn decode(
3016            &mut self,
3017            decoder: &mut fidl::encoding::Decoder<
3018                '_,
3019                fidl::encoding::DefaultFuchsiaResourceDialect,
3020            >,
3021            offset: usize,
3022            _depth: fidl::encoding::Depth,
3023        ) -> fidl::Result<()> {
3024            decoder.debug_check_bounds::<Self>(offset);
3025            // Verify that padding bytes are zero.
3026            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)?;
3027            Ok(())
3028        }
3029    }
3030
3031    impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWaitResponse {
3032        type Borrowed<'a> = &'a mut Self;
3033        fn take_or_borrow<'a>(
3034            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3035        ) -> Self::Borrowed<'a> {
3036            value
3037        }
3038    }
3039
3040    unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWaitResponse {
3041        type Owned = Self;
3042
3043        #[inline(always)]
3044        fn inline_align(_context: fidl::encoding::Context) -> usize {
3045            4
3046        }
3047
3048        #[inline(always)]
3049        fn inline_size(_context: fidl::encoding::Context) -> usize {
3050            4
3051        }
3052    }
3053
3054    unsafe impl
3055        fidl::encoding::Encode<
3056            DeviceStartAndWaitResponse,
3057            fidl::encoding::DefaultFuchsiaResourceDialect,
3058        > for &mut DeviceStartAndWaitResponse
3059    {
3060        #[inline]
3061        unsafe fn encode(
3062            self,
3063            encoder: &mut fidl::encoding::Encoder<
3064                '_,
3065                fidl::encoding::DefaultFuchsiaResourceDialect,
3066            >,
3067            offset: usize,
3068            _depth: fidl::encoding::Depth,
3069        ) -> fidl::Result<()> {
3070            encoder.debug_check_bounds::<DeviceStartAndWaitResponse>(offset);
3071            // Delegate to tuple encoding.
3072            fidl::encoding::Encode::<
3073                DeviceStartAndWaitResponse,
3074                fidl::encoding::DefaultFuchsiaResourceDialect,
3075            >::encode(
3076                (<fidl::encoding::HandleType<
3077                    fidl::EventPair,
3078                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3079                    16387,
3080                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3081                    &mut self.keep_alive
3082                ),),
3083                encoder,
3084                offset,
3085                _depth,
3086            )
3087        }
3088    }
3089    unsafe impl<
3090            T0: fidl::encoding::Encode<
3091                fidl::encoding::HandleType<
3092                    fidl::EventPair,
3093                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3094                    16387,
3095                >,
3096                fidl::encoding::DefaultFuchsiaResourceDialect,
3097            >,
3098        >
3099        fidl::encoding::Encode<
3100            DeviceStartAndWaitResponse,
3101            fidl::encoding::DefaultFuchsiaResourceDialect,
3102        > for (T0,)
3103    {
3104        #[inline]
3105        unsafe fn encode(
3106            self,
3107            encoder: &mut fidl::encoding::Encoder<
3108                '_,
3109                fidl::encoding::DefaultFuchsiaResourceDialect,
3110            >,
3111            offset: usize,
3112            depth: fidl::encoding::Depth,
3113        ) -> fidl::Result<()> {
3114            encoder.debug_check_bounds::<DeviceStartAndWaitResponse>(offset);
3115            // Zero out padding regions. There's no need to apply masks
3116            // because the unmasked parts will be overwritten by fields.
3117            // Write the fields.
3118            self.0.encode(encoder, offset + 0, depth)?;
3119            Ok(())
3120        }
3121    }
3122
3123    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3124        for DeviceStartAndWaitResponse
3125    {
3126        #[inline(always)]
3127        fn new_empty() -> Self {
3128            Self {
3129                keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3130            }
3131        }
3132
3133        #[inline]
3134        unsafe fn decode(
3135            &mut self,
3136            decoder: &mut fidl::encoding::Decoder<
3137                '_,
3138                fidl::encoding::DefaultFuchsiaResourceDialect,
3139            >,
3140            offset: usize,
3141            _depth: fidl::encoding::Depth,
3142        ) -> fidl::Result<()> {
3143            decoder.debug_check_bounds::<Self>(offset);
3144            // Verify that padding bytes are zero.
3145            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.keep_alive, decoder, offset + 0, _depth)?;
3146            Ok(())
3147        }
3148    }
3149
3150    impl Properties {
3151        #[inline(always)]
3152        fn max_ordinal_present(&self) -> u64 {
3153            if let Some(_) = self.timers_properties {
3154                return 1;
3155            }
3156            0
3157        }
3158    }
3159
3160    impl fidl::encoding::ResourceTypeMarker for Properties {
3161        type Borrowed<'a> = &'a mut Self;
3162        fn take_or_borrow<'a>(
3163            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3164        ) -> Self::Borrowed<'a> {
3165            value
3166        }
3167    }
3168
3169    unsafe impl fidl::encoding::TypeMarker for Properties {
3170        type Owned = Self;
3171
3172        #[inline(always)]
3173        fn inline_align(_context: fidl::encoding::Context) -> usize {
3174            8
3175        }
3176
3177        #[inline(always)]
3178        fn inline_size(_context: fidl::encoding::Context) -> usize {
3179            16
3180        }
3181    }
3182
3183    unsafe impl fidl::encoding::Encode<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>
3184        for &mut Properties
3185    {
3186        unsafe fn encode(
3187            self,
3188            encoder: &mut fidl::encoding::Encoder<
3189                '_,
3190                fidl::encoding::DefaultFuchsiaResourceDialect,
3191            >,
3192            offset: usize,
3193            mut depth: fidl::encoding::Depth,
3194        ) -> fidl::Result<()> {
3195            encoder.debug_check_bounds::<Properties>(offset);
3196            // Vector header
3197            let max_ordinal: u64 = self.max_ordinal_present();
3198            encoder.write_num(max_ordinal, offset);
3199            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3200            // Calling encoder.out_of_line_offset(0) is not allowed.
3201            if max_ordinal == 0 {
3202                return Ok(());
3203            }
3204            depth.increment()?;
3205            let envelope_size = 8;
3206            let bytes_len = max_ordinal as usize * envelope_size;
3207            #[allow(unused_variables)]
3208            let offset = encoder.out_of_line_offset(bytes_len);
3209            let mut _prev_end_offset: usize = 0;
3210            if 1 > max_ordinal {
3211                return Ok(());
3212            }
3213
3214            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3215            // are envelope_size bytes.
3216            let cur_offset: usize = (1 - 1) * envelope_size;
3217
3218            // Zero reserved fields.
3219            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3220
3221            // Safety:
3222            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3223            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3224            //   envelope_size bytes, there is always sufficient room.
3225            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<TimerProperties, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3226            self.timers_properties.as_ref().map(<fidl::encoding::Vector<TimerProperties, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3227            encoder, offset + cur_offset, depth
3228        )?;
3229
3230            _prev_end_offset = cur_offset + envelope_size;
3231
3232            Ok(())
3233        }
3234    }
3235
3236    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Properties {
3237        #[inline(always)]
3238        fn new_empty() -> Self {
3239            Self::default()
3240        }
3241
3242        unsafe fn decode(
3243            &mut self,
3244            decoder: &mut fidl::encoding::Decoder<
3245                '_,
3246                fidl::encoding::DefaultFuchsiaResourceDialect,
3247            >,
3248            offset: usize,
3249            mut depth: fidl::encoding::Depth,
3250        ) -> fidl::Result<()> {
3251            decoder.debug_check_bounds::<Self>(offset);
3252            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3253                None => return Err(fidl::Error::NotNullable),
3254                Some(len) => len,
3255            };
3256            // Calling decoder.out_of_line_offset(0) is not allowed.
3257            if len == 0 {
3258                return Ok(());
3259            };
3260            depth.increment()?;
3261            let envelope_size = 8;
3262            let bytes_len = len * envelope_size;
3263            let offset = decoder.out_of_line_offset(bytes_len)?;
3264            // Decode the envelope for each type.
3265            let mut _next_ordinal_to_read = 0;
3266            let mut next_offset = offset;
3267            let end_offset = offset + bytes_len;
3268            _next_ordinal_to_read += 1;
3269            if next_offset >= end_offset {
3270                return Ok(());
3271            }
3272
3273            // Decode unknown envelopes for gaps in ordinals.
3274            while _next_ordinal_to_read < 1 {
3275                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3276                _next_ordinal_to_read += 1;
3277                next_offset += envelope_size;
3278            }
3279
3280            let next_out_of_line = decoder.next_out_of_line();
3281            let handles_before = decoder.remaining_handles();
3282            if let Some((inlined, num_bytes, num_handles)) =
3283                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3284            {
3285                let member_inline_size = <fidl::encoding::Vector<TimerProperties, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3286                if inlined != (member_inline_size <= 4) {
3287                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3288                }
3289                let inner_offset;
3290                let mut inner_depth = depth.clone();
3291                if inlined {
3292                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3293                    inner_offset = next_offset;
3294                } else {
3295                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3296                    inner_depth.increment()?;
3297                }
3298                let val_ref =
3299                self.timers_properties.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<TimerProperties, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
3300                fidl::decode!(fidl::encoding::Vector<TimerProperties, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3301                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3302                {
3303                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3304                }
3305                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3306                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3307                }
3308            }
3309
3310            next_offset += envelope_size;
3311
3312            // Decode the remaining unknown envelopes.
3313            while next_offset < end_offset {
3314                _next_ordinal_to_read += 1;
3315                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3316                next_offset += envelope_size;
3317            }
3318
3319            Ok(())
3320        }
3321    }
3322}