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