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