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