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