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