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