Skip to main content

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