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 RealmFactoryControlHandle {
589    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
590        self.inner.shutdown_with_epitaph(status.into())
591    }
592}
593
594impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
595    fn shutdown(&self) {
596        self.inner.shutdown()
597    }
598
599    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
600        self.inner.shutdown_with_epitaph(status)
601    }
602
603    fn is_closed(&self) -> bool {
604        self.inner.channel().is_closed()
605    }
606    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
607        self.inner.channel().on_closed()
608    }
609
610    #[cfg(target_os = "fuchsia")]
611    fn signal_peer(
612        &self,
613        clear_mask: zx::Signals,
614        set_mask: zx::Signals,
615    ) -> Result<(), zx_status::Status> {
616        use fidl::Peered;
617        self.inner.channel().signal_peer(clear_mask, set_mask)
618    }
619}
620
621impl RealmFactoryControlHandle {}
622
623#[must_use = "FIDL methods require a response to be sent"]
624#[derive(Debug)]
625pub struct RealmFactoryCreateRealmResponder {
626    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
627    tx_id: u32,
628}
629
630/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
631/// if the responder is dropped without sending a response, so that the client
632/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
633impl std::ops::Drop for RealmFactoryCreateRealmResponder {
634    fn drop(&mut self) {
635        self.control_handle.shutdown();
636        // Safety: drops once, never accessed again
637        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
638    }
639}
640
641impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
642    type ControlHandle = RealmFactoryControlHandle;
643
644    fn control_handle(&self) -> &RealmFactoryControlHandle {
645        &self.control_handle
646    }
647
648    fn drop_without_shutdown(mut self) {
649        // Safety: drops once, never accessed again due to mem::forget
650        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
651        // Prevent Drop from running (which would shut down the channel)
652        std::mem::forget(self);
653    }
654}
655
656impl RealmFactoryCreateRealmResponder {
657    /// Sends a response to the FIDL transaction.
658    ///
659    /// Sets the channel to shutdown if an error occurs.
660    pub fn send(
661        self,
662        mut result: Result<&CreateRealmResponse, fidl_fuchsia_testing_harness::OperationError>,
663    ) -> Result<(), fidl::Error> {
664        let _result = self.send_raw(result);
665        if _result.is_err() {
666            self.control_handle.shutdown();
667        }
668        self.drop_without_shutdown();
669        _result
670    }
671
672    /// Similar to "send" but does not shutdown the channel if an error occurs.
673    pub fn send_no_shutdown_on_err(
674        self,
675        mut result: Result<&CreateRealmResponse, fidl_fuchsia_testing_harness::OperationError>,
676    ) -> Result<(), fidl::Error> {
677        let _result = self.send_raw(result);
678        self.drop_without_shutdown();
679        _result
680    }
681
682    fn send_raw(
683        &self,
684        mut result: Result<&CreateRealmResponse, fidl_fuchsia_testing_harness::OperationError>,
685    ) -> Result<(), fidl::Error> {
686        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
687            CreateRealmResponse,
688            fidl_fuchsia_testing_harness::OperationError,
689        >>(
690            fidl::encoding::FlexibleResult::new(result),
691            self.tx_id,
692            0x51aac08d328c3ae4,
693            fidl::encoding::DynamicFlags::FLEXIBLE,
694        )
695    }
696}
697
698mod internal {
699    use super::*;
700
701    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
702        type Borrowed<'a> = &'a mut Self;
703        fn take_or_borrow<'a>(
704            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
705        ) -> Self::Borrowed<'a> {
706            value
707        }
708    }
709
710    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
711        type Owned = Self;
712
713        #[inline(always)]
714        fn inline_align(_context: fidl::encoding::Context) -> usize {
715            8
716        }
717
718        #[inline(always)]
719        fn inline_size(_context: fidl::encoding::Context) -> usize {
720            24
721        }
722    }
723
724    unsafe impl
725        fidl::encoding::Encode<
726            RealmFactoryCreateRealmRequest,
727            fidl::encoding::DefaultFuchsiaResourceDialect,
728        > for &mut RealmFactoryCreateRealmRequest
729    {
730        #[inline]
731        unsafe fn encode(
732            self,
733            encoder: &mut fidl::encoding::Encoder<
734                '_,
735                fidl::encoding::DefaultFuchsiaResourceDialect,
736            >,
737            offset: usize,
738            _depth: fidl::encoding::Depth,
739        ) -> fidl::Result<()> {
740            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
741            // Delegate to tuple encoding.
742            fidl::encoding::Encode::<
743                RealmFactoryCreateRealmRequest,
744                fidl::encoding::DefaultFuchsiaResourceDialect,
745            >::encode(
746                (
747                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
748                        &mut self.options,
749                    ),
750                    <fidl::encoding::HandleType<
751                        fidl::EventPair,
752                        { fidl::ObjectType::EVENTPAIR.into_raw() },
753                        2147483648,
754                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
755                        &mut self.dictionary
756                    ),
757                ),
758                encoder,
759                offset,
760                _depth,
761            )
762        }
763    }
764    unsafe impl<
765        T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
766        T1: fidl::encoding::Encode<
767                fidl::encoding::HandleType<
768                    fidl::EventPair,
769                    { fidl::ObjectType::EVENTPAIR.into_raw() },
770                    2147483648,
771                >,
772                fidl::encoding::DefaultFuchsiaResourceDialect,
773            >,
774    >
775        fidl::encoding::Encode<
776            RealmFactoryCreateRealmRequest,
777            fidl::encoding::DefaultFuchsiaResourceDialect,
778        > for (T0, T1)
779    {
780        #[inline]
781        unsafe fn encode(
782            self,
783            encoder: &mut fidl::encoding::Encoder<
784                '_,
785                fidl::encoding::DefaultFuchsiaResourceDialect,
786            >,
787            offset: usize,
788            depth: fidl::encoding::Depth,
789        ) -> fidl::Result<()> {
790            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
791            // Zero out padding regions. There's no need to apply masks
792            // because the unmasked parts will be overwritten by fields.
793            unsafe {
794                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
795                (ptr as *mut u64).write_unaligned(0);
796            }
797            // Write the fields.
798            self.0.encode(encoder, offset + 0, depth)?;
799            self.1.encode(encoder, offset + 16, depth)?;
800            Ok(())
801        }
802    }
803
804    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
805        for RealmFactoryCreateRealmRequest
806    {
807        #[inline(always)]
808        fn new_empty() -> Self {
809            Self {
810                options: fidl::new_empty!(
811                    RealmOptions,
812                    fidl::encoding::DefaultFuchsiaResourceDialect
813                ),
814                dictionary: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
815            }
816        }
817
818        #[inline]
819        unsafe fn decode(
820            &mut self,
821            decoder: &mut fidl::encoding::Decoder<
822                '_,
823                fidl::encoding::DefaultFuchsiaResourceDialect,
824            >,
825            offset: usize,
826            _depth: fidl::encoding::Depth,
827        ) -> fidl::Result<()> {
828            decoder.debug_check_bounds::<Self>(offset);
829            // Verify that padding bytes are zero.
830            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
831            let padval = unsafe { (ptr as *const u64).read_unaligned() };
832            let mask = 0xffffffff00000000u64;
833            let maskedval = padval & mask;
834            if maskedval != 0 {
835                return Err(fidl::Error::NonZeroPadding {
836                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
837                });
838            }
839            fidl::decode!(
840                RealmOptions,
841                fidl::encoding::DefaultFuchsiaResourceDialect,
842                &mut self.options,
843                decoder,
844                offset + 0,
845                _depth
846            )?;
847            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.dictionary, decoder, offset + 16, _depth)?;
848            Ok(())
849        }
850    }
851
852    impl DriverConfig {
853        #[inline(always)]
854        fn max_ordinal_present(&self) -> u64 {
855            if let Some(_) = self.driver_test_realm_start_args {
856                return 3;
857            }
858            if let Some(_) = self.dev_class {
859                return 2;
860            }
861            if let Some(_) = self.dev_topological {
862                return 1;
863            }
864            0
865        }
866    }
867
868    impl fidl::encoding::ResourceTypeMarker for DriverConfig {
869        type Borrowed<'a> = &'a mut Self;
870        fn take_or_borrow<'a>(
871            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
872        ) -> Self::Borrowed<'a> {
873            value
874        }
875    }
876
877    unsafe impl fidl::encoding::TypeMarker for DriverConfig {
878        type Owned = Self;
879
880        #[inline(always)]
881        fn inline_align(_context: fidl::encoding::Context) -> usize {
882            8
883        }
884
885        #[inline(always)]
886        fn inline_size(_context: fidl::encoding::Context) -> usize {
887            16
888        }
889    }
890
891    unsafe impl fidl::encoding::Encode<DriverConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
892        for &mut DriverConfig
893    {
894        unsafe fn encode(
895            self,
896            encoder: &mut fidl::encoding::Encoder<
897                '_,
898                fidl::encoding::DefaultFuchsiaResourceDialect,
899            >,
900            offset: usize,
901            mut depth: fidl::encoding::Depth,
902        ) -> fidl::Result<()> {
903            encoder.debug_check_bounds::<DriverConfig>(offset);
904            // Vector header
905            let max_ordinal: u64 = self.max_ordinal_present();
906            encoder.write_num(max_ordinal, offset);
907            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
908            // Calling encoder.out_of_line_offset(0) is not allowed.
909            if max_ordinal == 0 {
910                return Ok(());
911            }
912            depth.increment()?;
913            let envelope_size = 8;
914            let bytes_len = max_ordinal as usize * envelope_size;
915            #[allow(unused_variables)]
916            let offset = encoder.out_of_line_offset(bytes_len);
917            let mut _prev_end_offset: usize = 0;
918            if 1 > max_ordinal {
919                return Ok(());
920            }
921
922            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
923            // are envelope_size bytes.
924            let cur_offset: usize = (1 - 1) * envelope_size;
925
926            // Zero reserved fields.
927            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
928
929            // Safety:
930            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
931            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
932            //   envelope_size bytes, there is always sufficient room.
933            fidl::encoding::encode_in_envelope_optional::<
934                fidl::encoding::Endpoint<
935                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
936                >,
937                fidl::encoding::DefaultFuchsiaResourceDialect,
938            >(
939                self.dev_topological.as_mut().map(
940                    <fidl::encoding::Endpoint<
941                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
942                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
943                ),
944                encoder,
945                offset + cur_offset,
946                depth,
947            )?;
948
949            _prev_end_offset = cur_offset + envelope_size;
950            if 2 > max_ordinal {
951                return Ok(());
952            }
953
954            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
955            // are envelope_size bytes.
956            let cur_offset: usize = (2 - 1) * envelope_size;
957
958            // Zero reserved fields.
959            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
960
961            // Safety:
962            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
963            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
964            //   envelope_size bytes, there is always sufficient room.
965            fidl::encoding::encode_in_envelope_optional::<
966                fidl::encoding::Endpoint<
967                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
968                >,
969                fidl::encoding::DefaultFuchsiaResourceDialect,
970            >(
971                self.dev_class.as_mut().map(
972                    <fidl::encoding::Endpoint<
973                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
974                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
975                ),
976                encoder,
977                offset + cur_offset,
978                depth,
979            )?;
980
981            _prev_end_offset = cur_offset + envelope_size;
982            if 3 > max_ordinal {
983                return Ok(());
984            }
985
986            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
987            // are envelope_size bytes.
988            let cur_offset: usize = (3 - 1) * envelope_size;
989
990            // Zero reserved fields.
991            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
992
993            // Safety:
994            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
995            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
996            //   envelope_size bytes, there is always sufficient room.
997            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_driver_test::RealmArgs, fidl::encoding::DefaultFuchsiaResourceDialect>(
998            self.driver_test_realm_start_args.as_mut().map(<fidl_fuchsia_driver_test::RealmArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
999            encoder, offset + cur_offset, depth
1000        )?;
1001
1002            _prev_end_offset = cur_offset + envelope_size;
1003
1004            Ok(())
1005        }
1006    }
1007
1008    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DriverConfig {
1009        #[inline(always)]
1010        fn new_empty() -> Self {
1011            Self::default()
1012        }
1013
1014        unsafe fn decode(
1015            &mut self,
1016            decoder: &mut fidl::encoding::Decoder<
1017                '_,
1018                fidl::encoding::DefaultFuchsiaResourceDialect,
1019            >,
1020            offset: usize,
1021            mut depth: fidl::encoding::Depth,
1022        ) -> fidl::Result<()> {
1023            decoder.debug_check_bounds::<Self>(offset);
1024            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1025                None => return Err(fidl::Error::NotNullable),
1026                Some(len) => len,
1027            };
1028            // Calling decoder.out_of_line_offset(0) is not allowed.
1029            if len == 0 {
1030                return Ok(());
1031            };
1032            depth.increment()?;
1033            let envelope_size = 8;
1034            let bytes_len = len * envelope_size;
1035            let offset = decoder.out_of_line_offset(bytes_len)?;
1036            // Decode the envelope for each type.
1037            let mut _next_ordinal_to_read = 0;
1038            let mut next_offset = offset;
1039            let end_offset = offset + bytes_len;
1040            _next_ordinal_to_read += 1;
1041            if next_offset >= end_offset {
1042                return Ok(());
1043            }
1044
1045            // Decode unknown envelopes for gaps in ordinals.
1046            while _next_ordinal_to_read < 1 {
1047                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1048                _next_ordinal_to_read += 1;
1049                next_offset += envelope_size;
1050            }
1051
1052            let next_out_of_line = decoder.next_out_of_line();
1053            let handles_before = decoder.remaining_handles();
1054            if let Some((inlined, num_bytes, num_handles)) =
1055                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1056            {
1057                let member_inline_size = <fidl::encoding::Endpoint<
1058                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1059                > as fidl::encoding::TypeMarker>::inline_size(
1060                    decoder.context
1061                );
1062                if inlined != (member_inline_size <= 4) {
1063                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1064                }
1065                let inner_offset;
1066                let mut inner_depth = depth.clone();
1067                if inlined {
1068                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1069                    inner_offset = next_offset;
1070                } else {
1071                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1072                    inner_depth.increment()?;
1073                }
1074                let val_ref = self.dev_topological.get_or_insert_with(|| {
1075                    fidl::new_empty!(
1076                        fidl::encoding::Endpoint<
1077                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1078                        >,
1079                        fidl::encoding::DefaultFuchsiaResourceDialect
1080                    )
1081                });
1082                fidl::decode!(
1083                    fidl::encoding::Endpoint<
1084                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1085                    >,
1086                    fidl::encoding::DefaultFuchsiaResourceDialect,
1087                    val_ref,
1088                    decoder,
1089                    inner_offset,
1090                    inner_depth
1091                )?;
1092                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1093                {
1094                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1095                }
1096                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1097                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1098                }
1099            }
1100
1101            next_offset += envelope_size;
1102            _next_ordinal_to_read += 1;
1103            if next_offset >= end_offset {
1104                return Ok(());
1105            }
1106
1107            // Decode unknown envelopes for gaps in ordinals.
1108            while _next_ordinal_to_read < 2 {
1109                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1110                _next_ordinal_to_read += 1;
1111                next_offset += envelope_size;
1112            }
1113
1114            let next_out_of_line = decoder.next_out_of_line();
1115            let handles_before = decoder.remaining_handles();
1116            if let Some((inlined, num_bytes, num_handles)) =
1117                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1118            {
1119                let member_inline_size = <fidl::encoding::Endpoint<
1120                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1121                > as fidl::encoding::TypeMarker>::inline_size(
1122                    decoder.context
1123                );
1124                if inlined != (member_inline_size <= 4) {
1125                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1126                }
1127                let inner_offset;
1128                let mut inner_depth = depth.clone();
1129                if inlined {
1130                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1131                    inner_offset = next_offset;
1132                } else {
1133                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1134                    inner_depth.increment()?;
1135                }
1136                let val_ref = self.dev_class.get_or_insert_with(|| {
1137                    fidl::new_empty!(
1138                        fidl::encoding::Endpoint<
1139                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1140                        >,
1141                        fidl::encoding::DefaultFuchsiaResourceDialect
1142                    )
1143                });
1144                fidl::decode!(
1145                    fidl::encoding::Endpoint<
1146                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1147                    >,
1148                    fidl::encoding::DefaultFuchsiaResourceDialect,
1149                    val_ref,
1150                    decoder,
1151                    inner_offset,
1152                    inner_depth
1153                )?;
1154                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1155                {
1156                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1157                }
1158                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1159                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1160                }
1161            }
1162
1163            next_offset += envelope_size;
1164            _next_ordinal_to_read += 1;
1165            if next_offset >= end_offset {
1166                return Ok(());
1167            }
1168
1169            // Decode unknown envelopes for gaps in ordinals.
1170            while _next_ordinal_to_read < 3 {
1171                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1172                _next_ordinal_to_read += 1;
1173                next_offset += envelope_size;
1174            }
1175
1176            let next_out_of_line = decoder.next_out_of_line();
1177            let handles_before = decoder.remaining_handles();
1178            if let Some((inlined, num_bytes, num_handles)) =
1179                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1180            {
1181                let member_inline_size = <fidl_fuchsia_driver_test::RealmArgs as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1182                if inlined != (member_inline_size <= 4) {
1183                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1184                }
1185                let inner_offset;
1186                let mut inner_depth = depth.clone();
1187                if inlined {
1188                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1189                    inner_offset = next_offset;
1190                } else {
1191                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1192                    inner_depth.increment()?;
1193                }
1194                let val_ref = self.driver_test_realm_start_args.get_or_insert_with(|| {
1195                    fidl::new_empty!(
1196                        fidl_fuchsia_driver_test::RealmArgs,
1197                        fidl::encoding::DefaultFuchsiaResourceDialect
1198                    )
1199                });
1200                fidl::decode!(
1201                    fidl_fuchsia_driver_test::RealmArgs,
1202                    fidl::encoding::DefaultFuchsiaResourceDialect,
1203                    val_ref,
1204                    decoder,
1205                    inner_offset,
1206                    inner_depth
1207                )?;
1208                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1209                {
1210                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1211                }
1212                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1213                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1214                }
1215            }
1216
1217            next_offset += envelope_size;
1218
1219            // Decode the remaining unknown envelopes.
1220            while next_offset < end_offset {
1221                _next_ordinal_to_read += 1;
1222                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1223                next_offset += envelope_size;
1224            }
1225
1226            Ok(())
1227        }
1228    }
1229
1230    impl DriversOnly {
1231        #[inline(always)]
1232        fn max_ordinal_present(&self) -> u64 {
1233            if let Some(_) = self.driver_config {
1234                return 1;
1235            }
1236            0
1237        }
1238    }
1239
1240    impl fidl::encoding::ResourceTypeMarker for DriversOnly {
1241        type Borrowed<'a> = &'a mut Self;
1242        fn take_or_borrow<'a>(
1243            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1244        ) -> Self::Borrowed<'a> {
1245            value
1246        }
1247    }
1248
1249    unsafe impl fidl::encoding::TypeMarker for DriversOnly {
1250        type Owned = Self;
1251
1252        #[inline(always)]
1253        fn inline_align(_context: fidl::encoding::Context) -> usize {
1254            8
1255        }
1256
1257        #[inline(always)]
1258        fn inline_size(_context: fidl::encoding::Context) -> usize {
1259            16
1260        }
1261    }
1262
1263    unsafe impl fidl::encoding::Encode<DriversOnly, fidl::encoding::DefaultFuchsiaResourceDialect>
1264        for &mut DriversOnly
1265    {
1266        unsafe fn encode(
1267            self,
1268            encoder: &mut fidl::encoding::Encoder<
1269                '_,
1270                fidl::encoding::DefaultFuchsiaResourceDialect,
1271            >,
1272            offset: usize,
1273            mut depth: fidl::encoding::Depth,
1274        ) -> fidl::Result<()> {
1275            encoder.debug_check_bounds::<DriversOnly>(offset);
1276            // Vector header
1277            let max_ordinal: u64 = self.max_ordinal_present();
1278            encoder.write_num(max_ordinal, offset);
1279            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1280            // Calling encoder.out_of_line_offset(0) is not allowed.
1281            if max_ordinal == 0 {
1282                return Ok(());
1283            }
1284            depth.increment()?;
1285            let envelope_size = 8;
1286            let bytes_len = max_ordinal as usize * envelope_size;
1287            #[allow(unused_variables)]
1288            let offset = encoder.out_of_line_offset(bytes_len);
1289            let mut _prev_end_offset: usize = 0;
1290            if 1 > max_ordinal {
1291                return Ok(());
1292            }
1293
1294            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1295            // are envelope_size bytes.
1296            let cur_offset: usize = (1 - 1) * envelope_size;
1297
1298            // Zero reserved fields.
1299            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1300
1301            // Safety:
1302            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1303            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1304            //   envelope_size bytes, there is always sufficient room.
1305            fidl::encoding::encode_in_envelope_optional::<
1306                DriverConfig,
1307                fidl::encoding::DefaultFuchsiaResourceDialect,
1308            >(
1309                self.driver_config
1310                    .as_mut()
1311                    .map(<DriverConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1312                encoder,
1313                offset + cur_offset,
1314                depth,
1315            )?;
1316
1317            _prev_end_offset = cur_offset + envelope_size;
1318
1319            Ok(())
1320        }
1321    }
1322
1323    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DriversOnly {
1324        #[inline(always)]
1325        fn new_empty() -> Self {
1326            Self::default()
1327        }
1328
1329        unsafe fn decode(
1330            &mut self,
1331            decoder: &mut fidl::encoding::Decoder<
1332                '_,
1333                fidl::encoding::DefaultFuchsiaResourceDialect,
1334            >,
1335            offset: usize,
1336            mut depth: fidl::encoding::Depth,
1337        ) -> fidl::Result<()> {
1338            decoder.debug_check_bounds::<Self>(offset);
1339            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1340                None => return Err(fidl::Error::NotNullable),
1341                Some(len) => len,
1342            };
1343            // Calling decoder.out_of_line_offset(0) is not allowed.
1344            if len == 0 {
1345                return Ok(());
1346            };
1347            depth.increment()?;
1348            let envelope_size = 8;
1349            let bytes_len = len * envelope_size;
1350            let offset = decoder.out_of_line_offset(bytes_len)?;
1351            // Decode the envelope for each type.
1352            let mut _next_ordinal_to_read = 0;
1353            let mut next_offset = offset;
1354            let end_offset = offset + bytes_len;
1355            _next_ordinal_to_read += 1;
1356            if next_offset >= end_offset {
1357                return Ok(());
1358            }
1359
1360            // Decode unknown envelopes for gaps in ordinals.
1361            while _next_ordinal_to_read < 1 {
1362                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1363                _next_ordinal_to_read += 1;
1364                next_offset += envelope_size;
1365            }
1366
1367            let next_out_of_line = decoder.next_out_of_line();
1368            let handles_before = decoder.remaining_handles();
1369            if let Some((inlined, num_bytes, num_handles)) =
1370                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1371            {
1372                let member_inline_size =
1373                    <DriverConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1374                if inlined != (member_inline_size <= 4) {
1375                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1376                }
1377                let inner_offset;
1378                let mut inner_depth = depth.clone();
1379                if inlined {
1380                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1381                    inner_offset = next_offset;
1382                } else {
1383                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1384                    inner_depth.increment()?;
1385                }
1386                let val_ref = self.driver_config.get_or_insert_with(|| {
1387                    fidl::new_empty!(DriverConfig, fidl::encoding::DefaultFuchsiaResourceDialect)
1388                });
1389                fidl::decode!(
1390                    DriverConfig,
1391                    fidl::encoding::DefaultFuchsiaResourceDialect,
1392                    val_ref,
1393                    decoder,
1394                    inner_offset,
1395                    inner_depth
1396                )?;
1397                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1398                {
1399                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1400                }
1401                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1402                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1403                }
1404            }
1405
1406            next_offset += envelope_size;
1407
1408            // Decode the remaining unknown envelopes.
1409            while next_offset < end_offset {
1410                _next_ordinal_to_read += 1;
1411                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1412                next_offset += envelope_size;
1413            }
1414
1415            Ok(())
1416        }
1417    }
1418
1419    impl RealmOptions {
1420        #[inline(always)]
1421        fn max_ordinal_present(&self) -> u64 {
1422            if let Some(_) = self.topology {
1423                return 3;
1424            }
1425            if let Some(_) = self.wlan_config {
1426                return 2;
1427            }
1428            if let Some(_) = self.devfs_server_end {
1429                return 1;
1430            }
1431            0
1432        }
1433    }
1434
1435    impl fidl::encoding::ResourceTypeMarker for RealmOptions {
1436        type Borrowed<'a> = &'a mut Self;
1437        fn take_or_borrow<'a>(
1438            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1439        ) -> Self::Borrowed<'a> {
1440            value
1441        }
1442    }
1443
1444    unsafe impl fidl::encoding::TypeMarker for RealmOptions {
1445        type Owned = Self;
1446
1447        #[inline(always)]
1448        fn inline_align(_context: fidl::encoding::Context) -> usize {
1449            8
1450        }
1451
1452        #[inline(always)]
1453        fn inline_size(_context: fidl::encoding::Context) -> usize {
1454            16
1455        }
1456    }
1457
1458    unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1459        for &mut RealmOptions
1460    {
1461        unsafe fn encode(
1462            self,
1463            encoder: &mut fidl::encoding::Encoder<
1464                '_,
1465                fidl::encoding::DefaultFuchsiaResourceDialect,
1466            >,
1467            offset: usize,
1468            mut depth: fidl::encoding::Depth,
1469        ) -> fidl::Result<()> {
1470            encoder.debug_check_bounds::<RealmOptions>(offset);
1471            // Vector header
1472            let max_ordinal: u64 = self.max_ordinal_present();
1473            encoder.write_num(max_ordinal, offset);
1474            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1475            // Calling encoder.out_of_line_offset(0) is not allowed.
1476            if max_ordinal == 0 {
1477                return Ok(());
1478            }
1479            depth.increment()?;
1480            let envelope_size = 8;
1481            let bytes_len = max_ordinal as usize * envelope_size;
1482            #[allow(unused_variables)]
1483            let offset = encoder.out_of_line_offset(bytes_len);
1484            let mut _prev_end_offset: usize = 0;
1485            if 1 > max_ordinal {
1486                return Ok(());
1487            }
1488
1489            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1490            // are envelope_size bytes.
1491            let cur_offset: usize = (1 - 1) * envelope_size;
1492
1493            // Zero reserved fields.
1494            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1495
1496            // Safety:
1497            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1498            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1499            //   envelope_size bytes, there is always sufficient room.
1500            fidl::encoding::encode_in_envelope_optional::<
1501                fidl::encoding::Endpoint<
1502                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1503                >,
1504                fidl::encoding::DefaultFuchsiaResourceDialect,
1505            >(
1506                self.devfs_server_end.as_mut().map(
1507                    <fidl::encoding::Endpoint<
1508                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1509                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1510                ),
1511                encoder,
1512                offset + cur_offset,
1513                depth,
1514            )?;
1515
1516            _prev_end_offset = cur_offset + envelope_size;
1517            if 2 > max_ordinal {
1518                return Ok(());
1519            }
1520
1521            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1522            // are envelope_size bytes.
1523            let cur_offset: usize = (2 - 1) * envelope_size;
1524
1525            // Zero reserved fields.
1526            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1527
1528            // Safety:
1529            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1530            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1531            //   envelope_size bytes, there is always sufficient room.
1532            fidl::encoding::encode_in_envelope_optional::<
1533                WlanConfig,
1534                fidl::encoding::DefaultFuchsiaResourceDialect,
1535            >(
1536                self.wlan_config
1537                    .as_mut()
1538                    .map(<WlanConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1539                encoder,
1540                offset + cur_offset,
1541                depth,
1542            )?;
1543
1544            _prev_end_offset = cur_offset + envelope_size;
1545            if 3 > max_ordinal {
1546                return Ok(());
1547            }
1548
1549            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1550            // are envelope_size bytes.
1551            let cur_offset: usize = (3 - 1) * envelope_size;
1552
1553            // Zero reserved fields.
1554            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1555
1556            // Safety:
1557            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1558            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1559            //   envelope_size bytes, there is always sufficient room.
1560            fidl::encoding::encode_in_envelope_optional::<
1561                Topology,
1562                fidl::encoding::DefaultFuchsiaResourceDialect,
1563            >(
1564                self.topology
1565                    .as_mut()
1566                    .map(<Topology as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1567                encoder,
1568                offset + cur_offset,
1569                depth,
1570            )?;
1571
1572            _prev_end_offset = cur_offset + envelope_size;
1573
1574            Ok(())
1575        }
1576    }
1577
1578    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
1579        #[inline(always)]
1580        fn new_empty() -> Self {
1581            Self::default()
1582        }
1583
1584        unsafe fn decode(
1585            &mut self,
1586            decoder: &mut fidl::encoding::Decoder<
1587                '_,
1588                fidl::encoding::DefaultFuchsiaResourceDialect,
1589            >,
1590            offset: usize,
1591            mut depth: fidl::encoding::Depth,
1592        ) -> fidl::Result<()> {
1593            decoder.debug_check_bounds::<Self>(offset);
1594            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1595                None => return Err(fidl::Error::NotNullable),
1596                Some(len) => len,
1597            };
1598            // Calling decoder.out_of_line_offset(0) is not allowed.
1599            if len == 0 {
1600                return Ok(());
1601            };
1602            depth.increment()?;
1603            let envelope_size = 8;
1604            let bytes_len = len * envelope_size;
1605            let offset = decoder.out_of_line_offset(bytes_len)?;
1606            // Decode the envelope for each type.
1607            let mut _next_ordinal_to_read = 0;
1608            let mut next_offset = offset;
1609            let end_offset = offset + bytes_len;
1610            _next_ordinal_to_read += 1;
1611            if next_offset >= end_offset {
1612                return Ok(());
1613            }
1614
1615            // Decode unknown envelopes for gaps in ordinals.
1616            while _next_ordinal_to_read < 1 {
1617                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1618                _next_ordinal_to_read += 1;
1619                next_offset += envelope_size;
1620            }
1621
1622            let next_out_of_line = decoder.next_out_of_line();
1623            let handles_before = decoder.remaining_handles();
1624            if let Some((inlined, num_bytes, num_handles)) =
1625                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1626            {
1627                let member_inline_size = <fidl::encoding::Endpoint<
1628                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1629                > as fidl::encoding::TypeMarker>::inline_size(
1630                    decoder.context
1631                );
1632                if inlined != (member_inline_size <= 4) {
1633                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1634                }
1635                let inner_offset;
1636                let mut inner_depth = depth.clone();
1637                if inlined {
1638                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1639                    inner_offset = next_offset;
1640                } else {
1641                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1642                    inner_depth.increment()?;
1643                }
1644                let val_ref = self.devfs_server_end.get_or_insert_with(|| {
1645                    fidl::new_empty!(
1646                        fidl::encoding::Endpoint<
1647                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1648                        >,
1649                        fidl::encoding::DefaultFuchsiaResourceDialect
1650                    )
1651                });
1652                fidl::decode!(
1653                    fidl::encoding::Endpoint<
1654                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1655                    >,
1656                    fidl::encoding::DefaultFuchsiaResourceDialect,
1657                    val_ref,
1658                    decoder,
1659                    inner_offset,
1660                    inner_depth
1661                )?;
1662                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1663                {
1664                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1665                }
1666                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1667                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1668                }
1669            }
1670
1671            next_offset += envelope_size;
1672            _next_ordinal_to_read += 1;
1673            if next_offset >= end_offset {
1674                return Ok(());
1675            }
1676
1677            // Decode unknown envelopes for gaps in ordinals.
1678            while _next_ordinal_to_read < 2 {
1679                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1680                _next_ordinal_to_read += 1;
1681                next_offset += envelope_size;
1682            }
1683
1684            let next_out_of_line = decoder.next_out_of_line();
1685            let handles_before = decoder.remaining_handles();
1686            if let Some((inlined, num_bytes, num_handles)) =
1687                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1688            {
1689                let member_inline_size =
1690                    <WlanConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1691                if inlined != (member_inline_size <= 4) {
1692                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1693                }
1694                let inner_offset;
1695                let mut inner_depth = depth.clone();
1696                if inlined {
1697                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1698                    inner_offset = next_offset;
1699                } else {
1700                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1701                    inner_depth.increment()?;
1702                }
1703                let val_ref = self.wlan_config.get_or_insert_with(|| {
1704                    fidl::new_empty!(WlanConfig, fidl::encoding::DefaultFuchsiaResourceDialect)
1705                });
1706                fidl::decode!(
1707                    WlanConfig,
1708                    fidl::encoding::DefaultFuchsiaResourceDialect,
1709                    val_ref,
1710                    decoder,
1711                    inner_offset,
1712                    inner_depth
1713                )?;
1714                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1715                {
1716                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1717                }
1718                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1719                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1720                }
1721            }
1722
1723            next_offset += envelope_size;
1724            _next_ordinal_to_read += 1;
1725            if next_offset >= end_offset {
1726                return Ok(());
1727            }
1728
1729            // Decode unknown envelopes for gaps in ordinals.
1730            while _next_ordinal_to_read < 3 {
1731                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1732                _next_ordinal_to_read += 1;
1733                next_offset += envelope_size;
1734            }
1735
1736            let next_out_of_line = decoder.next_out_of_line();
1737            let handles_before = decoder.remaining_handles();
1738            if let Some((inlined, num_bytes, num_handles)) =
1739                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1740            {
1741                let member_inline_size =
1742                    <Topology as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1743                if inlined != (member_inline_size <= 4) {
1744                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1745                }
1746                let inner_offset;
1747                let mut inner_depth = depth.clone();
1748                if inlined {
1749                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1750                    inner_offset = next_offset;
1751                } else {
1752                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1753                    inner_depth.increment()?;
1754                }
1755                let val_ref = self.topology.get_or_insert_with(|| {
1756                    fidl::new_empty!(Topology, fidl::encoding::DefaultFuchsiaResourceDialect)
1757                });
1758                fidl::decode!(
1759                    Topology,
1760                    fidl::encoding::DefaultFuchsiaResourceDialect,
1761                    val_ref,
1762                    decoder,
1763                    inner_offset,
1764                    inner_depth
1765                )?;
1766                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1767                {
1768                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1769                }
1770                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1771                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1772                }
1773            }
1774
1775            next_offset += envelope_size;
1776
1777            // Decode the remaining unknown envelopes.
1778            while next_offset < end_offset {
1779                _next_ordinal_to_read += 1;
1780                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1781                next_offset += envelope_size;
1782            }
1783
1784            Ok(())
1785        }
1786    }
1787
1788    impl WlanConfig {
1789        #[inline(always)]
1790        fn max_ordinal_present(&self) -> u64 {
1791            if let Some(_) = self.with_policy {
1792                return 5;
1793            }
1794            if let Some(_) = self.trace_manager_hermeticity {
1795                return 4;
1796            }
1797            if let Some(_) = self.name {
1798                return 3;
1799            }
1800            if let Some(_) = self.with_regulatory_region {
1801                return 2;
1802            }
1803            if let Some(_) = self.use_legacy_privacy {
1804                return 1;
1805            }
1806            0
1807        }
1808    }
1809
1810    impl fidl::encoding::ResourceTypeMarker for WlanConfig {
1811        type Borrowed<'a> = &'a mut Self;
1812        fn take_or_borrow<'a>(
1813            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1814        ) -> Self::Borrowed<'a> {
1815            value
1816        }
1817    }
1818
1819    unsafe impl fidl::encoding::TypeMarker for WlanConfig {
1820        type Owned = Self;
1821
1822        #[inline(always)]
1823        fn inline_align(_context: fidl::encoding::Context) -> usize {
1824            8
1825        }
1826
1827        #[inline(always)]
1828        fn inline_size(_context: fidl::encoding::Context) -> usize {
1829            16
1830        }
1831    }
1832
1833    unsafe impl fidl::encoding::Encode<WlanConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
1834        for &mut WlanConfig
1835    {
1836        unsafe fn encode(
1837            self,
1838            encoder: &mut fidl::encoding::Encoder<
1839                '_,
1840                fidl::encoding::DefaultFuchsiaResourceDialect,
1841            >,
1842            offset: usize,
1843            mut depth: fidl::encoding::Depth,
1844        ) -> fidl::Result<()> {
1845            encoder.debug_check_bounds::<WlanConfig>(offset);
1846            // Vector header
1847            let max_ordinal: u64 = self.max_ordinal_present();
1848            encoder.write_num(max_ordinal, offset);
1849            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1850            // Calling encoder.out_of_line_offset(0) is not allowed.
1851            if max_ordinal == 0 {
1852                return Ok(());
1853            }
1854            depth.increment()?;
1855            let envelope_size = 8;
1856            let bytes_len = max_ordinal as usize * envelope_size;
1857            #[allow(unused_variables)]
1858            let offset = encoder.out_of_line_offset(bytes_len);
1859            let mut _prev_end_offset: usize = 0;
1860            if 1 > max_ordinal {
1861                return Ok(());
1862            }
1863
1864            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1865            // are envelope_size bytes.
1866            let cur_offset: usize = (1 - 1) * envelope_size;
1867
1868            // Zero reserved fields.
1869            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1870
1871            // Safety:
1872            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1873            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1874            //   envelope_size bytes, there is always sufficient room.
1875            fidl::encoding::encode_in_envelope_optional::<
1876                bool,
1877                fidl::encoding::DefaultFuchsiaResourceDialect,
1878            >(
1879                self.use_legacy_privacy
1880                    .as_ref()
1881                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1882                encoder,
1883                offset + cur_offset,
1884                depth,
1885            )?;
1886
1887            _prev_end_offset = cur_offset + envelope_size;
1888            if 2 > max_ordinal {
1889                return Ok(());
1890            }
1891
1892            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1893            // are envelope_size bytes.
1894            let cur_offset: usize = (2 - 1) * envelope_size;
1895
1896            // Zero reserved fields.
1897            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1898
1899            // Safety:
1900            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1901            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1902            //   envelope_size bytes, there is always sufficient room.
1903            fidl::encoding::encode_in_envelope_optional::<
1904                bool,
1905                fidl::encoding::DefaultFuchsiaResourceDialect,
1906            >(
1907                self.with_regulatory_region
1908                    .as_ref()
1909                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1910                encoder,
1911                offset + cur_offset,
1912                depth,
1913            )?;
1914
1915            _prev_end_offset = cur_offset + envelope_size;
1916            if 3 > max_ordinal {
1917                return Ok(());
1918            }
1919
1920            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1921            // are envelope_size bytes.
1922            let cur_offset: usize = (3 - 1) * envelope_size;
1923
1924            // Zero reserved fields.
1925            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1926
1927            // Safety:
1928            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1929            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1930            //   envelope_size bytes, there is always sufficient room.
1931            fidl::encoding::encode_in_envelope_optional::<
1932                fidl::encoding::UnboundedString,
1933                fidl::encoding::DefaultFuchsiaResourceDialect,
1934            >(
1935                self.name.as_ref().map(
1936                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
1937                ),
1938                encoder,
1939                offset + cur_offset,
1940                depth,
1941            )?;
1942
1943            _prev_end_offset = cur_offset + envelope_size;
1944            if 4 > max_ordinal {
1945                return Ok(());
1946            }
1947
1948            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1949            // are envelope_size bytes.
1950            let cur_offset: usize = (4 - 1) * envelope_size;
1951
1952            // Zero reserved fields.
1953            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1954
1955            // Safety:
1956            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1957            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1958            //   envelope_size bytes, there is always sufficient room.
1959            fidl::encoding::encode_in_envelope_optional::<
1960                TraceManagerHermeticity,
1961                fidl::encoding::DefaultFuchsiaResourceDialect,
1962            >(
1963                self.trace_manager_hermeticity
1964                    .as_ref()
1965                    .map(<TraceManagerHermeticity as fidl::encoding::ValueTypeMarker>::borrow),
1966                encoder,
1967                offset + cur_offset,
1968                depth,
1969            )?;
1970
1971            _prev_end_offset = cur_offset + envelope_size;
1972            if 5 > max_ordinal {
1973                return Ok(());
1974            }
1975
1976            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1977            // are envelope_size bytes.
1978            let cur_offset: usize = (5 - 1) * envelope_size;
1979
1980            // Zero reserved fields.
1981            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1982
1983            // Safety:
1984            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1985            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1986            //   envelope_size bytes, there is always sufficient room.
1987            fidl::encoding::encode_in_envelope_optional::<
1988                bool,
1989                fidl::encoding::DefaultFuchsiaResourceDialect,
1990            >(
1991                self.with_policy.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1992                encoder,
1993                offset + cur_offset,
1994                depth,
1995            )?;
1996
1997            _prev_end_offset = cur_offset + envelope_size;
1998
1999            Ok(())
2000        }
2001    }
2002
2003    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for WlanConfig {
2004        #[inline(always)]
2005        fn new_empty() -> Self {
2006            Self::default()
2007        }
2008
2009        unsafe fn decode(
2010            &mut self,
2011            decoder: &mut fidl::encoding::Decoder<
2012                '_,
2013                fidl::encoding::DefaultFuchsiaResourceDialect,
2014            >,
2015            offset: usize,
2016            mut depth: fidl::encoding::Depth,
2017        ) -> fidl::Result<()> {
2018            decoder.debug_check_bounds::<Self>(offset);
2019            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2020                None => return Err(fidl::Error::NotNullable),
2021                Some(len) => len,
2022            };
2023            // Calling decoder.out_of_line_offset(0) is not allowed.
2024            if len == 0 {
2025                return Ok(());
2026            };
2027            depth.increment()?;
2028            let envelope_size = 8;
2029            let bytes_len = len * envelope_size;
2030            let offset = decoder.out_of_line_offset(bytes_len)?;
2031            // Decode the envelope for each type.
2032            let mut _next_ordinal_to_read = 0;
2033            let mut next_offset = offset;
2034            let end_offset = offset + bytes_len;
2035            _next_ordinal_to_read += 1;
2036            if next_offset >= end_offset {
2037                return Ok(());
2038            }
2039
2040            // Decode unknown envelopes for gaps in ordinals.
2041            while _next_ordinal_to_read < 1 {
2042                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2043                _next_ordinal_to_read += 1;
2044                next_offset += envelope_size;
2045            }
2046
2047            let next_out_of_line = decoder.next_out_of_line();
2048            let handles_before = decoder.remaining_handles();
2049            if let Some((inlined, num_bytes, num_handles)) =
2050                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2051            {
2052                let member_inline_size =
2053                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2054                if inlined != (member_inline_size <= 4) {
2055                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2056                }
2057                let inner_offset;
2058                let mut inner_depth = depth.clone();
2059                if inlined {
2060                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2061                    inner_offset = next_offset;
2062                } else {
2063                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2064                    inner_depth.increment()?;
2065                }
2066                let val_ref = self.use_legacy_privacy.get_or_insert_with(|| {
2067                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2068                });
2069                fidl::decode!(
2070                    bool,
2071                    fidl::encoding::DefaultFuchsiaResourceDialect,
2072                    val_ref,
2073                    decoder,
2074                    inner_offset,
2075                    inner_depth
2076                )?;
2077                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2078                {
2079                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2080                }
2081                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2082                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2083                }
2084            }
2085
2086            next_offset += envelope_size;
2087            _next_ordinal_to_read += 1;
2088            if next_offset >= end_offset {
2089                return Ok(());
2090            }
2091
2092            // Decode unknown envelopes for gaps in ordinals.
2093            while _next_ordinal_to_read < 2 {
2094                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2095                _next_ordinal_to_read += 1;
2096                next_offset += envelope_size;
2097            }
2098
2099            let next_out_of_line = decoder.next_out_of_line();
2100            let handles_before = decoder.remaining_handles();
2101            if let Some((inlined, num_bytes, num_handles)) =
2102                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2103            {
2104                let member_inline_size =
2105                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2106                if inlined != (member_inline_size <= 4) {
2107                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2108                }
2109                let inner_offset;
2110                let mut inner_depth = depth.clone();
2111                if inlined {
2112                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2113                    inner_offset = next_offset;
2114                } else {
2115                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2116                    inner_depth.increment()?;
2117                }
2118                let val_ref = self.with_regulatory_region.get_or_insert_with(|| {
2119                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2120                });
2121                fidl::decode!(
2122                    bool,
2123                    fidl::encoding::DefaultFuchsiaResourceDialect,
2124                    val_ref,
2125                    decoder,
2126                    inner_offset,
2127                    inner_depth
2128                )?;
2129                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2130                {
2131                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2132                }
2133                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2134                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2135                }
2136            }
2137
2138            next_offset += envelope_size;
2139            _next_ordinal_to_read += 1;
2140            if next_offset >= end_offset {
2141                return Ok(());
2142            }
2143
2144            // Decode unknown envelopes for gaps in ordinals.
2145            while _next_ordinal_to_read < 3 {
2146                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2147                _next_ordinal_to_read += 1;
2148                next_offset += envelope_size;
2149            }
2150
2151            let next_out_of_line = decoder.next_out_of_line();
2152            let handles_before = decoder.remaining_handles();
2153            if let Some((inlined, num_bytes, num_handles)) =
2154                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2155            {
2156                let member_inline_size =
2157                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
2158                        decoder.context,
2159                    );
2160                if inlined != (member_inline_size <= 4) {
2161                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2162                }
2163                let inner_offset;
2164                let mut inner_depth = depth.clone();
2165                if inlined {
2166                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2167                    inner_offset = next_offset;
2168                } else {
2169                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2170                    inner_depth.increment()?;
2171                }
2172                let val_ref = self.name.get_or_insert_with(|| {
2173                    fidl::new_empty!(
2174                        fidl::encoding::UnboundedString,
2175                        fidl::encoding::DefaultFuchsiaResourceDialect
2176                    )
2177                });
2178                fidl::decode!(
2179                    fidl::encoding::UnboundedString,
2180                    fidl::encoding::DefaultFuchsiaResourceDialect,
2181                    val_ref,
2182                    decoder,
2183                    inner_offset,
2184                    inner_depth
2185                )?;
2186                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2187                {
2188                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2189                }
2190                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2191                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2192                }
2193            }
2194
2195            next_offset += envelope_size;
2196            _next_ordinal_to_read += 1;
2197            if next_offset >= end_offset {
2198                return Ok(());
2199            }
2200
2201            // Decode unknown envelopes for gaps in ordinals.
2202            while _next_ordinal_to_read < 4 {
2203                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2204                _next_ordinal_to_read += 1;
2205                next_offset += envelope_size;
2206            }
2207
2208            let next_out_of_line = decoder.next_out_of_line();
2209            let handles_before = decoder.remaining_handles();
2210            if let Some((inlined, num_bytes, num_handles)) =
2211                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2212            {
2213                let member_inline_size =
2214                    <TraceManagerHermeticity as fidl::encoding::TypeMarker>::inline_size(
2215                        decoder.context,
2216                    );
2217                if inlined != (member_inline_size <= 4) {
2218                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2219                }
2220                let inner_offset;
2221                let mut inner_depth = depth.clone();
2222                if inlined {
2223                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2224                    inner_offset = next_offset;
2225                } else {
2226                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2227                    inner_depth.increment()?;
2228                }
2229                let val_ref = self.trace_manager_hermeticity.get_or_insert_with(|| {
2230                    fidl::new_empty!(
2231                        TraceManagerHermeticity,
2232                        fidl::encoding::DefaultFuchsiaResourceDialect
2233                    )
2234                });
2235                fidl::decode!(
2236                    TraceManagerHermeticity,
2237                    fidl::encoding::DefaultFuchsiaResourceDialect,
2238                    val_ref,
2239                    decoder,
2240                    inner_offset,
2241                    inner_depth
2242                )?;
2243                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2244                {
2245                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2246                }
2247                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2248                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2249                }
2250            }
2251
2252            next_offset += envelope_size;
2253            _next_ordinal_to_read += 1;
2254            if next_offset >= end_offset {
2255                return Ok(());
2256            }
2257
2258            // Decode unknown envelopes for gaps in ordinals.
2259            while _next_ordinal_to_read < 5 {
2260                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2261                _next_ordinal_to_read += 1;
2262                next_offset += envelope_size;
2263            }
2264
2265            let next_out_of_line = decoder.next_out_of_line();
2266            let handles_before = decoder.remaining_handles();
2267            if let Some((inlined, num_bytes, num_handles)) =
2268                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2269            {
2270                let member_inline_size =
2271                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2272                if inlined != (member_inline_size <= 4) {
2273                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2274                }
2275                let inner_offset;
2276                let mut inner_depth = depth.clone();
2277                if inlined {
2278                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2279                    inner_offset = next_offset;
2280                } else {
2281                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2282                    inner_depth.increment()?;
2283                }
2284                let val_ref = self.with_policy.get_or_insert_with(|| {
2285                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2286                });
2287                fidl::decode!(
2288                    bool,
2289                    fidl::encoding::DefaultFuchsiaResourceDialect,
2290                    val_ref,
2291                    decoder,
2292                    inner_offset,
2293                    inner_depth
2294                )?;
2295                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2296                {
2297                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2298                }
2299                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2300                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2301                }
2302            }
2303
2304            next_offset += envelope_size;
2305
2306            // Decode the remaining unknown envelopes.
2307            while next_offset < end_offset {
2308                _next_ordinal_to_read += 1;
2309                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2310                next_offset += envelope_size;
2311            }
2312
2313            Ok(())
2314        }
2315    }
2316
2317    impl fidl::encoding::ResourceTypeMarker for Topology {
2318        type Borrowed<'a> = &'a mut Self;
2319        fn take_or_borrow<'a>(
2320            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2321        ) -> Self::Borrowed<'a> {
2322            value
2323        }
2324    }
2325
2326    unsafe impl fidl::encoding::TypeMarker for Topology {
2327        type Owned = Self;
2328
2329        #[inline(always)]
2330        fn inline_align(_context: fidl::encoding::Context) -> usize {
2331            8
2332        }
2333
2334        #[inline(always)]
2335        fn inline_size(_context: fidl::encoding::Context) -> usize {
2336            16
2337        }
2338    }
2339
2340    unsafe impl fidl::encoding::Encode<Topology, fidl::encoding::DefaultFuchsiaResourceDialect>
2341        for &mut Topology
2342    {
2343        #[inline]
2344        unsafe fn encode(
2345            self,
2346            encoder: &mut fidl::encoding::Encoder<
2347                '_,
2348                fidl::encoding::DefaultFuchsiaResourceDialect,
2349            >,
2350            offset: usize,
2351            _depth: fidl::encoding::Depth,
2352        ) -> fidl::Result<()> {
2353            encoder.debug_check_bounds::<Topology>(offset);
2354            encoder.write_num::<u64>(self.ordinal(), offset);
2355            match self {
2356                Topology::DriversOnly(ref mut val) => fidl::encoding::encode_in_envelope::<
2357                    DriversOnly,
2358                    fidl::encoding::DefaultFuchsiaResourceDialect,
2359                >(
2360                    <DriversOnly as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2361                    encoder,
2362                    offset + 8,
2363                    _depth,
2364                ),
2365                Topology::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2366            }
2367        }
2368    }
2369
2370    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Topology {
2371        #[inline(always)]
2372        fn new_empty() -> Self {
2373            Self::__SourceBreaking { unknown_ordinal: 0 }
2374        }
2375
2376        #[inline]
2377        unsafe fn decode(
2378            &mut self,
2379            decoder: &mut fidl::encoding::Decoder<
2380                '_,
2381                fidl::encoding::DefaultFuchsiaResourceDialect,
2382            >,
2383            offset: usize,
2384            mut depth: fidl::encoding::Depth,
2385        ) -> fidl::Result<()> {
2386            decoder.debug_check_bounds::<Self>(offset);
2387            #[allow(unused_variables)]
2388            let next_out_of_line = decoder.next_out_of_line();
2389            let handles_before = decoder.remaining_handles();
2390            let (ordinal, inlined, num_bytes, num_handles) =
2391                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2392
2393            let member_inline_size = match ordinal {
2394                1 => <DriversOnly as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2395                0 => return Err(fidl::Error::UnknownUnionTag),
2396                _ => num_bytes as usize,
2397            };
2398
2399            if inlined != (member_inline_size <= 4) {
2400                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2401            }
2402            let _inner_offset;
2403            if inlined {
2404                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2405                _inner_offset = offset + 8;
2406            } else {
2407                depth.increment()?;
2408                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2409            }
2410            match ordinal {
2411                1 => {
2412                    #[allow(irrefutable_let_patterns)]
2413                    if let Topology::DriversOnly(_) = self {
2414                        // Do nothing, read the value into the object
2415                    } else {
2416                        // Initialize `self` to the right variant
2417                        *self = Topology::DriversOnly(fidl::new_empty!(
2418                            DriversOnly,
2419                            fidl::encoding::DefaultFuchsiaResourceDialect
2420                        ));
2421                    }
2422                    #[allow(irrefutable_let_patterns)]
2423                    if let Topology::DriversOnly(ref mut val) = self {
2424                        fidl::decode!(
2425                            DriversOnly,
2426                            fidl::encoding::DefaultFuchsiaResourceDialect,
2427                            val,
2428                            decoder,
2429                            _inner_offset,
2430                            depth
2431                        )?;
2432                    } else {
2433                        unreachable!()
2434                    }
2435                }
2436                #[allow(deprecated)]
2437                ordinal => {
2438                    for _ in 0..num_handles {
2439                        decoder.drop_next_handle()?;
2440                    }
2441                    *self = Topology::__SourceBreaking { unknown_ordinal: ordinal };
2442                }
2443            }
2444            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2445                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2446            }
2447            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2448                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2449            }
2450            Ok(())
2451        }
2452    }
2453}