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