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