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