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::NullableHandle {
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
643    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
644        self.inner.shutdown_with_epitaph(status)
645    }
646
647    fn is_closed(&self) -> bool {
648        self.inner.channel().is_closed()
649    }
650    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
651        self.inner.channel().on_closed()
652    }
653
654    #[cfg(target_os = "fuchsia")]
655    fn signal_peer(
656        &self,
657        clear_mask: zx::Signals,
658        set_mask: zx::Signals,
659    ) -> Result<(), zx_status::Status> {
660        use fidl::Peered;
661        self.inner.channel().signal_peer(clear_mask, set_mask)
662    }
663}
664
665impl RealmFactoryControlHandle {}
666
667#[must_use = "FIDL methods require a response to be sent"]
668#[derive(Debug)]
669pub struct RealmFactoryCreateRealmResponder {
670    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
671    tx_id: u32,
672}
673
674/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
675/// if the responder is dropped without sending a response, so that the client
676/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
677impl std::ops::Drop for RealmFactoryCreateRealmResponder {
678    fn drop(&mut self) {
679        self.control_handle.shutdown();
680        // Safety: drops once, never accessed again
681        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
682    }
683}
684
685impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
686    type ControlHandle = RealmFactoryControlHandle;
687
688    fn control_handle(&self) -> &RealmFactoryControlHandle {
689        &self.control_handle
690    }
691
692    fn drop_without_shutdown(mut self) {
693        // Safety: drops once, never accessed again due to mem::forget
694        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
695        // Prevent Drop from running (which would shut down the channel)
696        std::mem::forget(self);
697    }
698}
699
700impl RealmFactoryCreateRealmResponder {
701    /// Sends a response to the FIDL transaction.
702    ///
703    /// Sets the channel to shutdown if an error occurs.
704    pub fn send(
705        self,
706        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
707    ) -> Result<(), fidl::Error> {
708        let _result = self.send_raw(result);
709        if _result.is_err() {
710            self.control_handle.shutdown();
711        }
712        self.drop_without_shutdown();
713        _result
714    }
715
716    /// Similar to "send" but does not shutdown the channel if an error occurs.
717    pub fn send_no_shutdown_on_err(
718        self,
719        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
720    ) -> Result<(), fidl::Error> {
721        let _result = self.send_raw(result);
722        self.drop_without_shutdown();
723        _result
724    }
725
726    fn send_raw(
727        &self,
728        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
729    ) -> Result<(), fidl::Error> {
730        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
731            fidl::encoding::EmptyStruct,
732            fidl_fuchsia_testing_harness::OperationError,
733        >>(
734            fidl::encoding::FlexibleResult::new(result),
735            self.tx_id,
736            0x7311a7afaad69aa3,
737            fidl::encoding::DynamicFlags::FLEXIBLE,
738        )
739    }
740}
741
742#[must_use = "FIDL methods require a response to be sent"]
743#[derive(Debug)]
744pub struct RealmFactoryCreateRealm2Responder {
745    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
746    tx_id: u32,
747}
748
749/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
750/// if the responder is dropped without sending a response, so that the client
751/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
752impl std::ops::Drop for RealmFactoryCreateRealm2Responder {
753    fn drop(&mut self) {
754        self.control_handle.shutdown();
755        // Safety: drops once, never accessed again
756        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
757    }
758}
759
760impl fidl::endpoints::Responder for RealmFactoryCreateRealm2Responder {
761    type ControlHandle = RealmFactoryControlHandle;
762
763    fn control_handle(&self) -> &RealmFactoryControlHandle {
764        &self.control_handle
765    }
766
767    fn drop_without_shutdown(mut self) {
768        // Safety: drops once, never accessed again due to mem::forget
769        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
770        // Prevent Drop from running (which would shut down the channel)
771        std::mem::forget(self);
772    }
773}
774
775impl RealmFactoryCreateRealm2Responder {
776    /// Sends a response to the FIDL transaction.
777    ///
778    /// Sets the channel to shutdown if an error occurs.
779    pub fn send(
780        self,
781        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
782    ) -> Result<(), fidl::Error> {
783        let _result = self.send_raw(result);
784        if _result.is_err() {
785            self.control_handle.shutdown();
786        }
787        self.drop_without_shutdown();
788        _result
789    }
790
791    /// Similar to "send" but does not shutdown the channel if an error occurs.
792    pub fn send_no_shutdown_on_err(
793        self,
794        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
795    ) -> Result<(), fidl::Error> {
796        let _result = self.send_raw(result);
797        self.drop_without_shutdown();
798        _result
799    }
800
801    fn send_raw(
802        &self,
803        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
804    ) -> Result<(), fidl::Error> {
805        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
806            fidl::encoding::EmptyStruct,
807            fidl_fuchsia_testing_harness::OperationError,
808        >>(
809            fidl::encoding::FlexibleResult::new(result),
810            self.tx_id,
811            0x60e280c725202e95,
812            fidl::encoding::DynamicFlags::FLEXIBLE,
813        )
814    }
815}
816
817mod internal {
818    use super::*;
819
820    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealm2Request {
821        type Borrowed<'a> = &'a mut Self;
822        fn take_or_borrow<'a>(
823            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
824        ) -> Self::Borrowed<'a> {
825            value
826        }
827    }
828
829    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealm2Request {
830        type Owned = Self;
831
832        #[inline(always)]
833        fn inline_align(_context: fidl::encoding::Context) -> usize {
834            8
835        }
836
837        #[inline(always)]
838        fn inline_size(_context: fidl::encoding::Context) -> usize {
839            24
840        }
841    }
842
843    unsafe impl
844        fidl::encoding::Encode<
845            RealmFactoryCreateRealm2Request,
846            fidl::encoding::DefaultFuchsiaResourceDialect,
847        > for &mut RealmFactoryCreateRealm2Request
848    {
849        #[inline]
850        unsafe fn encode(
851            self,
852            encoder: &mut fidl::encoding::Encoder<
853                '_,
854                fidl::encoding::DefaultFuchsiaResourceDialect,
855            >,
856            offset: usize,
857            _depth: fidl::encoding::Depth,
858        ) -> fidl::Result<()> {
859            encoder.debug_check_bounds::<RealmFactoryCreateRealm2Request>(offset);
860            // Delegate to tuple encoding.
861            fidl::encoding::Encode::<
862                RealmFactoryCreateRealm2Request,
863                fidl::encoding::DefaultFuchsiaResourceDialect,
864            >::encode(
865                (
866                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
867                        &mut self.options,
868                    ),
869                    <fidl::encoding::Endpoint<
870                        fidl::endpoints::ServerEnd<
871                            fidl_fuchsia_component_sandbox::DictionaryMarker,
872                        >,
873                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
874                        &mut self.dictionary
875                    ),
876                ),
877                encoder,
878                offset,
879                _depth,
880            )
881        }
882    }
883    unsafe impl<
884        T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
885        T1: fidl::encoding::Encode<
886                fidl::encoding::Endpoint<
887                    fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
888                >,
889                fidl::encoding::DefaultFuchsiaResourceDialect,
890            >,
891    >
892        fidl::encoding::Encode<
893            RealmFactoryCreateRealm2Request,
894            fidl::encoding::DefaultFuchsiaResourceDialect,
895        > for (T0, T1)
896    {
897        #[inline]
898        unsafe fn encode(
899            self,
900            encoder: &mut fidl::encoding::Encoder<
901                '_,
902                fidl::encoding::DefaultFuchsiaResourceDialect,
903            >,
904            offset: usize,
905            depth: fidl::encoding::Depth,
906        ) -> fidl::Result<()> {
907            encoder.debug_check_bounds::<RealmFactoryCreateRealm2Request>(offset);
908            // Zero out padding regions. There's no need to apply masks
909            // because the unmasked parts will be overwritten by fields.
910            unsafe {
911                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
912                (ptr as *mut u64).write_unaligned(0);
913            }
914            // Write the fields.
915            self.0.encode(encoder, offset + 0, depth)?;
916            self.1.encode(encoder, offset + 16, depth)?;
917            Ok(())
918        }
919    }
920
921    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
922        for RealmFactoryCreateRealm2Request
923    {
924        #[inline(always)]
925        fn new_empty() -> Self {
926            Self {
927                options: fidl::new_empty!(
928                    RealmOptions,
929                    fidl::encoding::DefaultFuchsiaResourceDialect
930                ),
931                dictionary: fidl::new_empty!(
932                    fidl::encoding::Endpoint<
933                        fidl::endpoints::ServerEnd<
934                            fidl_fuchsia_component_sandbox::DictionaryMarker,
935                        >,
936                    >,
937                    fidl::encoding::DefaultFuchsiaResourceDialect
938                ),
939            }
940        }
941
942        #[inline]
943        unsafe fn decode(
944            &mut self,
945            decoder: &mut fidl::encoding::Decoder<
946                '_,
947                fidl::encoding::DefaultFuchsiaResourceDialect,
948            >,
949            offset: usize,
950            _depth: fidl::encoding::Depth,
951        ) -> fidl::Result<()> {
952            decoder.debug_check_bounds::<Self>(offset);
953            // Verify that padding bytes are zero.
954            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
955            let padval = unsafe { (ptr as *const u64).read_unaligned() };
956            let mask = 0xffffffff00000000u64;
957            let maskedval = padval & mask;
958            if maskedval != 0 {
959                return Err(fidl::Error::NonZeroPadding {
960                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
961                });
962            }
963            fidl::decode!(
964                RealmOptions,
965                fidl::encoding::DefaultFuchsiaResourceDialect,
966                &mut self.options,
967                decoder,
968                offset + 0,
969                _depth
970            )?;
971            fidl::decode!(
972                fidl::encoding::Endpoint<
973                    fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
974                >,
975                fidl::encoding::DefaultFuchsiaResourceDialect,
976                &mut self.dictionary,
977                decoder,
978                offset + 16,
979                _depth
980            )?;
981            Ok(())
982        }
983    }
984
985    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
986        type Borrowed<'a> = &'a mut Self;
987        fn take_or_borrow<'a>(
988            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
989        ) -> Self::Borrowed<'a> {
990            value
991        }
992    }
993
994    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
995        type Owned = Self;
996
997        #[inline(always)]
998        fn inline_align(_context: fidl::encoding::Context) -> usize {
999            8
1000        }
1001
1002        #[inline(always)]
1003        fn inline_size(_context: fidl::encoding::Context) -> usize {
1004            24
1005        }
1006    }
1007
1008    unsafe impl
1009        fidl::encoding::Encode<
1010            RealmFactoryCreateRealmRequest,
1011            fidl::encoding::DefaultFuchsiaResourceDialect,
1012        > for &mut RealmFactoryCreateRealmRequest
1013    {
1014        #[inline]
1015        unsafe fn encode(
1016            self,
1017            encoder: &mut fidl::encoding::Encoder<
1018                '_,
1019                fidl::encoding::DefaultFuchsiaResourceDialect,
1020            >,
1021            offset: usize,
1022            _depth: fidl::encoding::Depth,
1023        ) -> fidl::Result<()> {
1024            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1025            // Delegate to tuple encoding.
1026            fidl::encoding::Encode::<
1027                RealmFactoryCreateRealmRequest,
1028                fidl::encoding::DefaultFuchsiaResourceDialect,
1029            >::encode(
1030                (
1031                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1032                        &mut self.options,
1033                    ),
1034                    <fidl::encoding::Endpoint<
1035                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1036                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1037                        &mut self.realm_server,
1038                    ),
1039                ),
1040                encoder,
1041                offset,
1042                _depth,
1043            )
1044        }
1045    }
1046    unsafe impl<
1047        T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
1048        T1: fidl::encoding::Encode<
1049                fidl::encoding::Endpoint<
1050                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1051                >,
1052                fidl::encoding::DefaultFuchsiaResourceDialect,
1053            >,
1054    >
1055        fidl::encoding::Encode<
1056            RealmFactoryCreateRealmRequest,
1057            fidl::encoding::DefaultFuchsiaResourceDialect,
1058        > for (T0, T1)
1059    {
1060        #[inline]
1061        unsafe fn encode(
1062            self,
1063            encoder: &mut fidl::encoding::Encoder<
1064                '_,
1065                fidl::encoding::DefaultFuchsiaResourceDialect,
1066            >,
1067            offset: usize,
1068            depth: fidl::encoding::Depth,
1069        ) -> fidl::Result<()> {
1070            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1071            // Zero out padding regions. There's no need to apply masks
1072            // because the unmasked parts will be overwritten by fields.
1073            unsafe {
1074                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1075                (ptr as *mut u64).write_unaligned(0);
1076            }
1077            // Write the fields.
1078            self.0.encode(encoder, offset + 0, depth)?;
1079            self.1.encode(encoder, offset + 16, depth)?;
1080            Ok(())
1081        }
1082    }
1083
1084    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1085        for RealmFactoryCreateRealmRequest
1086    {
1087        #[inline(always)]
1088        fn new_empty() -> Self {
1089            Self {
1090                options: fidl::new_empty!(
1091                    RealmOptions,
1092                    fidl::encoding::DefaultFuchsiaResourceDialect
1093                ),
1094                realm_server: fidl::new_empty!(
1095                    fidl::encoding::Endpoint<
1096                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1097                    >,
1098                    fidl::encoding::DefaultFuchsiaResourceDialect
1099                ),
1100            }
1101        }
1102
1103        #[inline]
1104        unsafe fn decode(
1105            &mut self,
1106            decoder: &mut fidl::encoding::Decoder<
1107                '_,
1108                fidl::encoding::DefaultFuchsiaResourceDialect,
1109            >,
1110            offset: usize,
1111            _depth: fidl::encoding::Depth,
1112        ) -> fidl::Result<()> {
1113            decoder.debug_check_bounds::<Self>(offset);
1114            // Verify that padding bytes are zero.
1115            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1116            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1117            let mask = 0xffffffff00000000u64;
1118            let maskedval = padval & mask;
1119            if maskedval != 0 {
1120                return Err(fidl::Error::NonZeroPadding {
1121                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1122                });
1123            }
1124            fidl::decode!(
1125                RealmOptions,
1126                fidl::encoding::DefaultFuchsiaResourceDialect,
1127                &mut self.options,
1128                decoder,
1129                offset + 0,
1130                _depth
1131            )?;
1132            fidl::decode!(
1133                fidl::encoding::Endpoint<
1134                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1135                >,
1136                fidl::encoding::DefaultFuchsiaResourceDialect,
1137                &mut self.realm_server,
1138                decoder,
1139                offset + 16,
1140                _depth
1141            )?;
1142            Ok(())
1143        }
1144    }
1145
1146    impl RealmOptions {
1147        #[inline(always)]
1148        fn max_ordinal_present(&self) -> u64 {
1149            if let Some(_) = self.offers_client {
1150                return 5;
1151            }
1152            if let Some(_) = self.dev_class {
1153                return 4;
1154            }
1155            if let Some(_) = self.dev_topological {
1156                return 3;
1157            }
1158            if let Some(_) = self.driver_test_realm_url {
1159                return 2;
1160            }
1161            if let Some(_) = self.driver_test_realm_start_args {
1162                return 1;
1163            }
1164            0
1165        }
1166    }
1167
1168    impl fidl::encoding::ResourceTypeMarker for RealmOptions {
1169        type Borrowed<'a> = &'a mut Self;
1170        fn take_or_borrow<'a>(
1171            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1172        ) -> Self::Borrowed<'a> {
1173            value
1174        }
1175    }
1176
1177    unsafe impl fidl::encoding::TypeMarker for RealmOptions {
1178        type Owned = Self;
1179
1180        #[inline(always)]
1181        fn inline_align(_context: fidl::encoding::Context) -> usize {
1182            8
1183        }
1184
1185        #[inline(always)]
1186        fn inline_size(_context: fidl::encoding::Context) -> usize {
1187            16
1188        }
1189    }
1190
1191    unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1192        for &mut RealmOptions
1193    {
1194        unsafe fn encode(
1195            self,
1196            encoder: &mut fidl::encoding::Encoder<
1197                '_,
1198                fidl::encoding::DefaultFuchsiaResourceDialect,
1199            >,
1200            offset: usize,
1201            mut depth: fidl::encoding::Depth,
1202        ) -> fidl::Result<()> {
1203            encoder.debug_check_bounds::<RealmOptions>(offset);
1204            // Vector header
1205            let max_ordinal: u64 = self.max_ordinal_present();
1206            encoder.write_num(max_ordinal, offset);
1207            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1208            // Calling encoder.out_of_line_offset(0) is not allowed.
1209            if max_ordinal == 0 {
1210                return Ok(());
1211            }
1212            depth.increment()?;
1213            let envelope_size = 8;
1214            let bytes_len = max_ordinal as usize * envelope_size;
1215            #[allow(unused_variables)]
1216            let offset = encoder.out_of_line_offset(bytes_len);
1217            let mut _prev_end_offset: usize = 0;
1218            if 1 > max_ordinal {
1219                return Ok(());
1220            }
1221
1222            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1223            // are envelope_size bytes.
1224            let cur_offset: usize = (1 - 1) * envelope_size;
1225
1226            // Zero reserved fields.
1227            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1228
1229            // Safety:
1230            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1231            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1232            //   envelope_size bytes, there is always sufficient room.
1233            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_driver_test::RealmArgs, fidl::encoding::DefaultFuchsiaResourceDialect>(
1234            self.driver_test_realm_start_args.as_mut().map(<fidl_fuchsia_driver_test::RealmArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1235            encoder, offset + cur_offset, depth
1236        )?;
1237
1238            _prev_end_offset = cur_offset + envelope_size;
1239            if 2 > max_ordinal {
1240                return Ok(());
1241            }
1242
1243            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1244            // are envelope_size bytes.
1245            let cur_offset: usize = (2 - 1) * envelope_size;
1246
1247            // Zero reserved fields.
1248            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1249
1250            // Safety:
1251            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1252            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1253            //   envelope_size bytes, there is always sufficient room.
1254            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1255            self.driver_test_realm_url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
1256            encoder, offset + cur_offset, depth
1257        )?;
1258
1259            _prev_end_offset = cur_offset + envelope_size;
1260            if 3 > max_ordinal {
1261                return Ok(());
1262            }
1263
1264            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1265            // are envelope_size bytes.
1266            let cur_offset: usize = (3 - 1) * envelope_size;
1267
1268            // Zero reserved fields.
1269            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1270
1271            // Safety:
1272            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1273            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1274            //   envelope_size bytes, there is always sufficient room.
1275            fidl::encoding::encode_in_envelope_optional::<
1276                fidl::encoding::Endpoint<
1277                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1278                >,
1279                fidl::encoding::DefaultFuchsiaResourceDialect,
1280            >(
1281                self.dev_topological.as_mut().map(
1282                    <fidl::encoding::Endpoint<
1283                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1284                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1285                ),
1286                encoder,
1287                offset + cur_offset,
1288                depth,
1289            )?;
1290
1291            _prev_end_offset = cur_offset + envelope_size;
1292            if 4 > max_ordinal {
1293                return Ok(());
1294            }
1295
1296            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1297            // are envelope_size bytes.
1298            let cur_offset: usize = (4 - 1) * envelope_size;
1299
1300            // Zero reserved fields.
1301            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1302
1303            // Safety:
1304            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1305            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1306            //   envelope_size bytes, there is always sufficient room.
1307            fidl::encoding::encode_in_envelope_optional::<
1308                fidl::encoding::Endpoint<
1309                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1310                >,
1311                fidl::encoding::DefaultFuchsiaResourceDialect,
1312            >(
1313                self.dev_class.as_mut().map(
1314                    <fidl::encoding::Endpoint<
1315                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1316                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1317                ),
1318                encoder,
1319                offset + cur_offset,
1320                depth,
1321            )?;
1322
1323            _prev_end_offset = cur_offset + envelope_size;
1324            if 5 > max_ordinal {
1325                return Ok(());
1326            }
1327
1328            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1329            // are envelope_size bytes.
1330            let cur_offset: usize = (5 - 1) * envelope_size;
1331
1332            // Zero reserved fields.
1333            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1334
1335            // Safety:
1336            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1337            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1338            //   envelope_size bytes, there is always sufficient room.
1339            fidl::encoding::encode_in_envelope_optional::<
1340                fidl::encoding::Endpoint<
1341                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1342                >,
1343                fidl::encoding::DefaultFuchsiaResourceDialect,
1344            >(
1345                self.offers_client.as_mut().map(
1346                    <fidl::encoding::Endpoint<
1347                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1348                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1349                ),
1350                encoder,
1351                offset + cur_offset,
1352                depth,
1353            )?;
1354
1355            _prev_end_offset = cur_offset + envelope_size;
1356
1357            Ok(())
1358        }
1359    }
1360
1361    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
1362        #[inline(always)]
1363        fn new_empty() -> Self {
1364            Self::default()
1365        }
1366
1367        unsafe fn decode(
1368            &mut self,
1369            decoder: &mut fidl::encoding::Decoder<
1370                '_,
1371                fidl::encoding::DefaultFuchsiaResourceDialect,
1372            >,
1373            offset: usize,
1374            mut depth: fidl::encoding::Depth,
1375        ) -> fidl::Result<()> {
1376            decoder.debug_check_bounds::<Self>(offset);
1377            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1378                None => return Err(fidl::Error::NotNullable),
1379                Some(len) => len,
1380            };
1381            // Calling decoder.out_of_line_offset(0) is not allowed.
1382            if len == 0 {
1383                return Ok(());
1384            };
1385            depth.increment()?;
1386            let envelope_size = 8;
1387            let bytes_len = len * envelope_size;
1388            let offset = decoder.out_of_line_offset(bytes_len)?;
1389            // Decode the envelope for each type.
1390            let mut _next_ordinal_to_read = 0;
1391            let mut next_offset = offset;
1392            let end_offset = offset + bytes_len;
1393            _next_ordinal_to_read += 1;
1394            if next_offset >= end_offset {
1395                return Ok(());
1396            }
1397
1398            // Decode unknown envelopes for gaps in ordinals.
1399            while _next_ordinal_to_read < 1 {
1400                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1401                _next_ordinal_to_read += 1;
1402                next_offset += envelope_size;
1403            }
1404
1405            let next_out_of_line = decoder.next_out_of_line();
1406            let handles_before = decoder.remaining_handles();
1407            if let Some((inlined, num_bytes, num_handles)) =
1408                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1409            {
1410                let member_inline_size = <fidl_fuchsia_driver_test::RealmArgs as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1411                if inlined != (member_inline_size <= 4) {
1412                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1413                }
1414                let inner_offset;
1415                let mut inner_depth = depth.clone();
1416                if inlined {
1417                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1418                    inner_offset = next_offset;
1419                } else {
1420                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1421                    inner_depth.increment()?;
1422                }
1423                let val_ref = self.driver_test_realm_start_args.get_or_insert_with(|| {
1424                    fidl::new_empty!(
1425                        fidl_fuchsia_driver_test::RealmArgs,
1426                        fidl::encoding::DefaultFuchsiaResourceDialect
1427                    )
1428                });
1429                fidl::decode!(
1430                    fidl_fuchsia_driver_test::RealmArgs,
1431                    fidl::encoding::DefaultFuchsiaResourceDialect,
1432                    val_ref,
1433                    decoder,
1434                    inner_offset,
1435                    inner_depth
1436                )?;
1437                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1438                {
1439                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1440                }
1441                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1442                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1443                }
1444            }
1445
1446            next_offset += envelope_size;
1447            _next_ordinal_to_read += 1;
1448            if next_offset >= end_offset {
1449                return Ok(());
1450            }
1451
1452            // Decode unknown envelopes for gaps in ordinals.
1453            while _next_ordinal_to_read < 2 {
1454                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1455                _next_ordinal_to_read += 1;
1456                next_offset += envelope_size;
1457            }
1458
1459            let next_out_of_line = decoder.next_out_of_line();
1460            let handles_before = decoder.remaining_handles();
1461            if let Some((inlined, num_bytes, num_handles)) =
1462                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1463            {
1464                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1465                if inlined != (member_inline_size <= 4) {
1466                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1467                }
1468                let inner_offset;
1469                let mut inner_depth = depth.clone();
1470                if inlined {
1471                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1472                    inner_offset = next_offset;
1473                } else {
1474                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1475                    inner_depth.increment()?;
1476                }
1477                let val_ref = self.driver_test_realm_url.get_or_insert_with(|| {
1478                    fidl::new_empty!(
1479                        fidl::encoding::BoundedString<4096>,
1480                        fidl::encoding::DefaultFuchsiaResourceDialect
1481                    )
1482                });
1483                fidl::decode!(
1484                    fidl::encoding::BoundedString<4096>,
1485                    fidl::encoding::DefaultFuchsiaResourceDialect,
1486                    val_ref,
1487                    decoder,
1488                    inner_offset,
1489                    inner_depth
1490                )?;
1491                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1492                {
1493                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1494                }
1495                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1496                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1497                }
1498            }
1499
1500            next_offset += envelope_size;
1501            _next_ordinal_to_read += 1;
1502            if next_offset >= end_offset {
1503                return Ok(());
1504            }
1505
1506            // Decode unknown envelopes for gaps in ordinals.
1507            while _next_ordinal_to_read < 3 {
1508                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1509                _next_ordinal_to_read += 1;
1510                next_offset += envelope_size;
1511            }
1512
1513            let next_out_of_line = decoder.next_out_of_line();
1514            let handles_before = decoder.remaining_handles();
1515            if let Some((inlined, num_bytes, num_handles)) =
1516                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1517            {
1518                let member_inline_size = <fidl::encoding::Endpoint<
1519                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1520                > as fidl::encoding::TypeMarker>::inline_size(
1521                    decoder.context
1522                );
1523                if inlined != (member_inline_size <= 4) {
1524                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1525                }
1526                let inner_offset;
1527                let mut inner_depth = depth.clone();
1528                if inlined {
1529                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1530                    inner_offset = next_offset;
1531                } else {
1532                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1533                    inner_depth.increment()?;
1534                }
1535                let val_ref = self.dev_topological.get_or_insert_with(|| {
1536                    fidl::new_empty!(
1537                        fidl::encoding::Endpoint<
1538                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1539                        >,
1540                        fidl::encoding::DefaultFuchsiaResourceDialect
1541                    )
1542                });
1543                fidl::decode!(
1544                    fidl::encoding::Endpoint<
1545                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1546                    >,
1547                    fidl::encoding::DefaultFuchsiaResourceDialect,
1548                    val_ref,
1549                    decoder,
1550                    inner_offset,
1551                    inner_depth
1552                )?;
1553                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1554                {
1555                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1556                }
1557                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1558                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1559                }
1560            }
1561
1562            next_offset += envelope_size;
1563            _next_ordinal_to_read += 1;
1564            if next_offset >= end_offset {
1565                return Ok(());
1566            }
1567
1568            // Decode unknown envelopes for gaps in ordinals.
1569            while _next_ordinal_to_read < 4 {
1570                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1571                _next_ordinal_to_read += 1;
1572                next_offset += envelope_size;
1573            }
1574
1575            let next_out_of_line = decoder.next_out_of_line();
1576            let handles_before = decoder.remaining_handles();
1577            if let Some((inlined, num_bytes, num_handles)) =
1578                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1579            {
1580                let member_inline_size = <fidl::encoding::Endpoint<
1581                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1582                > as fidl::encoding::TypeMarker>::inline_size(
1583                    decoder.context
1584                );
1585                if inlined != (member_inline_size <= 4) {
1586                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1587                }
1588                let inner_offset;
1589                let mut inner_depth = depth.clone();
1590                if inlined {
1591                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1592                    inner_offset = next_offset;
1593                } else {
1594                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1595                    inner_depth.increment()?;
1596                }
1597                let val_ref = self.dev_class.get_or_insert_with(|| {
1598                    fidl::new_empty!(
1599                        fidl::encoding::Endpoint<
1600                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1601                        >,
1602                        fidl::encoding::DefaultFuchsiaResourceDialect
1603                    )
1604                });
1605                fidl::decode!(
1606                    fidl::encoding::Endpoint<
1607                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1608                    >,
1609                    fidl::encoding::DefaultFuchsiaResourceDialect,
1610                    val_ref,
1611                    decoder,
1612                    inner_offset,
1613                    inner_depth
1614                )?;
1615                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1616                {
1617                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1618                }
1619                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1620                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1621                }
1622            }
1623
1624            next_offset += envelope_size;
1625            _next_ordinal_to_read += 1;
1626            if next_offset >= end_offset {
1627                return Ok(());
1628            }
1629
1630            // Decode unknown envelopes for gaps in ordinals.
1631            while _next_ordinal_to_read < 5 {
1632                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1633                _next_ordinal_to_read += 1;
1634                next_offset += envelope_size;
1635            }
1636
1637            let next_out_of_line = decoder.next_out_of_line();
1638            let handles_before = decoder.remaining_handles();
1639            if let Some((inlined, num_bytes, num_handles)) =
1640                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1641            {
1642                let member_inline_size = <fidl::encoding::Endpoint<
1643                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1644                > as fidl::encoding::TypeMarker>::inline_size(
1645                    decoder.context
1646                );
1647                if inlined != (member_inline_size <= 4) {
1648                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1649                }
1650                let inner_offset;
1651                let mut inner_depth = depth.clone();
1652                if inlined {
1653                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1654                    inner_offset = next_offset;
1655                } else {
1656                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1657                    inner_depth.increment()?;
1658                }
1659                let val_ref = self.offers_client.get_or_insert_with(|| {
1660                    fidl::new_empty!(
1661                        fidl::encoding::Endpoint<
1662                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1663                        >,
1664                        fidl::encoding::DefaultFuchsiaResourceDialect
1665                    )
1666                });
1667                fidl::decode!(
1668                    fidl::encoding::Endpoint<
1669                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1670                    >,
1671                    fidl::encoding::DefaultFuchsiaResourceDialect,
1672                    val_ref,
1673                    decoder,
1674                    inner_offset,
1675                    inner_depth
1676                )?;
1677                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1678                {
1679                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1680                }
1681                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1682                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1683                }
1684            }
1685
1686            next_offset += envelope_size;
1687
1688            // Decode the remaining unknown envelopes.
1689            while next_offset < end_offset {
1690                _next_ordinal_to_read += 1;
1691                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1692                next_offset += envelope_size;
1693            }
1694
1695            Ok(())
1696        }
1697    }
1698}