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::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
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::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
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::endpoints::ServerEnd<
171            fidl_fuchsia_component_sandbox::DictionaryMarker,
172        >,
173        ___deadline: zx::MonotonicInstant,
174    ) -> Result<RealmFactoryCreateRealm2Result, fidl::Error> {
175        let _response = self
176            .client
177            .send_query::<RealmFactoryCreateRealm2Request, fidl::encoding::FlexibleResultType<
178                fidl::encoding::EmptyStruct,
179                fidl_fuchsia_testing_harness::OperationError,
180            >>(
181                (&mut options, dictionary),
182                0x60e280c725202e95,
183                fidl::encoding::DynamicFlags::FLEXIBLE,
184                ___deadline,
185            )?
186            .into_result::<RealmFactoryMarker>("create_realm2")?;
187        Ok(_response.map(|x| x))
188    }
189}
190
191#[derive(Debug, Clone)]
192pub struct RealmFactoryProxy {
193    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
194}
195
196impl fidl::endpoints::Proxy for RealmFactoryProxy {
197    type Protocol = RealmFactoryMarker;
198
199    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
200        Self::new(inner)
201    }
202
203    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
204        self.client.into_channel().map_err(|client| Self { client })
205    }
206
207    fn as_channel(&self) -> &::fidl::AsyncChannel {
208        self.client.as_channel()
209    }
210}
211
212impl RealmFactoryProxy {
213    /// Create a new Proxy for fuchsia.driver.testing/RealmFactory.
214    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
215        let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
216        Self { client: fidl::client::Client::new(channel, protocol_name) }
217    }
218
219    /// Get a Stream of events from the remote end of the protocol.
220    ///
221    /// # Panics
222    ///
223    /// Panics if the event stream was already taken.
224    pub fn take_event_stream(&self) -> RealmFactoryEventStream {
225        RealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
226    }
227
228    /// Creates a new realm and binds the given RealmProxy server end to it.
229    pub fn r#create_realm(
230        &self,
231        mut options: RealmOptions,
232        mut realm_server: fidl::endpoints::ServerEnd<
233            fidl_fuchsia_testing_harness::RealmProxy_Marker,
234        >,
235    ) -> fidl::client::QueryResponseFut<
236        RealmFactoryCreateRealmResult,
237        fidl::encoding::DefaultFuchsiaResourceDialect,
238    > {
239        RealmFactoryProxyInterface::r#create_realm(self, options, realm_server)
240    }
241
242    /// Creates a new realm and returns a dictionary containing its exposed capabilities.
243    pub fn r#create_realm2(
244        &self,
245        mut options: RealmOptions,
246        mut dictionary: fidl::endpoints::ServerEnd<
247            fidl_fuchsia_component_sandbox::DictionaryMarker,
248        >,
249    ) -> fidl::client::QueryResponseFut<
250        RealmFactoryCreateRealm2Result,
251        fidl::encoding::DefaultFuchsiaResourceDialect,
252    > {
253        RealmFactoryProxyInterface::r#create_realm2(self, options, dictionary)
254    }
255}
256
257impl RealmFactoryProxyInterface for RealmFactoryProxy {
258    type CreateRealmResponseFut = fidl::client::QueryResponseFut<
259        RealmFactoryCreateRealmResult,
260        fidl::encoding::DefaultFuchsiaResourceDialect,
261    >;
262    fn r#create_realm(
263        &self,
264        mut options: RealmOptions,
265        mut realm_server: fidl::endpoints::ServerEnd<
266            fidl_fuchsia_testing_harness::RealmProxy_Marker,
267        >,
268    ) -> Self::CreateRealmResponseFut {
269        fn _decode(
270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
271        ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
272            let _response = fidl::client::decode_transaction_body::<
273                fidl::encoding::FlexibleResultType<
274                    fidl::encoding::EmptyStruct,
275                    fidl_fuchsia_testing_harness::OperationError,
276                >,
277                fidl::encoding::DefaultFuchsiaResourceDialect,
278                0x7311a7afaad69aa3,
279            >(_buf?)?
280            .into_result::<RealmFactoryMarker>("create_realm")?;
281            Ok(_response.map(|x| x))
282        }
283        self.client
284            .send_query_and_decode::<RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResult>(
285                (&mut options, realm_server),
286                0x7311a7afaad69aa3,
287                fidl::encoding::DynamicFlags::FLEXIBLE,
288                _decode,
289            )
290    }
291
292    type CreateRealm2ResponseFut = fidl::client::QueryResponseFut<
293        RealmFactoryCreateRealm2Result,
294        fidl::encoding::DefaultFuchsiaResourceDialect,
295    >;
296    fn r#create_realm2(
297        &self,
298        mut options: RealmOptions,
299        mut dictionary: fidl::endpoints::ServerEnd<
300            fidl_fuchsia_component_sandbox::DictionaryMarker,
301        >,
302    ) -> Self::CreateRealm2ResponseFut {
303        fn _decode(
304            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
305        ) -> Result<RealmFactoryCreateRealm2Result, fidl::Error> {
306            let _response = fidl::client::decode_transaction_body::<
307                fidl::encoding::FlexibleResultType<
308                    fidl::encoding::EmptyStruct,
309                    fidl_fuchsia_testing_harness::OperationError,
310                >,
311                fidl::encoding::DefaultFuchsiaResourceDialect,
312                0x60e280c725202e95,
313            >(_buf?)?
314            .into_result::<RealmFactoryMarker>("create_realm2")?;
315            Ok(_response.map(|x| x))
316        }
317        self.client.send_query_and_decode::<
318            RealmFactoryCreateRealm2Request,
319            RealmFactoryCreateRealm2Result,
320        >(
321            (&mut options, dictionary,),
322            0x60e280c725202e95,
323            fidl::encoding::DynamicFlags::FLEXIBLE,
324            _decode,
325        )
326    }
327}
328
329pub struct RealmFactoryEventStream {
330    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
331}
332
333impl std::marker::Unpin for RealmFactoryEventStream {}
334
335impl futures::stream::FusedStream for RealmFactoryEventStream {
336    fn is_terminated(&self) -> bool {
337        self.event_receiver.is_terminated()
338    }
339}
340
341impl futures::Stream for RealmFactoryEventStream {
342    type Item = Result<RealmFactoryEvent, fidl::Error>;
343
344    fn poll_next(
345        mut self: std::pin::Pin<&mut Self>,
346        cx: &mut std::task::Context<'_>,
347    ) -> std::task::Poll<Option<Self::Item>> {
348        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
349            &mut self.event_receiver,
350            cx
351        )?) {
352            Some(buf) => std::task::Poll::Ready(Some(RealmFactoryEvent::decode(buf))),
353            None => std::task::Poll::Ready(None),
354        }
355    }
356}
357
358#[derive(Debug)]
359pub enum RealmFactoryEvent {
360    #[non_exhaustive]
361    _UnknownEvent {
362        /// Ordinal of the event that was sent.
363        ordinal: u64,
364    },
365}
366
367impl RealmFactoryEvent {
368    /// Decodes a message buffer as a [`RealmFactoryEvent`].
369    fn decode(
370        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
371    ) -> Result<RealmFactoryEvent, fidl::Error> {
372        let (bytes, _handles) = buf.split_mut();
373        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
374        debug_assert_eq!(tx_header.tx_id, 0);
375        match tx_header.ordinal {
376            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
377                Ok(RealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
378            }
379            _ => Err(fidl::Error::UnknownOrdinal {
380                ordinal: tx_header.ordinal,
381                protocol_name: <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
382            }),
383        }
384    }
385}
386
387/// A Stream of incoming requests for fuchsia.driver.testing/RealmFactory.
388pub struct RealmFactoryRequestStream {
389    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
390    is_terminated: bool,
391}
392
393impl std::marker::Unpin for RealmFactoryRequestStream {}
394
395impl futures::stream::FusedStream for RealmFactoryRequestStream {
396    fn is_terminated(&self) -> bool {
397        self.is_terminated
398    }
399}
400
401impl fidl::endpoints::RequestStream for RealmFactoryRequestStream {
402    type Protocol = RealmFactoryMarker;
403    type ControlHandle = RealmFactoryControlHandle;
404
405    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
406        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
407    }
408
409    fn control_handle(&self) -> Self::ControlHandle {
410        RealmFactoryControlHandle { inner: self.inner.clone() }
411    }
412
413    fn into_inner(
414        self,
415    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
416    {
417        (self.inner, self.is_terminated)
418    }
419
420    fn from_inner(
421        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
422        is_terminated: bool,
423    ) -> Self {
424        Self { inner, is_terminated }
425    }
426}
427
428impl futures::Stream for RealmFactoryRequestStream {
429    type Item = Result<RealmFactoryRequest, fidl::Error>;
430
431    fn poll_next(
432        mut self: std::pin::Pin<&mut Self>,
433        cx: &mut std::task::Context<'_>,
434    ) -> std::task::Poll<Option<Self::Item>> {
435        let this = &mut *self;
436        if this.inner.check_shutdown(cx) {
437            this.is_terminated = true;
438            return std::task::Poll::Ready(None);
439        }
440        if this.is_terminated {
441            panic!("polled RealmFactoryRequestStream after completion");
442        }
443        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
444            |bytes, handles| {
445                match this.inner.channel().read_etc(cx, bytes, handles) {
446                    std::task::Poll::Ready(Ok(())) => {}
447                    std::task::Poll::Pending => return std::task::Poll::Pending,
448                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
449                        this.is_terminated = true;
450                        return std::task::Poll::Ready(None);
451                    }
452                    std::task::Poll::Ready(Err(e)) => {
453                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
454                            e.into(),
455                        ))))
456                    }
457                }
458
459                // A message has been received from the channel
460                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
461
462                std::task::Poll::Ready(Some(match header.ordinal {
463                    0x7311a7afaad69aa3 => {
464                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
465                        let mut req = fidl::new_empty!(
466                            RealmFactoryCreateRealmRequest,
467                            fidl::encoding::DefaultFuchsiaResourceDialect
468                        );
469                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
470                        let control_handle =
471                            RealmFactoryControlHandle { inner: this.inner.clone() };
472                        Ok(RealmFactoryRequest::CreateRealm {
473                            options: req.options,
474                            realm_server: req.realm_server,
475
476                            responder: RealmFactoryCreateRealmResponder {
477                                control_handle: std::mem::ManuallyDrop::new(control_handle),
478                                tx_id: header.tx_id,
479                            },
480                        })
481                    }
482                    0x60e280c725202e95 => {
483                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
484                        let mut req = fidl::new_empty!(
485                            RealmFactoryCreateRealm2Request,
486                            fidl::encoding::DefaultFuchsiaResourceDialect
487                        );
488                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealm2Request>(&header, _body_bytes, handles, &mut req)?;
489                        let control_handle =
490                            RealmFactoryControlHandle { inner: this.inner.clone() };
491                        Ok(RealmFactoryRequest::CreateRealm2 {
492                            options: req.options,
493                            dictionary: req.dictionary,
494
495                            responder: RealmFactoryCreateRealm2Responder {
496                                control_handle: std::mem::ManuallyDrop::new(control_handle),
497                                tx_id: header.tx_id,
498                            },
499                        })
500                    }
501                    _ if header.tx_id == 0
502                        && header
503                            .dynamic_flags()
504                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
505                    {
506                        Ok(RealmFactoryRequest::_UnknownMethod {
507                            ordinal: header.ordinal,
508                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
509                            method_type: fidl::MethodType::OneWay,
510                        })
511                    }
512                    _ if header
513                        .dynamic_flags()
514                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
515                    {
516                        this.inner.send_framework_err(
517                            fidl::encoding::FrameworkErr::UnknownMethod,
518                            header.tx_id,
519                            header.ordinal,
520                            header.dynamic_flags(),
521                            (bytes, handles),
522                        )?;
523                        Ok(RealmFactoryRequest::_UnknownMethod {
524                            ordinal: header.ordinal,
525                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
526                            method_type: fidl::MethodType::TwoWay,
527                        })
528                    }
529                    _ => Err(fidl::Error::UnknownOrdinal {
530                        ordinal: header.ordinal,
531                        protocol_name:
532                            <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
533                    }),
534                }))
535            },
536        )
537    }
538}
539
540#[derive(Debug)]
541pub enum RealmFactoryRequest {
542    /// Creates a new realm and binds the given RealmProxy server end to it.
543    CreateRealm {
544        options: RealmOptions,
545        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
546        responder: RealmFactoryCreateRealmResponder,
547    },
548    /// Creates a new realm and returns a dictionary containing its exposed capabilities.
549    CreateRealm2 {
550        options: RealmOptions,
551        dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
552        responder: RealmFactoryCreateRealm2Responder,
553    },
554    /// An interaction was received which does not match any known method.
555    #[non_exhaustive]
556    _UnknownMethod {
557        /// Ordinal of the method that was called.
558        ordinal: u64,
559        control_handle: RealmFactoryControlHandle,
560        method_type: fidl::MethodType,
561    },
562}
563
564impl RealmFactoryRequest {
565    #[allow(irrefutable_let_patterns)]
566    pub fn into_create_realm(
567        self,
568    ) -> Option<(
569        RealmOptions,
570        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
571        RealmFactoryCreateRealmResponder,
572    )> {
573        if let RealmFactoryRequest::CreateRealm { options, realm_server, responder } = self {
574            Some((options, realm_server, responder))
575        } else {
576            None
577        }
578    }
579
580    #[allow(irrefutable_let_patterns)]
581    pub fn into_create_realm2(
582        self,
583    ) -> Option<(
584        RealmOptions,
585        fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
586        RealmFactoryCreateRealm2Responder,
587    )> {
588        if let RealmFactoryRequest::CreateRealm2 { options, dictionary, responder } = self {
589            Some((options, dictionary, responder))
590        } else {
591            None
592        }
593    }
594
595    /// Name of the method defined in FIDL
596    pub fn method_name(&self) -> &'static str {
597        match *self {
598            RealmFactoryRequest::CreateRealm { .. } => "create_realm",
599            RealmFactoryRequest::CreateRealm2 { .. } => "create_realm2",
600            RealmFactoryRequest::_UnknownMethod {
601                method_type: fidl::MethodType::OneWay, ..
602            } => "unknown one-way method",
603            RealmFactoryRequest::_UnknownMethod {
604                method_type: fidl::MethodType::TwoWay, ..
605            } => "unknown two-way method",
606        }
607    }
608}
609
610#[derive(Debug, Clone)]
611pub struct RealmFactoryControlHandle {
612    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
613}
614
615impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
616    fn shutdown(&self) {
617        self.inner.shutdown()
618    }
619    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
620        self.inner.shutdown_with_epitaph(status)
621    }
622
623    fn is_closed(&self) -> bool {
624        self.inner.channel().is_closed()
625    }
626    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
627        self.inner.channel().on_closed()
628    }
629
630    #[cfg(target_os = "fuchsia")]
631    fn signal_peer(
632        &self,
633        clear_mask: zx::Signals,
634        set_mask: zx::Signals,
635    ) -> Result<(), zx_status::Status> {
636        use fidl::Peered;
637        self.inner.channel().signal_peer(clear_mask, set_mask)
638    }
639}
640
641impl RealmFactoryControlHandle {}
642
643#[must_use = "FIDL methods require a response to be sent"]
644#[derive(Debug)]
645pub struct RealmFactoryCreateRealmResponder {
646    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
647    tx_id: u32,
648}
649
650/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
651/// if the responder is dropped without sending a response, so that the client
652/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
653impl std::ops::Drop for RealmFactoryCreateRealmResponder {
654    fn drop(&mut self) {
655        self.control_handle.shutdown();
656        // Safety: drops once, never accessed again
657        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
658    }
659}
660
661impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
662    type ControlHandle = RealmFactoryControlHandle;
663
664    fn control_handle(&self) -> &RealmFactoryControlHandle {
665        &self.control_handle
666    }
667
668    fn drop_without_shutdown(mut self) {
669        // Safety: drops once, never accessed again due to mem::forget
670        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
671        // Prevent Drop from running (which would shut down the channel)
672        std::mem::forget(self);
673    }
674}
675
676impl RealmFactoryCreateRealmResponder {
677    /// Sends a response to the FIDL transaction.
678    ///
679    /// Sets the channel to shutdown if an error occurs.
680    pub fn send(
681        self,
682        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
683    ) -> Result<(), fidl::Error> {
684        let _result = self.send_raw(result);
685        if _result.is_err() {
686            self.control_handle.shutdown();
687        }
688        self.drop_without_shutdown();
689        _result
690    }
691
692    /// Similar to "send" but does not shutdown the channel if an error occurs.
693    pub fn send_no_shutdown_on_err(
694        self,
695        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
696    ) -> Result<(), fidl::Error> {
697        let _result = self.send_raw(result);
698        self.drop_without_shutdown();
699        _result
700    }
701
702    fn send_raw(
703        &self,
704        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
705    ) -> Result<(), fidl::Error> {
706        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
707            fidl::encoding::EmptyStruct,
708            fidl_fuchsia_testing_harness::OperationError,
709        >>(
710            fidl::encoding::FlexibleResult::new(result),
711            self.tx_id,
712            0x7311a7afaad69aa3,
713            fidl::encoding::DynamicFlags::FLEXIBLE,
714        )
715    }
716}
717
718#[must_use = "FIDL methods require a response to be sent"]
719#[derive(Debug)]
720pub struct RealmFactoryCreateRealm2Responder {
721    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
722    tx_id: u32,
723}
724
725/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
726/// if the responder is dropped without sending a response, so that the client
727/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
728impl std::ops::Drop for RealmFactoryCreateRealm2Responder {
729    fn drop(&mut self) {
730        self.control_handle.shutdown();
731        // Safety: drops once, never accessed again
732        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
733    }
734}
735
736impl fidl::endpoints::Responder for RealmFactoryCreateRealm2Responder {
737    type ControlHandle = RealmFactoryControlHandle;
738
739    fn control_handle(&self) -> &RealmFactoryControlHandle {
740        &self.control_handle
741    }
742
743    fn drop_without_shutdown(mut self) {
744        // Safety: drops once, never accessed again due to mem::forget
745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
746        // Prevent Drop from running (which would shut down the channel)
747        std::mem::forget(self);
748    }
749}
750
751impl RealmFactoryCreateRealm2Responder {
752    /// Sends a response to the FIDL transaction.
753    ///
754    /// Sets the channel to shutdown if an error occurs.
755    pub fn send(
756        self,
757        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
758    ) -> Result<(), fidl::Error> {
759        let _result = self.send_raw(result);
760        if _result.is_err() {
761            self.control_handle.shutdown();
762        }
763        self.drop_without_shutdown();
764        _result
765    }
766
767    /// Similar to "send" but does not shutdown the channel if an error occurs.
768    pub fn send_no_shutdown_on_err(
769        self,
770        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
771    ) -> Result<(), fidl::Error> {
772        let _result = self.send_raw(result);
773        self.drop_without_shutdown();
774        _result
775    }
776
777    fn send_raw(
778        &self,
779        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
780    ) -> Result<(), fidl::Error> {
781        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
782            fidl::encoding::EmptyStruct,
783            fidl_fuchsia_testing_harness::OperationError,
784        >>(
785            fidl::encoding::FlexibleResult::new(result),
786            self.tx_id,
787            0x60e280c725202e95,
788            fidl::encoding::DynamicFlags::FLEXIBLE,
789        )
790    }
791}
792
793mod internal {
794    use super::*;
795
796    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealm2Request {
797        type Borrowed<'a> = &'a mut Self;
798        fn take_or_borrow<'a>(
799            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
800        ) -> Self::Borrowed<'a> {
801            value
802        }
803    }
804
805    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealm2Request {
806        type Owned = Self;
807
808        #[inline(always)]
809        fn inline_align(_context: fidl::encoding::Context) -> usize {
810            8
811        }
812
813        #[inline(always)]
814        fn inline_size(_context: fidl::encoding::Context) -> usize {
815            24
816        }
817    }
818
819    unsafe impl
820        fidl::encoding::Encode<
821            RealmFactoryCreateRealm2Request,
822            fidl::encoding::DefaultFuchsiaResourceDialect,
823        > for &mut RealmFactoryCreateRealm2Request
824    {
825        #[inline]
826        unsafe fn encode(
827            self,
828            encoder: &mut fidl::encoding::Encoder<
829                '_,
830                fidl::encoding::DefaultFuchsiaResourceDialect,
831            >,
832            offset: usize,
833            _depth: fidl::encoding::Depth,
834        ) -> fidl::Result<()> {
835            encoder.debug_check_bounds::<RealmFactoryCreateRealm2Request>(offset);
836            // Delegate to tuple encoding.
837            fidl::encoding::Encode::<
838                RealmFactoryCreateRealm2Request,
839                fidl::encoding::DefaultFuchsiaResourceDialect,
840            >::encode(
841                (
842                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
843                        &mut self.options,
844                    ),
845                    <fidl::encoding::Endpoint<
846                        fidl::endpoints::ServerEnd<
847                            fidl_fuchsia_component_sandbox::DictionaryMarker,
848                        >,
849                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
850                        &mut self.dictionary
851                    ),
852                ),
853                encoder,
854                offset,
855                _depth,
856            )
857        }
858    }
859    unsafe impl<
860            T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
861            T1: fidl::encoding::Encode<
862                fidl::encoding::Endpoint<
863                    fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
864                >,
865                fidl::encoding::DefaultFuchsiaResourceDialect,
866            >,
867        >
868        fidl::encoding::Encode<
869            RealmFactoryCreateRealm2Request,
870            fidl::encoding::DefaultFuchsiaResourceDialect,
871        > for (T0, T1)
872    {
873        #[inline]
874        unsafe fn encode(
875            self,
876            encoder: &mut fidl::encoding::Encoder<
877                '_,
878                fidl::encoding::DefaultFuchsiaResourceDialect,
879            >,
880            offset: usize,
881            depth: fidl::encoding::Depth,
882        ) -> fidl::Result<()> {
883            encoder.debug_check_bounds::<RealmFactoryCreateRealm2Request>(offset);
884            // Zero out padding regions. There's no need to apply masks
885            // because the unmasked parts will be overwritten by fields.
886            unsafe {
887                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
888                (ptr as *mut u64).write_unaligned(0);
889            }
890            // Write the fields.
891            self.0.encode(encoder, offset + 0, depth)?;
892            self.1.encode(encoder, offset + 16, depth)?;
893            Ok(())
894        }
895    }
896
897    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
898        for RealmFactoryCreateRealm2Request
899    {
900        #[inline(always)]
901        fn new_empty() -> Self {
902            Self {
903                options: fidl::new_empty!(
904                    RealmOptions,
905                    fidl::encoding::DefaultFuchsiaResourceDialect
906                ),
907                dictionary: fidl::new_empty!(
908                    fidl::encoding::Endpoint<
909                        fidl::endpoints::ServerEnd<
910                            fidl_fuchsia_component_sandbox::DictionaryMarker,
911                        >,
912                    >,
913                    fidl::encoding::DefaultFuchsiaResourceDialect
914                ),
915            }
916        }
917
918        #[inline]
919        unsafe fn decode(
920            &mut self,
921            decoder: &mut fidl::encoding::Decoder<
922                '_,
923                fidl::encoding::DefaultFuchsiaResourceDialect,
924            >,
925            offset: usize,
926            _depth: fidl::encoding::Depth,
927        ) -> fidl::Result<()> {
928            decoder.debug_check_bounds::<Self>(offset);
929            // Verify that padding bytes are zero.
930            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
931            let padval = unsafe { (ptr as *const u64).read_unaligned() };
932            let mask = 0xffffffff00000000u64;
933            let maskedval = padval & mask;
934            if maskedval != 0 {
935                return Err(fidl::Error::NonZeroPadding {
936                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
937                });
938            }
939            fidl::decode!(
940                RealmOptions,
941                fidl::encoding::DefaultFuchsiaResourceDialect,
942                &mut self.options,
943                decoder,
944                offset + 0,
945                _depth
946            )?;
947            fidl::decode!(
948                fidl::encoding::Endpoint<
949                    fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
950                >,
951                fidl::encoding::DefaultFuchsiaResourceDialect,
952                &mut self.dictionary,
953                decoder,
954                offset + 16,
955                _depth
956            )?;
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}