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::NullableHandle {
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
1162    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1163        self.inner.shutdown_with_epitaph(status)
1164    }
1165
1166    fn is_closed(&self) -> bool {
1167        self.inner.channel().is_closed()
1168    }
1169    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1170        self.inner.channel().on_closed()
1171    }
1172
1173    #[cfg(target_os = "fuchsia")]
1174    fn signal_peer(
1175        &self,
1176        clear_mask: zx::Signals,
1177        set_mask: zx::Signals,
1178    ) -> Result<(), zx_status::Status> {
1179        use fidl::Peered;
1180        self.inner.channel().signal_peer(clear_mask, set_mask)
1181    }
1182}
1183
1184impl FakeClockControlHandle {}
1185
1186#[must_use = "FIDL methods require a response to be sent"]
1187#[derive(Debug)]
1188pub struct FakeClockGetResponder {
1189    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1190    tx_id: u32,
1191}
1192
1193/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1194/// if the responder is dropped without sending a response, so that the client
1195/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1196impl std::ops::Drop for FakeClockGetResponder {
1197    fn drop(&mut self) {
1198        self.control_handle.shutdown();
1199        // Safety: drops once, never accessed again
1200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1201    }
1202}
1203
1204impl fidl::endpoints::Responder for FakeClockGetResponder {
1205    type ControlHandle = FakeClockControlHandle;
1206
1207    fn control_handle(&self) -> &FakeClockControlHandle {
1208        &self.control_handle
1209    }
1210
1211    fn drop_without_shutdown(mut self) {
1212        // Safety: drops once, never accessed again due to mem::forget
1213        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1214        // Prevent Drop from running (which would shut down the channel)
1215        std::mem::forget(self);
1216    }
1217}
1218
1219impl FakeClockGetResponder {
1220    /// Sends a response to the FIDL transaction.
1221    ///
1222    /// Sets the channel to shutdown if an error occurs.
1223    pub fn send(
1224        self,
1225        mut boot_time: fidl::BootInstant,
1226        mut monotonic_time: fidl::MonotonicInstant,
1227    ) -> Result<(), fidl::Error> {
1228        let _result = self.send_raw(boot_time, monotonic_time);
1229        if _result.is_err() {
1230            self.control_handle.shutdown();
1231        }
1232        self.drop_without_shutdown();
1233        _result
1234    }
1235
1236    /// Similar to "send" but does not shutdown the channel if an error occurs.
1237    pub fn send_no_shutdown_on_err(
1238        self,
1239        mut boot_time: fidl::BootInstant,
1240        mut monotonic_time: fidl::MonotonicInstant,
1241    ) -> Result<(), fidl::Error> {
1242        let _result = self.send_raw(boot_time, monotonic_time);
1243        self.drop_without_shutdown();
1244        _result
1245    }
1246
1247    fn send_raw(
1248        &self,
1249        mut boot_time: fidl::BootInstant,
1250        mut monotonic_time: fidl::MonotonicInstant,
1251    ) -> Result<(), fidl::Error> {
1252        self.control_handle.inner.send::<FakeClockGetResponse>(
1253            (boot_time, monotonic_time),
1254            self.tx_id,
1255            0x2a08c060e0b95e7c,
1256            fidl::encoding::DynamicFlags::empty(),
1257        )
1258    }
1259}
1260
1261#[must_use = "FIDL methods require a response to be sent"]
1262#[derive(Debug)]
1263pub struct FakeClockRescheduleEventInMonotonicResponder {
1264    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1265    tx_id: u32,
1266}
1267
1268/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1269/// if the responder is dropped without sending a response, so that the client
1270/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1271impl std::ops::Drop for FakeClockRescheduleEventInMonotonicResponder {
1272    fn drop(&mut self) {
1273        self.control_handle.shutdown();
1274        // Safety: drops once, never accessed again
1275        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1276    }
1277}
1278
1279impl fidl::endpoints::Responder for FakeClockRescheduleEventInMonotonicResponder {
1280    type ControlHandle = FakeClockControlHandle;
1281
1282    fn control_handle(&self) -> &FakeClockControlHandle {
1283        &self.control_handle
1284    }
1285
1286    fn drop_without_shutdown(mut self) {
1287        // Safety: drops once, never accessed again due to mem::forget
1288        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1289        // Prevent Drop from running (which would shut down the channel)
1290        std::mem::forget(self);
1291    }
1292}
1293
1294impl FakeClockRescheduleEventInMonotonicResponder {
1295    /// Sends a response to the FIDL transaction.
1296    ///
1297    /// Sets the channel to shutdown if an error occurs.
1298    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1299        let _result = self.send_raw(result);
1300        if _result.is_err() {
1301            self.control_handle.shutdown();
1302        }
1303        self.drop_without_shutdown();
1304        _result
1305    }
1306
1307    /// Similar to "send" but does not shutdown the channel if an error occurs.
1308    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1309        let _result = self.send_raw(result);
1310        self.drop_without_shutdown();
1311        _result
1312    }
1313
1314    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1315        self.control_handle
1316            .inner
1317            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1318                result,
1319                self.tx_id,
1320                0x5d35cdbfc1e464ae,
1321                fidl::encoding::DynamicFlags::empty(),
1322            )
1323    }
1324}
1325
1326#[must_use = "FIDL methods require a response to be sent"]
1327#[derive(Debug)]
1328pub struct FakeClockRescheduleEventInBootResponder {
1329    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1330    tx_id: u32,
1331}
1332
1333/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1334/// if the responder is dropped without sending a response, so that the client
1335/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1336impl std::ops::Drop for FakeClockRescheduleEventInBootResponder {
1337    fn drop(&mut self) {
1338        self.control_handle.shutdown();
1339        // Safety: drops once, never accessed again
1340        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1341    }
1342}
1343
1344impl fidl::endpoints::Responder for FakeClockRescheduleEventInBootResponder {
1345    type ControlHandle = FakeClockControlHandle;
1346
1347    fn control_handle(&self) -> &FakeClockControlHandle {
1348        &self.control_handle
1349    }
1350
1351    fn drop_without_shutdown(mut self) {
1352        // Safety: drops once, never accessed again due to mem::forget
1353        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1354        // Prevent Drop from running (which would shut down the channel)
1355        std::mem::forget(self);
1356    }
1357}
1358
1359impl FakeClockRescheduleEventInBootResponder {
1360    /// Sends a response to the FIDL transaction.
1361    ///
1362    /// Sets the channel to shutdown if an error occurs.
1363    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1364        let _result = self.send_raw(result);
1365        if _result.is_err() {
1366            self.control_handle.shutdown();
1367        }
1368        self.drop_without_shutdown();
1369        _result
1370    }
1371
1372    /// Similar to "send" but does not shutdown the channel if an error occurs.
1373    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1374        let _result = self.send_raw(result);
1375        self.drop_without_shutdown();
1376        _result
1377    }
1378
1379    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1380        self.control_handle
1381            .inner
1382            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1383                result,
1384                self.tx_id,
1385                0xdb8b1c8c4732adb,
1386                fidl::encoding::DynamicFlags::empty(),
1387            )
1388    }
1389}
1390
1391#[must_use = "FIDL methods require a response to be sent"]
1392#[derive(Debug)]
1393pub struct FakeClockCancelEventResponder {
1394    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1395    tx_id: u32,
1396}
1397
1398/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1399/// if the responder is dropped without sending a response, so that the client
1400/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1401impl std::ops::Drop for FakeClockCancelEventResponder {
1402    fn drop(&mut self) {
1403        self.control_handle.shutdown();
1404        // Safety: drops once, never accessed again
1405        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1406    }
1407}
1408
1409impl fidl::endpoints::Responder for FakeClockCancelEventResponder {
1410    type ControlHandle = FakeClockControlHandle;
1411
1412    fn control_handle(&self) -> &FakeClockControlHandle {
1413        &self.control_handle
1414    }
1415
1416    fn drop_without_shutdown(mut self) {
1417        // Safety: drops once, never accessed again due to mem::forget
1418        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1419        // Prevent Drop from running (which would shut down the channel)
1420        std::mem::forget(self);
1421    }
1422}
1423
1424impl FakeClockCancelEventResponder {
1425    /// Sends a response to the FIDL transaction.
1426    ///
1427    /// Sets the channel to shutdown if an error occurs.
1428    pub fn send(self) -> Result<(), fidl::Error> {
1429        let _result = self.send_raw();
1430        if _result.is_err() {
1431            self.control_handle.shutdown();
1432        }
1433        self.drop_without_shutdown();
1434        _result
1435    }
1436
1437    /// Similar to "send" but does not shutdown the channel if an error occurs.
1438    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1439        let _result = self.send_raw();
1440        self.drop_without_shutdown();
1441        _result
1442    }
1443
1444    fn send_raw(&self) -> Result<(), fidl::Error> {
1445        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1446            (),
1447            self.tx_id,
1448            0x18bbdb18faa6cac0,
1449            fidl::encoding::DynamicFlags::empty(),
1450        )
1451    }
1452}
1453
1454#[must_use = "FIDL methods require a response to be sent"]
1455#[derive(Debug)]
1456pub struct FakeClockCreateNamedDeadlineInMonotonicResponder {
1457    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1458    tx_id: u32,
1459}
1460
1461/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1462/// if the responder is dropped without sending a response, so that the client
1463/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1464impl std::ops::Drop for FakeClockCreateNamedDeadlineInMonotonicResponder {
1465    fn drop(&mut self) {
1466        self.control_handle.shutdown();
1467        // Safety: drops once, never accessed again
1468        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1469    }
1470}
1471
1472impl fidl::endpoints::Responder for FakeClockCreateNamedDeadlineInMonotonicResponder {
1473    type ControlHandle = FakeClockControlHandle;
1474
1475    fn control_handle(&self) -> &FakeClockControlHandle {
1476        &self.control_handle
1477    }
1478
1479    fn drop_without_shutdown(mut self) {
1480        // Safety: drops once, never accessed again due to mem::forget
1481        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1482        // Prevent Drop from running (which would shut down the channel)
1483        std::mem::forget(self);
1484    }
1485}
1486
1487impl FakeClockCreateNamedDeadlineInMonotonicResponder {
1488    /// Sends a response to the FIDL transaction.
1489    ///
1490    /// Sets the channel to shutdown if an error occurs.
1491    pub fn send(self, mut deadline: fidl::MonotonicInstant) -> Result<(), fidl::Error> {
1492        let _result = self.send_raw(deadline);
1493        if _result.is_err() {
1494            self.control_handle.shutdown();
1495        }
1496        self.drop_without_shutdown();
1497        _result
1498    }
1499
1500    /// Similar to "send" but does not shutdown the channel if an error occurs.
1501    pub fn send_no_shutdown_on_err(
1502        self,
1503        mut deadline: fidl::MonotonicInstant,
1504    ) -> Result<(), fidl::Error> {
1505        let _result = self.send_raw(deadline);
1506        self.drop_without_shutdown();
1507        _result
1508    }
1509
1510    fn send_raw(&self, mut deadline: fidl::MonotonicInstant) -> Result<(), fidl::Error> {
1511        self.control_handle.inner.send::<FakeClockCreateNamedDeadlineInMonotonicResponse>(
1512            (deadline,),
1513            self.tx_id,
1514            0x6ae636f6a0c93b3e,
1515            fidl::encoding::DynamicFlags::empty(),
1516        )
1517    }
1518}
1519
1520#[must_use = "FIDL methods require a response to be sent"]
1521#[derive(Debug)]
1522pub struct FakeClockCreateNamedDeadlineInBootResponder {
1523    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
1524    tx_id: u32,
1525}
1526
1527/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1528/// if the responder is dropped without sending a response, so that the client
1529/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1530impl std::ops::Drop for FakeClockCreateNamedDeadlineInBootResponder {
1531    fn drop(&mut self) {
1532        self.control_handle.shutdown();
1533        // Safety: drops once, never accessed again
1534        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1535    }
1536}
1537
1538impl fidl::endpoints::Responder for FakeClockCreateNamedDeadlineInBootResponder {
1539    type ControlHandle = FakeClockControlHandle;
1540
1541    fn control_handle(&self) -> &FakeClockControlHandle {
1542        &self.control_handle
1543    }
1544
1545    fn drop_without_shutdown(mut self) {
1546        // Safety: drops once, never accessed again due to mem::forget
1547        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1548        // Prevent Drop from running (which would shut down the channel)
1549        std::mem::forget(self);
1550    }
1551}
1552
1553impl FakeClockCreateNamedDeadlineInBootResponder {
1554    /// Sends a response to the FIDL transaction.
1555    ///
1556    /// Sets the channel to shutdown if an error occurs.
1557    pub fn send(self, mut deadline: fidl::BootInstant) -> Result<(), fidl::Error> {
1558        let _result = self.send_raw(deadline);
1559        if _result.is_err() {
1560            self.control_handle.shutdown();
1561        }
1562        self.drop_without_shutdown();
1563        _result
1564    }
1565
1566    /// Similar to "send" but does not shutdown the channel if an error occurs.
1567    pub fn send_no_shutdown_on_err(
1568        self,
1569        mut deadline: fidl::BootInstant,
1570    ) -> Result<(), fidl::Error> {
1571        let _result = self.send_raw(deadline);
1572        self.drop_without_shutdown();
1573        _result
1574    }
1575
1576    fn send_raw(&self, mut deadline: fidl::BootInstant) -> Result<(), fidl::Error> {
1577        self.control_handle.inner.send::<FakeClockCreateNamedDeadlineInBootResponse>(
1578            (deadline,),
1579            self.tx_id,
1580            0x15b0b36a16b354d8,
1581            fidl::encoding::DynamicFlags::empty(),
1582        )
1583    }
1584}
1585
1586#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1587pub struct FakeClockControlMarker;
1588
1589impl fidl::endpoints::ProtocolMarker for FakeClockControlMarker {
1590    type Proxy = FakeClockControlProxy;
1591    type RequestStream = FakeClockControlRequestStream;
1592    #[cfg(target_os = "fuchsia")]
1593    type SynchronousProxy = FakeClockControlSynchronousProxy;
1594
1595    const DEBUG_NAME: &'static str = "fuchsia.testing.FakeClockControl";
1596}
1597impl fidl::endpoints::DiscoverableProtocolMarker for FakeClockControlMarker {}
1598pub type FakeClockControlAdvanceResult = Result<(), i32>;
1599pub type FakeClockControlIncrementMonoToBootOffsetByResult = Result<(), i32>;
1600pub type FakeClockControlResumeWithIncrementsResult = Result<(), i32>;
1601pub type FakeClockControlAddStopPointResult = Result<(), i32>;
1602
1603pub trait FakeClockControlProxyInterface: Send + Sync {
1604    type AdvanceResponseFut: std::future::Future<Output = Result<FakeClockControlAdvanceResult, fidl::Error>>
1605        + Send;
1606    fn r#advance(&self, increment: &Increment) -> Self::AdvanceResponseFut;
1607    type IncrementMonoToBootOffsetByResponseFut: std::future::Future<
1608            Output = Result<FakeClockControlIncrementMonoToBootOffsetByResult, fidl::Error>,
1609        > + Send;
1610    fn r#increment_mono_to_boot_offset_by(
1611        &self,
1612        increment: i64,
1613    ) -> Self::IncrementMonoToBootOffsetByResponseFut;
1614    type ResumeWithIncrementsResponseFut: std::future::Future<
1615            Output = Result<FakeClockControlResumeWithIncrementsResult, fidl::Error>,
1616        > + Send;
1617    fn r#resume_with_increments(
1618        &self,
1619        real: i64,
1620        increment: &Increment,
1621    ) -> Self::ResumeWithIncrementsResponseFut;
1622    type AddStopPointResponseFut: std::future::Future<Output = Result<FakeClockControlAddStopPointResult, fidl::Error>>
1623        + Send;
1624    fn r#add_stop_point(
1625        &self,
1626        deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1627        event_type: DeadlineEventType,
1628        on_stop: fidl::EventPair,
1629    ) -> Self::AddStopPointResponseFut;
1630    type PauseResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1631    fn r#pause(&self) -> Self::PauseResponseFut;
1632    type IgnoreNamedDeadlineResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
1633        + Send;
1634    fn r#ignore_named_deadline(
1635        &self,
1636        deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1637    ) -> Self::IgnoreNamedDeadlineResponseFut;
1638}
1639#[derive(Debug)]
1640#[cfg(target_os = "fuchsia")]
1641pub struct FakeClockControlSynchronousProxy {
1642    client: fidl::client::sync::Client,
1643}
1644
1645#[cfg(target_os = "fuchsia")]
1646impl fidl::endpoints::SynchronousProxy for FakeClockControlSynchronousProxy {
1647    type Proxy = FakeClockControlProxy;
1648    type Protocol = FakeClockControlMarker;
1649
1650    fn from_channel(inner: fidl::Channel) -> Self {
1651        Self::new(inner)
1652    }
1653
1654    fn into_channel(self) -> fidl::Channel {
1655        self.client.into_channel()
1656    }
1657
1658    fn as_channel(&self) -> &fidl::Channel {
1659        self.client.as_channel()
1660    }
1661}
1662
1663#[cfg(target_os = "fuchsia")]
1664impl FakeClockControlSynchronousProxy {
1665    pub fn new(channel: fidl::Channel) -> Self {
1666        let protocol_name = <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1667        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1668    }
1669
1670    pub fn into_channel(self) -> fidl::Channel {
1671        self.client.into_channel()
1672    }
1673
1674    /// Waits until an event arrives and returns it. It is safe for other
1675    /// threads to make concurrent requests while waiting for an event.
1676    pub fn wait_for_event(
1677        &self,
1678        deadline: zx::MonotonicInstant,
1679    ) -> Result<FakeClockControlEvent, fidl::Error> {
1680        FakeClockControlEvent::decode(self.client.wait_for_event(deadline)?)
1681    }
1682
1683    /// Advances the fake clock `increment` once. This advances both monotonic and boot clocks by
1684    /// the same amount.
1685    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a badly formed
1686    /// RandomRange). Returns `ZX_ERR_ACCESS_DENIED` if called while the FakeClock is free-running.
1687    pub fn r#advance(
1688        &self,
1689        mut increment: &Increment,
1690        ___deadline: zx::MonotonicInstant,
1691    ) -> Result<FakeClockControlAdvanceResult, fidl::Error> {
1692        let _response = self.client.send_query::<
1693            FakeClockControlAdvanceRequest,
1694            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1695        >(
1696            (increment,),
1697            0x42f2265fb495497a,
1698            fidl::encoding::DynamicFlags::empty(),
1699            ___deadline,
1700        )?;
1701        Ok(_response.map(|x| x))
1702    }
1703
1704    /// Increments the mono-to-boot offset by the given `increment`. With real
1705    /// clocks, the positive offset from monotonic clock to boot clock increases
1706    /// during suspend. Here, this method fakes such an increase in offset.
1707    /// `increment` must be a positive duration.
1708    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is not positive.
1709    pub fn r#increment_mono_to_boot_offset_by(
1710        &self,
1711        mut increment: i64,
1712        ___deadline: zx::MonotonicInstant,
1713    ) -> Result<FakeClockControlIncrementMonoToBootOffsetByResult, fidl::Error> {
1714        let _response = self.client.send_query::<
1715            FakeClockControlIncrementMonoToBootOffsetByRequest,
1716            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1717        >(
1718            (increment,),
1719            0x294f89fe62a18857,
1720            fidl::encoding::DynamicFlags::empty(),
1721            ___deadline,
1722        )?;
1723        Ok(_response.map(|x| x))
1724    }
1725
1726    /// Resumes free-running increments on the fake clock.
1727    /// `real` is the period based on the real monotonic clock over which `increment` is going to be
1728    /// applied. Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a
1729    /// badly formed RandomRange).
1730    pub fn r#resume_with_increments(
1731        &self,
1732        mut real: i64,
1733        mut increment: &Increment,
1734        ___deadline: zx::MonotonicInstant,
1735    ) -> Result<FakeClockControlResumeWithIncrementsResult, fidl::Error> {
1736        let _response = self.client.send_query::<
1737            FakeClockControlResumeWithIncrementsRequest,
1738            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1739        >(
1740            (real, increment,),
1741            0x259be1eeba0bdd4a,
1742            fidl::encoding::DynamicFlags::empty(),
1743            ___deadline,
1744        )?;
1745        Ok(_response.map(|x| x))
1746    }
1747
1748    /// Registers interest in a deadline event.
1749    /// `deadline_id` and `event_type` identify the named deadline and the event associated with
1750    /// the deadline. When the event occurs, FakeClock will signal `EVENTPAIR_SIGNALED` on
1751    /// `on_stop`. If time is free-running, the clock is stopped. Closing the eventpair cancels
1752    /// interest in the deadline. If the eventpair is closed when a deadline is reached, time is
1753    /// not stopped. Note that only events that occur after `AddStopPoint` is called are matched.
1754    /// In addition, the `EXPIRED` event is always reported, even if the component that created the
1755    /// deadline does not act on the deadline expiration.
1756    ///
1757    /// The intended use is to set a stop point using `AddStopPoint`, resume running time with
1758    /// `ResumeWithIncrements`, then wait for the stop point to occur using the `on_stop`
1759    /// eventpair.
1760    /// Setting a stop point is only allowed while time is stopped. If time is free running when
1761    /// this method is invoked `ZX_ERR_ACCESS_DENIED` is returned. If a stop point is already
1762    /// registered for the same event, `ZX_ALREADY_BOUND` is returned.
1763    pub fn r#add_stop_point(
1764        &self,
1765        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1766        mut event_type: DeadlineEventType,
1767        mut on_stop: fidl::EventPair,
1768        ___deadline: zx::MonotonicInstant,
1769    ) -> Result<FakeClockControlAddStopPointResult, fidl::Error> {
1770        let _response = self.client.send_query::<
1771            FakeClockControlAddStopPointRequest,
1772            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1773        >(
1774            (deadline_id, event_type, on_stop,),
1775            0x3b52fe2cba8c4245,
1776            fidl::encoding::DynamicFlags::empty(),
1777            ___deadline,
1778        )?;
1779        Ok(_response.map(|x| x))
1780    }
1781
1782    /// Pauses free-running increments on the fake clock.
1783    pub fn r#pause(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1784        let _response =
1785            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1786                (),
1787                0x260df03b49199ba4,
1788                fidl::encoding::DynamicFlags::empty(),
1789                ___deadline,
1790            )?;
1791        Ok(_response)
1792    }
1793
1794    /// Instructs the fake clock to make deadlines named `deadline_id` never expire.
1795    /// This is a no-op if `deadline_id` is already in the ignored set.
1796    pub fn r#ignore_named_deadline(
1797        &self,
1798        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1799        ___deadline: zx::MonotonicInstant,
1800    ) -> Result<(), fidl::Error> {
1801        let _response = self
1802            .client
1803            .send_query::<FakeClockControlIgnoreNamedDeadlineRequest, fidl::encoding::EmptyPayload>(
1804                (deadline_id,),
1805                0x2e445152a80d44aa,
1806                fidl::encoding::DynamicFlags::empty(),
1807                ___deadline,
1808            )?;
1809        Ok(_response)
1810    }
1811}
1812
1813#[cfg(target_os = "fuchsia")]
1814impl From<FakeClockControlSynchronousProxy> for zx::NullableHandle {
1815    fn from(value: FakeClockControlSynchronousProxy) -> Self {
1816        value.into_channel().into()
1817    }
1818}
1819
1820#[cfg(target_os = "fuchsia")]
1821impl From<fidl::Channel> for FakeClockControlSynchronousProxy {
1822    fn from(value: fidl::Channel) -> Self {
1823        Self::new(value)
1824    }
1825}
1826
1827#[cfg(target_os = "fuchsia")]
1828impl fidl::endpoints::FromClient for FakeClockControlSynchronousProxy {
1829    type Protocol = FakeClockControlMarker;
1830
1831    fn from_client(value: fidl::endpoints::ClientEnd<FakeClockControlMarker>) -> Self {
1832        Self::new(value.into_channel())
1833    }
1834}
1835
1836#[derive(Debug, Clone)]
1837pub struct FakeClockControlProxy {
1838    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1839}
1840
1841impl fidl::endpoints::Proxy for FakeClockControlProxy {
1842    type Protocol = FakeClockControlMarker;
1843
1844    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1845        Self::new(inner)
1846    }
1847
1848    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1849        self.client.into_channel().map_err(|client| Self { client })
1850    }
1851
1852    fn as_channel(&self) -> &::fidl::AsyncChannel {
1853        self.client.as_channel()
1854    }
1855}
1856
1857impl FakeClockControlProxy {
1858    /// Create a new Proxy for fuchsia.testing/FakeClockControl.
1859    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1860        let protocol_name = <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1861        Self { client: fidl::client::Client::new(channel, protocol_name) }
1862    }
1863
1864    /// Get a Stream of events from the remote end of the protocol.
1865    ///
1866    /// # Panics
1867    ///
1868    /// Panics if the event stream was already taken.
1869    pub fn take_event_stream(&self) -> FakeClockControlEventStream {
1870        FakeClockControlEventStream { event_receiver: self.client.take_event_receiver() }
1871    }
1872
1873    /// Advances the fake clock `increment` once. This advances both monotonic and boot clocks by
1874    /// the same amount.
1875    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a badly formed
1876    /// RandomRange). Returns `ZX_ERR_ACCESS_DENIED` if called while the FakeClock is free-running.
1877    pub fn r#advance(
1878        &self,
1879        mut increment: &Increment,
1880    ) -> fidl::client::QueryResponseFut<
1881        FakeClockControlAdvanceResult,
1882        fidl::encoding::DefaultFuchsiaResourceDialect,
1883    > {
1884        FakeClockControlProxyInterface::r#advance(self, increment)
1885    }
1886
1887    /// Increments the mono-to-boot offset by the given `increment`. With real
1888    /// clocks, the positive offset from monotonic clock to boot clock increases
1889    /// during suspend. Here, this method fakes such an increase in offset.
1890    /// `increment` must be a positive duration.
1891    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is not positive.
1892    pub fn r#increment_mono_to_boot_offset_by(
1893        &self,
1894        mut increment: i64,
1895    ) -> fidl::client::QueryResponseFut<
1896        FakeClockControlIncrementMonoToBootOffsetByResult,
1897        fidl::encoding::DefaultFuchsiaResourceDialect,
1898    > {
1899        FakeClockControlProxyInterface::r#increment_mono_to_boot_offset_by(self, increment)
1900    }
1901
1902    /// Resumes free-running increments on the fake clock.
1903    /// `real` is the period based on the real monotonic clock over which `increment` is going to be
1904    /// applied. Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a
1905    /// badly formed RandomRange).
1906    pub fn r#resume_with_increments(
1907        &self,
1908        mut real: i64,
1909        mut increment: &Increment,
1910    ) -> fidl::client::QueryResponseFut<
1911        FakeClockControlResumeWithIncrementsResult,
1912        fidl::encoding::DefaultFuchsiaResourceDialect,
1913    > {
1914        FakeClockControlProxyInterface::r#resume_with_increments(self, real, increment)
1915    }
1916
1917    /// Registers interest in a deadline event.
1918    /// `deadline_id` and `event_type` identify the named deadline and the event associated with
1919    /// the deadline. When the event occurs, FakeClock will signal `EVENTPAIR_SIGNALED` on
1920    /// `on_stop`. If time is free-running, the clock is stopped. Closing the eventpair cancels
1921    /// interest in the deadline. If the eventpair is closed when a deadline is reached, time is
1922    /// not stopped. Note that only events that occur after `AddStopPoint` is called are matched.
1923    /// In addition, the `EXPIRED` event is always reported, even if the component that created the
1924    /// deadline does not act on the deadline expiration.
1925    ///
1926    /// The intended use is to set a stop point using `AddStopPoint`, resume running time with
1927    /// `ResumeWithIncrements`, then wait for the stop point to occur using the `on_stop`
1928    /// eventpair.
1929    /// Setting a stop point is only allowed while time is stopped. If time is free running when
1930    /// this method is invoked `ZX_ERR_ACCESS_DENIED` is returned. If a stop point is already
1931    /// registered for the same event, `ZX_ALREADY_BOUND` is returned.
1932    pub fn r#add_stop_point(
1933        &self,
1934        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1935        mut event_type: DeadlineEventType,
1936        mut on_stop: fidl::EventPair,
1937    ) -> fidl::client::QueryResponseFut<
1938        FakeClockControlAddStopPointResult,
1939        fidl::encoding::DefaultFuchsiaResourceDialect,
1940    > {
1941        FakeClockControlProxyInterface::r#add_stop_point(self, deadline_id, event_type, on_stop)
1942    }
1943
1944    /// Pauses free-running increments on the fake clock.
1945    pub fn r#pause(
1946        &self,
1947    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1948        FakeClockControlProxyInterface::r#pause(self)
1949    }
1950
1951    /// Instructs the fake clock to make deadlines named `deadline_id` never expire.
1952    /// This is a no-op if `deadline_id` is already in the ignored set.
1953    pub fn r#ignore_named_deadline(
1954        &self,
1955        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1956    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1957        FakeClockControlProxyInterface::r#ignore_named_deadline(self, deadline_id)
1958    }
1959}
1960
1961impl FakeClockControlProxyInterface for FakeClockControlProxy {
1962    type AdvanceResponseFut = fidl::client::QueryResponseFut<
1963        FakeClockControlAdvanceResult,
1964        fidl::encoding::DefaultFuchsiaResourceDialect,
1965    >;
1966    fn r#advance(&self, mut increment: &Increment) -> Self::AdvanceResponseFut {
1967        fn _decode(
1968            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1969        ) -> Result<FakeClockControlAdvanceResult, fidl::Error> {
1970            let _response = fidl::client::decode_transaction_body::<
1971                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1972                fidl::encoding::DefaultFuchsiaResourceDialect,
1973                0x42f2265fb495497a,
1974            >(_buf?)?;
1975            Ok(_response.map(|x| x))
1976        }
1977        self.client
1978            .send_query_and_decode::<FakeClockControlAdvanceRequest, FakeClockControlAdvanceResult>(
1979                (increment,),
1980                0x42f2265fb495497a,
1981                fidl::encoding::DynamicFlags::empty(),
1982                _decode,
1983            )
1984    }
1985
1986    type IncrementMonoToBootOffsetByResponseFut = fidl::client::QueryResponseFut<
1987        FakeClockControlIncrementMonoToBootOffsetByResult,
1988        fidl::encoding::DefaultFuchsiaResourceDialect,
1989    >;
1990    fn r#increment_mono_to_boot_offset_by(
1991        &self,
1992        mut increment: i64,
1993    ) -> Self::IncrementMonoToBootOffsetByResponseFut {
1994        fn _decode(
1995            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1996        ) -> Result<FakeClockControlIncrementMonoToBootOffsetByResult, fidl::Error> {
1997            let _response = fidl::client::decode_transaction_body::<
1998                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1999                fidl::encoding::DefaultFuchsiaResourceDialect,
2000                0x294f89fe62a18857,
2001            >(_buf?)?;
2002            Ok(_response.map(|x| x))
2003        }
2004        self.client.send_query_and_decode::<
2005            FakeClockControlIncrementMonoToBootOffsetByRequest,
2006            FakeClockControlIncrementMonoToBootOffsetByResult,
2007        >(
2008            (increment,),
2009            0x294f89fe62a18857,
2010            fidl::encoding::DynamicFlags::empty(),
2011            _decode,
2012        )
2013    }
2014
2015    type ResumeWithIncrementsResponseFut = fidl::client::QueryResponseFut<
2016        FakeClockControlResumeWithIncrementsResult,
2017        fidl::encoding::DefaultFuchsiaResourceDialect,
2018    >;
2019    fn r#resume_with_increments(
2020        &self,
2021        mut real: i64,
2022        mut increment: &Increment,
2023    ) -> Self::ResumeWithIncrementsResponseFut {
2024        fn _decode(
2025            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2026        ) -> Result<FakeClockControlResumeWithIncrementsResult, fidl::Error> {
2027            let _response = fidl::client::decode_transaction_body::<
2028                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2029                fidl::encoding::DefaultFuchsiaResourceDialect,
2030                0x259be1eeba0bdd4a,
2031            >(_buf?)?;
2032            Ok(_response.map(|x| x))
2033        }
2034        self.client.send_query_and_decode::<
2035            FakeClockControlResumeWithIncrementsRequest,
2036            FakeClockControlResumeWithIncrementsResult,
2037        >(
2038            (real, increment,),
2039            0x259be1eeba0bdd4a,
2040            fidl::encoding::DynamicFlags::empty(),
2041            _decode,
2042        )
2043    }
2044
2045    type AddStopPointResponseFut = fidl::client::QueryResponseFut<
2046        FakeClockControlAddStopPointResult,
2047        fidl::encoding::DefaultFuchsiaResourceDialect,
2048    >;
2049    fn r#add_stop_point(
2050        &self,
2051        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
2052        mut event_type: DeadlineEventType,
2053        mut on_stop: fidl::EventPair,
2054    ) -> Self::AddStopPointResponseFut {
2055        fn _decode(
2056            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2057        ) -> Result<FakeClockControlAddStopPointResult, fidl::Error> {
2058            let _response = fidl::client::decode_transaction_body::<
2059                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2060                fidl::encoding::DefaultFuchsiaResourceDialect,
2061                0x3b52fe2cba8c4245,
2062            >(_buf?)?;
2063            Ok(_response.map(|x| x))
2064        }
2065        self.client.send_query_and_decode::<
2066            FakeClockControlAddStopPointRequest,
2067            FakeClockControlAddStopPointResult,
2068        >(
2069            (deadline_id, event_type, on_stop,),
2070            0x3b52fe2cba8c4245,
2071            fidl::encoding::DynamicFlags::empty(),
2072            _decode,
2073        )
2074    }
2075
2076    type PauseResponseFut =
2077        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2078    fn r#pause(&self) -> Self::PauseResponseFut {
2079        fn _decode(
2080            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2081        ) -> Result<(), fidl::Error> {
2082            let _response = fidl::client::decode_transaction_body::<
2083                fidl::encoding::EmptyPayload,
2084                fidl::encoding::DefaultFuchsiaResourceDialect,
2085                0x260df03b49199ba4,
2086            >(_buf?)?;
2087            Ok(_response)
2088        }
2089        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2090            (),
2091            0x260df03b49199ba4,
2092            fidl::encoding::DynamicFlags::empty(),
2093            _decode,
2094        )
2095    }
2096
2097    type IgnoreNamedDeadlineResponseFut =
2098        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2099    fn r#ignore_named_deadline(
2100        &self,
2101        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
2102    ) -> Self::IgnoreNamedDeadlineResponseFut {
2103        fn _decode(
2104            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2105        ) -> Result<(), fidl::Error> {
2106            let _response = fidl::client::decode_transaction_body::<
2107                fidl::encoding::EmptyPayload,
2108                fidl::encoding::DefaultFuchsiaResourceDialect,
2109                0x2e445152a80d44aa,
2110            >(_buf?)?;
2111            Ok(_response)
2112        }
2113        self.client.send_query_and_decode::<FakeClockControlIgnoreNamedDeadlineRequest, ()>(
2114            (deadline_id,),
2115            0x2e445152a80d44aa,
2116            fidl::encoding::DynamicFlags::empty(),
2117            _decode,
2118        )
2119    }
2120}
2121
2122pub struct FakeClockControlEventStream {
2123    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2124}
2125
2126impl std::marker::Unpin for FakeClockControlEventStream {}
2127
2128impl futures::stream::FusedStream for FakeClockControlEventStream {
2129    fn is_terminated(&self) -> bool {
2130        self.event_receiver.is_terminated()
2131    }
2132}
2133
2134impl futures::Stream for FakeClockControlEventStream {
2135    type Item = Result<FakeClockControlEvent, fidl::Error>;
2136
2137    fn poll_next(
2138        mut self: std::pin::Pin<&mut Self>,
2139        cx: &mut std::task::Context<'_>,
2140    ) -> std::task::Poll<Option<Self::Item>> {
2141        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2142            &mut self.event_receiver,
2143            cx
2144        )?) {
2145            Some(buf) => std::task::Poll::Ready(Some(FakeClockControlEvent::decode(buf))),
2146            None => std::task::Poll::Ready(None),
2147        }
2148    }
2149}
2150
2151#[derive(Debug)]
2152pub enum FakeClockControlEvent {}
2153
2154impl FakeClockControlEvent {
2155    /// Decodes a message buffer as a [`FakeClockControlEvent`].
2156    fn decode(
2157        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2158    ) -> Result<FakeClockControlEvent, fidl::Error> {
2159        let (bytes, _handles) = buf.split_mut();
2160        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2161        debug_assert_eq!(tx_header.tx_id, 0);
2162        match tx_header.ordinal {
2163            _ => Err(fidl::Error::UnknownOrdinal {
2164                ordinal: tx_header.ordinal,
2165                protocol_name:
2166                    <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2167            }),
2168        }
2169    }
2170}
2171
2172/// A Stream of incoming requests for fuchsia.testing/FakeClockControl.
2173pub struct FakeClockControlRequestStream {
2174    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2175    is_terminated: bool,
2176}
2177
2178impl std::marker::Unpin for FakeClockControlRequestStream {}
2179
2180impl futures::stream::FusedStream for FakeClockControlRequestStream {
2181    fn is_terminated(&self) -> bool {
2182        self.is_terminated
2183    }
2184}
2185
2186impl fidl::endpoints::RequestStream for FakeClockControlRequestStream {
2187    type Protocol = FakeClockControlMarker;
2188    type ControlHandle = FakeClockControlControlHandle;
2189
2190    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2191        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2192    }
2193
2194    fn control_handle(&self) -> Self::ControlHandle {
2195        FakeClockControlControlHandle { inner: self.inner.clone() }
2196    }
2197
2198    fn into_inner(
2199        self,
2200    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2201    {
2202        (self.inner, self.is_terminated)
2203    }
2204
2205    fn from_inner(
2206        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2207        is_terminated: bool,
2208    ) -> Self {
2209        Self { inner, is_terminated }
2210    }
2211}
2212
2213impl futures::Stream for FakeClockControlRequestStream {
2214    type Item = Result<FakeClockControlRequest, fidl::Error>;
2215
2216    fn poll_next(
2217        mut self: std::pin::Pin<&mut Self>,
2218        cx: &mut std::task::Context<'_>,
2219    ) -> std::task::Poll<Option<Self::Item>> {
2220        let this = &mut *self;
2221        if this.inner.check_shutdown(cx) {
2222            this.is_terminated = true;
2223            return std::task::Poll::Ready(None);
2224        }
2225        if this.is_terminated {
2226            panic!("polled FakeClockControlRequestStream after completion");
2227        }
2228        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2229            |bytes, handles| {
2230                match this.inner.channel().read_etc(cx, bytes, handles) {
2231                    std::task::Poll::Ready(Ok(())) => {}
2232                    std::task::Poll::Pending => return std::task::Poll::Pending,
2233                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2234                        this.is_terminated = true;
2235                        return std::task::Poll::Ready(None);
2236                    }
2237                    std::task::Poll::Ready(Err(e)) => {
2238                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2239                            e.into(),
2240                        ))));
2241                    }
2242                }
2243
2244                // A message has been received from the channel
2245                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2246
2247                std::task::Poll::Ready(Some(match header.ordinal {
2248                    0x42f2265fb495497a => {
2249                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2250                        let mut req = fidl::new_empty!(
2251                            FakeClockControlAdvanceRequest,
2252                            fidl::encoding::DefaultFuchsiaResourceDialect
2253                        );
2254                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlAdvanceRequest>(&header, _body_bytes, handles, &mut req)?;
2255                        let control_handle =
2256                            FakeClockControlControlHandle { inner: this.inner.clone() };
2257                        Ok(FakeClockControlRequest::Advance {
2258                            increment: req.increment,
2259
2260                            responder: FakeClockControlAdvanceResponder {
2261                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2262                                tx_id: header.tx_id,
2263                            },
2264                        })
2265                    }
2266                    0x294f89fe62a18857 => {
2267                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2268                        let mut req = fidl::new_empty!(
2269                            FakeClockControlIncrementMonoToBootOffsetByRequest,
2270                            fidl::encoding::DefaultFuchsiaResourceDialect
2271                        );
2272                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlIncrementMonoToBootOffsetByRequest>(&header, _body_bytes, handles, &mut req)?;
2273                        let control_handle =
2274                            FakeClockControlControlHandle { inner: this.inner.clone() };
2275                        Ok(FakeClockControlRequest::IncrementMonoToBootOffsetBy {
2276                            increment: req.increment,
2277
2278                            responder: FakeClockControlIncrementMonoToBootOffsetByResponder {
2279                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2280                                tx_id: header.tx_id,
2281                            },
2282                        })
2283                    }
2284                    0x259be1eeba0bdd4a => {
2285                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2286                        let mut req = fidl::new_empty!(
2287                            FakeClockControlResumeWithIncrementsRequest,
2288                            fidl::encoding::DefaultFuchsiaResourceDialect
2289                        );
2290                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlResumeWithIncrementsRequest>(&header, _body_bytes, handles, &mut req)?;
2291                        let control_handle =
2292                            FakeClockControlControlHandle { inner: this.inner.clone() };
2293                        Ok(FakeClockControlRequest::ResumeWithIncrements {
2294                            real: req.real,
2295                            increment: req.increment,
2296
2297                            responder: FakeClockControlResumeWithIncrementsResponder {
2298                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2299                                tx_id: header.tx_id,
2300                            },
2301                        })
2302                    }
2303                    0x3b52fe2cba8c4245 => {
2304                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2305                        let mut req = fidl::new_empty!(
2306                            FakeClockControlAddStopPointRequest,
2307                            fidl::encoding::DefaultFuchsiaResourceDialect
2308                        );
2309                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlAddStopPointRequest>(&header, _body_bytes, handles, &mut req)?;
2310                        let control_handle =
2311                            FakeClockControlControlHandle { inner: this.inner.clone() };
2312                        Ok(FakeClockControlRequest::AddStopPoint {
2313                            deadline_id: req.deadline_id,
2314                            event_type: req.event_type,
2315                            on_stop: req.on_stop,
2316
2317                            responder: FakeClockControlAddStopPointResponder {
2318                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2319                                tx_id: header.tx_id,
2320                            },
2321                        })
2322                    }
2323                    0x260df03b49199ba4 => {
2324                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2325                        let mut req = fidl::new_empty!(
2326                            fidl::encoding::EmptyPayload,
2327                            fidl::encoding::DefaultFuchsiaResourceDialect
2328                        );
2329                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2330                        let control_handle =
2331                            FakeClockControlControlHandle { inner: this.inner.clone() };
2332                        Ok(FakeClockControlRequest::Pause {
2333                            responder: FakeClockControlPauseResponder {
2334                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2335                                tx_id: header.tx_id,
2336                            },
2337                        })
2338                    }
2339                    0x2e445152a80d44aa => {
2340                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2341                        let mut req = fidl::new_empty!(
2342                            FakeClockControlIgnoreNamedDeadlineRequest,
2343                            fidl::encoding::DefaultFuchsiaResourceDialect
2344                        );
2345                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlIgnoreNamedDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
2346                        let control_handle =
2347                            FakeClockControlControlHandle { inner: this.inner.clone() };
2348                        Ok(FakeClockControlRequest::IgnoreNamedDeadline {
2349                            deadline_id: req.deadline_id,
2350
2351                            responder: FakeClockControlIgnoreNamedDeadlineResponder {
2352                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2353                                tx_id: header.tx_id,
2354                            },
2355                        })
2356                    }
2357                    _ => Err(fidl::Error::UnknownOrdinal {
2358                        ordinal: header.ordinal,
2359                        protocol_name:
2360                            <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2361                    }),
2362                }))
2363            },
2364        )
2365    }
2366}
2367
2368/// Provides control over fake clocks.
2369///
2370/// `FakeClockControl` provides complete control of the fake clocks that it provides, and serves
2371/// over `FakeClock`.
2372///
2373/// Upon start up, all the clocks are set to free-running with increments set to 1ms:1ms (same as
2374/// calling `SetIncrements` with a `real` duration of 1ms and a `determined` `increment` of 1ms as
2375/// well).
2376///
2377/// The initial time value for every fake clock is read from the corresponding real clock at start
2378/// up.
2379#[derive(Debug)]
2380pub enum FakeClockControlRequest {
2381    /// Advances the fake clock `increment` once. This advances both monotonic and boot clocks by
2382    /// the same amount.
2383    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a badly formed
2384    /// RandomRange). Returns `ZX_ERR_ACCESS_DENIED` if called while the FakeClock is free-running.
2385    Advance { increment: Increment, responder: FakeClockControlAdvanceResponder },
2386    /// Increments the mono-to-boot offset by the given `increment`. With real
2387    /// clocks, the positive offset from monotonic clock to boot clock increases
2388    /// during suspend. Here, this method fakes such an increase in offset.
2389    /// `increment` must be a positive duration.
2390    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is not positive.
2391    IncrementMonoToBootOffsetBy {
2392        increment: i64,
2393        responder: FakeClockControlIncrementMonoToBootOffsetByResponder,
2394    },
2395    /// Resumes free-running increments on the fake clock.
2396    /// `real` is the period based on the real monotonic clock over which `increment` is going to be
2397    /// applied. Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a
2398    /// badly formed RandomRange).
2399    ResumeWithIncrements {
2400        real: i64,
2401        increment: Increment,
2402        responder: FakeClockControlResumeWithIncrementsResponder,
2403    },
2404    /// Registers interest in a deadline event.
2405    /// `deadline_id` and `event_type` identify the named deadline and the event associated with
2406    /// the deadline. When the event occurs, FakeClock will signal `EVENTPAIR_SIGNALED` on
2407    /// `on_stop`. If time is free-running, the clock is stopped. Closing the eventpair cancels
2408    /// interest in the deadline. If the eventpair is closed when a deadline is reached, time is
2409    /// not stopped. Note that only events that occur after `AddStopPoint` is called are matched.
2410    /// In addition, the `EXPIRED` event is always reported, even if the component that created the
2411    /// deadline does not act on the deadline expiration.
2412    ///
2413    /// The intended use is to set a stop point using `AddStopPoint`, resume running time with
2414    /// `ResumeWithIncrements`, then wait for the stop point to occur using the `on_stop`
2415    /// eventpair.
2416    /// Setting a stop point is only allowed while time is stopped. If time is free running when
2417    /// this method is invoked `ZX_ERR_ACCESS_DENIED` is returned. If a stop point is already
2418    /// registered for the same event, `ZX_ALREADY_BOUND` is returned.
2419    AddStopPoint {
2420        deadline_id: fidl_fuchsia_testing_deadline::DeadlineId,
2421        event_type: DeadlineEventType,
2422        on_stop: fidl::EventPair,
2423        responder: FakeClockControlAddStopPointResponder,
2424    },
2425    /// Pauses free-running increments on the fake clock.
2426    Pause { responder: FakeClockControlPauseResponder },
2427    /// Instructs the fake clock to make deadlines named `deadline_id` never expire.
2428    /// This is a no-op if `deadline_id` is already in the ignored set.
2429    IgnoreNamedDeadline {
2430        deadline_id: fidl_fuchsia_testing_deadline::DeadlineId,
2431        responder: FakeClockControlIgnoreNamedDeadlineResponder,
2432    },
2433}
2434
2435impl FakeClockControlRequest {
2436    #[allow(irrefutable_let_patterns)]
2437    pub fn into_advance(self) -> Option<(Increment, FakeClockControlAdvanceResponder)> {
2438        if let FakeClockControlRequest::Advance { increment, responder } = self {
2439            Some((increment, responder))
2440        } else {
2441            None
2442        }
2443    }
2444
2445    #[allow(irrefutable_let_patterns)]
2446    pub fn into_increment_mono_to_boot_offset_by(
2447        self,
2448    ) -> Option<(i64, FakeClockControlIncrementMonoToBootOffsetByResponder)> {
2449        if let FakeClockControlRequest::IncrementMonoToBootOffsetBy { increment, responder } = self
2450        {
2451            Some((increment, responder))
2452        } else {
2453            None
2454        }
2455    }
2456
2457    #[allow(irrefutable_let_patterns)]
2458    pub fn into_resume_with_increments(
2459        self,
2460    ) -> Option<(i64, Increment, FakeClockControlResumeWithIncrementsResponder)> {
2461        if let FakeClockControlRequest::ResumeWithIncrements { real, increment, responder } = self {
2462            Some((real, increment, responder))
2463        } else {
2464            None
2465        }
2466    }
2467
2468    #[allow(irrefutable_let_patterns)]
2469    pub fn into_add_stop_point(
2470        self,
2471    ) -> Option<(
2472        fidl_fuchsia_testing_deadline::DeadlineId,
2473        DeadlineEventType,
2474        fidl::EventPair,
2475        FakeClockControlAddStopPointResponder,
2476    )> {
2477        if let FakeClockControlRequest::AddStopPoint {
2478            deadline_id,
2479            event_type,
2480            on_stop,
2481            responder,
2482        } = self
2483        {
2484            Some((deadline_id, event_type, on_stop, responder))
2485        } else {
2486            None
2487        }
2488    }
2489
2490    #[allow(irrefutable_let_patterns)]
2491    pub fn into_pause(self) -> Option<(FakeClockControlPauseResponder)> {
2492        if let FakeClockControlRequest::Pause { responder } = self {
2493            Some((responder))
2494        } else {
2495            None
2496        }
2497    }
2498
2499    #[allow(irrefutable_let_patterns)]
2500    pub fn into_ignore_named_deadline(
2501        self,
2502    ) -> Option<(
2503        fidl_fuchsia_testing_deadline::DeadlineId,
2504        FakeClockControlIgnoreNamedDeadlineResponder,
2505    )> {
2506        if let FakeClockControlRequest::IgnoreNamedDeadline { deadline_id, responder } = self {
2507            Some((deadline_id, responder))
2508        } else {
2509            None
2510        }
2511    }
2512
2513    /// Name of the method defined in FIDL
2514    pub fn method_name(&self) -> &'static str {
2515        match *self {
2516            FakeClockControlRequest::Advance { .. } => "advance",
2517            FakeClockControlRequest::IncrementMonoToBootOffsetBy { .. } => {
2518                "increment_mono_to_boot_offset_by"
2519            }
2520            FakeClockControlRequest::ResumeWithIncrements { .. } => "resume_with_increments",
2521            FakeClockControlRequest::AddStopPoint { .. } => "add_stop_point",
2522            FakeClockControlRequest::Pause { .. } => "pause",
2523            FakeClockControlRequest::IgnoreNamedDeadline { .. } => "ignore_named_deadline",
2524        }
2525    }
2526}
2527
2528#[derive(Debug, Clone)]
2529pub struct FakeClockControlControlHandle {
2530    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2531}
2532
2533impl fidl::endpoints::ControlHandle for FakeClockControlControlHandle {
2534    fn shutdown(&self) {
2535        self.inner.shutdown()
2536    }
2537
2538    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2539        self.inner.shutdown_with_epitaph(status)
2540    }
2541
2542    fn is_closed(&self) -> bool {
2543        self.inner.channel().is_closed()
2544    }
2545    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2546        self.inner.channel().on_closed()
2547    }
2548
2549    #[cfg(target_os = "fuchsia")]
2550    fn signal_peer(
2551        &self,
2552        clear_mask: zx::Signals,
2553        set_mask: zx::Signals,
2554    ) -> Result<(), zx_status::Status> {
2555        use fidl::Peered;
2556        self.inner.channel().signal_peer(clear_mask, set_mask)
2557    }
2558}
2559
2560impl FakeClockControlControlHandle {}
2561
2562#[must_use = "FIDL methods require a response to be sent"]
2563#[derive(Debug)]
2564pub struct FakeClockControlAdvanceResponder {
2565    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2566    tx_id: u32,
2567}
2568
2569/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2570/// if the responder is dropped without sending a response, so that the client
2571/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2572impl std::ops::Drop for FakeClockControlAdvanceResponder {
2573    fn drop(&mut self) {
2574        self.control_handle.shutdown();
2575        // Safety: drops once, never accessed again
2576        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2577    }
2578}
2579
2580impl fidl::endpoints::Responder for FakeClockControlAdvanceResponder {
2581    type ControlHandle = FakeClockControlControlHandle;
2582
2583    fn control_handle(&self) -> &FakeClockControlControlHandle {
2584        &self.control_handle
2585    }
2586
2587    fn drop_without_shutdown(mut self) {
2588        // Safety: drops once, never accessed again due to mem::forget
2589        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2590        // Prevent Drop from running (which would shut down the channel)
2591        std::mem::forget(self);
2592    }
2593}
2594
2595impl FakeClockControlAdvanceResponder {
2596    /// Sends a response to the FIDL transaction.
2597    ///
2598    /// Sets the channel to shutdown if an error occurs.
2599    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2600        let _result = self.send_raw(result);
2601        if _result.is_err() {
2602            self.control_handle.shutdown();
2603        }
2604        self.drop_without_shutdown();
2605        _result
2606    }
2607
2608    /// Similar to "send" but does not shutdown the channel if an error occurs.
2609    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2610        let _result = self.send_raw(result);
2611        self.drop_without_shutdown();
2612        _result
2613    }
2614
2615    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2616        self.control_handle
2617            .inner
2618            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2619                result,
2620                self.tx_id,
2621                0x42f2265fb495497a,
2622                fidl::encoding::DynamicFlags::empty(),
2623            )
2624    }
2625}
2626
2627#[must_use = "FIDL methods require a response to be sent"]
2628#[derive(Debug)]
2629pub struct FakeClockControlIncrementMonoToBootOffsetByResponder {
2630    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2631    tx_id: u32,
2632}
2633
2634/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2635/// if the responder is dropped without sending a response, so that the client
2636/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2637impl std::ops::Drop for FakeClockControlIncrementMonoToBootOffsetByResponder {
2638    fn drop(&mut self) {
2639        self.control_handle.shutdown();
2640        // Safety: drops once, never accessed again
2641        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2642    }
2643}
2644
2645impl fidl::endpoints::Responder for FakeClockControlIncrementMonoToBootOffsetByResponder {
2646    type ControlHandle = FakeClockControlControlHandle;
2647
2648    fn control_handle(&self) -> &FakeClockControlControlHandle {
2649        &self.control_handle
2650    }
2651
2652    fn drop_without_shutdown(mut self) {
2653        // Safety: drops once, never accessed again due to mem::forget
2654        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2655        // Prevent Drop from running (which would shut down the channel)
2656        std::mem::forget(self);
2657    }
2658}
2659
2660impl FakeClockControlIncrementMonoToBootOffsetByResponder {
2661    /// Sends a response to the FIDL transaction.
2662    ///
2663    /// Sets the channel to shutdown if an error occurs.
2664    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2665        let _result = self.send_raw(result);
2666        if _result.is_err() {
2667            self.control_handle.shutdown();
2668        }
2669        self.drop_without_shutdown();
2670        _result
2671    }
2672
2673    /// Similar to "send" but does not shutdown the channel if an error occurs.
2674    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2675        let _result = self.send_raw(result);
2676        self.drop_without_shutdown();
2677        _result
2678    }
2679
2680    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2681        self.control_handle
2682            .inner
2683            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2684                result,
2685                self.tx_id,
2686                0x294f89fe62a18857,
2687                fidl::encoding::DynamicFlags::empty(),
2688            )
2689    }
2690}
2691
2692#[must_use = "FIDL methods require a response to be sent"]
2693#[derive(Debug)]
2694pub struct FakeClockControlResumeWithIncrementsResponder {
2695    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2696    tx_id: u32,
2697}
2698
2699/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2700/// if the responder is dropped without sending a response, so that the client
2701/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2702impl std::ops::Drop for FakeClockControlResumeWithIncrementsResponder {
2703    fn drop(&mut self) {
2704        self.control_handle.shutdown();
2705        // Safety: drops once, never accessed again
2706        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2707    }
2708}
2709
2710impl fidl::endpoints::Responder for FakeClockControlResumeWithIncrementsResponder {
2711    type ControlHandle = FakeClockControlControlHandle;
2712
2713    fn control_handle(&self) -> &FakeClockControlControlHandle {
2714        &self.control_handle
2715    }
2716
2717    fn drop_without_shutdown(mut self) {
2718        // Safety: drops once, never accessed again due to mem::forget
2719        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2720        // Prevent Drop from running (which would shut down the channel)
2721        std::mem::forget(self);
2722    }
2723}
2724
2725impl FakeClockControlResumeWithIncrementsResponder {
2726    /// Sends a response to the FIDL transaction.
2727    ///
2728    /// Sets the channel to shutdown if an error occurs.
2729    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2730        let _result = self.send_raw(result);
2731        if _result.is_err() {
2732            self.control_handle.shutdown();
2733        }
2734        self.drop_without_shutdown();
2735        _result
2736    }
2737
2738    /// Similar to "send" but does not shutdown the channel if an error occurs.
2739    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2740        let _result = self.send_raw(result);
2741        self.drop_without_shutdown();
2742        _result
2743    }
2744
2745    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2746        self.control_handle
2747            .inner
2748            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2749                result,
2750                self.tx_id,
2751                0x259be1eeba0bdd4a,
2752                fidl::encoding::DynamicFlags::empty(),
2753            )
2754    }
2755}
2756
2757#[must_use = "FIDL methods require a response to be sent"]
2758#[derive(Debug)]
2759pub struct FakeClockControlAddStopPointResponder {
2760    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2761    tx_id: u32,
2762}
2763
2764/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2765/// if the responder is dropped without sending a response, so that the client
2766/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2767impl std::ops::Drop for FakeClockControlAddStopPointResponder {
2768    fn drop(&mut self) {
2769        self.control_handle.shutdown();
2770        // Safety: drops once, never accessed again
2771        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2772    }
2773}
2774
2775impl fidl::endpoints::Responder for FakeClockControlAddStopPointResponder {
2776    type ControlHandle = FakeClockControlControlHandle;
2777
2778    fn control_handle(&self) -> &FakeClockControlControlHandle {
2779        &self.control_handle
2780    }
2781
2782    fn drop_without_shutdown(mut self) {
2783        // Safety: drops once, never accessed again due to mem::forget
2784        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2785        // Prevent Drop from running (which would shut down the channel)
2786        std::mem::forget(self);
2787    }
2788}
2789
2790impl FakeClockControlAddStopPointResponder {
2791    /// Sends a response to the FIDL transaction.
2792    ///
2793    /// Sets the channel to shutdown if an error occurs.
2794    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2795        let _result = self.send_raw(result);
2796        if _result.is_err() {
2797            self.control_handle.shutdown();
2798        }
2799        self.drop_without_shutdown();
2800        _result
2801    }
2802
2803    /// Similar to "send" but does not shutdown the channel if an error occurs.
2804    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2805        let _result = self.send_raw(result);
2806        self.drop_without_shutdown();
2807        _result
2808    }
2809
2810    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2811        self.control_handle
2812            .inner
2813            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2814                result,
2815                self.tx_id,
2816                0x3b52fe2cba8c4245,
2817                fidl::encoding::DynamicFlags::empty(),
2818            )
2819    }
2820}
2821
2822#[must_use = "FIDL methods require a response to be sent"]
2823#[derive(Debug)]
2824pub struct FakeClockControlPauseResponder {
2825    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2826    tx_id: u32,
2827}
2828
2829/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2830/// if the responder is dropped without sending a response, so that the client
2831/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2832impl std::ops::Drop for FakeClockControlPauseResponder {
2833    fn drop(&mut self) {
2834        self.control_handle.shutdown();
2835        // Safety: drops once, never accessed again
2836        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2837    }
2838}
2839
2840impl fidl::endpoints::Responder for FakeClockControlPauseResponder {
2841    type ControlHandle = FakeClockControlControlHandle;
2842
2843    fn control_handle(&self) -> &FakeClockControlControlHandle {
2844        &self.control_handle
2845    }
2846
2847    fn drop_without_shutdown(mut self) {
2848        // Safety: drops once, never accessed again due to mem::forget
2849        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2850        // Prevent Drop from running (which would shut down the channel)
2851        std::mem::forget(self);
2852    }
2853}
2854
2855impl FakeClockControlPauseResponder {
2856    /// Sends a response to the FIDL transaction.
2857    ///
2858    /// Sets the channel to shutdown if an error occurs.
2859    pub fn send(self) -> Result<(), fidl::Error> {
2860        let _result = self.send_raw();
2861        if _result.is_err() {
2862            self.control_handle.shutdown();
2863        }
2864        self.drop_without_shutdown();
2865        _result
2866    }
2867
2868    /// Similar to "send" but does not shutdown the channel if an error occurs.
2869    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2870        let _result = self.send_raw();
2871        self.drop_without_shutdown();
2872        _result
2873    }
2874
2875    fn send_raw(&self) -> Result<(), fidl::Error> {
2876        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2877            (),
2878            self.tx_id,
2879            0x260df03b49199ba4,
2880            fidl::encoding::DynamicFlags::empty(),
2881        )
2882    }
2883}
2884
2885#[must_use = "FIDL methods require a response to be sent"]
2886#[derive(Debug)]
2887pub struct FakeClockControlIgnoreNamedDeadlineResponder {
2888    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2889    tx_id: u32,
2890}
2891
2892/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2893/// if the responder is dropped without sending a response, so that the client
2894/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2895impl std::ops::Drop for FakeClockControlIgnoreNamedDeadlineResponder {
2896    fn drop(&mut self) {
2897        self.control_handle.shutdown();
2898        // Safety: drops once, never accessed again
2899        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2900    }
2901}
2902
2903impl fidl::endpoints::Responder for FakeClockControlIgnoreNamedDeadlineResponder {
2904    type ControlHandle = FakeClockControlControlHandle;
2905
2906    fn control_handle(&self) -> &FakeClockControlControlHandle {
2907        &self.control_handle
2908    }
2909
2910    fn drop_without_shutdown(mut self) {
2911        // Safety: drops once, never accessed again due to mem::forget
2912        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2913        // Prevent Drop from running (which would shut down the channel)
2914        std::mem::forget(self);
2915    }
2916}
2917
2918impl FakeClockControlIgnoreNamedDeadlineResponder {
2919    /// Sends a response to the FIDL transaction.
2920    ///
2921    /// Sets the channel to shutdown if an error occurs.
2922    pub fn send(self) -> Result<(), fidl::Error> {
2923        let _result = self.send_raw();
2924        if _result.is_err() {
2925            self.control_handle.shutdown();
2926        }
2927        self.drop_without_shutdown();
2928        _result
2929    }
2930
2931    /// Similar to "send" but does not shutdown the channel if an error occurs.
2932    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2933        let _result = self.send_raw();
2934        self.drop_without_shutdown();
2935        _result
2936    }
2937
2938    fn send_raw(&self) -> Result<(), fidl::Error> {
2939        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2940            (),
2941            self.tx_id,
2942            0x2e445152a80d44aa,
2943            fidl::encoding::DynamicFlags::empty(),
2944        )
2945    }
2946}
2947
2948mod internal {
2949    use super::*;
2950
2951    impl fidl::encoding::ResourceTypeMarker for FakeClockCancelEventRequest {
2952        type Borrowed<'a> = &'a mut Self;
2953        fn take_or_borrow<'a>(
2954            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2955        ) -> Self::Borrowed<'a> {
2956            value
2957        }
2958    }
2959
2960    unsafe impl fidl::encoding::TypeMarker for FakeClockCancelEventRequest {
2961        type Owned = Self;
2962
2963        #[inline(always)]
2964        fn inline_align(_context: fidl::encoding::Context) -> usize {
2965            4
2966        }
2967
2968        #[inline(always)]
2969        fn inline_size(_context: fidl::encoding::Context) -> usize {
2970            4
2971        }
2972    }
2973
2974    unsafe impl
2975        fidl::encoding::Encode<
2976            FakeClockCancelEventRequest,
2977            fidl::encoding::DefaultFuchsiaResourceDialect,
2978        > for &mut FakeClockCancelEventRequest
2979    {
2980        #[inline]
2981        unsafe fn encode(
2982            self,
2983            encoder: &mut fidl::encoding::Encoder<
2984                '_,
2985                fidl::encoding::DefaultFuchsiaResourceDialect,
2986            >,
2987            offset: usize,
2988            _depth: fidl::encoding::Depth,
2989        ) -> fidl::Result<()> {
2990            encoder.debug_check_bounds::<FakeClockCancelEventRequest>(offset);
2991            // Delegate to tuple encoding.
2992            fidl::encoding::Encode::<
2993                FakeClockCancelEventRequest,
2994                fidl::encoding::DefaultFuchsiaResourceDialect,
2995            >::encode(
2996                (<fidl::encoding::HandleType<
2997                    fidl::EventPair,
2998                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2999                    2147483648,
3000                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3001                    &mut self.event
3002                ),),
3003                encoder,
3004                offset,
3005                _depth,
3006            )
3007        }
3008    }
3009    unsafe impl<
3010        T0: fidl::encoding::Encode<
3011                fidl::encoding::HandleType<
3012                    fidl::EventPair,
3013                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3014                    2147483648,
3015                >,
3016                fidl::encoding::DefaultFuchsiaResourceDialect,
3017            >,
3018    >
3019        fidl::encoding::Encode<
3020            FakeClockCancelEventRequest,
3021            fidl::encoding::DefaultFuchsiaResourceDialect,
3022        > for (T0,)
3023    {
3024        #[inline]
3025        unsafe fn encode(
3026            self,
3027            encoder: &mut fidl::encoding::Encoder<
3028                '_,
3029                fidl::encoding::DefaultFuchsiaResourceDialect,
3030            >,
3031            offset: usize,
3032            depth: fidl::encoding::Depth,
3033        ) -> fidl::Result<()> {
3034            encoder.debug_check_bounds::<FakeClockCancelEventRequest>(offset);
3035            // Zero out padding regions. There's no need to apply masks
3036            // because the unmasked parts will be overwritten by fields.
3037            // Write the fields.
3038            self.0.encode(encoder, offset + 0, depth)?;
3039            Ok(())
3040        }
3041    }
3042
3043    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3044        for FakeClockCancelEventRequest
3045    {
3046        #[inline(always)]
3047        fn new_empty() -> Self {
3048            Self {
3049                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3050            }
3051        }
3052
3053        #[inline]
3054        unsafe fn decode(
3055            &mut self,
3056            decoder: &mut fidl::encoding::Decoder<
3057                '_,
3058                fidl::encoding::DefaultFuchsiaResourceDialect,
3059            >,
3060            offset: usize,
3061            _depth: fidl::encoding::Depth,
3062        ) -> fidl::Result<()> {
3063            decoder.debug_check_bounds::<Self>(offset);
3064            // Verify that padding bytes are zero.
3065            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3066            Ok(())
3067        }
3068    }
3069
3070    impl fidl::encoding::ResourceTypeMarker for FakeClockControlAddStopPointRequest {
3071        type Borrowed<'a> = &'a mut Self;
3072        fn take_or_borrow<'a>(
3073            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3074        ) -> Self::Borrowed<'a> {
3075            value
3076        }
3077    }
3078
3079    unsafe impl fidl::encoding::TypeMarker for FakeClockControlAddStopPointRequest {
3080        type Owned = Self;
3081
3082        #[inline(always)]
3083        fn inline_align(_context: fidl::encoding::Context) -> usize {
3084            8
3085        }
3086
3087        #[inline(always)]
3088        fn inline_size(_context: fidl::encoding::Context) -> usize {
3089            40
3090        }
3091    }
3092
3093    unsafe impl
3094        fidl::encoding::Encode<
3095            FakeClockControlAddStopPointRequest,
3096            fidl::encoding::DefaultFuchsiaResourceDialect,
3097        > for &mut FakeClockControlAddStopPointRequest
3098    {
3099        #[inline]
3100        unsafe fn encode(
3101            self,
3102            encoder: &mut fidl::encoding::Encoder<
3103                '_,
3104                fidl::encoding::DefaultFuchsiaResourceDialect,
3105            >,
3106            offset: usize,
3107            _depth: fidl::encoding::Depth,
3108        ) -> fidl::Result<()> {
3109            encoder.debug_check_bounds::<FakeClockControlAddStopPointRequest>(offset);
3110            // Delegate to tuple encoding.
3111            fidl::encoding::Encode::<FakeClockControlAddStopPointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3112                (
3113                    <fidl_fuchsia_testing_deadline::DeadlineId as fidl::encoding::ValueTypeMarker>::borrow(&self.deadline_id),
3114                    <DeadlineEventType as fidl::encoding::ValueTypeMarker>::borrow(&self.event_type),
3115                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.on_stop),
3116                ),
3117                encoder, offset, _depth
3118            )
3119        }
3120    }
3121    unsafe impl<
3122        T0: fidl::encoding::Encode<
3123                fidl_fuchsia_testing_deadline::DeadlineId,
3124                fidl::encoding::DefaultFuchsiaResourceDialect,
3125            >,
3126        T1: fidl::encoding::Encode<DeadlineEventType, fidl::encoding::DefaultFuchsiaResourceDialect>,
3127        T2: fidl::encoding::Encode<
3128                fidl::encoding::HandleType<
3129                    fidl::EventPair,
3130                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3131                    2147483648,
3132                >,
3133                fidl::encoding::DefaultFuchsiaResourceDialect,
3134            >,
3135    >
3136        fidl::encoding::Encode<
3137            FakeClockControlAddStopPointRequest,
3138            fidl::encoding::DefaultFuchsiaResourceDialect,
3139        > for (T0, T1, T2)
3140    {
3141        #[inline]
3142        unsafe fn encode(
3143            self,
3144            encoder: &mut fidl::encoding::Encoder<
3145                '_,
3146                fidl::encoding::DefaultFuchsiaResourceDialect,
3147            >,
3148            offset: usize,
3149            depth: fidl::encoding::Depth,
3150        ) -> fidl::Result<()> {
3151            encoder.debug_check_bounds::<FakeClockControlAddStopPointRequest>(offset);
3152            // Zero out padding regions. There's no need to apply masks
3153            // because the unmasked parts will be overwritten by fields.
3154            // Write the fields.
3155            self.0.encode(encoder, offset + 0, depth)?;
3156            self.1.encode(encoder, offset + 32, depth)?;
3157            self.2.encode(encoder, offset + 36, depth)?;
3158            Ok(())
3159        }
3160    }
3161
3162    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3163        for FakeClockControlAddStopPointRequest
3164    {
3165        #[inline(always)]
3166        fn new_empty() -> Self {
3167            Self {
3168                deadline_id: fidl::new_empty!(
3169                    fidl_fuchsia_testing_deadline::DeadlineId,
3170                    fidl::encoding::DefaultFuchsiaResourceDialect
3171                ),
3172                event_type: fidl::new_empty!(
3173                    DeadlineEventType,
3174                    fidl::encoding::DefaultFuchsiaResourceDialect
3175                ),
3176                on_stop: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3177            }
3178        }
3179
3180        #[inline]
3181        unsafe fn decode(
3182            &mut self,
3183            decoder: &mut fidl::encoding::Decoder<
3184                '_,
3185                fidl::encoding::DefaultFuchsiaResourceDialect,
3186            >,
3187            offset: usize,
3188            _depth: fidl::encoding::Depth,
3189        ) -> fidl::Result<()> {
3190            decoder.debug_check_bounds::<Self>(offset);
3191            // Verify that padding bytes are zero.
3192            fidl::decode!(
3193                fidl_fuchsia_testing_deadline::DeadlineId,
3194                fidl::encoding::DefaultFuchsiaResourceDialect,
3195                &mut self.deadline_id,
3196                decoder,
3197                offset + 0,
3198                _depth
3199            )?;
3200            fidl::decode!(
3201                DeadlineEventType,
3202                fidl::encoding::DefaultFuchsiaResourceDialect,
3203                &mut self.event_type,
3204                decoder,
3205                offset + 32,
3206                _depth
3207            )?;
3208            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.on_stop, decoder, offset + 36, _depth)?;
3209            Ok(())
3210        }
3211    }
3212
3213    impl fidl::encoding::ResourceTypeMarker for FakeClockRegisterEventInBootRequest {
3214        type Borrowed<'a> = &'a mut Self;
3215        fn take_or_borrow<'a>(
3216            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3217        ) -> Self::Borrowed<'a> {
3218            value
3219        }
3220    }
3221
3222    unsafe impl fidl::encoding::TypeMarker for FakeClockRegisterEventInBootRequest {
3223        type Owned = Self;
3224
3225        #[inline(always)]
3226        fn inline_align(_context: fidl::encoding::Context) -> usize {
3227            8
3228        }
3229
3230        #[inline(always)]
3231        fn inline_size(_context: fidl::encoding::Context) -> usize {
3232            16
3233        }
3234    }
3235
3236    unsafe impl
3237        fidl::encoding::Encode<
3238            FakeClockRegisterEventInBootRequest,
3239            fidl::encoding::DefaultFuchsiaResourceDialect,
3240        > for &mut FakeClockRegisterEventInBootRequest
3241    {
3242        #[inline]
3243        unsafe fn encode(
3244            self,
3245            encoder: &mut fidl::encoding::Encoder<
3246                '_,
3247                fidl::encoding::DefaultFuchsiaResourceDialect,
3248            >,
3249            offset: usize,
3250            _depth: fidl::encoding::Depth,
3251        ) -> fidl::Result<()> {
3252            encoder.debug_check_bounds::<FakeClockRegisterEventInBootRequest>(offset);
3253            // Delegate to tuple encoding.
3254            fidl::encoding::Encode::<
3255                FakeClockRegisterEventInBootRequest,
3256                fidl::encoding::DefaultFuchsiaResourceDialect,
3257            >::encode(
3258                (
3259                    <fidl::encoding::HandleType<
3260                        fidl::EventPair,
3261                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3262                        2147483648,
3263                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3264                        &mut self.event
3265                    ),
3266                    <fidl::BootInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
3267                ),
3268                encoder,
3269                offset,
3270                _depth,
3271            )
3272        }
3273    }
3274    unsafe impl<
3275        T0: fidl::encoding::Encode<
3276                fidl::encoding::HandleType<
3277                    fidl::EventPair,
3278                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3279                    2147483648,
3280                >,
3281                fidl::encoding::DefaultFuchsiaResourceDialect,
3282            >,
3283        T1: fidl::encoding::Encode<fidl::BootInstant, fidl::encoding::DefaultFuchsiaResourceDialect>,
3284    >
3285        fidl::encoding::Encode<
3286            FakeClockRegisterEventInBootRequest,
3287            fidl::encoding::DefaultFuchsiaResourceDialect,
3288        > for (T0, T1)
3289    {
3290        #[inline]
3291        unsafe fn encode(
3292            self,
3293            encoder: &mut fidl::encoding::Encoder<
3294                '_,
3295                fidl::encoding::DefaultFuchsiaResourceDialect,
3296            >,
3297            offset: usize,
3298            depth: fidl::encoding::Depth,
3299        ) -> fidl::Result<()> {
3300            encoder.debug_check_bounds::<FakeClockRegisterEventInBootRequest>(offset);
3301            // Zero out padding regions. There's no need to apply masks
3302            // because the unmasked parts will be overwritten by fields.
3303            unsafe {
3304                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3305                (ptr as *mut u64).write_unaligned(0);
3306            }
3307            // Write the fields.
3308            self.0.encode(encoder, offset + 0, depth)?;
3309            self.1.encode(encoder, offset + 8, depth)?;
3310            Ok(())
3311        }
3312    }
3313
3314    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3315        for FakeClockRegisterEventInBootRequest
3316    {
3317        #[inline(always)]
3318        fn new_empty() -> Self {
3319            Self {
3320                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3321                time: fidl::new_empty!(
3322                    fidl::BootInstant,
3323                    fidl::encoding::DefaultFuchsiaResourceDialect
3324                ),
3325            }
3326        }
3327
3328        #[inline]
3329        unsafe fn decode(
3330            &mut self,
3331            decoder: &mut fidl::encoding::Decoder<
3332                '_,
3333                fidl::encoding::DefaultFuchsiaResourceDialect,
3334            >,
3335            offset: usize,
3336            _depth: fidl::encoding::Depth,
3337        ) -> fidl::Result<()> {
3338            decoder.debug_check_bounds::<Self>(offset);
3339            // Verify that padding bytes are zero.
3340            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3341            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3342            let mask = 0xffffffff00000000u64;
3343            let maskedval = padval & mask;
3344            if maskedval != 0 {
3345                return Err(fidl::Error::NonZeroPadding {
3346                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3347                });
3348            }
3349            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3350            fidl::decode!(
3351                fidl::BootInstant,
3352                fidl::encoding::DefaultFuchsiaResourceDialect,
3353                &mut self.time,
3354                decoder,
3355                offset + 8,
3356                _depth
3357            )?;
3358            Ok(())
3359        }
3360    }
3361
3362    impl fidl::encoding::ResourceTypeMarker for FakeClockRegisterEventInMonotonicRequest {
3363        type Borrowed<'a> = &'a mut Self;
3364        fn take_or_borrow<'a>(
3365            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3366        ) -> Self::Borrowed<'a> {
3367            value
3368        }
3369    }
3370
3371    unsafe impl fidl::encoding::TypeMarker for FakeClockRegisterEventInMonotonicRequest {
3372        type Owned = Self;
3373
3374        #[inline(always)]
3375        fn inline_align(_context: fidl::encoding::Context) -> usize {
3376            8
3377        }
3378
3379        #[inline(always)]
3380        fn inline_size(_context: fidl::encoding::Context) -> usize {
3381            16
3382        }
3383    }
3384
3385    unsafe impl
3386        fidl::encoding::Encode<
3387            FakeClockRegisterEventInMonotonicRequest,
3388            fidl::encoding::DefaultFuchsiaResourceDialect,
3389        > for &mut FakeClockRegisterEventInMonotonicRequest
3390    {
3391        #[inline]
3392        unsafe fn encode(
3393            self,
3394            encoder: &mut fidl::encoding::Encoder<
3395                '_,
3396                fidl::encoding::DefaultFuchsiaResourceDialect,
3397            >,
3398            offset: usize,
3399            _depth: fidl::encoding::Depth,
3400        ) -> fidl::Result<()> {
3401            encoder.debug_check_bounds::<FakeClockRegisterEventInMonotonicRequest>(offset);
3402            // Delegate to tuple encoding.
3403            fidl::encoding::Encode::<
3404                FakeClockRegisterEventInMonotonicRequest,
3405                fidl::encoding::DefaultFuchsiaResourceDialect,
3406            >::encode(
3407                (
3408                    <fidl::encoding::HandleType<
3409                        fidl::EventPair,
3410                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3411                        2147483648,
3412                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3413                        &mut self.event
3414                    ),
3415                    <fidl::MonotonicInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
3416                ),
3417                encoder,
3418                offset,
3419                _depth,
3420            )
3421        }
3422    }
3423    unsafe impl<
3424        T0: fidl::encoding::Encode<
3425                fidl::encoding::HandleType<
3426                    fidl::EventPair,
3427                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3428                    2147483648,
3429                >,
3430                fidl::encoding::DefaultFuchsiaResourceDialect,
3431            >,
3432        T1: fidl::encoding::Encode<
3433                fidl::MonotonicInstant,
3434                fidl::encoding::DefaultFuchsiaResourceDialect,
3435            >,
3436    >
3437        fidl::encoding::Encode<
3438            FakeClockRegisterEventInMonotonicRequest,
3439            fidl::encoding::DefaultFuchsiaResourceDialect,
3440        > for (T0, T1)
3441    {
3442        #[inline]
3443        unsafe fn encode(
3444            self,
3445            encoder: &mut fidl::encoding::Encoder<
3446                '_,
3447                fidl::encoding::DefaultFuchsiaResourceDialect,
3448            >,
3449            offset: usize,
3450            depth: fidl::encoding::Depth,
3451        ) -> fidl::Result<()> {
3452            encoder.debug_check_bounds::<FakeClockRegisterEventInMonotonicRequest>(offset);
3453            // Zero out padding regions. There's no need to apply masks
3454            // because the unmasked parts will be overwritten by fields.
3455            unsafe {
3456                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3457                (ptr as *mut u64).write_unaligned(0);
3458            }
3459            // Write the fields.
3460            self.0.encode(encoder, offset + 0, depth)?;
3461            self.1.encode(encoder, offset + 8, depth)?;
3462            Ok(())
3463        }
3464    }
3465
3466    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3467        for FakeClockRegisterEventInMonotonicRequest
3468    {
3469        #[inline(always)]
3470        fn new_empty() -> Self {
3471            Self {
3472                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3473                time: fidl::new_empty!(
3474                    fidl::MonotonicInstant,
3475                    fidl::encoding::DefaultFuchsiaResourceDialect
3476                ),
3477            }
3478        }
3479
3480        #[inline]
3481        unsafe fn decode(
3482            &mut self,
3483            decoder: &mut fidl::encoding::Decoder<
3484                '_,
3485                fidl::encoding::DefaultFuchsiaResourceDialect,
3486            >,
3487            offset: usize,
3488            _depth: fidl::encoding::Depth,
3489        ) -> fidl::Result<()> {
3490            decoder.debug_check_bounds::<Self>(offset);
3491            // Verify that padding bytes are zero.
3492            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3493            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3494            let mask = 0xffffffff00000000u64;
3495            let maskedval = padval & mask;
3496            if maskedval != 0 {
3497                return Err(fidl::Error::NonZeroPadding {
3498                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3499                });
3500            }
3501            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3502            fidl::decode!(
3503                fidl::MonotonicInstant,
3504                fidl::encoding::DefaultFuchsiaResourceDialect,
3505                &mut self.time,
3506                decoder,
3507                offset + 8,
3508                _depth
3509            )?;
3510            Ok(())
3511        }
3512    }
3513
3514    impl fidl::encoding::ResourceTypeMarker for FakeClockRescheduleEventInBootRequest {
3515        type Borrowed<'a> = &'a mut Self;
3516        fn take_or_borrow<'a>(
3517            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3518        ) -> Self::Borrowed<'a> {
3519            value
3520        }
3521    }
3522
3523    unsafe impl fidl::encoding::TypeMarker for FakeClockRescheduleEventInBootRequest {
3524        type Owned = Self;
3525
3526        #[inline(always)]
3527        fn inline_align(_context: fidl::encoding::Context) -> usize {
3528            8
3529        }
3530
3531        #[inline(always)]
3532        fn inline_size(_context: fidl::encoding::Context) -> usize {
3533            16
3534        }
3535    }
3536
3537    unsafe impl
3538        fidl::encoding::Encode<
3539            FakeClockRescheduleEventInBootRequest,
3540            fidl::encoding::DefaultFuchsiaResourceDialect,
3541        > for &mut FakeClockRescheduleEventInBootRequest
3542    {
3543        #[inline]
3544        unsafe fn encode(
3545            self,
3546            encoder: &mut fidl::encoding::Encoder<
3547                '_,
3548                fidl::encoding::DefaultFuchsiaResourceDialect,
3549            >,
3550            offset: usize,
3551            _depth: fidl::encoding::Depth,
3552        ) -> fidl::Result<()> {
3553            encoder.debug_check_bounds::<FakeClockRescheduleEventInBootRequest>(offset);
3554            // Delegate to tuple encoding.
3555            fidl::encoding::Encode::<
3556                FakeClockRescheduleEventInBootRequest,
3557                fidl::encoding::DefaultFuchsiaResourceDialect,
3558            >::encode(
3559                (
3560                    <fidl::encoding::HandleType<
3561                        fidl::EventPair,
3562                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3563                        2147483648,
3564                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3565                        &mut self.event
3566                    ),
3567                    <fidl::BootInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
3568                ),
3569                encoder,
3570                offset,
3571                _depth,
3572            )
3573        }
3574    }
3575    unsafe impl<
3576        T0: fidl::encoding::Encode<
3577                fidl::encoding::HandleType<
3578                    fidl::EventPair,
3579                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3580                    2147483648,
3581                >,
3582                fidl::encoding::DefaultFuchsiaResourceDialect,
3583            >,
3584        T1: fidl::encoding::Encode<fidl::BootInstant, fidl::encoding::DefaultFuchsiaResourceDialect>,
3585    >
3586        fidl::encoding::Encode<
3587            FakeClockRescheduleEventInBootRequest,
3588            fidl::encoding::DefaultFuchsiaResourceDialect,
3589        > for (T0, T1)
3590    {
3591        #[inline]
3592        unsafe fn encode(
3593            self,
3594            encoder: &mut fidl::encoding::Encoder<
3595                '_,
3596                fidl::encoding::DefaultFuchsiaResourceDialect,
3597            >,
3598            offset: usize,
3599            depth: fidl::encoding::Depth,
3600        ) -> fidl::Result<()> {
3601            encoder.debug_check_bounds::<FakeClockRescheduleEventInBootRequest>(offset);
3602            // Zero out padding regions. There's no need to apply masks
3603            // because the unmasked parts will be overwritten by fields.
3604            unsafe {
3605                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3606                (ptr as *mut u64).write_unaligned(0);
3607            }
3608            // Write the fields.
3609            self.0.encode(encoder, offset + 0, depth)?;
3610            self.1.encode(encoder, offset + 8, depth)?;
3611            Ok(())
3612        }
3613    }
3614
3615    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3616        for FakeClockRescheduleEventInBootRequest
3617    {
3618        #[inline(always)]
3619        fn new_empty() -> Self {
3620            Self {
3621                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3622                time: fidl::new_empty!(
3623                    fidl::BootInstant,
3624                    fidl::encoding::DefaultFuchsiaResourceDialect
3625                ),
3626            }
3627        }
3628
3629        #[inline]
3630        unsafe fn decode(
3631            &mut self,
3632            decoder: &mut fidl::encoding::Decoder<
3633                '_,
3634                fidl::encoding::DefaultFuchsiaResourceDialect,
3635            >,
3636            offset: usize,
3637            _depth: fidl::encoding::Depth,
3638        ) -> fidl::Result<()> {
3639            decoder.debug_check_bounds::<Self>(offset);
3640            // Verify that padding bytes are zero.
3641            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3642            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3643            let mask = 0xffffffff00000000u64;
3644            let maskedval = padval & mask;
3645            if maskedval != 0 {
3646                return Err(fidl::Error::NonZeroPadding {
3647                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3648                });
3649            }
3650            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3651            fidl::decode!(
3652                fidl::BootInstant,
3653                fidl::encoding::DefaultFuchsiaResourceDialect,
3654                &mut self.time,
3655                decoder,
3656                offset + 8,
3657                _depth
3658            )?;
3659            Ok(())
3660        }
3661    }
3662
3663    impl fidl::encoding::ResourceTypeMarker for FakeClockRescheduleEventInMonotonicRequest {
3664        type Borrowed<'a> = &'a mut Self;
3665        fn take_or_borrow<'a>(
3666            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3667        ) -> Self::Borrowed<'a> {
3668            value
3669        }
3670    }
3671
3672    unsafe impl fidl::encoding::TypeMarker for FakeClockRescheduleEventInMonotonicRequest {
3673        type Owned = Self;
3674
3675        #[inline(always)]
3676        fn inline_align(_context: fidl::encoding::Context) -> usize {
3677            8
3678        }
3679
3680        #[inline(always)]
3681        fn inline_size(_context: fidl::encoding::Context) -> usize {
3682            16
3683        }
3684    }
3685
3686    unsafe impl
3687        fidl::encoding::Encode<
3688            FakeClockRescheduleEventInMonotonicRequest,
3689            fidl::encoding::DefaultFuchsiaResourceDialect,
3690        > for &mut FakeClockRescheduleEventInMonotonicRequest
3691    {
3692        #[inline]
3693        unsafe fn encode(
3694            self,
3695            encoder: &mut fidl::encoding::Encoder<
3696                '_,
3697                fidl::encoding::DefaultFuchsiaResourceDialect,
3698            >,
3699            offset: usize,
3700            _depth: fidl::encoding::Depth,
3701        ) -> fidl::Result<()> {
3702            encoder.debug_check_bounds::<FakeClockRescheduleEventInMonotonicRequest>(offset);
3703            // Delegate to tuple encoding.
3704            fidl::encoding::Encode::<
3705                FakeClockRescheduleEventInMonotonicRequest,
3706                fidl::encoding::DefaultFuchsiaResourceDialect,
3707            >::encode(
3708                (
3709                    <fidl::encoding::HandleType<
3710                        fidl::EventPair,
3711                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3712                        2147483648,
3713                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3714                        &mut self.event
3715                    ),
3716                    <fidl::MonotonicInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
3717                ),
3718                encoder,
3719                offset,
3720                _depth,
3721            )
3722        }
3723    }
3724    unsafe impl<
3725        T0: fidl::encoding::Encode<
3726                fidl::encoding::HandleType<
3727                    fidl::EventPair,
3728                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3729                    2147483648,
3730                >,
3731                fidl::encoding::DefaultFuchsiaResourceDialect,
3732            >,
3733        T1: fidl::encoding::Encode<
3734                fidl::MonotonicInstant,
3735                fidl::encoding::DefaultFuchsiaResourceDialect,
3736            >,
3737    >
3738        fidl::encoding::Encode<
3739            FakeClockRescheduleEventInMonotonicRequest,
3740            fidl::encoding::DefaultFuchsiaResourceDialect,
3741        > for (T0, T1)
3742    {
3743        #[inline]
3744        unsafe fn encode(
3745            self,
3746            encoder: &mut fidl::encoding::Encoder<
3747                '_,
3748                fidl::encoding::DefaultFuchsiaResourceDialect,
3749            >,
3750            offset: usize,
3751            depth: fidl::encoding::Depth,
3752        ) -> fidl::Result<()> {
3753            encoder.debug_check_bounds::<FakeClockRescheduleEventInMonotonicRequest>(offset);
3754            // Zero out padding regions. There's no need to apply masks
3755            // because the unmasked parts will be overwritten by fields.
3756            unsafe {
3757                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3758                (ptr as *mut u64).write_unaligned(0);
3759            }
3760            // Write the fields.
3761            self.0.encode(encoder, offset + 0, depth)?;
3762            self.1.encode(encoder, offset + 8, depth)?;
3763            Ok(())
3764        }
3765    }
3766
3767    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3768        for FakeClockRescheduleEventInMonotonicRequest
3769    {
3770        #[inline(always)]
3771        fn new_empty() -> Self {
3772            Self {
3773                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3774                time: fidl::new_empty!(
3775                    fidl::MonotonicInstant,
3776                    fidl::encoding::DefaultFuchsiaResourceDialect
3777                ),
3778            }
3779        }
3780
3781        #[inline]
3782        unsafe fn decode(
3783            &mut self,
3784            decoder: &mut fidl::encoding::Decoder<
3785                '_,
3786                fidl::encoding::DefaultFuchsiaResourceDialect,
3787            >,
3788            offset: usize,
3789            _depth: fidl::encoding::Depth,
3790        ) -> fidl::Result<()> {
3791            decoder.debug_check_bounds::<Self>(offset);
3792            // Verify that padding bytes are zero.
3793            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3794            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3795            let mask = 0xffffffff00000000u64;
3796            let maskedval = padval & mask;
3797            if maskedval != 0 {
3798                return Err(fidl::Error::NonZeroPadding {
3799                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3800                });
3801            }
3802            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3803            fidl::decode!(
3804                fidl::MonotonicInstant,
3805                fidl::encoding::DefaultFuchsiaResourceDialect,
3806                &mut self.time,
3807                decoder,
3808                offset + 8,
3809                _depth
3810            )?;
3811            Ok(())
3812        }
3813    }
3814}