Skip to main content

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