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