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