Skip to main content

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