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