fidl_fuchsia_testing/
fidl_fuchsia_testing.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_testing__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct FakeClockCancelEventRequest {
16    pub event: fidl::EventPair,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for FakeClockCancelEventRequest
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct FakeClockControlAddStopPointRequest {
26    pub deadline_id: fidl_fuchsia_testing_deadline::DeadlineId,
27    pub event_type: DeadlineEventType,
28    pub on_stop: fidl::EventPair,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for FakeClockControlAddStopPointRequest
33{
34}
35
36#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct FakeClockRegisterEventInBootRequest {
38    pub event: fidl::EventPair,
39    pub time: fidl::BootInstant,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for FakeClockRegisterEventInBootRequest
44{
45}
46
47#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48pub struct FakeClockRegisterEventInMonotonicRequest {
49    pub event: fidl::EventPair,
50    pub time: fidl::MonotonicInstant,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
54    for FakeClockRegisterEventInMonotonicRequest
55{
56}
57
58#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
59pub struct FakeClockRescheduleEventInBootRequest {
60    pub event: fidl::EventPair,
61    pub time: fidl::BootInstant,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
65    for FakeClockRescheduleEventInBootRequest
66{
67}
68
69#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
70pub struct FakeClockRescheduleEventInMonotonicRequest {
71    pub event: fidl::EventPair,
72    pub time: fidl::MonotonicInstant,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
76    for FakeClockRescheduleEventInMonotonicRequest
77{
78}
79
80#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
81pub struct FakeClockMarker;
82
83impl fidl::endpoints::ProtocolMarker for FakeClockMarker {
84    type Proxy = FakeClockProxy;
85    type RequestStream = FakeClockRequestStream;
86    #[cfg(target_os = "fuchsia")]
87    type SynchronousProxy = FakeClockSynchronousProxy;
88
89    const DEBUG_NAME: &'static str = "fuchsia.testing.FakeClock";
90}
91impl fidl::endpoints::DiscoverableProtocolMarker for FakeClockMarker {}
92pub type FakeClockRescheduleEventInMonotonicResult = Result<(), i32>;
93pub type FakeClockRescheduleEventInBootResult = Result<(), i32>;
94
95pub trait FakeClockProxyInterface: Send + Sync {
96    type GetResponseFut: std::future::Future<
97            Output = Result<(fidl::BootInstant, fidl::MonotonicInstant), fidl::Error>,
98        > + Send;
99    fn r#get(&self) -> Self::GetResponseFut;
100    fn r#register_event_in_monotonic(
101        &self,
102        event: fidl::EventPair,
103        time: fidl::MonotonicInstant,
104    ) -> Result<(), fidl::Error>;
105    fn r#register_event_in_boot(
106        &self,
107        event: fidl::EventPair,
108        time: fidl::BootInstant,
109    ) -> Result<(), fidl::Error>;
110    type RescheduleEventInMonotonicResponseFut: std::future::Future<Output = Result<FakeClockRescheduleEventInMonotonicResult, fidl::Error>>
111        + Send;
112    fn r#reschedule_event_in_monotonic(
113        &self,
114        event: fidl::EventPair,
115        time: fidl::MonotonicInstant,
116    ) -> Self::RescheduleEventInMonotonicResponseFut;
117    type RescheduleEventInBootResponseFut: std::future::Future<Output = Result<FakeClockRescheduleEventInBootResult, fidl::Error>>
118        + Send;
119    fn r#reschedule_event_in_boot(
120        &self,
121        event: fidl::EventPair,
122        time: fidl::BootInstant,
123    ) -> Self::RescheduleEventInBootResponseFut;
124    type CancelEventResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
125    fn r#cancel_event(&self, event: fidl::EventPair) -> Self::CancelEventResponseFut;
126    type CreateNamedDeadlineInMonotonicResponseFut: std::future::Future<Output = Result<fidl::MonotonicInstant, fidl::Error>>
127        + Send;
128    fn r#create_named_deadline_in_monotonic(
129        &self,
130        id: &fidl_fuchsia_testing_deadline::DeadlineId,
131        duration: i64,
132    ) -> Self::CreateNamedDeadlineInMonotonicResponseFut;
133    type CreateNamedDeadlineInBootResponseFut: std::future::Future<Output = Result<fidl::BootInstant, fidl::Error>>
134        + Send;
135    fn r#create_named_deadline_in_boot(
136        &self,
137        id: &fidl_fuchsia_testing_deadline::DeadlineId,
138        duration: i64,
139    ) -> Self::CreateNamedDeadlineInBootResponseFut;
140}
141#[derive(Debug)]
142#[cfg(target_os = "fuchsia")]
143pub struct FakeClockSynchronousProxy {
144    client: fidl::client::sync::Client,
145}
146
147#[cfg(target_os = "fuchsia")]
148impl fidl::endpoints::SynchronousProxy for FakeClockSynchronousProxy {
149    type Proxy = FakeClockProxy;
150    type Protocol = FakeClockMarker;
151
152    fn from_channel(inner: fidl::Channel) -> Self {
153        Self::new(inner)
154    }
155
156    fn into_channel(self) -> fidl::Channel {
157        self.client.into_channel()
158    }
159
160    fn as_channel(&self) -> &fidl::Channel {
161        self.client.as_channel()
162    }
163}
164
165#[cfg(target_os = "fuchsia")]
166impl FakeClockSynchronousProxy {
167    pub fn new(channel: fidl::Channel) -> Self {
168        let protocol_name = <FakeClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
169        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
170    }
171
172    pub fn into_channel(self) -> fidl::Channel {
173        self.client.into_channel()
174    }
175
176    /// Waits until an event arrives and returns it. It is safe for other
177    /// threads to make concurrent requests while waiting for an event.
178    pub fn wait_for_event(
179        &self,
180        deadline: zx::MonotonicInstant,
181    ) -> Result<FakeClockEvent, fidl::Error> {
182        FakeClockEvent::decode(self.client.wait_for_event(deadline)?)
183    }
184
185    /// Gets the current time.
186    pub fn r#get(
187        &self,
188        ___deadline: zx::MonotonicInstant,
189    ) -> Result<(fidl::BootInstant, fidl::MonotonicInstant), fidl::Error> {
190        let _response =
191            self.client.send_query::<fidl::encoding::EmptyPayload, FakeClockGetResponse>(
192                (),
193                0x2a08c060e0b95e7c,
194                fidl::encoding::DynamicFlags::empty(),
195                ___deadline,
196            )?;
197        Ok((_response.boot_time, _response.monotonic_time))
198    }
199
200    /// Registers the event handle `event` to be signaled with `ZX_EVENTPAIR_SIGNALED` when the
201    /// provided `time` is reached by the fake monotonic clock.
202    /// The `FakeClock` instance will retain this event (even after it's fired) for as long as the
203    /// client-side of the provided event pair `event` is open.
204    pub fn r#register_event_in_monotonic(
205        &self,
206        mut event: fidl::EventPair,
207        mut time: fidl::MonotonicInstant,
208    ) -> Result<(), fidl::Error> {
209        self.client.send::<FakeClockRegisterEventInMonotonicRequest>(
210            (event, time),
211            0xe88536afd142a72,
212            fidl::encoding::DynamicFlags::empty(),
213        )
214    }
215
216    /// Registers the event handle `event` to be signaled with `ZX_EVENTPAIR_SIGNALED` when the
217    /// provided `time` is reached by the fake boot clock.
218    /// The `FakeClock` instance will retain this event (even after it's fired) for as long as the
219    /// client-side of the provided event pair `event` is open.
220    pub fn r#register_event_in_boot(
221        &self,
222        mut event: fidl::EventPair,
223        mut time: fidl::BootInstant,
224    ) -> Result<(), fidl::Error> {
225        self.client.send::<FakeClockRegisterEventInBootRequest>(
226            (event, time),
227            0x5cacbe472ce51cc4,
228            fidl::encoding::DynamicFlags::empty(),
229        )
230    }
231
232    /// Reschedules an event to be signalled with `ZX_EVENTPAIR_SIGNALED` at the new deadline in
233    /// `time` on the monotonic clock.
234    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
235    /// originally registered event through its kernel object identifier.
236    pub fn r#reschedule_event_in_monotonic(
237        &self,
238        mut event: fidl::EventPair,
239        mut time: fidl::MonotonicInstant,
240        ___deadline: zx::MonotonicInstant,
241    ) -> Result<FakeClockRescheduleEventInMonotonicResult, fidl::Error> {
242        let _response = self.client.send_query::<
243            FakeClockRescheduleEventInMonotonicRequest,
244            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
245        >(
246            (event, time,),
247            0x5d35cdbfc1e464ae,
248            fidl::encoding::DynamicFlags::empty(),
249            ___deadline,
250        )?;
251        Ok(_response.map(|x| x))
252    }
253
254    /// Reschedules an event to be signalled with `ZX_EVENTPAIR_SIGNALED` at the new deadline in
255    /// `time` on the boot clock.
256    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
257    /// originally registered event through its kernel object identifier.
258    pub fn r#reschedule_event_in_boot(
259        &self,
260        mut event: fidl::EventPair,
261        mut time: fidl::BootInstant,
262        ___deadline: zx::MonotonicInstant,
263    ) -> Result<FakeClockRescheduleEventInBootResult, fidl::Error> {
264        let _response = self.client.send_query::<
265            FakeClockRescheduleEventInBootRequest,
266            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
267        >(
268            (event, time,),
269            0xdb8b1c8c4732adb,
270            fidl::encoding::DynamicFlags::empty(),
271            ___deadline,
272        )?;
273        Ok(_response.map(|x| x))
274    }
275
276    /// Cancels a previously registered event.
277    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
278    /// originally registered event through its kernel object identifier.
279    pub fn r#cancel_event(
280        &self,
281        mut event: fidl::EventPair,
282        ___deadline: zx::MonotonicInstant,
283    ) -> Result<(), fidl::Error> {
284        let _response =
285            self.client.send_query::<FakeClockCancelEventRequest, fidl::encoding::EmptyPayload>(
286                (event,),
287                0x18bbdb18faa6cac0,
288                fidl::encoding::DynamicFlags::empty(),
289                ___deadline,
290            )?;
291        Ok(_response)
292    }
293
294    /// Calculate and set a deadline associated with an id on the monotonic clock.
295    /// The returned `deadline` is calculated as `duration` after the current fake time.
296    /// FakeClock emits two events: A `SET` event immediately, and an `EXPIRED` event when the
297    /// deadline expires. A test using `FakeClockControl` may reference events related to the
298    /// deadline using a matching `id`. See `FakeClockControl.SetStopPoint` for information on how a
299    /// test can wait for a deadline event.
300    pub fn r#create_named_deadline_in_monotonic(
301        &self,
302        mut id: &fidl_fuchsia_testing_deadline::DeadlineId,
303        mut duration: i64,
304        ___deadline: zx::MonotonicInstant,
305    ) -> Result<fidl::MonotonicInstant, fidl::Error> {
306        let _response = self.client.send_query::<
307            FakeClockCreateNamedDeadlineInMonotonicRequest,
308            FakeClockCreateNamedDeadlineInMonotonicResponse,
309        >(
310            (id, duration,),
311            0x6ae636f6a0c93b3e,
312            fidl::encoding::DynamicFlags::empty(),
313            ___deadline,
314        )?;
315        Ok(_response.deadline)
316    }
317
318    /// Calculate and set a deadline associated with an id on the boot clock.
319    /// The returned `deadline` is calculated as `duration` after the current fake time.
320    /// FakeClock emits two events: A `SET` event immediately, and an `EXPIRED` event when the
321    /// deadline expires. A test using `FakeClockControl` may reference events related to the
322    /// deadline using a matching `id`. See `FakeClockControl.SetStopPoint` for information on how a
323    /// test can wait for a deadline event.
324    pub fn r#create_named_deadline_in_boot(
325        &self,
326        mut id: &fidl_fuchsia_testing_deadline::DeadlineId,
327        mut duration: i64,
328        ___deadline: zx::MonotonicInstant,
329    ) -> Result<fidl::BootInstant, fidl::Error> {
330        let _response = self.client.send_query::<
331            FakeClockCreateNamedDeadlineInBootRequest,
332            FakeClockCreateNamedDeadlineInBootResponse,
333        >(
334            (id, duration,),
335            0x15b0b36a16b354d8,
336            fidl::encoding::DynamicFlags::empty(),
337            ___deadline,
338        )?;
339        Ok(_response.deadline)
340    }
341}
342
343#[cfg(target_os = "fuchsia")]
344impl From<FakeClockSynchronousProxy> for zx::Handle {
345    fn from(value: FakeClockSynchronousProxy) -> Self {
346        value.into_channel().into()
347    }
348}
349
350#[cfg(target_os = "fuchsia")]
351impl From<fidl::Channel> for FakeClockSynchronousProxy {
352    fn from(value: fidl::Channel) -> Self {
353        Self::new(value)
354    }
355}
356
357#[cfg(target_os = "fuchsia")]
358impl fidl::endpoints::FromClient for FakeClockSynchronousProxy {
359    type Protocol = FakeClockMarker;
360
361    fn from_client(value: fidl::endpoints::ClientEnd<FakeClockMarker>) -> Self {
362        Self::new(value.into_channel())
363    }
364}
365
366#[derive(Debug, Clone)]
367pub struct FakeClockProxy {
368    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
369}
370
371impl fidl::endpoints::Proxy for FakeClockProxy {
372    type Protocol = FakeClockMarker;
373
374    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
375        Self::new(inner)
376    }
377
378    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
379        self.client.into_channel().map_err(|client| Self { client })
380    }
381
382    fn as_channel(&self) -> &::fidl::AsyncChannel {
383        self.client.as_channel()
384    }
385}
386
387impl FakeClockProxy {
388    /// Create a new Proxy for fuchsia.testing/FakeClock.
389    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
390        let protocol_name = <FakeClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
391        Self { client: fidl::client::Client::new(channel, protocol_name) }
392    }
393
394    /// Get a Stream of events from the remote end of the protocol.
395    ///
396    /// # Panics
397    ///
398    /// Panics if the event stream was already taken.
399    pub fn take_event_stream(&self) -> FakeClockEventStream {
400        FakeClockEventStream { event_receiver: self.client.take_event_receiver() }
401    }
402
403    /// Gets the current time.
404    pub fn r#get(
405        &self,
406    ) -> fidl::client::QueryResponseFut<
407        (fidl::BootInstant, fidl::MonotonicInstant),
408        fidl::encoding::DefaultFuchsiaResourceDialect,
409    > {
410        FakeClockProxyInterface::r#get(self)
411    }
412
413    /// Registers the event handle `event` to be signaled with `ZX_EVENTPAIR_SIGNALED` when the
414    /// provided `time` is reached by the fake monotonic clock.
415    /// The `FakeClock` instance will retain this event (even after it's fired) for as long as the
416    /// client-side of the provided event pair `event` is open.
417    pub fn r#register_event_in_monotonic(
418        &self,
419        mut event: fidl::EventPair,
420        mut time: fidl::MonotonicInstant,
421    ) -> Result<(), fidl::Error> {
422        FakeClockProxyInterface::r#register_event_in_monotonic(self, event, time)
423    }
424
425    /// Registers the event handle `event` to be signaled with `ZX_EVENTPAIR_SIGNALED` when the
426    /// provided `time` is reached by the fake boot clock.
427    /// The `FakeClock` instance will retain this event (even after it's fired) for as long as the
428    /// client-side of the provided event pair `event` is open.
429    pub fn r#register_event_in_boot(
430        &self,
431        mut event: fidl::EventPair,
432        mut time: fidl::BootInstant,
433    ) -> Result<(), fidl::Error> {
434        FakeClockProxyInterface::r#register_event_in_boot(self, event, time)
435    }
436
437    /// Reschedules an event to be signalled with `ZX_EVENTPAIR_SIGNALED` at the new deadline in
438    /// `time` on the monotonic clock.
439    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
440    /// originally registered event through its kernel object identifier.
441    pub fn r#reschedule_event_in_monotonic(
442        &self,
443        mut event: fidl::EventPair,
444        mut time: fidl::MonotonicInstant,
445    ) -> fidl::client::QueryResponseFut<
446        FakeClockRescheduleEventInMonotonicResult,
447        fidl::encoding::DefaultFuchsiaResourceDialect,
448    > {
449        FakeClockProxyInterface::r#reschedule_event_in_monotonic(self, event, time)
450    }
451
452    /// Reschedules an event to be signalled with `ZX_EVENTPAIR_SIGNALED` at the new deadline in
453    /// `time` on the boot clock.
454    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
455    /// originally registered event through its kernel object identifier.
456    pub fn r#reschedule_event_in_boot(
457        &self,
458        mut event: fidl::EventPair,
459        mut time: fidl::BootInstant,
460    ) -> fidl::client::QueryResponseFut<
461        FakeClockRescheduleEventInBootResult,
462        fidl::encoding::DefaultFuchsiaResourceDialect,
463    > {
464        FakeClockProxyInterface::r#reschedule_event_in_boot(self, event, time)
465    }
466
467    /// Cancels a previously registered event.
468    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
469    /// originally registered event through its kernel object identifier.
470    pub fn r#cancel_event(
471        &self,
472        mut event: fidl::EventPair,
473    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
474        FakeClockProxyInterface::r#cancel_event(self, event)
475    }
476
477    /// Calculate and set a deadline associated with an id on the monotonic clock.
478    /// The returned `deadline` is calculated as `duration` after the current fake time.
479    /// FakeClock emits two events: A `SET` event immediately, and an `EXPIRED` event when the
480    /// deadline expires. A test using `FakeClockControl` may reference events related to the
481    /// deadline using a matching `id`. See `FakeClockControl.SetStopPoint` for information on how a
482    /// test can wait for a deadline event.
483    pub fn r#create_named_deadline_in_monotonic(
484        &self,
485        mut id: &fidl_fuchsia_testing_deadline::DeadlineId,
486        mut duration: i64,
487    ) -> fidl::client::QueryResponseFut<
488        fidl::MonotonicInstant,
489        fidl::encoding::DefaultFuchsiaResourceDialect,
490    > {
491        FakeClockProxyInterface::r#create_named_deadline_in_monotonic(self, id, duration)
492    }
493
494    /// Calculate and set a deadline associated with an id on the boot clock.
495    /// The returned `deadline` is calculated as `duration` after the current fake time.
496    /// FakeClock emits two events: A `SET` event immediately, and an `EXPIRED` event when the
497    /// deadline expires. A test using `FakeClockControl` may reference events related to the
498    /// deadline using a matching `id`. See `FakeClockControl.SetStopPoint` for information on how a
499    /// test can wait for a deadline event.
500    pub fn r#create_named_deadline_in_boot(
501        &self,
502        mut id: &fidl_fuchsia_testing_deadline::DeadlineId,
503        mut duration: i64,
504    ) -> fidl::client::QueryResponseFut<
505        fidl::BootInstant,
506        fidl::encoding::DefaultFuchsiaResourceDialect,
507    > {
508        FakeClockProxyInterface::r#create_named_deadline_in_boot(self, id, duration)
509    }
510}
511
512impl FakeClockProxyInterface for FakeClockProxy {
513    type GetResponseFut = fidl::client::QueryResponseFut<
514        (fidl::BootInstant, fidl::MonotonicInstant),
515        fidl::encoding::DefaultFuchsiaResourceDialect,
516    >;
517    fn r#get(&self) -> Self::GetResponseFut {
518        fn _decode(
519            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
520        ) -> Result<(fidl::BootInstant, fidl::MonotonicInstant), fidl::Error> {
521            let _response = fidl::client::decode_transaction_body::<
522                FakeClockGetResponse,
523                fidl::encoding::DefaultFuchsiaResourceDialect,
524                0x2a08c060e0b95e7c,
525            >(_buf?)?;
526            Ok((_response.boot_time, _response.monotonic_time))
527        }
528        self.client.send_query_and_decode::<
529            fidl::encoding::EmptyPayload,
530            (fidl::BootInstant, fidl::MonotonicInstant),
531        >(
532            (),
533            0x2a08c060e0b95e7c,
534            fidl::encoding::DynamicFlags::empty(),
535            _decode,
536        )
537    }
538
539    fn r#register_event_in_monotonic(
540        &self,
541        mut event: fidl::EventPair,
542        mut time: fidl::MonotonicInstant,
543    ) -> Result<(), fidl::Error> {
544        self.client.send::<FakeClockRegisterEventInMonotonicRequest>(
545            (event, time),
546            0xe88536afd142a72,
547            fidl::encoding::DynamicFlags::empty(),
548        )
549    }
550
551    fn r#register_event_in_boot(
552        &self,
553        mut event: fidl::EventPair,
554        mut time: fidl::BootInstant,
555    ) -> Result<(), fidl::Error> {
556        self.client.send::<FakeClockRegisterEventInBootRequest>(
557            (event, time),
558            0x5cacbe472ce51cc4,
559            fidl::encoding::DynamicFlags::empty(),
560        )
561    }
562
563    type RescheduleEventInMonotonicResponseFut = fidl::client::QueryResponseFut<
564        FakeClockRescheduleEventInMonotonicResult,
565        fidl::encoding::DefaultFuchsiaResourceDialect,
566    >;
567    fn r#reschedule_event_in_monotonic(
568        &self,
569        mut event: fidl::EventPair,
570        mut time: fidl::MonotonicInstant,
571    ) -> Self::RescheduleEventInMonotonicResponseFut {
572        fn _decode(
573            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
574        ) -> Result<FakeClockRescheduleEventInMonotonicResult, fidl::Error> {
575            let _response = fidl::client::decode_transaction_body::<
576                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
577                fidl::encoding::DefaultFuchsiaResourceDialect,
578                0x5d35cdbfc1e464ae,
579            >(_buf?)?;
580            Ok(_response.map(|x| x))
581        }
582        self.client.send_query_and_decode::<
583            FakeClockRescheduleEventInMonotonicRequest,
584            FakeClockRescheduleEventInMonotonicResult,
585        >(
586            (event, time,),
587            0x5d35cdbfc1e464ae,
588            fidl::encoding::DynamicFlags::empty(),
589            _decode,
590        )
591    }
592
593    type RescheduleEventInBootResponseFut = fidl::client::QueryResponseFut<
594        FakeClockRescheduleEventInBootResult,
595        fidl::encoding::DefaultFuchsiaResourceDialect,
596    >;
597    fn r#reschedule_event_in_boot(
598        &self,
599        mut event: fidl::EventPair,
600        mut time: fidl::BootInstant,
601    ) -> Self::RescheduleEventInBootResponseFut {
602        fn _decode(
603            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
604        ) -> Result<FakeClockRescheduleEventInBootResult, fidl::Error> {
605            let _response = fidl::client::decode_transaction_body::<
606                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
607                fidl::encoding::DefaultFuchsiaResourceDialect,
608                0xdb8b1c8c4732adb,
609            >(_buf?)?;
610            Ok(_response.map(|x| x))
611        }
612        self.client.send_query_and_decode::<
613            FakeClockRescheduleEventInBootRequest,
614            FakeClockRescheduleEventInBootResult,
615        >(
616            (event, time,),
617            0xdb8b1c8c4732adb,
618            fidl::encoding::DynamicFlags::empty(),
619            _decode,
620        )
621    }
622
623    type CancelEventResponseFut =
624        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
625    fn r#cancel_event(&self, mut event: fidl::EventPair) -> Self::CancelEventResponseFut {
626        fn _decode(
627            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
628        ) -> Result<(), fidl::Error> {
629            let _response = fidl::client::decode_transaction_body::<
630                fidl::encoding::EmptyPayload,
631                fidl::encoding::DefaultFuchsiaResourceDialect,
632                0x18bbdb18faa6cac0,
633            >(_buf?)?;
634            Ok(_response)
635        }
636        self.client.send_query_and_decode::<FakeClockCancelEventRequest, ()>(
637            (event,),
638            0x18bbdb18faa6cac0,
639            fidl::encoding::DynamicFlags::empty(),
640            _decode,
641        )
642    }
643
644    type CreateNamedDeadlineInMonotonicResponseFut = fidl::client::QueryResponseFut<
645        fidl::MonotonicInstant,
646        fidl::encoding::DefaultFuchsiaResourceDialect,
647    >;
648    fn r#create_named_deadline_in_monotonic(
649        &self,
650        mut id: &fidl_fuchsia_testing_deadline::DeadlineId,
651        mut duration: i64,
652    ) -> Self::CreateNamedDeadlineInMonotonicResponseFut {
653        fn _decode(
654            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
655        ) -> Result<fidl::MonotonicInstant, fidl::Error> {
656            let _response = fidl::client::decode_transaction_body::<
657                FakeClockCreateNamedDeadlineInMonotonicResponse,
658                fidl::encoding::DefaultFuchsiaResourceDialect,
659                0x6ae636f6a0c93b3e,
660            >(_buf?)?;
661            Ok(_response.deadline)
662        }
663        self.client.send_query_and_decode::<
664            FakeClockCreateNamedDeadlineInMonotonicRequest,
665            fidl::MonotonicInstant,
666        >(
667            (id, duration,),
668            0x6ae636f6a0c93b3e,
669            fidl::encoding::DynamicFlags::empty(),
670            _decode,
671        )
672    }
673
674    type CreateNamedDeadlineInBootResponseFut = fidl::client::QueryResponseFut<
675        fidl::BootInstant,
676        fidl::encoding::DefaultFuchsiaResourceDialect,
677    >;
678    fn r#create_named_deadline_in_boot(
679        &self,
680        mut id: &fidl_fuchsia_testing_deadline::DeadlineId,
681        mut duration: i64,
682    ) -> Self::CreateNamedDeadlineInBootResponseFut {
683        fn _decode(
684            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
685        ) -> Result<fidl::BootInstant, fidl::Error> {
686            let _response = fidl::client::decode_transaction_body::<
687                FakeClockCreateNamedDeadlineInBootResponse,
688                fidl::encoding::DefaultFuchsiaResourceDialect,
689                0x15b0b36a16b354d8,
690            >(_buf?)?;
691            Ok(_response.deadline)
692        }
693        self.client
694            .send_query_and_decode::<FakeClockCreateNamedDeadlineInBootRequest, fidl::BootInstant>(
695                (id, duration),
696                0x15b0b36a16b354d8,
697                fidl::encoding::DynamicFlags::empty(),
698                _decode,
699            )
700    }
701}
702
703pub struct FakeClockEventStream {
704    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
705}
706
707impl std::marker::Unpin for FakeClockEventStream {}
708
709impl futures::stream::FusedStream for FakeClockEventStream {
710    fn is_terminated(&self) -> bool {
711        self.event_receiver.is_terminated()
712    }
713}
714
715impl futures::Stream for FakeClockEventStream {
716    type Item = Result<FakeClockEvent, fidl::Error>;
717
718    fn poll_next(
719        mut self: std::pin::Pin<&mut Self>,
720        cx: &mut std::task::Context<'_>,
721    ) -> std::task::Poll<Option<Self::Item>> {
722        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
723            &mut self.event_receiver,
724            cx
725        )?) {
726            Some(buf) => std::task::Poll::Ready(Some(FakeClockEvent::decode(buf))),
727            None => std::task::Poll::Ready(None),
728        }
729    }
730}
731
732#[derive(Debug)]
733pub enum FakeClockEvent {}
734
735impl FakeClockEvent {
736    /// Decodes a message buffer as a [`FakeClockEvent`].
737    fn decode(
738        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
739    ) -> Result<FakeClockEvent, fidl::Error> {
740        let (bytes, _handles) = buf.split_mut();
741        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
742        debug_assert_eq!(tx_header.tx_id, 0);
743        match tx_header.ordinal {
744            _ => Err(fidl::Error::UnknownOrdinal {
745                ordinal: tx_header.ordinal,
746                protocol_name: <FakeClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
747            }),
748        }
749    }
750}
751
752/// A Stream of incoming requests for fuchsia.testing/FakeClock.
753pub struct FakeClockRequestStream {
754    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
755    is_terminated: bool,
756}
757
758impl std::marker::Unpin for FakeClockRequestStream {}
759
760impl futures::stream::FusedStream for FakeClockRequestStream {
761    fn is_terminated(&self) -> bool {
762        self.is_terminated
763    }
764}
765
766impl fidl::endpoints::RequestStream for FakeClockRequestStream {
767    type Protocol = FakeClockMarker;
768    type ControlHandle = FakeClockControlHandle;
769
770    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
771        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
772    }
773
774    fn control_handle(&self) -> Self::ControlHandle {
775        FakeClockControlHandle { inner: self.inner.clone() }
776    }
777
778    fn into_inner(
779        self,
780    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
781    {
782        (self.inner, self.is_terminated)
783    }
784
785    fn from_inner(
786        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
787        is_terminated: bool,
788    ) -> Self {
789        Self { inner, is_terminated }
790    }
791}
792
793impl futures::Stream for FakeClockRequestStream {
794    type Item = Result<FakeClockRequest, fidl::Error>;
795
796    fn poll_next(
797        mut self: std::pin::Pin<&mut Self>,
798        cx: &mut std::task::Context<'_>,
799    ) -> std::task::Poll<Option<Self::Item>> {
800        let this = &mut *self;
801        if this.inner.check_shutdown(cx) {
802            this.is_terminated = true;
803            return std::task::Poll::Ready(None);
804        }
805        if this.is_terminated {
806            panic!("polled FakeClockRequestStream after completion");
807        }
808        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
809            |bytes, handles| {
810                match this.inner.channel().read_etc(cx, bytes, handles) {
811                    std::task::Poll::Ready(Ok(())) => {}
812                    std::task::Poll::Pending => return std::task::Poll::Pending,
813                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
814                        this.is_terminated = true;
815                        return std::task::Poll::Ready(None);
816                    }
817                    std::task::Poll::Ready(Err(e)) => {
818                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
819                            e.into(),
820                        ))));
821                    }
822                }
823
824                // A message has been received from the channel
825                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
826
827                std::task::Poll::Ready(Some(match header.ordinal {
828                    0x2a08c060e0b95e7c => {
829                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
830                        let mut req = fidl::new_empty!(
831                            fidl::encoding::EmptyPayload,
832                            fidl::encoding::DefaultFuchsiaResourceDialect
833                        );
834                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
835                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
836                        Ok(FakeClockRequest::Get {
837                            responder: FakeClockGetResponder {
838                                control_handle: std::mem::ManuallyDrop::new(control_handle),
839                                tx_id: header.tx_id,
840                            },
841                        })
842                    }
843                    0xe88536afd142a72 => {
844                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
845                        let mut req = fidl::new_empty!(
846                            FakeClockRegisterEventInMonotonicRequest,
847                            fidl::encoding::DefaultFuchsiaResourceDialect
848                        );
849                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockRegisterEventInMonotonicRequest>(&header, _body_bytes, handles, &mut req)?;
850                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
851                        Ok(FakeClockRequest::RegisterEventInMonotonic {
852                            event: req.event,
853                            time: req.time,
854
855                            control_handle,
856                        })
857                    }
858                    0x5cacbe472ce51cc4 => {
859                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
860                        let mut req = fidl::new_empty!(
861                            FakeClockRegisterEventInBootRequest,
862                            fidl::encoding::DefaultFuchsiaResourceDialect
863                        );
864                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockRegisterEventInBootRequest>(&header, _body_bytes, handles, &mut req)?;
865                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
866                        Ok(FakeClockRequest::RegisterEventInBoot {
867                            event: req.event,
868                            time: req.time,
869
870                            control_handle,
871                        })
872                    }
873                    0x5d35cdbfc1e464ae => {
874                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
875                        let mut req = fidl::new_empty!(
876                            FakeClockRescheduleEventInMonotonicRequest,
877                            fidl::encoding::DefaultFuchsiaResourceDialect
878                        );
879                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockRescheduleEventInMonotonicRequest>(&header, _body_bytes, handles, &mut req)?;
880                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
881                        Ok(FakeClockRequest::RescheduleEventInMonotonic {
882                            event: req.event,
883                            time: req.time,
884
885                            responder: FakeClockRescheduleEventInMonotonicResponder {
886                                control_handle: std::mem::ManuallyDrop::new(control_handle),
887                                tx_id: header.tx_id,
888                            },
889                        })
890                    }
891                    0xdb8b1c8c4732adb => {
892                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
893                        let mut req = fidl::new_empty!(
894                            FakeClockRescheduleEventInBootRequest,
895                            fidl::encoding::DefaultFuchsiaResourceDialect
896                        );
897                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockRescheduleEventInBootRequest>(&header, _body_bytes, handles, &mut req)?;
898                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
899                        Ok(FakeClockRequest::RescheduleEventInBoot {
900                            event: req.event,
901                            time: req.time,
902
903                            responder: FakeClockRescheduleEventInBootResponder {
904                                control_handle: std::mem::ManuallyDrop::new(control_handle),
905                                tx_id: header.tx_id,
906                            },
907                        })
908                    }
909                    0x18bbdb18faa6cac0 => {
910                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
911                        let mut req = fidl::new_empty!(
912                            FakeClockCancelEventRequest,
913                            fidl::encoding::DefaultFuchsiaResourceDialect
914                        );
915                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockCancelEventRequest>(&header, _body_bytes, handles, &mut req)?;
916                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
917                        Ok(FakeClockRequest::CancelEvent {
918                            event: req.event,
919
920                            responder: FakeClockCancelEventResponder {
921                                control_handle: std::mem::ManuallyDrop::new(control_handle),
922                                tx_id: header.tx_id,
923                            },
924                        })
925                    }
926                    0x6ae636f6a0c93b3e => {
927                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
928                        let mut req = fidl::new_empty!(
929                            FakeClockCreateNamedDeadlineInMonotonicRequest,
930                            fidl::encoding::DefaultFuchsiaResourceDialect
931                        );
932                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockCreateNamedDeadlineInMonotonicRequest>(&header, _body_bytes, handles, &mut req)?;
933                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
934                        Ok(FakeClockRequest::CreateNamedDeadlineInMonotonic {
935                            id: req.id,
936                            duration: req.duration,
937
938                            responder: FakeClockCreateNamedDeadlineInMonotonicResponder {
939                                control_handle: std::mem::ManuallyDrop::new(control_handle),
940                                tx_id: header.tx_id,
941                            },
942                        })
943                    }
944                    0x15b0b36a16b354d8 => {
945                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
946                        let mut req = fidl::new_empty!(
947                            FakeClockCreateNamedDeadlineInBootRequest,
948                            fidl::encoding::DefaultFuchsiaResourceDialect
949                        );
950                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockCreateNamedDeadlineInBootRequest>(&header, _body_bytes, handles, &mut req)?;
951                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
952                        Ok(FakeClockRequest::CreateNamedDeadlineInBoot {
953                            id: req.id,
954                            duration: req.duration,
955
956                            responder: FakeClockCreateNamedDeadlineInBootResponder {
957                                control_handle: std::mem::ManuallyDrop::new(control_handle),
958                                tx_id: header.tx_id,
959                            },
960                        })
961                    }
962                    _ => Err(fidl::Error::UnknownOrdinal {
963                        ordinal: header.ordinal,
964                        protocol_name:
965                            <FakeClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
966                    }),
967                }))
968            },
969        )
970    }
971}
972
973/// Allows access to fake clocks managed by `FakeClockControl`.
974#[derive(Debug)]
975pub enum FakeClockRequest {
976    /// Gets the current time.
977    Get { responder: FakeClockGetResponder },
978    /// Registers the event handle `event` to be signaled with `ZX_EVENTPAIR_SIGNALED` when the
979    /// provided `time` is reached by the fake monotonic clock.
980    /// The `FakeClock` instance will retain this event (even after it's fired) for as long as the
981    /// client-side of the provided event pair `event` is open.
982    RegisterEventInMonotonic {
983        event: fidl::EventPair,
984        time: fidl::MonotonicInstant,
985        control_handle: FakeClockControlHandle,
986    },
987    /// Registers the event handle `event` to be signaled with `ZX_EVENTPAIR_SIGNALED` when the
988    /// provided `time` is reached by the fake boot clock.
989    /// The `FakeClock` instance will retain this event (even after it's fired) for as long as the
990    /// client-side of the provided event pair `event` is open.
991    RegisterEventInBoot {
992        event: fidl::EventPair,
993        time: fidl::BootInstant,
994        control_handle: FakeClockControlHandle,
995    },
996    /// Reschedules an event to be signalled with `ZX_EVENTPAIR_SIGNALED` at the new deadline in
997    /// `time` on the monotonic clock.
998    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
999    /// originally registered event through its kernel object identifier.
1000    RescheduleEventInMonotonic {
1001        event: fidl::EventPair,
1002        time: fidl::MonotonicInstant,
1003        responder: FakeClockRescheduleEventInMonotonicResponder,
1004    },
1005    /// Reschedules an event to be signalled with `ZX_EVENTPAIR_SIGNALED` at the new deadline in
1006    /// `time` on the boot clock.
1007    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
1008    /// originally registered event through its kernel object identifier.
1009    RescheduleEventInBoot {
1010        event: fidl::EventPair,
1011        time: fidl::BootInstant,
1012        responder: FakeClockRescheduleEventInBootResponder,
1013    },
1014    /// Cancels a previously registered event.
1015    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
1016    /// originally registered event through its kernel object identifier.
1017    CancelEvent { event: fidl::EventPair, responder: FakeClockCancelEventResponder },
1018    /// Calculate and set a deadline associated with an id on the monotonic clock.
1019    /// The returned `deadline` is calculated as `duration` after the current fake time.
1020    /// FakeClock emits two events: A `SET` event immediately, and an `EXPIRED` event when the
1021    /// deadline expires. A test using `FakeClockControl` may reference events related to the
1022    /// deadline using a matching `id`. See `FakeClockControl.SetStopPoint` for information on how a
1023    /// test can wait for a deadline event.
1024    CreateNamedDeadlineInMonotonic {
1025        id: fidl_fuchsia_testing_deadline::DeadlineId,
1026        duration: i64,
1027        responder: FakeClockCreateNamedDeadlineInMonotonicResponder,
1028    },
1029    /// Calculate and set a deadline associated with an id on the boot clock.
1030    /// The returned `deadline` is calculated as `duration` after the current fake time.
1031    /// FakeClock emits two events: A `SET` event immediately, and an `EXPIRED` event when the
1032    /// deadline expires. A test using `FakeClockControl` may reference events related to the
1033    /// deadline using a matching `id`. See `FakeClockControl.SetStopPoint` for information on how a
1034    /// test can wait for a deadline event.
1035    CreateNamedDeadlineInBoot {
1036        id: fidl_fuchsia_testing_deadline::DeadlineId,
1037        duration: i64,
1038        responder: FakeClockCreateNamedDeadlineInBootResponder,
1039    },
1040}
1041
1042impl FakeClockRequest {
1043    #[allow(irrefutable_let_patterns)]
1044    pub fn into_get(self) -> Option<(FakeClockGetResponder)> {
1045        if let FakeClockRequest::Get { responder } = self { Some((responder)) } else { None }
1046    }
1047
1048    #[allow(irrefutable_let_patterns)]
1049    pub fn into_register_event_in_monotonic(
1050        self,
1051    ) -> Option<(fidl::EventPair, fidl::MonotonicInstant, FakeClockControlHandle)> {
1052        if let FakeClockRequest::RegisterEventInMonotonic { event, time, control_handle } = self {
1053            Some((event, time, control_handle))
1054        } else {
1055            None
1056        }
1057    }
1058
1059    #[allow(irrefutable_let_patterns)]
1060    pub fn into_register_event_in_boot(
1061        self,
1062    ) -> Option<(fidl::EventPair, fidl::BootInstant, FakeClockControlHandle)> {
1063        if let FakeClockRequest::RegisterEventInBoot { event, time, control_handle } = self {
1064            Some((event, time, control_handle))
1065        } else {
1066            None
1067        }
1068    }
1069
1070    #[allow(irrefutable_let_patterns)]
1071    pub fn into_reschedule_event_in_monotonic(
1072        self,
1073    ) -> Option<(
1074        fidl::EventPair,
1075        fidl::MonotonicInstant,
1076        FakeClockRescheduleEventInMonotonicResponder,
1077    )> {
1078        if let FakeClockRequest::RescheduleEventInMonotonic { event, time, responder } = self {
1079            Some((event, time, responder))
1080        } else {
1081            None
1082        }
1083    }
1084
1085    #[allow(irrefutable_let_patterns)]
1086    pub fn into_reschedule_event_in_boot(
1087        self,
1088    ) -> Option<(fidl::EventPair, fidl::BootInstant, FakeClockRescheduleEventInBootResponder)> {
1089        if let FakeClockRequest::RescheduleEventInBoot { event, time, responder } = self {
1090            Some((event, time, responder))
1091        } else {
1092            None
1093        }
1094    }
1095
1096    #[allow(irrefutable_let_patterns)]
1097    pub fn into_cancel_event(self) -> Option<(fidl::EventPair, FakeClockCancelEventResponder)> {
1098        if let FakeClockRequest::CancelEvent { event, responder } = self {
1099            Some((event, responder))
1100        } else {
1101            None
1102        }
1103    }
1104
1105    #[allow(irrefutable_let_patterns)]
1106    pub fn into_create_named_deadline_in_monotonic(
1107        self,
1108    ) -> Option<(
1109        fidl_fuchsia_testing_deadline::DeadlineId,
1110        i64,
1111        FakeClockCreateNamedDeadlineInMonotonicResponder,
1112    )> {
1113        if let FakeClockRequest::CreateNamedDeadlineInMonotonic { id, duration, responder } = self {
1114            Some((id, duration, responder))
1115        } else {
1116            None
1117        }
1118    }
1119
1120    #[allow(irrefutable_let_patterns)]
1121    pub fn into_create_named_deadline_in_boot(
1122        self,
1123    ) -> Option<(
1124        fidl_fuchsia_testing_deadline::DeadlineId,
1125        i64,
1126        FakeClockCreateNamedDeadlineInBootResponder,
1127    )> {
1128        if let FakeClockRequest::CreateNamedDeadlineInBoot { id, duration, responder } = self {
1129            Some((id, duration, responder))
1130        } else {
1131            None
1132        }
1133    }
1134
1135    /// Name of the method defined in FIDL
1136    pub fn method_name(&self) -> &'static str {
1137        match *self {
1138            FakeClockRequest::Get { .. } => "get",
1139            FakeClockRequest::RegisterEventInMonotonic { .. } => "register_event_in_monotonic",
1140            FakeClockRequest::RegisterEventInBoot { .. } => "register_event_in_boot",
1141            FakeClockRequest::RescheduleEventInMonotonic { .. } => "reschedule_event_in_monotonic",
1142            FakeClockRequest::RescheduleEventInBoot { .. } => "reschedule_event_in_boot",
1143            FakeClockRequest::CancelEvent { .. } => "cancel_event",
1144            FakeClockRequest::CreateNamedDeadlineInMonotonic { .. } => {
1145                "create_named_deadline_in_monotonic"
1146            }
1147            FakeClockRequest::CreateNamedDeadlineInBoot { .. } => "create_named_deadline_in_boot",
1148        }
1149    }
1150}
1151
1152#[derive(Debug, Clone)]
1153pub struct FakeClockControlHandle {
1154    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1155}
1156
1157impl fidl::endpoints::ControlHandle for FakeClockControlHandle {
1158    fn shutdown(&self) {
1159        self.inner.shutdown()
1160    }
1161    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1162        self.inner.shutdown_with_epitaph(status)
1163    }
1164
1165    fn is_closed(&self) -> bool {
1166        self.inner.channel().is_closed()
1167    }
1168    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1169        self.inner.channel().on_closed()
1170    }
1171
1172    #[cfg(target_os = "fuchsia")]
1173    fn signal_peer(
1174        &self,
1175        clear_mask: zx::Signals,
1176        set_mask: zx::Signals,
1177    ) -> Result<(), zx_status::Status> {
1178        use fidl::Peered;
1179        self.inner.channel().signal_peer(clear_mask, set_mask)
1180    }
1181}
1182
1183impl FakeClockControlHandle {}
1184
1185#[must_use = "FIDL methods require a response to be sent"]
1186#[derive(Debug)]
1187pub struct FakeClockGetResponder {
1188    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1189    tx_id: u32,
1190}
1191
1192/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1193/// if the responder is dropped without sending a response, so that the client
1194/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1195impl std::ops::Drop for FakeClockGetResponder {
1196    fn drop(&mut self) {
1197        self.control_handle.shutdown();
1198        // Safety: drops once, never accessed again
1199        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1200    }
1201}
1202
1203impl fidl::endpoints::Responder for FakeClockGetResponder {
1204    type ControlHandle = FakeClockControlHandle;
1205
1206    fn control_handle(&self) -> &FakeClockControlHandle {
1207        &self.control_handle
1208    }
1209
1210    fn drop_without_shutdown(mut self) {
1211        // Safety: drops once, never accessed again due to mem::forget
1212        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1213        // Prevent Drop from running (which would shut down the channel)
1214        std::mem::forget(self);
1215    }
1216}
1217
1218impl FakeClockGetResponder {
1219    /// Sends a response to the FIDL transaction.
1220    ///
1221    /// Sets the channel to shutdown if an error occurs.
1222    pub fn send(
1223        self,
1224        mut boot_time: fidl::BootInstant,
1225        mut monotonic_time: fidl::MonotonicInstant,
1226    ) -> Result<(), fidl::Error> {
1227        let _result = self.send_raw(boot_time, monotonic_time);
1228        if _result.is_err() {
1229            self.control_handle.shutdown();
1230        }
1231        self.drop_without_shutdown();
1232        _result
1233    }
1234
1235    /// Similar to "send" but does not shutdown the channel if an error occurs.
1236    pub fn send_no_shutdown_on_err(
1237        self,
1238        mut boot_time: fidl::BootInstant,
1239        mut monotonic_time: fidl::MonotonicInstant,
1240    ) -> Result<(), fidl::Error> {
1241        let _result = self.send_raw(boot_time, monotonic_time);
1242        self.drop_without_shutdown();
1243        _result
1244    }
1245
1246    fn send_raw(
1247        &self,
1248        mut boot_time: fidl::BootInstant,
1249        mut monotonic_time: fidl::MonotonicInstant,
1250    ) -> Result<(), fidl::Error> {
1251        self.control_handle.inner.send::<FakeClockGetResponse>(
1252            (boot_time, monotonic_time),
1253            self.tx_id,
1254            0x2a08c060e0b95e7c,
1255            fidl::encoding::DynamicFlags::empty(),
1256        )
1257    }
1258}
1259
1260#[must_use = "FIDL methods require a response to be sent"]
1261#[derive(Debug)]
1262pub struct FakeClockRescheduleEventInMonotonicResponder {
1263    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1264    tx_id: u32,
1265}
1266
1267/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1268/// if the responder is dropped without sending a response, so that the client
1269/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1270impl std::ops::Drop for FakeClockRescheduleEventInMonotonicResponder {
1271    fn drop(&mut self) {
1272        self.control_handle.shutdown();
1273        // Safety: drops once, never accessed again
1274        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1275    }
1276}
1277
1278impl fidl::endpoints::Responder for FakeClockRescheduleEventInMonotonicResponder {
1279    type ControlHandle = FakeClockControlHandle;
1280
1281    fn control_handle(&self) -> &FakeClockControlHandle {
1282        &self.control_handle
1283    }
1284
1285    fn drop_without_shutdown(mut self) {
1286        // Safety: drops once, never accessed again due to mem::forget
1287        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1288        // Prevent Drop from running (which would shut down the channel)
1289        std::mem::forget(self);
1290    }
1291}
1292
1293impl FakeClockRescheduleEventInMonotonicResponder {
1294    /// Sends a response to the FIDL transaction.
1295    ///
1296    /// Sets the channel to shutdown if an error occurs.
1297    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1298        let _result = self.send_raw(result);
1299        if _result.is_err() {
1300            self.control_handle.shutdown();
1301        }
1302        self.drop_without_shutdown();
1303        _result
1304    }
1305
1306    /// Similar to "send" but does not shutdown the channel if an error occurs.
1307    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1308        let _result = self.send_raw(result);
1309        self.drop_without_shutdown();
1310        _result
1311    }
1312
1313    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1314        self.control_handle
1315            .inner
1316            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1317                result,
1318                self.tx_id,
1319                0x5d35cdbfc1e464ae,
1320                fidl::encoding::DynamicFlags::empty(),
1321            )
1322    }
1323}
1324
1325#[must_use = "FIDL methods require a response to be sent"]
1326#[derive(Debug)]
1327pub struct FakeClockRescheduleEventInBootResponder {
1328    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1329    tx_id: u32,
1330}
1331
1332/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1333/// if the responder is dropped without sending a response, so that the client
1334/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1335impl std::ops::Drop for FakeClockRescheduleEventInBootResponder {
1336    fn drop(&mut self) {
1337        self.control_handle.shutdown();
1338        // Safety: drops once, never accessed again
1339        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1340    }
1341}
1342
1343impl fidl::endpoints::Responder for FakeClockRescheduleEventInBootResponder {
1344    type ControlHandle = FakeClockControlHandle;
1345
1346    fn control_handle(&self) -> &FakeClockControlHandle {
1347        &self.control_handle
1348    }
1349
1350    fn drop_without_shutdown(mut self) {
1351        // Safety: drops once, never accessed again due to mem::forget
1352        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1353        // Prevent Drop from running (which would shut down the channel)
1354        std::mem::forget(self);
1355    }
1356}
1357
1358impl FakeClockRescheduleEventInBootResponder {
1359    /// Sends a response to the FIDL transaction.
1360    ///
1361    /// Sets the channel to shutdown if an error occurs.
1362    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1363        let _result = self.send_raw(result);
1364        if _result.is_err() {
1365            self.control_handle.shutdown();
1366        }
1367        self.drop_without_shutdown();
1368        _result
1369    }
1370
1371    /// Similar to "send" but does not shutdown the channel if an error occurs.
1372    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1373        let _result = self.send_raw(result);
1374        self.drop_without_shutdown();
1375        _result
1376    }
1377
1378    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1379        self.control_handle
1380            .inner
1381            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1382                result,
1383                self.tx_id,
1384                0xdb8b1c8c4732adb,
1385                fidl::encoding::DynamicFlags::empty(),
1386            )
1387    }
1388}
1389
1390#[must_use = "FIDL methods require a response to be sent"]
1391#[derive(Debug)]
1392pub struct FakeClockCancelEventResponder {
1393    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1394    tx_id: u32,
1395}
1396
1397/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1398/// if the responder is dropped without sending a response, so that the client
1399/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1400impl std::ops::Drop for FakeClockCancelEventResponder {
1401    fn drop(&mut self) {
1402        self.control_handle.shutdown();
1403        // Safety: drops once, never accessed again
1404        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1405    }
1406}
1407
1408impl fidl::endpoints::Responder for FakeClockCancelEventResponder {
1409    type ControlHandle = FakeClockControlHandle;
1410
1411    fn control_handle(&self) -> &FakeClockControlHandle {
1412        &self.control_handle
1413    }
1414
1415    fn drop_without_shutdown(mut self) {
1416        // Safety: drops once, never accessed again due to mem::forget
1417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1418        // Prevent Drop from running (which would shut down the channel)
1419        std::mem::forget(self);
1420    }
1421}
1422
1423impl FakeClockCancelEventResponder {
1424    /// Sends a response to the FIDL transaction.
1425    ///
1426    /// Sets the channel to shutdown if an error occurs.
1427    pub fn send(self) -> Result<(), fidl::Error> {
1428        let _result = self.send_raw();
1429        if _result.is_err() {
1430            self.control_handle.shutdown();
1431        }
1432        self.drop_without_shutdown();
1433        _result
1434    }
1435
1436    /// Similar to "send" but does not shutdown the channel if an error occurs.
1437    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1438        let _result = self.send_raw();
1439        self.drop_without_shutdown();
1440        _result
1441    }
1442
1443    fn send_raw(&self) -> Result<(), fidl::Error> {
1444        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1445            (),
1446            self.tx_id,
1447            0x18bbdb18faa6cac0,
1448            fidl::encoding::DynamicFlags::empty(),
1449        )
1450    }
1451}
1452
1453#[must_use = "FIDL methods require a response to be sent"]
1454#[derive(Debug)]
1455pub struct FakeClockCreateNamedDeadlineInMonotonicResponder {
1456    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1457    tx_id: u32,
1458}
1459
1460/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1461/// if the responder is dropped without sending a response, so that the client
1462/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1463impl std::ops::Drop for FakeClockCreateNamedDeadlineInMonotonicResponder {
1464    fn drop(&mut self) {
1465        self.control_handle.shutdown();
1466        // Safety: drops once, never accessed again
1467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1468    }
1469}
1470
1471impl fidl::endpoints::Responder for FakeClockCreateNamedDeadlineInMonotonicResponder {
1472    type ControlHandle = FakeClockControlHandle;
1473
1474    fn control_handle(&self) -> &FakeClockControlHandle {
1475        &self.control_handle
1476    }
1477
1478    fn drop_without_shutdown(mut self) {
1479        // Safety: drops once, never accessed again due to mem::forget
1480        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1481        // Prevent Drop from running (which would shut down the channel)
1482        std::mem::forget(self);
1483    }
1484}
1485
1486impl FakeClockCreateNamedDeadlineInMonotonicResponder {
1487    /// Sends a response to the FIDL transaction.
1488    ///
1489    /// Sets the channel to shutdown if an error occurs.
1490    pub fn send(self, mut deadline: fidl::MonotonicInstant) -> Result<(), fidl::Error> {
1491        let _result = self.send_raw(deadline);
1492        if _result.is_err() {
1493            self.control_handle.shutdown();
1494        }
1495        self.drop_without_shutdown();
1496        _result
1497    }
1498
1499    /// Similar to "send" but does not shutdown the channel if an error occurs.
1500    pub fn send_no_shutdown_on_err(
1501        self,
1502        mut deadline: fidl::MonotonicInstant,
1503    ) -> Result<(), fidl::Error> {
1504        let _result = self.send_raw(deadline);
1505        self.drop_without_shutdown();
1506        _result
1507    }
1508
1509    fn send_raw(&self, mut deadline: fidl::MonotonicInstant) -> Result<(), fidl::Error> {
1510        self.control_handle.inner.send::<FakeClockCreateNamedDeadlineInMonotonicResponse>(
1511            (deadline,),
1512            self.tx_id,
1513            0x6ae636f6a0c93b3e,
1514            fidl::encoding::DynamicFlags::empty(),
1515        )
1516    }
1517}
1518
1519#[must_use = "FIDL methods require a response to be sent"]
1520#[derive(Debug)]
1521pub struct FakeClockCreateNamedDeadlineInBootResponder {
1522    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1523    tx_id: u32,
1524}
1525
1526/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1527/// if the responder is dropped without sending a response, so that the client
1528/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1529impl std::ops::Drop for FakeClockCreateNamedDeadlineInBootResponder {
1530    fn drop(&mut self) {
1531        self.control_handle.shutdown();
1532        // Safety: drops once, never accessed again
1533        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1534    }
1535}
1536
1537impl fidl::endpoints::Responder for FakeClockCreateNamedDeadlineInBootResponder {
1538    type ControlHandle = FakeClockControlHandle;
1539
1540    fn control_handle(&self) -> &FakeClockControlHandle {
1541        &self.control_handle
1542    }
1543
1544    fn drop_without_shutdown(mut self) {
1545        // Safety: drops once, never accessed again due to mem::forget
1546        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1547        // Prevent Drop from running (which would shut down the channel)
1548        std::mem::forget(self);
1549    }
1550}
1551
1552impl FakeClockCreateNamedDeadlineInBootResponder {
1553    /// Sends a response to the FIDL transaction.
1554    ///
1555    /// Sets the channel to shutdown if an error occurs.
1556    pub fn send(self, mut deadline: fidl::BootInstant) -> Result<(), fidl::Error> {
1557        let _result = self.send_raw(deadline);
1558        if _result.is_err() {
1559            self.control_handle.shutdown();
1560        }
1561        self.drop_without_shutdown();
1562        _result
1563    }
1564
1565    /// Similar to "send" but does not shutdown the channel if an error occurs.
1566    pub fn send_no_shutdown_on_err(
1567        self,
1568        mut deadline: fidl::BootInstant,
1569    ) -> Result<(), fidl::Error> {
1570        let _result = self.send_raw(deadline);
1571        self.drop_without_shutdown();
1572        _result
1573    }
1574
1575    fn send_raw(&self, mut deadline: fidl::BootInstant) -> Result<(), fidl::Error> {
1576        self.control_handle.inner.send::<FakeClockCreateNamedDeadlineInBootResponse>(
1577            (deadline,),
1578            self.tx_id,
1579            0x15b0b36a16b354d8,
1580            fidl::encoding::DynamicFlags::empty(),
1581        )
1582    }
1583}
1584
1585#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1586pub struct FakeClockControlMarker;
1587
1588impl fidl::endpoints::ProtocolMarker for FakeClockControlMarker {
1589    type Proxy = FakeClockControlProxy;
1590    type RequestStream = FakeClockControlRequestStream;
1591    #[cfg(target_os = "fuchsia")]
1592    type SynchronousProxy = FakeClockControlSynchronousProxy;
1593
1594    const DEBUG_NAME: &'static str = "fuchsia.testing.FakeClockControl";
1595}
1596impl fidl::endpoints::DiscoverableProtocolMarker for FakeClockControlMarker {}
1597pub type FakeClockControlAdvanceResult = Result<(), i32>;
1598pub type FakeClockControlIncrementMonoToBootOffsetByResult = Result<(), i32>;
1599pub type FakeClockControlResumeWithIncrementsResult = Result<(), i32>;
1600pub type FakeClockControlAddStopPointResult = Result<(), i32>;
1601
1602pub trait FakeClockControlProxyInterface: Send + Sync {
1603    type AdvanceResponseFut: std::future::Future<Output = Result<FakeClockControlAdvanceResult, fidl::Error>>
1604        + Send;
1605    fn r#advance(&self, increment: &Increment) -> Self::AdvanceResponseFut;
1606    type IncrementMonoToBootOffsetByResponseFut: std::future::Future<
1607            Output = Result<FakeClockControlIncrementMonoToBootOffsetByResult, fidl::Error>,
1608        > + Send;
1609    fn r#increment_mono_to_boot_offset_by(
1610        &self,
1611        increment: i64,
1612    ) -> Self::IncrementMonoToBootOffsetByResponseFut;
1613    type ResumeWithIncrementsResponseFut: std::future::Future<
1614            Output = Result<FakeClockControlResumeWithIncrementsResult, fidl::Error>,
1615        > + Send;
1616    fn r#resume_with_increments(
1617        &self,
1618        real: i64,
1619        increment: &Increment,
1620    ) -> Self::ResumeWithIncrementsResponseFut;
1621    type AddStopPointResponseFut: std::future::Future<Output = Result<FakeClockControlAddStopPointResult, fidl::Error>>
1622        + Send;
1623    fn r#add_stop_point(
1624        &self,
1625        deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1626        event_type: DeadlineEventType,
1627        on_stop: fidl::EventPair,
1628    ) -> Self::AddStopPointResponseFut;
1629    type PauseResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1630    fn r#pause(&self) -> Self::PauseResponseFut;
1631    type IgnoreNamedDeadlineResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
1632        + Send;
1633    fn r#ignore_named_deadline(
1634        &self,
1635        deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1636    ) -> Self::IgnoreNamedDeadlineResponseFut;
1637}
1638#[derive(Debug)]
1639#[cfg(target_os = "fuchsia")]
1640pub struct FakeClockControlSynchronousProxy {
1641    client: fidl::client::sync::Client,
1642}
1643
1644#[cfg(target_os = "fuchsia")]
1645impl fidl::endpoints::SynchronousProxy for FakeClockControlSynchronousProxy {
1646    type Proxy = FakeClockControlProxy;
1647    type Protocol = FakeClockControlMarker;
1648
1649    fn from_channel(inner: fidl::Channel) -> Self {
1650        Self::new(inner)
1651    }
1652
1653    fn into_channel(self) -> fidl::Channel {
1654        self.client.into_channel()
1655    }
1656
1657    fn as_channel(&self) -> &fidl::Channel {
1658        self.client.as_channel()
1659    }
1660}
1661
1662#[cfg(target_os = "fuchsia")]
1663impl FakeClockControlSynchronousProxy {
1664    pub fn new(channel: fidl::Channel) -> Self {
1665        let protocol_name = <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1666        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1667    }
1668
1669    pub fn into_channel(self) -> fidl::Channel {
1670        self.client.into_channel()
1671    }
1672
1673    /// Waits until an event arrives and returns it. It is safe for other
1674    /// threads to make concurrent requests while waiting for an event.
1675    pub fn wait_for_event(
1676        &self,
1677        deadline: zx::MonotonicInstant,
1678    ) -> Result<FakeClockControlEvent, fidl::Error> {
1679        FakeClockControlEvent::decode(self.client.wait_for_event(deadline)?)
1680    }
1681
1682    /// Advances the fake clock `increment` once. This advances both monotonic and boot clocks by
1683    /// the same amount.
1684    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a badly formed
1685    /// RandomRange). Returns `ZX_ERR_ACCESS_DENIED` if called while the FakeClock is free-running.
1686    pub fn r#advance(
1687        &self,
1688        mut increment: &Increment,
1689        ___deadline: zx::MonotonicInstant,
1690    ) -> Result<FakeClockControlAdvanceResult, fidl::Error> {
1691        let _response = self.client.send_query::<
1692            FakeClockControlAdvanceRequest,
1693            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1694        >(
1695            (increment,),
1696            0x42f2265fb495497a,
1697            fidl::encoding::DynamicFlags::empty(),
1698            ___deadline,
1699        )?;
1700        Ok(_response.map(|x| x))
1701    }
1702
1703    /// Increments the mono-to-boot offset by the given `increment`. With real
1704    /// clocks, the positive offset from monotonic clock to boot clock increases
1705    /// during suspend. Here, this method fakes such an increase in offset.
1706    /// `increment` must be a positive duration.
1707    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is not positive.
1708    pub fn r#increment_mono_to_boot_offset_by(
1709        &self,
1710        mut increment: i64,
1711        ___deadline: zx::MonotonicInstant,
1712    ) -> Result<FakeClockControlIncrementMonoToBootOffsetByResult, fidl::Error> {
1713        let _response = self.client.send_query::<
1714            FakeClockControlIncrementMonoToBootOffsetByRequest,
1715            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1716        >(
1717            (increment,),
1718            0x294f89fe62a18857,
1719            fidl::encoding::DynamicFlags::empty(),
1720            ___deadline,
1721        )?;
1722        Ok(_response.map(|x| x))
1723    }
1724
1725    /// Resumes free-running increments on the fake clock.
1726    /// `real` is the period based on the real monotonic clock over which `increment` is going to be
1727    /// applied. Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a
1728    /// badly formed RandomRange).
1729    pub fn r#resume_with_increments(
1730        &self,
1731        mut real: i64,
1732        mut increment: &Increment,
1733        ___deadline: zx::MonotonicInstant,
1734    ) -> Result<FakeClockControlResumeWithIncrementsResult, fidl::Error> {
1735        let _response = self.client.send_query::<
1736            FakeClockControlResumeWithIncrementsRequest,
1737            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1738        >(
1739            (real, increment,),
1740            0x259be1eeba0bdd4a,
1741            fidl::encoding::DynamicFlags::empty(),
1742            ___deadline,
1743        )?;
1744        Ok(_response.map(|x| x))
1745    }
1746
1747    /// Registers interest in a deadline event.
1748    /// `deadline_id` and `event_type` identify the named deadline and the event associated with
1749    /// the deadline. When the event occurs, FakeClock will signal `EVENTPAIR_SIGNALED` on
1750    /// `on_stop`. If time is free-running, the clock is stopped. Closing the eventpair cancels
1751    /// interest in the deadline. If the eventpair is closed when a deadline is reached, time is
1752    /// not stopped. Note that only events that occur after `AddStopPoint` is called are matched.
1753    /// In addition, the `EXPIRED` event is always reported, even if the component that created the
1754    /// deadline does not act on the deadline expiration.
1755    ///
1756    /// The intended use is to set a stop point using `AddStopPoint`, resume running time with
1757    /// `ResumeWithIncrements`, then wait for the stop point to occur using the `on_stop`
1758    /// eventpair.
1759    /// Setting a stop point is only allowed while time is stopped. If time is free running when
1760    /// this method is invoked `ZX_ERR_ACCESS_DENIED` is returned. If a stop point is already
1761    /// registered for the same event, `ZX_ALREADY_BOUND` is returned.
1762    pub fn r#add_stop_point(
1763        &self,
1764        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1765        mut event_type: DeadlineEventType,
1766        mut on_stop: fidl::EventPair,
1767        ___deadline: zx::MonotonicInstant,
1768    ) -> Result<FakeClockControlAddStopPointResult, fidl::Error> {
1769        let _response = self.client.send_query::<
1770            FakeClockControlAddStopPointRequest,
1771            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1772        >(
1773            (deadline_id, event_type, on_stop,),
1774            0x3b52fe2cba8c4245,
1775            fidl::encoding::DynamicFlags::empty(),
1776            ___deadline,
1777        )?;
1778        Ok(_response.map(|x| x))
1779    }
1780
1781    /// Pauses free-running increments on the fake clock.
1782    pub fn r#pause(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1783        let _response =
1784            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1785                (),
1786                0x260df03b49199ba4,
1787                fidl::encoding::DynamicFlags::empty(),
1788                ___deadline,
1789            )?;
1790        Ok(_response)
1791    }
1792
1793    /// Instructs the fake clock to make deadlines named `deadline_id` never expire.
1794    /// This is a no-op if `deadline_id` is already in the ignored set.
1795    pub fn r#ignore_named_deadline(
1796        &self,
1797        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1798        ___deadline: zx::MonotonicInstant,
1799    ) -> Result<(), fidl::Error> {
1800        let _response = self
1801            .client
1802            .send_query::<FakeClockControlIgnoreNamedDeadlineRequest, fidl::encoding::EmptyPayload>(
1803                (deadline_id,),
1804                0x2e445152a80d44aa,
1805                fidl::encoding::DynamicFlags::empty(),
1806                ___deadline,
1807            )?;
1808        Ok(_response)
1809    }
1810}
1811
1812#[cfg(target_os = "fuchsia")]
1813impl From<FakeClockControlSynchronousProxy> for zx::Handle {
1814    fn from(value: FakeClockControlSynchronousProxy) -> Self {
1815        value.into_channel().into()
1816    }
1817}
1818
1819#[cfg(target_os = "fuchsia")]
1820impl From<fidl::Channel> for FakeClockControlSynchronousProxy {
1821    fn from(value: fidl::Channel) -> Self {
1822        Self::new(value)
1823    }
1824}
1825
1826#[cfg(target_os = "fuchsia")]
1827impl fidl::endpoints::FromClient for FakeClockControlSynchronousProxy {
1828    type Protocol = FakeClockControlMarker;
1829
1830    fn from_client(value: fidl::endpoints::ClientEnd<FakeClockControlMarker>) -> Self {
1831        Self::new(value.into_channel())
1832    }
1833}
1834
1835#[derive(Debug, Clone)]
1836pub struct FakeClockControlProxy {
1837    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1838}
1839
1840impl fidl::endpoints::Proxy for FakeClockControlProxy {
1841    type Protocol = FakeClockControlMarker;
1842
1843    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1844        Self::new(inner)
1845    }
1846
1847    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1848        self.client.into_channel().map_err(|client| Self { client })
1849    }
1850
1851    fn as_channel(&self) -> &::fidl::AsyncChannel {
1852        self.client.as_channel()
1853    }
1854}
1855
1856impl FakeClockControlProxy {
1857    /// Create a new Proxy for fuchsia.testing/FakeClockControl.
1858    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1859        let protocol_name = <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1860        Self { client: fidl::client::Client::new(channel, protocol_name) }
1861    }
1862
1863    /// Get a Stream of events from the remote end of the protocol.
1864    ///
1865    /// # Panics
1866    ///
1867    /// Panics if the event stream was already taken.
1868    pub fn take_event_stream(&self) -> FakeClockControlEventStream {
1869        FakeClockControlEventStream { event_receiver: self.client.take_event_receiver() }
1870    }
1871
1872    /// Advances the fake clock `increment` once. This advances both monotonic and boot clocks by
1873    /// the same amount.
1874    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a badly formed
1875    /// RandomRange). Returns `ZX_ERR_ACCESS_DENIED` if called while the FakeClock is free-running.
1876    pub fn r#advance(
1877        &self,
1878        mut increment: &Increment,
1879    ) -> fidl::client::QueryResponseFut<
1880        FakeClockControlAdvanceResult,
1881        fidl::encoding::DefaultFuchsiaResourceDialect,
1882    > {
1883        FakeClockControlProxyInterface::r#advance(self, increment)
1884    }
1885
1886    /// Increments the mono-to-boot offset by the given `increment`. With real
1887    /// clocks, the positive offset from monotonic clock to boot clock increases
1888    /// during suspend. Here, this method fakes such an increase in offset.
1889    /// `increment` must be a positive duration.
1890    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is not positive.
1891    pub fn r#increment_mono_to_boot_offset_by(
1892        &self,
1893        mut increment: i64,
1894    ) -> fidl::client::QueryResponseFut<
1895        FakeClockControlIncrementMonoToBootOffsetByResult,
1896        fidl::encoding::DefaultFuchsiaResourceDialect,
1897    > {
1898        FakeClockControlProxyInterface::r#increment_mono_to_boot_offset_by(self, increment)
1899    }
1900
1901    /// Resumes free-running increments on the fake clock.
1902    /// `real` is the period based on the real monotonic clock over which `increment` is going to be
1903    /// applied. Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a
1904    /// badly formed RandomRange).
1905    pub fn r#resume_with_increments(
1906        &self,
1907        mut real: i64,
1908        mut increment: &Increment,
1909    ) -> fidl::client::QueryResponseFut<
1910        FakeClockControlResumeWithIncrementsResult,
1911        fidl::encoding::DefaultFuchsiaResourceDialect,
1912    > {
1913        FakeClockControlProxyInterface::r#resume_with_increments(self, real, increment)
1914    }
1915
1916    /// Registers interest in a deadline event.
1917    /// `deadline_id` and `event_type` identify the named deadline and the event associated with
1918    /// the deadline. When the event occurs, FakeClock will signal `EVENTPAIR_SIGNALED` on
1919    /// `on_stop`. If time is free-running, the clock is stopped. Closing the eventpair cancels
1920    /// interest in the deadline. If the eventpair is closed when a deadline is reached, time is
1921    /// not stopped. Note that only events that occur after `AddStopPoint` is called are matched.
1922    /// In addition, the `EXPIRED` event is always reported, even if the component that created the
1923    /// deadline does not act on the deadline expiration.
1924    ///
1925    /// The intended use is to set a stop point using `AddStopPoint`, resume running time with
1926    /// `ResumeWithIncrements`, then wait for the stop point to occur using the `on_stop`
1927    /// eventpair.
1928    /// Setting a stop point is only allowed while time is stopped. If time is free running when
1929    /// this method is invoked `ZX_ERR_ACCESS_DENIED` is returned. If a stop point is already
1930    /// registered for the same event, `ZX_ALREADY_BOUND` is returned.
1931    pub fn r#add_stop_point(
1932        &self,
1933        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1934        mut event_type: DeadlineEventType,
1935        mut on_stop: fidl::EventPair,
1936    ) -> fidl::client::QueryResponseFut<
1937        FakeClockControlAddStopPointResult,
1938        fidl::encoding::DefaultFuchsiaResourceDialect,
1939    > {
1940        FakeClockControlProxyInterface::r#add_stop_point(self, deadline_id, event_type, on_stop)
1941    }
1942
1943    /// Pauses free-running increments on the fake clock.
1944    pub fn r#pause(
1945        &self,
1946    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1947        FakeClockControlProxyInterface::r#pause(self)
1948    }
1949
1950    /// Instructs the fake clock to make deadlines named `deadline_id` never expire.
1951    /// This is a no-op if `deadline_id` is already in the ignored set.
1952    pub fn r#ignore_named_deadline(
1953        &self,
1954        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1955    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1956        FakeClockControlProxyInterface::r#ignore_named_deadline(self, deadline_id)
1957    }
1958}
1959
1960impl FakeClockControlProxyInterface for FakeClockControlProxy {
1961    type AdvanceResponseFut = fidl::client::QueryResponseFut<
1962        FakeClockControlAdvanceResult,
1963        fidl::encoding::DefaultFuchsiaResourceDialect,
1964    >;
1965    fn r#advance(&self, mut increment: &Increment) -> Self::AdvanceResponseFut {
1966        fn _decode(
1967            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1968        ) -> Result<FakeClockControlAdvanceResult, fidl::Error> {
1969            let _response = fidl::client::decode_transaction_body::<
1970                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1971                fidl::encoding::DefaultFuchsiaResourceDialect,
1972                0x42f2265fb495497a,
1973            >(_buf?)?;
1974            Ok(_response.map(|x| x))
1975        }
1976        self.client
1977            .send_query_and_decode::<FakeClockControlAdvanceRequest, FakeClockControlAdvanceResult>(
1978                (increment,),
1979                0x42f2265fb495497a,
1980                fidl::encoding::DynamicFlags::empty(),
1981                _decode,
1982            )
1983    }
1984
1985    type IncrementMonoToBootOffsetByResponseFut = fidl::client::QueryResponseFut<
1986        FakeClockControlIncrementMonoToBootOffsetByResult,
1987        fidl::encoding::DefaultFuchsiaResourceDialect,
1988    >;
1989    fn r#increment_mono_to_boot_offset_by(
1990        &self,
1991        mut increment: i64,
1992    ) -> Self::IncrementMonoToBootOffsetByResponseFut {
1993        fn _decode(
1994            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1995        ) -> Result<FakeClockControlIncrementMonoToBootOffsetByResult, fidl::Error> {
1996            let _response = fidl::client::decode_transaction_body::<
1997                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1998                fidl::encoding::DefaultFuchsiaResourceDialect,
1999                0x294f89fe62a18857,
2000            >(_buf?)?;
2001            Ok(_response.map(|x| x))
2002        }
2003        self.client.send_query_and_decode::<
2004            FakeClockControlIncrementMonoToBootOffsetByRequest,
2005            FakeClockControlIncrementMonoToBootOffsetByResult,
2006        >(
2007            (increment,),
2008            0x294f89fe62a18857,
2009            fidl::encoding::DynamicFlags::empty(),
2010            _decode,
2011        )
2012    }
2013
2014    type ResumeWithIncrementsResponseFut = fidl::client::QueryResponseFut<
2015        FakeClockControlResumeWithIncrementsResult,
2016        fidl::encoding::DefaultFuchsiaResourceDialect,
2017    >;
2018    fn r#resume_with_increments(
2019        &self,
2020        mut real: i64,
2021        mut increment: &Increment,
2022    ) -> Self::ResumeWithIncrementsResponseFut {
2023        fn _decode(
2024            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2025        ) -> Result<FakeClockControlResumeWithIncrementsResult, fidl::Error> {
2026            let _response = fidl::client::decode_transaction_body::<
2027                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2028                fidl::encoding::DefaultFuchsiaResourceDialect,
2029                0x259be1eeba0bdd4a,
2030            >(_buf?)?;
2031            Ok(_response.map(|x| x))
2032        }
2033        self.client.send_query_and_decode::<
2034            FakeClockControlResumeWithIncrementsRequest,
2035            FakeClockControlResumeWithIncrementsResult,
2036        >(
2037            (real, increment,),
2038            0x259be1eeba0bdd4a,
2039            fidl::encoding::DynamicFlags::empty(),
2040            _decode,
2041        )
2042    }
2043
2044    type AddStopPointResponseFut = fidl::client::QueryResponseFut<
2045        FakeClockControlAddStopPointResult,
2046        fidl::encoding::DefaultFuchsiaResourceDialect,
2047    >;
2048    fn r#add_stop_point(
2049        &self,
2050        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
2051        mut event_type: DeadlineEventType,
2052        mut on_stop: fidl::EventPair,
2053    ) -> Self::AddStopPointResponseFut {
2054        fn _decode(
2055            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2056        ) -> Result<FakeClockControlAddStopPointResult, fidl::Error> {
2057            let _response = fidl::client::decode_transaction_body::<
2058                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2059                fidl::encoding::DefaultFuchsiaResourceDialect,
2060                0x3b52fe2cba8c4245,
2061            >(_buf?)?;
2062            Ok(_response.map(|x| x))
2063        }
2064        self.client.send_query_and_decode::<
2065            FakeClockControlAddStopPointRequest,
2066            FakeClockControlAddStopPointResult,
2067        >(
2068            (deadline_id, event_type, on_stop,),
2069            0x3b52fe2cba8c4245,
2070            fidl::encoding::DynamicFlags::empty(),
2071            _decode,
2072        )
2073    }
2074
2075    type PauseResponseFut =
2076        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2077    fn r#pause(&self) -> Self::PauseResponseFut {
2078        fn _decode(
2079            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2080        ) -> Result<(), fidl::Error> {
2081            let _response = fidl::client::decode_transaction_body::<
2082                fidl::encoding::EmptyPayload,
2083                fidl::encoding::DefaultFuchsiaResourceDialect,
2084                0x260df03b49199ba4,
2085            >(_buf?)?;
2086            Ok(_response)
2087        }
2088        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2089            (),
2090            0x260df03b49199ba4,
2091            fidl::encoding::DynamicFlags::empty(),
2092            _decode,
2093        )
2094    }
2095
2096    type IgnoreNamedDeadlineResponseFut =
2097        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2098    fn r#ignore_named_deadline(
2099        &self,
2100        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
2101    ) -> Self::IgnoreNamedDeadlineResponseFut {
2102        fn _decode(
2103            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2104        ) -> Result<(), fidl::Error> {
2105            let _response = fidl::client::decode_transaction_body::<
2106                fidl::encoding::EmptyPayload,
2107                fidl::encoding::DefaultFuchsiaResourceDialect,
2108                0x2e445152a80d44aa,
2109            >(_buf?)?;
2110            Ok(_response)
2111        }
2112        self.client.send_query_and_decode::<FakeClockControlIgnoreNamedDeadlineRequest, ()>(
2113            (deadline_id,),
2114            0x2e445152a80d44aa,
2115            fidl::encoding::DynamicFlags::empty(),
2116            _decode,
2117        )
2118    }
2119}
2120
2121pub struct FakeClockControlEventStream {
2122    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2123}
2124
2125impl std::marker::Unpin for FakeClockControlEventStream {}
2126
2127impl futures::stream::FusedStream for FakeClockControlEventStream {
2128    fn is_terminated(&self) -> bool {
2129        self.event_receiver.is_terminated()
2130    }
2131}
2132
2133impl futures::Stream for FakeClockControlEventStream {
2134    type Item = Result<FakeClockControlEvent, fidl::Error>;
2135
2136    fn poll_next(
2137        mut self: std::pin::Pin<&mut Self>,
2138        cx: &mut std::task::Context<'_>,
2139    ) -> std::task::Poll<Option<Self::Item>> {
2140        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2141            &mut self.event_receiver,
2142            cx
2143        )?) {
2144            Some(buf) => std::task::Poll::Ready(Some(FakeClockControlEvent::decode(buf))),
2145            None => std::task::Poll::Ready(None),
2146        }
2147    }
2148}
2149
2150#[derive(Debug)]
2151pub enum FakeClockControlEvent {}
2152
2153impl FakeClockControlEvent {
2154    /// Decodes a message buffer as a [`FakeClockControlEvent`].
2155    fn decode(
2156        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2157    ) -> Result<FakeClockControlEvent, fidl::Error> {
2158        let (bytes, _handles) = buf.split_mut();
2159        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2160        debug_assert_eq!(tx_header.tx_id, 0);
2161        match tx_header.ordinal {
2162            _ => Err(fidl::Error::UnknownOrdinal {
2163                ordinal: tx_header.ordinal,
2164                protocol_name:
2165                    <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2166            }),
2167        }
2168    }
2169}
2170
2171/// A Stream of incoming requests for fuchsia.testing/FakeClockControl.
2172pub struct FakeClockControlRequestStream {
2173    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2174    is_terminated: bool,
2175}
2176
2177impl std::marker::Unpin for FakeClockControlRequestStream {}
2178
2179impl futures::stream::FusedStream for FakeClockControlRequestStream {
2180    fn is_terminated(&self) -> bool {
2181        self.is_terminated
2182    }
2183}
2184
2185impl fidl::endpoints::RequestStream for FakeClockControlRequestStream {
2186    type Protocol = FakeClockControlMarker;
2187    type ControlHandle = FakeClockControlControlHandle;
2188
2189    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2190        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2191    }
2192
2193    fn control_handle(&self) -> Self::ControlHandle {
2194        FakeClockControlControlHandle { inner: self.inner.clone() }
2195    }
2196
2197    fn into_inner(
2198        self,
2199    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2200    {
2201        (self.inner, self.is_terminated)
2202    }
2203
2204    fn from_inner(
2205        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2206        is_terminated: bool,
2207    ) -> Self {
2208        Self { inner, is_terminated }
2209    }
2210}
2211
2212impl futures::Stream for FakeClockControlRequestStream {
2213    type Item = Result<FakeClockControlRequest, fidl::Error>;
2214
2215    fn poll_next(
2216        mut self: std::pin::Pin<&mut Self>,
2217        cx: &mut std::task::Context<'_>,
2218    ) -> std::task::Poll<Option<Self::Item>> {
2219        let this = &mut *self;
2220        if this.inner.check_shutdown(cx) {
2221            this.is_terminated = true;
2222            return std::task::Poll::Ready(None);
2223        }
2224        if this.is_terminated {
2225            panic!("polled FakeClockControlRequestStream after completion");
2226        }
2227        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2228            |bytes, handles| {
2229                match this.inner.channel().read_etc(cx, bytes, handles) {
2230                    std::task::Poll::Ready(Ok(())) => {}
2231                    std::task::Poll::Pending => return std::task::Poll::Pending,
2232                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2233                        this.is_terminated = true;
2234                        return std::task::Poll::Ready(None);
2235                    }
2236                    std::task::Poll::Ready(Err(e)) => {
2237                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2238                            e.into(),
2239                        ))));
2240                    }
2241                }
2242
2243                // A message has been received from the channel
2244                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2245
2246                std::task::Poll::Ready(Some(match header.ordinal {
2247                    0x42f2265fb495497a => {
2248                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2249                        let mut req = fidl::new_empty!(
2250                            FakeClockControlAdvanceRequest,
2251                            fidl::encoding::DefaultFuchsiaResourceDialect
2252                        );
2253                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlAdvanceRequest>(&header, _body_bytes, handles, &mut req)?;
2254                        let control_handle =
2255                            FakeClockControlControlHandle { inner: this.inner.clone() };
2256                        Ok(FakeClockControlRequest::Advance {
2257                            increment: req.increment,
2258
2259                            responder: FakeClockControlAdvanceResponder {
2260                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2261                                tx_id: header.tx_id,
2262                            },
2263                        })
2264                    }
2265                    0x294f89fe62a18857 => {
2266                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2267                        let mut req = fidl::new_empty!(
2268                            FakeClockControlIncrementMonoToBootOffsetByRequest,
2269                            fidl::encoding::DefaultFuchsiaResourceDialect
2270                        );
2271                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlIncrementMonoToBootOffsetByRequest>(&header, _body_bytes, handles, &mut req)?;
2272                        let control_handle =
2273                            FakeClockControlControlHandle { inner: this.inner.clone() };
2274                        Ok(FakeClockControlRequest::IncrementMonoToBootOffsetBy {
2275                            increment: req.increment,
2276
2277                            responder: FakeClockControlIncrementMonoToBootOffsetByResponder {
2278                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2279                                tx_id: header.tx_id,
2280                            },
2281                        })
2282                    }
2283                    0x259be1eeba0bdd4a => {
2284                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2285                        let mut req = fidl::new_empty!(
2286                            FakeClockControlResumeWithIncrementsRequest,
2287                            fidl::encoding::DefaultFuchsiaResourceDialect
2288                        );
2289                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlResumeWithIncrementsRequest>(&header, _body_bytes, handles, &mut req)?;
2290                        let control_handle =
2291                            FakeClockControlControlHandle { inner: this.inner.clone() };
2292                        Ok(FakeClockControlRequest::ResumeWithIncrements {
2293                            real: req.real,
2294                            increment: req.increment,
2295
2296                            responder: FakeClockControlResumeWithIncrementsResponder {
2297                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2298                                tx_id: header.tx_id,
2299                            },
2300                        })
2301                    }
2302                    0x3b52fe2cba8c4245 => {
2303                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2304                        let mut req = fidl::new_empty!(
2305                            FakeClockControlAddStopPointRequest,
2306                            fidl::encoding::DefaultFuchsiaResourceDialect
2307                        );
2308                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlAddStopPointRequest>(&header, _body_bytes, handles, &mut req)?;
2309                        let control_handle =
2310                            FakeClockControlControlHandle { inner: this.inner.clone() };
2311                        Ok(FakeClockControlRequest::AddStopPoint {
2312                            deadline_id: req.deadline_id,
2313                            event_type: req.event_type,
2314                            on_stop: req.on_stop,
2315
2316                            responder: FakeClockControlAddStopPointResponder {
2317                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2318                                tx_id: header.tx_id,
2319                            },
2320                        })
2321                    }
2322                    0x260df03b49199ba4 => {
2323                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2324                        let mut req = fidl::new_empty!(
2325                            fidl::encoding::EmptyPayload,
2326                            fidl::encoding::DefaultFuchsiaResourceDialect
2327                        );
2328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2329                        let control_handle =
2330                            FakeClockControlControlHandle { inner: this.inner.clone() };
2331                        Ok(FakeClockControlRequest::Pause {
2332                            responder: FakeClockControlPauseResponder {
2333                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2334                                tx_id: header.tx_id,
2335                            },
2336                        })
2337                    }
2338                    0x2e445152a80d44aa => {
2339                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2340                        let mut req = fidl::new_empty!(
2341                            FakeClockControlIgnoreNamedDeadlineRequest,
2342                            fidl::encoding::DefaultFuchsiaResourceDialect
2343                        );
2344                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlIgnoreNamedDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
2345                        let control_handle =
2346                            FakeClockControlControlHandle { inner: this.inner.clone() };
2347                        Ok(FakeClockControlRequest::IgnoreNamedDeadline {
2348                            deadline_id: req.deadline_id,
2349
2350                            responder: FakeClockControlIgnoreNamedDeadlineResponder {
2351                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2352                                tx_id: header.tx_id,
2353                            },
2354                        })
2355                    }
2356                    _ => Err(fidl::Error::UnknownOrdinal {
2357                        ordinal: header.ordinal,
2358                        protocol_name:
2359                            <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2360                    }),
2361                }))
2362            },
2363        )
2364    }
2365}
2366
2367/// Provides control over fake clocks.
2368///
2369/// `FakeClockControl` provides complete control of the fake clocks that it provides, and serves
2370/// over `FakeClock`.
2371///
2372/// Upon start up, all the clocks are set to free-running with increments set to 1ms:1ms (same as
2373/// calling `SetIncrements` with a `real` duration of 1ms and a `determined` `increment` of 1ms as
2374/// well).
2375///
2376/// The initial time value for every fake clock is read from the corresponding real clock at start
2377/// up.
2378#[derive(Debug)]
2379pub enum FakeClockControlRequest {
2380    /// Advances the fake clock `increment` once. This advances both monotonic and boot clocks by
2381    /// the same amount.
2382    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a badly formed
2383    /// RandomRange). Returns `ZX_ERR_ACCESS_DENIED` if called while the FakeClock is free-running.
2384    Advance { increment: Increment, responder: FakeClockControlAdvanceResponder },
2385    /// Increments the mono-to-boot offset by the given `increment`. With real
2386    /// clocks, the positive offset from monotonic clock to boot clock increases
2387    /// during suspend. Here, this method fakes such an increase in offset.
2388    /// `increment` must be a positive duration.
2389    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is not positive.
2390    IncrementMonoToBootOffsetBy {
2391        increment: i64,
2392        responder: FakeClockControlIncrementMonoToBootOffsetByResponder,
2393    },
2394    /// Resumes free-running increments on the fake clock.
2395    /// `real` is the period based on the real monotonic clock over which `increment` is going to be
2396    /// applied. Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a
2397    /// badly formed RandomRange).
2398    ResumeWithIncrements {
2399        real: i64,
2400        increment: Increment,
2401        responder: FakeClockControlResumeWithIncrementsResponder,
2402    },
2403    /// Registers interest in a deadline event.
2404    /// `deadline_id` and `event_type` identify the named deadline and the event associated with
2405    /// the deadline. When the event occurs, FakeClock will signal `EVENTPAIR_SIGNALED` on
2406    /// `on_stop`. If time is free-running, the clock is stopped. Closing the eventpair cancels
2407    /// interest in the deadline. If the eventpair is closed when a deadline is reached, time is
2408    /// not stopped. Note that only events that occur after `AddStopPoint` is called are matched.
2409    /// In addition, the `EXPIRED` event is always reported, even if the component that created the
2410    /// deadline does not act on the deadline expiration.
2411    ///
2412    /// The intended use is to set a stop point using `AddStopPoint`, resume running time with
2413    /// `ResumeWithIncrements`, then wait for the stop point to occur using the `on_stop`
2414    /// eventpair.
2415    /// Setting a stop point is only allowed while time is stopped. If time is free running when
2416    /// this method is invoked `ZX_ERR_ACCESS_DENIED` is returned. If a stop point is already
2417    /// registered for the same event, `ZX_ALREADY_BOUND` is returned.
2418    AddStopPoint {
2419        deadline_id: fidl_fuchsia_testing_deadline::DeadlineId,
2420        event_type: DeadlineEventType,
2421        on_stop: fidl::EventPair,
2422        responder: FakeClockControlAddStopPointResponder,
2423    },
2424    /// Pauses free-running increments on the fake clock.
2425    Pause { responder: FakeClockControlPauseResponder },
2426    /// Instructs the fake clock to make deadlines named `deadline_id` never expire.
2427    /// This is a no-op if `deadline_id` is already in the ignored set.
2428    IgnoreNamedDeadline {
2429        deadline_id: fidl_fuchsia_testing_deadline::DeadlineId,
2430        responder: FakeClockControlIgnoreNamedDeadlineResponder,
2431    },
2432}
2433
2434impl FakeClockControlRequest {
2435    #[allow(irrefutable_let_patterns)]
2436    pub fn into_advance(self) -> Option<(Increment, FakeClockControlAdvanceResponder)> {
2437        if let FakeClockControlRequest::Advance { increment, responder } = self {
2438            Some((increment, responder))
2439        } else {
2440            None
2441        }
2442    }
2443
2444    #[allow(irrefutable_let_patterns)]
2445    pub fn into_increment_mono_to_boot_offset_by(
2446        self,
2447    ) -> Option<(i64, FakeClockControlIncrementMonoToBootOffsetByResponder)> {
2448        if let FakeClockControlRequest::IncrementMonoToBootOffsetBy { increment, responder } = self
2449        {
2450            Some((increment, responder))
2451        } else {
2452            None
2453        }
2454    }
2455
2456    #[allow(irrefutable_let_patterns)]
2457    pub fn into_resume_with_increments(
2458        self,
2459    ) -> Option<(i64, Increment, FakeClockControlResumeWithIncrementsResponder)> {
2460        if let FakeClockControlRequest::ResumeWithIncrements { real, increment, responder } = self {
2461            Some((real, increment, responder))
2462        } else {
2463            None
2464        }
2465    }
2466
2467    #[allow(irrefutable_let_patterns)]
2468    pub fn into_add_stop_point(
2469        self,
2470    ) -> Option<(
2471        fidl_fuchsia_testing_deadline::DeadlineId,
2472        DeadlineEventType,
2473        fidl::EventPair,
2474        FakeClockControlAddStopPointResponder,
2475    )> {
2476        if let FakeClockControlRequest::AddStopPoint {
2477            deadline_id,
2478            event_type,
2479            on_stop,
2480            responder,
2481        } = self
2482        {
2483            Some((deadline_id, event_type, on_stop, responder))
2484        } else {
2485            None
2486        }
2487    }
2488
2489    #[allow(irrefutable_let_patterns)]
2490    pub fn into_pause(self) -> Option<(FakeClockControlPauseResponder)> {
2491        if let FakeClockControlRequest::Pause { responder } = self {
2492            Some((responder))
2493        } else {
2494            None
2495        }
2496    }
2497
2498    #[allow(irrefutable_let_patterns)]
2499    pub fn into_ignore_named_deadline(
2500        self,
2501    ) -> Option<(
2502        fidl_fuchsia_testing_deadline::DeadlineId,
2503        FakeClockControlIgnoreNamedDeadlineResponder,
2504    )> {
2505        if let FakeClockControlRequest::IgnoreNamedDeadline { deadline_id, responder } = self {
2506            Some((deadline_id, responder))
2507        } else {
2508            None
2509        }
2510    }
2511
2512    /// Name of the method defined in FIDL
2513    pub fn method_name(&self) -> &'static str {
2514        match *self {
2515            FakeClockControlRequest::Advance { .. } => "advance",
2516            FakeClockControlRequest::IncrementMonoToBootOffsetBy { .. } => {
2517                "increment_mono_to_boot_offset_by"
2518            }
2519            FakeClockControlRequest::ResumeWithIncrements { .. } => "resume_with_increments",
2520            FakeClockControlRequest::AddStopPoint { .. } => "add_stop_point",
2521            FakeClockControlRequest::Pause { .. } => "pause",
2522            FakeClockControlRequest::IgnoreNamedDeadline { .. } => "ignore_named_deadline",
2523        }
2524    }
2525}
2526
2527#[derive(Debug, Clone)]
2528pub struct FakeClockControlControlHandle {
2529    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2530}
2531
2532impl fidl::endpoints::ControlHandle for FakeClockControlControlHandle {
2533    fn shutdown(&self) {
2534        self.inner.shutdown()
2535    }
2536    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2537        self.inner.shutdown_with_epitaph(status)
2538    }
2539
2540    fn is_closed(&self) -> bool {
2541        self.inner.channel().is_closed()
2542    }
2543    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2544        self.inner.channel().on_closed()
2545    }
2546
2547    #[cfg(target_os = "fuchsia")]
2548    fn signal_peer(
2549        &self,
2550        clear_mask: zx::Signals,
2551        set_mask: zx::Signals,
2552    ) -> Result<(), zx_status::Status> {
2553        use fidl::Peered;
2554        self.inner.channel().signal_peer(clear_mask, set_mask)
2555    }
2556}
2557
2558impl FakeClockControlControlHandle {}
2559
2560#[must_use = "FIDL methods require a response to be sent"]
2561#[derive(Debug)]
2562pub struct FakeClockControlAdvanceResponder {
2563    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2564    tx_id: u32,
2565}
2566
2567/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2568/// if the responder is dropped without sending a response, so that the client
2569/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2570impl std::ops::Drop for FakeClockControlAdvanceResponder {
2571    fn drop(&mut self) {
2572        self.control_handle.shutdown();
2573        // Safety: drops once, never accessed again
2574        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2575    }
2576}
2577
2578impl fidl::endpoints::Responder for FakeClockControlAdvanceResponder {
2579    type ControlHandle = FakeClockControlControlHandle;
2580
2581    fn control_handle(&self) -> &FakeClockControlControlHandle {
2582        &self.control_handle
2583    }
2584
2585    fn drop_without_shutdown(mut self) {
2586        // Safety: drops once, never accessed again due to mem::forget
2587        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2588        // Prevent Drop from running (which would shut down the channel)
2589        std::mem::forget(self);
2590    }
2591}
2592
2593impl FakeClockControlAdvanceResponder {
2594    /// Sends a response to the FIDL transaction.
2595    ///
2596    /// Sets the channel to shutdown if an error occurs.
2597    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2598        let _result = self.send_raw(result);
2599        if _result.is_err() {
2600            self.control_handle.shutdown();
2601        }
2602        self.drop_without_shutdown();
2603        _result
2604    }
2605
2606    /// Similar to "send" but does not shutdown the channel if an error occurs.
2607    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2608        let _result = self.send_raw(result);
2609        self.drop_without_shutdown();
2610        _result
2611    }
2612
2613    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2614        self.control_handle
2615            .inner
2616            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2617                result,
2618                self.tx_id,
2619                0x42f2265fb495497a,
2620                fidl::encoding::DynamicFlags::empty(),
2621            )
2622    }
2623}
2624
2625#[must_use = "FIDL methods require a response to be sent"]
2626#[derive(Debug)]
2627pub struct FakeClockControlIncrementMonoToBootOffsetByResponder {
2628    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2629    tx_id: u32,
2630}
2631
2632/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2633/// if the responder is dropped without sending a response, so that the client
2634/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2635impl std::ops::Drop for FakeClockControlIncrementMonoToBootOffsetByResponder {
2636    fn drop(&mut self) {
2637        self.control_handle.shutdown();
2638        // Safety: drops once, never accessed again
2639        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2640    }
2641}
2642
2643impl fidl::endpoints::Responder for FakeClockControlIncrementMonoToBootOffsetByResponder {
2644    type ControlHandle = FakeClockControlControlHandle;
2645
2646    fn control_handle(&self) -> &FakeClockControlControlHandle {
2647        &self.control_handle
2648    }
2649
2650    fn drop_without_shutdown(mut self) {
2651        // Safety: drops once, never accessed again due to mem::forget
2652        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2653        // Prevent Drop from running (which would shut down the channel)
2654        std::mem::forget(self);
2655    }
2656}
2657
2658impl FakeClockControlIncrementMonoToBootOffsetByResponder {
2659    /// Sends a response to the FIDL transaction.
2660    ///
2661    /// Sets the channel to shutdown if an error occurs.
2662    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2663        let _result = self.send_raw(result);
2664        if _result.is_err() {
2665            self.control_handle.shutdown();
2666        }
2667        self.drop_without_shutdown();
2668        _result
2669    }
2670
2671    /// Similar to "send" but does not shutdown the channel if an error occurs.
2672    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2673        let _result = self.send_raw(result);
2674        self.drop_without_shutdown();
2675        _result
2676    }
2677
2678    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2679        self.control_handle
2680            .inner
2681            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2682                result,
2683                self.tx_id,
2684                0x294f89fe62a18857,
2685                fidl::encoding::DynamicFlags::empty(),
2686            )
2687    }
2688}
2689
2690#[must_use = "FIDL methods require a response to be sent"]
2691#[derive(Debug)]
2692pub struct FakeClockControlResumeWithIncrementsResponder {
2693    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2694    tx_id: u32,
2695}
2696
2697/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2698/// if the responder is dropped without sending a response, so that the client
2699/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2700impl std::ops::Drop for FakeClockControlResumeWithIncrementsResponder {
2701    fn drop(&mut self) {
2702        self.control_handle.shutdown();
2703        // Safety: drops once, never accessed again
2704        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2705    }
2706}
2707
2708impl fidl::endpoints::Responder for FakeClockControlResumeWithIncrementsResponder {
2709    type ControlHandle = FakeClockControlControlHandle;
2710
2711    fn control_handle(&self) -> &FakeClockControlControlHandle {
2712        &self.control_handle
2713    }
2714
2715    fn drop_without_shutdown(mut self) {
2716        // Safety: drops once, never accessed again due to mem::forget
2717        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2718        // Prevent Drop from running (which would shut down the channel)
2719        std::mem::forget(self);
2720    }
2721}
2722
2723impl FakeClockControlResumeWithIncrementsResponder {
2724    /// Sends a response to the FIDL transaction.
2725    ///
2726    /// Sets the channel to shutdown if an error occurs.
2727    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2728        let _result = self.send_raw(result);
2729        if _result.is_err() {
2730            self.control_handle.shutdown();
2731        }
2732        self.drop_without_shutdown();
2733        _result
2734    }
2735
2736    /// Similar to "send" but does not shutdown the channel if an error occurs.
2737    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2738        let _result = self.send_raw(result);
2739        self.drop_without_shutdown();
2740        _result
2741    }
2742
2743    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2744        self.control_handle
2745            .inner
2746            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2747                result,
2748                self.tx_id,
2749                0x259be1eeba0bdd4a,
2750                fidl::encoding::DynamicFlags::empty(),
2751            )
2752    }
2753}
2754
2755#[must_use = "FIDL methods require a response to be sent"]
2756#[derive(Debug)]
2757pub struct FakeClockControlAddStopPointResponder {
2758    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2759    tx_id: u32,
2760}
2761
2762/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2763/// if the responder is dropped without sending a response, so that the client
2764/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2765impl std::ops::Drop for FakeClockControlAddStopPointResponder {
2766    fn drop(&mut self) {
2767        self.control_handle.shutdown();
2768        // Safety: drops once, never accessed again
2769        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2770    }
2771}
2772
2773impl fidl::endpoints::Responder for FakeClockControlAddStopPointResponder {
2774    type ControlHandle = FakeClockControlControlHandle;
2775
2776    fn control_handle(&self) -> &FakeClockControlControlHandle {
2777        &self.control_handle
2778    }
2779
2780    fn drop_without_shutdown(mut self) {
2781        // Safety: drops once, never accessed again due to mem::forget
2782        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2783        // Prevent Drop from running (which would shut down the channel)
2784        std::mem::forget(self);
2785    }
2786}
2787
2788impl FakeClockControlAddStopPointResponder {
2789    /// Sends a response to the FIDL transaction.
2790    ///
2791    /// Sets the channel to shutdown if an error occurs.
2792    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2793        let _result = self.send_raw(result);
2794        if _result.is_err() {
2795            self.control_handle.shutdown();
2796        }
2797        self.drop_without_shutdown();
2798        _result
2799    }
2800
2801    /// Similar to "send" but does not shutdown the channel if an error occurs.
2802    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2803        let _result = self.send_raw(result);
2804        self.drop_without_shutdown();
2805        _result
2806    }
2807
2808    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2809        self.control_handle
2810            .inner
2811            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2812                result,
2813                self.tx_id,
2814                0x3b52fe2cba8c4245,
2815                fidl::encoding::DynamicFlags::empty(),
2816            )
2817    }
2818}
2819
2820#[must_use = "FIDL methods require a response to be sent"]
2821#[derive(Debug)]
2822pub struct FakeClockControlPauseResponder {
2823    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2824    tx_id: u32,
2825}
2826
2827/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2828/// if the responder is dropped without sending a response, so that the client
2829/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2830impl std::ops::Drop for FakeClockControlPauseResponder {
2831    fn drop(&mut self) {
2832        self.control_handle.shutdown();
2833        // Safety: drops once, never accessed again
2834        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2835    }
2836}
2837
2838impl fidl::endpoints::Responder for FakeClockControlPauseResponder {
2839    type ControlHandle = FakeClockControlControlHandle;
2840
2841    fn control_handle(&self) -> &FakeClockControlControlHandle {
2842        &self.control_handle
2843    }
2844
2845    fn drop_without_shutdown(mut self) {
2846        // Safety: drops once, never accessed again due to mem::forget
2847        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2848        // Prevent Drop from running (which would shut down the channel)
2849        std::mem::forget(self);
2850    }
2851}
2852
2853impl FakeClockControlPauseResponder {
2854    /// Sends a response to the FIDL transaction.
2855    ///
2856    /// Sets the channel to shutdown if an error occurs.
2857    pub fn send(self) -> Result<(), fidl::Error> {
2858        let _result = self.send_raw();
2859        if _result.is_err() {
2860            self.control_handle.shutdown();
2861        }
2862        self.drop_without_shutdown();
2863        _result
2864    }
2865
2866    /// Similar to "send" but does not shutdown the channel if an error occurs.
2867    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2868        let _result = self.send_raw();
2869        self.drop_without_shutdown();
2870        _result
2871    }
2872
2873    fn send_raw(&self) -> Result<(), fidl::Error> {
2874        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2875            (),
2876            self.tx_id,
2877            0x260df03b49199ba4,
2878            fidl::encoding::DynamicFlags::empty(),
2879        )
2880    }
2881}
2882
2883#[must_use = "FIDL methods require a response to be sent"]
2884#[derive(Debug)]
2885pub struct FakeClockControlIgnoreNamedDeadlineResponder {
2886    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2887    tx_id: u32,
2888}
2889
2890/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2891/// if the responder is dropped without sending a response, so that the client
2892/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2893impl std::ops::Drop for FakeClockControlIgnoreNamedDeadlineResponder {
2894    fn drop(&mut self) {
2895        self.control_handle.shutdown();
2896        // Safety: drops once, never accessed again
2897        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2898    }
2899}
2900
2901impl fidl::endpoints::Responder for FakeClockControlIgnoreNamedDeadlineResponder {
2902    type ControlHandle = FakeClockControlControlHandle;
2903
2904    fn control_handle(&self) -> &FakeClockControlControlHandle {
2905        &self.control_handle
2906    }
2907
2908    fn drop_without_shutdown(mut self) {
2909        // Safety: drops once, never accessed again due to mem::forget
2910        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2911        // Prevent Drop from running (which would shut down the channel)
2912        std::mem::forget(self);
2913    }
2914}
2915
2916impl FakeClockControlIgnoreNamedDeadlineResponder {
2917    /// Sends a response to the FIDL transaction.
2918    ///
2919    /// Sets the channel to shutdown if an error occurs.
2920    pub fn send(self) -> Result<(), fidl::Error> {
2921        let _result = self.send_raw();
2922        if _result.is_err() {
2923            self.control_handle.shutdown();
2924        }
2925        self.drop_without_shutdown();
2926        _result
2927    }
2928
2929    /// Similar to "send" but does not shutdown the channel if an error occurs.
2930    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2931        let _result = self.send_raw();
2932        self.drop_without_shutdown();
2933        _result
2934    }
2935
2936    fn send_raw(&self) -> Result<(), fidl::Error> {
2937        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2938            (),
2939            self.tx_id,
2940            0x2e445152a80d44aa,
2941            fidl::encoding::DynamicFlags::empty(),
2942        )
2943    }
2944}
2945
2946mod internal {
2947    use super::*;
2948
2949    impl fidl::encoding::ResourceTypeMarker for FakeClockCancelEventRequest {
2950        type Borrowed<'a> = &'a mut Self;
2951        fn take_or_borrow<'a>(
2952            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2953        ) -> Self::Borrowed<'a> {
2954            value
2955        }
2956    }
2957
2958    unsafe impl fidl::encoding::TypeMarker for FakeClockCancelEventRequest {
2959        type Owned = Self;
2960
2961        #[inline(always)]
2962        fn inline_align(_context: fidl::encoding::Context) -> usize {
2963            4
2964        }
2965
2966        #[inline(always)]
2967        fn inline_size(_context: fidl::encoding::Context) -> usize {
2968            4
2969        }
2970    }
2971
2972    unsafe impl
2973        fidl::encoding::Encode<
2974            FakeClockCancelEventRequest,
2975            fidl::encoding::DefaultFuchsiaResourceDialect,
2976        > for &mut FakeClockCancelEventRequest
2977    {
2978        #[inline]
2979        unsafe fn encode(
2980            self,
2981            encoder: &mut fidl::encoding::Encoder<
2982                '_,
2983                fidl::encoding::DefaultFuchsiaResourceDialect,
2984            >,
2985            offset: usize,
2986            _depth: fidl::encoding::Depth,
2987        ) -> fidl::Result<()> {
2988            encoder.debug_check_bounds::<FakeClockCancelEventRequest>(offset);
2989            // Delegate to tuple encoding.
2990            fidl::encoding::Encode::<
2991                FakeClockCancelEventRequest,
2992                fidl::encoding::DefaultFuchsiaResourceDialect,
2993            >::encode(
2994                (<fidl::encoding::HandleType<
2995                    fidl::EventPair,
2996                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2997                    2147483648,
2998                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2999                    &mut self.event
3000                ),),
3001                encoder,
3002                offset,
3003                _depth,
3004            )
3005        }
3006    }
3007    unsafe impl<
3008        T0: fidl::encoding::Encode<
3009                fidl::encoding::HandleType<
3010                    fidl::EventPair,
3011                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3012                    2147483648,
3013                >,
3014                fidl::encoding::DefaultFuchsiaResourceDialect,
3015            >,
3016    >
3017        fidl::encoding::Encode<
3018            FakeClockCancelEventRequest,
3019            fidl::encoding::DefaultFuchsiaResourceDialect,
3020        > for (T0,)
3021    {
3022        #[inline]
3023        unsafe fn encode(
3024            self,
3025            encoder: &mut fidl::encoding::Encoder<
3026                '_,
3027                fidl::encoding::DefaultFuchsiaResourceDialect,
3028            >,
3029            offset: usize,
3030            depth: fidl::encoding::Depth,
3031        ) -> fidl::Result<()> {
3032            encoder.debug_check_bounds::<FakeClockCancelEventRequest>(offset);
3033            // Zero out padding regions. There's no need to apply masks
3034            // because the unmasked parts will be overwritten by fields.
3035            // Write the fields.
3036            self.0.encode(encoder, offset + 0, depth)?;
3037            Ok(())
3038        }
3039    }
3040
3041    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3042        for FakeClockCancelEventRequest
3043    {
3044        #[inline(always)]
3045        fn new_empty() -> Self {
3046            Self {
3047                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3048            }
3049        }
3050
3051        #[inline]
3052        unsafe fn decode(
3053            &mut self,
3054            decoder: &mut fidl::encoding::Decoder<
3055                '_,
3056                fidl::encoding::DefaultFuchsiaResourceDialect,
3057            >,
3058            offset: usize,
3059            _depth: fidl::encoding::Depth,
3060        ) -> fidl::Result<()> {
3061            decoder.debug_check_bounds::<Self>(offset);
3062            // Verify that padding bytes are zero.
3063            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3064            Ok(())
3065        }
3066    }
3067
3068    impl fidl::encoding::ResourceTypeMarker for FakeClockControlAddStopPointRequest {
3069        type Borrowed<'a> = &'a mut Self;
3070        fn take_or_borrow<'a>(
3071            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3072        ) -> Self::Borrowed<'a> {
3073            value
3074        }
3075    }
3076
3077    unsafe impl fidl::encoding::TypeMarker for FakeClockControlAddStopPointRequest {
3078        type Owned = Self;
3079
3080        #[inline(always)]
3081        fn inline_align(_context: fidl::encoding::Context) -> usize {
3082            8
3083        }
3084
3085        #[inline(always)]
3086        fn inline_size(_context: fidl::encoding::Context) -> usize {
3087            40
3088        }
3089    }
3090
3091    unsafe impl
3092        fidl::encoding::Encode<
3093            FakeClockControlAddStopPointRequest,
3094            fidl::encoding::DefaultFuchsiaResourceDialect,
3095        > for &mut FakeClockControlAddStopPointRequest
3096    {
3097        #[inline]
3098        unsafe fn encode(
3099            self,
3100            encoder: &mut fidl::encoding::Encoder<
3101                '_,
3102                fidl::encoding::DefaultFuchsiaResourceDialect,
3103            >,
3104            offset: usize,
3105            _depth: fidl::encoding::Depth,
3106        ) -> fidl::Result<()> {
3107            encoder.debug_check_bounds::<FakeClockControlAddStopPointRequest>(offset);
3108            // Delegate to tuple encoding.
3109            fidl::encoding::Encode::<FakeClockControlAddStopPointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3110                (
3111                    <fidl_fuchsia_testing_deadline::DeadlineId as fidl::encoding::ValueTypeMarker>::borrow(&self.deadline_id),
3112                    <DeadlineEventType as fidl::encoding::ValueTypeMarker>::borrow(&self.event_type),
3113                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.on_stop),
3114                ),
3115                encoder, offset, _depth
3116            )
3117        }
3118    }
3119    unsafe impl<
3120        T0: fidl::encoding::Encode<
3121                fidl_fuchsia_testing_deadline::DeadlineId,
3122                fidl::encoding::DefaultFuchsiaResourceDialect,
3123            >,
3124        T1: fidl::encoding::Encode<DeadlineEventType, fidl::encoding::DefaultFuchsiaResourceDialect>,
3125        T2: fidl::encoding::Encode<
3126                fidl::encoding::HandleType<
3127                    fidl::EventPair,
3128                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3129                    2147483648,
3130                >,
3131                fidl::encoding::DefaultFuchsiaResourceDialect,
3132            >,
3133    >
3134        fidl::encoding::Encode<
3135            FakeClockControlAddStopPointRequest,
3136            fidl::encoding::DefaultFuchsiaResourceDialect,
3137        > for (T0, T1, T2)
3138    {
3139        #[inline]
3140        unsafe fn encode(
3141            self,
3142            encoder: &mut fidl::encoding::Encoder<
3143                '_,
3144                fidl::encoding::DefaultFuchsiaResourceDialect,
3145            >,
3146            offset: usize,
3147            depth: fidl::encoding::Depth,
3148        ) -> fidl::Result<()> {
3149            encoder.debug_check_bounds::<FakeClockControlAddStopPointRequest>(offset);
3150            // Zero out padding regions. There's no need to apply masks
3151            // because the unmasked parts will be overwritten by fields.
3152            // Write the fields.
3153            self.0.encode(encoder, offset + 0, depth)?;
3154            self.1.encode(encoder, offset + 32, depth)?;
3155            self.2.encode(encoder, offset + 36, depth)?;
3156            Ok(())
3157        }
3158    }
3159
3160    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3161        for FakeClockControlAddStopPointRequest
3162    {
3163        #[inline(always)]
3164        fn new_empty() -> Self {
3165            Self {
3166                deadline_id: fidl::new_empty!(
3167                    fidl_fuchsia_testing_deadline::DeadlineId,
3168                    fidl::encoding::DefaultFuchsiaResourceDialect
3169                ),
3170                event_type: fidl::new_empty!(
3171                    DeadlineEventType,
3172                    fidl::encoding::DefaultFuchsiaResourceDialect
3173                ),
3174                on_stop: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3175            }
3176        }
3177
3178        #[inline]
3179        unsafe fn decode(
3180            &mut self,
3181            decoder: &mut fidl::encoding::Decoder<
3182                '_,
3183                fidl::encoding::DefaultFuchsiaResourceDialect,
3184            >,
3185            offset: usize,
3186            _depth: fidl::encoding::Depth,
3187        ) -> fidl::Result<()> {
3188            decoder.debug_check_bounds::<Self>(offset);
3189            // Verify that padding bytes are zero.
3190            fidl::decode!(
3191                fidl_fuchsia_testing_deadline::DeadlineId,
3192                fidl::encoding::DefaultFuchsiaResourceDialect,
3193                &mut self.deadline_id,
3194                decoder,
3195                offset + 0,
3196                _depth
3197            )?;
3198            fidl::decode!(
3199                DeadlineEventType,
3200                fidl::encoding::DefaultFuchsiaResourceDialect,
3201                &mut self.event_type,
3202                decoder,
3203                offset + 32,
3204                _depth
3205            )?;
3206            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.on_stop, decoder, offset + 36, _depth)?;
3207            Ok(())
3208        }
3209    }
3210
3211    impl fidl::encoding::ResourceTypeMarker for FakeClockRegisterEventInBootRequest {
3212        type Borrowed<'a> = &'a mut Self;
3213        fn take_or_borrow<'a>(
3214            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3215        ) -> Self::Borrowed<'a> {
3216            value
3217        }
3218    }
3219
3220    unsafe impl fidl::encoding::TypeMarker for FakeClockRegisterEventInBootRequest {
3221        type Owned = Self;
3222
3223        #[inline(always)]
3224        fn inline_align(_context: fidl::encoding::Context) -> usize {
3225            8
3226        }
3227
3228        #[inline(always)]
3229        fn inline_size(_context: fidl::encoding::Context) -> usize {
3230            16
3231        }
3232    }
3233
3234    unsafe impl
3235        fidl::encoding::Encode<
3236            FakeClockRegisterEventInBootRequest,
3237            fidl::encoding::DefaultFuchsiaResourceDialect,
3238        > for &mut FakeClockRegisterEventInBootRequest
3239    {
3240        #[inline]
3241        unsafe fn encode(
3242            self,
3243            encoder: &mut fidl::encoding::Encoder<
3244                '_,
3245                fidl::encoding::DefaultFuchsiaResourceDialect,
3246            >,
3247            offset: usize,
3248            _depth: fidl::encoding::Depth,
3249        ) -> fidl::Result<()> {
3250            encoder.debug_check_bounds::<FakeClockRegisterEventInBootRequest>(offset);
3251            // Delegate to tuple encoding.
3252            fidl::encoding::Encode::<
3253                FakeClockRegisterEventInBootRequest,
3254                fidl::encoding::DefaultFuchsiaResourceDialect,
3255            >::encode(
3256                (
3257                    <fidl::encoding::HandleType<
3258                        fidl::EventPair,
3259                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3260                        2147483648,
3261                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3262                        &mut self.event
3263                    ),
3264                    <fidl::BootInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
3265                ),
3266                encoder,
3267                offset,
3268                _depth,
3269            )
3270        }
3271    }
3272    unsafe impl<
3273        T0: fidl::encoding::Encode<
3274                fidl::encoding::HandleType<
3275                    fidl::EventPair,
3276                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3277                    2147483648,
3278                >,
3279                fidl::encoding::DefaultFuchsiaResourceDialect,
3280            >,
3281        T1: fidl::encoding::Encode<fidl::BootInstant, fidl::encoding::DefaultFuchsiaResourceDialect>,
3282    >
3283        fidl::encoding::Encode<
3284            FakeClockRegisterEventInBootRequest,
3285            fidl::encoding::DefaultFuchsiaResourceDialect,
3286        > for (T0, T1)
3287    {
3288        #[inline]
3289        unsafe fn encode(
3290            self,
3291            encoder: &mut fidl::encoding::Encoder<
3292                '_,
3293                fidl::encoding::DefaultFuchsiaResourceDialect,
3294            >,
3295            offset: usize,
3296            depth: fidl::encoding::Depth,
3297        ) -> fidl::Result<()> {
3298            encoder.debug_check_bounds::<FakeClockRegisterEventInBootRequest>(offset);
3299            // Zero out padding regions. There's no need to apply masks
3300            // because the unmasked parts will be overwritten by fields.
3301            unsafe {
3302                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3303                (ptr as *mut u64).write_unaligned(0);
3304            }
3305            // Write the fields.
3306            self.0.encode(encoder, offset + 0, depth)?;
3307            self.1.encode(encoder, offset + 8, depth)?;
3308            Ok(())
3309        }
3310    }
3311
3312    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3313        for FakeClockRegisterEventInBootRequest
3314    {
3315        #[inline(always)]
3316        fn new_empty() -> Self {
3317            Self {
3318                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3319                time: fidl::new_empty!(
3320                    fidl::BootInstant,
3321                    fidl::encoding::DefaultFuchsiaResourceDialect
3322                ),
3323            }
3324        }
3325
3326        #[inline]
3327        unsafe fn decode(
3328            &mut self,
3329            decoder: &mut fidl::encoding::Decoder<
3330                '_,
3331                fidl::encoding::DefaultFuchsiaResourceDialect,
3332            >,
3333            offset: usize,
3334            _depth: fidl::encoding::Depth,
3335        ) -> fidl::Result<()> {
3336            decoder.debug_check_bounds::<Self>(offset);
3337            // Verify that padding bytes are zero.
3338            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3339            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3340            let mask = 0xffffffff00000000u64;
3341            let maskedval = padval & mask;
3342            if maskedval != 0 {
3343                return Err(fidl::Error::NonZeroPadding {
3344                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3345                });
3346            }
3347            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3348            fidl::decode!(
3349                fidl::BootInstant,
3350                fidl::encoding::DefaultFuchsiaResourceDialect,
3351                &mut self.time,
3352                decoder,
3353                offset + 8,
3354                _depth
3355            )?;
3356            Ok(())
3357        }
3358    }
3359
3360    impl fidl::encoding::ResourceTypeMarker for FakeClockRegisterEventInMonotonicRequest {
3361        type Borrowed<'a> = &'a mut Self;
3362        fn take_or_borrow<'a>(
3363            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3364        ) -> Self::Borrowed<'a> {
3365            value
3366        }
3367    }
3368
3369    unsafe impl fidl::encoding::TypeMarker for FakeClockRegisterEventInMonotonicRequest {
3370        type Owned = Self;
3371
3372        #[inline(always)]
3373        fn inline_align(_context: fidl::encoding::Context) -> usize {
3374            8
3375        }
3376
3377        #[inline(always)]
3378        fn inline_size(_context: fidl::encoding::Context) -> usize {
3379            16
3380        }
3381    }
3382
3383    unsafe impl
3384        fidl::encoding::Encode<
3385            FakeClockRegisterEventInMonotonicRequest,
3386            fidl::encoding::DefaultFuchsiaResourceDialect,
3387        > for &mut FakeClockRegisterEventInMonotonicRequest
3388    {
3389        #[inline]
3390        unsafe fn encode(
3391            self,
3392            encoder: &mut fidl::encoding::Encoder<
3393                '_,
3394                fidl::encoding::DefaultFuchsiaResourceDialect,
3395            >,
3396            offset: usize,
3397            _depth: fidl::encoding::Depth,
3398        ) -> fidl::Result<()> {
3399            encoder.debug_check_bounds::<FakeClockRegisterEventInMonotonicRequest>(offset);
3400            // Delegate to tuple encoding.
3401            fidl::encoding::Encode::<
3402                FakeClockRegisterEventInMonotonicRequest,
3403                fidl::encoding::DefaultFuchsiaResourceDialect,
3404            >::encode(
3405                (
3406                    <fidl::encoding::HandleType<
3407                        fidl::EventPair,
3408                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3409                        2147483648,
3410                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3411                        &mut self.event
3412                    ),
3413                    <fidl::MonotonicInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
3414                ),
3415                encoder,
3416                offset,
3417                _depth,
3418            )
3419        }
3420    }
3421    unsafe impl<
3422        T0: fidl::encoding::Encode<
3423                fidl::encoding::HandleType<
3424                    fidl::EventPair,
3425                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3426                    2147483648,
3427                >,
3428                fidl::encoding::DefaultFuchsiaResourceDialect,
3429            >,
3430        T1: fidl::encoding::Encode<
3431                fidl::MonotonicInstant,
3432                fidl::encoding::DefaultFuchsiaResourceDialect,
3433            >,
3434    >
3435        fidl::encoding::Encode<
3436            FakeClockRegisterEventInMonotonicRequest,
3437            fidl::encoding::DefaultFuchsiaResourceDialect,
3438        > for (T0, T1)
3439    {
3440        #[inline]
3441        unsafe fn encode(
3442            self,
3443            encoder: &mut fidl::encoding::Encoder<
3444                '_,
3445                fidl::encoding::DefaultFuchsiaResourceDialect,
3446            >,
3447            offset: usize,
3448            depth: fidl::encoding::Depth,
3449        ) -> fidl::Result<()> {
3450            encoder.debug_check_bounds::<FakeClockRegisterEventInMonotonicRequest>(offset);
3451            // Zero out padding regions. There's no need to apply masks
3452            // because the unmasked parts will be overwritten by fields.
3453            unsafe {
3454                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3455                (ptr as *mut u64).write_unaligned(0);
3456            }
3457            // Write the fields.
3458            self.0.encode(encoder, offset + 0, depth)?;
3459            self.1.encode(encoder, offset + 8, depth)?;
3460            Ok(())
3461        }
3462    }
3463
3464    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3465        for FakeClockRegisterEventInMonotonicRequest
3466    {
3467        #[inline(always)]
3468        fn new_empty() -> Self {
3469            Self {
3470                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3471                time: fidl::new_empty!(
3472                    fidl::MonotonicInstant,
3473                    fidl::encoding::DefaultFuchsiaResourceDialect
3474                ),
3475            }
3476        }
3477
3478        #[inline]
3479        unsafe fn decode(
3480            &mut self,
3481            decoder: &mut fidl::encoding::Decoder<
3482                '_,
3483                fidl::encoding::DefaultFuchsiaResourceDialect,
3484            >,
3485            offset: usize,
3486            _depth: fidl::encoding::Depth,
3487        ) -> fidl::Result<()> {
3488            decoder.debug_check_bounds::<Self>(offset);
3489            // Verify that padding bytes are zero.
3490            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3491            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3492            let mask = 0xffffffff00000000u64;
3493            let maskedval = padval & mask;
3494            if maskedval != 0 {
3495                return Err(fidl::Error::NonZeroPadding {
3496                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3497                });
3498            }
3499            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3500            fidl::decode!(
3501                fidl::MonotonicInstant,
3502                fidl::encoding::DefaultFuchsiaResourceDialect,
3503                &mut self.time,
3504                decoder,
3505                offset + 8,
3506                _depth
3507            )?;
3508            Ok(())
3509        }
3510    }
3511
3512    impl fidl::encoding::ResourceTypeMarker for FakeClockRescheduleEventInBootRequest {
3513        type Borrowed<'a> = &'a mut Self;
3514        fn take_or_borrow<'a>(
3515            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3516        ) -> Self::Borrowed<'a> {
3517            value
3518        }
3519    }
3520
3521    unsafe impl fidl::encoding::TypeMarker for FakeClockRescheduleEventInBootRequest {
3522        type Owned = Self;
3523
3524        #[inline(always)]
3525        fn inline_align(_context: fidl::encoding::Context) -> usize {
3526            8
3527        }
3528
3529        #[inline(always)]
3530        fn inline_size(_context: fidl::encoding::Context) -> usize {
3531            16
3532        }
3533    }
3534
3535    unsafe impl
3536        fidl::encoding::Encode<
3537            FakeClockRescheduleEventInBootRequest,
3538            fidl::encoding::DefaultFuchsiaResourceDialect,
3539        > for &mut FakeClockRescheduleEventInBootRequest
3540    {
3541        #[inline]
3542        unsafe fn encode(
3543            self,
3544            encoder: &mut fidl::encoding::Encoder<
3545                '_,
3546                fidl::encoding::DefaultFuchsiaResourceDialect,
3547            >,
3548            offset: usize,
3549            _depth: fidl::encoding::Depth,
3550        ) -> fidl::Result<()> {
3551            encoder.debug_check_bounds::<FakeClockRescheduleEventInBootRequest>(offset);
3552            // Delegate to tuple encoding.
3553            fidl::encoding::Encode::<
3554                FakeClockRescheduleEventInBootRequest,
3555                fidl::encoding::DefaultFuchsiaResourceDialect,
3556            >::encode(
3557                (
3558                    <fidl::encoding::HandleType<
3559                        fidl::EventPair,
3560                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3561                        2147483648,
3562                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3563                        &mut self.event
3564                    ),
3565                    <fidl::BootInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
3566                ),
3567                encoder,
3568                offset,
3569                _depth,
3570            )
3571        }
3572    }
3573    unsafe impl<
3574        T0: fidl::encoding::Encode<
3575                fidl::encoding::HandleType<
3576                    fidl::EventPair,
3577                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3578                    2147483648,
3579                >,
3580                fidl::encoding::DefaultFuchsiaResourceDialect,
3581            >,
3582        T1: fidl::encoding::Encode<fidl::BootInstant, fidl::encoding::DefaultFuchsiaResourceDialect>,
3583    >
3584        fidl::encoding::Encode<
3585            FakeClockRescheduleEventInBootRequest,
3586            fidl::encoding::DefaultFuchsiaResourceDialect,
3587        > for (T0, T1)
3588    {
3589        #[inline]
3590        unsafe fn encode(
3591            self,
3592            encoder: &mut fidl::encoding::Encoder<
3593                '_,
3594                fidl::encoding::DefaultFuchsiaResourceDialect,
3595            >,
3596            offset: usize,
3597            depth: fidl::encoding::Depth,
3598        ) -> fidl::Result<()> {
3599            encoder.debug_check_bounds::<FakeClockRescheduleEventInBootRequest>(offset);
3600            // Zero out padding regions. There's no need to apply masks
3601            // because the unmasked parts will be overwritten by fields.
3602            unsafe {
3603                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3604                (ptr as *mut u64).write_unaligned(0);
3605            }
3606            // Write the fields.
3607            self.0.encode(encoder, offset + 0, depth)?;
3608            self.1.encode(encoder, offset + 8, depth)?;
3609            Ok(())
3610        }
3611    }
3612
3613    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3614        for FakeClockRescheduleEventInBootRequest
3615    {
3616        #[inline(always)]
3617        fn new_empty() -> Self {
3618            Self {
3619                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3620                time: fidl::new_empty!(
3621                    fidl::BootInstant,
3622                    fidl::encoding::DefaultFuchsiaResourceDialect
3623                ),
3624            }
3625        }
3626
3627        #[inline]
3628        unsafe fn decode(
3629            &mut self,
3630            decoder: &mut fidl::encoding::Decoder<
3631                '_,
3632                fidl::encoding::DefaultFuchsiaResourceDialect,
3633            >,
3634            offset: usize,
3635            _depth: fidl::encoding::Depth,
3636        ) -> fidl::Result<()> {
3637            decoder.debug_check_bounds::<Self>(offset);
3638            // Verify that padding bytes are zero.
3639            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3640            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3641            let mask = 0xffffffff00000000u64;
3642            let maskedval = padval & mask;
3643            if maskedval != 0 {
3644                return Err(fidl::Error::NonZeroPadding {
3645                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3646                });
3647            }
3648            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3649            fidl::decode!(
3650                fidl::BootInstant,
3651                fidl::encoding::DefaultFuchsiaResourceDialect,
3652                &mut self.time,
3653                decoder,
3654                offset + 8,
3655                _depth
3656            )?;
3657            Ok(())
3658        }
3659    }
3660
3661    impl fidl::encoding::ResourceTypeMarker for FakeClockRescheduleEventInMonotonicRequest {
3662        type Borrowed<'a> = &'a mut Self;
3663        fn take_or_borrow<'a>(
3664            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3665        ) -> Self::Borrowed<'a> {
3666            value
3667        }
3668    }
3669
3670    unsafe impl fidl::encoding::TypeMarker for FakeClockRescheduleEventInMonotonicRequest {
3671        type Owned = Self;
3672
3673        #[inline(always)]
3674        fn inline_align(_context: fidl::encoding::Context) -> usize {
3675            8
3676        }
3677
3678        #[inline(always)]
3679        fn inline_size(_context: fidl::encoding::Context) -> usize {
3680            16
3681        }
3682    }
3683
3684    unsafe impl
3685        fidl::encoding::Encode<
3686            FakeClockRescheduleEventInMonotonicRequest,
3687            fidl::encoding::DefaultFuchsiaResourceDialect,
3688        > for &mut FakeClockRescheduleEventInMonotonicRequest
3689    {
3690        #[inline]
3691        unsafe fn encode(
3692            self,
3693            encoder: &mut fidl::encoding::Encoder<
3694                '_,
3695                fidl::encoding::DefaultFuchsiaResourceDialect,
3696            >,
3697            offset: usize,
3698            _depth: fidl::encoding::Depth,
3699        ) -> fidl::Result<()> {
3700            encoder.debug_check_bounds::<FakeClockRescheduleEventInMonotonicRequest>(offset);
3701            // Delegate to tuple encoding.
3702            fidl::encoding::Encode::<
3703                FakeClockRescheduleEventInMonotonicRequest,
3704                fidl::encoding::DefaultFuchsiaResourceDialect,
3705            >::encode(
3706                (
3707                    <fidl::encoding::HandleType<
3708                        fidl::EventPair,
3709                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3710                        2147483648,
3711                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3712                        &mut self.event
3713                    ),
3714                    <fidl::MonotonicInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
3715                ),
3716                encoder,
3717                offset,
3718                _depth,
3719            )
3720        }
3721    }
3722    unsafe impl<
3723        T0: fidl::encoding::Encode<
3724                fidl::encoding::HandleType<
3725                    fidl::EventPair,
3726                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3727                    2147483648,
3728                >,
3729                fidl::encoding::DefaultFuchsiaResourceDialect,
3730            >,
3731        T1: fidl::encoding::Encode<
3732                fidl::MonotonicInstant,
3733                fidl::encoding::DefaultFuchsiaResourceDialect,
3734            >,
3735    >
3736        fidl::encoding::Encode<
3737            FakeClockRescheduleEventInMonotonicRequest,
3738            fidl::encoding::DefaultFuchsiaResourceDialect,
3739        > for (T0, T1)
3740    {
3741        #[inline]
3742        unsafe fn encode(
3743            self,
3744            encoder: &mut fidl::encoding::Encoder<
3745                '_,
3746                fidl::encoding::DefaultFuchsiaResourceDialect,
3747            >,
3748            offset: usize,
3749            depth: fidl::encoding::Depth,
3750        ) -> fidl::Result<()> {
3751            encoder.debug_check_bounds::<FakeClockRescheduleEventInMonotonicRequest>(offset);
3752            // Zero out padding regions. There's no need to apply masks
3753            // because the unmasked parts will be overwritten by fields.
3754            unsafe {
3755                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3756                (ptr as *mut u64).write_unaligned(0);
3757            }
3758            // Write the fields.
3759            self.0.encode(encoder, offset + 0, depth)?;
3760            self.1.encode(encoder, offset + 8, depth)?;
3761            Ok(())
3762        }
3763    }
3764
3765    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3766        for FakeClockRescheduleEventInMonotonicRequest
3767    {
3768        #[inline(always)]
3769        fn new_empty() -> Self {
3770            Self {
3771                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3772                time: fidl::new_empty!(
3773                    fidl::MonotonicInstant,
3774                    fidl::encoding::DefaultFuchsiaResourceDialect
3775                ),
3776            }
3777        }
3778
3779        #[inline]
3780        unsafe fn decode(
3781            &mut self,
3782            decoder: &mut fidl::encoding::Decoder<
3783                '_,
3784                fidl::encoding::DefaultFuchsiaResourceDialect,
3785            >,
3786            offset: usize,
3787            _depth: fidl::encoding::Depth,
3788        ) -> fidl::Result<()> {
3789            decoder.debug_check_bounds::<Self>(offset);
3790            // Verify that padding bytes are zero.
3791            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3792            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3793            let mask = 0xffffffff00000000u64;
3794            let maskedval = padval & mask;
3795            if maskedval != 0 {
3796                return Err(fidl::Error::NonZeroPadding {
3797                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3798                });
3799            }
3800            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3801            fidl::decode!(
3802                fidl::MonotonicInstant,
3803                fidl::encoding::DefaultFuchsiaResourceDialect,
3804                &mut self.time,
3805                decoder,
3806                offset + 8,
3807                _depth
3808            )?;
3809            Ok(())
3810        }
3811    }
3812}