fidl_fuchsia_starnix_container/
fidl_fuchsia_starnix_container.rs

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