fidl_test_time_realm/
fidl_test_time_realm.rs

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