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