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 RealmFactoryControlHandle {
632    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
633        self.inner.shutdown_with_epitaph(status.into())
634    }
635}
636
637impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
638    fn shutdown(&self) {
639        self.inner.shutdown()
640    }
641
642    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
643        self.inner.shutdown_with_epitaph(status)
644    }
645
646    fn is_closed(&self) -> bool {
647        self.inner.channel().is_closed()
648    }
649    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
650        self.inner.channel().on_closed()
651    }
652
653    #[cfg(target_os = "fuchsia")]
654    fn signal_peer(
655        &self,
656        clear_mask: zx::Signals,
657        set_mask: zx::Signals,
658    ) -> Result<(), zx_status::Status> {
659        use fidl::Peered;
660        self.inner.channel().signal_peer(clear_mask, set_mask)
661    }
662}
663
664impl RealmFactoryControlHandle {}
665
666#[must_use = "FIDL methods require a response to be sent"]
667#[derive(Debug)]
668pub struct RealmFactoryCreateRealmResponder {
669    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
670    tx_id: u32,
671}
672
673/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
674/// if the responder is dropped without sending a response, so that the client
675/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
676impl std::ops::Drop for RealmFactoryCreateRealmResponder {
677    fn drop(&mut self) {
678        self.control_handle.shutdown();
679        // Safety: drops once, never accessed again
680        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
681    }
682}
683
684impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
685    type ControlHandle = RealmFactoryControlHandle;
686
687    fn control_handle(&self) -> &RealmFactoryControlHandle {
688        &self.control_handle
689    }
690
691    fn drop_without_shutdown(mut self) {
692        // Safety: drops once, never accessed again due to mem::forget
693        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
694        // Prevent Drop from running (which would shut down the channel)
695        std::mem::forget(self);
696    }
697}
698
699impl RealmFactoryCreateRealmResponder {
700    /// Sends a response to the FIDL transaction.
701    ///
702    /// Sets the channel to shutdown if an error occurs.
703    pub fn send(
704        self,
705        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
706    ) -> Result<(), fidl::Error> {
707        let _result = self.send_raw(result);
708        if _result.is_err() {
709            self.control_handle.shutdown();
710        }
711        self.drop_without_shutdown();
712        _result
713    }
714
715    /// Similar to "send" but does not shutdown the channel if an error occurs.
716    pub fn send_no_shutdown_on_err(
717        self,
718        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
719    ) -> Result<(), fidl::Error> {
720        let _result = self.send_raw(result);
721        self.drop_without_shutdown();
722        _result
723    }
724
725    fn send_raw(
726        &self,
727        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
728    ) -> Result<(), fidl::Error> {
729        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
730            RealmFactoryCreateRealmResponse,
731            fidl_fuchsia_testing_harness::OperationError,
732        >>(
733            fidl::encoding::FlexibleResult::new(
734                result.map(|activity_governor_moniker| (activity_governor_moniker,)),
735            ),
736            self.tx_id,
737            0x3fcb27aa634a2df3,
738            fidl::encoding::DynamicFlags::FLEXIBLE,
739        )
740    }
741}
742
743#[must_use = "FIDL methods require a response to be sent"]
744#[derive(Debug)]
745pub struct RealmFactoryCreateRealmExtResponder {
746    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
747    tx_id: u32,
748}
749
750/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
751/// if the responder is dropped without sending a response, so that the client
752/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
753impl std::ops::Drop for RealmFactoryCreateRealmExtResponder {
754    fn drop(&mut self) {
755        self.control_handle.shutdown();
756        // Safety: drops once, never accessed again
757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
758    }
759}
760
761impl fidl::endpoints::Responder for RealmFactoryCreateRealmExtResponder {
762    type ControlHandle = RealmFactoryControlHandle;
763
764    fn control_handle(&self) -> &RealmFactoryControlHandle {
765        &self.control_handle
766    }
767
768    fn drop_without_shutdown(mut self) {
769        // Safety: drops once, never accessed again due to mem::forget
770        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
771        // Prevent Drop from running (which would shut down the channel)
772        std::mem::forget(self);
773    }
774}
775
776impl RealmFactoryCreateRealmExtResponder {
777    /// Sends a response to the FIDL transaction.
778    ///
779    /// Sets the channel to shutdown if an error occurs.
780    pub fn send(
781        self,
782        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
783    ) -> Result<(), fidl::Error> {
784        let _result = self.send_raw(result);
785        if _result.is_err() {
786            self.control_handle.shutdown();
787        }
788        self.drop_without_shutdown();
789        _result
790    }
791
792    /// Similar to "send" but does not shutdown the channel if an error occurs.
793    pub fn send_no_shutdown_on_err(
794        self,
795        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
796    ) -> Result<(), fidl::Error> {
797        let _result = self.send_raw(result);
798        self.drop_without_shutdown();
799        _result
800    }
801
802    fn send_raw(
803        &self,
804        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
805    ) -> Result<(), fidl::Error> {
806        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
807            RealmFactoryCreateRealmExtResponse,
808            fidl_fuchsia_testing_harness::OperationError,
809        >>(
810            fidl::encoding::FlexibleResult::new(
811                result.map(|activity_governor_moniker| (activity_governor_moniker,)),
812            ),
813            self.tx_id,
814            0x63a655ff630a0db0,
815            fidl::encoding::DynamicFlags::FLEXIBLE,
816        )
817    }
818}
819
820mod internal {
821    use super::*;
822
823    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmExtRequest {
824        type Borrowed<'a> = &'a mut Self;
825        fn take_or_borrow<'a>(
826            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
827        ) -> Self::Borrowed<'a> {
828            value
829        }
830    }
831
832    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmExtRequest {
833        type Owned = Self;
834
835        #[inline(always)]
836        fn inline_align(_context: fidl::encoding::Context) -> usize {
837            8
838        }
839
840        #[inline(always)]
841        fn inline_size(_context: fidl::encoding::Context) -> usize {
842            24
843        }
844    }
845
846    unsafe impl
847        fidl::encoding::Encode<
848            RealmFactoryCreateRealmExtRequest,
849            fidl::encoding::DefaultFuchsiaResourceDialect,
850        > for &mut RealmFactoryCreateRealmExtRequest
851    {
852        #[inline]
853        unsafe fn encode(
854            self,
855            encoder: &mut fidl::encoding::Encoder<
856                '_,
857                fidl::encoding::DefaultFuchsiaResourceDialect,
858            >,
859            offset: usize,
860            _depth: fidl::encoding::Depth,
861        ) -> fidl::Result<()> {
862            encoder.debug_check_bounds::<RealmFactoryCreateRealmExtRequest>(offset);
863            // Delegate to tuple encoding.
864            fidl::encoding::Encode::<
865                RealmFactoryCreateRealmExtRequest,
866                fidl::encoding::DefaultFuchsiaResourceDialect,
867            >::encode(
868                (
869                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
870                        &mut self.options,
871                    ),
872                    <fidl::encoding::Endpoint<
873                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
874                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
875                        &mut self.realm_server,
876                    ),
877                ),
878                encoder,
879                offset,
880                _depth,
881            )
882        }
883    }
884    unsafe impl<
885        T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
886        T1: fidl::encoding::Encode<
887                fidl::encoding::Endpoint<
888                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
889                >,
890                fidl::encoding::DefaultFuchsiaResourceDialect,
891            >,
892    >
893        fidl::encoding::Encode<
894            RealmFactoryCreateRealmExtRequest,
895            fidl::encoding::DefaultFuchsiaResourceDialect,
896        > for (T0, T1)
897    {
898        #[inline]
899        unsafe fn encode(
900            self,
901            encoder: &mut fidl::encoding::Encoder<
902                '_,
903                fidl::encoding::DefaultFuchsiaResourceDialect,
904            >,
905            offset: usize,
906            depth: fidl::encoding::Depth,
907        ) -> fidl::Result<()> {
908            encoder.debug_check_bounds::<RealmFactoryCreateRealmExtRequest>(offset);
909            // Zero out padding regions. There's no need to apply masks
910            // because the unmasked parts will be overwritten by fields.
911            unsafe {
912                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
913                (ptr as *mut u64).write_unaligned(0);
914            }
915            // Write the fields.
916            self.0.encode(encoder, offset + 0, depth)?;
917            self.1.encode(encoder, offset + 16, depth)?;
918            Ok(())
919        }
920    }
921
922    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
923        for RealmFactoryCreateRealmExtRequest
924    {
925        #[inline(always)]
926        fn new_empty() -> Self {
927            Self {
928                options: fidl::new_empty!(
929                    RealmOptions,
930                    fidl::encoding::DefaultFuchsiaResourceDialect
931                ),
932                realm_server: fidl::new_empty!(
933                    fidl::encoding::Endpoint<
934                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
935                    >,
936                    fidl::encoding::DefaultFuchsiaResourceDialect
937                ),
938            }
939        }
940
941        #[inline]
942        unsafe fn decode(
943            &mut self,
944            decoder: &mut fidl::encoding::Decoder<
945                '_,
946                fidl::encoding::DefaultFuchsiaResourceDialect,
947            >,
948            offset: usize,
949            _depth: fidl::encoding::Depth,
950        ) -> fidl::Result<()> {
951            decoder.debug_check_bounds::<Self>(offset);
952            // Verify that padding bytes are zero.
953            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
954            let padval = unsafe { (ptr as *const u64).read_unaligned() };
955            let mask = 0xffffffff00000000u64;
956            let maskedval = padval & mask;
957            if maskedval != 0 {
958                return Err(fidl::Error::NonZeroPadding {
959                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
960                });
961            }
962            fidl::decode!(
963                RealmOptions,
964                fidl::encoding::DefaultFuchsiaResourceDialect,
965                &mut self.options,
966                decoder,
967                offset + 0,
968                _depth
969            )?;
970            fidl::decode!(
971                fidl::encoding::Endpoint<
972                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
973                >,
974                fidl::encoding::DefaultFuchsiaResourceDialect,
975                &mut self.realm_server,
976                decoder,
977                offset + 16,
978                _depth
979            )?;
980            Ok(())
981        }
982    }
983
984    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
985        type Borrowed<'a> = &'a mut Self;
986        fn take_or_borrow<'a>(
987            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
988        ) -> Self::Borrowed<'a> {
989            value
990        }
991    }
992
993    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
994        type Owned = Self;
995
996        #[inline(always)]
997        fn inline_align(_context: fidl::encoding::Context) -> usize {
998            4
999        }
1000
1001        #[inline(always)]
1002        fn inline_size(_context: fidl::encoding::Context) -> usize {
1003            4
1004        }
1005    }
1006
1007    unsafe impl
1008        fidl::encoding::Encode<
1009            RealmFactoryCreateRealmRequest,
1010            fidl::encoding::DefaultFuchsiaResourceDialect,
1011        > for &mut RealmFactoryCreateRealmRequest
1012    {
1013        #[inline]
1014        unsafe fn encode(
1015            self,
1016            encoder: &mut fidl::encoding::Encoder<
1017                '_,
1018                fidl::encoding::DefaultFuchsiaResourceDialect,
1019            >,
1020            offset: usize,
1021            _depth: fidl::encoding::Depth,
1022        ) -> fidl::Result<()> {
1023            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1024            // Delegate to tuple encoding.
1025            fidl::encoding::Encode::<
1026                RealmFactoryCreateRealmRequest,
1027                fidl::encoding::DefaultFuchsiaResourceDialect,
1028            >::encode(
1029                (<fidl::encoding::Endpoint<
1030                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1031                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1032                    &mut self.realm_server
1033                ),),
1034                encoder,
1035                offset,
1036                _depth,
1037            )
1038        }
1039    }
1040    unsafe impl<
1041        T0: fidl::encoding::Encode<
1042                fidl::encoding::Endpoint<
1043                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1044                >,
1045                fidl::encoding::DefaultFuchsiaResourceDialect,
1046            >,
1047    >
1048        fidl::encoding::Encode<
1049            RealmFactoryCreateRealmRequest,
1050            fidl::encoding::DefaultFuchsiaResourceDialect,
1051        > for (T0,)
1052    {
1053        #[inline]
1054        unsafe fn encode(
1055            self,
1056            encoder: &mut fidl::encoding::Encoder<
1057                '_,
1058                fidl::encoding::DefaultFuchsiaResourceDialect,
1059            >,
1060            offset: usize,
1061            depth: fidl::encoding::Depth,
1062        ) -> fidl::Result<()> {
1063            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1064            // Zero out padding regions. There's no need to apply masks
1065            // because the unmasked parts will be overwritten by fields.
1066            // Write the fields.
1067            self.0.encode(encoder, offset + 0, depth)?;
1068            Ok(())
1069        }
1070    }
1071
1072    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1073        for RealmFactoryCreateRealmRequest
1074    {
1075        #[inline(always)]
1076        fn new_empty() -> Self {
1077            Self {
1078                realm_server: fidl::new_empty!(
1079                    fidl::encoding::Endpoint<
1080                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1081                    >,
1082                    fidl::encoding::DefaultFuchsiaResourceDialect
1083                ),
1084            }
1085        }
1086
1087        #[inline]
1088        unsafe fn decode(
1089            &mut self,
1090            decoder: &mut fidl::encoding::Decoder<
1091                '_,
1092                fidl::encoding::DefaultFuchsiaResourceDialect,
1093            >,
1094            offset: usize,
1095            _depth: fidl::encoding::Depth,
1096        ) -> fidl::Result<()> {
1097            decoder.debug_check_bounds::<Self>(offset);
1098            // Verify that padding bytes are zero.
1099            fidl::decode!(
1100                fidl::encoding::Endpoint<
1101                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1102                >,
1103                fidl::encoding::DefaultFuchsiaResourceDialect,
1104                &mut self.realm_server,
1105                decoder,
1106                offset + 0,
1107                _depth
1108            )?;
1109            Ok(())
1110        }
1111    }
1112
1113    impl RealmOptions {
1114        #[inline(always)]
1115        fn max_ordinal_present(&self) -> u64 {
1116            if let Some(_) = self.use_fake_clock {
1117                return 7;
1118            }
1119            if let Some(_) = self.long_wake_lease_timeout_seconds {
1120                return 6;
1121            }
1122            if let Some(_) = self.reboot_on_stalled_suspend_blocker {
1123                return 5;
1124            }
1125            if let Some(_) = self.stuck_warning_timeout_seconds {
1126                return 4;
1127            }
1128            if let Some(_) = self.use_suspender {
1129                return 3;
1130            }
1131            if let Some(_) = self.wait_for_suspending_token {
1132                return 2;
1133            }
1134            if let Some(_) = self.use_fake_sag {
1135                return 1;
1136            }
1137            0
1138        }
1139    }
1140
1141    impl fidl::encoding::ResourceTypeMarker for RealmOptions {
1142        type Borrowed<'a> = &'a mut Self;
1143        fn take_or_borrow<'a>(
1144            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1145        ) -> Self::Borrowed<'a> {
1146            value
1147        }
1148    }
1149
1150    unsafe impl fidl::encoding::TypeMarker for RealmOptions {
1151        type Owned = Self;
1152
1153        #[inline(always)]
1154        fn inline_align(_context: fidl::encoding::Context) -> usize {
1155            8
1156        }
1157
1158        #[inline(always)]
1159        fn inline_size(_context: fidl::encoding::Context) -> usize {
1160            16
1161        }
1162    }
1163
1164    unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1165        for &mut RealmOptions
1166    {
1167        unsafe fn encode(
1168            self,
1169            encoder: &mut fidl::encoding::Encoder<
1170                '_,
1171                fidl::encoding::DefaultFuchsiaResourceDialect,
1172            >,
1173            offset: usize,
1174            mut depth: fidl::encoding::Depth,
1175        ) -> fidl::Result<()> {
1176            encoder.debug_check_bounds::<RealmOptions>(offset);
1177            // Vector header
1178            let max_ordinal: u64 = self.max_ordinal_present();
1179            encoder.write_num(max_ordinal, offset);
1180            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1181            // Calling encoder.out_of_line_offset(0) is not allowed.
1182            if max_ordinal == 0 {
1183                return Ok(());
1184            }
1185            depth.increment()?;
1186            let envelope_size = 8;
1187            let bytes_len = max_ordinal as usize * envelope_size;
1188            #[allow(unused_variables)]
1189            let offset = encoder.out_of_line_offset(bytes_len);
1190            let mut _prev_end_offset: usize = 0;
1191            if 1 > max_ordinal {
1192                return Ok(());
1193            }
1194
1195            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1196            // are envelope_size bytes.
1197            let cur_offset: usize = (1 - 1) * envelope_size;
1198
1199            // Zero reserved fields.
1200            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1201
1202            // Safety:
1203            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1204            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1205            //   envelope_size bytes, there is always sufficient room.
1206            fidl::encoding::encode_in_envelope_optional::<
1207                bool,
1208                fidl::encoding::DefaultFuchsiaResourceDialect,
1209            >(
1210                self.use_fake_sag.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1211                encoder,
1212                offset + cur_offset,
1213                depth,
1214            )?;
1215
1216            _prev_end_offset = cur_offset + envelope_size;
1217            if 2 > max_ordinal {
1218                return Ok(());
1219            }
1220
1221            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1222            // are envelope_size bytes.
1223            let cur_offset: usize = (2 - 1) * envelope_size;
1224
1225            // Zero reserved fields.
1226            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1227
1228            // Safety:
1229            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1230            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1231            //   envelope_size bytes, there is always sufficient room.
1232            fidl::encoding::encode_in_envelope_optional::<
1233                bool,
1234                fidl::encoding::DefaultFuchsiaResourceDialect,
1235            >(
1236                self.wait_for_suspending_token
1237                    .as_ref()
1238                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1239                encoder,
1240                offset + cur_offset,
1241                depth,
1242            )?;
1243
1244            _prev_end_offset = cur_offset + envelope_size;
1245            if 3 > max_ordinal {
1246                return Ok(());
1247            }
1248
1249            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1250            // are envelope_size bytes.
1251            let cur_offset: usize = (3 - 1) * envelope_size;
1252
1253            // Zero reserved fields.
1254            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1255
1256            // Safety:
1257            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1258            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1259            //   envelope_size bytes, there is always sufficient room.
1260            fidl::encoding::encode_in_envelope_optional::<
1261                bool,
1262                fidl::encoding::DefaultFuchsiaResourceDialect,
1263            >(
1264                self.use_suspender.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1265                encoder,
1266                offset + cur_offset,
1267                depth,
1268            )?;
1269
1270            _prev_end_offset = cur_offset + envelope_size;
1271            if 4 > max_ordinal {
1272                return Ok(());
1273            }
1274
1275            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1276            // are envelope_size bytes.
1277            let cur_offset: usize = (4 - 1) * envelope_size;
1278
1279            // Zero reserved fields.
1280            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1281
1282            // Safety:
1283            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1284            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1285            //   envelope_size bytes, there is always sufficient room.
1286            fidl::encoding::encode_in_envelope_optional::<
1287                u32,
1288                fidl::encoding::DefaultFuchsiaResourceDialect,
1289            >(
1290                self.stuck_warning_timeout_seconds
1291                    .as_ref()
1292                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1293                encoder,
1294                offset + cur_offset,
1295                depth,
1296            )?;
1297
1298            _prev_end_offset = cur_offset + envelope_size;
1299            if 5 > max_ordinal {
1300                return Ok(());
1301            }
1302
1303            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1304            // are envelope_size bytes.
1305            let cur_offset: usize = (5 - 1) * envelope_size;
1306
1307            // Zero reserved fields.
1308            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1309
1310            // Safety:
1311            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1312            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1313            //   envelope_size bytes, there is always sufficient room.
1314            fidl::encoding::encode_in_envelope_optional::<
1315                bool,
1316                fidl::encoding::DefaultFuchsiaResourceDialect,
1317            >(
1318                self.reboot_on_stalled_suspend_blocker
1319                    .as_ref()
1320                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1321                encoder,
1322                offset + cur_offset,
1323                depth,
1324            )?;
1325
1326            _prev_end_offset = cur_offset + envelope_size;
1327            if 6 > max_ordinal {
1328                return Ok(());
1329            }
1330
1331            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1332            // are envelope_size bytes.
1333            let cur_offset: usize = (6 - 1) * envelope_size;
1334
1335            // Zero reserved fields.
1336            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1337
1338            // Safety:
1339            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1340            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1341            //   envelope_size bytes, there is always sufficient room.
1342            fidl::encoding::encode_in_envelope_optional::<
1343                u32,
1344                fidl::encoding::DefaultFuchsiaResourceDialect,
1345            >(
1346                self.long_wake_lease_timeout_seconds
1347                    .as_ref()
1348                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1349                encoder,
1350                offset + cur_offset,
1351                depth,
1352            )?;
1353
1354            _prev_end_offset = cur_offset + envelope_size;
1355            if 7 > max_ordinal {
1356                return Ok(());
1357            }
1358
1359            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1360            // are envelope_size bytes.
1361            let cur_offset: usize = (7 - 1) * envelope_size;
1362
1363            // Zero reserved fields.
1364            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1365
1366            // Safety:
1367            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1368            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1369            //   envelope_size bytes, there is always sufficient room.
1370            fidl::encoding::encode_in_envelope_optional::<
1371                bool,
1372                fidl::encoding::DefaultFuchsiaResourceDialect,
1373            >(
1374                self.use_fake_clock.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1375                encoder,
1376                offset + cur_offset,
1377                depth,
1378            )?;
1379
1380            _prev_end_offset = cur_offset + envelope_size;
1381
1382            Ok(())
1383        }
1384    }
1385
1386    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
1387        #[inline(always)]
1388        fn new_empty() -> Self {
1389            Self::default()
1390        }
1391
1392        unsafe fn decode(
1393            &mut self,
1394            decoder: &mut fidl::encoding::Decoder<
1395                '_,
1396                fidl::encoding::DefaultFuchsiaResourceDialect,
1397            >,
1398            offset: usize,
1399            mut depth: fidl::encoding::Depth,
1400        ) -> fidl::Result<()> {
1401            decoder.debug_check_bounds::<Self>(offset);
1402            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1403                None => return Err(fidl::Error::NotNullable),
1404                Some(len) => len,
1405            };
1406            // Calling decoder.out_of_line_offset(0) is not allowed.
1407            if len == 0 {
1408                return Ok(());
1409            };
1410            depth.increment()?;
1411            let envelope_size = 8;
1412            let bytes_len = len * envelope_size;
1413            let offset = decoder.out_of_line_offset(bytes_len)?;
1414            // Decode the envelope for each type.
1415            let mut _next_ordinal_to_read = 0;
1416            let mut next_offset = offset;
1417            let end_offset = offset + bytes_len;
1418            _next_ordinal_to_read += 1;
1419            if next_offset >= end_offset {
1420                return Ok(());
1421            }
1422
1423            // Decode unknown envelopes for gaps in ordinals.
1424            while _next_ordinal_to_read < 1 {
1425                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1426                _next_ordinal_to_read += 1;
1427                next_offset += envelope_size;
1428            }
1429
1430            let next_out_of_line = decoder.next_out_of_line();
1431            let handles_before = decoder.remaining_handles();
1432            if let Some((inlined, num_bytes, num_handles)) =
1433                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1434            {
1435                let member_inline_size =
1436                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1437                if inlined != (member_inline_size <= 4) {
1438                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1439                }
1440                let inner_offset;
1441                let mut inner_depth = depth.clone();
1442                if inlined {
1443                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1444                    inner_offset = next_offset;
1445                } else {
1446                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1447                    inner_depth.increment()?;
1448                }
1449                let val_ref = self.use_fake_sag.get_or_insert_with(|| {
1450                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1451                });
1452                fidl::decode!(
1453                    bool,
1454                    fidl::encoding::DefaultFuchsiaResourceDialect,
1455                    val_ref,
1456                    decoder,
1457                    inner_offset,
1458                    inner_depth
1459                )?;
1460                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1461                {
1462                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1463                }
1464                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1465                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1466                }
1467            }
1468
1469            next_offset += envelope_size;
1470            _next_ordinal_to_read += 1;
1471            if next_offset >= end_offset {
1472                return Ok(());
1473            }
1474
1475            // Decode unknown envelopes for gaps in ordinals.
1476            while _next_ordinal_to_read < 2 {
1477                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1478                _next_ordinal_to_read += 1;
1479                next_offset += envelope_size;
1480            }
1481
1482            let next_out_of_line = decoder.next_out_of_line();
1483            let handles_before = decoder.remaining_handles();
1484            if let Some((inlined, num_bytes, num_handles)) =
1485                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1486            {
1487                let member_inline_size =
1488                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1489                if inlined != (member_inline_size <= 4) {
1490                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1491                }
1492                let inner_offset;
1493                let mut inner_depth = depth.clone();
1494                if inlined {
1495                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1496                    inner_offset = next_offset;
1497                } else {
1498                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1499                    inner_depth.increment()?;
1500                }
1501                let val_ref = self.wait_for_suspending_token.get_or_insert_with(|| {
1502                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1503                });
1504                fidl::decode!(
1505                    bool,
1506                    fidl::encoding::DefaultFuchsiaResourceDialect,
1507                    val_ref,
1508                    decoder,
1509                    inner_offset,
1510                    inner_depth
1511                )?;
1512                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1513                {
1514                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1515                }
1516                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1517                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1518                }
1519            }
1520
1521            next_offset += envelope_size;
1522            _next_ordinal_to_read += 1;
1523            if next_offset >= end_offset {
1524                return Ok(());
1525            }
1526
1527            // Decode unknown envelopes for gaps in ordinals.
1528            while _next_ordinal_to_read < 3 {
1529                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1530                _next_ordinal_to_read += 1;
1531                next_offset += envelope_size;
1532            }
1533
1534            let next_out_of_line = decoder.next_out_of_line();
1535            let handles_before = decoder.remaining_handles();
1536            if let Some((inlined, num_bytes, num_handles)) =
1537                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1538            {
1539                let member_inline_size =
1540                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1541                if inlined != (member_inline_size <= 4) {
1542                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1543                }
1544                let inner_offset;
1545                let mut inner_depth = depth.clone();
1546                if inlined {
1547                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1548                    inner_offset = next_offset;
1549                } else {
1550                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1551                    inner_depth.increment()?;
1552                }
1553                let val_ref = self.use_suspender.get_or_insert_with(|| {
1554                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1555                });
1556                fidl::decode!(
1557                    bool,
1558                    fidl::encoding::DefaultFuchsiaResourceDialect,
1559                    val_ref,
1560                    decoder,
1561                    inner_offset,
1562                    inner_depth
1563                )?;
1564                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1565                {
1566                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1567                }
1568                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1569                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1570                }
1571            }
1572
1573            next_offset += envelope_size;
1574            _next_ordinal_to_read += 1;
1575            if next_offset >= end_offset {
1576                return Ok(());
1577            }
1578
1579            // Decode unknown envelopes for gaps in ordinals.
1580            while _next_ordinal_to_read < 4 {
1581                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1582                _next_ordinal_to_read += 1;
1583                next_offset += envelope_size;
1584            }
1585
1586            let next_out_of_line = decoder.next_out_of_line();
1587            let handles_before = decoder.remaining_handles();
1588            if let Some((inlined, num_bytes, num_handles)) =
1589                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1590            {
1591                let member_inline_size =
1592                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1593                if inlined != (member_inline_size <= 4) {
1594                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1595                }
1596                let inner_offset;
1597                let mut inner_depth = depth.clone();
1598                if inlined {
1599                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1600                    inner_offset = next_offset;
1601                } else {
1602                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1603                    inner_depth.increment()?;
1604                }
1605                let val_ref = self.stuck_warning_timeout_seconds.get_or_insert_with(|| {
1606                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1607                });
1608                fidl::decode!(
1609                    u32,
1610                    fidl::encoding::DefaultFuchsiaResourceDialect,
1611                    val_ref,
1612                    decoder,
1613                    inner_offset,
1614                    inner_depth
1615                )?;
1616                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1617                {
1618                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1619                }
1620                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1621                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1622                }
1623            }
1624
1625            next_offset += envelope_size;
1626            _next_ordinal_to_read += 1;
1627            if next_offset >= end_offset {
1628                return Ok(());
1629            }
1630
1631            // Decode unknown envelopes for gaps in ordinals.
1632            while _next_ordinal_to_read < 5 {
1633                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1634                _next_ordinal_to_read += 1;
1635                next_offset += envelope_size;
1636            }
1637
1638            let next_out_of_line = decoder.next_out_of_line();
1639            let handles_before = decoder.remaining_handles();
1640            if let Some((inlined, num_bytes, num_handles)) =
1641                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1642            {
1643                let member_inline_size =
1644                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1645                if inlined != (member_inline_size <= 4) {
1646                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1647                }
1648                let inner_offset;
1649                let mut inner_depth = depth.clone();
1650                if inlined {
1651                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1652                    inner_offset = next_offset;
1653                } else {
1654                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1655                    inner_depth.increment()?;
1656                }
1657                let val_ref = self.reboot_on_stalled_suspend_blocker.get_or_insert_with(|| {
1658                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1659                });
1660                fidl::decode!(
1661                    bool,
1662                    fidl::encoding::DefaultFuchsiaResourceDialect,
1663                    val_ref,
1664                    decoder,
1665                    inner_offset,
1666                    inner_depth
1667                )?;
1668                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1669                {
1670                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1671                }
1672                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1673                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1674                }
1675            }
1676
1677            next_offset += envelope_size;
1678            _next_ordinal_to_read += 1;
1679            if next_offset >= end_offset {
1680                return Ok(());
1681            }
1682
1683            // Decode unknown envelopes for gaps in ordinals.
1684            while _next_ordinal_to_read < 6 {
1685                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1686                _next_ordinal_to_read += 1;
1687                next_offset += envelope_size;
1688            }
1689
1690            let next_out_of_line = decoder.next_out_of_line();
1691            let handles_before = decoder.remaining_handles();
1692            if let Some((inlined, num_bytes, num_handles)) =
1693                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1694            {
1695                let member_inline_size =
1696                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1697                if inlined != (member_inline_size <= 4) {
1698                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1699                }
1700                let inner_offset;
1701                let mut inner_depth = depth.clone();
1702                if inlined {
1703                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1704                    inner_offset = next_offset;
1705                } else {
1706                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1707                    inner_depth.increment()?;
1708                }
1709                let val_ref = self.long_wake_lease_timeout_seconds.get_or_insert_with(|| {
1710                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1711                });
1712                fidl::decode!(
1713                    u32,
1714                    fidl::encoding::DefaultFuchsiaResourceDialect,
1715                    val_ref,
1716                    decoder,
1717                    inner_offset,
1718                    inner_depth
1719                )?;
1720                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1721                {
1722                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1723                }
1724                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1725                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1726                }
1727            }
1728
1729            next_offset += envelope_size;
1730            _next_ordinal_to_read += 1;
1731            if next_offset >= end_offset {
1732                return Ok(());
1733            }
1734
1735            // Decode unknown envelopes for gaps in ordinals.
1736            while _next_ordinal_to_read < 7 {
1737                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1738                _next_ordinal_to_read += 1;
1739                next_offset += envelope_size;
1740            }
1741
1742            let next_out_of_line = decoder.next_out_of_line();
1743            let handles_before = decoder.remaining_handles();
1744            if let Some((inlined, num_bytes, num_handles)) =
1745                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1746            {
1747                let member_inline_size =
1748                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1749                if inlined != (member_inline_size <= 4) {
1750                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1751                }
1752                let inner_offset;
1753                let mut inner_depth = depth.clone();
1754                if inlined {
1755                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1756                    inner_offset = next_offset;
1757                } else {
1758                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1759                    inner_depth.increment()?;
1760                }
1761                let val_ref = self.use_fake_clock.get_or_insert_with(|| {
1762                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1763                });
1764                fidl::decode!(
1765                    bool,
1766                    fidl::encoding::DefaultFuchsiaResourceDialect,
1767                    val_ref,
1768                    decoder,
1769                    inner_offset,
1770                    inner_depth
1771                )?;
1772                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1773                {
1774                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1775                }
1776                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1777                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1778                }
1779            }
1780
1781            next_offset += envelope_size;
1782
1783            // Decode the remaining unknown envelopes.
1784            while next_offset < end_offset {
1785                _next_ordinal_to_read += 1;
1786                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1787                next_offset += envelope_size;
1788            }
1789
1790            Ok(())
1791        }
1792    }
1793}