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