fdomain_fuchsia_process/
fdomain_fuchsia_process.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 fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_process__common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// Information about a handle provided to a process at startup.
14///
15/// Processes are given a set of initial handles as part of the bootstrapping
16/// sequence. Some of these handles are associated with process argument
17/// identifiers that designate their intended use by the new process.
18///
19/// This structure represents one such handle and its associated identifier.
20#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
21pub struct HandleInfo {
22    /// The handle to use for this process argument.
23    pub handle: fdomain_client::Handle,
24    /// Process argument identifier.
25    ///
26    /// See <zircon/processargs.h> for definitions of well-known process
27    /// arguments.
28    pub id: u32,
29}
30
31impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for HandleInfo {}
32
33/// The information needed to launch a process.
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct LaunchInfo {
36    /// The executable to run in the process.
37    pub executable: fdomain_client::Vmo,
38    /// The job in which to create the process.
39    pub job: fdomain_client::Job,
40    /// The name to assign to the created process.
41    pub name: String,
42}
43
44impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for LaunchInfo {}
45
46#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
47pub struct LauncherAddHandlesRequest {
48    pub handles: Vec<HandleInfo>,
49}
50
51impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for LauncherAddHandlesRequest {}
52
53#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
54pub struct LauncherAddNamesRequest {
55    pub names: Vec<NameInfo>,
56}
57
58impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for LauncherAddNamesRequest {}
59
60#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
61pub struct LauncherCreateWithoutStartingRequest {
62    pub info: LaunchInfo,
63}
64
65impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
66    for LauncherCreateWithoutStartingRequest
67{
68}
69
70#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
71pub struct LauncherCreateWithoutStartingResponse {
72    pub status: i32,
73    pub data: Option<Box<ProcessStartData>>,
74}
75
76impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
77    for LauncherCreateWithoutStartingResponse
78{
79}
80
81#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
82pub struct LauncherLaunchRequest {
83    pub info: LaunchInfo,
84}
85
86impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for LauncherLaunchRequest {}
87
88#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
89pub struct LauncherLaunchResponse {
90    pub status: i32,
91    pub process: Option<fdomain_client::Process>,
92}
93
94impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for LauncherLaunchResponse {}
95
96/// A namespace entry provided to a process at startup.
97///
98/// Processes are given a set of initial handles as part of the bootstrapping
99/// sequence. Some of these handles are associated with paths that designate
100/// their intended use by the new process as namespace entries.
101///
102/// This structure represents one such handle and its associated namespace path.
103#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
104pub struct NameInfo {
105    /// Path at which to install the associated directory.
106    ///
107    /// Must be an absolute path (i.e., start with '/').
108    pub path: String,
109    /// The associated directory.
110    pub directory: fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>,
111}
112
113impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NameInfo {}
114
115/// The information required to start a process.
116///
117/// To start the process, call `zx_process_start` with the arguments provided.
118#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
119pub struct ProcessStartData {
120    /// The process that was created.
121    pub process: fdomain_client::Process,
122    /// The vmar object that was created when the process was created.
123    ///
124    /// See <https://fuchsia.dev/fuchsia-src/reference/syscalls/process_create.md>.
125    pub root_vmar: fdomain_client::Vmar,
126    /// The initial thread for the process.
127    ///
128    /// Should be passed to `zx_process_start` when starting the process.
129    pub thread: fdomain_client::Thread,
130    /// The address of the initial entry point in the process.
131    ///
132    /// Should be passed to `zx_process_start` when starting the process.
133    pub entry: u64,
134    /// The stack pointer value for the initial thread of the process.
135    ///
136    /// Should be passed to `zx_process_start` when starting the process.
137    pub stack: u64,
138    /// The bootstrap channel to pass to the process on startup.
139    ///
140    /// Should be passed to `zx_process_start` when starting the process.
141    pub bootstrap: fdomain_client::Channel,
142    /// The base address of the vDSO to pass to the process on startup.
143    ///
144    /// Should be passed to `zx_process_start` when starting the process.
145    pub vdso_base: u64,
146    /// The base load address of the ELF file loaded.
147    ///
148    /// Most often used by debuggers or other tools that inspect the process.
149    pub base: u64,
150}
151
152impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for ProcessStartData {}
153
154#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
155pub struct ResolverResolveResponse {
156    pub status: i32,
157    pub executable: Option<fdomain_client::Vmo>,
158    pub ldsvc: Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>>,
159}
160
161impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for ResolverResolveResponse {}
162
163#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
164pub struct LauncherMarker;
165
166impl fdomain_client::fidl::ProtocolMarker for LauncherMarker {
167    type Proxy = LauncherProxy;
168    type RequestStream = LauncherRequestStream;
169
170    const DEBUG_NAME: &'static str = "fuchsia.process.Launcher";
171}
172impl fdomain_client::fidl::DiscoverableProtocolMarker for LauncherMarker {}
173
174pub trait LauncherProxyInterface: Send + Sync {
175    type LaunchResponseFut: std::future::Future<Output = Result<(i32, Option<fdomain_client::Process>), fidl::Error>>
176        + Send;
177    fn r#launch(&self, info: LaunchInfo) -> Self::LaunchResponseFut;
178    type CreateWithoutStartingResponseFut: std::future::Future<Output = Result<(i32, Option<Box<ProcessStartData>>), fidl::Error>>
179        + Send;
180    fn r#create_without_starting(&self, info: LaunchInfo)
181        -> Self::CreateWithoutStartingResponseFut;
182    fn r#add_args(&self, args: &[Vec<u8>]) -> Result<(), fidl::Error>;
183    fn r#add_environs(&self, environ: &[Vec<u8>]) -> Result<(), fidl::Error>;
184    fn r#add_names(&self, names: Vec<NameInfo>) -> Result<(), fidl::Error>;
185    fn r#add_handles(&self, handles: Vec<HandleInfo>) -> Result<(), fidl::Error>;
186    fn r#set_options(&self, options: u32) -> Result<(), fidl::Error>;
187}
188
189#[derive(Debug, Clone)]
190pub struct LauncherProxy {
191    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
192}
193
194impl fdomain_client::fidl::Proxy for LauncherProxy {
195    type Protocol = LauncherMarker;
196
197    fn from_channel(inner: fdomain_client::Channel) -> Self {
198        Self::new(inner)
199    }
200
201    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
202        self.client.into_channel().map_err(|client| Self { client })
203    }
204
205    fn as_channel(&self) -> &fdomain_client::Channel {
206        self.client.as_channel()
207    }
208}
209
210impl LauncherProxy {
211    /// Create a new Proxy for fuchsia.process/Launcher.
212    pub fn new(channel: fdomain_client::Channel) -> Self {
213        let protocol_name = <LauncherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
214        Self { client: fidl::client::Client::new(channel, protocol_name) }
215    }
216
217    /// Get a Stream of events from the remote end of the protocol.
218    ///
219    /// # Panics
220    ///
221    /// Panics if the event stream was already taken.
222    pub fn take_event_stream(&self) -> LauncherEventStream {
223        LauncherEventStream { event_receiver: self.client.take_event_receiver() }
224    }
225
226    /// Creates and starts the process described by `info`.
227    ///
228    /// After processing this message, the `Launcher` is reset to its initial
229    /// state and is ready to launch another process.
230    ///
231    /// `process` is present if, and only if, `status` is `ZX_OK`.
232    pub fn r#launch(
233        &self,
234        mut info: LaunchInfo,
235    ) -> fidl::client::QueryResponseFut<
236        (i32, Option<fdomain_client::Process>),
237        fdomain_client::fidl::FDomainResourceDialect,
238    > {
239        LauncherProxyInterface::r#launch(self, info)
240    }
241
242    /// Creates the process described by `info` but does not start it.
243    ///
244    /// After processing this message, the `Launcher` is reset to its initial
245    /// state and is ready to launch another process.
246    ///
247    /// The caller is responsible for calling `zx_process_start` using the data
248    /// in `ProcessStartData` to actually start the process.
249    ///
250    /// `data` is present if, and only if, `status` is `ZX_OK`.
251    pub fn r#create_without_starting(
252        &self,
253        mut info: LaunchInfo,
254    ) -> fidl::client::QueryResponseFut<
255        (i32, Option<Box<ProcessStartData>>),
256        fdomain_client::fidl::FDomainResourceDialect,
257    > {
258        LauncherProxyInterface::r#create_without_starting(self, info)
259    }
260
261    /// Adds the given arguments to the command-line for the process.
262    ///
263    /// Calling this method multiple times concatenates the arguments.
264    pub fn r#add_args(&self, mut args: &[Vec<u8>]) -> Result<(), fidl::Error> {
265        LauncherProxyInterface::r#add_args(self, args)
266    }
267
268    /// Adds the given variables to the environment variables for the process.
269    ///
270    /// Calling this method multiple times concatenates the variables.
271    pub fn r#add_environs(&self, mut environ: &[Vec<u8>]) -> Result<(), fidl::Error> {
272        LauncherProxyInterface::r#add_environs(self, environ)
273    }
274
275    /// Adds the given names to the namespace for the process.
276    ///
277    /// The paths in the namespace must be non-overlapping. See
278    /// <https://fuchsia.dev/fuchsia-src/concepts/process/namespaces> for details.
279    ///
280    /// Calling this method multiple times concatenates the names.
281    pub fn r#add_names(&self, mut names: Vec<NameInfo>) -> Result<(), fidl::Error> {
282        LauncherProxyInterface::r#add_names(self, names)
283    }
284
285    /// Adds the given handles to the startup handles for the process.
286    ///
287    /// Calling this method multiple times concatenates the handles.
288    pub fn r#add_handles(&self, mut handles: Vec<HandleInfo>) -> Result<(), fidl::Error> {
289        LauncherProxyInterface::r#add_handles(self, handles)
290    }
291
292    /// Sets the options with which the process is created.
293    ///
294    /// Calling this method multiple times will overwrite the current options.
295    pub fn r#set_options(&self, mut options: u32) -> Result<(), fidl::Error> {
296        LauncherProxyInterface::r#set_options(self, options)
297    }
298}
299
300impl LauncherProxyInterface for LauncherProxy {
301    type LaunchResponseFut = fidl::client::QueryResponseFut<
302        (i32, Option<fdomain_client::Process>),
303        fdomain_client::fidl::FDomainResourceDialect,
304    >;
305    fn r#launch(&self, mut info: LaunchInfo) -> Self::LaunchResponseFut {
306        fn _decode(
307            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
308        ) -> Result<(i32, Option<fdomain_client::Process>), fidl::Error> {
309            let _response = fidl::client::decode_transaction_body::<
310                LauncherLaunchResponse,
311                fdomain_client::fidl::FDomainResourceDialect,
312                0x11335a9928afbfa4,
313            >(_buf?)?;
314            Ok((_response.status, _response.process))
315        }
316        self.client
317            .send_query_and_decode::<LauncherLaunchRequest, (i32, Option<fdomain_client::Process>)>(
318                (&mut info,),
319                0x11335a9928afbfa4,
320                fidl::encoding::DynamicFlags::empty(),
321                _decode,
322            )
323    }
324
325    type CreateWithoutStartingResponseFut = fidl::client::QueryResponseFut<
326        (i32, Option<Box<ProcessStartData>>),
327        fdomain_client::fidl::FDomainResourceDialect,
328    >;
329    fn r#create_without_starting(
330        &self,
331        mut info: LaunchInfo,
332    ) -> Self::CreateWithoutStartingResponseFut {
333        fn _decode(
334            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
335        ) -> Result<(i32, Option<Box<ProcessStartData>>), fidl::Error> {
336            let _response = fidl::client::decode_transaction_body::<
337                LauncherCreateWithoutStartingResponse,
338                fdomain_client::fidl::FDomainResourceDialect,
339                0x755f8263fe51cb61,
340            >(_buf?)?;
341            Ok((_response.status, _response.data))
342        }
343        self.client.send_query_and_decode::<
344            LauncherCreateWithoutStartingRequest,
345            (i32, Option<Box<ProcessStartData>>),
346        >(
347            (&mut info,),
348            0x755f8263fe51cb61,
349            fidl::encoding::DynamicFlags::empty(),
350            _decode,
351        )
352    }
353
354    fn r#add_args(&self, mut args: &[Vec<u8>]) -> Result<(), fidl::Error> {
355        self.client.send::<LauncherAddArgsRequest>(
356            (args,),
357            0x3be445d3e4fd6512,
358            fidl::encoding::DynamicFlags::empty(),
359        )
360    }
361
362    fn r#add_environs(&self, mut environ: &[Vec<u8>]) -> Result<(), fidl::Error> {
363        self.client.send::<LauncherAddEnvironsRequest>(
364            (environ,),
365            0x73a3c97fa7fe1779,
366            fidl::encoding::DynamicFlags::empty(),
367        )
368    }
369
370    fn r#add_names(&self, mut names: Vec<NameInfo>) -> Result<(), fidl::Error> {
371        self.client.send::<LauncherAddNamesRequest>(
372            (names.as_mut(),),
373            0x2579ee2c7be28662,
374            fidl::encoding::DynamicFlags::empty(),
375        )
376    }
377
378    fn r#add_handles(&self, mut handles: Vec<HandleInfo>) -> Result<(), fidl::Error> {
379        self.client.send::<LauncherAddHandlesRequest>(
380            (handles.as_mut(),),
381            0x51025267a537a615,
382            fidl::encoding::DynamicFlags::empty(),
383        )
384    }
385
386    fn r#set_options(&self, mut options: u32) -> Result<(), fidl::Error> {
387        self.client.send::<LauncherSetOptionsRequest>(
388            (options,),
389            0x5b92576147ebfd87,
390            fidl::encoding::DynamicFlags::empty(),
391        )
392    }
393}
394
395pub struct LauncherEventStream {
396    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
397}
398
399impl std::marker::Unpin for LauncherEventStream {}
400
401impl futures::stream::FusedStream for LauncherEventStream {
402    fn is_terminated(&self) -> bool {
403        self.event_receiver.is_terminated()
404    }
405}
406
407impl futures::Stream for LauncherEventStream {
408    type Item = Result<LauncherEvent, fidl::Error>;
409
410    fn poll_next(
411        mut self: std::pin::Pin<&mut Self>,
412        cx: &mut std::task::Context<'_>,
413    ) -> std::task::Poll<Option<Self::Item>> {
414        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
415            &mut self.event_receiver,
416            cx
417        )?) {
418            Some(buf) => std::task::Poll::Ready(Some(LauncherEvent::decode(buf))),
419            None => std::task::Poll::Ready(None),
420        }
421    }
422}
423
424#[derive(Debug)]
425pub enum LauncherEvent {}
426
427impl LauncherEvent {
428    /// Decodes a message buffer as a [`LauncherEvent`].
429    fn decode(
430        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
431    ) -> Result<LauncherEvent, fidl::Error> {
432        let (bytes, _handles) = buf.split_mut();
433        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
434        debug_assert_eq!(tx_header.tx_id, 0);
435        match tx_header.ordinal {
436            _ => Err(fidl::Error::UnknownOrdinal {
437                ordinal: tx_header.ordinal,
438                protocol_name: <LauncherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
439            }),
440        }
441    }
442}
443
444/// A Stream of incoming requests for fuchsia.process/Launcher.
445pub struct LauncherRequestStream {
446    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
447    is_terminated: bool,
448}
449
450impl std::marker::Unpin for LauncherRequestStream {}
451
452impl futures::stream::FusedStream for LauncherRequestStream {
453    fn is_terminated(&self) -> bool {
454        self.is_terminated
455    }
456}
457
458impl fdomain_client::fidl::RequestStream for LauncherRequestStream {
459    type Protocol = LauncherMarker;
460    type ControlHandle = LauncherControlHandle;
461
462    fn from_channel(channel: fdomain_client::Channel) -> Self {
463        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
464    }
465
466    fn control_handle(&self) -> Self::ControlHandle {
467        LauncherControlHandle { inner: self.inner.clone() }
468    }
469
470    fn into_inner(
471        self,
472    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
473    {
474        (self.inner, self.is_terminated)
475    }
476
477    fn from_inner(
478        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
479        is_terminated: bool,
480    ) -> Self {
481        Self { inner, is_terminated }
482    }
483}
484
485impl futures::Stream for LauncherRequestStream {
486    type Item = Result<LauncherRequest, fidl::Error>;
487
488    fn poll_next(
489        mut self: std::pin::Pin<&mut Self>,
490        cx: &mut std::task::Context<'_>,
491    ) -> std::task::Poll<Option<Self::Item>> {
492        let this = &mut *self;
493        if this.inner.check_shutdown(cx) {
494            this.is_terminated = true;
495            return std::task::Poll::Ready(None);
496        }
497        if this.is_terminated {
498            panic!("polled LauncherRequestStream after completion");
499        }
500        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
501            |bytes, handles| {
502                match this.inner.channel().read_etc(cx, bytes, handles) {
503                    std::task::Poll::Ready(Ok(())) => {}
504                    std::task::Poll::Pending => return std::task::Poll::Pending,
505                    std::task::Poll::Ready(Err(None)) => {
506                        this.is_terminated = true;
507                        return std::task::Poll::Ready(None);
508                    }
509                    std::task::Poll::Ready(Err(Some(e))) => {
510                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
511                            e.into(),
512                        ))))
513                    }
514                }
515
516                // A message has been received from the channel
517                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
518
519                std::task::Poll::Ready(Some(match header.ordinal {
520                    0x11335a9928afbfa4 => {
521                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
522                        let mut req = fidl::new_empty!(
523                            LauncherLaunchRequest,
524                            fdomain_client::fidl::FDomainResourceDialect
525                        );
526                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LauncherLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
527                        let control_handle = LauncherControlHandle { inner: this.inner.clone() };
528                        Ok(LauncherRequest::Launch {
529                            info: req.info,
530
531                            responder: LauncherLaunchResponder {
532                                control_handle: std::mem::ManuallyDrop::new(control_handle),
533                                tx_id: header.tx_id,
534                            },
535                        })
536                    }
537                    0x755f8263fe51cb61 => {
538                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
539                        let mut req = fidl::new_empty!(
540                            LauncherCreateWithoutStartingRequest,
541                            fdomain_client::fidl::FDomainResourceDialect
542                        );
543                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LauncherCreateWithoutStartingRequest>(&header, _body_bytes, handles, &mut req)?;
544                        let control_handle = LauncherControlHandle { inner: this.inner.clone() };
545                        Ok(LauncherRequest::CreateWithoutStarting {
546                            info: req.info,
547
548                            responder: LauncherCreateWithoutStartingResponder {
549                                control_handle: std::mem::ManuallyDrop::new(control_handle),
550                                tx_id: header.tx_id,
551                            },
552                        })
553                    }
554                    0x3be445d3e4fd6512 => {
555                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
556                        let mut req = fidl::new_empty!(
557                            LauncherAddArgsRequest,
558                            fdomain_client::fidl::FDomainResourceDialect
559                        );
560                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LauncherAddArgsRequest>(&header, _body_bytes, handles, &mut req)?;
561                        let control_handle = LauncherControlHandle { inner: this.inner.clone() };
562                        Ok(LauncherRequest::AddArgs { args: req.args, control_handle })
563                    }
564                    0x73a3c97fa7fe1779 => {
565                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
566                        let mut req = fidl::new_empty!(
567                            LauncherAddEnvironsRequest,
568                            fdomain_client::fidl::FDomainResourceDialect
569                        );
570                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LauncherAddEnvironsRequest>(&header, _body_bytes, handles, &mut req)?;
571                        let control_handle = LauncherControlHandle { inner: this.inner.clone() };
572                        Ok(LauncherRequest::AddEnvirons { environ: req.environ, control_handle })
573                    }
574                    0x2579ee2c7be28662 => {
575                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
576                        let mut req = fidl::new_empty!(
577                            LauncherAddNamesRequest,
578                            fdomain_client::fidl::FDomainResourceDialect
579                        );
580                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LauncherAddNamesRequest>(&header, _body_bytes, handles, &mut req)?;
581                        let control_handle = LauncherControlHandle { inner: this.inner.clone() };
582                        Ok(LauncherRequest::AddNames { names: req.names, control_handle })
583                    }
584                    0x51025267a537a615 => {
585                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
586                        let mut req = fidl::new_empty!(
587                            LauncherAddHandlesRequest,
588                            fdomain_client::fidl::FDomainResourceDialect
589                        );
590                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LauncherAddHandlesRequest>(&header, _body_bytes, handles, &mut req)?;
591                        let control_handle = LauncherControlHandle { inner: this.inner.clone() };
592                        Ok(LauncherRequest::AddHandles { handles: req.handles, control_handle })
593                    }
594                    0x5b92576147ebfd87 => {
595                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
596                        let mut req = fidl::new_empty!(
597                            LauncherSetOptionsRequest,
598                            fdomain_client::fidl::FDomainResourceDialect
599                        );
600                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LauncherSetOptionsRequest>(&header, _body_bytes, handles, &mut req)?;
601                        let control_handle = LauncherControlHandle { inner: this.inner.clone() };
602                        Ok(LauncherRequest::SetOptions { options: req.options, control_handle })
603                    }
604                    _ => Err(fidl::Error::UnknownOrdinal {
605                        ordinal: header.ordinal,
606                        protocol_name:
607                            <LauncherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
608                    }),
609                }))
610            },
611        )
612    }
613}
614
615/// A low-level interface for launching processes.
616///
617/// This interface is used for manually assembling a process. The caller supplies
618/// all the capabilities for the newly created process.
619///
620/// That create processes typically use `fdio_spawn` or `fdio_spawn_etc` rather
621/// than using this interface directly. The `fdio_spawn` and `fdio_spawn_etc`
622/// functions are implemented using this interface.
623///
624/// Debuggers and other clients that need to create processes in a suspended
625/// state often use this interface directly. These clients use the
626/// `CreateWithoutStarting` method to create the process without actually
627/// starting it.
628#[derive(Debug)]
629pub enum LauncherRequest {
630    /// Creates and starts the process described by `info`.
631    ///
632    /// After processing this message, the `Launcher` is reset to its initial
633    /// state and is ready to launch another process.
634    ///
635    /// `process` is present if, and only if, `status` is `ZX_OK`.
636    Launch { info: LaunchInfo, responder: LauncherLaunchResponder },
637    /// Creates the process described by `info` but does not start it.
638    ///
639    /// After processing this message, the `Launcher` is reset to its initial
640    /// state and is ready to launch another process.
641    ///
642    /// The caller is responsible for calling `zx_process_start` using the data
643    /// in `ProcessStartData` to actually start the process.
644    ///
645    /// `data` is present if, and only if, `status` is `ZX_OK`.
646    CreateWithoutStarting { info: LaunchInfo, responder: LauncherCreateWithoutStartingResponder },
647    /// Adds the given arguments to the command-line for the process.
648    ///
649    /// Calling this method multiple times concatenates the arguments.
650    AddArgs { args: Vec<Vec<u8>>, control_handle: LauncherControlHandle },
651    /// Adds the given variables to the environment variables for the process.
652    ///
653    /// Calling this method multiple times concatenates the variables.
654    AddEnvirons { environ: Vec<Vec<u8>>, control_handle: LauncherControlHandle },
655    /// Adds the given names to the namespace for the process.
656    ///
657    /// The paths in the namespace must be non-overlapping. See
658    /// <https://fuchsia.dev/fuchsia-src/concepts/process/namespaces> for details.
659    ///
660    /// Calling this method multiple times concatenates the names.
661    AddNames { names: Vec<NameInfo>, control_handle: LauncherControlHandle },
662    /// Adds the given handles to the startup handles for the process.
663    ///
664    /// Calling this method multiple times concatenates the handles.
665    AddHandles { handles: Vec<HandleInfo>, control_handle: LauncherControlHandle },
666    /// Sets the options with which the process is created.
667    ///
668    /// Calling this method multiple times will overwrite the current options.
669    SetOptions { options: u32, control_handle: LauncherControlHandle },
670}
671
672impl LauncherRequest {
673    #[allow(irrefutable_let_patterns)]
674    pub fn into_launch(self) -> Option<(LaunchInfo, LauncherLaunchResponder)> {
675        if let LauncherRequest::Launch { info, responder } = self {
676            Some((info, responder))
677        } else {
678            None
679        }
680    }
681
682    #[allow(irrefutable_let_patterns)]
683    pub fn into_create_without_starting(
684        self,
685    ) -> Option<(LaunchInfo, LauncherCreateWithoutStartingResponder)> {
686        if let LauncherRequest::CreateWithoutStarting { info, responder } = self {
687            Some((info, responder))
688        } else {
689            None
690        }
691    }
692
693    #[allow(irrefutable_let_patterns)]
694    pub fn into_add_args(self) -> Option<(Vec<Vec<u8>>, LauncherControlHandle)> {
695        if let LauncherRequest::AddArgs { args, control_handle } = self {
696            Some((args, control_handle))
697        } else {
698            None
699        }
700    }
701
702    #[allow(irrefutable_let_patterns)]
703    pub fn into_add_environs(self) -> Option<(Vec<Vec<u8>>, LauncherControlHandle)> {
704        if let LauncherRequest::AddEnvirons { environ, control_handle } = self {
705            Some((environ, control_handle))
706        } else {
707            None
708        }
709    }
710
711    #[allow(irrefutable_let_patterns)]
712    pub fn into_add_names(self) -> Option<(Vec<NameInfo>, LauncherControlHandle)> {
713        if let LauncherRequest::AddNames { names, control_handle } = self {
714            Some((names, control_handle))
715        } else {
716            None
717        }
718    }
719
720    #[allow(irrefutable_let_patterns)]
721    pub fn into_add_handles(self) -> Option<(Vec<HandleInfo>, LauncherControlHandle)> {
722        if let LauncherRequest::AddHandles { handles, control_handle } = self {
723            Some((handles, control_handle))
724        } else {
725            None
726        }
727    }
728
729    #[allow(irrefutable_let_patterns)]
730    pub fn into_set_options(self) -> Option<(u32, LauncherControlHandle)> {
731        if let LauncherRequest::SetOptions { options, control_handle } = self {
732            Some((options, control_handle))
733        } else {
734            None
735        }
736    }
737
738    /// Name of the method defined in FIDL
739    pub fn method_name(&self) -> &'static str {
740        match *self {
741            LauncherRequest::Launch { .. } => "launch",
742            LauncherRequest::CreateWithoutStarting { .. } => "create_without_starting",
743            LauncherRequest::AddArgs { .. } => "add_args",
744            LauncherRequest::AddEnvirons { .. } => "add_environs",
745            LauncherRequest::AddNames { .. } => "add_names",
746            LauncherRequest::AddHandles { .. } => "add_handles",
747            LauncherRequest::SetOptions { .. } => "set_options",
748        }
749    }
750}
751
752#[derive(Debug, Clone)]
753pub struct LauncherControlHandle {
754    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
755}
756
757impl fdomain_client::fidl::ControlHandle for LauncherControlHandle {
758    fn shutdown(&self) {
759        self.inner.shutdown()
760    }
761
762    fn is_closed(&self) -> bool {
763        self.inner.channel().is_closed()
764    }
765    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
766        self.inner.channel().on_closed()
767    }
768}
769
770impl LauncherControlHandle {}
771
772#[must_use = "FIDL methods require a response to be sent"]
773#[derive(Debug)]
774pub struct LauncherLaunchResponder {
775    control_handle: std::mem::ManuallyDrop<LauncherControlHandle>,
776    tx_id: u32,
777}
778
779/// Set the the channel to be shutdown (see [`LauncherControlHandle::shutdown`])
780/// if the responder is dropped without sending a response, so that the client
781/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
782impl std::ops::Drop for LauncherLaunchResponder {
783    fn drop(&mut self) {
784        self.control_handle.shutdown();
785        // Safety: drops once, never accessed again
786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
787    }
788}
789
790impl fdomain_client::fidl::Responder for LauncherLaunchResponder {
791    type ControlHandle = LauncherControlHandle;
792
793    fn control_handle(&self) -> &LauncherControlHandle {
794        &self.control_handle
795    }
796
797    fn drop_without_shutdown(mut self) {
798        // Safety: drops once, never accessed again due to mem::forget
799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
800        // Prevent Drop from running (which would shut down the channel)
801        std::mem::forget(self);
802    }
803}
804
805impl LauncherLaunchResponder {
806    /// Sends a response to the FIDL transaction.
807    ///
808    /// Sets the channel to shutdown if an error occurs.
809    pub fn send(
810        self,
811        mut status: i32,
812        mut process: Option<fdomain_client::Process>,
813    ) -> Result<(), fidl::Error> {
814        let _result = self.send_raw(status, process);
815        if _result.is_err() {
816            self.control_handle.shutdown();
817        }
818        self.drop_without_shutdown();
819        _result
820    }
821
822    /// Similar to "send" but does not shutdown the channel if an error occurs.
823    pub fn send_no_shutdown_on_err(
824        self,
825        mut status: i32,
826        mut process: Option<fdomain_client::Process>,
827    ) -> Result<(), fidl::Error> {
828        let _result = self.send_raw(status, process);
829        self.drop_without_shutdown();
830        _result
831    }
832
833    fn send_raw(
834        &self,
835        mut status: i32,
836        mut process: Option<fdomain_client::Process>,
837    ) -> Result<(), fidl::Error> {
838        self.control_handle.inner.send::<LauncherLaunchResponse>(
839            (status, process),
840            self.tx_id,
841            0x11335a9928afbfa4,
842            fidl::encoding::DynamicFlags::empty(),
843        )
844    }
845}
846
847#[must_use = "FIDL methods require a response to be sent"]
848#[derive(Debug)]
849pub struct LauncherCreateWithoutStartingResponder {
850    control_handle: std::mem::ManuallyDrop<LauncherControlHandle>,
851    tx_id: u32,
852}
853
854/// Set the the channel to be shutdown (see [`LauncherControlHandle::shutdown`])
855/// if the responder is dropped without sending a response, so that the client
856/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
857impl std::ops::Drop for LauncherCreateWithoutStartingResponder {
858    fn drop(&mut self) {
859        self.control_handle.shutdown();
860        // Safety: drops once, never accessed again
861        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
862    }
863}
864
865impl fdomain_client::fidl::Responder for LauncherCreateWithoutStartingResponder {
866    type ControlHandle = LauncherControlHandle;
867
868    fn control_handle(&self) -> &LauncherControlHandle {
869        &self.control_handle
870    }
871
872    fn drop_without_shutdown(mut self) {
873        // Safety: drops once, never accessed again due to mem::forget
874        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
875        // Prevent Drop from running (which would shut down the channel)
876        std::mem::forget(self);
877    }
878}
879
880impl LauncherCreateWithoutStartingResponder {
881    /// Sends a response to the FIDL transaction.
882    ///
883    /// Sets the channel to shutdown if an error occurs.
884    pub fn send(
885        self,
886        mut status: i32,
887        mut data: Option<ProcessStartData>,
888    ) -> Result<(), fidl::Error> {
889        let _result = self.send_raw(status, data);
890        if _result.is_err() {
891            self.control_handle.shutdown();
892        }
893        self.drop_without_shutdown();
894        _result
895    }
896
897    /// Similar to "send" but does not shutdown the channel if an error occurs.
898    pub fn send_no_shutdown_on_err(
899        self,
900        mut status: i32,
901        mut data: Option<ProcessStartData>,
902    ) -> Result<(), fidl::Error> {
903        let _result = self.send_raw(status, data);
904        self.drop_without_shutdown();
905        _result
906    }
907
908    fn send_raw(
909        &self,
910        mut status: i32,
911        mut data: Option<ProcessStartData>,
912    ) -> Result<(), fidl::Error> {
913        self.control_handle.inner.send::<LauncherCreateWithoutStartingResponse>(
914            (status, data.as_mut()),
915            self.tx_id,
916            0x755f8263fe51cb61,
917            fidl::encoding::DynamicFlags::empty(),
918        )
919    }
920}
921
922#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
923pub struct ResolverMarker;
924
925impl fdomain_client::fidl::ProtocolMarker for ResolverMarker {
926    type Proxy = ResolverProxy;
927    type RequestStream = ResolverRequestStream;
928
929    const DEBUG_NAME: &'static str = "fuchsia.process.Resolver";
930}
931impl fdomain_client::fidl::DiscoverableProtocolMarker for ResolverMarker {}
932
933pub trait ResolverProxyInterface: Send + Sync {
934    type ResolveResponseFut: std::future::Future<
935            Output = Result<
936                (
937                    i32,
938                    Option<fdomain_client::Vmo>,
939                    Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>>,
940                ),
941                fidl::Error,
942            >,
943        > + Send;
944    fn r#resolve(&self, name: &str) -> Self::ResolveResponseFut;
945}
946
947#[derive(Debug, Clone)]
948pub struct ResolverProxy {
949    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
950}
951
952impl fdomain_client::fidl::Proxy for ResolverProxy {
953    type Protocol = ResolverMarker;
954
955    fn from_channel(inner: fdomain_client::Channel) -> Self {
956        Self::new(inner)
957    }
958
959    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
960        self.client.into_channel().map_err(|client| Self { client })
961    }
962
963    fn as_channel(&self) -> &fdomain_client::Channel {
964        self.client.as_channel()
965    }
966}
967
968impl ResolverProxy {
969    /// Create a new Proxy for fuchsia.process/Resolver.
970    pub fn new(channel: fdomain_client::Channel) -> Self {
971        let protocol_name = <ResolverMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
972        Self { client: fidl::client::Client::new(channel, protocol_name) }
973    }
974
975    /// Get a Stream of events from the remote end of the protocol.
976    ///
977    /// # Panics
978    ///
979    /// Panics if the event stream was already taken.
980    pub fn take_event_stream(&self) -> ResolverEventStream {
981        ResolverEventStream { event_receiver: self.client.take_event_receiver() }
982    }
983
984    /// Resolves the given `name` to an `executable` and an shared library
985    /// loader.
986    ///
987    /// If present, the `executable` is suitable for use as the `executable`
988    /// property of `LaunchInfo` -- in particular, it will have `ZX_RIGHT_EXECUTE`.
989    /// If present, the `ldsvc` is suitable for use as the `PA_LDSVC_LOADER`
990    /// handle when launching the process.
991    ///
992    /// For example, the resolver might locate the given `name` inside a package
993    /// and return the executable binary from the package as well as a shared
994    /// library loader scoped to that package.
995    pub fn r#resolve(
996        &self,
997        mut name: &str,
998    ) -> fidl::client::QueryResponseFut<
999        (
1000            i32,
1001            Option<fdomain_client::Vmo>,
1002            Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>>,
1003        ),
1004        fdomain_client::fidl::FDomainResourceDialect,
1005    > {
1006        ResolverProxyInterface::r#resolve(self, name)
1007    }
1008}
1009
1010impl ResolverProxyInterface for ResolverProxy {
1011    type ResolveResponseFut = fidl::client::QueryResponseFut<
1012        (
1013            i32,
1014            Option<fdomain_client::Vmo>,
1015            Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>>,
1016        ),
1017        fdomain_client::fidl::FDomainResourceDialect,
1018    >;
1019    fn r#resolve(&self, mut name: &str) -> Self::ResolveResponseFut {
1020        fn _decode(
1021            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1022        ) -> Result<
1023            (
1024                i32,
1025                Option<fdomain_client::Vmo>,
1026                Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>>,
1027            ),
1028            fidl::Error,
1029        > {
1030            let _response = fidl::client::decode_transaction_body::<
1031                ResolverResolveResponse,
1032                fdomain_client::fidl::FDomainResourceDialect,
1033                0x3c15951efde89c90,
1034            >(_buf?)?;
1035            Ok((_response.status, _response.executable, _response.ldsvc))
1036        }
1037        self.client.send_query_and_decode::<ResolverResolveRequest, (
1038            i32,
1039            Option<fdomain_client::Vmo>,
1040            Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>>,
1041        )>(
1042            (name,), 0x3c15951efde89c90, fidl::encoding::DynamicFlags::empty(), _decode
1043        )
1044    }
1045}
1046
1047pub struct ResolverEventStream {
1048    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1049}
1050
1051impl std::marker::Unpin for ResolverEventStream {}
1052
1053impl futures::stream::FusedStream for ResolverEventStream {
1054    fn is_terminated(&self) -> bool {
1055        self.event_receiver.is_terminated()
1056    }
1057}
1058
1059impl futures::Stream for ResolverEventStream {
1060    type Item = Result<ResolverEvent, fidl::Error>;
1061
1062    fn poll_next(
1063        mut self: std::pin::Pin<&mut Self>,
1064        cx: &mut std::task::Context<'_>,
1065    ) -> std::task::Poll<Option<Self::Item>> {
1066        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1067            &mut self.event_receiver,
1068            cx
1069        )?) {
1070            Some(buf) => std::task::Poll::Ready(Some(ResolverEvent::decode(buf))),
1071            None => std::task::Poll::Ready(None),
1072        }
1073    }
1074}
1075
1076#[derive(Debug)]
1077pub enum ResolverEvent {}
1078
1079impl ResolverEvent {
1080    /// Decodes a message buffer as a [`ResolverEvent`].
1081    fn decode(
1082        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1083    ) -> Result<ResolverEvent, fidl::Error> {
1084        let (bytes, _handles) = buf.split_mut();
1085        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1086        debug_assert_eq!(tx_header.tx_id, 0);
1087        match tx_header.ordinal {
1088            _ => Err(fidl::Error::UnknownOrdinal {
1089                ordinal: tx_header.ordinal,
1090                protocol_name: <ResolverMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1091            }),
1092        }
1093    }
1094}
1095
1096/// A Stream of incoming requests for fuchsia.process/Resolver.
1097pub struct ResolverRequestStream {
1098    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1099    is_terminated: bool,
1100}
1101
1102impl std::marker::Unpin for ResolverRequestStream {}
1103
1104impl futures::stream::FusedStream for ResolverRequestStream {
1105    fn is_terminated(&self) -> bool {
1106        self.is_terminated
1107    }
1108}
1109
1110impl fdomain_client::fidl::RequestStream for ResolverRequestStream {
1111    type Protocol = ResolverMarker;
1112    type ControlHandle = ResolverControlHandle;
1113
1114    fn from_channel(channel: fdomain_client::Channel) -> Self {
1115        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1116    }
1117
1118    fn control_handle(&self) -> Self::ControlHandle {
1119        ResolverControlHandle { inner: self.inner.clone() }
1120    }
1121
1122    fn into_inner(
1123        self,
1124    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1125    {
1126        (self.inner, self.is_terminated)
1127    }
1128
1129    fn from_inner(
1130        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1131        is_terminated: bool,
1132    ) -> Self {
1133        Self { inner, is_terminated }
1134    }
1135}
1136
1137impl futures::Stream for ResolverRequestStream {
1138    type Item = Result<ResolverRequest, fidl::Error>;
1139
1140    fn poll_next(
1141        mut self: std::pin::Pin<&mut Self>,
1142        cx: &mut std::task::Context<'_>,
1143    ) -> std::task::Poll<Option<Self::Item>> {
1144        let this = &mut *self;
1145        if this.inner.check_shutdown(cx) {
1146            this.is_terminated = true;
1147            return std::task::Poll::Ready(None);
1148        }
1149        if this.is_terminated {
1150            panic!("polled ResolverRequestStream after completion");
1151        }
1152        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1153            |bytes, handles| {
1154                match this.inner.channel().read_etc(cx, bytes, handles) {
1155                    std::task::Poll::Ready(Ok(())) => {}
1156                    std::task::Poll::Pending => return std::task::Poll::Pending,
1157                    std::task::Poll::Ready(Err(None)) => {
1158                        this.is_terminated = true;
1159                        return std::task::Poll::Ready(None);
1160                    }
1161                    std::task::Poll::Ready(Err(Some(e))) => {
1162                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1163                            e.into(),
1164                        ))))
1165                    }
1166                }
1167
1168                // A message has been received from the channel
1169                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1170
1171                std::task::Poll::Ready(Some(match header.ordinal {
1172                    0x3c15951efde89c90 => {
1173                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1174                        let mut req = fidl::new_empty!(
1175                            ResolverResolveRequest,
1176                            fdomain_client::fidl::FDomainResourceDialect
1177                        );
1178                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ResolverResolveRequest>(&header, _body_bytes, handles, &mut req)?;
1179                        let control_handle = ResolverControlHandle { inner: this.inner.clone() };
1180                        Ok(ResolverRequest::Resolve {
1181                            name: req.name,
1182
1183                            responder: ResolverResolveResponder {
1184                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1185                                tx_id: header.tx_id,
1186                            },
1187                        })
1188                    }
1189                    _ => Err(fidl::Error::UnknownOrdinal {
1190                        ordinal: header.ordinal,
1191                        protocol_name:
1192                            <ResolverMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1193                    }),
1194                }))
1195            },
1196        )
1197    }
1198}
1199
1200/// An interface for resolving names to executables and library loaders.
1201///
1202/// An executable itself is often not sufficient to create a working process
1203/// because many executables also load shared libraries. On Fuchsia, there is no
1204/// global pool of shared libraries. Instead, every process has an associated
1205/// `fuchsia.ldsvc.Loader`, which provides access to a private pool of shared
1206/// libraries appropriate for that process.
1207///
1208/// This interface provides a protocol for resolving a name into both the
1209/// `zx.Handle:VMO` for the executable and the `fuchsia.ldsvc.Loader` for its
1210/// associated shared libraries.
1211///
1212/// This interface is rarely used directly. Instead, `fdio_spawn` and
1213/// `fdio_spawn_etc` use this interface internally when they try to run a file
1214/// with a `#!resolve` directive.
1215#[derive(Debug)]
1216pub enum ResolverRequest {
1217    /// Resolves the given `name` to an `executable` and an shared library
1218    /// loader.
1219    ///
1220    /// If present, the `executable` is suitable for use as the `executable`
1221    /// property of `LaunchInfo` -- in particular, it will have `ZX_RIGHT_EXECUTE`.
1222    /// If present, the `ldsvc` is suitable for use as the `PA_LDSVC_LOADER`
1223    /// handle when launching the process.
1224    ///
1225    /// For example, the resolver might locate the given `name` inside a package
1226    /// and return the executable binary from the package as well as a shared
1227    /// library loader scoped to that package.
1228    Resolve { name: String, responder: ResolverResolveResponder },
1229}
1230
1231impl ResolverRequest {
1232    #[allow(irrefutable_let_patterns)]
1233    pub fn into_resolve(self) -> Option<(String, ResolverResolveResponder)> {
1234        if let ResolverRequest::Resolve { name, responder } = self {
1235            Some((name, responder))
1236        } else {
1237            None
1238        }
1239    }
1240
1241    /// Name of the method defined in FIDL
1242    pub fn method_name(&self) -> &'static str {
1243        match *self {
1244            ResolverRequest::Resolve { .. } => "resolve",
1245        }
1246    }
1247}
1248
1249#[derive(Debug, Clone)]
1250pub struct ResolverControlHandle {
1251    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1252}
1253
1254impl fdomain_client::fidl::ControlHandle for ResolverControlHandle {
1255    fn shutdown(&self) {
1256        self.inner.shutdown()
1257    }
1258
1259    fn is_closed(&self) -> bool {
1260        self.inner.channel().is_closed()
1261    }
1262    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1263        self.inner.channel().on_closed()
1264    }
1265}
1266
1267impl ResolverControlHandle {}
1268
1269#[must_use = "FIDL methods require a response to be sent"]
1270#[derive(Debug)]
1271pub struct ResolverResolveResponder {
1272    control_handle: std::mem::ManuallyDrop<ResolverControlHandle>,
1273    tx_id: u32,
1274}
1275
1276/// Set the the channel to be shutdown (see [`ResolverControlHandle::shutdown`])
1277/// if the responder is dropped without sending a response, so that the client
1278/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1279impl std::ops::Drop for ResolverResolveResponder {
1280    fn drop(&mut self) {
1281        self.control_handle.shutdown();
1282        // Safety: drops once, never accessed again
1283        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1284    }
1285}
1286
1287impl fdomain_client::fidl::Responder for ResolverResolveResponder {
1288    type ControlHandle = ResolverControlHandle;
1289
1290    fn control_handle(&self) -> &ResolverControlHandle {
1291        &self.control_handle
1292    }
1293
1294    fn drop_without_shutdown(mut self) {
1295        // Safety: drops once, never accessed again due to mem::forget
1296        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1297        // Prevent Drop from running (which would shut down the channel)
1298        std::mem::forget(self);
1299    }
1300}
1301
1302impl ResolverResolveResponder {
1303    /// Sends a response to the FIDL transaction.
1304    ///
1305    /// Sets the channel to shutdown if an error occurs.
1306    pub fn send(
1307        self,
1308        mut status: i32,
1309        mut executable: Option<fdomain_client::Vmo>,
1310        mut ldsvc: Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>>,
1311    ) -> Result<(), fidl::Error> {
1312        let _result = self.send_raw(status, executable, ldsvc);
1313        if _result.is_err() {
1314            self.control_handle.shutdown();
1315        }
1316        self.drop_without_shutdown();
1317        _result
1318    }
1319
1320    /// Similar to "send" but does not shutdown the channel if an error occurs.
1321    pub fn send_no_shutdown_on_err(
1322        self,
1323        mut status: i32,
1324        mut executable: Option<fdomain_client::Vmo>,
1325        mut ldsvc: Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>>,
1326    ) -> Result<(), fidl::Error> {
1327        let _result = self.send_raw(status, executable, ldsvc);
1328        self.drop_without_shutdown();
1329        _result
1330    }
1331
1332    fn send_raw(
1333        &self,
1334        mut status: i32,
1335        mut executable: Option<fdomain_client::Vmo>,
1336        mut ldsvc: Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>>,
1337    ) -> Result<(), fidl::Error> {
1338        self.control_handle.inner.send::<ResolverResolveResponse>(
1339            (status, executable, ldsvc),
1340            self.tx_id,
1341            0x3c15951efde89c90,
1342            fidl::encoding::DynamicFlags::empty(),
1343        )
1344    }
1345}
1346
1347mod internal {
1348    use super::*;
1349
1350    impl fidl::encoding::ResourceTypeMarker for HandleInfo {
1351        type Borrowed<'a> = &'a mut Self;
1352        fn take_or_borrow<'a>(
1353            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1354        ) -> Self::Borrowed<'a> {
1355            value
1356        }
1357    }
1358
1359    unsafe impl fidl::encoding::TypeMarker for HandleInfo {
1360        type Owned = Self;
1361
1362        #[inline(always)]
1363        fn inline_align(_context: fidl::encoding::Context) -> usize {
1364            4
1365        }
1366
1367        #[inline(always)]
1368        fn inline_size(_context: fidl::encoding::Context) -> usize {
1369            8
1370        }
1371    }
1372
1373    unsafe impl fidl::encoding::Encode<HandleInfo, fdomain_client::fidl::FDomainResourceDialect>
1374        for &mut HandleInfo
1375    {
1376        #[inline]
1377        unsafe fn encode(
1378            self,
1379            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1380            offset: usize,
1381            _depth: fidl::encoding::Depth,
1382        ) -> fidl::Result<()> {
1383            encoder.debug_check_bounds::<HandleInfo>(offset);
1384            // Delegate to tuple encoding.
1385            fidl::encoding::Encode::<HandleInfo, fdomain_client::fidl::FDomainResourceDialect>::encode(
1386                (
1387                    <fidl::encoding::HandleType<fdomain_client::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
1388                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1389                ),
1390                encoder, offset, _depth
1391            )
1392        }
1393    }
1394    unsafe impl<
1395            T0: fidl::encoding::Encode<
1396                fidl::encoding::HandleType<
1397                    fdomain_client::Handle,
1398                    { fidl::ObjectType::NONE.into_raw() },
1399                    2147483648,
1400                >,
1401                fdomain_client::fidl::FDomainResourceDialect,
1402            >,
1403            T1: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
1404        > fidl::encoding::Encode<HandleInfo, fdomain_client::fidl::FDomainResourceDialect>
1405        for (T0, T1)
1406    {
1407        #[inline]
1408        unsafe fn encode(
1409            self,
1410            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1411            offset: usize,
1412            depth: fidl::encoding::Depth,
1413        ) -> fidl::Result<()> {
1414            encoder.debug_check_bounds::<HandleInfo>(offset);
1415            // Zero out padding regions. There's no need to apply masks
1416            // because the unmasked parts will be overwritten by fields.
1417            // Write the fields.
1418            self.0.encode(encoder, offset + 0, depth)?;
1419            self.1.encode(encoder, offset + 4, depth)?;
1420            Ok(())
1421        }
1422    }
1423
1424    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for HandleInfo {
1425        #[inline(always)]
1426        fn new_empty() -> Self {
1427            Self {
1428                handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
1429                id: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
1430            }
1431        }
1432
1433        #[inline]
1434        unsafe fn decode(
1435            &mut self,
1436            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1437            offset: usize,
1438            _depth: fidl::encoding::Depth,
1439        ) -> fidl::Result<()> {
1440            decoder.debug_check_bounds::<Self>(offset);
1441            // Verify that padding bytes are zero.
1442            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.handle, decoder, offset + 0, _depth)?;
1443            fidl::decode!(
1444                u32,
1445                fdomain_client::fidl::FDomainResourceDialect,
1446                &mut self.id,
1447                decoder,
1448                offset + 4,
1449                _depth
1450            )?;
1451            Ok(())
1452        }
1453    }
1454
1455    impl fidl::encoding::ResourceTypeMarker for LaunchInfo {
1456        type Borrowed<'a> = &'a mut Self;
1457        fn take_or_borrow<'a>(
1458            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1459        ) -> Self::Borrowed<'a> {
1460            value
1461        }
1462    }
1463
1464    unsafe impl fidl::encoding::TypeMarker for LaunchInfo {
1465        type Owned = Self;
1466
1467        #[inline(always)]
1468        fn inline_align(_context: fidl::encoding::Context) -> usize {
1469            8
1470        }
1471
1472        #[inline(always)]
1473        fn inline_size(_context: fidl::encoding::Context) -> usize {
1474            24
1475        }
1476    }
1477
1478    unsafe impl fidl::encoding::Encode<LaunchInfo, fdomain_client::fidl::FDomainResourceDialect>
1479        for &mut LaunchInfo
1480    {
1481        #[inline]
1482        unsafe fn encode(
1483            self,
1484            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1485            offset: usize,
1486            _depth: fidl::encoding::Depth,
1487        ) -> fidl::Result<()> {
1488            encoder.debug_check_bounds::<LaunchInfo>(offset);
1489            // Delegate to tuple encoding.
1490            fidl::encoding::Encode::<LaunchInfo, fdomain_client::fidl::FDomainResourceDialect>::encode(
1491                (
1492                    <fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.executable),
1493                    <fidl::encoding::HandleType<fdomain_client::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.job),
1494                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
1495                ),
1496                encoder, offset, _depth
1497            )
1498        }
1499    }
1500    unsafe impl<
1501            T0: fidl::encoding::Encode<
1502                fidl::encoding::HandleType<
1503                    fdomain_client::Vmo,
1504                    { fidl::ObjectType::VMO.into_raw() },
1505                    2147483648,
1506                >,
1507                fdomain_client::fidl::FDomainResourceDialect,
1508            >,
1509            T1: fidl::encoding::Encode<
1510                fidl::encoding::HandleType<
1511                    fdomain_client::Job,
1512                    { fidl::ObjectType::JOB.into_raw() },
1513                    2147483648,
1514                >,
1515                fdomain_client::fidl::FDomainResourceDialect,
1516            >,
1517            T2: fidl::encoding::Encode<
1518                fidl::encoding::BoundedString<32>,
1519                fdomain_client::fidl::FDomainResourceDialect,
1520            >,
1521        > fidl::encoding::Encode<LaunchInfo, fdomain_client::fidl::FDomainResourceDialect>
1522        for (T0, T1, T2)
1523    {
1524        #[inline]
1525        unsafe fn encode(
1526            self,
1527            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1528            offset: usize,
1529            depth: fidl::encoding::Depth,
1530        ) -> fidl::Result<()> {
1531            encoder.debug_check_bounds::<LaunchInfo>(offset);
1532            // Zero out padding regions. There's no need to apply masks
1533            // because the unmasked parts will be overwritten by fields.
1534            // Write the fields.
1535            self.0.encode(encoder, offset + 0, depth)?;
1536            self.1.encode(encoder, offset + 4, depth)?;
1537            self.2.encode(encoder, offset + 8, depth)?;
1538            Ok(())
1539        }
1540    }
1541
1542    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for LaunchInfo {
1543        #[inline(always)]
1544        fn new_empty() -> Self {
1545            Self {
1546                executable: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
1547                job: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
1548                name: fidl::new_empty!(
1549                    fidl::encoding::BoundedString<32>,
1550                    fdomain_client::fidl::FDomainResourceDialect
1551                ),
1552            }
1553        }
1554
1555        #[inline]
1556        unsafe fn decode(
1557            &mut self,
1558            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1559            offset: usize,
1560            _depth: fidl::encoding::Depth,
1561        ) -> fidl::Result<()> {
1562            decoder.debug_check_bounds::<Self>(offset);
1563            // Verify that padding bytes are zero.
1564            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.executable, decoder, offset + 0, _depth)?;
1565            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.job, decoder, offset + 4, _depth)?;
1566            fidl::decode!(
1567                fidl::encoding::BoundedString<32>,
1568                fdomain_client::fidl::FDomainResourceDialect,
1569                &mut self.name,
1570                decoder,
1571                offset + 8,
1572                _depth
1573            )?;
1574            Ok(())
1575        }
1576    }
1577
1578    impl fidl::encoding::ResourceTypeMarker for LauncherAddHandlesRequest {
1579        type Borrowed<'a> = &'a mut Self;
1580        fn take_or_borrow<'a>(
1581            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1582        ) -> Self::Borrowed<'a> {
1583            value
1584        }
1585    }
1586
1587    unsafe impl fidl::encoding::TypeMarker for LauncherAddHandlesRequest {
1588        type Owned = Self;
1589
1590        #[inline(always)]
1591        fn inline_align(_context: fidl::encoding::Context) -> usize {
1592            8
1593        }
1594
1595        #[inline(always)]
1596        fn inline_size(_context: fidl::encoding::Context) -> usize {
1597            16
1598        }
1599    }
1600
1601    unsafe impl
1602        fidl::encoding::Encode<
1603            LauncherAddHandlesRequest,
1604            fdomain_client::fidl::FDomainResourceDialect,
1605        > for &mut LauncherAddHandlesRequest
1606    {
1607        #[inline]
1608        unsafe fn encode(
1609            self,
1610            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1611            offset: usize,
1612            _depth: fidl::encoding::Depth,
1613        ) -> fidl::Result<()> {
1614            encoder.debug_check_bounds::<LauncherAddHandlesRequest>(offset);
1615            // Delegate to tuple encoding.
1616            fidl::encoding::Encode::<LauncherAddHandlesRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
1617                (
1618                    <fidl::encoding::UnboundedVector<HandleInfo> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handles),
1619                ),
1620                encoder, offset, _depth
1621            )
1622        }
1623    }
1624    unsafe impl<
1625            T0: fidl::encoding::Encode<
1626                fidl::encoding::UnboundedVector<HandleInfo>,
1627                fdomain_client::fidl::FDomainResourceDialect,
1628            >,
1629        >
1630        fidl::encoding::Encode<
1631            LauncherAddHandlesRequest,
1632            fdomain_client::fidl::FDomainResourceDialect,
1633        > for (T0,)
1634    {
1635        #[inline]
1636        unsafe fn encode(
1637            self,
1638            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1639            offset: usize,
1640            depth: fidl::encoding::Depth,
1641        ) -> fidl::Result<()> {
1642            encoder.debug_check_bounds::<LauncherAddHandlesRequest>(offset);
1643            // Zero out padding regions. There's no need to apply masks
1644            // because the unmasked parts will be overwritten by fields.
1645            // Write the fields.
1646            self.0.encode(encoder, offset + 0, depth)?;
1647            Ok(())
1648        }
1649    }
1650
1651    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1652        for LauncherAddHandlesRequest
1653    {
1654        #[inline(always)]
1655        fn new_empty() -> Self {
1656            Self {
1657                handles: fidl::new_empty!(
1658                    fidl::encoding::UnboundedVector<HandleInfo>,
1659                    fdomain_client::fidl::FDomainResourceDialect
1660                ),
1661            }
1662        }
1663
1664        #[inline]
1665        unsafe fn decode(
1666            &mut self,
1667            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1668            offset: usize,
1669            _depth: fidl::encoding::Depth,
1670        ) -> fidl::Result<()> {
1671            decoder.debug_check_bounds::<Self>(offset);
1672            // Verify that padding bytes are zero.
1673            fidl::decode!(
1674                fidl::encoding::UnboundedVector<HandleInfo>,
1675                fdomain_client::fidl::FDomainResourceDialect,
1676                &mut self.handles,
1677                decoder,
1678                offset + 0,
1679                _depth
1680            )?;
1681            Ok(())
1682        }
1683    }
1684
1685    impl fidl::encoding::ResourceTypeMarker for LauncherAddNamesRequest {
1686        type Borrowed<'a> = &'a mut Self;
1687        fn take_or_borrow<'a>(
1688            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1689        ) -> Self::Borrowed<'a> {
1690            value
1691        }
1692    }
1693
1694    unsafe impl fidl::encoding::TypeMarker for LauncherAddNamesRequest {
1695        type Owned = Self;
1696
1697        #[inline(always)]
1698        fn inline_align(_context: fidl::encoding::Context) -> usize {
1699            8
1700        }
1701
1702        #[inline(always)]
1703        fn inline_size(_context: fidl::encoding::Context) -> usize {
1704            16
1705        }
1706    }
1707
1708    unsafe impl
1709        fidl::encoding::Encode<
1710            LauncherAddNamesRequest,
1711            fdomain_client::fidl::FDomainResourceDialect,
1712        > for &mut LauncherAddNamesRequest
1713    {
1714        #[inline]
1715        unsafe fn encode(
1716            self,
1717            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1718            offset: usize,
1719            _depth: fidl::encoding::Depth,
1720        ) -> fidl::Result<()> {
1721            encoder.debug_check_bounds::<LauncherAddNamesRequest>(offset);
1722            // Delegate to tuple encoding.
1723            fidl::encoding::Encode::<LauncherAddNamesRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
1724                (
1725                    <fidl::encoding::UnboundedVector<NameInfo> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.names),
1726                ),
1727                encoder, offset, _depth
1728            )
1729        }
1730    }
1731    unsafe impl<
1732            T0: fidl::encoding::Encode<
1733                fidl::encoding::UnboundedVector<NameInfo>,
1734                fdomain_client::fidl::FDomainResourceDialect,
1735            >,
1736        >
1737        fidl::encoding::Encode<
1738            LauncherAddNamesRequest,
1739            fdomain_client::fidl::FDomainResourceDialect,
1740        > for (T0,)
1741    {
1742        #[inline]
1743        unsafe fn encode(
1744            self,
1745            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1746            offset: usize,
1747            depth: fidl::encoding::Depth,
1748        ) -> fidl::Result<()> {
1749            encoder.debug_check_bounds::<LauncherAddNamesRequest>(offset);
1750            // Zero out padding regions. There's no need to apply masks
1751            // because the unmasked parts will be overwritten by fields.
1752            // Write the fields.
1753            self.0.encode(encoder, offset + 0, depth)?;
1754            Ok(())
1755        }
1756    }
1757
1758    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1759        for LauncherAddNamesRequest
1760    {
1761        #[inline(always)]
1762        fn new_empty() -> Self {
1763            Self {
1764                names: fidl::new_empty!(
1765                    fidl::encoding::UnboundedVector<NameInfo>,
1766                    fdomain_client::fidl::FDomainResourceDialect
1767                ),
1768            }
1769        }
1770
1771        #[inline]
1772        unsafe fn decode(
1773            &mut self,
1774            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1775            offset: usize,
1776            _depth: fidl::encoding::Depth,
1777        ) -> fidl::Result<()> {
1778            decoder.debug_check_bounds::<Self>(offset);
1779            // Verify that padding bytes are zero.
1780            fidl::decode!(
1781                fidl::encoding::UnboundedVector<NameInfo>,
1782                fdomain_client::fidl::FDomainResourceDialect,
1783                &mut self.names,
1784                decoder,
1785                offset + 0,
1786                _depth
1787            )?;
1788            Ok(())
1789        }
1790    }
1791
1792    impl fidl::encoding::ResourceTypeMarker for LauncherCreateWithoutStartingRequest {
1793        type Borrowed<'a> = &'a mut Self;
1794        fn take_or_borrow<'a>(
1795            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1796        ) -> Self::Borrowed<'a> {
1797            value
1798        }
1799    }
1800
1801    unsafe impl fidl::encoding::TypeMarker for LauncherCreateWithoutStartingRequest {
1802        type Owned = Self;
1803
1804        #[inline(always)]
1805        fn inline_align(_context: fidl::encoding::Context) -> usize {
1806            8
1807        }
1808
1809        #[inline(always)]
1810        fn inline_size(_context: fidl::encoding::Context) -> usize {
1811            24
1812        }
1813    }
1814
1815    unsafe impl
1816        fidl::encoding::Encode<
1817            LauncherCreateWithoutStartingRequest,
1818            fdomain_client::fidl::FDomainResourceDialect,
1819        > for &mut LauncherCreateWithoutStartingRequest
1820    {
1821        #[inline]
1822        unsafe fn encode(
1823            self,
1824            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1825            offset: usize,
1826            _depth: fidl::encoding::Depth,
1827        ) -> fidl::Result<()> {
1828            encoder.debug_check_bounds::<LauncherCreateWithoutStartingRequest>(offset);
1829            // Delegate to tuple encoding.
1830            fidl::encoding::Encode::<
1831                LauncherCreateWithoutStartingRequest,
1832                fdomain_client::fidl::FDomainResourceDialect,
1833            >::encode(
1834                (<LaunchInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1835                    &mut self.info,
1836                ),),
1837                encoder,
1838                offset,
1839                _depth,
1840            )
1841        }
1842    }
1843    unsafe impl<T0: fidl::encoding::Encode<LaunchInfo, fdomain_client::fidl::FDomainResourceDialect>>
1844        fidl::encoding::Encode<
1845            LauncherCreateWithoutStartingRequest,
1846            fdomain_client::fidl::FDomainResourceDialect,
1847        > for (T0,)
1848    {
1849        #[inline]
1850        unsafe fn encode(
1851            self,
1852            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1853            offset: usize,
1854            depth: fidl::encoding::Depth,
1855        ) -> fidl::Result<()> {
1856            encoder.debug_check_bounds::<LauncherCreateWithoutStartingRequest>(offset);
1857            // Zero out padding regions. There's no need to apply masks
1858            // because the unmasked parts will be overwritten by fields.
1859            // Write the fields.
1860            self.0.encode(encoder, offset + 0, depth)?;
1861            Ok(())
1862        }
1863    }
1864
1865    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1866        for LauncherCreateWithoutStartingRequest
1867    {
1868        #[inline(always)]
1869        fn new_empty() -> Self {
1870            Self {
1871                info: fidl::new_empty!(LaunchInfo, fdomain_client::fidl::FDomainResourceDialect),
1872            }
1873        }
1874
1875        #[inline]
1876        unsafe fn decode(
1877            &mut self,
1878            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1879            offset: usize,
1880            _depth: fidl::encoding::Depth,
1881        ) -> fidl::Result<()> {
1882            decoder.debug_check_bounds::<Self>(offset);
1883            // Verify that padding bytes are zero.
1884            fidl::decode!(
1885                LaunchInfo,
1886                fdomain_client::fidl::FDomainResourceDialect,
1887                &mut self.info,
1888                decoder,
1889                offset + 0,
1890                _depth
1891            )?;
1892            Ok(())
1893        }
1894    }
1895
1896    impl fidl::encoding::ResourceTypeMarker for LauncherCreateWithoutStartingResponse {
1897        type Borrowed<'a> = &'a mut Self;
1898        fn take_or_borrow<'a>(
1899            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1900        ) -> Self::Borrowed<'a> {
1901            value
1902        }
1903    }
1904
1905    unsafe impl fidl::encoding::TypeMarker for LauncherCreateWithoutStartingResponse {
1906        type Owned = Self;
1907
1908        #[inline(always)]
1909        fn inline_align(_context: fidl::encoding::Context) -> usize {
1910            8
1911        }
1912
1913        #[inline(always)]
1914        fn inline_size(_context: fidl::encoding::Context) -> usize {
1915            16
1916        }
1917    }
1918
1919    unsafe impl
1920        fidl::encoding::Encode<
1921            LauncherCreateWithoutStartingResponse,
1922            fdomain_client::fidl::FDomainResourceDialect,
1923        > for &mut LauncherCreateWithoutStartingResponse
1924    {
1925        #[inline]
1926        unsafe fn encode(
1927            self,
1928            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1929            offset: usize,
1930            _depth: fidl::encoding::Depth,
1931        ) -> fidl::Result<()> {
1932            encoder.debug_check_bounds::<LauncherCreateWithoutStartingResponse>(offset);
1933            // Delegate to tuple encoding.
1934            fidl::encoding::Encode::<LauncherCreateWithoutStartingResponse, fdomain_client::fidl::FDomainResourceDialect>::encode(
1935                (
1936                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
1937                    <fidl::encoding::Boxed<ProcessStartData> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.data),
1938                ),
1939                encoder, offset, _depth
1940            )
1941        }
1942    }
1943    unsafe impl<
1944            T0: fidl::encoding::Encode<i32, fdomain_client::fidl::FDomainResourceDialect>,
1945            T1: fidl::encoding::Encode<
1946                fidl::encoding::Boxed<ProcessStartData>,
1947                fdomain_client::fidl::FDomainResourceDialect,
1948            >,
1949        >
1950        fidl::encoding::Encode<
1951            LauncherCreateWithoutStartingResponse,
1952            fdomain_client::fidl::FDomainResourceDialect,
1953        > for (T0, T1)
1954    {
1955        #[inline]
1956        unsafe fn encode(
1957            self,
1958            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1959            offset: usize,
1960            depth: fidl::encoding::Depth,
1961        ) -> fidl::Result<()> {
1962            encoder.debug_check_bounds::<LauncherCreateWithoutStartingResponse>(offset);
1963            // Zero out padding regions. There's no need to apply masks
1964            // because the unmasked parts will be overwritten by fields.
1965            unsafe {
1966                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1967                (ptr as *mut u64).write_unaligned(0);
1968            }
1969            // Write the fields.
1970            self.0.encode(encoder, offset + 0, depth)?;
1971            self.1.encode(encoder, offset + 8, depth)?;
1972            Ok(())
1973        }
1974    }
1975
1976    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1977        for LauncherCreateWithoutStartingResponse
1978    {
1979        #[inline(always)]
1980        fn new_empty() -> Self {
1981            Self {
1982                status: fidl::new_empty!(i32, fdomain_client::fidl::FDomainResourceDialect),
1983                data: fidl::new_empty!(
1984                    fidl::encoding::Boxed<ProcessStartData>,
1985                    fdomain_client::fidl::FDomainResourceDialect
1986                ),
1987            }
1988        }
1989
1990        #[inline]
1991        unsafe fn decode(
1992            &mut self,
1993            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1994            offset: usize,
1995            _depth: fidl::encoding::Depth,
1996        ) -> fidl::Result<()> {
1997            decoder.debug_check_bounds::<Self>(offset);
1998            // Verify that padding bytes are zero.
1999            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2000            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2001            let mask = 0xffffffff00000000u64;
2002            let maskedval = padval & mask;
2003            if maskedval != 0 {
2004                return Err(fidl::Error::NonZeroPadding {
2005                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2006                });
2007            }
2008            fidl::decode!(
2009                i32,
2010                fdomain_client::fidl::FDomainResourceDialect,
2011                &mut self.status,
2012                decoder,
2013                offset + 0,
2014                _depth
2015            )?;
2016            fidl::decode!(
2017                fidl::encoding::Boxed<ProcessStartData>,
2018                fdomain_client::fidl::FDomainResourceDialect,
2019                &mut self.data,
2020                decoder,
2021                offset + 8,
2022                _depth
2023            )?;
2024            Ok(())
2025        }
2026    }
2027
2028    impl fidl::encoding::ResourceTypeMarker for LauncherLaunchRequest {
2029        type Borrowed<'a> = &'a mut Self;
2030        fn take_or_borrow<'a>(
2031            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2032        ) -> Self::Borrowed<'a> {
2033            value
2034        }
2035    }
2036
2037    unsafe impl fidl::encoding::TypeMarker for LauncherLaunchRequest {
2038        type Owned = Self;
2039
2040        #[inline(always)]
2041        fn inline_align(_context: fidl::encoding::Context) -> usize {
2042            8
2043        }
2044
2045        #[inline(always)]
2046        fn inline_size(_context: fidl::encoding::Context) -> usize {
2047            24
2048        }
2049    }
2050
2051    unsafe impl
2052        fidl::encoding::Encode<LauncherLaunchRequest, fdomain_client::fidl::FDomainResourceDialect>
2053        for &mut LauncherLaunchRequest
2054    {
2055        #[inline]
2056        unsafe fn encode(
2057            self,
2058            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2059            offset: usize,
2060            _depth: fidl::encoding::Depth,
2061        ) -> fidl::Result<()> {
2062            encoder.debug_check_bounds::<LauncherLaunchRequest>(offset);
2063            // Delegate to tuple encoding.
2064            fidl::encoding::Encode::<
2065                LauncherLaunchRequest,
2066                fdomain_client::fidl::FDomainResourceDialect,
2067            >::encode(
2068                (<LaunchInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2069                    &mut self.info,
2070                ),),
2071                encoder,
2072                offset,
2073                _depth,
2074            )
2075        }
2076    }
2077    unsafe impl<T0: fidl::encoding::Encode<LaunchInfo, fdomain_client::fidl::FDomainResourceDialect>>
2078        fidl::encoding::Encode<LauncherLaunchRequest, fdomain_client::fidl::FDomainResourceDialect>
2079        for (T0,)
2080    {
2081        #[inline]
2082        unsafe fn encode(
2083            self,
2084            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2085            offset: usize,
2086            depth: fidl::encoding::Depth,
2087        ) -> fidl::Result<()> {
2088            encoder.debug_check_bounds::<LauncherLaunchRequest>(offset);
2089            // Zero out padding regions. There's no need to apply masks
2090            // because the unmasked parts will be overwritten by fields.
2091            // Write the fields.
2092            self.0.encode(encoder, offset + 0, depth)?;
2093            Ok(())
2094        }
2095    }
2096
2097    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2098        for LauncherLaunchRequest
2099    {
2100        #[inline(always)]
2101        fn new_empty() -> Self {
2102            Self {
2103                info: fidl::new_empty!(LaunchInfo, fdomain_client::fidl::FDomainResourceDialect),
2104            }
2105        }
2106
2107        #[inline]
2108        unsafe fn decode(
2109            &mut self,
2110            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2111            offset: usize,
2112            _depth: fidl::encoding::Depth,
2113        ) -> fidl::Result<()> {
2114            decoder.debug_check_bounds::<Self>(offset);
2115            // Verify that padding bytes are zero.
2116            fidl::decode!(
2117                LaunchInfo,
2118                fdomain_client::fidl::FDomainResourceDialect,
2119                &mut self.info,
2120                decoder,
2121                offset + 0,
2122                _depth
2123            )?;
2124            Ok(())
2125        }
2126    }
2127
2128    impl fidl::encoding::ResourceTypeMarker for LauncherLaunchResponse {
2129        type Borrowed<'a> = &'a mut Self;
2130        fn take_or_borrow<'a>(
2131            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2132        ) -> Self::Borrowed<'a> {
2133            value
2134        }
2135    }
2136
2137    unsafe impl fidl::encoding::TypeMarker for LauncherLaunchResponse {
2138        type Owned = Self;
2139
2140        #[inline(always)]
2141        fn inline_align(_context: fidl::encoding::Context) -> usize {
2142            4
2143        }
2144
2145        #[inline(always)]
2146        fn inline_size(_context: fidl::encoding::Context) -> usize {
2147            8
2148        }
2149    }
2150
2151    unsafe impl
2152        fidl::encoding::Encode<LauncherLaunchResponse, fdomain_client::fidl::FDomainResourceDialect>
2153        for &mut LauncherLaunchResponse
2154    {
2155        #[inline]
2156        unsafe fn encode(
2157            self,
2158            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2159            offset: usize,
2160            _depth: fidl::encoding::Depth,
2161        ) -> fidl::Result<()> {
2162            encoder.debug_check_bounds::<LauncherLaunchResponse>(offset);
2163            // Delegate to tuple encoding.
2164            fidl::encoding::Encode::<
2165                LauncherLaunchResponse,
2166                fdomain_client::fidl::FDomainResourceDialect,
2167            >::encode(
2168                (
2169                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
2170                    <fidl::encoding::Optional<
2171                        fidl::encoding::HandleType<
2172                            fdomain_client::Process,
2173                            { fidl::ObjectType::PROCESS.into_raw() },
2174                            2147483648,
2175                        >,
2176                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2177                        &mut self.process
2178                    ),
2179                ),
2180                encoder,
2181                offset,
2182                _depth,
2183            )
2184        }
2185    }
2186    unsafe impl<
2187            T0: fidl::encoding::Encode<i32, fdomain_client::fidl::FDomainResourceDialect>,
2188            T1: fidl::encoding::Encode<
2189                fidl::encoding::Optional<
2190                    fidl::encoding::HandleType<
2191                        fdomain_client::Process,
2192                        { fidl::ObjectType::PROCESS.into_raw() },
2193                        2147483648,
2194                    >,
2195                >,
2196                fdomain_client::fidl::FDomainResourceDialect,
2197            >,
2198        >
2199        fidl::encoding::Encode<LauncherLaunchResponse, fdomain_client::fidl::FDomainResourceDialect>
2200        for (T0, T1)
2201    {
2202        #[inline]
2203        unsafe fn encode(
2204            self,
2205            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2206            offset: usize,
2207            depth: fidl::encoding::Depth,
2208        ) -> fidl::Result<()> {
2209            encoder.debug_check_bounds::<LauncherLaunchResponse>(offset);
2210            // Zero out padding regions. There's no need to apply masks
2211            // because the unmasked parts will be overwritten by fields.
2212            // Write the fields.
2213            self.0.encode(encoder, offset + 0, depth)?;
2214            self.1.encode(encoder, offset + 4, depth)?;
2215            Ok(())
2216        }
2217    }
2218
2219    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2220        for LauncherLaunchResponse
2221    {
2222        #[inline(always)]
2223        fn new_empty() -> Self {
2224            Self {
2225                status: fidl::new_empty!(i32, fdomain_client::fidl::FDomainResourceDialect),
2226                process: fidl::new_empty!(
2227                    fidl::encoding::Optional<
2228                        fidl::encoding::HandleType<
2229                            fdomain_client::Process,
2230                            { fidl::ObjectType::PROCESS.into_raw() },
2231                            2147483648,
2232                        >,
2233                    >,
2234                    fdomain_client::fidl::FDomainResourceDialect
2235                ),
2236            }
2237        }
2238
2239        #[inline]
2240        unsafe fn decode(
2241            &mut self,
2242            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2243            offset: usize,
2244            _depth: fidl::encoding::Depth,
2245        ) -> fidl::Result<()> {
2246            decoder.debug_check_bounds::<Self>(offset);
2247            // Verify that padding bytes are zero.
2248            fidl::decode!(
2249                i32,
2250                fdomain_client::fidl::FDomainResourceDialect,
2251                &mut self.status,
2252                decoder,
2253                offset + 0,
2254                _depth
2255            )?;
2256            fidl::decode!(
2257                fidl::encoding::Optional<
2258                    fidl::encoding::HandleType<
2259                        fdomain_client::Process,
2260                        { fidl::ObjectType::PROCESS.into_raw() },
2261                        2147483648,
2262                    >,
2263                >,
2264                fdomain_client::fidl::FDomainResourceDialect,
2265                &mut self.process,
2266                decoder,
2267                offset + 4,
2268                _depth
2269            )?;
2270            Ok(())
2271        }
2272    }
2273
2274    impl fidl::encoding::ResourceTypeMarker for NameInfo {
2275        type Borrowed<'a> = &'a mut Self;
2276        fn take_or_borrow<'a>(
2277            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2278        ) -> Self::Borrowed<'a> {
2279            value
2280        }
2281    }
2282
2283    unsafe impl fidl::encoding::TypeMarker for NameInfo {
2284        type Owned = Self;
2285
2286        #[inline(always)]
2287        fn inline_align(_context: fidl::encoding::Context) -> usize {
2288            8
2289        }
2290
2291        #[inline(always)]
2292        fn inline_size(_context: fidl::encoding::Context) -> usize {
2293            24
2294        }
2295    }
2296
2297    unsafe impl fidl::encoding::Encode<NameInfo, fdomain_client::fidl::FDomainResourceDialect>
2298        for &mut NameInfo
2299    {
2300        #[inline]
2301        unsafe fn encode(
2302            self,
2303            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2304            offset: usize,
2305            _depth: fidl::encoding::Depth,
2306        ) -> fidl::Result<()> {
2307            encoder.debug_check_bounds::<NameInfo>(offset);
2308            // Delegate to tuple encoding.
2309            fidl::encoding::Encode::<NameInfo, fdomain_client::fidl::FDomainResourceDialect>::encode(
2310                (
2311                    <fidl::encoding::BoundedString<4095> as fidl::encoding::ValueTypeMarker>::borrow(&self.path),
2312                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.directory),
2313                ),
2314                encoder, offset, _depth
2315            )
2316        }
2317    }
2318    unsafe impl<
2319            T0: fidl::encoding::Encode<
2320                fidl::encoding::BoundedString<4095>,
2321                fdomain_client::fidl::FDomainResourceDialect,
2322            >,
2323            T1: fidl::encoding::Encode<
2324                fidl::encoding::Endpoint<
2325                    fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>,
2326                >,
2327                fdomain_client::fidl::FDomainResourceDialect,
2328            >,
2329        > fidl::encoding::Encode<NameInfo, fdomain_client::fidl::FDomainResourceDialect>
2330        for (T0, T1)
2331    {
2332        #[inline]
2333        unsafe fn encode(
2334            self,
2335            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2336            offset: usize,
2337            depth: fidl::encoding::Depth,
2338        ) -> fidl::Result<()> {
2339            encoder.debug_check_bounds::<NameInfo>(offset);
2340            // Zero out padding regions. There's no need to apply masks
2341            // because the unmasked parts will be overwritten by fields.
2342            unsafe {
2343                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2344                (ptr as *mut u64).write_unaligned(0);
2345            }
2346            // Write the fields.
2347            self.0.encode(encoder, offset + 0, depth)?;
2348            self.1.encode(encoder, offset + 16, depth)?;
2349            Ok(())
2350        }
2351    }
2352
2353    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for NameInfo {
2354        #[inline(always)]
2355        fn new_empty() -> Self {
2356            Self {
2357                path: fidl::new_empty!(
2358                    fidl::encoding::BoundedString<4095>,
2359                    fdomain_client::fidl::FDomainResourceDialect
2360                ),
2361                directory: fidl::new_empty!(
2362                    fidl::encoding::Endpoint<
2363                        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>,
2364                    >,
2365                    fdomain_client::fidl::FDomainResourceDialect
2366                ),
2367            }
2368        }
2369
2370        #[inline]
2371        unsafe fn decode(
2372            &mut self,
2373            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2374            offset: usize,
2375            _depth: fidl::encoding::Depth,
2376        ) -> fidl::Result<()> {
2377            decoder.debug_check_bounds::<Self>(offset);
2378            // Verify that padding bytes are zero.
2379            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2380            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2381            let mask = 0xffffffff00000000u64;
2382            let maskedval = padval & mask;
2383            if maskedval != 0 {
2384                return Err(fidl::Error::NonZeroPadding {
2385                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2386                });
2387            }
2388            fidl::decode!(
2389                fidl::encoding::BoundedString<4095>,
2390                fdomain_client::fidl::FDomainResourceDialect,
2391                &mut self.path,
2392                decoder,
2393                offset + 0,
2394                _depth
2395            )?;
2396            fidl::decode!(
2397                fidl::encoding::Endpoint<
2398                    fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>,
2399                >,
2400                fdomain_client::fidl::FDomainResourceDialect,
2401                &mut self.directory,
2402                decoder,
2403                offset + 16,
2404                _depth
2405            )?;
2406            Ok(())
2407        }
2408    }
2409
2410    impl fidl::encoding::ResourceTypeMarker for ProcessStartData {
2411        type Borrowed<'a> = &'a mut Self;
2412        fn take_or_borrow<'a>(
2413            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2414        ) -> Self::Borrowed<'a> {
2415            value
2416        }
2417    }
2418
2419    unsafe impl fidl::encoding::TypeMarker for ProcessStartData {
2420        type Owned = Self;
2421
2422        #[inline(always)]
2423        fn inline_align(_context: fidl::encoding::Context) -> usize {
2424            8
2425        }
2426
2427        #[inline(always)]
2428        fn inline_size(_context: fidl::encoding::Context) -> usize {
2429            56
2430        }
2431    }
2432
2433    unsafe impl
2434        fidl::encoding::Encode<ProcessStartData, fdomain_client::fidl::FDomainResourceDialect>
2435        for &mut ProcessStartData
2436    {
2437        #[inline]
2438        unsafe fn encode(
2439            self,
2440            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2441            offset: usize,
2442            _depth: fidl::encoding::Depth,
2443        ) -> fidl::Result<()> {
2444            encoder.debug_check_bounds::<ProcessStartData>(offset);
2445            // Delegate to tuple encoding.
2446            fidl::encoding::Encode::<ProcessStartData, fdomain_client::fidl::FDomainResourceDialect>::encode(
2447                (
2448                    <fidl::encoding::HandleType<fdomain_client::Process, { fidl::ObjectType::PROCESS.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.process),
2449                    <fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.root_vmar),
2450                    <fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.thread),
2451                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.entry),
2452                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.stack),
2453                    <fidl::encoding::HandleType<fdomain_client::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.bootstrap),
2454                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vdso_base),
2455                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.base),
2456                ),
2457                encoder, offset, _depth
2458            )
2459        }
2460    }
2461    unsafe impl<
2462            T0: fidl::encoding::Encode<
2463                fidl::encoding::HandleType<
2464                    fdomain_client::Process,
2465                    { fidl::ObjectType::PROCESS.into_raw() },
2466                    2147483648,
2467                >,
2468                fdomain_client::fidl::FDomainResourceDialect,
2469            >,
2470            T1: fidl::encoding::Encode<
2471                fidl::encoding::HandleType<
2472                    fdomain_client::Vmar,
2473                    { fidl::ObjectType::VMAR.into_raw() },
2474                    2147483648,
2475                >,
2476                fdomain_client::fidl::FDomainResourceDialect,
2477            >,
2478            T2: fidl::encoding::Encode<
2479                fidl::encoding::HandleType<
2480                    fdomain_client::Thread,
2481                    { fidl::ObjectType::THREAD.into_raw() },
2482                    2147483648,
2483                >,
2484                fdomain_client::fidl::FDomainResourceDialect,
2485            >,
2486            T3: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
2487            T4: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
2488            T5: fidl::encoding::Encode<
2489                fidl::encoding::HandleType<
2490                    fdomain_client::Channel,
2491                    { fidl::ObjectType::CHANNEL.into_raw() },
2492                    2147483648,
2493                >,
2494                fdomain_client::fidl::FDomainResourceDialect,
2495            >,
2496            T6: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
2497            T7: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
2498        > fidl::encoding::Encode<ProcessStartData, fdomain_client::fidl::FDomainResourceDialect>
2499        for (T0, T1, T2, T3, T4, T5, T6, T7)
2500    {
2501        #[inline]
2502        unsafe fn encode(
2503            self,
2504            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2505            offset: usize,
2506            depth: fidl::encoding::Depth,
2507        ) -> fidl::Result<()> {
2508            encoder.debug_check_bounds::<ProcessStartData>(offset);
2509            // Zero out padding regions. There's no need to apply masks
2510            // because the unmasked parts will be overwritten by fields.
2511            unsafe {
2512                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
2513                (ptr as *mut u64).write_unaligned(0);
2514            }
2515            unsafe {
2516                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
2517                (ptr as *mut u64).write_unaligned(0);
2518            }
2519            // Write the fields.
2520            self.0.encode(encoder, offset + 0, depth)?;
2521            self.1.encode(encoder, offset + 4, depth)?;
2522            self.2.encode(encoder, offset + 8, depth)?;
2523            self.3.encode(encoder, offset + 16, depth)?;
2524            self.4.encode(encoder, offset + 24, depth)?;
2525            self.5.encode(encoder, offset + 32, depth)?;
2526            self.6.encode(encoder, offset + 40, depth)?;
2527            self.7.encode(encoder, offset + 48, depth)?;
2528            Ok(())
2529        }
2530    }
2531
2532    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2533        for ProcessStartData
2534    {
2535        #[inline(always)]
2536        fn new_empty() -> Self {
2537            Self {
2538                process: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Process, { fidl::ObjectType::PROCESS.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
2539                root_vmar: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
2540                thread: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
2541                entry: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
2542                stack: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
2543                bootstrap: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
2544                vdso_base: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
2545                base: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
2546            }
2547        }
2548
2549        #[inline]
2550        unsafe fn decode(
2551            &mut self,
2552            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2553            offset: usize,
2554            _depth: fidl::encoding::Depth,
2555        ) -> fidl::Result<()> {
2556            decoder.debug_check_bounds::<Self>(offset);
2557            // Verify that padding bytes are zero.
2558            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
2559            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2560            let mask = 0xffffffff00000000u64;
2561            let maskedval = padval & mask;
2562            if maskedval != 0 {
2563                return Err(fidl::Error::NonZeroPadding {
2564                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
2565                });
2566            }
2567            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
2568            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2569            let mask = 0xffffffff00000000u64;
2570            let maskedval = padval & mask;
2571            if maskedval != 0 {
2572                return Err(fidl::Error::NonZeroPadding {
2573                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
2574                });
2575            }
2576            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Process, { fidl::ObjectType::PROCESS.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.process, decoder, offset + 0, _depth)?;
2577            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.root_vmar, decoder, offset + 4, _depth)?;
2578            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.thread, decoder, offset + 8, _depth)?;
2579            fidl::decode!(
2580                u64,
2581                fdomain_client::fidl::FDomainResourceDialect,
2582                &mut self.entry,
2583                decoder,
2584                offset + 16,
2585                _depth
2586            )?;
2587            fidl::decode!(
2588                u64,
2589                fdomain_client::fidl::FDomainResourceDialect,
2590                &mut self.stack,
2591                decoder,
2592                offset + 24,
2593                _depth
2594            )?;
2595            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.bootstrap, decoder, offset + 32, _depth)?;
2596            fidl::decode!(
2597                u64,
2598                fdomain_client::fidl::FDomainResourceDialect,
2599                &mut self.vdso_base,
2600                decoder,
2601                offset + 40,
2602                _depth
2603            )?;
2604            fidl::decode!(
2605                u64,
2606                fdomain_client::fidl::FDomainResourceDialect,
2607                &mut self.base,
2608                decoder,
2609                offset + 48,
2610                _depth
2611            )?;
2612            Ok(())
2613        }
2614    }
2615
2616    impl fidl::encoding::ResourceTypeMarker for ResolverResolveResponse {
2617        type Borrowed<'a> = &'a mut Self;
2618        fn take_or_borrow<'a>(
2619            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2620        ) -> Self::Borrowed<'a> {
2621            value
2622        }
2623    }
2624
2625    unsafe impl fidl::encoding::TypeMarker for ResolverResolveResponse {
2626        type Owned = Self;
2627
2628        #[inline(always)]
2629        fn inline_align(_context: fidl::encoding::Context) -> usize {
2630            4
2631        }
2632
2633        #[inline(always)]
2634        fn inline_size(_context: fidl::encoding::Context) -> usize {
2635            12
2636        }
2637    }
2638
2639    unsafe impl
2640        fidl::encoding::Encode<
2641            ResolverResolveResponse,
2642            fdomain_client::fidl::FDomainResourceDialect,
2643        > for &mut ResolverResolveResponse
2644    {
2645        #[inline]
2646        unsafe fn encode(
2647            self,
2648            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2649            offset: usize,
2650            _depth: fidl::encoding::Depth,
2651        ) -> fidl::Result<()> {
2652            encoder.debug_check_bounds::<ResolverResolveResponse>(offset);
2653            // Delegate to tuple encoding.
2654            fidl::encoding::Encode::<
2655                ResolverResolveResponse,
2656                fdomain_client::fidl::FDomainResourceDialect,
2657            >::encode(
2658                (
2659                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
2660                    <fidl::encoding::Optional<
2661                        fidl::encoding::HandleType<
2662                            fdomain_client::Vmo,
2663                            { fidl::ObjectType::VMO.into_raw() },
2664                            2147483648,
2665                        >,
2666                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2667                        &mut self.executable
2668                    ),
2669                    <fidl::encoding::Optional<
2670                        fidl::encoding::Endpoint<
2671                            fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>,
2672                        >,
2673                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2674                        &mut self.ldsvc
2675                    ),
2676                ),
2677                encoder,
2678                offset,
2679                _depth,
2680            )
2681        }
2682    }
2683    unsafe impl<
2684            T0: fidl::encoding::Encode<i32, fdomain_client::fidl::FDomainResourceDialect>,
2685            T1: fidl::encoding::Encode<
2686                fidl::encoding::Optional<
2687                    fidl::encoding::HandleType<
2688                        fdomain_client::Vmo,
2689                        { fidl::ObjectType::VMO.into_raw() },
2690                        2147483648,
2691                    >,
2692                >,
2693                fdomain_client::fidl::FDomainResourceDialect,
2694            >,
2695            T2: fidl::encoding::Encode<
2696                fidl::encoding::Optional<
2697                    fidl::encoding::Endpoint<
2698                        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>,
2699                    >,
2700                >,
2701                fdomain_client::fidl::FDomainResourceDialect,
2702            >,
2703        >
2704        fidl::encoding::Encode<
2705            ResolverResolveResponse,
2706            fdomain_client::fidl::FDomainResourceDialect,
2707        > for (T0, T1, T2)
2708    {
2709        #[inline]
2710        unsafe fn encode(
2711            self,
2712            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2713            offset: usize,
2714            depth: fidl::encoding::Depth,
2715        ) -> fidl::Result<()> {
2716            encoder.debug_check_bounds::<ResolverResolveResponse>(offset);
2717            // Zero out padding regions. There's no need to apply masks
2718            // because the unmasked parts will be overwritten by fields.
2719            // Write the fields.
2720            self.0.encode(encoder, offset + 0, depth)?;
2721            self.1.encode(encoder, offset + 4, depth)?;
2722            self.2.encode(encoder, offset + 8, depth)?;
2723            Ok(())
2724        }
2725    }
2726
2727    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2728        for ResolverResolveResponse
2729    {
2730        #[inline(always)]
2731        fn new_empty() -> Self {
2732            Self {
2733                status: fidl::new_empty!(i32, fdomain_client::fidl::FDomainResourceDialect),
2734                executable: fidl::new_empty!(
2735                    fidl::encoding::Optional<
2736                        fidl::encoding::HandleType<
2737                            fdomain_client::Vmo,
2738                            { fidl::ObjectType::VMO.into_raw() },
2739                            2147483648,
2740                        >,
2741                    >,
2742                    fdomain_client::fidl::FDomainResourceDialect
2743                ),
2744                ldsvc: fidl::new_empty!(
2745                    fidl::encoding::Optional<
2746                        fidl::encoding::Endpoint<
2747                            fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>,
2748                        >,
2749                    >,
2750                    fdomain_client::fidl::FDomainResourceDialect
2751                ),
2752            }
2753        }
2754
2755        #[inline]
2756        unsafe fn decode(
2757            &mut self,
2758            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2759            offset: usize,
2760            _depth: fidl::encoding::Depth,
2761        ) -> fidl::Result<()> {
2762            decoder.debug_check_bounds::<Self>(offset);
2763            // Verify that padding bytes are zero.
2764            fidl::decode!(
2765                i32,
2766                fdomain_client::fidl::FDomainResourceDialect,
2767                &mut self.status,
2768                decoder,
2769                offset + 0,
2770                _depth
2771            )?;
2772            fidl::decode!(
2773                fidl::encoding::Optional<
2774                    fidl::encoding::HandleType<
2775                        fdomain_client::Vmo,
2776                        { fidl::ObjectType::VMO.into_raw() },
2777                        2147483648,
2778                    >,
2779                >,
2780                fdomain_client::fidl::FDomainResourceDialect,
2781                &mut self.executable,
2782                decoder,
2783                offset + 4,
2784                _depth
2785            )?;
2786            fidl::decode!(
2787                fidl::encoding::Optional<
2788                    fidl::encoding::Endpoint<
2789                        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_ldsvc::LoaderMarker>,
2790                    >,
2791                >,
2792                fdomain_client::fidl::FDomainResourceDialect,
2793                &mut self.ldsvc,
2794                decoder,
2795                offset + 8,
2796                _depth
2797            )?;
2798            Ok(())
2799        }
2800    }
2801}