Skip to main content

fidl_fuchsia_driver_testing/
fidl_fuchsia_driver_testing.rs

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