Skip to main content

fidl_fuchsia_hardware_clock/
fidl_fuchsia_hardware_clock.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_clock_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ClockMarker;
16
17impl fidl::endpoints::ProtocolMarker for ClockMarker {
18    type Proxy = ClockProxy;
19    type RequestStream = ClockRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ClockSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.hardware.clock.Clock";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ClockMarker {}
26pub type ClockEnableResult = Result<(), i32>;
27pub type ClockDisableResult = Result<(), i32>;
28pub type ClockIsEnabledResult = Result<bool, i32>;
29pub type ClockSetRateResult = Result<(), i32>;
30pub type ClockQuerySupportedRateResult = Result<u64, i32>;
31pub type ClockGetRateResult = Result<u64, i32>;
32pub type ClockSetInputResult = Result<(), i32>;
33pub type ClockGetNumInputsResult = Result<u32, i32>;
34pub type ClockGetInputResult = Result<u32, i32>;
35
36pub trait ClockProxyInterface: Send + Sync {
37    type EnableResponseFut: std::future::Future<Output = Result<ClockEnableResult, fidl::Error>>
38        + Send;
39    fn r#enable(&self) -> Self::EnableResponseFut;
40    type DisableResponseFut: std::future::Future<Output = Result<ClockDisableResult, fidl::Error>>
41        + Send;
42    fn r#disable(&self) -> Self::DisableResponseFut;
43    type IsEnabledResponseFut: std::future::Future<Output = Result<ClockIsEnabledResult, fidl::Error>>
44        + Send;
45    fn r#is_enabled(&self) -> Self::IsEnabledResponseFut;
46    type SetRateResponseFut: std::future::Future<Output = Result<ClockSetRateResult, fidl::Error>>
47        + Send;
48    fn r#set_rate(&self, hz: u64) -> Self::SetRateResponseFut;
49    type QuerySupportedRateResponseFut: std::future::Future<Output = Result<ClockQuerySupportedRateResult, fidl::Error>>
50        + Send;
51    fn r#query_supported_rate(&self, hz_in: u64) -> Self::QuerySupportedRateResponseFut;
52    type GetRateResponseFut: std::future::Future<Output = Result<ClockGetRateResult, fidl::Error>>
53        + Send;
54    fn r#get_rate(&self) -> Self::GetRateResponseFut;
55    type SetInputResponseFut: std::future::Future<Output = Result<ClockSetInputResult, fidl::Error>>
56        + Send;
57    fn r#set_input(&self, idx: u32) -> Self::SetInputResponseFut;
58    type GetNumInputsResponseFut: std::future::Future<Output = Result<ClockGetNumInputsResult, fidl::Error>>
59        + Send;
60    fn r#get_num_inputs(&self) -> Self::GetNumInputsResponseFut;
61    type GetInputResponseFut: std::future::Future<Output = Result<ClockGetInputResult, fidl::Error>>
62        + Send;
63    fn r#get_input(&self) -> Self::GetInputResponseFut;
64    type GetPropertiesResponseFut: std::future::Future<Output = Result<(u32, String), fidl::Error>>
65        + Send;
66    fn r#get_properties(&self) -> Self::GetPropertiesResponseFut;
67}
68#[derive(Debug)]
69#[cfg(target_os = "fuchsia")]
70pub struct ClockSynchronousProxy {
71    client: fidl::client::sync::Client,
72}
73
74#[cfg(target_os = "fuchsia")]
75impl fidl::endpoints::SynchronousProxy for ClockSynchronousProxy {
76    type Proxy = ClockProxy;
77    type Protocol = ClockMarker;
78
79    fn from_channel(inner: fidl::Channel) -> Self {
80        Self::new(inner)
81    }
82
83    fn into_channel(self) -> fidl::Channel {
84        self.client.into_channel()
85    }
86
87    fn as_channel(&self) -> &fidl::Channel {
88        self.client.as_channel()
89    }
90}
91
92#[cfg(target_os = "fuchsia")]
93impl ClockSynchronousProxy {
94    pub fn new(channel: fidl::Channel) -> Self {
95        Self { client: fidl::client::sync::Client::new(channel) }
96    }
97
98    pub fn into_channel(self) -> fidl::Channel {
99        self.client.into_channel()
100    }
101
102    /// Waits until an event arrives and returns it. It is safe for other
103    /// threads to make concurrent requests while waiting for an event.
104    pub fn wait_for_event(
105        &self,
106        deadline: zx::MonotonicInstant,
107    ) -> Result<ClockEvent, fidl::Error> {
108        ClockEvent::decode(self.client.wait_for_event::<ClockMarker>(deadline)?)
109    }
110
111    /// Enables (ungates) this clock.
112    /// Drivers *must* call enable on all clocks they depend upon.
113    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `Enable`.
114    /// Returns `ZX_ERR_TIMED_OUT` if an operation timed out (for instance, a PLL was unable to lock).
115    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
116    pub fn r#enable(
117        &self,
118        ___deadline: zx::MonotonicInstant,
119    ) -> Result<ClockEnableResult, fidl::Error> {
120        let _response = self.client.send_query::<
121            fidl::encoding::EmptyPayload,
122            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
123            ClockMarker,
124        >(
125            (),
126            0x5e2816e21e9da22e,
127            fidl::encoding::DynamicFlags::FLEXIBLE,
128            ___deadline,
129        )?
130        .into_result::<ClockMarker>("enable")?;
131        Ok(_response.map(|x| x))
132    }
133
134    /// Disables (gates) this clock.
135    /// Drivers should call this method to indicate to the clock subsystem that
136    /// a particular clock signal is no longer necessary.
137    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `Disable`
138    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
139    pub fn r#disable(
140        &self,
141        ___deadline: zx::MonotonicInstant,
142    ) -> Result<ClockDisableResult, fidl::Error> {
143        let _response = self.client.send_query::<
144            fidl::encoding::EmptyPayload,
145            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
146            ClockMarker,
147        >(
148            (),
149            0x798ab22d09abb19,
150            fidl::encoding::DynamicFlags::FLEXIBLE,
151            ___deadline,
152        )?
153        .into_result::<ClockMarker>("disable")?;
154        Ok(_response.map(|x| x))
155    }
156
157    /// Returns `true` if a given clock is running.
158    /// May query the hardware or return a cached value.
159    /// IsEnabled shall not alter the state of the clock tree in any way.
160    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `IsEnabled`.
161    pub fn r#is_enabled(
162        &self,
163        ___deadline: zx::MonotonicInstant,
164    ) -> Result<ClockIsEnabledResult, fidl::Error> {
165        let _response = self.client.send_query::<
166            fidl::encoding::EmptyPayload,
167            fidl::encoding::FlexibleResultType<ClockIsEnabledResponse, i32>,
168            ClockMarker,
169        >(
170            (),
171            0xcf2dc6aafb08d87,
172            fidl::encoding::DynamicFlags::FLEXIBLE,
173            ___deadline,
174        )?
175        .into_result::<ClockMarker>("is_enabled")?;
176        Ok(_response.map(|x| x.enabled))
177    }
178
179    /// Attempt to set the rate of the clock provider.
180    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `SetRate`
181    /// Returns `ZX_ERR_INVALID_ARGS` if the requested rate is not one that is reported as supported by `QuerySupportedRate`.
182    /// Returns `ZX_ERR_TIMED_OUT` if an operation timed out (for instance, a PLL was unable to lock).
183    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
184    pub fn r#set_rate(
185        &self,
186        mut hz: u64,
187        ___deadline: zx::MonotonicInstant,
188    ) -> Result<ClockSetRateResult, fidl::Error> {
189        let _response = self.client.send_query::<
190            ClockSetRateRequest,
191            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
192            ClockMarker,
193        >(
194            (hz,),
195            0xe55e2c37b5f6e04,
196            fidl::encoding::DynamicFlags::FLEXIBLE,
197            ___deadline,
198        )?
199        .into_result::<ClockMarker>("set_rate")?;
200        Ok(_response.map(|x| x))
201    }
202
203    /// Query the hardware for the highest supported rate that does not
204    /// exceed hz_in.
205    /// `QuerySupportedRate` shall not alter the state of the clock tree in any way.
206    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `QuerySupportedRate`.
207    /// Returns `ZX_ERR_OUT_OF_RANGE` if a suitable rate could not be found.
208    pub fn r#query_supported_rate(
209        &self,
210        mut hz_in: u64,
211        ___deadline: zx::MonotonicInstant,
212    ) -> Result<ClockQuerySupportedRateResult, fidl::Error> {
213        let _response = self.client.send_query::<
214            ClockQuerySupportedRateRequest,
215            fidl::encoding::FlexibleResultType<ClockQuerySupportedRateResponse, i32>,
216            ClockMarker,
217        >(
218            (hz_in,),
219            0x3c42f4eb055765d1,
220            fidl::encoding::DynamicFlags::FLEXIBLE,
221            ___deadline,
222        )?
223        .into_result::<ClockMarker>("query_supported_rate")?;
224        Ok(_response.map(|x| x.hz_out))
225    }
226
227    /// Returns the current rate that a given clock is running at.
228    /// GetRate shall not alter the state of the clock tree in any way.
229    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `GetRate `.
230    pub fn r#get_rate(
231        &self,
232        ___deadline: zx::MonotonicInstant,
233    ) -> Result<ClockGetRateResult, fidl::Error> {
234        let _response = self.client.send_query::<
235            fidl::encoding::EmptyPayload,
236            fidl::encoding::FlexibleResultType<ClockGetRateResponse, i32>,
237            ClockMarker,
238        >(
239            (),
240            0xf8f2c8acaa82e7d,
241            fidl::encoding::DynamicFlags::FLEXIBLE,
242            ___deadline,
243        )?
244        .into_result::<ClockMarker>("get_rate")?;
245        Ok(_response.map(|x| x.hz))
246    }
247
248    /// Sets the input of this clock by index. I.e. by selecting a mux.
249    /// This clock has N inputs defined 0 through N-1, which are valid arguemts
250    /// as the index to SetInput.
251    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `SetInput`
252    /// Returns `ZX_ERR_OUT_OF_RANGE` if `idx` is outside of the range supplied by `GetNumInputs`.
253    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
254    pub fn r#set_input(
255        &self,
256        mut idx: u32,
257        ___deadline: zx::MonotonicInstant,
258    ) -> Result<ClockSetInputResult, fidl::Error> {
259        let _response = self.client.send_query::<
260            ClockSetInputRequest,
261            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
262            ClockMarker,
263        >(
264            (idx,),
265            0x486aad01b832c460,
266            fidl::encoding::DynamicFlags::FLEXIBLE,
267            ___deadline,
268        )?
269        .into_result::<ClockMarker>("set_input")?;
270        Ok(_response.map(|x| x))
271    }
272
273    /// Returns the number of inputs this clock has.
274    /// Any value between 0 and UINT32_MAX is a valid return for this method.
275    /// A Root Oscillator may return 0 for instance, if it has no inputs.
276    /// GetNumInputs shall not alter the state of the clock tree in any way.
277    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `GetNumInputs`.
278    pub fn r#get_num_inputs(
279        &self,
280        ___deadline: zx::MonotonicInstant,
281    ) -> Result<ClockGetNumInputsResult, fidl::Error> {
282        let _response = self.client.send_query::<
283            fidl::encoding::EmptyPayload,
284            fidl::encoding::FlexibleResultType<ClockGetNumInputsResponse, i32>,
285            ClockMarker,
286        >(
287            (),
288            0x7666d4a62c66de43,
289            fidl::encoding::DynamicFlags::FLEXIBLE,
290            ___deadline,
291        )?
292        .into_result::<ClockMarker>("get_num_inputs")?;
293        Ok(_response.map(|x| x.n))
294    }
295
296    /// Returns the index of the current input of this clock.
297    /// GetInput shall not alter the state of the clock tree in any way.
298    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `GetInput`.
299    pub fn r#get_input(
300        &self,
301        ___deadline: zx::MonotonicInstant,
302    ) -> Result<ClockGetInputResult, fidl::Error> {
303        let _response = self.client.send_query::<
304            fidl::encoding::EmptyPayload,
305            fidl::encoding::FlexibleResultType<ClockGetInputResponse, i32>,
306            ClockMarker,
307        >(
308            (),
309            0x23de9a9d0640a111,
310            fidl::encoding::DynamicFlags::FLEXIBLE,
311            ___deadline,
312        )?
313        .into_result::<ClockMarker>("get_input")?;
314        Ok(_response.map(|x| x.index))
315    }
316
317    /// Returns the static properties of a clock.
318    pub fn r#get_properties(
319        &self,
320        ___deadline: zx::MonotonicInstant,
321    ) -> Result<(u32, String), fidl::Error> {
322        let _response = self.client.send_query::<
323            fidl::encoding::EmptyPayload,
324            fidl::encoding::FlexibleType<ClockGetPropertiesResponse>,
325            ClockMarker,
326        >(
327            (),
328            0x26490b5719bab4da,
329            fidl::encoding::DynamicFlags::FLEXIBLE,
330            ___deadline,
331        )?
332        .into_result::<ClockMarker>("get_properties")?;
333        Ok((_response.id, _response.name))
334    }
335}
336
337#[cfg(target_os = "fuchsia")]
338impl From<ClockSynchronousProxy> for zx::NullableHandle {
339    fn from(value: ClockSynchronousProxy) -> Self {
340        value.into_channel().into()
341    }
342}
343
344#[cfg(target_os = "fuchsia")]
345impl From<fidl::Channel> for ClockSynchronousProxy {
346    fn from(value: fidl::Channel) -> Self {
347        Self::new(value)
348    }
349}
350
351#[cfg(target_os = "fuchsia")]
352impl fidl::endpoints::FromClient for ClockSynchronousProxy {
353    type Protocol = ClockMarker;
354
355    fn from_client(value: fidl::endpoints::ClientEnd<ClockMarker>) -> Self {
356        Self::new(value.into_channel())
357    }
358}
359
360#[derive(Debug, Clone)]
361pub struct ClockProxy {
362    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
363}
364
365impl fidl::endpoints::Proxy for ClockProxy {
366    type Protocol = ClockMarker;
367
368    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
369        Self::new(inner)
370    }
371
372    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
373        self.client.into_channel().map_err(|client| Self { client })
374    }
375
376    fn as_channel(&self) -> &::fidl::AsyncChannel {
377        self.client.as_channel()
378    }
379}
380
381impl ClockProxy {
382    /// Create a new Proxy for fuchsia.hardware.clock/Clock.
383    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
384        let protocol_name = <ClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
385        Self { client: fidl::client::Client::new(channel, protocol_name) }
386    }
387
388    /// Get a Stream of events from the remote end of the protocol.
389    ///
390    /// # Panics
391    ///
392    /// Panics if the event stream was already taken.
393    pub fn take_event_stream(&self) -> ClockEventStream {
394        ClockEventStream { event_receiver: self.client.take_event_receiver() }
395    }
396
397    /// Enables (ungates) this clock.
398    /// Drivers *must* call enable on all clocks they depend upon.
399    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `Enable`.
400    /// Returns `ZX_ERR_TIMED_OUT` if an operation timed out (for instance, a PLL was unable to lock).
401    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
402    pub fn r#enable(
403        &self,
404    ) -> fidl::client::QueryResponseFut<
405        ClockEnableResult,
406        fidl::encoding::DefaultFuchsiaResourceDialect,
407    > {
408        ClockProxyInterface::r#enable(self)
409    }
410
411    /// Disables (gates) this clock.
412    /// Drivers should call this method to indicate to the clock subsystem that
413    /// a particular clock signal is no longer necessary.
414    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `Disable`
415    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
416    pub fn r#disable(
417        &self,
418    ) -> fidl::client::QueryResponseFut<
419        ClockDisableResult,
420        fidl::encoding::DefaultFuchsiaResourceDialect,
421    > {
422        ClockProxyInterface::r#disable(self)
423    }
424
425    /// Returns `true` if a given clock is running.
426    /// May query the hardware or return a cached value.
427    /// IsEnabled shall not alter the state of the clock tree in any way.
428    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `IsEnabled`.
429    pub fn r#is_enabled(
430        &self,
431    ) -> fidl::client::QueryResponseFut<
432        ClockIsEnabledResult,
433        fidl::encoding::DefaultFuchsiaResourceDialect,
434    > {
435        ClockProxyInterface::r#is_enabled(self)
436    }
437
438    /// Attempt to set the rate of the clock provider.
439    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `SetRate`
440    /// Returns `ZX_ERR_INVALID_ARGS` if the requested rate is not one that is reported as supported by `QuerySupportedRate`.
441    /// Returns `ZX_ERR_TIMED_OUT` if an operation timed out (for instance, a PLL was unable to lock).
442    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
443    pub fn r#set_rate(
444        &self,
445        mut hz: u64,
446    ) -> fidl::client::QueryResponseFut<
447        ClockSetRateResult,
448        fidl::encoding::DefaultFuchsiaResourceDialect,
449    > {
450        ClockProxyInterface::r#set_rate(self, hz)
451    }
452
453    /// Query the hardware for the highest supported rate that does not
454    /// exceed hz_in.
455    /// `QuerySupportedRate` shall not alter the state of the clock tree in any way.
456    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `QuerySupportedRate`.
457    /// Returns `ZX_ERR_OUT_OF_RANGE` if a suitable rate could not be found.
458    pub fn r#query_supported_rate(
459        &self,
460        mut hz_in: u64,
461    ) -> fidl::client::QueryResponseFut<
462        ClockQuerySupportedRateResult,
463        fidl::encoding::DefaultFuchsiaResourceDialect,
464    > {
465        ClockProxyInterface::r#query_supported_rate(self, hz_in)
466    }
467
468    /// Returns the current rate that a given clock is running at.
469    /// GetRate shall not alter the state of the clock tree in any way.
470    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `GetRate `.
471    pub fn r#get_rate(
472        &self,
473    ) -> fidl::client::QueryResponseFut<
474        ClockGetRateResult,
475        fidl::encoding::DefaultFuchsiaResourceDialect,
476    > {
477        ClockProxyInterface::r#get_rate(self)
478    }
479
480    /// Sets the input of this clock by index. I.e. by selecting a mux.
481    /// This clock has N inputs defined 0 through N-1, which are valid arguemts
482    /// as the index to SetInput.
483    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `SetInput`
484    /// Returns `ZX_ERR_OUT_OF_RANGE` if `idx` is outside of the range supplied by `GetNumInputs`.
485    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
486    pub fn r#set_input(
487        &self,
488        mut idx: u32,
489    ) -> fidl::client::QueryResponseFut<
490        ClockSetInputResult,
491        fidl::encoding::DefaultFuchsiaResourceDialect,
492    > {
493        ClockProxyInterface::r#set_input(self, idx)
494    }
495
496    /// Returns the number of inputs this clock has.
497    /// Any value between 0 and UINT32_MAX is a valid return for this method.
498    /// A Root Oscillator may return 0 for instance, if it has no inputs.
499    /// GetNumInputs shall not alter the state of the clock tree in any way.
500    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `GetNumInputs`.
501    pub fn r#get_num_inputs(
502        &self,
503    ) -> fidl::client::QueryResponseFut<
504        ClockGetNumInputsResult,
505        fidl::encoding::DefaultFuchsiaResourceDialect,
506    > {
507        ClockProxyInterface::r#get_num_inputs(self)
508    }
509
510    /// Returns the index of the current input of this clock.
511    /// GetInput shall not alter the state of the clock tree in any way.
512    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `GetInput`.
513    pub fn r#get_input(
514        &self,
515    ) -> fidl::client::QueryResponseFut<
516        ClockGetInputResult,
517        fidl::encoding::DefaultFuchsiaResourceDialect,
518    > {
519        ClockProxyInterface::r#get_input(self)
520    }
521
522    /// Returns the static properties of a clock.
523    pub fn r#get_properties(
524        &self,
525    ) -> fidl::client::QueryResponseFut<(u32, String), fidl::encoding::DefaultFuchsiaResourceDialect>
526    {
527        ClockProxyInterface::r#get_properties(self)
528    }
529}
530
531impl ClockProxyInterface for ClockProxy {
532    type EnableResponseFut = fidl::client::QueryResponseFut<
533        ClockEnableResult,
534        fidl::encoding::DefaultFuchsiaResourceDialect,
535    >;
536    fn r#enable(&self) -> Self::EnableResponseFut {
537        fn _decode(
538            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
539        ) -> Result<ClockEnableResult, fidl::Error> {
540            let _response = fidl::client::decode_transaction_body::<
541                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
542                fidl::encoding::DefaultFuchsiaResourceDialect,
543                0x5e2816e21e9da22e,
544            >(_buf?)?
545            .into_result::<ClockMarker>("enable")?;
546            Ok(_response.map(|x| x))
547        }
548        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ClockEnableResult>(
549            (),
550            0x5e2816e21e9da22e,
551            fidl::encoding::DynamicFlags::FLEXIBLE,
552            _decode,
553        )
554    }
555
556    type DisableResponseFut = fidl::client::QueryResponseFut<
557        ClockDisableResult,
558        fidl::encoding::DefaultFuchsiaResourceDialect,
559    >;
560    fn r#disable(&self) -> Self::DisableResponseFut {
561        fn _decode(
562            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
563        ) -> Result<ClockDisableResult, fidl::Error> {
564            let _response = fidl::client::decode_transaction_body::<
565                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
566                fidl::encoding::DefaultFuchsiaResourceDialect,
567                0x798ab22d09abb19,
568            >(_buf?)?
569            .into_result::<ClockMarker>("disable")?;
570            Ok(_response.map(|x| x))
571        }
572        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ClockDisableResult>(
573            (),
574            0x798ab22d09abb19,
575            fidl::encoding::DynamicFlags::FLEXIBLE,
576            _decode,
577        )
578    }
579
580    type IsEnabledResponseFut = fidl::client::QueryResponseFut<
581        ClockIsEnabledResult,
582        fidl::encoding::DefaultFuchsiaResourceDialect,
583    >;
584    fn r#is_enabled(&self) -> Self::IsEnabledResponseFut {
585        fn _decode(
586            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
587        ) -> Result<ClockIsEnabledResult, fidl::Error> {
588            let _response = fidl::client::decode_transaction_body::<
589                fidl::encoding::FlexibleResultType<ClockIsEnabledResponse, i32>,
590                fidl::encoding::DefaultFuchsiaResourceDialect,
591                0xcf2dc6aafb08d87,
592            >(_buf?)?
593            .into_result::<ClockMarker>("is_enabled")?;
594            Ok(_response.map(|x| x.enabled))
595        }
596        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ClockIsEnabledResult>(
597            (),
598            0xcf2dc6aafb08d87,
599            fidl::encoding::DynamicFlags::FLEXIBLE,
600            _decode,
601        )
602    }
603
604    type SetRateResponseFut = fidl::client::QueryResponseFut<
605        ClockSetRateResult,
606        fidl::encoding::DefaultFuchsiaResourceDialect,
607    >;
608    fn r#set_rate(&self, mut hz: u64) -> Self::SetRateResponseFut {
609        fn _decode(
610            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
611        ) -> Result<ClockSetRateResult, fidl::Error> {
612            let _response = fidl::client::decode_transaction_body::<
613                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
614                fidl::encoding::DefaultFuchsiaResourceDialect,
615                0xe55e2c37b5f6e04,
616            >(_buf?)?
617            .into_result::<ClockMarker>("set_rate")?;
618            Ok(_response.map(|x| x))
619        }
620        self.client.send_query_and_decode::<ClockSetRateRequest, ClockSetRateResult>(
621            (hz,),
622            0xe55e2c37b5f6e04,
623            fidl::encoding::DynamicFlags::FLEXIBLE,
624            _decode,
625        )
626    }
627
628    type QuerySupportedRateResponseFut = fidl::client::QueryResponseFut<
629        ClockQuerySupportedRateResult,
630        fidl::encoding::DefaultFuchsiaResourceDialect,
631    >;
632    fn r#query_supported_rate(&self, mut hz_in: u64) -> Self::QuerySupportedRateResponseFut {
633        fn _decode(
634            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
635        ) -> Result<ClockQuerySupportedRateResult, fidl::Error> {
636            let _response = fidl::client::decode_transaction_body::<
637                fidl::encoding::FlexibleResultType<ClockQuerySupportedRateResponse, i32>,
638                fidl::encoding::DefaultFuchsiaResourceDialect,
639                0x3c42f4eb055765d1,
640            >(_buf?)?
641            .into_result::<ClockMarker>("query_supported_rate")?;
642            Ok(_response.map(|x| x.hz_out))
643        }
644        self.client
645            .send_query_and_decode::<ClockQuerySupportedRateRequest, ClockQuerySupportedRateResult>(
646                (hz_in,),
647                0x3c42f4eb055765d1,
648                fidl::encoding::DynamicFlags::FLEXIBLE,
649                _decode,
650            )
651    }
652
653    type GetRateResponseFut = fidl::client::QueryResponseFut<
654        ClockGetRateResult,
655        fidl::encoding::DefaultFuchsiaResourceDialect,
656    >;
657    fn r#get_rate(&self) -> Self::GetRateResponseFut {
658        fn _decode(
659            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
660        ) -> Result<ClockGetRateResult, fidl::Error> {
661            let _response = fidl::client::decode_transaction_body::<
662                fidl::encoding::FlexibleResultType<ClockGetRateResponse, i32>,
663                fidl::encoding::DefaultFuchsiaResourceDialect,
664                0xf8f2c8acaa82e7d,
665            >(_buf?)?
666            .into_result::<ClockMarker>("get_rate")?;
667            Ok(_response.map(|x| x.hz))
668        }
669        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ClockGetRateResult>(
670            (),
671            0xf8f2c8acaa82e7d,
672            fidl::encoding::DynamicFlags::FLEXIBLE,
673            _decode,
674        )
675    }
676
677    type SetInputResponseFut = fidl::client::QueryResponseFut<
678        ClockSetInputResult,
679        fidl::encoding::DefaultFuchsiaResourceDialect,
680    >;
681    fn r#set_input(&self, mut idx: u32) -> Self::SetInputResponseFut {
682        fn _decode(
683            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
684        ) -> Result<ClockSetInputResult, fidl::Error> {
685            let _response = fidl::client::decode_transaction_body::<
686                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
687                fidl::encoding::DefaultFuchsiaResourceDialect,
688                0x486aad01b832c460,
689            >(_buf?)?
690            .into_result::<ClockMarker>("set_input")?;
691            Ok(_response.map(|x| x))
692        }
693        self.client.send_query_and_decode::<ClockSetInputRequest, ClockSetInputResult>(
694            (idx,),
695            0x486aad01b832c460,
696            fidl::encoding::DynamicFlags::FLEXIBLE,
697            _decode,
698        )
699    }
700
701    type GetNumInputsResponseFut = fidl::client::QueryResponseFut<
702        ClockGetNumInputsResult,
703        fidl::encoding::DefaultFuchsiaResourceDialect,
704    >;
705    fn r#get_num_inputs(&self) -> Self::GetNumInputsResponseFut {
706        fn _decode(
707            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
708        ) -> Result<ClockGetNumInputsResult, fidl::Error> {
709            let _response = fidl::client::decode_transaction_body::<
710                fidl::encoding::FlexibleResultType<ClockGetNumInputsResponse, i32>,
711                fidl::encoding::DefaultFuchsiaResourceDialect,
712                0x7666d4a62c66de43,
713            >(_buf?)?
714            .into_result::<ClockMarker>("get_num_inputs")?;
715            Ok(_response.map(|x| x.n))
716        }
717        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ClockGetNumInputsResult>(
718            (),
719            0x7666d4a62c66de43,
720            fidl::encoding::DynamicFlags::FLEXIBLE,
721            _decode,
722        )
723    }
724
725    type GetInputResponseFut = fidl::client::QueryResponseFut<
726        ClockGetInputResult,
727        fidl::encoding::DefaultFuchsiaResourceDialect,
728    >;
729    fn r#get_input(&self) -> Self::GetInputResponseFut {
730        fn _decode(
731            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
732        ) -> Result<ClockGetInputResult, fidl::Error> {
733            let _response = fidl::client::decode_transaction_body::<
734                fidl::encoding::FlexibleResultType<ClockGetInputResponse, i32>,
735                fidl::encoding::DefaultFuchsiaResourceDialect,
736                0x23de9a9d0640a111,
737            >(_buf?)?
738            .into_result::<ClockMarker>("get_input")?;
739            Ok(_response.map(|x| x.index))
740        }
741        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ClockGetInputResult>(
742            (),
743            0x23de9a9d0640a111,
744            fidl::encoding::DynamicFlags::FLEXIBLE,
745            _decode,
746        )
747    }
748
749    type GetPropertiesResponseFut = fidl::client::QueryResponseFut<
750        (u32, String),
751        fidl::encoding::DefaultFuchsiaResourceDialect,
752    >;
753    fn r#get_properties(&self) -> Self::GetPropertiesResponseFut {
754        fn _decode(
755            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
756        ) -> Result<(u32, String), fidl::Error> {
757            let _response = fidl::client::decode_transaction_body::<
758                fidl::encoding::FlexibleType<ClockGetPropertiesResponse>,
759                fidl::encoding::DefaultFuchsiaResourceDialect,
760                0x26490b5719bab4da,
761            >(_buf?)?
762            .into_result::<ClockMarker>("get_properties")?;
763            Ok((_response.id, _response.name))
764        }
765        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (u32, String)>(
766            (),
767            0x26490b5719bab4da,
768            fidl::encoding::DynamicFlags::FLEXIBLE,
769            _decode,
770        )
771    }
772}
773
774pub struct ClockEventStream {
775    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
776}
777
778impl std::marker::Unpin for ClockEventStream {}
779
780impl futures::stream::FusedStream for ClockEventStream {
781    fn is_terminated(&self) -> bool {
782        self.event_receiver.is_terminated()
783    }
784}
785
786impl futures::Stream for ClockEventStream {
787    type Item = Result<ClockEvent, fidl::Error>;
788
789    fn poll_next(
790        mut self: std::pin::Pin<&mut Self>,
791        cx: &mut std::task::Context<'_>,
792    ) -> std::task::Poll<Option<Self::Item>> {
793        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
794            &mut self.event_receiver,
795            cx
796        )?) {
797            Some(buf) => std::task::Poll::Ready(Some(ClockEvent::decode(buf))),
798            None => std::task::Poll::Ready(None),
799        }
800    }
801}
802
803#[derive(Debug)]
804pub enum ClockEvent {
805    #[non_exhaustive]
806    _UnknownEvent {
807        /// Ordinal of the event that was sent.
808        ordinal: u64,
809    },
810}
811
812impl ClockEvent {
813    /// Decodes a message buffer as a [`ClockEvent`].
814    fn decode(
815        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
816    ) -> Result<ClockEvent, fidl::Error> {
817        let (bytes, _handles) = buf.split_mut();
818        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
819        debug_assert_eq!(tx_header.tx_id, 0);
820        match tx_header.ordinal {
821            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
822                Ok(ClockEvent::_UnknownEvent { ordinal: tx_header.ordinal })
823            }
824            _ => Err(fidl::Error::UnknownOrdinal {
825                ordinal: tx_header.ordinal,
826                protocol_name: <ClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
827            }),
828        }
829    }
830}
831
832/// A Stream of incoming requests for fuchsia.hardware.clock/Clock.
833pub struct ClockRequestStream {
834    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
835    is_terminated: bool,
836}
837
838impl std::marker::Unpin for ClockRequestStream {}
839
840impl futures::stream::FusedStream for ClockRequestStream {
841    fn is_terminated(&self) -> bool {
842        self.is_terminated
843    }
844}
845
846impl fidl::endpoints::RequestStream for ClockRequestStream {
847    type Protocol = ClockMarker;
848    type ControlHandle = ClockControlHandle;
849
850    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
851        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
852    }
853
854    fn control_handle(&self) -> Self::ControlHandle {
855        ClockControlHandle { inner: self.inner.clone() }
856    }
857
858    fn into_inner(
859        self,
860    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
861    {
862        (self.inner, self.is_terminated)
863    }
864
865    fn from_inner(
866        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
867        is_terminated: bool,
868    ) -> Self {
869        Self { inner, is_terminated }
870    }
871}
872
873impl futures::Stream for ClockRequestStream {
874    type Item = Result<ClockRequest, fidl::Error>;
875
876    fn poll_next(
877        mut self: std::pin::Pin<&mut Self>,
878        cx: &mut std::task::Context<'_>,
879    ) -> std::task::Poll<Option<Self::Item>> {
880        let this = &mut *self;
881        if this.inner.check_shutdown(cx) {
882            this.is_terminated = true;
883            return std::task::Poll::Ready(None);
884        }
885        if this.is_terminated {
886            panic!("polled ClockRequestStream after completion");
887        }
888        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
889            |bytes, handles| {
890                match this.inner.channel().read_etc(cx, bytes, handles) {
891                    std::task::Poll::Ready(Ok(())) => {}
892                    std::task::Poll::Pending => return std::task::Poll::Pending,
893                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
894                        this.is_terminated = true;
895                        return std::task::Poll::Ready(None);
896                    }
897                    std::task::Poll::Ready(Err(e)) => {
898                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
899                            e.into(),
900                        ))));
901                    }
902                }
903
904                // A message has been received from the channel
905                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
906
907                std::task::Poll::Ready(Some(match header.ordinal {
908                    0x5e2816e21e9da22e => {
909                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
910                        let mut req = fidl::new_empty!(
911                            fidl::encoding::EmptyPayload,
912                            fidl::encoding::DefaultFuchsiaResourceDialect
913                        );
914                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
915                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
916                        Ok(ClockRequest::Enable {
917                            responder: ClockEnableResponder {
918                                control_handle: std::mem::ManuallyDrop::new(control_handle),
919                                tx_id: header.tx_id,
920                            },
921                        })
922                    }
923                    0x798ab22d09abb19 => {
924                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
925                        let mut req = fidl::new_empty!(
926                            fidl::encoding::EmptyPayload,
927                            fidl::encoding::DefaultFuchsiaResourceDialect
928                        );
929                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
930                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
931                        Ok(ClockRequest::Disable {
932                            responder: ClockDisableResponder {
933                                control_handle: std::mem::ManuallyDrop::new(control_handle),
934                                tx_id: header.tx_id,
935                            },
936                        })
937                    }
938                    0xcf2dc6aafb08d87 => {
939                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
940                        let mut req = fidl::new_empty!(
941                            fidl::encoding::EmptyPayload,
942                            fidl::encoding::DefaultFuchsiaResourceDialect
943                        );
944                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
945                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
946                        Ok(ClockRequest::IsEnabled {
947                            responder: ClockIsEnabledResponder {
948                                control_handle: std::mem::ManuallyDrop::new(control_handle),
949                                tx_id: header.tx_id,
950                            },
951                        })
952                    }
953                    0xe55e2c37b5f6e04 => {
954                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
955                        let mut req = fidl::new_empty!(
956                            ClockSetRateRequest,
957                            fidl::encoding::DefaultFuchsiaResourceDialect
958                        );
959                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClockSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
960                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
961                        Ok(ClockRequest::SetRate {
962                            hz: req.hz,
963
964                            responder: ClockSetRateResponder {
965                                control_handle: std::mem::ManuallyDrop::new(control_handle),
966                                tx_id: header.tx_id,
967                            },
968                        })
969                    }
970                    0x3c42f4eb055765d1 => {
971                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
972                        let mut req = fidl::new_empty!(
973                            ClockQuerySupportedRateRequest,
974                            fidl::encoding::DefaultFuchsiaResourceDialect
975                        );
976                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClockQuerySupportedRateRequest>(&header, _body_bytes, handles, &mut req)?;
977                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
978                        Ok(ClockRequest::QuerySupportedRate {
979                            hz_in: req.hz_in,
980
981                            responder: ClockQuerySupportedRateResponder {
982                                control_handle: std::mem::ManuallyDrop::new(control_handle),
983                                tx_id: header.tx_id,
984                            },
985                        })
986                    }
987                    0xf8f2c8acaa82e7d => {
988                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
989                        let mut req = fidl::new_empty!(
990                            fidl::encoding::EmptyPayload,
991                            fidl::encoding::DefaultFuchsiaResourceDialect
992                        );
993                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
994                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
995                        Ok(ClockRequest::GetRate {
996                            responder: ClockGetRateResponder {
997                                control_handle: std::mem::ManuallyDrop::new(control_handle),
998                                tx_id: header.tx_id,
999                            },
1000                        })
1001                    }
1002                    0x486aad01b832c460 => {
1003                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1004                        let mut req = fidl::new_empty!(
1005                            ClockSetInputRequest,
1006                            fidl::encoding::DefaultFuchsiaResourceDialect
1007                        );
1008                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClockSetInputRequest>(&header, _body_bytes, handles, &mut req)?;
1009                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
1010                        Ok(ClockRequest::SetInput {
1011                            idx: req.idx,
1012
1013                            responder: ClockSetInputResponder {
1014                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1015                                tx_id: header.tx_id,
1016                            },
1017                        })
1018                    }
1019                    0x7666d4a62c66de43 => {
1020                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1021                        let mut req = fidl::new_empty!(
1022                            fidl::encoding::EmptyPayload,
1023                            fidl::encoding::DefaultFuchsiaResourceDialect
1024                        );
1025                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1026                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
1027                        Ok(ClockRequest::GetNumInputs {
1028                            responder: ClockGetNumInputsResponder {
1029                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1030                                tx_id: header.tx_id,
1031                            },
1032                        })
1033                    }
1034                    0x23de9a9d0640a111 => {
1035                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1036                        let mut req = fidl::new_empty!(
1037                            fidl::encoding::EmptyPayload,
1038                            fidl::encoding::DefaultFuchsiaResourceDialect
1039                        );
1040                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1041                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
1042                        Ok(ClockRequest::GetInput {
1043                            responder: ClockGetInputResponder {
1044                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1045                                tx_id: header.tx_id,
1046                            },
1047                        })
1048                    }
1049                    0x26490b5719bab4da => {
1050                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1051                        let mut req = fidl::new_empty!(
1052                            fidl::encoding::EmptyPayload,
1053                            fidl::encoding::DefaultFuchsiaResourceDialect
1054                        );
1055                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1056                        let control_handle = ClockControlHandle { inner: this.inner.clone() };
1057                        Ok(ClockRequest::GetProperties {
1058                            responder: ClockGetPropertiesResponder {
1059                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1060                                tx_id: header.tx_id,
1061                            },
1062                        })
1063                    }
1064                    _ if header.tx_id == 0
1065                        && header
1066                            .dynamic_flags()
1067                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1068                    {
1069                        Ok(ClockRequest::_UnknownMethod {
1070                            ordinal: header.ordinal,
1071                            control_handle: ClockControlHandle { inner: this.inner.clone() },
1072                            method_type: fidl::MethodType::OneWay,
1073                        })
1074                    }
1075                    _ if header
1076                        .dynamic_flags()
1077                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1078                    {
1079                        this.inner.send_framework_err(
1080                            fidl::encoding::FrameworkErr::UnknownMethod,
1081                            header.tx_id,
1082                            header.ordinal,
1083                            header.dynamic_flags(),
1084                            (bytes, handles),
1085                        )?;
1086                        Ok(ClockRequest::_UnknownMethod {
1087                            ordinal: header.ordinal,
1088                            control_handle: ClockControlHandle { inner: this.inner.clone() },
1089                            method_type: fidl::MethodType::TwoWay,
1090                        })
1091                    }
1092                    _ => Err(fidl::Error::UnknownOrdinal {
1093                        ordinal: header.ordinal,
1094                        protocol_name: <ClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1095                    }),
1096                }))
1097            },
1098        )
1099    }
1100}
1101
1102/// Used for driver-to-driver communication.
1103#[derive(Debug)]
1104pub enum ClockRequest {
1105    /// Enables (ungates) this clock.
1106    /// Drivers *must* call enable on all clocks they depend upon.
1107    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `Enable`.
1108    /// Returns `ZX_ERR_TIMED_OUT` if an operation timed out (for instance, a PLL was unable to lock).
1109    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
1110    Enable { responder: ClockEnableResponder },
1111    /// Disables (gates) this clock.
1112    /// Drivers should call this method to indicate to the clock subsystem that
1113    /// a particular clock signal is no longer necessary.
1114    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `Disable`
1115    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
1116    Disable { responder: ClockDisableResponder },
1117    /// Returns `true` if a given clock is running.
1118    /// May query the hardware or return a cached value.
1119    /// IsEnabled shall not alter the state of the clock tree in any way.
1120    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `IsEnabled`.
1121    IsEnabled { responder: ClockIsEnabledResponder },
1122    /// Attempt to set the rate of the clock provider.
1123    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `SetRate`
1124    /// Returns `ZX_ERR_INVALID_ARGS` if the requested rate is not one that is reported as supported by `QuerySupportedRate`.
1125    /// Returns `ZX_ERR_TIMED_OUT` if an operation timed out (for instance, a PLL was unable to lock).
1126    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
1127    SetRate { hz: u64, responder: ClockSetRateResponder },
1128    /// Query the hardware for the highest supported rate that does not
1129    /// exceed hz_in.
1130    /// `QuerySupportedRate` shall not alter the state of the clock tree in any way.
1131    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `QuerySupportedRate`.
1132    /// Returns `ZX_ERR_OUT_OF_RANGE` if a suitable rate could not be found.
1133    QuerySupportedRate { hz_in: u64, responder: ClockQuerySupportedRateResponder },
1134    /// Returns the current rate that a given clock is running at.
1135    /// GetRate shall not alter the state of the clock tree in any way.
1136    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `GetRate `.
1137    GetRate { responder: ClockGetRateResponder },
1138    /// Sets the input of this clock by index. I.e. by selecting a mux.
1139    /// This clock has N inputs defined 0 through N-1, which are valid arguemts
1140    /// as the index to SetInput.
1141    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `SetInput`
1142    /// Returns `ZX_ERR_OUT_OF_RANGE` if `idx` is outside of the range supplied by `GetNumInputs`.
1143    /// Returns `ZX_ERR_INTERNAL` if the operation failed for any other reason.
1144    SetInput { idx: u32, responder: ClockSetInputResponder },
1145    /// Returns the number of inputs this clock has.
1146    /// Any value between 0 and UINT32_MAX is a valid return for this method.
1147    /// A Root Oscillator may return 0 for instance, if it has no inputs.
1148    /// GetNumInputs shall not alter the state of the clock tree in any way.
1149    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `GetNumInputs`.
1150    GetNumInputs { responder: ClockGetNumInputsResponder },
1151    /// Returns the index of the current input of this clock.
1152    /// GetInput shall not alter the state of the clock tree in any way.
1153    /// Returns `ZX_ERR_NOT_SUPPORTED` if this clock type does not support `GetInput`.
1154    GetInput { responder: ClockGetInputResponder },
1155    /// Returns the static properties of a clock.
1156    GetProperties { responder: ClockGetPropertiesResponder },
1157    /// An interaction was received which does not match any known method.
1158    #[non_exhaustive]
1159    _UnknownMethod {
1160        /// Ordinal of the method that was called.
1161        ordinal: u64,
1162        control_handle: ClockControlHandle,
1163        method_type: fidl::MethodType,
1164    },
1165}
1166
1167impl ClockRequest {
1168    #[allow(irrefutable_let_patterns)]
1169    pub fn into_enable(self) -> Option<(ClockEnableResponder)> {
1170        if let ClockRequest::Enable { responder } = self { Some((responder)) } else { None }
1171    }
1172
1173    #[allow(irrefutable_let_patterns)]
1174    pub fn into_disable(self) -> Option<(ClockDisableResponder)> {
1175        if let ClockRequest::Disable { responder } = self { Some((responder)) } else { None }
1176    }
1177
1178    #[allow(irrefutable_let_patterns)]
1179    pub fn into_is_enabled(self) -> Option<(ClockIsEnabledResponder)> {
1180        if let ClockRequest::IsEnabled { responder } = self { Some((responder)) } else { None }
1181    }
1182
1183    #[allow(irrefutable_let_patterns)]
1184    pub fn into_set_rate(self) -> Option<(u64, ClockSetRateResponder)> {
1185        if let ClockRequest::SetRate { hz, responder } = self {
1186            Some((hz, responder))
1187        } else {
1188            None
1189        }
1190    }
1191
1192    #[allow(irrefutable_let_patterns)]
1193    pub fn into_query_supported_rate(self) -> Option<(u64, ClockQuerySupportedRateResponder)> {
1194        if let ClockRequest::QuerySupportedRate { hz_in, responder } = self {
1195            Some((hz_in, responder))
1196        } else {
1197            None
1198        }
1199    }
1200
1201    #[allow(irrefutable_let_patterns)]
1202    pub fn into_get_rate(self) -> Option<(ClockGetRateResponder)> {
1203        if let ClockRequest::GetRate { responder } = self { Some((responder)) } else { None }
1204    }
1205
1206    #[allow(irrefutable_let_patterns)]
1207    pub fn into_set_input(self) -> Option<(u32, ClockSetInputResponder)> {
1208        if let ClockRequest::SetInput { idx, responder } = self {
1209            Some((idx, responder))
1210        } else {
1211            None
1212        }
1213    }
1214
1215    #[allow(irrefutable_let_patterns)]
1216    pub fn into_get_num_inputs(self) -> Option<(ClockGetNumInputsResponder)> {
1217        if let ClockRequest::GetNumInputs { responder } = self { Some((responder)) } else { None }
1218    }
1219
1220    #[allow(irrefutable_let_patterns)]
1221    pub fn into_get_input(self) -> Option<(ClockGetInputResponder)> {
1222        if let ClockRequest::GetInput { responder } = self { Some((responder)) } else { None }
1223    }
1224
1225    #[allow(irrefutable_let_patterns)]
1226    pub fn into_get_properties(self) -> Option<(ClockGetPropertiesResponder)> {
1227        if let ClockRequest::GetProperties { responder } = self { Some((responder)) } else { None }
1228    }
1229
1230    /// Name of the method defined in FIDL
1231    pub fn method_name(&self) -> &'static str {
1232        match *self {
1233            ClockRequest::Enable { .. } => "enable",
1234            ClockRequest::Disable { .. } => "disable",
1235            ClockRequest::IsEnabled { .. } => "is_enabled",
1236            ClockRequest::SetRate { .. } => "set_rate",
1237            ClockRequest::QuerySupportedRate { .. } => "query_supported_rate",
1238            ClockRequest::GetRate { .. } => "get_rate",
1239            ClockRequest::SetInput { .. } => "set_input",
1240            ClockRequest::GetNumInputs { .. } => "get_num_inputs",
1241            ClockRequest::GetInput { .. } => "get_input",
1242            ClockRequest::GetProperties { .. } => "get_properties",
1243            ClockRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1244                "unknown one-way method"
1245            }
1246            ClockRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1247                "unknown two-way method"
1248            }
1249        }
1250    }
1251}
1252
1253#[derive(Debug, Clone)]
1254pub struct ClockControlHandle {
1255    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1256}
1257
1258impl ClockControlHandle {
1259    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1260        self.inner.shutdown_with_epitaph(status.into())
1261    }
1262}
1263
1264impl fidl::endpoints::ControlHandle for ClockControlHandle {
1265    fn shutdown(&self) {
1266        self.inner.shutdown()
1267    }
1268
1269    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1270        self.inner.shutdown_with_epitaph(status)
1271    }
1272
1273    fn is_closed(&self) -> bool {
1274        self.inner.channel().is_closed()
1275    }
1276    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1277        self.inner.channel().on_closed()
1278    }
1279
1280    #[cfg(target_os = "fuchsia")]
1281    fn signal_peer(
1282        &self,
1283        clear_mask: zx::Signals,
1284        set_mask: zx::Signals,
1285    ) -> Result<(), zx_status::Status> {
1286        use fidl::Peered;
1287        self.inner.channel().signal_peer(clear_mask, set_mask)
1288    }
1289}
1290
1291impl ClockControlHandle {}
1292
1293#[must_use = "FIDL methods require a response to be sent"]
1294#[derive(Debug)]
1295pub struct ClockEnableResponder {
1296    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1297    tx_id: u32,
1298}
1299
1300/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1301/// if the responder is dropped without sending a response, so that the client
1302/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1303impl std::ops::Drop for ClockEnableResponder {
1304    fn drop(&mut self) {
1305        self.control_handle.shutdown();
1306        // Safety: drops once, never accessed again
1307        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1308    }
1309}
1310
1311impl fidl::endpoints::Responder for ClockEnableResponder {
1312    type ControlHandle = ClockControlHandle;
1313
1314    fn control_handle(&self) -> &ClockControlHandle {
1315        &self.control_handle
1316    }
1317
1318    fn drop_without_shutdown(mut self) {
1319        // Safety: drops once, never accessed again due to mem::forget
1320        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1321        // Prevent Drop from running (which would shut down the channel)
1322        std::mem::forget(self);
1323    }
1324}
1325
1326impl ClockEnableResponder {
1327    /// Sends a response to the FIDL transaction.
1328    ///
1329    /// Sets the channel to shutdown if an error occurs.
1330    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1331        let _result = self.send_raw(result);
1332        if _result.is_err() {
1333            self.control_handle.shutdown();
1334        }
1335        self.drop_without_shutdown();
1336        _result
1337    }
1338
1339    /// Similar to "send" but does not shutdown the channel if an error occurs.
1340    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1341        let _result = self.send_raw(result);
1342        self.drop_without_shutdown();
1343        _result
1344    }
1345
1346    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1347        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1348            fidl::encoding::EmptyStruct,
1349            i32,
1350        >>(
1351            fidl::encoding::FlexibleResult::new(result),
1352            self.tx_id,
1353            0x5e2816e21e9da22e,
1354            fidl::encoding::DynamicFlags::FLEXIBLE,
1355        )
1356    }
1357}
1358
1359#[must_use = "FIDL methods require a response to be sent"]
1360#[derive(Debug)]
1361pub struct ClockDisableResponder {
1362    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1363    tx_id: u32,
1364}
1365
1366/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1367/// if the responder is dropped without sending a response, so that the client
1368/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1369impl std::ops::Drop for ClockDisableResponder {
1370    fn drop(&mut self) {
1371        self.control_handle.shutdown();
1372        // Safety: drops once, never accessed again
1373        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1374    }
1375}
1376
1377impl fidl::endpoints::Responder for ClockDisableResponder {
1378    type ControlHandle = ClockControlHandle;
1379
1380    fn control_handle(&self) -> &ClockControlHandle {
1381        &self.control_handle
1382    }
1383
1384    fn drop_without_shutdown(mut self) {
1385        // Safety: drops once, never accessed again due to mem::forget
1386        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1387        // Prevent Drop from running (which would shut down the channel)
1388        std::mem::forget(self);
1389    }
1390}
1391
1392impl ClockDisableResponder {
1393    /// Sends a response to the FIDL transaction.
1394    ///
1395    /// Sets the channel to shutdown if an error occurs.
1396    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1397        let _result = self.send_raw(result);
1398        if _result.is_err() {
1399            self.control_handle.shutdown();
1400        }
1401        self.drop_without_shutdown();
1402        _result
1403    }
1404
1405    /// Similar to "send" but does not shutdown the channel if an error occurs.
1406    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1407        let _result = self.send_raw(result);
1408        self.drop_without_shutdown();
1409        _result
1410    }
1411
1412    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1413        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1414            fidl::encoding::EmptyStruct,
1415            i32,
1416        >>(
1417            fidl::encoding::FlexibleResult::new(result),
1418            self.tx_id,
1419            0x798ab22d09abb19,
1420            fidl::encoding::DynamicFlags::FLEXIBLE,
1421        )
1422    }
1423}
1424
1425#[must_use = "FIDL methods require a response to be sent"]
1426#[derive(Debug)]
1427pub struct ClockIsEnabledResponder {
1428    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1429    tx_id: u32,
1430}
1431
1432/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1433/// if the responder is dropped without sending a response, so that the client
1434/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1435impl std::ops::Drop for ClockIsEnabledResponder {
1436    fn drop(&mut self) {
1437        self.control_handle.shutdown();
1438        // Safety: drops once, never accessed again
1439        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1440    }
1441}
1442
1443impl fidl::endpoints::Responder for ClockIsEnabledResponder {
1444    type ControlHandle = ClockControlHandle;
1445
1446    fn control_handle(&self) -> &ClockControlHandle {
1447        &self.control_handle
1448    }
1449
1450    fn drop_without_shutdown(mut self) {
1451        // Safety: drops once, never accessed again due to mem::forget
1452        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1453        // Prevent Drop from running (which would shut down the channel)
1454        std::mem::forget(self);
1455    }
1456}
1457
1458impl ClockIsEnabledResponder {
1459    /// Sends a response to the FIDL transaction.
1460    ///
1461    /// Sets the channel to shutdown if an error occurs.
1462    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
1463        let _result = self.send_raw(result);
1464        if _result.is_err() {
1465            self.control_handle.shutdown();
1466        }
1467        self.drop_without_shutdown();
1468        _result
1469    }
1470
1471    /// Similar to "send" but does not shutdown the channel if an error occurs.
1472    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
1473        let _result = self.send_raw(result);
1474        self.drop_without_shutdown();
1475        _result
1476    }
1477
1478    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
1479        self.control_handle
1480            .inner
1481            .send::<fidl::encoding::FlexibleResultType<ClockIsEnabledResponse, i32>>(
1482                fidl::encoding::FlexibleResult::new(result.map(|enabled| (enabled,))),
1483                self.tx_id,
1484                0xcf2dc6aafb08d87,
1485                fidl::encoding::DynamicFlags::FLEXIBLE,
1486            )
1487    }
1488}
1489
1490#[must_use = "FIDL methods require a response to be sent"]
1491#[derive(Debug)]
1492pub struct ClockSetRateResponder {
1493    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1494    tx_id: u32,
1495}
1496
1497/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1498/// if the responder is dropped without sending a response, so that the client
1499/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1500impl std::ops::Drop for ClockSetRateResponder {
1501    fn drop(&mut self) {
1502        self.control_handle.shutdown();
1503        // Safety: drops once, never accessed again
1504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1505    }
1506}
1507
1508impl fidl::endpoints::Responder for ClockSetRateResponder {
1509    type ControlHandle = ClockControlHandle;
1510
1511    fn control_handle(&self) -> &ClockControlHandle {
1512        &self.control_handle
1513    }
1514
1515    fn drop_without_shutdown(mut self) {
1516        // Safety: drops once, never accessed again due to mem::forget
1517        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1518        // Prevent Drop from running (which would shut down the channel)
1519        std::mem::forget(self);
1520    }
1521}
1522
1523impl ClockSetRateResponder {
1524    /// Sends a response to the FIDL transaction.
1525    ///
1526    /// Sets the channel to shutdown if an error occurs.
1527    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1528        let _result = self.send_raw(result);
1529        if _result.is_err() {
1530            self.control_handle.shutdown();
1531        }
1532        self.drop_without_shutdown();
1533        _result
1534    }
1535
1536    /// Similar to "send" but does not shutdown the channel if an error occurs.
1537    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1538        let _result = self.send_raw(result);
1539        self.drop_without_shutdown();
1540        _result
1541    }
1542
1543    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1544        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1545            fidl::encoding::EmptyStruct,
1546            i32,
1547        >>(
1548            fidl::encoding::FlexibleResult::new(result),
1549            self.tx_id,
1550            0xe55e2c37b5f6e04,
1551            fidl::encoding::DynamicFlags::FLEXIBLE,
1552        )
1553    }
1554}
1555
1556#[must_use = "FIDL methods require a response to be sent"]
1557#[derive(Debug)]
1558pub struct ClockQuerySupportedRateResponder {
1559    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1560    tx_id: u32,
1561}
1562
1563/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1564/// if the responder is dropped without sending a response, so that the client
1565/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1566impl std::ops::Drop for ClockQuerySupportedRateResponder {
1567    fn drop(&mut self) {
1568        self.control_handle.shutdown();
1569        // Safety: drops once, never accessed again
1570        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1571    }
1572}
1573
1574impl fidl::endpoints::Responder for ClockQuerySupportedRateResponder {
1575    type ControlHandle = ClockControlHandle;
1576
1577    fn control_handle(&self) -> &ClockControlHandle {
1578        &self.control_handle
1579    }
1580
1581    fn drop_without_shutdown(mut self) {
1582        // Safety: drops once, never accessed again due to mem::forget
1583        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1584        // Prevent Drop from running (which would shut down the channel)
1585        std::mem::forget(self);
1586    }
1587}
1588
1589impl ClockQuerySupportedRateResponder {
1590    /// Sends a response to the FIDL transaction.
1591    ///
1592    /// Sets the channel to shutdown if an error occurs.
1593    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1594        let _result = self.send_raw(result);
1595        if _result.is_err() {
1596            self.control_handle.shutdown();
1597        }
1598        self.drop_without_shutdown();
1599        _result
1600    }
1601
1602    /// Similar to "send" but does not shutdown the channel if an error occurs.
1603    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1604        let _result = self.send_raw(result);
1605        self.drop_without_shutdown();
1606        _result
1607    }
1608
1609    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1610        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1611            ClockQuerySupportedRateResponse,
1612            i32,
1613        >>(
1614            fidl::encoding::FlexibleResult::new(result.map(|hz_out| (hz_out,))),
1615            self.tx_id,
1616            0x3c42f4eb055765d1,
1617            fidl::encoding::DynamicFlags::FLEXIBLE,
1618        )
1619    }
1620}
1621
1622#[must_use = "FIDL methods require a response to be sent"]
1623#[derive(Debug)]
1624pub struct ClockGetRateResponder {
1625    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1626    tx_id: u32,
1627}
1628
1629/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1630/// if the responder is dropped without sending a response, so that the client
1631/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1632impl std::ops::Drop for ClockGetRateResponder {
1633    fn drop(&mut self) {
1634        self.control_handle.shutdown();
1635        // Safety: drops once, never accessed again
1636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1637    }
1638}
1639
1640impl fidl::endpoints::Responder for ClockGetRateResponder {
1641    type ControlHandle = ClockControlHandle;
1642
1643    fn control_handle(&self) -> &ClockControlHandle {
1644        &self.control_handle
1645    }
1646
1647    fn drop_without_shutdown(mut self) {
1648        // Safety: drops once, never accessed again due to mem::forget
1649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1650        // Prevent Drop from running (which would shut down the channel)
1651        std::mem::forget(self);
1652    }
1653}
1654
1655impl ClockGetRateResponder {
1656    /// Sends a response to the FIDL transaction.
1657    ///
1658    /// Sets the channel to shutdown if an error occurs.
1659    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1660        let _result = self.send_raw(result);
1661        if _result.is_err() {
1662            self.control_handle.shutdown();
1663        }
1664        self.drop_without_shutdown();
1665        _result
1666    }
1667
1668    /// Similar to "send" but does not shutdown the channel if an error occurs.
1669    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1670        let _result = self.send_raw(result);
1671        self.drop_without_shutdown();
1672        _result
1673    }
1674
1675    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1676        self.control_handle
1677            .inner
1678            .send::<fidl::encoding::FlexibleResultType<ClockGetRateResponse, i32>>(
1679                fidl::encoding::FlexibleResult::new(result.map(|hz| (hz,))),
1680                self.tx_id,
1681                0xf8f2c8acaa82e7d,
1682                fidl::encoding::DynamicFlags::FLEXIBLE,
1683            )
1684    }
1685}
1686
1687#[must_use = "FIDL methods require a response to be sent"]
1688#[derive(Debug)]
1689pub struct ClockSetInputResponder {
1690    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1691    tx_id: u32,
1692}
1693
1694/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1695/// if the responder is dropped without sending a response, so that the client
1696/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1697impl std::ops::Drop for ClockSetInputResponder {
1698    fn drop(&mut self) {
1699        self.control_handle.shutdown();
1700        // Safety: drops once, never accessed again
1701        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1702    }
1703}
1704
1705impl fidl::endpoints::Responder for ClockSetInputResponder {
1706    type ControlHandle = ClockControlHandle;
1707
1708    fn control_handle(&self) -> &ClockControlHandle {
1709        &self.control_handle
1710    }
1711
1712    fn drop_without_shutdown(mut self) {
1713        // Safety: drops once, never accessed again due to mem::forget
1714        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1715        // Prevent Drop from running (which would shut down the channel)
1716        std::mem::forget(self);
1717    }
1718}
1719
1720impl ClockSetInputResponder {
1721    /// Sends a response to the FIDL transaction.
1722    ///
1723    /// Sets the channel to shutdown if an error occurs.
1724    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1725        let _result = self.send_raw(result);
1726        if _result.is_err() {
1727            self.control_handle.shutdown();
1728        }
1729        self.drop_without_shutdown();
1730        _result
1731    }
1732
1733    /// Similar to "send" but does not shutdown the channel if an error occurs.
1734    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1735        let _result = self.send_raw(result);
1736        self.drop_without_shutdown();
1737        _result
1738    }
1739
1740    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1741        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1742            fidl::encoding::EmptyStruct,
1743            i32,
1744        >>(
1745            fidl::encoding::FlexibleResult::new(result),
1746            self.tx_id,
1747            0x486aad01b832c460,
1748            fidl::encoding::DynamicFlags::FLEXIBLE,
1749        )
1750    }
1751}
1752
1753#[must_use = "FIDL methods require a response to be sent"]
1754#[derive(Debug)]
1755pub struct ClockGetNumInputsResponder {
1756    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1757    tx_id: u32,
1758}
1759
1760/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1761/// if the responder is dropped without sending a response, so that the client
1762/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1763impl std::ops::Drop for ClockGetNumInputsResponder {
1764    fn drop(&mut self) {
1765        self.control_handle.shutdown();
1766        // Safety: drops once, never accessed again
1767        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1768    }
1769}
1770
1771impl fidl::endpoints::Responder for ClockGetNumInputsResponder {
1772    type ControlHandle = ClockControlHandle;
1773
1774    fn control_handle(&self) -> &ClockControlHandle {
1775        &self.control_handle
1776    }
1777
1778    fn drop_without_shutdown(mut self) {
1779        // Safety: drops once, never accessed again due to mem::forget
1780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1781        // Prevent Drop from running (which would shut down the channel)
1782        std::mem::forget(self);
1783    }
1784}
1785
1786impl ClockGetNumInputsResponder {
1787    /// Sends a response to the FIDL transaction.
1788    ///
1789    /// Sets the channel to shutdown if an error occurs.
1790    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1791        let _result = self.send_raw(result);
1792        if _result.is_err() {
1793            self.control_handle.shutdown();
1794        }
1795        self.drop_without_shutdown();
1796        _result
1797    }
1798
1799    /// Similar to "send" but does not shutdown the channel if an error occurs.
1800    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1801        let _result = self.send_raw(result);
1802        self.drop_without_shutdown();
1803        _result
1804    }
1805
1806    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1807        self.control_handle
1808            .inner
1809            .send::<fidl::encoding::FlexibleResultType<ClockGetNumInputsResponse, i32>>(
1810                fidl::encoding::FlexibleResult::new(result.map(|n| (n,))),
1811                self.tx_id,
1812                0x7666d4a62c66de43,
1813                fidl::encoding::DynamicFlags::FLEXIBLE,
1814            )
1815    }
1816}
1817
1818#[must_use = "FIDL methods require a response to be sent"]
1819#[derive(Debug)]
1820pub struct ClockGetInputResponder {
1821    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1822    tx_id: u32,
1823}
1824
1825/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1826/// if the responder is dropped without sending a response, so that the client
1827/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1828impl std::ops::Drop for ClockGetInputResponder {
1829    fn drop(&mut self) {
1830        self.control_handle.shutdown();
1831        // Safety: drops once, never accessed again
1832        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1833    }
1834}
1835
1836impl fidl::endpoints::Responder for ClockGetInputResponder {
1837    type ControlHandle = ClockControlHandle;
1838
1839    fn control_handle(&self) -> &ClockControlHandle {
1840        &self.control_handle
1841    }
1842
1843    fn drop_without_shutdown(mut self) {
1844        // Safety: drops once, never accessed again due to mem::forget
1845        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1846        // Prevent Drop from running (which would shut down the channel)
1847        std::mem::forget(self);
1848    }
1849}
1850
1851impl ClockGetInputResponder {
1852    /// Sends a response to the FIDL transaction.
1853    ///
1854    /// Sets the channel to shutdown if an error occurs.
1855    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1856        let _result = self.send_raw(result);
1857        if _result.is_err() {
1858            self.control_handle.shutdown();
1859        }
1860        self.drop_without_shutdown();
1861        _result
1862    }
1863
1864    /// Similar to "send" but does not shutdown the channel if an error occurs.
1865    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1866        let _result = self.send_raw(result);
1867        self.drop_without_shutdown();
1868        _result
1869    }
1870
1871    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1872        self.control_handle
1873            .inner
1874            .send::<fidl::encoding::FlexibleResultType<ClockGetInputResponse, i32>>(
1875                fidl::encoding::FlexibleResult::new(result.map(|index| (index,))),
1876                self.tx_id,
1877                0x23de9a9d0640a111,
1878                fidl::encoding::DynamicFlags::FLEXIBLE,
1879            )
1880    }
1881}
1882
1883#[must_use = "FIDL methods require a response to be sent"]
1884#[derive(Debug)]
1885pub struct ClockGetPropertiesResponder {
1886    control_handle: std::mem::ManuallyDrop<ClockControlHandle>,
1887    tx_id: u32,
1888}
1889
1890/// Set the the channel to be shutdown (see [`ClockControlHandle::shutdown`])
1891/// if the responder is dropped without sending a response, so that the client
1892/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1893impl std::ops::Drop for ClockGetPropertiesResponder {
1894    fn drop(&mut self) {
1895        self.control_handle.shutdown();
1896        // Safety: drops once, never accessed again
1897        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1898    }
1899}
1900
1901impl fidl::endpoints::Responder for ClockGetPropertiesResponder {
1902    type ControlHandle = ClockControlHandle;
1903
1904    fn control_handle(&self) -> &ClockControlHandle {
1905        &self.control_handle
1906    }
1907
1908    fn drop_without_shutdown(mut self) {
1909        // Safety: drops once, never accessed again due to mem::forget
1910        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1911        // Prevent Drop from running (which would shut down the channel)
1912        std::mem::forget(self);
1913    }
1914}
1915
1916impl ClockGetPropertiesResponder {
1917    /// Sends a response to the FIDL transaction.
1918    ///
1919    /// Sets the channel to shutdown if an error occurs.
1920    pub fn send(self, mut id: u32, mut name: &str) -> Result<(), fidl::Error> {
1921        let _result = self.send_raw(id, name);
1922        if _result.is_err() {
1923            self.control_handle.shutdown();
1924        }
1925        self.drop_without_shutdown();
1926        _result
1927    }
1928
1929    /// Similar to "send" but does not shutdown the channel if an error occurs.
1930    pub fn send_no_shutdown_on_err(self, mut id: u32, mut name: &str) -> Result<(), fidl::Error> {
1931        let _result = self.send_raw(id, name);
1932        self.drop_without_shutdown();
1933        _result
1934    }
1935
1936    fn send_raw(&self, mut id: u32, mut name: &str) -> Result<(), fidl::Error> {
1937        self.control_handle.inner.send::<fidl::encoding::FlexibleType<ClockGetPropertiesResponse>>(
1938            fidl::encoding::Flexible::new((id, name)),
1939            self.tx_id,
1940            0x26490b5719bab4da,
1941            fidl::encoding::DynamicFlags::FLEXIBLE,
1942        )
1943    }
1944}
1945
1946#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1947pub struct DebugServiceMarker;
1948
1949#[cfg(target_os = "fuchsia")]
1950impl fidl::endpoints::ServiceMarker for DebugServiceMarker {
1951    type Proxy = DebugServiceProxy;
1952    type Request = DebugServiceRequest;
1953    const SERVICE_NAME: &'static str = "fuchsia.hardware.clock.DebugService";
1954}
1955
1956/// A request for one of the member protocols of DebugService.
1957///
1958#[cfg(target_os = "fuchsia")]
1959pub enum DebugServiceRequest {
1960    Device(ClockRequestStream),
1961}
1962
1963#[cfg(target_os = "fuchsia")]
1964impl fidl::endpoints::ServiceRequest for DebugServiceRequest {
1965    type Service = DebugServiceMarker;
1966
1967    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1968        match name {
1969            "device" => Self::Device(
1970                <ClockRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1971            ),
1972            _ => panic!("no such member protocol name for service DebugService"),
1973        }
1974    }
1975
1976    fn member_names() -> &'static [&'static str] {
1977        &["device"]
1978    }
1979}
1980#[cfg(target_os = "fuchsia")]
1981pub struct DebugServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1982
1983#[cfg(target_os = "fuchsia")]
1984impl fidl::endpoints::ServiceProxy for DebugServiceProxy {
1985    type Service = DebugServiceMarker;
1986
1987    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1988        Self(opener)
1989    }
1990}
1991
1992#[cfg(target_os = "fuchsia")]
1993impl DebugServiceProxy {
1994    pub fn connect_to_device(&self) -> Result<ClockProxy, fidl::Error> {
1995        let (proxy, server_end) = fidl::endpoints::create_proxy::<ClockMarker>();
1996        self.connect_channel_to_device(server_end)?;
1997        Ok(proxy)
1998    }
1999
2000    /// Like `connect_to_device`, but returns a sync proxy.
2001    /// See [`Self::connect_to_device`] for more details.
2002    pub fn connect_to_device_sync(&self) -> Result<ClockSynchronousProxy, fidl::Error> {
2003        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ClockMarker>();
2004        self.connect_channel_to_device(server_end)?;
2005        Ok(proxy)
2006    }
2007
2008    /// Like `connect_to_device`, but accepts a server end.
2009    /// See [`Self::connect_to_device`] for more details.
2010    pub fn connect_channel_to_device(
2011        &self,
2012        server_end: fidl::endpoints::ServerEnd<ClockMarker>,
2013    ) -> Result<(), fidl::Error> {
2014        self.0.open_member("device", server_end.into_channel())
2015    }
2016
2017    pub fn instance_name(&self) -> &str {
2018        self.0.instance_name()
2019    }
2020}
2021
2022#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2023pub struct ServiceMarker;
2024
2025#[cfg(target_os = "fuchsia")]
2026impl fidl::endpoints::ServiceMarker for ServiceMarker {
2027    type Proxy = ServiceProxy;
2028    type Request = ServiceRequest;
2029    const SERVICE_NAME: &'static str = "fuchsia.hardware.clock.Service";
2030}
2031
2032/// A request for one of the member protocols of Service.
2033///
2034#[cfg(target_os = "fuchsia")]
2035pub enum ServiceRequest {
2036    Clock(ClockRequestStream),
2037}
2038
2039#[cfg(target_os = "fuchsia")]
2040impl fidl::endpoints::ServiceRequest for ServiceRequest {
2041    type Service = ServiceMarker;
2042
2043    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2044        match name {
2045            "clock" => Self::Clock(
2046                <ClockRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2047            ),
2048            _ => panic!("no such member protocol name for service Service"),
2049        }
2050    }
2051
2052    fn member_names() -> &'static [&'static str] {
2053        &["clock"]
2054    }
2055}
2056#[cfg(target_os = "fuchsia")]
2057pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2058
2059#[cfg(target_os = "fuchsia")]
2060impl fidl::endpoints::ServiceProxy for ServiceProxy {
2061    type Service = ServiceMarker;
2062
2063    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2064        Self(opener)
2065    }
2066}
2067
2068#[cfg(target_os = "fuchsia")]
2069impl ServiceProxy {
2070    pub fn connect_to_clock(&self) -> Result<ClockProxy, fidl::Error> {
2071        let (proxy, server_end) = fidl::endpoints::create_proxy::<ClockMarker>();
2072        self.connect_channel_to_clock(server_end)?;
2073        Ok(proxy)
2074    }
2075
2076    /// Like `connect_to_clock`, but returns a sync proxy.
2077    /// See [`Self::connect_to_clock`] for more details.
2078    pub fn connect_to_clock_sync(&self) -> Result<ClockSynchronousProxy, fidl::Error> {
2079        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ClockMarker>();
2080        self.connect_channel_to_clock(server_end)?;
2081        Ok(proxy)
2082    }
2083
2084    /// Like `connect_to_clock`, but accepts a server end.
2085    /// See [`Self::connect_to_clock`] for more details.
2086    pub fn connect_channel_to_clock(
2087        &self,
2088        server_end: fidl::endpoints::ServerEnd<ClockMarker>,
2089    ) -> Result<(), fidl::Error> {
2090        self.0.open_member("clock", server_end.into_channel())
2091    }
2092
2093    pub fn instance_name(&self) -> &str {
2094        self.0.instance_name()
2095    }
2096}
2097
2098mod internal {
2099    use super::*;
2100}