fidl_fuchsia_ui_test_context/
fidl_fuchsia_ui_test_context.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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// Renderer type passed to scenic.
14#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub enum RendererType {
16    /// Send all rendering operations to void.
17    Null,
18    /// Use CPU for rendering.
19    Cpu,
20    /// Use Vulkan for rendering.
21    Vulkan,
22    #[doc(hidden)]
23    __SourceBreaking { unknown_ordinal: u32 },
24}
25
26/// Pattern that matches an unknown `RendererType` member.
27#[macro_export]
28macro_rules! RendererTypeUnknown {
29    () => {
30        _
31    };
32}
33
34impl RendererType {
35    #[inline]
36    pub fn from_primitive(prim: u32) -> Option<Self> {
37        match prim {
38            0 => Some(Self::Null),
39            1 => Some(Self::Cpu),
40            2 => Some(Self::Vulkan),
41            _ => None,
42        }
43    }
44
45    #[inline]
46    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
47        match prim {
48            0 => Self::Null,
49            1 => Self::Cpu,
50            2 => Self::Vulkan,
51            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
52        }
53    }
54
55    #[inline]
56    pub fn unknown() -> Self {
57        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
58    }
59
60    #[inline]
61    pub const fn into_primitive(self) -> u32 {
62        match self {
63            Self::Null => 0,
64            Self::Cpu => 1,
65            Self::Vulkan => 2,
66            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
67        }
68    }
69
70    #[inline]
71    pub fn is_unknown(&self) -> bool {
72        match self {
73            Self::__SourceBreaking { unknown_ordinal: _ } => true,
74            _ => false,
75        }
76    }
77}
78
79#[derive(Debug, Default, PartialEq)]
80pub struct RealmFactoryCreateRealmRequest {
81    pub realm_server:
82        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>>,
83    pub display_rotation: Option<u32>,
84    pub device_pixel_ratio: Option<f32>,
85    #[doc(hidden)]
86    pub __source_breaking: fidl::marker::SourceBreaking,
87}
88
89impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
90    for RealmFactoryCreateRealmRequest
91{
92}
93
94#[derive(Debug, Default, PartialEq)]
95pub struct ScenicRealmFactoryCreateRealmRequest {
96    pub realm_server:
97        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>>,
98    pub renderer: Option<RendererType>,
99    pub display_rotation: Option<u64>,
100    pub display_composition: Option<bool>,
101    #[doc(hidden)]
102    pub __source_breaking: fidl::marker::SourceBreaking,
103}
104
105impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
106    for ScenicRealmFactoryCreateRealmRequest
107{
108}
109
110#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
111pub struct RealmFactoryMarker;
112
113impl fidl::endpoints::ProtocolMarker for RealmFactoryMarker {
114    type Proxy = RealmFactoryProxy;
115    type RequestStream = RealmFactoryRequestStream;
116    #[cfg(target_os = "fuchsia")]
117    type SynchronousProxy = RealmFactorySynchronousProxy;
118
119    const DEBUG_NAME: &'static str = "fuchsia.ui.test.context.RealmFactory";
120}
121impl fidl::endpoints::DiscoverableProtocolMarker for RealmFactoryMarker {}
122pub type RealmFactoryCreateRealmResult = Result<(), fidl_fuchsia_testing_harness::OperationError>;
123
124pub trait RealmFactoryProxyInterface: Send + Sync {
125    type CreateRealmResponseFut: std::future::Future<Output = Result<RealmFactoryCreateRealmResult, fidl::Error>>
126        + Send;
127    fn r#create_realm(
128        &self,
129        payload: RealmFactoryCreateRealmRequest,
130    ) -> Self::CreateRealmResponseFut;
131}
132#[derive(Debug)]
133#[cfg(target_os = "fuchsia")]
134pub struct RealmFactorySynchronousProxy {
135    client: fidl::client::sync::Client,
136}
137
138#[cfg(target_os = "fuchsia")]
139impl fidl::endpoints::SynchronousProxy for RealmFactorySynchronousProxy {
140    type Proxy = RealmFactoryProxy;
141    type Protocol = RealmFactoryMarker;
142
143    fn from_channel(inner: fidl::Channel) -> Self {
144        Self::new(inner)
145    }
146
147    fn into_channel(self) -> fidl::Channel {
148        self.client.into_channel()
149    }
150
151    fn as_channel(&self) -> &fidl::Channel {
152        self.client.as_channel()
153    }
154}
155
156#[cfg(target_os = "fuchsia")]
157impl RealmFactorySynchronousProxy {
158    pub fn new(channel: fidl::Channel) -> Self {
159        let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
160        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
161    }
162
163    pub fn into_channel(self) -> fidl::Channel {
164        self.client.into_channel()
165    }
166
167    /// Waits until an event arrives and returns it. It is safe for other
168    /// threads to make concurrent requests while waiting for an event.
169    pub fn wait_for_event(
170        &self,
171        deadline: zx::MonotonicInstant,
172    ) -> Result<RealmFactoryEvent, fidl::Error> {
173        RealmFactoryEvent::decode(self.client.wait_for_event(deadline)?)
174    }
175
176    pub fn r#create_realm(
177        &self,
178        mut payload: RealmFactoryCreateRealmRequest,
179        ___deadline: zx::MonotonicInstant,
180    ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
181        let _response = self
182            .client
183            .send_query::<RealmFactoryCreateRealmRequest, fidl::encoding::FlexibleResultType<
184                fidl::encoding::EmptyStruct,
185                fidl_fuchsia_testing_harness::OperationError,
186            >>(
187                &mut payload,
188                0x6e1c904f44c7d0fc,
189                fidl::encoding::DynamicFlags::FLEXIBLE,
190                ___deadline,
191            )?
192            .into_result::<RealmFactoryMarker>("create_realm")?;
193        Ok(_response.map(|x| x))
194    }
195}
196
197#[derive(Debug, Clone)]
198pub struct RealmFactoryProxy {
199    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
200}
201
202impl fidl::endpoints::Proxy for RealmFactoryProxy {
203    type Protocol = RealmFactoryMarker;
204
205    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
206        Self::new(inner)
207    }
208
209    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
210        self.client.into_channel().map_err(|client| Self { client })
211    }
212
213    fn as_channel(&self) -> &::fidl::AsyncChannel {
214        self.client.as_channel()
215    }
216}
217
218impl RealmFactoryProxy {
219    /// Create a new Proxy for fuchsia.ui.test.context/RealmFactory.
220    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
221        let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
222        Self { client: fidl::client::Client::new(channel, protocol_name) }
223    }
224
225    /// Get a Stream of events from the remote end of the protocol.
226    ///
227    /// # Panics
228    ///
229    /// Panics if the event stream was already taken.
230    pub fn take_event_stream(&self) -> RealmFactoryEventStream {
231        RealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
232    }
233
234    pub fn r#create_realm(
235        &self,
236        mut payload: RealmFactoryCreateRealmRequest,
237    ) -> fidl::client::QueryResponseFut<
238        RealmFactoryCreateRealmResult,
239        fidl::encoding::DefaultFuchsiaResourceDialect,
240    > {
241        RealmFactoryProxyInterface::r#create_realm(self, payload)
242    }
243}
244
245impl RealmFactoryProxyInterface for RealmFactoryProxy {
246    type CreateRealmResponseFut = fidl::client::QueryResponseFut<
247        RealmFactoryCreateRealmResult,
248        fidl::encoding::DefaultFuchsiaResourceDialect,
249    >;
250    fn r#create_realm(
251        &self,
252        mut payload: RealmFactoryCreateRealmRequest,
253    ) -> Self::CreateRealmResponseFut {
254        fn _decode(
255            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
256        ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
257            let _response = fidl::client::decode_transaction_body::<
258                fidl::encoding::FlexibleResultType<
259                    fidl::encoding::EmptyStruct,
260                    fidl_fuchsia_testing_harness::OperationError,
261                >,
262                fidl::encoding::DefaultFuchsiaResourceDialect,
263                0x6e1c904f44c7d0fc,
264            >(_buf?)?
265            .into_result::<RealmFactoryMarker>("create_realm")?;
266            Ok(_response.map(|x| x))
267        }
268        self.client
269            .send_query_and_decode::<RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResult>(
270                &mut payload,
271                0x6e1c904f44c7d0fc,
272                fidl::encoding::DynamicFlags::FLEXIBLE,
273                _decode,
274            )
275    }
276}
277
278pub struct RealmFactoryEventStream {
279    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
280}
281
282impl std::marker::Unpin for RealmFactoryEventStream {}
283
284impl futures::stream::FusedStream for RealmFactoryEventStream {
285    fn is_terminated(&self) -> bool {
286        self.event_receiver.is_terminated()
287    }
288}
289
290impl futures::Stream for RealmFactoryEventStream {
291    type Item = Result<RealmFactoryEvent, fidl::Error>;
292
293    fn poll_next(
294        mut self: std::pin::Pin<&mut Self>,
295        cx: &mut std::task::Context<'_>,
296    ) -> std::task::Poll<Option<Self::Item>> {
297        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
298            &mut self.event_receiver,
299            cx
300        )?) {
301            Some(buf) => std::task::Poll::Ready(Some(RealmFactoryEvent::decode(buf))),
302            None => std::task::Poll::Ready(None),
303        }
304    }
305}
306
307#[derive(Debug)]
308pub enum RealmFactoryEvent {
309    #[non_exhaustive]
310    _UnknownEvent {
311        /// Ordinal of the event that was sent.
312        ordinal: u64,
313    },
314}
315
316impl RealmFactoryEvent {
317    /// Decodes a message buffer as a [`RealmFactoryEvent`].
318    fn decode(
319        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
320    ) -> Result<RealmFactoryEvent, fidl::Error> {
321        let (bytes, _handles) = buf.split_mut();
322        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
323        debug_assert_eq!(tx_header.tx_id, 0);
324        match tx_header.ordinal {
325            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
326                Ok(RealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
327            }
328            _ => Err(fidl::Error::UnknownOrdinal {
329                ordinal: tx_header.ordinal,
330                protocol_name: <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
331            }),
332        }
333    }
334}
335
336/// A Stream of incoming requests for fuchsia.ui.test.context/RealmFactory.
337pub struct RealmFactoryRequestStream {
338    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
339    is_terminated: bool,
340}
341
342impl std::marker::Unpin for RealmFactoryRequestStream {}
343
344impl futures::stream::FusedStream for RealmFactoryRequestStream {
345    fn is_terminated(&self) -> bool {
346        self.is_terminated
347    }
348}
349
350impl fidl::endpoints::RequestStream for RealmFactoryRequestStream {
351    type Protocol = RealmFactoryMarker;
352    type ControlHandle = RealmFactoryControlHandle;
353
354    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
355        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
356    }
357
358    fn control_handle(&self) -> Self::ControlHandle {
359        RealmFactoryControlHandle { inner: self.inner.clone() }
360    }
361
362    fn into_inner(
363        self,
364    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
365    {
366        (self.inner, self.is_terminated)
367    }
368
369    fn from_inner(
370        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
371        is_terminated: bool,
372    ) -> Self {
373        Self { inner, is_terminated }
374    }
375}
376
377impl futures::Stream for RealmFactoryRequestStream {
378    type Item = Result<RealmFactoryRequest, fidl::Error>;
379
380    fn poll_next(
381        mut self: std::pin::Pin<&mut Self>,
382        cx: &mut std::task::Context<'_>,
383    ) -> std::task::Poll<Option<Self::Item>> {
384        let this = &mut *self;
385        if this.inner.check_shutdown(cx) {
386            this.is_terminated = true;
387            return std::task::Poll::Ready(None);
388        }
389        if this.is_terminated {
390            panic!("polled RealmFactoryRequestStream after completion");
391        }
392        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
393            |bytes, handles| {
394                match this.inner.channel().read_etc(cx, bytes, handles) {
395                    std::task::Poll::Ready(Ok(())) => {}
396                    std::task::Poll::Pending => return std::task::Poll::Pending,
397                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
398                        this.is_terminated = true;
399                        return std::task::Poll::Ready(None);
400                    }
401                    std::task::Poll::Ready(Err(e)) => {
402                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
403                            e.into(),
404                        ))))
405                    }
406                }
407
408                // A message has been received from the channel
409                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
410
411                std::task::Poll::Ready(Some(match header.ordinal {
412                    0x6e1c904f44c7d0fc => {
413                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
414                        let mut req = fidl::new_empty!(
415                            RealmFactoryCreateRealmRequest,
416                            fidl::encoding::DefaultFuchsiaResourceDialect
417                        );
418                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
419                        let control_handle =
420                            RealmFactoryControlHandle { inner: this.inner.clone() };
421                        Ok(RealmFactoryRequest::CreateRealm {
422                            payload: req,
423                            responder: RealmFactoryCreateRealmResponder {
424                                control_handle: std::mem::ManuallyDrop::new(control_handle),
425                                tx_id: header.tx_id,
426                            },
427                        })
428                    }
429                    _ if header.tx_id == 0
430                        && header
431                            .dynamic_flags()
432                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
433                    {
434                        Ok(RealmFactoryRequest::_UnknownMethod {
435                            ordinal: header.ordinal,
436                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
437                            method_type: fidl::MethodType::OneWay,
438                        })
439                    }
440                    _ if header
441                        .dynamic_flags()
442                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
443                    {
444                        this.inner.send_framework_err(
445                            fidl::encoding::FrameworkErr::UnknownMethod,
446                            header.tx_id,
447                            header.ordinal,
448                            header.dynamic_flags(),
449                            (bytes, handles),
450                        )?;
451                        Ok(RealmFactoryRequest::_UnknownMethod {
452                            ordinal: header.ordinal,
453                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
454                            method_type: fidl::MethodType::TwoWay,
455                        })
456                    }
457                    _ => Err(fidl::Error::UnknownOrdinal {
458                        ordinal: header.ordinal,
459                        protocol_name:
460                            <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
461                    }),
462                }))
463            },
464        )
465    }
466}
467
468/// RealmFactory creates test realm for UI related tests, and give the realm
469/// proxy to test suite so that test suite can access protocols in test realm.
470/// Protocols served by Scenic, SceneManager and A11yManager are available.
471#[derive(Debug)]
472pub enum RealmFactoryRequest {
473    CreateRealm {
474        payload: RealmFactoryCreateRealmRequest,
475        responder: RealmFactoryCreateRealmResponder,
476    },
477    /// An interaction was received which does not match any known method.
478    #[non_exhaustive]
479    _UnknownMethod {
480        /// Ordinal of the method that was called.
481        ordinal: u64,
482        control_handle: RealmFactoryControlHandle,
483        method_type: fidl::MethodType,
484    },
485}
486
487impl RealmFactoryRequest {
488    #[allow(irrefutable_let_patterns)]
489    pub fn into_create_realm(
490        self,
491    ) -> Option<(RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResponder)> {
492        if let RealmFactoryRequest::CreateRealm { payload, responder } = self {
493            Some((payload, responder))
494        } else {
495            None
496        }
497    }
498
499    /// Name of the method defined in FIDL
500    pub fn method_name(&self) -> &'static str {
501        match *self {
502            RealmFactoryRequest::CreateRealm { .. } => "create_realm",
503            RealmFactoryRequest::_UnknownMethod {
504                method_type: fidl::MethodType::OneWay, ..
505            } => "unknown one-way method",
506            RealmFactoryRequest::_UnknownMethod {
507                method_type: fidl::MethodType::TwoWay, ..
508            } => "unknown two-way method",
509        }
510    }
511}
512
513#[derive(Debug, Clone)]
514pub struct RealmFactoryControlHandle {
515    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
516}
517
518impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
519    fn shutdown(&self) {
520        self.inner.shutdown()
521    }
522    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
523        self.inner.shutdown_with_epitaph(status)
524    }
525
526    fn is_closed(&self) -> bool {
527        self.inner.channel().is_closed()
528    }
529    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
530        self.inner.channel().on_closed()
531    }
532
533    #[cfg(target_os = "fuchsia")]
534    fn signal_peer(
535        &self,
536        clear_mask: zx::Signals,
537        set_mask: zx::Signals,
538    ) -> Result<(), zx_status::Status> {
539        use fidl::Peered;
540        self.inner.channel().signal_peer(clear_mask, set_mask)
541    }
542}
543
544impl RealmFactoryControlHandle {}
545
546#[must_use = "FIDL methods require a response to be sent"]
547#[derive(Debug)]
548pub struct RealmFactoryCreateRealmResponder {
549    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
550    tx_id: u32,
551}
552
553/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
554/// if the responder is dropped without sending a response, so that the client
555/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
556impl std::ops::Drop for RealmFactoryCreateRealmResponder {
557    fn drop(&mut self) {
558        self.control_handle.shutdown();
559        // Safety: drops once, never accessed again
560        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
561    }
562}
563
564impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
565    type ControlHandle = RealmFactoryControlHandle;
566
567    fn control_handle(&self) -> &RealmFactoryControlHandle {
568        &self.control_handle
569    }
570
571    fn drop_without_shutdown(mut self) {
572        // Safety: drops once, never accessed again due to mem::forget
573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
574        // Prevent Drop from running (which would shut down the channel)
575        std::mem::forget(self);
576    }
577}
578
579impl RealmFactoryCreateRealmResponder {
580    /// Sends a response to the FIDL transaction.
581    ///
582    /// Sets the channel to shutdown if an error occurs.
583    pub fn send(
584        self,
585        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
586    ) -> Result<(), fidl::Error> {
587        let _result = self.send_raw(result);
588        if _result.is_err() {
589            self.control_handle.shutdown();
590        }
591        self.drop_without_shutdown();
592        _result
593    }
594
595    /// Similar to "send" but does not shutdown the channel if an error occurs.
596    pub fn send_no_shutdown_on_err(
597        self,
598        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
599    ) -> Result<(), fidl::Error> {
600        let _result = self.send_raw(result);
601        self.drop_without_shutdown();
602        _result
603    }
604
605    fn send_raw(
606        &self,
607        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
608    ) -> Result<(), fidl::Error> {
609        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
610            fidl::encoding::EmptyStruct,
611            fidl_fuchsia_testing_harness::OperationError,
612        >>(
613            fidl::encoding::FlexibleResult::new(result),
614            self.tx_id,
615            0x6e1c904f44c7d0fc,
616            fidl::encoding::DynamicFlags::FLEXIBLE,
617        )
618    }
619}
620
621#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
622pub struct ScenicRealmFactoryMarker;
623
624impl fidl::endpoints::ProtocolMarker for ScenicRealmFactoryMarker {
625    type Proxy = ScenicRealmFactoryProxy;
626    type RequestStream = ScenicRealmFactoryRequestStream;
627    #[cfg(target_os = "fuchsia")]
628    type SynchronousProxy = ScenicRealmFactorySynchronousProxy;
629
630    const DEBUG_NAME: &'static str = "fuchsia.ui.test.context.ScenicRealmFactory";
631}
632impl fidl::endpoints::DiscoverableProtocolMarker for ScenicRealmFactoryMarker {}
633pub type ScenicRealmFactoryCreateRealmResult =
634    Result<(), fidl_fuchsia_testing_harness::OperationError>;
635
636pub trait ScenicRealmFactoryProxyInterface: Send + Sync {
637    type CreateRealmResponseFut: std::future::Future<Output = Result<ScenicRealmFactoryCreateRealmResult, fidl::Error>>
638        + Send;
639    fn r#create_realm(
640        &self,
641        payload: ScenicRealmFactoryCreateRealmRequest,
642    ) -> Self::CreateRealmResponseFut;
643}
644#[derive(Debug)]
645#[cfg(target_os = "fuchsia")]
646pub struct ScenicRealmFactorySynchronousProxy {
647    client: fidl::client::sync::Client,
648}
649
650#[cfg(target_os = "fuchsia")]
651impl fidl::endpoints::SynchronousProxy for ScenicRealmFactorySynchronousProxy {
652    type Proxy = ScenicRealmFactoryProxy;
653    type Protocol = ScenicRealmFactoryMarker;
654
655    fn from_channel(inner: fidl::Channel) -> Self {
656        Self::new(inner)
657    }
658
659    fn into_channel(self) -> fidl::Channel {
660        self.client.into_channel()
661    }
662
663    fn as_channel(&self) -> &fidl::Channel {
664        self.client.as_channel()
665    }
666}
667
668#[cfg(target_os = "fuchsia")]
669impl ScenicRealmFactorySynchronousProxy {
670    pub fn new(channel: fidl::Channel) -> Self {
671        let protocol_name =
672            <ScenicRealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
673        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
674    }
675
676    pub fn into_channel(self) -> fidl::Channel {
677        self.client.into_channel()
678    }
679
680    /// Waits until an event arrives and returns it. It is safe for other
681    /// threads to make concurrent requests while waiting for an event.
682    pub fn wait_for_event(
683        &self,
684        deadline: zx::MonotonicInstant,
685    ) -> Result<ScenicRealmFactoryEvent, fidl::Error> {
686        ScenicRealmFactoryEvent::decode(self.client.wait_for_event(deadline)?)
687    }
688
689    pub fn r#create_realm(
690        &self,
691        mut payload: ScenicRealmFactoryCreateRealmRequest,
692        ___deadline: zx::MonotonicInstant,
693    ) -> Result<ScenicRealmFactoryCreateRealmResult, fidl::Error> {
694        let _response = self
695            .client
696            .send_query::<ScenicRealmFactoryCreateRealmRequest, fidl::encoding::FlexibleResultType<
697                fidl::encoding::EmptyStruct,
698                fidl_fuchsia_testing_harness::OperationError,
699            >>(
700                &mut payload,
701                0x11f2157d1648e6ba,
702                fidl::encoding::DynamicFlags::FLEXIBLE,
703                ___deadline,
704            )?
705            .into_result::<ScenicRealmFactoryMarker>("create_realm")?;
706        Ok(_response.map(|x| x))
707    }
708}
709
710#[derive(Debug, Clone)]
711pub struct ScenicRealmFactoryProxy {
712    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
713}
714
715impl fidl::endpoints::Proxy for ScenicRealmFactoryProxy {
716    type Protocol = ScenicRealmFactoryMarker;
717
718    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
719        Self::new(inner)
720    }
721
722    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
723        self.client.into_channel().map_err(|client| Self { client })
724    }
725
726    fn as_channel(&self) -> &::fidl::AsyncChannel {
727        self.client.as_channel()
728    }
729}
730
731impl ScenicRealmFactoryProxy {
732    /// Create a new Proxy for fuchsia.ui.test.context/ScenicRealmFactory.
733    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
734        let protocol_name =
735            <ScenicRealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
736        Self { client: fidl::client::Client::new(channel, protocol_name) }
737    }
738
739    /// Get a Stream of events from the remote end of the protocol.
740    ///
741    /// # Panics
742    ///
743    /// Panics if the event stream was already taken.
744    pub fn take_event_stream(&self) -> ScenicRealmFactoryEventStream {
745        ScenicRealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
746    }
747
748    pub fn r#create_realm(
749        &self,
750        mut payload: ScenicRealmFactoryCreateRealmRequest,
751    ) -> fidl::client::QueryResponseFut<
752        ScenicRealmFactoryCreateRealmResult,
753        fidl::encoding::DefaultFuchsiaResourceDialect,
754    > {
755        ScenicRealmFactoryProxyInterface::r#create_realm(self, payload)
756    }
757}
758
759impl ScenicRealmFactoryProxyInterface for ScenicRealmFactoryProxy {
760    type CreateRealmResponseFut = fidl::client::QueryResponseFut<
761        ScenicRealmFactoryCreateRealmResult,
762        fidl::encoding::DefaultFuchsiaResourceDialect,
763    >;
764    fn r#create_realm(
765        &self,
766        mut payload: ScenicRealmFactoryCreateRealmRequest,
767    ) -> Self::CreateRealmResponseFut {
768        fn _decode(
769            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
770        ) -> Result<ScenicRealmFactoryCreateRealmResult, fidl::Error> {
771            let _response = fidl::client::decode_transaction_body::<
772                fidl::encoding::FlexibleResultType<
773                    fidl::encoding::EmptyStruct,
774                    fidl_fuchsia_testing_harness::OperationError,
775                >,
776                fidl::encoding::DefaultFuchsiaResourceDialect,
777                0x11f2157d1648e6ba,
778            >(_buf?)?
779            .into_result::<ScenicRealmFactoryMarker>("create_realm")?;
780            Ok(_response.map(|x| x))
781        }
782        self.client.send_query_and_decode::<
783            ScenicRealmFactoryCreateRealmRequest,
784            ScenicRealmFactoryCreateRealmResult,
785        >(
786            &mut payload,
787            0x11f2157d1648e6ba,
788            fidl::encoding::DynamicFlags::FLEXIBLE,
789            _decode,
790        )
791    }
792}
793
794pub struct ScenicRealmFactoryEventStream {
795    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
796}
797
798impl std::marker::Unpin for ScenicRealmFactoryEventStream {}
799
800impl futures::stream::FusedStream for ScenicRealmFactoryEventStream {
801    fn is_terminated(&self) -> bool {
802        self.event_receiver.is_terminated()
803    }
804}
805
806impl futures::Stream for ScenicRealmFactoryEventStream {
807    type Item = Result<ScenicRealmFactoryEvent, fidl::Error>;
808
809    fn poll_next(
810        mut self: std::pin::Pin<&mut Self>,
811        cx: &mut std::task::Context<'_>,
812    ) -> std::task::Poll<Option<Self::Item>> {
813        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
814            &mut self.event_receiver,
815            cx
816        )?) {
817            Some(buf) => std::task::Poll::Ready(Some(ScenicRealmFactoryEvent::decode(buf))),
818            None => std::task::Poll::Ready(None),
819        }
820    }
821}
822
823#[derive(Debug)]
824pub enum ScenicRealmFactoryEvent {
825    #[non_exhaustive]
826    _UnknownEvent {
827        /// Ordinal of the event that was sent.
828        ordinal: u64,
829    },
830}
831
832impl ScenicRealmFactoryEvent {
833    /// Decodes a message buffer as a [`ScenicRealmFactoryEvent`].
834    fn decode(
835        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
836    ) -> Result<ScenicRealmFactoryEvent, fidl::Error> {
837        let (bytes, _handles) = buf.split_mut();
838        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
839        debug_assert_eq!(tx_header.tx_id, 0);
840        match tx_header.ordinal {
841            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
842                Ok(ScenicRealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
843            }
844            _ => Err(fidl::Error::UnknownOrdinal {
845                ordinal: tx_header.ordinal,
846                protocol_name:
847                    <ScenicRealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
848            }),
849        }
850    }
851}
852
853/// A Stream of incoming requests for fuchsia.ui.test.context/ScenicRealmFactory.
854pub struct ScenicRealmFactoryRequestStream {
855    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
856    is_terminated: bool,
857}
858
859impl std::marker::Unpin for ScenicRealmFactoryRequestStream {}
860
861impl futures::stream::FusedStream for ScenicRealmFactoryRequestStream {
862    fn is_terminated(&self) -> bool {
863        self.is_terminated
864    }
865}
866
867impl fidl::endpoints::RequestStream for ScenicRealmFactoryRequestStream {
868    type Protocol = ScenicRealmFactoryMarker;
869    type ControlHandle = ScenicRealmFactoryControlHandle;
870
871    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
872        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
873    }
874
875    fn control_handle(&self) -> Self::ControlHandle {
876        ScenicRealmFactoryControlHandle { inner: self.inner.clone() }
877    }
878
879    fn into_inner(
880        self,
881    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
882    {
883        (self.inner, self.is_terminated)
884    }
885
886    fn from_inner(
887        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
888        is_terminated: bool,
889    ) -> Self {
890        Self { inner, is_terminated }
891    }
892}
893
894impl futures::Stream for ScenicRealmFactoryRequestStream {
895    type Item = Result<ScenicRealmFactoryRequest, fidl::Error>;
896
897    fn poll_next(
898        mut self: std::pin::Pin<&mut Self>,
899        cx: &mut std::task::Context<'_>,
900    ) -> std::task::Poll<Option<Self::Item>> {
901        let this = &mut *self;
902        if this.inner.check_shutdown(cx) {
903            this.is_terminated = true;
904            return std::task::Poll::Ready(None);
905        }
906        if this.is_terminated {
907            panic!("polled ScenicRealmFactoryRequestStream after completion");
908        }
909        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
910            |bytes, handles| {
911                match this.inner.channel().read_etc(cx, bytes, handles) {
912                    std::task::Poll::Ready(Ok(())) => {}
913                    std::task::Poll::Pending => return std::task::Poll::Pending,
914                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
915                        this.is_terminated = true;
916                        return std::task::Poll::Ready(None);
917                    }
918                    std::task::Poll::Ready(Err(e)) => {
919                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
920                            e.into(),
921                        ))))
922                    }
923                }
924
925                // A message has been received from the channel
926                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
927
928                std::task::Poll::Ready(Some(match header.ordinal {
929                0x11f2157d1648e6ba => {
930                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
931                    let mut req = fidl::new_empty!(ScenicRealmFactoryCreateRealmRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
932                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScenicRealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
933                    let control_handle = ScenicRealmFactoryControlHandle {
934                        inner: this.inner.clone(),
935                    };
936                    Ok(ScenicRealmFactoryRequest::CreateRealm {payload: req,
937                        responder: ScenicRealmFactoryCreateRealmResponder {
938                            control_handle: std::mem::ManuallyDrop::new(control_handle),
939                            tx_id: header.tx_id,
940                        },
941                    })
942                }
943                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
944                    Ok(ScenicRealmFactoryRequest::_UnknownMethod {
945                        ordinal: header.ordinal,
946                        control_handle: ScenicRealmFactoryControlHandle { inner: this.inner.clone() },
947                        method_type: fidl::MethodType::OneWay,
948                    })
949                }
950                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
951                    this.inner.send_framework_err(
952                        fidl::encoding::FrameworkErr::UnknownMethod,
953                        header.tx_id,
954                        header.ordinal,
955                        header.dynamic_flags(),
956                        (bytes, handles),
957                    )?;
958                    Ok(ScenicRealmFactoryRequest::_UnknownMethod {
959                        ordinal: header.ordinal,
960                        control_handle: ScenicRealmFactoryControlHandle { inner: this.inner.clone() },
961                        method_type: fidl::MethodType::TwoWay,
962                    })
963                }
964                _ => Err(fidl::Error::UnknownOrdinal {
965                    ordinal: header.ordinal,
966                    protocol_name: <ScenicRealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
967                }),
968            }))
969            },
970        )
971    }
972}
973
974/// ScenicRealmFactory creates test realm for Scenic related tests, and give
975/// the realm proxy to test suite so that test suite can access protocols in
976/// test realm. Only the protocols served by Scenic are available.
977#[derive(Debug)]
978pub enum ScenicRealmFactoryRequest {
979    CreateRealm {
980        payload: ScenicRealmFactoryCreateRealmRequest,
981        responder: ScenicRealmFactoryCreateRealmResponder,
982    },
983    /// An interaction was received which does not match any known method.
984    #[non_exhaustive]
985    _UnknownMethod {
986        /// Ordinal of the method that was called.
987        ordinal: u64,
988        control_handle: ScenicRealmFactoryControlHandle,
989        method_type: fidl::MethodType,
990    },
991}
992
993impl ScenicRealmFactoryRequest {
994    #[allow(irrefutable_let_patterns)]
995    pub fn into_create_realm(
996        self,
997    ) -> Option<(ScenicRealmFactoryCreateRealmRequest, ScenicRealmFactoryCreateRealmResponder)>
998    {
999        if let ScenicRealmFactoryRequest::CreateRealm { payload, responder } = self {
1000            Some((payload, responder))
1001        } else {
1002            None
1003        }
1004    }
1005
1006    /// Name of the method defined in FIDL
1007    pub fn method_name(&self) -> &'static str {
1008        match *self {
1009            ScenicRealmFactoryRequest::CreateRealm { .. } => "create_realm",
1010            ScenicRealmFactoryRequest::_UnknownMethod {
1011                method_type: fidl::MethodType::OneWay,
1012                ..
1013            } => "unknown one-way method",
1014            ScenicRealmFactoryRequest::_UnknownMethod {
1015                method_type: fidl::MethodType::TwoWay,
1016                ..
1017            } => "unknown two-way method",
1018        }
1019    }
1020}
1021
1022#[derive(Debug, Clone)]
1023pub struct ScenicRealmFactoryControlHandle {
1024    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1025}
1026
1027impl fidl::endpoints::ControlHandle for ScenicRealmFactoryControlHandle {
1028    fn shutdown(&self) {
1029        self.inner.shutdown()
1030    }
1031    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1032        self.inner.shutdown_with_epitaph(status)
1033    }
1034
1035    fn is_closed(&self) -> bool {
1036        self.inner.channel().is_closed()
1037    }
1038    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1039        self.inner.channel().on_closed()
1040    }
1041
1042    #[cfg(target_os = "fuchsia")]
1043    fn signal_peer(
1044        &self,
1045        clear_mask: zx::Signals,
1046        set_mask: zx::Signals,
1047    ) -> Result<(), zx_status::Status> {
1048        use fidl::Peered;
1049        self.inner.channel().signal_peer(clear_mask, set_mask)
1050    }
1051}
1052
1053impl ScenicRealmFactoryControlHandle {}
1054
1055#[must_use = "FIDL methods require a response to be sent"]
1056#[derive(Debug)]
1057pub struct ScenicRealmFactoryCreateRealmResponder {
1058    control_handle: std::mem::ManuallyDrop<ScenicRealmFactoryControlHandle>,
1059    tx_id: u32,
1060}
1061
1062/// Set the the channel to be shutdown (see [`ScenicRealmFactoryControlHandle::shutdown`])
1063/// if the responder is dropped without sending a response, so that the client
1064/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1065impl std::ops::Drop for ScenicRealmFactoryCreateRealmResponder {
1066    fn drop(&mut self) {
1067        self.control_handle.shutdown();
1068        // Safety: drops once, never accessed again
1069        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1070    }
1071}
1072
1073impl fidl::endpoints::Responder for ScenicRealmFactoryCreateRealmResponder {
1074    type ControlHandle = ScenicRealmFactoryControlHandle;
1075
1076    fn control_handle(&self) -> &ScenicRealmFactoryControlHandle {
1077        &self.control_handle
1078    }
1079
1080    fn drop_without_shutdown(mut self) {
1081        // Safety: drops once, never accessed again due to mem::forget
1082        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1083        // Prevent Drop from running (which would shut down the channel)
1084        std::mem::forget(self);
1085    }
1086}
1087
1088impl ScenicRealmFactoryCreateRealmResponder {
1089    /// Sends a response to the FIDL transaction.
1090    ///
1091    /// Sets the channel to shutdown if an error occurs.
1092    pub fn send(
1093        self,
1094        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
1095    ) -> Result<(), fidl::Error> {
1096        let _result = self.send_raw(result);
1097        if _result.is_err() {
1098            self.control_handle.shutdown();
1099        }
1100        self.drop_without_shutdown();
1101        _result
1102    }
1103
1104    /// Similar to "send" but does not shutdown the channel if an error occurs.
1105    pub fn send_no_shutdown_on_err(
1106        self,
1107        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
1108    ) -> Result<(), fidl::Error> {
1109        let _result = self.send_raw(result);
1110        self.drop_without_shutdown();
1111        _result
1112    }
1113
1114    fn send_raw(
1115        &self,
1116        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
1117    ) -> Result<(), fidl::Error> {
1118        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1119            fidl::encoding::EmptyStruct,
1120            fidl_fuchsia_testing_harness::OperationError,
1121        >>(
1122            fidl::encoding::FlexibleResult::new(result),
1123            self.tx_id,
1124            0x11f2157d1648e6ba,
1125            fidl::encoding::DynamicFlags::FLEXIBLE,
1126        )
1127    }
1128}
1129
1130mod internal {
1131    use super::*;
1132    unsafe impl fidl::encoding::TypeMarker for RendererType {
1133        type Owned = Self;
1134
1135        #[inline(always)]
1136        fn inline_align(_context: fidl::encoding::Context) -> usize {
1137            std::mem::align_of::<u32>()
1138        }
1139
1140        #[inline(always)]
1141        fn inline_size(_context: fidl::encoding::Context) -> usize {
1142            std::mem::size_of::<u32>()
1143        }
1144
1145        #[inline(always)]
1146        fn encode_is_copy() -> bool {
1147            false
1148        }
1149
1150        #[inline(always)]
1151        fn decode_is_copy() -> bool {
1152            false
1153        }
1154    }
1155
1156    impl fidl::encoding::ValueTypeMarker for RendererType {
1157        type Borrowed<'a> = Self;
1158        #[inline(always)]
1159        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1160            *value
1161        }
1162    }
1163
1164    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RendererType {
1165        #[inline]
1166        unsafe fn encode(
1167            self,
1168            encoder: &mut fidl::encoding::Encoder<'_, D>,
1169            offset: usize,
1170            _depth: fidl::encoding::Depth,
1171        ) -> fidl::Result<()> {
1172            encoder.debug_check_bounds::<Self>(offset);
1173            encoder.write_num(self.into_primitive(), offset);
1174            Ok(())
1175        }
1176    }
1177
1178    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RendererType {
1179        #[inline(always)]
1180        fn new_empty() -> Self {
1181            Self::unknown()
1182        }
1183
1184        #[inline]
1185        unsafe fn decode(
1186            &mut self,
1187            decoder: &mut fidl::encoding::Decoder<'_, D>,
1188            offset: usize,
1189            _depth: fidl::encoding::Depth,
1190        ) -> fidl::Result<()> {
1191            decoder.debug_check_bounds::<Self>(offset);
1192            let prim = decoder.read_num::<u32>(offset);
1193
1194            *self = Self::from_primitive_allow_unknown(prim);
1195            Ok(())
1196        }
1197    }
1198
1199    impl RealmFactoryCreateRealmRequest {
1200        #[inline(always)]
1201        fn max_ordinal_present(&self) -> u64 {
1202            if let Some(_) = self.device_pixel_ratio {
1203                return 3;
1204            }
1205            if let Some(_) = self.display_rotation {
1206                return 2;
1207            }
1208            if let Some(_) = self.realm_server {
1209                return 1;
1210            }
1211            0
1212        }
1213    }
1214
1215    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
1216        type Borrowed<'a> = &'a mut Self;
1217        fn take_or_borrow<'a>(
1218            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1219        ) -> Self::Borrowed<'a> {
1220            value
1221        }
1222    }
1223
1224    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
1225        type Owned = Self;
1226
1227        #[inline(always)]
1228        fn inline_align(_context: fidl::encoding::Context) -> usize {
1229            8
1230        }
1231
1232        #[inline(always)]
1233        fn inline_size(_context: fidl::encoding::Context) -> usize {
1234            16
1235        }
1236    }
1237
1238    unsafe impl
1239        fidl::encoding::Encode<
1240            RealmFactoryCreateRealmRequest,
1241            fidl::encoding::DefaultFuchsiaResourceDialect,
1242        > for &mut RealmFactoryCreateRealmRequest
1243    {
1244        unsafe fn encode(
1245            self,
1246            encoder: &mut fidl::encoding::Encoder<
1247                '_,
1248                fidl::encoding::DefaultFuchsiaResourceDialect,
1249            >,
1250            offset: usize,
1251            mut depth: fidl::encoding::Depth,
1252        ) -> fidl::Result<()> {
1253            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1254            // Vector header
1255            let max_ordinal: u64 = self.max_ordinal_present();
1256            encoder.write_num(max_ordinal, offset);
1257            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1258            // Calling encoder.out_of_line_offset(0) is not allowed.
1259            if max_ordinal == 0 {
1260                return Ok(());
1261            }
1262            depth.increment()?;
1263            let envelope_size = 8;
1264            let bytes_len = max_ordinal as usize * envelope_size;
1265            #[allow(unused_variables)]
1266            let offset = encoder.out_of_line_offset(bytes_len);
1267            let mut _prev_end_offset: usize = 0;
1268            if 1 > max_ordinal {
1269                return Ok(());
1270            }
1271
1272            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1273            // are envelope_size bytes.
1274            let cur_offset: usize = (1 - 1) * envelope_size;
1275
1276            // Zero reserved fields.
1277            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1278
1279            // Safety:
1280            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1281            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1282            //   envelope_size bytes, there is always sufficient room.
1283            fidl::encoding::encode_in_envelope_optional::<
1284                fidl::encoding::Endpoint<
1285                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1286                >,
1287                fidl::encoding::DefaultFuchsiaResourceDialect,
1288            >(
1289                self.realm_server.as_mut().map(
1290                    <fidl::encoding::Endpoint<
1291                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1292                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1293                ),
1294                encoder,
1295                offset + cur_offset,
1296                depth,
1297            )?;
1298
1299            _prev_end_offset = cur_offset + envelope_size;
1300            if 2 > max_ordinal {
1301                return Ok(());
1302            }
1303
1304            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1305            // are envelope_size bytes.
1306            let cur_offset: usize = (2 - 1) * envelope_size;
1307
1308            // Zero reserved fields.
1309            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1310
1311            // Safety:
1312            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1313            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1314            //   envelope_size bytes, there is always sufficient room.
1315            fidl::encoding::encode_in_envelope_optional::<
1316                u32,
1317                fidl::encoding::DefaultFuchsiaResourceDialect,
1318            >(
1319                self.display_rotation
1320                    .as_ref()
1321                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1322                encoder,
1323                offset + cur_offset,
1324                depth,
1325            )?;
1326
1327            _prev_end_offset = cur_offset + envelope_size;
1328            if 3 > max_ordinal {
1329                return Ok(());
1330            }
1331
1332            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1333            // are envelope_size bytes.
1334            let cur_offset: usize = (3 - 1) * envelope_size;
1335
1336            // Zero reserved fields.
1337            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1338
1339            // Safety:
1340            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1341            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1342            //   envelope_size bytes, there is always sufficient room.
1343            fidl::encoding::encode_in_envelope_optional::<
1344                f32,
1345                fidl::encoding::DefaultFuchsiaResourceDialect,
1346            >(
1347                self.device_pixel_ratio
1348                    .as_ref()
1349                    .map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
1350                encoder,
1351                offset + cur_offset,
1352                depth,
1353            )?;
1354
1355            _prev_end_offset = cur_offset + envelope_size;
1356
1357            Ok(())
1358        }
1359    }
1360
1361    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1362        for RealmFactoryCreateRealmRequest
1363    {
1364        #[inline(always)]
1365        fn new_empty() -> Self {
1366            Self::default()
1367        }
1368
1369        unsafe fn decode(
1370            &mut self,
1371            decoder: &mut fidl::encoding::Decoder<
1372                '_,
1373                fidl::encoding::DefaultFuchsiaResourceDialect,
1374            >,
1375            offset: usize,
1376            mut depth: fidl::encoding::Depth,
1377        ) -> fidl::Result<()> {
1378            decoder.debug_check_bounds::<Self>(offset);
1379            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1380                None => return Err(fidl::Error::NotNullable),
1381                Some(len) => len,
1382            };
1383            // Calling decoder.out_of_line_offset(0) is not allowed.
1384            if len == 0 {
1385                return Ok(());
1386            };
1387            depth.increment()?;
1388            let envelope_size = 8;
1389            let bytes_len = len * envelope_size;
1390            let offset = decoder.out_of_line_offset(bytes_len)?;
1391            // Decode the envelope for each type.
1392            let mut _next_ordinal_to_read = 0;
1393            let mut next_offset = offset;
1394            let end_offset = offset + bytes_len;
1395            _next_ordinal_to_read += 1;
1396            if next_offset >= end_offset {
1397                return Ok(());
1398            }
1399
1400            // Decode unknown envelopes for gaps in ordinals.
1401            while _next_ordinal_to_read < 1 {
1402                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1403                _next_ordinal_to_read += 1;
1404                next_offset += envelope_size;
1405            }
1406
1407            let next_out_of_line = decoder.next_out_of_line();
1408            let handles_before = decoder.remaining_handles();
1409            if let Some((inlined, num_bytes, num_handles)) =
1410                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1411            {
1412                let member_inline_size = <fidl::encoding::Endpoint<
1413                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1414                > as fidl::encoding::TypeMarker>::inline_size(
1415                    decoder.context
1416                );
1417                if inlined != (member_inline_size <= 4) {
1418                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1419                }
1420                let inner_offset;
1421                let mut inner_depth = depth.clone();
1422                if inlined {
1423                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1424                    inner_offset = next_offset;
1425                } else {
1426                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1427                    inner_depth.increment()?;
1428                }
1429                let val_ref = self.realm_server.get_or_insert_with(|| {
1430                    fidl::new_empty!(
1431                        fidl::encoding::Endpoint<
1432                            fidl::endpoints::ServerEnd<
1433                                fidl_fuchsia_testing_harness::RealmProxy_Marker,
1434                            >,
1435                        >,
1436                        fidl::encoding::DefaultFuchsiaResourceDialect
1437                    )
1438                });
1439                fidl::decode!(
1440                    fidl::encoding::Endpoint<
1441                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1442                    >,
1443                    fidl::encoding::DefaultFuchsiaResourceDialect,
1444                    val_ref,
1445                    decoder,
1446                    inner_offset,
1447                    inner_depth
1448                )?;
1449                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1450                {
1451                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1452                }
1453                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1454                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1455                }
1456            }
1457
1458            next_offset += envelope_size;
1459            _next_ordinal_to_read += 1;
1460            if next_offset >= end_offset {
1461                return Ok(());
1462            }
1463
1464            // Decode unknown envelopes for gaps in ordinals.
1465            while _next_ordinal_to_read < 2 {
1466                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1467                _next_ordinal_to_read += 1;
1468                next_offset += envelope_size;
1469            }
1470
1471            let next_out_of_line = decoder.next_out_of_line();
1472            let handles_before = decoder.remaining_handles();
1473            if let Some((inlined, num_bytes, num_handles)) =
1474                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1475            {
1476                let member_inline_size =
1477                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1478                if inlined != (member_inline_size <= 4) {
1479                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1480                }
1481                let inner_offset;
1482                let mut inner_depth = depth.clone();
1483                if inlined {
1484                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1485                    inner_offset = next_offset;
1486                } else {
1487                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1488                    inner_depth.increment()?;
1489                }
1490                let val_ref = self.display_rotation.get_or_insert_with(|| {
1491                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1492                });
1493                fidl::decode!(
1494                    u32,
1495                    fidl::encoding::DefaultFuchsiaResourceDialect,
1496                    val_ref,
1497                    decoder,
1498                    inner_offset,
1499                    inner_depth
1500                )?;
1501                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1502                {
1503                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1504                }
1505                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1506                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1507                }
1508            }
1509
1510            next_offset += envelope_size;
1511            _next_ordinal_to_read += 1;
1512            if next_offset >= end_offset {
1513                return Ok(());
1514            }
1515
1516            // Decode unknown envelopes for gaps in ordinals.
1517            while _next_ordinal_to_read < 3 {
1518                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1519                _next_ordinal_to_read += 1;
1520                next_offset += envelope_size;
1521            }
1522
1523            let next_out_of_line = decoder.next_out_of_line();
1524            let handles_before = decoder.remaining_handles();
1525            if let Some((inlined, num_bytes, num_handles)) =
1526                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1527            {
1528                let member_inline_size =
1529                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1530                if inlined != (member_inline_size <= 4) {
1531                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1532                }
1533                let inner_offset;
1534                let mut inner_depth = depth.clone();
1535                if inlined {
1536                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1537                    inner_offset = next_offset;
1538                } else {
1539                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1540                    inner_depth.increment()?;
1541                }
1542                let val_ref = self.device_pixel_ratio.get_or_insert_with(|| {
1543                    fidl::new_empty!(f32, fidl::encoding::DefaultFuchsiaResourceDialect)
1544                });
1545                fidl::decode!(
1546                    f32,
1547                    fidl::encoding::DefaultFuchsiaResourceDialect,
1548                    val_ref,
1549                    decoder,
1550                    inner_offset,
1551                    inner_depth
1552                )?;
1553                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1554                {
1555                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1556                }
1557                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1558                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1559                }
1560            }
1561
1562            next_offset += envelope_size;
1563
1564            // Decode the remaining unknown envelopes.
1565            while next_offset < end_offset {
1566                _next_ordinal_to_read += 1;
1567                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1568                next_offset += envelope_size;
1569            }
1570
1571            Ok(())
1572        }
1573    }
1574
1575    impl ScenicRealmFactoryCreateRealmRequest {
1576        #[inline(always)]
1577        fn max_ordinal_present(&self) -> u64 {
1578            if let Some(_) = self.display_composition {
1579                return 4;
1580            }
1581            if let Some(_) = self.display_rotation {
1582                return 3;
1583            }
1584            if let Some(_) = self.renderer {
1585                return 2;
1586            }
1587            if let Some(_) = self.realm_server {
1588                return 1;
1589            }
1590            0
1591        }
1592    }
1593
1594    impl fidl::encoding::ResourceTypeMarker for ScenicRealmFactoryCreateRealmRequest {
1595        type Borrowed<'a> = &'a mut Self;
1596        fn take_or_borrow<'a>(
1597            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1598        ) -> Self::Borrowed<'a> {
1599            value
1600        }
1601    }
1602
1603    unsafe impl fidl::encoding::TypeMarker for ScenicRealmFactoryCreateRealmRequest {
1604        type Owned = Self;
1605
1606        #[inline(always)]
1607        fn inline_align(_context: fidl::encoding::Context) -> usize {
1608            8
1609        }
1610
1611        #[inline(always)]
1612        fn inline_size(_context: fidl::encoding::Context) -> usize {
1613            16
1614        }
1615    }
1616
1617    unsafe impl
1618        fidl::encoding::Encode<
1619            ScenicRealmFactoryCreateRealmRequest,
1620            fidl::encoding::DefaultFuchsiaResourceDialect,
1621        > for &mut ScenicRealmFactoryCreateRealmRequest
1622    {
1623        unsafe fn encode(
1624            self,
1625            encoder: &mut fidl::encoding::Encoder<
1626                '_,
1627                fidl::encoding::DefaultFuchsiaResourceDialect,
1628            >,
1629            offset: usize,
1630            mut depth: fidl::encoding::Depth,
1631        ) -> fidl::Result<()> {
1632            encoder.debug_check_bounds::<ScenicRealmFactoryCreateRealmRequest>(offset);
1633            // Vector header
1634            let max_ordinal: u64 = self.max_ordinal_present();
1635            encoder.write_num(max_ordinal, offset);
1636            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1637            // Calling encoder.out_of_line_offset(0) is not allowed.
1638            if max_ordinal == 0 {
1639                return Ok(());
1640            }
1641            depth.increment()?;
1642            let envelope_size = 8;
1643            let bytes_len = max_ordinal as usize * envelope_size;
1644            #[allow(unused_variables)]
1645            let offset = encoder.out_of_line_offset(bytes_len);
1646            let mut _prev_end_offset: usize = 0;
1647            if 1 > max_ordinal {
1648                return Ok(());
1649            }
1650
1651            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1652            // are envelope_size bytes.
1653            let cur_offset: usize = (1 - 1) * envelope_size;
1654
1655            // Zero reserved fields.
1656            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1657
1658            // Safety:
1659            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1660            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1661            //   envelope_size bytes, there is always sufficient room.
1662            fidl::encoding::encode_in_envelope_optional::<
1663                fidl::encoding::Endpoint<
1664                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1665                >,
1666                fidl::encoding::DefaultFuchsiaResourceDialect,
1667            >(
1668                self.realm_server.as_mut().map(
1669                    <fidl::encoding::Endpoint<
1670                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1671                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1672                ),
1673                encoder,
1674                offset + cur_offset,
1675                depth,
1676            )?;
1677
1678            _prev_end_offset = cur_offset + envelope_size;
1679            if 2 > max_ordinal {
1680                return Ok(());
1681            }
1682
1683            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1684            // are envelope_size bytes.
1685            let cur_offset: usize = (2 - 1) * envelope_size;
1686
1687            // Zero reserved fields.
1688            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1689
1690            // Safety:
1691            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1692            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1693            //   envelope_size bytes, there is always sufficient room.
1694            fidl::encoding::encode_in_envelope_optional::<
1695                RendererType,
1696                fidl::encoding::DefaultFuchsiaResourceDialect,
1697            >(
1698                self.renderer
1699                    .as_ref()
1700                    .map(<RendererType as fidl::encoding::ValueTypeMarker>::borrow),
1701                encoder,
1702                offset + cur_offset,
1703                depth,
1704            )?;
1705
1706            _prev_end_offset = cur_offset + envelope_size;
1707            if 3 > max_ordinal {
1708                return Ok(());
1709            }
1710
1711            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1712            // are envelope_size bytes.
1713            let cur_offset: usize = (3 - 1) * envelope_size;
1714
1715            // Zero reserved fields.
1716            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1717
1718            // Safety:
1719            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1720            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1721            //   envelope_size bytes, there is always sufficient room.
1722            fidl::encoding::encode_in_envelope_optional::<
1723                u64,
1724                fidl::encoding::DefaultFuchsiaResourceDialect,
1725            >(
1726                self.display_rotation
1727                    .as_ref()
1728                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1729                encoder,
1730                offset + cur_offset,
1731                depth,
1732            )?;
1733
1734            _prev_end_offset = cur_offset + envelope_size;
1735            if 4 > max_ordinal {
1736                return Ok(());
1737            }
1738
1739            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1740            // are envelope_size bytes.
1741            let cur_offset: usize = (4 - 1) * envelope_size;
1742
1743            // Zero reserved fields.
1744            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1745
1746            // Safety:
1747            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1748            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1749            //   envelope_size bytes, there is always sufficient room.
1750            fidl::encoding::encode_in_envelope_optional::<
1751                bool,
1752                fidl::encoding::DefaultFuchsiaResourceDialect,
1753            >(
1754                self.display_composition
1755                    .as_ref()
1756                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1757                encoder,
1758                offset + cur_offset,
1759                depth,
1760            )?;
1761
1762            _prev_end_offset = cur_offset + envelope_size;
1763
1764            Ok(())
1765        }
1766    }
1767
1768    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1769        for ScenicRealmFactoryCreateRealmRequest
1770    {
1771        #[inline(always)]
1772        fn new_empty() -> Self {
1773            Self::default()
1774        }
1775
1776        unsafe fn decode(
1777            &mut self,
1778            decoder: &mut fidl::encoding::Decoder<
1779                '_,
1780                fidl::encoding::DefaultFuchsiaResourceDialect,
1781            >,
1782            offset: usize,
1783            mut depth: fidl::encoding::Depth,
1784        ) -> fidl::Result<()> {
1785            decoder.debug_check_bounds::<Self>(offset);
1786            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1787                None => return Err(fidl::Error::NotNullable),
1788                Some(len) => len,
1789            };
1790            // Calling decoder.out_of_line_offset(0) is not allowed.
1791            if len == 0 {
1792                return Ok(());
1793            };
1794            depth.increment()?;
1795            let envelope_size = 8;
1796            let bytes_len = len * envelope_size;
1797            let offset = decoder.out_of_line_offset(bytes_len)?;
1798            // Decode the envelope for each type.
1799            let mut _next_ordinal_to_read = 0;
1800            let mut next_offset = offset;
1801            let end_offset = offset + bytes_len;
1802            _next_ordinal_to_read += 1;
1803            if next_offset >= end_offset {
1804                return Ok(());
1805            }
1806
1807            // Decode unknown envelopes for gaps in ordinals.
1808            while _next_ordinal_to_read < 1 {
1809                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1810                _next_ordinal_to_read += 1;
1811                next_offset += envelope_size;
1812            }
1813
1814            let next_out_of_line = decoder.next_out_of_line();
1815            let handles_before = decoder.remaining_handles();
1816            if let Some((inlined, num_bytes, num_handles)) =
1817                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1818            {
1819                let member_inline_size = <fidl::encoding::Endpoint<
1820                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1821                > as fidl::encoding::TypeMarker>::inline_size(
1822                    decoder.context
1823                );
1824                if inlined != (member_inline_size <= 4) {
1825                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1826                }
1827                let inner_offset;
1828                let mut inner_depth = depth.clone();
1829                if inlined {
1830                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1831                    inner_offset = next_offset;
1832                } else {
1833                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1834                    inner_depth.increment()?;
1835                }
1836                let val_ref = self.realm_server.get_or_insert_with(|| {
1837                    fidl::new_empty!(
1838                        fidl::encoding::Endpoint<
1839                            fidl::endpoints::ServerEnd<
1840                                fidl_fuchsia_testing_harness::RealmProxy_Marker,
1841                            >,
1842                        >,
1843                        fidl::encoding::DefaultFuchsiaResourceDialect
1844                    )
1845                });
1846                fidl::decode!(
1847                    fidl::encoding::Endpoint<
1848                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1849                    >,
1850                    fidl::encoding::DefaultFuchsiaResourceDialect,
1851                    val_ref,
1852                    decoder,
1853                    inner_offset,
1854                    inner_depth
1855                )?;
1856                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1857                {
1858                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1859                }
1860                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1861                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1862                }
1863            }
1864
1865            next_offset += envelope_size;
1866            _next_ordinal_to_read += 1;
1867            if next_offset >= end_offset {
1868                return Ok(());
1869            }
1870
1871            // Decode unknown envelopes for gaps in ordinals.
1872            while _next_ordinal_to_read < 2 {
1873                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1874                _next_ordinal_to_read += 1;
1875                next_offset += envelope_size;
1876            }
1877
1878            let next_out_of_line = decoder.next_out_of_line();
1879            let handles_before = decoder.remaining_handles();
1880            if let Some((inlined, num_bytes, num_handles)) =
1881                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1882            {
1883                let member_inline_size =
1884                    <RendererType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1885                if inlined != (member_inline_size <= 4) {
1886                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1887                }
1888                let inner_offset;
1889                let mut inner_depth = depth.clone();
1890                if inlined {
1891                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1892                    inner_offset = next_offset;
1893                } else {
1894                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1895                    inner_depth.increment()?;
1896                }
1897                let val_ref = self.renderer.get_or_insert_with(|| {
1898                    fidl::new_empty!(RendererType, fidl::encoding::DefaultFuchsiaResourceDialect)
1899                });
1900                fidl::decode!(
1901                    RendererType,
1902                    fidl::encoding::DefaultFuchsiaResourceDialect,
1903                    val_ref,
1904                    decoder,
1905                    inner_offset,
1906                    inner_depth
1907                )?;
1908                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1909                {
1910                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1911                }
1912                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1913                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1914                }
1915            }
1916
1917            next_offset += envelope_size;
1918            _next_ordinal_to_read += 1;
1919            if next_offset >= end_offset {
1920                return Ok(());
1921            }
1922
1923            // Decode unknown envelopes for gaps in ordinals.
1924            while _next_ordinal_to_read < 3 {
1925                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1926                _next_ordinal_to_read += 1;
1927                next_offset += envelope_size;
1928            }
1929
1930            let next_out_of_line = decoder.next_out_of_line();
1931            let handles_before = decoder.remaining_handles();
1932            if let Some((inlined, num_bytes, num_handles)) =
1933                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1934            {
1935                let member_inline_size =
1936                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1937                if inlined != (member_inline_size <= 4) {
1938                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1939                }
1940                let inner_offset;
1941                let mut inner_depth = depth.clone();
1942                if inlined {
1943                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1944                    inner_offset = next_offset;
1945                } else {
1946                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1947                    inner_depth.increment()?;
1948                }
1949                let val_ref = self.display_rotation.get_or_insert_with(|| {
1950                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
1951                });
1952                fidl::decode!(
1953                    u64,
1954                    fidl::encoding::DefaultFuchsiaResourceDialect,
1955                    val_ref,
1956                    decoder,
1957                    inner_offset,
1958                    inner_depth
1959                )?;
1960                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1961                {
1962                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1963                }
1964                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1965                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1966                }
1967            }
1968
1969            next_offset += envelope_size;
1970            _next_ordinal_to_read += 1;
1971            if next_offset >= end_offset {
1972                return Ok(());
1973            }
1974
1975            // Decode unknown envelopes for gaps in ordinals.
1976            while _next_ordinal_to_read < 4 {
1977                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1978                _next_ordinal_to_read += 1;
1979                next_offset += envelope_size;
1980            }
1981
1982            let next_out_of_line = decoder.next_out_of_line();
1983            let handles_before = decoder.remaining_handles();
1984            if let Some((inlined, num_bytes, num_handles)) =
1985                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1986            {
1987                let member_inline_size =
1988                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1989                if inlined != (member_inline_size <= 4) {
1990                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1991                }
1992                let inner_offset;
1993                let mut inner_depth = depth.clone();
1994                if inlined {
1995                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1996                    inner_offset = next_offset;
1997                } else {
1998                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1999                    inner_depth.increment()?;
2000                }
2001                let val_ref = self.display_composition.get_or_insert_with(|| {
2002                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2003                });
2004                fidl::decode!(
2005                    bool,
2006                    fidl::encoding::DefaultFuchsiaResourceDialect,
2007                    val_ref,
2008                    decoder,
2009                    inner_offset,
2010                    inner_depth
2011                )?;
2012                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2013                {
2014                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2015                }
2016                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2017                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2018                }
2019            }
2020
2021            next_offset += envelope_size;
2022
2023            // Decode the remaining unknown envelopes.
2024            while next_offset < end_offset {
2025                _next_ordinal_to_read += 1;
2026                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2027                next_offset += envelope_size;
2028            }
2029
2030            Ok(())
2031        }
2032    }
2033}