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