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