fidl_fuchsia_testing/
fidl_fuchsia_testing.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_testing__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct FakeClockCancelEventRequest {
16    pub event: fidl::EventPair,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for FakeClockCancelEventRequest
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct FakeClockControlAddStopPointRequest {
26    pub deadline_id: fidl_fuchsia_testing_deadline::DeadlineId,
27    pub event_type: DeadlineEventType,
28    pub on_stop: fidl::EventPair,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for FakeClockControlAddStopPointRequest
33{
34}
35
36#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct FakeClockRegisterEventRequest {
38    pub event: fidl::EventPair,
39    pub time: i64,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for FakeClockRegisterEventRequest
44{
45}
46
47#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48pub struct FakeClockRescheduleEventRequest {
49    pub event: fidl::EventPair,
50    pub time: i64,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
54    for FakeClockRescheduleEventRequest
55{
56}
57
58#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
59pub struct FakeClockMarker;
60
61impl fidl::endpoints::ProtocolMarker for FakeClockMarker {
62    type Proxy = FakeClockProxy;
63    type RequestStream = FakeClockRequestStream;
64    #[cfg(target_os = "fuchsia")]
65    type SynchronousProxy = FakeClockSynchronousProxy;
66
67    const DEBUG_NAME: &'static str = "fuchsia.testing.FakeClock";
68}
69impl fidl::endpoints::DiscoverableProtocolMarker for FakeClockMarker {}
70
71pub trait FakeClockProxyInterface: Send + Sync {
72    type GetResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
73    fn r#get(&self) -> Self::GetResponseFut;
74    fn r#register_event(&self, event: fidl::EventPair, time: i64) -> Result<(), fidl::Error>;
75    type RescheduleEventResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
76    fn r#reschedule_event(
77        &self,
78        event: fidl::EventPair,
79        time: i64,
80    ) -> Self::RescheduleEventResponseFut;
81    type CancelEventResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
82    fn r#cancel_event(&self, event: fidl::EventPair) -> Self::CancelEventResponseFut;
83    type CreateNamedDeadlineResponseFut: std::future::Future<Output = Result<i64, fidl::Error>>
84        + Send;
85    fn r#create_named_deadline(
86        &self,
87        id: &fidl_fuchsia_testing_deadline::DeadlineId,
88        duration: i64,
89    ) -> Self::CreateNamedDeadlineResponseFut;
90}
91#[derive(Debug)]
92#[cfg(target_os = "fuchsia")]
93pub struct FakeClockSynchronousProxy {
94    client: fidl::client::sync::Client,
95}
96
97#[cfg(target_os = "fuchsia")]
98impl fidl::endpoints::SynchronousProxy for FakeClockSynchronousProxy {
99    type Proxy = FakeClockProxy;
100    type Protocol = FakeClockMarker;
101
102    fn from_channel(inner: fidl::Channel) -> Self {
103        Self::new(inner)
104    }
105
106    fn into_channel(self) -> fidl::Channel {
107        self.client.into_channel()
108    }
109
110    fn as_channel(&self) -> &fidl::Channel {
111        self.client.as_channel()
112    }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl FakeClockSynchronousProxy {
117    pub fn new(channel: fidl::Channel) -> Self {
118        let protocol_name = <FakeClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
119        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
120    }
121
122    pub fn into_channel(self) -> fidl::Channel {
123        self.client.into_channel()
124    }
125
126    /// Waits until an event arrives and returns it. It is safe for other
127    /// threads to make concurrent requests while waiting for an event.
128    pub fn wait_for_event(
129        &self,
130        deadline: zx::MonotonicInstant,
131    ) -> Result<FakeClockEvent, fidl::Error> {
132        FakeClockEvent::decode(self.client.wait_for_event(deadline)?)
133    }
134
135    /// Gets the current time.
136    pub fn r#get(&self, ___deadline: zx::MonotonicInstant) -> Result<i64, fidl::Error> {
137        let _response =
138            self.client.send_query::<fidl::encoding::EmptyPayload, FakeClockGetResponse>(
139                (),
140                0x2a08c060e0b95e7c,
141                fidl::encoding::DynamicFlags::empty(),
142                ___deadline,
143            )?;
144        Ok(_response.time)
145    }
146
147    /// Registers the event handle `event` to be signaled with `ZX_EVENTPAIR_SIGNALED` when the
148    /// provided `time` is reached by the fake clock.
149    /// The `FakeClock` instance will retain this event (even after it's fired) for as long as the
150    /// client-side of the provided event pair `event` is open.
151    pub fn r#register_event(
152        &self,
153        mut event: fidl::EventPair,
154        mut time: i64,
155    ) -> Result<(), fidl::Error> {
156        self.client.send::<FakeClockRegisterEventRequest>(
157            (event, time),
158            0x79917345514b5f95,
159            fidl::encoding::DynamicFlags::empty(),
160        )
161    }
162
163    /// Reschedules an event to be signalled with `ZX_EVENTPAIR_SIGNALED` at the new deadline in
164    /// `time`.
165    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
166    /// originally registered event through its kernel object identifier.
167    pub fn r#reschedule_event(
168        &self,
169        mut event: fidl::EventPair,
170        mut time: i64,
171        ___deadline: zx::MonotonicInstant,
172    ) -> Result<(), fidl::Error> {
173        let _response = self
174            .client
175            .send_query::<FakeClockRescheduleEventRequest, fidl::encoding::EmptyPayload>(
176                (event, time),
177                0x4e5207df2b0dba46,
178                fidl::encoding::DynamicFlags::empty(),
179                ___deadline,
180            )?;
181        Ok(_response)
182    }
183
184    /// Cancels a previously registered event.
185    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
186    /// originally registered event through its kernel object identifier.
187    pub fn r#cancel_event(
188        &self,
189        mut event: fidl::EventPair,
190        ___deadline: zx::MonotonicInstant,
191    ) -> Result<(), fidl::Error> {
192        let _response =
193            self.client.send_query::<FakeClockCancelEventRequest, fidl::encoding::EmptyPayload>(
194                (event,),
195                0x18bbdb18faa6cac0,
196                fidl::encoding::DynamicFlags::empty(),
197                ___deadline,
198            )?;
199        Ok(_response)
200    }
201
202    /// Calculate and set a deadline associated with an id.
203    /// The returned `deadline` is calculated as `duration` after the current fake time.
204    /// FakeClock emits two events: A `SET` event immediately, and an `EXPIRED` event when the
205    /// deadline expires. A test using `FakeClockControl` may reference events related to the
206    /// deadline using a matching `id`. See `FakeClockControl.SetStopPoint` for information on how a
207    /// test can wait for a deadline event.
208    pub fn r#create_named_deadline(
209        &self,
210        mut id: &fidl_fuchsia_testing_deadline::DeadlineId,
211        mut duration: i64,
212        ___deadline: zx::MonotonicInstant,
213    ) -> Result<i64, fidl::Error> {
214        let _response = self.client.send_query::<
215            FakeClockCreateNamedDeadlineRequest,
216            FakeClockCreateNamedDeadlineResponse,
217        >(
218            (id, duration,),
219            0xf7a02c2ac2d116c,
220            fidl::encoding::DynamicFlags::empty(),
221            ___deadline,
222        )?;
223        Ok(_response.deadline)
224    }
225}
226
227#[cfg(target_os = "fuchsia")]
228impl From<FakeClockSynchronousProxy> for zx::Handle {
229    fn from(value: FakeClockSynchronousProxy) -> Self {
230        value.into_channel().into()
231    }
232}
233
234#[cfg(target_os = "fuchsia")]
235impl From<fidl::Channel> for FakeClockSynchronousProxy {
236    fn from(value: fidl::Channel) -> Self {
237        Self::new(value)
238    }
239}
240
241#[cfg(target_os = "fuchsia")]
242impl fidl::endpoints::FromClient for FakeClockSynchronousProxy {
243    type Protocol = FakeClockMarker;
244
245    fn from_client(value: fidl::endpoints::ClientEnd<FakeClockMarker>) -> Self {
246        Self::new(value.into_channel())
247    }
248}
249
250#[derive(Debug, Clone)]
251pub struct FakeClockProxy {
252    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
253}
254
255impl fidl::endpoints::Proxy for FakeClockProxy {
256    type Protocol = FakeClockMarker;
257
258    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
259        Self::new(inner)
260    }
261
262    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
263        self.client.into_channel().map_err(|client| Self { client })
264    }
265
266    fn as_channel(&self) -> &::fidl::AsyncChannel {
267        self.client.as_channel()
268    }
269}
270
271impl FakeClockProxy {
272    /// Create a new Proxy for fuchsia.testing/FakeClock.
273    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
274        let protocol_name = <FakeClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
275        Self { client: fidl::client::Client::new(channel, protocol_name) }
276    }
277
278    /// Get a Stream of events from the remote end of the protocol.
279    ///
280    /// # Panics
281    ///
282    /// Panics if the event stream was already taken.
283    pub fn take_event_stream(&self) -> FakeClockEventStream {
284        FakeClockEventStream { event_receiver: self.client.take_event_receiver() }
285    }
286
287    /// Gets the current time.
288    pub fn r#get(
289        &self,
290    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
291        FakeClockProxyInterface::r#get(self)
292    }
293
294    /// Registers the event handle `event` to be signaled with `ZX_EVENTPAIR_SIGNALED` when the
295    /// provided `time` is reached by the fake clock.
296    /// The `FakeClock` instance will retain this event (even after it's fired) for as long as the
297    /// client-side of the provided event pair `event` is open.
298    pub fn r#register_event(
299        &self,
300        mut event: fidl::EventPair,
301        mut time: i64,
302    ) -> Result<(), fidl::Error> {
303        FakeClockProxyInterface::r#register_event(self, event, time)
304    }
305
306    /// Reschedules an event to be signalled with `ZX_EVENTPAIR_SIGNALED` at the new deadline in
307    /// `time`.
308    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
309    /// originally registered event through its kernel object identifier.
310    pub fn r#reschedule_event(
311        &self,
312        mut event: fidl::EventPair,
313        mut time: i64,
314    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
315        FakeClockProxyInterface::r#reschedule_event(self, event, time)
316    }
317
318    /// Cancels a previously registered event.
319    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
320    /// originally registered event through its kernel object identifier.
321    pub fn r#cancel_event(
322        &self,
323        mut event: fidl::EventPair,
324    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
325        FakeClockProxyInterface::r#cancel_event(self, event)
326    }
327
328    /// Calculate and set a deadline associated with an id.
329    /// The returned `deadline` is calculated as `duration` after the current fake time.
330    /// FakeClock emits two events: A `SET` event immediately, and an `EXPIRED` event when the
331    /// deadline expires. A test using `FakeClockControl` may reference events related to the
332    /// deadline using a matching `id`. See `FakeClockControl.SetStopPoint` for information on how a
333    /// test can wait for a deadline event.
334    pub fn r#create_named_deadline(
335        &self,
336        mut id: &fidl_fuchsia_testing_deadline::DeadlineId,
337        mut duration: i64,
338    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
339        FakeClockProxyInterface::r#create_named_deadline(self, id, duration)
340    }
341}
342
343impl FakeClockProxyInterface for FakeClockProxy {
344    type GetResponseFut =
345        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
346    fn r#get(&self) -> Self::GetResponseFut {
347        fn _decode(
348            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
349        ) -> Result<i64, fidl::Error> {
350            let _response = fidl::client::decode_transaction_body::<
351                FakeClockGetResponse,
352                fidl::encoding::DefaultFuchsiaResourceDialect,
353                0x2a08c060e0b95e7c,
354            >(_buf?)?;
355            Ok(_response.time)
356        }
357        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
358            (),
359            0x2a08c060e0b95e7c,
360            fidl::encoding::DynamicFlags::empty(),
361            _decode,
362        )
363    }
364
365    fn r#register_event(
366        &self,
367        mut event: fidl::EventPair,
368        mut time: i64,
369    ) -> Result<(), fidl::Error> {
370        self.client.send::<FakeClockRegisterEventRequest>(
371            (event, time),
372            0x79917345514b5f95,
373            fidl::encoding::DynamicFlags::empty(),
374        )
375    }
376
377    type RescheduleEventResponseFut =
378        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
379    fn r#reschedule_event(
380        &self,
381        mut event: fidl::EventPair,
382        mut time: i64,
383    ) -> Self::RescheduleEventResponseFut {
384        fn _decode(
385            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
386        ) -> Result<(), fidl::Error> {
387            let _response = fidl::client::decode_transaction_body::<
388                fidl::encoding::EmptyPayload,
389                fidl::encoding::DefaultFuchsiaResourceDialect,
390                0x4e5207df2b0dba46,
391            >(_buf?)?;
392            Ok(_response)
393        }
394        self.client.send_query_and_decode::<FakeClockRescheduleEventRequest, ()>(
395            (event, time),
396            0x4e5207df2b0dba46,
397            fidl::encoding::DynamicFlags::empty(),
398            _decode,
399        )
400    }
401
402    type CancelEventResponseFut =
403        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
404    fn r#cancel_event(&self, mut event: fidl::EventPair) -> Self::CancelEventResponseFut {
405        fn _decode(
406            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
407        ) -> Result<(), fidl::Error> {
408            let _response = fidl::client::decode_transaction_body::<
409                fidl::encoding::EmptyPayload,
410                fidl::encoding::DefaultFuchsiaResourceDialect,
411                0x18bbdb18faa6cac0,
412            >(_buf?)?;
413            Ok(_response)
414        }
415        self.client.send_query_and_decode::<FakeClockCancelEventRequest, ()>(
416            (event,),
417            0x18bbdb18faa6cac0,
418            fidl::encoding::DynamicFlags::empty(),
419            _decode,
420        )
421    }
422
423    type CreateNamedDeadlineResponseFut =
424        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
425    fn r#create_named_deadline(
426        &self,
427        mut id: &fidl_fuchsia_testing_deadline::DeadlineId,
428        mut duration: i64,
429    ) -> Self::CreateNamedDeadlineResponseFut {
430        fn _decode(
431            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
432        ) -> Result<i64, fidl::Error> {
433            let _response = fidl::client::decode_transaction_body::<
434                FakeClockCreateNamedDeadlineResponse,
435                fidl::encoding::DefaultFuchsiaResourceDialect,
436                0xf7a02c2ac2d116c,
437            >(_buf?)?;
438            Ok(_response.deadline)
439        }
440        self.client.send_query_and_decode::<FakeClockCreateNamedDeadlineRequest, i64>(
441            (id, duration),
442            0xf7a02c2ac2d116c,
443            fidl::encoding::DynamicFlags::empty(),
444            _decode,
445        )
446    }
447}
448
449pub struct FakeClockEventStream {
450    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
451}
452
453impl std::marker::Unpin for FakeClockEventStream {}
454
455impl futures::stream::FusedStream for FakeClockEventStream {
456    fn is_terminated(&self) -> bool {
457        self.event_receiver.is_terminated()
458    }
459}
460
461impl futures::Stream for FakeClockEventStream {
462    type Item = Result<FakeClockEvent, fidl::Error>;
463
464    fn poll_next(
465        mut self: std::pin::Pin<&mut Self>,
466        cx: &mut std::task::Context<'_>,
467    ) -> std::task::Poll<Option<Self::Item>> {
468        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
469            &mut self.event_receiver,
470            cx
471        )?) {
472            Some(buf) => std::task::Poll::Ready(Some(FakeClockEvent::decode(buf))),
473            None => std::task::Poll::Ready(None),
474        }
475    }
476}
477
478#[derive(Debug)]
479pub enum FakeClockEvent {}
480
481impl FakeClockEvent {
482    /// Decodes a message buffer as a [`FakeClockEvent`].
483    fn decode(
484        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
485    ) -> Result<FakeClockEvent, fidl::Error> {
486        let (bytes, _handles) = buf.split_mut();
487        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
488        debug_assert_eq!(tx_header.tx_id, 0);
489        match tx_header.ordinal {
490            _ => Err(fidl::Error::UnknownOrdinal {
491                ordinal: tx_header.ordinal,
492                protocol_name: <FakeClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
493            }),
494        }
495    }
496}
497
498/// A Stream of incoming requests for fuchsia.testing/FakeClock.
499pub struct FakeClockRequestStream {
500    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
501    is_terminated: bool,
502}
503
504impl std::marker::Unpin for FakeClockRequestStream {}
505
506impl futures::stream::FusedStream for FakeClockRequestStream {
507    fn is_terminated(&self) -> bool {
508        self.is_terminated
509    }
510}
511
512impl fidl::endpoints::RequestStream for FakeClockRequestStream {
513    type Protocol = FakeClockMarker;
514    type ControlHandle = FakeClockControlHandle;
515
516    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
517        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
518    }
519
520    fn control_handle(&self) -> Self::ControlHandle {
521        FakeClockControlHandle { inner: self.inner.clone() }
522    }
523
524    fn into_inner(
525        self,
526    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
527    {
528        (self.inner, self.is_terminated)
529    }
530
531    fn from_inner(
532        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
533        is_terminated: bool,
534    ) -> Self {
535        Self { inner, is_terminated }
536    }
537}
538
539impl futures::Stream for FakeClockRequestStream {
540    type Item = Result<FakeClockRequest, fidl::Error>;
541
542    fn poll_next(
543        mut self: std::pin::Pin<&mut Self>,
544        cx: &mut std::task::Context<'_>,
545    ) -> std::task::Poll<Option<Self::Item>> {
546        let this = &mut *self;
547        if this.inner.check_shutdown(cx) {
548            this.is_terminated = true;
549            return std::task::Poll::Ready(None);
550        }
551        if this.is_terminated {
552            panic!("polled FakeClockRequestStream after completion");
553        }
554        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
555            |bytes, handles| {
556                match this.inner.channel().read_etc(cx, bytes, handles) {
557                    std::task::Poll::Ready(Ok(())) => {}
558                    std::task::Poll::Pending => return std::task::Poll::Pending,
559                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
560                        this.is_terminated = true;
561                        return std::task::Poll::Ready(None);
562                    }
563                    std::task::Poll::Ready(Err(e)) => {
564                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
565                            e.into(),
566                        ))))
567                    }
568                }
569
570                // A message has been received from the channel
571                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
572
573                std::task::Poll::Ready(Some(match header.ordinal {
574                    0x2a08c060e0b95e7c => {
575                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
576                        let mut req = fidl::new_empty!(
577                            fidl::encoding::EmptyPayload,
578                            fidl::encoding::DefaultFuchsiaResourceDialect
579                        );
580                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
581                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
582                        Ok(FakeClockRequest::Get {
583                            responder: FakeClockGetResponder {
584                                control_handle: std::mem::ManuallyDrop::new(control_handle),
585                                tx_id: header.tx_id,
586                            },
587                        })
588                    }
589                    0x79917345514b5f95 => {
590                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
591                        let mut req = fidl::new_empty!(
592                            FakeClockRegisterEventRequest,
593                            fidl::encoding::DefaultFuchsiaResourceDialect
594                        );
595                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockRegisterEventRequest>(&header, _body_bytes, handles, &mut req)?;
596                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
597                        Ok(FakeClockRequest::RegisterEvent {
598                            event: req.event,
599                            time: req.time,
600
601                            control_handle,
602                        })
603                    }
604                    0x4e5207df2b0dba46 => {
605                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
606                        let mut req = fidl::new_empty!(
607                            FakeClockRescheduleEventRequest,
608                            fidl::encoding::DefaultFuchsiaResourceDialect
609                        );
610                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockRescheduleEventRequest>(&header, _body_bytes, handles, &mut req)?;
611                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
612                        Ok(FakeClockRequest::RescheduleEvent {
613                            event: req.event,
614                            time: req.time,
615
616                            responder: FakeClockRescheduleEventResponder {
617                                control_handle: std::mem::ManuallyDrop::new(control_handle),
618                                tx_id: header.tx_id,
619                            },
620                        })
621                    }
622                    0x18bbdb18faa6cac0 => {
623                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
624                        let mut req = fidl::new_empty!(
625                            FakeClockCancelEventRequest,
626                            fidl::encoding::DefaultFuchsiaResourceDialect
627                        );
628                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockCancelEventRequest>(&header, _body_bytes, handles, &mut req)?;
629                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
630                        Ok(FakeClockRequest::CancelEvent {
631                            event: req.event,
632
633                            responder: FakeClockCancelEventResponder {
634                                control_handle: std::mem::ManuallyDrop::new(control_handle),
635                                tx_id: header.tx_id,
636                            },
637                        })
638                    }
639                    0xf7a02c2ac2d116c => {
640                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
641                        let mut req = fidl::new_empty!(
642                            FakeClockCreateNamedDeadlineRequest,
643                            fidl::encoding::DefaultFuchsiaResourceDialect
644                        );
645                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockCreateNamedDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
646                        let control_handle = FakeClockControlHandle { inner: this.inner.clone() };
647                        Ok(FakeClockRequest::CreateNamedDeadline {
648                            id: req.id,
649                            duration: req.duration,
650
651                            responder: FakeClockCreateNamedDeadlineResponder {
652                                control_handle: std::mem::ManuallyDrop::new(control_handle),
653                                tx_id: header.tx_id,
654                            },
655                        })
656                    }
657                    _ => Err(fidl::Error::UnknownOrdinal {
658                        ordinal: header.ordinal,
659                        protocol_name:
660                            <FakeClockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
661                    }),
662                }))
663            },
664        )
665    }
666}
667
668/// Allows access to fake clocks managed by `FakeClockControl`.
669#[derive(Debug)]
670pub enum FakeClockRequest {
671    /// Gets the current time.
672    Get { responder: FakeClockGetResponder },
673    /// Registers the event handle `event` to be signaled with `ZX_EVENTPAIR_SIGNALED` when the
674    /// provided `time` is reached by the fake clock.
675    /// The `FakeClock` instance will retain this event (even after it's fired) for as long as the
676    /// client-side of the provided event pair `event` is open.
677    RegisterEvent { event: fidl::EventPair, time: i64, control_handle: FakeClockControlHandle },
678    /// Reschedules an event to be signalled with `ZX_EVENTPAIR_SIGNALED` at the new deadline in
679    /// `time`.
680    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
681    /// originally registered event through its kernel object identifier.
682    RescheduleEvent {
683        event: fidl::EventPair,
684        time: i64,
685        responder: FakeClockRescheduleEventResponder,
686    },
687    /// Cancels a previously registered event.
688    /// `event` is a duplicate of the client-side of the event pair, and it's used to retrieve the
689    /// originally registered event through its kernel object identifier.
690    CancelEvent { event: fidl::EventPair, responder: FakeClockCancelEventResponder },
691    /// Calculate and set a deadline associated with an id.
692    /// The returned `deadline` is calculated as `duration` after the current fake time.
693    /// FakeClock emits two events: A `SET` event immediately, and an `EXPIRED` event when the
694    /// deadline expires. A test using `FakeClockControl` may reference events related to the
695    /// deadline using a matching `id`. See `FakeClockControl.SetStopPoint` for information on how a
696    /// test can wait for a deadline event.
697    CreateNamedDeadline {
698        id: fidl_fuchsia_testing_deadline::DeadlineId,
699        duration: i64,
700        responder: FakeClockCreateNamedDeadlineResponder,
701    },
702}
703
704impl FakeClockRequest {
705    #[allow(irrefutable_let_patterns)]
706    pub fn into_get(self) -> Option<(FakeClockGetResponder)> {
707        if let FakeClockRequest::Get { responder } = self {
708            Some((responder))
709        } else {
710            None
711        }
712    }
713
714    #[allow(irrefutable_let_patterns)]
715    pub fn into_register_event(self) -> Option<(fidl::EventPair, i64, FakeClockControlHandle)> {
716        if let FakeClockRequest::RegisterEvent { event, time, control_handle } = self {
717            Some((event, time, control_handle))
718        } else {
719            None
720        }
721    }
722
723    #[allow(irrefutable_let_patterns)]
724    pub fn into_reschedule_event(
725        self,
726    ) -> Option<(fidl::EventPair, i64, FakeClockRescheduleEventResponder)> {
727        if let FakeClockRequest::RescheduleEvent { event, time, responder } = self {
728            Some((event, time, responder))
729        } else {
730            None
731        }
732    }
733
734    #[allow(irrefutable_let_patterns)]
735    pub fn into_cancel_event(self) -> Option<(fidl::EventPair, FakeClockCancelEventResponder)> {
736        if let FakeClockRequest::CancelEvent { event, responder } = self {
737            Some((event, responder))
738        } else {
739            None
740        }
741    }
742
743    #[allow(irrefutable_let_patterns)]
744    pub fn into_create_named_deadline(
745        self,
746    ) -> Option<(
747        fidl_fuchsia_testing_deadline::DeadlineId,
748        i64,
749        FakeClockCreateNamedDeadlineResponder,
750    )> {
751        if let FakeClockRequest::CreateNamedDeadline { id, duration, responder } = self {
752            Some((id, duration, responder))
753        } else {
754            None
755        }
756    }
757
758    /// Name of the method defined in FIDL
759    pub fn method_name(&self) -> &'static str {
760        match *self {
761            FakeClockRequest::Get { .. } => "get",
762            FakeClockRequest::RegisterEvent { .. } => "register_event",
763            FakeClockRequest::RescheduleEvent { .. } => "reschedule_event",
764            FakeClockRequest::CancelEvent { .. } => "cancel_event",
765            FakeClockRequest::CreateNamedDeadline { .. } => "create_named_deadline",
766        }
767    }
768}
769
770#[derive(Debug, Clone)]
771pub struct FakeClockControlHandle {
772    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
773}
774
775impl fidl::endpoints::ControlHandle for FakeClockControlHandle {
776    fn shutdown(&self) {
777        self.inner.shutdown()
778    }
779    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
780        self.inner.shutdown_with_epitaph(status)
781    }
782
783    fn is_closed(&self) -> bool {
784        self.inner.channel().is_closed()
785    }
786    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
787        self.inner.channel().on_closed()
788    }
789
790    #[cfg(target_os = "fuchsia")]
791    fn signal_peer(
792        &self,
793        clear_mask: zx::Signals,
794        set_mask: zx::Signals,
795    ) -> Result<(), zx_status::Status> {
796        use fidl::Peered;
797        self.inner.channel().signal_peer(clear_mask, set_mask)
798    }
799}
800
801impl FakeClockControlHandle {}
802
803#[must_use = "FIDL methods require a response to be sent"]
804#[derive(Debug)]
805pub struct FakeClockGetResponder {
806    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
807    tx_id: u32,
808}
809
810/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
811/// if the responder is dropped without sending a response, so that the client
812/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
813impl std::ops::Drop for FakeClockGetResponder {
814    fn drop(&mut self) {
815        self.control_handle.shutdown();
816        // Safety: drops once, never accessed again
817        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
818    }
819}
820
821impl fidl::endpoints::Responder for FakeClockGetResponder {
822    type ControlHandle = FakeClockControlHandle;
823
824    fn control_handle(&self) -> &FakeClockControlHandle {
825        &self.control_handle
826    }
827
828    fn drop_without_shutdown(mut self) {
829        // Safety: drops once, never accessed again due to mem::forget
830        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
831        // Prevent Drop from running (which would shut down the channel)
832        std::mem::forget(self);
833    }
834}
835
836impl FakeClockGetResponder {
837    /// Sends a response to the FIDL transaction.
838    ///
839    /// Sets the channel to shutdown if an error occurs.
840    pub fn send(self, mut time: i64) -> Result<(), fidl::Error> {
841        let _result = self.send_raw(time);
842        if _result.is_err() {
843            self.control_handle.shutdown();
844        }
845        self.drop_without_shutdown();
846        _result
847    }
848
849    /// Similar to "send" but does not shutdown the channel if an error occurs.
850    pub fn send_no_shutdown_on_err(self, mut time: i64) -> Result<(), fidl::Error> {
851        let _result = self.send_raw(time);
852        self.drop_without_shutdown();
853        _result
854    }
855
856    fn send_raw(&self, mut time: i64) -> Result<(), fidl::Error> {
857        self.control_handle.inner.send::<FakeClockGetResponse>(
858            (time,),
859            self.tx_id,
860            0x2a08c060e0b95e7c,
861            fidl::encoding::DynamicFlags::empty(),
862        )
863    }
864}
865
866#[must_use = "FIDL methods require a response to be sent"]
867#[derive(Debug)]
868pub struct FakeClockRescheduleEventResponder {
869    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
870    tx_id: u32,
871}
872
873/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
874/// if the responder is dropped without sending a response, so that the client
875/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
876impl std::ops::Drop for FakeClockRescheduleEventResponder {
877    fn drop(&mut self) {
878        self.control_handle.shutdown();
879        // Safety: drops once, never accessed again
880        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
881    }
882}
883
884impl fidl::endpoints::Responder for FakeClockRescheduleEventResponder {
885    type ControlHandle = FakeClockControlHandle;
886
887    fn control_handle(&self) -> &FakeClockControlHandle {
888        &self.control_handle
889    }
890
891    fn drop_without_shutdown(mut self) {
892        // Safety: drops once, never accessed again due to mem::forget
893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
894        // Prevent Drop from running (which would shut down the channel)
895        std::mem::forget(self);
896    }
897}
898
899impl FakeClockRescheduleEventResponder {
900    /// Sends a response to the FIDL transaction.
901    ///
902    /// Sets the channel to shutdown if an error occurs.
903    pub fn send(self) -> Result<(), fidl::Error> {
904        let _result = self.send_raw();
905        if _result.is_err() {
906            self.control_handle.shutdown();
907        }
908        self.drop_without_shutdown();
909        _result
910    }
911
912    /// Similar to "send" but does not shutdown the channel if an error occurs.
913    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
914        let _result = self.send_raw();
915        self.drop_without_shutdown();
916        _result
917    }
918
919    fn send_raw(&self) -> Result<(), fidl::Error> {
920        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
921            (),
922            self.tx_id,
923            0x4e5207df2b0dba46,
924            fidl::encoding::DynamicFlags::empty(),
925        )
926    }
927}
928
929#[must_use = "FIDL methods require a response to be sent"]
930#[derive(Debug)]
931pub struct FakeClockCancelEventResponder {
932    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
933    tx_id: u32,
934}
935
936/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
937/// if the responder is dropped without sending a response, so that the client
938/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
939impl std::ops::Drop for FakeClockCancelEventResponder {
940    fn drop(&mut self) {
941        self.control_handle.shutdown();
942        // Safety: drops once, never accessed again
943        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
944    }
945}
946
947impl fidl::endpoints::Responder for FakeClockCancelEventResponder {
948    type ControlHandle = FakeClockControlHandle;
949
950    fn control_handle(&self) -> &FakeClockControlHandle {
951        &self.control_handle
952    }
953
954    fn drop_without_shutdown(mut self) {
955        // Safety: drops once, never accessed again due to mem::forget
956        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
957        // Prevent Drop from running (which would shut down the channel)
958        std::mem::forget(self);
959    }
960}
961
962impl FakeClockCancelEventResponder {
963    /// Sends a response to the FIDL transaction.
964    ///
965    /// Sets the channel to shutdown if an error occurs.
966    pub fn send(self) -> Result<(), fidl::Error> {
967        let _result = self.send_raw();
968        if _result.is_err() {
969            self.control_handle.shutdown();
970        }
971        self.drop_without_shutdown();
972        _result
973    }
974
975    /// Similar to "send" but does not shutdown the channel if an error occurs.
976    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
977        let _result = self.send_raw();
978        self.drop_without_shutdown();
979        _result
980    }
981
982    fn send_raw(&self) -> Result<(), fidl::Error> {
983        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
984            (),
985            self.tx_id,
986            0x18bbdb18faa6cac0,
987            fidl::encoding::DynamicFlags::empty(),
988        )
989    }
990}
991
992#[must_use = "FIDL methods require a response to be sent"]
993#[derive(Debug)]
994pub struct FakeClockCreateNamedDeadlineResponder {
995    control_handle: std::mem::ManuallyDrop<FakeClockControlHandle>,
996    tx_id: u32,
997}
998
999/// Set the the channel to be shutdown (see [`FakeClockControlHandle::shutdown`])
1000/// if the responder is dropped without sending a response, so that the client
1001/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1002impl std::ops::Drop for FakeClockCreateNamedDeadlineResponder {
1003    fn drop(&mut self) {
1004        self.control_handle.shutdown();
1005        // Safety: drops once, never accessed again
1006        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1007    }
1008}
1009
1010impl fidl::endpoints::Responder for FakeClockCreateNamedDeadlineResponder {
1011    type ControlHandle = FakeClockControlHandle;
1012
1013    fn control_handle(&self) -> &FakeClockControlHandle {
1014        &self.control_handle
1015    }
1016
1017    fn drop_without_shutdown(mut self) {
1018        // Safety: drops once, never accessed again due to mem::forget
1019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1020        // Prevent Drop from running (which would shut down the channel)
1021        std::mem::forget(self);
1022    }
1023}
1024
1025impl FakeClockCreateNamedDeadlineResponder {
1026    /// Sends a response to the FIDL transaction.
1027    ///
1028    /// Sets the channel to shutdown if an error occurs.
1029    pub fn send(self, mut deadline: i64) -> Result<(), fidl::Error> {
1030        let _result = self.send_raw(deadline);
1031        if _result.is_err() {
1032            self.control_handle.shutdown();
1033        }
1034        self.drop_without_shutdown();
1035        _result
1036    }
1037
1038    /// Similar to "send" but does not shutdown the channel if an error occurs.
1039    pub fn send_no_shutdown_on_err(self, mut deadline: i64) -> Result<(), fidl::Error> {
1040        let _result = self.send_raw(deadline);
1041        self.drop_without_shutdown();
1042        _result
1043    }
1044
1045    fn send_raw(&self, mut deadline: i64) -> Result<(), fidl::Error> {
1046        self.control_handle.inner.send::<FakeClockCreateNamedDeadlineResponse>(
1047            (deadline,),
1048            self.tx_id,
1049            0xf7a02c2ac2d116c,
1050            fidl::encoding::DynamicFlags::empty(),
1051        )
1052    }
1053}
1054
1055#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1056pub struct FakeClockControlMarker;
1057
1058impl fidl::endpoints::ProtocolMarker for FakeClockControlMarker {
1059    type Proxy = FakeClockControlProxy;
1060    type RequestStream = FakeClockControlRequestStream;
1061    #[cfg(target_os = "fuchsia")]
1062    type SynchronousProxy = FakeClockControlSynchronousProxy;
1063
1064    const DEBUG_NAME: &'static str = "fuchsia.testing.FakeClockControl";
1065}
1066impl fidl::endpoints::DiscoverableProtocolMarker for FakeClockControlMarker {}
1067pub type FakeClockControlAdvanceResult = Result<(), i32>;
1068pub type FakeClockControlResumeWithIncrementsResult = Result<(), i32>;
1069pub type FakeClockControlAddStopPointResult = Result<(), i32>;
1070
1071pub trait FakeClockControlProxyInterface: Send + Sync {
1072    type AdvanceResponseFut: std::future::Future<Output = Result<FakeClockControlAdvanceResult, fidl::Error>>
1073        + Send;
1074    fn r#advance(&self, increment: &Increment) -> Self::AdvanceResponseFut;
1075    type ResumeWithIncrementsResponseFut: std::future::Future<
1076            Output = Result<FakeClockControlResumeWithIncrementsResult, fidl::Error>,
1077        > + Send;
1078    fn r#resume_with_increments(
1079        &self,
1080        real: i64,
1081        increment: &Increment,
1082    ) -> Self::ResumeWithIncrementsResponseFut;
1083    type AddStopPointResponseFut: std::future::Future<Output = Result<FakeClockControlAddStopPointResult, fidl::Error>>
1084        + Send;
1085    fn r#add_stop_point(
1086        &self,
1087        deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1088        event_type: DeadlineEventType,
1089        on_stop: fidl::EventPair,
1090    ) -> Self::AddStopPointResponseFut;
1091    type PauseResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1092    fn r#pause(&self) -> Self::PauseResponseFut;
1093    type IgnoreNamedDeadlineResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
1094        + Send;
1095    fn r#ignore_named_deadline(
1096        &self,
1097        deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1098    ) -> Self::IgnoreNamedDeadlineResponseFut;
1099}
1100#[derive(Debug)]
1101#[cfg(target_os = "fuchsia")]
1102pub struct FakeClockControlSynchronousProxy {
1103    client: fidl::client::sync::Client,
1104}
1105
1106#[cfg(target_os = "fuchsia")]
1107impl fidl::endpoints::SynchronousProxy for FakeClockControlSynchronousProxy {
1108    type Proxy = FakeClockControlProxy;
1109    type Protocol = FakeClockControlMarker;
1110
1111    fn from_channel(inner: fidl::Channel) -> Self {
1112        Self::new(inner)
1113    }
1114
1115    fn into_channel(self) -> fidl::Channel {
1116        self.client.into_channel()
1117    }
1118
1119    fn as_channel(&self) -> &fidl::Channel {
1120        self.client.as_channel()
1121    }
1122}
1123
1124#[cfg(target_os = "fuchsia")]
1125impl FakeClockControlSynchronousProxy {
1126    pub fn new(channel: fidl::Channel) -> Self {
1127        let protocol_name = <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1128        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1129    }
1130
1131    pub fn into_channel(self) -> fidl::Channel {
1132        self.client.into_channel()
1133    }
1134
1135    /// Waits until an event arrives and returns it. It is safe for other
1136    /// threads to make concurrent requests while waiting for an event.
1137    pub fn wait_for_event(
1138        &self,
1139        deadline: zx::MonotonicInstant,
1140    ) -> Result<FakeClockControlEvent, fidl::Error> {
1141        FakeClockControlEvent::decode(self.client.wait_for_event(deadline)?)
1142    }
1143
1144    /// Advances the fake clock `increment` once.
1145    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a badly formed
1146    /// RandomRange). Returns `ZX_ERR_ACCESS_DENIED` if called while the FakeClock is free-running.
1147    pub fn r#advance(
1148        &self,
1149        mut increment: &Increment,
1150        ___deadline: zx::MonotonicInstant,
1151    ) -> Result<FakeClockControlAdvanceResult, fidl::Error> {
1152        let _response = self.client.send_query::<
1153            FakeClockControlAdvanceRequest,
1154            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1155        >(
1156            (increment,),
1157            0x42f2265fb495497a,
1158            fidl::encoding::DynamicFlags::empty(),
1159            ___deadline,
1160        )?;
1161        Ok(_response.map(|x| x))
1162    }
1163
1164    /// Resumes free-running increments on the fake clock.
1165    /// `real` is the period based on the real monotonic clock over which `increment` is going to be
1166    /// applied. Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a
1167    /// badly formed RandomRange).
1168    pub fn r#resume_with_increments(
1169        &self,
1170        mut real: i64,
1171        mut increment: &Increment,
1172        ___deadline: zx::MonotonicInstant,
1173    ) -> Result<FakeClockControlResumeWithIncrementsResult, fidl::Error> {
1174        let _response = self.client.send_query::<
1175            FakeClockControlResumeWithIncrementsRequest,
1176            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1177        >(
1178            (real, increment,),
1179            0x259be1eeba0bdd4a,
1180            fidl::encoding::DynamicFlags::empty(),
1181            ___deadline,
1182        )?;
1183        Ok(_response.map(|x| x))
1184    }
1185
1186    /// Registers interest in a deadline event.
1187    /// `deadline_id` and `event_type` identify the named deadline and the event associated with
1188    /// the deadline. When the event occurs, FakeClock will signal `EVENTPAIR_SIGNALED` on
1189    /// `on_stop`. If time is free-running, the clock is stopped. Closing the eventpair cancels
1190    /// interest in the deadline. If the eventpair is closed when a deadline is reached, time is
1191    /// not stopped. Note that only events that occur after `AddStopPoint` is called are matched.
1192    /// In addition, the `EXPIRED` event is always reported, even if the component that created the
1193    /// deadline does not act on the deadline expiration.
1194    ///
1195    /// The intended use is to set a stop point using `AddStopPoint`, resume running time with
1196    /// `ResumeWithIncrements`, then wait for the stop point to occur using the `on_stop`
1197    /// eventpair.
1198    /// Setting a stop point is only allowed while time is stopped. If time is free running when
1199    /// this method is invoked `ZX_ERR_ACCESS_DENIED` is returned. If a stop point is already
1200    /// registered for the same event, `ZX_ALREADY_BOUND` is returned.
1201    pub fn r#add_stop_point(
1202        &self,
1203        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1204        mut event_type: DeadlineEventType,
1205        mut on_stop: fidl::EventPair,
1206        ___deadline: zx::MonotonicInstant,
1207    ) -> Result<FakeClockControlAddStopPointResult, fidl::Error> {
1208        let _response = self.client.send_query::<
1209            FakeClockControlAddStopPointRequest,
1210            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1211        >(
1212            (deadline_id, event_type, on_stop,),
1213            0x3b52fe2cba8c4245,
1214            fidl::encoding::DynamicFlags::empty(),
1215            ___deadline,
1216        )?;
1217        Ok(_response.map(|x| x))
1218    }
1219
1220    /// Pauses free-running increments on the fake clock.
1221    pub fn r#pause(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1222        let _response =
1223            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1224                (),
1225                0x260df03b49199ba4,
1226                fidl::encoding::DynamicFlags::empty(),
1227                ___deadline,
1228            )?;
1229        Ok(_response)
1230    }
1231
1232    /// Instructs the fake clock to make deadlines named `deadline_id` never expire.
1233    /// This is a no-op if `deadline_id` is already in the ignored set.
1234    pub fn r#ignore_named_deadline(
1235        &self,
1236        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1237        ___deadline: zx::MonotonicInstant,
1238    ) -> Result<(), fidl::Error> {
1239        let _response = self
1240            .client
1241            .send_query::<FakeClockControlIgnoreNamedDeadlineRequest, fidl::encoding::EmptyPayload>(
1242                (deadline_id,),
1243                0x2e445152a80d44aa,
1244                fidl::encoding::DynamicFlags::empty(),
1245                ___deadline,
1246            )?;
1247        Ok(_response)
1248    }
1249}
1250
1251#[cfg(target_os = "fuchsia")]
1252impl From<FakeClockControlSynchronousProxy> for zx::Handle {
1253    fn from(value: FakeClockControlSynchronousProxy) -> Self {
1254        value.into_channel().into()
1255    }
1256}
1257
1258#[cfg(target_os = "fuchsia")]
1259impl From<fidl::Channel> for FakeClockControlSynchronousProxy {
1260    fn from(value: fidl::Channel) -> Self {
1261        Self::new(value)
1262    }
1263}
1264
1265#[cfg(target_os = "fuchsia")]
1266impl fidl::endpoints::FromClient for FakeClockControlSynchronousProxy {
1267    type Protocol = FakeClockControlMarker;
1268
1269    fn from_client(value: fidl::endpoints::ClientEnd<FakeClockControlMarker>) -> Self {
1270        Self::new(value.into_channel())
1271    }
1272}
1273
1274#[derive(Debug, Clone)]
1275pub struct FakeClockControlProxy {
1276    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1277}
1278
1279impl fidl::endpoints::Proxy for FakeClockControlProxy {
1280    type Protocol = FakeClockControlMarker;
1281
1282    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1283        Self::new(inner)
1284    }
1285
1286    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1287        self.client.into_channel().map_err(|client| Self { client })
1288    }
1289
1290    fn as_channel(&self) -> &::fidl::AsyncChannel {
1291        self.client.as_channel()
1292    }
1293}
1294
1295impl FakeClockControlProxy {
1296    /// Create a new Proxy for fuchsia.testing/FakeClockControl.
1297    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1298        let protocol_name = <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1299        Self { client: fidl::client::Client::new(channel, protocol_name) }
1300    }
1301
1302    /// Get a Stream of events from the remote end of the protocol.
1303    ///
1304    /// # Panics
1305    ///
1306    /// Panics if the event stream was already taken.
1307    pub fn take_event_stream(&self) -> FakeClockControlEventStream {
1308        FakeClockControlEventStream { event_receiver: self.client.take_event_receiver() }
1309    }
1310
1311    /// Advances the fake clock `increment` once.
1312    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a badly formed
1313    /// RandomRange). Returns `ZX_ERR_ACCESS_DENIED` if called while the FakeClock is free-running.
1314    pub fn r#advance(
1315        &self,
1316        mut increment: &Increment,
1317    ) -> fidl::client::QueryResponseFut<
1318        FakeClockControlAdvanceResult,
1319        fidl::encoding::DefaultFuchsiaResourceDialect,
1320    > {
1321        FakeClockControlProxyInterface::r#advance(self, increment)
1322    }
1323
1324    /// Resumes free-running increments on the fake clock.
1325    /// `real` is the period based on the real monotonic clock over which `increment` is going to be
1326    /// applied. Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a
1327    /// badly formed RandomRange).
1328    pub fn r#resume_with_increments(
1329        &self,
1330        mut real: i64,
1331        mut increment: &Increment,
1332    ) -> fidl::client::QueryResponseFut<
1333        FakeClockControlResumeWithIncrementsResult,
1334        fidl::encoding::DefaultFuchsiaResourceDialect,
1335    > {
1336        FakeClockControlProxyInterface::r#resume_with_increments(self, real, increment)
1337    }
1338
1339    /// Registers interest in a deadline event.
1340    /// `deadline_id` and `event_type` identify the named deadline and the event associated with
1341    /// the deadline. When the event occurs, FakeClock will signal `EVENTPAIR_SIGNALED` on
1342    /// `on_stop`. If time is free-running, the clock is stopped. Closing the eventpair cancels
1343    /// interest in the deadline. If the eventpair is closed when a deadline is reached, time is
1344    /// not stopped. Note that only events that occur after `AddStopPoint` is called are matched.
1345    /// In addition, the `EXPIRED` event is always reported, even if the component that created the
1346    /// deadline does not act on the deadline expiration.
1347    ///
1348    /// The intended use is to set a stop point using `AddStopPoint`, resume running time with
1349    /// `ResumeWithIncrements`, then wait for the stop point to occur using the `on_stop`
1350    /// eventpair.
1351    /// Setting a stop point is only allowed while time is stopped. If time is free running when
1352    /// this method is invoked `ZX_ERR_ACCESS_DENIED` is returned. If a stop point is already
1353    /// registered for the same event, `ZX_ALREADY_BOUND` is returned.
1354    pub fn r#add_stop_point(
1355        &self,
1356        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1357        mut event_type: DeadlineEventType,
1358        mut on_stop: fidl::EventPair,
1359    ) -> fidl::client::QueryResponseFut<
1360        FakeClockControlAddStopPointResult,
1361        fidl::encoding::DefaultFuchsiaResourceDialect,
1362    > {
1363        FakeClockControlProxyInterface::r#add_stop_point(self, deadline_id, event_type, on_stop)
1364    }
1365
1366    /// Pauses free-running increments on the fake clock.
1367    pub fn r#pause(
1368        &self,
1369    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1370        FakeClockControlProxyInterface::r#pause(self)
1371    }
1372
1373    /// Instructs the fake clock to make deadlines named `deadline_id` never expire.
1374    /// This is a no-op if `deadline_id` is already in the ignored set.
1375    pub fn r#ignore_named_deadline(
1376        &self,
1377        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1378    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1379        FakeClockControlProxyInterface::r#ignore_named_deadline(self, deadline_id)
1380    }
1381}
1382
1383impl FakeClockControlProxyInterface for FakeClockControlProxy {
1384    type AdvanceResponseFut = fidl::client::QueryResponseFut<
1385        FakeClockControlAdvanceResult,
1386        fidl::encoding::DefaultFuchsiaResourceDialect,
1387    >;
1388    fn r#advance(&self, mut increment: &Increment) -> Self::AdvanceResponseFut {
1389        fn _decode(
1390            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1391        ) -> Result<FakeClockControlAdvanceResult, fidl::Error> {
1392            let _response = fidl::client::decode_transaction_body::<
1393                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1394                fidl::encoding::DefaultFuchsiaResourceDialect,
1395                0x42f2265fb495497a,
1396            >(_buf?)?;
1397            Ok(_response.map(|x| x))
1398        }
1399        self.client
1400            .send_query_and_decode::<FakeClockControlAdvanceRequest, FakeClockControlAdvanceResult>(
1401                (increment,),
1402                0x42f2265fb495497a,
1403                fidl::encoding::DynamicFlags::empty(),
1404                _decode,
1405            )
1406    }
1407
1408    type ResumeWithIncrementsResponseFut = fidl::client::QueryResponseFut<
1409        FakeClockControlResumeWithIncrementsResult,
1410        fidl::encoding::DefaultFuchsiaResourceDialect,
1411    >;
1412    fn r#resume_with_increments(
1413        &self,
1414        mut real: i64,
1415        mut increment: &Increment,
1416    ) -> Self::ResumeWithIncrementsResponseFut {
1417        fn _decode(
1418            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1419        ) -> Result<FakeClockControlResumeWithIncrementsResult, fidl::Error> {
1420            let _response = fidl::client::decode_transaction_body::<
1421                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1422                fidl::encoding::DefaultFuchsiaResourceDialect,
1423                0x259be1eeba0bdd4a,
1424            >(_buf?)?;
1425            Ok(_response.map(|x| x))
1426        }
1427        self.client.send_query_and_decode::<
1428            FakeClockControlResumeWithIncrementsRequest,
1429            FakeClockControlResumeWithIncrementsResult,
1430        >(
1431            (real, increment,),
1432            0x259be1eeba0bdd4a,
1433            fidl::encoding::DynamicFlags::empty(),
1434            _decode,
1435        )
1436    }
1437
1438    type AddStopPointResponseFut = fidl::client::QueryResponseFut<
1439        FakeClockControlAddStopPointResult,
1440        fidl::encoding::DefaultFuchsiaResourceDialect,
1441    >;
1442    fn r#add_stop_point(
1443        &self,
1444        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1445        mut event_type: DeadlineEventType,
1446        mut on_stop: fidl::EventPair,
1447    ) -> Self::AddStopPointResponseFut {
1448        fn _decode(
1449            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1450        ) -> Result<FakeClockControlAddStopPointResult, fidl::Error> {
1451            let _response = fidl::client::decode_transaction_body::<
1452                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1453                fidl::encoding::DefaultFuchsiaResourceDialect,
1454                0x3b52fe2cba8c4245,
1455            >(_buf?)?;
1456            Ok(_response.map(|x| x))
1457        }
1458        self.client.send_query_and_decode::<
1459            FakeClockControlAddStopPointRequest,
1460            FakeClockControlAddStopPointResult,
1461        >(
1462            (deadline_id, event_type, on_stop,),
1463            0x3b52fe2cba8c4245,
1464            fidl::encoding::DynamicFlags::empty(),
1465            _decode,
1466        )
1467    }
1468
1469    type PauseResponseFut =
1470        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1471    fn r#pause(&self) -> Self::PauseResponseFut {
1472        fn _decode(
1473            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1474        ) -> Result<(), fidl::Error> {
1475            let _response = fidl::client::decode_transaction_body::<
1476                fidl::encoding::EmptyPayload,
1477                fidl::encoding::DefaultFuchsiaResourceDialect,
1478                0x260df03b49199ba4,
1479            >(_buf?)?;
1480            Ok(_response)
1481        }
1482        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1483            (),
1484            0x260df03b49199ba4,
1485            fidl::encoding::DynamicFlags::empty(),
1486            _decode,
1487        )
1488    }
1489
1490    type IgnoreNamedDeadlineResponseFut =
1491        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1492    fn r#ignore_named_deadline(
1493        &self,
1494        mut deadline_id: &fidl_fuchsia_testing_deadline::DeadlineId,
1495    ) -> Self::IgnoreNamedDeadlineResponseFut {
1496        fn _decode(
1497            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1498        ) -> Result<(), fidl::Error> {
1499            let _response = fidl::client::decode_transaction_body::<
1500                fidl::encoding::EmptyPayload,
1501                fidl::encoding::DefaultFuchsiaResourceDialect,
1502                0x2e445152a80d44aa,
1503            >(_buf?)?;
1504            Ok(_response)
1505        }
1506        self.client.send_query_and_decode::<FakeClockControlIgnoreNamedDeadlineRequest, ()>(
1507            (deadline_id,),
1508            0x2e445152a80d44aa,
1509            fidl::encoding::DynamicFlags::empty(),
1510            _decode,
1511        )
1512    }
1513}
1514
1515pub struct FakeClockControlEventStream {
1516    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1517}
1518
1519impl std::marker::Unpin for FakeClockControlEventStream {}
1520
1521impl futures::stream::FusedStream for FakeClockControlEventStream {
1522    fn is_terminated(&self) -> bool {
1523        self.event_receiver.is_terminated()
1524    }
1525}
1526
1527impl futures::Stream for FakeClockControlEventStream {
1528    type Item = Result<FakeClockControlEvent, fidl::Error>;
1529
1530    fn poll_next(
1531        mut self: std::pin::Pin<&mut Self>,
1532        cx: &mut std::task::Context<'_>,
1533    ) -> std::task::Poll<Option<Self::Item>> {
1534        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1535            &mut self.event_receiver,
1536            cx
1537        )?) {
1538            Some(buf) => std::task::Poll::Ready(Some(FakeClockControlEvent::decode(buf))),
1539            None => std::task::Poll::Ready(None),
1540        }
1541    }
1542}
1543
1544#[derive(Debug)]
1545pub enum FakeClockControlEvent {}
1546
1547impl FakeClockControlEvent {
1548    /// Decodes a message buffer as a [`FakeClockControlEvent`].
1549    fn decode(
1550        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1551    ) -> Result<FakeClockControlEvent, fidl::Error> {
1552        let (bytes, _handles) = buf.split_mut();
1553        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1554        debug_assert_eq!(tx_header.tx_id, 0);
1555        match tx_header.ordinal {
1556            _ => Err(fidl::Error::UnknownOrdinal {
1557                ordinal: tx_header.ordinal,
1558                protocol_name:
1559                    <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1560            }),
1561        }
1562    }
1563}
1564
1565/// A Stream of incoming requests for fuchsia.testing/FakeClockControl.
1566pub struct FakeClockControlRequestStream {
1567    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1568    is_terminated: bool,
1569}
1570
1571impl std::marker::Unpin for FakeClockControlRequestStream {}
1572
1573impl futures::stream::FusedStream for FakeClockControlRequestStream {
1574    fn is_terminated(&self) -> bool {
1575        self.is_terminated
1576    }
1577}
1578
1579impl fidl::endpoints::RequestStream for FakeClockControlRequestStream {
1580    type Protocol = FakeClockControlMarker;
1581    type ControlHandle = FakeClockControlControlHandle;
1582
1583    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1584        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1585    }
1586
1587    fn control_handle(&self) -> Self::ControlHandle {
1588        FakeClockControlControlHandle { inner: self.inner.clone() }
1589    }
1590
1591    fn into_inner(
1592        self,
1593    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1594    {
1595        (self.inner, self.is_terminated)
1596    }
1597
1598    fn from_inner(
1599        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1600        is_terminated: bool,
1601    ) -> Self {
1602        Self { inner, is_terminated }
1603    }
1604}
1605
1606impl futures::Stream for FakeClockControlRequestStream {
1607    type Item = Result<FakeClockControlRequest, fidl::Error>;
1608
1609    fn poll_next(
1610        mut self: std::pin::Pin<&mut Self>,
1611        cx: &mut std::task::Context<'_>,
1612    ) -> std::task::Poll<Option<Self::Item>> {
1613        let this = &mut *self;
1614        if this.inner.check_shutdown(cx) {
1615            this.is_terminated = true;
1616            return std::task::Poll::Ready(None);
1617        }
1618        if this.is_terminated {
1619            panic!("polled FakeClockControlRequestStream after completion");
1620        }
1621        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1622            |bytes, handles| {
1623                match this.inner.channel().read_etc(cx, bytes, handles) {
1624                    std::task::Poll::Ready(Ok(())) => {}
1625                    std::task::Poll::Pending => return std::task::Poll::Pending,
1626                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1627                        this.is_terminated = true;
1628                        return std::task::Poll::Ready(None);
1629                    }
1630                    std::task::Poll::Ready(Err(e)) => {
1631                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1632                            e.into(),
1633                        ))))
1634                    }
1635                }
1636
1637                // A message has been received from the channel
1638                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1639
1640                std::task::Poll::Ready(Some(match header.ordinal {
1641                    0x42f2265fb495497a => {
1642                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1643                        let mut req = fidl::new_empty!(
1644                            FakeClockControlAdvanceRequest,
1645                            fidl::encoding::DefaultFuchsiaResourceDialect
1646                        );
1647                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlAdvanceRequest>(&header, _body_bytes, handles, &mut req)?;
1648                        let control_handle =
1649                            FakeClockControlControlHandle { inner: this.inner.clone() };
1650                        Ok(FakeClockControlRequest::Advance {
1651                            increment: req.increment,
1652
1653                            responder: FakeClockControlAdvanceResponder {
1654                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1655                                tx_id: header.tx_id,
1656                            },
1657                        })
1658                    }
1659                    0x259be1eeba0bdd4a => {
1660                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1661                        let mut req = fidl::new_empty!(
1662                            FakeClockControlResumeWithIncrementsRequest,
1663                            fidl::encoding::DefaultFuchsiaResourceDialect
1664                        );
1665                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlResumeWithIncrementsRequest>(&header, _body_bytes, handles, &mut req)?;
1666                        let control_handle =
1667                            FakeClockControlControlHandle { inner: this.inner.clone() };
1668                        Ok(FakeClockControlRequest::ResumeWithIncrements {
1669                            real: req.real,
1670                            increment: req.increment,
1671
1672                            responder: FakeClockControlResumeWithIncrementsResponder {
1673                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1674                                tx_id: header.tx_id,
1675                            },
1676                        })
1677                    }
1678                    0x3b52fe2cba8c4245 => {
1679                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1680                        let mut req = fidl::new_empty!(
1681                            FakeClockControlAddStopPointRequest,
1682                            fidl::encoding::DefaultFuchsiaResourceDialect
1683                        );
1684                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlAddStopPointRequest>(&header, _body_bytes, handles, &mut req)?;
1685                        let control_handle =
1686                            FakeClockControlControlHandle { inner: this.inner.clone() };
1687                        Ok(FakeClockControlRequest::AddStopPoint {
1688                            deadline_id: req.deadline_id,
1689                            event_type: req.event_type,
1690                            on_stop: req.on_stop,
1691
1692                            responder: FakeClockControlAddStopPointResponder {
1693                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1694                                tx_id: header.tx_id,
1695                            },
1696                        })
1697                    }
1698                    0x260df03b49199ba4 => {
1699                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1700                        let mut req = fidl::new_empty!(
1701                            fidl::encoding::EmptyPayload,
1702                            fidl::encoding::DefaultFuchsiaResourceDialect
1703                        );
1704                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1705                        let control_handle =
1706                            FakeClockControlControlHandle { inner: this.inner.clone() };
1707                        Ok(FakeClockControlRequest::Pause {
1708                            responder: FakeClockControlPauseResponder {
1709                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1710                                tx_id: header.tx_id,
1711                            },
1712                        })
1713                    }
1714                    0x2e445152a80d44aa => {
1715                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1716                        let mut req = fidl::new_empty!(
1717                            FakeClockControlIgnoreNamedDeadlineRequest,
1718                            fidl::encoding::DefaultFuchsiaResourceDialect
1719                        );
1720                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeClockControlIgnoreNamedDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
1721                        let control_handle =
1722                            FakeClockControlControlHandle { inner: this.inner.clone() };
1723                        Ok(FakeClockControlRequest::IgnoreNamedDeadline {
1724                            deadline_id: req.deadline_id,
1725
1726                            responder: FakeClockControlIgnoreNamedDeadlineResponder {
1727                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1728                                tx_id: header.tx_id,
1729                            },
1730                        })
1731                    }
1732                    _ => Err(fidl::Error::UnknownOrdinal {
1733                        ordinal: header.ordinal,
1734                        protocol_name:
1735                            <FakeClockControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1736                    }),
1737                }))
1738            },
1739        )
1740    }
1741}
1742
1743/// Provides control over fake clocks.
1744///
1745/// `FakeClockControl` provides complete control of the fake clocks that it provides, and serves
1746/// over `FakeClock`.
1747///
1748/// Upon start up, all the clocks are set to free-running with increments set to 1ms:1ms (same as
1749/// calling `SetIncrements` with a `real` duration of 1ms and a `determined` `increment` of 1ms as
1750/// well).
1751///
1752/// The initial time value for every fake clock is read from the corresponding real clock at start
1753/// up.
1754#[derive(Debug)]
1755pub enum FakeClockControlRequest {
1756    /// Advances the fake clock `increment` once.
1757    /// Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a badly formed
1758    /// RandomRange). Returns `ZX_ERR_ACCESS_DENIED` if called while the FakeClock is free-running.
1759    Advance { increment: Increment, responder: FakeClockControlAdvanceResponder },
1760    /// Resumes free-running increments on the fake clock.
1761    /// `real` is the period based on the real monotonic clock over which `increment` is going to be
1762    /// applied. Returns `ZX_ERR_INVALID_ARGS` if the provided `increment` is invalid (such as a
1763    /// badly formed RandomRange).
1764    ResumeWithIncrements {
1765        real: i64,
1766        increment: Increment,
1767        responder: FakeClockControlResumeWithIncrementsResponder,
1768    },
1769    /// Registers interest in a deadline event.
1770    /// `deadline_id` and `event_type` identify the named deadline and the event associated with
1771    /// the deadline. When the event occurs, FakeClock will signal `EVENTPAIR_SIGNALED` on
1772    /// `on_stop`. If time is free-running, the clock is stopped. Closing the eventpair cancels
1773    /// interest in the deadline. If the eventpair is closed when a deadline is reached, time is
1774    /// not stopped. Note that only events that occur after `AddStopPoint` is called are matched.
1775    /// In addition, the `EXPIRED` event is always reported, even if the component that created the
1776    /// deadline does not act on the deadline expiration.
1777    ///
1778    /// The intended use is to set a stop point using `AddStopPoint`, resume running time with
1779    /// `ResumeWithIncrements`, then wait for the stop point to occur using the `on_stop`
1780    /// eventpair.
1781    /// Setting a stop point is only allowed while time is stopped. If time is free running when
1782    /// this method is invoked `ZX_ERR_ACCESS_DENIED` is returned. If a stop point is already
1783    /// registered for the same event, `ZX_ALREADY_BOUND` is returned.
1784    AddStopPoint {
1785        deadline_id: fidl_fuchsia_testing_deadline::DeadlineId,
1786        event_type: DeadlineEventType,
1787        on_stop: fidl::EventPair,
1788        responder: FakeClockControlAddStopPointResponder,
1789    },
1790    /// Pauses free-running increments on the fake clock.
1791    Pause { responder: FakeClockControlPauseResponder },
1792    /// Instructs the fake clock to make deadlines named `deadline_id` never expire.
1793    /// This is a no-op if `deadline_id` is already in the ignored set.
1794    IgnoreNamedDeadline {
1795        deadline_id: fidl_fuchsia_testing_deadline::DeadlineId,
1796        responder: FakeClockControlIgnoreNamedDeadlineResponder,
1797    },
1798}
1799
1800impl FakeClockControlRequest {
1801    #[allow(irrefutable_let_patterns)]
1802    pub fn into_advance(self) -> Option<(Increment, FakeClockControlAdvanceResponder)> {
1803        if let FakeClockControlRequest::Advance { increment, responder } = self {
1804            Some((increment, responder))
1805        } else {
1806            None
1807        }
1808    }
1809
1810    #[allow(irrefutable_let_patterns)]
1811    pub fn into_resume_with_increments(
1812        self,
1813    ) -> Option<(i64, Increment, FakeClockControlResumeWithIncrementsResponder)> {
1814        if let FakeClockControlRequest::ResumeWithIncrements { real, increment, responder } = self {
1815            Some((real, increment, responder))
1816        } else {
1817            None
1818        }
1819    }
1820
1821    #[allow(irrefutable_let_patterns)]
1822    pub fn into_add_stop_point(
1823        self,
1824    ) -> Option<(
1825        fidl_fuchsia_testing_deadline::DeadlineId,
1826        DeadlineEventType,
1827        fidl::EventPair,
1828        FakeClockControlAddStopPointResponder,
1829    )> {
1830        if let FakeClockControlRequest::AddStopPoint {
1831            deadline_id,
1832            event_type,
1833            on_stop,
1834            responder,
1835        } = self
1836        {
1837            Some((deadline_id, event_type, on_stop, responder))
1838        } else {
1839            None
1840        }
1841    }
1842
1843    #[allow(irrefutable_let_patterns)]
1844    pub fn into_pause(self) -> Option<(FakeClockControlPauseResponder)> {
1845        if let FakeClockControlRequest::Pause { responder } = self {
1846            Some((responder))
1847        } else {
1848            None
1849        }
1850    }
1851
1852    #[allow(irrefutable_let_patterns)]
1853    pub fn into_ignore_named_deadline(
1854        self,
1855    ) -> Option<(
1856        fidl_fuchsia_testing_deadline::DeadlineId,
1857        FakeClockControlIgnoreNamedDeadlineResponder,
1858    )> {
1859        if let FakeClockControlRequest::IgnoreNamedDeadline { deadline_id, responder } = self {
1860            Some((deadline_id, responder))
1861        } else {
1862            None
1863        }
1864    }
1865
1866    /// Name of the method defined in FIDL
1867    pub fn method_name(&self) -> &'static str {
1868        match *self {
1869            FakeClockControlRequest::Advance { .. } => "advance",
1870            FakeClockControlRequest::ResumeWithIncrements { .. } => "resume_with_increments",
1871            FakeClockControlRequest::AddStopPoint { .. } => "add_stop_point",
1872            FakeClockControlRequest::Pause { .. } => "pause",
1873            FakeClockControlRequest::IgnoreNamedDeadline { .. } => "ignore_named_deadline",
1874        }
1875    }
1876}
1877
1878#[derive(Debug, Clone)]
1879pub struct FakeClockControlControlHandle {
1880    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1881}
1882
1883impl fidl::endpoints::ControlHandle for FakeClockControlControlHandle {
1884    fn shutdown(&self) {
1885        self.inner.shutdown()
1886    }
1887    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1888        self.inner.shutdown_with_epitaph(status)
1889    }
1890
1891    fn is_closed(&self) -> bool {
1892        self.inner.channel().is_closed()
1893    }
1894    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1895        self.inner.channel().on_closed()
1896    }
1897
1898    #[cfg(target_os = "fuchsia")]
1899    fn signal_peer(
1900        &self,
1901        clear_mask: zx::Signals,
1902        set_mask: zx::Signals,
1903    ) -> Result<(), zx_status::Status> {
1904        use fidl::Peered;
1905        self.inner.channel().signal_peer(clear_mask, set_mask)
1906    }
1907}
1908
1909impl FakeClockControlControlHandle {}
1910
1911#[must_use = "FIDL methods require a response to be sent"]
1912#[derive(Debug)]
1913pub struct FakeClockControlAdvanceResponder {
1914    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
1915    tx_id: u32,
1916}
1917
1918/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
1919/// if the responder is dropped without sending a response, so that the client
1920/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1921impl std::ops::Drop for FakeClockControlAdvanceResponder {
1922    fn drop(&mut self) {
1923        self.control_handle.shutdown();
1924        // Safety: drops once, never accessed again
1925        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1926    }
1927}
1928
1929impl fidl::endpoints::Responder for FakeClockControlAdvanceResponder {
1930    type ControlHandle = FakeClockControlControlHandle;
1931
1932    fn control_handle(&self) -> &FakeClockControlControlHandle {
1933        &self.control_handle
1934    }
1935
1936    fn drop_without_shutdown(mut self) {
1937        // Safety: drops once, never accessed again due to mem::forget
1938        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1939        // Prevent Drop from running (which would shut down the channel)
1940        std::mem::forget(self);
1941    }
1942}
1943
1944impl FakeClockControlAdvanceResponder {
1945    /// Sends a response to the FIDL transaction.
1946    ///
1947    /// Sets the channel to shutdown if an error occurs.
1948    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1949        let _result = self.send_raw(result);
1950        if _result.is_err() {
1951            self.control_handle.shutdown();
1952        }
1953        self.drop_without_shutdown();
1954        _result
1955    }
1956
1957    /// Similar to "send" but does not shutdown the channel if an error occurs.
1958    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1959        let _result = self.send_raw(result);
1960        self.drop_without_shutdown();
1961        _result
1962    }
1963
1964    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1965        self.control_handle
1966            .inner
1967            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1968                result,
1969                self.tx_id,
1970                0x42f2265fb495497a,
1971                fidl::encoding::DynamicFlags::empty(),
1972            )
1973    }
1974}
1975
1976#[must_use = "FIDL methods require a response to be sent"]
1977#[derive(Debug)]
1978pub struct FakeClockControlResumeWithIncrementsResponder {
1979    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
1980    tx_id: u32,
1981}
1982
1983/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
1984/// if the responder is dropped without sending a response, so that the client
1985/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1986impl std::ops::Drop for FakeClockControlResumeWithIncrementsResponder {
1987    fn drop(&mut self) {
1988        self.control_handle.shutdown();
1989        // Safety: drops once, never accessed again
1990        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1991    }
1992}
1993
1994impl fidl::endpoints::Responder for FakeClockControlResumeWithIncrementsResponder {
1995    type ControlHandle = FakeClockControlControlHandle;
1996
1997    fn control_handle(&self) -> &FakeClockControlControlHandle {
1998        &self.control_handle
1999    }
2000
2001    fn drop_without_shutdown(mut self) {
2002        // Safety: drops once, never accessed again due to mem::forget
2003        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2004        // Prevent Drop from running (which would shut down the channel)
2005        std::mem::forget(self);
2006    }
2007}
2008
2009impl FakeClockControlResumeWithIncrementsResponder {
2010    /// Sends a response to the FIDL transaction.
2011    ///
2012    /// Sets the channel to shutdown if an error occurs.
2013    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2014        let _result = self.send_raw(result);
2015        if _result.is_err() {
2016            self.control_handle.shutdown();
2017        }
2018        self.drop_without_shutdown();
2019        _result
2020    }
2021
2022    /// Similar to "send" but does not shutdown the channel if an error occurs.
2023    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2024        let _result = self.send_raw(result);
2025        self.drop_without_shutdown();
2026        _result
2027    }
2028
2029    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2030        self.control_handle
2031            .inner
2032            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2033                result,
2034                self.tx_id,
2035                0x259be1eeba0bdd4a,
2036                fidl::encoding::DynamicFlags::empty(),
2037            )
2038    }
2039}
2040
2041#[must_use = "FIDL methods require a response to be sent"]
2042#[derive(Debug)]
2043pub struct FakeClockControlAddStopPointResponder {
2044    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2045    tx_id: u32,
2046}
2047
2048/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2049/// if the responder is dropped without sending a response, so that the client
2050/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2051impl std::ops::Drop for FakeClockControlAddStopPointResponder {
2052    fn drop(&mut self) {
2053        self.control_handle.shutdown();
2054        // Safety: drops once, never accessed again
2055        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2056    }
2057}
2058
2059impl fidl::endpoints::Responder for FakeClockControlAddStopPointResponder {
2060    type ControlHandle = FakeClockControlControlHandle;
2061
2062    fn control_handle(&self) -> &FakeClockControlControlHandle {
2063        &self.control_handle
2064    }
2065
2066    fn drop_without_shutdown(mut self) {
2067        // Safety: drops once, never accessed again due to mem::forget
2068        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2069        // Prevent Drop from running (which would shut down the channel)
2070        std::mem::forget(self);
2071    }
2072}
2073
2074impl FakeClockControlAddStopPointResponder {
2075    /// Sends a response to the FIDL transaction.
2076    ///
2077    /// Sets the channel to shutdown if an error occurs.
2078    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2079        let _result = self.send_raw(result);
2080        if _result.is_err() {
2081            self.control_handle.shutdown();
2082        }
2083        self.drop_without_shutdown();
2084        _result
2085    }
2086
2087    /// Similar to "send" but does not shutdown the channel if an error occurs.
2088    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2089        let _result = self.send_raw(result);
2090        self.drop_without_shutdown();
2091        _result
2092    }
2093
2094    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2095        self.control_handle
2096            .inner
2097            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2098                result,
2099                self.tx_id,
2100                0x3b52fe2cba8c4245,
2101                fidl::encoding::DynamicFlags::empty(),
2102            )
2103    }
2104}
2105
2106#[must_use = "FIDL methods require a response to be sent"]
2107#[derive(Debug)]
2108pub struct FakeClockControlPauseResponder {
2109    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2110    tx_id: u32,
2111}
2112
2113/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2114/// if the responder is dropped without sending a response, so that the client
2115/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2116impl std::ops::Drop for FakeClockControlPauseResponder {
2117    fn drop(&mut self) {
2118        self.control_handle.shutdown();
2119        // Safety: drops once, never accessed again
2120        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2121    }
2122}
2123
2124impl fidl::endpoints::Responder for FakeClockControlPauseResponder {
2125    type ControlHandle = FakeClockControlControlHandle;
2126
2127    fn control_handle(&self) -> &FakeClockControlControlHandle {
2128        &self.control_handle
2129    }
2130
2131    fn drop_without_shutdown(mut self) {
2132        // Safety: drops once, never accessed again due to mem::forget
2133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2134        // Prevent Drop from running (which would shut down the channel)
2135        std::mem::forget(self);
2136    }
2137}
2138
2139impl FakeClockControlPauseResponder {
2140    /// Sends a response to the FIDL transaction.
2141    ///
2142    /// Sets the channel to shutdown if an error occurs.
2143    pub fn send(self) -> Result<(), fidl::Error> {
2144        let _result = self.send_raw();
2145        if _result.is_err() {
2146            self.control_handle.shutdown();
2147        }
2148        self.drop_without_shutdown();
2149        _result
2150    }
2151
2152    /// Similar to "send" but does not shutdown the channel if an error occurs.
2153    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2154        let _result = self.send_raw();
2155        self.drop_without_shutdown();
2156        _result
2157    }
2158
2159    fn send_raw(&self) -> Result<(), fidl::Error> {
2160        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2161            (),
2162            self.tx_id,
2163            0x260df03b49199ba4,
2164            fidl::encoding::DynamicFlags::empty(),
2165        )
2166    }
2167}
2168
2169#[must_use = "FIDL methods require a response to be sent"]
2170#[derive(Debug)]
2171pub struct FakeClockControlIgnoreNamedDeadlineResponder {
2172    control_handle: std::mem::ManuallyDrop<FakeClockControlControlHandle>,
2173    tx_id: u32,
2174}
2175
2176/// Set the the channel to be shutdown (see [`FakeClockControlControlHandle::shutdown`])
2177/// if the responder is dropped without sending a response, so that the client
2178/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2179impl std::ops::Drop for FakeClockControlIgnoreNamedDeadlineResponder {
2180    fn drop(&mut self) {
2181        self.control_handle.shutdown();
2182        // Safety: drops once, never accessed again
2183        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2184    }
2185}
2186
2187impl fidl::endpoints::Responder for FakeClockControlIgnoreNamedDeadlineResponder {
2188    type ControlHandle = FakeClockControlControlHandle;
2189
2190    fn control_handle(&self) -> &FakeClockControlControlHandle {
2191        &self.control_handle
2192    }
2193
2194    fn drop_without_shutdown(mut self) {
2195        // Safety: drops once, never accessed again due to mem::forget
2196        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2197        // Prevent Drop from running (which would shut down the channel)
2198        std::mem::forget(self);
2199    }
2200}
2201
2202impl FakeClockControlIgnoreNamedDeadlineResponder {
2203    /// Sends a response to the FIDL transaction.
2204    ///
2205    /// Sets the channel to shutdown if an error occurs.
2206    pub fn send(self) -> Result<(), fidl::Error> {
2207        let _result = self.send_raw();
2208        if _result.is_err() {
2209            self.control_handle.shutdown();
2210        }
2211        self.drop_without_shutdown();
2212        _result
2213    }
2214
2215    /// Similar to "send" but does not shutdown the channel if an error occurs.
2216    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2217        let _result = self.send_raw();
2218        self.drop_without_shutdown();
2219        _result
2220    }
2221
2222    fn send_raw(&self) -> Result<(), fidl::Error> {
2223        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2224            (),
2225            self.tx_id,
2226            0x2e445152a80d44aa,
2227            fidl::encoding::DynamicFlags::empty(),
2228        )
2229    }
2230}
2231
2232mod internal {
2233    use super::*;
2234
2235    impl fidl::encoding::ResourceTypeMarker for FakeClockCancelEventRequest {
2236        type Borrowed<'a> = &'a mut Self;
2237        fn take_or_borrow<'a>(
2238            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2239        ) -> Self::Borrowed<'a> {
2240            value
2241        }
2242    }
2243
2244    unsafe impl fidl::encoding::TypeMarker for FakeClockCancelEventRequest {
2245        type Owned = Self;
2246
2247        #[inline(always)]
2248        fn inline_align(_context: fidl::encoding::Context) -> usize {
2249            4
2250        }
2251
2252        #[inline(always)]
2253        fn inline_size(_context: fidl::encoding::Context) -> usize {
2254            4
2255        }
2256    }
2257
2258    unsafe impl
2259        fidl::encoding::Encode<
2260            FakeClockCancelEventRequest,
2261            fidl::encoding::DefaultFuchsiaResourceDialect,
2262        > for &mut FakeClockCancelEventRequest
2263    {
2264        #[inline]
2265        unsafe fn encode(
2266            self,
2267            encoder: &mut fidl::encoding::Encoder<
2268                '_,
2269                fidl::encoding::DefaultFuchsiaResourceDialect,
2270            >,
2271            offset: usize,
2272            _depth: fidl::encoding::Depth,
2273        ) -> fidl::Result<()> {
2274            encoder.debug_check_bounds::<FakeClockCancelEventRequest>(offset);
2275            // Delegate to tuple encoding.
2276            fidl::encoding::Encode::<
2277                FakeClockCancelEventRequest,
2278                fidl::encoding::DefaultFuchsiaResourceDialect,
2279            >::encode(
2280                (<fidl::encoding::HandleType<
2281                    fidl::EventPair,
2282                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2283                    2147483648,
2284                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2285                    &mut self.event
2286                ),),
2287                encoder,
2288                offset,
2289                _depth,
2290            )
2291        }
2292    }
2293    unsafe impl<
2294            T0: fidl::encoding::Encode<
2295                fidl::encoding::HandleType<
2296                    fidl::EventPair,
2297                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2298                    2147483648,
2299                >,
2300                fidl::encoding::DefaultFuchsiaResourceDialect,
2301            >,
2302        >
2303        fidl::encoding::Encode<
2304            FakeClockCancelEventRequest,
2305            fidl::encoding::DefaultFuchsiaResourceDialect,
2306        > for (T0,)
2307    {
2308        #[inline]
2309        unsafe fn encode(
2310            self,
2311            encoder: &mut fidl::encoding::Encoder<
2312                '_,
2313                fidl::encoding::DefaultFuchsiaResourceDialect,
2314            >,
2315            offset: usize,
2316            depth: fidl::encoding::Depth,
2317        ) -> fidl::Result<()> {
2318            encoder.debug_check_bounds::<FakeClockCancelEventRequest>(offset);
2319            // Zero out padding regions. There's no need to apply masks
2320            // because the unmasked parts will be overwritten by fields.
2321            // Write the fields.
2322            self.0.encode(encoder, offset + 0, depth)?;
2323            Ok(())
2324        }
2325    }
2326
2327    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2328        for FakeClockCancelEventRequest
2329    {
2330        #[inline(always)]
2331        fn new_empty() -> Self {
2332            Self {
2333                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2334            }
2335        }
2336
2337        #[inline]
2338        unsafe fn decode(
2339            &mut self,
2340            decoder: &mut fidl::encoding::Decoder<
2341                '_,
2342                fidl::encoding::DefaultFuchsiaResourceDialect,
2343            >,
2344            offset: usize,
2345            _depth: fidl::encoding::Depth,
2346        ) -> fidl::Result<()> {
2347            decoder.debug_check_bounds::<Self>(offset);
2348            // Verify that padding bytes are zero.
2349            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
2350            Ok(())
2351        }
2352    }
2353
2354    impl fidl::encoding::ResourceTypeMarker for FakeClockControlAddStopPointRequest {
2355        type Borrowed<'a> = &'a mut Self;
2356        fn take_or_borrow<'a>(
2357            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2358        ) -> Self::Borrowed<'a> {
2359            value
2360        }
2361    }
2362
2363    unsafe impl fidl::encoding::TypeMarker for FakeClockControlAddStopPointRequest {
2364        type Owned = Self;
2365
2366        #[inline(always)]
2367        fn inline_align(_context: fidl::encoding::Context) -> usize {
2368            8
2369        }
2370
2371        #[inline(always)]
2372        fn inline_size(_context: fidl::encoding::Context) -> usize {
2373            40
2374        }
2375    }
2376
2377    unsafe impl
2378        fidl::encoding::Encode<
2379            FakeClockControlAddStopPointRequest,
2380            fidl::encoding::DefaultFuchsiaResourceDialect,
2381        > for &mut FakeClockControlAddStopPointRequest
2382    {
2383        #[inline]
2384        unsafe fn encode(
2385            self,
2386            encoder: &mut fidl::encoding::Encoder<
2387                '_,
2388                fidl::encoding::DefaultFuchsiaResourceDialect,
2389            >,
2390            offset: usize,
2391            _depth: fidl::encoding::Depth,
2392        ) -> fidl::Result<()> {
2393            encoder.debug_check_bounds::<FakeClockControlAddStopPointRequest>(offset);
2394            // Delegate to tuple encoding.
2395            fidl::encoding::Encode::<FakeClockControlAddStopPointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2396                (
2397                    <fidl_fuchsia_testing_deadline::DeadlineId as fidl::encoding::ValueTypeMarker>::borrow(&self.deadline_id),
2398                    <DeadlineEventType as fidl::encoding::ValueTypeMarker>::borrow(&self.event_type),
2399                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.on_stop),
2400                ),
2401                encoder, offset, _depth
2402            )
2403        }
2404    }
2405    unsafe impl<
2406            T0: fidl::encoding::Encode<
2407                fidl_fuchsia_testing_deadline::DeadlineId,
2408                fidl::encoding::DefaultFuchsiaResourceDialect,
2409            >,
2410            T1: fidl::encoding::Encode<
2411                DeadlineEventType,
2412                fidl::encoding::DefaultFuchsiaResourceDialect,
2413            >,
2414            T2: fidl::encoding::Encode<
2415                fidl::encoding::HandleType<
2416                    fidl::EventPair,
2417                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2418                    2147483648,
2419                >,
2420                fidl::encoding::DefaultFuchsiaResourceDialect,
2421            >,
2422        >
2423        fidl::encoding::Encode<
2424            FakeClockControlAddStopPointRequest,
2425            fidl::encoding::DefaultFuchsiaResourceDialect,
2426        > for (T0, T1, T2)
2427    {
2428        #[inline]
2429        unsafe fn encode(
2430            self,
2431            encoder: &mut fidl::encoding::Encoder<
2432                '_,
2433                fidl::encoding::DefaultFuchsiaResourceDialect,
2434            >,
2435            offset: usize,
2436            depth: fidl::encoding::Depth,
2437        ) -> fidl::Result<()> {
2438            encoder.debug_check_bounds::<FakeClockControlAddStopPointRequest>(offset);
2439            // Zero out padding regions. There's no need to apply masks
2440            // because the unmasked parts will be overwritten by fields.
2441            // Write the fields.
2442            self.0.encode(encoder, offset + 0, depth)?;
2443            self.1.encode(encoder, offset + 32, depth)?;
2444            self.2.encode(encoder, offset + 36, depth)?;
2445            Ok(())
2446        }
2447    }
2448
2449    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2450        for FakeClockControlAddStopPointRequest
2451    {
2452        #[inline(always)]
2453        fn new_empty() -> Self {
2454            Self {
2455                deadline_id: fidl::new_empty!(
2456                    fidl_fuchsia_testing_deadline::DeadlineId,
2457                    fidl::encoding::DefaultFuchsiaResourceDialect
2458                ),
2459                event_type: fidl::new_empty!(
2460                    DeadlineEventType,
2461                    fidl::encoding::DefaultFuchsiaResourceDialect
2462                ),
2463                on_stop: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2464            }
2465        }
2466
2467        #[inline]
2468        unsafe fn decode(
2469            &mut self,
2470            decoder: &mut fidl::encoding::Decoder<
2471                '_,
2472                fidl::encoding::DefaultFuchsiaResourceDialect,
2473            >,
2474            offset: usize,
2475            _depth: fidl::encoding::Depth,
2476        ) -> fidl::Result<()> {
2477            decoder.debug_check_bounds::<Self>(offset);
2478            // Verify that padding bytes are zero.
2479            fidl::decode!(
2480                fidl_fuchsia_testing_deadline::DeadlineId,
2481                fidl::encoding::DefaultFuchsiaResourceDialect,
2482                &mut self.deadline_id,
2483                decoder,
2484                offset + 0,
2485                _depth
2486            )?;
2487            fidl::decode!(
2488                DeadlineEventType,
2489                fidl::encoding::DefaultFuchsiaResourceDialect,
2490                &mut self.event_type,
2491                decoder,
2492                offset + 32,
2493                _depth
2494            )?;
2495            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.on_stop, decoder, offset + 36, _depth)?;
2496            Ok(())
2497        }
2498    }
2499
2500    impl fidl::encoding::ResourceTypeMarker for FakeClockRegisterEventRequest {
2501        type Borrowed<'a> = &'a mut Self;
2502        fn take_or_borrow<'a>(
2503            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2504        ) -> Self::Borrowed<'a> {
2505            value
2506        }
2507    }
2508
2509    unsafe impl fidl::encoding::TypeMarker for FakeClockRegisterEventRequest {
2510        type Owned = Self;
2511
2512        #[inline(always)]
2513        fn inline_align(_context: fidl::encoding::Context) -> usize {
2514            8
2515        }
2516
2517        #[inline(always)]
2518        fn inline_size(_context: fidl::encoding::Context) -> usize {
2519            16
2520        }
2521    }
2522
2523    unsafe impl
2524        fidl::encoding::Encode<
2525            FakeClockRegisterEventRequest,
2526            fidl::encoding::DefaultFuchsiaResourceDialect,
2527        > for &mut FakeClockRegisterEventRequest
2528    {
2529        #[inline]
2530        unsafe fn encode(
2531            self,
2532            encoder: &mut fidl::encoding::Encoder<
2533                '_,
2534                fidl::encoding::DefaultFuchsiaResourceDialect,
2535            >,
2536            offset: usize,
2537            _depth: fidl::encoding::Depth,
2538        ) -> fidl::Result<()> {
2539            encoder.debug_check_bounds::<FakeClockRegisterEventRequest>(offset);
2540            // Delegate to tuple encoding.
2541            fidl::encoding::Encode::<
2542                FakeClockRegisterEventRequest,
2543                fidl::encoding::DefaultFuchsiaResourceDialect,
2544            >::encode(
2545                (
2546                    <fidl::encoding::HandleType<
2547                        fidl::EventPair,
2548                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2549                        2147483648,
2550                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2551                        &mut self.event
2552                    ),
2553                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
2554                ),
2555                encoder,
2556                offset,
2557                _depth,
2558            )
2559        }
2560    }
2561    unsafe impl<
2562            T0: fidl::encoding::Encode<
2563                fidl::encoding::HandleType<
2564                    fidl::EventPair,
2565                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2566                    2147483648,
2567                >,
2568                fidl::encoding::DefaultFuchsiaResourceDialect,
2569            >,
2570            T1: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2571        >
2572        fidl::encoding::Encode<
2573            FakeClockRegisterEventRequest,
2574            fidl::encoding::DefaultFuchsiaResourceDialect,
2575        > for (T0, T1)
2576    {
2577        #[inline]
2578        unsafe fn encode(
2579            self,
2580            encoder: &mut fidl::encoding::Encoder<
2581                '_,
2582                fidl::encoding::DefaultFuchsiaResourceDialect,
2583            >,
2584            offset: usize,
2585            depth: fidl::encoding::Depth,
2586        ) -> fidl::Result<()> {
2587            encoder.debug_check_bounds::<FakeClockRegisterEventRequest>(offset);
2588            // Zero out padding regions. There's no need to apply masks
2589            // because the unmasked parts will be overwritten by fields.
2590            unsafe {
2591                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2592                (ptr as *mut u64).write_unaligned(0);
2593            }
2594            // Write the fields.
2595            self.0.encode(encoder, offset + 0, depth)?;
2596            self.1.encode(encoder, offset + 8, depth)?;
2597            Ok(())
2598        }
2599    }
2600
2601    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2602        for FakeClockRegisterEventRequest
2603    {
2604        #[inline(always)]
2605        fn new_empty() -> Self {
2606            Self {
2607                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2608                time: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
2609            }
2610        }
2611
2612        #[inline]
2613        unsafe fn decode(
2614            &mut self,
2615            decoder: &mut fidl::encoding::Decoder<
2616                '_,
2617                fidl::encoding::DefaultFuchsiaResourceDialect,
2618            >,
2619            offset: usize,
2620            _depth: fidl::encoding::Depth,
2621        ) -> fidl::Result<()> {
2622            decoder.debug_check_bounds::<Self>(offset);
2623            // Verify that padding bytes are zero.
2624            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2625            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2626            let mask = 0xffffffff00000000u64;
2627            let maskedval = padval & mask;
2628            if maskedval != 0 {
2629                return Err(fidl::Error::NonZeroPadding {
2630                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2631                });
2632            }
2633            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
2634            fidl::decode!(
2635                i64,
2636                fidl::encoding::DefaultFuchsiaResourceDialect,
2637                &mut self.time,
2638                decoder,
2639                offset + 8,
2640                _depth
2641            )?;
2642            Ok(())
2643        }
2644    }
2645
2646    impl fidl::encoding::ResourceTypeMarker for FakeClockRescheduleEventRequest {
2647        type Borrowed<'a> = &'a mut Self;
2648        fn take_or_borrow<'a>(
2649            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2650        ) -> Self::Borrowed<'a> {
2651            value
2652        }
2653    }
2654
2655    unsafe impl fidl::encoding::TypeMarker for FakeClockRescheduleEventRequest {
2656        type Owned = Self;
2657
2658        #[inline(always)]
2659        fn inline_align(_context: fidl::encoding::Context) -> usize {
2660            8
2661        }
2662
2663        #[inline(always)]
2664        fn inline_size(_context: fidl::encoding::Context) -> usize {
2665            16
2666        }
2667    }
2668
2669    unsafe impl
2670        fidl::encoding::Encode<
2671            FakeClockRescheduleEventRequest,
2672            fidl::encoding::DefaultFuchsiaResourceDialect,
2673        > for &mut FakeClockRescheduleEventRequest
2674    {
2675        #[inline]
2676        unsafe fn encode(
2677            self,
2678            encoder: &mut fidl::encoding::Encoder<
2679                '_,
2680                fidl::encoding::DefaultFuchsiaResourceDialect,
2681            >,
2682            offset: usize,
2683            _depth: fidl::encoding::Depth,
2684        ) -> fidl::Result<()> {
2685            encoder.debug_check_bounds::<FakeClockRescheduleEventRequest>(offset);
2686            // Delegate to tuple encoding.
2687            fidl::encoding::Encode::<
2688                FakeClockRescheduleEventRequest,
2689                fidl::encoding::DefaultFuchsiaResourceDialect,
2690            >::encode(
2691                (
2692                    <fidl::encoding::HandleType<
2693                        fidl::EventPair,
2694                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2695                        2147483648,
2696                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2697                        &mut self.event
2698                    ),
2699                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.time),
2700                ),
2701                encoder,
2702                offset,
2703                _depth,
2704            )
2705        }
2706    }
2707    unsafe impl<
2708            T0: fidl::encoding::Encode<
2709                fidl::encoding::HandleType<
2710                    fidl::EventPair,
2711                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2712                    2147483648,
2713                >,
2714                fidl::encoding::DefaultFuchsiaResourceDialect,
2715            >,
2716            T1: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2717        >
2718        fidl::encoding::Encode<
2719            FakeClockRescheduleEventRequest,
2720            fidl::encoding::DefaultFuchsiaResourceDialect,
2721        > for (T0, T1)
2722    {
2723        #[inline]
2724        unsafe fn encode(
2725            self,
2726            encoder: &mut fidl::encoding::Encoder<
2727                '_,
2728                fidl::encoding::DefaultFuchsiaResourceDialect,
2729            >,
2730            offset: usize,
2731            depth: fidl::encoding::Depth,
2732        ) -> fidl::Result<()> {
2733            encoder.debug_check_bounds::<FakeClockRescheduleEventRequest>(offset);
2734            // Zero out padding regions. There's no need to apply masks
2735            // because the unmasked parts will be overwritten by fields.
2736            unsafe {
2737                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2738                (ptr as *mut u64).write_unaligned(0);
2739            }
2740            // Write the fields.
2741            self.0.encode(encoder, offset + 0, depth)?;
2742            self.1.encode(encoder, offset + 8, depth)?;
2743            Ok(())
2744        }
2745    }
2746
2747    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2748        for FakeClockRescheduleEventRequest
2749    {
2750        #[inline(always)]
2751        fn new_empty() -> Self {
2752            Self {
2753                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2754                time: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
2755            }
2756        }
2757
2758        #[inline]
2759        unsafe fn decode(
2760            &mut self,
2761            decoder: &mut fidl::encoding::Decoder<
2762                '_,
2763                fidl::encoding::DefaultFuchsiaResourceDialect,
2764            >,
2765            offset: usize,
2766            _depth: fidl::encoding::Depth,
2767        ) -> fidl::Result<()> {
2768            decoder.debug_check_bounds::<Self>(offset);
2769            // Verify that padding bytes are zero.
2770            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2771            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2772            let mask = 0xffffffff00000000u64;
2773            let maskedval = padval & mask;
2774            if maskedval != 0 {
2775                return Err(fidl::Error::NonZeroPadding {
2776                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2777                });
2778            }
2779            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
2780            fidl::decode!(
2781                i64,
2782                fidl::encoding::DefaultFuchsiaResourceDialect,
2783                &mut self.time,
2784                decoder,
2785                offset + 8,
2786                _depth
2787            )?;
2788            Ok(())
2789        }
2790    }
2791}