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