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