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::NullableHandle {
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
830    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
831        self.inner.shutdown_with_epitaph(status)
832    }
833
834    fn is_closed(&self) -> bool {
835        self.inner.channel().is_closed()
836    }
837    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
838        self.inner.channel().on_closed()
839    }
840
841    #[cfg(target_os = "fuchsia")]
842    fn signal_peer(
843        &self,
844        clear_mask: zx::Signals,
845        set_mask: zx::Signals,
846    ) -> Result<(), zx_status::Status> {
847        use fidl::Peered;
848        self.inner.channel().signal_peer(clear_mask, set_mask)
849    }
850}
851
852impl ControllerControlHandle {}
853
854#[must_use = "FIDL methods require a response to be sent"]
855#[derive(Debug)]
856pub struct ControllerSpawnConsoleResponder {
857    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
858    tx_id: u32,
859}
860
861/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
862/// if the responder is dropped without sending a response, so that the client
863/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
864impl std::ops::Drop for ControllerSpawnConsoleResponder {
865    fn drop(&mut self) {
866        self.control_handle.shutdown();
867        // Safety: drops once, never accessed again
868        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
869    }
870}
871
872impl fidl::endpoints::Responder for ControllerSpawnConsoleResponder {
873    type ControlHandle = ControllerControlHandle;
874
875    fn control_handle(&self) -> &ControllerControlHandle {
876        &self.control_handle
877    }
878
879    fn drop_without_shutdown(mut self) {
880        // Safety: drops once, never accessed again due to mem::forget
881        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
882        // Prevent Drop from running (which would shut down the channel)
883        std::mem::forget(self);
884    }
885}
886
887impl ControllerSpawnConsoleResponder {
888    /// Sends a response to the FIDL transaction.
889    ///
890    /// Sets the channel to shutdown if an error occurs.
891    pub fn send(self, mut result: Result<u8, SpawnConsoleError>) -> Result<(), fidl::Error> {
892        let _result = self.send_raw(result);
893        if _result.is_err() {
894            self.control_handle.shutdown();
895        }
896        self.drop_without_shutdown();
897        _result
898    }
899
900    /// Similar to "send" but does not shutdown the channel if an error occurs.
901    pub fn send_no_shutdown_on_err(
902        self,
903        mut result: Result<u8, SpawnConsoleError>,
904    ) -> Result<(), fidl::Error> {
905        let _result = self.send_raw(result);
906        self.drop_without_shutdown();
907        _result
908    }
909
910    fn send_raw(&self, mut result: Result<u8, SpawnConsoleError>) -> Result<(), fidl::Error> {
911        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
912            ControllerSpawnConsoleResponse,
913            SpawnConsoleError,
914        >>(
915            fidl::encoding::FlexibleResult::new(result.map(|exit_code| (exit_code,))),
916            self.tx_id,
917            0x76eb46fdc63aa8b8,
918            fidl::encoding::DynamicFlags::FLEXIBLE,
919        )
920    }
921}
922
923#[must_use = "FIDL methods require a response to be sent"]
924#[derive(Debug)]
925pub struct ControllerGetVmoReferencesResponder {
926    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
927    tx_id: u32,
928}
929
930/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
931/// if the responder is dropped without sending a response, so that the client
932/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
933impl std::ops::Drop for ControllerGetVmoReferencesResponder {
934    fn drop(&mut self) {
935        self.control_handle.shutdown();
936        // Safety: drops once, never accessed again
937        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
938    }
939}
940
941impl fidl::endpoints::Responder for ControllerGetVmoReferencesResponder {
942    type ControlHandle = ControllerControlHandle;
943
944    fn control_handle(&self) -> &ControllerControlHandle {
945        &self.control_handle
946    }
947
948    fn drop_without_shutdown(mut self) {
949        // Safety: drops once, never accessed again due to mem::forget
950        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
951        // Prevent Drop from running (which would shut down the channel)
952        std::mem::forget(self);
953    }
954}
955
956impl ControllerGetVmoReferencesResponder {
957    /// Sends a response to the FIDL transaction.
958    ///
959    /// Sets the channel to shutdown if an error occurs.
960    pub fn send(self, mut payload: &ControllerGetVmoReferencesResponse) -> Result<(), fidl::Error> {
961        let _result = self.send_raw(payload);
962        if _result.is_err() {
963            self.control_handle.shutdown();
964        }
965        self.drop_without_shutdown();
966        _result
967    }
968
969    /// Similar to "send" but does not shutdown the channel if an error occurs.
970    pub fn send_no_shutdown_on_err(
971        self,
972        mut payload: &ControllerGetVmoReferencesResponse,
973    ) -> Result<(), fidl::Error> {
974        let _result = self.send_raw(payload);
975        self.drop_without_shutdown();
976        _result
977    }
978
979    fn send_raw(
980        &self,
981        mut payload: &ControllerGetVmoReferencesResponse,
982    ) -> Result<(), fidl::Error> {
983        self.control_handle
984            .inner
985            .send::<fidl::encoding::FlexibleType<ControllerGetVmoReferencesResponse>>(
986                fidl::encoding::Flexible::new(payload),
987                self.tx_id,
988                0x47a7f039bb97f173,
989                fidl::encoding::DynamicFlags::FLEXIBLE,
990            )
991    }
992}
993
994#[must_use = "FIDL methods require a response to be sent"]
995#[derive(Debug)]
996pub struct ControllerGetJobHandleResponder {
997    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
998    tx_id: u32,
999}
1000
1001/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
1002/// if the responder is dropped without sending a response, so that the client
1003/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1004impl std::ops::Drop for ControllerGetJobHandleResponder {
1005    fn drop(&mut self) {
1006        self.control_handle.shutdown();
1007        // Safety: drops once, never accessed again
1008        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1009    }
1010}
1011
1012impl fidl::endpoints::Responder for ControllerGetJobHandleResponder {
1013    type ControlHandle = ControllerControlHandle;
1014
1015    fn control_handle(&self) -> &ControllerControlHandle {
1016        &self.control_handle
1017    }
1018
1019    fn drop_without_shutdown(mut self) {
1020        // Safety: drops once, never accessed again due to mem::forget
1021        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1022        // Prevent Drop from running (which would shut down the channel)
1023        std::mem::forget(self);
1024    }
1025}
1026
1027impl ControllerGetJobHandleResponder {
1028    /// Sends a response to the FIDL transaction.
1029    ///
1030    /// Sets the channel to shutdown if an error occurs.
1031    pub fn send(self, mut payload: ControllerGetJobHandleResponse) -> Result<(), fidl::Error> {
1032        let _result = self.send_raw(payload);
1033        if _result.is_err() {
1034            self.control_handle.shutdown();
1035        }
1036        self.drop_without_shutdown();
1037        _result
1038    }
1039
1040    /// Similar to "send" but does not shutdown the channel if an error occurs.
1041    pub fn send_no_shutdown_on_err(
1042        self,
1043        mut payload: ControllerGetJobHandleResponse,
1044    ) -> Result<(), fidl::Error> {
1045        let _result = self.send_raw(payload);
1046        self.drop_without_shutdown();
1047        _result
1048    }
1049
1050    fn send_raw(&self, mut payload: ControllerGetJobHandleResponse) -> Result<(), fidl::Error> {
1051        self.control_handle
1052            .inner
1053            .send::<fidl::encoding::FlexibleType<ControllerGetJobHandleResponse>>(
1054                fidl::encoding::Flexible::new(&mut payload),
1055                self.tx_id,
1056                0x60a31a248576ffea,
1057                fidl::encoding::DynamicFlags::FLEXIBLE,
1058            )
1059    }
1060}
1061
1062#[must_use = "FIDL methods require a response to be sent"]
1063#[derive(Debug)]
1064pub struct ControllerSendSignalResponder {
1065    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1066    tx_id: u32,
1067}
1068
1069/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
1070/// if the responder is dropped without sending a response, so that the client
1071/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1072impl std::ops::Drop for ControllerSendSignalResponder {
1073    fn drop(&mut self) {
1074        self.control_handle.shutdown();
1075        // Safety: drops once, never accessed again
1076        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1077    }
1078}
1079
1080impl fidl::endpoints::Responder for ControllerSendSignalResponder {
1081    type ControlHandle = ControllerControlHandle;
1082
1083    fn control_handle(&self) -> &ControllerControlHandle {
1084        &self.control_handle
1085    }
1086
1087    fn drop_without_shutdown(mut self) {
1088        // Safety: drops once, never accessed again due to mem::forget
1089        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1090        // Prevent Drop from running (which would shut down the channel)
1091        std::mem::forget(self);
1092    }
1093}
1094
1095impl ControllerSendSignalResponder {
1096    /// Sends a response to the FIDL transaction.
1097    ///
1098    /// Sets the channel to shutdown if an error occurs.
1099    pub fn send(self, mut result: Result<(), SignalError>) -> Result<(), fidl::Error> {
1100        let _result = self.send_raw(result);
1101        if _result.is_err() {
1102            self.control_handle.shutdown();
1103        }
1104        self.drop_without_shutdown();
1105        _result
1106    }
1107
1108    /// Similar to "send" but does not shutdown the channel if an error occurs.
1109    pub fn send_no_shutdown_on_err(
1110        self,
1111        mut result: Result<(), SignalError>,
1112    ) -> Result<(), fidl::Error> {
1113        let _result = self.send_raw(result);
1114        self.drop_without_shutdown();
1115        _result
1116    }
1117
1118    fn send_raw(&self, mut result: Result<(), SignalError>) -> Result<(), fidl::Error> {
1119        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1120            fidl::encoding::EmptyStruct,
1121            SignalError,
1122        >>(
1123            fidl::encoding::FlexibleResult::new(result),
1124            self.tx_id,
1125            0x253b1a0d3b9639e3,
1126            fidl::encoding::DynamicFlags::FLEXIBLE,
1127        )
1128    }
1129}
1130
1131mod internal {
1132    use super::*;
1133
1134    impl ControllerSpawnConsoleRequest {
1135        #[inline(always)]
1136        fn max_ordinal_present(&self) -> u64 {
1137            if let Some(_) = self.window_size {
1138                return 6;
1139            }
1140            if let Some(_) = self.environ {
1141                return 5;
1142            }
1143            if let Some(_) = self.argv {
1144                return 4;
1145            }
1146            if let Some(_) = self.binary_path {
1147                return 3;
1148            }
1149            if let Some(_) = self.console_out {
1150                return 2;
1151            }
1152            if let Some(_) = self.console_in {
1153                return 1;
1154            }
1155            0
1156        }
1157    }
1158
1159    impl fidl::encoding::ResourceTypeMarker for ControllerSpawnConsoleRequest {
1160        type Borrowed<'a> = &'a mut Self;
1161        fn take_or_borrow<'a>(
1162            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1163        ) -> Self::Borrowed<'a> {
1164            value
1165        }
1166    }
1167
1168    unsafe impl fidl::encoding::TypeMarker for ControllerSpawnConsoleRequest {
1169        type Owned = Self;
1170
1171        #[inline(always)]
1172        fn inline_align(_context: fidl::encoding::Context) -> usize {
1173            8
1174        }
1175
1176        #[inline(always)]
1177        fn inline_size(_context: fidl::encoding::Context) -> usize {
1178            16
1179        }
1180    }
1181
1182    unsafe impl
1183        fidl::encoding::Encode<
1184            ControllerSpawnConsoleRequest,
1185            fidl::encoding::DefaultFuchsiaResourceDialect,
1186        > for &mut ControllerSpawnConsoleRequest
1187    {
1188        unsafe fn encode(
1189            self,
1190            encoder: &mut fidl::encoding::Encoder<
1191                '_,
1192                fidl::encoding::DefaultFuchsiaResourceDialect,
1193            >,
1194            offset: usize,
1195            mut depth: fidl::encoding::Depth,
1196        ) -> fidl::Result<()> {
1197            encoder.debug_check_bounds::<ControllerSpawnConsoleRequest>(offset);
1198            // Vector header
1199            let max_ordinal: u64 = self.max_ordinal_present();
1200            encoder.write_num(max_ordinal, offset);
1201            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1202            // Calling encoder.out_of_line_offset(0) is not allowed.
1203            if max_ordinal == 0 {
1204                return Ok(());
1205            }
1206            depth.increment()?;
1207            let envelope_size = 8;
1208            let bytes_len = max_ordinal as usize * envelope_size;
1209            #[allow(unused_variables)]
1210            let offset = encoder.out_of_line_offset(bytes_len);
1211            let mut _prev_end_offset: usize = 0;
1212            if 1 > max_ordinal {
1213                return Ok(());
1214            }
1215
1216            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1217            // are envelope_size bytes.
1218            let cur_offset: usize = (1 - 1) * envelope_size;
1219
1220            // Zero reserved fields.
1221            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1222
1223            // Safety:
1224            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1225            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1226            //   envelope_size bytes, there is always sufficient room.
1227            fidl::encoding::encode_in_envelope_optional::<
1228                fidl::encoding::HandleType<
1229                    fidl::Socket,
1230                    { fidl::ObjectType::SOCKET.into_raw() },
1231                    2147483648,
1232                >,
1233                fidl::encoding::DefaultFuchsiaResourceDialect,
1234            >(
1235                self.console_in.as_mut().map(
1236                    <fidl::encoding::HandleType<
1237                        fidl::Socket,
1238                        { fidl::ObjectType::SOCKET.into_raw() },
1239                        2147483648,
1240                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1241                ),
1242                encoder,
1243                offset + cur_offset,
1244                depth,
1245            )?;
1246
1247            _prev_end_offset = cur_offset + envelope_size;
1248            if 2 > max_ordinal {
1249                return Ok(());
1250            }
1251
1252            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1253            // are envelope_size bytes.
1254            let cur_offset: usize = (2 - 1) * envelope_size;
1255
1256            // Zero reserved fields.
1257            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1258
1259            // Safety:
1260            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1261            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1262            //   envelope_size bytes, there is always sufficient room.
1263            fidl::encoding::encode_in_envelope_optional::<
1264                fidl::encoding::HandleType<
1265                    fidl::Socket,
1266                    { fidl::ObjectType::SOCKET.into_raw() },
1267                    2147483648,
1268                >,
1269                fidl::encoding::DefaultFuchsiaResourceDialect,
1270            >(
1271                self.console_out.as_mut().map(
1272                    <fidl::encoding::HandleType<
1273                        fidl::Socket,
1274                        { fidl::ObjectType::SOCKET.into_raw() },
1275                        2147483648,
1276                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1277                ),
1278                encoder,
1279                offset + cur_offset,
1280                depth,
1281            )?;
1282
1283            _prev_end_offset = cur_offset + envelope_size;
1284            if 3 > max_ordinal {
1285                return Ok(());
1286            }
1287
1288            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1289            // are envelope_size bytes.
1290            let cur_offset: usize = (3 - 1) * envelope_size;
1291
1292            // Zero reserved fields.
1293            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1294
1295            // Safety:
1296            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1297            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1298            //   envelope_size bytes, there is always sufficient room.
1299            fidl::encoding::encode_in_envelope_optional::<
1300                fidl::encoding::UnboundedString,
1301                fidl::encoding::DefaultFuchsiaResourceDialect,
1302            >(
1303                self.binary_path.as_ref().map(
1304                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
1305                ),
1306                encoder,
1307                offset + cur_offset,
1308                depth,
1309            )?;
1310
1311            _prev_end_offset = cur_offset + envelope_size;
1312            if 4 > max_ordinal {
1313                return Ok(());
1314            }
1315
1316            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1317            // are envelope_size bytes.
1318            let cur_offset: usize = (4 - 1) * envelope_size;
1319
1320            // Zero reserved fields.
1321            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1322
1323            // Safety:
1324            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1325            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1326            //   envelope_size bytes, there is always sufficient room.
1327            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1328            self.argv.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow),
1329            encoder, offset + cur_offset, depth
1330        )?;
1331
1332            _prev_end_offset = cur_offset + envelope_size;
1333            if 5 > max_ordinal {
1334                return Ok(());
1335            }
1336
1337            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1338            // are envelope_size bytes.
1339            let cur_offset: usize = (5 - 1) * envelope_size;
1340
1341            // Zero reserved fields.
1342            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1343
1344            // Safety:
1345            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1346            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1347            //   envelope_size bytes, there is always sufficient room.
1348            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1349            self.environ.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow),
1350            encoder, offset + cur_offset, depth
1351        )?;
1352
1353            _prev_end_offset = cur_offset + envelope_size;
1354            if 6 > max_ordinal {
1355                return Ok(());
1356            }
1357
1358            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1359            // are envelope_size bytes.
1360            let cur_offset: usize = (6 - 1) * envelope_size;
1361
1362            // Zero reserved fields.
1363            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1364
1365            // Safety:
1366            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1367            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1368            //   envelope_size bytes, there is always sufficient room.
1369            fidl::encoding::encode_in_envelope_optional::<
1370                ConsoleWindowSize,
1371                fidl::encoding::DefaultFuchsiaResourceDialect,
1372            >(
1373                self.window_size
1374                    .as_ref()
1375                    .map(<ConsoleWindowSize as fidl::encoding::ValueTypeMarker>::borrow),
1376                encoder,
1377                offset + cur_offset,
1378                depth,
1379            )?;
1380
1381            _prev_end_offset = cur_offset + envelope_size;
1382
1383            Ok(())
1384        }
1385    }
1386
1387    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1388        for ControllerSpawnConsoleRequest
1389    {
1390        #[inline(always)]
1391        fn new_empty() -> Self {
1392            Self::default()
1393        }
1394
1395        unsafe fn decode(
1396            &mut self,
1397            decoder: &mut fidl::encoding::Decoder<
1398                '_,
1399                fidl::encoding::DefaultFuchsiaResourceDialect,
1400            >,
1401            offset: usize,
1402            mut depth: fidl::encoding::Depth,
1403        ) -> fidl::Result<()> {
1404            decoder.debug_check_bounds::<Self>(offset);
1405            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1406                None => return Err(fidl::Error::NotNullable),
1407                Some(len) => len,
1408            };
1409            // Calling decoder.out_of_line_offset(0) is not allowed.
1410            if len == 0 {
1411                return Ok(());
1412            };
1413            depth.increment()?;
1414            let envelope_size = 8;
1415            let bytes_len = len * envelope_size;
1416            let offset = decoder.out_of_line_offset(bytes_len)?;
1417            // Decode the envelope for each type.
1418            let mut _next_ordinal_to_read = 0;
1419            let mut next_offset = offset;
1420            let end_offset = offset + bytes_len;
1421            _next_ordinal_to_read += 1;
1422            if next_offset >= end_offset {
1423                return Ok(());
1424            }
1425
1426            // Decode unknown envelopes for gaps in ordinals.
1427            while _next_ordinal_to_read < 1 {
1428                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1429                _next_ordinal_to_read += 1;
1430                next_offset += envelope_size;
1431            }
1432
1433            let next_out_of_line = decoder.next_out_of_line();
1434            let handles_before = decoder.remaining_handles();
1435            if let Some((inlined, num_bytes, num_handles)) =
1436                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1437            {
1438                let member_inline_size = <fidl::encoding::HandleType<
1439                    fidl::Socket,
1440                    { fidl::ObjectType::SOCKET.into_raw() },
1441                    2147483648,
1442                > as fidl::encoding::TypeMarker>::inline_size(
1443                    decoder.context
1444                );
1445                if inlined != (member_inline_size <= 4) {
1446                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1447                }
1448                let inner_offset;
1449                let mut inner_depth = depth.clone();
1450                if inlined {
1451                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1452                    inner_offset = next_offset;
1453                } else {
1454                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1455                    inner_depth.increment()?;
1456                }
1457                let val_ref =
1458                self.console_in.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1459                fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1460                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1461                {
1462                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1463                }
1464                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1465                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1466                }
1467            }
1468
1469            next_offset += envelope_size;
1470            _next_ordinal_to_read += 1;
1471            if next_offset >= end_offset {
1472                return Ok(());
1473            }
1474
1475            // Decode unknown envelopes for gaps in ordinals.
1476            while _next_ordinal_to_read < 2 {
1477                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1478                _next_ordinal_to_read += 1;
1479                next_offset += envelope_size;
1480            }
1481
1482            let next_out_of_line = decoder.next_out_of_line();
1483            let handles_before = decoder.remaining_handles();
1484            if let Some((inlined, num_bytes, num_handles)) =
1485                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1486            {
1487                let member_inline_size = <fidl::encoding::HandleType<
1488                    fidl::Socket,
1489                    { fidl::ObjectType::SOCKET.into_raw() },
1490                    2147483648,
1491                > as fidl::encoding::TypeMarker>::inline_size(
1492                    decoder.context
1493                );
1494                if inlined != (member_inline_size <= 4) {
1495                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1496                }
1497                let inner_offset;
1498                let mut inner_depth = depth.clone();
1499                if inlined {
1500                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1501                    inner_offset = next_offset;
1502                } else {
1503                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1504                    inner_depth.increment()?;
1505                }
1506                let val_ref =
1507                self.console_out.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1508                fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1509                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1510                {
1511                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1512                }
1513                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1514                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1515                }
1516            }
1517
1518            next_offset += envelope_size;
1519            _next_ordinal_to_read += 1;
1520            if next_offset >= end_offset {
1521                return Ok(());
1522            }
1523
1524            // Decode unknown envelopes for gaps in ordinals.
1525            while _next_ordinal_to_read < 3 {
1526                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1527                _next_ordinal_to_read += 1;
1528                next_offset += envelope_size;
1529            }
1530
1531            let next_out_of_line = decoder.next_out_of_line();
1532            let handles_before = decoder.remaining_handles();
1533            if let Some((inlined, num_bytes, num_handles)) =
1534                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1535            {
1536                let member_inline_size =
1537                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
1538                        decoder.context,
1539                    );
1540                if inlined != (member_inline_size <= 4) {
1541                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1542                }
1543                let inner_offset;
1544                let mut inner_depth = depth.clone();
1545                if inlined {
1546                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1547                    inner_offset = next_offset;
1548                } else {
1549                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1550                    inner_depth.increment()?;
1551                }
1552                let val_ref = self.binary_path.get_or_insert_with(|| {
1553                    fidl::new_empty!(
1554                        fidl::encoding::UnboundedString,
1555                        fidl::encoding::DefaultFuchsiaResourceDialect
1556                    )
1557                });
1558                fidl::decode!(
1559                    fidl::encoding::UnboundedString,
1560                    fidl::encoding::DefaultFuchsiaResourceDialect,
1561                    val_ref,
1562                    decoder,
1563                    inner_offset,
1564                    inner_depth
1565                )?;
1566                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1567                {
1568                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1569                }
1570                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1571                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1572                }
1573            }
1574
1575            next_offset += envelope_size;
1576            _next_ordinal_to_read += 1;
1577            if next_offset >= end_offset {
1578                return Ok(());
1579            }
1580
1581            // Decode unknown envelopes for gaps in ordinals.
1582            while _next_ordinal_to_read < 4 {
1583                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1584                _next_ordinal_to_read += 1;
1585                next_offset += envelope_size;
1586            }
1587
1588            let next_out_of_line = decoder.next_out_of_line();
1589            let handles_before = decoder.remaining_handles();
1590            if let Some((inlined, num_bytes, num_handles)) =
1591                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1592            {
1593                let member_inline_size = <fidl::encoding::UnboundedVector<
1594                    fidl::encoding::UnboundedString,
1595                > as fidl::encoding::TypeMarker>::inline_size(
1596                    decoder.context
1597                );
1598                if inlined != (member_inline_size <= 4) {
1599                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1600                }
1601                let inner_offset;
1602                let mut inner_depth = depth.clone();
1603                if inlined {
1604                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1605                    inner_offset = next_offset;
1606                } else {
1607                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1608                    inner_depth.increment()?;
1609                }
1610                let val_ref = self.argv.get_or_insert_with(|| {
1611                    fidl::new_empty!(
1612                        fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
1613                        fidl::encoding::DefaultFuchsiaResourceDialect
1614                    )
1615                });
1616                fidl::decode!(
1617                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
1618                    fidl::encoding::DefaultFuchsiaResourceDialect,
1619                    val_ref,
1620                    decoder,
1621                    inner_offset,
1622                    inner_depth
1623                )?;
1624                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1625                {
1626                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1627                }
1628                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1629                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1630                }
1631            }
1632
1633            next_offset += envelope_size;
1634            _next_ordinal_to_read += 1;
1635            if next_offset >= end_offset {
1636                return Ok(());
1637            }
1638
1639            // Decode unknown envelopes for gaps in ordinals.
1640            while _next_ordinal_to_read < 5 {
1641                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1642                _next_ordinal_to_read += 1;
1643                next_offset += envelope_size;
1644            }
1645
1646            let next_out_of_line = decoder.next_out_of_line();
1647            let handles_before = decoder.remaining_handles();
1648            if let Some((inlined, num_bytes, num_handles)) =
1649                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1650            {
1651                let member_inline_size = <fidl::encoding::UnboundedVector<
1652                    fidl::encoding::UnboundedString,
1653                > as fidl::encoding::TypeMarker>::inline_size(
1654                    decoder.context
1655                );
1656                if inlined != (member_inline_size <= 4) {
1657                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1658                }
1659                let inner_offset;
1660                let mut inner_depth = depth.clone();
1661                if inlined {
1662                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1663                    inner_offset = next_offset;
1664                } else {
1665                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1666                    inner_depth.increment()?;
1667                }
1668                let val_ref = self.environ.get_or_insert_with(|| {
1669                    fidl::new_empty!(
1670                        fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
1671                        fidl::encoding::DefaultFuchsiaResourceDialect
1672                    )
1673                });
1674                fidl::decode!(
1675                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
1676                    fidl::encoding::DefaultFuchsiaResourceDialect,
1677                    val_ref,
1678                    decoder,
1679                    inner_offset,
1680                    inner_depth
1681                )?;
1682                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1683                {
1684                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1685                }
1686                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1687                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1688                }
1689            }
1690
1691            next_offset += envelope_size;
1692            _next_ordinal_to_read += 1;
1693            if next_offset >= end_offset {
1694                return Ok(());
1695            }
1696
1697            // Decode unknown envelopes for gaps in ordinals.
1698            while _next_ordinal_to_read < 6 {
1699                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1700                _next_ordinal_to_read += 1;
1701                next_offset += envelope_size;
1702            }
1703
1704            let next_out_of_line = decoder.next_out_of_line();
1705            let handles_before = decoder.remaining_handles();
1706            if let Some((inlined, num_bytes, num_handles)) =
1707                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1708            {
1709                let member_inline_size =
1710                    <ConsoleWindowSize as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1711                if inlined != (member_inline_size <= 4) {
1712                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1713                }
1714                let inner_offset;
1715                let mut inner_depth = depth.clone();
1716                if inlined {
1717                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1718                    inner_offset = next_offset;
1719                } else {
1720                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1721                    inner_depth.increment()?;
1722                }
1723                let val_ref = self.window_size.get_or_insert_with(|| {
1724                    fidl::new_empty!(
1725                        ConsoleWindowSize,
1726                        fidl::encoding::DefaultFuchsiaResourceDialect
1727                    )
1728                });
1729                fidl::decode!(
1730                    ConsoleWindowSize,
1731                    fidl::encoding::DefaultFuchsiaResourceDialect,
1732                    val_ref,
1733                    decoder,
1734                    inner_offset,
1735                    inner_depth
1736                )?;
1737                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1738                {
1739                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1740                }
1741                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1742                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1743                }
1744            }
1745
1746            next_offset += envelope_size;
1747
1748            // Decode the remaining unknown envelopes.
1749            while next_offset < end_offset {
1750                _next_ordinal_to_read += 1;
1751                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1752                next_offset += envelope_size;
1753            }
1754
1755            Ok(())
1756        }
1757    }
1758
1759    impl ControllerVsockConnectRequest {
1760        #[inline(always)]
1761        fn max_ordinal_present(&self) -> u64 {
1762            if let Some(_) = self.bridge_socket {
1763                return 2;
1764            }
1765            if let Some(_) = self.port {
1766                return 1;
1767            }
1768            0
1769        }
1770    }
1771
1772    impl fidl::encoding::ResourceTypeMarker for ControllerVsockConnectRequest {
1773        type Borrowed<'a> = &'a mut Self;
1774        fn take_or_borrow<'a>(
1775            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1776        ) -> Self::Borrowed<'a> {
1777            value
1778        }
1779    }
1780
1781    unsafe impl fidl::encoding::TypeMarker for ControllerVsockConnectRequest {
1782        type Owned = Self;
1783
1784        #[inline(always)]
1785        fn inline_align(_context: fidl::encoding::Context) -> usize {
1786            8
1787        }
1788
1789        #[inline(always)]
1790        fn inline_size(_context: fidl::encoding::Context) -> usize {
1791            16
1792        }
1793    }
1794
1795    unsafe impl
1796        fidl::encoding::Encode<
1797            ControllerVsockConnectRequest,
1798            fidl::encoding::DefaultFuchsiaResourceDialect,
1799        > for &mut ControllerVsockConnectRequest
1800    {
1801        unsafe fn encode(
1802            self,
1803            encoder: &mut fidl::encoding::Encoder<
1804                '_,
1805                fidl::encoding::DefaultFuchsiaResourceDialect,
1806            >,
1807            offset: usize,
1808            mut depth: fidl::encoding::Depth,
1809        ) -> fidl::Result<()> {
1810            encoder.debug_check_bounds::<ControllerVsockConnectRequest>(offset);
1811            // Vector header
1812            let max_ordinal: u64 = self.max_ordinal_present();
1813            encoder.write_num(max_ordinal, offset);
1814            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1815            // Calling encoder.out_of_line_offset(0) is not allowed.
1816            if max_ordinal == 0 {
1817                return Ok(());
1818            }
1819            depth.increment()?;
1820            let envelope_size = 8;
1821            let bytes_len = max_ordinal as usize * envelope_size;
1822            #[allow(unused_variables)]
1823            let offset = encoder.out_of_line_offset(bytes_len);
1824            let mut _prev_end_offset: usize = 0;
1825            if 1 > max_ordinal {
1826                return Ok(());
1827            }
1828
1829            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1830            // are envelope_size bytes.
1831            let cur_offset: usize = (1 - 1) * envelope_size;
1832
1833            // Zero reserved fields.
1834            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1835
1836            // Safety:
1837            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1838            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1839            //   envelope_size bytes, there is always sufficient room.
1840            fidl::encoding::encode_in_envelope_optional::<
1841                u32,
1842                fidl::encoding::DefaultFuchsiaResourceDialect,
1843            >(
1844                self.port.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1845                encoder,
1846                offset + cur_offset,
1847                depth,
1848            )?;
1849
1850            _prev_end_offset = cur_offset + envelope_size;
1851            if 2 > max_ordinal {
1852                return Ok(());
1853            }
1854
1855            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1856            // are envelope_size bytes.
1857            let cur_offset: usize = (2 - 1) * envelope_size;
1858
1859            // Zero reserved fields.
1860            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1861
1862            // Safety:
1863            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1864            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1865            //   envelope_size bytes, there is always sufficient room.
1866            fidl::encoding::encode_in_envelope_optional::<
1867                fidl::encoding::HandleType<
1868                    fidl::Socket,
1869                    { fidl::ObjectType::SOCKET.into_raw() },
1870                    2147483648,
1871                >,
1872                fidl::encoding::DefaultFuchsiaResourceDialect,
1873            >(
1874                self.bridge_socket.as_mut().map(
1875                    <fidl::encoding::HandleType<
1876                        fidl::Socket,
1877                        { fidl::ObjectType::SOCKET.into_raw() },
1878                        2147483648,
1879                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1880                ),
1881                encoder,
1882                offset + cur_offset,
1883                depth,
1884            )?;
1885
1886            _prev_end_offset = cur_offset + envelope_size;
1887
1888            Ok(())
1889        }
1890    }
1891
1892    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1893        for ControllerVsockConnectRequest
1894    {
1895        #[inline(always)]
1896        fn new_empty() -> Self {
1897            Self::default()
1898        }
1899
1900        unsafe fn decode(
1901            &mut self,
1902            decoder: &mut fidl::encoding::Decoder<
1903                '_,
1904                fidl::encoding::DefaultFuchsiaResourceDialect,
1905            >,
1906            offset: usize,
1907            mut depth: fidl::encoding::Depth,
1908        ) -> fidl::Result<()> {
1909            decoder.debug_check_bounds::<Self>(offset);
1910            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1911                None => return Err(fidl::Error::NotNullable),
1912                Some(len) => len,
1913            };
1914            // Calling decoder.out_of_line_offset(0) is not allowed.
1915            if len == 0 {
1916                return Ok(());
1917            };
1918            depth.increment()?;
1919            let envelope_size = 8;
1920            let bytes_len = len * envelope_size;
1921            let offset = decoder.out_of_line_offset(bytes_len)?;
1922            // Decode the envelope for each type.
1923            let mut _next_ordinal_to_read = 0;
1924            let mut next_offset = offset;
1925            let end_offset = offset + bytes_len;
1926            _next_ordinal_to_read += 1;
1927            if next_offset >= end_offset {
1928                return Ok(());
1929            }
1930
1931            // Decode unknown envelopes for gaps in ordinals.
1932            while _next_ordinal_to_read < 1 {
1933                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1934                _next_ordinal_to_read += 1;
1935                next_offset += envelope_size;
1936            }
1937
1938            let next_out_of_line = decoder.next_out_of_line();
1939            let handles_before = decoder.remaining_handles();
1940            if let Some((inlined, num_bytes, num_handles)) =
1941                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1942            {
1943                let member_inline_size =
1944                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1945                if inlined != (member_inline_size <= 4) {
1946                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1947                }
1948                let inner_offset;
1949                let mut inner_depth = depth.clone();
1950                if inlined {
1951                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1952                    inner_offset = next_offset;
1953                } else {
1954                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1955                    inner_depth.increment()?;
1956                }
1957                let val_ref = self.port.get_or_insert_with(|| {
1958                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1959                });
1960                fidl::decode!(
1961                    u32,
1962                    fidl::encoding::DefaultFuchsiaResourceDialect,
1963                    val_ref,
1964                    decoder,
1965                    inner_offset,
1966                    inner_depth
1967                )?;
1968                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1969                {
1970                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1971                }
1972                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1973                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1974                }
1975            }
1976
1977            next_offset += envelope_size;
1978            _next_ordinal_to_read += 1;
1979            if next_offset >= end_offset {
1980                return Ok(());
1981            }
1982
1983            // Decode unknown envelopes for gaps in ordinals.
1984            while _next_ordinal_to_read < 2 {
1985                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1986                _next_ordinal_to_read += 1;
1987                next_offset += envelope_size;
1988            }
1989
1990            let next_out_of_line = decoder.next_out_of_line();
1991            let handles_before = decoder.remaining_handles();
1992            if let Some((inlined, num_bytes, num_handles)) =
1993                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1994            {
1995                let member_inline_size = <fidl::encoding::HandleType<
1996                    fidl::Socket,
1997                    { fidl::ObjectType::SOCKET.into_raw() },
1998                    2147483648,
1999                > as fidl::encoding::TypeMarker>::inline_size(
2000                    decoder.context
2001                );
2002                if inlined != (member_inline_size <= 4) {
2003                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2004                }
2005                let inner_offset;
2006                let mut inner_depth = depth.clone();
2007                if inlined {
2008                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2009                    inner_offset = next_offset;
2010                } else {
2011                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2012                    inner_depth.increment()?;
2013                }
2014                let val_ref =
2015                self.bridge_socket.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2016                fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2017                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2018                {
2019                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2020                }
2021                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2022                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2023                }
2024            }
2025
2026            next_offset += envelope_size;
2027
2028            // Decode the remaining unknown envelopes.
2029            while next_offset < end_offset {
2030                _next_ordinal_to_read += 1;
2031                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2032                next_offset += envelope_size;
2033            }
2034
2035            Ok(())
2036        }
2037    }
2038
2039    impl ControllerGetJobHandleResponse {
2040        #[inline(always)]
2041        fn max_ordinal_present(&self) -> u64 {
2042            if let Some(_) = self.job {
2043                return 1;
2044            }
2045            0
2046        }
2047    }
2048
2049    impl fidl::encoding::ResourceTypeMarker for ControllerGetJobHandleResponse {
2050        type Borrowed<'a> = &'a mut Self;
2051        fn take_or_borrow<'a>(
2052            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2053        ) -> Self::Borrowed<'a> {
2054            value
2055        }
2056    }
2057
2058    unsafe impl fidl::encoding::TypeMarker for ControllerGetJobHandleResponse {
2059        type Owned = Self;
2060
2061        #[inline(always)]
2062        fn inline_align(_context: fidl::encoding::Context) -> usize {
2063            8
2064        }
2065
2066        #[inline(always)]
2067        fn inline_size(_context: fidl::encoding::Context) -> usize {
2068            16
2069        }
2070    }
2071
2072    unsafe impl
2073        fidl::encoding::Encode<
2074            ControllerGetJobHandleResponse,
2075            fidl::encoding::DefaultFuchsiaResourceDialect,
2076        > for &mut ControllerGetJobHandleResponse
2077    {
2078        unsafe fn encode(
2079            self,
2080            encoder: &mut fidl::encoding::Encoder<
2081                '_,
2082                fidl::encoding::DefaultFuchsiaResourceDialect,
2083            >,
2084            offset: usize,
2085            mut depth: fidl::encoding::Depth,
2086        ) -> fidl::Result<()> {
2087            encoder.debug_check_bounds::<ControllerGetJobHandleResponse>(offset);
2088            // Vector header
2089            let max_ordinal: u64 = self.max_ordinal_present();
2090            encoder.write_num(max_ordinal, offset);
2091            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2092            // Calling encoder.out_of_line_offset(0) is not allowed.
2093            if max_ordinal == 0 {
2094                return Ok(());
2095            }
2096            depth.increment()?;
2097            let envelope_size = 8;
2098            let bytes_len = max_ordinal as usize * envelope_size;
2099            #[allow(unused_variables)]
2100            let offset = encoder.out_of_line_offset(bytes_len);
2101            let mut _prev_end_offset: usize = 0;
2102            if 1 > max_ordinal {
2103                return Ok(());
2104            }
2105
2106            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2107            // are envelope_size bytes.
2108            let cur_offset: usize = (1 - 1) * envelope_size;
2109
2110            // Zero reserved fields.
2111            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2112
2113            // Safety:
2114            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2115            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2116            //   envelope_size bytes, there is always sufficient room.
2117            fidl::encoding::encode_in_envelope_optional::<
2118                fidl::encoding::HandleType<
2119                    fidl::Job,
2120                    { fidl::ObjectType::JOB.into_raw() },
2121                    2147483648,
2122                >,
2123                fidl::encoding::DefaultFuchsiaResourceDialect,
2124            >(
2125                self.job.as_mut().map(
2126                    <fidl::encoding::HandleType<
2127                        fidl::Job,
2128                        { fidl::ObjectType::JOB.into_raw() },
2129                        2147483648,
2130                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2131                ),
2132                encoder,
2133                offset + cur_offset,
2134                depth,
2135            )?;
2136
2137            _prev_end_offset = cur_offset + envelope_size;
2138
2139            Ok(())
2140        }
2141    }
2142
2143    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2144        for ControllerGetJobHandleResponse
2145    {
2146        #[inline(always)]
2147        fn new_empty() -> Self {
2148            Self::default()
2149        }
2150
2151        unsafe fn decode(
2152            &mut self,
2153            decoder: &mut fidl::encoding::Decoder<
2154                '_,
2155                fidl::encoding::DefaultFuchsiaResourceDialect,
2156            >,
2157            offset: usize,
2158            mut depth: fidl::encoding::Depth,
2159        ) -> fidl::Result<()> {
2160            decoder.debug_check_bounds::<Self>(offset);
2161            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2162                None => return Err(fidl::Error::NotNullable),
2163                Some(len) => len,
2164            };
2165            // Calling decoder.out_of_line_offset(0) is not allowed.
2166            if len == 0 {
2167                return Ok(());
2168            };
2169            depth.increment()?;
2170            let envelope_size = 8;
2171            let bytes_len = len * envelope_size;
2172            let offset = decoder.out_of_line_offset(bytes_len)?;
2173            // Decode the envelope for each type.
2174            let mut _next_ordinal_to_read = 0;
2175            let mut next_offset = offset;
2176            let end_offset = offset + bytes_len;
2177            _next_ordinal_to_read += 1;
2178            if next_offset >= end_offset {
2179                return Ok(());
2180            }
2181
2182            // Decode unknown envelopes for gaps in ordinals.
2183            while _next_ordinal_to_read < 1 {
2184                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2185                _next_ordinal_to_read += 1;
2186                next_offset += envelope_size;
2187            }
2188
2189            let next_out_of_line = decoder.next_out_of_line();
2190            let handles_before = decoder.remaining_handles();
2191            if let Some((inlined, num_bytes, num_handles)) =
2192                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2193            {
2194                let member_inline_size = <fidl::encoding::HandleType<
2195                    fidl::Job,
2196                    { fidl::ObjectType::JOB.into_raw() },
2197                    2147483648,
2198                > as fidl::encoding::TypeMarker>::inline_size(
2199                    decoder.context
2200                );
2201                if inlined != (member_inline_size <= 4) {
2202                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2203                }
2204                let inner_offset;
2205                let mut inner_depth = depth.clone();
2206                if inlined {
2207                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2208                    inner_offset = next_offset;
2209                } else {
2210                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2211                    inner_depth.increment()?;
2212                }
2213                let val_ref =
2214                self.job.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2215                fidl::decode!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2216                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2217                {
2218                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2219                }
2220                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2221                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2222                }
2223            }
2224
2225            next_offset += envelope_size;
2226
2227            // Decode the remaining unknown envelopes.
2228            while next_offset < end_offset {
2229                _next_ordinal_to_read += 1;
2230                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2231                next_offset += envelope_size;
2232            }
2233
2234            Ok(())
2235        }
2236    }
2237}