Skip to main content

fidl_test_systemactivitygovernor/
fidl_test_systemactivitygovernor.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_systemactivitygovernor__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct RealmFactoryCreateRealmExtRequest {
16    pub options: RealmOptions,
17    pub realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for RealmFactoryCreateRealmExtRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct RealmFactoryCreateRealmRequest {
27    pub realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for RealmFactoryCreateRealmRequest
32{
33}
34
35/// RealmOptions tells the RealmFactory protocol how to create the test realm.
36#[derive(Debug, Default, PartialEq)]
37pub struct RealmOptions {
38    /// Specifies whether to use a fake SAG that exposes additional protocols
39    /// to set/watch real SAG power element power levels. Defaults to false.
40    pub use_fake_sag: Option<bool>,
41    /// Specifies whether to set the fuchsia.power.WaitForSuspendingToken config
42    /// capability to true. If true, SAG will wait to receive a token through
43    /// [`fuchsia.power.system/CpuElementManager.AddExectuionStateDependency`].
44    /// If false, SAG will skip adding external Execution State dependencies.
45    /// Defaults to false.
46    pub wait_for_suspending_token: Option<bool>,
47    /// Specifies whether SAG will use a suspender or not. Defaults to true.
48    pub use_suspender: Option<bool>,
49    /// Specifies the timeout in seconds for the suspend/resume watchdog.
50    /// Defaults to 60 seconds if not specified.
51    pub stuck_warning_timeout_seconds: Option<u32>,
52    #[doc(hidden)]
53    pub __source_breaking: fidl::marker::SourceBreaking,
54}
55
56impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {}
57
58#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
59pub struct RealmFactoryMarker;
60
61impl fidl::endpoints::ProtocolMarker for RealmFactoryMarker {
62    type Proxy = RealmFactoryProxy;
63    type RequestStream = RealmFactoryRequestStream;
64    #[cfg(target_os = "fuchsia")]
65    type SynchronousProxy = RealmFactorySynchronousProxy;
66
67    const DEBUG_NAME: &'static str = "test.systemactivitygovernor.RealmFactory";
68}
69impl fidl::endpoints::DiscoverableProtocolMarker for RealmFactoryMarker {}
70pub type RealmFactoryCreateRealmResult =
71    Result<String, fidl_fuchsia_testing_harness::OperationError>;
72pub type RealmFactoryCreateRealmExtResult =
73    Result<String, fidl_fuchsia_testing_harness::OperationError>;
74
75pub trait RealmFactoryProxyInterface: Send + Sync {
76    type CreateRealmResponseFut: std::future::Future<Output = Result<RealmFactoryCreateRealmResult, fidl::Error>>
77        + Send;
78    fn r#create_realm(
79        &self,
80        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
81    ) -> Self::CreateRealmResponseFut;
82    type CreateRealmExtResponseFut: std::future::Future<Output = Result<RealmFactoryCreateRealmExtResult, fidl::Error>>
83        + Send;
84    fn r#create_realm_ext(
85        &self,
86        options: RealmOptions,
87        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
88    ) -> Self::CreateRealmExtResponseFut;
89}
90#[derive(Debug)]
91#[cfg(target_os = "fuchsia")]
92pub struct RealmFactorySynchronousProxy {
93    client: fidl::client::sync::Client,
94}
95
96#[cfg(target_os = "fuchsia")]
97impl fidl::endpoints::SynchronousProxy for RealmFactorySynchronousProxy {
98    type Proxy = RealmFactoryProxy;
99    type Protocol = RealmFactoryMarker;
100
101    fn from_channel(inner: fidl::Channel) -> Self {
102        Self::new(inner)
103    }
104
105    fn into_channel(self) -> fidl::Channel {
106        self.client.into_channel()
107    }
108
109    fn as_channel(&self) -> &fidl::Channel {
110        self.client.as_channel()
111    }
112}
113
114#[cfg(target_os = "fuchsia")]
115impl RealmFactorySynchronousProxy {
116    pub fn new(channel: fidl::Channel) -> Self {
117        Self { client: fidl::client::sync::Client::new(channel) }
118    }
119
120    pub fn into_channel(self) -> fidl::Channel {
121        self.client.into_channel()
122    }
123
124    /// Waits until an event arrives and returns it. It is safe for other
125    /// threads to make concurrent requests while waiting for an event.
126    pub fn wait_for_event(
127        &self,
128        deadline: zx::MonotonicInstant,
129    ) -> Result<RealmFactoryEvent, fidl::Error> {
130        RealmFactoryEvent::decode(self.client.wait_for_event::<RealmFactoryMarker>(deadline)?)
131    }
132
133    /// Creates a new realm and binds the given RealmProxy server end to it.
134    pub fn r#create_realm(
135        &self,
136        mut realm_server: fidl::endpoints::ServerEnd<
137            fidl_fuchsia_testing_harness::RealmProxy_Marker,
138        >,
139        ___deadline: zx::MonotonicInstant,
140    ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
141        let _response = self
142            .client
143            .send_query::<RealmFactoryCreateRealmRequest, fidl::encoding::FlexibleResultType<
144                RealmFactoryCreateRealmResponse,
145                fidl_fuchsia_testing_harness::OperationError,
146            >, RealmFactoryMarker>(
147                (realm_server,),
148                0x3fcb27aa634a2df3,
149                fidl::encoding::DynamicFlags::FLEXIBLE,
150                ___deadline,
151            )?
152            .into_result::<RealmFactoryMarker>("create_realm")?;
153        Ok(_response.map(|x| x.activity_governor_moniker))
154    }
155
156    /// Creates a new realm and accepts options.
157    pub fn r#create_realm_ext(
158        &self,
159        mut options: RealmOptions,
160        mut realm_server: fidl::endpoints::ServerEnd<
161            fidl_fuchsia_testing_harness::RealmProxy_Marker,
162        >,
163        ___deadline: zx::MonotonicInstant,
164    ) -> Result<RealmFactoryCreateRealmExtResult, fidl::Error> {
165        let _response = self
166            .client
167            .send_query::<RealmFactoryCreateRealmExtRequest, fidl::encoding::FlexibleResultType<
168                RealmFactoryCreateRealmExtResponse,
169                fidl_fuchsia_testing_harness::OperationError,
170            >, RealmFactoryMarker>(
171                (&mut options, realm_server),
172                0x63a655ff630a0db0,
173                fidl::encoding::DynamicFlags::FLEXIBLE,
174                ___deadline,
175            )?
176            .into_result::<RealmFactoryMarker>("create_realm_ext")?;
177        Ok(_response.map(|x| x.activity_governor_moniker))
178    }
179}
180
181#[cfg(target_os = "fuchsia")]
182impl From<RealmFactorySynchronousProxy> for zx::NullableHandle {
183    fn from(value: RealmFactorySynchronousProxy) -> Self {
184        value.into_channel().into()
185    }
186}
187
188#[cfg(target_os = "fuchsia")]
189impl From<fidl::Channel> for RealmFactorySynchronousProxy {
190    fn from(value: fidl::Channel) -> Self {
191        Self::new(value)
192    }
193}
194
195#[cfg(target_os = "fuchsia")]
196impl fidl::endpoints::FromClient for RealmFactorySynchronousProxy {
197    type Protocol = RealmFactoryMarker;
198
199    fn from_client(value: fidl::endpoints::ClientEnd<RealmFactoryMarker>) -> Self {
200        Self::new(value.into_channel())
201    }
202}
203
204#[derive(Debug, Clone)]
205pub struct RealmFactoryProxy {
206    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
207}
208
209impl fidl::endpoints::Proxy for RealmFactoryProxy {
210    type Protocol = RealmFactoryMarker;
211
212    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
213        Self::new(inner)
214    }
215
216    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
217        self.client.into_channel().map_err(|client| Self { client })
218    }
219
220    fn as_channel(&self) -> &::fidl::AsyncChannel {
221        self.client.as_channel()
222    }
223}
224
225impl RealmFactoryProxy {
226    /// Create a new Proxy for test.systemactivitygovernor/RealmFactory.
227    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
228        let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
229        Self { client: fidl::client::Client::new(channel, protocol_name) }
230    }
231
232    /// Get a Stream of events from the remote end of the protocol.
233    ///
234    /// # Panics
235    ///
236    /// Panics if the event stream was already taken.
237    pub fn take_event_stream(&self) -> RealmFactoryEventStream {
238        RealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
239    }
240
241    /// Creates a new realm and binds the given RealmProxy server end to it.
242    pub fn r#create_realm(
243        &self,
244        mut realm_server: fidl::endpoints::ServerEnd<
245            fidl_fuchsia_testing_harness::RealmProxy_Marker,
246        >,
247    ) -> fidl::client::QueryResponseFut<
248        RealmFactoryCreateRealmResult,
249        fidl::encoding::DefaultFuchsiaResourceDialect,
250    > {
251        RealmFactoryProxyInterface::r#create_realm(self, realm_server)
252    }
253
254    /// Creates a new realm and accepts options.
255    pub fn r#create_realm_ext(
256        &self,
257        mut options: RealmOptions,
258        mut realm_server: fidl::endpoints::ServerEnd<
259            fidl_fuchsia_testing_harness::RealmProxy_Marker,
260        >,
261    ) -> fidl::client::QueryResponseFut<
262        RealmFactoryCreateRealmExtResult,
263        fidl::encoding::DefaultFuchsiaResourceDialect,
264    > {
265        RealmFactoryProxyInterface::r#create_realm_ext(self, options, realm_server)
266    }
267}
268
269impl RealmFactoryProxyInterface for RealmFactoryProxy {
270    type CreateRealmResponseFut = fidl::client::QueryResponseFut<
271        RealmFactoryCreateRealmResult,
272        fidl::encoding::DefaultFuchsiaResourceDialect,
273    >;
274    fn r#create_realm(
275        &self,
276        mut realm_server: fidl::endpoints::ServerEnd<
277            fidl_fuchsia_testing_harness::RealmProxy_Marker,
278        >,
279    ) -> Self::CreateRealmResponseFut {
280        fn _decode(
281            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
282        ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
283            let _response = fidl::client::decode_transaction_body::<
284                fidl::encoding::FlexibleResultType<
285                    RealmFactoryCreateRealmResponse,
286                    fidl_fuchsia_testing_harness::OperationError,
287                >,
288                fidl::encoding::DefaultFuchsiaResourceDialect,
289                0x3fcb27aa634a2df3,
290            >(_buf?)?
291            .into_result::<RealmFactoryMarker>("create_realm")?;
292            Ok(_response.map(|x| x.activity_governor_moniker))
293        }
294        self.client
295            .send_query_and_decode::<RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResult>(
296                (realm_server,),
297                0x3fcb27aa634a2df3,
298                fidl::encoding::DynamicFlags::FLEXIBLE,
299                _decode,
300            )
301    }
302
303    type CreateRealmExtResponseFut = fidl::client::QueryResponseFut<
304        RealmFactoryCreateRealmExtResult,
305        fidl::encoding::DefaultFuchsiaResourceDialect,
306    >;
307    fn r#create_realm_ext(
308        &self,
309        mut options: RealmOptions,
310        mut realm_server: fidl::endpoints::ServerEnd<
311            fidl_fuchsia_testing_harness::RealmProxy_Marker,
312        >,
313    ) -> Self::CreateRealmExtResponseFut {
314        fn _decode(
315            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
316        ) -> Result<RealmFactoryCreateRealmExtResult, fidl::Error> {
317            let _response = fidl::client::decode_transaction_body::<
318                fidl::encoding::FlexibleResultType<
319                    RealmFactoryCreateRealmExtResponse,
320                    fidl_fuchsia_testing_harness::OperationError,
321                >,
322                fidl::encoding::DefaultFuchsiaResourceDialect,
323                0x63a655ff630a0db0,
324            >(_buf?)?
325            .into_result::<RealmFactoryMarker>("create_realm_ext")?;
326            Ok(_response.map(|x| x.activity_governor_moniker))
327        }
328        self.client.send_query_and_decode::<
329            RealmFactoryCreateRealmExtRequest,
330            RealmFactoryCreateRealmExtResult,
331        >(
332            (&mut options, realm_server,),
333            0x63a655ff630a0db0,
334            fidl::encoding::DynamicFlags::FLEXIBLE,
335            _decode,
336        )
337    }
338}
339
340pub struct RealmFactoryEventStream {
341    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
342}
343
344impl std::marker::Unpin for RealmFactoryEventStream {}
345
346impl futures::stream::FusedStream for RealmFactoryEventStream {
347    fn is_terminated(&self) -> bool {
348        self.event_receiver.is_terminated()
349    }
350}
351
352impl futures::Stream for RealmFactoryEventStream {
353    type Item = Result<RealmFactoryEvent, fidl::Error>;
354
355    fn poll_next(
356        mut self: std::pin::Pin<&mut Self>,
357        cx: &mut std::task::Context<'_>,
358    ) -> std::task::Poll<Option<Self::Item>> {
359        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
360            &mut self.event_receiver,
361            cx
362        )?) {
363            Some(buf) => std::task::Poll::Ready(Some(RealmFactoryEvent::decode(buf))),
364            None => std::task::Poll::Ready(None),
365        }
366    }
367}
368
369#[derive(Debug)]
370pub enum RealmFactoryEvent {
371    #[non_exhaustive]
372    _UnknownEvent {
373        /// Ordinal of the event that was sent.
374        ordinal: u64,
375    },
376}
377
378impl RealmFactoryEvent {
379    /// Decodes a message buffer as a [`RealmFactoryEvent`].
380    fn decode(
381        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
382    ) -> Result<RealmFactoryEvent, fidl::Error> {
383        let (bytes, _handles) = buf.split_mut();
384        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
385        debug_assert_eq!(tx_header.tx_id, 0);
386        match tx_header.ordinal {
387            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
388                Ok(RealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
389            }
390            _ => Err(fidl::Error::UnknownOrdinal {
391                ordinal: tx_header.ordinal,
392                protocol_name: <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
393            }),
394        }
395    }
396}
397
398/// A Stream of incoming requests for test.systemactivitygovernor/RealmFactory.
399pub struct RealmFactoryRequestStream {
400    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
401    is_terminated: bool,
402}
403
404impl std::marker::Unpin for RealmFactoryRequestStream {}
405
406impl futures::stream::FusedStream for RealmFactoryRequestStream {
407    fn is_terminated(&self) -> bool {
408        self.is_terminated
409    }
410}
411
412impl fidl::endpoints::RequestStream for RealmFactoryRequestStream {
413    type Protocol = RealmFactoryMarker;
414    type ControlHandle = RealmFactoryControlHandle;
415
416    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
417        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
418    }
419
420    fn control_handle(&self) -> Self::ControlHandle {
421        RealmFactoryControlHandle { inner: self.inner.clone() }
422    }
423
424    fn into_inner(
425        self,
426    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
427    {
428        (self.inner, self.is_terminated)
429    }
430
431    fn from_inner(
432        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
433        is_terminated: bool,
434    ) -> Self {
435        Self { inner, is_terminated }
436    }
437}
438
439impl futures::Stream for RealmFactoryRequestStream {
440    type Item = Result<RealmFactoryRequest, fidl::Error>;
441
442    fn poll_next(
443        mut self: std::pin::Pin<&mut Self>,
444        cx: &mut std::task::Context<'_>,
445    ) -> std::task::Poll<Option<Self::Item>> {
446        let this = &mut *self;
447        if this.inner.check_shutdown(cx) {
448            this.is_terminated = true;
449            return std::task::Poll::Ready(None);
450        }
451        if this.is_terminated {
452            panic!("polled RealmFactoryRequestStream after completion");
453        }
454        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
455            |bytes, handles| {
456                match this.inner.channel().read_etc(cx, bytes, handles) {
457                    std::task::Poll::Ready(Ok(())) => {}
458                    std::task::Poll::Pending => return std::task::Poll::Pending,
459                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
460                        this.is_terminated = true;
461                        return std::task::Poll::Ready(None);
462                    }
463                    std::task::Poll::Ready(Err(e)) => {
464                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
465                            e.into(),
466                        ))));
467                    }
468                }
469
470                // A message has been received from the channel
471                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
472
473                std::task::Poll::Ready(Some(match header.ordinal {
474                    0x3fcb27aa634a2df3 => {
475                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
476                        let mut req = fidl::new_empty!(
477                            RealmFactoryCreateRealmRequest,
478                            fidl::encoding::DefaultFuchsiaResourceDialect
479                        );
480                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
481                        let control_handle =
482                            RealmFactoryControlHandle { inner: this.inner.clone() };
483                        Ok(RealmFactoryRequest::CreateRealm {
484                            realm_server: req.realm_server,
485
486                            responder: RealmFactoryCreateRealmResponder {
487                                control_handle: std::mem::ManuallyDrop::new(control_handle),
488                                tx_id: header.tx_id,
489                            },
490                        })
491                    }
492                    0x63a655ff630a0db0 => {
493                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
494                        let mut req = fidl::new_empty!(
495                            RealmFactoryCreateRealmExtRequest,
496                            fidl::encoding::DefaultFuchsiaResourceDialect
497                        );
498                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmExtRequest>(&header, _body_bytes, handles, &mut req)?;
499                        let control_handle =
500                            RealmFactoryControlHandle { inner: this.inner.clone() };
501                        Ok(RealmFactoryRequest::CreateRealmExt {
502                            options: req.options,
503                            realm_server: req.realm_server,
504
505                            responder: RealmFactoryCreateRealmExtResponder {
506                                control_handle: std::mem::ManuallyDrop::new(control_handle),
507                                tx_id: header.tx_id,
508                            },
509                        })
510                    }
511                    _ if header.tx_id == 0
512                        && header
513                            .dynamic_flags()
514                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
515                    {
516                        Ok(RealmFactoryRequest::_UnknownMethod {
517                            ordinal: header.ordinal,
518                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
519                            method_type: fidl::MethodType::OneWay,
520                        })
521                    }
522                    _ if header
523                        .dynamic_flags()
524                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
525                    {
526                        this.inner.send_framework_err(
527                            fidl::encoding::FrameworkErr::UnknownMethod,
528                            header.tx_id,
529                            header.ordinal,
530                            header.dynamic_flags(),
531                            (bytes, handles),
532                        )?;
533                        Ok(RealmFactoryRequest::_UnknownMethod {
534                            ordinal: header.ordinal,
535                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
536                            method_type: fidl::MethodType::TwoWay,
537                        })
538                    }
539                    _ => Err(fidl::Error::UnknownOrdinal {
540                        ordinal: header.ordinal,
541                        protocol_name:
542                            <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
543                    }),
544                }))
545            },
546        )
547    }
548}
549
550#[derive(Debug)]
551pub enum RealmFactoryRequest {
552    /// Creates a new realm and binds the given RealmProxy server end to it.
553    CreateRealm {
554        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
555        responder: RealmFactoryCreateRealmResponder,
556    },
557    /// Creates a new realm and accepts options.
558    CreateRealmExt {
559        options: RealmOptions,
560        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
561        responder: RealmFactoryCreateRealmExtResponder,
562    },
563    /// An interaction was received which does not match any known method.
564    #[non_exhaustive]
565    _UnknownMethod {
566        /// Ordinal of the method that was called.
567        ordinal: u64,
568        control_handle: RealmFactoryControlHandle,
569        method_type: fidl::MethodType,
570    },
571}
572
573impl RealmFactoryRequest {
574    #[allow(irrefutable_let_patterns)]
575    pub fn into_create_realm(
576        self,
577    ) -> Option<(
578        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
579        RealmFactoryCreateRealmResponder,
580    )> {
581        if let RealmFactoryRequest::CreateRealm { realm_server, responder } = self {
582            Some((realm_server, responder))
583        } else {
584            None
585        }
586    }
587
588    #[allow(irrefutable_let_patterns)]
589    pub fn into_create_realm_ext(
590        self,
591    ) -> Option<(
592        RealmOptions,
593        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
594        RealmFactoryCreateRealmExtResponder,
595    )> {
596        if let RealmFactoryRequest::CreateRealmExt { options, realm_server, responder } = self {
597            Some((options, realm_server, responder))
598        } else {
599            None
600        }
601    }
602
603    /// Name of the method defined in FIDL
604    pub fn method_name(&self) -> &'static str {
605        match *self {
606            RealmFactoryRequest::CreateRealm { .. } => "create_realm",
607            RealmFactoryRequest::CreateRealmExt { .. } => "create_realm_ext",
608            RealmFactoryRequest::_UnknownMethod {
609                method_type: fidl::MethodType::OneWay, ..
610            } => "unknown one-way method",
611            RealmFactoryRequest::_UnknownMethod {
612                method_type: fidl::MethodType::TwoWay, ..
613            } => "unknown two-way method",
614        }
615    }
616}
617
618#[derive(Debug, Clone)]
619pub struct RealmFactoryControlHandle {
620    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
621}
622
623impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
624    fn shutdown(&self) {
625        self.inner.shutdown()
626    }
627
628    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
629        self.inner.shutdown_with_epitaph(status)
630    }
631
632    fn is_closed(&self) -> bool {
633        self.inner.channel().is_closed()
634    }
635    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
636        self.inner.channel().on_closed()
637    }
638
639    #[cfg(target_os = "fuchsia")]
640    fn signal_peer(
641        &self,
642        clear_mask: zx::Signals,
643        set_mask: zx::Signals,
644    ) -> Result<(), zx_status::Status> {
645        use fidl::Peered;
646        self.inner.channel().signal_peer(clear_mask, set_mask)
647    }
648}
649
650impl RealmFactoryControlHandle {}
651
652#[must_use = "FIDL methods require a response to be sent"]
653#[derive(Debug)]
654pub struct RealmFactoryCreateRealmResponder {
655    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
656    tx_id: u32,
657}
658
659/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
660/// if the responder is dropped without sending a response, so that the client
661/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
662impl std::ops::Drop for RealmFactoryCreateRealmResponder {
663    fn drop(&mut self) {
664        self.control_handle.shutdown();
665        // Safety: drops once, never accessed again
666        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
667    }
668}
669
670impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
671    type ControlHandle = RealmFactoryControlHandle;
672
673    fn control_handle(&self) -> &RealmFactoryControlHandle {
674        &self.control_handle
675    }
676
677    fn drop_without_shutdown(mut self) {
678        // Safety: drops once, never accessed again due to mem::forget
679        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
680        // Prevent Drop from running (which would shut down the channel)
681        std::mem::forget(self);
682    }
683}
684
685impl RealmFactoryCreateRealmResponder {
686    /// Sends a response to the FIDL transaction.
687    ///
688    /// Sets the channel to shutdown if an error occurs.
689    pub fn send(
690        self,
691        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
692    ) -> Result<(), fidl::Error> {
693        let _result = self.send_raw(result);
694        if _result.is_err() {
695            self.control_handle.shutdown();
696        }
697        self.drop_without_shutdown();
698        _result
699    }
700
701    /// Similar to "send" but does not shutdown the channel if an error occurs.
702    pub fn send_no_shutdown_on_err(
703        self,
704        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
705    ) -> Result<(), fidl::Error> {
706        let _result = self.send_raw(result);
707        self.drop_without_shutdown();
708        _result
709    }
710
711    fn send_raw(
712        &self,
713        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
714    ) -> Result<(), fidl::Error> {
715        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
716            RealmFactoryCreateRealmResponse,
717            fidl_fuchsia_testing_harness::OperationError,
718        >>(
719            fidl::encoding::FlexibleResult::new(
720                result.map(|activity_governor_moniker| (activity_governor_moniker,)),
721            ),
722            self.tx_id,
723            0x3fcb27aa634a2df3,
724            fidl::encoding::DynamicFlags::FLEXIBLE,
725        )
726    }
727}
728
729#[must_use = "FIDL methods require a response to be sent"]
730#[derive(Debug)]
731pub struct RealmFactoryCreateRealmExtResponder {
732    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
733    tx_id: u32,
734}
735
736/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
737/// if the responder is dropped without sending a response, so that the client
738/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
739impl std::ops::Drop for RealmFactoryCreateRealmExtResponder {
740    fn drop(&mut self) {
741        self.control_handle.shutdown();
742        // Safety: drops once, never accessed again
743        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
744    }
745}
746
747impl fidl::endpoints::Responder for RealmFactoryCreateRealmExtResponder {
748    type ControlHandle = RealmFactoryControlHandle;
749
750    fn control_handle(&self) -> &RealmFactoryControlHandle {
751        &self.control_handle
752    }
753
754    fn drop_without_shutdown(mut self) {
755        // Safety: drops once, never accessed again due to mem::forget
756        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
757        // Prevent Drop from running (which would shut down the channel)
758        std::mem::forget(self);
759    }
760}
761
762impl RealmFactoryCreateRealmExtResponder {
763    /// Sends a response to the FIDL transaction.
764    ///
765    /// Sets the channel to shutdown if an error occurs.
766    pub fn send(
767        self,
768        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
769    ) -> Result<(), fidl::Error> {
770        let _result = self.send_raw(result);
771        if _result.is_err() {
772            self.control_handle.shutdown();
773        }
774        self.drop_without_shutdown();
775        _result
776    }
777
778    /// Similar to "send" but does not shutdown the channel if an error occurs.
779    pub fn send_no_shutdown_on_err(
780        self,
781        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
782    ) -> Result<(), fidl::Error> {
783        let _result = self.send_raw(result);
784        self.drop_without_shutdown();
785        _result
786    }
787
788    fn send_raw(
789        &self,
790        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
791    ) -> Result<(), fidl::Error> {
792        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
793            RealmFactoryCreateRealmExtResponse,
794            fidl_fuchsia_testing_harness::OperationError,
795        >>(
796            fidl::encoding::FlexibleResult::new(
797                result.map(|activity_governor_moniker| (activity_governor_moniker,)),
798            ),
799            self.tx_id,
800            0x63a655ff630a0db0,
801            fidl::encoding::DynamicFlags::FLEXIBLE,
802        )
803    }
804}
805
806mod internal {
807    use super::*;
808
809    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmExtRequest {
810        type Borrowed<'a> = &'a mut Self;
811        fn take_or_borrow<'a>(
812            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
813        ) -> Self::Borrowed<'a> {
814            value
815        }
816    }
817
818    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmExtRequest {
819        type Owned = Self;
820
821        #[inline(always)]
822        fn inline_align(_context: fidl::encoding::Context) -> usize {
823            8
824        }
825
826        #[inline(always)]
827        fn inline_size(_context: fidl::encoding::Context) -> usize {
828            24
829        }
830    }
831
832    unsafe impl
833        fidl::encoding::Encode<
834            RealmFactoryCreateRealmExtRequest,
835            fidl::encoding::DefaultFuchsiaResourceDialect,
836        > for &mut RealmFactoryCreateRealmExtRequest
837    {
838        #[inline]
839        unsafe fn encode(
840            self,
841            encoder: &mut fidl::encoding::Encoder<
842                '_,
843                fidl::encoding::DefaultFuchsiaResourceDialect,
844            >,
845            offset: usize,
846            _depth: fidl::encoding::Depth,
847        ) -> fidl::Result<()> {
848            encoder.debug_check_bounds::<RealmFactoryCreateRealmExtRequest>(offset);
849            // Delegate to tuple encoding.
850            fidl::encoding::Encode::<
851                RealmFactoryCreateRealmExtRequest,
852                fidl::encoding::DefaultFuchsiaResourceDialect,
853            >::encode(
854                (
855                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
856                        &mut self.options,
857                    ),
858                    <fidl::encoding::Endpoint<
859                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
860                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
861                        &mut self.realm_server,
862                    ),
863                ),
864                encoder,
865                offset,
866                _depth,
867            )
868        }
869    }
870    unsafe impl<
871        T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
872        T1: fidl::encoding::Encode<
873                fidl::encoding::Endpoint<
874                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
875                >,
876                fidl::encoding::DefaultFuchsiaResourceDialect,
877            >,
878    >
879        fidl::encoding::Encode<
880            RealmFactoryCreateRealmExtRequest,
881            fidl::encoding::DefaultFuchsiaResourceDialect,
882        > for (T0, T1)
883    {
884        #[inline]
885        unsafe fn encode(
886            self,
887            encoder: &mut fidl::encoding::Encoder<
888                '_,
889                fidl::encoding::DefaultFuchsiaResourceDialect,
890            >,
891            offset: usize,
892            depth: fidl::encoding::Depth,
893        ) -> fidl::Result<()> {
894            encoder.debug_check_bounds::<RealmFactoryCreateRealmExtRequest>(offset);
895            // Zero out padding regions. There's no need to apply masks
896            // because the unmasked parts will be overwritten by fields.
897            unsafe {
898                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
899                (ptr as *mut u64).write_unaligned(0);
900            }
901            // Write the fields.
902            self.0.encode(encoder, offset + 0, depth)?;
903            self.1.encode(encoder, offset + 16, depth)?;
904            Ok(())
905        }
906    }
907
908    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
909        for RealmFactoryCreateRealmExtRequest
910    {
911        #[inline(always)]
912        fn new_empty() -> Self {
913            Self {
914                options: fidl::new_empty!(
915                    RealmOptions,
916                    fidl::encoding::DefaultFuchsiaResourceDialect
917                ),
918                realm_server: fidl::new_empty!(
919                    fidl::encoding::Endpoint<
920                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
921                    >,
922                    fidl::encoding::DefaultFuchsiaResourceDialect
923                ),
924            }
925        }
926
927        #[inline]
928        unsafe fn decode(
929            &mut self,
930            decoder: &mut fidl::encoding::Decoder<
931                '_,
932                fidl::encoding::DefaultFuchsiaResourceDialect,
933            >,
934            offset: usize,
935            _depth: fidl::encoding::Depth,
936        ) -> fidl::Result<()> {
937            decoder.debug_check_bounds::<Self>(offset);
938            // Verify that padding bytes are zero.
939            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
940            let padval = unsafe { (ptr as *const u64).read_unaligned() };
941            let mask = 0xffffffff00000000u64;
942            let maskedval = padval & mask;
943            if maskedval != 0 {
944                return Err(fidl::Error::NonZeroPadding {
945                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
946                });
947            }
948            fidl::decode!(
949                RealmOptions,
950                fidl::encoding::DefaultFuchsiaResourceDialect,
951                &mut self.options,
952                decoder,
953                offset + 0,
954                _depth
955            )?;
956            fidl::decode!(
957                fidl::encoding::Endpoint<
958                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
959                >,
960                fidl::encoding::DefaultFuchsiaResourceDialect,
961                &mut self.realm_server,
962                decoder,
963                offset + 16,
964                _depth
965            )?;
966            Ok(())
967        }
968    }
969
970    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
971        type Borrowed<'a> = &'a mut Self;
972        fn take_or_borrow<'a>(
973            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
974        ) -> Self::Borrowed<'a> {
975            value
976        }
977    }
978
979    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
980        type Owned = Self;
981
982        #[inline(always)]
983        fn inline_align(_context: fidl::encoding::Context) -> usize {
984            4
985        }
986
987        #[inline(always)]
988        fn inline_size(_context: fidl::encoding::Context) -> usize {
989            4
990        }
991    }
992
993    unsafe impl
994        fidl::encoding::Encode<
995            RealmFactoryCreateRealmRequest,
996            fidl::encoding::DefaultFuchsiaResourceDialect,
997        > for &mut RealmFactoryCreateRealmRequest
998    {
999        #[inline]
1000        unsafe fn encode(
1001            self,
1002            encoder: &mut fidl::encoding::Encoder<
1003                '_,
1004                fidl::encoding::DefaultFuchsiaResourceDialect,
1005            >,
1006            offset: usize,
1007            _depth: fidl::encoding::Depth,
1008        ) -> fidl::Result<()> {
1009            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1010            // Delegate to tuple encoding.
1011            fidl::encoding::Encode::<
1012                RealmFactoryCreateRealmRequest,
1013                fidl::encoding::DefaultFuchsiaResourceDialect,
1014            >::encode(
1015                (<fidl::encoding::Endpoint<
1016                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1017                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1018                    &mut self.realm_server
1019                ),),
1020                encoder,
1021                offset,
1022                _depth,
1023            )
1024        }
1025    }
1026    unsafe impl<
1027        T0: fidl::encoding::Encode<
1028                fidl::encoding::Endpoint<
1029                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1030                >,
1031                fidl::encoding::DefaultFuchsiaResourceDialect,
1032            >,
1033    >
1034        fidl::encoding::Encode<
1035            RealmFactoryCreateRealmRequest,
1036            fidl::encoding::DefaultFuchsiaResourceDialect,
1037        > for (T0,)
1038    {
1039        #[inline]
1040        unsafe fn encode(
1041            self,
1042            encoder: &mut fidl::encoding::Encoder<
1043                '_,
1044                fidl::encoding::DefaultFuchsiaResourceDialect,
1045            >,
1046            offset: usize,
1047            depth: fidl::encoding::Depth,
1048        ) -> fidl::Result<()> {
1049            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1050            // Zero out padding regions. There's no need to apply masks
1051            // because the unmasked parts will be overwritten by fields.
1052            // Write the fields.
1053            self.0.encode(encoder, offset + 0, depth)?;
1054            Ok(())
1055        }
1056    }
1057
1058    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1059        for RealmFactoryCreateRealmRequest
1060    {
1061        #[inline(always)]
1062        fn new_empty() -> Self {
1063            Self {
1064                realm_server: fidl::new_empty!(
1065                    fidl::encoding::Endpoint<
1066                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1067                    >,
1068                    fidl::encoding::DefaultFuchsiaResourceDialect
1069                ),
1070            }
1071        }
1072
1073        #[inline]
1074        unsafe fn decode(
1075            &mut self,
1076            decoder: &mut fidl::encoding::Decoder<
1077                '_,
1078                fidl::encoding::DefaultFuchsiaResourceDialect,
1079            >,
1080            offset: usize,
1081            _depth: fidl::encoding::Depth,
1082        ) -> fidl::Result<()> {
1083            decoder.debug_check_bounds::<Self>(offset);
1084            // Verify that padding bytes are zero.
1085            fidl::decode!(
1086                fidl::encoding::Endpoint<
1087                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1088                >,
1089                fidl::encoding::DefaultFuchsiaResourceDialect,
1090                &mut self.realm_server,
1091                decoder,
1092                offset + 0,
1093                _depth
1094            )?;
1095            Ok(())
1096        }
1097    }
1098
1099    impl RealmOptions {
1100        #[inline(always)]
1101        fn max_ordinal_present(&self) -> u64 {
1102            if let Some(_) = self.stuck_warning_timeout_seconds {
1103                return 4;
1104            }
1105            if let Some(_) = self.use_suspender {
1106                return 3;
1107            }
1108            if let Some(_) = self.wait_for_suspending_token {
1109                return 2;
1110            }
1111            if let Some(_) = self.use_fake_sag {
1112                return 1;
1113            }
1114            0
1115        }
1116    }
1117
1118    impl fidl::encoding::ResourceTypeMarker for RealmOptions {
1119        type Borrowed<'a> = &'a mut Self;
1120        fn take_or_borrow<'a>(
1121            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1122        ) -> Self::Borrowed<'a> {
1123            value
1124        }
1125    }
1126
1127    unsafe impl fidl::encoding::TypeMarker for RealmOptions {
1128        type Owned = Self;
1129
1130        #[inline(always)]
1131        fn inline_align(_context: fidl::encoding::Context) -> usize {
1132            8
1133        }
1134
1135        #[inline(always)]
1136        fn inline_size(_context: fidl::encoding::Context) -> usize {
1137            16
1138        }
1139    }
1140
1141    unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1142        for &mut RealmOptions
1143    {
1144        unsafe fn encode(
1145            self,
1146            encoder: &mut fidl::encoding::Encoder<
1147                '_,
1148                fidl::encoding::DefaultFuchsiaResourceDialect,
1149            >,
1150            offset: usize,
1151            mut depth: fidl::encoding::Depth,
1152        ) -> fidl::Result<()> {
1153            encoder.debug_check_bounds::<RealmOptions>(offset);
1154            // Vector header
1155            let max_ordinal: u64 = self.max_ordinal_present();
1156            encoder.write_num(max_ordinal, offset);
1157            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1158            // Calling encoder.out_of_line_offset(0) is not allowed.
1159            if max_ordinal == 0 {
1160                return Ok(());
1161            }
1162            depth.increment()?;
1163            let envelope_size = 8;
1164            let bytes_len = max_ordinal as usize * envelope_size;
1165            #[allow(unused_variables)]
1166            let offset = encoder.out_of_line_offset(bytes_len);
1167            let mut _prev_end_offset: usize = 0;
1168            if 1 > max_ordinal {
1169                return Ok(());
1170            }
1171
1172            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1173            // are envelope_size bytes.
1174            let cur_offset: usize = (1 - 1) * envelope_size;
1175
1176            // Zero reserved fields.
1177            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1178
1179            // Safety:
1180            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1181            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1182            //   envelope_size bytes, there is always sufficient room.
1183            fidl::encoding::encode_in_envelope_optional::<
1184                bool,
1185                fidl::encoding::DefaultFuchsiaResourceDialect,
1186            >(
1187                self.use_fake_sag.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1188                encoder,
1189                offset + cur_offset,
1190                depth,
1191            )?;
1192
1193            _prev_end_offset = cur_offset + envelope_size;
1194            if 2 > max_ordinal {
1195                return Ok(());
1196            }
1197
1198            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1199            // are envelope_size bytes.
1200            let cur_offset: usize = (2 - 1) * envelope_size;
1201
1202            // Zero reserved fields.
1203            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1204
1205            // Safety:
1206            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1207            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1208            //   envelope_size bytes, there is always sufficient room.
1209            fidl::encoding::encode_in_envelope_optional::<
1210                bool,
1211                fidl::encoding::DefaultFuchsiaResourceDialect,
1212            >(
1213                self.wait_for_suspending_token
1214                    .as_ref()
1215                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1216                encoder,
1217                offset + cur_offset,
1218                depth,
1219            )?;
1220
1221            _prev_end_offset = cur_offset + envelope_size;
1222            if 3 > max_ordinal {
1223                return Ok(());
1224            }
1225
1226            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1227            // are envelope_size bytes.
1228            let cur_offset: usize = (3 - 1) * envelope_size;
1229
1230            // Zero reserved fields.
1231            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1232
1233            // Safety:
1234            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1235            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1236            //   envelope_size bytes, there is always sufficient room.
1237            fidl::encoding::encode_in_envelope_optional::<
1238                bool,
1239                fidl::encoding::DefaultFuchsiaResourceDialect,
1240            >(
1241                self.use_suspender.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1242                encoder,
1243                offset + cur_offset,
1244                depth,
1245            )?;
1246
1247            _prev_end_offset = cur_offset + envelope_size;
1248            if 4 > max_ordinal {
1249                return Ok(());
1250            }
1251
1252            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1253            // are envelope_size bytes.
1254            let cur_offset: usize = (4 - 1) * envelope_size;
1255
1256            // Zero reserved fields.
1257            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1258
1259            // Safety:
1260            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1261            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1262            //   envelope_size bytes, there is always sufficient room.
1263            fidl::encoding::encode_in_envelope_optional::<
1264                u32,
1265                fidl::encoding::DefaultFuchsiaResourceDialect,
1266            >(
1267                self.stuck_warning_timeout_seconds
1268                    .as_ref()
1269                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1270                encoder,
1271                offset + cur_offset,
1272                depth,
1273            )?;
1274
1275            _prev_end_offset = cur_offset + envelope_size;
1276
1277            Ok(())
1278        }
1279    }
1280
1281    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
1282        #[inline(always)]
1283        fn new_empty() -> Self {
1284            Self::default()
1285        }
1286
1287        unsafe fn decode(
1288            &mut self,
1289            decoder: &mut fidl::encoding::Decoder<
1290                '_,
1291                fidl::encoding::DefaultFuchsiaResourceDialect,
1292            >,
1293            offset: usize,
1294            mut depth: fidl::encoding::Depth,
1295        ) -> fidl::Result<()> {
1296            decoder.debug_check_bounds::<Self>(offset);
1297            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1298                None => return Err(fidl::Error::NotNullable),
1299                Some(len) => len,
1300            };
1301            // Calling decoder.out_of_line_offset(0) is not allowed.
1302            if len == 0 {
1303                return Ok(());
1304            };
1305            depth.increment()?;
1306            let envelope_size = 8;
1307            let bytes_len = len * envelope_size;
1308            let offset = decoder.out_of_line_offset(bytes_len)?;
1309            // Decode the envelope for each type.
1310            let mut _next_ordinal_to_read = 0;
1311            let mut next_offset = offset;
1312            let end_offset = offset + bytes_len;
1313            _next_ordinal_to_read += 1;
1314            if next_offset >= end_offset {
1315                return Ok(());
1316            }
1317
1318            // Decode unknown envelopes for gaps in ordinals.
1319            while _next_ordinal_to_read < 1 {
1320                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1321                _next_ordinal_to_read += 1;
1322                next_offset += envelope_size;
1323            }
1324
1325            let next_out_of_line = decoder.next_out_of_line();
1326            let handles_before = decoder.remaining_handles();
1327            if let Some((inlined, num_bytes, num_handles)) =
1328                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1329            {
1330                let member_inline_size =
1331                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1332                if inlined != (member_inline_size <= 4) {
1333                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1334                }
1335                let inner_offset;
1336                let mut inner_depth = depth.clone();
1337                if inlined {
1338                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1339                    inner_offset = next_offset;
1340                } else {
1341                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1342                    inner_depth.increment()?;
1343                }
1344                let val_ref = self.use_fake_sag.get_or_insert_with(|| {
1345                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1346                });
1347                fidl::decode!(
1348                    bool,
1349                    fidl::encoding::DefaultFuchsiaResourceDialect,
1350                    val_ref,
1351                    decoder,
1352                    inner_offset,
1353                    inner_depth
1354                )?;
1355                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1356                {
1357                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1358                }
1359                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1360                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1361                }
1362            }
1363
1364            next_offset += envelope_size;
1365            _next_ordinal_to_read += 1;
1366            if next_offset >= end_offset {
1367                return Ok(());
1368            }
1369
1370            // Decode unknown envelopes for gaps in ordinals.
1371            while _next_ordinal_to_read < 2 {
1372                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1373                _next_ordinal_to_read += 1;
1374                next_offset += envelope_size;
1375            }
1376
1377            let next_out_of_line = decoder.next_out_of_line();
1378            let handles_before = decoder.remaining_handles();
1379            if let Some((inlined, num_bytes, num_handles)) =
1380                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1381            {
1382                let member_inline_size =
1383                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1384                if inlined != (member_inline_size <= 4) {
1385                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1386                }
1387                let inner_offset;
1388                let mut inner_depth = depth.clone();
1389                if inlined {
1390                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1391                    inner_offset = next_offset;
1392                } else {
1393                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1394                    inner_depth.increment()?;
1395                }
1396                let val_ref = self.wait_for_suspending_token.get_or_insert_with(|| {
1397                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1398                });
1399                fidl::decode!(
1400                    bool,
1401                    fidl::encoding::DefaultFuchsiaResourceDialect,
1402                    val_ref,
1403                    decoder,
1404                    inner_offset,
1405                    inner_depth
1406                )?;
1407                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1408                {
1409                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1410                }
1411                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1412                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1413                }
1414            }
1415
1416            next_offset += envelope_size;
1417            _next_ordinal_to_read += 1;
1418            if next_offset >= end_offset {
1419                return Ok(());
1420            }
1421
1422            // Decode unknown envelopes for gaps in ordinals.
1423            while _next_ordinal_to_read < 3 {
1424                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1425                _next_ordinal_to_read += 1;
1426                next_offset += envelope_size;
1427            }
1428
1429            let next_out_of_line = decoder.next_out_of_line();
1430            let handles_before = decoder.remaining_handles();
1431            if let Some((inlined, num_bytes, num_handles)) =
1432                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1433            {
1434                let member_inline_size =
1435                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1436                if inlined != (member_inline_size <= 4) {
1437                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1438                }
1439                let inner_offset;
1440                let mut inner_depth = depth.clone();
1441                if inlined {
1442                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1443                    inner_offset = next_offset;
1444                } else {
1445                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1446                    inner_depth.increment()?;
1447                }
1448                let val_ref = self.use_suspender.get_or_insert_with(|| {
1449                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1450                });
1451                fidl::decode!(
1452                    bool,
1453                    fidl::encoding::DefaultFuchsiaResourceDialect,
1454                    val_ref,
1455                    decoder,
1456                    inner_offset,
1457                    inner_depth
1458                )?;
1459                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1460                {
1461                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1462                }
1463                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1464                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1465                }
1466            }
1467
1468            next_offset += envelope_size;
1469            _next_ordinal_to_read += 1;
1470            if next_offset >= end_offset {
1471                return Ok(());
1472            }
1473
1474            // Decode unknown envelopes for gaps in ordinals.
1475            while _next_ordinal_to_read < 4 {
1476                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1477                _next_ordinal_to_read += 1;
1478                next_offset += envelope_size;
1479            }
1480
1481            let next_out_of_line = decoder.next_out_of_line();
1482            let handles_before = decoder.remaining_handles();
1483            if let Some((inlined, num_bytes, num_handles)) =
1484                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1485            {
1486                let member_inline_size =
1487                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1488                if inlined != (member_inline_size <= 4) {
1489                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1490                }
1491                let inner_offset;
1492                let mut inner_depth = depth.clone();
1493                if inlined {
1494                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1495                    inner_offset = next_offset;
1496                } else {
1497                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1498                    inner_depth.increment()?;
1499                }
1500                let val_ref = self.stuck_warning_timeout_seconds.get_or_insert_with(|| {
1501                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1502                });
1503                fidl::decode!(
1504                    u32,
1505                    fidl::encoding::DefaultFuchsiaResourceDialect,
1506                    val_ref,
1507                    decoder,
1508                    inner_offset,
1509                    inner_depth
1510                )?;
1511                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1512                {
1513                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1514                }
1515                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1516                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1517                }
1518            }
1519
1520            next_offset += envelope_size;
1521
1522            // Decode the remaining unknown envelopes.
1523            while next_offset < end_offset {
1524                _next_ordinal_to_read += 1;
1525                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1526                next_offset += envelope_size;
1527            }
1528
1529            Ok(())
1530        }
1531    }
1532}