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