fidl_fuchsia_netemul/
fidl_fuchsia_netemul.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_fuchsia_netemul_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ManagedRealmAddDeviceRequest {
16    pub path: String,
17    pub device: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::DeviceProxy_Marker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ManagedRealmAddDeviceRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct ManagedRealmConnectToProtocolRequest {
27    pub protocol_name: String,
28    pub child_name: Option<String>,
29    pub req: fidl::Channel,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for ManagedRealmConnectToProtocolRequest
34{
35}
36
37#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
38pub struct ManagedRealmGetDevfsRequest {
39    pub devfs: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for ManagedRealmGetDevfsRequest
44{
45}
46
47#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48pub struct ManagedRealmOpenDiagnosticsDirectoryRequest {
49    pub child_name: String,
50    pub directory: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
54    for ManagedRealmOpenDiagnosticsDirectoryRequest
55{
56}
57
58#[derive(Debug, PartialEq)]
59pub struct SandboxCreateRealmRequest {
60    pub realm: fidl::endpoints::ServerEnd<ManagedRealmMarker>,
61    pub options: RealmOptions,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SandboxCreateRealmRequest {}
65
66#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67pub struct SandboxGetNetworkContextRequest {
68    pub network_context:
69        fidl::endpoints::ServerEnd<fidl_fuchsia_netemul_network::NetworkContextMarker>,
70}
71
72impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
73    for SandboxGetNetworkContextRequest
74{
75}
76
77#[derive(Debug, Default, PartialEq)]
78pub struct ChildDef {
79    /// The runtime source for creating this child.
80    ///
81    /// Required.
82    pub source: Option<ChildSource>,
83    /// The name of this child local to its containing realm.
84    ///
85    /// Required.
86    pub name: Option<String>,
87    /// Protocols that this child exposes to the realm.
88    ///
89    /// If not set, interpreted as an empty vector.
90    pub exposes: Option<Vec<String>>,
91    /// Capabilities that this child uses.
92    ///
93    /// If not set, no capabilities will be routed to the component.
94    pub uses: Option<ChildUses>,
95    /// Arguments to be passed to the child at runtime. If
96    /// specified, overrides any arguments specified in the
97    /// manifest.
98    ///
99    /// If not set, the original arguments from the manifest are
100    /// used.
101    pub program_args: Option<Vec<String>>,
102    /// Whether the component should be started eagerly once the
103    /// realm is created.
104    ///
105    /// If not set, interpreted as false.
106    pub eager: Option<bool>,
107    /// Structured configuration values to *override* when launching
108    /// the child.
109    ///
110    /// If not set, interpereted as an empty vector.
111    pub config_values: Option<Vec<ChildConfigValue>>,
112    #[doc(hidden)]
113    pub __source_breaking: fidl::marker::SourceBreaking,
114}
115
116impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ChildDef {}
117
118#[derive(Debug, Default, PartialEq)]
119pub struct InterfaceOptions {
120    /// The name of the interface to be created.
121    ///
122    /// Required.
123    pub name: Option<String>,
124    /// The device port to be installed.
125    ///
126    /// Required.
127    pub device: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>>,
128    /// Whether to disable automatic generation and assignment of link-
129    /// local IPv6 addresses for the interface.
130    ///
131    /// If not set, interpreted as false.
132    pub without_autogenerated_addresses: Option<bool>,
133    /// Static IP addresses to be assigned to the interface.
134    /// Corresponding local subnet routes will also be added to the
135    /// netstack's routing table.
136    ///
137    /// If not set, interpreted as an empty vector.
138    pub static_ips: Option<Vec<fidl_fuchsia_net::Subnet>>,
139    /// The IP address of the default gateway.
140    ///
141    /// If not set, no default route will be added to the netstack.
142    pub gateway: Option<fidl_fuchsia_net::IpAddress>,
143    /// Whether to enable IPv4 forwarding on the interface.
144    ///
145    /// If not set, interpreted as false.
146    pub enable_ipv4_forwarding: Option<bool>,
147    /// Whether to enable IPv6 forwarding on the interface.
148    ///
149    /// If not set, interpreted as false.
150    pub enable_ipv6_forwarding: Option<bool>,
151    /// The maximum number of IPv4 multicast neighbor solicitations.
152    ///
153    /// If not set, uses the system default.
154    pub ipv4_multicast_neighbor_solicitations: Option<u16>,
155    /// The maximum number of IPv6 multicast neighbor solicitations.
156    ///
157    /// If not set, uses the system default.
158    pub ipv6_multicast_neighbor_solicitations: Option<u16>,
159    #[doc(hidden)]
160    pub __source_breaking: fidl::marker::SourceBreaking,
161}
162
163impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for InterfaceOptions {}
164
165#[derive(Debug, Default, PartialEq)]
166pub struct RealmOptions {
167    /// Realm name.
168    ///
169    /// The realm name is used for attribution and debugging purposes.
170    /// It is used to decorate logs that come from its constituent child
171    /// components.
172    ///
173    /// If not set, an automatically-generated name will be used.
174    pub name: Option<String>,
175    /// Child components to dynamically create in this realm.
176    ///
177    /// If not set, interpreted as an empty vector.
178    pub children: Option<Vec<ChildDef>>,
179    #[doc(hidden)]
180    pub __source_breaking: fidl::marker::SourceBreaking,
181}
182
183impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {}
184
185#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
186pub enum ChildSource {
187    /// Spawn a child from a component with the provided URL.
188    Component(String),
189    /// Spawn a mock child which serves its exposed directory
190    /// through the provided handle.
191    Mock(fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>),
192}
193
194impl ChildSource {
195    #[inline]
196    pub fn ordinal(&self) -> u64 {
197        match *self {
198            Self::Component(_) => 1,
199            Self::Mock(_) => 2,
200        }
201    }
202
203    #[deprecated = "Strict unions should not use `is_unknown`"]
204    #[inline]
205    pub fn is_unknown(&self) -> bool {
206        false
207    }
208}
209
210impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ChildSource {}
211
212#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
213pub struct ConfigurableNetstackMarker;
214
215impl fidl::endpoints::ProtocolMarker for ConfigurableNetstackMarker {
216    type Proxy = ConfigurableNetstackProxy;
217    type RequestStream = ConfigurableNetstackRequestStream;
218    #[cfg(target_os = "fuchsia")]
219    type SynchronousProxy = ConfigurableNetstackSynchronousProxy;
220
221    const DEBUG_NAME: &'static str = "fuchsia.netemul.ConfigurableNetstack";
222}
223impl fidl::endpoints::DiscoverableProtocolMarker for ConfigurableNetstackMarker {}
224pub type ConfigurableNetstackConfigureInterfaceResult = Result<(), ConfigurationError>;
225
226pub trait ConfigurableNetstackProxyInterface: Send + Sync {
227    type ConfigureInterfaceResponseFut: std::future::Future<
228            Output = Result<ConfigurableNetstackConfigureInterfaceResult, fidl::Error>,
229        > + Send;
230    fn r#configure_interface(
231        &self,
232        payload: InterfaceOptions,
233    ) -> Self::ConfigureInterfaceResponseFut;
234}
235#[derive(Debug)]
236#[cfg(target_os = "fuchsia")]
237pub struct ConfigurableNetstackSynchronousProxy {
238    client: fidl::client::sync::Client,
239}
240
241#[cfg(target_os = "fuchsia")]
242impl fidl::endpoints::SynchronousProxy for ConfigurableNetstackSynchronousProxy {
243    type Proxy = ConfigurableNetstackProxy;
244    type Protocol = ConfigurableNetstackMarker;
245
246    fn from_channel(inner: fidl::Channel) -> Self {
247        Self::new(inner)
248    }
249
250    fn into_channel(self) -> fidl::Channel {
251        self.client.into_channel()
252    }
253
254    fn as_channel(&self) -> &fidl::Channel {
255        self.client.as_channel()
256    }
257}
258
259#[cfg(target_os = "fuchsia")]
260impl ConfigurableNetstackSynchronousProxy {
261    pub fn new(channel: fidl::Channel) -> Self {
262        let protocol_name =
263            <ConfigurableNetstackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
264        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
265    }
266
267    pub fn into_channel(self) -> fidl::Channel {
268        self.client.into_channel()
269    }
270
271    /// Waits until an event arrives and returns it. It is safe for other
272    /// threads to make concurrent requests while waiting for an event.
273    pub fn wait_for_event(
274        &self,
275        deadline: zx::MonotonicInstant,
276    ) -> Result<ConfigurableNetstackEvent, fidl::Error> {
277        ConfigurableNetstackEvent::decode(self.client.wait_for_event(deadline)?)
278    }
279
280    /// Installs a device in the netstack with the provided configuration.
281    ///
282    /// + request `options` configuration options on the interface.
283    ///
284    /// * error `INVALID_ARGS` if `options` is invalid, as validated by the
285    ///     configurable-netstack.
286    /// * error `REJECTED_BY_NETSTACK` if an error is returned from an operation
287    ///     on the netstack, e.g. attempting to add an invalid route.
288    /// * error `INTERNAL` if an unexpected error is encountered that is not
289    ///     caused by the client, e.g. an error communicating with the netstack.
290    pub fn r#configure_interface(
291        &self,
292        mut payload: InterfaceOptions,
293        ___deadline: zx::MonotonicInstant,
294    ) -> Result<ConfigurableNetstackConfigureInterfaceResult, fidl::Error> {
295        let _response = self.client.send_query::<InterfaceOptions, fidl::encoding::ResultType<
296            fidl::encoding::EmptyStruct,
297            ConfigurationError,
298        >>(
299            &mut payload,
300            0x64db8deb981ee49,
301            fidl::encoding::DynamicFlags::empty(),
302            ___deadline,
303        )?;
304        Ok(_response.map(|x| x))
305    }
306}
307
308#[derive(Debug, Clone)]
309pub struct ConfigurableNetstackProxy {
310    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
311}
312
313impl fidl::endpoints::Proxy for ConfigurableNetstackProxy {
314    type Protocol = ConfigurableNetstackMarker;
315
316    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
317        Self::new(inner)
318    }
319
320    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
321        self.client.into_channel().map_err(|client| Self { client })
322    }
323
324    fn as_channel(&self) -> &::fidl::AsyncChannel {
325        self.client.as_channel()
326    }
327}
328
329impl ConfigurableNetstackProxy {
330    /// Create a new Proxy for fuchsia.netemul/ConfigurableNetstack.
331    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
332        let protocol_name =
333            <ConfigurableNetstackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
334        Self { client: fidl::client::Client::new(channel, protocol_name) }
335    }
336
337    /// Get a Stream of events from the remote end of the protocol.
338    ///
339    /// # Panics
340    ///
341    /// Panics if the event stream was already taken.
342    pub fn take_event_stream(&self) -> ConfigurableNetstackEventStream {
343        ConfigurableNetstackEventStream { event_receiver: self.client.take_event_receiver() }
344    }
345
346    /// Installs a device in the netstack with the provided configuration.
347    ///
348    /// + request `options` configuration options on the interface.
349    ///
350    /// * error `INVALID_ARGS` if `options` is invalid, as validated by the
351    ///     configurable-netstack.
352    /// * error `REJECTED_BY_NETSTACK` if an error is returned from an operation
353    ///     on the netstack, e.g. attempting to add an invalid route.
354    /// * error `INTERNAL` if an unexpected error is encountered that is not
355    ///     caused by the client, e.g. an error communicating with the netstack.
356    pub fn r#configure_interface(
357        &self,
358        mut payload: InterfaceOptions,
359    ) -> fidl::client::QueryResponseFut<
360        ConfigurableNetstackConfigureInterfaceResult,
361        fidl::encoding::DefaultFuchsiaResourceDialect,
362    > {
363        ConfigurableNetstackProxyInterface::r#configure_interface(self, payload)
364    }
365}
366
367impl ConfigurableNetstackProxyInterface for ConfigurableNetstackProxy {
368    type ConfigureInterfaceResponseFut = fidl::client::QueryResponseFut<
369        ConfigurableNetstackConfigureInterfaceResult,
370        fidl::encoding::DefaultFuchsiaResourceDialect,
371    >;
372    fn r#configure_interface(
373        &self,
374        mut payload: InterfaceOptions,
375    ) -> Self::ConfigureInterfaceResponseFut {
376        fn _decode(
377            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
378        ) -> Result<ConfigurableNetstackConfigureInterfaceResult, fidl::Error> {
379            let _response = fidl::client::decode_transaction_body::<
380                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ConfigurationError>,
381                fidl::encoding::DefaultFuchsiaResourceDialect,
382                0x64db8deb981ee49,
383            >(_buf?)?;
384            Ok(_response.map(|x| x))
385        }
386        self.client.send_query_and_decode::<
387            InterfaceOptions,
388            ConfigurableNetstackConfigureInterfaceResult,
389        >(
390            &mut payload,
391            0x64db8deb981ee49,
392            fidl::encoding::DynamicFlags::empty(),
393            _decode,
394        )
395    }
396}
397
398pub struct ConfigurableNetstackEventStream {
399    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
400}
401
402impl std::marker::Unpin for ConfigurableNetstackEventStream {}
403
404impl futures::stream::FusedStream for ConfigurableNetstackEventStream {
405    fn is_terminated(&self) -> bool {
406        self.event_receiver.is_terminated()
407    }
408}
409
410impl futures::Stream for ConfigurableNetstackEventStream {
411    type Item = Result<ConfigurableNetstackEvent, fidl::Error>;
412
413    fn poll_next(
414        mut self: std::pin::Pin<&mut Self>,
415        cx: &mut std::task::Context<'_>,
416    ) -> std::task::Poll<Option<Self::Item>> {
417        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
418            &mut self.event_receiver,
419            cx
420        )?) {
421            Some(buf) => std::task::Poll::Ready(Some(ConfigurableNetstackEvent::decode(buf))),
422            None => std::task::Poll::Ready(None),
423        }
424    }
425}
426
427#[derive(Debug)]
428pub enum ConfigurableNetstackEvent {}
429
430impl ConfigurableNetstackEvent {
431    /// Decodes a message buffer as a [`ConfigurableNetstackEvent`].
432    fn decode(
433        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
434    ) -> Result<ConfigurableNetstackEvent, fidl::Error> {
435        let (bytes, _handles) = buf.split_mut();
436        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
437        debug_assert_eq!(tx_header.tx_id, 0);
438        match tx_header.ordinal {
439            _ => Err(fidl::Error::UnknownOrdinal {
440                ordinal: tx_header.ordinal,
441                protocol_name:
442                    <ConfigurableNetstackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
443            }),
444        }
445    }
446}
447
448/// A Stream of incoming requests for fuchsia.netemul/ConfigurableNetstack.
449pub struct ConfigurableNetstackRequestStream {
450    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
451    is_terminated: bool,
452}
453
454impl std::marker::Unpin for ConfigurableNetstackRequestStream {}
455
456impl futures::stream::FusedStream for ConfigurableNetstackRequestStream {
457    fn is_terminated(&self) -> bool {
458        self.is_terminated
459    }
460}
461
462impl fidl::endpoints::RequestStream for ConfigurableNetstackRequestStream {
463    type Protocol = ConfigurableNetstackMarker;
464    type ControlHandle = ConfigurableNetstackControlHandle;
465
466    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
467        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
468    }
469
470    fn control_handle(&self) -> Self::ControlHandle {
471        ConfigurableNetstackControlHandle { inner: self.inner.clone() }
472    }
473
474    fn into_inner(
475        self,
476    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
477    {
478        (self.inner, self.is_terminated)
479    }
480
481    fn from_inner(
482        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
483        is_terminated: bool,
484    ) -> Self {
485        Self { inner, is_terminated }
486    }
487}
488
489impl futures::Stream for ConfigurableNetstackRequestStream {
490    type Item = Result<ConfigurableNetstackRequest, fidl::Error>;
491
492    fn poll_next(
493        mut self: std::pin::Pin<&mut Self>,
494        cx: &mut std::task::Context<'_>,
495    ) -> std::task::Poll<Option<Self::Item>> {
496        let this = &mut *self;
497        if this.inner.check_shutdown(cx) {
498            this.is_terminated = true;
499            return std::task::Poll::Ready(None);
500        }
501        if this.is_terminated {
502            panic!("polled ConfigurableNetstackRequestStream after completion");
503        }
504        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
505            |bytes, handles| {
506                match this.inner.channel().read_etc(cx, bytes, handles) {
507                    std::task::Poll::Ready(Ok(())) => {}
508                    std::task::Poll::Pending => return std::task::Poll::Pending,
509                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
510                        this.is_terminated = true;
511                        return std::task::Poll::Ready(None);
512                    }
513                    std::task::Poll::Ready(Err(e)) => {
514                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
515                            e.into(),
516                        ))))
517                    }
518                }
519
520                // A message has been received from the channel
521                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
522
523                std::task::Poll::Ready(Some(match header.ordinal {
524                0x64db8deb981ee49 => {
525                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
526                    let mut req = fidl::new_empty!(InterfaceOptions, fidl::encoding::DefaultFuchsiaResourceDialect);
527                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InterfaceOptions>(&header, _body_bytes, handles, &mut req)?;
528                    let control_handle = ConfigurableNetstackControlHandle {
529                        inner: this.inner.clone(),
530                    };
531                    Ok(ConfigurableNetstackRequest::ConfigureInterface {payload: req,
532                        responder: ConfigurableNetstackConfigureInterfaceResponder {
533                            control_handle: std::mem::ManuallyDrop::new(control_handle),
534                            tx_id: header.tx_id,
535                        },
536                    })
537                }
538                _ => Err(fidl::Error::UnknownOrdinal {
539                    ordinal: header.ordinal,
540                    protocol_name: <ConfigurableNetstackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
541                }),
542            }))
543            },
544        )
545    }
546}
547
548/// A test-friendly wrapper around Fuchsia's administrative netstack APIs.
549///
550/// This protocol provides a simplified interface to an underlying netstack that
551/// allows the caller to configure it for use in a test environment.
552#[derive(Debug)]
553pub enum ConfigurableNetstackRequest {
554    /// Installs a device in the netstack with the provided configuration.
555    ///
556    /// + request `options` configuration options on the interface.
557    ///
558    /// * error `INVALID_ARGS` if `options` is invalid, as validated by the
559    ///     configurable-netstack.
560    /// * error `REJECTED_BY_NETSTACK` if an error is returned from an operation
561    ///     on the netstack, e.g. attempting to add an invalid route.
562    /// * error `INTERNAL` if an unexpected error is encountered that is not
563    ///     caused by the client, e.g. an error communicating with the netstack.
564    ConfigureInterface {
565        payload: InterfaceOptions,
566        responder: ConfigurableNetstackConfigureInterfaceResponder,
567    },
568}
569
570impl ConfigurableNetstackRequest {
571    #[allow(irrefutable_let_patterns)]
572    pub fn into_configure_interface(
573        self,
574    ) -> Option<(InterfaceOptions, ConfigurableNetstackConfigureInterfaceResponder)> {
575        if let ConfigurableNetstackRequest::ConfigureInterface { payload, responder } = self {
576            Some((payload, responder))
577        } else {
578            None
579        }
580    }
581
582    /// Name of the method defined in FIDL
583    pub fn method_name(&self) -> &'static str {
584        match *self {
585            ConfigurableNetstackRequest::ConfigureInterface { .. } => "configure_interface",
586        }
587    }
588}
589
590#[derive(Debug, Clone)]
591pub struct ConfigurableNetstackControlHandle {
592    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
593}
594
595impl fidl::endpoints::ControlHandle for ConfigurableNetstackControlHandle {
596    fn shutdown(&self) {
597        self.inner.shutdown()
598    }
599    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
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 ConfigurableNetstackControlHandle {}
622
623#[must_use = "FIDL methods require a response to be sent"]
624#[derive(Debug)]
625pub struct ConfigurableNetstackConfigureInterfaceResponder {
626    control_handle: std::mem::ManuallyDrop<ConfigurableNetstackControlHandle>,
627    tx_id: u32,
628}
629
630/// Set the the channel to be shutdown (see [`ConfigurableNetstackControlHandle::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 ConfigurableNetstackConfigureInterfaceResponder {
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 ConfigurableNetstackConfigureInterfaceResponder {
642    type ControlHandle = ConfigurableNetstackControlHandle;
643
644    fn control_handle(&self) -> &ConfigurableNetstackControlHandle {
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 ConfigurableNetstackConfigureInterfaceResponder {
657    /// Sends a response to the FIDL transaction.
658    ///
659    /// Sets the channel to shutdown if an error occurs.
660    pub fn send(self, mut result: Result<(), ConfigurationError>) -> Result<(), fidl::Error> {
661        let _result = self.send_raw(result);
662        if _result.is_err() {
663            self.control_handle.shutdown();
664        }
665        self.drop_without_shutdown();
666        _result
667    }
668
669    /// Similar to "send" but does not shutdown the channel if an error occurs.
670    pub fn send_no_shutdown_on_err(
671        self,
672        mut result: Result<(), ConfigurationError>,
673    ) -> Result<(), fidl::Error> {
674        let _result = self.send_raw(result);
675        self.drop_without_shutdown();
676        _result
677    }
678
679    fn send_raw(&self, mut result: Result<(), ConfigurationError>) -> Result<(), fidl::Error> {
680        self.control_handle.inner.send::<fidl::encoding::ResultType<
681            fidl::encoding::EmptyStruct,
682            ConfigurationError,
683        >>(
684            result,
685            self.tx_id,
686            0x64db8deb981ee49,
687            fidl::encoding::DynamicFlags::empty(),
688        )
689    }
690}
691
692#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
693pub struct ManagedRealmMarker;
694
695impl fidl::endpoints::ProtocolMarker for ManagedRealmMarker {
696    type Proxy = ManagedRealmProxy;
697    type RequestStream = ManagedRealmRequestStream;
698    #[cfg(target_os = "fuchsia")]
699    type SynchronousProxy = ManagedRealmSynchronousProxy;
700
701    const DEBUG_NAME: &'static str = "(anonymous) ManagedRealm";
702}
703pub type ManagedRealmAddDeviceResult = Result<(), i32>;
704pub type ManagedRealmRemoveDeviceResult = Result<(), i32>;
705pub type ManagedRealmStartChildComponentResult = Result<(), i32>;
706pub type ManagedRealmStopChildComponentResult = Result<(), i32>;
707
708pub trait ManagedRealmProxyInterface: Send + Sync {
709    type GetMonikerResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
710    fn r#get_moniker(&self) -> Self::GetMonikerResponseFut;
711    fn r#connect_to_protocol(
712        &self,
713        protocol_name: &str,
714        child_name: Option<&str>,
715        req: fidl::Channel,
716    ) -> Result<(), fidl::Error>;
717    type AddDeviceResponseFut: std::future::Future<Output = Result<ManagedRealmAddDeviceResult, fidl::Error>>
718        + Send;
719    fn r#add_device(
720        &self,
721        path: &str,
722        device: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::DeviceProxy_Marker>,
723    ) -> Self::AddDeviceResponseFut;
724    type RemoveDeviceResponseFut: std::future::Future<Output = Result<ManagedRealmRemoveDeviceResult, fidl::Error>>
725        + Send;
726    fn r#remove_device(&self, path: &str) -> Self::RemoveDeviceResponseFut;
727    fn r#get_devfs(
728        &self,
729        devfs: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
730    ) -> Result<(), fidl::Error>;
731    type StartChildComponentResponseFut: std::future::Future<Output = Result<ManagedRealmStartChildComponentResult, fidl::Error>>
732        + Send;
733    fn r#start_child_component(&self, child_name: &str) -> Self::StartChildComponentResponseFut;
734    type StopChildComponentResponseFut: std::future::Future<Output = Result<ManagedRealmStopChildComponentResult, fidl::Error>>
735        + Send;
736    fn r#stop_child_component(&self, child_name: &str) -> Self::StopChildComponentResponseFut;
737    fn r#shutdown(&self) -> Result<(), fidl::Error>;
738    fn r#open_diagnostics_directory(
739        &self,
740        child_name: &str,
741        directory: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
742    ) -> Result<(), fidl::Error>;
743}
744#[derive(Debug)]
745#[cfg(target_os = "fuchsia")]
746pub struct ManagedRealmSynchronousProxy {
747    client: fidl::client::sync::Client,
748}
749
750#[cfg(target_os = "fuchsia")]
751impl fidl::endpoints::SynchronousProxy for ManagedRealmSynchronousProxy {
752    type Proxy = ManagedRealmProxy;
753    type Protocol = ManagedRealmMarker;
754
755    fn from_channel(inner: fidl::Channel) -> Self {
756        Self::new(inner)
757    }
758
759    fn into_channel(self) -> fidl::Channel {
760        self.client.into_channel()
761    }
762
763    fn as_channel(&self) -> &fidl::Channel {
764        self.client.as_channel()
765    }
766}
767
768#[cfg(target_os = "fuchsia")]
769impl ManagedRealmSynchronousProxy {
770    pub fn new(channel: fidl::Channel) -> Self {
771        let protocol_name = <ManagedRealmMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
772        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
773    }
774
775    pub fn into_channel(self) -> fidl::Channel {
776        self.client.into_channel()
777    }
778
779    /// Waits until an event arrives and returns it. It is safe for other
780    /// threads to make concurrent requests while waiting for an event.
781    pub fn wait_for_event(
782        &self,
783        deadline: zx::MonotonicInstant,
784    ) -> Result<ManagedRealmEvent, fidl::Error> {
785        ManagedRealmEvent::decode(self.client.wait_for_event(deadline)?)
786    }
787
788    /// Returns the moniker of the root of the managed realm.
789    ///
790    /// - response `moniker` the moniker of the root of the generated
791    ///     topology that contains this realm's child components.
792    pub fn r#get_moniker(&self, ___deadline: zx::MonotonicInstant) -> Result<String, fidl::Error> {
793        let _response = self
794            .client
795            .send_query::<fidl::encoding::EmptyPayload, ManagedRealmGetMonikerResponse>(
796                (),
797                0xec8f2bf894ddc5f,
798                fidl::encoding::DynamicFlags::empty(),
799                ___deadline,
800            )?;
801        Ok(_response.moniker)
802    }
803
804    /// Connects to a protocol named `protocol_name` provided by a child in this
805    /// realm.
806    ///
807    /// If `child_name` is not provided, connects to the first child offering
808    /// `protocol_name`.
809    ///
810    /// + request `protocol_name` the name of the protocol to connect to.
811    /// + request `child_name` the name of the child component that is exposing
812    ///     the requested protocol.
813    /// + request `req` a channel to be bound to an implementation of the
814    ///     protocol.
815    pub fn r#connect_to_protocol(
816        &self,
817        mut protocol_name: &str,
818        mut child_name: Option<&str>,
819        mut req: fidl::Channel,
820    ) -> Result<(), fidl::Error> {
821        self.client.send::<ManagedRealmConnectToProtocolRequest>(
822            (protocol_name, child_name, req),
823            0x20865b728239813d,
824            fidl::encoding::DynamicFlags::empty(),
825        )
826    }
827
828    /// Mounts new virtual device `device` on netemul's `devfs` instance within
829    /// this realm.
830    ///
831    /// This `devfs` instance is available to components that have the
832    /// [`Capability.netemul_devfs`] capability.
833    ///
834    /// + request `path` relative path from `devfs` root to the virtual device
835    ///     to be added to the realm.
836    /// + request `device` virtual device server.
837    /// * error `ZX_ERR_ALREADY_EXISTS` if `device.path` is already in use.
838    /// * error `ZX_ERR_INVALID_ARGS` if an element of `path` exceeds
839    ///     [`fuchsia.io/MAX_FILENAME`] bytes in length.
840    pub fn r#add_device(
841        &self,
842        mut path: &str,
843        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::DeviceProxy_Marker>,
844        ___deadline: zx::MonotonicInstant,
845    ) -> Result<ManagedRealmAddDeviceResult, fidl::Error> {
846        let _response = self.client.send_query::<
847            ManagedRealmAddDeviceRequest,
848            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
849        >(
850            (path, device,),
851            0x789925e6f5d47c07,
852            fidl::encoding::DynamicFlags::empty(),
853            ___deadline,
854        )?;
855        Ok(_response.map(|x| x))
856    }
857
858    /// Removes virtual device mounted at `path`.
859    ///
860    /// + request `path` the path to virtual device to be removed from the
861    ///     realm, relative to `devfs` root.
862    /// * error `ZX_ERR_NOT_FOUND` if `path` is not currently bound to a device.
863    /// * error `ZX_ERR_INVALID_ARGS` if an element of `path` exceeds
864    ///     [`fuchsia.io/MAX_FILENAME`] bytes in length.
865    pub fn r#remove_device(
866        &self,
867        mut path: &str,
868        ___deadline: zx::MonotonicInstant,
869    ) -> Result<ManagedRealmRemoveDeviceResult, fidl::Error> {
870        let _response = self.client.send_query::<
871            ManagedRealmRemoveDeviceRequest,
872            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
873        >(
874            (path,),
875            0x6cffbba70ac757cc,
876            fidl::encoding::DynamicFlags::empty(),
877            ___deadline,
878        )?;
879        Ok(_response.map(|x| x))
880    }
881
882    /// Connects to netemul's `devfs` instance for this realm.
883    ///
884    /// + request `devfs` request handle to the `devfs` directory.
885    pub fn r#get_devfs(
886        &self,
887        mut devfs: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
888    ) -> Result<(), fidl::Error> {
889        self.client.send::<ManagedRealmGetDevfsRequest>(
890            (devfs,),
891            0x707e2b17f65fcadc,
892            fidl::encoding::DynamicFlags::empty(),
893        )
894    }
895
896    /// Starts the specified child component in this realm. Starting an already
897    /// running child component is a no-op and returns success.
898    ///
899    /// + request `child_name` the name of the child component to be started.
900    /// * error `ZX_ERR_NOT_FOUND` if `child_name` is not a child component in
901    ///     this realm.
902    /// * error `ZX_ERR_INVALID_ARGS` if `child_name` cannot be composed into a
903    ///     well-formed moniker.
904    /// * error `ZX_ERR_INTERNAL` if the call to the service dependency fails.
905    pub fn r#start_child_component(
906        &self,
907        mut child_name: &str,
908        ___deadline: zx::MonotonicInstant,
909    ) -> Result<ManagedRealmStartChildComponentResult, fidl::Error> {
910        let _response = self.client.send_query::<
911            ManagedRealmStartChildComponentRequest,
912            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
913        >(
914            (child_name,),
915            0x20dfa243752906a1,
916            fidl::encoding::DynamicFlags::empty(),
917            ___deadline,
918        )?;
919        Ok(_response.map(|x| x))
920    }
921
922    /// Stops the specified child component in this realm. Stopping an already
923    /// stopped child component is a no-op and returns success.
924    ///
925    /// + request `child_name` the name of the child component to be stopped.
926    /// * error `ZX_ERR_NOT_FOUND` if `child_name` is not a child component in
927    ///     this realm.
928    /// * error `ZX_ERR_INVALID_ARGS` if `child_name` cannot be composed into a
929    ///     well-formed moniker.
930    /// * error `ZX_ERR_INTERNAL` if the call to the service dependency fails.
931    pub fn r#stop_child_component(
932        &self,
933        mut child_name: &str,
934        ___deadline: zx::MonotonicInstant,
935    ) -> Result<ManagedRealmStopChildComponentResult, fidl::Error> {
936        let _response = self.client.send_query::<
937            ManagedRealmStopChildComponentRequest,
938            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
939        >(
940            (child_name,),
941            0x5ecfe48430aeeca7,
942            fidl::encoding::DynamicFlags::empty(),
943            ___deadline,
944        )?;
945        Ok(_response.map(|x| x))
946    }
947
948    /// Request that the managed realm shut down.
949    ///
950    /// The realm will send an `OnShutdown` event when shutdown is complete and
951    /// before closing the channel.
952    pub fn r#shutdown(&self) -> Result<(), fidl::Error> {
953        self.client.send::<fidl::encoding::EmptyPayload>(
954            (),
955            0x4750920f723fba9d,
956            fidl::encoding::DynamicFlags::empty(),
957        )
958    }
959
960    /// Opens the diagnostics directory exposed by the component `child_name`.
961    pub fn r#open_diagnostics_directory(
962        &self,
963        mut child_name: &str,
964        mut directory: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
965    ) -> Result<(), fidl::Error> {
966        self.client.send::<ManagedRealmOpenDiagnosticsDirectoryRequest>(
967            (child_name, directory),
968            0x7c5312484aa41c99,
969            fidl::encoding::DynamicFlags::empty(),
970        )
971    }
972}
973
974#[derive(Debug, Clone)]
975pub struct ManagedRealmProxy {
976    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
977}
978
979impl fidl::endpoints::Proxy for ManagedRealmProxy {
980    type Protocol = ManagedRealmMarker;
981
982    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
983        Self::new(inner)
984    }
985
986    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
987        self.client.into_channel().map_err(|client| Self { client })
988    }
989
990    fn as_channel(&self) -> &::fidl::AsyncChannel {
991        self.client.as_channel()
992    }
993}
994
995impl ManagedRealmProxy {
996    /// Create a new Proxy for fuchsia.netemul/ManagedRealm.
997    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
998        let protocol_name = <ManagedRealmMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
999        Self { client: fidl::client::Client::new(channel, protocol_name) }
1000    }
1001
1002    /// Get a Stream of events from the remote end of the protocol.
1003    ///
1004    /// # Panics
1005    ///
1006    /// Panics if the event stream was already taken.
1007    pub fn take_event_stream(&self) -> ManagedRealmEventStream {
1008        ManagedRealmEventStream { event_receiver: self.client.take_event_receiver() }
1009    }
1010
1011    /// Returns the moniker of the root of the managed realm.
1012    ///
1013    /// - response `moniker` the moniker of the root of the generated
1014    ///     topology that contains this realm's child components.
1015    pub fn r#get_moniker(
1016        &self,
1017    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
1018        ManagedRealmProxyInterface::r#get_moniker(self)
1019    }
1020
1021    /// Connects to a protocol named `protocol_name` provided by a child in this
1022    /// realm.
1023    ///
1024    /// If `child_name` is not provided, connects to the first child offering
1025    /// `protocol_name`.
1026    ///
1027    /// + request `protocol_name` the name of the protocol to connect to.
1028    /// + request `child_name` the name of the child component that is exposing
1029    ///     the requested protocol.
1030    /// + request `req` a channel to be bound to an implementation of the
1031    ///     protocol.
1032    pub fn r#connect_to_protocol(
1033        &self,
1034        mut protocol_name: &str,
1035        mut child_name: Option<&str>,
1036        mut req: fidl::Channel,
1037    ) -> Result<(), fidl::Error> {
1038        ManagedRealmProxyInterface::r#connect_to_protocol(self, protocol_name, child_name, req)
1039    }
1040
1041    /// Mounts new virtual device `device` on netemul's `devfs` instance within
1042    /// this realm.
1043    ///
1044    /// This `devfs` instance is available to components that have the
1045    /// [`Capability.netemul_devfs`] capability.
1046    ///
1047    /// + request `path` relative path from `devfs` root to the virtual device
1048    ///     to be added to the realm.
1049    /// + request `device` virtual device server.
1050    /// * error `ZX_ERR_ALREADY_EXISTS` if `device.path` is already in use.
1051    /// * error `ZX_ERR_INVALID_ARGS` if an element of `path` exceeds
1052    ///     [`fuchsia.io/MAX_FILENAME`] bytes in length.
1053    pub fn r#add_device(
1054        &self,
1055        mut path: &str,
1056        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::DeviceProxy_Marker>,
1057    ) -> fidl::client::QueryResponseFut<
1058        ManagedRealmAddDeviceResult,
1059        fidl::encoding::DefaultFuchsiaResourceDialect,
1060    > {
1061        ManagedRealmProxyInterface::r#add_device(self, path, device)
1062    }
1063
1064    /// Removes virtual device mounted at `path`.
1065    ///
1066    /// + request `path` the path to virtual device to be removed from the
1067    ///     realm, relative to `devfs` root.
1068    /// * error `ZX_ERR_NOT_FOUND` if `path` is not currently bound to a device.
1069    /// * error `ZX_ERR_INVALID_ARGS` if an element of `path` exceeds
1070    ///     [`fuchsia.io/MAX_FILENAME`] bytes in length.
1071    pub fn r#remove_device(
1072        &self,
1073        mut path: &str,
1074    ) -> fidl::client::QueryResponseFut<
1075        ManagedRealmRemoveDeviceResult,
1076        fidl::encoding::DefaultFuchsiaResourceDialect,
1077    > {
1078        ManagedRealmProxyInterface::r#remove_device(self, path)
1079    }
1080
1081    /// Connects to netemul's `devfs` instance for this realm.
1082    ///
1083    /// + request `devfs` request handle to the `devfs` directory.
1084    pub fn r#get_devfs(
1085        &self,
1086        mut devfs: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1087    ) -> Result<(), fidl::Error> {
1088        ManagedRealmProxyInterface::r#get_devfs(self, devfs)
1089    }
1090
1091    /// Starts the specified child component in this realm. Starting an already
1092    /// running child component is a no-op and returns success.
1093    ///
1094    /// + request `child_name` the name of the child component to be started.
1095    /// * error `ZX_ERR_NOT_FOUND` if `child_name` is not a child component in
1096    ///     this realm.
1097    /// * error `ZX_ERR_INVALID_ARGS` if `child_name` cannot be composed into a
1098    ///     well-formed moniker.
1099    /// * error `ZX_ERR_INTERNAL` if the call to the service dependency fails.
1100    pub fn r#start_child_component(
1101        &self,
1102        mut child_name: &str,
1103    ) -> fidl::client::QueryResponseFut<
1104        ManagedRealmStartChildComponentResult,
1105        fidl::encoding::DefaultFuchsiaResourceDialect,
1106    > {
1107        ManagedRealmProxyInterface::r#start_child_component(self, child_name)
1108    }
1109
1110    /// Stops the specified child component in this realm. Stopping an already
1111    /// stopped child component is a no-op and returns success.
1112    ///
1113    /// + request `child_name` the name of the child component to be stopped.
1114    /// * error `ZX_ERR_NOT_FOUND` if `child_name` is not a child component in
1115    ///     this realm.
1116    /// * error `ZX_ERR_INVALID_ARGS` if `child_name` cannot be composed into a
1117    ///     well-formed moniker.
1118    /// * error `ZX_ERR_INTERNAL` if the call to the service dependency fails.
1119    pub fn r#stop_child_component(
1120        &self,
1121        mut child_name: &str,
1122    ) -> fidl::client::QueryResponseFut<
1123        ManagedRealmStopChildComponentResult,
1124        fidl::encoding::DefaultFuchsiaResourceDialect,
1125    > {
1126        ManagedRealmProxyInterface::r#stop_child_component(self, child_name)
1127    }
1128
1129    /// Request that the managed realm shut down.
1130    ///
1131    /// The realm will send an `OnShutdown` event when shutdown is complete and
1132    /// before closing the channel.
1133    pub fn r#shutdown(&self) -> Result<(), fidl::Error> {
1134        ManagedRealmProxyInterface::r#shutdown(self)
1135    }
1136
1137    /// Opens the diagnostics directory exposed by the component `child_name`.
1138    pub fn r#open_diagnostics_directory(
1139        &self,
1140        mut child_name: &str,
1141        mut directory: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1142    ) -> Result<(), fidl::Error> {
1143        ManagedRealmProxyInterface::r#open_diagnostics_directory(self, child_name, directory)
1144    }
1145}
1146
1147impl ManagedRealmProxyInterface for ManagedRealmProxy {
1148    type GetMonikerResponseFut =
1149        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
1150    fn r#get_moniker(&self) -> Self::GetMonikerResponseFut {
1151        fn _decode(
1152            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1153        ) -> Result<String, fidl::Error> {
1154            let _response = fidl::client::decode_transaction_body::<
1155                ManagedRealmGetMonikerResponse,
1156                fidl::encoding::DefaultFuchsiaResourceDialect,
1157                0xec8f2bf894ddc5f,
1158            >(_buf?)?;
1159            Ok(_response.moniker)
1160        }
1161        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
1162            (),
1163            0xec8f2bf894ddc5f,
1164            fidl::encoding::DynamicFlags::empty(),
1165            _decode,
1166        )
1167    }
1168
1169    fn r#connect_to_protocol(
1170        &self,
1171        mut protocol_name: &str,
1172        mut child_name: Option<&str>,
1173        mut req: fidl::Channel,
1174    ) -> Result<(), fidl::Error> {
1175        self.client.send::<ManagedRealmConnectToProtocolRequest>(
1176            (protocol_name, child_name, req),
1177            0x20865b728239813d,
1178            fidl::encoding::DynamicFlags::empty(),
1179        )
1180    }
1181
1182    type AddDeviceResponseFut = fidl::client::QueryResponseFut<
1183        ManagedRealmAddDeviceResult,
1184        fidl::encoding::DefaultFuchsiaResourceDialect,
1185    >;
1186    fn r#add_device(
1187        &self,
1188        mut path: &str,
1189        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::DeviceProxy_Marker>,
1190    ) -> Self::AddDeviceResponseFut {
1191        fn _decode(
1192            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1193        ) -> Result<ManagedRealmAddDeviceResult, fidl::Error> {
1194            let _response = fidl::client::decode_transaction_body::<
1195                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1196                fidl::encoding::DefaultFuchsiaResourceDialect,
1197                0x789925e6f5d47c07,
1198            >(_buf?)?;
1199            Ok(_response.map(|x| x))
1200        }
1201        self.client
1202            .send_query_and_decode::<ManagedRealmAddDeviceRequest, ManagedRealmAddDeviceResult>(
1203                (path, device),
1204                0x789925e6f5d47c07,
1205                fidl::encoding::DynamicFlags::empty(),
1206                _decode,
1207            )
1208    }
1209
1210    type RemoveDeviceResponseFut = fidl::client::QueryResponseFut<
1211        ManagedRealmRemoveDeviceResult,
1212        fidl::encoding::DefaultFuchsiaResourceDialect,
1213    >;
1214    fn r#remove_device(&self, mut path: &str) -> Self::RemoveDeviceResponseFut {
1215        fn _decode(
1216            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1217        ) -> Result<ManagedRealmRemoveDeviceResult, fidl::Error> {
1218            let _response = fidl::client::decode_transaction_body::<
1219                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1220                fidl::encoding::DefaultFuchsiaResourceDialect,
1221                0x6cffbba70ac757cc,
1222            >(_buf?)?;
1223            Ok(_response.map(|x| x))
1224        }
1225        self.client.send_query_and_decode::<
1226            ManagedRealmRemoveDeviceRequest,
1227            ManagedRealmRemoveDeviceResult,
1228        >(
1229            (path,),
1230            0x6cffbba70ac757cc,
1231            fidl::encoding::DynamicFlags::empty(),
1232            _decode,
1233        )
1234    }
1235
1236    fn r#get_devfs(
1237        &self,
1238        mut devfs: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1239    ) -> Result<(), fidl::Error> {
1240        self.client.send::<ManagedRealmGetDevfsRequest>(
1241            (devfs,),
1242            0x707e2b17f65fcadc,
1243            fidl::encoding::DynamicFlags::empty(),
1244        )
1245    }
1246
1247    type StartChildComponentResponseFut = fidl::client::QueryResponseFut<
1248        ManagedRealmStartChildComponentResult,
1249        fidl::encoding::DefaultFuchsiaResourceDialect,
1250    >;
1251    fn r#start_child_component(
1252        &self,
1253        mut child_name: &str,
1254    ) -> Self::StartChildComponentResponseFut {
1255        fn _decode(
1256            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1257        ) -> Result<ManagedRealmStartChildComponentResult, fidl::Error> {
1258            let _response = fidl::client::decode_transaction_body::<
1259                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1260                fidl::encoding::DefaultFuchsiaResourceDialect,
1261                0x20dfa243752906a1,
1262            >(_buf?)?;
1263            Ok(_response.map(|x| x))
1264        }
1265        self.client.send_query_and_decode::<
1266            ManagedRealmStartChildComponentRequest,
1267            ManagedRealmStartChildComponentResult,
1268        >(
1269            (child_name,),
1270            0x20dfa243752906a1,
1271            fidl::encoding::DynamicFlags::empty(),
1272            _decode,
1273        )
1274    }
1275
1276    type StopChildComponentResponseFut = fidl::client::QueryResponseFut<
1277        ManagedRealmStopChildComponentResult,
1278        fidl::encoding::DefaultFuchsiaResourceDialect,
1279    >;
1280    fn r#stop_child_component(&self, mut child_name: &str) -> Self::StopChildComponentResponseFut {
1281        fn _decode(
1282            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1283        ) -> Result<ManagedRealmStopChildComponentResult, fidl::Error> {
1284            let _response = fidl::client::decode_transaction_body::<
1285                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1286                fidl::encoding::DefaultFuchsiaResourceDialect,
1287                0x5ecfe48430aeeca7,
1288            >(_buf?)?;
1289            Ok(_response.map(|x| x))
1290        }
1291        self.client.send_query_and_decode::<
1292            ManagedRealmStopChildComponentRequest,
1293            ManagedRealmStopChildComponentResult,
1294        >(
1295            (child_name,),
1296            0x5ecfe48430aeeca7,
1297            fidl::encoding::DynamicFlags::empty(),
1298            _decode,
1299        )
1300    }
1301
1302    fn r#shutdown(&self) -> Result<(), fidl::Error> {
1303        self.client.send::<fidl::encoding::EmptyPayload>(
1304            (),
1305            0x4750920f723fba9d,
1306            fidl::encoding::DynamicFlags::empty(),
1307        )
1308    }
1309
1310    fn r#open_diagnostics_directory(
1311        &self,
1312        mut child_name: &str,
1313        mut directory: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1314    ) -> Result<(), fidl::Error> {
1315        self.client.send::<ManagedRealmOpenDiagnosticsDirectoryRequest>(
1316            (child_name, directory),
1317            0x7c5312484aa41c99,
1318            fidl::encoding::DynamicFlags::empty(),
1319        )
1320    }
1321}
1322
1323pub struct ManagedRealmEventStream {
1324    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1325}
1326
1327impl std::marker::Unpin for ManagedRealmEventStream {}
1328
1329impl futures::stream::FusedStream for ManagedRealmEventStream {
1330    fn is_terminated(&self) -> bool {
1331        self.event_receiver.is_terminated()
1332    }
1333}
1334
1335impl futures::Stream for ManagedRealmEventStream {
1336    type Item = Result<ManagedRealmEvent, fidl::Error>;
1337
1338    fn poll_next(
1339        mut self: std::pin::Pin<&mut Self>,
1340        cx: &mut std::task::Context<'_>,
1341    ) -> std::task::Poll<Option<Self::Item>> {
1342        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1343            &mut self.event_receiver,
1344            cx
1345        )?) {
1346            Some(buf) => std::task::Poll::Ready(Some(ManagedRealmEvent::decode(buf))),
1347            None => std::task::Poll::Ready(None),
1348        }
1349    }
1350}
1351
1352#[derive(Debug)]
1353pub enum ManagedRealmEvent {
1354    OnShutdown {},
1355}
1356
1357impl ManagedRealmEvent {
1358    #[allow(irrefutable_let_patterns)]
1359    pub fn into_on_shutdown(self) -> Option<()> {
1360        if let ManagedRealmEvent::OnShutdown {} = self {
1361            Some(())
1362        } else {
1363            None
1364        }
1365    }
1366
1367    /// Decodes a message buffer as a [`ManagedRealmEvent`].
1368    fn decode(
1369        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1370    ) -> Result<ManagedRealmEvent, fidl::Error> {
1371        let (bytes, _handles) = buf.split_mut();
1372        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1373        debug_assert_eq!(tx_header.tx_id, 0);
1374        match tx_header.ordinal {
1375            0x1dff0b58a5b546be => {
1376                let mut out = fidl::new_empty!(
1377                    fidl::encoding::EmptyPayload,
1378                    fidl::encoding::DefaultFuchsiaResourceDialect
1379                );
1380                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
1381                Ok((ManagedRealmEvent::OnShutdown {}))
1382            }
1383            _ => Err(fidl::Error::UnknownOrdinal {
1384                ordinal: tx_header.ordinal,
1385                protocol_name: <ManagedRealmMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1386            }),
1387        }
1388    }
1389}
1390
1391/// A Stream of incoming requests for fuchsia.netemul/ManagedRealm.
1392pub struct ManagedRealmRequestStream {
1393    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1394    is_terminated: bool,
1395}
1396
1397impl std::marker::Unpin for ManagedRealmRequestStream {}
1398
1399impl futures::stream::FusedStream for ManagedRealmRequestStream {
1400    fn is_terminated(&self) -> bool {
1401        self.is_terminated
1402    }
1403}
1404
1405impl fidl::endpoints::RequestStream for ManagedRealmRequestStream {
1406    type Protocol = ManagedRealmMarker;
1407    type ControlHandle = ManagedRealmControlHandle;
1408
1409    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1410        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1411    }
1412
1413    fn control_handle(&self) -> Self::ControlHandle {
1414        ManagedRealmControlHandle { inner: self.inner.clone() }
1415    }
1416
1417    fn into_inner(
1418        self,
1419    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1420    {
1421        (self.inner, self.is_terminated)
1422    }
1423
1424    fn from_inner(
1425        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1426        is_terminated: bool,
1427    ) -> Self {
1428        Self { inner, is_terminated }
1429    }
1430}
1431
1432impl futures::Stream for ManagedRealmRequestStream {
1433    type Item = Result<ManagedRealmRequest, fidl::Error>;
1434
1435    fn poll_next(
1436        mut self: std::pin::Pin<&mut Self>,
1437        cx: &mut std::task::Context<'_>,
1438    ) -> std::task::Poll<Option<Self::Item>> {
1439        let this = &mut *self;
1440        if this.inner.check_shutdown(cx) {
1441            this.is_terminated = true;
1442            return std::task::Poll::Ready(None);
1443        }
1444        if this.is_terminated {
1445            panic!("polled ManagedRealmRequestStream after completion");
1446        }
1447        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1448            |bytes, handles| {
1449                match this.inner.channel().read_etc(cx, bytes, handles) {
1450                    std::task::Poll::Ready(Ok(())) => {}
1451                    std::task::Poll::Pending => return std::task::Poll::Pending,
1452                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1453                        this.is_terminated = true;
1454                        return std::task::Poll::Ready(None);
1455                    }
1456                    std::task::Poll::Ready(Err(e)) => {
1457                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1458                            e.into(),
1459                        ))))
1460                    }
1461                }
1462
1463                // A message has been received from the channel
1464                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1465
1466                std::task::Poll::Ready(Some(match header.ordinal {
1467                    0xec8f2bf894ddc5f => {
1468                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1469                        let mut req = fidl::new_empty!(
1470                            fidl::encoding::EmptyPayload,
1471                            fidl::encoding::DefaultFuchsiaResourceDialect
1472                        );
1473                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1474                        let control_handle =
1475                            ManagedRealmControlHandle { inner: this.inner.clone() };
1476                        Ok(ManagedRealmRequest::GetMoniker {
1477                            responder: ManagedRealmGetMonikerResponder {
1478                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1479                                tx_id: header.tx_id,
1480                            },
1481                        })
1482                    }
1483                    0x20865b728239813d => {
1484                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1485                        let mut req = fidl::new_empty!(
1486                            ManagedRealmConnectToProtocolRequest,
1487                            fidl::encoding::DefaultFuchsiaResourceDialect
1488                        );
1489                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagedRealmConnectToProtocolRequest>(&header, _body_bytes, handles, &mut req)?;
1490                        let control_handle =
1491                            ManagedRealmControlHandle { inner: this.inner.clone() };
1492                        Ok(ManagedRealmRequest::ConnectToProtocol {
1493                            protocol_name: req.protocol_name,
1494                            child_name: req.child_name,
1495                            req: req.req,
1496
1497                            control_handle,
1498                        })
1499                    }
1500                    0x789925e6f5d47c07 => {
1501                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1502                        let mut req = fidl::new_empty!(
1503                            ManagedRealmAddDeviceRequest,
1504                            fidl::encoding::DefaultFuchsiaResourceDialect
1505                        );
1506                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagedRealmAddDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
1507                        let control_handle =
1508                            ManagedRealmControlHandle { inner: this.inner.clone() };
1509                        Ok(ManagedRealmRequest::AddDevice {
1510                            path: req.path,
1511                            device: req.device,
1512
1513                            responder: ManagedRealmAddDeviceResponder {
1514                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1515                                tx_id: header.tx_id,
1516                            },
1517                        })
1518                    }
1519                    0x6cffbba70ac757cc => {
1520                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1521                        let mut req = fidl::new_empty!(
1522                            ManagedRealmRemoveDeviceRequest,
1523                            fidl::encoding::DefaultFuchsiaResourceDialect
1524                        );
1525                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagedRealmRemoveDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
1526                        let control_handle =
1527                            ManagedRealmControlHandle { inner: this.inner.clone() };
1528                        Ok(ManagedRealmRequest::RemoveDevice {
1529                            path: req.path,
1530
1531                            responder: ManagedRealmRemoveDeviceResponder {
1532                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1533                                tx_id: header.tx_id,
1534                            },
1535                        })
1536                    }
1537                    0x707e2b17f65fcadc => {
1538                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1539                        let mut req = fidl::new_empty!(
1540                            ManagedRealmGetDevfsRequest,
1541                            fidl::encoding::DefaultFuchsiaResourceDialect
1542                        );
1543                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagedRealmGetDevfsRequest>(&header, _body_bytes, handles, &mut req)?;
1544                        let control_handle =
1545                            ManagedRealmControlHandle { inner: this.inner.clone() };
1546                        Ok(ManagedRealmRequest::GetDevfs { devfs: req.devfs, control_handle })
1547                    }
1548                    0x20dfa243752906a1 => {
1549                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1550                        let mut req = fidl::new_empty!(
1551                            ManagedRealmStartChildComponentRequest,
1552                            fidl::encoding::DefaultFuchsiaResourceDialect
1553                        );
1554                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagedRealmStartChildComponentRequest>(&header, _body_bytes, handles, &mut req)?;
1555                        let control_handle =
1556                            ManagedRealmControlHandle { inner: this.inner.clone() };
1557                        Ok(ManagedRealmRequest::StartChildComponent {
1558                            child_name: req.child_name,
1559
1560                            responder: ManagedRealmStartChildComponentResponder {
1561                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1562                                tx_id: header.tx_id,
1563                            },
1564                        })
1565                    }
1566                    0x5ecfe48430aeeca7 => {
1567                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1568                        let mut req = fidl::new_empty!(
1569                            ManagedRealmStopChildComponentRequest,
1570                            fidl::encoding::DefaultFuchsiaResourceDialect
1571                        );
1572                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagedRealmStopChildComponentRequest>(&header, _body_bytes, handles, &mut req)?;
1573                        let control_handle =
1574                            ManagedRealmControlHandle { inner: this.inner.clone() };
1575                        Ok(ManagedRealmRequest::StopChildComponent {
1576                            child_name: req.child_name,
1577
1578                            responder: ManagedRealmStopChildComponentResponder {
1579                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1580                                tx_id: header.tx_id,
1581                            },
1582                        })
1583                    }
1584                    0x4750920f723fba9d => {
1585                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1586                        let mut req = fidl::new_empty!(
1587                            fidl::encoding::EmptyPayload,
1588                            fidl::encoding::DefaultFuchsiaResourceDialect
1589                        );
1590                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1591                        let control_handle =
1592                            ManagedRealmControlHandle { inner: this.inner.clone() };
1593                        Ok(ManagedRealmRequest::Shutdown { control_handle })
1594                    }
1595                    0x7c5312484aa41c99 => {
1596                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1597                        let mut req = fidl::new_empty!(
1598                            ManagedRealmOpenDiagnosticsDirectoryRequest,
1599                            fidl::encoding::DefaultFuchsiaResourceDialect
1600                        );
1601                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagedRealmOpenDiagnosticsDirectoryRequest>(&header, _body_bytes, handles, &mut req)?;
1602                        let control_handle =
1603                            ManagedRealmControlHandle { inner: this.inner.clone() };
1604                        Ok(ManagedRealmRequest::OpenDiagnosticsDirectory {
1605                            child_name: req.child_name,
1606                            directory: req.directory,
1607
1608                            control_handle,
1609                        })
1610                    }
1611                    _ => Err(fidl::Error::UnknownOrdinal {
1612                        ordinal: header.ordinal,
1613                        protocol_name:
1614                            <ManagedRealmMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1615                    }),
1616                }))
1617            },
1618        )
1619    }
1620}
1621
1622/// `ManagedRealm` is a netemul-managed realm.
1623///
1624/// A `ManagedRealm` is hermetic with respect to capabilities except for
1625///  * netemul-provided capabilities to allow networking
1626///  * logging
1627///
1628/// `ManagedRealm` also provides a `devfs` instance: a directory standing for a
1629/// virtual device filesystem that can be controlled through the [`AddDevice`]
1630/// and [`RemoveDevice`] methods.
1631///
1632/// The lifetime of a `ManagedRealm` and all its children are tied to its
1633/// channel. Upon closure, all children of the realm will be destroyed.
1634#[derive(Debug)]
1635pub enum ManagedRealmRequest {
1636    /// Returns the moniker of the root of the managed realm.
1637    ///
1638    /// - response `moniker` the moniker of the root of the generated
1639    ///     topology that contains this realm's child components.
1640    GetMoniker { responder: ManagedRealmGetMonikerResponder },
1641    /// Connects to a protocol named `protocol_name` provided by a child in this
1642    /// realm.
1643    ///
1644    /// If `child_name` is not provided, connects to the first child offering
1645    /// `protocol_name`.
1646    ///
1647    /// + request `protocol_name` the name of the protocol to connect to.
1648    /// + request `child_name` the name of the child component that is exposing
1649    ///     the requested protocol.
1650    /// + request `req` a channel to be bound to an implementation of the
1651    ///     protocol.
1652    ConnectToProtocol {
1653        protocol_name: String,
1654        child_name: Option<String>,
1655        req: fidl::Channel,
1656        control_handle: ManagedRealmControlHandle,
1657    },
1658    /// Mounts new virtual device `device` on netemul's `devfs` instance within
1659    /// this realm.
1660    ///
1661    /// This `devfs` instance is available to components that have the
1662    /// [`Capability.netemul_devfs`] capability.
1663    ///
1664    /// + request `path` relative path from `devfs` root to the virtual device
1665    ///     to be added to the realm.
1666    /// + request `device` virtual device server.
1667    /// * error `ZX_ERR_ALREADY_EXISTS` if `device.path` is already in use.
1668    /// * error `ZX_ERR_INVALID_ARGS` if an element of `path` exceeds
1669    ///     [`fuchsia.io/MAX_FILENAME`] bytes in length.
1670    AddDevice {
1671        path: String,
1672        device: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::DeviceProxy_Marker>,
1673        responder: ManagedRealmAddDeviceResponder,
1674    },
1675    /// Removes virtual device mounted at `path`.
1676    ///
1677    /// + request `path` the path to virtual device to be removed from the
1678    ///     realm, relative to `devfs` root.
1679    /// * error `ZX_ERR_NOT_FOUND` if `path` is not currently bound to a device.
1680    /// * error `ZX_ERR_INVALID_ARGS` if an element of `path` exceeds
1681    ///     [`fuchsia.io/MAX_FILENAME`] bytes in length.
1682    RemoveDevice { path: String, responder: ManagedRealmRemoveDeviceResponder },
1683    /// Connects to netemul's `devfs` instance for this realm.
1684    ///
1685    /// + request `devfs` request handle to the `devfs` directory.
1686    GetDevfs {
1687        devfs: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1688        control_handle: ManagedRealmControlHandle,
1689    },
1690    /// Starts the specified child component in this realm. Starting an already
1691    /// running child component is a no-op and returns success.
1692    ///
1693    /// + request `child_name` the name of the child component to be started.
1694    /// * error `ZX_ERR_NOT_FOUND` if `child_name` is not a child component in
1695    ///     this realm.
1696    /// * error `ZX_ERR_INVALID_ARGS` if `child_name` cannot be composed into a
1697    ///     well-formed moniker.
1698    /// * error `ZX_ERR_INTERNAL` if the call to the service dependency fails.
1699    StartChildComponent { child_name: String, responder: ManagedRealmStartChildComponentResponder },
1700    /// Stops the specified child component in this realm. Stopping an already
1701    /// stopped child component is a no-op and returns success.
1702    ///
1703    /// + request `child_name` the name of the child component to be stopped.
1704    /// * error `ZX_ERR_NOT_FOUND` if `child_name` is not a child component in
1705    ///     this realm.
1706    /// * error `ZX_ERR_INVALID_ARGS` if `child_name` cannot be composed into a
1707    ///     well-formed moniker.
1708    /// * error `ZX_ERR_INTERNAL` if the call to the service dependency fails.
1709    StopChildComponent { child_name: String, responder: ManagedRealmStopChildComponentResponder },
1710    /// Request that the managed realm shut down.
1711    ///
1712    /// The realm will send an `OnShutdown` event when shutdown is complete and
1713    /// before closing the channel.
1714    Shutdown { control_handle: ManagedRealmControlHandle },
1715    /// Opens the diagnostics directory exposed by the component `child_name`.
1716    OpenDiagnosticsDirectory {
1717        child_name: String,
1718        directory: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1719        control_handle: ManagedRealmControlHandle,
1720    },
1721}
1722
1723impl ManagedRealmRequest {
1724    #[allow(irrefutable_let_patterns)]
1725    pub fn into_get_moniker(self) -> Option<(ManagedRealmGetMonikerResponder)> {
1726        if let ManagedRealmRequest::GetMoniker { responder } = self {
1727            Some((responder))
1728        } else {
1729            None
1730        }
1731    }
1732
1733    #[allow(irrefutable_let_patterns)]
1734    pub fn into_connect_to_protocol(
1735        self,
1736    ) -> Option<(String, Option<String>, fidl::Channel, ManagedRealmControlHandle)> {
1737        if let ManagedRealmRequest::ConnectToProtocol {
1738            protocol_name,
1739            child_name,
1740            req,
1741            control_handle,
1742        } = self
1743        {
1744            Some((protocol_name, child_name, req, control_handle))
1745        } else {
1746            None
1747        }
1748    }
1749
1750    #[allow(irrefutable_let_patterns)]
1751    pub fn into_add_device(
1752        self,
1753    ) -> Option<(
1754        String,
1755        fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::DeviceProxy_Marker>,
1756        ManagedRealmAddDeviceResponder,
1757    )> {
1758        if let ManagedRealmRequest::AddDevice { path, device, responder } = self {
1759            Some((path, device, responder))
1760        } else {
1761            None
1762        }
1763    }
1764
1765    #[allow(irrefutable_let_patterns)]
1766    pub fn into_remove_device(self) -> Option<(String, ManagedRealmRemoveDeviceResponder)> {
1767        if let ManagedRealmRequest::RemoveDevice { path, responder } = self {
1768            Some((path, responder))
1769        } else {
1770            None
1771        }
1772    }
1773
1774    #[allow(irrefutable_let_patterns)]
1775    pub fn into_get_devfs(
1776        self,
1777    ) -> Option<(
1778        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1779        ManagedRealmControlHandle,
1780    )> {
1781        if let ManagedRealmRequest::GetDevfs { devfs, control_handle } = self {
1782            Some((devfs, control_handle))
1783        } else {
1784            None
1785        }
1786    }
1787
1788    #[allow(irrefutable_let_patterns)]
1789    pub fn into_start_child_component(
1790        self,
1791    ) -> Option<(String, ManagedRealmStartChildComponentResponder)> {
1792        if let ManagedRealmRequest::StartChildComponent { child_name, responder } = self {
1793            Some((child_name, responder))
1794        } else {
1795            None
1796        }
1797    }
1798
1799    #[allow(irrefutable_let_patterns)]
1800    pub fn into_stop_child_component(
1801        self,
1802    ) -> Option<(String, ManagedRealmStopChildComponentResponder)> {
1803        if let ManagedRealmRequest::StopChildComponent { child_name, responder } = self {
1804            Some((child_name, responder))
1805        } else {
1806            None
1807        }
1808    }
1809
1810    #[allow(irrefutable_let_patterns)]
1811    pub fn into_shutdown(self) -> Option<(ManagedRealmControlHandle)> {
1812        if let ManagedRealmRequest::Shutdown { control_handle } = self {
1813            Some((control_handle))
1814        } else {
1815            None
1816        }
1817    }
1818
1819    #[allow(irrefutable_let_patterns)]
1820    pub fn into_open_diagnostics_directory(
1821        self,
1822    ) -> Option<(
1823        String,
1824        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1825        ManagedRealmControlHandle,
1826    )> {
1827        if let ManagedRealmRequest::OpenDiagnosticsDirectory {
1828            child_name,
1829            directory,
1830            control_handle,
1831        } = self
1832        {
1833            Some((child_name, directory, control_handle))
1834        } else {
1835            None
1836        }
1837    }
1838
1839    /// Name of the method defined in FIDL
1840    pub fn method_name(&self) -> &'static str {
1841        match *self {
1842            ManagedRealmRequest::GetMoniker { .. } => "get_moniker",
1843            ManagedRealmRequest::ConnectToProtocol { .. } => "connect_to_protocol",
1844            ManagedRealmRequest::AddDevice { .. } => "add_device",
1845            ManagedRealmRequest::RemoveDevice { .. } => "remove_device",
1846            ManagedRealmRequest::GetDevfs { .. } => "get_devfs",
1847            ManagedRealmRequest::StartChildComponent { .. } => "start_child_component",
1848            ManagedRealmRequest::StopChildComponent { .. } => "stop_child_component",
1849            ManagedRealmRequest::Shutdown { .. } => "shutdown",
1850            ManagedRealmRequest::OpenDiagnosticsDirectory { .. } => "open_diagnostics_directory",
1851        }
1852    }
1853}
1854
1855#[derive(Debug, Clone)]
1856pub struct ManagedRealmControlHandle {
1857    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1858}
1859
1860impl fidl::endpoints::ControlHandle for ManagedRealmControlHandle {
1861    fn shutdown(&self) {
1862        self.inner.shutdown()
1863    }
1864    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1865        self.inner.shutdown_with_epitaph(status)
1866    }
1867
1868    fn is_closed(&self) -> bool {
1869        self.inner.channel().is_closed()
1870    }
1871    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1872        self.inner.channel().on_closed()
1873    }
1874
1875    #[cfg(target_os = "fuchsia")]
1876    fn signal_peer(
1877        &self,
1878        clear_mask: zx::Signals,
1879        set_mask: zx::Signals,
1880    ) -> Result<(), zx_status::Status> {
1881        use fidl::Peered;
1882        self.inner.channel().signal_peer(clear_mask, set_mask)
1883    }
1884}
1885
1886impl ManagedRealmControlHandle {
1887    pub fn send_on_shutdown(&self) -> Result<(), fidl::Error> {
1888        self.inner.send::<fidl::encoding::EmptyPayload>(
1889            (),
1890            0,
1891            0x1dff0b58a5b546be,
1892            fidl::encoding::DynamicFlags::empty(),
1893        )
1894    }
1895}
1896
1897#[must_use = "FIDL methods require a response to be sent"]
1898#[derive(Debug)]
1899pub struct ManagedRealmGetMonikerResponder {
1900    control_handle: std::mem::ManuallyDrop<ManagedRealmControlHandle>,
1901    tx_id: u32,
1902}
1903
1904/// Set the the channel to be shutdown (see [`ManagedRealmControlHandle::shutdown`])
1905/// if the responder is dropped without sending a response, so that the client
1906/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1907impl std::ops::Drop for ManagedRealmGetMonikerResponder {
1908    fn drop(&mut self) {
1909        self.control_handle.shutdown();
1910        // Safety: drops once, never accessed again
1911        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1912    }
1913}
1914
1915impl fidl::endpoints::Responder for ManagedRealmGetMonikerResponder {
1916    type ControlHandle = ManagedRealmControlHandle;
1917
1918    fn control_handle(&self) -> &ManagedRealmControlHandle {
1919        &self.control_handle
1920    }
1921
1922    fn drop_without_shutdown(mut self) {
1923        // Safety: drops once, never accessed again due to mem::forget
1924        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1925        // Prevent Drop from running (which would shut down the channel)
1926        std::mem::forget(self);
1927    }
1928}
1929
1930impl ManagedRealmGetMonikerResponder {
1931    /// Sends a response to the FIDL transaction.
1932    ///
1933    /// Sets the channel to shutdown if an error occurs.
1934    pub fn send(self, mut moniker: &str) -> Result<(), fidl::Error> {
1935        let _result = self.send_raw(moniker);
1936        if _result.is_err() {
1937            self.control_handle.shutdown();
1938        }
1939        self.drop_without_shutdown();
1940        _result
1941    }
1942
1943    /// Similar to "send" but does not shutdown the channel if an error occurs.
1944    pub fn send_no_shutdown_on_err(self, mut moniker: &str) -> Result<(), fidl::Error> {
1945        let _result = self.send_raw(moniker);
1946        self.drop_without_shutdown();
1947        _result
1948    }
1949
1950    fn send_raw(&self, mut moniker: &str) -> Result<(), fidl::Error> {
1951        self.control_handle.inner.send::<ManagedRealmGetMonikerResponse>(
1952            (moniker,),
1953            self.tx_id,
1954            0xec8f2bf894ddc5f,
1955            fidl::encoding::DynamicFlags::empty(),
1956        )
1957    }
1958}
1959
1960#[must_use = "FIDL methods require a response to be sent"]
1961#[derive(Debug)]
1962pub struct ManagedRealmAddDeviceResponder {
1963    control_handle: std::mem::ManuallyDrop<ManagedRealmControlHandle>,
1964    tx_id: u32,
1965}
1966
1967/// Set the the channel to be shutdown (see [`ManagedRealmControlHandle::shutdown`])
1968/// if the responder is dropped without sending a response, so that the client
1969/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1970impl std::ops::Drop for ManagedRealmAddDeviceResponder {
1971    fn drop(&mut self) {
1972        self.control_handle.shutdown();
1973        // Safety: drops once, never accessed again
1974        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1975    }
1976}
1977
1978impl fidl::endpoints::Responder for ManagedRealmAddDeviceResponder {
1979    type ControlHandle = ManagedRealmControlHandle;
1980
1981    fn control_handle(&self) -> &ManagedRealmControlHandle {
1982        &self.control_handle
1983    }
1984
1985    fn drop_without_shutdown(mut self) {
1986        // Safety: drops once, never accessed again due to mem::forget
1987        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1988        // Prevent Drop from running (which would shut down the channel)
1989        std::mem::forget(self);
1990    }
1991}
1992
1993impl ManagedRealmAddDeviceResponder {
1994    /// Sends a response to the FIDL transaction.
1995    ///
1996    /// Sets the channel to shutdown if an error occurs.
1997    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1998        let _result = self.send_raw(result);
1999        if _result.is_err() {
2000            self.control_handle.shutdown();
2001        }
2002        self.drop_without_shutdown();
2003        _result
2004    }
2005
2006    /// Similar to "send" but does not shutdown the channel if an error occurs.
2007    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2008        let _result = self.send_raw(result);
2009        self.drop_without_shutdown();
2010        _result
2011    }
2012
2013    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2014        self.control_handle
2015            .inner
2016            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2017                result,
2018                self.tx_id,
2019                0x789925e6f5d47c07,
2020                fidl::encoding::DynamicFlags::empty(),
2021            )
2022    }
2023}
2024
2025#[must_use = "FIDL methods require a response to be sent"]
2026#[derive(Debug)]
2027pub struct ManagedRealmRemoveDeviceResponder {
2028    control_handle: std::mem::ManuallyDrop<ManagedRealmControlHandle>,
2029    tx_id: u32,
2030}
2031
2032/// Set the the channel to be shutdown (see [`ManagedRealmControlHandle::shutdown`])
2033/// if the responder is dropped without sending a response, so that the client
2034/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2035impl std::ops::Drop for ManagedRealmRemoveDeviceResponder {
2036    fn drop(&mut self) {
2037        self.control_handle.shutdown();
2038        // Safety: drops once, never accessed again
2039        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2040    }
2041}
2042
2043impl fidl::endpoints::Responder for ManagedRealmRemoveDeviceResponder {
2044    type ControlHandle = ManagedRealmControlHandle;
2045
2046    fn control_handle(&self) -> &ManagedRealmControlHandle {
2047        &self.control_handle
2048    }
2049
2050    fn drop_without_shutdown(mut self) {
2051        // Safety: drops once, never accessed again due to mem::forget
2052        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2053        // Prevent Drop from running (which would shut down the channel)
2054        std::mem::forget(self);
2055    }
2056}
2057
2058impl ManagedRealmRemoveDeviceResponder {
2059    /// Sends a response to the FIDL transaction.
2060    ///
2061    /// Sets the channel to shutdown if an error occurs.
2062    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2063        let _result = self.send_raw(result);
2064        if _result.is_err() {
2065            self.control_handle.shutdown();
2066        }
2067        self.drop_without_shutdown();
2068        _result
2069    }
2070
2071    /// Similar to "send" but does not shutdown the channel if an error occurs.
2072    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2073        let _result = self.send_raw(result);
2074        self.drop_without_shutdown();
2075        _result
2076    }
2077
2078    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2079        self.control_handle
2080            .inner
2081            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2082                result,
2083                self.tx_id,
2084                0x6cffbba70ac757cc,
2085                fidl::encoding::DynamicFlags::empty(),
2086            )
2087    }
2088}
2089
2090#[must_use = "FIDL methods require a response to be sent"]
2091#[derive(Debug)]
2092pub struct ManagedRealmStartChildComponentResponder {
2093    control_handle: std::mem::ManuallyDrop<ManagedRealmControlHandle>,
2094    tx_id: u32,
2095}
2096
2097/// Set the the channel to be shutdown (see [`ManagedRealmControlHandle::shutdown`])
2098/// if the responder is dropped without sending a response, so that the client
2099/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2100impl std::ops::Drop for ManagedRealmStartChildComponentResponder {
2101    fn drop(&mut self) {
2102        self.control_handle.shutdown();
2103        // Safety: drops once, never accessed again
2104        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2105    }
2106}
2107
2108impl fidl::endpoints::Responder for ManagedRealmStartChildComponentResponder {
2109    type ControlHandle = ManagedRealmControlHandle;
2110
2111    fn control_handle(&self) -> &ManagedRealmControlHandle {
2112        &self.control_handle
2113    }
2114
2115    fn drop_without_shutdown(mut self) {
2116        // Safety: drops once, never accessed again due to mem::forget
2117        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2118        // Prevent Drop from running (which would shut down the channel)
2119        std::mem::forget(self);
2120    }
2121}
2122
2123impl ManagedRealmStartChildComponentResponder {
2124    /// Sends a response to the FIDL transaction.
2125    ///
2126    /// Sets the channel to shutdown if an error occurs.
2127    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2128        let _result = self.send_raw(result);
2129        if _result.is_err() {
2130            self.control_handle.shutdown();
2131        }
2132        self.drop_without_shutdown();
2133        _result
2134    }
2135
2136    /// Similar to "send" but does not shutdown the channel if an error occurs.
2137    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2138        let _result = self.send_raw(result);
2139        self.drop_without_shutdown();
2140        _result
2141    }
2142
2143    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2144        self.control_handle
2145            .inner
2146            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2147                result,
2148                self.tx_id,
2149                0x20dfa243752906a1,
2150                fidl::encoding::DynamicFlags::empty(),
2151            )
2152    }
2153}
2154
2155#[must_use = "FIDL methods require a response to be sent"]
2156#[derive(Debug)]
2157pub struct ManagedRealmStopChildComponentResponder {
2158    control_handle: std::mem::ManuallyDrop<ManagedRealmControlHandle>,
2159    tx_id: u32,
2160}
2161
2162/// Set the the channel to be shutdown (see [`ManagedRealmControlHandle::shutdown`])
2163/// if the responder is dropped without sending a response, so that the client
2164/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2165impl std::ops::Drop for ManagedRealmStopChildComponentResponder {
2166    fn drop(&mut self) {
2167        self.control_handle.shutdown();
2168        // Safety: drops once, never accessed again
2169        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2170    }
2171}
2172
2173impl fidl::endpoints::Responder for ManagedRealmStopChildComponentResponder {
2174    type ControlHandle = ManagedRealmControlHandle;
2175
2176    fn control_handle(&self) -> &ManagedRealmControlHandle {
2177        &self.control_handle
2178    }
2179
2180    fn drop_without_shutdown(mut self) {
2181        // Safety: drops once, never accessed again due to mem::forget
2182        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2183        // Prevent Drop from running (which would shut down the channel)
2184        std::mem::forget(self);
2185    }
2186}
2187
2188impl ManagedRealmStopChildComponentResponder {
2189    /// Sends a response to the FIDL transaction.
2190    ///
2191    /// Sets the channel to shutdown if an error occurs.
2192    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2193        let _result = self.send_raw(result);
2194        if _result.is_err() {
2195            self.control_handle.shutdown();
2196        }
2197        self.drop_without_shutdown();
2198        _result
2199    }
2200
2201    /// Similar to "send" but does not shutdown the channel if an error occurs.
2202    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2203        let _result = self.send_raw(result);
2204        self.drop_without_shutdown();
2205        _result
2206    }
2207
2208    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2209        self.control_handle
2210            .inner
2211            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2212                result,
2213                self.tx_id,
2214                0x5ecfe48430aeeca7,
2215                fidl::encoding::DynamicFlags::empty(),
2216            )
2217    }
2218}
2219
2220#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2221pub struct SandboxMarker;
2222
2223impl fidl::endpoints::ProtocolMarker for SandboxMarker {
2224    type Proxy = SandboxProxy;
2225    type RequestStream = SandboxRequestStream;
2226    #[cfg(target_os = "fuchsia")]
2227    type SynchronousProxy = SandboxSynchronousProxy;
2228
2229    const DEBUG_NAME: &'static str = "fuchsia.netemul.Sandbox";
2230}
2231impl fidl::endpoints::DiscoverableProtocolMarker for SandboxMarker {}
2232
2233pub trait SandboxProxyInterface: Send + Sync {
2234    fn r#create_realm(
2235        &self,
2236        realm: fidl::endpoints::ServerEnd<ManagedRealmMarker>,
2237        options: RealmOptions,
2238    ) -> Result<(), fidl::Error>;
2239    fn r#get_network_context(
2240        &self,
2241        network_context: fidl::endpoints::ServerEnd<
2242            fidl_fuchsia_netemul_network::NetworkContextMarker,
2243        >,
2244    ) -> Result<(), fidl::Error>;
2245}
2246#[derive(Debug)]
2247#[cfg(target_os = "fuchsia")]
2248pub struct SandboxSynchronousProxy {
2249    client: fidl::client::sync::Client,
2250}
2251
2252#[cfg(target_os = "fuchsia")]
2253impl fidl::endpoints::SynchronousProxy for SandboxSynchronousProxy {
2254    type Proxy = SandboxProxy;
2255    type Protocol = SandboxMarker;
2256
2257    fn from_channel(inner: fidl::Channel) -> Self {
2258        Self::new(inner)
2259    }
2260
2261    fn into_channel(self) -> fidl::Channel {
2262        self.client.into_channel()
2263    }
2264
2265    fn as_channel(&self) -> &fidl::Channel {
2266        self.client.as_channel()
2267    }
2268}
2269
2270#[cfg(target_os = "fuchsia")]
2271impl SandboxSynchronousProxy {
2272    pub fn new(channel: fidl::Channel) -> Self {
2273        let protocol_name = <SandboxMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2274        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2275    }
2276
2277    pub fn into_channel(self) -> fidl::Channel {
2278        self.client.into_channel()
2279    }
2280
2281    /// Waits until an event arrives and returns it. It is safe for other
2282    /// threads to make concurrent requests while waiting for an event.
2283    pub fn wait_for_event(
2284        &self,
2285        deadline: zx::MonotonicInstant,
2286    ) -> Result<SandboxEvent, fidl::Error> {
2287        SandboxEvent::decode(self.client.wait_for_event(deadline)?)
2288    }
2289
2290    /// Creates a new realm configured by `options`.
2291    ///
2292    /// + request `realm` request handle to the newly created managed realm.
2293    /// + request `options` configures the setup and child components of
2294    ///     `realm`. If `options` is invalid, `realm` will be closed.
2295    ///
2296    /// Errors are presented as an epitaph on the `realm` channel.
2297    /// * error `ZX_ERR_INVALID_ARGS` if `options` was invalid.
2298    /// * error `ZX_ERR_INTERNAL` for internal errors, including failures to
2299    ///     build the requested component topology.
2300    pub fn r#create_realm(
2301        &self,
2302        mut realm: fidl::endpoints::ServerEnd<ManagedRealmMarker>,
2303        mut options: RealmOptions,
2304    ) -> Result<(), fidl::Error> {
2305        self.client.send::<SandboxCreateRealmRequest>(
2306            (realm, &mut options),
2307            0x25d0bc5f1006a0c9,
2308            fidl::encoding::DynamicFlags::empty(),
2309        )
2310    }
2311
2312    /// Gets this sandbox's network context.
2313    ///
2314    /// + request `network_context` request handle to the network context.
2315    pub fn r#get_network_context(
2316        &self,
2317        mut network_context: fidl::endpoints::ServerEnd<
2318            fidl_fuchsia_netemul_network::NetworkContextMarker,
2319        >,
2320    ) -> Result<(), fidl::Error> {
2321        self.client.send::<SandboxGetNetworkContextRequest>(
2322            (network_context,),
2323            0x140cb104c2605970,
2324            fidl::encoding::DynamicFlags::empty(),
2325        )
2326    }
2327}
2328
2329#[derive(Debug, Clone)]
2330pub struct SandboxProxy {
2331    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2332}
2333
2334impl fidl::endpoints::Proxy for SandboxProxy {
2335    type Protocol = SandboxMarker;
2336
2337    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2338        Self::new(inner)
2339    }
2340
2341    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2342        self.client.into_channel().map_err(|client| Self { client })
2343    }
2344
2345    fn as_channel(&self) -> &::fidl::AsyncChannel {
2346        self.client.as_channel()
2347    }
2348}
2349
2350impl SandboxProxy {
2351    /// Create a new Proxy for fuchsia.netemul/Sandbox.
2352    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2353        let protocol_name = <SandboxMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2354        Self { client: fidl::client::Client::new(channel, protocol_name) }
2355    }
2356
2357    /// Get a Stream of events from the remote end of the protocol.
2358    ///
2359    /// # Panics
2360    ///
2361    /// Panics if the event stream was already taken.
2362    pub fn take_event_stream(&self) -> SandboxEventStream {
2363        SandboxEventStream { event_receiver: self.client.take_event_receiver() }
2364    }
2365
2366    /// Creates a new realm configured by `options`.
2367    ///
2368    /// + request `realm` request handle to the newly created managed realm.
2369    /// + request `options` configures the setup and child components of
2370    ///     `realm`. If `options` is invalid, `realm` will be closed.
2371    ///
2372    /// Errors are presented as an epitaph on the `realm` channel.
2373    /// * error `ZX_ERR_INVALID_ARGS` if `options` was invalid.
2374    /// * error `ZX_ERR_INTERNAL` for internal errors, including failures to
2375    ///     build the requested component topology.
2376    pub fn r#create_realm(
2377        &self,
2378        mut realm: fidl::endpoints::ServerEnd<ManagedRealmMarker>,
2379        mut options: RealmOptions,
2380    ) -> Result<(), fidl::Error> {
2381        SandboxProxyInterface::r#create_realm(self, realm, options)
2382    }
2383
2384    /// Gets this sandbox's network context.
2385    ///
2386    /// + request `network_context` request handle to the network context.
2387    pub fn r#get_network_context(
2388        &self,
2389        mut network_context: fidl::endpoints::ServerEnd<
2390            fidl_fuchsia_netemul_network::NetworkContextMarker,
2391        >,
2392    ) -> Result<(), fidl::Error> {
2393        SandboxProxyInterface::r#get_network_context(self, network_context)
2394    }
2395}
2396
2397impl SandboxProxyInterface for SandboxProxy {
2398    fn r#create_realm(
2399        &self,
2400        mut realm: fidl::endpoints::ServerEnd<ManagedRealmMarker>,
2401        mut options: RealmOptions,
2402    ) -> Result<(), fidl::Error> {
2403        self.client.send::<SandboxCreateRealmRequest>(
2404            (realm, &mut options),
2405            0x25d0bc5f1006a0c9,
2406            fidl::encoding::DynamicFlags::empty(),
2407        )
2408    }
2409
2410    fn r#get_network_context(
2411        &self,
2412        mut network_context: fidl::endpoints::ServerEnd<
2413            fidl_fuchsia_netemul_network::NetworkContextMarker,
2414        >,
2415    ) -> Result<(), fidl::Error> {
2416        self.client.send::<SandboxGetNetworkContextRequest>(
2417            (network_context,),
2418            0x140cb104c2605970,
2419            fidl::encoding::DynamicFlags::empty(),
2420        )
2421    }
2422}
2423
2424pub struct SandboxEventStream {
2425    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2426}
2427
2428impl std::marker::Unpin for SandboxEventStream {}
2429
2430impl futures::stream::FusedStream for SandboxEventStream {
2431    fn is_terminated(&self) -> bool {
2432        self.event_receiver.is_terminated()
2433    }
2434}
2435
2436impl futures::Stream for SandboxEventStream {
2437    type Item = Result<SandboxEvent, fidl::Error>;
2438
2439    fn poll_next(
2440        mut self: std::pin::Pin<&mut Self>,
2441        cx: &mut std::task::Context<'_>,
2442    ) -> std::task::Poll<Option<Self::Item>> {
2443        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2444            &mut self.event_receiver,
2445            cx
2446        )?) {
2447            Some(buf) => std::task::Poll::Ready(Some(SandboxEvent::decode(buf))),
2448            None => std::task::Poll::Ready(None),
2449        }
2450    }
2451}
2452
2453#[derive(Debug)]
2454pub enum SandboxEvent {}
2455
2456impl SandboxEvent {
2457    /// Decodes a message buffer as a [`SandboxEvent`].
2458    fn decode(
2459        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2460    ) -> Result<SandboxEvent, fidl::Error> {
2461        let (bytes, _handles) = buf.split_mut();
2462        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2463        debug_assert_eq!(tx_header.tx_id, 0);
2464        match tx_header.ordinal {
2465            _ => Err(fidl::Error::UnknownOrdinal {
2466                ordinal: tx_header.ordinal,
2467                protocol_name: <SandboxMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2468            }),
2469        }
2470    }
2471}
2472
2473/// A Stream of incoming requests for fuchsia.netemul/Sandbox.
2474pub struct SandboxRequestStream {
2475    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2476    is_terminated: bool,
2477}
2478
2479impl std::marker::Unpin for SandboxRequestStream {}
2480
2481impl futures::stream::FusedStream for SandboxRequestStream {
2482    fn is_terminated(&self) -> bool {
2483        self.is_terminated
2484    }
2485}
2486
2487impl fidl::endpoints::RequestStream for SandboxRequestStream {
2488    type Protocol = SandboxMarker;
2489    type ControlHandle = SandboxControlHandle;
2490
2491    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2492        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2493    }
2494
2495    fn control_handle(&self) -> Self::ControlHandle {
2496        SandboxControlHandle { inner: self.inner.clone() }
2497    }
2498
2499    fn into_inner(
2500        self,
2501    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2502    {
2503        (self.inner, self.is_terminated)
2504    }
2505
2506    fn from_inner(
2507        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2508        is_terminated: bool,
2509    ) -> Self {
2510        Self { inner, is_terminated }
2511    }
2512}
2513
2514impl futures::Stream for SandboxRequestStream {
2515    type Item = Result<SandboxRequest, fidl::Error>;
2516
2517    fn poll_next(
2518        mut self: std::pin::Pin<&mut Self>,
2519        cx: &mut std::task::Context<'_>,
2520    ) -> std::task::Poll<Option<Self::Item>> {
2521        let this = &mut *self;
2522        if this.inner.check_shutdown(cx) {
2523            this.is_terminated = true;
2524            return std::task::Poll::Ready(None);
2525        }
2526        if this.is_terminated {
2527            panic!("polled SandboxRequestStream after completion");
2528        }
2529        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2530            |bytes, handles| {
2531                match this.inner.channel().read_etc(cx, bytes, handles) {
2532                    std::task::Poll::Ready(Ok(())) => {}
2533                    std::task::Poll::Pending => return std::task::Poll::Pending,
2534                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2535                        this.is_terminated = true;
2536                        return std::task::Poll::Ready(None);
2537                    }
2538                    std::task::Poll::Ready(Err(e)) => {
2539                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2540                            e.into(),
2541                        ))))
2542                    }
2543                }
2544
2545                // A message has been received from the channel
2546                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2547
2548                std::task::Poll::Ready(Some(match header.ordinal {
2549                    0x25d0bc5f1006a0c9 => {
2550                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2551                        let mut req = fidl::new_empty!(
2552                            SandboxCreateRealmRequest,
2553                            fidl::encoding::DefaultFuchsiaResourceDialect
2554                        );
2555                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SandboxCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
2556                        let control_handle = SandboxControlHandle { inner: this.inner.clone() };
2557                        Ok(SandboxRequest::CreateRealm {
2558                            realm: req.realm,
2559                            options: req.options,
2560
2561                            control_handle,
2562                        })
2563                    }
2564                    0x140cb104c2605970 => {
2565                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2566                        let mut req = fidl::new_empty!(
2567                            SandboxGetNetworkContextRequest,
2568                            fidl::encoding::DefaultFuchsiaResourceDialect
2569                        );
2570                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SandboxGetNetworkContextRequest>(&header, _body_bytes, handles, &mut req)?;
2571                        let control_handle = SandboxControlHandle { inner: this.inner.clone() };
2572                        Ok(SandboxRequest::GetNetworkContext {
2573                            network_context: req.network_context,
2574
2575                            control_handle,
2576                        })
2577                    }
2578                    _ => Err(fidl::Error::UnknownOrdinal {
2579                        ordinal: header.ordinal,
2580                        protocol_name:
2581                            <SandboxMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2582                    }),
2583                }))
2584            },
2585        )
2586    }
2587}
2588
2589/// `Sandbox` is a hermetic container for network emulation testing.
2590///
2591/// Every connection to `Sandbox` represents a self-contained context where
2592/// [`fuchsia.netemul/ManagedRealm`]s can be created. The
2593/// [`fuchsia.netemul.network/NetworkContext`] instance offered by it is the
2594/// same that is exposed to any `ManagedRealm`s created by the `Sandbox`.
2595///
2596/// The lifetime of the created realms (and the context services) is bound to
2597/// the connection to the `Sandbox` protocol. If the channel is closed, all the
2598/// realms and the components created within them will be terminated.
2599#[derive(Debug)]
2600pub enum SandboxRequest {
2601    /// Creates a new realm configured by `options`.
2602    ///
2603    /// + request `realm` request handle to the newly created managed realm.
2604    /// + request `options` configures the setup and child components of
2605    ///     `realm`. If `options` is invalid, `realm` will be closed.
2606    ///
2607    /// Errors are presented as an epitaph on the `realm` channel.
2608    /// * error `ZX_ERR_INVALID_ARGS` if `options` was invalid.
2609    /// * error `ZX_ERR_INTERNAL` for internal errors, including failures to
2610    ///     build the requested component topology.
2611    CreateRealm {
2612        realm: fidl::endpoints::ServerEnd<ManagedRealmMarker>,
2613        options: RealmOptions,
2614        control_handle: SandboxControlHandle,
2615    },
2616    /// Gets this sandbox's network context.
2617    ///
2618    /// + request `network_context` request handle to the network context.
2619    GetNetworkContext {
2620        network_context:
2621            fidl::endpoints::ServerEnd<fidl_fuchsia_netemul_network::NetworkContextMarker>,
2622        control_handle: SandboxControlHandle,
2623    },
2624}
2625
2626impl SandboxRequest {
2627    #[allow(irrefutable_let_patterns)]
2628    pub fn into_create_realm(
2629        self,
2630    ) -> Option<(fidl::endpoints::ServerEnd<ManagedRealmMarker>, RealmOptions, SandboxControlHandle)>
2631    {
2632        if let SandboxRequest::CreateRealm { realm, options, control_handle } = self {
2633            Some((realm, options, control_handle))
2634        } else {
2635            None
2636        }
2637    }
2638
2639    #[allow(irrefutable_let_patterns)]
2640    pub fn into_get_network_context(
2641        self,
2642    ) -> Option<(
2643        fidl::endpoints::ServerEnd<fidl_fuchsia_netemul_network::NetworkContextMarker>,
2644        SandboxControlHandle,
2645    )> {
2646        if let SandboxRequest::GetNetworkContext { network_context, control_handle } = self {
2647            Some((network_context, control_handle))
2648        } else {
2649            None
2650        }
2651    }
2652
2653    /// Name of the method defined in FIDL
2654    pub fn method_name(&self) -> &'static str {
2655        match *self {
2656            SandboxRequest::CreateRealm { .. } => "create_realm",
2657            SandboxRequest::GetNetworkContext { .. } => "get_network_context",
2658        }
2659    }
2660}
2661
2662#[derive(Debug, Clone)]
2663pub struct SandboxControlHandle {
2664    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2665}
2666
2667impl fidl::endpoints::ControlHandle for SandboxControlHandle {
2668    fn shutdown(&self) {
2669        self.inner.shutdown()
2670    }
2671    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2672        self.inner.shutdown_with_epitaph(status)
2673    }
2674
2675    fn is_closed(&self) -> bool {
2676        self.inner.channel().is_closed()
2677    }
2678    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2679        self.inner.channel().on_closed()
2680    }
2681
2682    #[cfg(target_os = "fuchsia")]
2683    fn signal_peer(
2684        &self,
2685        clear_mask: zx::Signals,
2686        set_mask: zx::Signals,
2687    ) -> Result<(), zx_status::Status> {
2688        use fidl::Peered;
2689        self.inner.channel().signal_peer(clear_mask, set_mask)
2690    }
2691}
2692
2693impl SandboxControlHandle {}
2694
2695mod internal {
2696    use super::*;
2697
2698    impl fidl::encoding::ResourceTypeMarker for ManagedRealmAddDeviceRequest {
2699        type Borrowed<'a> = &'a mut Self;
2700        fn take_or_borrow<'a>(
2701            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2702        ) -> Self::Borrowed<'a> {
2703            value
2704        }
2705    }
2706
2707    unsafe impl fidl::encoding::TypeMarker for ManagedRealmAddDeviceRequest {
2708        type Owned = Self;
2709
2710        #[inline(always)]
2711        fn inline_align(_context: fidl::encoding::Context) -> usize {
2712            8
2713        }
2714
2715        #[inline(always)]
2716        fn inline_size(_context: fidl::encoding::Context) -> usize {
2717            24
2718        }
2719    }
2720
2721    unsafe impl
2722        fidl::encoding::Encode<
2723            ManagedRealmAddDeviceRequest,
2724            fidl::encoding::DefaultFuchsiaResourceDialect,
2725        > for &mut ManagedRealmAddDeviceRequest
2726    {
2727        #[inline]
2728        unsafe fn encode(
2729            self,
2730            encoder: &mut fidl::encoding::Encoder<
2731                '_,
2732                fidl::encoding::DefaultFuchsiaResourceDialect,
2733            >,
2734            offset: usize,
2735            _depth: fidl::encoding::Depth,
2736        ) -> fidl::Result<()> {
2737            encoder.debug_check_bounds::<ManagedRealmAddDeviceRequest>(offset);
2738            // Delegate to tuple encoding.
2739            fidl::encoding::Encode::<
2740                ManagedRealmAddDeviceRequest,
2741                fidl::encoding::DefaultFuchsiaResourceDialect,
2742            >::encode(
2743                (
2744                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
2745                        &self.path,
2746                    ),
2747                    <fidl::encoding::Endpoint<
2748                        fidl::endpoints::ClientEnd<
2749                            fidl_fuchsia_netemul_network::DeviceProxy_Marker,
2750                        >,
2751                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2752                        &mut self.device
2753                    ),
2754                ),
2755                encoder,
2756                offset,
2757                _depth,
2758            )
2759        }
2760    }
2761    unsafe impl<
2762            T0: fidl::encoding::Encode<
2763                fidl::encoding::UnboundedString,
2764                fidl::encoding::DefaultFuchsiaResourceDialect,
2765            >,
2766            T1: fidl::encoding::Encode<
2767                fidl::encoding::Endpoint<
2768                    fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::DeviceProxy_Marker>,
2769                >,
2770                fidl::encoding::DefaultFuchsiaResourceDialect,
2771            >,
2772        >
2773        fidl::encoding::Encode<
2774            ManagedRealmAddDeviceRequest,
2775            fidl::encoding::DefaultFuchsiaResourceDialect,
2776        > for (T0, T1)
2777    {
2778        #[inline]
2779        unsafe fn encode(
2780            self,
2781            encoder: &mut fidl::encoding::Encoder<
2782                '_,
2783                fidl::encoding::DefaultFuchsiaResourceDialect,
2784            >,
2785            offset: usize,
2786            depth: fidl::encoding::Depth,
2787        ) -> fidl::Result<()> {
2788            encoder.debug_check_bounds::<ManagedRealmAddDeviceRequest>(offset);
2789            // Zero out padding regions. There's no need to apply masks
2790            // because the unmasked parts will be overwritten by fields.
2791            unsafe {
2792                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2793                (ptr as *mut u64).write_unaligned(0);
2794            }
2795            // Write the fields.
2796            self.0.encode(encoder, offset + 0, depth)?;
2797            self.1.encode(encoder, offset + 16, depth)?;
2798            Ok(())
2799        }
2800    }
2801
2802    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2803        for ManagedRealmAddDeviceRequest
2804    {
2805        #[inline(always)]
2806        fn new_empty() -> Self {
2807            Self {
2808                path: fidl::new_empty!(
2809                    fidl::encoding::UnboundedString,
2810                    fidl::encoding::DefaultFuchsiaResourceDialect
2811                ),
2812                device: fidl::new_empty!(
2813                    fidl::encoding::Endpoint<
2814                        fidl::endpoints::ClientEnd<
2815                            fidl_fuchsia_netemul_network::DeviceProxy_Marker,
2816                        >,
2817                    >,
2818                    fidl::encoding::DefaultFuchsiaResourceDialect
2819                ),
2820            }
2821        }
2822
2823        #[inline]
2824        unsafe fn decode(
2825            &mut self,
2826            decoder: &mut fidl::encoding::Decoder<
2827                '_,
2828                fidl::encoding::DefaultFuchsiaResourceDialect,
2829            >,
2830            offset: usize,
2831            _depth: fidl::encoding::Depth,
2832        ) -> fidl::Result<()> {
2833            decoder.debug_check_bounds::<Self>(offset);
2834            // Verify that padding bytes are zero.
2835            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2836            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2837            let mask = 0xffffffff00000000u64;
2838            let maskedval = padval & mask;
2839            if maskedval != 0 {
2840                return Err(fidl::Error::NonZeroPadding {
2841                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2842                });
2843            }
2844            fidl::decode!(
2845                fidl::encoding::UnboundedString,
2846                fidl::encoding::DefaultFuchsiaResourceDialect,
2847                &mut self.path,
2848                decoder,
2849                offset + 0,
2850                _depth
2851            )?;
2852            fidl::decode!(
2853                fidl::encoding::Endpoint<
2854                    fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::DeviceProxy_Marker>,
2855                >,
2856                fidl::encoding::DefaultFuchsiaResourceDialect,
2857                &mut self.device,
2858                decoder,
2859                offset + 16,
2860                _depth
2861            )?;
2862            Ok(())
2863        }
2864    }
2865
2866    impl fidl::encoding::ResourceTypeMarker for ManagedRealmConnectToProtocolRequest {
2867        type Borrowed<'a> = &'a mut Self;
2868        fn take_or_borrow<'a>(
2869            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2870        ) -> Self::Borrowed<'a> {
2871            value
2872        }
2873    }
2874
2875    unsafe impl fidl::encoding::TypeMarker for ManagedRealmConnectToProtocolRequest {
2876        type Owned = Self;
2877
2878        #[inline(always)]
2879        fn inline_align(_context: fidl::encoding::Context) -> usize {
2880            8
2881        }
2882
2883        #[inline(always)]
2884        fn inline_size(_context: fidl::encoding::Context) -> usize {
2885            40
2886        }
2887    }
2888
2889    unsafe impl
2890        fidl::encoding::Encode<
2891            ManagedRealmConnectToProtocolRequest,
2892            fidl::encoding::DefaultFuchsiaResourceDialect,
2893        > for &mut ManagedRealmConnectToProtocolRequest
2894    {
2895        #[inline]
2896        unsafe fn encode(
2897            self,
2898            encoder: &mut fidl::encoding::Encoder<
2899                '_,
2900                fidl::encoding::DefaultFuchsiaResourceDialect,
2901            >,
2902            offset: usize,
2903            _depth: fidl::encoding::Depth,
2904        ) -> fidl::Result<()> {
2905            encoder.debug_check_bounds::<ManagedRealmConnectToProtocolRequest>(offset);
2906            // Delegate to tuple encoding.
2907            fidl::encoding::Encode::<ManagedRealmConnectToProtocolRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2908                (
2909                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.protocol_name),
2910                    <fidl::encoding::Optional<fidl::encoding::BoundedString<255>> as fidl::encoding::ValueTypeMarker>::borrow(&self.child_name),
2911                    <fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.req),
2912                ),
2913                encoder, offset, _depth
2914            )
2915        }
2916    }
2917    unsafe impl<
2918            T0: fidl::encoding::Encode<
2919                fidl::encoding::BoundedString<255>,
2920                fidl::encoding::DefaultFuchsiaResourceDialect,
2921            >,
2922            T1: fidl::encoding::Encode<
2923                fidl::encoding::Optional<fidl::encoding::BoundedString<255>>,
2924                fidl::encoding::DefaultFuchsiaResourceDialect,
2925            >,
2926            T2: fidl::encoding::Encode<
2927                fidl::encoding::HandleType<
2928                    fidl::Channel,
2929                    { fidl::ObjectType::CHANNEL.into_raw() },
2930                    2147483648,
2931                >,
2932                fidl::encoding::DefaultFuchsiaResourceDialect,
2933            >,
2934        >
2935        fidl::encoding::Encode<
2936            ManagedRealmConnectToProtocolRequest,
2937            fidl::encoding::DefaultFuchsiaResourceDialect,
2938        > for (T0, T1, T2)
2939    {
2940        #[inline]
2941        unsafe fn encode(
2942            self,
2943            encoder: &mut fidl::encoding::Encoder<
2944                '_,
2945                fidl::encoding::DefaultFuchsiaResourceDialect,
2946            >,
2947            offset: usize,
2948            depth: fidl::encoding::Depth,
2949        ) -> fidl::Result<()> {
2950            encoder.debug_check_bounds::<ManagedRealmConnectToProtocolRequest>(offset);
2951            // Zero out padding regions. There's no need to apply masks
2952            // because the unmasked parts will be overwritten by fields.
2953            unsafe {
2954                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
2955                (ptr as *mut u64).write_unaligned(0);
2956            }
2957            // Write the fields.
2958            self.0.encode(encoder, offset + 0, depth)?;
2959            self.1.encode(encoder, offset + 16, depth)?;
2960            self.2.encode(encoder, offset + 32, depth)?;
2961            Ok(())
2962        }
2963    }
2964
2965    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2966        for ManagedRealmConnectToProtocolRequest
2967    {
2968        #[inline(always)]
2969        fn new_empty() -> Self {
2970            Self {
2971                protocol_name: fidl::new_empty!(
2972                    fidl::encoding::BoundedString<255>,
2973                    fidl::encoding::DefaultFuchsiaResourceDialect
2974                ),
2975                child_name: fidl::new_empty!(
2976                    fidl::encoding::Optional<fidl::encoding::BoundedString<255>>,
2977                    fidl::encoding::DefaultFuchsiaResourceDialect
2978                ),
2979                req: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2980            }
2981        }
2982
2983        #[inline]
2984        unsafe fn decode(
2985            &mut self,
2986            decoder: &mut fidl::encoding::Decoder<
2987                '_,
2988                fidl::encoding::DefaultFuchsiaResourceDialect,
2989            >,
2990            offset: usize,
2991            _depth: fidl::encoding::Depth,
2992        ) -> fidl::Result<()> {
2993            decoder.debug_check_bounds::<Self>(offset);
2994            // Verify that padding bytes are zero.
2995            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
2996            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2997            let mask = 0xffffffff00000000u64;
2998            let maskedval = padval & mask;
2999            if maskedval != 0 {
3000                return Err(fidl::Error::NonZeroPadding {
3001                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
3002                });
3003            }
3004            fidl::decode!(
3005                fidl::encoding::BoundedString<255>,
3006                fidl::encoding::DefaultFuchsiaResourceDialect,
3007                &mut self.protocol_name,
3008                decoder,
3009                offset + 0,
3010                _depth
3011            )?;
3012            fidl::decode!(
3013                fidl::encoding::Optional<fidl::encoding::BoundedString<255>>,
3014                fidl::encoding::DefaultFuchsiaResourceDialect,
3015                &mut self.child_name,
3016                decoder,
3017                offset + 16,
3018                _depth
3019            )?;
3020            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.req, decoder, offset + 32, _depth)?;
3021            Ok(())
3022        }
3023    }
3024
3025    impl fidl::encoding::ResourceTypeMarker for ManagedRealmGetDevfsRequest {
3026        type Borrowed<'a> = &'a mut Self;
3027        fn take_or_borrow<'a>(
3028            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3029        ) -> Self::Borrowed<'a> {
3030            value
3031        }
3032    }
3033
3034    unsafe impl fidl::encoding::TypeMarker for ManagedRealmGetDevfsRequest {
3035        type Owned = Self;
3036
3037        #[inline(always)]
3038        fn inline_align(_context: fidl::encoding::Context) -> usize {
3039            4
3040        }
3041
3042        #[inline(always)]
3043        fn inline_size(_context: fidl::encoding::Context) -> usize {
3044            4
3045        }
3046    }
3047
3048    unsafe impl
3049        fidl::encoding::Encode<
3050            ManagedRealmGetDevfsRequest,
3051            fidl::encoding::DefaultFuchsiaResourceDialect,
3052        > for &mut ManagedRealmGetDevfsRequest
3053    {
3054        #[inline]
3055        unsafe fn encode(
3056            self,
3057            encoder: &mut fidl::encoding::Encoder<
3058                '_,
3059                fidl::encoding::DefaultFuchsiaResourceDialect,
3060            >,
3061            offset: usize,
3062            _depth: fidl::encoding::Depth,
3063        ) -> fidl::Result<()> {
3064            encoder.debug_check_bounds::<ManagedRealmGetDevfsRequest>(offset);
3065            // Delegate to tuple encoding.
3066            fidl::encoding::Encode::<
3067                ManagedRealmGetDevfsRequest,
3068                fidl::encoding::DefaultFuchsiaResourceDialect,
3069            >::encode(
3070                (<fidl::encoding::Endpoint<
3071                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3072                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3073                    &mut self.devfs
3074                ),),
3075                encoder,
3076                offset,
3077                _depth,
3078            )
3079        }
3080    }
3081    unsafe impl<
3082            T0: fidl::encoding::Encode<
3083                fidl::encoding::Endpoint<
3084                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3085                >,
3086                fidl::encoding::DefaultFuchsiaResourceDialect,
3087            >,
3088        >
3089        fidl::encoding::Encode<
3090            ManagedRealmGetDevfsRequest,
3091            fidl::encoding::DefaultFuchsiaResourceDialect,
3092        > for (T0,)
3093    {
3094        #[inline]
3095        unsafe fn encode(
3096            self,
3097            encoder: &mut fidl::encoding::Encoder<
3098                '_,
3099                fidl::encoding::DefaultFuchsiaResourceDialect,
3100            >,
3101            offset: usize,
3102            depth: fidl::encoding::Depth,
3103        ) -> fidl::Result<()> {
3104            encoder.debug_check_bounds::<ManagedRealmGetDevfsRequest>(offset);
3105            // Zero out padding regions. There's no need to apply masks
3106            // because the unmasked parts will be overwritten by fields.
3107            // Write the fields.
3108            self.0.encode(encoder, offset + 0, depth)?;
3109            Ok(())
3110        }
3111    }
3112
3113    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3114        for ManagedRealmGetDevfsRequest
3115    {
3116        #[inline(always)]
3117        fn new_empty() -> Self {
3118            Self {
3119                devfs: fidl::new_empty!(
3120                    fidl::encoding::Endpoint<
3121                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3122                    >,
3123                    fidl::encoding::DefaultFuchsiaResourceDialect
3124                ),
3125            }
3126        }
3127
3128        #[inline]
3129        unsafe fn decode(
3130            &mut self,
3131            decoder: &mut fidl::encoding::Decoder<
3132                '_,
3133                fidl::encoding::DefaultFuchsiaResourceDialect,
3134            >,
3135            offset: usize,
3136            _depth: fidl::encoding::Depth,
3137        ) -> fidl::Result<()> {
3138            decoder.debug_check_bounds::<Self>(offset);
3139            // Verify that padding bytes are zero.
3140            fidl::decode!(
3141                fidl::encoding::Endpoint<
3142                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3143                >,
3144                fidl::encoding::DefaultFuchsiaResourceDialect,
3145                &mut self.devfs,
3146                decoder,
3147                offset + 0,
3148                _depth
3149            )?;
3150            Ok(())
3151        }
3152    }
3153
3154    impl fidl::encoding::ResourceTypeMarker for ManagedRealmOpenDiagnosticsDirectoryRequest {
3155        type Borrowed<'a> = &'a mut Self;
3156        fn take_or_borrow<'a>(
3157            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3158        ) -> Self::Borrowed<'a> {
3159            value
3160        }
3161    }
3162
3163    unsafe impl fidl::encoding::TypeMarker for ManagedRealmOpenDiagnosticsDirectoryRequest {
3164        type Owned = Self;
3165
3166        #[inline(always)]
3167        fn inline_align(_context: fidl::encoding::Context) -> usize {
3168            8
3169        }
3170
3171        #[inline(always)]
3172        fn inline_size(_context: fidl::encoding::Context) -> usize {
3173            24
3174        }
3175    }
3176
3177    unsafe impl
3178        fidl::encoding::Encode<
3179            ManagedRealmOpenDiagnosticsDirectoryRequest,
3180            fidl::encoding::DefaultFuchsiaResourceDialect,
3181        > for &mut ManagedRealmOpenDiagnosticsDirectoryRequest
3182    {
3183        #[inline]
3184        unsafe fn encode(
3185            self,
3186            encoder: &mut fidl::encoding::Encoder<
3187                '_,
3188                fidl::encoding::DefaultFuchsiaResourceDialect,
3189            >,
3190            offset: usize,
3191            _depth: fidl::encoding::Depth,
3192        ) -> fidl::Result<()> {
3193            encoder.debug_check_bounds::<ManagedRealmOpenDiagnosticsDirectoryRequest>(offset);
3194            // Delegate to tuple encoding.
3195            fidl::encoding::Encode::<
3196                ManagedRealmOpenDiagnosticsDirectoryRequest,
3197                fidl::encoding::DefaultFuchsiaResourceDialect,
3198            >::encode(
3199                (
3200                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
3201                        &self.child_name,
3202                    ),
3203                    <fidl::encoding::Endpoint<
3204                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3205                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3206                        &mut self.directory
3207                    ),
3208                ),
3209                encoder,
3210                offset,
3211                _depth,
3212            )
3213        }
3214    }
3215    unsafe impl<
3216            T0: fidl::encoding::Encode<
3217                fidl::encoding::BoundedString<255>,
3218                fidl::encoding::DefaultFuchsiaResourceDialect,
3219            >,
3220            T1: fidl::encoding::Encode<
3221                fidl::encoding::Endpoint<
3222                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3223                >,
3224                fidl::encoding::DefaultFuchsiaResourceDialect,
3225            >,
3226        >
3227        fidl::encoding::Encode<
3228            ManagedRealmOpenDiagnosticsDirectoryRequest,
3229            fidl::encoding::DefaultFuchsiaResourceDialect,
3230        > for (T0, T1)
3231    {
3232        #[inline]
3233        unsafe fn encode(
3234            self,
3235            encoder: &mut fidl::encoding::Encoder<
3236                '_,
3237                fidl::encoding::DefaultFuchsiaResourceDialect,
3238            >,
3239            offset: usize,
3240            depth: fidl::encoding::Depth,
3241        ) -> fidl::Result<()> {
3242            encoder.debug_check_bounds::<ManagedRealmOpenDiagnosticsDirectoryRequest>(offset);
3243            // Zero out padding regions. There's no need to apply masks
3244            // because the unmasked parts will be overwritten by fields.
3245            unsafe {
3246                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3247                (ptr as *mut u64).write_unaligned(0);
3248            }
3249            // Write the fields.
3250            self.0.encode(encoder, offset + 0, depth)?;
3251            self.1.encode(encoder, offset + 16, depth)?;
3252            Ok(())
3253        }
3254    }
3255
3256    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3257        for ManagedRealmOpenDiagnosticsDirectoryRequest
3258    {
3259        #[inline(always)]
3260        fn new_empty() -> Self {
3261            Self {
3262                child_name: fidl::new_empty!(
3263                    fidl::encoding::BoundedString<255>,
3264                    fidl::encoding::DefaultFuchsiaResourceDialect
3265                ),
3266                directory: fidl::new_empty!(
3267                    fidl::encoding::Endpoint<
3268                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3269                    >,
3270                    fidl::encoding::DefaultFuchsiaResourceDialect
3271                ),
3272            }
3273        }
3274
3275        #[inline]
3276        unsafe fn decode(
3277            &mut self,
3278            decoder: &mut fidl::encoding::Decoder<
3279                '_,
3280                fidl::encoding::DefaultFuchsiaResourceDialect,
3281            >,
3282            offset: usize,
3283            _depth: fidl::encoding::Depth,
3284        ) -> fidl::Result<()> {
3285            decoder.debug_check_bounds::<Self>(offset);
3286            // Verify that padding bytes are zero.
3287            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3288            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3289            let mask = 0xffffffff00000000u64;
3290            let maskedval = padval & mask;
3291            if maskedval != 0 {
3292                return Err(fidl::Error::NonZeroPadding {
3293                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3294                });
3295            }
3296            fidl::decode!(
3297                fidl::encoding::BoundedString<255>,
3298                fidl::encoding::DefaultFuchsiaResourceDialect,
3299                &mut self.child_name,
3300                decoder,
3301                offset + 0,
3302                _depth
3303            )?;
3304            fidl::decode!(
3305                fidl::encoding::Endpoint<
3306                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3307                >,
3308                fidl::encoding::DefaultFuchsiaResourceDialect,
3309                &mut self.directory,
3310                decoder,
3311                offset + 16,
3312                _depth
3313            )?;
3314            Ok(())
3315        }
3316    }
3317
3318    impl fidl::encoding::ResourceTypeMarker for SandboxCreateRealmRequest {
3319        type Borrowed<'a> = &'a mut Self;
3320        fn take_or_borrow<'a>(
3321            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3322        ) -> Self::Borrowed<'a> {
3323            value
3324        }
3325    }
3326
3327    unsafe impl fidl::encoding::TypeMarker for SandboxCreateRealmRequest {
3328        type Owned = Self;
3329
3330        #[inline(always)]
3331        fn inline_align(_context: fidl::encoding::Context) -> usize {
3332            8
3333        }
3334
3335        #[inline(always)]
3336        fn inline_size(_context: fidl::encoding::Context) -> usize {
3337            24
3338        }
3339    }
3340
3341    unsafe impl
3342        fidl::encoding::Encode<
3343            SandboxCreateRealmRequest,
3344            fidl::encoding::DefaultFuchsiaResourceDialect,
3345        > for &mut SandboxCreateRealmRequest
3346    {
3347        #[inline]
3348        unsafe fn encode(
3349            self,
3350            encoder: &mut fidl::encoding::Encoder<
3351                '_,
3352                fidl::encoding::DefaultFuchsiaResourceDialect,
3353            >,
3354            offset: usize,
3355            _depth: fidl::encoding::Depth,
3356        ) -> fidl::Result<()> {
3357            encoder.debug_check_bounds::<SandboxCreateRealmRequest>(offset);
3358            // Delegate to tuple encoding.
3359            fidl::encoding::Encode::<SandboxCreateRealmRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3360                (
3361                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ManagedRealmMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.realm),
3362                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.options),
3363                ),
3364                encoder, offset, _depth
3365            )
3366        }
3367    }
3368    unsafe impl<
3369            T0: fidl::encoding::Encode<
3370                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ManagedRealmMarker>>,
3371                fidl::encoding::DefaultFuchsiaResourceDialect,
3372            >,
3373            T1: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
3374        >
3375        fidl::encoding::Encode<
3376            SandboxCreateRealmRequest,
3377            fidl::encoding::DefaultFuchsiaResourceDialect,
3378        > for (T0, T1)
3379    {
3380        #[inline]
3381        unsafe fn encode(
3382            self,
3383            encoder: &mut fidl::encoding::Encoder<
3384                '_,
3385                fidl::encoding::DefaultFuchsiaResourceDialect,
3386            >,
3387            offset: usize,
3388            depth: fidl::encoding::Depth,
3389        ) -> fidl::Result<()> {
3390            encoder.debug_check_bounds::<SandboxCreateRealmRequest>(offset);
3391            // Zero out padding regions. There's no need to apply masks
3392            // because the unmasked parts will be overwritten by fields.
3393            unsafe {
3394                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3395                (ptr as *mut u64).write_unaligned(0);
3396            }
3397            // Write the fields.
3398            self.0.encode(encoder, offset + 0, depth)?;
3399            self.1.encode(encoder, offset + 8, depth)?;
3400            Ok(())
3401        }
3402    }
3403
3404    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3405        for SandboxCreateRealmRequest
3406    {
3407        #[inline(always)]
3408        fn new_empty() -> Self {
3409            Self {
3410                realm: fidl::new_empty!(
3411                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ManagedRealmMarker>>,
3412                    fidl::encoding::DefaultFuchsiaResourceDialect
3413                ),
3414                options: fidl::new_empty!(
3415                    RealmOptions,
3416                    fidl::encoding::DefaultFuchsiaResourceDialect
3417                ),
3418            }
3419        }
3420
3421        #[inline]
3422        unsafe fn decode(
3423            &mut self,
3424            decoder: &mut fidl::encoding::Decoder<
3425                '_,
3426                fidl::encoding::DefaultFuchsiaResourceDialect,
3427            >,
3428            offset: usize,
3429            _depth: fidl::encoding::Depth,
3430        ) -> fidl::Result<()> {
3431            decoder.debug_check_bounds::<Self>(offset);
3432            // Verify that padding bytes are zero.
3433            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3434            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3435            let mask = 0xffffffff00000000u64;
3436            let maskedval = padval & mask;
3437            if maskedval != 0 {
3438                return Err(fidl::Error::NonZeroPadding {
3439                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3440                });
3441            }
3442            fidl::decode!(
3443                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ManagedRealmMarker>>,
3444                fidl::encoding::DefaultFuchsiaResourceDialect,
3445                &mut self.realm,
3446                decoder,
3447                offset + 0,
3448                _depth
3449            )?;
3450            fidl::decode!(
3451                RealmOptions,
3452                fidl::encoding::DefaultFuchsiaResourceDialect,
3453                &mut self.options,
3454                decoder,
3455                offset + 8,
3456                _depth
3457            )?;
3458            Ok(())
3459        }
3460    }
3461
3462    impl fidl::encoding::ResourceTypeMarker for SandboxGetNetworkContextRequest {
3463        type Borrowed<'a> = &'a mut Self;
3464        fn take_or_borrow<'a>(
3465            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3466        ) -> Self::Borrowed<'a> {
3467            value
3468        }
3469    }
3470
3471    unsafe impl fidl::encoding::TypeMarker for SandboxGetNetworkContextRequest {
3472        type Owned = Self;
3473
3474        #[inline(always)]
3475        fn inline_align(_context: fidl::encoding::Context) -> usize {
3476            4
3477        }
3478
3479        #[inline(always)]
3480        fn inline_size(_context: fidl::encoding::Context) -> usize {
3481            4
3482        }
3483    }
3484
3485    unsafe impl
3486        fidl::encoding::Encode<
3487            SandboxGetNetworkContextRequest,
3488            fidl::encoding::DefaultFuchsiaResourceDialect,
3489        > for &mut SandboxGetNetworkContextRequest
3490    {
3491        #[inline]
3492        unsafe fn encode(
3493            self,
3494            encoder: &mut fidl::encoding::Encoder<
3495                '_,
3496                fidl::encoding::DefaultFuchsiaResourceDialect,
3497            >,
3498            offset: usize,
3499            _depth: fidl::encoding::Depth,
3500        ) -> fidl::Result<()> {
3501            encoder.debug_check_bounds::<SandboxGetNetworkContextRequest>(offset);
3502            // Delegate to tuple encoding.
3503            fidl::encoding::Encode::<
3504                SandboxGetNetworkContextRequest,
3505                fidl::encoding::DefaultFuchsiaResourceDialect,
3506            >::encode(
3507                (<fidl::encoding::Endpoint<
3508                    fidl::endpoints::ServerEnd<fidl_fuchsia_netemul_network::NetworkContextMarker>,
3509                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3510                    &mut self.network_context,
3511                ),),
3512                encoder,
3513                offset,
3514                _depth,
3515            )
3516        }
3517    }
3518    unsafe impl<
3519            T0: fidl::encoding::Encode<
3520                fidl::encoding::Endpoint<
3521                    fidl::endpoints::ServerEnd<fidl_fuchsia_netemul_network::NetworkContextMarker>,
3522                >,
3523                fidl::encoding::DefaultFuchsiaResourceDialect,
3524            >,
3525        >
3526        fidl::encoding::Encode<
3527            SandboxGetNetworkContextRequest,
3528            fidl::encoding::DefaultFuchsiaResourceDialect,
3529        > for (T0,)
3530    {
3531        #[inline]
3532        unsafe fn encode(
3533            self,
3534            encoder: &mut fidl::encoding::Encoder<
3535                '_,
3536                fidl::encoding::DefaultFuchsiaResourceDialect,
3537            >,
3538            offset: usize,
3539            depth: fidl::encoding::Depth,
3540        ) -> fidl::Result<()> {
3541            encoder.debug_check_bounds::<SandboxGetNetworkContextRequest>(offset);
3542            // Zero out padding regions. There's no need to apply masks
3543            // because the unmasked parts will be overwritten by fields.
3544            // Write the fields.
3545            self.0.encode(encoder, offset + 0, depth)?;
3546            Ok(())
3547        }
3548    }
3549
3550    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3551        for SandboxGetNetworkContextRequest
3552    {
3553        #[inline(always)]
3554        fn new_empty() -> Self {
3555            Self {
3556                network_context: fidl::new_empty!(
3557                    fidl::encoding::Endpoint<
3558                        fidl::endpoints::ServerEnd<
3559                            fidl_fuchsia_netemul_network::NetworkContextMarker,
3560                        >,
3561                    >,
3562                    fidl::encoding::DefaultFuchsiaResourceDialect
3563                ),
3564            }
3565        }
3566
3567        #[inline]
3568        unsafe fn decode(
3569            &mut self,
3570            decoder: &mut fidl::encoding::Decoder<
3571                '_,
3572                fidl::encoding::DefaultFuchsiaResourceDialect,
3573            >,
3574            offset: usize,
3575            _depth: fidl::encoding::Depth,
3576        ) -> fidl::Result<()> {
3577            decoder.debug_check_bounds::<Self>(offset);
3578            // Verify that padding bytes are zero.
3579            fidl::decode!(
3580                fidl::encoding::Endpoint<
3581                    fidl::endpoints::ServerEnd<fidl_fuchsia_netemul_network::NetworkContextMarker>,
3582                >,
3583                fidl::encoding::DefaultFuchsiaResourceDialect,
3584                &mut self.network_context,
3585                decoder,
3586                offset + 0,
3587                _depth
3588            )?;
3589            Ok(())
3590        }
3591    }
3592
3593    impl ChildDef {
3594        #[inline(always)]
3595        fn max_ordinal_present(&self) -> u64 {
3596            if let Some(_) = self.config_values {
3597                return 7;
3598            }
3599            if let Some(_) = self.eager {
3600                return 6;
3601            }
3602            if let Some(_) = self.program_args {
3603                return 5;
3604            }
3605            if let Some(_) = self.uses {
3606                return 4;
3607            }
3608            if let Some(_) = self.exposes {
3609                return 3;
3610            }
3611            if let Some(_) = self.name {
3612                return 2;
3613            }
3614            if let Some(_) = self.source {
3615                return 1;
3616            }
3617            0
3618        }
3619    }
3620
3621    impl fidl::encoding::ResourceTypeMarker for ChildDef {
3622        type Borrowed<'a> = &'a mut Self;
3623        fn take_or_borrow<'a>(
3624            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3625        ) -> Self::Borrowed<'a> {
3626            value
3627        }
3628    }
3629
3630    unsafe impl fidl::encoding::TypeMarker for ChildDef {
3631        type Owned = Self;
3632
3633        #[inline(always)]
3634        fn inline_align(_context: fidl::encoding::Context) -> usize {
3635            8
3636        }
3637
3638        #[inline(always)]
3639        fn inline_size(_context: fidl::encoding::Context) -> usize {
3640            16
3641        }
3642    }
3643
3644    unsafe impl fidl::encoding::Encode<ChildDef, fidl::encoding::DefaultFuchsiaResourceDialect>
3645        for &mut ChildDef
3646    {
3647        unsafe fn encode(
3648            self,
3649            encoder: &mut fidl::encoding::Encoder<
3650                '_,
3651                fidl::encoding::DefaultFuchsiaResourceDialect,
3652            >,
3653            offset: usize,
3654            mut depth: fidl::encoding::Depth,
3655        ) -> fidl::Result<()> {
3656            encoder.debug_check_bounds::<ChildDef>(offset);
3657            // Vector header
3658            let max_ordinal: u64 = self.max_ordinal_present();
3659            encoder.write_num(max_ordinal, offset);
3660            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3661            // Calling encoder.out_of_line_offset(0) is not allowed.
3662            if max_ordinal == 0 {
3663                return Ok(());
3664            }
3665            depth.increment()?;
3666            let envelope_size = 8;
3667            let bytes_len = max_ordinal as usize * envelope_size;
3668            #[allow(unused_variables)]
3669            let offset = encoder.out_of_line_offset(bytes_len);
3670            let mut _prev_end_offset: usize = 0;
3671            if 1 > max_ordinal {
3672                return Ok(());
3673            }
3674
3675            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3676            // are envelope_size bytes.
3677            let cur_offset: usize = (1 - 1) * envelope_size;
3678
3679            // Zero reserved fields.
3680            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3681
3682            // Safety:
3683            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3684            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3685            //   envelope_size bytes, there is always sufficient room.
3686            fidl::encoding::encode_in_envelope_optional::<
3687                ChildSource,
3688                fidl::encoding::DefaultFuchsiaResourceDialect,
3689            >(
3690                self.source
3691                    .as_mut()
3692                    .map(<ChildSource as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3693                encoder,
3694                offset + cur_offset,
3695                depth,
3696            )?;
3697
3698            _prev_end_offset = cur_offset + envelope_size;
3699            if 2 > max_ordinal {
3700                return Ok(());
3701            }
3702
3703            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3704            // are envelope_size bytes.
3705            let cur_offset: usize = (2 - 1) * envelope_size;
3706
3707            // Zero reserved fields.
3708            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3709
3710            // Safety:
3711            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3712            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3713            //   envelope_size bytes, there is always sufficient room.
3714            fidl::encoding::encode_in_envelope_optional::<
3715                fidl::encoding::BoundedString<255>,
3716                fidl::encoding::DefaultFuchsiaResourceDialect,
3717            >(
3718                self.name.as_ref().map(
3719                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow,
3720                ),
3721                encoder,
3722                offset + cur_offset,
3723                depth,
3724            )?;
3725
3726            _prev_end_offset = cur_offset + envelope_size;
3727            if 3 > max_ordinal {
3728                return Ok(());
3729            }
3730
3731            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3732            // are envelope_size bytes.
3733            let cur_offset: usize = (3 - 1) * envelope_size;
3734
3735            // Zero reserved fields.
3736            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3737
3738            // Safety:
3739            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3740            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3741            //   envelope_size bytes, there is always sufficient room.
3742            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<255>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3743            self.exposes.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<255>> as fidl::encoding::ValueTypeMarker>::borrow),
3744            encoder, offset + cur_offset, depth
3745        )?;
3746
3747            _prev_end_offset = cur_offset + envelope_size;
3748            if 4 > max_ordinal {
3749                return Ok(());
3750            }
3751
3752            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3753            // are envelope_size bytes.
3754            let cur_offset: usize = (4 - 1) * envelope_size;
3755
3756            // Zero reserved fields.
3757            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3758
3759            // Safety:
3760            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3761            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3762            //   envelope_size bytes, there is always sufficient room.
3763            fidl::encoding::encode_in_envelope_optional::<
3764                ChildUses,
3765                fidl::encoding::DefaultFuchsiaResourceDialect,
3766            >(
3767                self.uses.as_ref().map(<ChildUses as fidl::encoding::ValueTypeMarker>::borrow),
3768                encoder,
3769                offset + cur_offset,
3770                depth,
3771            )?;
3772
3773            _prev_end_offset = cur_offset + envelope_size;
3774            if 5 > max_ordinal {
3775                return Ok(());
3776            }
3777
3778            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3779            // are envelope_size bytes.
3780            let cur_offset: usize = (5 - 1) * envelope_size;
3781
3782            // Zero reserved fields.
3783            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3784
3785            // Safety:
3786            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3787            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3788            //   envelope_size bytes, there is always sufficient room.
3789            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3790            self.program_args.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow),
3791            encoder, offset + cur_offset, depth
3792        )?;
3793
3794            _prev_end_offset = cur_offset + envelope_size;
3795            if 6 > max_ordinal {
3796                return Ok(());
3797            }
3798
3799            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3800            // are envelope_size bytes.
3801            let cur_offset: usize = (6 - 1) * envelope_size;
3802
3803            // Zero reserved fields.
3804            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3805
3806            // Safety:
3807            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3808            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3809            //   envelope_size bytes, there is always sufficient room.
3810            fidl::encoding::encode_in_envelope_optional::<
3811                bool,
3812                fidl::encoding::DefaultFuchsiaResourceDialect,
3813            >(
3814                self.eager.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3815                encoder,
3816                offset + cur_offset,
3817                depth,
3818            )?;
3819
3820            _prev_end_offset = cur_offset + envelope_size;
3821            if 7 > max_ordinal {
3822                return Ok(());
3823            }
3824
3825            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3826            // are envelope_size bytes.
3827            let cur_offset: usize = (7 - 1) * envelope_size;
3828
3829            // Zero reserved fields.
3830            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3831
3832            // Safety:
3833            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3834            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3835            //   envelope_size bytes, there is always sufficient room.
3836            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<ChildConfigValue>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3837            self.config_values.as_ref().map(<fidl::encoding::UnboundedVector<ChildConfigValue> as fidl::encoding::ValueTypeMarker>::borrow),
3838            encoder, offset + cur_offset, depth
3839        )?;
3840
3841            _prev_end_offset = cur_offset + envelope_size;
3842
3843            Ok(())
3844        }
3845    }
3846
3847    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for ChildDef {
3848        #[inline(always)]
3849        fn new_empty() -> Self {
3850            Self::default()
3851        }
3852
3853        unsafe fn decode(
3854            &mut self,
3855            decoder: &mut fidl::encoding::Decoder<
3856                '_,
3857                fidl::encoding::DefaultFuchsiaResourceDialect,
3858            >,
3859            offset: usize,
3860            mut depth: fidl::encoding::Depth,
3861        ) -> fidl::Result<()> {
3862            decoder.debug_check_bounds::<Self>(offset);
3863            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3864                None => return Err(fidl::Error::NotNullable),
3865                Some(len) => len,
3866            };
3867            // Calling decoder.out_of_line_offset(0) is not allowed.
3868            if len == 0 {
3869                return Ok(());
3870            };
3871            depth.increment()?;
3872            let envelope_size = 8;
3873            let bytes_len = len * envelope_size;
3874            let offset = decoder.out_of_line_offset(bytes_len)?;
3875            // Decode the envelope for each type.
3876            let mut _next_ordinal_to_read = 0;
3877            let mut next_offset = offset;
3878            let end_offset = offset + bytes_len;
3879            _next_ordinal_to_read += 1;
3880            if next_offset >= end_offset {
3881                return Ok(());
3882            }
3883
3884            // Decode unknown envelopes for gaps in ordinals.
3885            while _next_ordinal_to_read < 1 {
3886                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3887                _next_ordinal_to_read += 1;
3888                next_offset += envelope_size;
3889            }
3890
3891            let next_out_of_line = decoder.next_out_of_line();
3892            let handles_before = decoder.remaining_handles();
3893            if let Some((inlined, num_bytes, num_handles)) =
3894                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3895            {
3896                let member_inline_size =
3897                    <ChildSource as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3898                if inlined != (member_inline_size <= 4) {
3899                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3900                }
3901                let inner_offset;
3902                let mut inner_depth = depth.clone();
3903                if inlined {
3904                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3905                    inner_offset = next_offset;
3906                } else {
3907                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3908                    inner_depth.increment()?;
3909                }
3910                let val_ref = self.source.get_or_insert_with(|| {
3911                    fidl::new_empty!(ChildSource, fidl::encoding::DefaultFuchsiaResourceDialect)
3912                });
3913                fidl::decode!(
3914                    ChildSource,
3915                    fidl::encoding::DefaultFuchsiaResourceDialect,
3916                    val_ref,
3917                    decoder,
3918                    inner_offset,
3919                    inner_depth
3920                )?;
3921                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3922                {
3923                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3924                }
3925                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3926                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3927                }
3928            }
3929
3930            next_offset += envelope_size;
3931            _next_ordinal_to_read += 1;
3932            if next_offset >= end_offset {
3933                return Ok(());
3934            }
3935
3936            // Decode unknown envelopes for gaps in ordinals.
3937            while _next_ordinal_to_read < 2 {
3938                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3939                _next_ordinal_to_read += 1;
3940                next_offset += envelope_size;
3941            }
3942
3943            let next_out_of_line = decoder.next_out_of_line();
3944            let handles_before = decoder.remaining_handles();
3945            if let Some((inlined, num_bytes, num_handles)) =
3946                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3947            {
3948                let member_inline_size =
3949                    <fidl::encoding::BoundedString<255> as fidl::encoding::TypeMarker>::inline_size(
3950                        decoder.context,
3951                    );
3952                if inlined != (member_inline_size <= 4) {
3953                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3954                }
3955                let inner_offset;
3956                let mut inner_depth = depth.clone();
3957                if inlined {
3958                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3959                    inner_offset = next_offset;
3960                } else {
3961                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3962                    inner_depth.increment()?;
3963                }
3964                let val_ref = self.name.get_or_insert_with(|| {
3965                    fidl::new_empty!(
3966                        fidl::encoding::BoundedString<255>,
3967                        fidl::encoding::DefaultFuchsiaResourceDialect
3968                    )
3969                });
3970                fidl::decode!(
3971                    fidl::encoding::BoundedString<255>,
3972                    fidl::encoding::DefaultFuchsiaResourceDialect,
3973                    val_ref,
3974                    decoder,
3975                    inner_offset,
3976                    inner_depth
3977                )?;
3978                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3979                {
3980                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3981                }
3982                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3983                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3984                }
3985            }
3986
3987            next_offset += envelope_size;
3988            _next_ordinal_to_read += 1;
3989            if next_offset >= end_offset {
3990                return Ok(());
3991            }
3992
3993            // Decode unknown envelopes for gaps in ordinals.
3994            while _next_ordinal_to_read < 3 {
3995                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3996                _next_ordinal_to_read += 1;
3997                next_offset += envelope_size;
3998            }
3999
4000            let next_out_of_line = decoder.next_out_of_line();
4001            let handles_before = decoder.remaining_handles();
4002            if let Some((inlined, num_bytes, num_handles)) =
4003                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4004            {
4005                let member_inline_size = <fidl::encoding::UnboundedVector<
4006                    fidl::encoding::BoundedString<255>,
4007                > as fidl::encoding::TypeMarker>::inline_size(
4008                    decoder.context
4009                );
4010                if inlined != (member_inline_size <= 4) {
4011                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4012                }
4013                let inner_offset;
4014                let mut inner_depth = depth.clone();
4015                if inlined {
4016                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4017                    inner_offset = next_offset;
4018                } else {
4019                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4020                    inner_depth.increment()?;
4021                }
4022                let val_ref = self.exposes.get_or_insert_with(|| {
4023                    fidl::new_empty!(
4024                        fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<255>>,
4025                        fidl::encoding::DefaultFuchsiaResourceDialect
4026                    )
4027                });
4028                fidl::decode!(
4029                    fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<255>>,
4030                    fidl::encoding::DefaultFuchsiaResourceDialect,
4031                    val_ref,
4032                    decoder,
4033                    inner_offset,
4034                    inner_depth
4035                )?;
4036                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4037                {
4038                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4039                }
4040                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4041                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4042                }
4043            }
4044
4045            next_offset += envelope_size;
4046            _next_ordinal_to_read += 1;
4047            if next_offset >= end_offset {
4048                return Ok(());
4049            }
4050
4051            // Decode unknown envelopes for gaps in ordinals.
4052            while _next_ordinal_to_read < 4 {
4053                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4054                _next_ordinal_to_read += 1;
4055                next_offset += envelope_size;
4056            }
4057
4058            let next_out_of_line = decoder.next_out_of_line();
4059            let handles_before = decoder.remaining_handles();
4060            if let Some((inlined, num_bytes, num_handles)) =
4061                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4062            {
4063                let member_inline_size =
4064                    <ChildUses as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4065                if inlined != (member_inline_size <= 4) {
4066                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4067                }
4068                let inner_offset;
4069                let mut inner_depth = depth.clone();
4070                if inlined {
4071                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4072                    inner_offset = next_offset;
4073                } else {
4074                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4075                    inner_depth.increment()?;
4076                }
4077                let val_ref = self.uses.get_or_insert_with(|| {
4078                    fidl::new_empty!(ChildUses, fidl::encoding::DefaultFuchsiaResourceDialect)
4079                });
4080                fidl::decode!(
4081                    ChildUses,
4082                    fidl::encoding::DefaultFuchsiaResourceDialect,
4083                    val_ref,
4084                    decoder,
4085                    inner_offset,
4086                    inner_depth
4087                )?;
4088                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4089                {
4090                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4091                }
4092                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4093                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4094                }
4095            }
4096
4097            next_offset += envelope_size;
4098            _next_ordinal_to_read += 1;
4099            if next_offset >= end_offset {
4100                return Ok(());
4101            }
4102
4103            // Decode unknown envelopes for gaps in ordinals.
4104            while _next_ordinal_to_read < 5 {
4105                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4106                _next_ordinal_to_read += 1;
4107                next_offset += envelope_size;
4108            }
4109
4110            let next_out_of_line = decoder.next_out_of_line();
4111            let handles_before = decoder.remaining_handles();
4112            if let Some((inlined, num_bytes, num_handles)) =
4113                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4114            {
4115                let member_inline_size = <fidl::encoding::UnboundedVector<
4116                    fidl::encoding::UnboundedString,
4117                > as fidl::encoding::TypeMarker>::inline_size(
4118                    decoder.context
4119                );
4120                if inlined != (member_inline_size <= 4) {
4121                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4122                }
4123                let inner_offset;
4124                let mut inner_depth = depth.clone();
4125                if inlined {
4126                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4127                    inner_offset = next_offset;
4128                } else {
4129                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4130                    inner_depth.increment()?;
4131                }
4132                let val_ref = self.program_args.get_or_insert_with(|| {
4133                    fidl::new_empty!(
4134                        fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
4135                        fidl::encoding::DefaultFuchsiaResourceDialect
4136                    )
4137                });
4138                fidl::decode!(
4139                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
4140                    fidl::encoding::DefaultFuchsiaResourceDialect,
4141                    val_ref,
4142                    decoder,
4143                    inner_offset,
4144                    inner_depth
4145                )?;
4146                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4147                {
4148                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4149                }
4150                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4151                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4152                }
4153            }
4154
4155            next_offset += envelope_size;
4156            _next_ordinal_to_read += 1;
4157            if next_offset >= end_offset {
4158                return Ok(());
4159            }
4160
4161            // Decode unknown envelopes for gaps in ordinals.
4162            while _next_ordinal_to_read < 6 {
4163                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4164                _next_ordinal_to_read += 1;
4165                next_offset += envelope_size;
4166            }
4167
4168            let next_out_of_line = decoder.next_out_of_line();
4169            let handles_before = decoder.remaining_handles();
4170            if let Some((inlined, num_bytes, num_handles)) =
4171                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4172            {
4173                let member_inline_size =
4174                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4175                if inlined != (member_inline_size <= 4) {
4176                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4177                }
4178                let inner_offset;
4179                let mut inner_depth = depth.clone();
4180                if inlined {
4181                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4182                    inner_offset = next_offset;
4183                } else {
4184                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4185                    inner_depth.increment()?;
4186                }
4187                let val_ref = self.eager.get_or_insert_with(|| {
4188                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
4189                });
4190                fidl::decode!(
4191                    bool,
4192                    fidl::encoding::DefaultFuchsiaResourceDialect,
4193                    val_ref,
4194                    decoder,
4195                    inner_offset,
4196                    inner_depth
4197                )?;
4198                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4199                {
4200                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4201                }
4202                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4203                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4204                }
4205            }
4206
4207            next_offset += envelope_size;
4208            _next_ordinal_to_read += 1;
4209            if next_offset >= end_offset {
4210                return Ok(());
4211            }
4212
4213            // Decode unknown envelopes for gaps in ordinals.
4214            while _next_ordinal_to_read < 7 {
4215                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4216                _next_ordinal_to_read += 1;
4217                next_offset += envelope_size;
4218            }
4219
4220            let next_out_of_line = decoder.next_out_of_line();
4221            let handles_before = decoder.remaining_handles();
4222            if let Some((inlined, num_bytes, num_handles)) =
4223                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4224            {
4225                let member_inline_size = <fidl::encoding::UnboundedVector<ChildConfigValue> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4226                if inlined != (member_inline_size <= 4) {
4227                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4228                }
4229                let inner_offset;
4230                let mut inner_depth = depth.clone();
4231                if inlined {
4232                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4233                    inner_offset = next_offset;
4234                } else {
4235                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4236                    inner_depth.increment()?;
4237                }
4238                let val_ref = self.config_values.get_or_insert_with(|| {
4239                    fidl::new_empty!(
4240                        fidl::encoding::UnboundedVector<ChildConfigValue>,
4241                        fidl::encoding::DefaultFuchsiaResourceDialect
4242                    )
4243                });
4244                fidl::decode!(
4245                    fidl::encoding::UnboundedVector<ChildConfigValue>,
4246                    fidl::encoding::DefaultFuchsiaResourceDialect,
4247                    val_ref,
4248                    decoder,
4249                    inner_offset,
4250                    inner_depth
4251                )?;
4252                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4253                {
4254                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4255                }
4256                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4257                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4258                }
4259            }
4260
4261            next_offset += envelope_size;
4262
4263            // Decode the remaining unknown envelopes.
4264            while next_offset < end_offset {
4265                _next_ordinal_to_read += 1;
4266                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4267                next_offset += envelope_size;
4268            }
4269
4270            Ok(())
4271        }
4272    }
4273
4274    impl InterfaceOptions {
4275        #[inline(always)]
4276        fn max_ordinal_present(&self) -> u64 {
4277            if let Some(_) = self.ipv6_multicast_neighbor_solicitations {
4278                return 9;
4279            }
4280            if let Some(_) = self.ipv4_multicast_neighbor_solicitations {
4281                return 8;
4282            }
4283            if let Some(_) = self.enable_ipv6_forwarding {
4284                return 7;
4285            }
4286            if let Some(_) = self.enable_ipv4_forwarding {
4287                return 6;
4288            }
4289            if let Some(_) = self.gateway {
4290                return 5;
4291            }
4292            if let Some(_) = self.static_ips {
4293                return 4;
4294            }
4295            if let Some(_) = self.without_autogenerated_addresses {
4296                return 3;
4297            }
4298            if let Some(_) = self.device {
4299                return 2;
4300            }
4301            if let Some(_) = self.name {
4302                return 1;
4303            }
4304            0
4305        }
4306    }
4307
4308    impl fidl::encoding::ResourceTypeMarker for InterfaceOptions {
4309        type Borrowed<'a> = &'a mut Self;
4310        fn take_or_borrow<'a>(
4311            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4312        ) -> Self::Borrowed<'a> {
4313            value
4314        }
4315    }
4316
4317    unsafe impl fidl::encoding::TypeMarker for InterfaceOptions {
4318        type Owned = Self;
4319
4320        #[inline(always)]
4321        fn inline_align(_context: fidl::encoding::Context) -> usize {
4322            8
4323        }
4324
4325        #[inline(always)]
4326        fn inline_size(_context: fidl::encoding::Context) -> usize {
4327            16
4328        }
4329    }
4330
4331    unsafe impl
4332        fidl::encoding::Encode<InterfaceOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
4333        for &mut InterfaceOptions
4334    {
4335        unsafe fn encode(
4336            self,
4337            encoder: &mut fidl::encoding::Encoder<
4338                '_,
4339                fidl::encoding::DefaultFuchsiaResourceDialect,
4340            >,
4341            offset: usize,
4342            mut depth: fidl::encoding::Depth,
4343        ) -> fidl::Result<()> {
4344            encoder.debug_check_bounds::<InterfaceOptions>(offset);
4345            // Vector header
4346            let max_ordinal: u64 = self.max_ordinal_present();
4347            encoder.write_num(max_ordinal, offset);
4348            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4349            // Calling encoder.out_of_line_offset(0) is not allowed.
4350            if max_ordinal == 0 {
4351                return Ok(());
4352            }
4353            depth.increment()?;
4354            let envelope_size = 8;
4355            let bytes_len = max_ordinal as usize * envelope_size;
4356            #[allow(unused_variables)]
4357            let offset = encoder.out_of_line_offset(bytes_len);
4358            let mut _prev_end_offset: usize = 0;
4359            if 1 > max_ordinal {
4360                return Ok(());
4361            }
4362
4363            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4364            // are envelope_size bytes.
4365            let cur_offset: usize = (1 - 1) * envelope_size;
4366
4367            // Zero reserved fields.
4368            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4369
4370            // Safety:
4371            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4372            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4373            //   envelope_size bytes, there is always sufficient room.
4374            fidl::encoding::encode_in_envelope_optional::<
4375                fidl::encoding::UnboundedString,
4376                fidl::encoding::DefaultFuchsiaResourceDialect,
4377            >(
4378                self.name.as_ref().map(
4379                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
4380                ),
4381                encoder,
4382                offset + cur_offset,
4383                depth,
4384            )?;
4385
4386            _prev_end_offset = cur_offset + envelope_size;
4387            if 2 > max_ordinal {
4388                return Ok(());
4389            }
4390
4391            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4392            // are envelope_size bytes.
4393            let cur_offset: usize = (2 - 1) * envelope_size;
4394
4395            // Zero reserved fields.
4396            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4397
4398            // Safety:
4399            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4400            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4401            //   envelope_size bytes, there is always sufficient room.
4402            fidl::encoding::encode_in_envelope_optional::<
4403                fidl::encoding::Endpoint<
4404                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
4405                >,
4406                fidl::encoding::DefaultFuchsiaResourceDialect,
4407            >(
4408                self.device.as_mut().map(
4409                    <fidl::encoding::Endpoint<
4410                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
4411                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4412                ),
4413                encoder,
4414                offset + cur_offset,
4415                depth,
4416            )?;
4417
4418            _prev_end_offset = cur_offset + envelope_size;
4419            if 3 > max_ordinal {
4420                return Ok(());
4421            }
4422
4423            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4424            // are envelope_size bytes.
4425            let cur_offset: usize = (3 - 1) * envelope_size;
4426
4427            // Zero reserved fields.
4428            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4429
4430            // Safety:
4431            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4432            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4433            //   envelope_size bytes, there is always sufficient room.
4434            fidl::encoding::encode_in_envelope_optional::<
4435                bool,
4436                fidl::encoding::DefaultFuchsiaResourceDialect,
4437            >(
4438                self.without_autogenerated_addresses
4439                    .as_ref()
4440                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4441                encoder,
4442                offset + cur_offset,
4443                depth,
4444            )?;
4445
4446            _prev_end_offset = cur_offset + envelope_size;
4447            if 4 > max_ordinal {
4448                return Ok(());
4449            }
4450
4451            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4452            // are envelope_size bytes.
4453            let cur_offset: usize = (4 - 1) * envelope_size;
4454
4455            // Zero reserved fields.
4456            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4457
4458            // Safety:
4459            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4460            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4461            //   envelope_size bytes, there is always sufficient room.
4462            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_net::Subnet>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4463            self.static_ips.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_net::Subnet> as fidl::encoding::ValueTypeMarker>::borrow),
4464            encoder, offset + cur_offset, depth
4465        )?;
4466
4467            _prev_end_offset = cur_offset + envelope_size;
4468            if 5 > max_ordinal {
4469                return Ok(());
4470            }
4471
4472            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4473            // are envelope_size bytes.
4474            let cur_offset: usize = (5 - 1) * envelope_size;
4475
4476            // Zero reserved fields.
4477            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4478
4479            // Safety:
4480            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4481            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4482            //   envelope_size bytes, there is always sufficient room.
4483            fidl::encoding::encode_in_envelope_optional::<
4484                fidl_fuchsia_net::IpAddress,
4485                fidl::encoding::DefaultFuchsiaResourceDialect,
4486            >(
4487                self.gateway
4488                    .as_ref()
4489                    .map(<fidl_fuchsia_net::IpAddress as fidl::encoding::ValueTypeMarker>::borrow),
4490                encoder,
4491                offset + cur_offset,
4492                depth,
4493            )?;
4494
4495            _prev_end_offset = cur_offset + envelope_size;
4496            if 6 > max_ordinal {
4497                return Ok(());
4498            }
4499
4500            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4501            // are envelope_size bytes.
4502            let cur_offset: usize = (6 - 1) * envelope_size;
4503
4504            // Zero reserved fields.
4505            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4506
4507            // Safety:
4508            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4509            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4510            //   envelope_size bytes, there is always sufficient room.
4511            fidl::encoding::encode_in_envelope_optional::<
4512                bool,
4513                fidl::encoding::DefaultFuchsiaResourceDialect,
4514            >(
4515                self.enable_ipv4_forwarding
4516                    .as_ref()
4517                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4518                encoder,
4519                offset + cur_offset,
4520                depth,
4521            )?;
4522
4523            _prev_end_offset = cur_offset + envelope_size;
4524            if 7 > max_ordinal {
4525                return Ok(());
4526            }
4527
4528            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4529            // are envelope_size bytes.
4530            let cur_offset: usize = (7 - 1) * envelope_size;
4531
4532            // Zero reserved fields.
4533            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4534
4535            // Safety:
4536            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4537            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4538            //   envelope_size bytes, there is always sufficient room.
4539            fidl::encoding::encode_in_envelope_optional::<
4540                bool,
4541                fidl::encoding::DefaultFuchsiaResourceDialect,
4542            >(
4543                self.enable_ipv6_forwarding
4544                    .as_ref()
4545                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4546                encoder,
4547                offset + cur_offset,
4548                depth,
4549            )?;
4550
4551            _prev_end_offset = cur_offset + envelope_size;
4552            if 8 > max_ordinal {
4553                return Ok(());
4554            }
4555
4556            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4557            // are envelope_size bytes.
4558            let cur_offset: usize = (8 - 1) * envelope_size;
4559
4560            // Zero reserved fields.
4561            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4562
4563            // Safety:
4564            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4565            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4566            //   envelope_size bytes, there is always sufficient room.
4567            fidl::encoding::encode_in_envelope_optional::<
4568                u16,
4569                fidl::encoding::DefaultFuchsiaResourceDialect,
4570            >(
4571                self.ipv4_multicast_neighbor_solicitations
4572                    .as_ref()
4573                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
4574                encoder,
4575                offset + cur_offset,
4576                depth,
4577            )?;
4578
4579            _prev_end_offset = cur_offset + envelope_size;
4580            if 9 > max_ordinal {
4581                return Ok(());
4582            }
4583
4584            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4585            // are envelope_size bytes.
4586            let cur_offset: usize = (9 - 1) * envelope_size;
4587
4588            // Zero reserved fields.
4589            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4590
4591            // Safety:
4592            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4593            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4594            //   envelope_size bytes, there is always sufficient room.
4595            fidl::encoding::encode_in_envelope_optional::<
4596                u16,
4597                fidl::encoding::DefaultFuchsiaResourceDialect,
4598            >(
4599                self.ipv6_multicast_neighbor_solicitations
4600                    .as_ref()
4601                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
4602                encoder,
4603                offset + cur_offset,
4604                depth,
4605            )?;
4606
4607            _prev_end_offset = cur_offset + envelope_size;
4608
4609            Ok(())
4610        }
4611    }
4612
4613    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4614        for InterfaceOptions
4615    {
4616        #[inline(always)]
4617        fn new_empty() -> Self {
4618            Self::default()
4619        }
4620
4621        unsafe fn decode(
4622            &mut self,
4623            decoder: &mut fidl::encoding::Decoder<
4624                '_,
4625                fidl::encoding::DefaultFuchsiaResourceDialect,
4626            >,
4627            offset: usize,
4628            mut depth: fidl::encoding::Depth,
4629        ) -> fidl::Result<()> {
4630            decoder.debug_check_bounds::<Self>(offset);
4631            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4632                None => return Err(fidl::Error::NotNullable),
4633                Some(len) => len,
4634            };
4635            // Calling decoder.out_of_line_offset(0) is not allowed.
4636            if len == 0 {
4637                return Ok(());
4638            };
4639            depth.increment()?;
4640            let envelope_size = 8;
4641            let bytes_len = len * envelope_size;
4642            let offset = decoder.out_of_line_offset(bytes_len)?;
4643            // Decode the envelope for each type.
4644            let mut _next_ordinal_to_read = 0;
4645            let mut next_offset = offset;
4646            let end_offset = offset + bytes_len;
4647            _next_ordinal_to_read += 1;
4648            if next_offset >= end_offset {
4649                return Ok(());
4650            }
4651
4652            // Decode unknown envelopes for gaps in ordinals.
4653            while _next_ordinal_to_read < 1 {
4654                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4655                _next_ordinal_to_read += 1;
4656                next_offset += envelope_size;
4657            }
4658
4659            let next_out_of_line = decoder.next_out_of_line();
4660            let handles_before = decoder.remaining_handles();
4661            if let Some((inlined, num_bytes, num_handles)) =
4662                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4663            {
4664                let member_inline_size =
4665                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
4666                        decoder.context,
4667                    );
4668                if inlined != (member_inline_size <= 4) {
4669                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4670                }
4671                let inner_offset;
4672                let mut inner_depth = depth.clone();
4673                if inlined {
4674                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4675                    inner_offset = next_offset;
4676                } else {
4677                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4678                    inner_depth.increment()?;
4679                }
4680                let val_ref = self.name.get_or_insert_with(|| {
4681                    fidl::new_empty!(
4682                        fidl::encoding::UnboundedString,
4683                        fidl::encoding::DefaultFuchsiaResourceDialect
4684                    )
4685                });
4686                fidl::decode!(
4687                    fidl::encoding::UnboundedString,
4688                    fidl::encoding::DefaultFuchsiaResourceDialect,
4689                    val_ref,
4690                    decoder,
4691                    inner_offset,
4692                    inner_depth
4693                )?;
4694                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4695                {
4696                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4697                }
4698                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4699                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4700                }
4701            }
4702
4703            next_offset += envelope_size;
4704            _next_ordinal_to_read += 1;
4705            if next_offset >= end_offset {
4706                return Ok(());
4707            }
4708
4709            // Decode unknown envelopes for gaps in ordinals.
4710            while _next_ordinal_to_read < 2 {
4711                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4712                _next_ordinal_to_read += 1;
4713                next_offset += envelope_size;
4714            }
4715
4716            let next_out_of_line = decoder.next_out_of_line();
4717            let handles_before = decoder.remaining_handles();
4718            if let Some((inlined, num_bytes, num_handles)) =
4719                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4720            {
4721                let member_inline_size = <fidl::encoding::Endpoint<
4722                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
4723                > as fidl::encoding::TypeMarker>::inline_size(
4724                    decoder.context
4725                );
4726                if inlined != (member_inline_size <= 4) {
4727                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4728                }
4729                let inner_offset;
4730                let mut inner_depth = depth.clone();
4731                if inlined {
4732                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4733                    inner_offset = next_offset;
4734                } else {
4735                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4736                    inner_depth.increment()?;
4737                }
4738                let val_ref = self.device.get_or_insert_with(|| {
4739                    fidl::new_empty!(
4740                        fidl::encoding::Endpoint<
4741                            fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
4742                        >,
4743                        fidl::encoding::DefaultFuchsiaResourceDialect
4744                    )
4745                });
4746                fidl::decode!(
4747                    fidl::encoding::Endpoint<
4748                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
4749                    >,
4750                    fidl::encoding::DefaultFuchsiaResourceDialect,
4751                    val_ref,
4752                    decoder,
4753                    inner_offset,
4754                    inner_depth
4755                )?;
4756                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4757                {
4758                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4759                }
4760                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4761                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4762                }
4763            }
4764
4765            next_offset += envelope_size;
4766            _next_ordinal_to_read += 1;
4767            if next_offset >= end_offset {
4768                return Ok(());
4769            }
4770
4771            // Decode unknown envelopes for gaps in ordinals.
4772            while _next_ordinal_to_read < 3 {
4773                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4774                _next_ordinal_to_read += 1;
4775                next_offset += envelope_size;
4776            }
4777
4778            let next_out_of_line = decoder.next_out_of_line();
4779            let handles_before = decoder.remaining_handles();
4780            if let Some((inlined, num_bytes, num_handles)) =
4781                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4782            {
4783                let member_inline_size =
4784                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4785                if inlined != (member_inline_size <= 4) {
4786                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4787                }
4788                let inner_offset;
4789                let mut inner_depth = depth.clone();
4790                if inlined {
4791                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4792                    inner_offset = next_offset;
4793                } else {
4794                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4795                    inner_depth.increment()?;
4796                }
4797                let val_ref = self.without_autogenerated_addresses.get_or_insert_with(|| {
4798                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
4799                });
4800                fidl::decode!(
4801                    bool,
4802                    fidl::encoding::DefaultFuchsiaResourceDialect,
4803                    val_ref,
4804                    decoder,
4805                    inner_offset,
4806                    inner_depth
4807                )?;
4808                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4809                {
4810                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4811                }
4812                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4813                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4814                }
4815            }
4816
4817            next_offset += envelope_size;
4818            _next_ordinal_to_read += 1;
4819            if next_offset >= end_offset {
4820                return Ok(());
4821            }
4822
4823            // Decode unknown envelopes for gaps in ordinals.
4824            while _next_ordinal_to_read < 4 {
4825                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4826                _next_ordinal_to_read += 1;
4827                next_offset += envelope_size;
4828            }
4829
4830            let next_out_of_line = decoder.next_out_of_line();
4831            let handles_before = decoder.remaining_handles();
4832            if let Some((inlined, num_bytes, num_handles)) =
4833                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4834            {
4835                let member_inline_size = <fidl::encoding::UnboundedVector<fidl_fuchsia_net::Subnet> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4836                if inlined != (member_inline_size <= 4) {
4837                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4838                }
4839                let inner_offset;
4840                let mut inner_depth = depth.clone();
4841                if inlined {
4842                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4843                    inner_offset = next_offset;
4844                } else {
4845                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4846                    inner_depth.increment()?;
4847                }
4848                let val_ref = self.static_ips.get_or_insert_with(|| {
4849                    fidl::new_empty!(
4850                        fidl::encoding::UnboundedVector<fidl_fuchsia_net::Subnet>,
4851                        fidl::encoding::DefaultFuchsiaResourceDialect
4852                    )
4853                });
4854                fidl::decode!(
4855                    fidl::encoding::UnboundedVector<fidl_fuchsia_net::Subnet>,
4856                    fidl::encoding::DefaultFuchsiaResourceDialect,
4857                    val_ref,
4858                    decoder,
4859                    inner_offset,
4860                    inner_depth
4861                )?;
4862                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4863                {
4864                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4865                }
4866                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4867                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4868                }
4869            }
4870
4871            next_offset += envelope_size;
4872            _next_ordinal_to_read += 1;
4873            if next_offset >= end_offset {
4874                return Ok(());
4875            }
4876
4877            // Decode unknown envelopes for gaps in ordinals.
4878            while _next_ordinal_to_read < 5 {
4879                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4880                _next_ordinal_to_read += 1;
4881                next_offset += envelope_size;
4882            }
4883
4884            let next_out_of_line = decoder.next_out_of_line();
4885            let handles_before = decoder.remaining_handles();
4886            if let Some((inlined, num_bytes, num_handles)) =
4887                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4888            {
4889                let member_inline_size =
4890                    <fidl_fuchsia_net::IpAddress as fidl::encoding::TypeMarker>::inline_size(
4891                        decoder.context,
4892                    );
4893                if inlined != (member_inline_size <= 4) {
4894                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4895                }
4896                let inner_offset;
4897                let mut inner_depth = depth.clone();
4898                if inlined {
4899                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4900                    inner_offset = next_offset;
4901                } else {
4902                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4903                    inner_depth.increment()?;
4904                }
4905                let val_ref = self.gateway.get_or_insert_with(|| {
4906                    fidl::new_empty!(
4907                        fidl_fuchsia_net::IpAddress,
4908                        fidl::encoding::DefaultFuchsiaResourceDialect
4909                    )
4910                });
4911                fidl::decode!(
4912                    fidl_fuchsia_net::IpAddress,
4913                    fidl::encoding::DefaultFuchsiaResourceDialect,
4914                    val_ref,
4915                    decoder,
4916                    inner_offset,
4917                    inner_depth
4918                )?;
4919                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4920                {
4921                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4922                }
4923                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4924                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4925                }
4926            }
4927
4928            next_offset += envelope_size;
4929            _next_ordinal_to_read += 1;
4930            if next_offset >= end_offset {
4931                return Ok(());
4932            }
4933
4934            // Decode unknown envelopes for gaps in ordinals.
4935            while _next_ordinal_to_read < 6 {
4936                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4937                _next_ordinal_to_read += 1;
4938                next_offset += envelope_size;
4939            }
4940
4941            let next_out_of_line = decoder.next_out_of_line();
4942            let handles_before = decoder.remaining_handles();
4943            if let Some((inlined, num_bytes, num_handles)) =
4944                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4945            {
4946                let member_inline_size =
4947                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4948                if inlined != (member_inline_size <= 4) {
4949                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4950                }
4951                let inner_offset;
4952                let mut inner_depth = depth.clone();
4953                if inlined {
4954                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4955                    inner_offset = next_offset;
4956                } else {
4957                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4958                    inner_depth.increment()?;
4959                }
4960                let val_ref = self.enable_ipv4_forwarding.get_or_insert_with(|| {
4961                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
4962                });
4963                fidl::decode!(
4964                    bool,
4965                    fidl::encoding::DefaultFuchsiaResourceDialect,
4966                    val_ref,
4967                    decoder,
4968                    inner_offset,
4969                    inner_depth
4970                )?;
4971                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4972                {
4973                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4974                }
4975                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4976                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4977                }
4978            }
4979
4980            next_offset += envelope_size;
4981            _next_ordinal_to_read += 1;
4982            if next_offset >= end_offset {
4983                return Ok(());
4984            }
4985
4986            // Decode unknown envelopes for gaps in ordinals.
4987            while _next_ordinal_to_read < 7 {
4988                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4989                _next_ordinal_to_read += 1;
4990                next_offset += envelope_size;
4991            }
4992
4993            let next_out_of_line = decoder.next_out_of_line();
4994            let handles_before = decoder.remaining_handles();
4995            if let Some((inlined, num_bytes, num_handles)) =
4996                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4997            {
4998                let member_inline_size =
4999                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5000                if inlined != (member_inline_size <= 4) {
5001                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5002                }
5003                let inner_offset;
5004                let mut inner_depth = depth.clone();
5005                if inlined {
5006                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5007                    inner_offset = next_offset;
5008                } else {
5009                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5010                    inner_depth.increment()?;
5011                }
5012                let val_ref = self.enable_ipv6_forwarding.get_or_insert_with(|| {
5013                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
5014                });
5015                fidl::decode!(
5016                    bool,
5017                    fidl::encoding::DefaultFuchsiaResourceDialect,
5018                    val_ref,
5019                    decoder,
5020                    inner_offset,
5021                    inner_depth
5022                )?;
5023                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5024                {
5025                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5026                }
5027                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5028                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5029                }
5030            }
5031
5032            next_offset += envelope_size;
5033            _next_ordinal_to_read += 1;
5034            if next_offset >= end_offset {
5035                return Ok(());
5036            }
5037
5038            // Decode unknown envelopes for gaps in ordinals.
5039            while _next_ordinal_to_read < 8 {
5040                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5041                _next_ordinal_to_read += 1;
5042                next_offset += envelope_size;
5043            }
5044
5045            let next_out_of_line = decoder.next_out_of_line();
5046            let handles_before = decoder.remaining_handles();
5047            if let Some((inlined, num_bytes, num_handles)) =
5048                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5049            {
5050                let member_inline_size =
5051                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5052                if inlined != (member_inline_size <= 4) {
5053                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5054                }
5055                let inner_offset;
5056                let mut inner_depth = depth.clone();
5057                if inlined {
5058                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5059                    inner_offset = next_offset;
5060                } else {
5061                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5062                    inner_depth.increment()?;
5063                }
5064                let val_ref = self.ipv4_multicast_neighbor_solicitations.get_or_insert_with(|| {
5065                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
5066                });
5067                fidl::decode!(
5068                    u16,
5069                    fidl::encoding::DefaultFuchsiaResourceDialect,
5070                    val_ref,
5071                    decoder,
5072                    inner_offset,
5073                    inner_depth
5074                )?;
5075                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5076                {
5077                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5078                }
5079                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5080                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5081                }
5082            }
5083
5084            next_offset += envelope_size;
5085            _next_ordinal_to_read += 1;
5086            if next_offset >= end_offset {
5087                return Ok(());
5088            }
5089
5090            // Decode unknown envelopes for gaps in ordinals.
5091            while _next_ordinal_to_read < 9 {
5092                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5093                _next_ordinal_to_read += 1;
5094                next_offset += envelope_size;
5095            }
5096
5097            let next_out_of_line = decoder.next_out_of_line();
5098            let handles_before = decoder.remaining_handles();
5099            if let Some((inlined, num_bytes, num_handles)) =
5100                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5101            {
5102                let member_inline_size =
5103                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5104                if inlined != (member_inline_size <= 4) {
5105                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5106                }
5107                let inner_offset;
5108                let mut inner_depth = depth.clone();
5109                if inlined {
5110                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5111                    inner_offset = next_offset;
5112                } else {
5113                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5114                    inner_depth.increment()?;
5115                }
5116                let val_ref = self.ipv6_multicast_neighbor_solicitations.get_or_insert_with(|| {
5117                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
5118                });
5119                fidl::decode!(
5120                    u16,
5121                    fidl::encoding::DefaultFuchsiaResourceDialect,
5122                    val_ref,
5123                    decoder,
5124                    inner_offset,
5125                    inner_depth
5126                )?;
5127                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5128                {
5129                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5130                }
5131                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5132                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5133                }
5134            }
5135
5136            next_offset += envelope_size;
5137
5138            // Decode the remaining unknown envelopes.
5139            while next_offset < end_offset {
5140                _next_ordinal_to_read += 1;
5141                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5142                next_offset += envelope_size;
5143            }
5144
5145            Ok(())
5146        }
5147    }
5148
5149    impl RealmOptions {
5150        #[inline(always)]
5151        fn max_ordinal_present(&self) -> u64 {
5152            if let Some(_) = self.children {
5153                return 2;
5154            }
5155            if let Some(_) = self.name {
5156                return 1;
5157            }
5158            0
5159        }
5160    }
5161
5162    impl fidl::encoding::ResourceTypeMarker for RealmOptions {
5163        type Borrowed<'a> = &'a mut Self;
5164        fn take_or_borrow<'a>(
5165            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5166        ) -> Self::Borrowed<'a> {
5167            value
5168        }
5169    }
5170
5171    unsafe impl fidl::encoding::TypeMarker for RealmOptions {
5172        type Owned = Self;
5173
5174        #[inline(always)]
5175        fn inline_align(_context: fidl::encoding::Context) -> usize {
5176            8
5177        }
5178
5179        #[inline(always)]
5180        fn inline_size(_context: fidl::encoding::Context) -> usize {
5181            16
5182        }
5183    }
5184
5185    unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
5186        for &mut RealmOptions
5187    {
5188        unsafe fn encode(
5189            self,
5190            encoder: &mut fidl::encoding::Encoder<
5191                '_,
5192                fidl::encoding::DefaultFuchsiaResourceDialect,
5193            >,
5194            offset: usize,
5195            mut depth: fidl::encoding::Depth,
5196        ) -> fidl::Result<()> {
5197            encoder.debug_check_bounds::<RealmOptions>(offset);
5198            // Vector header
5199            let max_ordinal: u64 = self.max_ordinal_present();
5200            encoder.write_num(max_ordinal, offset);
5201            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5202            // Calling encoder.out_of_line_offset(0) is not allowed.
5203            if max_ordinal == 0 {
5204                return Ok(());
5205            }
5206            depth.increment()?;
5207            let envelope_size = 8;
5208            let bytes_len = max_ordinal as usize * envelope_size;
5209            #[allow(unused_variables)]
5210            let offset = encoder.out_of_line_offset(bytes_len);
5211            let mut _prev_end_offset: usize = 0;
5212            if 1 > max_ordinal {
5213                return Ok(());
5214            }
5215
5216            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5217            // are envelope_size bytes.
5218            let cur_offset: usize = (1 - 1) * envelope_size;
5219
5220            // Zero reserved fields.
5221            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5222
5223            // Safety:
5224            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5225            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5226            //   envelope_size bytes, there is always sufficient room.
5227            fidl::encoding::encode_in_envelope_optional::<
5228                fidl::encoding::UnboundedString,
5229                fidl::encoding::DefaultFuchsiaResourceDialect,
5230            >(
5231                self.name.as_ref().map(
5232                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
5233                ),
5234                encoder,
5235                offset + cur_offset,
5236                depth,
5237            )?;
5238
5239            _prev_end_offset = cur_offset + envelope_size;
5240            if 2 > max_ordinal {
5241                return Ok(());
5242            }
5243
5244            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5245            // are envelope_size bytes.
5246            let cur_offset: usize = (2 - 1) * envelope_size;
5247
5248            // Zero reserved fields.
5249            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5250
5251            // Safety:
5252            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5253            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5254            //   envelope_size bytes, there is always sufficient room.
5255            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<ChildDef>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5256            self.children.as_mut().map(<fidl::encoding::UnboundedVector<ChildDef> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5257            encoder, offset + cur_offset, depth
5258        )?;
5259
5260            _prev_end_offset = cur_offset + envelope_size;
5261
5262            Ok(())
5263        }
5264    }
5265
5266    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
5267        #[inline(always)]
5268        fn new_empty() -> Self {
5269            Self::default()
5270        }
5271
5272        unsafe fn decode(
5273            &mut self,
5274            decoder: &mut fidl::encoding::Decoder<
5275                '_,
5276                fidl::encoding::DefaultFuchsiaResourceDialect,
5277            >,
5278            offset: usize,
5279            mut depth: fidl::encoding::Depth,
5280        ) -> fidl::Result<()> {
5281            decoder.debug_check_bounds::<Self>(offset);
5282            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5283                None => return Err(fidl::Error::NotNullable),
5284                Some(len) => len,
5285            };
5286            // Calling decoder.out_of_line_offset(0) is not allowed.
5287            if len == 0 {
5288                return Ok(());
5289            };
5290            depth.increment()?;
5291            let envelope_size = 8;
5292            let bytes_len = len * envelope_size;
5293            let offset = decoder.out_of_line_offset(bytes_len)?;
5294            // Decode the envelope for each type.
5295            let mut _next_ordinal_to_read = 0;
5296            let mut next_offset = offset;
5297            let end_offset = offset + bytes_len;
5298            _next_ordinal_to_read += 1;
5299            if next_offset >= end_offset {
5300                return Ok(());
5301            }
5302
5303            // Decode unknown envelopes for gaps in ordinals.
5304            while _next_ordinal_to_read < 1 {
5305                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5306                _next_ordinal_to_read += 1;
5307                next_offset += envelope_size;
5308            }
5309
5310            let next_out_of_line = decoder.next_out_of_line();
5311            let handles_before = decoder.remaining_handles();
5312            if let Some((inlined, num_bytes, num_handles)) =
5313                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5314            {
5315                let member_inline_size =
5316                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
5317                        decoder.context,
5318                    );
5319                if inlined != (member_inline_size <= 4) {
5320                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5321                }
5322                let inner_offset;
5323                let mut inner_depth = depth.clone();
5324                if inlined {
5325                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5326                    inner_offset = next_offset;
5327                } else {
5328                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5329                    inner_depth.increment()?;
5330                }
5331                let val_ref = self.name.get_or_insert_with(|| {
5332                    fidl::new_empty!(
5333                        fidl::encoding::UnboundedString,
5334                        fidl::encoding::DefaultFuchsiaResourceDialect
5335                    )
5336                });
5337                fidl::decode!(
5338                    fidl::encoding::UnboundedString,
5339                    fidl::encoding::DefaultFuchsiaResourceDialect,
5340                    val_ref,
5341                    decoder,
5342                    inner_offset,
5343                    inner_depth
5344                )?;
5345                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5346                {
5347                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5348                }
5349                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5350                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5351                }
5352            }
5353
5354            next_offset += envelope_size;
5355            _next_ordinal_to_read += 1;
5356            if next_offset >= end_offset {
5357                return Ok(());
5358            }
5359
5360            // Decode unknown envelopes for gaps in ordinals.
5361            while _next_ordinal_to_read < 2 {
5362                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5363                _next_ordinal_to_read += 1;
5364                next_offset += envelope_size;
5365            }
5366
5367            let next_out_of_line = decoder.next_out_of_line();
5368            let handles_before = decoder.remaining_handles();
5369            if let Some((inlined, num_bytes, num_handles)) =
5370                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5371            {
5372                let member_inline_size = <fidl::encoding::UnboundedVector<ChildDef> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5373                if inlined != (member_inline_size <= 4) {
5374                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5375                }
5376                let inner_offset;
5377                let mut inner_depth = depth.clone();
5378                if inlined {
5379                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5380                    inner_offset = next_offset;
5381                } else {
5382                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5383                    inner_depth.increment()?;
5384                }
5385                let val_ref = self.children.get_or_insert_with(|| {
5386                    fidl::new_empty!(
5387                        fidl::encoding::UnboundedVector<ChildDef>,
5388                        fidl::encoding::DefaultFuchsiaResourceDialect
5389                    )
5390                });
5391                fidl::decode!(
5392                    fidl::encoding::UnboundedVector<ChildDef>,
5393                    fidl::encoding::DefaultFuchsiaResourceDialect,
5394                    val_ref,
5395                    decoder,
5396                    inner_offset,
5397                    inner_depth
5398                )?;
5399                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5400                {
5401                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5402                }
5403                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5404                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5405                }
5406            }
5407
5408            next_offset += envelope_size;
5409
5410            // Decode the remaining unknown envelopes.
5411            while next_offset < end_offset {
5412                _next_ordinal_to_read += 1;
5413                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5414                next_offset += envelope_size;
5415            }
5416
5417            Ok(())
5418        }
5419    }
5420
5421    impl fidl::encoding::ResourceTypeMarker for ChildSource {
5422        type Borrowed<'a> = &'a mut Self;
5423        fn take_or_borrow<'a>(
5424            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5425        ) -> Self::Borrowed<'a> {
5426            value
5427        }
5428    }
5429
5430    unsafe impl fidl::encoding::TypeMarker for ChildSource {
5431        type Owned = Self;
5432
5433        #[inline(always)]
5434        fn inline_align(_context: fidl::encoding::Context) -> usize {
5435            8
5436        }
5437
5438        #[inline(always)]
5439        fn inline_size(_context: fidl::encoding::Context) -> usize {
5440            16
5441        }
5442    }
5443
5444    unsafe impl fidl::encoding::Encode<ChildSource, fidl::encoding::DefaultFuchsiaResourceDialect>
5445        for &mut ChildSource
5446    {
5447        #[inline]
5448        unsafe fn encode(
5449            self,
5450            encoder: &mut fidl::encoding::Encoder<
5451                '_,
5452                fidl::encoding::DefaultFuchsiaResourceDialect,
5453            >,
5454            offset: usize,
5455            _depth: fidl::encoding::Depth,
5456        ) -> fidl::Result<()> {
5457            encoder.debug_check_bounds::<ChildSource>(offset);
5458            encoder.write_num::<u64>(self.ordinal(), offset);
5459            match self {
5460            ChildSource::Component(ref val) => {
5461                fidl::encoding::encode_in_envelope::<fidl::encoding::BoundedString<4096>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5462                    <fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow(val),
5463                    encoder, offset + 8, _depth
5464                )
5465            }
5466            ChildSource::Mock(ref mut val) => {
5467                fidl::encoding::encode_in_envelope::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5468                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
5469                    encoder, offset + 8, _depth
5470                )
5471            }
5472        }
5473        }
5474    }
5475
5476    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for ChildSource {
5477        #[inline(always)]
5478        fn new_empty() -> Self {
5479            Self::Component(fidl::new_empty!(
5480                fidl::encoding::BoundedString<4096>,
5481                fidl::encoding::DefaultFuchsiaResourceDialect
5482            ))
5483        }
5484
5485        #[inline]
5486        unsafe fn decode(
5487            &mut self,
5488            decoder: &mut fidl::encoding::Decoder<
5489                '_,
5490                fidl::encoding::DefaultFuchsiaResourceDialect,
5491            >,
5492            offset: usize,
5493            mut depth: fidl::encoding::Depth,
5494        ) -> fidl::Result<()> {
5495            decoder.debug_check_bounds::<Self>(offset);
5496            #[allow(unused_variables)]
5497            let next_out_of_line = decoder.next_out_of_line();
5498            let handles_before = decoder.remaining_handles();
5499            let (ordinal, inlined, num_bytes, num_handles) =
5500                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
5501
5502            let member_inline_size = match ordinal {
5503                1 => {
5504                    <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(
5505                        decoder.context,
5506                    )
5507                }
5508                2 => <fidl::encoding::Endpoint<
5509                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
5510                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5511                _ => return Err(fidl::Error::UnknownUnionTag),
5512            };
5513
5514            if inlined != (member_inline_size <= 4) {
5515                return Err(fidl::Error::InvalidInlineBitInEnvelope);
5516            }
5517            let _inner_offset;
5518            if inlined {
5519                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
5520                _inner_offset = offset + 8;
5521            } else {
5522                depth.increment()?;
5523                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5524            }
5525            match ordinal {
5526                1 => {
5527                    #[allow(irrefutable_let_patterns)]
5528                    if let ChildSource::Component(_) = self {
5529                        // Do nothing, read the value into the object
5530                    } else {
5531                        // Initialize `self` to the right variant
5532                        *self = ChildSource::Component(fidl::new_empty!(
5533                            fidl::encoding::BoundedString<4096>,
5534                            fidl::encoding::DefaultFuchsiaResourceDialect
5535                        ));
5536                    }
5537                    #[allow(irrefutable_let_patterns)]
5538                    if let ChildSource::Component(ref mut val) = self {
5539                        fidl::decode!(
5540                            fidl::encoding::BoundedString<4096>,
5541                            fidl::encoding::DefaultFuchsiaResourceDialect,
5542                            val,
5543                            decoder,
5544                            _inner_offset,
5545                            depth
5546                        )?;
5547                    } else {
5548                        unreachable!()
5549                    }
5550                }
5551                2 => {
5552                    #[allow(irrefutable_let_patterns)]
5553                    if let ChildSource::Mock(_) = self {
5554                        // Do nothing, read the value into the object
5555                    } else {
5556                        // Initialize `self` to the right variant
5557                        *self = ChildSource::Mock(fidl::new_empty!(
5558                            fidl::encoding::Endpoint<
5559                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
5560                            >,
5561                            fidl::encoding::DefaultFuchsiaResourceDialect
5562                        ));
5563                    }
5564                    #[allow(irrefutable_let_patterns)]
5565                    if let ChildSource::Mock(ref mut val) = self {
5566                        fidl::decode!(
5567                            fidl::encoding::Endpoint<
5568                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
5569                            >,
5570                            fidl::encoding::DefaultFuchsiaResourceDialect,
5571                            val,
5572                            decoder,
5573                            _inner_offset,
5574                            depth
5575                        )?;
5576                    } else {
5577                        unreachable!()
5578                    }
5579                }
5580                ordinal => panic!("unexpected ordinal {:?}", ordinal),
5581            }
5582            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
5583                return Err(fidl::Error::InvalidNumBytesInEnvelope);
5584            }
5585            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5586                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5587            }
5588            Ok(())
5589        }
5590    }
5591}