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