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