Skip to main content

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