Skip to main content

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