Skip to main content

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