fidl_test_wlan_realm/
fidl_test_wlan_realm.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_test_wlan_realm_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct RealmFactoryCreateRealm2Request {
16    pub options: RealmOptions,
17    pub dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for RealmFactoryCreateRealm2Request
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct RealmFactoryCreateRealmRequest {
27    pub options: RealmOptions,
28    pub realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for RealmFactoryCreateRealmRequest
33{
34}
35
36/// Options for configuring the Driver Test Realm in the constructed test realm.
37#[derive(Debug, Default, PartialEq)]
38pub struct DriverConfig {
39    /// These will be opened in the test realm's devfs. The test suite holds the client end that
40    /// can be used to connect to FIDL protocols exposed by drivers over dev_topological or dev_class.
41    pub dev_topological: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>>,
42    pub dev_class: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>>,
43    /// Any topology that requires drivers will want the Driver Test Realm to be started.
44    /// For convenience, the realm factory starts the Driver Test Realm with these args.
45    pub driver_test_realm_start_args: Option<fidl_fuchsia_driver_test::RealmArgs>,
46    #[doc(hidden)]
47    pub __source_breaking: fidl::marker::SourceBreaking,
48}
49
50impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverConfig {}
51
52#[derive(Debug, Default, PartialEq)]
53pub struct DriversOnly {
54    pub driver_config: Option<DriverConfig>,
55    #[doc(hidden)]
56    pub __source_breaking: fidl::marker::SourceBreaking,
57}
58
59impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriversOnly {}
60
61/// RealmOptions tells the RealmFactory protocol how to create the test realm.
62#[derive(Debug, Default, PartialEq)]
63pub struct RealmOptions {
64    pub devfs_server_end: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>>,
65    pub wlan_config: Option<WlanConfig>,
66    /// Specifies the components included in the test realm, the client
67    /// protocols exposed to the test suite, and the mock protocols that the
68    /// test suite needs to inject into the test realm. See the |Topology| type
69    /// for more details.
70    pub topology: Option<Topology>,
71    #[doc(hidden)]
72    pub __source_breaking: fidl::marker::SourceBreaking,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {}
76
77/// Defines the configuration of the WLAN components under test.
78#[derive(Debug, Default, PartialEq)]
79pub struct WlanConfig {
80    /// If true, WEP and WPA1 are supported.
81    /// If not present, defaults to false.
82    pub use_legacy_privacy: Option<bool>,
83    /// If true, the regulatory region component is used.
84    /// If not present, defaults to true.
85    pub with_regulatory_region: Option<bool>,
86    /// The name of the created realm.
87    /// Note that this must be unique among all realms that may exist at one
88    /// time.
89    /// If not present, the name will be autogenerated.
90    pub name: Option<String>,
91    #[doc(hidden)]
92    pub __source_breaking: fidl::marker::SourceBreaking,
93}
94
95impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for WlanConfig {}
96
97/// Each variant specifies which WLAN components are included in the constructed
98/// test realm, what protocols are exposed to the test suite, and how mock
99/// protocols are injected by the test suite into the test realm.
100#[derive(Debug)]
101pub enum Topology {
102    /// Only the Driver Test Realm is included in this configuration.
103    /// No protocols are exposed through the test realm proxy.
104    /// Instead, the user should connect to the test driver directly through
105    /// |driver_config.dev_topological| or |driver_config.dev_class|.
106    DriversOnly(DriversOnly),
107    #[doc(hidden)]
108    __SourceBreaking { unknown_ordinal: u64 },
109}
110
111/// Pattern that matches an unknown `Topology` member.
112#[macro_export]
113macro_rules! TopologyUnknown {
114    () => {
115        _
116    };
117}
118
119// Custom PartialEq so that unknown variants are not equal to themselves.
120impl PartialEq for Topology {
121    fn eq(&self, other: &Self) -> bool {
122        match (self, other) {
123            (Self::DriversOnly(x), Self::DriversOnly(y)) => *x == *y,
124            _ => false,
125        }
126    }
127}
128
129impl Topology {
130    #[inline]
131    pub fn ordinal(&self) -> u64 {
132        match *self {
133            Self::DriversOnly(_) => 1,
134            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
135        }
136    }
137
138    #[inline]
139    pub fn unknown_variant_for_testing() -> Self {
140        Self::__SourceBreaking { unknown_ordinal: 0 }
141    }
142
143    #[inline]
144    pub fn is_unknown(&self) -> bool {
145        match self {
146            Self::__SourceBreaking { .. } => true,
147            _ => false,
148        }
149    }
150}
151
152impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Topology {}
153
154#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
155pub struct RealmFactoryMarker;
156
157impl fidl::endpoints::ProtocolMarker for RealmFactoryMarker {
158    type Proxy = RealmFactoryProxy;
159    type RequestStream = RealmFactoryRequestStream;
160    #[cfg(target_os = "fuchsia")]
161    type SynchronousProxy = RealmFactorySynchronousProxy;
162
163    const DEBUG_NAME: &'static str = "test.wlan.realm.RealmFactory";
164}
165impl fidl::endpoints::DiscoverableProtocolMarker for RealmFactoryMarker {}
166pub type RealmFactoryCreateRealmResult = Result<(), fidl_fuchsia_testing_harness::OperationError>;
167pub type RealmFactoryCreateRealm2Result = Result<(), fidl_fuchsia_testing_harness::OperationError>;
168
169pub trait RealmFactoryProxyInterface: Send + Sync {
170    type CreateRealmResponseFut: std::future::Future<Output = Result<RealmFactoryCreateRealmResult, fidl::Error>>
171        + Send;
172    fn r#create_realm(
173        &self,
174        options: RealmOptions,
175        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
176    ) -> Self::CreateRealmResponseFut;
177    type CreateRealm2ResponseFut: std::future::Future<Output = Result<RealmFactoryCreateRealm2Result, fidl::Error>>
178        + Send;
179    fn r#create_realm2(
180        &self,
181        options: RealmOptions,
182        dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
183    ) -> Self::CreateRealm2ResponseFut;
184}
185#[derive(Debug)]
186#[cfg(target_os = "fuchsia")]
187pub struct RealmFactorySynchronousProxy {
188    client: fidl::client::sync::Client,
189}
190
191#[cfg(target_os = "fuchsia")]
192impl fidl::endpoints::SynchronousProxy for RealmFactorySynchronousProxy {
193    type Proxy = RealmFactoryProxy;
194    type Protocol = RealmFactoryMarker;
195
196    fn from_channel(inner: fidl::Channel) -> Self {
197        Self::new(inner)
198    }
199
200    fn into_channel(self) -> fidl::Channel {
201        self.client.into_channel()
202    }
203
204    fn as_channel(&self) -> &fidl::Channel {
205        self.client.as_channel()
206    }
207}
208
209#[cfg(target_os = "fuchsia")]
210impl RealmFactorySynchronousProxy {
211    pub fn new(channel: fidl::Channel) -> Self {
212        let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
213        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
214    }
215
216    pub fn into_channel(self) -> fidl::Channel {
217        self.client.into_channel()
218    }
219
220    /// Waits until an event arrives and returns it. It is safe for other
221    /// threads to make concurrent requests while waiting for an event.
222    pub fn wait_for_event(
223        &self,
224        deadline: zx::MonotonicInstant,
225    ) -> Result<RealmFactoryEvent, fidl::Error> {
226        RealmFactoryEvent::decode(self.client.wait_for_event(deadline)?)
227    }
228
229    /// Creates the realm using the given options.
230    pub fn r#create_realm(
231        &self,
232        mut options: RealmOptions,
233        mut realm_server: fidl::endpoints::ServerEnd<
234            fidl_fuchsia_testing_harness::RealmProxy_Marker,
235        >,
236        ___deadline: zx::MonotonicInstant,
237    ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
238        let _response = self
239            .client
240            .send_query::<RealmFactoryCreateRealmRequest, fidl::encoding::FlexibleResultType<
241                fidl::encoding::EmptyStruct,
242                fidl_fuchsia_testing_harness::OperationError,
243            >>(
244                (&mut options, realm_server),
245                0x51aac08d328c3ae4,
246                fidl::encoding::DynamicFlags::FLEXIBLE,
247                ___deadline,
248            )?
249            .into_result::<RealmFactoryMarker>("create_realm")?;
250        Ok(_response.map(|x| x))
251    }
252
253    /// Creates a new realm and returns a dictionary containing its exposed capabilities.
254    pub fn r#create_realm2(
255        &self,
256        mut options: RealmOptions,
257        mut dictionary: fidl::endpoints::ServerEnd<
258            fidl_fuchsia_component_sandbox::DictionaryMarker,
259        >,
260        ___deadline: zx::MonotonicInstant,
261    ) -> Result<RealmFactoryCreateRealm2Result, fidl::Error> {
262        let _response = self
263            .client
264            .send_query::<RealmFactoryCreateRealm2Request, fidl::encoding::FlexibleResultType<
265                fidl::encoding::EmptyStruct,
266                fidl_fuchsia_testing_harness::OperationError,
267            >>(
268                (&mut options, dictionary),
269                0x29dd599835927548,
270                fidl::encoding::DynamicFlags::FLEXIBLE,
271                ___deadline,
272            )?
273            .into_result::<RealmFactoryMarker>("create_realm2")?;
274        Ok(_response.map(|x| x))
275    }
276}
277
278#[derive(Debug, Clone)]
279pub struct RealmFactoryProxy {
280    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
281}
282
283impl fidl::endpoints::Proxy for RealmFactoryProxy {
284    type Protocol = RealmFactoryMarker;
285
286    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
287        Self::new(inner)
288    }
289
290    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
291        self.client.into_channel().map_err(|client| Self { client })
292    }
293
294    fn as_channel(&self) -> &::fidl::AsyncChannel {
295        self.client.as_channel()
296    }
297}
298
299impl RealmFactoryProxy {
300    /// Create a new Proxy for test.wlan.realm/RealmFactory.
301    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
302        let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
303        Self { client: fidl::client::Client::new(channel, protocol_name) }
304    }
305
306    /// Get a Stream of events from the remote end of the protocol.
307    ///
308    /// # Panics
309    ///
310    /// Panics if the event stream was already taken.
311    pub fn take_event_stream(&self) -> RealmFactoryEventStream {
312        RealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
313    }
314
315    /// Creates the realm using the given options.
316    pub fn r#create_realm(
317        &self,
318        mut options: RealmOptions,
319        mut realm_server: fidl::endpoints::ServerEnd<
320            fidl_fuchsia_testing_harness::RealmProxy_Marker,
321        >,
322    ) -> fidl::client::QueryResponseFut<
323        RealmFactoryCreateRealmResult,
324        fidl::encoding::DefaultFuchsiaResourceDialect,
325    > {
326        RealmFactoryProxyInterface::r#create_realm(self, options, realm_server)
327    }
328
329    /// Creates a new realm and returns a dictionary containing its exposed capabilities.
330    pub fn r#create_realm2(
331        &self,
332        mut options: RealmOptions,
333        mut dictionary: fidl::endpoints::ServerEnd<
334            fidl_fuchsia_component_sandbox::DictionaryMarker,
335        >,
336    ) -> fidl::client::QueryResponseFut<
337        RealmFactoryCreateRealm2Result,
338        fidl::encoding::DefaultFuchsiaResourceDialect,
339    > {
340        RealmFactoryProxyInterface::r#create_realm2(self, options, dictionary)
341    }
342}
343
344impl RealmFactoryProxyInterface for RealmFactoryProxy {
345    type CreateRealmResponseFut = fidl::client::QueryResponseFut<
346        RealmFactoryCreateRealmResult,
347        fidl::encoding::DefaultFuchsiaResourceDialect,
348    >;
349    fn r#create_realm(
350        &self,
351        mut options: RealmOptions,
352        mut realm_server: fidl::endpoints::ServerEnd<
353            fidl_fuchsia_testing_harness::RealmProxy_Marker,
354        >,
355    ) -> Self::CreateRealmResponseFut {
356        fn _decode(
357            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
358        ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
359            let _response = fidl::client::decode_transaction_body::<
360                fidl::encoding::FlexibleResultType<
361                    fidl::encoding::EmptyStruct,
362                    fidl_fuchsia_testing_harness::OperationError,
363                >,
364                fidl::encoding::DefaultFuchsiaResourceDialect,
365                0x51aac08d328c3ae4,
366            >(_buf?)?
367            .into_result::<RealmFactoryMarker>("create_realm")?;
368            Ok(_response.map(|x| x))
369        }
370        self.client
371            .send_query_and_decode::<RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResult>(
372                (&mut options, realm_server),
373                0x51aac08d328c3ae4,
374                fidl::encoding::DynamicFlags::FLEXIBLE,
375                _decode,
376            )
377    }
378
379    type CreateRealm2ResponseFut = fidl::client::QueryResponseFut<
380        RealmFactoryCreateRealm2Result,
381        fidl::encoding::DefaultFuchsiaResourceDialect,
382    >;
383    fn r#create_realm2(
384        &self,
385        mut options: RealmOptions,
386        mut dictionary: fidl::endpoints::ServerEnd<
387            fidl_fuchsia_component_sandbox::DictionaryMarker,
388        >,
389    ) -> Self::CreateRealm2ResponseFut {
390        fn _decode(
391            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
392        ) -> Result<RealmFactoryCreateRealm2Result, fidl::Error> {
393            let _response = fidl::client::decode_transaction_body::<
394                fidl::encoding::FlexibleResultType<
395                    fidl::encoding::EmptyStruct,
396                    fidl_fuchsia_testing_harness::OperationError,
397                >,
398                fidl::encoding::DefaultFuchsiaResourceDialect,
399                0x29dd599835927548,
400            >(_buf?)?
401            .into_result::<RealmFactoryMarker>("create_realm2")?;
402            Ok(_response.map(|x| x))
403        }
404        self.client.send_query_and_decode::<
405            RealmFactoryCreateRealm2Request,
406            RealmFactoryCreateRealm2Result,
407        >(
408            (&mut options, dictionary,),
409            0x29dd599835927548,
410            fidl::encoding::DynamicFlags::FLEXIBLE,
411            _decode,
412        )
413    }
414}
415
416pub struct RealmFactoryEventStream {
417    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
418}
419
420impl std::marker::Unpin for RealmFactoryEventStream {}
421
422impl futures::stream::FusedStream for RealmFactoryEventStream {
423    fn is_terminated(&self) -> bool {
424        self.event_receiver.is_terminated()
425    }
426}
427
428impl futures::Stream for RealmFactoryEventStream {
429    type Item = Result<RealmFactoryEvent, fidl::Error>;
430
431    fn poll_next(
432        mut self: std::pin::Pin<&mut Self>,
433        cx: &mut std::task::Context<'_>,
434    ) -> std::task::Poll<Option<Self::Item>> {
435        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
436            &mut self.event_receiver,
437            cx
438        )?) {
439            Some(buf) => std::task::Poll::Ready(Some(RealmFactoryEvent::decode(buf))),
440            None => std::task::Poll::Ready(None),
441        }
442    }
443}
444
445#[derive(Debug)]
446pub enum RealmFactoryEvent {
447    #[non_exhaustive]
448    _UnknownEvent {
449        /// Ordinal of the event that was sent.
450        ordinal: u64,
451    },
452}
453
454impl RealmFactoryEvent {
455    /// Decodes a message buffer as a [`RealmFactoryEvent`].
456    fn decode(
457        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
458    ) -> Result<RealmFactoryEvent, fidl::Error> {
459        let (bytes, _handles) = buf.split_mut();
460        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
461        debug_assert_eq!(tx_header.tx_id, 0);
462        match tx_header.ordinal {
463            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
464                Ok(RealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
465            }
466            _ => Err(fidl::Error::UnknownOrdinal {
467                ordinal: tx_header.ordinal,
468                protocol_name: <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
469            }),
470        }
471    }
472}
473
474/// A Stream of incoming requests for test.wlan.realm/RealmFactory.
475pub struct RealmFactoryRequestStream {
476    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
477    is_terminated: bool,
478}
479
480impl std::marker::Unpin for RealmFactoryRequestStream {}
481
482impl futures::stream::FusedStream for RealmFactoryRequestStream {
483    fn is_terminated(&self) -> bool {
484        self.is_terminated
485    }
486}
487
488impl fidl::endpoints::RequestStream for RealmFactoryRequestStream {
489    type Protocol = RealmFactoryMarker;
490    type ControlHandle = RealmFactoryControlHandle;
491
492    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
493        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
494    }
495
496    fn control_handle(&self) -> Self::ControlHandle {
497        RealmFactoryControlHandle { inner: self.inner.clone() }
498    }
499
500    fn into_inner(
501        self,
502    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
503    {
504        (self.inner, self.is_terminated)
505    }
506
507    fn from_inner(
508        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
509        is_terminated: bool,
510    ) -> Self {
511        Self { inner, is_terminated }
512    }
513}
514
515impl futures::Stream for RealmFactoryRequestStream {
516    type Item = Result<RealmFactoryRequest, fidl::Error>;
517
518    fn poll_next(
519        mut self: std::pin::Pin<&mut Self>,
520        cx: &mut std::task::Context<'_>,
521    ) -> std::task::Poll<Option<Self::Item>> {
522        let this = &mut *self;
523        if this.inner.check_shutdown(cx) {
524            this.is_terminated = true;
525            return std::task::Poll::Ready(None);
526        }
527        if this.is_terminated {
528            panic!("polled RealmFactoryRequestStream after completion");
529        }
530        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
531            |bytes, handles| {
532                match this.inner.channel().read_etc(cx, bytes, handles) {
533                    std::task::Poll::Ready(Ok(())) => {}
534                    std::task::Poll::Pending => return std::task::Poll::Pending,
535                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
536                        this.is_terminated = true;
537                        return std::task::Poll::Ready(None);
538                    }
539                    std::task::Poll::Ready(Err(e)) => {
540                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
541                            e.into(),
542                        ))))
543                    }
544                }
545
546                // A message has been received from the channel
547                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
548
549                std::task::Poll::Ready(Some(match header.ordinal {
550                    0x51aac08d328c3ae4 => {
551                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
552                        let mut req = fidl::new_empty!(
553                            RealmFactoryCreateRealmRequest,
554                            fidl::encoding::DefaultFuchsiaResourceDialect
555                        );
556                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
557                        let control_handle =
558                            RealmFactoryControlHandle { inner: this.inner.clone() };
559                        Ok(RealmFactoryRequest::CreateRealm {
560                            options: req.options,
561                            realm_server: req.realm_server,
562
563                            responder: RealmFactoryCreateRealmResponder {
564                                control_handle: std::mem::ManuallyDrop::new(control_handle),
565                                tx_id: header.tx_id,
566                            },
567                        })
568                    }
569                    0x29dd599835927548 => {
570                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
571                        let mut req = fidl::new_empty!(
572                            RealmFactoryCreateRealm2Request,
573                            fidl::encoding::DefaultFuchsiaResourceDialect
574                        );
575                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealm2Request>(&header, _body_bytes, handles, &mut req)?;
576                        let control_handle =
577                            RealmFactoryControlHandle { inner: this.inner.clone() };
578                        Ok(RealmFactoryRequest::CreateRealm2 {
579                            options: req.options,
580                            dictionary: req.dictionary,
581
582                            responder: RealmFactoryCreateRealm2Responder {
583                                control_handle: std::mem::ManuallyDrop::new(control_handle),
584                                tx_id: header.tx_id,
585                            },
586                        })
587                    }
588                    _ if header.tx_id == 0
589                        && header
590                            .dynamic_flags()
591                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
592                    {
593                        Ok(RealmFactoryRequest::_UnknownMethod {
594                            ordinal: header.ordinal,
595                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
596                            method_type: fidl::MethodType::OneWay,
597                        })
598                    }
599                    _ if header
600                        .dynamic_flags()
601                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
602                    {
603                        this.inner.send_framework_err(
604                            fidl::encoding::FrameworkErr::UnknownMethod,
605                            header.tx_id,
606                            header.ordinal,
607                            header.dynamic_flags(),
608                            (bytes, handles),
609                        )?;
610                        Ok(RealmFactoryRequest::_UnknownMethod {
611                            ordinal: header.ordinal,
612                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
613                            method_type: fidl::MethodType::TwoWay,
614                        })
615                    }
616                    _ => Err(fidl::Error::UnknownOrdinal {
617                        ordinal: header.ordinal,
618                        protocol_name:
619                            <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
620                    }),
621                }))
622            },
623        )
624    }
625}
626
627#[derive(Debug)]
628pub enum RealmFactoryRequest {
629    /// Creates the realm using the given options.
630    CreateRealm {
631        options: RealmOptions,
632        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
633        responder: RealmFactoryCreateRealmResponder,
634    },
635    /// Creates a new realm and returns a dictionary containing its exposed capabilities.
636    CreateRealm2 {
637        options: RealmOptions,
638        dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
639        responder: RealmFactoryCreateRealm2Responder,
640    },
641    /// An interaction was received which does not match any known method.
642    #[non_exhaustive]
643    _UnknownMethod {
644        /// Ordinal of the method that was called.
645        ordinal: u64,
646        control_handle: RealmFactoryControlHandle,
647        method_type: fidl::MethodType,
648    },
649}
650
651impl RealmFactoryRequest {
652    #[allow(irrefutable_let_patterns)]
653    pub fn into_create_realm(
654        self,
655    ) -> Option<(
656        RealmOptions,
657        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
658        RealmFactoryCreateRealmResponder,
659    )> {
660        if let RealmFactoryRequest::CreateRealm { options, realm_server, responder } = self {
661            Some((options, realm_server, responder))
662        } else {
663            None
664        }
665    }
666
667    #[allow(irrefutable_let_patterns)]
668    pub fn into_create_realm2(
669        self,
670    ) -> Option<(
671        RealmOptions,
672        fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
673        RealmFactoryCreateRealm2Responder,
674    )> {
675        if let RealmFactoryRequest::CreateRealm2 { options, dictionary, responder } = self {
676            Some((options, dictionary, responder))
677        } else {
678            None
679        }
680    }
681
682    /// Name of the method defined in FIDL
683    pub fn method_name(&self) -> &'static str {
684        match *self {
685            RealmFactoryRequest::CreateRealm { .. } => "create_realm",
686            RealmFactoryRequest::CreateRealm2 { .. } => "create_realm2",
687            RealmFactoryRequest::_UnknownMethod {
688                method_type: fidl::MethodType::OneWay, ..
689            } => "unknown one-way method",
690            RealmFactoryRequest::_UnknownMethod {
691                method_type: fidl::MethodType::TwoWay, ..
692            } => "unknown two-way method",
693        }
694    }
695}
696
697#[derive(Debug, Clone)]
698pub struct RealmFactoryControlHandle {
699    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
700}
701
702impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
703    fn shutdown(&self) {
704        self.inner.shutdown()
705    }
706    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
707        self.inner.shutdown_with_epitaph(status)
708    }
709
710    fn is_closed(&self) -> bool {
711        self.inner.channel().is_closed()
712    }
713    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
714        self.inner.channel().on_closed()
715    }
716
717    #[cfg(target_os = "fuchsia")]
718    fn signal_peer(
719        &self,
720        clear_mask: zx::Signals,
721        set_mask: zx::Signals,
722    ) -> Result<(), zx_status::Status> {
723        use fidl::Peered;
724        self.inner.channel().signal_peer(clear_mask, set_mask)
725    }
726}
727
728impl RealmFactoryControlHandle {}
729
730#[must_use = "FIDL methods require a response to be sent"]
731#[derive(Debug)]
732pub struct RealmFactoryCreateRealmResponder {
733    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
734    tx_id: u32,
735}
736
737/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
738/// if the responder is dropped without sending a response, so that the client
739/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
740impl std::ops::Drop for RealmFactoryCreateRealmResponder {
741    fn drop(&mut self) {
742        self.control_handle.shutdown();
743        // Safety: drops once, never accessed again
744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
745    }
746}
747
748impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
749    type ControlHandle = RealmFactoryControlHandle;
750
751    fn control_handle(&self) -> &RealmFactoryControlHandle {
752        &self.control_handle
753    }
754
755    fn drop_without_shutdown(mut self) {
756        // Safety: drops once, never accessed again due to mem::forget
757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
758        // Prevent Drop from running (which would shut down the channel)
759        std::mem::forget(self);
760    }
761}
762
763impl RealmFactoryCreateRealmResponder {
764    /// Sends a response to the FIDL transaction.
765    ///
766    /// Sets the channel to shutdown if an error occurs.
767    pub fn send(
768        self,
769        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
770    ) -> Result<(), fidl::Error> {
771        let _result = self.send_raw(result);
772        if _result.is_err() {
773            self.control_handle.shutdown();
774        }
775        self.drop_without_shutdown();
776        _result
777    }
778
779    /// Similar to "send" but does not shutdown the channel if an error occurs.
780    pub fn send_no_shutdown_on_err(
781        self,
782        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
783    ) -> Result<(), fidl::Error> {
784        let _result = self.send_raw(result);
785        self.drop_without_shutdown();
786        _result
787    }
788
789    fn send_raw(
790        &self,
791        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
792    ) -> Result<(), fidl::Error> {
793        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
794            fidl::encoding::EmptyStruct,
795            fidl_fuchsia_testing_harness::OperationError,
796        >>(
797            fidl::encoding::FlexibleResult::new(result),
798            self.tx_id,
799            0x51aac08d328c3ae4,
800            fidl::encoding::DynamicFlags::FLEXIBLE,
801        )
802    }
803}
804
805#[must_use = "FIDL methods require a response to be sent"]
806#[derive(Debug)]
807pub struct RealmFactoryCreateRealm2Responder {
808    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
809    tx_id: u32,
810}
811
812/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
813/// if the responder is dropped without sending a response, so that the client
814/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
815impl std::ops::Drop for RealmFactoryCreateRealm2Responder {
816    fn drop(&mut self) {
817        self.control_handle.shutdown();
818        // Safety: drops once, never accessed again
819        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
820    }
821}
822
823impl fidl::endpoints::Responder for RealmFactoryCreateRealm2Responder {
824    type ControlHandle = RealmFactoryControlHandle;
825
826    fn control_handle(&self) -> &RealmFactoryControlHandle {
827        &self.control_handle
828    }
829
830    fn drop_without_shutdown(mut self) {
831        // Safety: drops once, never accessed again due to mem::forget
832        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
833        // Prevent Drop from running (which would shut down the channel)
834        std::mem::forget(self);
835    }
836}
837
838impl RealmFactoryCreateRealm2Responder {
839    /// Sends a response to the FIDL transaction.
840    ///
841    /// Sets the channel to shutdown if an error occurs.
842    pub fn send(
843        self,
844        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
845    ) -> Result<(), fidl::Error> {
846        let _result = self.send_raw(result);
847        if _result.is_err() {
848            self.control_handle.shutdown();
849        }
850        self.drop_without_shutdown();
851        _result
852    }
853
854    /// Similar to "send" but does not shutdown the channel if an error occurs.
855    pub fn send_no_shutdown_on_err(
856        self,
857        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
858    ) -> Result<(), fidl::Error> {
859        let _result = self.send_raw(result);
860        self.drop_without_shutdown();
861        _result
862    }
863
864    fn send_raw(
865        &self,
866        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
867    ) -> Result<(), fidl::Error> {
868        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
869            fidl::encoding::EmptyStruct,
870            fidl_fuchsia_testing_harness::OperationError,
871        >>(
872            fidl::encoding::FlexibleResult::new(result),
873            self.tx_id,
874            0x29dd599835927548,
875            fidl::encoding::DynamicFlags::FLEXIBLE,
876        )
877    }
878}
879
880mod internal {
881    use super::*;
882
883    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealm2Request {
884        type Borrowed<'a> = &'a mut Self;
885        fn take_or_borrow<'a>(
886            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
887        ) -> Self::Borrowed<'a> {
888            value
889        }
890    }
891
892    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealm2Request {
893        type Owned = Self;
894
895        #[inline(always)]
896        fn inline_align(_context: fidl::encoding::Context) -> usize {
897            8
898        }
899
900        #[inline(always)]
901        fn inline_size(_context: fidl::encoding::Context) -> usize {
902            24
903        }
904    }
905
906    unsafe impl
907        fidl::encoding::Encode<
908            RealmFactoryCreateRealm2Request,
909            fidl::encoding::DefaultFuchsiaResourceDialect,
910        > for &mut RealmFactoryCreateRealm2Request
911    {
912        #[inline]
913        unsafe fn encode(
914            self,
915            encoder: &mut fidl::encoding::Encoder<
916                '_,
917                fidl::encoding::DefaultFuchsiaResourceDialect,
918            >,
919            offset: usize,
920            _depth: fidl::encoding::Depth,
921        ) -> fidl::Result<()> {
922            encoder.debug_check_bounds::<RealmFactoryCreateRealm2Request>(offset);
923            // Delegate to tuple encoding.
924            fidl::encoding::Encode::<
925                RealmFactoryCreateRealm2Request,
926                fidl::encoding::DefaultFuchsiaResourceDialect,
927            >::encode(
928                (
929                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
930                        &mut self.options,
931                    ),
932                    <fidl::encoding::Endpoint<
933                        fidl::endpoints::ServerEnd<
934                            fidl_fuchsia_component_sandbox::DictionaryMarker,
935                        >,
936                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
937                        &mut self.dictionary
938                    ),
939                ),
940                encoder,
941                offset,
942                _depth,
943            )
944        }
945    }
946    unsafe impl<
947            T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
948            T1: fidl::encoding::Encode<
949                fidl::encoding::Endpoint<
950                    fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
951                >,
952                fidl::encoding::DefaultFuchsiaResourceDialect,
953            >,
954        >
955        fidl::encoding::Encode<
956            RealmFactoryCreateRealm2Request,
957            fidl::encoding::DefaultFuchsiaResourceDialect,
958        > for (T0, T1)
959    {
960        #[inline]
961        unsafe fn encode(
962            self,
963            encoder: &mut fidl::encoding::Encoder<
964                '_,
965                fidl::encoding::DefaultFuchsiaResourceDialect,
966            >,
967            offset: usize,
968            depth: fidl::encoding::Depth,
969        ) -> fidl::Result<()> {
970            encoder.debug_check_bounds::<RealmFactoryCreateRealm2Request>(offset);
971            // Zero out padding regions. There's no need to apply masks
972            // because the unmasked parts will be overwritten by fields.
973            unsafe {
974                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
975                (ptr as *mut u64).write_unaligned(0);
976            }
977            // Write the fields.
978            self.0.encode(encoder, offset + 0, depth)?;
979            self.1.encode(encoder, offset + 16, depth)?;
980            Ok(())
981        }
982    }
983
984    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
985        for RealmFactoryCreateRealm2Request
986    {
987        #[inline(always)]
988        fn new_empty() -> Self {
989            Self {
990                options: fidl::new_empty!(
991                    RealmOptions,
992                    fidl::encoding::DefaultFuchsiaResourceDialect
993                ),
994                dictionary: fidl::new_empty!(
995                    fidl::encoding::Endpoint<
996                        fidl::endpoints::ServerEnd<
997                            fidl_fuchsia_component_sandbox::DictionaryMarker,
998                        >,
999                    >,
1000                    fidl::encoding::DefaultFuchsiaResourceDialect
1001                ),
1002            }
1003        }
1004
1005        #[inline]
1006        unsafe fn decode(
1007            &mut self,
1008            decoder: &mut fidl::encoding::Decoder<
1009                '_,
1010                fidl::encoding::DefaultFuchsiaResourceDialect,
1011            >,
1012            offset: usize,
1013            _depth: fidl::encoding::Depth,
1014        ) -> fidl::Result<()> {
1015            decoder.debug_check_bounds::<Self>(offset);
1016            // Verify that padding bytes are zero.
1017            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1018            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1019            let mask = 0xffffffff00000000u64;
1020            let maskedval = padval & mask;
1021            if maskedval != 0 {
1022                return Err(fidl::Error::NonZeroPadding {
1023                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1024                });
1025            }
1026            fidl::decode!(
1027                RealmOptions,
1028                fidl::encoding::DefaultFuchsiaResourceDialect,
1029                &mut self.options,
1030                decoder,
1031                offset + 0,
1032                _depth
1033            )?;
1034            fidl::decode!(
1035                fidl::encoding::Endpoint<
1036                    fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
1037                >,
1038                fidl::encoding::DefaultFuchsiaResourceDialect,
1039                &mut self.dictionary,
1040                decoder,
1041                offset + 16,
1042                _depth
1043            )?;
1044            Ok(())
1045        }
1046    }
1047
1048    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
1049        type Borrowed<'a> = &'a mut Self;
1050        fn take_or_borrow<'a>(
1051            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1052        ) -> Self::Borrowed<'a> {
1053            value
1054        }
1055    }
1056
1057    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
1058        type Owned = Self;
1059
1060        #[inline(always)]
1061        fn inline_align(_context: fidl::encoding::Context) -> usize {
1062            8
1063        }
1064
1065        #[inline(always)]
1066        fn inline_size(_context: fidl::encoding::Context) -> usize {
1067            24
1068        }
1069    }
1070
1071    unsafe impl
1072        fidl::encoding::Encode<
1073            RealmFactoryCreateRealmRequest,
1074            fidl::encoding::DefaultFuchsiaResourceDialect,
1075        > for &mut RealmFactoryCreateRealmRequest
1076    {
1077        #[inline]
1078        unsafe fn encode(
1079            self,
1080            encoder: &mut fidl::encoding::Encoder<
1081                '_,
1082                fidl::encoding::DefaultFuchsiaResourceDialect,
1083            >,
1084            offset: usize,
1085            _depth: fidl::encoding::Depth,
1086        ) -> fidl::Result<()> {
1087            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1088            // Delegate to tuple encoding.
1089            fidl::encoding::Encode::<
1090                RealmFactoryCreateRealmRequest,
1091                fidl::encoding::DefaultFuchsiaResourceDialect,
1092            >::encode(
1093                (
1094                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1095                        &mut self.options,
1096                    ),
1097                    <fidl::encoding::Endpoint<
1098                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1099                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1100                        &mut self.realm_server,
1101                    ),
1102                ),
1103                encoder,
1104                offset,
1105                _depth,
1106            )
1107        }
1108    }
1109    unsafe impl<
1110            T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
1111            T1: fidl::encoding::Encode<
1112                fidl::encoding::Endpoint<
1113                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1114                >,
1115                fidl::encoding::DefaultFuchsiaResourceDialect,
1116            >,
1117        >
1118        fidl::encoding::Encode<
1119            RealmFactoryCreateRealmRequest,
1120            fidl::encoding::DefaultFuchsiaResourceDialect,
1121        > for (T0, T1)
1122    {
1123        #[inline]
1124        unsafe fn encode(
1125            self,
1126            encoder: &mut fidl::encoding::Encoder<
1127                '_,
1128                fidl::encoding::DefaultFuchsiaResourceDialect,
1129            >,
1130            offset: usize,
1131            depth: fidl::encoding::Depth,
1132        ) -> fidl::Result<()> {
1133            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
1134            // Zero out padding regions. There's no need to apply masks
1135            // because the unmasked parts will be overwritten by fields.
1136            unsafe {
1137                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1138                (ptr as *mut u64).write_unaligned(0);
1139            }
1140            // Write the fields.
1141            self.0.encode(encoder, offset + 0, depth)?;
1142            self.1.encode(encoder, offset + 16, depth)?;
1143            Ok(())
1144        }
1145    }
1146
1147    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1148        for RealmFactoryCreateRealmRequest
1149    {
1150        #[inline(always)]
1151        fn new_empty() -> Self {
1152            Self {
1153                options: fidl::new_empty!(
1154                    RealmOptions,
1155                    fidl::encoding::DefaultFuchsiaResourceDialect
1156                ),
1157                realm_server: fidl::new_empty!(
1158                    fidl::encoding::Endpoint<
1159                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1160                    >,
1161                    fidl::encoding::DefaultFuchsiaResourceDialect
1162                ),
1163            }
1164        }
1165
1166        #[inline]
1167        unsafe fn decode(
1168            &mut self,
1169            decoder: &mut fidl::encoding::Decoder<
1170                '_,
1171                fidl::encoding::DefaultFuchsiaResourceDialect,
1172            >,
1173            offset: usize,
1174            _depth: fidl::encoding::Depth,
1175        ) -> fidl::Result<()> {
1176            decoder.debug_check_bounds::<Self>(offset);
1177            // Verify that padding bytes are zero.
1178            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1179            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1180            let mask = 0xffffffff00000000u64;
1181            let maskedval = padval & mask;
1182            if maskedval != 0 {
1183                return Err(fidl::Error::NonZeroPadding {
1184                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1185                });
1186            }
1187            fidl::decode!(
1188                RealmOptions,
1189                fidl::encoding::DefaultFuchsiaResourceDialect,
1190                &mut self.options,
1191                decoder,
1192                offset + 0,
1193                _depth
1194            )?;
1195            fidl::decode!(
1196                fidl::encoding::Endpoint<
1197                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
1198                >,
1199                fidl::encoding::DefaultFuchsiaResourceDialect,
1200                &mut self.realm_server,
1201                decoder,
1202                offset + 16,
1203                _depth
1204            )?;
1205            Ok(())
1206        }
1207    }
1208
1209    impl DriverConfig {
1210        #[inline(always)]
1211        fn max_ordinal_present(&self) -> u64 {
1212            if let Some(_) = self.driver_test_realm_start_args {
1213                return 3;
1214            }
1215            if let Some(_) = self.dev_class {
1216                return 2;
1217            }
1218            if let Some(_) = self.dev_topological {
1219                return 1;
1220            }
1221            0
1222        }
1223    }
1224
1225    impl fidl::encoding::ResourceTypeMarker for DriverConfig {
1226        type Borrowed<'a> = &'a mut Self;
1227        fn take_or_borrow<'a>(
1228            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1229        ) -> Self::Borrowed<'a> {
1230            value
1231        }
1232    }
1233
1234    unsafe impl fidl::encoding::TypeMarker for DriverConfig {
1235        type Owned = Self;
1236
1237        #[inline(always)]
1238        fn inline_align(_context: fidl::encoding::Context) -> usize {
1239            8
1240        }
1241
1242        #[inline(always)]
1243        fn inline_size(_context: fidl::encoding::Context) -> usize {
1244            16
1245        }
1246    }
1247
1248    unsafe impl fidl::encoding::Encode<DriverConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
1249        for &mut DriverConfig
1250    {
1251        unsafe fn encode(
1252            self,
1253            encoder: &mut fidl::encoding::Encoder<
1254                '_,
1255                fidl::encoding::DefaultFuchsiaResourceDialect,
1256            >,
1257            offset: usize,
1258            mut depth: fidl::encoding::Depth,
1259        ) -> fidl::Result<()> {
1260            encoder.debug_check_bounds::<DriverConfig>(offset);
1261            // Vector header
1262            let max_ordinal: u64 = self.max_ordinal_present();
1263            encoder.write_num(max_ordinal, offset);
1264            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1265            // Calling encoder.out_of_line_offset(0) is not allowed.
1266            if max_ordinal == 0 {
1267                return Ok(());
1268            }
1269            depth.increment()?;
1270            let envelope_size = 8;
1271            let bytes_len = max_ordinal as usize * envelope_size;
1272            #[allow(unused_variables)]
1273            let offset = encoder.out_of_line_offset(bytes_len);
1274            let mut _prev_end_offset: usize = 0;
1275            if 1 > max_ordinal {
1276                return Ok(());
1277            }
1278
1279            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1280            // are envelope_size bytes.
1281            let cur_offset: usize = (1 - 1) * envelope_size;
1282
1283            // Zero reserved fields.
1284            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1285
1286            // Safety:
1287            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1288            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1289            //   envelope_size bytes, there is always sufficient room.
1290            fidl::encoding::encode_in_envelope_optional::<
1291                fidl::encoding::Endpoint<
1292                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1293                >,
1294                fidl::encoding::DefaultFuchsiaResourceDialect,
1295            >(
1296                self.dev_topological.as_mut().map(
1297                    <fidl::encoding::Endpoint<
1298                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1299                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1300                ),
1301                encoder,
1302                offset + cur_offset,
1303                depth,
1304            )?;
1305
1306            _prev_end_offset = cur_offset + envelope_size;
1307            if 2 > max_ordinal {
1308                return Ok(());
1309            }
1310
1311            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1312            // are envelope_size bytes.
1313            let cur_offset: usize = (2 - 1) * envelope_size;
1314
1315            // Zero reserved fields.
1316            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1317
1318            // Safety:
1319            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1320            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1321            //   envelope_size bytes, there is always sufficient room.
1322            fidl::encoding::encode_in_envelope_optional::<
1323                fidl::encoding::Endpoint<
1324                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1325                >,
1326                fidl::encoding::DefaultFuchsiaResourceDialect,
1327            >(
1328                self.dev_class.as_mut().map(
1329                    <fidl::encoding::Endpoint<
1330                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1331                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1332                ),
1333                encoder,
1334                offset + cur_offset,
1335                depth,
1336            )?;
1337
1338            _prev_end_offset = cur_offset + envelope_size;
1339            if 3 > max_ordinal {
1340                return Ok(());
1341            }
1342
1343            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1344            // are envelope_size bytes.
1345            let cur_offset: usize = (3 - 1) * envelope_size;
1346
1347            // Zero reserved fields.
1348            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1349
1350            // Safety:
1351            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1352            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1353            //   envelope_size bytes, there is always sufficient room.
1354            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_driver_test::RealmArgs, fidl::encoding::DefaultFuchsiaResourceDialect>(
1355            self.driver_test_realm_start_args.as_mut().map(<fidl_fuchsia_driver_test::RealmArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1356            encoder, offset + cur_offset, depth
1357        )?;
1358
1359            _prev_end_offset = cur_offset + envelope_size;
1360
1361            Ok(())
1362        }
1363    }
1364
1365    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DriverConfig {
1366        #[inline(always)]
1367        fn new_empty() -> Self {
1368            Self::default()
1369        }
1370
1371        unsafe fn decode(
1372            &mut self,
1373            decoder: &mut fidl::encoding::Decoder<
1374                '_,
1375                fidl::encoding::DefaultFuchsiaResourceDialect,
1376            >,
1377            offset: usize,
1378            mut depth: fidl::encoding::Depth,
1379        ) -> fidl::Result<()> {
1380            decoder.debug_check_bounds::<Self>(offset);
1381            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1382                None => return Err(fidl::Error::NotNullable),
1383                Some(len) => len,
1384            };
1385            // Calling decoder.out_of_line_offset(0) is not allowed.
1386            if len == 0 {
1387                return Ok(());
1388            };
1389            depth.increment()?;
1390            let envelope_size = 8;
1391            let bytes_len = len * envelope_size;
1392            let offset = decoder.out_of_line_offset(bytes_len)?;
1393            // Decode the envelope for each type.
1394            let mut _next_ordinal_to_read = 0;
1395            let mut next_offset = offset;
1396            let end_offset = offset + bytes_len;
1397            _next_ordinal_to_read += 1;
1398            if next_offset >= end_offset {
1399                return Ok(());
1400            }
1401
1402            // Decode unknown envelopes for gaps in ordinals.
1403            while _next_ordinal_to_read < 1 {
1404                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1405                _next_ordinal_to_read += 1;
1406                next_offset += envelope_size;
1407            }
1408
1409            let next_out_of_line = decoder.next_out_of_line();
1410            let handles_before = decoder.remaining_handles();
1411            if let Some((inlined, num_bytes, num_handles)) =
1412                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1413            {
1414                let member_inline_size = <fidl::encoding::Endpoint<
1415                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1416                > as fidl::encoding::TypeMarker>::inline_size(
1417                    decoder.context
1418                );
1419                if inlined != (member_inline_size <= 4) {
1420                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1421                }
1422                let inner_offset;
1423                let mut inner_depth = depth.clone();
1424                if inlined {
1425                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1426                    inner_offset = next_offset;
1427                } else {
1428                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1429                    inner_depth.increment()?;
1430                }
1431                let val_ref = self.dev_topological.get_or_insert_with(|| {
1432                    fidl::new_empty!(
1433                        fidl::encoding::Endpoint<
1434                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1435                        >,
1436                        fidl::encoding::DefaultFuchsiaResourceDialect
1437                    )
1438                });
1439                fidl::decode!(
1440                    fidl::encoding::Endpoint<
1441                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1442                    >,
1443                    fidl::encoding::DefaultFuchsiaResourceDialect,
1444                    val_ref,
1445                    decoder,
1446                    inner_offset,
1447                    inner_depth
1448                )?;
1449                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1450                {
1451                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1452                }
1453                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1454                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1455                }
1456            }
1457
1458            next_offset += envelope_size;
1459            _next_ordinal_to_read += 1;
1460            if next_offset >= end_offset {
1461                return Ok(());
1462            }
1463
1464            // Decode unknown envelopes for gaps in ordinals.
1465            while _next_ordinal_to_read < 2 {
1466                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1467                _next_ordinal_to_read += 1;
1468                next_offset += envelope_size;
1469            }
1470
1471            let next_out_of_line = decoder.next_out_of_line();
1472            let handles_before = decoder.remaining_handles();
1473            if let Some((inlined, num_bytes, num_handles)) =
1474                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1475            {
1476                let member_inline_size = <fidl::encoding::Endpoint<
1477                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1478                > as fidl::encoding::TypeMarker>::inline_size(
1479                    decoder.context
1480                );
1481                if inlined != (member_inline_size <= 4) {
1482                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1483                }
1484                let inner_offset;
1485                let mut inner_depth = depth.clone();
1486                if inlined {
1487                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1488                    inner_offset = next_offset;
1489                } else {
1490                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1491                    inner_depth.increment()?;
1492                }
1493                let val_ref = self.dev_class.get_or_insert_with(|| {
1494                    fidl::new_empty!(
1495                        fidl::encoding::Endpoint<
1496                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1497                        >,
1498                        fidl::encoding::DefaultFuchsiaResourceDialect
1499                    )
1500                });
1501                fidl::decode!(
1502                    fidl::encoding::Endpoint<
1503                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1504                    >,
1505                    fidl::encoding::DefaultFuchsiaResourceDialect,
1506                    val_ref,
1507                    decoder,
1508                    inner_offset,
1509                    inner_depth
1510                )?;
1511                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1512                {
1513                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1514                }
1515                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1516                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1517                }
1518            }
1519
1520            next_offset += envelope_size;
1521            _next_ordinal_to_read += 1;
1522            if next_offset >= end_offset {
1523                return Ok(());
1524            }
1525
1526            // Decode unknown envelopes for gaps in ordinals.
1527            while _next_ordinal_to_read < 3 {
1528                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1529                _next_ordinal_to_read += 1;
1530                next_offset += envelope_size;
1531            }
1532
1533            let next_out_of_line = decoder.next_out_of_line();
1534            let handles_before = decoder.remaining_handles();
1535            if let Some((inlined, num_bytes, num_handles)) =
1536                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1537            {
1538                let member_inline_size = <fidl_fuchsia_driver_test::RealmArgs as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1539                if inlined != (member_inline_size <= 4) {
1540                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1541                }
1542                let inner_offset;
1543                let mut inner_depth = depth.clone();
1544                if inlined {
1545                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1546                    inner_offset = next_offset;
1547                } else {
1548                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1549                    inner_depth.increment()?;
1550                }
1551                let val_ref = self.driver_test_realm_start_args.get_or_insert_with(|| {
1552                    fidl::new_empty!(
1553                        fidl_fuchsia_driver_test::RealmArgs,
1554                        fidl::encoding::DefaultFuchsiaResourceDialect
1555                    )
1556                });
1557                fidl::decode!(
1558                    fidl_fuchsia_driver_test::RealmArgs,
1559                    fidl::encoding::DefaultFuchsiaResourceDialect,
1560                    val_ref,
1561                    decoder,
1562                    inner_offset,
1563                    inner_depth
1564                )?;
1565                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1566                {
1567                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1568                }
1569                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1570                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1571                }
1572            }
1573
1574            next_offset += envelope_size;
1575
1576            // Decode the remaining unknown envelopes.
1577            while next_offset < end_offset {
1578                _next_ordinal_to_read += 1;
1579                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1580                next_offset += envelope_size;
1581            }
1582
1583            Ok(())
1584        }
1585    }
1586
1587    impl DriversOnly {
1588        #[inline(always)]
1589        fn max_ordinal_present(&self) -> u64 {
1590            if let Some(_) = self.driver_config {
1591                return 1;
1592            }
1593            0
1594        }
1595    }
1596
1597    impl fidl::encoding::ResourceTypeMarker for DriversOnly {
1598        type Borrowed<'a> = &'a mut Self;
1599        fn take_or_borrow<'a>(
1600            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1601        ) -> Self::Borrowed<'a> {
1602            value
1603        }
1604    }
1605
1606    unsafe impl fidl::encoding::TypeMarker for DriversOnly {
1607        type Owned = Self;
1608
1609        #[inline(always)]
1610        fn inline_align(_context: fidl::encoding::Context) -> usize {
1611            8
1612        }
1613
1614        #[inline(always)]
1615        fn inline_size(_context: fidl::encoding::Context) -> usize {
1616            16
1617        }
1618    }
1619
1620    unsafe impl fidl::encoding::Encode<DriversOnly, fidl::encoding::DefaultFuchsiaResourceDialect>
1621        for &mut DriversOnly
1622    {
1623        unsafe fn encode(
1624            self,
1625            encoder: &mut fidl::encoding::Encoder<
1626                '_,
1627                fidl::encoding::DefaultFuchsiaResourceDialect,
1628            >,
1629            offset: usize,
1630            mut depth: fidl::encoding::Depth,
1631        ) -> fidl::Result<()> {
1632            encoder.debug_check_bounds::<DriversOnly>(offset);
1633            // Vector header
1634            let max_ordinal: u64 = self.max_ordinal_present();
1635            encoder.write_num(max_ordinal, offset);
1636            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1637            // Calling encoder.out_of_line_offset(0) is not allowed.
1638            if max_ordinal == 0 {
1639                return Ok(());
1640            }
1641            depth.increment()?;
1642            let envelope_size = 8;
1643            let bytes_len = max_ordinal as usize * envelope_size;
1644            #[allow(unused_variables)]
1645            let offset = encoder.out_of_line_offset(bytes_len);
1646            let mut _prev_end_offset: usize = 0;
1647            if 1 > max_ordinal {
1648                return Ok(());
1649            }
1650
1651            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1652            // are envelope_size bytes.
1653            let cur_offset: usize = (1 - 1) * envelope_size;
1654
1655            // Zero reserved fields.
1656            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1657
1658            // Safety:
1659            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1660            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1661            //   envelope_size bytes, there is always sufficient room.
1662            fidl::encoding::encode_in_envelope_optional::<
1663                DriverConfig,
1664                fidl::encoding::DefaultFuchsiaResourceDialect,
1665            >(
1666                self.driver_config
1667                    .as_mut()
1668                    .map(<DriverConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1669                encoder,
1670                offset + cur_offset,
1671                depth,
1672            )?;
1673
1674            _prev_end_offset = cur_offset + envelope_size;
1675
1676            Ok(())
1677        }
1678    }
1679
1680    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DriversOnly {
1681        #[inline(always)]
1682        fn new_empty() -> Self {
1683            Self::default()
1684        }
1685
1686        unsafe fn decode(
1687            &mut self,
1688            decoder: &mut fidl::encoding::Decoder<
1689                '_,
1690                fidl::encoding::DefaultFuchsiaResourceDialect,
1691            >,
1692            offset: usize,
1693            mut depth: fidl::encoding::Depth,
1694        ) -> fidl::Result<()> {
1695            decoder.debug_check_bounds::<Self>(offset);
1696            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1697                None => return Err(fidl::Error::NotNullable),
1698                Some(len) => len,
1699            };
1700            // Calling decoder.out_of_line_offset(0) is not allowed.
1701            if len == 0 {
1702                return Ok(());
1703            };
1704            depth.increment()?;
1705            let envelope_size = 8;
1706            let bytes_len = len * envelope_size;
1707            let offset = decoder.out_of_line_offset(bytes_len)?;
1708            // Decode the envelope for each type.
1709            let mut _next_ordinal_to_read = 0;
1710            let mut next_offset = offset;
1711            let end_offset = offset + bytes_len;
1712            _next_ordinal_to_read += 1;
1713            if next_offset >= end_offset {
1714                return Ok(());
1715            }
1716
1717            // Decode unknown envelopes for gaps in ordinals.
1718            while _next_ordinal_to_read < 1 {
1719                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1720                _next_ordinal_to_read += 1;
1721                next_offset += envelope_size;
1722            }
1723
1724            let next_out_of_line = decoder.next_out_of_line();
1725            let handles_before = decoder.remaining_handles();
1726            if let Some((inlined, num_bytes, num_handles)) =
1727                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1728            {
1729                let member_inline_size =
1730                    <DriverConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1731                if inlined != (member_inline_size <= 4) {
1732                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1733                }
1734                let inner_offset;
1735                let mut inner_depth = depth.clone();
1736                if inlined {
1737                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1738                    inner_offset = next_offset;
1739                } else {
1740                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1741                    inner_depth.increment()?;
1742                }
1743                let val_ref = self.driver_config.get_or_insert_with(|| {
1744                    fidl::new_empty!(DriverConfig, fidl::encoding::DefaultFuchsiaResourceDialect)
1745                });
1746                fidl::decode!(
1747                    DriverConfig,
1748                    fidl::encoding::DefaultFuchsiaResourceDialect,
1749                    val_ref,
1750                    decoder,
1751                    inner_offset,
1752                    inner_depth
1753                )?;
1754                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1755                {
1756                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1757                }
1758                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1759                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1760                }
1761            }
1762
1763            next_offset += envelope_size;
1764
1765            // Decode the remaining unknown envelopes.
1766            while next_offset < end_offset {
1767                _next_ordinal_to_read += 1;
1768                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1769                next_offset += envelope_size;
1770            }
1771
1772            Ok(())
1773        }
1774    }
1775
1776    impl RealmOptions {
1777        #[inline(always)]
1778        fn max_ordinal_present(&self) -> u64 {
1779            if let Some(_) = self.topology {
1780                return 3;
1781            }
1782            if let Some(_) = self.wlan_config {
1783                return 2;
1784            }
1785            if let Some(_) = self.devfs_server_end {
1786                return 1;
1787            }
1788            0
1789        }
1790    }
1791
1792    impl fidl::encoding::ResourceTypeMarker for RealmOptions {
1793        type Borrowed<'a> = &'a mut Self;
1794        fn take_or_borrow<'a>(
1795            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1796        ) -> Self::Borrowed<'a> {
1797            value
1798        }
1799    }
1800
1801    unsafe impl fidl::encoding::TypeMarker for RealmOptions {
1802        type Owned = Self;
1803
1804        #[inline(always)]
1805        fn inline_align(_context: fidl::encoding::Context) -> usize {
1806            8
1807        }
1808
1809        #[inline(always)]
1810        fn inline_size(_context: fidl::encoding::Context) -> usize {
1811            16
1812        }
1813    }
1814
1815    unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1816        for &mut RealmOptions
1817    {
1818        unsafe fn encode(
1819            self,
1820            encoder: &mut fidl::encoding::Encoder<
1821                '_,
1822                fidl::encoding::DefaultFuchsiaResourceDialect,
1823            >,
1824            offset: usize,
1825            mut depth: fidl::encoding::Depth,
1826        ) -> fidl::Result<()> {
1827            encoder.debug_check_bounds::<RealmOptions>(offset);
1828            // Vector header
1829            let max_ordinal: u64 = self.max_ordinal_present();
1830            encoder.write_num(max_ordinal, offset);
1831            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1832            // Calling encoder.out_of_line_offset(0) is not allowed.
1833            if max_ordinal == 0 {
1834                return Ok(());
1835            }
1836            depth.increment()?;
1837            let envelope_size = 8;
1838            let bytes_len = max_ordinal as usize * envelope_size;
1839            #[allow(unused_variables)]
1840            let offset = encoder.out_of_line_offset(bytes_len);
1841            let mut _prev_end_offset: usize = 0;
1842            if 1 > max_ordinal {
1843                return Ok(());
1844            }
1845
1846            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1847            // are envelope_size bytes.
1848            let cur_offset: usize = (1 - 1) * envelope_size;
1849
1850            // Zero reserved fields.
1851            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1852
1853            // Safety:
1854            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1855            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1856            //   envelope_size bytes, there is always sufficient room.
1857            fidl::encoding::encode_in_envelope_optional::<
1858                fidl::encoding::Endpoint<
1859                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1860                >,
1861                fidl::encoding::DefaultFuchsiaResourceDialect,
1862            >(
1863                self.devfs_server_end.as_mut().map(
1864                    <fidl::encoding::Endpoint<
1865                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1866                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1867                ),
1868                encoder,
1869                offset + cur_offset,
1870                depth,
1871            )?;
1872
1873            _prev_end_offset = cur_offset + envelope_size;
1874            if 2 > max_ordinal {
1875                return Ok(());
1876            }
1877
1878            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1879            // are envelope_size bytes.
1880            let cur_offset: usize = (2 - 1) * envelope_size;
1881
1882            // Zero reserved fields.
1883            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1884
1885            // Safety:
1886            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1887            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1888            //   envelope_size bytes, there is always sufficient room.
1889            fidl::encoding::encode_in_envelope_optional::<
1890                WlanConfig,
1891                fidl::encoding::DefaultFuchsiaResourceDialect,
1892            >(
1893                self.wlan_config
1894                    .as_mut()
1895                    .map(<WlanConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1896                encoder,
1897                offset + cur_offset,
1898                depth,
1899            )?;
1900
1901            _prev_end_offset = cur_offset + envelope_size;
1902            if 3 > max_ordinal {
1903                return Ok(());
1904            }
1905
1906            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1907            // are envelope_size bytes.
1908            let cur_offset: usize = (3 - 1) * envelope_size;
1909
1910            // Zero reserved fields.
1911            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1912
1913            // Safety:
1914            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1915            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1916            //   envelope_size bytes, there is always sufficient room.
1917            fidl::encoding::encode_in_envelope_optional::<
1918                Topology,
1919                fidl::encoding::DefaultFuchsiaResourceDialect,
1920            >(
1921                self.topology
1922                    .as_mut()
1923                    .map(<Topology as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1924                encoder,
1925                offset + cur_offset,
1926                depth,
1927            )?;
1928
1929            _prev_end_offset = cur_offset + envelope_size;
1930
1931            Ok(())
1932        }
1933    }
1934
1935    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
1936        #[inline(always)]
1937        fn new_empty() -> Self {
1938            Self::default()
1939        }
1940
1941        unsafe fn decode(
1942            &mut self,
1943            decoder: &mut fidl::encoding::Decoder<
1944                '_,
1945                fidl::encoding::DefaultFuchsiaResourceDialect,
1946            >,
1947            offset: usize,
1948            mut depth: fidl::encoding::Depth,
1949        ) -> fidl::Result<()> {
1950            decoder.debug_check_bounds::<Self>(offset);
1951            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1952                None => return Err(fidl::Error::NotNullable),
1953                Some(len) => len,
1954            };
1955            // Calling decoder.out_of_line_offset(0) is not allowed.
1956            if len == 0 {
1957                return Ok(());
1958            };
1959            depth.increment()?;
1960            let envelope_size = 8;
1961            let bytes_len = len * envelope_size;
1962            let offset = decoder.out_of_line_offset(bytes_len)?;
1963            // Decode the envelope for each type.
1964            let mut _next_ordinal_to_read = 0;
1965            let mut next_offset = offset;
1966            let end_offset = offset + bytes_len;
1967            _next_ordinal_to_read += 1;
1968            if next_offset >= end_offset {
1969                return Ok(());
1970            }
1971
1972            // Decode unknown envelopes for gaps in ordinals.
1973            while _next_ordinal_to_read < 1 {
1974                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1975                _next_ordinal_to_read += 1;
1976                next_offset += envelope_size;
1977            }
1978
1979            let next_out_of_line = decoder.next_out_of_line();
1980            let handles_before = decoder.remaining_handles();
1981            if let Some((inlined, num_bytes, num_handles)) =
1982                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1983            {
1984                let member_inline_size = <fidl::encoding::Endpoint<
1985                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1986                > as fidl::encoding::TypeMarker>::inline_size(
1987                    decoder.context
1988                );
1989                if inlined != (member_inline_size <= 4) {
1990                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1991                }
1992                let inner_offset;
1993                let mut inner_depth = depth.clone();
1994                if inlined {
1995                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1996                    inner_offset = next_offset;
1997                } else {
1998                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1999                    inner_depth.increment()?;
2000                }
2001                let val_ref = self.devfs_server_end.get_or_insert_with(|| {
2002                    fidl::new_empty!(
2003                        fidl::encoding::Endpoint<
2004                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2005                        >,
2006                        fidl::encoding::DefaultFuchsiaResourceDialect
2007                    )
2008                });
2009                fidl::decode!(
2010                    fidl::encoding::Endpoint<
2011                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2012                    >,
2013                    fidl::encoding::DefaultFuchsiaResourceDialect,
2014                    val_ref,
2015                    decoder,
2016                    inner_offset,
2017                    inner_depth
2018                )?;
2019                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2020                {
2021                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2022                }
2023                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2024                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2025                }
2026            }
2027
2028            next_offset += envelope_size;
2029            _next_ordinal_to_read += 1;
2030            if next_offset >= end_offset {
2031                return Ok(());
2032            }
2033
2034            // Decode unknown envelopes for gaps in ordinals.
2035            while _next_ordinal_to_read < 2 {
2036                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2037                _next_ordinal_to_read += 1;
2038                next_offset += envelope_size;
2039            }
2040
2041            let next_out_of_line = decoder.next_out_of_line();
2042            let handles_before = decoder.remaining_handles();
2043            if let Some((inlined, num_bytes, num_handles)) =
2044                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2045            {
2046                let member_inline_size =
2047                    <WlanConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2048                if inlined != (member_inline_size <= 4) {
2049                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2050                }
2051                let inner_offset;
2052                let mut inner_depth = depth.clone();
2053                if inlined {
2054                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2055                    inner_offset = next_offset;
2056                } else {
2057                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2058                    inner_depth.increment()?;
2059                }
2060                let val_ref = self.wlan_config.get_or_insert_with(|| {
2061                    fidl::new_empty!(WlanConfig, fidl::encoding::DefaultFuchsiaResourceDialect)
2062                });
2063                fidl::decode!(
2064                    WlanConfig,
2065                    fidl::encoding::DefaultFuchsiaResourceDialect,
2066                    val_ref,
2067                    decoder,
2068                    inner_offset,
2069                    inner_depth
2070                )?;
2071                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2072                {
2073                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2074                }
2075                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2076                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2077                }
2078            }
2079
2080            next_offset += envelope_size;
2081            _next_ordinal_to_read += 1;
2082            if next_offset >= end_offset {
2083                return Ok(());
2084            }
2085
2086            // Decode unknown envelopes for gaps in ordinals.
2087            while _next_ordinal_to_read < 3 {
2088                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2089                _next_ordinal_to_read += 1;
2090                next_offset += envelope_size;
2091            }
2092
2093            let next_out_of_line = decoder.next_out_of_line();
2094            let handles_before = decoder.remaining_handles();
2095            if let Some((inlined, num_bytes, num_handles)) =
2096                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2097            {
2098                let member_inline_size =
2099                    <Topology as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2100                if inlined != (member_inline_size <= 4) {
2101                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2102                }
2103                let inner_offset;
2104                let mut inner_depth = depth.clone();
2105                if inlined {
2106                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2107                    inner_offset = next_offset;
2108                } else {
2109                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2110                    inner_depth.increment()?;
2111                }
2112                let val_ref = self.topology.get_or_insert_with(|| {
2113                    fidl::new_empty!(Topology, fidl::encoding::DefaultFuchsiaResourceDialect)
2114                });
2115                fidl::decode!(
2116                    Topology,
2117                    fidl::encoding::DefaultFuchsiaResourceDialect,
2118                    val_ref,
2119                    decoder,
2120                    inner_offset,
2121                    inner_depth
2122                )?;
2123                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2124                {
2125                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2126                }
2127                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2128                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2129                }
2130            }
2131
2132            next_offset += envelope_size;
2133
2134            // Decode the remaining unknown envelopes.
2135            while next_offset < end_offset {
2136                _next_ordinal_to_read += 1;
2137                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2138                next_offset += envelope_size;
2139            }
2140
2141            Ok(())
2142        }
2143    }
2144
2145    impl WlanConfig {
2146        #[inline(always)]
2147        fn max_ordinal_present(&self) -> u64 {
2148            if let Some(_) = self.name {
2149                return 3;
2150            }
2151            if let Some(_) = self.with_regulatory_region {
2152                return 2;
2153            }
2154            if let Some(_) = self.use_legacy_privacy {
2155                return 1;
2156            }
2157            0
2158        }
2159    }
2160
2161    impl fidl::encoding::ResourceTypeMarker for WlanConfig {
2162        type Borrowed<'a> = &'a mut Self;
2163        fn take_or_borrow<'a>(
2164            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2165        ) -> Self::Borrowed<'a> {
2166            value
2167        }
2168    }
2169
2170    unsafe impl fidl::encoding::TypeMarker for WlanConfig {
2171        type Owned = Self;
2172
2173        #[inline(always)]
2174        fn inline_align(_context: fidl::encoding::Context) -> usize {
2175            8
2176        }
2177
2178        #[inline(always)]
2179        fn inline_size(_context: fidl::encoding::Context) -> usize {
2180            16
2181        }
2182    }
2183
2184    unsafe impl fidl::encoding::Encode<WlanConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
2185        for &mut WlanConfig
2186    {
2187        unsafe fn encode(
2188            self,
2189            encoder: &mut fidl::encoding::Encoder<
2190                '_,
2191                fidl::encoding::DefaultFuchsiaResourceDialect,
2192            >,
2193            offset: usize,
2194            mut depth: fidl::encoding::Depth,
2195        ) -> fidl::Result<()> {
2196            encoder.debug_check_bounds::<WlanConfig>(offset);
2197            // Vector header
2198            let max_ordinal: u64 = self.max_ordinal_present();
2199            encoder.write_num(max_ordinal, offset);
2200            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2201            // Calling encoder.out_of_line_offset(0) is not allowed.
2202            if max_ordinal == 0 {
2203                return Ok(());
2204            }
2205            depth.increment()?;
2206            let envelope_size = 8;
2207            let bytes_len = max_ordinal as usize * envelope_size;
2208            #[allow(unused_variables)]
2209            let offset = encoder.out_of_line_offset(bytes_len);
2210            let mut _prev_end_offset: usize = 0;
2211            if 1 > max_ordinal {
2212                return Ok(());
2213            }
2214
2215            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2216            // are envelope_size bytes.
2217            let cur_offset: usize = (1 - 1) * envelope_size;
2218
2219            // Zero reserved fields.
2220            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2221
2222            // Safety:
2223            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2224            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2225            //   envelope_size bytes, there is always sufficient room.
2226            fidl::encoding::encode_in_envelope_optional::<
2227                bool,
2228                fidl::encoding::DefaultFuchsiaResourceDialect,
2229            >(
2230                self.use_legacy_privacy
2231                    .as_ref()
2232                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2233                encoder,
2234                offset + cur_offset,
2235                depth,
2236            )?;
2237
2238            _prev_end_offset = cur_offset + envelope_size;
2239            if 2 > max_ordinal {
2240                return Ok(());
2241            }
2242
2243            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2244            // are envelope_size bytes.
2245            let cur_offset: usize = (2 - 1) * envelope_size;
2246
2247            // Zero reserved fields.
2248            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2249
2250            // Safety:
2251            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2252            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2253            //   envelope_size bytes, there is always sufficient room.
2254            fidl::encoding::encode_in_envelope_optional::<
2255                bool,
2256                fidl::encoding::DefaultFuchsiaResourceDialect,
2257            >(
2258                self.with_regulatory_region
2259                    .as_ref()
2260                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2261                encoder,
2262                offset + cur_offset,
2263                depth,
2264            )?;
2265
2266            _prev_end_offset = cur_offset + envelope_size;
2267            if 3 > max_ordinal {
2268                return Ok(());
2269            }
2270
2271            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2272            // are envelope_size bytes.
2273            let cur_offset: usize = (3 - 1) * envelope_size;
2274
2275            // Zero reserved fields.
2276            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2277
2278            // Safety:
2279            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2280            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2281            //   envelope_size bytes, there is always sufficient room.
2282            fidl::encoding::encode_in_envelope_optional::<
2283                fidl::encoding::UnboundedString,
2284                fidl::encoding::DefaultFuchsiaResourceDialect,
2285            >(
2286                self.name.as_ref().map(
2287                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
2288                ),
2289                encoder,
2290                offset + cur_offset,
2291                depth,
2292            )?;
2293
2294            _prev_end_offset = cur_offset + envelope_size;
2295
2296            Ok(())
2297        }
2298    }
2299
2300    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for WlanConfig {
2301        #[inline(always)]
2302        fn new_empty() -> Self {
2303            Self::default()
2304        }
2305
2306        unsafe fn decode(
2307            &mut self,
2308            decoder: &mut fidl::encoding::Decoder<
2309                '_,
2310                fidl::encoding::DefaultFuchsiaResourceDialect,
2311            >,
2312            offset: usize,
2313            mut depth: fidl::encoding::Depth,
2314        ) -> fidl::Result<()> {
2315            decoder.debug_check_bounds::<Self>(offset);
2316            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2317                None => return Err(fidl::Error::NotNullable),
2318                Some(len) => len,
2319            };
2320            // Calling decoder.out_of_line_offset(0) is not allowed.
2321            if len == 0 {
2322                return Ok(());
2323            };
2324            depth.increment()?;
2325            let envelope_size = 8;
2326            let bytes_len = len * envelope_size;
2327            let offset = decoder.out_of_line_offset(bytes_len)?;
2328            // Decode the envelope for each type.
2329            let mut _next_ordinal_to_read = 0;
2330            let mut next_offset = offset;
2331            let end_offset = offset + bytes_len;
2332            _next_ordinal_to_read += 1;
2333            if next_offset >= end_offset {
2334                return Ok(());
2335            }
2336
2337            // Decode unknown envelopes for gaps in ordinals.
2338            while _next_ordinal_to_read < 1 {
2339                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2340                _next_ordinal_to_read += 1;
2341                next_offset += envelope_size;
2342            }
2343
2344            let next_out_of_line = decoder.next_out_of_line();
2345            let handles_before = decoder.remaining_handles();
2346            if let Some((inlined, num_bytes, num_handles)) =
2347                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2348            {
2349                let member_inline_size =
2350                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2351                if inlined != (member_inline_size <= 4) {
2352                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2353                }
2354                let inner_offset;
2355                let mut inner_depth = depth.clone();
2356                if inlined {
2357                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2358                    inner_offset = next_offset;
2359                } else {
2360                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2361                    inner_depth.increment()?;
2362                }
2363                let val_ref = self.use_legacy_privacy.get_or_insert_with(|| {
2364                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2365                });
2366                fidl::decode!(
2367                    bool,
2368                    fidl::encoding::DefaultFuchsiaResourceDialect,
2369                    val_ref,
2370                    decoder,
2371                    inner_offset,
2372                    inner_depth
2373                )?;
2374                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2375                {
2376                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2377                }
2378                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2379                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2380                }
2381            }
2382
2383            next_offset += envelope_size;
2384            _next_ordinal_to_read += 1;
2385            if next_offset >= end_offset {
2386                return Ok(());
2387            }
2388
2389            // Decode unknown envelopes for gaps in ordinals.
2390            while _next_ordinal_to_read < 2 {
2391                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2392                _next_ordinal_to_read += 1;
2393                next_offset += envelope_size;
2394            }
2395
2396            let next_out_of_line = decoder.next_out_of_line();
2397            let handles_before = decoder.remaining_handles();
2398            if let Some((inlined, num_bytes, num_handles)) =
2399                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2400            {
2401                let member_inline_size =
2402                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2403                if inlined != (member_inline_size <= 4) {
2404                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2405                }
2406                let inner_offset;
2407                let mut inner_depth = depth.clone();
2408                if inlined {
2409                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2410                    inner_offset = next_offset;
2411                } else {
2412                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2413                    inner_depth.increment()?;
2414                }
2415                let val_ref = self.with_regulatory_region.get_or_insert_with(|| {
2416                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2417                });
2418                fidl::decode!(
2419                    bool,
2420                    fidl::encoding::DefaultFuchsiaResourceDialect,
2421                    val_ref,
2422                    decoder,
2423                    inner_offset,
2424                    inner_depth
2425                )?;
2426                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2427                {
2428                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2429                }
2430                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2431                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2432                }
2433            }
2434
2435            next_offset += envelope_size;
2436            _next_ordinal_to_read += 1;
2437            if next_offset >= end_offset {
2438                return Ok(());
2439            }
2440
2441            // Decode unknown envelopes for gaps in ordinals.
2442            while _next_ordinal_to_read < 3 {
2443                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2444                _next_ordinal_to_read += 1;
2445                next_offset += envelope_size;
2446            }
2447
2448            let next_out_of_line = decoder.next_out_of_line();
2449            let handles_before = decoder.remaining_handles();
2450            if let Some((inlined, num_bytes, num_handles)) =
2451                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2452            {
2453                let member_inline_size =
2454                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
2455                        decoder.context,
2456                    );
2457                if inlined != (member_inline_size <= 4) {
2458                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2459                }
2460                let inner_offset;
2461                let mut inner_depth = depth.clone();
2462                if inlined {
2463                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2464                    inner_offset = next_offset;
2465                } else {
2466                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2467                    inner_depth.increment()?;
2468                }
2469                let val_ref = self.name.get_or_insert_with(|| {
2470                    fidl::new_empty!(
2471                        fidl::encoding::UnboundedString,
2472                        fidl::encoding::DefaultFuchsiaResourceDialect
2473                    )
2474                });
2475                fidl::decode!(
2476                    fidl::encoding::UnboundedString,
2477                    fidl::encoding::DefaultFuchsiaResourceDialect,
2478                    val_ref,
2479                    decoder,
2480                    inner_offset,
2481                    inner_depth
2482                )?;
2483                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2484                {
2485                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2486                }
2487                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2488                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2489                }
2490            }
2491
2492            next_offset += envelope_size;
2493
2494            // Decode the remaining unknown envelopes.
2495            while next_offset < end_offset {
2496                _next_ordinal_to_read += 1;
2497                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2498                next_offset += envelope_size;
2499            }
2500
2501            Ok(())
2502        }
2503    }
2504
2505    impl fidl::encoding::ResourceTypeMarker for Topology {
2506        type Borrowed<'a> = &'a mut Self;
2507        fn take_or_borrow<'a>(
2508            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2509        ) -> Self::Borrowed<'a> {
2510            value
2511        }
2512    }
2513
2514    unsafe impl fidl::encoding::TypeMarker for Topology {
2515        type Owned = Self;
2516
2517        #[inline(always)]
2518        fn inline_align(_context: fidl::encoding::Context) -> usize {
2519            8
2520        }
2521
2522        #[inline(always)]
2523        fn inline_size(_context: fidl::encoding::Context) -> usize {
2524            16
2525        }
2526    }
2527
2528    unsafe impl fidl::encoding::Encode<Topology, fidl::encoding::DefaultFuchsiaResourceDialect>
2529        for &mut Topology
2530    {
2531        #[inline]
2532        unsafe fn encode(
2533            self,
2534            encoder: &mut fidl::encoding::Encoder<
2535                '_,
2536                fidl::encoding::DefaultFuchsiaResourceDialect,
2537            >,
2538            offset: usize,
2539            _depth: fidl::encoding::Depth,
2540        ) -> fidl::Result<()> {
2541            encoder.debug_check_bounds::<Topology>(offset);
2542            encoder.write_num::<u64>(self.ordinal(), offset);
2543            match self {
2544                Topology::DriversOnly(ref mut val) => fidl::encoding::encode_in_envelope::<
2545                    DriversOnly,
2546                    fidl::encoding::DefaultFuchsiaResourceDialect,
2547                >(
2548                    <DriversOnly as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2549                    encoder,
2550                    offset + 8,
2551                    _depth,
2552                ),
2553                Topology::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2554            }
2555        }
2556    }
2557
2558    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Topology {
2559        #[inline(always)]
2560        fn new_empty() -> Self {
2561            Self::__SourceBreaking { unknown_ordinal: 0 }
2562        }
2563
2564        #[inline]
2565        unsafe fn decode(
2566            &mut self,
2567            decoder: &mut fidl::encoding::Decoder<
2568                '_,
2569                fidl::encoding::DefaultFuchsiaResourceDialect,
2570            >,
2571            offset: usize,
2572            mut depth: fidl::encoding::Depth,
2573        ) -> fidl::Result<()> {
2574            decoder.debug_check_bounds::<Self>(offset);
2575            #[allow(unused_variables)]
2576            let next_out_of_line = decoder.next_out_of_line();
2577            let handles_before = decoder.remaining_handles();
2578            let (ordinal, inlined, num_bytes, num_handles) =
2579                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2580
2581            let member_inline_size = match ordinal {
2582                1 => <DriversOnly as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2583                0 => return Err(fidl::Error::UnknownUnionTag),
2584                _ => num_bytes as usize,
2585            };
2586
2587            if inlined != (member_inline_size <= 4) {
2588                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2589            }
2590            let _inner_offset;
2591            if inlined {
2592                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2593                _inner_offset = offset + 8;
2594            } else {
2595                depth.increment()?;
2596                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2597            }
2598            match ordinal {
2599                1 => {
2600                    #[allow(irrefutable_let_patterns)]
2601                    if let Topology::DriversOnly(_) = self {
2602                        // Do nothing, read the value into the object
2603                    } else {
2604                        // Initialize `self` to the right variant
2605                        *self = Topology::DriversOnly(fidl::new_empty!(
2606                            DriversOnly,
2607                            fidl::encoding::DefaultFuchsiaResourceDialect
2608                        ));
2609                    }
2610                    #[allow(irrefutable_let_patterns)]
2611                    if let Topology::DriversOnly(ref mut val) = self {
2612                        fidl::decode!(
2613                            DriversOnly,
2614                            fidl::encoding::DefaultFuchsiaResourceDialect,
2615                            val,
2616                            decoder,
2617                            _inner_offset,
2618                            depth
2619                        )?;
2620                    } else {
2621                        unreachable!()
2622                    }
2623                }
2624                #[allow(deprecated)]
2625                ordinal => {
2626                    for _ in 0..num_handles {
2627                        decoder.drop_next_handle()?;
2628                    }
2629                    *self = Topology::__SourceBreaking { unknown_ordinal: ordinal };
2630                }
2631            }
2632            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2633                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2634            }
2635            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2636                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2637            }
2638            Ok(())
2639        }
2640    }
2641}