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::Handle {
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    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
626        self.inner.shutdown_with_epitaph(status)
627    }
628
629    fn is_closed(&self) -> bool {
630        self.inner.channel().is_closed()
631    }
632    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
633        self.inner.channel().on_closed()
634    }
635
636    #[cfg(target_os = "fuchsia")]
637    fn signal_peer(
638        &self,
639        clear_mask: zx::Signals,
640        set_mask: zx::Signals,
641    ) -> Result<(), zx_status::Status> {
642        use fidl::Peered;
643        self.inner.channel().signal_peer(clear_mask, set_mask)
644    }
645}
646
647impl RealmFactoryControlHandle {}
648
649#[must_use = "FIDL methods require a response to be sent"]
650#[derive(Debug)]
651pub struct RealmFactoryCreateRealmResponder {
652    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
653    tx_id: u32,
654}
655
656/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
657/// if the responder is dropped without sending a response, so that the client
658/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
659impl std::ops::Drop for RealmFactoryCreateRealmResponder {
660    fn drop(&mut self) {
661        self.control_handle.shutdown();
662        // Safety: drops once, never accessed again
663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
664    }
665}
666
667impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
668    type ControlHandle = RealmFactoryControlHandle;
669
670    fn control_handle(&self) -> &RealmFactoryControlHandle {
671        &self.control_handle
672    }
673
674    fn drop_without_shutdown(mut self) {
675        // Safety: drops once, never accessed again due to mem::forget
676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
677        // Prevent Drop from running (which would shut down the channel)
678        std::mem::forget(self);
679    }
680}
681
682impl RealmFactoryCreateRealmResponder {
683    /// Sends a response to the FIDL transaction.
684    ///
685    /// Sets the channel to shutdown if an error occurs.
686    pub fn send(
687        self,
688        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
689    ) -> Result<(), fidl::Error> {
690        let _result = self.send_raw(result);
691        if _result.is_err() {
692            self.control_handle.shutdown();
693        }
694        self.drop_without_shutdown();
695        _result
696    }
697
698    /// Similar to "send" but does not shutdown the channel if an error occurs.
699    pub fn send_no_shutdown_on_err(
700        self,
701        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
702    ) -> Result<(), fidl::Error> {
703        let _result = self.send_raw(result);
704        self.drop_without_shutdown();
705        _result
706    }
707
708    fn send_raw(
709        &self,
710        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
711    ) -> Result<(), fidl::Error> {
712        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
713            RealmFactoryCreateRealmResponse,
714            fidl_fuchsia_testing_harness::OperationError,
715        >>(
716            fidl::encoding::FlexibleResult::new(
717                result.map(|activity_governor_moniker| (activity_governor_moniker,)),
718            ),
719            self.tx_id,
720            0x3fcb27aa634a2df3,
721            fidl::encoding::DynamicFlags::FLEXIBLE,
722        )
723    }
724}
725
726#[must_use = "FIDL methods require a response to be sent"]
727#[derive(Debug)]
728pub struct RealmFactoryCreateRealmExtResponder {
729    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
730    tx_id: u32,
731}
732
733/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
734/// if the responder is dropped without sending a response, so that the client
735/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
736impl std::ops::Drop for RealmFactoryCreateRealmExtResponder {
737    fn drop(&mut self) {
738        self.control_handle.shutdown();
739        // Safety: drops once, never accessed again
740        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
741    }
742}
743
744impl fidl::endpoints::Responder for RealmFactoryCreateRealmExtResponder {
745    type ControlHandle = RealmFactoryControlHandle;
746
747    fn control_handle(&self) -> &RealmFactoryControlHandle {
748        &self.control_handle
749    }
750
751    fn drop_without_shutdown(mut self) {
752        // Safety: drops once, never accessed again due to mem::forget
753        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
754        // Prevent Drop from running (which would shut down the channel)
755        std::mem::forget(self);
756    }
757}
758
759impl RealmFactoryCreateRealmExtResponder {
760    /// Sends a response to the FIDL transaction.
761    ///
762    /// Sets the channel to shutdown if an error occurs.
763    pub fn send(
764        self,
765        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
766    ) -> Result<(), fidl::Error> {
767        let _result = self.send_raw(result);
768        if _result.is_err() {
769            self.control_handle.shutdown();
770        }
771        self.drop_without_shutdown();
772        _result
773    }
774
775    /// Similar to "send" but does not shutdown the channel if an error occurs.
776    pub fn send_no_shutdown_on_err(
777        self,
778        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
779    ) -> Result<(), fidl::Error> {
780        let _result = self.send_raw(result);
781        self.drop_without_shutdown();
782        _result
783    }
784
785    fn send_raw(
786        &self,
787        mut result: Result<&str, fidl_fuchsia_testing_harness::OperationError>,
788    ) -> Result<(), fidl::Error> {
789        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
790            RealmFactoryCreateRealmExtResponse,
791            fidl_fuchsia_testing_harness::OperationError,
792        >>(
793            fidl::encoding::FlexibleResult::new(
794                result.map(|activity_governor_moniker| (activity_governor_moniker,)),
795            ),
796            self.tx_id,
797            0x63a655ff630a0db0,
798            fidl::encoding::DynamicFlags::FLEXIBLE,
799        )
800    }
801}
802
803mod internal {
804    use super::*;
805
806    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmExtRequest {
807        type Borrowed<'a> = &'a mut Self;
808        fn take_or_borrow<'a>(
809            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
810        ) -> Self::Borrowed<'a> {
811            value
812        }
813    }
814
815    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmExtRequest {
816        type Owned = Self;
817
818        #[inline(always)]
819        fn inline_align(_context: fidl::encoding::Context) -> usize {
820            8
821        }
822
823        #[inline(always)]
824        fn inline_size(_context: fidl::encoding::Context) -> usize {
825            24
826        }
827    }
828
829    unsafe impl
830        fidl::encoding::Encode<
831            RealmFactoryCreateRealmExtRequest,
832            fidl::encoding::DefaultFuchsiaResourceDialect,
833        > for &mut RealmFactoryCreateRealmExtRequest
834    {
835        #[inline]
836        unsafe fn encode(
837            self,
838            encoder: &mut fidl::encoding::Encoder<
839                '_,
840                fidl::encoding::DefaultFuchsiaResourceDialect,
841            >,
842            offset: usize,
843            _depth: fidl::encoding::Depth,
844        ) -> fidl::Result<()> {
845            encoder.debug_check_bounds::<RealmFactoryCreateRealmExtRequest>(offset);
846            // Delegate to tuple encoding.
847            fidl::encoding::Encode::<
848                RealmFactoryCreateRealmExtRequest,
849                fidl::encoding::DefaultFuchsiaResourceDialect,
850            >::encode(
851                (
852                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
853                        &mut self.options,
854                    ),
855                    <fidl::encoding::Endpoint<
856                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
857                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
858                        &mut self.realm_server,
859                    ),
860                ),
861                encoder,
862                offset,
863                _depth,
864            )
865        }
866    }
867    unsafe impl<
868            T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
869            T1: fidl::encoding::Encode<
870                fidl::encoding::Endpoint<
871                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
872                >,
873                fidl::encoding::DefaultFuchsiaResourceDialect,
874            >,
875        >
876        fidl::encoding::Encode<
877            RealmFactoryCreateRealmExtRequest,
878            fidl::encoding::DefaultFuchsiaResourceDialect,
879        > for (T0, T1)
880    {
881        #[inline]
882        unsafe fn encode(
883            self,
884            encoder: &mut fidl::encoding::Encoder<
885                '_,
886                fidl::encoding::DefaultFuchsiaResourceDialect,
887            >,
888            offset: usize,
889            depth: fidl::encoding::Depth,
890        ) -> fidl::Result<()> {
891            encoder.debug_check_bounds::<RealmFactoryCreateRealmExtRequest>(offset);
892            // Zero out padding regions. There's no need to apply masks
893            // because the unmasked parts will be overwritten by fields.
894            unsafe {
895                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
896                (ptr as *mut u64).write_unaligned(0);
897            }
898            // Write the fields.
899            self.0.encode(encoder, offset + 0, depth)?;
900            self.1.encode(encoder, offset + 16, depth)?;
901            Ok(())
902        }
903    }
904
905    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
906        for RealmFactoryCreateRealmExtRequest
907    {
908        #[inline(always)]
909        fn new_empty() -> Self {
910            Self {
911                options: fidl::new_empty!(
912                    RealmOptions,
913                    fidl::encoding::DefaultFuchsiaResourceDialect
914                ),
915                realm_server: fidl::new_empty!(
916                    fidl::encoding::Endpoint<
917                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
918                    >,
919                    fidl::encoding::DefaultFuchsiaResourceDialect
920                ),
921            }
922        }
923
924        #[inline]
925        unsafe fn decode(
926            &mut self,
927            decoder: &mut fidl::encoding::Decoder<
928                '_,
929                fidl::encoding::DefaultFuchsiaResourceDialect,
930            >,
931            offset: usize,
932            _depth: fidl::encoding::Depth,
933        ) -> fidl::Result<()> {
934            decoder.debug_check_bounds::<Self>(offset);
935            // Verify that padding bytes are zero.
936            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
937            let padval = unsafe { (ptr as *const u64).read_unaligned() };
938            let mask = 0xffffffff00000000u64;
939            let maskedval = padval & mask;
940            if maskedval != 0 {
941                return Err(fidl::Error::NonZeroPadding {
942                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
943                });
944            }
945            fidl::decode!(
946                RealmOptions,
947                fidl::encoding::DefaultFuchsiaResourceDialect,
948                &mut self.options,
949                decoder,
950                offset + 0,
951                _depth
952            )?;
953            fidl::decode!(
954                fidl::encoding::Endpoint<
955                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
956                >,
957                fidl::encoding::DefaultFuchsiaResourceDialect,
958                &mut self.realm_server,
959                decoder,
960                offset + 16,
961                _depth
962            )?;
963            Ok(())
964        }
965    }
966
967    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
968        type Borrowed<'a> = &'a mut Self;
969        fn take_or_borrow<'a>(
970            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
971        ) -> Self::Borrowed<'a> {
972            value
973        }
974    }
975
976    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
977        type Owned = Self;
978
979        #[inline(always)]
980        fn inline_align(_context: fidl::encoding::Context) -> usize {
981            4
982        }
983
984        #[inline(always)]
985        fn inline_size(_context: fidl::encoding::Context) -> usize {
986            4
987        }
988    }
989
990    unsafe impl
991        fidl::encoding::Encode<
992            RealmFactoryCreateRealmRequest,
993            fidl::encoding::DefaultFuchsiaResourceDialect,
994        > for &mut RealmFactoryCreateRealmRequest
995    {
996        #[inline]
997        unsafe fn encode(
998            self,
999            encoder: &mut fidl::encoding::Encoder<
1000                '_,
1001                fidl::encoding::DefaultFuchsiaResourceDialect,
1002            >,
1003            offset: usize,
1004            _depth: fidl::encoding::Depth,
1005        ) -> fidl::Result<()> {
1006            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1007            // Delegate to tuple encoding.
1008            fidl::encoding::Encode::<
1009                RealmFactoryCreateRealmRequest,
1010                fidl::encoding::DefaultFuchsiaResourceDialect,
1011            >::encode(
1012                (<fidl::encoding::Endpoint<
1013                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1014                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1015                    &mut self.realm_server
1016                ),),
1017                encoder,
1018                offset,
1019                _depth,
1020            )
1021        }
1022    }
1023    unsafe impl<
1024            T0: fidl::encoding::Encode<
1025                fidl::encoding::Endpoint<
1026                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1027                >,
1028                fidl::encoding::DefaultFuchsiaResourceDialect,
1029            >,
1030        >
1031        fidl::encoding::Encode<
1032            RealmFactoryCreateRealmRequest,
1033            fidl::encoding::DefaultFuchsiaResourceDialect,
1034        > for (T0,)
1035    {
1036        #[inline]
1037        unsafe fn encode(
1038            self,
1039            encoder: &mut fidl::encoding::Encoder<
1040                '_,
1041                fidl::encoding::DefaultFuchsiaResourceDialect,
1042            >,
1043            offset: usize,
1044            depth: fidl::encoding::Depth,
1045        ) -> fidl::Result<()> {
1046            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1047            // Zero out padding regions. There's no need to apply masks
1048            // because the unmasked parts will be overwritten by fields.
1049            // Write the fields.
1050            self.0.encode(encoder, offset + 0, depth)?;
1051            Ok(())
1052        }
1053    }
1054
1055    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1056        for RealmFactoryCreateRealmRequest
1057    {
1058        #[inline(always)]
1059        fn new_empty() -> Self {
1060            Self {
1061                realm_server: fidl::new_empty!(
1062                    fidl::encoding::Endpoint<
1063                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1064                    >,
1065                    fidl::encoding::DefaultFuchsiaResourceDialect
1066                ),
1067            }
1068        }
1069
1070        #[inline]
1071        unsafe fn decode(
1072            &mut self,
1073            decoder: &mut fidl::encoding::Decoder<
1074                '_,
1075                fidl::encoding::DefaultFuchsiaResourceDialect,
1076            >,
1077            offset: usize,
1078            _depth: fidl::encoding::Depth,
1079        ) -> fidl::Result<()> {
1080            decoder.debug_check_bounds::<Self>(offset);
1081            // Verify that padding bytes are zero.
1082            fidl::decode!(
1083                fidl::encoding::Endpoint<
1084                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1085                >,
1086                fidl::encoding::DefaultFuchsiaResourceDialect,
1087                &mut self.realm_server,
1088                decoder,
1089                offset + 0,
1090                _depth
1091            )?;
1092            Ok(())
1093        }
1094    }
1095
1096    impl RealmOptions {
1097        #[inline(always)]
1098        fn max_ordinal_present(&self) -> u64 {
1099            if let Some(_) = self.use_suspender {
1100                return 3;
1101            }
1102            if let Some(_) = self.wait_for_suspending_token {
1103                return 2;
1104            }
1105            if let Some(_) = self.use_fake_sag {
1106                return 1;
1107            }
1108            0
1109        }
1110    }
1111
1112    impl fidl::encoding::ResourceTypeMarker for RealmOptions {
1113        type Borrowed<'a> = &'a mut Self;
1114        fn take_or_borrow<'a>(
1115            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1116        ) -> Self::Borrowed<'a> {
1117            value
1118        }
1119    }
1120
1121    unsafe impl fidl::encoding::TypeMarker for RealmOptions {
1122        type Owned = Self;
1123
1124        #[inline(always)]
1125        fn inline_align(_context: fidl::encoding::Context) -> usize {
1126            8
1127        }
1128
1129        #[inline(always)]
1130        fn inline_size(_context: fidl::encoding::Context) -> usize {
1131            16
1132        }
1133    }
1134
1135    unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1136        for &mut RealmOptions
1137    {
1138        unsafe fn encode(
1139            self,
1140            encoder: &mut fidl::encoding::Encoder<
1141                '_,
1142                fidl::encoding::DefaultFuchsiaResourceDialect,
1143            >,
1144            offset: usize,
1145            mut depth: fidl::encoding::Depth,
1146        ) -> fidl::Result<()> {
1147            encoder.debug_check_bounds::<RealmOptions>(offset);
1148            // Vector header
1149            let max_ordinal: u64 = self.max_ordinal_present();
1150            encoder.write_num(max_ordinal, offset);
1151            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1152            // Calling encoder.out_of_line_offset(0) is not allowed.
1153            if max_ordinal == 0 {
1154                return Ok(());
1155            }
1156            depth.increment()?;
1157            let envelope_size = 8;
1158            let bytes_len = max_ordinal as usize * envelope_size;
1159            #[allow(unused_variables)]
1160            let offset = encoder.out_of_line_offset(bytes_len);
1161            let mut _prev_end_offset: usize = 0;
1162            if 1 > max_ordinal {
1163                return Ok(());
1164            }
1165
1166            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1167            // are envelope_size bytes.
1168            let cur_offset: usize = (1 - 1) * envelope_size;
1169
1170            // Zero reserved fields.
1171            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1172
1173            // Safety:
1174            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1175            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1176            //   envelope_size bytes, there is always sufficient room.
1177            fidl::encoding::encode_in_envelope_optional::<
1178                bool,
1179                fidl::encoding::DefaultFuchsiaResourceDialect,
1180            >(
1181                self.use_fake_sag.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1182                encoder,
1183                offset + cur_offset,
1184                depth,
1185            )?;
1186
1187            _prev_end_offset = cur_offset + envelope_size;
1188            if 2 > max_ordinal {
1189                return Ok(());
1190            }
1191
1192            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1193            // are envelope_size bytes.
1194            let cur_offset: usize = (2 - 1) * envelope_size;
1195
1196            // Zero reserved fields.
1197            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1198
1199            // Safety:
1200            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1201            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1202            //   envelope_size bytes, there is always sufficient room.
1203            fidl::encoding::encode_in_envelope_optional::<
1204                bool,
1205                fidl::encoding::DefaultFuchsiaResourceDialect,
1206            >(
1207                self.wait_for_suspending_token
1208                    .as_ref()
1209                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1210                encoder,
1211                offset + cur_offset,
1212                depth,
1213            )?;
1214
1215            _prev_end_offset = cur_offset + envelope_size;
1216            if 3 > max_ordinal {
1217                return Ok(());
1218            }
1219
1220            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1221            // are envelope_size bytes.
1222            let cur_offset: usize = (3 - 1) * envelope_size;
1223
1224            // Zero reserved fields.
1225            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1226
1227            // Safety:
1228            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1229            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1230            //   envelope_size bytes, there is always sufficient room.
1231            fidl::encoding::encode_in_envelope_optional::<
1232                bool,
1233                fidl::encoding::DefaultFuchsiaResourceDialect,
1234            >(
1235                self.use_suspender.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1236                encoder,
1237                offset + cur_offset,
1238                depth,
1239            )?;
1240
1241            _prev_end_offset = cur_offset + envelope_size;
1242
1243            Ok(())
1244        }
1245    }
1246
1247    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
1248        #[inline(always)]
1249        fn new_empty() -> Self {
1250            Self::default()
1251        }
1252
1253        unsafe fn decode(
1254            &mut self,
1255            decoder: &mut fidl::encoding::Decoder<
1256                '_,
1257                fidl::encoding::DefaultFuchsiaResourceDialect,
1258            >,
1259            offset: usize,
1260            mut depth: fidl::encoding::Depth,
1261        ) -> fidl::Result<()> {
1262            decoder.debug_check_bounds::<Self>(offset);
1263            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1264                None => return Err(fidl::Error::NotNullable),
1265                Some(len) => len,
1266            };
1267            // Calling decoder.out_of_line_offset(0) is not allowed.
1268            if len == 0 {
1269                return Ok(());
1270            };
1271            depth.increment()?;
1272            let envelope_size = 8;
1273            let bytes_len = len * envelope_size;
1274            let offset = decoder.out_of_line_offset(bytes_len)?;
1275            // Decode the envelope for each type.
1276            let mut _next_ordinal_to_read = 0;
1277            let mut next_offset = offset;
1278            let end_offset = offset + bytes_len;
1279            _next_ordinal_to_read += 1;
1280            if next_offset >= end_offset {
1281                return Ok(());
1282            }
1283
1284            // Decode unknown envelopes for gaps in ordinals.
1285            while _next_ordinal_to_read < 1 {
1286                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1287                _next_ordinal_to_read += 1;
1288                next_offset += envelope_size;
1289            }
1290
1291            let next_out_of_line = decoder.next_out_of_line();
1292            let handles_before = decoder.remaining_handles();
1293            if let Some((inlined, num_bytes, num_handles)) =
1294                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1295            {
1296                let member_inline_size =
1297                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1298                if inlined != (member_inline_size <= 4) {
1299                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1300                }
1301                let inner_offset;
1302                let mut inner_depth = depth.clone();
1303                if inlined {
1304                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1305                    inner_offset = next_offset;
1306                } else {
1307                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1308                    inner_depth.increment()?;
1309                }
1310                let val_ref = self.use_fake_sag.get_or_insert_with(|| {
1311                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1312                });
1313                fidl::decode!(
1314                    bool,
1315                    fidl::encoding::DefaultFuchsiaResourceDialect,
1316                    val_ref,
1317                    decoder,
1318                    inner_offset,
1319                    inner_depth
1320                )?;
1321                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1322                {
1323                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1324                }
1325                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1326                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1327                }
1328            }
1329
1330            next_offset += envelope_size;
1331            _next_ordinal_to_read += 1;
1332            if next_offset >= end_offset {
1333                return Ok(());
1334            }
1335
1336            // Decode unknown envelopes for gaps in ordinals.
1337            while _next_ordinal_to_read < 2 {
1338                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1339                _next_ordinal_to_read += 1;
1340                next_offset += envelope_size;
1341            }
1342
1343            let next_out_of_line = decoder.next_out_of_line();
1344            let handles_before = decoder.remaining_handles();
1345            if let Some((inlined, num_bytes, num_handles)) =
1346                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1347            {
1348                let member_inline_size =
1349                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1350                if inlined != (member_inline_size <= 4) {
1351                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1352                }
1353                let inner_offset;
1354                let mut inner_depth = depth.clone();
1355                if inlined {
1356                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1357                    inner_offset = next_offset;
1358                } else {
1359                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1360                    inner_depth.increment()?;
1361                }
1362                let val_ref = self.wait_for_suspending_token.get_or_insert_with(|| {
1363                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1364                });
1365                fidl::decode!(
1366                    bool,
1367                    fidl::encoding::DefaultFuchsiaResourceDialect,
1368                    val_ref,
1369                    decoder,
1370                    inner_offset,
1371                    inner_depth
1372                )?;
1373                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1374                {
1375                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1376                }
1377                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1378                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1379                }
1380            }
1381
1382            next_offset += envelope_size;
1383            _next_ordinal_to_read += 1;
1384            if next_offset >= end_offset {
1385                return Ok(());
1386            }
1387
1388            // Decode unknown envelopes for gaps in ordinals.
1389            while _next_ordinal_to_read < 3 {
1390                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1391                _next_ordinal_to_read += 1;
1392                next_offset += envelope_size;
1393            }
1394
1395            let next_out_of_line = decoder.next_out_of_line();
1396            let handles_before = decoder.remaining_handles();
1397            if let Some((inlined, num_bytes, num_handles)) =
1398                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1399            {
1400                let member_inline_size =
1401                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1402                if inlined != (member_inline_size <= 4) {
1403                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1404                }
1405                let inner_offset;
1406                let mut inner_depth = depth.clone();
1407                if inlined {
1408                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1409                    inner_offset = next_offset;
1410                } else {
1411                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1412                    inner_depth.increment()?;
1413                }
1414                let val_ref = self.use_suspender.get_or_insert_with(|| {
1415                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1416                });
1417                fidl::decode!(
1418                    bool,
1419                    fidl::encoding::DefaultFuchsiaResourceDialect,
1420                    val_ref,
1421                    decoder,
1422                    inner_offset,
1423                    inner_depth
1424                )?;
1425                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1426                {
1427                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1428                }
1429                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1430                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1431                }
1432            }
1433
1434            next_offset += envelope_size;
1435
1436            // Decode the remaining unknown envelopes.
1437            while next_offset < end_offset {
1438                _next_ordinal_to_read += 1;
1439                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1440                next_offset += envelope_size;
1441            }
1442
1443            Ok(())
1444        }
1445    }
1446}