fidl_fuchsia_virtualization/
fidl_fuchsia_virtualization.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_virtualization_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14/// Properties describing a block device.
15#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
16pub struct BlockSpec {
17    /// The ID used to identify the block device.
18    pub id: String,
19    /// The access mode for the block device.
20    pub mode: BlockMode,
21    /// The data format of the block device.
22    pub format: BlockFormat,
23}
24
25impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockSpec {}
26
27#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
28pub struct GuestGetBalloonControllerRequest {
29    pub controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for GuestGetBalloonControllerRequest
34{
35}
36
37#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
38pub struct GuestGetHostVsockEndpointRequest {
39    pub endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for GuestGetHostVsockEndpointRequest
44{
45}
46
47#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48pub struct GuestGetMemControllerRequest {
49    pub controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
50}
51
52impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
53    for GuestGetMemControllerRequest
54{
55}
56
57#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
58pub struct GuestGetSerialResponse {
59    pub socket: fidl::Socket,
60}
61
62impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for GuestGetSerialResponse {}
63
64#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
65pub struct GuestLifecycleBindRequest {
66    pub guest: fidl::endpoints::ServerEnd<GuestMarker>,
67}
68
69impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for GuestLifecycleBindRequest {}
70
71#[derive(Debug, PartialEq)]
72pub struct GuestLifecycleCreateRequest {
73    pub guest_config: GuestConfig,
74}
75
76impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
77    for GuestLifecycleCreateRequest
78{
79}
80
81#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
82pub struct GuestManagerConnectRequest {
83    pub controller: fidl::endpoints::ServerEnd<GuestMarker>,
84}
85
86impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
87    for GuestManagerConnectRequest
88{
89}
90
91#[derive(Debug, PartialEq)]
92pub struct GuestManagerGetInfoResponse {
93    pub guest_info: GuestInfo,
94}
95
96impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
97    for GuestManagerGetInfoResponse
98{
99}
100
101#[derive(Debug, PartialEq)]
102pub struct GuestManagerLaunchRequest {
103    pub guest_config: GuestConfig,
104    pub controller: fidl::endpoints::ServerEnd<GuestMarker>,
105}
106
107impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for GuestManagerLaunchRequest {}
108
109#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
110pub struct GuestGetConsoleResponse {
111    pub socket: fidl::Socket,
112}
113
114impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for GuestGetConsoleResponse {}
115
116#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
117pub struct HostVsockAcceptorAcceptResponse {
118    pub socket: fidl::Socket,
119}
120
121impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
122    for HostVsockAcceptorAcceptResponse
123{
124}
125
126#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
127pub struct HostVsockEndpointConnectResponse {
128    pub socket: fidl::Socket,
129}
130
131impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
132    for HostVsockEndpointConnectResponse
133{
134}
135
136#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
137pub struct Listener {
138    pub port: u32,
139    pub acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
140}
141
142impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Listener {}
143
144/// Properties describing a virtio_wl device.
145#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
146pub struct WaylandDevice {
147    /// The amount of guest-physical address space to allocate for virtio_wl
148    /// buffers.
149    ///
150    /// Default to a 1GiB allocation.
151    pub memory: u64,
152    /// The server for new virtio_wl connections.
153    pub server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
154}
155
156impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for WaylandDevice {}
157
158/// The configuration required to start up a guest. When adding a new field, consider updating
159/// fuchsia.virtualization.GuestDescriptor which is an informational snapshot of this table.
160#[derive(Debug, Default, PartialEq)]
161pub struct GuestConfig {
162    /// Type of kernel to load. Cannot be changed from the command-line.
163    pub kernel_type: Option<KernelType>,
164    /// File to load the kernel from. Cannot be changed from the command-line.
165    pub kernel: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
166    /// File to load the initial RAM disk from. Cannot be changed from the
167    /// command-line.
168    pub ramdisk: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
169    /// File to load the dtb overlay for a Linux kernel from. Cannot be changed
170    /// from the command-line.
171    pub dtb_overlay: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
172    /// Kernel command-line to use. Cannot be changed from the command-line.
173    pub cmdline: Option<String>,
174    /// Additional kernel command-lines to append to the main command-line.
175    pub cmdline_add: Option<Vec<String>>,
176    /// The number of CPUs to provide to a guest.
177    pub cpus: Option<u8>,
178    /// Amount of guest memory required, in bytes. This value may be rounded up depending on
179    /// the system configuration.
180    pub guest_memory: Option<u64>,
181    /// A list of block devices to give a guest. Cannot be changed from the
182    /// command-line.
183    pub block_devices: Option<Vec<BlockSpec>>,
184    /// A list of specifications for network devices.
185    pub net_devices: Option<Vec<NetSpec>>,
186    /// Optional virtio-wl device.
187    pub wayland_device: Option<WaylandDevice>,
188    /// Optional virtio-magma device.
189    pub magma_device: Option<MagmaDevice>,
190    /// Whether to add a default network device.
191    pub default_net: Option<bool>,
192    /// Enable virtio-balloon.
193    pub virtio_balloon: Option<bool>,
194    /// Enable virtio-console.
195    pub virtio_console: Option<bool>,
196    /// Enable virtio-gpu.
197    pub virtio_gpu: Option<bool>,
198    /// Enable virtio-rng.
199    pub virtio_rng: Option<bool>,
200    /// Enable virtio-vsock.
201    pub virtio_vsock: Option<bool>,
202    /// Enable virtio-sound.
203    pub virtio_sound: Option<bool>,
204    /// Enable input streams (capture) for virtio-sound.
205    pub virtio_sound_input: Option<bool>,
206    /// Host ports to listen for guest initiated vsock connections on. This can be used for
207    /// simplicity if a Listener is known at config creation time, or if a Listener must be
208    /// available at the moment of guest creation for timing reasons.
209    ///
210    /// To add a Listener after a guest starts, see HostVsockEndpoint::Listen.
211    pub vsock_listeners: Option<Vec<Listener>>,
212    /// Enable virtio-mem
213    pub virtio_mem: Option<bool>,
214    /// Size of the dynamically (un)pluggable memory block.
215    /// Memory can be (un)plugged at this granularity.
216    /// Smaller block size increases changes of successful unplug at the cost of increasing
217    /// the size of tracking bitmap.
218    pub virtio_mem_block_size: Option<u64>,
219    /// Size of the entire dynamically pluggable memory region
220    pub virtio_mem_region_size: Option<u64>,
221    /// Required alignment of the dynamically pluggable memory region
222    pub virtio_mem_region_alignment: Option<u64>,
223    #[doc(hidden)]
224    pub __source_breaking: fidl::marker::SourceBreaking,
225}
226
227impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for GuestConfig {}
228
229#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
230pub enum BlockFormat {
231    /// File IO. All reads and writes go directly to disk as a flat file.
232    File(fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>),
233    /// QCOW image. All reads and writes go to a QCOW image.
234    Qcow(fidl::Channel),
235    /// Block IO. All reads and writes go to a block server.
236    Block(fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>),
237}
238
239impl BlockFormat {
240    #[inline]
241    pub fn ordinal(&self) -> u64 {
242        match *self {
243            Self::File(_) => 1,
244            Self::Qcow(_) => 2,
245            Self::Block(_) => 3,
246        }
247    }
248
249    #[deprecated = "Strict unions should not use `is_unknown`"]
250    #[inline]
251    pub fn is_unknown(&self) -> bool {
252        false
253    }
254}
255
256impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockFormat {}
257
258#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
259pub struct BalloonControllerMarker;
260
261impl fidl::endpoints::ProtocolMarker for BalloonControllerMarker {
262    type Proxy = BalloonControllerProxy;
263    type RequestStream = BalloonControllerRequestStream;
264    #[cfg(target_os = "fuchsia")]
265    type SynchronousProxy = BalloonControllerSynchronousProxy;
266
267    const DEBUG_NAME: &'static str = "fuchsia.virtualization.BalloonController";
268}
269impl fidl::endpoints::DiscoverableProtocolMarker for BalloonControllerMarker {}
270
271pub trait BalloonControllerProxyInterface: Send + Sync {
272    type GetBalloonSizeResponseFut: std::future::Future<Output = Result<(u32, u32), fidl::Error>>
273        + Send;
274    fn r#get_balloon_size(&self) -> Self::GetBalloonSizeResponseFut;
275    fn r#request_num_pages(&self, requested_num_pages: u32) -> Result<(), fidl::Error>;
276    type GetMemStatsResponseFut: std::future::Future<Output = Result<(i32, Option<Vec<MemStat>>), fidl::Error>>
277        + Send;
278    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut;
279}
280#[derive(Debug)]
281#[cfg(target_os = "fuchsia")]
282pub struct BalloonControllerSynchronousProxy {
283    client: fidl::client::sync::Client,
284}
285
286#[cfg(target_os = "fuchsia")]
287impl fidl::endpoints::SynchronousProxy for BalloonControllerSynchronousProxy {
288    type Proxy = BalloonControllerProxy;
289    type Protocol = BalloonControllerMarker;
290
291    fn from_channel(inner: fidl::Channel) -> Self {
292        Self::new(inner)
293    }
294
295    fn into_channel(self) -> fidl::Channel {
296        self.client.into_channel()
297    }
298
299    fn as_channel(&self) -> &fidl::Channel {
300        self.client.as_channel()
301    }
302}
303
304#[cfg(target_os = "fuchsia")]
305impl BalloonControllerSynchronousProxy {
306    pub fn new(channel: fidl::Channel) -> Self {
307        let protocol_name =
308            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
309        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
310    }
311
312    pub fn into_channel(self) -> fidl::Channel {
313        self.client.into_channel()
314    }
315
316    /// Waits until an event arrives and returns it. It is safe for other
317    /// threads to make concurrent requests while waiting for an event.
318    pub fn wait_for_event(
319        &self,
320        deadline: zx::MonotonicInstant,
321    ) -> Result<BalloonControllerEvent, fidl::Error> {
322        BalloonControllerEvent::decode(self.client.wait_for_event(deadline)?)
323    }
324
325    /// Get the current and requested number of pages in the memory balloon.
326    ///
327    /// current_num_pages is the number of pages balloon has right now.
328    /// requested_num_pages is the desired number of pages in the balloon.
329    ///
330    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
331    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
332    pub fn r#get_balloon_size(
333        &self,
334        ___deadline: zx::MonotonicInstant,
335    ) -> Result<(u32, u32), fidl::Error> {
336        let _response = self
337            .client
338            .send_query::<fidl::encoding::EmptyPayload, BalloonControllerGetBalloonSizeResponse>(
339                (),
340                0x2bb2ebaa6ff64d0b,
341                fidl::encoding::DynamicFlags::empty(),
342                ___deadline,
343            )?;
344        Ok((_response.current_num_pages, _response.requested_num_pages))
345    }
346
347    /// Request a number of pages to be supplied to the memory balloon.
348    ///
349    /// If `requested_num_pages` is greater than the `current_num_pages` config
350    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
351    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
352    /// the guest driver MAY reclaim pages from the memory balloon.
353    pub fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
354        self.client.send::<BalloonControllerRequestNumPagesRequest>(
355            (requested_num_pages,),
356            0x55c444d65e1df1e8,
357            fidl::encoding::DynamicFlags::empty(),
358        )
359    }
360
361    /// Get memory statistics of the guest instance.
362    pub fn r#get_mem_stats(
363        &self,
364        ___deadline: zx::MonotonicInstant,
365    ) -> Result<(i32, Option<Vec<MemStat>>), fidl::Error> {
366        let _response = self
367            .client
368            .send_query::<fidl::encoding::EmptyPayload, BalloonControllerGetMemStatsResponse>(
369                (),
370                0x676199795cc01142,
371                fidl::encoding::DynamicFlags::empty(),
372                ___deadline,
373            )?;
374        Ok((_response.status, _response.mem_stats))
375    }
376}
377
378#[derive(Debug, Clone)]
379pub struct BalloonControllerProxy {
380    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
381}
382
383impl fidl::endpoints::Proxy for BalloonControllerProxy {
384    type Protocol = BalloonControllerMarker;
385
386    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
387        Self::new(inner)
388    }
389
390    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
391        self.client.into_channel().map_err(|client| Self { client })
392    }
393
394    fn as_channel(&self) -> &::fidl::AsyncChannel {
395        self.client.as_channel()
396    }
397}
398
399impl BalloonControllerProxy {
400    /// Create a new Proxy for fuchsia.virtualization/BalloonController.
401    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
402        let protocol_name =
403            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
404        Self { client: fidl::client::Client::new(channel, protocol_name) }
405    }
406
407    /// Get a Stream of events from the remote end of the protocol.
408    ///
409    /// # Panics
410    ///
411    /// Panics if the event stream was already taken.
412    pub fn take_event_stream(&self) -> BalloonControllerEventStream {
413        BalloonControllerEventStream { event_receiver: self.client.take_event_receiver() }
414    }
415
416    /// Get the current and requested number of pages in the memory balloon.
417    ///
418    /// current_num_pages is the number of pages balloon has right now.
419    /// requested_num_pages is the desired number of pages in the balloon.
420    ///
421    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
422    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
423    pub fn r#get_balloon_size(
424        &self,
425    ) -> fidl::client::QueryResponseFut<(u32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
426    {
427        BalloonControllerProxyInterface::r#get_balloon_size(self)
428    }
429
430    /// Request a number of pages to be supplied to the memory balloon.
431    ///
432    /// If `requested_num_pages` is greater than the `current_num_pages` config
433    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
434    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
435    /// the guest driver MAY reclaim pages from the memory balloon.
436    pub fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
437        BalloonControllerProxyInterface::r#request_num_pages(self, requested_num_pages)
438    }
439
440    /// Get memory statistics of the guest instance.
441    pub fn r#get_mem_stats(
442        &self,
443    ) -> fidl::client::QueryResponseFut<
444        (i32, Option<Vec<MemStat>>),
445        fidl::encoding::DefaultFuchsiaResourceDialect,
446    > {
447        BalloonControllerProxyInterface::r#get_mem_stats(self)
448    }
449}
450
451impl BalloonControllerProxyInterface for BalloonControllerProxy {
452    type GetBalloonSizeResponseFut =
453        fidl::client::QueryResponseFut<(u32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
454    fn r#get_balloon_size(&self) -> Self::GetBalloonSizeResponseFut {
455        fn _decode(
456            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
457        ) -> Result<(u32, u32), fidl::Error> {
458            let _response = fidl::client::decode_transaction_body::<
459                BalloonControllerGetBalloonSizeResponse,
460                fidl::encoding::DefaultFuchsiaResourceDialect,
461                0x2bb2ebaa6ff64d0b,
462            >(_buf?)?;
463            Ok((_response.current_num_pages, _response.requested_num_pages))
464        }
465        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (u32, u32)>(
466            (),
467            0x2bb2ebaa6ff64d0b,
468            fidl::encoding::DynamicFlags::empty(),
469            _decode,
470        )
471    }
472
473    fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
474        self.client.send::<BalloonControllerRequestNumPagesRequest>(
475            (requested_num_pages,),
476            0x55c444d65e1df1e8,
477            fidl::encoding::DynamicFlags::empty(),
478        )
479    }
480
481    type GetMemStatsResponseFut = fidl::client::QueryResponseFut<
482        (i32, Option<Vec<MemStat>>),
483        fidl::encoding::DefaultFuchsiaResourceDialect,
484    >;
485    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut {
486        fn _decode(
487            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
488        ) -> Result<(i32, Option<Vec<MemStat>>), fidl::Error> {
489            let _response = fidl::client::decode_transaction_body::<
490                BalloonControllerGetMemStatsResponse,
491                fidl::encoding::DefaultFuchsiaResourceDialect,
492                0x676199795cc01142,
493            >(_buf?)?;
494            Ok((_response.status, _response.mem_stats))
495        }
496        self.client
497            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<Vec<MemStat>>)>(
498                (),
499                0x676199795cc01142,
500                fidl::encoding::DynamicFlags::empty(),
501                _decode,
502            )
503    }
504}
505
506pub struct BalloonControllerEventStream {
507    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
508}
509
510impl std::marker::Unpin for BalloonControllerEventStream {}
511
512impl futures::stream::FusedStream for BalloonControllerEventStream {
513    fn is_terminated(&self) -> bool {
514        self.event_receiver.is_terminated()
515    }
516}
517
518impl futures::Stream for BalloonControllerEventStream {
519    type Item = Result<BalloonControllerEvent, fidl::Error>;
520
521    fn poll_next(
522        mut self: std::pin::Pin<&mut Self>,
523        cx: &mut std::task::Context<'_>,
524    ) -> std::task::Poll<Option<Self::Item>> {
525        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
526            &mut self.event_receiver,
527            cx
528        )?) {
529            Some(buf) => std::task::Poll::Ready(Some(BalloonControllerEvent::decode(buf))),
530            None => std::task::Poll::Ready(None),
531        }
532    }
533}
534
535#[derive(Debug)]
536pub enum BalloonControllerEvent {}
537
538impl BalloonControllerEvent {
539    /// Decodes a message buffer as a [`BalloonControllerEvent`].
540    fn decode(
541        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
542    ) -> Result<BalloonControllerEvent, fidl::Error> {
543        let (bytes, _handles) = buf.split_mut();
544        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
545        debug_assert_eq!(tx_header.tx_id, 0);
546        match tx_header.ordinal {
547            _ => Err(fidl::Error::UnknownOrdinal {
548                ordinal: tx_header.ordinal,
549                protocol_name:
550                    <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
551            }),
552        }
553    }
554}
555
556/// A Stream of incoming requests for fuchsia.virtualization/BalloonController.
557pub struct BalloonControllerRequestStream {
558    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
559    is_terminated: bool,
560}
561
562impl std::marker::Unpin for BalloonControllerRequestStream {}
563
564impl futures::stream::FusedStream for BalloonControllerRequestStream {
565    fn is_terminated(&self) -> bool {
566        self.is_terminated
567    }
568}
569
570impl fidl::endpoints::RequestStream for BalloonControllerRequestStream {
571    type Protocol = BalloonControllerMarker;
572    type ControlHandle = BalloonControllerControlHandle;
573
574    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
575        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
576    }
577
578    fn control_handle(&self) -> Self::ControlHandle {
579        BalloonControllerControlHandle { inner: self.inner.clone() }
580    }
581
582    fn into_inner(
583        self,
584    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
585    {
586        (self.inner, self.is_terminated)
587    }
588
589    fn from_inner(
590        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
591        is_terminated: bool,
592    ) -> Self {
593        Self { inner, is_terminated }
594    }
595}
596
597impl futures::Stream for BalloonControllerRequestStream {
598    type Item = Result<BalloonControllerRequest, fidl::Error>;
599
600    fn poll_next(
601        mut self: std::pin::Pin<&mut Self>,
602        cx: &mut std::task::Context<'_>,
603    ) -> std::task::Poll<Option<Self::Item>> {
604        let this = &mut *self;
605        if this.inner.check_shutdown(cx) {
606            this.is_terminated = true;
607            return std::task::Poll::Ready(None);
608        }
609        if this.is_terminated {
610            panic!("polled BalloonControllerRequestStream after completion");
611        }
612        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
613            |bytes, handles| {
614                match this.inner.channel().read_etc(cx, bytes, handles) {
615                    std::task::Poll::Ready(Ok(())) => {}
616                    std::task::Poll::Pending => return std::task::Poll::Pending,
617                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
618                        this.is_terminated = true;
619                        return std::task::Poll::Ready(None);
620                    }
621                    std::task::Poll::Ready(Err(e)) => {
622                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
623                            e.into(),
624                        ))))
625                    }
626                }
627
628                // A message has been received from the channel
629                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
630
631                std::task::Poll::Ready(Some(match header.ordinal {
632                    0x2bb2ebaa6ff64d0b => {
633                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
634                        let mut req = fidl::new_empty!(
635                            fidl::encoding::EmptyPayload,
636                            fidl::encoding::DefaultFuchsiaResourceDialect
637                        );
638                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
639                        let control_handle =
640                            BalloonControllerControlHandle { inner: this.inner.clone() };
641                        Ok(BalloonControllerRequest::GetBalloonSize {
642                            responder: BalloonControllerGetBalloonSizeResponder {
643                                control_handle: std::mem::ManuallyDrop::new(control_handle),
644                                tx_id: header.tx_id,
645                            },
646                        })
647                    }
648                    0x55c444d65e1df1e8 => {
649                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
650                        let mut req = fidl::new_empty!(
651                            BalloonControllerRequestNumPagesRequest,
652                            fidl::encoding::DefaultFuchsiaResourceDialect
653                        );
654                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BalloonControllerRequestNumPagesRequest>(&header, _body_bytes, handles, &mut req)?;
655                        let control_handle =
656                            BalloonControllerControlHandle { inner: this.inner.clone() };
657                        Ok(BalloonControllerRequest::RequestNumPages {
658                            requested_num_pages: req.requested_num_pages,
659
660                            control_handle,
661                        })
662                    }
663                    0x676199795cc01142 => {
664                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
665                        let mut req = fidl::new_empty!(
666                            fidl::encoding::EmptyPayload,
667                            fidl::encoding::DefaultFuchsiaResourceDialect
668                        );
669                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
670                        let control_handle =
671                            BalloonControllerControlHandle { inner: this.inner.clone() };
672                        Ok(BalloonControllerRequest::GetMemStats {
673                            responder: BalloonControllerGetMemStatsResponder {
674                                control_handle: std::mem::ManuallyDrop::new(control_handle),
675                                tx_id: header.tx_id,
676                            },
677                        })
678                    }
679                    _ => Err(fidl::Error::UnknownOrdinal {
680                        ordinal: header.ordinal,
681                        protocol_name:
682                            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
683                    }),
684                }))
685            },
686        )
687    }
688}
689
690/// A `BalloonController` controls a guest instance's memory balloon.
691#[derive(Debug)]
692pub enum BalloonControllerRequest {
693    /// Get the current and requested number of pages in the memory balloon.
694    ///
695    /// current_num_pages is the number of pages balloon has right now.
696    /// requested_num_pages is the desired number of pages in the balloon.
697    ///
698    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
699    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
700    GetBalloonSize { responder: BalloonControllerGetBalloonSizeResponder },
701    /// Request a number of pages to be supplied to the memory balloon.
702    ///
703    /// If `requested_num_pages` is greater than the `current_num_pages` config
704    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
705    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
706    /// the guest driver MAY reclaim pages from the memory balloon.
707    RequestNumPages { requested_num_pages: u32, control_handle: BalloonControllerControlHandle },
708    /// Get memory statistics of the guest instance.
709    GetMemStats { responder: BalloonControllerGetMemStatsResponder },
710}
711
712impl BalloonControllerRequest {
713    #[allow(irrefutable_let_patterns)]
714    pub fn into_get_balloon_size(self) -> Option<(BalloonControllerGetBalloonSizeResponder)> {
715        if let BalloonControllerRequest::GetBalloonSize { responder } = self {
716            Some((responder))
717        } else {
718            None
719        }
720    }
721
722    #[allow(irrefutable_let_patterns)]
723    pub fn into_request_num_pages(self) -> Option<(u32, BalloonControllerControlHandle)> {
724        if let BalloonControllerRequest::RequestNumPages { requested_num_pages, control_handle } =
725            self
726        {
727            Some((requested_num_pages, control_handle))
728        } else {
729            None
730        }
731    }
732
733    #[allow(irrefutable_let_patterns)]
734    pub fn into_get_mem_stats(self) -> Option<(BalloonControllerGetMemStatsResponder)> {
735        if let BalloonControllerRequest::GetMemStats { responder } = self {
736            Some((responder))
737        } else {
738            None
739        }
740    }
741
742    /// Name of the method defined in FIDL
743    pub fn method_name(&self) -> &'static str {
744        match *self {
745            BalloonControllerRequest::GetBalloonSize { .. } => "get_balloon_size",
746            BalloonControllerRequest::RequestNumPages { .. } => "request_num_pages",
747            BalloonControllerRequest::GetMemStats { .. } => "get_mem_stats",
748        }
749    }
750}
751
752#[derive(Debug, Clone)]
753pub struct BalloonControllerControlHandle {
754    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
755}
756
757impl fidl::endpoints::ControlHandle for BalloonControllerControlHandle {
758    fn shutdown(&self) {
759        self.inner.shutdown()
760    }
761    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
762        self.inner.shutdown_with_epitaph(status)
763    }
764
765    fn is_closed(&self) -> bool {
766        self.inner.channel().is_closed()
767    }
768    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
769        self.inner.channel().on_closed()
770    }
771
772    #[cfg(target_os = "fuchsia")]
773    fn signal_peer(
774        &self,
775        clear_mask: zx::Signals,
776        set_mask: zx::Signals,
777    ) -> Result<(), zx_status::Status> {
778        use fidl::Peered;
779        self.inner.channel().signal_peer(clear_mask, set_mask)
780    }
781}
782
783impl BalloonControllerControlHandle {}
784
785#[must_use = "FIDL methods require a response to be sent"]
786#[derive(Debug)]
787pub struct BalloonControllerGetBalloonSizeResponder {
788    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
789    tx_id: u32,
790}
791
792/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
793/// if the responder is dropped without sending a response, so that the client
794/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
795impl std::ops::Drop for BalloonControllerGetBalloonSizeResponder {
796    fn drop(&mut self) {
797        self.control_handle.shutdown();
798        // Safety: drops once, never accessed again
799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
800    }
801}
802
803impl fidl::endpoints::Responder for BalloonControllerGetBalloonSizeResponder {
804    type ControlHandle = BalloonControllerControlHandle;
805
806    fn control_handle(&self) -> &BalloonControllerControlHandle {
807        &self.control_handle
808    }
809
810    fn drop_without_shutdown(mut self) {
811        // Safety: drops once, never accessed again due to mem::forget
812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
813        // Prevent Drop from running (which would shut down the channel)
814        std::mem::forget(self);
815    }
816}
817
818impl BalloonControllerGetBalloonSizeResponder {
819    /// Sends a response to the FIDL transaction.
820    ///
821    /// Sets the channel to shutdown if an error occurs.
822    pub fn send(
823        self,
824        mut current_num_pages: u32,
825        mut requested_num_pages: u32,
826    ) -> Result<(), fidl::Error> {
827        let _result = self.send_raw(current_num_pages, requested_num_pages);
828        if _result.is_err() {
829            self.control_handle.shutdown();
830        }
831        self.drop_without_shutdown();
832        _result
833    }
834
835    /// Similar to "send" but does not shutdown the channel if an error occurs.
836    pub fn send_no_shutdown_on_err(
837        self,
838        mut current_num_pages: u32,
839        mut requested_num_pages: u32,
840    ) -> Result<(), fidl::Error> {
841        let _result = self.send_raw(current_num_pages, requested_num_pages);
842        self.drop_without_shutdown();
843        _result
844    }
845
846    fn send_raw(
847        &self,
848        mut current_num_pages: u32,
849        mut requested_num_pages: u32,
850    ) -> Result<(), fidl::Error> {
851        self.control_handle.inner.send::<BalloonControllerGetBalloonSizeResponse>(
852            (current_num_pages, requested_num_pages),
853            self.tx_id,
854            0x2bb2ebaa6ff64d0b,
855            fidl::encoding::DynamicFlags::empty(),
856        )
857    }
858}
859
860#[must_use = "FIDL methods require a response to be sent"]
861#[derive(Debug)]
862pub struct BalloonControllerGetMemStatsResponder {
863    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
864    tx_id: u32,
865}
866
867/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
868/// if the responder is dropped without sending a response, so that the client
869/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
870impl std::ops::Drop for BalloonControllerGetMemStatsResponder {
871    fn drop(&mut self) {
872        self.control_handle.shutdown();
873        // Safety: drops once, never accessed again
874        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
875    }
876}
877
878impl fidl::endpoints::Responder for BalloonControllerGetMemStatsResponder {
879    type ControlHandle = BalloonControllerControlHandle;
880
881    fn control_handle(&self) -> &BalloonControllerControlHandle {
882        &self.control_handle
883    }
884
885    fn drop_without_shutdown(mut self) {
886        // Safety: drops once, never accessed again due to mem::forget
887        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
888        // Prevent Drop from running (which would shut down the channel)
889        std::mem::forget(self);
890    }
891}
892
893impl BalloonControllerGetMemStatsResponder {
894    /// Sends a response to the FIDL transaction.
895    ///
896    /// Sets the channel to shutdown if an error occurs.
897    pub fn send(
898        self,
899        mut status: i32,
900        mut mem_stats: Option<&[MemStat]>,
901    ) -> Result<(), fidl::Error> {
902        let _result = self.send_raw(status, mem_stats);
903        if _result.is_err() {
904            self.control_handle.shutdown();
905        }
906        self.drop_without_shutdown();
907        _result
908    }
909
910    /// Similar to "send" but does not shutdown the channel if an error occurs.
911    pub fn send_no_shutdown_on_err(
912        self,
913        mut status: i32,
914        mut mem_stats: Option<&[MemStat]>,
915    ) -> Result<(), fidl::Error> {
916        let _result = self.send_raw(status, mem_stats);
917        self.drop_without_shutdown();
918        _result
919    }
920
921    fn send_raw(
922        &self,
923        mut status: i32,
924        mut mem_stats: Option<&[MemStat]>,
925    ) -> Result<(), fidl::Error> {
926        self.control_handle.inner.send::<BalloonControllerGetMemStatsResponse>(
927            (status, mem_stats),
928            self.tx_id,
929            0x676199795cc01142,
930            fidl::encoding::DynamicFlags::empty(),
931        )
932    }
933}
934
935#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
936pub struct DebianGuestManagerMarker;
937
938impl fidl::endpoints::ProtocolMarker for DebianGuestManagerMarker {
939    type Proxy = DebianGuestManagerProxy;
940    type RequestStream = DebianGuestManagerRequestStream;
941    #[cfg(target_os = "fuchsia")]
942    type SynchronousProxy = DebianGuestManagerSynchronousProxy;
943
944    const DEBUG_NAME: &'static str = "fuchsia.virtualization.DebianGuestManager";
945}
946impl fidl::endpoints::DiscoverableProtocolMarker for DebianGuestManagerMarker {}
947
948pub trait DebianGuestManagerProxyInterface: Send + Sync {
949    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
950        + Send;
951    fn r#launch(
952        &self,
953        guest_config: GuestConfig,
954        controller: fidl::endpoints::ServerEnd<GuestMarker>,
955    ) -> Self::LaunchResponseFut;
956    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
957    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
958    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
959        + Send;
960    fn r#connect(
961        &self,
962        controller: fidl::endpoints::ServerEnd<GuestMarker>,
963    ) -> Self::ConnectResponseFut;
964    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
965    fn r#get_info(&self) -> Self::GetInfoResponseFut;
966}
967#[derive(Debug)]
968#[cfg(target_os = "fuchsia")]
969pub struct DebianGuestManagerSynchronousProxy {
970    client: fidl::client::sync::Client,
971}
972
973#[cfg(target_os = "fuchsia")]
974impl fidl::endpoints::SynchronousProxy for DebianGuestManagerSynchronousProxy {
975    type Proxy = DebianGuestManagerProxy;
976    type Protocol = DebianGuestManagerMarker;
977
978    fn from_channel(inner: fidl::Channel) -> Self {
979        Self::new(inner)
980    }
981
982    fn into_channel(self) -> fidl::Channel {
983        self.client.into_channel()
984    }
985
986    fn as_channel(&self) -> &fidl::Channel {
987        self.client.as_channel()
988    }
989}
990
991#[cfg(target_os = "fuchsia")]
992impl DebianGuestManagerSynchronousProxy {
993    pub fn new(channel: fidl::Channel) -> Self {
994        let protocol_name =
995            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
996        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
997    }
998
999    pub fn into_channel(self) -> fidl::Channel {
1000        self.client.into_channel()
1001    }
1002
1003    /// Waits until an event arrives and returns it. It is safe for other
1004    /// threads to make concurrent requests while waiting for an event.
1005    pub fn wait_for_event(
1006        &self,
1007        deadline: zx::MonotonicInstant,
1008    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1009        DebianGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
1010    }
1011
1012    /// Launch a new guest instance.
1013    ///
1014    /// Possible errors:
1015    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1016    ///         problems detected by the guest manager.
1017    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1018    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1019    ///         component logs for a more specific failure.
1020    pub fn r#launch(
1021        &self,
1022        mut guest_config: GuestConfig,
1023        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1024        ___deadline: zx::MonotonicInstant,
1025    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1026        let _response =
1027            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
1028                fidl::encoding::EmptyStruct,
1029                GuestManagerError,
1030            >>(
1031                (&mut guest_config, controller),
1032                0x394a2e29f750323e,
1033                fidl::encoding::DynamicFlags::empty(),
1034                ___deadline,
1035            )?;
1036        Ok(_response.map(|x| x))
1037    }
1038
1039    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1040    /// be used to launch another guest.
1041    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1042        let _response =
1043            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1044                (),
1045                0x3ad9a012982f872d,
1046                fidl::encoding::DynamicFlags::empty(),
1047                ___deadline,
1048            )?;
1049        Ok(_response)
1050    }
1051
1052    /// Connect to a currently running guest.
1053    ///
1054    /// Possible errors:
1055    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1056    ///         has launched before attempting to reconnect.
1057    pub fn r#connect(
1058        &self,
1059        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1060        ___deadline: zx::MonotonicInstant,
1061    ) -> Result<GuestManagerConnectResult, fidl::Error> {
1062        let _response =
1063            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
1064                fidl::encoding::EmptyStruct,
1065                GuestManagerError,
1066            >>(
1067                (controller,),
1068                0x4e489076e3bb15b4,
1069                fidl::encoding::DynamicFlags::empty(),
1070                ___deadline,
1071            )?;
1072        Ok(_response.map(|x| x))
1073    }
1074
1075    /// Query guest info
1076    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
1077        let _response =
1078            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
1079                (),
1080                0x76892614aea695dc,
1081                fidl::encoding::DynamicFlags::empty(),
1082                ___deadline,
1083            )?;
1084        Ok(_response.guest_info)
1085    }
1086}
1087
1088#[derive(Debug, Clone)]
1089pub struct DebianGuestManagerProxy {
1090    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1091}
1092
1093impl fidl::endpoints::Proxy for DebianGuestManagerProxy {
1094    type Protocol = DebianGuestManagerMarker;
1095
1096    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1097        Self::new(inner)
1098    }
1099
1100    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1101        self.client.into_channel().map_err(|client| Self { client })
1102    }
1103
1104    fn as_channel(&self) -> &::fidl::AsyncChannel {
1105        self.client.as_channel()
1106    }
1107}
1108
1109impl DebianGuestManagerProxy {
1110    /// Create a new Proxy for fuchsia.virtualization/DebianGuestManager.
1111    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1112        let protocol_name =
1113            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1114        Self { client: fidl::client::Client::new(channel, protocol_name) }
1115    }
1116
1117    /// Get a Stream of events from the remote end of the protocol.
1118    ///
1119    /// # Panics
1120    ///
1121    /// Panics if the event stream was already taken.
1122    pub fn take_event_stream(&self) -> DebianGuestManagerEventStream {
1123        DebianGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
1124    }
1125
1126    /// Launch a new guest instance.
1127    ///
1128    /// Possible errors:
1129    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1130    ///         problems detected by the guest manager.
1131    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1132    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1133    ///         component logs for a more specific failure.
1134    pub fn r#launch(
1135        &self,
1136        mut guest_config: GuestConfig,
1137        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1138    ) -> fidl::client::QueryResponseFut<
1139        GuestManagerLaunchResult,
1140        fidl::encoding::DefaultFuchsiaResourceDialect,
1141    > {
1142        DebianGuestManagerProxyInterface::r#launch(self, guest_config, controller)
1143    }
1144
1145    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1146    /// be used to launch another guest.
1147    pub fn r#force_shutdown(
1148        &self,
1149    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1150        DebianGuestManagerProxyInterface::r#force_shutdown(self)
1151    }
1152
1153    /// Connect to a currently running guest.
1154    ///
1155    /// Possible errors:
1156    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1157    ///         has launched before attempting to reconnect.
1158    pub fn r#connect(
1159        &self,
1160        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1161    ) -> fidl::client::QueryResponseFut<
1162        GuestManagerConnectResult,
1163        fidl::encoding::DefaultFuchsiaResourceDialect,
1164    > {
1165        DebianGuestManagerProxyInterface::r#connect(self, controller)
1166    }
1167
1168    /// Query guest info
1169    pub fn r#get_info(
1170        &self,
1171    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1172    {
1173        DebianGuestManagerProxyInterface::r#get_info(self)
1174    }
1175}
1176
1177impl DebianGuestManagerProxyInterface for DebianGuestManagerProxy {
1178    type LaunchResponseFut = fidl::client::QueryResponseFut<
1179        GuestManagerLaunchResult,
1180        fidl::encoding::DefaultFuchsiaResourceDialect,
1181    >;
1182    fn r#launch(
1183        &self,
1184        mut guest_config: GuestConfig,
1185        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1186    ) -> Self::LaunchResponseFut {
1187        fn _decode(
1188            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1189        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1190            let _response = fidl::client::decode_transaction_body::<
1191                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1192                fidl::encoding::DefaultFuchsiaResourceDialect,
1193                0x394a2e29f750323e,
1194            >(_buf?)?;
1195            Ok(_response.map(|x| x))
1196        }
1197        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
1198            (&mut guest_config, controller),
1199            0x394a2e29f750323e,
1200            fidl::encoding::DynamicFlags::empty(),
1201            _decode,
1202        )
1203    }
1204
1205    type ForceShutdownResponseFut =
1206        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1207    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
1208        fn _decode(
1209            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1210        ) -> Result<(), fidl::Error> {
1211            let _response = fidl::client::decode_transaction_body::<
1212                fidl::encoding::EmptyPayload,
1213                fidl::encoding::DefaultFuchsiaResourceDialect,
1214                0x3ad9a012982f872d,
1215            >(_buf?)?;
1216            Ok(_response)
1217        }
1218        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1219            (),
1220            0x3ad9a012982f872d,
1221            fidl::encoding::DynamicFlags::empty(),
1222            _decode,
1223        )
1224    }
1225
1226    type ConnectResponseFut = fidl::client::QueryResponseFut<
1227        GuestManagerConnectResult,
1228        fidl::encoding::DefaultFuchsiaResourceDialect,
1229    >;
1230    fn r#connect(
1231        &self,
1232        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1233    ) -> Self::ConnectResponseFut {
1234        fn _decode(
1235            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1236        ) -> Result<GuestManagerConnectResult, fidl::Error> {
1237            let _response = fidl::client::decode_transaction_body::<
1238                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1239                fidl::encoding::DefaultFuchsiaResourceDialect,
1240                0x4e489076e3bb15b4,
1241            >(_buf?)?;
1242            Ok(_response.map(|x| x))
1243        }
1244        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
1245            (controller,),
1246            0x4e489076e3bb15b4,
1247            fidl::encoding::DynamicFlags::empty(),
1248            _decode,
1249        )
1250    }
1251
1252    type GetInfoResponseFut =
1253        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
1254    fn r#get_info(&self) -> Self::GetInfoResponseFut {
1255        fn _decode(
1256            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1257        ) -> Result<GuestInfo, fidl::Error> {
1258            let _response = fidl::client::decode_transaction_body::<
1259                GuestManagerGetInfoResponse,
1260                fidl::encoding::DefaultFuchsiaResourceDialect,
1261                0x76892614aea695dc,
1262            >(_buf?)?;
1263            Ok(_response.guest_info)
1264        }
1265        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
1266            (),
1267            0x76892614aea695dc,
1268            fidl::encoding::DynamicFlags::empty(),
1269            _decode,
1270        )
1271    }
1272}
1273
1274pub struct DebianGuestManagerEventStream {
1275    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1276}
1277
1278impl std::marker::Unpin for DebianGuestManagerEventStream {}
1279
1280impl futures::stream::FusedStream for DebianGuestManagerEventStream {
1281    fn is_terminated(&self) -> bool {
1282        self.event_receiver.is_terminated()
1283    }
1284}
1285
1286impl futures::Stream for DebianGuestManagerEventStream {
1287    type Item = Result<DebianGuestManagerEvent, fidl::Error>;
1288
1289    fn poll_next(
1290        mut self: std::pin::Pin<&mut Self>,
1291        cx: &mut std::task::Context<'_>,
1292    ) -> std::task::Poll<Option<Self::Item>> {
1293        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1294            &mut self.event_receiver,
1295            cx
1296        )?) {
1297            Some(buf) => std::task::Poll::Ready(Some(DebianGuestManagerEvent::decode(buf))),
1298            None => std::task::Poll::Ready(None),
1299        }
1300    }
1301}
1302
1303#[derive(Debug)]
1304pub enum DebianGuestManagerEvent {}
1305
1306impl DebianGuestManagerEvent {
1307    /// Decodes a message buffer as a [`DebianGuestManagerEvent`].
1308    fn decode(
1309        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1310    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1311        let (bytes, _handles) = buf.split_mut();
1312        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1313        debug_assert_eq!(tx_header.tx_id, 0);
1314        match tx_header.ordinal {
1315            _ => Err(fidl::Error::UnknownOrdinal {
1316                ordinal: tx_header.ordinal,
1317                protocol_name:
1318                    <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1319            }),
1320        }
1321    }
1322}
1323
1324/// A Stream of incoming requests for fuchsia.virtualization/DebianGuestManager.
1325pub struct DebianGuestManagerRequestStream {
1326    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1327    is_terminated: bool,
1328}
1329
1330impl std::marker::Unpin for DebianGuestManagerRequestStream {}
1331
1332impl futures::stream::FusedStream for DebianGuestManagerRequestStream {
1333    fn is_terminated(&self) -> bool {
1334        self.is_terminated
1335    }
1336}
1337
1338impl fidl::endpoints::RequestStream for DebianGuestManagerRequestStream {
1339    type Protocol = DebianGuestManagerMarker;
1340    type ControlHandle = DebianGuestManagerControlHandle;
1341
1342    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1343        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1344    }
1345
1346    fn control_handle(&self) -> Self::ControlHandle {
1347        DebianGuestManagerControlHandle { inner: self.inner.clone() }
1348    }
1349
1350    fn into_inner(
1351        self,
1352    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1353    {
1354        (self.inner, self.is_terminated)
1355    }
1356
1357    fn from_inner(
1358        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1359        is_terminated: bool,
1360    ) -> Self {
1361        Self { inner, is_terminated }
1362    }
1363}
1364
1365impl futures::Stream for DebianGuestManagerRequestStream {
1366    type Item = Result<DebianGuestManagerRequest, fidl::Error>;
1367
1368    fn poll_next(
1369        mut self: std::pin::Pin<&mut Self>,
1370        cx: &mut std::task::Context<'_>,
1371    ) -> std::task::Poll<Option<Self::Item>> {
1372        let this = &mut *self;
1373        if this.inner.check_shutdown(cx) {
1374            this.is_terminated = true;
1375            return std::task::Poll::Ready(None);
1376        }
1377        if this.is_terminated {
1378            panic!("polled DebianGuestManagerRequestStream after completion");
1379        }
1380        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1381            |bytes, handles| {
1382                match this.inner.channel().read_etc(cx, bytes, handles) {
1383                    std::task::Poll::Ready(Ok(())) => {}
1384                    std::task::Poll::Pending => return std::task::Poll::Pending,
1385                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1386                        this.is_terminated = true;
1387                        return std::task::Poll::Ready(None);
1388                    }
1389                    std::task::Poll::Ready(Err(e)) => {
1390                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1391                            e.into(),
1392                        ))))
1393                    }
1394                }
1395
1396                // A message has been received from the channel
1397                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1398
1399                std::task::Poll::Ready(Some(match header.ordinal {
1400                0x394a2e29f750323e => {
1401                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1402                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1403                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
1404                    let control_handle = DebianGuestManagerControlHandle {
1405                        inner: this.inner.clone(),
1406                    };
1407                    Ok(DebianGuestManagerRequest::Launch {guest_config: req.guest_config,
1408controller: req.controller,
1409
1410                        responder: DebianGuestManagerLaunchResponder {
1411                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1412                            tx_id: header.tx_id,
1413                        },
1414                    })
1415                }
1416                0x3ad9a012982f872d => {
1417                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1418                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1419                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1420                    let control_handle = DebianGuestManagerControlHandle {
1421                        inner: this.inner.clone(),
1422                    };
1423                    Ok(DebianGuestManagerRequest::ForceShutdown {
1424                        responder: DebianGuestManagerForceShutdownResponder {
1425                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1426                            tx_id: header.tx_id,
1427                        },
1428                    })
1429                }
1430                0x4e489076e3bb15b4 => {
1431                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1432                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1433                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1434                    let control_handle = DebianGuestManagerControlHandle {
1435                        inner: this.inner.clone(),
1436                    };
1437                    Ok(DebianGuestManagerRequest::Connect {controller: req.controller,
1438
1439                        responder: DebianGuestManagerConnectResponder {
1440                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1441                            tx_id: header.tx_id,
1442                        },
1443                    })
1444                }
1445                0x76892614aea695dc => {
1446                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1447                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1448                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1449                    let control_handle = DebianGuestManagerControlHandle {
1450                        inner: this.inner.clone(),
1451                    };
1452                    Ok(DebianGuestManagerRequest::GetInfo {
1453                        responder: DebianGuestManagerGetInfoResponder {
1454                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1455                            tx_id: header.tx_id,
1456                        },
1457                    })
1458                }
1459                _ => Err(fidl::Error::UnknownOrdinal {
1460                    ordinal: header.ordinal,
1461                    protocol_name: <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1462                }),
1463            }))
1464            },
1465        )
1466    }
1467}
1468
1469#[derive(Debug)]
1470pub enum DebianGuestManagerRequest {
1471    /// Launch a new guest instance.
1472    ///
1473    /// Possible errors:
1474    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1475    ///         problems detected by the guest manager.
1476    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1477    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1478    ///         component logs for a more specific failure.
1479    Launch {
1480        guest_config: GuestConfig,
1481        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1482        responder: DebianGuestManagerLaunchResponder,
1483    },
1484    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1485    /// be used to launch another guest.
1486    ForceShutdown { responder: DebianGuestManagerForceShutdownResponder },
1487    /// Connect to a currently running guest.
1488    ///
1489    /// Possible errors:
1490    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1491    ///         has launched before attempting to reconnect.
1492    Connect {
1493        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1494        responder: DebianGuestManagerConnectResponder,
1495    },
1496    /// Query guest info
1497    GetInfo { responder: DebianGuestManagerGetInfoResponder },
1498}
1499
1500impl DebianGuestManagerRequest {
1501    #[allow(irrefutable_let_patterns)]
1502    pub fn into_launch(
1503        self,
1504    ) -> Option<(
1505        GuestConfig,
1506        fidl::endpoints::ServerEnd<GuestMarker>,
1507        DebianGuestManagerLaunchResponder,
1508    )> {
1509        if let DebianGuestManagerRequest::Launch { guest_config, controller, responder } = self {
1510            Some((guest_config, controller, responder))
1511        } else {
1512            None
1513        }
1514    }
1515
1516    #[allow(irrefutable_let_patterns)]
1517    pub fn into_force_shutdown(self) -> Option<(DebianGuestManagerForceShutdownResponder)> {
1518        if let DebianGuestManagerRequest::ForceShutdown { responder } = self {
1519            Some((responder))
1520        } else {
1521            None
1522        }
1523    }
1524
1525    #[allow(irrefutable_let_patterns)]
1526    pub fn into_connect(
1527        self,
1528    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, DebianGuestManagerConnectResponder)> {
1529        if let DebianGuestManagerRequest::Connect { controller, responder } = self {
1530            Some((controller, responder))
1531        } else {
1532            None
1533        }
1534    }
1535
1536    #[allow(irrefutable_let_patterns)]
1537    pub fn into_get_info(self) -> Option<(DebianGuestManagerGetInfoResponder)> {
1538        if let DebianGuestManagerRequest::GetInfo { responder } = self {
1539            Some((responder))
1540        } else {
1541            None
1542        }
1543    }
1544
1545    /// Name of the method defined in FIDL
1546    pub fn method_name(&self) -> &'static str {
1547        match *self {
1548            DebianGuestManagerRequest::Launch { .. } => "launch",
1549            DebianGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
1550            DebianGuestManagerRequest::Connect { .. } => "connect",
1551            DebianGuestManagerRequest::GetInfo { .. } => "get_info",
1552        }
1553    }
1554}
1555
1556#[derive(Debug, Clone)]
1557pub struct DebianGuestManagerControlHandle {
1558    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1559}
1560
1561impl fidl::endpoints::ControlHandle for DebianGuestManagerControlHandle {
1562    fn shutdown(&self) {
1563        self.inner.shutdown()
1564    }
1565    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1566        self.inner.shutdown_with_epitaph(status)
1567    }
1568
1569    fn is_closed(&self) -> bool {
1570        self.inner.channel().is_closed()
1571    }
1572    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1573        self.inner.channel().on_closed()
1574    }
1575
1576    #[cfg(target_os = "fuchsia")]
1577    fn signal_peer(
1578        &self,
1579        clear_mask: zx::Signals,
1580        set_mask: zx::Signals,
1581    ) -> Result<(), zx_status::Status> {
1582        use fidl::Peered;
1583        self.inner.channel().signal_peer(clear_mask, set_mask)
1584    }
1585}
1586
1587impl DebianGuestManagerControlHandle {}
1588
1589#[must_use = "FIDL methods require a response to be sent"]
1590#[derive(Debug)]
1591pub struct DebianGuestManagerLaunchResponder {
1592    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1593    tx_id: u32,
1594}
1595
1596/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1597/// if the responder is dropped without sending a response, so that the client
1598/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1599impl std::ops::Drop for DebianGuestManagerLaunchResponder {
1600    fn drop(&mut self) {
1601        self.control_handle.shutdown();
1602        // Safety: drops once, never accessed again
1603        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1604    }
1605}
1606
1607impl fidl::endpoints::Responder for DebianGuestManagerLaunchResponder {
1608    type ControlHandle = DebianGuestManagerControlHandle;
1609
1610    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1611        &self.control_handle
1612    }
1613
1614    fn drop_without_shutdown(mut self) {
1615        // Safety: drops once, never accessed again due to mem::forget
1616        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1617        // Prevent Drop from running (which would shut down the channel)
1618        std::mem::forget(self);
1619    }
1620}
1621
1622impl DebianGuestManagerLaunchResponder {
1623    /// Sends a response to the FIDL transaction.
1624    ///
1625    /// Sets the channel to shutdown if an error occurs.
1626    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1627        let _result = self.send_raw(result);
1628        if _result.is_err() {
1629            self.control_handle.shutdown();
1630        }
1631        self.drop_without_shutdown();
1632        _result
1633    }
1634
1635    /// Similar to "send" but does not shutdown the channel if an error occurs.
1636    pub fn send_no_shutdown_on_err(
1637        self,
1638        mut result: Result<(), GuestManagerError>,
1639    ) -> Result<(), fidl::Error> {
1640        let _result = self.send_raw(result);
1641        self.drop_without_shutdown();
1642        _result
1643    }
1644
1645    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1646        self.control_handle.inner.send::<fidl::encoding::ResultType<
1647            fidl::encoding::EmptyStruct,
1648            GuestManagerError,
1649        >>(
1650            result,
1651            self.tx_id,
1652            0x394a2e29f750323e,
1653            fidl::encoding::DynamicFlags::empty(),
1654        )
1655    }
1656}
1657
1658#[must_use = "FIDL methods require a response to be sent"]
1659#[derive(Debug)]
1660pub struct DebianGuestManagerForceShutdownResponder {
1661    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1662    tx_id: u32,
1663}
1664
1665/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1666/// if the responder is dropped without sending a response, so that the client
1667/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1668impl std::ops::Drop for DebianGuestManagerForceShutdownResponder {
1669    fn drop(&mut self) {
1670        self.control_handle.shutdown();
1671        // Safety: drops once, never accessed again
1672        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1673    }
1674}
1675
1676impl fidl::endpoints::Responder for DebianGuestManagerForceShutdownResponder {
1677    type ControlHandle = DebianGuestManagerControlHandle;
1678
1679    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1680        &self.control_handle
1681    }
1682
1683    fn drop_without_shutdown(mut self) {
1684        // Safety: drops once, never accessed again due to mem::forget
1685        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1686        // Prevent Drop from running (which would shut down the channel)
1687        std::mem::forget(self);
1688    }
1689}
1690
1691impl DebianGuestManagerForceShutdownResponder {
1692    /// Sends a response to the FIDL transaction.
1693    ///
1694    /// Sets the channel to shutdown if an error occurs.
1695    pub fn send(self) -> Result<(), fidl::Error> {
1696        let _result = self.send_raw();
1697        if _result.is_err() {
1698            self.control_handle.shutdown();
1699        }
1700        self.drop_without_shutdown();
1701        _result
1702    }
1703
1704    /// Similar to "send" but does not shutdown the channel if an error occurs.
1705    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1706        let _result = self.send_raw();
1707        self.drop_without_shutdown();
1708        _result
1709    }
1710
1711    fn send_raw(&self) -> Result<(), fidl::Error> {
1712        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1713            (),
1714            self.tx_id,
1715            0x3ad9a012982f872d,
1716            fidl::encoding::DynamicFlags::empty(),
1717        )
1718    }
1719}
1720
1721#[must_use = "FIDL methods require a response to be sent"]
1722#[derive(Debug)]
1723pub struct DebianGuestManagerConnectResponder {
1724    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1725    tx_id: u32,
1726}
1727
1728/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1729/// if the responder is dropped without sending a response, so that the client
1730/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1731impl std::ops::Drop for DebianGuestManagerConnectResponder {
1732    fn drop(&mut self) {
1733        self.control_handle.shutdown();
1734        // Safety: drops once, never accessed again
1735        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1736    }
1737}
1738
1739impl fidl::endpoints::Responder for DebianGuestManagerConnectResponder {
1740    type ControlHandle = DebianGuestManagerControlHandle;
1741
1742    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1743        &self.control_handle
1744    }
1745
1746    fn drop_without_shutdown(mut self) {
1747        // Safety: drops once, never accessed again due to mem::forget
1748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1749        // Prevent Drop from running (which would shut down the channel)
1750        std::mem::forget(self);
1751    }
1752}
1753
1754impl DebianGuestManagerConnectResponder {
1755    /// Sends a response to the FIDL transaction.
1756    ///
1757    /// Sets the channel to shutdown if an error occurs.
1758    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1759        let _result = self.send_raw(result);
1760        if _result.is_err() {
1761            self.control_handle.shutdown();
1762        }
1763        self.drop_without_shutdown();
1764        _result
1765    }
1766
1767    /// Similar to "send" but does not shutdown the channel if an error occurs.
1768    pub fn send_no_shutdown_on_err(
1769        self,
1770        mut result: Result<(), GuestManagerError>,
1771    ) -> Result<(), fidl::Error> {
1772        let _result = self.send_raw(result);
1773        self.drop_without_shutdown();
1774        _result
1775    }
1776
1777    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1778        self.control_handle.inner.send::<fidl::encoding::ResultType<
1779            fidl::encoding::EmptyStruct,
1780            GuestManagerError,
1781        >>(
1782            result,
1783            self.tx_id,
1784            0x4e489076e3bb15b4,
1785            fidl::encoding::DynamicFlags::empty(),
1786        )
1787    }
1788}
1789
1790#[must_use = "FIDL methods require a response to be sent"]
1791#[derive(Debug)]
1792pub struct DebianGuestManagerGetInfoResponder {
1793    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1794    tx_id: u32,
1795}
1796
1797/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1798/// if the responder is dropped without sending a response, so that the client
1799/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1800impl std::ops::Drop for DebianGuestManagerGetInfoResponder {
1801    fn drop(&mut self) {
1802        self.control_handle.shutdown();
1803        // Safety: drops once, never accessed again
1804        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1805    }
1806}
1807
1808impl fidl::endpoints::Responder for DebianGuestManagerGetInfoResponder {
1809    type ControlHandle = DebianGuestManagerControlHandle;
1810
1811    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1812        &self.control_handle
1813    }
1814
1815    fn drop_without_shutdown(mut self) {
1816        // Safety: drops once, never accessed again due to mem::forget
1817        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1818        // Prevent Drop from running (which would shut down the channel)
1819        std::mem::forget(self);
1820    }
1821}
1822
1823impl DebianGuestManagerGetInfoResponder {
1824    /// Sends a response to the FIDL transaction.
1825    ///
1826    /// Sets the channel to shutdown if an error occurs.
1827    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1828        let _result = self.send_raw(guest_info);
1829        if _result.is_err() {
1830            self.control_handle.shutdown();
1831        }
1832        self.drop_without_shutdown();
1833        _result
1834    }
1835
1836    /// Similar to "send" but does not shutdown the channel if an error occurs.
1837    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1838        let _result = self.send_raw(guest_info);
1839        self.drop_without_shutdown();
1840        _result
1841    }
1842
1843    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1844        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
1845            (guest_info,),
1846            self.tx_id,
1847            0x76892614aea695dc,
1848            fidl::encoding::DynamicFlags::empty(),
1849        )
1850    }
1851}
1852
1853#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1854pub struct GuestMarker;
1855
1856impl fidl::endpoints::ProtocolMarker for GuestMarker {
1857    type Proxy = GuestProxy;
1858    type RequestStream = GuestRequestStream;
1859    #[cfg(target_os = "fuchsia")]
1860    type SynchronousProxy = GuestSynchronousProxy;
1861
1862    const DEBUG_NAME: &'static str = "fuchsia.virtualization.Guest";
1863}
1864impl fidl::endpoints::DiscoverableProtocolMarker for GuestMarker {}
1865pub type GuestGetConsoleResult = Result<fidl::Socket, GuestError>;
1866pub type GuestGetHostVsockEndpointResult = Result<(), GuestError>;
1867pub type GuestGetBalloonControllerResult = Result<(), GuestError>;
1868pub type GuestGetMemControllerResult = Result<(), GuestError>;
1869
1870pub trait GuestProxyInterface: Send + Sync {
1871    type GetConsoleResponseFut: std::future::Future<Output = Result<GuestGetConsoleResult, fidl::Error>>
1872        + Send;
1873    fn r#get_console(&self) -> Self::GetConsoleResponseFut;
1874    type GetSerialResponseFut: std::future::Future<Output = Result<fidl::Socket, fidl::Error>>
1875        + Send;
1876    fn r#get_serial(&self) -> Self::GetSerialResponseFut;
1877    type GetHostVsockEndpointResponseFut: std::future::Future<Output = Result<GuestGetHostVsockEndpointResult, fidl::Error>>
1878        + Send;
1879    fn r#get_host_vsock_endpoint(
1880        &self,
1881        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
1882    ) -> Self::GetHostVsockEndpointResponseFut;
1883    type GetBalloonControllerResponseFut: std::future::Future<Output = Result<GuestGetBalloonControllerResult, fidl::Error>>
1884        + Send;
1885    fn r#get_balloon_controller(
1886        &self,
1887        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
1888    ) -> Self::GetBalloonControllerResponseFut;
1889    type GetMemControllerResponseFut: std::future::Future<Output = Result<GuestGetMemControllerResult, fidl::Error>>
1890        + Send;
1891    fn r#get_mem_controller(
1892        &self,
1893        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
1894    ) -> Self::GetMemControllerResponseFut;
1895}
1896#[derive(Debug)]
1897#[cfg(target_os = "fuchsia")]
1898pub struct GuestSynchronousProxy {
1899    client: fidl::client::sync::Client,
1900}
1901
1902#[cfg(target_os = "fuchsia")]
1903impl fidl::endpoints::SynchronousProxy for GuestSynchronousProxy {
1904    type Proxy = GuestProxy;
1905    type Protocol = GuestMarker;
1906
1907    fn from_channel(inner: fidl::Channel) -> Self {
1908        Self::new(inner)
1909    }
1910
1911    fn into_channel(self) -> fidl::Channel {
1912        self.client.into_channel()
1913    }
1914
1915    fn as_channel(&self) -> &fidl::Channel {
1916        self.client.as_channel()
1917    }
1918}
1919
1920#[cfg(target_os = "fuchsia")]
1921impl GuestSynchronousProxy {
1922    pub fn new(channel: fidl::Channel) -> Self {
1923        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1924        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1925    }
1926
1927    pub fn into_channel(self) -> fidl::Channel {
1928        self.client.into_channel()
1929    }
1930
1931    /// Waits until an event arrives and returns it. It is safe for other
1932    /// threads to make concurrent requests while waiting for an event.
1933    pub fn wait_for_event(
1934        &self,
1935        deadline: zx::MonotonicInstant,
1936    ) -> Result<GuestEvent, fidl::Error> {
1937        GuestEvent::decode(self.client.wait_for_event(deadline)?)
1938    }
1939
1940    /// Get a guest console.
1941    ///
1942    /// The details regarding what output is produced and what input is accepted
1943    /// are determined by each guest, but will typically be a read/write socket
1944    /// with a shell.
1945    ///
1946    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
1947    pub fn r#get_console(
1948        &self,
1949        ___deadline: zx::MonotonicInstant,
1950    ) -> Result<GuestGetConsoleResult, fidl::Error> {
1951        let _response = self.client.send_query::<
1952            fidl::encoding::EmptyPayload,
1953            fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
1954        >(
1955            (),
1956            0x48cbcecb7793806e,
1957            fidl::encoding::DynamicFlags::empty(),
1958            ___deadline,
1959        )?;
1960        Ok(_response.map(|x| x.socket))
1961    }
1962
1963    /// Get the socket for low-level guest debug logs.
1964    ///
1965    /// The details regarding what output is produced and what input is accepted
1966    /// are determined by each guest, but will typically be a read-only socket
1967    /// with the guest kernel's serial logs.
1968    pub fn r#get_serial(
1969        &self,
1970        ___deadline: zx::MonotonicInstant,
1971    ) -> Result<fidl::Socket, fidl::Error> {
1972        let _response =
1973            self.client.send_query::<fidl::encoding::EmptyPayload, GuestGetSerialResponse>(
1974                (),
1975                0xcdd541a160d7044,
1976                fidl::encoding::DynamicFlags::empty(),
1977                ___deadline,
1978            )?;
1979        Ok(_response.socket)
1980    }
1981
1982    /// Get the vsock endpoint for the guest.
1983    ///
1984    /// This endpoint can be used to register listeners for guest initiated connections, and
1985    /// to initiate connections from a client. If listeners need to be registered before the guest
1986    /// starts so that they are immediately available, set them via the guest config instead of
1987    /// using this endpoint.
1988    ///
1989    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
1990    pub fn r#get_host_vsock_endpoint(
1991        &self,
1992        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
1993        ___deadline: zx::MonotonicInstant,
1994    ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
1995        let _response = self.client.send_query::<
1996            GuestGetHostVsockEndpointRequest,
1997            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
1998        >(
1999            (endpoint,),
2000            0x766e96aeb9c28ed1,
2001            fidl::encoding::DynamicFlags::empty(),
2002            ___deadline,
2003        )?;
2004        Ok(_response.map(|x| x))
2005    }
2006
2007    /// Get the balloon controller endpoint for the guest.
2008    ///
2009    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2010    pub fn r#get_balloon_controller(
2011        &self,
2012        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2013        ___deadline: zx::MonotonicInstant,
2014    ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2015        let _response = self.client.send_query::<
2016            GuestGetBalloonControllerRequest,
2017            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2018        >(
2019            (controller,),
2020            0x7b210bff219ac84e,
2021            fidl::encoding::DynamicFlags::empty(),
2022            ___deadline,
2023        )?;
2024        Ok(_response.map(|x| x))
2025    }
2026
2027    /// Get the mem controller endpoint for the guest.
2028    ///
2029    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2030    pub fn r#get_mem_controller(
2031        &self,
2032        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2033        ___deadline: zx::MonotonicInstant,
2034    ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2035        let _response = self.client.send_query::<
2036            GuestGetMemControllerRequest,
2037            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2038        >(
2039            (controller,),
2040            0x170b19f4b867a01c,
2041            fidl::encoding::DynamicFlags::empty(),
2042            ___deadline,
2043        )?;
2044        Ok(_response.map(|x| x))
2045    }
2046}
2047
2048#[derive(Debug, Clone)]
2049pub struct GuestProxy {
2050    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2051}
2052
2053impl fidl::endpoints::Proxy for GuestProxy {
2054    type Protocol = GuestMarker;
2055
2056    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2057        Self::new(inner)
2058    }
2059
2060    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2061        self.client.into_channel().map_err(|client| Self { client })
2062    }
2063
2064    fn as_channel(&self) -> &::fidl::AsyncChannel {
2065        self.client.as_channel()
2066    }
2067}
2068
2069impl GuestProxy {
2070    /// Create a new Proxy for fuchsia.virtualization/Guest.
2071    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2072        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2073        Self { client: fidl::client::Client::new(channel, protocol_name) }
2074    }
2075
2076    /// Get a Stream of events from the remote end of the protocol.
2077    ///
2078    /// # Panics
2079    ///
2080    /// Panics if the event stream was already taken.
2081    pub fn take_event_stream(&self) -> GuestEventStream {
2082        GuestEventStream { event_receiver: self.client.take_event_receiver() }
2083    }
2084
2085    /// Get a guest console.
2086    ///
2087    /// The details regarding what output is produced and what input is accepted
2088    /// are determined by each guest, but will typically be a read/write socket
2089    /// with a shell.
2090    ///
2091    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2092    pub fn r#get_console(
2093        &self,
2094    ) -> fidl::client::QueryResponseFut<
2095        GuestGetConsoleResult,
2096        fidl::encoding::DefaultFuchsiaResourceDialect,
2097    > {
2098        GuestProxyInterface::r#get_console(self)
2099    }
2100
2101    /// Get the socket for low-level guest debug logs.
2102    ///
2103    /// The details regarding what output is produced and what input is accepted
2104    /// are determined by each guest, but will typically be a read-only socket
2105    /// with the guest kernel's serial logs.
2106    pub fn r#get_serial(
2107        &self,
2108    ) -> fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>
2109    {
2110        GuestProxyInterface::r#get_serial(self)
2111    }
2112
2113    /// Get the vsock endpoint for the guest.
2114    ///
2115    /// This endpoint can be used to register listeners for guest initiated connections, and
2116    /// to initiate connections from a client. If listeners need to be registered before the guest
2117    /// starts so that they are immediately available, set them via the guest config instead of
2118    /// using this endpoint.
2119    ///
2120    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2121    pub fn r#get_host_vsock_endpoint(
2122        &self,
2123        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2124    ) -> fidl::client::QueryResponseFut<
2125        GuestGetHostVsockEndpointResult,
2126        fidl::encoding::DefaultFuchsiaResourceDialect,
2127    > {
2128        GuestProxyInterface::r#get_host_vsock_endpoint(self, endpoint)
2129    }
2130
2131    /// Get the balloon controller endpoint for the guest.
2132    ///
2133    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2134    pub fn r#get_balloon_controller(
2135        &self,
2136        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2137    ) -> fidl::client::QueryResponseFut<
2138        GuestGetBalloonControllerResult,
2139        fidl::encoding::DefaultFuchsiaResourceDialect,
2140    > {
2141        GuestProxyInterface::r#get_balloon_controller(self, controller)
2142    }
2143
2144    /// Get the mem controller endpoint for the guest.
2145    ///
2146    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2147    pub fn r#get_mem_controller(
2148        &self,
2149        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2150    ) -> fidl::client::QueryResponseFut<
2151        GuestGetMemControllerResult,
2152        fidl::encoding::DefaultFuchsiaResourceDialect,
2153    > {
2154        GuestProxyInterface::r#get_mem_controller(self, controller)
2155    }
2156}
2157
2158impl GuestProxyInterface for GuestProxy {
2159    type GetConsoleResponseFut = fidl::client::QueryResponseFut<
2160        GuestGetConsoleResult,
2161        fidl::encoding::DefaultFuchsiaResourceDialect,
2162    >;
2163    fn r#get_console(&self) -> Self::GetConsoleResponseFut {
2164        fn _decode(
2165            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2166        ) -> Result<GuestGetConsoleResult, fidl::Error> {
2167            let _response = fidl::client::decode_transaction_body::<
2168                fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
2169                fidl::encoding::DefaultFuchsiaResourceDialect,
2170                0x48cbcecb7793806e,
2171            >(_buf?)?;
2172            Ok(_response.map(|x| x.socket))
2173        }
2174        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestGetConsoleResult>(
2175            (),
2176            0x48cbcecb7793806e,
2177            fidl::encoding::DynamicFlags::empty(),
2178            _decode,
2179        )
2180    }
2181
2182    type GetSerialResponseFut =
2183        fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2184    fn r#get_serial(&self) -> Self::GetSerialResponseFut {
2185        fn _decode(
2186            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2187        ) -> Result<fidl::Socket, fidl::Error> {
2188            let _response = fidl::client::decode_transaction_body::<
2189                GuestGetSerialResponse,
2190                fidl::encoding::DefaultFuchsiaResourceDialect,
2191                0xcdd541a160d7044,
2192            >(_buf?)?;
2193            Ok(_response.socket)
2194        }
2195        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Socket>(
2196            (),
2197            0xcdd541a160d7044,
2198            fidl::encoding::DynamicFlags::empty(),
2199            _decode,
2200        )
2201    }
2202
2203    type GetHostVsockEndpointResponseFut = fidl::client::QueryResponseFut<
2204        GuestGetHostVsockEndpointResult,
2205        fidl::encoding::DefaultFuchsiaResourceDialect,
2206    >;
2207    fn r#get_host_vsock_endpoint(
2208        &self,
2209        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2210    ) -> Self::GetHostVsockEndpointResponseFut {
2211        fn _decode(
2212            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2213        ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2214            let _response = fidl::client::decode_transaction_body::<
2215                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2216                fidl::encoding::DefaultFuchsiaResourceDialect,
2217                0x766e96aeb9c28ed1,
2218            >(_buf?)?;
2219            Ok(_response.map(|x| x))
2220        }
2221        self.client.send_query_and_decode::<
2222            GuestGetHostVsockEndpointRequest,
2223            GuestGetHostVsockEndpointResult,
2224        >(
2225            (endpoint,),
2226            0x766e96aeb9c28ed1,
2227            fidl::encoding::DynamicFlags::empty(),
2228            _decode,
2229        )
2230    }
2231
2232    type GetBalloonControllerResponseFut = fidl::client::QueryResponseFut<
2233        GuestGetBalloonControllerResult,
2234        fidl::encoding::DefaultFuchsiaResourceDialect,
2235    >;
2236    fn r#get_balloon_controller(
2237        &self,
2238        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2239    ) -> Self::GetBalloonControllerResponseFut {
2240        fn _decode(
2241            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2242        ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2243            let _response = fidl::client::decode_transaction_body::<
2244                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2245                fidl::encoding::DefaultFuchsiaResourceDialect,
2246                0x7b210bff219ac84e,
2247            >(_buf?)?;
2248            Ok(_response.map(|x| x))
2249        }
2250        self.client.send_query_and_decode::<
2251            GuestGetBalloonControllerRequest,
2252            GuestGetBalloonControllerResult,
2253        >(
2254            (controller,),
2255            0x7b210bff219ac84e,
2256            fidl::encoding::DynamicFlags::empty(),
2257            _decode,
2258        )
2259    }
2260
2261    type GetMemControllerResponseFut = fidl::client::QueryResponseFut<
2262        GuestGetMemControllerResult,
2263        fidl::encoding::DefaultFuchsiaResourceDialect,
2264    >;
2265    fn r#get_mem_controller(
2266        &self,
2267        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2268    ) -> Self::GetMemControllerResponseFut {
2269        fn _decode(
2270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2271        ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2272            let _response = fidl::client::decode_transaction_body::<
2273                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2274                fidl::encoding::DefaultFuchsiaResourceDialect,
2275                0x170b19f4b867a01c,
2276            >(_buf?)?;
2277            Ok(_response.map(|x| x))
2278        }
2279        self.client
2280            .send_query_and_decode::<GuestGetMemControllerRequest, GuestGetMemControllerResult>(
2281                (controller,),
2282                0x170b19f4b867a01c,
2283                fidl::encoding::DynamicFlags::empty(),
2284                _decode,
2285            )
2286    }
2287}
2288
2289pub struct GuestEventStream {
2290    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2291}
2292
2293impl std::marker::Unpin for GuestEventStream {}
2294
2295impl futures::stream::FusedStream for GuestEventStream {
2296    fn is_terminated(&self) -> bool {
2297        self.event_receiver.is_terminated()
2298    }
2299}
2300
2301impl futures::Stream for GuestEventStream {
2302    type Item = Result<GuestEvent, fidl::Error>;
2303
2304    fn poll_next(
2305        mut self: std::pin::Pin<&mut Self>,
2306        cx: &mut std::task::Context<'_>,
2307    ) -> std::task::Poll<Option<Self::Item>> {
2308        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2309            &mut self.event_receiver,
2310            cx
2311        )?) {
2312            Some(buf) => std::task::Poll::Ready(Some(GuestEvent::decode(buf))),
2313            None => std::task::Poll::Ready(None),
2314        }
2315    }
2316}
2317
2318#[derive(Debug)]
2319pub enum GuestEvent {}
2320
2321impl GuestEvent {
2322    /// Decodes a message buffer as a [`GuestEvent`].
2323    fn decode(
2324        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2325    ) -> Result<GuestEvent, fidl::Error> {
2326        let (bytes, _handles) = buf.split_mut();
2327        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2328        debug_assert_eq!(tx_header.tx_id, 0);
2329        match tx_header.ordinal {
2330            _ => Err(fidl::Error::UnknownOrdinal {
2331                ordinal: tx_header.ordinal,
2332                protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2333            }),
2334        }
2335    }
2336}
2337
2338/// A Stream of incoming requests for fuchsia.virtualization/Guest.
2339pub struct GuestRequestStream {
2340    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2341    is_terminated: bool,
2342}
2343
2344impl std::marker::Unpin for GuestRequestStream {}
2345
2346impl futures::stream::FusedStream for GuestRequestStream {
2347    fn is_terminated(&self) -> bool {
2348        self.is_terminated
2349    }
2350}
2351
2352impl fidl::endpoints::RequestStream for GuestRequestStream {
2353    type Protocol = GuestMarker;
2354    type ControlHandle = GuestControlHandle;
2355
2356    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2357        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2358    }
2359
2360    fn control_handle(&self) -> Self::ControlHandle {
2361        GuestControlHandle { inner: self.inner.clone() }
2362    }
2363
2364    fn into_inner(
2365        self,
2366    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2367    {
2368        (self.inner, self.is_terminated)
2369    }
2370
2371    fn from_inner(
2372        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2373        is_terminated: bool,
2374    ) -> Self {
2375        Self { inner, is_terminated }
2376    }
2377}
2378
2379impl futures::Stream for GuestRequestStream {
2380    type Item = Result<GuestRequest, fidl::Error>;
2381
2382    fn poll_next(
2383        mut self: std::pin::Pin<&mut Self>,
2384        cx: &mut std::task::Context<'_>,
2385    ) -> std::task::Poll<Option<Self::Item>> {
2386        let this = &mut *self;
2387        if this.inner.check_shutdown(cx) {
2388            this.is_terminated = true;
2389            return std::task::Poll::Ready(None);
2390        }
2391        if this.is_terminated {
2392            panic!("polled GuestRequestStream after completion");
2393        }
2394        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2395            |bytes, handles| {
2396                match this.inner.channel().read_etc(cx, bytes, handles) {
2397                    std::task::Poll::Ready(Ok(())) => {}
2398                    std::task::Poll::Pending => return std::task::Poll::Pending,
2399                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2400                        this.is_terminated = true;
2401                        return std::task::Poll::Ready(None);
2402                    }
2403                    std::task::Poll::Ready(Err(e)) => {
2404                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2405                            e.into(),
2406                        ))))
2407                    }
2408                }
2409
2410                // A message has been received from the channel
2411                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2412
2413                std::task::Poll::Ready(Some(match header.ordinal {
2414                    0x48cbcecb7793806e => {
2415                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2416                        let mut req = fidl::new_empty!(
2417                            fidl::encoding::EmptyPayload,
2418                            fidl::encoding::DefaultFuchsiaResourceDialect
2419                        );
2420                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2421                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2422                        Ok(GuestRequest::GetConsole {
2423                            responder: GuestGetConsoleResponder {
2424                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2425                                tx_id: header.tx_id,
2426                            },
2427                        })
2428                    }
2429                    0xcdd541a160d7044 => {
2430                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2431                        let mut req = fidl::new_empty!(
2432                            fidl::encoding::EmptyPayload,
2433                            fidl::encoding::DefaultFuchsiaResourceDialect
2434                        );
2435                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2436                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2437                        Ok(GuestRequest::GetSerial {
2438                            responder: GuestGetSerialResponder {
2439                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2440                                tx_id: header.tx_id,
2441                            },
2442                        })
2443                    }
2444                    0x766e96aeb9c28ed1 => {
2445                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2446                        let mut req = fidl::new_empty!(
2447                            GuestGetHostVsockEndpointRequest,
2448                            fidl::encoding::DefaultFuchsiaResourceDialect
2449                        );
2450                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetHostVsockEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
2451                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2452                        Ok(GuestRequest::GetHostVsockEndpoint {
2453                            endpoint: req.endpoint,
2454
2455                            responder: GuestGetHostVsockEndpointResponder {
2456                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2457                                tx_id: header.tx_id,
2458                            },
2459                        })
2460                    }
2461                    0x7b210bff219ac84e => {
2462                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2463                        let mut req = fidl::new_empty!(
2464                            GuestGetBalloonControllerRequest,
2465                            fidl::encoding::DefaultFuchsiaResourceDialect
2466                        );
2467                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetBalloonControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2468                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2469                        Ok(GuestRequest::GetBalloonController {
2470                            controller: req.controller,
2471
2472                            responder: GuestGetBalloonControllerResponder {
2473                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2474                                tx_id: header.tx_id,
2475                            },
2476                        })
2477                    }
2478                    0x170b19f4b867a01c => {
2479                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2480                        let mut req = fidl::new_empty!(
2481                            GuestGetMemControllerRequest,
2482                            fidl::encoding::DefaultFuchsiaResourceDialect
2483                        );
2484                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetMemControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2485                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2486                        Ok(GuestRequest::GetMemController {
2487                            controller: req.controller,
2488
2489                            responder: GuestGetMemControllerResponder {
2490                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2491                                tx_id: header.tx_id,
2492                            },
2493                        })
2494                    }
2495                    _ => Err(fidl::Error::UnknownOrdinal {
2496                        ordinal: header.ordinal,
2497                        protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2498                    }),
2499                }))
2500            },
2501        )
2502    }
2503}
2504
2505/// The guest client API providing high level access to guest features. When the guest terminates,
2506/// this channel will contain a ZX_OK epitaph on a clean shutdown, a ZX_ERR_INTERNAL epitaph on
2507/// an unexpected shutdown, and no epitaph if the component crashed.
2508#[derive(Debug)]
2509pub enum GuestRequest {
2510    /// Get a guest console.
2511    ///
2512    /// The details regarding what output is produced and what input is accepted
2513    /// are determined by each guest, but will typically be a read/write socket
2514    /// with a shell.
2515    ///
2516    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2517    GetConsole { responder: GuestGetConsoleResponder },
2518    /// Get the socket for low-level guest debug logs.
2519    ///
2520    /// The details regarding what output is produced and what input is accepted
2521    /// are determined by each guest, but will typically be a read-only socket
2522    /// with the guest kernel's serial logs.
2523    GetSerial { responder: GuestGetSerialResponder },
2524    /// Get the vsock endpoint for the guest.
2525    ///
2526    /// This endpoint can be used to register listeners for guest initiated connections, and
2527    /// to initiate connections from a client. If listeners need to be registered before the guest
2528    /// starts so that they are immediately available, set them via the guest config instead of
2529    /// using this endpoint.
2530    ///
2531    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2532    GetHostVsockEndpoint {
2533        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2534        responder: GuestGetHostVsockEndpointResponder,
2535    },
2536    /// Get the balloon controller endpoint for the guest.
2537    ///
2538    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2539    GetBalloonController {
2540        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2541        responder: GuestGetBalloonControllerResponder,
2542    },
2543    /// Get the mem controller endpoint for the guest.
2544    ///
2545    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2546    GetMemController {
2547        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2548        responder: GuestGetMemControllerResponder,
2549    },
2550}
2551
2552impl GuestRequest {
2553    #[allow(irrefutable_let_patterns)]
2554    pub fn into_get_console(self) -> Option<(GuestGetConsoleResponder)> {
2555        if let GuestRequest::GetConsole { responder } = self {
2556            Some((responder))
2557        } else {
2558            None
2559        }
2560    }
2561
2562    #[allow(irrefutable_let_patterns)]
2563    pub fn into_get_serial(self) -> Option<(GuestGetSerialResponder)> {
2564        if let GuestRequest::GetSerial { responder } = self {
2565            Some((responder))
2566        } else {
2567            None
2568        }
2569    }
2570
2571    #[allow(irrefutable_let_patterns)]
2572    pub fn into_get_host_vsock_endpoint(
2573        self,
2574    ) -> Option<(
2575        fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2576        GuestGetHostVsockEndpointResponder,
2577    )> {
2578        if let GuestRequest::GetHostVsockEndpoint { endpoint, responder } = self {
2579            Some((endpoint, responder))
2580        } else {
2581            None
2582        }
2583    }
2584
2585    #[allow(irrefutable_let_patterns)]
2586    pub fn into_get_balloon_controller(
2587        self,
2588    ) -> Option<(
2589        fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2590        GuestGetBalloonControllerResponder,
2591    )> {
2592        if let GuestRequest::GetBalloonController { controller, responder } = self {
2593            Some((controller, responder))
2594        } else {
2595            None
2596        }
2597    }
2598
2599    #[allow(irrefutable_let_patterns)]
2600    pub fn into_get_mem_controller(
2601        self,
2602    ) -> Option<(fidl::endpoints::ServerEnd<MemControllerMarker>, GuestGetMemControllerResponder)>
2603    {
2604        if let GuestRequest::GetMemController { controller, responder } = self {
2605            Some((controller, responder))
2606        } else {
2607            None
2608        }
2609    }
2610
2611    /// Name of the method defined in FIDL
2612    pub fn method_name(&self) -> &'static str {
2613        match *self {
2614            GuestRequest::GetConsole { .. } => "get_console",
2615            GuestRequest::GetSerial { .. } => "get_serial",
2616            GuestRequest::GetHostVsockEndpoint { .. } => "get_host_vsock_endpoint",
2617            GuestRequest::GetBalloonController { .. } => "get_balloon_controller",
2618            GuestRequest::GetMemController { .. } => "get_mem_controller",
2619        }
2620    }
2621}
2622
2623#[derive(Debug, Clone)]
2624pub struct GuestControlHandle {
2625    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2626}
2627
2628impl fidl::endpoints::ControlHandle for GuestControlHandle {
2629    fn shutdown(&self) {
2630        self.inner.shutdown()
2631    }
2632    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2633        self.inner.shutdown_with_epitaph(status)
2634    }
2635
2636    fn is_closed(&self) -> bool {
2637        self.inner.channel().is_closed()
2638    }
2639    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2640        self.inner.channel().on_closed()
2641    }
2642
2643    #[cfg(target_os = "fuchsia")]
2644    fn signal_peer(
2645        &self,
2646        clear_mask: zx::Signals,
2647        set_mask: zx::Signals,
2648    ) -> Result<(), zx_status::Status> {
2649        use fidl::Peered;
2650        self.inner.channel().signal_peer(clear_mask, set_mask)
2651    }
2652}
2653
2654impl GuestControlHandle {}
2655
2656#[must_use = "FIDL methods require a response to be sent"]
2657#[derive(Debug)]
2658pub struct GuestGetConsoleResponder {
2659    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2660    tx_id: u32,
2661}
2662
2663/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2664/// if the responder is dropped without sending a response, so that the client
2665/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2666impl std::ops::Drop for GuestGetConsoleResponder {
2667    fn drop(&mut self) {
2668        self.control_handle.shutdown();
2669        // Safety: drops once, never accessed again
2670        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2671    }
2672}
2673
2674impl fidl::endpoints::Responder for GuestGetConsoleResponder {
2675    type ControlHandle = GuestControlHandle;
2676
2677    fn control_handle(&self) -> &GuestControlHandle {
2678        &self.control_handle
2679    }
2680
2681    fn drop_without_shutdown(mut self) {
2682        // Safety: drops once, never accessed again due to mem::forget
2683        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2684        // Prevent Drop from running (which would shut down the channel)
2685        std::mem::forget(self);
2686    }
2687}
2688
2689impl GuestGetConsoleResponder {
2690    /// Sends a response to the FIDL transaction.
2691    ///
2692    /// Sets the channel to shutdown if an error occurs.
2693    pub fn send(self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2694        let _result = self.send_raw(result);
2695        if _result.is_err() {
2696            self.control_handle.shutdown();
2697        }
2698        self.drop_without_shutdown();
2699        _result
2700    }
2701
2702    /// Similar to "send" but does not shutdown the channel if an error occurs.
2703    pub fn send_no_shutdown_on_err(
2704        self,
2705        mut result: Result<fidl::Socket, GuestError>,
2706    ) -> Result<(), fidl::Error> {
2707        let _result = self.send_raw(result);
2708        self.drop_without_shutdown();
2709        _result
2710    }
2711
2712    fn send_raw(&self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2713        self.control_handle
2714            .inner
2715            .send::<fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>>(
2716                result.map(|socket| (socket,)),
2717                self.tx_id,
2718                0x48cbcecb7793806e,
2719                fidl::encoding::DynamicFlags::empty(),
2720            )
2721    }
2722}
2723
2724#[must_use = "FIDL methods require a response to be sent"]
2725#[derive(Debug)]
2726pub struct GuestGetSerialResponder {
2727    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2728    tx_id: u32,
2729}
2730
2731/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2732/// if the responder is dropped without sending a response, so that the client
2733/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2734impl std::ops::Drop for GuestGetSerialResponder {
2735    fn drop(&mut self) {
2736        self.control_handle.shutdown();
2737        // Safety: drops once, never accessed again
2738        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2739    }
2740}
2741
2742impl fidl::endpoints::Responder for GuestGetSerialResponder {
2743    type ControlHandle = GuestControlHandle;
2744
2745    fn control_handle(&self) -> &GuestControlHandle {
2746        &self.control_handle
2747    }
2748
2749    fn drop_without_shutdown(mut self) {
2750        // Safety: drops once, never accessed again due to mem::forget
2751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2752        // Prevent Drop from running (which would shut down the channel)
2753        std::mem::forget(self);
2754    }
2755}
2756
2757impl GuestGetSerialResponder {
2758    /// Sends a response to the FIDL transaction.
2759    ///
2760    /// Sets the channel to shutdown if an error occurs.
2761    pub fn send(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2762        let _result = self.send_raw(socket);
2763        if _result.is_err() {
2764            self.control_handle.shutdown();
2765        }
2766        self.drop_without_shutdown();
2767        _result
2768    }
2769
2770    /// Similar to "send" but does not shutdown the channel if an error occurs.
2771    pub fn send_no_shutdown_on_err(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2772        let _result = self.send_raw(socket);
2773        self.drop_without_shutdown();
2774        _result
2775    }
2776
2777    fn send_raw(&self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2778        self.control_handle.inner.send::<GuestGetSerialResponse>(
2779            (socket,),
2780            self.tx_id,
2781            0xcdd541a160d7044,
2782            fidl::encoding::DynamicFlags::empty(),
2783        )
2784    }
2785}
2786
2787#[must_use = "FIDL methods require a response to be sent"]
2788#[derive(Debug)]
2789pub struct GuestGetHostVsockEndpointResponder {
2790    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2791    tx_id: u32,
2792}
2793
2794/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2795/// if the responder is dropped without sending a response, so that the client
2796/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2797impl std::ops::Drop for GuestGetHostVsockEndpointResponder {
2798    fn drop(&mut self) {
2799        self.control_handle.shutdown();
2800        // Safety: drops once, never accessed again
2801        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2802    }
2803}
2804
2805impl fidl::endpoints::Responder for GuestGetHostVsockEndpointResponder {
2806    type ControlHandle = GuestControlHandle;
2807
2808    fn control_handle(&self) -> &GuestControlHandle {
2809        &self.control_handle
2810    }
2811
2812    fn drop_without_shutdown(mut self) {
2813        // Safety: drops once, never accessed again due to mem::forget
2814        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2815        // Prevent Drop from running (which would shut down the channel)
2816        std::mem::forget(self);
2817    }
2818}
2819
2820impl GuestGetHostVsockEndpointResponder {
2821    /// Sends a response to the FIDL transaction.
2822    ///
2823    /// Sets the channel to shutdown if an error occurs.
2824    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2825        let _result = self.send_raw(result);
2826        if _result.is_err() {
2827            self.control_handle.shutdown();
2828        }
2829        self.drop_without_shutdown();
2830        _result
2831    }
2832
2833    /// Similar to "send" but does not shutdown the channel if an error occurs.
2834    pub fn send_no_shutdown_on_err(
2835        self,
2836        mut result: Result<(), GuestError>,
2837    ) -> Result<(), fidl::Error> {
2838        let _result = self.send_raw(result);
2839        self.drop_without_shutdown();
2840        _result
2841    }
2842
2843    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2844        self.control_handle
2845            .inner
2846            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2847                result,
2848                self.tx_id,
2849                0x766e96aeb9c28ed1,
2850                fidl::encoding::DynamicFlags::empty(),
2851            )
2852    }
2853}
2854
2855#[must_use = "FIDL methods require a response to be sent"]
2856#[derive(Debug)]
2857pub struct GuestGetBalloonControllerResponder {
2858    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2859    tx_id: u32,
2860}
2861
2862/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2863/// if the responder is dropped without sending a response, so that the client
2864/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2865impl std::ops::Drop for GuestGetBalloonControllerResponder {
2866    fn drop(&mut self) {
2867        self.control_handle.shutdown();
2868        // Safety: drops once, never accessed again
2869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2870    }
2871}
2872
2873impl fidl::endpoints::Responder for GuestGetBalloonControllerResponder {
2874    type ControlHandle = GuestControlHandle;
2875
2876    fn control_handle(&self) -> &GuestControlHandle {
2877        &self.control_handle
2878    }
2879
2880    fn drop_without_shutdown(mut self) {
2881        // Safety: drops once, never accessed again due to mem::forget
2882        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2883        // Prevent Drop from running (which would shut down the channel)
2884        std::mem::forget(self);
2885    }
2886}
2887
2888impl GuestGetBalloonControllerResponder {
2889    /// Sends a response to the FIDL transaction.
2890    ///
2891    /// Sets the channel to shutdown if an error occurs.
2892    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2893        let _result = self.send_raw(result);
2894        if _result.is_err() {
2895            self.control_handle.shutdown();
2896        }
2897        self.drop_without_shutdown();
2898        _result
2899    }
2900
2901    /// Similar to "send" but does not shutdown the channel if an error occurs.
2902    pub fn send_no_shutdown_on_err(
2903        self,
2904        mut result: Result<(), GuestError>,
2905    ) -> Result<(), fidl::Error> {
2906        let _result = self.send_raw(result);
2907        self.drop_without_shutdown();
2908        _result
2909    }
2910
2911    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2912        self.control_handle
2913            .inner
2914            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2915                result,
2916                self.tx_id,
2917                0x7b210bff219ac84e,
2918                fidl::encoding::DynamicFlags::empty(),
2919            )
2920    }
2921}
2922
2923#[must_use = "FIDL methods require a response to be sent"]
2924#[derive(Debug)]
2925pub struct GuestGetMemControllerResponder {
2926    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2927    tx_id: u32,
2928}
2929
2930/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2931/// if the responder is dropped without sending a response, so that the client
2932/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2933impl std::ops::Drop for GuestGetMemControllerResponder {
2934    fn drop(&mut self) {
2935        self.control_handle.shutdown();
2936        // Safety: drops once, never accessed again
2937        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2938    }
2939}
2940
2941impl fidl::endpoints::Responder for GuestGetMemControllerResponder {
2942    type ControlHandle = GuestControlHandle;
2943
2944    fn control_handle(&self) -> &GuestControlHandle {
2945        &self.control_handle
2946    }
2947
2948    fn drop_without_shutdown(mut self) {
2949        // Safety: drops once, never accessed again due to mem::forget
2950        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2951        // Prevent Drop from running (which would shut down the channel)
2952        std::mem::forget(self);
2953    }
2954}
2955
2956impl GuestGetMemControllerResponder {
2957    /// Sends a response to the FIDL transaction.
2958    ///
2959    /// Sets the channel to shutdown if an error occurs.
2960    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2961        let _result = self.send_raw(result);
2962        if _result.is_err() {
2963            self.control_handle.shutdown();
2964        }
2965        self.drop_without_shutdown();
2966        _result
2967    }
2968
2969    /// Similar to "send" but does not shutdown the channel if an error occurs.
2970    pub fn send_no_shutdown_on_err(
2971        self,
2972        mut result: Result<(), GuestError>,
2973    ) -> Result<(), fidl::Error> {
2974        let _result = self.send_raw(result);
2975        self.drop_without_shutdown();
2976        _result
2977    }
2978
2979    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2980        self.control_handle
2981            .inner
2982            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2983                result,
2984                self.tx_id,
2985                0x170b19f4b867a01c,
2986                fidl::encoding::DynamicFlags::empty(),
2987            )
2988    }
2989}
2990
2991#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2992pub struct GuestLifecycleMarker;
2993
2994impl fidl::endpoints::ProtocolMarker for GuestLifecycleMarker {
2995    type Proxy = GuestLifecycleProxy;
2996    type RequestStream = GuestLifecycleRequestStream;
2997    #[cfg(target_os = "fuchsia")]
2998    type SynchronousProxy = GuestLifecycleSynchronousProxy;
2999
3000    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestLifecycle";
3001}
3002impl fidl::endpoints::DiscoverableProtocolMarker for GuestLifecycleMarker {}
3003pub type GuestLifecycleCreateResult = Result<(), GuestError>;
3004pub type GuestLifecycleRunResult = Result<(), GuestError>;
3005
3006pub trait GuestLifecycleProxyInterface: Send + Sync {
3007    type CreateResponseFut: std::future::Future<Output = Result<GuestLifecycleCreateResult, fidl::Error>>
3008        + Send;
3009    fn r#create(&self, guest_config: GuestConfig) -> Self::CreateResponseFut;
3010    fn r#bind(&self, guest: fidl::endpoints::ServerEnd<GuestMarker>) -> Result<(), fidl::Error>;
3011    type RunResponseFut: std::future::Future<Output = Result<GuestLifecycleRunResult, fidl::Error>>
3012        + Send;
3013    fn r#run(&self) -> Self::RunResponseFut;
3014    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3015    fn r#stop(&self) -> Self::StopResponseFut;
3016}
3017#[derive(Debug)]
3018#[cfg(target_os = "fuchsia")]
3019pub struct GuestLifecycleSynchronousProxy {
3020    client: fidl::client::sync::Client,
3021}
3022
3023#[cfg(target_os = "fuchsia")]
3024impl fidl::endpoints::SynchronousProxy for GuestLifecycleSynchronousProxy {
3025    type Proxy = GuestLifecycleProxy;
3026    type Protocol = GuestLifecycleMarker;
3027
3028    fn from_channel(inner: fidl::Channel) -> Self {
3029        Self::new(inner)
3030    }
3031
3032    fn into_channel(self) -> fidl::Channel {
3033        self.client.into_channel()
3034    }
3035
3036    fn as_channel(&self) -> &fidl::Channel {
3037        self.client.as_channel()
3038    }
3039}
3040
3041#[cfg(target_os = "fuchsia")]
3042impl GuestLifecycleSynchronousProxy {
3043    pub fn new(channel: fidl::Channel) -> Self {
3044        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3045        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3046    }
3047
3048    pub fn into_channel(self) -> fidl::Channel {
3049        self.client.into_channel()
3050    }
3051
3052    /// Waits until an event arrives and returns it. It is safe for other
3053    /// threads to make concurrent requests while waiting for an event.
3054    pub fn wait_for_event(
3055        &self,
3056        deadline: zx::MonotonicInstant,
3057    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3058        GuestLifecycleEvent::decode(self.client.wait_for_event(deadline)?)
3059    }
3060
3061    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3062    /// the kernel without starting the VCPU or device dispatch loops.
3063    ///
3064    /// Possible errors:
3065    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3066    ///         recreated.
3067    ///
3068    /// All other errors are related to VMM initialization.
3069    pub fn r#create(
3070        &self,
3071        mut guest_config: GuestConfig,
3072        ___deadline: zx::MonotonicInstant,
3073    ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3074        let _response = self.client.send_query::<
3075            GuestLifecycleCreateRequest,
3076            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3077        >(
3078            (&mut guest_config,),
3079            0x152719eed416ed41,
3080            fidl::encoding::DynamicFlags::empty(),
3081            ___deadline,
3082        )?;
3083        Ok(_response.map(|x| x))
3084    }
3085
3086    /// Binds to the Guest protocol for an initialized guest.
3087    ///
3088    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3089    /// will be immediately closed.
3090    pub fn r#bind(
3091        &self,
3092        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3093    ) -> Result<(), fidl::Error> {
3094        self.client.send::<GuestLifecycleBindRequest>(
3095            (guest,),
3096            0x57dd3e245f9598ed,
3097            fidl::encoding::DynamicFlags::empty(),
3098        )
3099    }
3100
3101    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3102    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3103    ///
3104    /// Possible errors:
3105    ///     - ALREADY_RUNING: The VMM has already been started.
3106    ///     - NOT_CREATED: Run was called before the VMM was created.
3107    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3108    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3109    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3110    pub fn r#run(
3111        &self,
3112        ___deadline: zx::MonotonicInstant,
3113    ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3114        let _response = self.client.send_query::<
3115            fidl::encoding::EmptyPayload,
3116            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3117        >(
3118            (),
3119            0x2907fef2ac775657,
3120            fidl::encoding::DynamicFlags::empty(),
3121            ___deadline,
3122        )?;
3123        Ok(_response.map(|x| x))
3124    }
3125
3126    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3127    /// Create and then Run can be called again.
3128    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3129        let _response =
3130            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
3131                (),
3132                0x27eef9c535ac8eb4,
3133                fidl::encoding::DynamicFlags::empty(),
3134                ___deadline,
3135            )?;
3136        Ok(_response)
3137    }
3138}
3139
3140#[derive(Debug, Clone)]
3141pub struct GuestLifecycleProxy {
3142    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3143}
3144
3145impl fidl::endpoints::Proxy for GuestLifecycleProxy {
3146    type Protocol = GuestLifecycleMarker;
3147
3148    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3149        Self::new(inner)
3150    }
3151
3152    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3153        self.client.into_channel().map_err(|client| Self { client })
3154    }
3155
3156    fn as_channel(&self) -> &::fidl::AsyncChannel {
3157        self.client.as_channel()
3158    }
3159}
3160
3161impl GuestLifecycleProxy {
3162    /// Create a new Proxy for fuchsia.virtualization/GuestLifecycle.
3163    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3164        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3165        Self { client: fidl::client::Client::new(channel, protocol_name) }
3166    }
3167
3168    /// Get a Stream of events from the remote end of the protocol.
3169    ///
3170    /// # Panics
3171    ///
3172    /// Panics if the event stream was already taken.
3173    pub fn take_event_stream(&self) -> GuestLifecycleEventStream {
3174        GuestLifecycleEventStream { event_receiver: self.client.take_event_receiver() }
3175    }
3176
3177    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3178    /// the kernel without starting the VCPU or device dispatch loops.
3179    ///
3180    /// Possible errors:
3181    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3182    ///         recreated.
3183    ///
3184    /// All other errors are related to VMM initialization.
3185    pub fn r#create(
3186        &self,
3187        mut guest_config: GuestConfig,
3188    ) -> fidl::client::QueryResponseFut<
3189        GuestLifecycleCreateResult,
3190        fidl::encoding::DefaultFuchsiaResourceDialect,
3191    > {
3192        GuestLifecycleProxyInterface::r#create(self, guest_config)
3193    }
3194
3195    /// Binds to the Guest protocol for an initialized guest.
3196    ///
3197    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3198    /// will be immediately closed.
3199    pub fn r#bind(
3200        &self,
3201        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3202    ) -> Result<(), fidl::Error> {
3203        GuestLifecycleProxyInterface::r#bind(self, guest)
3204    }
3205
3206    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3207    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3208    ///
3209    /// Possible errors:
3210    ///     - ALREADY_RUNING: The VMM has already been started.
3211    ///     - NOT_CREATED: Run was called before the VMM was created.
3212    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3213    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3214    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3215    pub fn r#run(
3216        &self,
3217    ) -> fidl::client::QueryResponseFut<
3218        GuestLifecycleRunResult,
3219        fidl::encoding::DefaultFuchsiaResourceDialect,
3220    > {
3221        GuestLifecycleProxyInterface::r#run(self)
3222    }
3223
3224    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3225    /// Create and then Run can be called again.
3226    pub fn r#stop(
3227        &self,
3228    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3229        GuestLifecycleProxyInterface::r#stop(self)
3230    }
3231}
3232
3233impl GuestLifecycleProxyInterface for GuestLifecycleProxy {
3234    type CreateResponseFut = fidl::client::QueryResponseFut<
3235        GuestLifecycleCreateResult,
3236        fidl::encoding::DefaultFuchsiaResourceDialect,
3237    >;
3238    fn r#create(&self, mut guest_config: GuestConfig) -> Self::CreateResponseFut {
3239        fn _decode(
3240            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3241        ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3242            let _response = fidl::client::decode_transaction_body::<
3243                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3244                fidl::encoding::DefaultFuchsiaResourceDialect,
3245                0x152719eed416ed41,
3246            >(_buf?)?;
3247            Ok(_response.map(|x| x))
3248        }
3249        self.client
3250            .send_query_and_decode::<GuestLifecycleCreateRequest, GuestLifecycleCreateResult>(
3251                (&mut guest_config,),
3252                0x152719eed416ed41,
3253                fidl::encoding::DynamicFlags::empty(),
3254                _decode,
3255            )
3256    }
3257
3258    fn r#bind(
3259        &self,
3260        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3261    ) -> Result<(), fidl::Error> {
3262        self.client.send::<GuestLifecycleBindRequest>(
3263            (guest,),
3264            0x57dd3e245f9598ed,
3265            fidl::encoding::DynamicFlags::empty(),
3266        )
3267    }
3268
3269    type RunResponseFut = fidl::client::QueryResponseFut<
3270        GuestLifecycleRunResult,
3271        fidl::encoding::DefaultFuchsiaResourceDialect,
3272    >;
3273    fn r#run(&self) -> Self::RunResponseFut {
3274        fn _decode(
3275            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3276        ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3277            let _response = fidl::client::decode_transaction_body::<
3278                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3279                fidl::encoding::DefaultFuchsiaResourceDialect,
3280                0x2907fef2ac775657,
3281            >(_buf?)?;
3282            Ok(_response.map(|x| x))
3283        }
3284        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestLifecycleRunResult>(
3285            (),
3286            0x2907fef2ac775657,
3287            fidl::encoding::DynamicFlags::empty(),
3288            _decode,
3289        )
3290    }
3291
3292    type StopResponseFut =
3293        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3294    fn r#stop(&self) -> Self::StopResponseFut {
3295        fn _decode(
3296            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3297        ) -> Result<(), fidl::Error> {
3298            let _response = fidl::client::decode_transaction_body::<
3299                fidl::encoding::EmptyPayload,
3300                fidl::encoding::DefaultFuchsiaResourceDialect,
3301                0x27eef9c535ac8eb4,
3302            >(_buf?)?;
3303            Ok(_response)
3304        }
3305        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3306            (),
3307            0x27eef9c535ac8eb4,
3308            fidl::encoding::DynamicFlags::empty(),
3309            _decode,
3310        )
3311    }
3312}
3313
3314pub struct GuestLifecycleEventStream {
3315    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3316}
3317
3318impl std::marker::Unpin for GuestLifecycleEventStream {}
3319
3320impl futures::stream::FusedStream for GuestLifecycleEventStream {
3321    fn is_terminated(&self) -> bool {
3322        self.event_receiver.is_terminated()
3323    }
3324}
3325
3326impl futures::Stream for GuestLifecycleEventStream {
3327    type Item = Result<GuestLifecycleEvent, fidl::Error>;
3328
3329    fn poll_next(
3330        mut self: std::pin::Pin<&mut Self>,
3331        cx: &mut std::task::Context<'_>,
3332    ) -> std::task::Poll<Option<Self::Item>> {
3333        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3334            &mut self.event_receiver,
3335            cx
3336        )?) {
3337            Some(buf) => std::task::Poll::Ready(Some(GuestLifecycleEvent::decode(buf))),
3338            None => std::task::Poll::Ready(None),
3339        }
3340    }
3341}
3342
3343#[derive(Debug)]
3344pub enum GuestLifecycleEvent {}
3345
3346impl GuestLifecycleEvent {
3347    /// Decodes a message buffer as a [`GuestLifecycleEvent`].
3348    fn decode(
3349        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3350    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3351        let (bytes, _handles) = buf.split_mut();
3352        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3353        debug_assert_eq!(tx_header.tx_id, 0);
3354        match tx_header.ordinal {
3355            _ => Err(fidl::Error::UnknownOrdinal {
3356                ordinal: tx_header.ordinal,
3357                protocol_name:
3358                    <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3359            }),
3360        }
3361    }
3362}
3363
3364/// A Stream of incoming requests for fuchsia.virtualization/GuestLifecycle.
3365pub struct GuestLifecycleRequestStream {
3366    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3367    is_terminated: bool,
3368}
3369
3370impl std::marker::Unpin for GuestLifecycleRequestStream {}
3371
3372impl futures::stream::FusedStream for GuestLifecycleRequestStream {
3373    fn is_terminated(&self) -> bool {
3374        self.is_terminated
3375    }
3376}
3377
3378impl fidl::endpoints::RequestStream for GuestLifecycleRequestStream {
3379    type Protocol = GuestLifecycleMarker;
3380    type ControlHandle = GuestLifecycleControlHandle;
3381
3382    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3383        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3384    }
3385
3386    fn control_handle(&self) -> Self::ControlHandle {
3387        GuestLifecycleControlHandle { inner: self.inner.clone() }
3388    }
3389
3390    fn into_inner(
3391        self,
3392    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3393    {
3394        (self.inner, self.is_terminated)
3395    }
3396
3397    fn from_inner(
3398        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3399        is_terminated: bool,
3400    ) -> Self {
3401        Self { inner, is_terminated }
3402    }
3403}
3404
3405impl futures::Stream for GuestLifecycleRequestStream {
3406    type Item = Result<GuestLifecycleRequest, fidl::Error>;
3407
3408    fn poll_next(
3409        mut self: std::pin::Pin<&mut Self>,
3410        cx: &mut std::task::Context<'_>,
3411    ) -> std::task::Poll<Option<Self::Item>> {
3412        let this = &mut *self;
3413        if this.inner.check_shutdown(cx) {
3414            this.is_terminated = true;
3415            return std::task::Poll::Ready(None);
3416        }
3417        if this.is_terminated {
3418            panic!("polled GuestLifecycleRequestStream after completion");
3419        }
3420        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3421            |bytes, handles| {
3422                match this.inner.channel().read_etc(cx, bytes, handles) {
3423                    std::task::Poll::Ready(Ok(())) => {}
3424                    std::task::Poll::Pending => return std::task::Poll::Pending,
3425                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3426                        this.is_terminated = true;
3427                        return std::task::Poll::Ready(None);
3428                    }
3429                    std::task::Poll::Ready(Err(e)) => {
3430                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3431                            e.into(),
3432                        ))))
3433                    }
3434                }
3435
3436                // A message has been received from the channel
3437                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3438
3439                std::task::Poll::Ready(Some(match header.ordinal {
3440                    0x152719eed416ed41 => {
3441                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3442                        let mut req = fidl::new_empty!(
3443                            GuestLifecycleCreateRequest,
3444                            fidl::encoding::DefaultFuchsiaResourceDialect
3445                        );
3446                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleCreateRequest>(&header, _body_bytes, handles, &mut req)?;
3447                        let control_handle =
3448                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3449                        Ok(GuestLifecycleRequest::Create {
3450                            guest_config: req.guest_config,
3451
3452                            responder: GuestLifecycleCreateResponder {
3453                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3454                                tx_id: header.tx_id,
3455                            },
3456                        })
3457                    }
3458                    0x57dd3e245f9598ed => {
3459                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3460                        let mut req = fidl::new_empty!(
3461                            GuestLifecycleBindRequest,
3462                            fidl::encoding::DefaultFuchsiaResourceDialect
3463                        );
3464                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleBindRequest>(&header, _body_bytes, handles, &mut req)?;
3465                        let control_handle =
3466                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3467                        Ok(GuestLifecycleRequest::Bind { guest: req.guest, control_handle })
3468                    }
3469                    0x2907fef2ac775657 => {
3470                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3471                        let mut req = fidl::new_empty!(
3472                            fidl::encoding::EmptyPayload,
3473                            fidl::encoding::DefaultFuchsiaResourceDialect
3474                        );
3475                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3476                        let control_handle =
3477                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3478                        Ok(GuestLifecycleRequest::Run {
3479                            responder: GuestLifecycleRunResponder {
3480                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3481                                tx_id: header.tx_id,
3482                            },
3483                        })
3484                    }
3485                    0x27eef9c535ac8eb4 => {
3486                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3487                        let mut req = fidl::new_empty!(
3488                            fidl::encoding::EmptyPayload,
3489                            fidl::encoding::DefaultFuchsiaResourceDialect
3490                        );
3491                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3492                        let control_handle =
3493                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3494                        Ok(GuestLifecycleRequest::Stop {
3495                            responder: GuestLifecycleStopResponder {
3496                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3497                                tx_id: header.tx_id,
3498                            },
3499                        })
3500                    }
3501                    _ => Err(fidl::Error::UnknownOrdinal {
3502                        ordinal: header.ordinal,
3503                        protocol_name:
3504                            <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3505                    }),
3506                }))
3507            },
3508        )
3509    }
3510}
3511
3512/// The guest control plane allowing for creating, starting, and stopping the guest.
3513#[derive(Debug)]
3514pub enum GuestLifecycleRequest {
3515    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3516    /// the kernel without starting the VCPU or device dispatch loops.
3517    ///
3518    /// Possible errors:
3519    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3520    ///         recreated.
3521    ///
3522    /// All other errors are related to VMM initialization.
3523    Create { guest_config: GuestConfig, responder: GuestLifecycleCreateResponder },
3524    /// Binds to the Guest protocol for an initialized guest.
3525    ///
3526    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3527    /// will be immediately closed.
3528    Bind {
3529        guest: fidl::endpoints::ServerEnd<GuestMarker>,
3530        control_handle: GuestLifecycleControlHandle,
3531    },
3532    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3533    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3534    ///
3535    /// Possible errors:
3536    ///     - ALREADY_RUNING: The VMM has already been started.
3537    ///     - NOT_CREATED: Run was called before the VMM was created.
3538    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3539    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3540    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3541    Run { responder: GuestLifecycleRunResponder },
3542    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3543    /// Create and then Run can be called again.
3544    Stop { responder: GuestLifecycleStopResponder },
3545}
3546
3547impl GuestLifecycleRequest {
3548    #[allow(irrefutable_let_patterns)]
3549    pub fn into_create(self) -> Option<(GuestConfig, GuestLifecycleCreateResponder)> {
3550        if let GuestLifecycleRequest::Create { guest_config, responder } = self {
3551            Some((guest_config, responder))
3552        } else {
3553            None
3554        }
3555    }
3556
3557    #[allow(irrefutable_let_patterns)]
3558    pub fn into_bind(
3559        self,
3560    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestLifecycleControlHandle)> {
3561        if let GuestLifecycleRequest::Bind { guest, control_handle } = self {
3562            Some((guest, control_handle))
3563        } else {
3564            None
3565        }
3566    }
3567
3568    #[allow(irrefutable_let_patterns)]
3569    pub fn into_run(self) -> Option<(GuestLifecycleRunResponder)> {
3570        if let GuestLifecycleRequest::Run { responder } = self {
3571            Some((responder))
3572        } else {
3573            None
3574        }
3575    }
3576
3577    #[allow(irrefutable_let_patterns)]
3578    pub fn into_stop(self) -> Option<(GuestLifecycleStopResponder)> {
3579        if let GuestLifecycleRequest::Stop { responder } = self {
3580            Some((responder))
3581        } else {
3582            None
3583        }
3584    }
3585
3586    /// Name of the method defined in FIDL
3587    pub fn method_name(&self) -> &'static str {
3588        match *self {
3589            GuestLifecycleRequest::Create { .. } => "create",
3590            GuestLifecycleRequest::Bind { .. } => "bind",
3591            GuestLifecycleRequest::Run { .. } => "run",
3592            GuestLifecycleRequest::Stop { .. } => "stop",
3593        }
3594    }
3595}
3596
3597#[derive(Debug, Clone)]
3598pub struct GuestLifecycleControlHandle {
3599    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3600}
3601
3602impl fidl::endpoints::ControlHandle for GuestLifecycleControlHandle {
3603    fn shutdown(&self) {
3604        self.inner.shutdown()
3605    }
3606    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3607        self.inner.shutdown_with_epitaph(status)
3608    }
3609
3610    fn is_closed(&self) -> bool {
3611        self.inner.channel().is_closed()
3612    }
3613    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3614        self.inner.channel().on_closed()
3615    }
3616
3617    #[cfg(target_os = "fuchsia")]
3618    fn signal_peer(
3619        &self,
3620        clear_mask: zx::Signals,
3621        set_mask: zx::Signals,
3622    ) -> Result<(), zx_status::Status> {
3623        use fidl::Peered;
3624        self.inner.channel().signal_peer(clear_mask, set_mask)
3625    }
3626}
3627
3628impl GuestLifecycleControlHandle {}
3629
3630#[must_use = "FIDL methods require a response to be sent"]
3631#[derive(Debug)]
3632pub struct GuestLifecycleCreateResponder {
3633    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3634    tx_id: u32,
3635}
3636
3637/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3638/// if the responder is dropped without sending a response, so that the client
3639/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3640impl std::ops::Drop for GuestLifecycleCreateResponder {
3641    fn drop(&mut self) {
3642        self.control_handle.shutdown();
3643        // Safety: drops once, never accessed again
3644        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3645    }
3646}
3647
3648impl fidl::endpoints::Responder for GuestLifecycleCreateResponder {
3649    type ControlHandle = GuestLifecycleControlHandle;
3650
3651    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3652        &self.control_handle
3653    }
3654
3655    fn drop_without_shutdown(mut self) {
3656        // Safety: drops once, never accessed again due to mem::forget
3657        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3658        // Prevent Drop from running (which would shut down the channel)
3659        std::mem::forget(self);
3660    }
3661}
3662
3663impl GuestLifecycleCreateResponder {
3664    /// Sends a response to the FIDL transaction.
3665    ///
3666    /// Sets the channel to shutdown if an error occurs.
3667    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3668        let _result = self.send_raw(result);
3669        if _result.is_err() {
3670            self.control_handle.shutdown();
3671        }
3672        self.drop_without_shutdown();
3673        _result
3674    }
3675
3676    /// Similar to "send" but does not shutdown the channel if an error occurs.
3677    pub fn send_no_shutdown_on_err(
3678        self,
3679        mut result: Result<(), GuestError>,
3680    ) -> Result<(), fidl::Error> {
3681        let _result = self.send_raw(result);
3682        self.drop_without_shutdown();
3683        _result
3684    }
3685
3686    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3687        self.control_handle
3688            .inner
3689            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3690                result,
3691                self.tx_id,
3692                0x152719eed416ed41,
3693                fidl::encoding::DynamicFlags::empty(),
3694            )
3695    }
3696}
3697
3698#[must_use = "FIDL methods require a response to be sent"]
3699#[derive(Debug)]
3700pub struct GuestLifecycleRunResponder {
3701    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3702    tx_id: u32,
3703}
3704
3705/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3706/// if the responder is dropped without sending a response, so that the client
3707/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3708impl std::ops::Drop for GuestLifecycleRunResponder {
3709    fn drop(&mut self) {
3710        self.control_handle.shutdown();
3711        // Safety: drops once, never accessed again
3712        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3713    }
3714}
3715
3716impl fidl::endpoints::Responder for GuestLifecycleRunResponder {
3717    type ControlHandle = GuestLifecycleControlHandle;
3718
3719    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3720        &self.control_handle
3721    }
3722
3723    fn drop_without_shutdown(mut self) {
3724        // Safety: drops once, never accessed again due to mem::forget
3725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3726        // Prevent Drop from running (which would shut down the channel)
3727        std::mem::forget(self);
3728    }
3729}
3730
3731impl GuestLifecycleRunResponder {
3732    /// Sends a response to the FIDL transaction.
3733    ///
3734    /// Sets the channel to shutdown if an error occurs.
3735    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3736        let _result = self.send_raw(result);
3737        if _result.is_err() {
3738            self.control_handle.shutdown();
3739        }
3740        self.drop_without_shutdown();
3741        _result
3742    }
3743
3744    /// Similar to "send" but does not shutdown the channel if an error occurs.
3745    pub fn send_no_shutdown_on_err(
3746        self,
3747        mut result: Result<(), GuestError>,
3748    ) -> Result<(), fidl::Error> {
3749        let _result = self.send_raw(result);
3750        self.drop_without_shutdown();
3751        _result
3752    }
3753
3754    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3755        self.control_handle
3756            .inner
3757            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3758                result,
3759                self.tx_id,
3760                0x2907fef2ac775657,
3761                fidl::encoding::DynamicFlags::empty(),
3762            )
3763    }
3764}
3765
3766#[must_use = "FIDL methods require a response to be sent"]
3767#[derive(Debug)]
3768pub struct GuestLifecycleStopResponder {
3769    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3770    tx_id: u32,
3771}
3772
3773/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3774/// if the responder is dropped without sending a response, so that the client
3775/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3776impl std::ops::Drop for GuestLifecycleStopResponder {
3777    fn drop(&mut self) {
3778        self.control_handle.shutdown();
3779        // Safety: drops once, never accessed again
3780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3781    }
3782}
3783
3784impl fidl::endpoints::Responder for GuestLifecycleStopResponder {
3785    type ControlHandle = GuestLifecycleControlHandle;
3786
3787    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3788        &self.control_handle
3789    }
3790
3791    fn drop_without_shutdown(mut self) {
3792        // Safety: drops once, never accessed again due to mem::forget
3793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3794        // Prevent Drop from running (which would shut down the channel)
3795        std::mem::forget(self);
3796    }
3797}
3798
3799impl GuestLifecycleStopResponder {
3800    /// Sends a response to the FIDL transaction.
3801    ///
3802    /// Sets the channel to shutdown if an error occurs.
3803    pub fn send(self) -> Result<(), fidl::Error> {
3804        let _result = self.send_raw();
3805        if _result.is_err() {
3806            self.control_handle.shutdown();
3807        }
3808        self.drop_without_shutdown();
3809        _result
3810    }
3811
3812    /// Similar to "send" but does not shutdown the channel if an error occurs.
3813    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3814        let _result = self.send_raw();
3815        self.drop_without_shutdown();
3816        _result
3817    }
3818
3819    fn send_raw(&self) -> Result<(), fidl::Error> {
3820        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3821            (),
3822            self.tx_id,
3823            0x27eef9c535ac8eb4,
3824            fidl::encoding::DynamicFlags::empty(),
3825        )
3826    }
3827}
3828
3829#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3830pub struct GuestManagerMarker;
3831
3832impl fidl::endpoints::ProtocolMarker for GuestManagerMarker {
3833    type Proxy = GuestManagerProxy;
3834    type RequestStream = GuestManagerRequestStream;
3835    #[cfg(target_os = "fuchsia")]
3836    type SynchronousProxy = GuestManagerSynchronousProxy;
3837
3838    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestManager";
3839}
3840impl fidl::endpoints::DiscoverableProtocolMarker for GuestManagerMarker {}
3841pub type GuestManagerLaunchResult = Result<(), GuestManagerError>;
3842pub type GuestManagerConnectResult = Result<(), GuestManagerError>;
3843
3844pub trait GuestManagerProxyInterface: Send + Sync {
3845    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
3846        + Send;
3847    fn r#launch(
3848        &self,
3849        guest_config: GuestConfig,
3850        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3851    ) -> Self::LaunchResponseFut;
3852    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3853    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
3854    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
3855        + Send;
3856    fn r#connect(
3857        &self,
3858        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3859    ) -> Self::ConnectResponseFut;
3860    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
3861    fn r#get_info(&self) -> Self::GetInfoResponseFut;
3862}
3863#[derive(Debug)]
3864#[cfg(target_os = "fuchsia")]
3865pub struct GuestManagerSynchronousProxy {
3866    client: fidl::client::sync::Client,
3867}
3868
3869#[cfg(target_os = "fuchsia")]
3870impl fidl::endpoints::SynchronousProxy for GuestManagerSynchronousProxy {
3871    type Proxy = GuestManagerProxy;
3872    type Protocol = GuestManagerMarker;
3873
3874    fn from_channel(inner: fidl::Channel) -> Self {
3875        Self::new(inner)
3876    }
3877
3878    fn into_channel(self) -> fidl::Channel {
3879        self.client.into_channel()
3880    }
3881
3882    fn as_channel(&self) -> &fidl::Channel {
3883        self.client.as_channel()
3884    }
3885}
3886
3887#[cfg(target_os = "fuchsia")]
3888impl GuestManagerSynchronousProxy {
3889    pub fn new(channel: fidl::Channel) -> Self {
3890        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3891        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3892    }
3893
3894    pub fn into_channel(self) -> fidl::Channel {
3895        self.client.into_channel()
3896    }
3897
3898    /// Waits until an event arrives and returns it. It is safe for other
3899    /// threads to make concurrent requests while waiting for an event.
3900    pub fn wait_for_event(
3901        &self,
3902        deadline: zx::MonotonicInstant,
3903    ) -> Result<GuestManagerEvent, fidl::Error> {
3904        GuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
3905    }
3906
3907    /// Launch a new guest instance.
3908    ///
3909    /// Possible errors:
3910    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
3911    ///         problems detected by the guest manager.
3912    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
3913    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
3914    ///         component logs for a more specific failure.
3915    pub fn r#launch(
3916        &self,
3917        mut guest_config: GuestConfig,
3918        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
3919        ___deadline: zx::MonotonicInstant,
3920    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
3921        let _response =
3922            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
3923                fidl::encoding::EmptyStruct,
3924                GuestManagerError,
3925            >>(
3926                (&mut guest_config, controller),
3927                0x394a2e29f750323e,
3928                fidl::encoding::DynamicFlags::empty(),
3929                ___deadline,
3930            )?;
3931        Ok(_response.map(|x| x))
3932    }
3933
3934    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
3935    /// be used to launch another guest.
3936    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3937        let _response =
3938            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
3939                (),
3940                0x3ad9a012982f872d,
3941                fidl::encoding::DynamicFlags::empty(),
3942                ___deadline,
3943            )?;
3944        Ok(_response)
3945    }
3946
3947    /// Connect to a currently running guest.
3948    ///
3949    /// Possible errors:
3950    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
3951    ///         has launched before attempting to reconnect.
3952    pub fn r#connect(
3953        &self,
3954        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
3955        ___deadline: zx::MonotonicInstant,
3956    ) -> Result<GuestManagerConnectResult, fidl::Error> {
3957        let _response =
3958            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
3959                fidl::encoding::EmptyStruct,
3960                GuestManagerError,
3961            >>(
3962                (controller,),
3963                0x4e489076e3bb15b4,
3964                fidl::encoding::DynamicFlags::empty(),
3965                ___deadline,
3966            )?;
3967        Ok(_response.map(|x| x))
3968    }
3969
3970    /// Query guest info
3971    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
3972        let _response =
3973            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
3974                (),
3975                0x76892614aea695dc,
3976                fidl::encoding::DynamicFlags::empty(),
3977                ___deadline,
3978            )?;
3979        Ok(_response.guest_info)
3980    }
3981}
3982
3983#[derive(Debug, Clone)]
3984pub struct GuestManagerProxy {
3985    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3986}
3987
3988impl fidl::endpoints::Proxy for GuestManagerProxy {
3989    type Protocol = GuestManagerMarker;
3990
3991    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3992        Self::new(inner)
3993    }
3994
3995    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3996        self.client.into_channel().map_err(|client| Self { client })
3997    }
3998
3999    fn as_channel(&self) -> &::fidl::AsyncChannel {
4000        self.client.as_channel()
4001    }
4002}
4003
4004impl GuestManagerProxy {
4005    /// Create a new Proxy for fuchsia.virtualization/GuestManager.
4006    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4007        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4008        Self { client: fidl::client::Client::new(channel, protocol_name) }
4009    }
4010
4011    /// Get a Stream of events from the remote end of the protocol.
4012    ///
4013    /// # Panics
4014    ///
4015    /// Panics if the event stream was already taken.
4016    pub fn take_event_stream(&self) -> GuestManagerEventStream {
4017        GuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
4018    }
4019
4020    /// Launch a new guest instance.
4021    ///
4022    /// Possible errors:
4023    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4024    ///         problems detected by the guest manager.
4025    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4026    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4027    ///         component logs for a more specific failure.
4028    pub fn r#launch(
4029        &self,
4030        mut guest_config: GuestConfig,
4031        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4032    ) -> fidl::client::QueryResponseFut<
4033        GuestManagerLaunchResult,
4034        fidl::encoding::DefaultFuchsiaResourceDialect,
4035    > {
4036        GuestManagerProxyInterface::r#launch(self, guest_config, controller)
4037    }
4038
4039    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4040    /// be used to launch another guest.
4041    pub fn r#force_shutdown(
4042        &self,
4043    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4044        GuestManagerProxyInterface::r#force_shutdown(self)
4045    }
4046
4047    /// Connect to a currently running guest.
4048    ///
4049    /// Possible errors:
4050    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4051    ///         has launched before attempting to reconnect.
4052    pub fn r#connect(
4053        &self,
4054        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4055    ) -> fidl::client::QueryResponseFut<
4056        GuestManagerConnectResult,
4057        fidl::encoding::DefaultFuchsiaResourceDialect,
4058    > {
4059        GuestManagerProxyInterface::r#connect(self, controller)
4060    }
4061
4062    /// Query guest info
4063    pub fn r#get_info(
4064        &self,
4065    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
4066    {
4067        GuestManagerProxyInterface::r#get_info(self)
4068    }
4069}
4070
4071impl GuestManagerProxyInterface for GuestManagerProxy {
4072    type LaunchResponseFut = fidl::client::QueryResponseFut<
4073        GuestManagerLaunchResult,
4074        fidl::encoding::DefaultFuchsiaResourceDialect,
4075    >;
4076    fn r#launch(
4077        &self,
4078        mut guest_config: GuestConfig,
4079        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4080    ) -> Self::LaunchResponseFut {
4081        fn _decode(
4082            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4083        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
4084            let _response = fidl::client::decode_transaction_body::<
4085                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4086                fidl::encoding::DefaultFuchsiaResourceDialect,
4087                0x394a2e29f750323e,
4088            >(_buf?)?;
4089            Ok(_response.map(|x| x))
4090        }
4091        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
4092            (&mut guest_config, controller),
4093            0x394a2e29f750323e,
4094            fidl::encoding::DynamicFlags::empty(),
4095            _decode,
4096        )
4097    }
4098
4099    type ForceShutdownResponseFut =
4100        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4101    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
4102        fn _decode(
4103            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4104        ) -> Result<(), fidl::Error> {
4105            let _response = fidl::client::decode_transaction_body::<
4106                fidl::encoding::EmptyPayload,
4107                fidl::encoding::DefaultFuchsiaResourceDialect,
4108                0x3ad9a012982f872d,
4109            >(_buf?)?;
4110            Ok(_response)
4111        }
4112        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
4113            (),
4114            0x3ad9a012982f872d,
4115            fidl::encoding::DynamicFlags::empty(),
4116            _decode,
4117        )
4118    }
4119
4120    type ConnectResponseFut = fidl::client::QueryResponseFut<
4121        GuestManagerConnectResult,
4122        fidl::encoding::DefaultFuchsiaResourceDialect,
4123    >;
4124    fn r#connect(
4125        &self,
4126        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4127    ) -> Self::ConnectResponseFut {
4128        fn _decode(
4129            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4130        ) -> Result<GuestManagerConnectResult, fidl::Error> {
4131            let _response = fidl::client::decode_transaction_body::<
4132                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4133                fidl::encoding::DefaultFuchsiaResourceDialect,
4134                0x4e489076e3bb15b4,
4135            >(_buf?)?;
4136            Ok(_response.map(|x| x))
4137        }
4138        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
4139            (controller,),
4140            0x4e489076e3bb15b4,
4141            fidl::encoding::DynamicFlags::empty(),
4142            _decode,
4143        )
4144    }
4145
4146    type GetInfoResponseFut =
4147        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
4148    fn r#get_info(&self) -> Self::GetInfoResponseFut {
4149        fn _decode(
4150            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4151        ) -> Result<GuestInfo, fidl::Error> {
4152            let _response = fidl::client::decode_transaction_body::<
4153                GuestManagerGetInfoResponse,
4154                fidl::encoding::DefaultFuchsiaResourceDialect,
4155                0x76892614aea695dc,
4156            >(_buf?)?;
4157            Ok(_response.guest_info)
4158        }
4159        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
4160            (),
4161            0x76892614aea695dc,
4162            fidl::encoding::DynamicFlags::empty(),
4163            _decode,
4164        )
4165    }
4166}
4167
4168pub struct GuestManagerEventStream {
4169    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4170}
4171
4172impl std::marker::Unpin for GuestManagerEventStream {}
4173
4174impl futures::stream::FusedStream for GuestManagerEventStream {
4175    fn is_terminated(&self) -> bool {
4176        self.event_receiver.is_terminated()
4177    }
4178}
4179
4180impl futures::Stream for GuestManagerEventStream {
4181    type Item = Result<GuestManagerEvent, fidl::Error>;
4182
4183    fn poll_next(
4184        mut self: std::pin::Pin<&mut Self>,
4185        cx: &mut std::task::Context<'_>,
4186    ) -> std::task::Poll<Option<Self::Item>> {
4187        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4188            &mut self.event_receiver,
4189            cx
4190        )?) {
4191            Some(buf) => std::task::Poll::Ready(Some(GuestManagerEvent::decode(buf))),
4192            None => std::task::Poll::Ready(None),
4193        }
4194    }
4195}
4196
4197#[derive(Debug)]
4198pub enum GuestManagerEvent {}
4199
4200impl GuestManagerEvent {
4201    /// Decodes a message buffer as a [`GuestManagerEvent`].
4202    fn decode(
4203        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4204    ) -> Result<GuestManagerEvent, fidl::Error> {
4205        let (bytes, _handles) = buf.split_mut();
4206        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4207        debug_assert_eq!(tx_header.tx_id, 0);
4208        match tx_header.ordinal {
4209            _ => Err(fidl::Error::UnknownOrdinal {
4210                ordinal: tx_header.ordinal,
4211                protocol_name: <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4212            }),
4213        }
4214    }
4215}
4216
4217/// A Stream of incoming requests for fuchsia.virtualization/GuestManager.
4218pub struct GuestManagerRequestStream {
4219    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4220    is_terminated: bool,
4221}
4222
4223impl std::marker::Unpin for GuestManagerRequestStream {}
4224
4225impl futures::stream::FusedStream for GuestManagerRequestStream {
4226    fn is_terminated(&self) -> bool {
4227        self.is_terminated
4228    }
4229}
4230
4231impl fidl::endpoints::RequestStream for GuestManagerRequestStream {
4232    type Protocol = GuestManagerMarker;
4233    type ControlHandle = GuestManagerControlHandle;
4234
4235    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4236        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4237    }
4238
4239    fn control_handle(&self) -> Self::ControlHandle {
4240        GuestManagerControlHandle { inner: self.inner.clone() }
4241    }
4242
4243    fn into_inner(
4244        self,
4245    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4246    {
4247        (self.inner, self.is_terminated)
4248    }
4249
4250    fn from_inner(
4251        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4252        is_terminated: bool,
4253    ) -> Self {
4254        Self { inner, is_terminated }
4255    }
4256}
4257
4258impl futures::Stream for GuestManagerRequestStream {
4259    type Item = Result<GuestManagerRequest, fidl::Error>;
4260
4261    fn poll_next(
4262        mut self: std::pin::Pin<&mut Self>,
4263        cx: &mut std::task::Context<'_>,
4264    ) -> std::task::Poll<Option<Self::Item>> {
4265        let this = &mut *self;
4266        if this.inner.check_shutdown(cx) {
4267            this.is_terminated = true;
4268            return std::task::Poll::Ready(None);
4269        }
4270        if this.is_terminated {
4271            panic!("polled GuestManagerRequestStream after completion");
4272        }
4273        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4274            |bytes, handles| {
4275                match this.inner.channel().read_etc(cx, bytes, handles) {
4276                    std::task::Poll::Ready(Ok(())) => {}
4277                    std::task::Poll::Pending => return std::task::Poll::Pending,
4278                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4279                        this.is_terminated = true;
4280                        return std::task::Poll::Ready(None);
4281                    }
4282                    std::task::Poll::Ready(Err(e)) => {
4283                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4284                            e.into(),
4285                        ))))
4286                    }
4287                }
4288
4289                // A message has been received from the channel
4290                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4291
4292                std::task::Poll::Ready(Some(match header.ordinal {
4293                    0x394a2e29f750323e => {
4294                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4295                        let mut req = fidl::new_empty!(
4296                            GuestManagerLaunchRequest,
4297                            fidl::encoding::DefaultFuchsiaResourceDialect
4298                        );
4299                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
4300                        let control_handle =
4301                            GuestManagerControlHandle { inner: this.inner.clone() };
4302                        Ok(GuestManagerRequest::Launch {
4303                            guest_config: req.guest_config,
4304                            controller: req.controller,
4305
4306                            responder: GuestManagerLaunchResponder {
4307                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4308                                tx_id: header.tx_id,
4309                            },
4310                        })
4311                    }
4312                    0x3ad9a012982f872d => {
4313                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4314                        let mut req = fidl::new_empty!(
4315                            fidl::encoding::EmptyPayload,
4316                            fidl::encoding::DefaultFuchsiaResourceDialect
4317                        );
4318                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4319                        let control_handle =
4320                            GuestManagerControlHandle { inner: this.inner.clone() };
4321                        Ok(GuestManagerRequest::ForceShutdown {
4322                            responder: GuestManagerForceShutdownResponder {
4323                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4324                                tx_id: header.tx_id,
4325                            },
4326                        })
4327                    }
4328                    0x4e489076e3bb15b4 => {
4329                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4330                        let mut req = fidl::new_empty!(
4331                            GuestManagerConnectRequest,
4332                            fidl::encoding::DefaultFuchsiaResourceDialect
4333                        );
4334                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
4335                        let control_handle =
4336                            GuestManagerControlHandle { inner: this.inner.clone() };
4337                        Ok(GuestManagerRequest::Connect {
4338                            controller: req.controller,
4339
4340                            responder: GuestManagerConnectResponder {
4341                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4342                                tx_id: header.tx_id,
4343                            },
4344                        })
4345                    }
4346                    0x76892614aea695dc => {
4347                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4348                        let mut req = fidl::new_empty!(
4349                            fidl::encoding::EmptyPayload,
4350                            fidl::encoding::DefaultFuchsiaResourceDialect
4351                        );
4352                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4353                        let control_handle =
4354                            GuestManagerControlHandle { inner: this.inner.clone() };
4355                        Ok(GuestManagerRequest::GetInfo {
4356                            responder: GuestManagerGetInfoResponder {
4357                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4358                                tx_id: header.tx_id,
4359                            },
4360                        })
4361                    }
4362                    _ => Err(fidl::Error::UnknownOrdinal {
4363                        ordinal: header.ordinal,
4364                        protocol_name:
4365                            <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4366                    }),
4367                }))
4368            },
4369        )
4370    }
4371}
4372
4373#[derive(Debug)]
4374pub enum GuestManagerRequest {
4375    /// Launch a new guest instance.
4376    ///
4377    /// Possible errors:
4378    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4379    ///         problems detected by the guest manager.
4380    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4381    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4382    ///         component logs for a more specific failure.
4383    Launch {
4384        guest_config: GuestConfig,
4385        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4386        responder: GuestManagerLaunchResponder,
4387    },
4388    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4389    /// be used to launch another guest.
4390    ForceShutdown { responder: GuestManagerForceShutdownResponder },
4391    /// Connect to a currently running guest.
4392    ///
4393    /// Possible errors:
4394    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4395    ///         has launched before attempting to reconnect.
4396    Connect {
4397        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4398        responder: GuestManagerConnectResponder,
4399    },
4400    /// Query guest info
4401    GetInfo { responder: GuestManagerGetInfoResponder },
4402}
4403
4404impl GuestManagerRequest {
4405    #[allow(irrefutable_let_patterns)]
4406    pub fn into_launch(
4407        self,
4408    ) -> Option<(GuestConfig, fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerLaunchResponder)>
4409    {
4410        if let GuestManagerRequest::Launch { guest_config, controller, responder } = self {
4411            Some((guest_config, controller, responder))
4412        } else {
4413            None
4414        }
4415    }
4416
4417    #[allow(irrefutable_let_patterns)]
4418    pub fn into_force_shutdown(self) -> Option<(GuestManagerForceShutdownResponder)> {
4419        if let GuestManagerRequest::ForceShutdown { responder } = self {
4420            Some((responder))
4421        } else {
4422            None
4423        }
4424    }
4425
4426    #[allow(irrefutable_let_patterns)]
4427    pub fn into_connect(
4428        self,
4429    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerConnectResponder)> {
4430        if let GuestManagerRequest::Connect { controller, responder } = self {
4431            Some((controller, responder))
4432        } else {
4433            None
4434        }
4435    }
4436
4437    #[allow(irrefutable_let_patterns)]
4438    pub fn into_get_info(self) -> Option<(GuestManagerGetInfoResponder)> {
4439        if let GuestManagerRequest::GetInfo { responder } = self {
4440            Some((responder))
4441        } else {
4442            None
4443        }
4444    }
4445
4446    /// Name of the method defined in FIDL
4447    pub fn method_name(&self) -> &'static str {
4448        match *self {
4449            GuestManagerRequest::Launch { .. } => "launch",
4450            GuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
4451            GuestManagerRequest::Connect { .. } => "connect",
4452            GuestManagerRequest::GetInfo { .. } => "get_info",
4453        }
4454    }
4455}
4456
4457#[derive(Debug, Clone)]
4458pub struct GuestManagerControlHandle {
4459    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4460}
4461
4462impl fidl::endpoints::ControlHandle for GuestManagerControlHandle {
4463    fn shutdown(&self) {
4464        self.inner.shutdown()
4465    }
4466    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4467        self.inner.shutdown_with_epitaph(status)
4468    }
4469
4470    fn is_closed(&self) -> bool {
4471        self.inner.channel().is_closed()
4472    }
4473    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4474        self.inner.channel().on_closed()
4475    }
4476
4477    #[cfg(target_os = "fuchsia")]
4478    fn signal_peer(
4479        &self,
4480        clear_mask: zx::Signals,
4481        set_mask: zx::Signals,
4482    ) -> Result<(), zx_status::Status> {
4483        use fidl::Peered;
4484        self.inner.channel().signal_peer(clear_mask, set_mask)
4485    }
4486}
4487
4488impl GuestManagerControlHandle {}
4489
4490#[must_use = "FIDL methods require a response to be sent"]
4491#[derive(Debug)]
4492pub struct GuestManagerLaunchResponder {
4493    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4494    tx_id: u32,
4495}
4496
4497/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4498/// if the responder is dropped without sending a response, so that the client
4499/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4500impl std::ops::Drop for GuestManagerLaunchResponder {
4501    fn drop(&mut self) {
4502        self.control_handle.shutdown();
4503        // Safety: drops once, never accessed again
4504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4505    }
4506}
4507
4508impl fidl::endpoints::Responder for GuestManagerLaunchResponder {
4509    type ControlHandle = GuestManagerControlHandle;
4510
4511    fn control_handle(&self) -> &GuestManagerControlHandle {
4512        &self.control_handle
4513    }
4514
4515    fn drop_without_shutdown(mut self) {
4516        // Safety: drops once, never accessed again due to mem::forget
4517        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4518        // Prevent Drop from running (which would shut down the channel)
4519        std::mem::forget(self);
4520    }
4521}
4522
4523impl GuestManagerLaunchResponder {
4524    /// Sends a response to the FIDL transaction.
4525    ///
4526    /// Sets the channel to shutdown if an error occurs.
4527    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4528        let _result = self.send_raw(result);
4529        if _result.is_err() {
4530            self.control_handle.shutdown();
4531        }
4532        self.drop_without_shutdown();
4533        _result
4534    }
4535
4536    /// Similar to "send" but does not shutdown the channel if an error occurs.
4537    pub fn send_no_shutdown_on_err(
4538        self,
4539        mut result: Result<(), GuestManagerError>,
4540    ) -> Result<(), fidl::Error> {
4541        let _result = self.send_raw(result);
4542        self.drop_without_shutdown();
4543        _result
4544    }
4545
4546    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4547        self.control_handle.inner.send::<fidl::encoding::ResultType<
4548            fidl::encoding::EmptyStruct,
4549            GuestManagerError,
4550        >>(
4551            result,
4552            self.tx_id,
4553            0x394a2e29f750323e,
4554            fidl::encoding::DynamicFlags::empty(),
4555        )
4556    }
4557}
4558
4559#[must_use = "FIDL methods require a response to be sent"]
4560#[derive(Debug)]
4561pub struct GuestManagerForceShutdownResponder {
4562    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4563    tx_id: u32,
4564}
4565
4566/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4567/// if the responder is dropped without sending a response, so that the client
4568/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4569impl std::ops::Drop for GuestManagerForceShutdownResponder {
4570    fn drop(&mut self) {
4571        self.control_handle.shutdown();
4572        // Safety: drops once, never accessed again
4573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4574    }
4575}
4576
4577impl fidl::endpoints::Responder for GuestManagerForceShutdownResponder {
4578    type ControlHandle = GuestManagerControlHandle;
4579
4580    fn control_handle(&self) -> &GuestManagerControlHandle {
4581        &self.control_handle
4582    }
4583
4584    fn drop_without_shutdown(mut self) {
4585        // Safety: drops once, never accessed again due to mem::forget
4586        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4587        // Prevent Drop from running (which would shut down the channel)
4588        std::mem::forget(self);
4589    }
4590}
4591
4592impl GuestManagerForceShutdownResponder {
4593    /// Sends a response to the FIDL transaction.
4594    ///
4595    /// Sets the channel to shutdown if an error occurs.
4596    pub fn send(self) -> Result<(), fidl::Error> {
4597        let _result = self.send_raw();
4598        if _result.is_err() {
4599            self.control_handle.shutdown();
4600        }
4601        self.drop_without_shutdown();
4602        _result
4603    }
4604
4605    /// Similar to "send" but does not shutdown the channel if an error occurs.
4606    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4607        let _result = self.send_raw();
4608        self.drop_without_shutdown();
4609        _result
4610    }
4611
4612    fn send_raw(&self) -> Result<(), fidl::Error> {
4613        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4614            (),
4615            self.tx_id,
4616            0x3ad9a012982f872d,
4617            fidl::encoding::DynamicFlags::empty(),
4618        )
4619    }
4620}
4621
4622#[must_use = "FIDL methods require a response to be sent"]
4623#[derive(Debug)]
4624pub struct GuestManagerConnectResponder {
4625    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4626    tx_id: u32,
4627}
4628
4629/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4630/// if the responder is dropped without sending a response, so that the client
4631/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4632impl std::ops::Drop for GuestManagerConnectResponder {
4633    fn drop(&mut self) {
4634        self.control_handle.shutdown();
4635        // Safety: drops once, never accessed again
4636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4637    }
4638}
4639
4640impl fidl::endpoints::Responder for GuestManagerConnectResponder {
4641    type ControlHandle = GuestManagerControlHandle;
4642
4643    fn control_handle(&self) -> &GuestManagerControlHandle {
4644        &self.control_handle
4645    }
4646
4647    fn drop_without_shutdown(mut self) {
4648        // Safety: drops once, never accessed again due to mem::forget
4649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4650        // Prevent Drop from running (which would shut down the channel)
4651        std::mem::forget(self);
4652    }
4653}
4654
4655impl GuestManagerConnectResponder {
4656    /// Sends a response to the FIDL transaction.
4657    ///
4658    /// Sets the channel to shutdown if an error occurs.
4659    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4660        let _result = self.send_raw(result);
4661        if _result.is_err() {
4662            self.control_handle.shutdown();
4663        }
4664        self.drop_without_shutdown();
4665        _result
4666    }
4667
4668    /// Similar to "send" but does not shutdown the channel if an error occurs.
4669    pub fn send_no_shutdown_on_err(
4670        self,
4671        mut result: Result<(), GuestManagerError>,
4672    ) -> Result<(), fidl::Error> {
4673        let _result = self.send_raw(result);
4674        self.drop_without_shutdown();
4675        _result
4676    }
4677
4678    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4679        self.control_handle.inner.send::<fidl::encoding::ResultType<
4680            fidl::encoding::EmptyStruct,
4681            GuestManagerError,
4682        >>(
4683            result,
4684            self.tx_id,
4685            0x4e489076e3bb15b4,
4686            fidl::encoding::DynamicFlags::empty(),
4687        )
4688    }
4689}
4690
4691#[must_use = "FIDL methods require a response to be sent"]
4692#[derive(Debug)]
4693pub struct GuestManagerGetInfoResponder {
4694    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4695    tx_id: u32,
4696}
4697
4698/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4699/// if the responder is dropped without sending a response, so that the client
4700/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4701impl std::ops::Drop for GuestManagerGetInfoResponder {
4702    fn drop(&mut self) {
4703        self.control_handle.shutdown();
4704        // Safety: drops once, never accessed again
4705        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4706    }
4707}
4708
4709impl fidl::endpoints::Responder for GuestManagerGetInfoResponder {
4710    type ControlHandle = GuestManagerControlHandle;
4711
4712    fn control_handle(&self) -> &GuestManagerControlHandle {
4713        &self.control_handle
4714    }
4715
4716    fn drop_without_shutdown(mut self) {
4717        // Safety: drops once, never accessed again due to mem::forget
4718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4719        // Prevent Drop from running (which would shut down the channel)
4720        std::mem::forget(self);
4721    }
4722}
4723
4724impl GuestManagerGetInfoResponder {
4725    /// Sends a response to the FIDL transaction.
4726    ///
4727    /// Sets the channel to shutdown if an error occurs.
4728    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4729        let _result = self.send_raw(guest_info);
4730        if _result.is_err() {
4731            self.control_handle.shutdown();
4732        }
4733        self.drop_without_shutdown();
4734        _result
4735    }
4736
4737    /// Similar to "send" but does not shutdown the channel if an error occurs.
4738    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4739        let _result = self.send_raw(guest_info);
4740        self.drop_without_shutdown();
4741        _result
4742    }
4743
4744    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4745        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
4746            (guest_info,),
4747            self.tx_id,
4748            0x76892614aea695dc,
4749            fidl::encoding::DynamicFlags::empty(),
4750        )
4751    }
4752}
4753
4754#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4755pub struct HostVsockAcceptorMarker;
4756
4757impl fidl::endpoints::ProtocolMarker for HostVsockAcceptorMarker {
4758    type Proxy = HostVsockAcceptorProxy;
4759    type RequestStream = HostVsockAcceptorRequestStream;
4760    #[cfg(target_os = "fuchsia")]
4761    type SynchronousProxy = HostVsockAcceptorSynchronousProxy;
4762
4763    const DEBUG_NAME: &'static str = "(anonymous) HostVsockAcceptor";
4764}
4765pub type HostVsockAcceptorAcceptResult = Result<fidl::Socket, i32>;
4766
4767pub trait HostVsockAcceptorProxyInterface: Send + Sync {
4768    type AcceptResponseFut: std::future::Future<Output = Result<HostVsockAcceptorAcceptResult, fidl::Error>>
4769        + Send;
4770    fn r#accept(&self, src_cid: u32, src_port: u32, port: u32) -> Self::AcceptResponseFut;
4771}
4772#[derive(Debug)]
4773#[cfg(target_os = "fuchsia")]
4774pub struct HostVsockAcceptorSynchronousProxy {
4775    client: fidl::client::sync::Client,
4776}
4777
4778#[cfg(target_os = "fuchsia")]
4779impl fidl::endpoints::SynchronousProxy for HostVsockAcceptorSynchronousProxy {
4780    type Proxy = HostVsockAcceptorProxy;
4781    type Protocol = HostVsockAcceptorMarker;
4782
4783    fn from_channel(inner: fidl::Channel) -> Self {
4784        Self::new(inner)
4785    }
4786
4787    fn into_channel(self) -> fidl::Channel {
4788        self.client.into_channel()
4789    }
4790
4791    fn as_channel(&self) -> &fidl::Channel {
4792        self.client.as_channel()
4793    }
4794}
4795
4796#[cfg(target_os = "fuchsia")]
4797impl HostVsockAcceptorSynchronousProxy {
4798    pub fn new(channel: fidl::Channel) -> Self {
4799        let protocol_name =
4800            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4801        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4802    }
4803
4804    pub fn into_channel(self) -> fidl::Channel {
4805        self.client.into_channel()
4806    }
4807
4808    /// Waits until an event arrives and returns it. It is safe for other
4809    /// threads to make concurrent requests while waiting for an event.
4810    pub fn wait_for_event(
4811        &self,
4812        deadline: zx::MonotonicInstant,
4813    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
4814        HostVsockAcceptorEvent::decode(self.client.wait_for_event(deadline)?)
4815    }
4816
4817    pub fn r#accept(
4818        &self,
4819        mut src_cid: u32,
4820        mut src_port: u32,
4821        mut port: u32,
4822        ___deadline: zx::MonotonicInstant,
4823    ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
4824        let _response = self.client.send_query::<
4825            HostVsockAcceptorAcceptRequest,
4826            fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
4827        >(
4828            (src_cid, src_port, port,),
4829            0x6996ed935beaa2d7,
4830            fidl::encoding::DynamicFlags::empty(),
4831            ___deadline,
4832        )?;
4833        Ok(_response.map(|x| x.socket))
4834    }
4835}
4836
4837#[derive(Debug, Clone)]
4838pub struct HostVsockAcceptorProxy {
4839    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4840}
4841
4842impl fidl::endpoints::Proxy for HostVsockAcceptorProxy {
4843    type Protocol = HostVsockAcceptorMarker;
4844
4845    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4846        Self::new(inner)
4847    }
4848
4849    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4850        self.client.into_channel().map_err(|client| Self { client })
4851    }
4852
4853    fn as_channel(&self) -> &::fidl::AsyncChannel {
4854        self.client.as_channel()
4855    }
4856}
4857
4858impl HostVsockAcceptorProxy {
4859    /// Create a new Proxy for fuchsia.virtualization/HostVsockAcceptor.
4860    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4861        let protocol_name =
4862            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4863        Self { client: fidl::client::Client::new(channel, protocol_name) }
4864    }
4865
4866    /// Get a Stream of events from the remote end of the protocol.
4867    ///
4868    /// # Panics
4869    ///
4870    /// Panics if the event stream was already taken.
4871    pub fn take_event_stream(&self) -> HostVsockAcceptorEventStream {
4872        HostVsockAcceptorEventStream { event_receiver: self.client.take_event_receiver() }
4873    }
4874
4875    pub fn r#accept(
4876        &self,
4877        mut src_cid: u32,
4878        mut src_port: u32,
4879        mut port: u32,
4880    ) -> fidl::client::QueryResponseFut<
4881        HostVsockAcceptorAcceptResult,
4882        fidl::encoding::DefaultFuchsiaResourceDialect,
4883    > {
4884        HostVsockAcceptorProxyInterface::r#accept(self, src_cid, src_port, port)
4885    }
4886}
4887
4888impl HostVsockAcceptorProxyInterface for HostVsockAcceptorProxy {
4889    type AcceptResponseFut = fidl::client::QueryResponseFut<
4890        HostVsockAcceptorAcceptResult,
4891        fidl::encoding::DefaultFuchsiaResourceDialect,
4892    >;
4893    fn r#accept(
4894        &self,
4895        mut src_cid: u32,
4896        mut src_port: u32,
4897        mut port: u32,
4898    ) -> Self::AcceptResponseFut {
4899        fn _decode(
4900            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4901        ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
4902            let _response = fidl::client::decode_transaction_body::<
4903                fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
4904                fidl::encoding::DefaultFuchsiaResourceDialect,
4905                0x6996ed935beaa2d7,
4906            >(_buf?)?;
4907            Ok(_response.map(|x| x.socket))
4908        }
4909        self.client
4910            .send_query_and_decode::<HostVsockAcceptorAcceptRequest, HostVsockAcceptorAcceptResult>(
4911                (src_cid, src_port, port),
4912                0x6996ed935beaa2d7,
4913                fidl::encoding::DynamicFlags::empty(),
4914                _decode,
4915            )
4916    }
4917}
4918
4919pub struct HostVsockAcceptorEventStream {
4920    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4921}
4922
4923impl std::marker::Unpin for HostVsockAcceptorEventStream {}
4924
4925impl futures::stream::FusedStream for HostVsockAcceptorEventStream {
4926    fn is_terminated(&self) -> bool {
4927        self.event_receiver.is_terminated()
4928    }
4929}
4930
4931impl futures::Stream for HostVsockAcceptorEventStream {
4932    type Item = Result<HostVsockAcceptorEvent, fidl::Error>;
4933
4934    fn poll_next(
4935        mut self: std::pin::Pin<&mut Self>,
4936        cx: &mut std::task::Context<'_>,
4937    ) -> std::task::Poll<Option<Self::Item>> {
4938        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4939            &mut self.event_receiver,
4940            cx
4941        )?) {
4942            Some(buf) => std::task::Poll::Ready(Some(HostVsockAcceptorEvent::decode(buf))),
4943            None => std::task::Poll::Ready(None),
4944        }
4945    }
4946}
4947
4948#[derive(Debug)]
4949pub enum HostVsockAcceptorEvent {}
4950
4951impl HostVsockAcceptorEvent {
4952    /// Decodes a message buffer as a [`HostVsockAcceptorEvent`].
4953    fn decode(
4954        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4955    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
4956        let (bytes, _handles) = buf.split_mut();
4957        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4958        debug_assert_eq!(tx_header.tx_id, 0);
4959        match tx_header.ordinal {
4960            _ => Err(fidl::Error::UnknownOrdinal {
4961                ordinal: tx_header.ordinal,
4962                protocol_name:
4963                    <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4964            }),
4965        }
4966    }
4967}
4968
4969/// A Stream of incoming requests for fuchsia.virtualization/HostVsockAcceptor.
4970pub struct HostVsockAcceptorRequestStream {
4971    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4972    is_terminated: bool,
4973}
4974
4975impl std::marker::Unpin for HostVsockAcceptorRequestStream {}
4976
4977impl futures::stream::FusedStream for HostVsockAcceptorRequestStream {
4978    fn is_terminated(&self) -> bool {
4979        self.is_terminated
4980    }
4981}
4982
4983impl fidl::endpoints::RequestStream for HostVsockAcceptorRequestStream {
4984    type Protocol = HostVsockAcceptorMarker;
4985    type ControlHandle = HostVsockAcceptorControlHandle;
4986
4987    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4988        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4989    }
4990
4991    fn control_handle(&self) -> Self::ControlHandle {
4992        HostVsockAcceptorControlHandle { inner: self.inner.clone() }
4993    }
4994
4995    fn into_inner(
4996        self,
4997    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4998    {
4999        (self.inner, self.is_terminated)
5000    }
5001
5002    fn from_inner(
5003        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5004        is_terminated: bool,
5005    ) -> Self {
5006        Self { inner, is_terminated }
5007    }
5008}
5009
5010impl futures::Stream for HostVsockAcceptorRequestStream {
5011    type Item = Result<HostVsockAcceptorRequest, fidl::Error>;
5012
5013    fn poll_next(
5014        mut self: std::pin::Pin<&mut Self>,
5015        cx: &mut std::task::Context<'_>,
5016    ) -> std::task::Poll<Option<Self::Item>> {
5017        let this = &mut *self;
5018        if this.inner.check_shutdown(cx) {
5019            this.is_terminated = true;
5020            return std::task::Poll::Ready(None);
5021        }
5022        if this.is_terminated {
5023            panic!("polled HostVsockAcceptorRequestStream after completion");
5024        }
5025        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5026            |bytes, handles| {
5027                match this.inner.channel().read_etc(cx, bytes, handles) {
5028                    std::task::Poll::Ready(Ok(())) => {}
5029                    std::task::Poll::Pending => return std::task::Poll::Pending,
5030                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5031                        this.is_terminated = true;
5032                        return std::task::Poll::Ready(None);
5033                    }
5034                    std::task::Poll::Ready(Err(e)) => {
5035                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5036                            e.into(),
5037                        ))))
5038                    }
5039                }
5040
5041                // A message has been received from the channel
5042                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5043
5044                std::task::Poll::Ready(Some(match header.ordinal {
5045                    0x6996ed935beaa2d7 => {
5046                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5047                        let mut req = fidl::new_empty!(
5048                            HostVsockAcceptorAcceptRequest,
5049                            fidl::encoding::DefaultFuchsiaResourceDialect
5050                        );
5051                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockAcceptorAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
5052                        let control_handle =
5053                            HostVsockAcceptorControlHandle { inner: this.inner.clone() };
5054                        Ok(HostVsockAcceptorRequest::Accept {
5055                            src_cid: req.src_cid,
5056                            src_port: req.src_port,
5057                            port: req.port,
5058
5059                            responder: HostVsockAcceptorAcceptResponder {
5060                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5061                                tx_id: header.tx_id,
5062                            },
5063                        })
5064                    }
5065                    _ => Err(fidl::Error::UnknownOrdinal {
5066                        ordinal: header.ordinal,
5067                        protocol_name:
5068                            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5069                    }),
5070                }))
5071            },
5072        )
5073    }
5074}
5075
5076/// Exposed by a host capable of listening via vsocks. A variant of a
5077/// `GuestVsockAcceptor` that is responsible for creating the `socket` with which
5078/// to communicate.
5079#[derive(Debug)]
5080pub enum HostVsockAcceptorRequest {
5081    Accept { src_cid: u32, src_port: u32, port: u32, responder: HostVsockAcceptorAcceptResponder },
5082}
5083
5084impl HostVsockAcceptorRequest {
5085    #[allow(irrefutable_let_patterns)]
5086    pub fn into_accept(self) -> Option<(u32, u32, u32, HostVsockAcceptorAcceptResponder)> {
5087        if let HostVsockAcceptorRequest::Accept { src_cid, src_port, port, responder } = self {
5088            Some((src_cid, src_port, port, responder))
5089        } else {
5090            None
5091        }
5092    }
5093
5094    /// Name of the method defined in FIDL
5095    pub fn method_name(&self) -> &'static str {
5096        match *self {
5097            HostVsockAcceptorRequest::Accept { .. } => "accept",
5098        }
5099    }
5100}
5101
5102#[derive(Debug, Clone)]
5103pub struct HostVsockAcceptorControlHandle {
5104    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5105}
5106
5107impl fidl::endpoints::ControlHandle for HostVsockAcceptorControlHandle {
5108    fn shutdown(&self) {
5109        self.inner.shutdown()
5110    }
5111    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5112        self.inner.shutdown_with_epitaph(status)
5113    }
5114
5115    fn is_closed(&self) -> bool {
5116        self.inner.channel().is_closed()
5117    }
5118    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5119        self.inner.channel().on_closed()
5120    }
5121
5122    #[cfg(target_os = "fuchsia")]
5123    fn signal_peer(
5124        &self,
5125        clear_mask: zx::Signals,
5126        set_mask: zx::Signals,
5127    ) -> Result<(), zx_status::Status> {
5128        use fidl::Peered;
5129        self.inner.channel().signal_peer(clear_mask, set_mask)
5130    }
5131}
5132
5133impl HostVsockAcceptorControlHandle {}
5134
5135#[must_use = "FIDL methods require a response to be sent"]
5136#[derive(Debug)]
5137pub struct HostVsockAcceptorAcceptResponder {
5138    control_handle: std::mem::ManuallyDrop<HostVsockAcceptorControlHandle>,
5139    tx_id: u32,
5140}
5141
5142/// Set the the channel to be shutdown (see [`HostVsockAcceptorControlHandle::shutdown`])
5143/// if the responder is dropped without sending a response, so that the client
5144/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5145impl std::ops::Drop for HostVsockAcceptorAcceptResponder {
5146    fn drop(&mut self) {
5147        self.control_handle.shutdown();
5148        // Safety: drops once, never accessed again
5149        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5150    }
5151}
5152
5153impl fidl::endpoints::Responder for HostVsockAcceptorAcceptResponder {
5154    type ControlHandle = HostVsockAcceptorControlHandle;
5155
5156    fn control_handle(&self) -> &HostVsockAcceptorControlHandle {
5157        &self.control_handle
5158    }
5159
5160    fn drop_without_shutdown(mut self) {
5161        // Safety: drops once, never accessed again due to mem::forget
5162        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5163        // Prevent Drop from running (which would shut down the channel)
5164        std::mem::forget(self);
5165    }
5166}
5167
5168impl HostVsockAcceptorAcceptResponder {
5169    /// Sends a response to the FIDL transaction.
5170    ///
5171    /// Sets the channel to shutdown if an error occurs.
5172    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5173        let _result = self.send_raw(result);
5174        if _result.is_err() {
5175            self.control_handle.shutdown();
5176        }
5177        self.drop_without_shutdown();
5178        _result
5179    }
5180
5181    /// Similar to "send" but does not shutdown the channel if an error occurs.
5182    pub fn send_no_shutdown_on_err(
5183        self,
5184        mut result: Result<fidl::Socket, i32>,
5185    ) -> Result<(), fidl::Error> {
5186        let _result = self.send_raw(result);
5187        self.drop_without_shutdown();
5188        _result
5189    }
5190
5191    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5192        self.control_handle
5193            .inner
5194            .send::<fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>>(
5195                result.map(|socket| (socket,)),
5196                self.tx_id,
5197                0x6996ed935beaa2d7,
5198                fidl::encoding::DynamicFlags::empty(),
5199            )
5200    }
5201}
5202
5203#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5204pub struct HostVsockEndpointMarker;
5205
5206impl fidl::endpoints::ProtocolMarker for HostVsockEndpointMarker {
5207    type Proxy = HostVsockEndpointProxy;
5208    type RequestStream = HostVsockEndpointRequestStream;
5209    #[cfg(target_os = "fuchsia")]
5210    type SynchronousProxy = HostVsockEndpointSynchronousProxy;
5211
5212    const DEBUG_NAME: &'static str = "fuchsia.virtualization.HostVsockEndpoint";
5213}
5214impl fidl::endpoints::DiscoverableProtocolMarker for HostVsockEndpointMarker {}
5215pub type HostVsockEndpointListenResult = Result<(), i32>;
5216pub type HostVsockEndpointConnectResult = Result<fidl::Socket, i32>;
5217
5218pub trait HostVsockEndpointProxyInterface: Send + Sync {
5219    type ListenResponseFut: std::future::Future<Output = Result<HostVsockEndpointListenResult, fidl::Error>>
5220        + Send;
5221    fn r#listen(
5222        &self,
5223        port: u32,
5224        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5225    ) -> Self::ListenResponseFut;
5226    type ConnectResponseFut: std::future::Future<Output = Result<HostVsockEndpointConnectResult, fidl::Error>>
5227        + Send;
5228    fn r#connect(&self, guest_port: u32) -> Self::ConnectResponseFut;
5229}
5230#[derive(Debug)]
5231#[cfg(target_os = "fuchsia")]
5232pub struct HostVsockEndpointSynchronousProxy {
5233    client: fidl::client::sync::Client,
5234}
5235
5236#[cfg(target_os = "fuchsia")]
5237impl fidl::endpoints::SynchronousProxy for HostVsockEndpointSynchronousProxy {
5238    type Proxy = HostVsockEndpointProxy;
5239    type Protocol = HostVsockEndpointMarker;
5240
5241    fn from_channel(inner: fidl::Channel) -> Self {
5242        Self::new(inner)
5243    }
5244
5245    fn into_channel(self) -> fidl::Channel {
5246        self.client.into_channel()
5247    }
5248
5249    fn as_channel(&self) -> &fidl::Channel {
5250        self.client.as_channel()
5251    }
5252}
5253
5254#[cfg(target_os = "fuchsia")]
5255impl HostVsockEndpointSynchronousProxy {
5256    pub fn new(channel: fidl::Channel) -> Self {
5257        let protocol_name =
5258            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5259        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5260    }
5261
5262    pub fn into_channel(self) -> fidl::Channel {
5263        self.client.into_channel()
5264    }
5265
5266    /// Waits until an event arrives and returns it. It is safe for other
5267    /// threads to make concurrent requests while waiting for an event.
5268    pub fn wait_for_event(
5269        &self,
5270        deadline: zx::MonotonicInstant,
5271    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5272        HostVsockEndpointEvent::decode(self.client.wait_for_event(deadline)?)
5273    }
5274
5275    /// Instructs the device to listen for guest initiated connections to a given port by
5276    /// using `acceptor` when the guest creates a connection.
5277    ///
5278    /// Possible errors:
5279    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5280    pub fn r#listen(
5281        &self,
5282        mut port: u32,
5283        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5284        ___deadline: zx::MonotonicInstant,
5285    ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5286        let _response = self
5287            .client
5288            .send_query::<Listener, fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5289                (port, acceptor),
5290                0xfd88f3b4767f2c7,
5291                fidl::encoding::DynamicFlags::empty(),
5292                ___deadline,
5293            )?;
5294        Ok(_response.map(|x| x))
5295    }
5296
5297    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5298    /// ephemeral host port.
5299    ///
5300    /// Possible errors:
5301    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5302    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5303    ///
5304    /// Other errors are related to socket creation, see
5305    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5306    pub fn r#connect(
5307        &self,
5308        mut guest_port: u32,
5309        ___deadline: zx::MonotonicInstant,
5310    ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5311        let _response = self.client.send_query::<
5312            HostVsockEndpointConnectRequest,
5313            fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5314        >(
5315            (guest_port,),
5316            0x4d12e10e946b43e4,
5317            fidl::encoding::DynamicFlags::empty(),
5318            ___deadline,
5319        )?;
5320        Ok(_response.map(|x| x.socket))
5321    }
5322}
5323
5324#[derive(Debug, Clone)]
5325pub struct HostVsockEndpointProxy {
5326    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5327}
5328
5329impl fidl::endpoints::Proxy for HostVsockEndpointProxy {
5330    type Protocol = HostVsockEndpointMarker;
5331
5332    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5333        Self::new(inner)
5334    }
5335
5336    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5337        self.client.into_channel().map_err(|client| Self { client })
5338    }
5339
5340    fn as_channel(&self) -> &::fidl::AsyncChannel {
5341        self.client.as_channel()
5342    }
5343}
5344
5345impl HostVsockEndpointProxy {
5346    /// Create a new Proxy for fuchsia.virtualization/HostVsockEndpoint.
5347    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5348        let protocol_name =
5349            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5350        Self { client: fidl::client::Client::new(channel, protocol_name) }
5351    }
5352
5353    /// Get a Stream of events from the remote end of the protocol.
5354    ///
5355    /// # Panics
5356    ///
5357    /// Panics if the event stream was already taken.
5358    pub fn take_event_stream(&self) -> HostVsockEndpointEventStream {
5359        HostVsockEndpointEventStream { event_receiver: self.client.take_event_receiver() }
5360    }
5361
5362    /// Instructs the device to listen for guest initiated connections to a given port by
5363    /// using `acceptor` when the guest creates a connection.
5364    ///
5365    /// Possible errors:
5366    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5367    pub fn r#listen(
5368        &self,
5369        mut port: u32,
5370        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5371    ) -> fidl::client::QueryResponseFut<
5372        HostVsockEndpointListenResult,
5373        fidl::encoding::DefaultFuchsiaResourceDialect,
5374    > {
5375        HostVsockEndpointProxyInterface::r#listen(self, port, acceptor)
5376    }
5377
5378    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5379    /// ephemeral host port.
5380    ///
5381    /// Possible errors:
5382    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5383    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5384    ///
5385    /// Other errors are related to socket creation, see
5386    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5387    pub fn r#connect(
5388        &self,
5389        mut guest_port: u32,
5390    ) -> fidl::client::QueryResponseFut<
5391        HostVsockEndpointConnectResult,
5392        fidl::encoding::DefaultFuchsiaResourceDialect,
5393    > {
5394        HostVsockEndpointProxyInterface::r#connect(self, guest_port)
5395    }
5396}
5397
5398impl HostVsockEndpointProxyInterface for HostVsockEndpointProxy {
5399    type ListenResponseFut = fidl::client::QueryResponseFut<
5400        HostVsockEndpointListenResult,
5401        fidl::encoding::DefaultFuchsiaResourceDialect,
5402    >;
5403    fn r#listen(
5404        &self,
5405        mut port: u32,
5406        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5407    ) -> Self::ListenResponseFut {
5408        fn _decode(
5409            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5410        ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5411            let _response = fidl::client::decode_transaction_body::<
5412                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5413                fidl::encoding::DefaultFuchsiaResourceDialect,
5414                0xfd88f3b4767f2c7,
5415            >(_buf?)?;
5416            Ok(_response.map(|x| x))
5417        }
5418        self.client.send_query_and_decode::<Listener, HostVsockEndpointListenResult>(
5419            (port, acceptor),
5420            0xfd88f3b4767f2c7,
5421            fidl::encoding::DynamicFlags::empty(),
5422            _decode,
5423        )
5424    }
5425
5426    type ConnectResponseFut = fidl::client::QueryResponseFut<
5427        HostVsockEndpointConnectResult,
5428        fidl::encoding::DefaultFuchsiaResourceDialect,
5429    >;
5430    fn r#connect(&self, mut guest_port: u32) -> Self::ConnectResponseFut {
5431        fn _decode(
5432            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5433        ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5434            let _response = fidl::client::decode_transaction_body::<
5435                fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5436                fidl::encoding::DefaultFuchsiaResourceDialect,
5437                0x4d12e10e946b43e4,
5438            >(_buf?)?;
5439            Ok(_response.map(|x| x.socket))
5440        }
5441        self.client.send_query_and_decode::<
5442            HostVsockEndpointConnectRequest,
5443            HostVsockEndpointConnectResult,
5444        >(
5445            (guest_port,),
5446            0x4d12e10e946b43e4,
5447            fidl::encoding::DynamicFlags::empty(),
5448            _decode,
5449        )
5450    }
5451}
5452
5453pub struct HostVsockEndpointEventStream {
5454    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5455}
5456
5457impl std::marker::Unpin for HostVsockEndpointEventStream {}
5458
5459impl futures::stream::FusedStream for HostVsockEndpointEventStream {
5460    fn is_terminated(&self) -> bool {
5461        self.event_receiver.is_terminated()
5462    }
5463}
5464
5465impl futures::Stream for HostVsockEndpointEventStream {
5466    type Item = Result<HostVsockEndpointEvent, fidl::Error>;
5467
5468    fn poll_next(
5469        mut self: std::pin::Pin<&mut Self>,
5470        cx: &mut std::task::Context<'_>,
5471    ) -> std::task::Poll<Option<Self::Item>> {
5472        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5473            &mut self.event_receiver,
5474            cx
5475        )?) {
5476            Some(buf) => std::task::Poll::Ready(Some(HostVsockEndpointEvent::decode(buf))),
5477            None => std::task::Poll::Ready(None),
5478        }
5479    }
5480}
5481
5482#[derive(Debug)]
5483pub enum HostVsockEndpointEvent {}
5484
5485impl HostVsockEndpointEvent {
5486    /// Decodes a message buffer as a [`HostVsockEndpointEvent`].
5487    fn decode(
5488        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5489    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5490        let (bytes, _handles) = buf.split_mut();
5491        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5492        debug_assert_eq!(tx_header.tx_id, 0);
5493        match tx_header.ordinal {
5494            _ => Err(fidl::Error::UnknownOrdinal {
5495                ordinal: tx_header.ordinal,
5496                protocol_name:
5497                    <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5498            }),
5499        }
5500    }
5501}
5502
5503/// A Stream of incoming requests for fuchsia.virtualization/HostVsockEndpoint.
5504pub struct HostVsockEndpointRequestStream {
5505    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5506    is_terminated: bool,
5507}
5508
5509impl std::marker::Unpin for HostVsockEndpointRequestStream {}
5510
5511impl futures::stream::FusedStream for HostVsockEndpointRequestStream {
5512    fn is_terminated(&self) -> bool {
5513        self.is_terminated
5514    }
5515}
5516
5517impl fidl::endpoints::RequestStream for HostVsockEndpointRequestStream {
5518    type Protocol = HostVsockEndpointMarker;
5519    type ControlHandle = HostVsockEndpointControlHandle;
5520
5521    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5522        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5523    }
5524
5525    fn control_handle(&self) -> Self::ControlHandle {
5526        HostVsockEndpointControlHandle { inner: self.inner.clone() }
5527    }
5528
5529    fn into_inner(
5530        self,
5531    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5532    {
5533        (self.inner, self.is_terminated)
5534    }
5535
5536    fn from_inner(
5537        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5538        is_terminated: bool,
5539    ) -> Self {
5540        Self { inner, is_terminated }
5541    }
5542}
5543
5544impl futures::Stream for HostVsockEndpointRequestStream {
5545    type Item = Result<HostVsockEndpointRequest, fidl::Error>;
5546
5547    fn poll_next(
5548        mut self: std::pin::Pin<&mut Self>,
5549        cx: &mut std::task::Context<'_>,
5550    ) -> std::task::Poll<Option<Self::Item>> {
5551        let this = &mut *self;
5552        if this.inner.check_shutdown(cx) {
5553            this.is_terminated = true;
5554            return std::task::Poll::Ready(None);
5555        }
5556        if this.is_terminated {
5557            panic!("polled HostVsockEndpointRequestStream after completion");
5558        }
5559        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5560            |bytes, handles| {
5561                match this.inner.channel().read_etc(cx, bytes, handles) {
5562                    std::task::Poll::Ready(Ok(())) => {}
5563                    std::task::Poll::Pending => return std::task::Poll::Pending,
5564                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5565                        this.is_terminated = true;
5566                        return std::task::Poll::Ready(None);
5567                    }
5568                    std::task::Poll::Ready(Err(e)) => {
5569                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5570                            e.into(),
5571                        ))))
5572                    }
5573                }
5574
5575                // A message has been received from the channel
5576                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5577
5578                std::task::Poll::Ready(Some(match header.ordinal {
5579                    0xfd88f3b4767f2c7 => {
5580                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5581                        let mut req = fidl::new_empty!(
5582                            Listener,
5583                            fidl::encoding::DefaultFuchsiaResourceDialect
5584                        );
5585                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Listener>(&header, _body_bytes, handles, &mut req)?;
5586                        let control_handle =
5587                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5588                        Ok(HostVsockEndpointRequest::Listen {
5589                            port: req.port,
5590                            acceptor: req.acceptor,
5591
5592                            responder: HostVsockEndpointListenResponder {
5593                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5594                                tx_id: header.tx_id,
5595                            },
5596                        })
5597                    }
5598                    0x4d12e10e946b43e4 => {
5599                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5600                        let mut req = fidl::new_empty!(
5601                            HostVsockEndpointConnectRequest,
5602                            fidl::encoding::DefaultFuchsiaResourceDialect
5603                        );
5604                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockEndpointConnectRequest>(&header, _body_bytes, handles, &mut req)?;
5605                        let control_handle =
5606                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5607                        Ok(HostVsockEndpointRequest::Connect {
5608                            guest_port: req.guest_port,
5609
5610                            responder: HostVsockEndpointConnectResponder {
5611                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5612                                tx_id: header.tx_id,
5613                            },
5614                        })
5615                    }
5616                    _ => Err(fidl::Error::UnknownOrdinal {
5617                        ordinal: header.ordinal,
5618                        protocol_name:
5619                            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5620                    }),
5621                }))
5622            },
5623        )
5624    }
5625}
5626
5627/// Exposed by a host to provide the ability for listeners to be multiplexed by
5628/// port and to manage dynamic port allocation for outbound connections.
5629#[derive(Debug)]
5630pub enum HostVsockEndpointRequest {
5631    /// Instructs the device to listen for guest initiated connections to a given port by
5632    /// using `acceptor` when the guest creates a connection.
5633    ///
5634    /// Possible errors:
5635    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5636    Listen {
5637        port: u32,
5638        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5639        responder: HostVsockEndpointListenResponder,
5640    },
5641    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5642    /// ephemeral host port.
5643    ///
5644    /// Possible errors:
5645    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5646    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5647    ///
5648    /// Other errors are related to socket creation, see
5649    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5650    Connect { guest_port: u32, responder: HostVsockEndpointConnectResponder },
5651}
5652
5653impl HostVsockEndpointRequest {
5654    #[allow(irrefutable_let_patterns)]
5655    pub fn into_listen(
5656        self,
5657    ) -> Option<(
5658        u32,
5659        fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5660        HostVsockEndpointListenResponder,
5661    )> {
5662        if let HostVsockEndpointRequest::Listen { port, acceptor, responder } = self {
5663            Some((port, acceptor, responder))
5664        } else {
5665            None
5666        }
5667    }
5668
5669    #[allow(irrefutable_let_patterns)]
5670    pub fn into_connect(self) -> Option<(u32, HostVsockEndpointConnectResponder)> {
5671        if let HostVsockEndpointRequest::Connect { guest_port, responder } = self {
5672            Some((guest_port, responder))
5673        } else {
5674            None
5675        }
5676    }
5677
5678    /// Name of the method defined in FIDL
5679    pub fn method_name(&self) -> &'static str {
5680        match *self {
5681            HostVsockEndpointRequest::Listen { .. } => "listen",
5682            HostVsockEndpointRequest::Connect { .. } => "connect",
5683        }
5684    }
5685}
5686
5687#[derive(Debug, Clone)]
5688pub struct HostVsockEndpointControlHandle {
5689    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5690}
5691
5692impl fidl::endpoints::ControlHandle for HostVsockEndpointControlHandle {
5693    fn shutdown(&self) {
5694        self.inner.shutdown()
5695    }
5696    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5697        self.inner.shutdown_with_epitaph(status)
5698    }
5699
5700    fn is_closed(&self) -> bool {
5701        self.inner.channel().is_closed()
5702    }
5703    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5704        self.inner.channel().on_closed()
5705    }
5706
5707    #[cfg(target_os = "fuchsia")]
5708    fn signal_peer(
5709        &self,
5710        clear_mask: zx::Signals,
5711        set_mask: zx::Signals,
5712    ) -> Result<(), zx_status::Status> {
5713        use fidl::Peered;
5714        self.inner.channel().signal_peer(clear_mask, set_mask)
5715    }
5716}
5717
5718impl HostVsockEndpointControlHandle {}
5719
5720#[must_use = "FIDL methods require a response to be sent"]
5721#[derive(Debug)]
5722pub struct HostVsockEndpointListenResponder {
5723    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5724    tx_id: u32,
5725}
5726
5727/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5728/// if the responder is dropped without sending a response, so that the client
5729/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5730impl std::ops::Drop for HostVsockEndpointListenResponder {
5731    fn drop(&mut self) {
5732        self.control_handle.shutdown();
5733        // Safety: drops once, never accessed again
5734        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5735    }
5736}
5737
5738impl fidl::endpoints::Responder for HostVsockEndpointListenResponder {
5739    type ControlHandle = HostVsockEndpointControlHandle;
5740
5741    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5742        &self.control_handle
5743    }
5744
5745    fn drop_without_shutdown(mut self) {
5746        // Safety: drops once, never accessed again due to mem::forget
5747        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5748        // Prevent Drop from running (which would shut down the channel)
5749        std::mem::forget(self);
5750    }
5751}
5752
5753impl HostVsockEndpointListenResponder {
5754    /// Sends a response to the FIDL transaction.
5755    ///
5756    /// Sets the channel to shutdown if an error occurs.
5757    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5758        let _result = self.send_raw(result);
5759        if _result.is_err() {
5760            self.control_handle.shutdown();
5761        }
5762        self.drop_without_shutdown();
5763        _result
5764    }
5765
5766    /// Similar to "send" but does not shutdown the channel if an error occurs.
5767    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5768        let _result = self.send_raw(result);
5769        self.drop_without_shutdown();
5770        _result
5771    }
5772
5773    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5774        self.control_handle
5775            .inner
5776            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5777                result,
5778                self.tx_id,
5779                0xfd88f3b4767f2c7,
5780                fidl::encoding::DynamicFlags::empty(),
5781            )
5782    }
5783}
5784
5785#[must_use = "FIDL methods require a response to be sent"]
5786#[derive(Debug)]
5787pub struct HostVsockEndpointConnectResponder {
5788    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5789    tx_id: u32,
5790}
5791
5792/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5793/// if the responder is dropped without sending a response, so that the client
5794/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5795impl std::ops::Drop for HostVsockEndpointConnectResponder {
5796    fn drop(&mut self) {
5797        self.control_handle.shutdown();
5798        // Safety: drops once, never accessed again
5799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5800    }
5801}
5802
5803impl fidl::endpoints::Responder for HostVsockEndpointConnectResponder {
5804    type ControlHandle = HostVsockEndpointControlHandle;
5805
5806    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5807        &self.control_handle
5808    }
5809
5810    fn drop_without_shutdown(mut self) {
5811        // Safety: drops once, never accessed again due to mem::forget
5812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5813        // Prevent Drop from running (which would shut down the channel)
5814        std::mem::forget(self);
5815    }
5816}
5817
5818impl HostVsockEndpointConnectResponder {
5819    /// Sends a response to the FIDL transaction.
5820    ///
5821    /// Sets the channel to shutdown if an error occurs.
5822    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5823        let _result = self.send_raw(result);
5824        if _result.is_err() {
5825            self.control_handle.shutdown();
5826        }
5827        self.drop_without_shutdown();
5828        _result
5829    }
5830
5831    /// Similar to "send" but does not shutdown the channel if an error occurs.
5832    pub fn send_no_shutdown_on_err(
5833        self,
5834        mut result: Result<fidl::Socket, i32>,
5835    ) -> Result<(), fidl::Error> {
5836        let _result = self.send_raw(result);
5837        self.drop_without_shutdown();
5838        _result
5839    }
5840
5841    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5842        self.control_handle
5843            .inner
5844            .send::<fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>>(
5845                result.map(|socket| (socket,)),
5846                self.tx_id,
5847                0x4d12e10e946b43e4,
5848                fidl::encoding::DynamicFlags::empty(),
5849            )
5850    }
5851}
5852
5853#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5854pub struct LinuxManagerMarker;
5855
5856impl fidl::endpoints::ProtocolMarker for LinuxManagerMarker {
5857    type Proxy = LinuxManagerProxy;
5858    type RequestStream = LinuxManagerRequestStream;
5859    #[cfg(target_os = "fuchsia")]
5860    type SynchronousProxy = LinuxManagerSynchronousProxy;
5861
5862    const DEBUG_NAME: &'static str = "fuchsia.virtualization.LinuxManager";
5863}
5864impl fidl::endpoints::DiscoverableProtocolMarker for LinuxManagerMarker {}
5865pub type LinuxManagerStartAndGetLinuxGuestInfoResult = Result<LinuxGuestInfo, i32>;
5866pub type LinuxManagerWipeDataResult = Result<(), i32>;
5867
5868pub trait LinuxManagerProxyInterface: Send + Sync {
5869    type StartAndGetLinuxGuestInfoResponseFut: std::future::Future<
5870            Output = Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error>,
5871        > + Send;
5872    fn r#start_and_get_linux_guest_info(
5873        &self,
5874        label: &str,
5875    ) -> Self::StartAndGetLinuxGuestInfoResponseFut;
5876    type WipeDataResponseFut: std::future::Future<Output = Result<LinuxManagerWipeDataResult, fidl::Error>>
5877        + Send;
5878    fn r#wipe_data(&self) -> Self::WipeDataResponseFut;
5879    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error>;
5880}
5881#[derive(Debug)]
5882#[cfg(target_os = "fuchsia")]
5883pub struct LinuxManagerSynchronousProxy {
5884    client: fidl::client::sync::Client,
5885}
5886
5887#[cfg(target_os = "fuchsia")]
5888impl fidl::endpoints::SynchronousProxy for LinuxManagerSynchronousProxy {
5889    type Proxy = LinuxManagerProxy;
5890    type Protocol = LinuxManagerMarker;
5891
5892    fn from_channel(inner: fidl::Channel) -> Self {
5893        Self::new(inner)
5894    }
5895
5896    fn into_channel(self) -> fidl::Channel {
5897        self.client.into_channel()
5898    }
5899
5900    fn as_channel(&self) -> &fidl::Channel {
5901        self.client.as_channel()
5902    }
5903}
5904
5905#[cfg(target_os = "fuchsia")]
5906impl LinuxManagerSynchronousProxy {
5907    pub fn new(channel: fidl::Channel) -> Self {
5908        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5909        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5910    }
5911
5912    pub fn into_channel(self) -> fidl::Channel {
5913        self.client.into_channel()
5914    }
5915
5916    /// Waits until an event arrives and returns it. It is safe for other
5917    /// threads to make concurrent requests while waiting for an event.
5918    pub fn wait_for_event(
5919        &self,
5920        deadline: zx::MonotonicInstant,
5921    ) -> Result<LinuxManagerEvent, fidl::Error> {
5922        LinuxManagerEvent::decode(self.client.wait_for_event(deadline)?)
5923    }
5924
5925    /// Get Linux guest environment info.
5926    ///
5927    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
5928    pub fn r#start_and_get_linux_guest_info(
5929        &self,
5930        mut label: &str,
5931        ___deadline: zx::MonotonicInstant,
5932    ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
5933        let _response = self.client.send_query::<
5934            LinuxManagerStartAndGetLinuxGuestInfoRequest,
5935            fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
5936        >(
5937            (label,),
5938            0x11809ced100a2bea,
5939            fidl::encoding::DynamicFlags::empty(),
5940            ___deadline,
5941        )?;
5942        Ok(_response.map(|x| x.info))
5943    }
5944
5945    /// Clears the stateful data. This includes any installed containers and any user data
5946    /// they may contain.
5947    ///
5948    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
5949    /// Returns ZX_ERR_IO if there was an IO failure while performing the
5950    /// operation.
5951    pub fn r#wipe_data(
5952        &self,
5953        ___deadline: zx::MonotonicInstant,
5954    ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
5955        let _response = self.client.send_query::<
5956            fidl::encoding::EmptyPayload,
5957            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5958        >(
5959            (),
5960            0x732c69394548a76a,
5961            fidl::encoding::DynamicFlags::empty(),
5962            ___deadline,
5963        )?;
5964        Ok(_response.map(|x| x))
5965    }
5966
5967    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
5968    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
5969    /// the epitaph) before attempting to launch another guest.
5970    ///
5971    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
5972    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
5973    /// a component crash).
5974    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
5975        self.client.send::<fidl::encoding::EmptyPayload>(
5976            (),
5977            0x5dab12b50bc9909d,
5978            fidl::encoding::DynamicFlags::empty(),
5979        )
5980    }
5981}
5982
5983#[derive(Debug, Clone)]
5984pub struct LinuxManagerProxy {
5985    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5986}
5987
5988impl fidl::endpoints::Proxy for LinuxManagerProxy {
5989    type Protocol = LinuxManagerMarker;
5990
5991    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5992        Self::new(inner)
5993    }
5994
5995    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5996        self.client.into_channel().map_err(|client| Self { client })
5997    }
5998
5999    fn as_channel(&self) -> &::fidl::AsyncChannel {
6000        self.client.as_channel()
6001    }
6002}
6003
6004impl LinuxManagerProxy {
6005    /// Create a new Proxy for fuchsia.virtualization/LinuxManager.
6006    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6007        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6008        Self { client: fidl::client::Client::new(channel, protocol_name) }
6009    }
6010
6011    /// Get a Stream of events from the remote end of the protocol.
6012    ///
6013    /// # Panics
6014    ///
6015    /// Panics if the event stream was already taken.
6016    pub fn take_event_stream(&self) -> LinuxManagerEventStream {
6017        LinuxManagerEventStream { event_receiver: self.client.take_event_receiver() }
6018    }
6019
6020    /// Get Linux guest environment info.
6021    ///
6022    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6023    pub fn r#start_and_get_linux_guest_info(
6024        &self,
6025        mut label: &str,
6026    ) -> fidl::client::QueryResponseFut<
6027        LinuxManagerStartAndGetLinuxGuestInfoResult,
6028        fidl::encoding::DefaultFuchsiaResourceDialect,
6029    > {
6030        LinuxManagerProxyInterface::r#start_and_get_linux_guest_info(self, label)
6031    }
6032
6033    /// Clears the stateful data. This includes any installed containers and any user data
6034    /// they may contain.
6035    ///
6036    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6037    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6038    /// operation.
6039    pub fn r#wipe_data(
6040        &self,
6041    ) -> fidl::client::QueryResponseFut<
6042        LinuxManagerWipeDataResult,
6043        fidl::encoding::DefaultFuchsiaResourceDialect,
6044    > {
6045        LinuxManagerProxyInterface::r#wipe_data(self)
6046    }
6047
6048    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6049    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6050    /// the epitaph) before attempting to launch another guest.
6051    ///
6052    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6053    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6054    /// a component crash).
6055    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6056        LinuxManagerProxyInterface::r#graceful_shutdown(self)
6057    }
6058}
6059
6060impl LinuxManagerProxyInterface for LinuxManagerProxy {
6061    type StartAndGetLinuxGuestInfoResponseFut = fidl::client::QueryResponseFut<
6062        LinuxManagerStartAndGetLinuxGuestInfoResult,
6063        fidl::encoding::DefaultFuchsiaResourceDialect,
6064    >;
6065    fn r#start_and_get_linux_guest_info(
6066        &self,
6067        mut label: &str,
6068    ) -> Self::StartAndGetLinuxGuestInfoResponseFut {
6069        fn _decode(
6070            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6071        ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6072            let _response = fidl::client::decode_transaction_body::<
6073                fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6074                fidl::encoding::DefaultFuchsiaResourceDialect,
6075                0x11809ced100a2bea,
6076            >(_buf?)?;
6077            Ok(_response.map(|x| x.info))
6078        }
6079        self.client.send_query_and_decode::<
6080            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6081            LinuxManagerStartAndGetLinuxGuestInfoResult,
6082        >(
6083            (label,),
6084            0x11809ced100a2bea,
6085            fidl::encoding::DynamicFlags::empty(),
6086            _decode,
6087        )
6088    }
6089
6090    type WipeDataResponseFut = fidl::client::QueryResponseFut<
6091        LinuxManagerWipeDataResult,
6092        fidl::encoding::DefaultFuchsiaResourceDialect,
6093    >;
6094    fn r#wipe_data(&self) -> Self::WipeDataResponseFut {
6095        fn _decode(
6096            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6097        ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6098            let _response = fidl::client::decode_transaction_body::<
6099                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6100                fidl::encoding::DefaultFuchsiaResourceDialect,
6101                0x732c69394548a76a,
6102            >(_buf?)?;
6103            Ok(_response.map(|x| x))
6104        }
6105        self.client
6106            .send_query_and_decode::<fidl::encoding::EmptyPayload, LinuxManagerWipeDataResult>(
6107                (),
6108                0x732c69394548a76a,
6109                fidl::encoding::DynamicFlags::empty(),
6110                _decode,
6111            )
6112    }
6113
6114    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6115        self.client.send::<fidl::encoding::EmptyPayload>(
6116            (),
6117            0x5dab12b50bc9909d,
6118            fidl::encoding::DynamicFlags::empty(),
6119        )
6120    }
6121}
6122
6123pub struct LinuxManagerEventStream {
6124    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6125}
6126
6127impl std::marker::Unpin for LinuxManagerEventStream {}
6128
6129impl futures::stream::FusedStream for LinuxManagerEventStream {
6130    fn is_terminated(&self) -> bool {
6131        self.event_receiver.is_terminated()
6132    }
6133}
6134
6135impl futures::Stream for LinuxManagerEventStream {
6136    type Item = Result<LinuxManagerEvent, fidl::Error>;
6137
6138    fn poll_next(
6139        mut self: std::pin::Pin<&mut Self>,
6140        cx: &mut std::task::Context<'_>,
6141    ) -> std::task::Poll<Option<Self::Item>> {
6142        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6143            &mut self.event_receiver,
6144            cx
6145        )?) {
6146            Some(buf) => std::task::Poll::Ready(Some(LinuxManagerEvent::decode(buf))),
6147            None => std::task::Poll::Ready(None),
6148        }
6149    }
6150}
6151
6152#[derive(Debug)]
6153pub enum LinuxManagerEvent {
6154    OnGuestInfoChanged { label: String, info: LinuxGuestInfo },
6155}
6156
6157impl LinuxManagerEvent {
6158    #[allow(irrefutable_let_patterns)]
6159    pub fn into_on_guest_info_changed(self) -> Option<(String, LinuxGuestInfo)> {
6160        if let LinuxManagerEvent::OnGuestInfoChanged { label, info } = self {
6161            Some((label, info))
6162        } else {
6163            None
6164        }
6165    }
6166
6167    /// Decodes a message buffer as a [`LinuxManagerEvent`].
6168    fn decode(
6169        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6170    ) -> Result<LinuxManagerEvent, fidl::Error> {
6171        let (bytes, _handles) = buf.split_mut();
6172        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6173        debug_assert_eq!(tx_header.tx_id, 0);
6174        match tx_header.ordinal {
6175            0x30a9be4c43d6a2d6 => {
6176                let mut out = fidl::new_empty!(
6177                    LinuxManagerOnGuestInfoChangedRequest,
6178                    fidl::encoding::DefaultFuchsiaResourceDialect
6179                );
6180                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerOnGuestInfoChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6181                Ok((LinuxManagerEvent::OnGuestInfoChanged { label: out.label, info: out.info }))
6182            }
6183            _ => Err(fidl::Error::UnknownOrdinal {
6184                ordinal: tx_header.ordinal,
6185                protocol_name: <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6186            }),
6187        }
6188    }
6189}
6190
6191/// A Stream of incoming requests for fuchsia.virtualization/LinuxManager.
6192pub struct LinuxManagerRequestStream {
6193    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6194    is_terminated: bool,
6195}
6196
6197impl std::marker::Unpin for LinuxManagerRequestStream {}
6198
6199impl futures::stream::FusedStream for LinuxManagerRequestStream {
6200    fn is_terminated(&self) -> bool {
6201        self.is_terminated
6202    }
6203}
6204
6205impl fidl::endpoints::RequestStream for LinuxManagerRequestStream {
6206    type Protocol = LinuxManagerMarker;
6207    type ControlHandle = LinuxManagerControlHandle;
6208
6209    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6210        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6211    }
6212
6213    fn control_handle(&self) -> Self::ControlHandle {
6214        LinuxManagerControlHandle { inner: self.inner.clone() }
6215    }
6216
6217    fn into_inner(
6218        self,
6219    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6220    {
6221        (self.inner, self.is_terminated)
6222    }
6223
6224    fn from_inner(
6225        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6226        is_terminated: bool,
6227    ) -> Self {
6228        Self { inner, is_terminated }
6229    }
6230}
6231
6232impl futures::Stream for LinuxManagerRequestStream {
6233    type Item = Result<LinuxManagerRequest, fidl::Error>;
6234
6235    fn poll_next(
6236        mut self: std::pin::Pin<&mut Self>,
6237        cx: &mut std::task::Context<'_>,
6238    ) -> std::task::Poll<Option<Self::Item>> {
6239        let this = &mut *self;
6240        if this.inner.check_shutdown(cx) {
6241            this.is_terminated = true;
6242            return std::task::Poll::Ready(None);
6243        }
6244        if this.is_terminated {
6245            panic!("polled LinuxManagerRequestStream after completion");
6246        }
6247        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6248            |bytes, handles| {
6249                match this.inner.channel().read_etc(cx, bytes, handles) {
6250                    std::task::Poll::Ready(Ok(())) => {}
6251                    std::task::Poll::Pending => return std::task::Poll::Pending,
6252                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6253                        this.is_terminated = true;
6254                        return std::task::Poll::Ready(None);
6255                    }
6256                    std::task::Poll::Ready(Err(e)) => {
6257                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6258                            e.into(),
6259                        ))))
6260                    }
6261                }
6262
6263                // A message has been received from the channel
6264                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6265
6266                std::task::Poll::Ready(Some(match header.ordinal {
6267                    0x11809ced100a2bea => {
6268                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6269                        let mut req = fidl::new_empty!(
6270                            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6271                            fidl::encoding::DefaultFuchsiaResourceDialect
6272                        );
6273                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerStartAndGetLinuxGuestInfoRequest>(&header, _body_bytes, handles, &mut req)?;
6274                        let control_handle =
6275                            LinuxManagerControlHandle { inner: this.inner.clone() };
6276                        Ok(LinuxManagerRequest::StartAndGetLinuxGuestInfo {
6277                            label: req.label,
6278
6279                            responder: LinuxManagerStartAndGetLinuxGuestInfoResponder {
6280                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6281                                tx_id: header.tx_id,
6282                            },
6283                        })
6284                    }
6285                    0x732c69394548a76a => {
6286                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6287                        let mut req = fidl::new_empty!(
6288                            fidl::encoding::EmptyPayload,
6289                            fidl::encoding::DefaultFuchsiaResourceDialect
6290                        );
6291                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6292                        let control_handle =
6293                            LinuxManagerControlHandle { inner: this.inner.clone() };
6294                        Ok(LinuxManagerRequest::WipeData {
6295                            responder: LinuxManagerWipeDataResponder {
6296                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6297                                tx_id: header.tx_id,
6298                            },
6299                        })
6300                    }
6301                    0x5dab12b50bc9909d => {
6302                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6303                        let mut req = fidl::new_empty!(
6304                            fidl::encoding::EmptyPayload,
6305                            fidl::encoding::DefaultFuchsiaResourceDialect
6306                        );
6307                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6308                        let control_handle =
6309                            LinuxManagerControlHandle { inner: this.inner.clone() };
6310                        Ok(LinuxManagerRequest::GracefulShutdown { control_handle })
6311                    }
6312                    _ => Err(fidl::Error::UnknownOrdinal {
6313                        ordinal: header.ordinal,
6314                        protocol_name:
6315                            <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6316                    }),
6317                }))
6318            },
6319        )
6320    }
6321}
6322
6323/// A `LinuxManager` provides access to the status of Linux guest instances.
6324#[derive(Debug)]
6325pub enum LinuxManagerRequest {
6326    /// Get Linux guest environment info.
6327    ///
6328    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6329    StartAndGetLinuxGuestInfo {
6330        label: String,
6331        responder: LinuxManagerStartAndGetLinuxGuestInfoResponder,
6332    },
6333    /// Clears the stateful data. This includes any installed containers and any user data
6334    /// they may contain.
6335    ///
6336    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6337    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6338    /// operation.
6339    WipeData { responder: LinuxManagerWipeDataResponder },
6340    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6341    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6342    /// the epitaph) before attempting to launch another guest.
6343    ///
6344    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6345    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6346    /// a component crash).
6347    GracefulShutdown { control_handle: LinuxManagerControlHandle },
6348}
6349
6350impl LinuxManagerRequest {
6351    #[allow(irrefutable_let_patterns)]
6352    pub fn into_start_and_get_linux_guest_info(
6353        self,
6354    ) -> Option<(String, LinuxManagerStartAndGetLinuxGuestInfoResponder)> {
6355        if let LinuxManagerRequest::StartAndGetLinuxGuestInfo { label, responder } = self {
6356            Some((label, responder))
6357        } else {
6358            None
6359        }
6360    }
6361
6362    #[allow(irrefutable_let_patterns)]
6363    pub fn into_wipe_data(self) -> Option<(LinuxManagerWipeDataResponder)> {
6364        if let LinuxManagerRequest::WipeData { responder } = self {
6365            Some((responder))
6366        } else {
6367            None
6368        }
6369    }
6370
6371    #[allow(irrefutable_let_patterns)]
6372    pub fn into_graceful_shutdown(self) -> Option<(LinuxManagerControlHandle)> {
6373        if let LinuxManagerRequest::GracefulShutdown { control_handle } = self {
6374            Some((control_handle))
6375        } else {
6376            None
6377        }
6378    }
6379
6380    /// Name of the method defined in FIDL
6381    pub fn method_name(&self) -> &'static str {
6382        match *self {
6383            LinuxManagerRequest::StartAndGetLinuxGuestInfo { .. } => {
6384                "start_and_get_linux_guest_info"
6385            }
6386            LinuxManagerRequest::WipeData { .. } => "wipe_data",
6387            LinuxManagerRequest::GracefulShutdown { .. } => "graceful_shutdown",
6388        }
6389    }
6390}
6391
6392#[derive(Debug, Clone)]
6393pub struct LinuxManagerControlHandle {
6394    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6395}
6396
6397impl fidl::endpoints::ControlHandle for LinuxManagerControlHandle {
6398    fn shutdown(&self) {
6399        self.inner.shutdown()
6400    }
6401    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6402        self.inner.shutdown_with_epitaph(status)
6403    }
6404
6405    fn is_closed(&self) -> bool {
6406        self.inner.channel().is_closed()
6407    }
6408    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6409        self.inner.channel().on_closed()
6410    }
6411
6412    #[cfg(target_os = "fuchsia")]
6413    fn signal_peer(
6414        &self,
6415        clear_mask: zx::Signals,
6416        set_mask: zx::Signals,
6417    ) -> Result<(), zx_status::Status> {
6418        use fidl::Peered;
6419        self.inner.channel().signal_peer(clear_mask, set_mask)
6420    }
6421}
6422
6423impl LinuxManagerControlHandle {
6424    pub fn send_on_guest_info_changed(
6425        &self,
6426        mut label: &str,
6427        mut info: &LinuxGuestInfo,
6428    ) -> Result<(), fidl::Error> {
6429        self.inner.send::<LinuxManagerOnGuestInfoChangedRequest>(
6430            (label, info),
6431            0,
6432            0x30a9be4c43d6a2d6,
6433            fidl::encoding::DynamicFlags::empty(),
6434        )
6435    }
6436}
6437
6438#[must_use = "FIDL methods require a response to be sent"]
6439#[derive(Debug)]
6440pub struct LinuxManagerStartAndGetLinuxGuestInfoResponder {
6441    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6442    tx_id: u32,
6443}
6444
6445/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6446/// if the responder is dropped without sending a response, so that the client
6447/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6448impl std::ops::Drop for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6449    fn drop(&mut self) {
6450        self.control_handle.shutdown();
6451        // Safety: drops once, never accessed again
6452        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6453    }
6454}
6455
6456impl fidl::endpoints::Responder for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6457    type ControlHandle = LinuxManagerControlHandle;
6458
6459    fn control_handle(&self) -> &LinuxManagerControlHandle {
6460        &self.control_handle
6461    }
6462
6463    fn drop_without_shutdown(mut self) {
6464        // Safety: drops once, never accessed again due to mem::forget
6465        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6466        // Prevent Drop from running (which would shut down the channel)
6467        std::mem::forget(self);
6468    }
6469}
6470
6471impl LinuxManagerStartAndGetLinuxGuestInfoResponder {
6472    /// Sends a response to the FIDL transaction.
6473    ///
6474    /// Sets the channel to shutdown if an error occurs.
6475    pub fn send(self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6476        let _result = self.send_raw(result);
6477        if _result.is_err() {
6478            self.control_handle.shutdown();
6479        }
6480        self.drop_without_shutdown();
6481        _result
6482    }
6483
6484    /// Similar to "send" but does not shutdown the channel if an error occurs.
6485    pub fn send_no_shutdown_on_err(
6486        self,
6487        mut result: Result<&LinuxGuestInfo, i32>,
6488    ) -> Result<(), fidl::Error> {
6489        let _result = self.send_raw(result);
6490        self.drop_without_shutdown();
6491        _result
6492    }
6493
6494    fn send_raw(&self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6495        self.control_handle.inner.send::<fidl::encoding::ResultType<
6496            LinuxManagerStartAndGetLinuxGuestInfoResponse,
6497            i32,
6498        >>(
6499            result.map(|info| (info,)),
6500            self.tx_id,
6501            0x11809ced100a2bea,
6502            fidl::encoding::DynamicFlags::empty(),
6503        )
6504    }
6505}
6506
6507#[must_use = "FIDL methods require a response to be sent"]
6508#[derive(Debug)]
6509pub struct LinuxManagerWipeDataResponder {
6510    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6511    tx_id: u32,
6512}
6513
6514/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6515/// if the responder is dropped without sending a response, so that the client
6516/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6517impl std::ops::Drop for LinuxManagerWipeDataResponder {
6518    fn drop(&mut self) {
6519        self.control_handle.shutdown();
6520        // Safety: drops once, never accessed again
6521        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6522    }
6523}
6524
6525impl fidl::endpoints::Responder for LinuxManagerWipeDataResponder {
6526    type ControlHandle = LinuxManagerControlHandle;
6527
6528    fn control_handle(&self) -> &LinuxManagerControlHandle {
6529        &self.control_handle
6530    }
6531
6532    fn drop_without_shutdown(mut self) {
6533        // Safety: drops once, never accessed again due to mem::forget
6534        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6535        // Prevent Drop from running (which would shut down the channel)
6536        std::mem::forget(self);
6537    }
6538}
6539
6540impl LinuxManagerWipeDataResponder {
6541    /// Sends a response to the FIDL transaction.
6542    ///
6543    /// Sets the channel to shutdown if an error occurs.
6544    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6545        let _result = self.send_raw(result);
6546        if _result.is_err() {
6547            self.control_handle.shutdown();
6548        }
6549        self.drop_without_shutdown();
6550        _result
6551    }
6552
6553    /// Similar to "send" but does not shutdown the channel if an error occurs.
6554    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6555        let _result = self.send_raw(result);
6556        self.drop_without_shutdown();
6557        _result
6558    }
6559
6560    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6561        self.control_handle
6562            .inner
6563            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6564                result,
6565                self.tx_id,
6566                0x732c69394548a76a,
6567                fidl::encoding::DynamicFlags::empty(),
6568            )
6569    }
6570}
6571
6572#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6573pub struct MemControllerMarker;
6574
6575impl fidl::endpoints::ProtocolMarker for MemControllerMarker {
6576    type Proxy = MemControllerProxy;
6577    type RequestStream = MemControllerRequestStream;
6578    #[cfg(target_os = "fuchsia")]
6579    type SynchronousProxy = MemControllerSynchronousProxy;
6580
6581    const DEBUG_NAME: &'static str = "fuchsia.virtualization.MemController";
6582}
6583impl fidl::endpoints::DiscoverableProtocolMarker for MemControllerMarker {}
6584
6585pub trait MemControllerProxyInterface: Send + Sync {
6586    type GetMemSizeResponseFut: std::future::Future<Output = Result<(u64, u64, u64, u64, u64), fidl::Error>>
6587        + Send;
6588    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut;
6589    fn r#request_size(&self, requested_size: u64) -> Result<(), fidl::Error>;
6590}
6591#[derive(Debug)]
6592#[cfg(target_os = "fuchsia")]
6593pub struct MemControllerSynchronousProxy {
6594    client: fidl::client::sync::Client,
6595}
6596
6597#[cfg(target_os = "fuchsia")]
6598impl fidl::endpoints::SynchronousProxy for MemControllerSynchronousProxy {
6599    type Proxy = MemControllerProxy;
6600    type Protocol = MemControllerMarker;
6601
6602    fn from_channel(inner: fidl::Channel) -> Self {
6603        Self::new(inner)
6604    }
6605
6606    fn into_channel(self) -> fidl::Channel {
6607        self.client.into_channel()
6608    }
6609
6610    fn as_channel(&self) -> &fidl::Channel {
6611        self.client.as_channel()
6612    }
6613}
6614
6615#[cfg(target_os = "fuchsia")]
6616impl MemControllerSynchronousProxy {
6617    pub fn new(channel: fidl::Channel) -> Self {
6618        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6619        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6620    }
6621
6622    pub fn into_channel(self) -> fidl::Channel {
6623        self.client.into_channel()
6624    }
6625
6626    /// Waits until an event arrives and returns it. It is safe for other
6627    /// threads to make concurrent requests while waiting for an event.
6628    pub fn wait_for_event(
6629        &self,
6630        deadline: zx::MonotonicInstant,
6631    ) -> Result<MemControllerEvent, fidl::Error> {
6632        MemControllerEvent::decode(self.client.wait_for_event(deadline)?)
6633    }
6634
6635    /// Get the configured region size, usable region size, plugged size and requestd size
6636    ///
6637    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6638    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6639    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6640    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6641    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6642    /// memory region.
6643    /// requested_size is the requested amount of plugged memory within the usable device-managed
6644    /// memory region.
6645    pub fn r#get_mem_size(
6646        &self,
6647        ___deadline: zx::MonotonicInstant,
6648    ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6649        let _response = self
6650            .client
6651            .send_query::<fidl::encoding::EmptyPayload, MemControllerGetMemSizeResponse>(
6652                (),
6653                0x6e9d496f9b66ea56,
6654                fidl::encoding::DynamicFlags::empty(),
6655                ___deadline,
6656            )?;
6657        Ok((
6658            _response.block_size,
6659            _response.region_size,
6660            _response.usable_region_size,
6661            _response.plugged_size,
6662            _response.requested_size,
6663        ))
6664    }
6665
6666    /// Update the requested size to plug or unplug memory
6667    ///
6668    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6669    /// configuration changed) by (un)plugging memory blocks.
6670    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6671        self.client.send::<MemControllerRequestSizeRequest>(
6672            (requested_size,),
6673            0x12f8e2cc21ee8102,
6674            fidl::encoding::DynamicFlags::empty(),
6675        )
6676    }
6677}
6678
6679#[derive(Debug, Clone)]
6680pub struct MemControllerProxy {
6681    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6682}
6683
6684impl fidl::endpoints::Proxy for MemControllerProxy {
6685    type Protocol = MemControllerMarker;
6686
6687    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6688        Self::new(inner)
6689    }
6690
6691    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6692        self.client.into_channel().map_err(|client| Self { client })
6693    }
6694
6695    fn as_channel(&self) -> &::fidl::AsyncChannel {
6696        self.client.as_channel()
6697    }
6698}
6699
6700impl MemControllerProxy {
6701    /// Create a new Proxy for fuchsia.virtualization/MemController.
6702    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6703        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6704        Self { client: fidl::client::Client::new(channel, protocol_name) }
6705    }
6706
6707    /// Get a Stream of events from the remote end of the protocol.
6708    ///
6709    /// # Panics
6710    ///
6711    /// Panics if the event stream was already taken.
6712    pub fn take_event_stream(&self) -> MemControllerEventStream {
6713        MemControllerEventStream { event_receiver: self.client.take_event_receiver() }
6714    }
6715
6716    /// Get the configured region size, usable region size, plugged size and requestd size
6717    ///
6718    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6719    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6720    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6721    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6722    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6723    /// memory region.
6724    /// requested_size is the requested amount of plugged memory within the usable device-managed
6725    /// memory region.
6726    pub fn r#get_mem_size(
6727        &self,
6728    ) -> fidl::client::QueryResponseFut<
6729        (u64, u64, u64, u64, u64),
6730        fidl::encoding::DefaultFuchsiaResourceDialect,
6731    > {
6732        MemControllerProxyInterface::r#get_mem_size(self)
6733    }
6734
6735    /// Update the requested size to plug or unplug memory
6736    ///
6737    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6738    /// configuration changed) by (un)plugging memory blocks.
6739    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6740        MemControllerProxyInterface::r#request_size(self, requested_size)
6741    }
6742}
6743
6744impl MemControllerProxyInterface for MemControllerProxy {
6745    type GetMemSizeResponseFut = fidl::client::QueryResponseFut<
6746        (u64, u64, u64, u64, u64),
6747        fidl::encoding::DefaultFuchsiaResourceDialect,
6748    >;
6749    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut {
6750        fn _decode(
6751            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6752        ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6753            let _response = fidl::client::decode_transaction_body::<
6754                MemControllerGetMemSizeResponse,
6755                fidl::encoding::DefaultFuchsiaResourceDialect,
6756                0x6e9d496f9b66ea56,
6757            >(_buf?)?;
6758            Ok((
6759                _response.block_size,
6760                _response.region_size,
6761                _response.usable_region_size,
6762                _response.plugged_size,
6763                _response.requested_size,
6764            ))
6765        }
6766        self.client
6767            .send_query_and_decode::<fidl::encoding::EmptyPayload, (u64, u64, u64, u64, u64)>(
6768                (),
6769                0x6e9d496f9b66ea56,
6770                fidl::encoding::DynamicFlags::empty(),
6771                _decode,
6772            )
6773    }
6774
6775    fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6776        self.client.send::<MemControllerRequestSizeRequest>(
6777            (requested_size,),
6778            0x12f8e2cc21ee8102,
6779            fidl::encoding::DynamicFlags::empty(),
6780        )
6781    }
6782}
6783
6784pub struct MemControllerEventStream {
6785    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6786}
6787
6788impl std::marker::Unpin for MemControllerEventStream {}
6789
6790impl futures::stream::FusedStream for MemControllerEventStream {
6791    fn is_terminated(&self) -> bool {
6792        self.event_receiver.is_terminated()
6793    }
6794}
6795
6796impl futures::Stream for MemControllerEventStream {
6797    type Item = Result<MemControllerEvent, fidl::Error>;
6798
6799    fn poll_next(
6800        mut self: std::pin::Pin<&mut Self>,
6801        cx: &mut std::task::Context<'_>,
6802    ) -> std::task::Poll<Option<Self::Item>> {
6803        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6804            &mut self.event_receiver,
6805            cx
6806        )?) {
6807            Some(buf) => std::task::Poll::Ready(Some(MemControllerEvent::decode(buf))),
6808            None => std::task::Poll::Ready(None),
6809        }
6810    }
6811}
6812
6813#[derive(Debug)]
6814pub enum MemControllerEvent {}
6815
6816impl MemControllerEvent {
6817    /// Decodes a message buffer as a [`MemControllerEvent`].
6818    fn decode(
6819        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6820    ) -> Result<MemControllerEvent, fidl::Error> {
6821        let (bytes, _handles) = buf.split_mut();
6822        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6823        debug_assert_eq!(tx_header.tx_id, 0);
6824        match tx_header.ordinal {
6825            _ => Err(fidl::Error::UnknownOrdinal {
6826                ordinal: tx_header.ordinal,
6827                protocol_name: <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6828            }),
6829        }
6830    }
6831}
6832
6833/// A Stream of incoming requests for fuchsia.virtualization/MemController.
6834pub struct MemControllerRequestStream {
6835    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6836    is_terminated: bool,
6837}
6838
6839impl std::marker::Unpin for MemControllerRequestStream {}
6840
6841impl futures::stream::FusedStream for MemControllerRequestStream {
6842    fn is_terminated(&self) -> bool {
6843        self.is_terminated
6844    }
6845}
6846
6847impl fidl::endpoints::RequestStream for MemControllerRequestStream {
6848    type Protocol = MemControllerMarker;
6849    type ControlHandle = MemControllerControlHandle;
6850
6851    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6852        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6853    }
6854
6855    fn control_handle(&self) -> Self::ControlHandle {
6856        MemControllerControlHandle { inner: self.inner.clone() }
6857    }
6858
6859    fn into_inner(
6860        self,
6861    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6862    {
6863        (self.inner, self.is_terminated)
6864    }
6865
6866    fn from_inner(
6867        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6868        is_terminated: bool,
6869    ) -> Self {
6870        Self { inner, is_terminated }
6871    }
6872}
6873
6874impl futures::Stream for MemControllerRequestStream {
6875    type Item = Result<MemControllerRequest, fidl::Error>;
6876
6877    fn poll_next(
6878        mut self: std::pin::Pin<&mut Self>,
6879        cx: &mut std::task::Context<'_>,
6880    ) -> std::task::Poll<Option<Self::Item>> {
6881        let this = &mut *self;
6882        if this.inner.check_shutdown(cx) {
6883            this.is_terminated = true;
6884            return std::task::Poll::Ready(None);
6885        }
6886        if this.is_terminated {
6887            panic!("polled MemControllerRequestStream after completion");
6888        }
6889        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6890            |bytes, handles| {
6891                match this.inner.channel().read_etc(cx, bytes, handles) {
6892                    std::task::Poll::Ready(Ok(())) => {}
6893                    std::task::Poll::Pending => return std::task::Poll::Pending,
6894                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6895                        this.is_terminated = true;
6896                        return std::task::Poll::Ready(None);
6897                    }
6898                    std::task::Poll::Ready(Err(e)) => {
6899                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6900                            e.into(),
6901                        ))))
6902                    }
6903                }
6904
6905                // A message has been received from the channel
6906                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6907
6908                std::task::Poll::Ready(Some(match header.ordinal {
6909                    0x6e9d496f9b66ea56 => {
6910                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6911                        let mut req = fidl::new_empty!(
6912                            fidl::encoding::EmptyPayload,
6913                            fidl::encoding::DefaultFuchsiaResourceDialect
6914                        );
6915                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6916                        let control_handle =
6917                            MemControllerControlHandle { inner: this.inner.clone() };
6918                        Ok(MemControllerRequest::GetMemSize {
6919                            responder: MemControllerGetMemSizeResponder {
6920                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6921                                tx_id: header.tx_id,
6922                            },
6923                        })
6924                    }
6925                    0x12f8e2cc21ee8102 => {
6926                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6927                        let mut req = fidl::new_empty!(
6928                            MemControllerRequestSizeRequest,
6929                            fidl::encoding::DefaultFuchsiaResourceDialect
6930                        );
6931                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MemControllerRequestSizeRequest>(&header, _body_bytes, handles, &mut req)?;
6932                        let control_handle =
6933                            MemControllerControlHandle { inner: this.inner.clone() };
6934                        Ok(MemControllerRequest::RequestSize {
6935                            requested_size: req.requested_size,
6936
6937                            control_handle,
6938                        })
6939                    }
6940                    _ => Err(fidl::Error::UnknownOrdinal {
6941                        ordinal: header.ordinal,
6942                        protocol_name:
6943                            <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6944                    }),
6945                }))
6946            },
6947        )
6948    }
6949}
6950
6951/// A `MemController` controls a guest's virtio-mem
6952#[derive(Debug)]
6953pub enum MemControllerRequest {
6954    /// Get the configured region size, usable region size, plugged size and requestd size
6955    ///
6956    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6957    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6958    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6959    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6960    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6961    /// memory region.
6962    /// requested_size is the requested amount of plugged memory within the usable device-managed
6963    /// memory region.
6964    GetMemSize { responder: MemControllerGetMemSizeResponder },
6965    /// Update the requested size to plug or unplug memory
6966    ///
6967    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6968    /// configuration changed) by (un)plugging memory blocks.
6969    RequestSize { requested_size: u64, control_handle: MemControllerControlHandle },
6970}
6971
6972impl MemControllerRequest {
6973    #[allow(irrefutable_let_patterns)]
6974    pub fn into_get_mem_size(self) -> Option<(MemControllerGetMemSizeResponder)> {
6975        if let MemControllerRequest::GetMemSize { responder } = self {
6976            Some((responder))
6977        } else {
6978            None
6979        }
6980    }
6981
6982    #[allow(irrefutable_let_patterns)]
6983    pub fn into_request_size(self) -> Option<(u64, MemControllerControlHandle)> {
6984        if let MemControllerRequest::RequestSize { requested_size, control_handle } = self {
6985            Some((requested_size, control_handle))
6986        } else {
6987            None
6988        }
6989    }
6990
6991    /// Name of the method defined in FIDL
6992    pub fn method_name(&self) -> &'static str {
6993        match *self {
6994            MemControllerRequest::GetMemSize { .. } => "get_mem_size",
6995            MemControllerRequest::RequestSize { .. } => "request_size",
6996        }
6997    }
6998}
6999
7000#[derive(Debug, Clone)]
7001pub struct MemControllerControlHandle {
7002    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7003}
7004
7005impl fidl::endpoints::ControlHandle for MemControllerControlHandle {
7006    fn shutdown(&self) {
7007        self.inner.shutdown()
7008    }
7009    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7010        self.inner.shutdown_with_epitaph(status)
7011    }
7012
7013    fn is_closed(&self) -> bool {
7014        self.inner.channel().is_closed()
7015    }
7016    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7017        self.inner.channel().on_closed()
7018    }
7019
7020    #[cfg(target_os = "fuchsia")]
7021    fn signal_peer(
7022        &self,
7023        clear_mask: zx::Signals,
7024        set_mask: zx::Signals,
7025    ) -> Result<(), zx_status::Status> {
7026        use fidl::Peered;
7027        self.inner.channel().signal_peer(clear_mask, set_mask)
7028    }
7029}
7030
7031impl MemControllerControlHandle {}
7032
7033#[must_use = "FIDL methods require a response to be sent"]
7034#[derive(Debug)]
7035pub struct MemControllerGetMemSizeResponder {
7036    control_handle: std::mem::ManuallyDrop<MemControllerControlHandle>,
7037    tx_id: u32,
7038}
7039
7040/// Set the the channel to be shutdown (see [`MemControllerControlHandle::shutdown`])
7041/// if the responder is dropped without sending a response, so that the client
7042/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7043impl std::ops::Drop for MemControllerGetMemSizeResponder {
7044    fn drop(&mut self) {
7045        self.control_handle.shutdown();
7046        // Safety: drops once, never accessed again
7047        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7048    }
7049}
7050
7051impl fidl::endpoints::Responder for MemControllerGetMemSizeResponder {
7052    type ControlHandle = MemControllerControlHandle;
7053
7054    fn control_handle(&self) -> &MemControllerControlHandle {
7055        &self.control_handle
7056    }
7057
7058    fn drop_without_shutdown(mut self) {
7059        // Safety: drops once, never accessed again due to mem::forget
7060        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7061        // Prevent Drop from running (which would shut down the channel)
7062        std::mem::forget(self);
7063    }
7064}
7065
7066impl MemControllerGetMemSizeResponder {
7067    /// Sends a response to the FIDL transaction.
7068    ///
7069    /// Sets the channel to shutdown if an error occurs.
7070    pub fn send(
7071        self,
7072        mut block_size: u64,
7073        mut region_size: u64,
7074        mut usable_region_size: u64,
7075        mut plugged_size: u64,
7076        mut requested_size: u64,
7077    ) -> Result<(), fidl::Error> {
7078        let _result = self.send_raw(
7079            block_size,
7080            region_size,
7081            usable_region_size,
7082            plugged_size,
7083            requested_size,
7084        );
7085        if _result.is_err() {
7086            self.control_handle.shutdown();
7087        }
7088        self.drop_without_shutdown();
7089        _result
7090    }
7091
7092    /// Similar to "send" but does not shutdown the channel if an error occurs.
7093    pub fn send_no_shutdown_on_err(
7094        self,
7095        mut block_size: u64,
7096        mut region_size: u64,
7097        mut usable_region_size: u64,
7098        mut plugged_size: u64,
7099        mut requested_size: u64,
7100    ) -> Result<(), fidl::Error> {
7101        let _result = self.send_raw(
7102            block_size,
7103            region_size,
7104            usable_region_size,
7105            plugged_size,
7106            requested_size,
7107        );
7108        self.drop_without_shutdown();
7109        _result
7110    }
7111
7112    fn send_raw(
7113        &self,
7114        mut block_size: u64,
7115        mut region_size: u64,
7116        mut usable_region_size: u64,
7117        mut plugged_size: u64,
7118        mut requested_size: u64,
7119    ) -> Result<(), fidl::Error> {
7120        self.control_handle.inner.send::<MemControllerGetMemSizeResponse>(
7121            (block_size, region_size, usable_region_size, plugged_size, requested_size),
7122            self.tx_id,
7123            0x6e9d496f9b66ea56,
7124            fidl::encoding::DynamicFlags::empty(),
7125        )
7126    }
7127}
7128
7129#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7130pub struct TerminaGuestManagerMarker;
7131
7132impl fidl::endpoints::ProtocolMarker for TerminaGuestManagerMarker {
7133    type Proxy = TerminaGuestManagerProxy;
7134    type RequestStream = TerminaGuestManagerRequestStream;
7135    #[cfg(target_os = "fuchsia")]
7136    type SynchronousProxy = TerminaGuestManagerSynchronousProxy;
7137
7138    const DEBUG_NAME: &'static str = "fuchsia.virtualization.TerminaGuestManager";
7139}
7140impl fidl::endpoints::DiscoverableProtocolMarker for TerminaGuestManagerMarker {}
7141
7142pub trait TerminaGuestManagerProxyInterface: Send + Sync {
7143    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
7144        + Send;
7145    fn r#launch(
7146        &self,
7147        guest_config: GuestConfig,
7148        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7149    ) -> Self::LaunchResponseFut;
7150    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7151    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
7152    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
7153        + Send;
7154    fn r#connect(
7155        &self,
7156        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7157    ) -> Self::ConnectResponseFut;
7158    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
7159    fn r#get_info(&self) -> Self::GetInfoResponseFut;
7160}
7161#[derive(Debug)]
7162#[cfg(target_os = "fuchsia")]
7163pub struct TerminaGuestManagerSynchronousProxy {
7164    client: fidl::client::sync::Client,
7165}
7166
7167#[cfg(target_os = "fuchsia")]
7168impl fidl::endpoints::SynchronousProxy for TerminaGuestManagerSynchronousProxy {
7169    type Proxy = TerminaGuestManagerProxy;
7170    type Protocol = TerminaGuestManagerMarker;
7171
7172    fn from_channel(inner: fidl::Channel) -> Self {
7173        Self::new(inner)
7174    }
7175
7176    fn into_channel(self) -> fidl::Channel {
7177        self.client.into_channel()
7178    }
7179
7180    fn as_channel(&self) -> &fidl::Channel {
7181        self.client.as_channel()
7182    }
7183}
7184
7185#[cfg(target_os = "fuchsia")]
7186impl TerminaGuestManagerSynchronousProxy {
7187    pub fn new(channel: fidl::Channel) -> Self {
7188        let protocol_name =
7189            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7190        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7191    }
7192
7193    pub fn into_channel(self) -> fidl::Channel {
7194        self.client.into_channel()
7195    }
7196
7197    /// Waits until an event arrives and returns it. It is safe for other
7198    /// threads to make concurrent requests while waiting for an event.
7199    pub fn wait_for_event(
7200        &self,
7201        deadline: zx::MonotonicInstant,
7202    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7203        TerminaGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
7204    }
7205
7206    /// Launch a new guest instance.
7207    ///
7208    /// Possible errors:
7209    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7210    ///         problems detected by the guest manager.
7211    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7212    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7213    ///         component logs for a more specific failure.
7214    pub fn r#launch(
7215        &self,
7216        mut guest_config: GuestConfig,
7217        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7218        ___deadline: zx::MonotonicInstant,
7219    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7220        let _response =
7221            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
7222                fidl::encoding::EmptyStruct,
7223                GuestManagerError,
7224            >>(
7225                (&mut guest_config, controller),
7226                0x394a2e29f750323e,
7227                fidl::encoding::DynamicFlags::empty(),
7228                ___deadline,
7229            )?;
7230        Ok(_response.map(|x| x))
7231    }
7232
7233    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7234    /// be used to launch another guest.
7235    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
7236        let _response =
7237            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
7238                (),
7239                0x3ad9a012982f872d,
7240                fidl::encoding::DynamicFlags::empty(),
7241                ___deadline,
7242            )?;
7243        Ok(_response)
7244    }
7245
7246    /// Connect to a currently running guest.
7247    ///
7248    /// Possible errors:
7249    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7250    ///         has launched before attempting to reconnect.
7251    pub fn r#connect(
7252        &self,
7253        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7254        ___deadline: zx::MonotonicInstant,
7255    ) -> Result<GuestManagerConnectResult, fidl::Error> {
7256        let _response =
7257            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
7258                fidl::encoding::EmptyStruct,
7259                GuestManagerError,
7260            >>(
7261                (controller,),
7262                0x4e489076e3bb15b4,
7263                fidl::encoding::DynamicFlags::empty(),
7264                ___deadline,
7265            )?;
7266        Ok(_response.map(|x| x))
7267    }
7268
7269    /// Query guest info
7270    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
7271        let _response =
7272            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
7273                (),
7274                0x76892614aea695dc,
7275                fidl::encoding::DynamicFlags::empty(),
7276                ___deadline,
7277            )?;
7278        Ok(_response.guest_info)
7279    }
7280}
7281
7282#[derive(Debug, Clone)]
7283pub struct TerminaGuestManagerProxy {
7284    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7285}
7286
7287impl fidl::endpoints::Proxy for TerminaGuestManagerProxy {
7288    type Protocol = TerminaGuestManagerMarker;
7289
7290    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7291        Self::new(inner)
7292    }
7293
7294    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7295        self.client.into_channel().map_err(|client| Self { client })
7296    }
7297
7298    fn as_channel(&self) -> &::fidl::AsyncChannel {
7299        self.client.as_channel()
7300    }
7301}
7302
7303impl TerminaGuestManagerProxy {
7304    /// Create a new Proxy for fuchsia.virtualization/TerminaGuestManager.
7305    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7306        let protocol_name =
7307            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7308        Self { client: fidl::client::Client::new(channel, protocol_name) }
7309    }
7310
7311    /// Get a Stream of events from the remote end of the protocol.
7312    ///
7313    /// # Panics
7314    ///
7315    /// Panics if the event stream was already taken.
7316    pub fn take_event_stream(&self) -> TerminaGuestManagerEventStream {
7317        TerminaGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
7318    }
7319
7320    /// Launch a new guest instance.
7321    ///
7322    /// Possible errors:
7323    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7324    ///         problems detected by the guest manager.
7325    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7326    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7327    ///         component logs for a more specific failure.
7328    pub fn r#launch(
7329        &self,
7330        mut guest_config: GuestConfig,
7331        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7332    ) -> fidl::client::QueryResponseFut<
7333        GuestManagerLaunchResult,
7334        fidl::encoding::DefaultFuchsiaResourceDialect,
7335    > {
7336        TerminaGuestManagerProxyInterface::r#launch(self, guest_config, controller)
7337    }
7338
7339    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7340    /// be used to launch another guest.
7341    pub fn r#force_shutdown(
7342        &self,
7343    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7344        TerminaGuestManagerProxyInterface::r#force_shutdown(self)
7345    }
7346
7347    /// Connect to a currently running guest.
7348    ///
7349    /// Possible errors:
7350    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7351    ///         has launched before attempting to reconnect.
7352    pub fn r#connect(
7353        &self,
7354        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7355    ) -> fidl::client::QueryResponseFut<
7356        GuestManagerConnectResult,
7357        fidl::encoding::DefaultFuchsiaResourceDialect,
7358    > {
7359        TerminaGuestManagerProxyInterface::r#connect(self, controller)
7360    }
7361
7362    /// Query guest info
7363    pub fn r#get_info(
7364        &self,
7365    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
7366    {
7367        TerminaGuestManagerProxyInterface::r#get_info(self)
7368    }
7369}
7370
7371impl TerminaGuestManagerProxyInterface for TerminaGuestManagerProxy {
7372    type LaunchResponseFut = fidl::client::QueryResponseFut<
7373        GuestManagerLaunchResult,
7374        fidl::encoding::DefaultFuchsiaResourceDialect,
7375    >;
7376    fn r#launch(
7377        &self,
7378        mut guest_config: GuestConfig,
7379        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7380    ) -> Self::LaunchResponseFut {
7381        fn _decode(
7382            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7383        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7384            let _response = fidl::client::decode_transaction_body::<
7385                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7386                fidl::encoding::DefaultFuchsiaResourceDialect,
7387                0x394a2e29f750323e,
7388            >(_buf?)?;
7389            Ok(_response.map(|x| x))
7390        }
7391        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
7392            (&mut guest_config, controller),
7393            0x394a2e29f750323e,
7394            fidl::encoding::DynamicFlags::empty(),
7395            _decode,
7396        )
7397    }
7398
7399    type ForceShutdownResponseFut =
7400        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7401    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
7402        fn _decode(
7403            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7404        ) -> Result<(), fidl::Error> {
7405            let _response = fidl::client::decode_transaction_body::<
7406                fidl::encoding::EmptyPayload,
7407                fidl::encoding::DefaultFuchsiaResourceDialect,
7408                0x3ad9a012982f872d,
7409            >(_buf?)?;
7410            Ok(_response)
7411        }
7412        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7413            (),
7414            0x3ad9a012982f872d,
7415            fidl::encoding::DynamicFlags::empty(),
7416            _decode,
7417        )
7418    }
7419
7420    type ConnectResponseFut = fidl::client::QueryResponseFut<
7421        GuestManagerConnectResult,
7422        fidl::encoding::DefaultFuchsiaResourceDialect,
7423    >;
7424    fn r#connect(
7425        &self,
7426        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7427    ) -> Self::ConnectResponseFut {
7428        fn _decode(
7429            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7430        ) -> Result<GuestManagerConnectResult, fidl::Error> {
7431            let _response = fidl::client::decode_transaction_body::<
7432                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7433                fidl::encoding::DefaultFuchsiaResourceDialect,
7434                0x4e489076e3bb15b4,
7435            >(_buf?)?;
7436            Ok(_response.map(|x| x))
7437        }
7438        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
7439            (controller,),
7440            0x4e489076e3bb15b4,
7441            fidl::encoding::DynamicFlags::empty(),
7442            _decode,
7443        )
7444    }
7445
7446    type GetInfoResponseFut =
7447        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
7448    fn r#get_info(&self) -> Self::GetInfoResponseFut {
7449        fn _decode(
7450            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7451        ) -> Result<GuestInfo, fidl::Error> {
7452            let _response = fidl::client::decode_transaction_body::<
7453                GuestManagerGetInfoResponse,
7454                fidl::encoding::DefaultFuchsiaResourceDialect,
7455                0x76892614aea695dc,
7456            >(_buf?)?;
7457            Ok(_response.guest_info)
7458        }
7459        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
7460            (),
7461            0x76892614aea695dc,
7462            fidl::encoding::DynamicFlags::empty(),
7463            _decode,
7464        )
7465    }
7466}
7467
7468pub struct TerminaGuestManagerEventStream {
7469    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7470}
7471
7472impl std::marker::Unpin for TerminaGuestManagerEventStream {}
7473
7474impl futures::stream::FusedStream for TerminaGuestManagerEventStream {
7475    fn is_terminated(&self) -> bool {
7476        self.event_receiver.is_terminated()
7477    }
7478}
7479
7480impl futures::Stream for TerminaGuestManagerEventStream {
7481    type Item = Result<TerminaGuestManagerEvent, fidl::Error>;
7482
7483    fn poll_next(
7484        mut self: std::pin::Pin<&mut Self>,
7485        cx: &mut std::task::Context<'_>,
7486    ) -> std::task::Poll<Option<Self::Item>> {
7487        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7488            &mut self.event_receiver,
7489            cx
7490        )?) {
7491            Some(buf) => std::task::Poll::Ready(Some(TerminaGuestManagerEvent::decode(buf))),
7492            None => std::task::Poll::Ready(None),
7493        }
7494    }
7495}
7496
7497#[derive(Debug)]
7498pub enum TerminaGuestManagerEvent {}
7499
7500impl TerminaGuestManagerEvent {
7501    /// Decodes a message buffer as a [`TerminaGuestManagerEvent`].
7502    fn decode(
7503        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7504    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7505        let (bytes, _handles) = buf.split_mut();
7506        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7507        debug_assert_eq!(tx_header.tx_id, 0);
7508        match tx_header.ordinal {
7509            _ => Err(fidl::Error::UnknownOrdinal {
7510                ordinal: tx_header.ordinal,
7511                protocol_name:
7512                    <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7513            }),
7514        }
7515    }
7516}
7517
7518/// A Stream of incoming requests for fuchsia.virtualization/TerminaGuestManager.
7519pub struct TerminaGuestManagerRequestStream {
7520    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7521    is_terminated: bool,
7522}
7523
7524impl std::marker::Unpin for TerminaGuestManagerRequestStream {}
7525
7526impl futures::stream::FusedStream for TerminaGuestManagerRequestStream {
7527    fn is_terminated(&self) -> bool {
7528        self.is_terminated
7529    }
7530}
7531
7532impl fidl::endpoints::RequestStream for TerminaGuestManagerRequestStream {
7533    type Protocol = TerminaGuestManagerMarker;
7534    type ControlHandle = TerminaGuestManagerControlHandle;
7535
7536    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7537        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7538    }
7539
7540    fn control_handle(&self) -> Self::ControlHandle {
7541        TerminaGuestManagerControlHandle { inner: self.inner.clone() }
7542    }
7543
7544    fn into_inner(
7545        self,
7546    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7547    {
7548        (self.inner, self.is_terminated)
7549    }
7550
7551    fn from_inner(
7552        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7553        is_terminated: bool,
7554    ) -> Self {
7555        Self { inner, is_terminated }
7556    }
7557}
7558
7559impl futures::Stream for TerminaGuestManagerRequestStream {
7560    type Item = Result<TerminaGuestManagerRequest, fidl::Error>;
7561
7562    fn poll_next(
7563        mut self: std::pin::Pin<&mut Self>,
7564        cx: &mut std::task::Context<'_>,
7565    ) -> std::task::Poll<Option<Self::Item>> {
7566        let this = &mut *self;
7567        if this.inner.check_shutdown(cx) {
7568            this.is_terminated = true;
7569            return std::task::Poll::Ready(None);
7570        }
7571        if this.is_terminated {
7572            panic!("polled TerminaGuestManagerRequestStream after completion");
7573        }
7574        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7575            |bytes, handles| {
7576                match this.inner.channel().read_etc(cx, bytes, handles) {
7577                    std::task::Poll::Ready(Ok(())) => {}
7578                    std::task::Poll::Pending => return std::task::Poll::Pending,
7579                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7580                        this.is_terminated = true;
7581                        return std::task::Poll::Ready(None);
7582                    }
7583                    std::task::Poll::Ready(Err(e)) => {
7584                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7585                            e.into(),
7586                        ))))
7587                    }
7588                }
7589
7590                // A message has been received from the channel
7591                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7592
7593                std::task::Poll::Ready(Some(match header.ordinal {
7594                0x394a2e29f750323e => {
7595                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7596                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7597                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
7598                    let control_handle = TerminaGuestManagerControlHandle {
7599                        inner: this.inner.clone(),
7600                    };
7601                    Ok(TerminaGuestManagerRequest::Launch {guest_config: req.guest_config,
7602controller: req.controller,
7603
7604                        responder: TerminaGuestManagerLaunchResponder {
7605                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7606                            tx_id: header.tx_id,
7607                        },
7608                    })
7609                }
7610                0x3ad9a012982f872d => {
7611                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7612                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7613                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7614                    let control_handle = TerminaGuestManagerControlHandle {
7615                        inner: this.inner.clone(),
7616                    };
7617                    Ok(TerminaGuestManagerRequest::ForceShutdown {
7618                        responder: TerminaGuestManagerForceShutdownResponder {
7619                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7620                            tx_id: header.tx_id,
7621                        },
7622                    })
7623                }
7624                0x4e489076e3bb15b4 => {
7625                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7626                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7627                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
7628                    let control_handle = TerminaGuestManagerControlHandle {
7629                        inner: this.inner.clone(),
7630                    };
7631                    Ok(TerminaGuestManagerRequest::Connect {controller: req.controller,
7632
7633                        responder: TerminaGuestManagerConnectResponder {
7634                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7635                            tx_id: header.tx_id,
7636                        },
7637                    })
7638                }
7639                0x76892614aea695dc => {
7640                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7641                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7642                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7643                    let control_handle = TerminaGuestManagerControlHandle {
7644                        inner: this.inner.clone(),
7645                    };
7646                    Ok(TerminaGuestManagerRequest::GetInfo {
7647                        responder: TerminaGuestManagerGetInfoResponder {
7648                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7649                            tx_id: header.tx_id,
7650                        },
7651                    })
7652                }
7653                _ => Err(fidl::Error::UnknownOrdinal {
7654                    ordinal: header.ordinal,
7655                    protocol_name: <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7656                }),
7657            }))
7658            },
7659        )
7660    }
7661}
7662
7663#[derive(Debug)]
7664pub enum TerminaGuestManagerRequest {
7665    /// Launch a new guest instance.
7666    ///
7667    /// Possible errors:
7668    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7669    ///         problems detected by the guest manager.
7670    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7671    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7672    ///         component logs for a more specific failure.
7673    Launch {
7674        guest_config: GuestConfig,
7675        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7676        responder: TerminaGuestManagerLaunchResponder,
7677    },
7678    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7679    /// be used to launch another guest.
7680    ForceShutdown { responder: TerminaGuestManagerForceShutdownResponder },
7681    /// Connect to a currently running guest.
7682    ///
7683    /// Possible errors:
7684    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7685    ///         has launched before attempting to reconnect.
7686    Connect {
7687        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7688        responder: TerminaGuestManagerConnectResponder,
7689    },
7690    /// Query guest info
7691    GetInfo { responder: TerminaGuestManagerGetInfoResponder },
7692}
7693
7694impl TerminaGuestManagerRequest {
7695    #[allow(irrefutable_let_patterns)]
7696    pub fn into_launch(
7697        self,
7698    ) -> Option<(
7699        GuestConfig,
7700        fidl::endpoints::ServerEnd<GuestMarker>,
7701        TerminaGuestManagerLaunchResponder,
7702    )> {
7703        if let TerminaGuestManagerRequest::Launch { guest_config, controller, responder } = self {
7704            Some((guest_config, controller, responder))
7705        } else {
7706            None
7707        }
7708    }
7709
7710    #[allow(irrefutable_let_patterns)]
7711    pub fn into_force_shutdown(self) -> Option<(TerminaGuestManagerForceShutdownResponder)> {
7712        if let TerminaGuestManagerRequest::ForceShutdown { responder } = self {
7713            Some((responder))
7714        } else {
7715            None
7716        }
7717    }
7718
7719    #[allow(irrefutable_let_patterns)]
7720    pub fn into_connect(
7721        self,
7722    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, TerminaGuestManagerConnectResponder)>
7723    {
7724        if let TerminaGuestManagerRequest::Connect { controller, responder } = self {
7725            Some((controller, responder))
7726        } else {
7727            None
7728        }
7729    }
7730
7731    #[allow(irrefutable_let_patterns)]
7732    pub fn into_get_info(self) -> Option<(TerminaGuestManagerGetInfoResponder)> {
7733        if let TerminaGuestManagerRequest::GetInfo { responder } = self {
7734            Some((responder))
7735        } else {
7736            None
7737        }
7738    }
7739
7740    /// Name of the method defined in FIDL
7741    pub fn method_name(&self) -> &'static str {
7742        match *self {
7743            TerminaGuestManagerRequest::Launch { .. } => "launch",
7744            TerminaGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
7745            TerminaGuestManagerRequest::Connect { .. } => "connect",
7746            TerminaGuestManagerRequest::GetInfo { .. } => "get_info",
7747        }
7748    }
7749}
7750
7751#[derive(Debug, Clone)]
7752pub struct TerminaGuestManagerControlHandle {
7753    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7754}
7755
7756impl fidl::endpoints::ControlHandle for TerminaGuestManagerControlHandle {
7757    fn shutdown(&self) {
7758        self.inner.shutdown()
7759    }
7760    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7761        self.inner.shutdown_with_epitaph(status)
7762    }
7763
7764    fn is_closed(&self) -> bool {
7765        self.inner.channel().is_closed()
7766    }
7767    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7768        self.inner.channel().on_closed()
7769    }
7770
7771    #[cfg(target_os = "fuchsia")]
7772    fn signal_peer(
7773        &self,
7774        clear_mask: zx::Signals,
7775        set_mask: zx::Signals,
7776    ) -> Result<(), zx_status::Status> {
7777        use fidl::Peered;
7778        self.inner.channel().signal_peer(clear_mask, set_mask)
7779    }
7780}
7781
7782impl TerminaGuestManagerControlHandle {}
7783
7784#[must_use = "FIDL methods require a response to be sent"]
7785#[derive(Debug)]
7786pub struct TerminaGuestManagerLaunchResponder {
7787    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
7788    tx_id: u32,
7789}
7790
7791/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
7792/// if the responder is dropped without sending a response, so that the client
7793/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7794impl std::ops::Drop for TerminaGuestManagerLaunchResponder {
7795    fn drop(&mut self) {
7796        self.control_handle.shutdown();
7797        // Safety: drops once, never accessed again
7798        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7799    }
7800}
7801
7802impl fidl::endpoints::Responder for TerminaGuestManagerLaunchResponder {
7803    type ControlHandle = TerminaGuestManagerControlHandle;
7804
7805    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
7806        &self.control_handle
7807    }
7808
7809    fn drop_without_shutdown(mut self) {
7810        // Safety: drops once, never accessed again due to mem::forget
7811        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7812        // Prevent Drop from running (which would shut down the channel)
7813        std::mem::forget(self);
7814    }
7815}
7816
7817impl TerminaGuestManagerLaunchResponder {
7818    /// Sends a response to the FIDL transaction.
7819    ///
7820    /// Sets the channel to shutdown if an error occurs.
7821    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
7822        let _result = self.send_raw(result);
7823        if _result.is_err() {
7824            self.control_handle.shutdown();
7825        }
7826        self.drop_without_shutdown();
7827        _result
7828    }
7829
7830    /// Similar to "send" but does not shutdown the channel if an error occurs.
7831    pub fn send_no_shutdown_on_err(
7832        self,
7833        mut result: Result<(), GuestManagerError>,
7834    ) -> Result<(), fidl::Error> {
7835        let _result = self.send_raw(result);
7836        self.drop_without_shutdown();
7837        _result
7838    }
7839
7840    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
7841        self.control_handle.inner.send::<fidl::encoding::ResultType<
7842            fidl::encoding::EmptyStruct,
7843            GuestManagerError,
7844        >>(
7845            result,
7846            self.tx_id,
7847            0x394a2e29f750323e,
7848            fidl::encoding::DynamicFlags::empty(),
7849        )
7850    }
7851}
7852
7853#[must_use = "FIDL methods require a response to be sent"]
7854#[derive(Debug)]
7855pub struct TerminaGuestManagerForceShutdownResponder {
7856    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
7857    tx_id: u32,
7858}
7859
7860/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
7861/// if the responder is dropped without sending a response, so that the client
7862/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7863impl std::ops::Drop for TerminaGuestManagerForceShutdownResponder {
7864    fn drop(&mut self) {
7865        self.control_handle.shutdown();
7866        // Safety: drops once, never accessed again
7867        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7868    }
7869}
7870
7871impl fidl::endpoints::Responder for TerminaGuestManagerForceShutdownResponder {
7872    type ControlHandle = TerminaGuestManagerControlHandle;
7873
7874    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
7875        &self.control_handle
7876    }
7877
7878    fn drop_without_shutdown(mut self) {
7879        // Safety: drops once, never accessed again due to mem::forget
7880        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7881        // Prevent Drop from running (which would shut down the channel)
7882        std::mem::forget(self);
7883    }
7884}
7885
7886impl TerminaGuestManagerForceShutdownResponder {
7887    /// Sends a response to the FIDL transaction.
7888    ///
7889    /// Sets the channel to shutdown if an error occurs.
7890    pub fn send(self) -> Result<(), fidl::Error> {
7891        let _result = self.send_raw();
7892        if _result.is_err() {
7893            self.control_handle.shutdown();
7894        }
7895        self.drop_without_shutdown();
7896        _result
7897    }
7898
7899    /// Similar to "send" but does not shutdown the channel if an error occurs.
7900    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7901        let _result = self.send_raw();
7902        self.drop_without_shutdown();
7903        _result
7904    }
7905
7906    fn send_raw(&self) -> Result<(), fidl::Error> {
7907        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7908            (),
7909            self.tx_id,
7910            0x3ad9a012982f872d,
7911            fidl::encoding::DynamicFlags::empty(),
7912        )
7913    }
7914}
7915
7916#[must_use = "FIDL methods require a response to be sent"]
7917#[derive(Debug)]
7918pub struct TerminaGuestManagerConnectResponder {
7919    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
7920    tx_id: u32,
7921}
7922
7923/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
7924/// if the responder is dropped without sending a response, so that the client
7925/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7926impl std::ops::Drop for TerminaGuestManagerConnectResponder {
7927    fn drop(&mut self) {
7928        self.control_handle.shutdown();
7929        // Safety: drops once, never accessed again
7930        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7931    }
7932}
7933
7934impl fidl::endpoints::Responder for TerminaGuestManagerConnectResponder {
7935    type ControlHandle = TerminaGuestManagerControlHandle;
7936
7937    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
7938        &self.control_handle
7939    }
7940
7941    fn drop_without_shutdown(mut self) {
7942        // Safety: drops once, never accessed again due to mem::forget
7943        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7944        // Prevent Drop from running (which would shut down the channel)
7945        std::mem::forget(self);
7946    }
7947}
7948
7949impl TerminaGuestManagerConnectResponder {
7950    /// Sends a response to the FIDL transaction.
7951    ///
7952    /// Sets the channel to shutdown if an error occurs.
7953    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
7954        let _result = self.send_raw(result);
7955        if _result.is_err() {
7956            self.control_handle.shutdown();
7957        }
7958        self.drop_without_shutdown();
7959        _result
7960    }
7961
7962    /// Similar to "send" but does not shutdown the channel if an error occurs.
7963    pub fn send_no_shutdown_on_err(
7964        self,
7965        mut result: Result<(), GuestManagerError>,
7966    ) -> Result<(), fidl::Error> {
7967        let _result = self.send_raw(result);
7968        self.drop_without_shutdown();
7969        _result
7970    }
7971
7972    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
7973        self.control_handle.inner.send::<fidl::encoding::ResultType<
7974            fidl::encoding::EmptyStruct,
7975            GuestManagerError,
7976        >>(
7977            result,
7978            self.tx_id,
7979            0x4e489076e3bb15b4,
7980            fidl::encoding::DynamicFlags::empty(),
7981        )
7982    }
7983}
7984
7985#[must_use = "FIDL methods require a response to be sent"]
7986#[derive(Debug)]
7987pub struct TerminaGuestManagerGetInfoResponder {
7988    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
7989    tx_id: u32,
7990}
7991
7992/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
7993/// if the responder is dropped without sending a response, so that the client
7994/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7995impl std::ops::Drop for TerminaGuestManagerGetInfoResponder {
7996    fn drop(&mut self) {
7997        self.control_handle.shutdown();
7998        // Safety: drops once, never accessed again
7999        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8000    }
8001}
8002
8003impl fidl::endpoints::Responder for TerminaGuestManagerGetInfoResponder {
8004    type ControlHandle = TerminaGuestManagerControlHandle;
8005
8006    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8007        &self.control_handle
8008    }
8009
8010    fn drop_without_shutdown(mut self) {
8011        // Safety: drops once, never accessed again due to mem::forget
8012        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8013        // Prevent Drop from running (which would shut down the channel)
8014        std::mem::forget(self);
8015    }
8016}
8017
8018impl TerminaGuestManagerGetInfoResponder {
8019    /// Sends a response to the FIDL transaction.
8020    ///
8021    /// Sets the channel to shutdown if an error occurs.
8022    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8023        let _result = self.send_raw(guest_info);
8024        if _result.is_err() {
8025            self.control_handle.shutdown();
8026        }
8027        self.drop_without_shutdown();
8028        _result
8029    }
8030
8031    /// Similar to "send" but does not shutdown the channel if an error occurs.
8032    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8033        let _result = self.send_raw(guest_info);
8034        self.drop_without_shutdown();
8035        _result
8036    }
8037
8038    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8039        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
8040            (guest_info,),
8041            self.tx_id,
8042            0x76892614aea695dc,
8043            fidl::encoding::DynamicFlags::empty(),
8044        )
8045    }
8046}
8047
8048#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8049pub struct ZirconGuestManagerMarker;
8050
8051impl fidl::endpoints::ProtocolMarker for ZirconGuestManagerMarker {
8052    type Proxy = ZirconGuestManagerProxy;
8053    type RequestStream = ZirconGuestManagerRequestStream;
8054    #[cfg(target_os = "fuchsia")]
8055    type SynchronousProxy = ZirconGuestManagerSynchronousProxy;
8056
8057    const DEBUG_NAME: &'static str = "fuchsia.virtualization.ZirconGuestManager";
8058}
8059impl fidl::endpoints::DiscoverableProtocolMarker for ZirconGuestManagerMarker {}
8060
8061pub trait ZirconGuestManagerProxyInterface: Send + Sync {
8062    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
8063        + Send;
8064    fn r#launch(
8065        &self,
8066        guest_config: GuestConfig,
8067        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8068    ) -> Self::LaunchResponseFut;
8069    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8070    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
8071    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
8072        + Send;
8073    fn r#connect(
8074        &self,
8075        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8076    ) -> Self::ConnectResponseFut;
8077    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
8078    fn r#get_info(&self) -> Self::GetInfoResponseFut;
8079}
8080#[derive(Debug)]
8081#[cfg(target_os = "fuchsia")]
8082pub struct ZirconGuestManagerSynchronousProxy {
8083    client: fidl::client::sync::Client,
8084}
8085
8086#[cfg(target_os = "fuchsia")]
8087impl fidl::endpoints::SynchronousProxy for ZirconGuestManagerSynchronousProxy {
8088    type Proxy = ZirconGuestManagerProxy;
8089    type Protocol = ZirconGuestManagerMarker;
8090
8091    fn from_channel(inner: fidl::Channel) -> Self {
8092        Self::new(inner)
8093    }
8094
8095    fn into_channel(self) -> fidl::Channel {
8096        self.client.into_channel()
8097    }
8098
8099    fn as_channel(&self) -> &fidl::Channel {
8100        self.client.as_channel()
8101    }
8102}
8103
8104#[cfg(target_os = "fuchsia")]
8105impl ZirconGuestManagerSynchronousProxy {
8106    pub fn new(channel: fidl::Channel) -> Self {
8107        let protocol_name =
8108            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8109        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8110    }
8111
8112    pub fn into_channel(self) -> fidl::Channel {
8113        self.client.into_channel()
8114    }
8115
8116    /// Waits until an event arrives and returns it. It is safe for other
8117    /// threads to make concurrent requests while waiting for an event.
8118    pub fn wait_for_event(
8119        &self,
8120        deadline: zx::MonotonicInstant,
8121    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8122        ZirconGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
8123    }
8124
8125    /// Launch a new guest instance.
8126    ///
8127    /// Possible errors:
8128    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8129    ///         problems detected by the guest manager.
8130    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8131    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8132    ///         component logs for a more specific failure.
8133    pub fn r#launch(
8134        &self,
8135        mut guest_config: GuestConfig,
8136        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8137        ___deadline: zx::MonotonicInstant,
8138    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8139        let _response =
8140            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
8141                fidl::encoding::EmptyStruct,
8142                GuestManagerError,
8143            >>(
8144                (&mut guest_config, controller),
8145                0x394a2e29f750323e,
8146                fidl::encoding::DynamicFlags::empty(),
8147                ___deadline,
8148            )?;
8149        Ok(_response.map(|x| x))
8150    }
8151
8152    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8153    /// be used to launch another guest.
8154    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
8155        let _response =
8156            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
8157                (),
8158                0x3ad9a012982f872d,
8159                fidl::encoding::DynamicFlags::empty(),
8160                ___deadline,
8161            )?;
8162        Ok(_response)
8163    }
8164
8165    /// Connect to a currently running guest.
8166    ///
8167    /// Possible errors:
8168    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8169    ///         has launched before attempting to reconnect.
8170    pub fn r#connect(
8171        &self,
8172        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8173        ___deadline: zx::MonotonicInstant,
8174    ) -> Result<GuestManagerConnectResult, fidl::Error> {
8175        let _response =
8176            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
8177                fidl::encoding::EmptyStruct,
8178                GuestManagerError,
8179            >>(
8180                (controller,),
8181                0x4e489076e3bb15b4,
8182                fidl::encoding::DynamicFlags::empty(),
8183                ___deadline,
8184            )?;
8185        Ok(_response.map(|x| x))
8186    }
8187
8188    /// Query guest info
8189    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
8190        let _response =
8191            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
8192                (),
8193                0x76892614aea695dc,
8194                fidl::encoding::DynamicFlags::empty(),
8195                ___deadline,
8196            )?;
8197        Ok(_response.guest_info)
8198    }
8199}
8200
8201#[derive(Debug, Clone)]
8202pub struct ZirconGuestManagerProxy {
8203    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8204}
8205
8206impl fidl::endpoints::Proxy for ZirconGuestManagerProxy {
8207    type Protocol = ZirconGuestManagerMarker;
8208
8209    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8210        Self::new(inner)
8211    }
8212
8213    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8214        self.client.into_channel().map_err(|client| Self { client })
8215    }
8216
8217    fn as_channel(&self) -> &::fidl::AsyncChannel {
8218        self.client.as_channel()
8219    }
8220}
8221
8222impl ZirconGuestManagerProxy {
8223    /// Create a new Proxy for fuchsia.virtualization/ZirconGuestManager.
8224    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8225        let protocol_name =
8226            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8227        Self { client: fidl::client::Client::new(channel, protocol_name) }
8228    }
8229
8230    /// Get a Stream of events from the remote end of the protocol.
8231    ///
8232    /// # Panics
8233    ///
8234    /// Panics if the event stream was already taken.
8235    pub fn take_event_stream(&self) -> ZirconGuestManagerEventStream {
8236        ZirconGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
8237    }
8238
8239    /// Launch a new guest instance.
8240    ///
8241    /// Possible errors:
8242    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8243    ///         problems detected by the guest manager.
8244    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8245    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8246    ///         component logs for a more specific failure.
8247    pub fn r#launch(
8248        &self,
8249        mut guest_config: GuestConfig,
8250        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8251    ) -> fidl::client::QueryResponseFut<
8252        GuestManagerLaunchResult,
8253        fidl::encoding::DefaultFuchsiaResourceDialect,
8254    > {
8255        ZirconGuestManagerProxyInterface::r#launch(self, guest_config, controller)
8256    }
8257
8258    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8259    /// be used to launch another guest.
8260    pub fn r#force_shutdown(
8261        &self,
8262    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8263        ZirconGuestManagerProxyInterface::r#force_shutdown(self)
8264    }
8265
8266    /// Connect to a currently running guest.
8267    ///
8268    /// Possible errors:
8269    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8270    ///         has launched before attempting to reconnect.
8271    pub fn r#connect(
8272        &self,
8273        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8274    ) -> fidl::client::QueryResponseFut<
8275        GuestManagerConnectResult,
8276        fidl::encoding::DefaultFuchsiaResourceDialect,
8277    > {
8278        ZirconGuestManagerProxyInterface::r#connect(self, controller)
8279    }
8280
8281    /// Query guest info
8282    pub fn r#get_info(
8283        &self,
8284    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
8285    {
8286        ZirconGuestManagerProxyInterface::r#get_info(self)
8287    }
8288}
8289
8290impl ZirconGuestManagerProxyInterface for ZirconGuestManagerProxy {
8291    type LaunchResponseFut = fidl::client::QueryResponseFut<
8292        GuestManagerLaunchResult,
8293        fidl::encoding::DefaultFuchsiaResourceDialect,
8294    >;
8295    fn r#launch(
8296        &self,
8297        mut guest_config: GuestConfig,
8298        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8299    ) -> Self::LaunchResponseFut {
8300        fn _decode(
8301            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8302        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8303            let _response = fidl::client::decode_transaction_body::<
8304                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8305                fidl::encoding::DefaultFuchsiaResourceDialect,
8306                0x394a2e29f750323e,
8307            >(_buf?)?;
8308            Ok(_response.map(|x| x))
8309        }
8310        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
8311            (&mut guest_config, controller),
8312            0x394a2e29f750323e,
8313            fidl::encoding::DynamicFlags::empty(),
8314            _decode,
8315        )
8316    }
8317
8318    type ForceShutdownResponseFut =
8319        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8320    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
8321        fn _decode(
8322            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8323        ) -> Result<(), fidl::Error> {
8324            let _response = fidl::client::decode_transaction_body::<
8325                fidl::encoding::EmptyPayload,
8326                fidl::encoding::DefaultFuchsiaResourceDialect,
8327                0x3ad9a012982f872d,
8328            >(_buf?)?;
8329            Ok(_response)
8330        }
8331        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
8332            (),
8333            0x3ad9a012982f872d,
8334            fidl::encoding::DynamicFlags::empty(),
8335            _decode,
8336        )
8337    }
8338
8339    type ConnectResponseFut = fidl::client::QueryResponseFut<
8340        GuestManagerConnectResult,
8341        fidl::encoding::DefaultFuchsiaResourceDialect,
8342    >;
8343    fn r#connect(
8344        &self,
8345        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8346    ) -> Self::ConnectResponseFut {
8347        fn _decode(
8348            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8349        ) -> Result<GuestManagerConnectResult, fidl::Error> {
8350            let _response = fidl::client::decode_transaction_body::<
8351                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8352                fidl::encoding::DefaultFuchsiaResourceDialect,
8353                0x4e489076e3bb15b4,
8354            >(_buf?)?;
8355            Ok(_response.map(|x| x))
8356        }
8357        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
8358            (controller,),
8359            0x4e489076e3bb15b4,
8360            fidl::encoding::DynamicFlags::empty(),
8361            _decode,
8362        )
8363    }
8364
8365    type GetInfoResponseFut =
8366        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
8367    fn r#get_info(&self) -> Self::GetInfoResponseFut {
8368        fn _decode(
8369            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8370        ) -> Result<GuestInfo, fidl::Error> {
8371            let _response = fidl::client::decode_transaction_body::<
8372                GuestManagerGetInfoResponse,
8373                fidl::encoding::DefaultFuchsiaResourceDialect,
8374                0x76892614aea695dc,
8375            >(_buf?)?;
8376            Ok(_response.guest_info)
8377        }
8378        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
8379            (),
8380            0x76892614aea695dc,
8381            fidl::encoding::DynamicFlags::empty(),
8382            _decode,
8383        )
8384    }
8385}
8386
8387pub struct ZirconGuestManagerEventStream {
8388    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8389}
8390
8391impl std::marker::Unpin for ZirconGuestManagerEventStream {}
8392
8393impl futures::stream::FusedStream for ZirconGuestManagerEventStream {
8394    fn is_terminated(&self) -> bool {
8395        self.event_receiver.is_terminated()
8396    }
8397}
8398
8399impl futures::Stream for ZirconGuestManagerEventStream {
8400    type Item = Result<ZirconGuestManagerEvent, fidl::Error>;
8401
8402    fn poll_next(
8403        mut self: std::pin::Pin<&mut Self>,
8404        cx: &mut std::task::Context<'_>,
8405    ) -> std::task::Poll<Option<Self::Item>> {
8406        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8407            &mut self.event_receiver,
8408            cx
8409        )?) {
8410            Some(buf) => std::task::Poll::Ready(Some(ZirconGuestManagerEvent::decode(buf))),
8411            None => std::task::Poll::Ready(None),
8412        }
8413    }
8414}
8415
8416#[derive(Debug)]
8417pub enum ZirconGuestManagerEvent {}
8418
8419impl ZirconGuestManagerEvent {
8420    /// Decodes a message buffer as a [`ZirconGuestManagerEvent`].
8421    fn decode(
8422        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8423    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8424        let (bytes, _handles) = buf.split_mut();
8425        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8426        debug_assert_eq!(tx_header.tx_id, 0);
8427        match tx_header.ordinal {
8428            _ => Err(fidl::Error::UnknownOrdinal {
8429                ordinal: tx_header.ordinal,
8430                protocol_name:
8431                    <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8432            }),
8433        }
8434    }
8435}
8436
8437/// A Stream of incoming requests for fuchsia.virtualization/ZirconGuestManager.
8438pub struct ZirconGuestManagerRequestStream {
8439    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8440    is_terminated: bool,
8441}
8442
8443impl std::marker::Unpin for ZirconGuestManagerRequestStream {}
8444
8445impl futures::stream::FusedStream for ZirconGuestManagerRequestStream {
8446    fn is_terminated(&self) -> bool {
8447        self.is_terminated
8448    }
8449}
8450
8451impl fidl::endpoints::RequestStream for ZirconGuestManagerRequestStream {
8452    type Protocol = ZirconGuestManagerMarker;
8453    type ControlHandle = ZirconGuestManagerControlHandle;
8454
8455    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8456        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8457    }
8458
8459    fn control_handle(&self) -> Self::ControlHandle {
8460        ZirconGuestManagerControlHandle { inner: self.inner.clone() }
8461    }
8462
8463    fn into_inner(
8464        self,
8465    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8466    {
8467        (self.inner, self.is_terminated)
8468    }
8469
8470    fn from_inner(
8471        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8472        is_terminated: bool,
8473    ) -> Self {
8474        Self { inner, is_terminated }
8475    }
8476}
8477
8478impl futures::Stream for ZirconGuestManagerRequestStream {
8479    type Item = Result<ZirconGuestManagerRequest, fidl::Error>;
8480
8481    fn poll_next(
8482        mut self: std::pin::Pin<&mut Self>,
8483        cx: &mut std::task::Context<'_>,
8484    ) -> std::task::Poll<Option<Self::Item>> {
8485        let this = &mut *self;
8486        if this.inner.check_shutdown(cx) {
8487            this.is_terminated = true;
8488            return std::task::Poll::Ready(None);
8489        }
8490        if this.is_terminated {
8491            panic!("polled ZirconGuestManagerRequestStream after completion");
8492        }
8493        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8494            |bytes, handles| {
8495                match this.inner.channel().read_etc(cx, bytes, handles) {
8496                    std::task::Poll::Ready(Ok(())) => {}
8497                    std::task::Poll::Pending => return std::task::Poll::Pending,
8498                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8499                        this.is_terminated = true;
8500                        return std::task::Poll::Ready(None);
8501                    }
8502                    std::task::Poll::Ready(Err(e)) => {
8503                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8504                            e.into(),
8505                        ))))
8506                    }
8507                }
8508
8509                // A message has been received from the channel
8510                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8511
8512                std::task::Poll::Ready(Some(match header.ordinal {
8513                0x394a2e29f750323e => {
8514                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8515                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8516                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
8517                    let control_handle = ZirconGuestManagerControlHandle {
8518                        inner: this.inner.clone(),
8519                    };
8520                    Ok(ZirconGuestManagerRequest::Launch {guest_config: req.guest_config,
8521controller: req.controller,
8522
8523                        responder: ZirconGuestManagerLaunchResponder {
8524                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8525                            tx_id: header.tx_id,
8526                        },
8527                    })
8528                }
8529                0x3ad9a012982f872d => {
8530                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8531                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8532                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8533                    let control_handle = ZirconGuestManagerControlHandle {
8534                        inner: this.inner.clone(),
8535                    };
8536                    Ok(ZirconGuestManagerRequest::ForceShutdown {
8537                        responder: ZirconGuestManagerForceShutdownResponder {
8538                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8539                            tx_id: header.tx_id,
8540                        },
8541                    })
8542                }
8543                0x4e489076e3bb15b4 => {
8544                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8545                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8546                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
8547                    let control_handle = ZirconGuestManagerControlHandle {
8548                        inner: this.inner.clone(),
8549                    };
8550                    Ok(ZirconGuestManagerRequest::Connect {controller: req.controller,
8551
8552                        responder: ZirconGuestManagerConnectResponder {
8553                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8554                            tx_id: header.tx_id,
8555                        },
8556                    })
8557                }
8558                0x76892614aea695dc => {
8559                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8560                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8561                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8562                    let control_handle = ZirconGuestManagerControlHandle {
8563                        inner: this.inner.clone(),
8564                    };
8565                    Ok(ZirconGuestManagerRequest::GetInfo {
8566                        responder: ZirconGuestManagerGetInfoResponder {
8567                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8568                            tx_id: header.tx_id,
8569                        },
8570                    })
8571                }
8572                _ => Err(fidl::Error::UnknownOrdinal {
8573                    ordinal: header.ordinal,
8574                    protocol_name: <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8575                }),
8576            }))
8577            },
8578        )
8579    }
8580}
8581
8582#[derive(Debug)]
8583pub enum ZirconGuestManagerRequest {
8584    /// Launch a new guest instance.
8585    ///
8586    /// Possible errors:
8587    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8588    ///         problems detected by the guest manager.
8589    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8590    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8591    ///         component logs for a more specific failure.
8592    Launch {
8593        guest_config: GuestConfig,
8594        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8595        responder: ZirconGuestManagerLaunchResponder,
8596    },
8597    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8598    /// be used to launch another guest.
8599    ForceShutdown { responder: ZirconGuestManagerForceShutdownResponder },
8600    /// Connect to a currently running guest.
8601    ///
8602    /// Possible errors:
8603    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8604    ///         has launched before attempting to reconnect.
8605    Connect {
8606        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8607        responder: ZirconGuestManagerConnectResponder,
8608    },
8609    /// Query guest info
8610    GetInfo { responder: ZirconGuestManagerGetInfoResponder },
8611}
8612
8613impl ZirconGuestManagerRequest {
8614    #[allow(irrefutable_let_patterns)]
8615    pub fn into_launch(
8616        self,
8617    ) -> Option<(
8618        GuestConfig,
8619        fidl::endpoints::ServerEnd<GuestMarker>,
8620        ZirconGuestManagerLaunchResponder,
8621    )> {
8622        if let ZirconGuestManagerRequest::Launch { guest_config, controller, responder } = self {
8623            Some((guest_config, controller, responder))
8624        } else {
8625            None
8626        }
8627    }
8628
8629    #[allow(irrefutable_let_patterns)]
8630    pub fn into_force_shutdown(self) -> Option<(ZirconGuestManagerForceShutdownResponder)> {
8631        if let ZirconGuestManagerRequest::ForceShutdown { responder } = self {
8632            Some((responder))
8633        } else {
8634            None
8635        }
8636    }
8637
8638    #[allow(irrefutable_let_patterns)]
8639    pub fn into_connect(
8640        self,
8641    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, ZirconGuestManagerConnectResponder)> {
8642        if let ZirconGuestManagerRequest::Connect { controller, responder } = self {
8643            Some((controller, responder))
8644        } else {
8645            None
8646        }
8647    }
8648
8649    #[allow(irrefutable_let_patterns)]
8650    pub fn into_get_info(self) -> Option<(ZirconGuestManagerGetInfoResponder)> {
8651        if let ZirconGuestManagerRequest::GetInfo { responder } = self {
8652            Some((responder))
8653        } else {
8654            None
8655        }
8656    }
8657
8658    /// Name of the method defined in FIDL
8659    pub fn method_name(&self) -> &'static str {
8660        match *self {
8661            ZirconGuestManagerRequest::Launch { .. } => "launch",
8662            ZirconGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
8663            ZirconGuestManagerRequest::Connect { .. } => "connect",
8664            ZirconGuestManagerRequest::GetInfo { .. } => "get_info",
8665        }
8666    }
8667}
8668
8669#[derive(Debug, Clone)]
8670pub struct ZirconGuestManagerControlHandle {
8671    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8672}
8673
8674impl fidl::endpoints::ControlHandle for ZirconGuestManagerControlHandle {
8675    fn shutdown(&self) {
8676        self.inner.shutdown()
8677    }
8678    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8679        self.inner.shutdown_with_epitaph(status)
8680    }
8681
8682    fn is_closed(&self) -> bool {
8683        self.inner.channel().is_closed()
8684    }
8685    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8686        self.inner.channel().on_closed()
8687    }
8688
8689    #[cfg(target_os = "fuchsia")]
8690    fn signal_peer(
8691        &self,
8692        clear_mask: zx::Signals,
8693        set_mask: zx::Signals,
8694    ) -> Result<(), zx_status::Status> {
8695        use fidl::Peered;
8696        self.inner.channel().signal_peer(clear_mask, set_mask)
8697    }
8698}
8699
8700impl ZirconGuestManagerControlHandle {}
8701
8702#[must_use = "FIDL methods require a response to be sent"]
8703#[derive(Debug)]
8704pub struct ZirconGuestManagerLaunchResponder {
8705    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8706    tx_id: u32,
8707}
8708
8709/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8710/// if the responder is dropped without sending a response, so that the client
8711/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8712impl std::ops::Drop for ZirconGuestManagerLaunchResponder {
8713    fn drop(&mut self) {
8714        self.control_handle.shutdown();
8715        // Safety: drops once, never accessed again
8716        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8717    }
8718}
8719
8720impl fidl::endpoints::Responder for ZirconGuestManagerLaunchResponder {
8721    type ControlHandle = ZirconGuestManagerControlHandle;
8722
8723    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
8724        &self.control_handle
8725    }
8726
8727    fn drop_without_shutdown(mut self) {
8728        // Safety: drops once, never accessed again due to mem::forget
8729        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8730        // Prevent Drop from running (which would shut down the channel)
8731        std::mem::forget(self);
8732    }
8733}
8734
8735impl ZirconGuestManagerLaunchResponder {
8736    /// Sends a response to the FIDL transaction.
8737    ///
8738    /// Sets the channel to shutdown if an error occurs.
8739    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8740        let _result = self.send_raw(result);
8741        if _result.is_err() {
8742            self.control_handle.shutdown();
8743        }
8744        self.drop_without_shutdown();
8745        _result
8746    }
8747
8748    /// Similar to "send" but does not shutdown the channel if an error occurs.
8749    pub fn send_no_shutdown_on_err(
8750        self,
8751        mut result: Result<(), GuestManagerError>,
8752    ) -> Result<(), fidl::Error> {
8753        let _result = self.send_raw(result);
8754        self.drop_without_shutdown();
8755        _result
8756    }
8757
8758    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8759        self.control_handle.inner.send::<fidl::encoding::ResultType<
8760            fidl::encoding::EmptyStruct,
8761            GuestManagerError,
8762        >>(
8763            result,
8764            self.tx_id,
8765            0x394a2e29f750323e,
8766            fidl::encoding::DynamicFlags::empty(),
8767        )
8768    }
8769}
8770
8771#[must_use = "FIDL methods require a response to be sent"]
8772#[derive(Debug)]
8773pub struct ZirconGuestManagerForceShutdownResponder {
8774    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8775    tx_id: u32,
8776}
8777
8778/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8779/// if the responder is dropped without sending a response, so that the client
8780/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8781impl std::ops::Drop for ZirconGuestManagerForceShutdownResponder {
8782    fn drop(&mut self) {
8783        self.control_handle.shutdown();
8784        // Safety: drops once, never accessed again
8785        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8786    }
8787}
8788
8789impl fidl::endpoints::Responder for ZirconGuestManagerForceShutdownResponder {
8790    type ControlHandle = ZirconGuestManagerControlHandle;
8791
8792    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
8793        &self.control_handle
8794    }
8795
8796    fn drop_without_shutdown(mut self) {
8797        // Safety: drops once, never accessed again due to mem::forget
8798        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8799        // Prevent Drop from running (which would shut down the channel)
8800        std::mem::forget(self);
8801    }
8802}
8803
8804impl ZirconGuestManagerForceShutdownResponder {
8805    /// Sends a response to the FIDL transaction.
8806    ///
8807    /// Sets the channel to shutdown if an error occurs.
8808    pub fn send(self) -> Result<(), fidl::Error> {
8809        let _result = self.send_raw();
8810        if _result.is_err() {
8811            self.control_handle.shutdown();
8812        }
8813        self.drop_without_shutdown();
8814        _result
8815    }
8816
8817    /// Similar to "send" but does not shutdown the channel if an error occurs.
8818    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8819        let _result = self.send_raw();
8820        self.drop_without_shutdown();
8821        _result
8822    }
8823
8824    fn send_raw(&self) -> Result<(), fidl::Error> {
8825        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8826            (),
8827            self.tx_id,
8828            0x3ad9a012982f872d,
8829            fidl::encoding::DynamicFlags::empty(),
8830        )
8831    }
8832}
8833
8834#[must_use = "FIDL methods require a response to be sent"]
8835#[derive(Debug)]
8836pub struct ZirconGuestManagerConnectResponder {
8837    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8838    tx_id: u32,
8839}
8840
8841/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8842/// if the responder is dropped without sending a response, so that the client
8843/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8844impl std::ops::Drop for ZirconGuestManagerConnectResponder {
8845    fn drop(&mut self) {
8846        self.control_handle.shutdown();
8847        // Safety: drops once, never accessed again
8848        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8849    }
8850}
8851
8852impl fidl::endpoints::Responder for ZirconGuestManagerConnectResponder {
8853    type ControlHandle = ZirconGuestManagerControlHandle;
8854
8855    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
8856        &self.control_handle
8857    }
8858
8859    fn drop_without_shutdown(mut self) {
8860        // Safety: drops once, never accessed again due to mem::forget
8861        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8862        // Prevent Drop from running (which would shut down the channel)
8863        std::mem::forget(self);
8864    }
8865}
8866
8867impl ZirconGuestManagerConnectResponder {
8868    /// Sends a response to the FIDL transaction.
8869    ///
8870    /// Sets the channel to shutdown if an error occurs.
8871    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8872        let _result = self.send_raw(result);
8873        if _result.is_err() {
8874            self.control_handle.shutdown();
8875        }
8876        self.drop_without_shutdown();
8877        _result
8878    }
8879
8880    /// Similar to "send" but does not shutdown the channel if an error occurs.
8881    pub fn send_no_shutdown_on_err(
8882        self,
8883        mut result: Result<(), GuestManagerError>,
8884    ) -> Result<(), fidl::Error> {
8885        let _result = self.send_raw(result);
8886        self.drop_without_shutdown();
8887        _result
8888    }
8889
8890    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8891        self.control_handle.inner.send::<fidl::encoding::ResultType<
8892            fidl::encoding::EmptyStruct,
8893            GuestManagerError,
8894        >>(
8895            result,
8896            self.tx_id,
8897            0x4e489076e3bb15b4,
8898            fidl::encoding::DynamicFlags::empty(),
8899        )
8900    }
8901}
8902
8903#[must_use = "FIDL methods require a response to be sent"]
8904#[derive(Debug)]
8905pub struct ZirconGuestManagerGetInfoResponder {
8906    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8907    tx_id: u32,
8908}
8909
8910/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8911/// if the responder is dropped without sending a response, so that the client
8912/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8913impl std::ops::Drop for ZirconGuestManagerGetInfoResponder {
8914    fn drop(&mut self) {
8915        self.control_handle.shutdown();
8916        // Safety: drops once, never accessed again
8917        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8918    }
8919}
8920
8921impl fidl::endpoints::Responder for ZirconGuestManagerGetInfoResponder {
8922    type ControlHandle = ZirconGuestManagerControlHandle;
8923
8924    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
8925        &self.control_handle
8926    }
8927
8928    fn drop_without_shutdown(mut self) {
8929        // Safety: drops once, never accessed again due to mem::forget
8930        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8931        // Prevent Drop from running (which would shut down the channel)
8932        std::mem::forget(self);
8933    }
8934}
8935
8936impl ZirconGuestManagerGetInfoResponder {
8937    /// Sends a response to the FIDL transaction.
8938    ///
8939    /// Sets the channel to shutdown if an error occurs.
8940    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8941        let _result = self.send_raw(guest_info);
8942        if _result.is_err() {
8943            self.control_handle.shutdown();
8944        }
8945        self.drop_without_shutdown();
8946        _result
8947    }
8948
8949    /// Similar to "send" but does not shutdown the channel if an error occurs.
8950    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8951        let _result = self.send_raw(guest_info);
8952        self.drop_without_shutdown();
8953        _result
8954    }
8955
8956    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8957        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
8958            (guest_info,),
8959            self.tx_id,
8960            0x76892614aea695dc,
8961            fidl::encoding::DynamicFlags::empty(),
8962        )
8963    }
8964}
8965
8966mod internal {
8967    use super::*;
8968
8969    impl fidl::encoding::ResourceTypeMarker for BlockSpec {
8970        type Borrowed<'a> = &'a mut Self;
8971        fn take_or_borrow<'a>(
8972            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8973        ) -> Self::Borrowed<'a> {
8974            value
8975        }
8976    }
8977
8978    unsafe impl fidl::encoding::TypeMarker for BlockSpec {
8979        type Owned = Self;
8980
8981        #[inline(always)]
8982        fn inline_align(_context: fidl::encoding::Context) -> usize {
8983            8
8984        }
8985
8986        #[inline(always)]
8987        fn inline_size(_context: fidl::encoding::Context) -> usize {
8988            40
8989        }
8990    }
8991
8992    unsafe impl fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
8993        for &mut BlockSpec
8994    {
8995        #[inline]
8996        unsafe fn encode(
8997            self,
8998            encoder: &mut fidl::encoding::Encoder<
8999                '_,
9000                fidl::encoding::DefaultFuchsiaResourceDialect,
9001            >,
9002            offset: usize,
9003            _depth: fidl::encoding::Depth,
9004        ) -> fidl::Result<()> {
9005            encoder.debug_check_bounds::<BlockSpec>(offset);
9006            // Delegate to tuple encoding.
9007            fidl::encoding::Encode::<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9008                (
9009                    <fidl::encoding::BoundedString<20> as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
9010                    <BlockMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
9011                    <BlockFormat as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.format),
9012                ),
9013                encoder, offset, _depth
9014            )
9015        }
9016    }
9017    unsafe impl<
9018            T0: fidl::encoding::Encode<
9019                fidl::encoding::BoundedString<20>,
9020                fidl::encoding::DefaultFuchsiaResourceDialect,
9021            >,
9022            T1: fidl::encoding::Encode<BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect>,
9023            T2: fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>,
9024        > fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9025        for (T0, T1, T2)
9026    {
9027        #[inline]
9028        unsafe fn encode(
9029            self,
9030            encoder: &mut fidl::encoding::Encoder<
9031                '_,
9032                fidl::encoding::DefaultFuchsiaResourceDialect,
9033            >,
9034            offset: usize,
9035            depth: fidl::encoding::Depth,
9036        ) -> fidl::Result<()> {
9037            encoder.debug_check_bounds::<BlockSpec>(offset);
9038            // Zero out padding regions. There's no need to apply masks
9039            // because the unmasked parts will be overwritten by fields.
9040            unsafe {
9041                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9042                (ptr as *mut u64).write_unaligned(0);
9043            }
9044            // Write the fields.
9045            self.0.encode(encoder, offset + 0, depth)?;
9046            self.1.encode(encoder, offset + 16, depth)?;
9047            self.2.encode(encoder, offset + 24, depth)?;
9048            Ok(())
9049        }
9050    }
9051
9052    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockSpec {
9053        #[inline(always)]
9054        fn new_empty() -> Self {
9055            Self {
9056                id: fidl::new_empty!(
9057                    fidl::encoding::BoundedString<20>,
9058                    fidl::encoding::DefaultFuchsiaResourceDialect
9059                ),
9060                mode: fidl::new_empty!(BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect),
9061                format: fidl::new_empty!(
9062                    BlockFormat,
9063                    fidl::encoding::DefaultFuchsiaResourceDialect
9064                ),
9065            }
9066        }
9067
9068        #[inline]
9069        unsafe fn decode(
9070            &mut self,
9071            decoder: &mut fidl::encoding::Decoder<
9072                '_,
9073                fidl::encoding::DefaultFuchsiaResourceDialect,
9074            >,
9075            offset: usize,
9076            _depth: fidl::encoding::Depth,
9077        ) -> fidl::Result<()> {
9078            decoder.debug_check_bounds::<Self>(offset);
9079            // Verify that padding bytes are zero.
9080            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9081            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9082            let mask = 0xffffffff00000000u64;
9083            let maskedval = padval & mask;
9084            if maskedval != 0 {
9085                return Err(fidl::Error::NonZeroPadding {
9086                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9087                });
9088            }
9089            fidl::decode!(
9090                fidl::encoding::BoundedString<20>,
9091                fidl::encoding::DefaultFuchsiaResourceDialect,
9092                &mut self.id,
9093                decoder,
9094                offset + 0,
9095                _depth
9096            )?;
9097            fidl::decode!(
9098                BlockMode,
9099                fidl::encoding::DefaultFuchsiaResourceDialect,
9100                &mut self.mode,
9101                decoder,
9102                offset + 16,
9103                _depth
9104            )?;
9105            fidl::decode!(
9106                BlockFormat,
9107                fidl::encoding::DefaultFuchsiaResourceDialect,
9108                &mut self.format,
9109                decoder,
9110                offset + 24,
9111                _depth
9112            )?;
9113            Ok(())
9114        }
9115    }
9116
9117    impl fidl::encoding::ResourceTypeMarker for GuestGetBalloonControllerRequest {
9118        type Borrowed<'a> = &'a mut Self;
9119        fn take_or_borrow<'a>(
9120            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9121        ) -> Self::Borrowed<'a> {
9122            value
9123        }
9124    }
9125
9126    unsafe impl fidl::encoding::TypeMarker for GuestGetBalloonControllerRequest {
9127        type Owned = Self;
9128
9129        #[inline(always)]
9130        fn inline_align(_context: fidl::encoding::Context) -> usize {
9131            4
9132        }
9133
9134        #[inline(always)]
9135        fn inline_size(_context: fidl::encoding::Context) -> usize {
9136            4
9137        }
9138    }
9139
9140    unsafe impl
9141        fidl::encoding::Encode<
9142            GuestGetBalloonControllerRequest,
9143            fidl::encoding::DefaultFuchsiaResourceDialect,
9144        > for &mut GuestGetBalloonControllerRequest
9145    {
9146        #[inline]
9147        unsafe fn encode(
9148            self,
9149            encoder: &mut fidl::encoding::Encoder<
9150                '_,
9151                fidl::encoding::DefaultFuchsiaResourceDialect,
9152            >,
9153            offset: usize,
9154            _depth: fidl::encoding::Depth,
9155        ) -> fidl::Result<()> {
9156            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9157            // Delegate to tuple encoding.
9158            fidl::encoding::Encode::<GuestGetBalloonControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9159                (
9160                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9161                ),
9162                encoder, offset, _depth
9163            )
9164        }
9165    }
9166    unsafe impl<
9167            T0: fidl::encoding::Encode<
9168                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9169                fidl::encoding::DefaultFuchsiaResourceDialect,
9170            >,
9171        >
9172        fidl::encoding::Encode<
9173            GuestGetBalloonControllerRequest,
9174            fidl::encoding::DefaultFuchsiaResourceDialect,
9175        > for (T0,)
9176    {
9177        #[inline]
9178        unsafe fn encode(
9179            self,
9180            encoder: &mut fidl::encoding::Encoder<
9181                '_,
9182                fidl::encoding::DefaultFuchsiaResourceDialect,
9183            >,
9184            offset: usize,
9185            depth: fidl::encoding::Depth,
9186        ) -> fidl::Result<()> {
9187            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9188            // Zero out padding regions. There's no need to apply masks
9189            // because the unmasked parts will be overwritten by fields.
9190            // Write the fields.
9191            self.0.encode(encoder, offset + 0, depth)?;
9192            Ok(())
9193        }
9194    }
9195
9196    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9197        for GuestGetBalloonControllerRequest
9198    {
9199        #[inline(always)]
9200        fn new_empty() -> Self {
9201            Self {
9202                controller: fidl::new_empty!(
9203                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9204                    fidl::encoding::DefaultFuchsiaResourceDialect
9205                ),
9206            }
9207        }
9208
9209        #[inline]
9210        unsafe fn decode(
9211            &mut self,
9212            decoder: &mut fidl::encoding::Decoder<
9213                '_,
9214                fidl::encoding::DefaultFuchsiaResourceDialect,
9215            >,
9216            offset: usize,
9217            _depth: fidl::encoding::Depth,
9218        ) -> fidl::Result<()> {
9219            decoder.debug_check_bounds::<Self>(offset);
9220            // Verify that padding bytes are zero.
9221            fidl::decode!(
9222                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9223                fidl::encoding::DefaultFuchsiaResourceDialect,
9224                &mut self.controller,
9225                decoder,
9226                offset + 0,
9227                _depth
9228            )?;
9229            Ok(())
9230        }
9231    }
9232
9233    impl fidl::encoding::ResourceTypeMarker for GuestGetHostVsockEndpointRequest {
9234        type Borrowed<'a> = &'a mut Self;
9235        fn take_or_borrow<'a>(
9236            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9237        ) -> Self::Borrowed<'a> {
9238            value
9239        }
9240    }
9241
9242    unsafe impl fidl::encoding::TypeMarker for GuestGetHostVsockEndpointRequest {
9243        type Owned = Self;
9244
9245        #[inline(always)]
9246        fn inline_align(_context: fidl::encoding::Context) -> usize {
9247            4
9248        }
9249
9250        #[inline(always)]
9251        fn inline_size(_context: fidl::encoding::Context) -> usize {
9252            4
9253        }
9254    }
9255
9256    unsafe impl
9257        fidl::encoding::Encode<
9258            GuestGetHostVsockEndpointRequest,
9259            fidl::encoding::DefaultFuchsiaResourceDialect,
9260        > for &mut GuestGetHostVsockEndpointRequest
9261    {
9262        #[inline]
9263        unsafe fn encode(
9264            self,
9265            encoder: &mut fidl::encoding::Encoder<
9266                '_,
9267                fidl::encoding::DefaultFuchsiaResourceDialect,
9268            >,
9269            offset: usize,
9270            _depth: fidl::encoding::Depth,
9271        ) -> fidl::Result<()> {
9272            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9273            // Delegate to tuple encoding.
9274            fidl::encoding::Encode::<GuestGetHostVsockEndpointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9275                (
9276                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoint),
9277                ),
9278                encoder, offset, _depth
9279            )
9280        }
9281    }
9282    unsafe impl<
9283            T0: fidl::encoding::Encode<
9284                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9285                fidl::encoding::DefaultFuchsiaResourceDialect,
9286            >,
9287        >
9288        fidl::encoding::Encode<
9289            GuestGetHostVsockEndpointRequest,
9290            fidl::encoding::DefaultFuchsiaResourceDialect,
9291        > for (T0,)
9292    {
9293        #[inline]
9294        unsafe fn encode(
9295            self,
9296            encoder: &mut fidl::encoding::Encoder<
9297                '_,
9298                fidl::encoding::DefaultFuchsiaResourceDialect,
9299            >,
9300            offset: usize,
9301            depth: fidl::encoding::Depth,
9302        ) -> fidl::Result<()> {
9303            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9304            // Zero out padding regions. There's no need to apply masks
9305            // because the unmasked parts will be overwritten by fields.
9306            // Write the fields.
9307            self.0.encode(encoder, offset + 0, depth)?;
9308            Ok(())
9309        }
9310    }
9311
9312    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9313        for GuestGetHostVsockEndpointRequest
9314    {
9315        #[inline(always)]
9316        fn new_empty() -> Self {
9317            Self {
9318                endpoint: fidl::new_empty!(
9319                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9320                    fidl::encoding::DefaultFuchsiaResourceDialect
9321                ),
9322            }
9323        }
9324
9325        #[inline]
9326        unsafe fn decode(
9327            &mut self,
9328            decoder: &mut fidl::encoding::Decoder<
9329                '_,
9330                fidl::encoding::DefaultFuchsiaResourceDialect,
9331            >,
9332            offset: usize,
9333            _depth: fidl::encoding::Depth,
9334        ) -> fidl::Result<()> {
9335            decoder.debug_check_bounds::<Self>(offset);
9336            // Verify that padding bytes are zero.
9337            fidl::decode!(
9338                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9339                fidl::encoding::DefaultFuchsiaResourceDialect,
9340                &mut self.endpoint,
9341                decoder,
9342                offset + 0,
9343                _depth
9344            )?;
9345            Ok(())
9346        }
9347    }
9348
9349    impl fidl::encoding::ResourceTypeMarker for GuestGetMemControllerRequest {
9350        type Borrowed<'a> = &'a mut Self;
9351        fn take_or_borrow<'a>(
9352            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9353        ) -> Self::Borrowed<'a> {
9354            value
9355        }
9356    }
9357
9358    unsafe impl fidl::encoding::TypeMarker for GuestGetMemControllerRequest {
9359        type Owned = Self;
9360
9361        #[inline(always)]
9362        fn inline_align(_context: fidl::encoding::Context) -> usize {
9363            4
9364        }
9365
9366        #[inline(always)]
9367        fn inline_size(_context: fidl::encoding::Context) -> usize {
9368            4
9369        }
9370    }
9371
9372    unsafe impl
9373        fidl::encoding::Encode<
9374            GuestGetMemControllerRequest,
9375            fidl::encoding::DefaultFuchsiaResourceDialect,
9376        > for &mut GuestGetMemControllerRequest
9377    {
9378        #[inline]
9379        unsafe fn encode(
9380            self,
9381            encoder: &mut fidl::encoding::Encoder<
9382                '_,
9383                fidl::encoding::DefaultFuchsiaResourceDialect,
9384            >,
9385            offset: usize,
9386            _depth: fidl::encoding::Depth,
9387        ) -> fidl::Result<()> {
9388            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9389            // Delegate to tuple encoding.
9390            fidl::encoding::Encode::<GuestGetMemControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9391                (
9392                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9393                ),
9394                encoder, offset, _depth
9395            )
9396        }
9397    }
9398    unsafe impl<
9399            T0: fidl::encoding::Encode<
9400                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9401                fidl::encoding::DefaultFuchsiaResourceDialect,
9402            >,
9403        >
9404        fidl::encoding::Encode<
9405            GuestGetMemControllerRequest,
9406            fidl::encoding::DefaultFuchsiaResourceDialect,
9407        > for (T0,)
9408    {
9409        #[inline]
9410        unsafe fn encode(
9411            self,
9412            encoder: &mut fidl::encoding::Encoder<
9413                '_,
9414                fidl::encoding::DefaultFuchsiaResourceDialect,
9415            >,
9416            offset: usize,
9417            depth: fidl::encoding::Depth,
9418        ) -> fidl::Result<()> {
9419            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9420            // Zero out padding regions. There's no need to apply masks
9421            // because the unmasked parts will be overwritten by fields.
9422            // Write the fields.
9423            self.0.encode(encoder, offset + 0, depth)?;
9424            Ok(())
9425        }
9426    }
9427
9428    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9429        for GuestGetMemControllerRequest
9430    {
9431        #[inline(always)]
9432        fn new_empty() -> Self {
9433            Self {
9434                controller: fidl::new_empty!(
9435                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9436                    fidl::encoding::DefaultFuchsiaResourceDialect
9437                ),
9438            }
9439        }
9440
9441        #[inline]
9442        unsafe fn decode(
9443            &mut self,
9444            decoder: &mut fidl::encoding::Decoder<
9445                '_,
9446                fidl::encoding::DefaultFuchsiaResourceDialect,
9447            >,
9448            offset: usize,
9449            _depth: fidl::encoding::Depth,
9450        ) -> fidl::Result<()> {
9451            decoder.debug_check_bounds::<Self>(offset);
9452            // Verify that padding bytes are zero.
9453            fidl::decode!(
9454                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9455                fidl::encoding::DefaultFuchsiaResourceDialect,
9456                &mut self.controller,
9457                decoder,
9458                offset + 0,
9459                _depth
9460            )?;
9461            Ok(())
9462        }
9463    }
9464
9465    impl fidl::encoding::ResourceTypeMarker for GuestGetSerialResponse {
9466        type Borrowed<'a> = &'a mut Self;
9467        fn take_or_borrow<'a>(
9468            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9469        ) -> Self::Borrowed<'a> {
9470            value
9471        }
9472    }
9473
9474    unsafe impl fidl::encoding::TypeMarker for GuestGetSerialResponse {
9475        type Owned = Self;
9476
9477        #[inline(always)]
9478        fn inline_align(_context: fidl::encoding::Context) -> usize {
9479            4
9480        }
9481
9482        #[inline(always)]
9483        fn inline_size(_context: fidl::encoding::Context) -> usize {
9484            4
9485        }
9486    }
9487
9488    unsafe impl
9489        fidl::encoding::Encode<
9490            GuestGetSerialResponse,
9491            fidl::encoding::DefaultFuchsiaResourceDialect,
9492        > for &mut GuestGetSerialResponse
9493    {
9494        #[inline]
9495        unsafe fn encode(
9496            self,
9497            encoder: &mut fidl::encoding::Encoder<
9498                '_,
9499                fidl::encoding::DefaultFuchsiaResourceDialect,
9500            >,
9501            offset: usize,
9502            _depth: fidl::encoding::Depth,
9503        ) -> fidl::Result<()> {
9504            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9505            // Delegate to tuple encoding.
9506            fidl::encoding::Encode::<
9507                GuestGetSerialResponse,
9508                fidl::encoding::DefaultFuchsiaResourceDialect,
9509            >::encode(
9510                (<fidl::encoding::HandleType<
9511                    fidl::Socket,
9512                    { fidl::ObjectType::SOCKET.into_raw() },
9513                    2147483648,
9514                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9515                    &mut self.socket
9516                ),),
9517                encoder,
9518                offset,
9519                _depth,
9520            )
9521        }
9522    }
9523    unsafe impl<
9524            T0: fidl::encoding::Encode<
9525                fidl::encoding::HandleType<
9526                    fidl::Socket,
9527                    { fidl::ObjectType::SOCKET.into_raw() },
9528                    2147483648,
9529                >,
9530                fidl::encoding::DefaultFuchsiaResourceDialect,
9531            >,
9532        >
9533        fidl::encoding::Encode<
9534            GuestGetSerialResponse,
9535            fidl::encoding::DefaultFuchsiaResourceDialect,
9536        > for (T0,)
9537    {
9538        #[inline]
9539        unsafe fn encode(
9540            self,
9541            encoder: &mut fidl::encoding::Encoder<
9542                '_,
9543                fidl::encoding::DefaultFuchsiaResourceDialect,
9544            >,
9545            offset: usize,
9546            depth: fidl::encoding::Depth,
9547        ) -> fidl::Result<()> {
9548            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9549            // Zero out padding regions. There's no need to apply masks
9550            // because the unmasked parts will be overwritten by fields.
9551            // Write the fields.
9552            self.0.encode(encoder, offset + 0, depth)?;
9553            Ok(())
9554        }
9555    }
9556
9557    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9558        for GuestGetSerialResponse
9559    {
9560        #[inline(always)]
9561        fn new_empty() -> Self {
9562            Self {
9563                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9564            }
9565        }
9566
9567        #[inline]
9568        unsafe fn decode(
9569            &mut self,
9570            decoder: &mut fidl::encoding::Decoder<
9571                '_,
9572                fidl::encoding::DefaultFuchsiaResourceDialect,
9573            >,
9574            offset: usize,
9575            _depth: fidl::encoding::Depth,
9576        ) -> fidl::Result<()> {
9577            decoder.debug_check_bounds::<Self>(offset);
9578            // Verify that padding bytes are zero.
9579            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
9580            Ok(())
9581        }
9582    }
9583
9584    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleBindRequest {
9585        type Borrowed<'a> = &'a mut Self;
9586        fn take_or_borrow<'a>(
9587            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9588        ) -> Self::Borrowed<'a> {
9589            value
9590        }
9591    }
9592
9593    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleBindRequest {
9594        type Owned = Self;
9595
9596        #[inline(always)]
9597        fn inline_align(_context: fidl::encoding::Context) -> usize {
9598            4
9599        }
9600
9601        #[inline(always)]
9602        fn inline_size(_context: fidl::encoding::Context) -> usize {
9603            4
9604        }
9605    }
9606
9607    unsafe impl
9608        fidl::encoding::Encode<
9609            GuestLifecycleBindRequest,
9610            fidl::encoding::DefaultFuchsiaResourceDialect,
9611        > for &mut GuestLifecycleBindRequest
9612    {
9613        #[inline]
9614        unsafe fn encode(
9615            self,
9616            encoder: &mut fidl::encoding::Encoder<
9617                '_,
9618                fidl::encoding::DefaultFuchsiaResourceDialect,
9619            >,
9620            offset: usize,
9621            _depth: fidl::encoding::Depth,
9622        ) -> fidl::Result<()> {
9623            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9624            // Delegate to tuple encoding.
9625            fidl::encoding::Encode::<GuestLifecycleBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9626                (
9627                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest),
9628                ),
9629                encoder, offset, _depth
9630            )
9631        }
9632    }
9633    unsafe impl<
9634            T0: fidl::encoding::Encode<
9635                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9636                fidl::encoding::DefaultFuchsiaResourceDialect,
9637            >,
9638        >
9639        fidl::encoding::Encode<
9640            GuestLifecycleBindRequest,
9641            fidl::encoding::DefaultFuchsiaResourceDialect,
9642        > for (T0,)
9643    {
9644        #[inline]
9645        unsafe fn encode(
9646            self,
9647            encoder: &mut fidl::encoding::Encoder<
9648                '_,
9649                fidl::encoding::DefaultFuchsiaResourceDialect,
9650            >,
9651            offset: usize,
9652            depth: fidl::encoding::Depth,
9653        ) -> fidl::Result<()> {
9654            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9655            // Zero out padding regions. There's no need to apply masks
9656            // because the unmasked parts will be overwritten by fields.
9657            // Write the fields.
9658            self.0.encode(encoder, offset + 0, depth)?;
9659            Ok(())
9660        }
9661    }
9662
9663    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9664        for GuestLifecycleBindRequest
9665    {
9666        #[inline(always)]
9667        fn new_empty() -> Self {
9668            Self {
9669                guest: fidl::new_empty!(
9670                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9671                    fidl::encoding::DefaultFuchsiaResourceDialect
9672                ),
9673            }
9674        }
9675
9676        #[inline]
9677        unsafe fn decode(
9678            &mut self,
9679            decoder: &mut fidl::encoding::Decoder<
9680                '_,
9681                fidl::encoding::DefaultFuchsiaResourceDialect,
9682            >,
9683            offset: usize,
9684            _depth: fidl::encoding::Depth,
9685        ) -> fidl::Result<()> {
9686            decoder.debug_check_bounds::<Self>(offset);
9687            // Verify that padding bytes are zero.
9688            fidl::decode!(
9689                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9690                fidl::encoding::DefaultFuchsiaResourceDialect,
9691                &mut self.guest,
9692                decoder,
9693                offset + 0,
9694                _depth
9695            )?;
9696            Ok(())
9697        }
9698    }
9699
9700    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleCreateRequest {
9701        type Borrowed<'a> = &'a mut Self;
9702        fn take_or_borrow<'a>(
9703            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9704        ) -> Self::Borrowed<'a> {
9705            value
9706        }
9707    }
9708
9709    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleCreateRequest {
9710        type Owned = Self;
9711
9712        #[inline(always)]
9713        fn inline_align(_context: fidl::encoding::Context) -> usize {
9714            8
9715        }
9716
9717        #[inline(always)]
9718        fn inline_size(_context: fidl::encoding::Context) -> usize {
9719            16
9720        }
9721    }
9722
9723    unsafe impl
9724        fidl::encoding::Encode<
9725            GuestLifecycleCreateRequest,
9726            fidl::encoding::DefaultFuchsiaResourceDialect,
9727        > for &mut GuestLifecycleCreateRequest
9728    {
9729        #[inline]
9730        unsafe fn encode(
9731            self,
9732            encoder: &mut fidl::encoding::Encoder<
9733                '_,
9734                fidl::encoding::DefaultFuchsiaResourceDialect,
9735            >,
9736            offset: usize,
9737            _depth: fidl::encoding::Depth,
9738        ) -> fidl::Result<()> {
9739            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
9740            // Delegate to tuple encoding.
9741            fidl::encoding::Encode::<
9742                GuestLifecycleCreateRequest,
9743                fidl::encoding::DefaultFuchsiaResourceDialect,
9744            >::encode(
9745                (<GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9746                    &mut self.guest_config,
9747                ),),
9748                encoder,
9749                offset,
9750                _depth,
9751            )
9752        }
9753    }
9754    unsafe impl<
9755            T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
9756        >
9757        fidl::encoding::Encode<
9758            GuestLifecycleCreateRequest,
9759            fidl::encoding::DefaultFuchsiaResourceDialect,
9760        > for (T0,)
9761    {
9762        #[inline]
9763        unsafe fn encode(
9764            self,
9765            encoder: &mut fidl::encoding::Encoder<
9766                '_,
9767                fidl::encoding::DefaultFuchsiaResourceDialect,
9768            >,
9769            offset: usize,
9770            depth: fidl::encoding::Depth,
9771        ) -> fidl::Result<()> {
9772            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
9773            // Zero out padding regions. There's no need to apply masks
9774            // because the unmasked parts will be overwritten by fields.
9775            // Write the fields.
9776            self.0.encode(encoder, offset + 0, depth)?;
9777            Ok(())
9778        }
9779    }
9780
9781    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9782        for GuestLifecycleCreateRequest
9783    {
9784        #[inline(always)]
9785        fn new_empty() -> Self {
9786            Self {
9787                guest_config: fidl::new_empty!(
9788                    GuestConfig,
9789                    fidl::encoding::DefaultFuchsiaResourceDialect
9790                ),
9791            }
9792        }
9793
9794        #[inline]
9795        unsafe fn decode(
9796            &mut self,
9797            decoder: &mut fidl::encoding::Decoder<
9798                '_,
9799                fidl::encoding::DefaultFuchsiaResourceDialect,
9800            >,
9801            offset: usize,
9802            _depth: fidl::encoding::Depth,
9803        ) -> fidl::Result<()> {
9804            decoder.debug_check_bounds::<Self>(offset);
9805            // Verify that padding bytes are zero.
9806            fidl::decode!(
9807                GuestConfig,
9808                fidl::encoding::DefaultFuchsiaResourceDialect,
9809                &mut self.guest_config,
9810                decoder,
9811                offset + 0,
9812                _depth
9813            )?;
9814            Ok(())
9815        }
9816    }
9817
9818    impl fidl::encoding::ResourceTypeMarker for GuestManagerConnectRequest {
9819        type Borrowed<'a> = &'a mut Self;
9820        fn take_or_borrow<'a>(
9821            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9822        ) -> Self::Borrowed<'a> {
9823            value
9824        }
9825    }
9826
9827    unsafe impl fidl::encoding::TypeMarker for GuestManagerConnectRequest {
9828        type Owned = Self;
9829
9830        #[inline(always)]
9831        fn inline_align(_context: fidl::encoding::Context) -> usize {
9832            4
9833        }
9834
9835        #[inline(always)]
9836        fn inline_size(_context: fidl::encoding::Context) -> usize {
9837            4
9838        }
9839    }
9840
9841    unsafe impl
9842        fidl::encoding::Encode<
9843            GuestManagerConnectRequest,
9844            fidl::encoding::DefaultFuchsiaResourceDialect,
9845        > for &mut GuestManagerConnectRequest
9846    {
9847        #[inline]
9848        unsafe fn encode(
9849            self,
9850            encoder: &mut fidl::encoding::Encoder<
9851                '_,
9852                fidl::encoding::DefaultFuchsiaResourceDialect,
9853            >,
9854            offset: usize,
9855            _depth: fidl::encoding::Depth,
9856        ) -> fidl::Result<()> {
9857            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
9858            // Delegate to tuple encoding.
9859            fidl::encoding::Encode::<GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9860                (
9861                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9862                ),
9863                encoder, offset, _depth
9864            )
9865        }
9866    }
9867    unsafe impl<
9868            T0: fidl::encoding::Encode<
9869                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9870                fidl::encoding::DefaultFuchsiaResourceDialect,
9871            >,
9872        >
9873        fidl::encoding::Encode<
9874            GuestManagerConnectRequest,
9875            fidl::encoding::DefaultFuchsiaResourceDialect,
9876        > for (T0,)
9877    {
9878        #[inline]
9879        unsafe fn encode(
9880            self,
9881            encoder: &mut fidl::encoding::Encoder<
9882                '_,
9883                fidl::encoding::DefaultFuchsiaResourceDialect,
9884            >,
9885            offset: usize,
9886            depth: fidl::encoding::Depth,
9887        ) -> fidl::Result<()> {
9888            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
9889            // Zero out padding regions. There's no need to apply masks
9890            // because the unmasked parts will be overwritten by fields.
9891            // Write the fields.
9892            self.0.encode(encoder, offset + 0, depth)?;
9893            Ok(())
9894        }
9895    }
9896
9897    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9898        for GuestManagerConnectRequest
9899    {
9900        #[inline(always)]
9901        fn new_empty() -> Self {
9902            Self {
9903                controller: fidl::new_empty!(
9904                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9905                    fidl::encoding::DefaultFuchsiaResourceDialect
9906                ),
9907            }
9908        }
9909
9910        #[inline]
9911        unsafe fn decode(
9912            &mut self,
9913            decoder: &mut fidl::encoding::Decoder<
9914                '_,
9915                fidl::encoding::DefaultFuchsiaResourceDialect,
9916            >,
9917            offset: usize,
9918            _depth: fidl::encoding::Depth,
9919        ) -> fidl::Result<()> {
9920            decoder.debug_check_bounds::<Self>(offset);
9921            // Verify that padding bytes are zero.
9922            fidl::decode!(
9923                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9924                fidl::encoding::DefaultFuchsiaResourceDialect,
9925                &mut self.controller,
9926                decoder,
9927                offset + 0,
9928                _depth
9929            )?;
9930            Ok(())
9931        }
9932    }
9933
9934    impl fidl::encoding::ResourceTypeMarker for GuestManagerGetInfoResponse {
9935        type Borrowed<'a> = &'a mut Self;
9936        fn take_or_borrow<'a>(
9937            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9938        ) -> Self::Borrowed<'a> {
9939            value
9940        }
9941    }
9942
9943    unsafe impl fidl::encoding::TypeMarker for GuestManagerGetInfoResponse {
9944        type Owned = Self;
9945
9946        #[inline(always)]
9947        fn inline_align(_context: fidl::encoding::Context) -> usize {
9948            8
9949        }
9950
9951        #[inline(always)]
9952        fn inline_size(_context: fidl::encoding::Context) -> usize {
9953            16
9954        }
9955    }
9956
9957    unsafe impl
9958        fidl::encoding::Encode<
9959            GuestManagerGetInfoResponse,
9960            fidl::encoding::DefaultFuchsiaResourceDialect,
9961        > for &mut GuestManagerGetInfoResponse
9962    {
9963        #[inline]
9964        unsafe fn encode(
9965            self,
9966            encoder: &mut fidl::encoding::Encoder<
9967                '_,
9968                fidl::encoding::DefaultFuchsiaResourceDialect,
9969            >,
9970            offset: usize,
9971            _depth: fidl::encoding::Depth,
9972        ) -> fidl::Result<()> {
9973            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
9974            // Delegate to tuple encoding.
9975            fidl::encoding::Encode::<
9976                GuestManagerGetInfoResponse,
9977                fidl::encoding::DefaultFuchsiaResourceDialect,
9978            >::encode(
9979                (<GuestInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.guest_info),),
9980                encoder,
9981                offset,
9982                _depth,
9983            )
9984        }
9985    }
9986    unsafe impl<T0: fidl::encoding::Encode<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>>
9987        fidl::encoding::Encode<
9988            GuestManagerGetInfoResponse,
9989            fidl::encoding::DefaultFuchsiaResourceDialect,
9990        > for (T0,)
9991    {
9992        #[inline]
9993        unsafe fn encode(
9994            self,
9995            encoder: &mut fidl::encoding::Encoder<
9996                '_,
9997                fidl::encoding::DefaultFuchsiaResourceDialect,
9998            >,
9999            offset: usize,
10000            depth: fidl::encoding::Depth,
10001        ) -> fidl::Result<()> {
10002            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10003            // Zero out padding regions. There's no need to apply masks
10004            // because the unmasked parts will be overwritten by fields.
10005            // Write the fields.
10006            self.0.encode(encoder, offset + 0, depth)?;
10007            Ok(())
10008        }
10009    }
10010
10011    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10012        for GuestManagerGetInfoResponse
10013    {
10014        #[inline(always)]
10015        fn new_empty() -> Self {
10016            Self {
10017                guest_info: fidl::new_empty!(
10018                    GuestInfo,
10019                    fidl::encoding::DefaultFuchsiaResourceDialect
10020                ),
10021            }
10022        }
10023
10024        #[inline]
10025        unsafe fn decode(
10026            &mut self,
10027            decoder: &mut fidl::encoding::Decoder<
10028                '_,
10029                fidl::encoding::DefaultFuchsiaResourceDialect,
10030            >,
10031            offset: usize,
10032            _depth: fidl::encoding::Depth,
10033        ) -> fidl::Result<()> {
10034            decoder.debug_check_bounds::<Self>(offset);
10035            // Verify that padding bytes are zero.
10036            fidl::decode!(
10037                GuestInfo,
10038                fidl::encoding::DefaultFuchsiaResourceDialect,
10039                &mut self.guest_info,
10040                decoder,
10041                offset + 0,
10042                _depth
10043            )?;
10044            Ok(())
10045        }
10046    }
10047
10048    impl fidl::encoding::ResourceTypeMarker for GuestManagerLaunchRequest {
10049        type Borrowed<'a> = &'a mut Self;
10050        fn take_or_borrow<'a>(
10051            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10052        ) -> Self::Borrowed<'a> {
10053            value
10054        }
10055    }
10056
10057    unsafe impl fidl::encoding::TypeMarker for GuestManagerLaunchRequest {
10058        type Owned = Self;
10059
10060        #[inline(always)]
10061        fn inline_align(_context: fidl::encoding::Context) -> usize {
10062            8
10063        }
10064
10065        #[inline(always)]
10066        fn inline_size(_context: fidl::encoding::Context) -> usize {
10067            24
10068        }
10069    }
10070
10071    unsafe impl
10072        fidl::encoding::Encode<
10073            GuestManagerLaunchRequest,
10074            fidl::encoding::DefaultFuchsiaResourceDialect,
10075        > for &mut GuestManagerLaunchRequest
10076    {
10077        #[inline]
10078        unsafe fn encode(
10079            self,
10080            encoder: &mut fidl::encoding::Encoder<
10081                '_,
10082                fidl::encoding::DefaultFuchsiaResourceDialect,
10083            >,
10084            offset: usize,
10085            _depth: fidl::encoding::Depth,
10086        ) -> fidl::Result<()> {
10087            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10088            // Delegate to tuple encoding.
10089            fidl::encoding::Encode::<GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10090                (
10091                    <GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest_config),
10092                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10093                ),
10094                encoder, offset, _depth
10095            )
10096        }
10097    }
10098    unsafe impl<
10099            T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
10100            T1: fidl::encoding::Encode<
10101                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10102                fidl::encoding::DefaultFuchsiaResourceDialect,
10103            >,
10104        >
10105        fidl::encoding::Encode<
10106            GuestManagerLaunchRequest,
10107            fidl::encoding::DefaultFuchsiaResourceDialect,
10108        > for (T0, T1)
10109    {
10110        #[inline]
10111        unsafe fn encode(
10112            self,
10113            encoder: &mut fidl::encoding::Encoder<
10114                '_,
10115                fidl::encoding::DefaultFuchsiaResourceDialect,
10116            >,
10117            offset: usize,
10118            depth: fidl::encoding::Depth,
10119        ) -> fidl::Result<()> {
10120            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10121            // Zero out padding regions. There's no need to apply masks
10122            // because the unmasked parts will be overwritten by fields.
10123            unsafe {
10124                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10125                (ptr as *mut u64).write_unaligned(0);
10126            }
10127            // Write the fields.
10128            self.0.encode(encoder, offset + 0, depth)?;
10129            self.1.encode(encoder, offset + 16, depth)?;
10130            Ok(())
10131        }
10132    }
10133
10134    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10135        for GuestManagerLaunchRequest
10136    {
10137        #[inline(always)]
10138        fn new_empty() -> Self {
10139            Self {
10140                guest_config: fidl::new_empty!(
10141                    GuestConfig,
10142                    fidl::encoding::DefaultFuchsiaResourceDialect
10143                ),
10144                controller: fidl::new_empty!(
10145                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10146                    fidl::encoding::DefaultFuchsiaResourceDialect
10147                ),
10148            }
10149        }
10150
10151        #[inline]
10152        unsafe fn decode(
10153            &mut self,
10154            decoder: &mut fidl::encoding::Decoder<
10155                '_,
10156                fidl::encoding::DefaultFuchsiaResourceDialect,
10157            >,
10158            offset: usize,
10159            _depth: fidl::encoding::Depth,
10160        ) -> fidl::Result<()> {
10161            decoder.debug_check_bounds::<Self>(offset);
10162            // Verify that padding bytes are zero.
10163            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10164            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10165            let mask = 0xffffffff00000000u64;
10166            let maskedval = padval & mask;
10167            if maskedval != 0 {
10168                return Err(fidl::Error::NonZeroPadding {
10169                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10170                });
10171            }
10172            fidl::decode!(
10173                GuestConfig,
10174                fidl::encoding::DefaultFuchsiaResourceDialect,
10175                &mut self.guest_config,
10176                decoder,
10177                offset + 0,
10178                _depth
10179            )?;
10180            fidl::decode!(
10181                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10182                fidl::encoding::DefaultFuchsiaResourceDialect,
10183                &mut self.controller,
10184                decoder,
10185                offset + 16,
10186                _depth
10187            )?;
10188            Ok(())
10189        }
10190    }
10191
10192    impl fidl::encoding::ResourceTypeMarker for GuestGetConsoleResponse {
10193        type Borrowed<'a> = &'a mut Self;
10194        fn take_or_borrow<'a>(
10195            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10196        ) -> Self::Borrowed<'a> {
10197            value
10198        }
10199    }
10200
10201    unsafe impl fidl::encoding::TypeMarker for GuestGetConsoleResponse {
10202        type Owned = Self;
10203
10204        #[inline(always)]
10205        fn inline_align(_context: fidl::encoding::Context) -> usize {
10206            4
10207        }
10208
10209        #[inline(always)]
10210        fn inline_size(_context: fidl::encoding::Context) -> usize {
10211            4
10212        }
10213    }
10214
10215    unsafe impl
10216        fidl::encoding::Encode<
10217            GuestGetConsoleResponse,
10218            fidl::encoding::DefaultFuchsiaResourceDialect,
10219        > for &mut GuestGetConsoleResponse
10220    {
10221        #[inline]
10222        unsafe fn encode(
10223            self,
10224            encoder: &mut fidl::encoding::Encoder<
10225                '_,
10226                fidl::encoding::DefaultFuchsiaResourceDialect,
10227            >,
10228            offset: usize,
10229            _depth: fidl::encoding::Depth,
10230        ) -> fidl::Result<()> {
10231            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10232            // Delegate to tuple encoding.
10233            fidl::encoding::Encode::<
10234                GuestGetConsoleResponse,
10235                fidl::encoding::DefaultFuchsiaResourceDialect,
10236            >::encode(
10237                (<fidl::encoding::HandleType<
10238                    fidl::Socket,
10239                    { fidl::ObjectType::SOCKET.into_raw() },
10240                    2147483648,
10241                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10242                    &mut self.socket
10243                ),),
10244                encoder,
10245                offset,
10246                _depth,
10247            )
10248        }
10249    }
10250    unsafe impl<
10251            T0: fidl::encoding::Encode<
10252                fidl::encoding::HandleType<
10253                    fidl::Socket,
10254                    { fidl::ObjectType::SOCKET.into_raw() },
10255                    2147483648,
10256                >,
10257                fidl::encoding::DefaultFuchsiaResourceDialect,
10258            >,
10259        >
10260        fidl::encoding::Encode<
10261            GuestGetConsoleResponse,
10262            fidl::encoding::DefaultFuchsiaResourceDialect,
10263        > for (T0,)
10264    {
10265        #[inline]
10266        unsafe fn encode(
10267            self,
10268            encoder: &mut fidl::encoding::Encoder<
10269                '_,
10270                fidl::encoding::DefaultFuchsiaResourceDialect,
10271            >,
10272            offset: usize,
10273            depth: fidl::encoding::Depth,
10274        ) -> fidl::Result<()> {
10275            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10276            // Zero out padding regions. There's no need to apply masks
10277            // because the unmasked parts will be overwritten by fields.
10278            // Write the fields.
10279            self.0.encode(encoder, offset + 0, depth)?;
10280            Ok(())
10281        }
10282    }
10283
10284    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10285        for GuestGetConsoleResponse
10286    {
10287        #[inline(always)]
10288        fn new_empty() -> Self {
10289            Self {
10290                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10291            }
10292        }
10293
10294        #[inline]
10295        unsafe fn decode(
10296            &mut self,
10297            decoder: &mut fidl::encoding::Decoder<
10298                '_,
10299                fidl::encoding::DefaultFuchsiaResourceDialect,
10300            >,
10301            offset: usize,
10302            _depth: fidl::encoding::Depth,
10303        ) -> fidl::Result<()> {
10304            decoder.debug_check_bounds::<Self>(offset);
10305            // Verify that padding bytes are zero.
10306            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10307            Ok(())
10308        }
10309    }
10310
10311    impl fidl::encoding::ResourceTypeMarker for HostVsockAcceptorAcceptResponse {
10312        type Borrowed<'a> = &'a mut Self;
10313        fn take_or_borrow<'a>(
10314            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10315        ) -> Self::Borrowed<'a> {
10316            value
10317        }
10318    }
10319
10320    unsafe impl fidl::encoding::TypeMarker for HostVsockAcceptorAcceptResponse {
10321        type Owned = Self;
10322
10323        #[inline(always)]
10324        fn inline_align(_context: fidl::encoding::Context) -> usize {
10325            4
10326        }
10327
10328        #[inline(always)]
10329        fn inline_size(_context: fidl::encoding::Context) -> usize {
10330            4
10331        }
10332    }
10333
10334    unsafe impl
10335        fidl::encoding::Encode<
10336            HostVsockAcceptorAcceptResponse,
10337            fidl::encoding::DefaultFuchsiaResourceDialect,
10338        > for &mut HostVsockAcceptorAcceptResponse
10339    {
10340        #[inline]
10341        unsafe fn encode(
10342            self,
10343            encoder: &mut fidl::encoding::Encoder<
10344                '_,
10345                fidl::encoding::DefaultFuchsiaResourceDialect,
10346            >,
10347            offset: usize,
10348            _depth: fidl::encoding::Depth,
10349        ) -> fidl::Result<()> {
10350            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10351            // Delegate to tuple encoding.
10352            fidl::encoding::Encode::<
10353                HostVsockAcceptorAcceptResponse,
10354                fidl::encoding::DefaultFuchsiaResourceDialect,
10355            >::encode(
10356                (<fidl::encoding::HandleType<
10357                    fidl::Socket,
10358                    { fidl::ObjectType::SOCKET.into_raw() },
10359                    2147483648,
10360                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10361                    &mut self.socket
10362                ),),
10363                encoder,
10364                offset,
10365                _depth,
10366            )
10367        }
10368    }
10369    unsafe impl<
10370            T0: fidl::encoding::Encode<
10371                fidl::encoding::HandleType<
10372                    fidl::Socket,
10373                    { fidl::ObjectType::SOCKET.into_raw() },
10374                    2147483648,
10375                >,
10376                fidl::encoding::DefaultFuchsiaResourceDialect,
10377            >,
10378        >
10379        fidl::encoding::Encode<
10380            HostVsockAcceptorAcceptResponse,
10381            fidl::encoding::DefaultFuchsiaResourceDialect,
10382        > for (T0,)
10383    {
10384        #[inline]
10385        unsafe fn encode(
10386            self,
10387            encoder: &mut fidl::encoding::Encoder<
10388                '_,
10389                fidl::encoding::DefaultFuchsiaResourceDialect,
10390            >,
10391            offset: usize,
10392            depth: fidl::encoding::Depth,
10393        ) -> fidl::Result<()> {
10394            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10395            // Zero out padding regions. There's no need to apply masks
10396            // because the unmasked parts will be overwritten by fields.
10397            // Write the fields.
10398            self.0.encode(encoder, offset + 0, depth)?;
10399            Ok(())
10400        }
10401    }
10402
10403    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10404        for HostVsockAcceptorAcceptResponse
10405    {
10406        #[inline(always)]
10407        fn new_empty() -> Self {
10408            Self {
10409                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10410            }
10411        }
10412
10413        #[inline]
10414        unsafe fn decode(
10415            &mut self,
10416            decoder: &mut fidl::encoding::Decoder<
10417                '_,
10418                fidl::encoding::DefaultFuchsiaResourceDialect,
10419            >,
10420            offset: usize,
10421            _depth: fidl::encoding::Depth,
10422        ) -> fidl::Result<()> {
10423            decoder.debug_check_bounds::<Self>(offset);
10424            // Verify that padding bytes are zero.
10425            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10426            Ok(())
10427        }
10428    }
10429
10430    impl fidl::encoding::ResourceTypeMarker for HostVsockEndpointConnectResponse {
10431        type Borrowed<'a> = &'a mut Self;
10432        fn take_or_borrow<'a>(
10433            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10434        ) -> Self::Borrowed<'a> {
10435            value
10436        }
10437    }
10438
10439    unsafe impl fidl::encoding::TypeMarker for HostVsockEndpointConnectResponse {
10440        type Owned = Self;
10441
10442        #[inline(always)]
10443        fn inline_align(_context: fidl::encoding::Context) -> usize {
10444            4
10445        }
10446
10447        #[inline(always)]
10448        fn inline_size(_context: fidl::encoding::Context) -> usize {
10449            4
10450        }
10451    }
10452
10453    unsafe impl
10454        fidl::encoding::Encode<
10455            HostVsockEndpointConnectResponse,
10456            fidl::encoding::DefaultFuchsiaResourceDialect,
10457        > for &mut HostVsockEndpointConnectResponse
10458    {
10459        #[inline]
10460        unsafe fn encode(
10461            self,
10462            encoder: &mut fidl::encoding::Encoder<
10463                '_,
10464                fidl::encoding::DefaultFuchsiaResourceDialect,
10465            >,
10466            offset: usize,
10467            _depth: fidl::encoding::Depth,
10468        ) -> fidl::Result<()> {
10469            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10470            // Delegate to tuple encoding.
10471            fidl::encoding::Encode::<
10472                HostVsockEndpointConnectResponse,
10473                fidl::encoding::DefaultFuchsiaResourceDialect,
10474            >::encode(
10475                (<fidl::encoding::HandleType<
10476                    fidl::Socket,
10477                    { fidl::ObjectType::SOCKET.into_raw() },
10478                    2147483648,
10479                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10480                    &mut self.socket
10481                ),),
10482                encoder,
10483                offset,
10484                _depth,
10485            )
10486        }
10487    }
10488    unsafe impl<
10489            T0: fidl::encoding::Encode<
10490                fidl::encoding::HandleType<
10491                    fidl::Socket,
10492                    { fidl::ObjectType::SOCKET.into_raw() },
10493                    2147483648,
10494                >,
10495                fidl::encoding::DefaultFuchsiaResourceDialect,
10496            >,
10497        >
10498        fidl::encoding::Encode<
10499            HostVsockEndpointConnectResponse,
10500            fidl::encoding::DefaultFuchsiaResourceDialect,
10501        > for (T0,)
10502    {
10503        #[inline]
10504        unsafe fn encode(
10505            self,
10506            encoder: &mut fidl::encoding::Encoder<
10507                '_,
10508                fidl::encoding::DefaultFuchsiaResourceDialect,
10509            >,
10510            offset: usize,
10511            depth: fidl::encoding::Depth,
10512        ) -> fidl::Result<()> {
10513            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10514            // Zero out padding regions. There's no need to apply masks
10515            // because the unmasked parts will be overwritten by fields.
10516            // Write the fields.
10517            self.0.encode(encoder, offset + 0, depth)?;
10518            Ok(())
10519        }
10520    }
10521
10522    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10523        for HostVsockEndpointConnectResponse
10524    {
10525        #[inline(always)]
10526        fn new_empty() -> Self {
10527            Self {
10528                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10529            }
10530        }
10531
10532        #[inline]
10533        unsafe fn decode(
10534            &mut self,
10535            decoder: &mut fidl::encoding::Decoder<
10536                '_,
10537                fidl::encoding::DefaultFuchsiaResourceDialect,
10538            >,
10539            offset: usize,
10540            _depth: fidl::encoding::Depth,
10541        ) -> fidl::Result<()> {
10542            decoder.debug_check_bounds::<Self>(offset);
10543            // Verify that padding bytes are zero.
10544            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10545            Ok(())
10546        }
10547    }
10548
10549    impl fidl::encoding::ResourceTypeMarker for Listener {
10550        type Borrowed<'a> = &'a mut Self;
10551        fn take_or_borrow<'a>(
10552            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10553        ) -> Self::Borrowed<'a> {
10554            value
10555        }
10556    }
10557
10558    unsafe impl fidl::encoding::TypeMarker for Listener {
10559        type Owned = Self;
10560
10561        #[inline(always)]
10562        fn inline_align(_context: fidl::encoding::Context) -> usize {
10563            4
10564        }
10565
10566        #[inline(always)]
10567        fn inline_size(_context: fidl::encoding::Context) -> usize {
10568            8
10569        }
10570    }
10571
10572    unsafe impl fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>
10573        for &mut Listener
10574    {
10575        #[inline]
10576        unsafe fn encode(
10577            self,
10578            encoder: &mut fidl::encoding::Encoder<
10579                '_,
10580                fidl::encoding::DefaultFuchsiaResourceDialect,
10581            >,
10582            offset: usize,
10583            _depth: fidl::encoding::Depth,
10584        ) -> fidl::Result<()> {
10585            encoder.debug_check_bounds::<Listener>(offset);
10586            // Delegate to tuple encoding.
10587            fidl::encoding::Encode::<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10588                (
10589                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.port),
10590                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.acceptor),
10591                ),
10592                encoder, offset, _depth
10593            )
10594        }
10595    }
10596    unsafe impl<
10597            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
10598            T1: fidl::encoding::Encode<
10599                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10600                fidl::encoding::DefaultFuchsiaResourceDialect,
10601            >,
10602        > fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>
10603        for (T0, T1)
10604    {
10605        #[inline]
10606        unsafe fn encode(
10607            self,
10608            encoder: &mut fidl::encoding::Encoder<
10609                '_,
10610                fidl::encoding::DefaultFuchsiaResourceDialect,
10611            >,
10612            offset: usize,
10613            depth: fidl::encoding::Depth,
10614        ) -> fidl::Result<()> {
10615            encoder.debug_check_bounds::<Listener>(offset);
10616            // Zero out padding regions. There's no need to apply masks
10617            // because the unmasked parts will be overwritten by fields.
10618            // Write the fields.
10619            self.0.encode(encoder, offset + 0, depth)?;
10620            self.1.encode(encoder, offset + 4, depth)?;
10621            Ok(())
10622        }
10623    }
10624
10625    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Listener {
10626        #[inline(always)]
10627        fn new_empty() -> Self {
10628            Self {
10629                port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
10630                acceptor: fidl::new_empty!(
10631                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10632                    fidl::encoding::DefaultFuchsiaResourceDialect
10633                ),
10634            }
10635        }
10636
10637        #[inline]
10638        unsafe fn decode(
10639            &mut self,
10640            decoder: &mut fidl::encoding::Decoder<
10641                '_,
10642                fidl::encoding::DefaultFuchsiaResourceDialect,
10643            >,
10644            offset: usize,
10645            _depth: fidl::encoding::Depth,
10646        ) -> fidl::Result<()> {
10647            decoder.debug_check_bounds::<Self>(offset);
10648            // Verify that padding bytes are zero.
10649            fidl::decode!(
10650                u32,
10651                fidl::encoding::DefaultFuchsiaResourceDialect,
10652                &mut self.port,
10653                decoder,
10654                offset + 0,
10655                _depth
10656            )?;
10657            fidl::decode!(
10658                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10659                fidl::encoding::DefaultFuchsiaResourceDialect,
10660                &mut self.acceptor,
10661                decoder,
10662                offset + 4,
10663                _depth
10664            )?;
10665            Ok(())
10666        }
10667    }
10668
10669    impl fidl::encoding::ResourceTypeMarker for WaylandDevice {
10670        type Borrowed<'a> = &'a mut Self;
10671        fn take_or_borrow<'a>(
10672            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10673        ) -> Self::Borrowed<'a> {
10674            value
10675        }
10676    }
10677
10678    unsafe impl fidl::encoding::TypeMarker for WaylandDevice {
10679        type Owned = Self;
10680
10681        #[inline(always)]
10682        fn inline_align(_context: fidl::encoding::Context) -> usize {
10683            8
10684        }
10685
10686        #[inline(always)]
10687        fn inline_size(_context: fidl::encoding::Context) -> usize {
10688            16
10689        }
10690    }
10691
10692    unsafe impl fidl::encoding::Encode<WaylandDevice, fidl::encoding::DefaultFuchsiaResourceDialect>
10693        for &mut WaylandDevice
10694    {
10695        #[inline]
10696        unsafe fn encode(
10697            self,
10698            encoder: &mut fidl::encoding::Encoder<
10699                '_,
10700                fidl::encoding::DefaultFuchsiaResourceDialect,
10701            >,
10702            offset: usize,
10703            _depth: fidl::encoding::Depth,
10704        ) -> fidl::Result<()> {
10705            encoder.debug_check_bounds::<WaylandDevice>(offset);
10706            // Delegate to tuple encoding.
10707            fidl::encoding::Encode::<WaylandDevice, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10708                (
10709                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.memory),
10710                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server),
10711                ),
10712                encoder, offset, _depth
10713            )
10714        }
10715    }
10716    unsafe impl<
10717            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
10718            T1: fidl::encoding::Encode<
10719                fidl::encoding::Optional<
10720                    fidl::encoding::Endpoint<
10721                        fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
10722                    >,
10723                >,
10724                fidl::encoding::DefaultFuchsiaResourceDialect,
10725            >,
10726        > fidl::encoding::Encode<WaylandDevice, fidl::encoding::DefaultFuchsiaResourceDialect>
10727        for (T0, T1)
10728    {
10729        #[inline]
10730        unsafe fn encode(
10731            self,
10732            encoder: &mut fidl::encoding::Encoder<
10733                '_,
10734                fidl::encoding::DefaultFuchsiaResourceDialect,
10735            >,
10736            offset: usize,
10737            depth: fidl::encoding::Depth,
10738        ) -> fidl::Result<()> {
10739            encoder.debug_check_bounds::<WaylandDevice>(offset);
10740            // Zero out padding regions. There's no need to apply masks
10741            // because the unmasked parts will be overwritten by fields.
10742            unsafe {
10743                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
10744                (ptr as *mut u64).write_unaligned(0);
10745            }
10746            // Write the fields.
10747            self.0.encode(encoder, offset + 0, depth)?;
10748            self.1.encode(encoder, offset + 8, depth)?;
10749            Ok(())
10750        }
10751    }
10752
10753    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for WaylandDevice {
10754        #[inline(always)]
10755        fn new_empty() -> Self {
10756            Self {
10757                memory: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
10758                server: fidl::new_empty!(
10759                    fidl::encoding::Optional<
10760                        fidl::encoding::Endpoint<
10761                            fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
10762                        >,
10763                    >,
10764                    fidl::encoding::DefaultFuchsiaResourceDialect
10765                ),
10766            }
10767        }
10768
10769        #[inline]
10770        unsafe fn decode(
10771            &mut self,
10772            decoder: &mut fidl::encoding::Decoder<
10773                '_,
10774                fidl::encoding::DefaultFuchsiaResourceDialect,
10775            >,
10776            offset: usize,
10777            _depth: fidl::encoding::Depth,
10778        ) -> fidl::Result<()> {
10779            decoder.debug_check_bounds::<Self>(offset);
10780            // Verify that padding bytes are zero.
10781            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
10782            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10783            let mask = 0xffffffff00000000u64;
10784            let maskedval = padval & mask;
10785            if maskedval != 0 {
10786                return Err(fidl::Error::NonZeroPadding {
10787                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
10788                });
10789            }
10790            fidl::decode!(
10791                u64,
10792                fidl::encoding::DefaultFuchsiaResourceDialect,
10793                &mut self.memory,
10794                decoder,
10795                offset + 0,
10796                _depth
10797            )?;
10798            fidl::decode!(
10799                fidl::encoding::Optional<
10800                    fidl::encoding::Endpoint<
10801                        fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
10802                    >,
10803                >,
10804                fidl::encoding::DefaultFuchsiaResourceDialect,
10805                &mut self.server,
10806                decoder,
10807                offset + 8,
10808                _depth
10809            )?;
10810            Ok(())
10811        }
10812    }
10813
10814    impl GuestConfig {
10815        #[inline(always)]
10816        fn max_ordinal_present(&self) -> u64 {
10817            if let Some(_) = self.virtio_mem_region_alignment {
10818                return 25;
10819            }
10820            if let Some(_) = self.virtio_mem_region_size {
10821                return 24;
10822            }
10823            if let Some(_) = self.virtio_mem_block_size {
10824                return 23;
10825            }
10826            if let Some(_) = self.virtio_mem {
10827                return 22;
10828            }
10829            if let Some(_) = self.vsock_listeners {
10830                return 21;
10831            }
10832            if let Some(_) = self.virtio_sound_input {
10833                return 20;
10834            }
10835            if let Some(_) = self.virtio_sound {
10836                return 19;
10837            }
10838            if let Some(_) = self.virtio_vsock {
10839                return 18;
10840            }
10841            if let Some(_) = self.virtio_rng {
10842                return 17;
10843            }
10844            if let Some(_) = self.virtio_gpu {
10845                return 16;
10846            }
10847            if let Some(_) = self.virtio_console {
10848                return 15;
10849            }
10850            if let Some(_) = self.virtio_balloon {
10851                return 14;
10852            }
10853            if let Some(_) = self.default_net {
10854                return 13;
10855            }
10856            if let Some(_) = self.magma_device {
10857                return 12;
10858            }
10859            if let Some(_) = self.wayland_device {
10860                return 11;
10861            }
10862            if let Some(_) = self.net_devices {
10863                return 10;
10864            }
10865            if let Some(_) = self.block_devices {
10866                return 9;
10867            }
10868            if let Some(_) = self.guest_memory {
10869                return 8;
10870            }
10871            if let Some(_) = self.cpus {
10872                return 7;
10873            }
10874            if let Some(_) = self.cmdline_add {
10875                return 6;
10876            }
10877            if let Some(_) = self.cmdline {
10878                return 5;
10879            }
10880            if let Some(_) = self.dtb_overlay {
10881                return 4;
10882            }
10883            if let Some(_) = self.ramdisk {
10884                return 3;
10885            }
10886            if let Some(_) = self.kernel {
10887                return 2;
10888            }
10889            if let Some(_) = self.kernel_type {
10890                return 1;
10891            }
10892            0
10893        }
10894    }
10895
10896    impl fidl::encoding::ResourceTypeMarker for GuestConfig {
10897        type Borrowed<'a> = &'a mut Self;
10898        fn take_or_borrow<'a>(
10899            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10900        ) -> Self::Borrowed<'a> {
10901            value
10902        }
10903    }
10904
10905    unsafe impl fidl::encoding::TypeMarker for GuestConfig {
10906        type Owned = Self;
10907
10908        #[inline(always)]
10909        fn inline_align(_context: fidl::encoding::Context) -> usize {
10910            8
10911        }
10912
10913        #[inline(always)]
10914        fn inline_size(_context: fidl::encoding::Context) -> usize {
10915            16
10916        }
10917    }
10918
10919    unsafe impl fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
10920        for &mut GuestConfig
10921    {
10922        unsafe fn encode(
10923            self,
10924            encoder: &mut fidl::encoding::Encoder<
10925                '_,
10926                fidl::encoding::DefaultFuchsiaResourceDialect,
10927            >,
10928            offset: usize,
10929            mut depth: fidl::encoding::Depth,
10930        ) -> fidl::Result<()> {
10931            encoder.debug_check_bounds::<GuestConfig>(offset);
10932            // Vector header
10933            let max_ordinal: u64 = self.max_ordinal_present();
10934            encoder.write_num(max_ordinal, offset);
10935            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10936            // Calling encoder.out_of_line_offset(0) is not allowed.
10937            if max_ordinal == 0 {
10938                return Ok(());
10939            }
10940            depth.increment()?;
10941            let envelope_size = 8;
10942            let bytes_len = max_ordinal as usize * envelope_size;
10943            #[allow(unused_variables)]
10944            let offset = encoder.out_of_line_offset(bytes_len);
10945            let mut _prev_end_offset: usize = 0;
10946            if 1 > max_ordinal {
10947                return Ok(());
10948            }
10949
10950            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10951            // are envelope_size bytes.
10952            let cur_offset: usize = (1 - 1) * envelope_size;
10953
10954            // Zero reserved fields.
10955            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10956
10957            // Safety:
10958            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10959            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10960            //   envelope_size bytes, there is always sufficient room.
10961            fidl::encoding::encode_in_envelope_optional::<
10962                KernelType,
10963                fidl::encoding::DefaultFuchsiaResourceDialect,
10964            >(
10965                self.kernel_type
10966                    .as_ref()
10967                    .map(<KernelType as fidl::encoding::ValueTypeMarker>::borrow),
10968                encoder,
10969                offset + cur_offset,
10970                depth,
10971            )?;
10972
10973            _prev_end_offset = cur_offset + envelope_size;
10974            if 2 > max_ordinal {
10975                return Ok(());
10976            }
10977
10978            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10979            // are envelope_size bytes.
10980            let cur_offset: usize = (2 - 1) * envelope_size;
10981
10982            // Zero reserved fields.
10983            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10984
10985            // Safety:
10986            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10987            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10988            //   envelope_size bytes, there is always sufficient room.
10989            fidl::encoding::encode_in_envelope_optional::<
10990                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
10991                fidl::encoding::DefaultFuchsiaResourceDialect,
10992            >(
10993                self.kernel.as_mut().map(
10994                    <fidl::encoding::Endpoint<
10995                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
10996                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10997                ),
10998                encoder,
10999                offset + cur_offset,
11000                depth,
11001            )?;
11002
11003            _prev_end_offset = cur_offset + envelope_size;
11004            if 3 > max_ordinal {
11005                return Ok(());
11006            }
11007
11008            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11009            // are envelope_size bytes.
11010            let cur_offset: usize = (3 - 1) * envelope_size;
11011
11012            // Zero reserved fields.
11013            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11014
11015            // Safety:
11016            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11017            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11018            //   envelope_size bytes, there is always sufficient room.
11019            fidl::encoding::encode_in_envelope_optional::<
11020                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11021                fidl::encoding::DefaultFuchsiaResourceDialect,
11022            >(
11023                self.ramdisk.as_mut().map(
11024                    <fidl::encoding::Endpoint<
11025                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11026                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11027                ),
11028                encoder,
11029                offset + cur_offset,
11030                depth,
11031            )?;
11032
11033            _prev_end_offset = cur_offset + envelope_size;
11034            if 4 > max_ordinal {
11035                return Ok(());
11036            }
11037
11038            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11039            // are envelope_size bytes.
11040            let cur_offset: usize = (4 - 1) * envelope_size;
11041
11042            // Zero reserved fields.
11043            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11044
11045            // Safety:
11046            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11047            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11048            //   envelope_size bytes, there is always sufficient room.
11049            fidl::encoding::encode_in_envelope_optional::<
11050                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11051                fidl::encoding::DefaultFuchsiaResourceDialect,
11052            >(
11053                self.dtb_overlay.as_mut().map(
11054                    <fidl::encoding::Endpoint<
11055                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11056                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11057                ),
11058                encoder,
11059                offset + cur_offset,
11060                depth,
11061            )?;
11062
11063            _prev_end_offset = cur_offset + envelope_size;
11064            if 5 > max_ordinal {
11065                return Ok(());
11066            }
11067
11068            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11069            // are envelope_size bytes.
11070            let cur_offset: usize = (5 - 1) * envelope_size;
11071
11072            // Zero reserved fields.
11073            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11074
11075            // Safety:
11076            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11077            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11078            //   envelope_size bytes, there is always sufficient room.
11079            fidl::encoding::encode_in_envelope_optional::<
11080                fidl::encoding::UnboundedString,
11081                fidl::encoding::DefaultFuchsiaResourceDialect,
11082            >(
11083                self.cmdline.as_ref().map(
11084                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
11085                ),
11086                encoder,
11087                offset + cur_offset,
11088                depth,
11089            )?;
11090
11091            _prev_end_offset = cur_offset + envelope_size;
11092            if 6 > max_ordinal {
11093                return Ok(());
11094            }
11095
11096            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11097            // are envelope_size bytes.
11098            let cur_offset: usize = (6 - 1) * envelope_size;
11099
11100            // Zero reserved fields.
11101            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11102
11103            // Safety:
11104            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11105            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11106            //   envelope_size bytes, there is always sufficient room.
11107            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11108            self.cmdline_add.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow),
11109            encoder, offset + cur_offset, depth
11110        )?;
11111
11112            _prev_end_offset = cur_offset + envelope_size;
11113            if 7 > max_ordinal {
11114                return Ok(());
11115            }
11116
11117            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11118            // are envelope_size bytes.
11119            let cur_offset: usize = (7 - 1) * envelope_size;
11120
11121            // Zero reserved fields.
11122            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11123
11124            // Safety:
11125            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11126            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11127            //   envelope_size bytes, there is always sufficient room.
11128            fidl::encoding::encode_in_envelope_optional::<
11129                u8,
11130                fidl::encoding::DefaultFuchsiaResourceDialect,
11131            >(
11132                self.cpus.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
11133                encoder,
11134                offset + cur_offset,
11135                depth,
11136            )?;
11137
11138            _prev_end_offset = cur_offset + envelope_size;
11139            if 8 > max_ordinal {
11140                return Ok(());
11141            }
11142
11143            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11144            // are envelope_size bytes.
11145            let cur_offset: usize = (8 - 1) * envelope_size;
11146
11147            // Zero reserved fields.
11148            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11149
11150            // Safety:
11151            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11152            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11153            //   envelope_size bytes, there is always sufficient room.
11154            fidl::encoding::encode_in_envelope_optional::<
11155                u64,
11156                fidl::encoding::DefaultFuchsiaResourceDialect,
11157            >(
11158                self.guest_memory.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11159                encoder,
11160                offset + cur_offset,
11161                depth,
11162            )?;
11163
11164            _prev_end_offset = cur_offset + envelope_size;
11165            if 9 > max_ordinal {
11166                return Ok(());
11167            }
11168
11169            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11170            // are envelope_size bytes.
11171            let cur_offset: usize = (9 - 1) * envelope_size;
11172
11173            // Zero reserved fields.
11174            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11175
11176            // Safety:
11177            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11178            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11179            //   envelope_size bytes, there is always sufficient room.
11180            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11181            self.block_devices.as_mut().map(<fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11182            encoder, offset + cur_offset, depth
11183        )?;
11184
11185            _prev_end_offset = cur_offset + envelope_size;
11186            if 10 > max_ordinal {
11187                return Ok(());
11188            }
11189
11190            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11191            // are envelope_size bytes.
11192            let cur_offset: usize = (10 - 1) * envelope_size;
11193
11194            // Zero reserved fields.
11195            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11196
11197            // Safety:
11198            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11199            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11200            //   envelope_size bytes, there is always sufficient room.
11201            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11202            self.net_devices.as_ref().map(<fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11203            encoder, offset + cur_offset, depth
11204        )?;
11205
11206            _prev_end_offset = cur_offset + envelope_size;
11207            if 11 > max_ordinal {
11208                return Ok(());
11209            }
11210
11211            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11212            // are envelope_size bytes.
11213            let cur_offset: usize = (11 - 1) * envelope_size;
11214
11215            // Zero reserved fields.
11216            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11217
11218            // Safety:
11219            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11220            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11221            //   envelope_size bytes, there is always sufficient room.
11222            fidl::encoding::encode_in_envelope_optional::<
11223                WaylandDevice,
11224                fidl::encoding::DefaultFuchsiaResourceDialect,
11225            >(
11226                self.wayland_device
11227                    .as_mut()
11228                    .map(<WaylandDevice as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11229                encoder,
11230                offset + cur_offset,
11231                depth,
11232            )?;
11233
11234            _prev_end_offset = cur_offset + envelope_size;
11235            if 12 > max_ordinal {
11236                return Ok(());
11237            }
11238
11239            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11240            // are envelope_size bytes.
11241            let cur_offset: usize = (12 - 1) * envelope_size;
11242
11243            // Zero reserved fields.
11244            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11245
11246            // Safety:
11247            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11248            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11249            //   envelope_size bytes, there is always sufficient room.
11250            fidl::encoding::encode_in_envelope_optional::<
11251                MagmaDevice,
11252                fidl::encoding::DefaultFuchsiaResourceDialect,
11253            >(
11254                self.magma_device
11255                    .as_ref()
11256                    .map(<MagmaDevice as fidl::encoding::ValueTypeMarker>::borrow),
11257                encoder,
11258                offset + cur_offset,
11259                depth,
11260            )?;
11261
11262            _prev_end_offset = cur_offset + envelope_size;
11263            if 13 > max_ordinal {
11264                return Ok(());
11265            }
11266
11267            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11268            // are envelope_size bytes.
11269            let cur_offset: usize = (13 - 1) * envelope_size;
11270
11271            // Zero reserved fields.
11272            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11273
11274            // Safety:
11275            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11276            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11277            //   envelope_size bytes, there is always sufficient room.
11278            fidl::encoding::encode_in_envelope_optional::<
11279                bool,
11280                fidl::encoding::DefaultFuchsiaResourceDialect,
11281            >(
11282                self.default_net.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11283                encoder,
11284                offset + cur_offset,
11285                depth,
11286            )?;
11287
11288            _prev_end_offset = cur_offset + envelope_size;
11289            if 14 > max_ordinal {
11290                return Ok(());
11291            }
11292
11293            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11294            // are envelope_size bytes.
11295            let cur_offset: usize = (14 - 1) * envelope_size;
11296
11297            // Zero reserved fields.
11298            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11299
11300            // Safety:
11301            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11302            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11303            //   envelope_size bytes, there is always sufficient room.
11304            fidl::encoding::encode_in_envelope_optional::<
11305                bool,
11306                fidl::encoding::DefaultFuchsiaResourceDialect,
11307            >(
11308                self.virtio_balloon.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11309                encoder,
11310                offset + cur_offset,
11311                depth,
11312            )?;
11313
11314            _prev_end_offset = cur_offset + envelope_size;
11315            if 15 > max_ordinal {
11316                return Ok(());
11317            }
11318
11319            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11320            // are envelope_size bytes.
11321            let cur_offset: usize = (15 - 1) * envelope_size;
11322
11323            // Zero reserved fields.
11324            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11325
11326            // Safety:
11327            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11328            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11329            //   envelope_size bytes, there is always sufficient room.
11330            fidl::encoding::encode_in_envelope_optional::<
11331                bool,
11332                fidl::encoding::DefaultFuchsiaResourceDialect,
11333            >(
11334                self.virtio_console.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11335                encoder,
11336                offset + cur_offset,
11337                depth,
11338            )?;
11339
11340            _prev_end_offset = cur_offset + envelope_size;
11341            if 16 > max_ordinal {
11342                return Ok(());
11343            }
11344
11345            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11346            // are envelope_size bytes.
11347            let cur_offset: usize = (16 - 1) * envelope_size;
11348
11349            // Zero reserved fields.
11350            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11351
11352            // Safety:
11353            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11354            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11355            //   envelope_size bytes, there is always sufficient room.
11356            fidl::encoding::encode_in_envelope_optional::<
11357                bool,
11358                fidl::encoding::DefaultFuchsiaResourceDialect,
11359            >(
11360                self.virtio_gpu.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11361                encoder,
11362                offset + cur_offset,
11363                depth,
11364            )?;
11365
11366            _prev_end_offset = cur_offset + envelope_size;
11367            if 17 > max_ordinal {
11368                return Ok(());
11369            }
11370
11371            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11372            // are envelope_size bytes.
11373            let cur_offset: usize = (17 - 1) * envelope_size;
11374
11375            // Zero reserved fields.
11376            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11377
11378            // Safety:
11379            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11380            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11381            //   envelope_size bytes, there is always sufficient room.
11382            fidl::encoding::encode_in_envelope_optional::<
11383                bool,
11384                fidl::encoding::DefaultFuchsiaResourceDialect,
11385            >(
11386                self.virtio_rng.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11387                encoder,
11388                offset + cur_offset,
11389                depth,
11390            )?;
11391
11392            _prev_end_offset = cur_offset + envelope_size;
11393            if 18 > max_ordinal {
11394                return Ok(());
11395            }
11396
11397            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11398            // are envelope_size bytes.
11399            let cur_offset: usize = (18 - 1) * envelope_size;
11400
11401            // Zero reserved fields.
11402            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11403
11404            // Safety:
11405            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11406            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11407            //   envelope_size bytes, there is always sufficient room.
11408            fidl::encoding::encode_in_envelope_optional::<
11409                bool,
11410                fidl::encoding::DefaultFuchsiaResourceDialect,
11411            >(
11412                self.virtio_vsock.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11413                encoder,
11414                offset + cur_offset,
11415                depth,
11416            )?;
11417
11418            _prev_end_offset = cur_offset + envelope_size;
11419            if 19 > max_ordinal {
11420                return Ok(());
11421            }
11422
11423            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11424            // are envelope_size bytes.
11425            let cur_offset: usize = (19 - 1) * envelope_size;
11426
11427            // Zero reserved fields.
11428            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11429
11430            // Safety:
11431            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11432            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11433            //   envelope_size bytes, there is always sufficient room.
11434            fidl::encoding::encode_in_envelope_optional::<
11435                bool,
11436                fidl::encoding::DefaultFuchsiaResourceDialect,
11437            >(
11438                self.virtio_sound.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11439                encoder,
11440                offset + cur_offset,
11441                depth,
11442            )?;
11443
11444            _prev_end_offset = cur_offset + envelope_size;
11445            if 20 > max_ordinal {
11446                return Ok(());
11447            }
11448
11449            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11450            // are envelope_size bytes.
11451            let cur_offset: usize = (20 - 1) * envelope_size;
11452
11453            // Zero reserved fields.
11454            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11455
11456            // Safety:
11457            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11458            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11459            //   envelope_size bytes, there is always sufficient room.
11460            fidl::encoding::encode_in_envelope_optional::<
11461                bool,
11462                fidl::encoding::DefaultFuchsiaResourceDialect,
11463            >(
11464                self.virtio_sound_input
11465                    .as_ref()
11466                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11467                encoder,
11468                offset + cur_offset,
11469                depth,
11470            )?;
11471
11472            _prev_end_offset = cur_offset + envelope_size;
11473            if 21 > max_ordinal {
11474                return Ok(());
11475            }
11476
11477            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11478            // are envelope_size bytes.
11479            let cur_offset: usize = (21 - 1) * envelope_size;
11480
11481            // Zero reserved fields.
11482            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11483
11484            // Safety:
11485            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11486            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11487            //   envelope_size bytes, there is always sufficient room.
11488            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Listener>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11489            self.vsock_listeners.as_mut().map(<fidl::encoding::UnboundedVector<Listener> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11490            encoder, offset + cur_offset, depth
11491        )?;
11492
11493            _prev_end_offset = cur_offset + envelope_size;
11494            if 22 > max_ordinal {
11495                return Ok(());
11496            }
11497
11498            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11499            // are envelope_size bytes.
11500            let cur_offset: usize = (22 - 1) * envelope_size;
11501
11502            // Zero reserved fields.
11503            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11504
11505            // Safety:
11506            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11507            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11508            //   envelope_size bytes, there is always sufficient room.
11509            fidl::encoding::encode_in_envelope_optional::<
11510                bool,
11511                fidl::encoding::DefaultFuchsiaResourceDialect,
11512            >(
11513                self.virtio_mem.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11514                encoder,
11515                offset + cur_offset,
11516                depth,
11517            )?;
11518
11519            _prev_end_offset = cur_offset + envelope_size;
11520            if 23 > max_ordinal {
11521                return Ok(());
11522            }
11523
11524            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11525            // are envelope_size bytes.
11526            let cur_offset: usize = (23 - 1) * envelope_size;
11527
11528            // Zero reserved fields.
11529            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11530
11531            // Safety:
11532            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11533            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11534            //   envelope_size bytes, there is always sufficient room.
11535            fidl::encoding::encode_in_envelope_optional::<
11536                u64,
11537                fidl::encoding::DefaultFuchsiaResourceDialect,
11538            >(
11539                self.virtio_mem_block_size
11540                    .as_ref()
11541                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11542                encoder,
11543                offset + cur_offset,
11544                depth,
11545            )?;
11546
11547            _prev_end_offset = cur_offset + envelope_size;
11548            if 24 > max_ordinal {
11549                return Ok(());
11550            }
11551
11552            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11553            // are envelope_size bytes.
11554            let cur_offset: usize = (24 - 1) * envelope_size;
11555
11556            // Zero reserved fields.
11557            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11558
11559            // Safety:
11560            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11561            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11562            //   envelope_size bytes, there is always sufficient room.
11563            fidl::encoding::encode_in_envelope_optional::<
11564                u64,
11565                fidl::encoding::DefaultFuchsiaResourceDialect,
11566            >(
11567                self.virtio_mem_region_size
11568                    .as_ref()
11569                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11570                encoder,
11571                offset + cur_offset,
11572                depth,
11573            )?;
11574
11575            _prev_end_offset = cur_offset + envelope_size;
11576            if 25 > max_ordinal {
11577                return Ok(());
11578            }
11579
11580            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11581            // are envelope_size bytes.
11582            let cur_offset: usize = (25 - 1) * envelope_size;
11583
11584            // Zero reserved fields.
11585            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11586
11587            // Safety:
11588            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11589            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11590            //   envelope_size bytes, there is always sufficient room.
11591            fidl::encoding::encode_in_envelope_optional::<
11592                u64,
11593                fidl::encoding::DefaultFuchsiaResourceDialect,
11594            >(
11595                self.virtio_mem_region_alignment
11596                    .as_ref()
11597                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11598                encoder,
11599                offset + cur_offset,
11600                depth,
11601            )?;
11602
11603            _prev_end_offset = cur_offset + envelope_size;
11604
11605            Ok(())
11606        }
11607    }
11608
11609    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for GuestConfig {
11610        #[inline(always)]
11611        fn new_empty() -> Self {
11612            Self::default()
11613        }
11614
11615        unsafe fn decode(
11616            &mut self,
11617            decoder: &mut fidl::encoding::Decoder<
11618                '_,
11619                fidl::encoding::DefaultFuchsiaResourceDialect,
11620            >,
11621            offset: usize,
11622            mut depth: fidl::encoding::Depth,
11623        ) -> fidl::Result<()> {
11624            decoder.debug_check_bounds::<Self>(offset);
11625            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11626                None => return Err(fidl::Error::NotNullable),
11627                Some(len) => len,
11628            };
11629            // Calling decoder.out_of_line_offset(0) is not allowed.
11630            if len == 0 {
11631                return Ok(());
11632            };
11633            depth.increment()?;
11634            let envelope_size = 8;
11635            let bytes_len = len * envelope_size;
11636            let offset = decoder.out_of_line_offset(bytes_len)?;
11637            // Decode the envelope for each type.
11638            let mut _next_ordinal_to_read = 0;
11639            let mut next_offset = offset;
11640            let end_offset = offset + bytes_len;
11641            _next_ordinal_to_read += 1;
11642            if next_offset >= end_offset {
11643                return Ok(());
11644            }
11645
11646            // Decode unknown envelopes for gaps in ordinals.
11647            while _next_ordinal_to_read < 1 {
11648                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11649                _next_ordinal_to_read += 1;
11650                next_offset += envelope_size;
11651            }
11652
11653            let next_out_of_line = decoder.next_out_of_line();
11654            let handles_before = decoder.remaining_handles();
11655            if let Some((inlined, num_bytes, num_handles)) =
11656                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11657            {
11658                let member_inline_size =
11659                    <KernelType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11660                if inlined != (member_inline_size <= 4) {
11661                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11662                }
11663                let inner_offset;
11664                let mut inner_depth = depth.clone();
11665                if inlined {
11666                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11667                    inner_offset = next_offset;
11668                } else {
11669                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11670                    inner_depth.increment()?;
11671                }
11672                let val_ref = self.kernel_type.get_or_insert_with(|| {
11673                    fidl::new_empty!(KernelType, fidl::encoding::DefaultFuchsiaResourceDialect)
11674                });
11675                fidl::decode!(
11676                    KernelType,
11677                    fidl::encoding::DefaultFuchsiaResourceDialect,
11678                    val_ref,
11679                    decoder,
11680                    inner_offset,
11681                    inner_depth
11682                )?;
11683                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11684                {
11685                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11686                }
11687                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11688                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11689                }
11690            }
11691
11692            next_offset += envelope_size;
11693            _next_ordinal_to_read += 1;
11694            if next_offset >= end_offset {
11695                return Ok(());
11696            }
11697
11698            // Decode unknown envelopes for gaps in ordinals.
11699            while _next_ordinal_to_read < 2 {
11700                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11701                _next_ordinal_to_read += 1;
11702                next_offset += envelope_size;
11703            }
11704
11705            let next_out_of_line = decoder.next_out_of_line();
11706            let handles_before = decoder.remaining_handles();
11707            if let Some((inlined, num_bytes, num_handles)) =
11708                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11709            {
11710                let member_inline_size = <fidl::encoding::Endpoint<
11711                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11712                > as fidl::encoding::TypeMarker>::inline_size(
11713                    decoder.context
11714                );
11715                if inlined != (member_inline_size <= 4) {
11716                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11717                }
11718                let inner_offset;
11719                let mut inner_depth = depth.clone();
11720                if inlined {
11721                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11722                    inner_offset = next_offset;
11723                } else {
11724                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11725                    inner_depth.increment()?;
11726                }
11727                let val_ref = self.kernel.get_or_insert_with(|| {
11728                    fidl::new_empty!(
11729                        fidl::encoding::Endpoint<
11730                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11731                        >,
11732                        fidl::encoding::DefaultFuchsiaResourceDialect
11733                    )
11734                });
11735                fidl::decode!(
11736                    fidl::encoding::Endpoint<
11737                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11738                    >,
11739                    fidl::encoding::DefaultFuchsiaResourceDialect,
11740                    val_ref,
11741                    decoder,
11742                    inner_offset,
11743                    inner_depth
11744                )?;
11745                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11746                {
11747                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11748                }
11749                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11750                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11751                }
11752            }
11753
11754            next_offset += envelope_size;
11755            _next_ordinal_to_read += 1;
11756            if next_offset >= end_offset {
11757                return Ok(());
11758            }
11759
11760            // Decode unknown envelopes for gaps in ordinals.
11761            while _next_ordinal_to_read < 3 {
11762                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11763                _next_ordinal_to_read += 1;
11764                next_offset += envelope_size;
11765            }
11766
11767            let next_out_of_line = decoder.next_out_of_line();
11768            let handles_before = decoder.remaining_handles();
11769            if let Some((inlined, num_bytes, num_handles)) =
11770                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11771            {
11772                let member_inline_size = <fidl::encoding::Endpoint<
11773                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11774                > as fidl::encoding::TypeMarker>::inline_size(
11775                    decoder.context
11776                );
11777                if inlined != (member_inline_size <= 4) {
11778                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11779                }
11780                let inner_offset;
11781                let mut inner_depth = depth.clone();
11782                if inlined {
11783                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11784                    inner_offset = next_offset;
11785                } else {
11786                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11787                    inner_depth.increment()?;
11788                }
11789                let val_ref = self.ramdisk.get_or_insert_with(|| {
11790                    fidl::new_empty!(
11791                        fidl::encoding::Endpoint<
11792                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11793                        >,
11794                        fidl::encoding::DefaultFuchsiaResourceDialect
11795                    )
11796                });
11797                fidl::decode!(
11798                    fidl::encoding::Endpoint<
11799                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11800                    >,
11801                    fidl::encoding::DefaultFuchsiaResourceDialect,
11802                    val_ref,
11803                    decoder,
11804                    inner_offset,
11805                    inner_depth
11806                )?;
11807                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11808                {
11809                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11810                }
11811                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11812                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11813                }
11814            }
11815
11816            next_offset += envelope_size;
11817            _next_ordinal_to_read += 1;
11818            if next_offset >= end_offset {
11819                return Ok(());
11820            }
11821
11822            // Decode unknown envelopes for gaps in ordinals.
11823            while _next_ordinal_to_read < 4 {
11824                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11825                _next_ordinal_to_read += 1;
11826                next_offset += envelope_size;
11827            }
11828
11829            let next_out_of_line = decoder.next_out_of_line();
11830            let handles_before = decoder.remaining_handles();
11831            if let Some((inlined, num_bytes, num_handles)) =
11832                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11833            {
11834                let member_inline_size = <fidl::encoding::Endpoint<
11835                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11836                > as fidl::encoding::TypeMarker>::inline_size(
11837                    decoder.context
11838                );
11839                if inlined != (member_inline_size <= 4) {
11840                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11841                }
11842                let inner_offset;
11843                let mut inner_depth = depth.clone();
11844                if inlined {
11845                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11846                    inner_offset = next_offset;
11847                } else {
11848                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11849                    inner_depth.increment()?;
11850                }
11851                let val_ref = self.dtb_overlay.get_or_insert_with(|| {
11852                    fidl::new_empty!(
11853                        fidl::encoding::Endpoint<
11854                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11855                        >,
11856                        fidl::encoding::DefaultFuchsiaResourceDialect
11857                    )
11858                });
11859                fidl::decode!(
11860                    fidl::encoding::Endpoint<
11861                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11862                    >,
11863                    fidl::encoding::DefaultFuchsiaResourceDialect,
11864                    val_ref,
11865                    decoder,
11866                    inner_offset,
11867                    inner_depth
11868                )?;
11869                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11870                {
11871                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11872                }
11873                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11874                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11875                }
11876            }
11877
11878            next_offset += envelope_size;
11879            _next_ordinal_to_read += 1;
11880            if next_offset >= end_offset {
11881                return Ok(());
11882            }
11883
11884            // Decode unknown envelopes for gaps in ordinals.
11885            while _next_ordinal_to_read < 5 {
11886                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11887                _next_ordinal_to_read += 1;
11888                next_offset += envelope_size;
11889            }
11890
11891            let next_out_of_line = decoder.next_out_of_line();
11892            let handles_before = decoder.remaining_handles();
11893            if let Some((inlined, num_bytes, num_handles)) =
11894                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11895            {
11896                let member_inline_size =
11897                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
11898                        decoder.context,
11899                    );
11900                if inlined != (member_inline_size <= 4) {
11901                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11902                }
11903                let inner_offset;
11904                let mut inner_depth = depth.clone();
11905                if inlined {
11906                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11907                    inner_offset = next_offset;
11908                } else {
11909                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11910                    inner_depth.increment()?;
11911                }
11912                let val_ref = self.cmdline.get_or_insert_with(|| {
11913                    fidl::new_empty!(
11914                        fidl::encoding::UnboundedString,
11915                        fidl::encoding::DefaultFuchsiaResourceDialect
11916                    )
11917                });
11918                fidl::decode!(
11919                    fidl::encoding::UnboundedString,
11920                    fidl::encoding::DefaultFuchsiaResourceDialect,
11921                    val_ref,
11922                    decoder,
11923                    inner_offset,
11924                    inner_depth
11925                )?;
11926                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11927                {
11928                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11929                }
11930                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11931                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11932                }
11933            }
11934
11935            next_offset += envelope_size;
11936            _next_ordinal_to_read += 1;
11937            if next_offset >= end_offset {
11938                return Ok(());
11939            }
11940
11941            // Decode unknown envelopes for gaps in ordinals.
11942            while _next_ordinal_to_read < 6 {
11943                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11944                _next_ordinal_to_read += 1;
11945                next_offset += envelope_size;
11946            }
11947
11948            let next_out_of_line = decoder.next_out_of_line();
11949            let handles_before = decoder.remaining_handles();
11950            if let Some((inlined, num_bytes, num_handles)) =
11951                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11952            {
11953                let member_inline_size = <fidl::encoding::UnboundedVector<
11954                    fidl::encoding::UnboundedString,
11955                > as fidl::encoding::TypeMarker>::inline_size(
11956                    decoder.context
11957                );
11958                if inlined != (member_inline_size <= 4) {
11959                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11960                }
11961                let inner_offset;
11962                let mut inner_depth = depth.clone();
11963                if inlined {
11964                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11965                    inner_offset = next_offset;
11966                } else {
11967                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11968                    inner_depth.increment()?;
11969                }
11970                let val_ref = self.cmdline_add.get_or_insert_with(|| {
11971                    fidl::new_empty!(
11972                        fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
11973                        fidl::encoding::DefaultFuchsiaResourceDialect
11974                    )
11975                });
11976                fidl::decode!(
11977                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
11978                    fidl::encoding::DefaultFuchsiaResourceDialect,
11979                    val_ref,
11980                    decoder,
11981                    inner_offset,
11982                    inner_depth
11983                )?;
11984                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11985                {
11986                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11987                }
11988                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11989                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11990                }
11991            }
11992
11993            next_offset += envelope_size;
11994            _next_ordinal_to_read += 1;
11995            if next_offset >= end_offset {
11996                return Ok(());
11997            }
11998
11999            // Decode unknown envelopes for gaps in ordinals.
12000            while _next_ordinal_to_read < 7 {
12001                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12002                _next_ordinal_to_read += 1;
12003                next_offset += envelope_size;
12004            }
12005
12006            let next_out_of_line = decoder.next_out_of_line();
12007            let handles_before = decoder.remaining_handles();
12008            if let Some((inlined, num_bytes, num_handles)) =
12009                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12010            {
12011                let member_inline_size =
12012                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12013                if inlined != (member_inline_size <= 4) {
12014                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12015                }
12016                let inner_offset;
12017                let mut inner_depth = depth.clone();
12018                if inlined {
12019                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12020                    inner_offset = next_offset;
12021                } else {
12022                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12023                    inner_depth.increment()?;
12024                }
12025                let val_ref = self.cpus.get_or_insert_with(|| {
12026                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12027                });
12028                fidl::decode!(
12029                    u8,
12030                    fidl::encoding::DefaultFuchsiaResourceDialect,
12031                    val_ref,
12032                    decoder,
12033                    inner_offset,
12034                    inner_depth
12035                )?;
12036                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12037                {
12038                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12039                }
12040                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12041                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12042                }
12043            }
12044
12045            next_offset += envelope_size;
12046            _next_ordinal_to_read += 1;
12047            if next_offset >= end_offset {
12048                return Ok(());
12049            }
12050
12051            // Decode unknown envelopes for gaps in ordinals.
12052            while _next_ordinal_to_read < 8 {
12053                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12054                _next_ordinal_to_read += 1;
12055                next_offset += envelope_size;
12056            }
12057
12058            let next_out_of_line = decoder.next_out_of_line();
12059            let handles_before = decoder.remaining_handles();
12060            if let Some((inlined, num_bytes, num_handles)) =
12061                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12062            {
12063                let member_inline_size =
12064                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12065                if inlined != (member_inline_size <= 4) {
12066                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12067                }
12068                let inner_offset;
12069                let mut inner_depth = depth.clone();
12070                if inlined {
12071                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12072                    inner_offset = next_offset;
12073                } else {
12074                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12075                    inner_depth.increment()?;
12076                }
12077                let val_ref = self.guest_memory.get_or_insert_with(|| {
12078                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12079                });
12080                fidl::decode!(
12081                    u64,
12082                    fidl::encoding::DefaultFuchsiaResourceDialect,
12083                    val_ref,
12084                    decoder,
12085                    inner_offset,
12086                    inner_depth
12087                )?;
12088                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12089                {
12090                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12091                }
12092                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12093                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12094                }
12095            }
12096
12097            next_offset += envelope_size;
12098            _next_ordinal_to_read += 1;
12099            if next_offset >= end_offset {
12100                return Ok(());
12101            }
12102
12103            // Decode unknown envelopes for gaps in ordinals.
12104            while _next_ordinal_to_read < 9 {
12105                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12106                _next_ordinal_to_read += 1;
12107                next_offset += envelope_size;
12108            }
12109
12110            let next_out_of_line = decoder.next_out_of_line();
12111            let handles_before = decoder.remaining_handles();
12112            if let Some((inlined, num_bytes, num_handles)) =
12113                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12114            {
12115                let member_inline_size = <fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12116                if inlined != (member_inline_size <= 4) {
12117                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12118                }
12119                let inner_offset;
12120                let mut inner_depth = depth.clone();
12121                if inlined {
12122                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12123                    inner_offset = next_offset;
12124                } else {
12125                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12126                    inner_depth.increment()?;
12127                }
12128                let val_ref =
12129                self.block_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12130                fidl::decode!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12131                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12132                {
12133                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12134                }
12135                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12136                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12137                }
12138            }
12139
12140            next_offset += envelope_size;
12141            _next_ordinal_to_read += 1;
12142            if next_offset >= end_offset {
12143                return Ok(());
12144            }
12145
12146            // Decode unknown envelopes for gaps in ordinals.
12147            while _next_ordinal_to_read < 10 {
12148                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12149                _next_ordinal_to_read += 1;
12150                next_offset += envelope_size;
12151            }
12152
12153            let next_out_of_line = decoder.next_out_of_line();
12154            let handles_before = decoder.remaining_handles();
12155            if let Some((inlined, num_bytes, num_handles)) =
12156                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12157            {
12158                let member_inline_size = <fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12159                if inlined != (member_inline_size <= 4) {
12160                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12161                }
12162                let inner_offset;
12163                let mut inner_depth = depth.clone();
12164                if inlined {
12165                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12166                    inner_offset = next_offset;
12167                } else {
12168                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12169                    inner_depth.increment()?;
12170                }
12171                let val_ref =
12172                self.net_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12173                fidl::decode!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12174                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12175                {
12176                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12177                }
12178                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12179                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12180                }
12181            }
12182
12183            next_offset += envelope_size;
12184            _next_ordinal_to_read += 1;
12185            if next_offset >= end_offset {
12186                return Ok(());
12187            }
12188
12189            // Decode unknown envelopes for gaps in ordinals.
12190            while _next_ordinal_to_read < 11 {
12191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12192                _next_ordinal_to_read += 1;
12193                next_offset += envelope_size;
12194            }
12195
12196            let next_out_of_line = decoder.next_out_of_line();
12197            let handles_before = decoder.remaining_handles();
12198            if let Some((inlined, num_bytes, num_handles)) =
12199                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12200            {
12201                let member_inline_size =
12202                    <WaylandDevice as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12203                if inlined != (member_inline_size <= 4) {
12204                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12205                }
12206                let inner_offset;
12207                let mut inner_depth = depth.clone();
12208                if inlined {
12209                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12210                    inner_offset = next_offset;
12211                } else {
12212                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12213                    inner_depth.increment()?;
12214                }
12215                let val_ref = self.wayland_device.get_or_insert_with(|| {
12216                    fidl::new_empty!(WaylandDevice, fidl::encoding::DefaultFuchsiaResourceDialect)
12217                });
12218                fidl::decode!(
12219                    WaylandDevice,
12220                    fidl::encoding::DefaultFuchsiaResourceDialect,
12221                    val_ref,
12222                    decoder,
12223                    inner_offset,
12224                    inner_depth
12225                )?;
12226                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12227                {
12228                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12229                }
12230                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12231                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12232                }
12233            }
12234
12235            next_offset += envelope_size;
12236            _next_ordinal_to_read += 1;
12237            if next_offset >= end_offset {
12238                return Ok(());
12239            }
12240
12241            // Decode unknown envelopes for gaps in ordinals.
12242            while _next_ordinal_to_read < 12 {
12243                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12244                _next_ordinal_to_read += 1;
12245                next_offset += envelope_size;
12246            }
12247
12248            let next_out_of_line = decoder.next_out_of_line();
12249            let handles_before = decoder.remaining_handles();
12250            if let Some((inlined, num_bytes, num_handles)) =
12251                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12252            {
12253                let member_inline_size =
12254                    <MagmaDevice as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12255                if inlined != (member_inline_size <= 4) {
12256                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12257                }
12258                let inner_offset;
12259                let mut inner_depth = depth.clone();
12260                if inlined {
12261                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12262                    inner_offset = next_offset;
12263                } else {
12264                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12265                    inner_depth.increment()?;
12266                }
12267                let val_ref = self.magma_device.get_or_insert_with(|| {
12268                    fidl::new_empty!(MagmaDevice, fidl::encoding::DefaultFuchsiaResourceDialect)
12269                });
12270                fidl::decode!(
12271                    MagmaDevice,
12272                    fidl::encoding::DefaultFuchsiaResourceDialect,
12273                    val_ref,
12274                    decoder,
12275                    inner_offset,
12276                    inner_depth
12277                )?;
12278                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12279                {
12280                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12281                }
12282                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12283                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12284                }
12285            }
12286
12287            next_offset += envelope_size;
12288            _next_ordinal_to_read += 1;
12289            if next_offset >= end_offset {
12290                return Ok(());
12291            }
12292
12293            // Decode unknown envelopes for gaps in ordinals.
12294            while _next_ordinal_to_read < 13 {
12295                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12296                _next_ordinal_to_read += 1;
12297                next_offset += envelope_size;
12298            }
12299
12300            let next_out_of_line = decoder.next_out_of_line();
12301            let handles_before = decoder.remaining_handles();
12302            if let Some((inlined, num_bytes, num_handles)) =
12303                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12304            {
12305                let member_inline_size =
12306                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12307                if inlined != (member_inline_size <= 4) {
12308                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12309                }
12310                let inner_offset;
12311                let mut inner_depth = depth.clone();
12312                if inlined {
12313                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12314                    inner_offset = next_offset;
12315                } else {
12316                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12317                    inner_depth.increment()?;
12318                }
12319                let val_ref = self.default_net.get_or_insert_with(|| {
12320                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12321                });
12322                fidl::decode!(
12323                    bool,
12324                    fidl::encoding::DefaultFuchsiaResourceDialect,
12325                    val_ref,
12326                    decoder,
12327                    inner_offset,
12328                    inner_depth
12329                )?;
12330                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12331                {
12332                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12333                }
12334                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12335                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12336                }
12337            }
12338
12339            next_offset += envelope_size;
12340            _next_ordinal_to_read += 1;
12341            if next_offset >= end_offset {
12342                return Ok(());
12343            }
12344
12345            // Decode unknown envelopes for gaps in ordinals.
12346            while _next_ordinal_to_read < 14 {
12347                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12348                _next_ordinal_to_read += 1;
12349                next_offset += envelope_size;
12350            }
12351
12352            let next_out_of_line = decoder.next_out_of_line();
12353            let handles_before = decoder.remaining_handles();
12354            if let Some((inlined, num_bytes, num_handles)) =
12355                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12356            {
12357                let member_inline_size =
12358                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12359                if inlined != (member_inline_size <= 4) {
12360                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12361                }
12362                let inner_offset;
12363                let mut inner_depth = depth.clone();
12364                if inlined {
12365                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12366                    inner_offset = next_offset;
12367                } else {
12368                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12369                    inner_depth.increment()?;
12370                }
12371                let val_ref = self.virtio_balloon.get_or_insert_with(|| {
12372                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12373                });
12374                fidl::decode!(
12375                    bool,
12376                    fidl::encoding::DefaultFuchsiaResourceDialect,
12377                    val_ref,
12378                    decoder,
12379                    inner_offset,
12380                    inner_depth
12381                )?;
12382                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12383                {
12384                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12385                }
12386                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12387                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12388                }
12389            }
12390
12391            next_offset += envelope_size;
12392            _next_ordinal_to_read += 1;
12393            if next_offset >= end_offset {
12394                return Ok(());
12395            }
12396
12397            // Decode unknown envelopes for gaps in ordinals.
12398            while _next_ordinal_to_read < 15 {
12399                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12400                _next_ordinal_to_read += 1;
12401                next_offset += envelope_size;
12402            }
12403
12404            let next_out_of_line = decoder.next_out_of_line();
12405            let handles_before = decoder.remaining_handles();
12406            if let Some((inlined, num_bytes, num_handles)) =
12407                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12408            {
12409                let member_inline_size =
12410                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12411                if inlined != (member_inline_size <= 4) {
12412                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12413                }
12414                let inner_offset;
12415                let mut inner_depth = depth.clone();
12416                if inlined {
12417                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12418                    inner_offset = next_offset;
12419                } else {
12420                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12421                    inner_depth.increment()?;
12422                }
12423                let val_ref = self.virtio_console.get_or_insert_with(|| {
12424                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12425                });
12426                fidl::decode!(
12427                    bool,
12428                    fidl::encoding::DefaultFuchsiaResourceDialect,
12429                    val_ref,
12430                    decoder,
12431                    inner_offset,
12432                    inner_depth
12433                )?;
12434                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12435                {
12436                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12437                }
12438                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12439                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12440                }
12441            }
12442
12443            next_offset += envelope_size;
12444            _next_ordinal_to_read += 1;
12445            if next_offset >= end_offset {
12446                return Ok(());
12447            }
12448
12449            // Decode unknown envelopes for gaps in ordinals.
12450            while _next_ordinal_to_read < 16 {
12451                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12452                _next_ordinal_to_read += 1;
12453                next_offset += envelope_size;
12454            }
12455
12456            let next_out_of_line = decoder.next_out_of_line();
12457            let handles_before = decoder.remaining_handles();
12458            if let Some((inlined, num_bytes, num_handles)) =
12459                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12460            {
12461                let member_inline_size =
12462                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12463                if inlined != (member_inline_size <= 4) {
12464                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12465                }
12466                let inner_offset;
12467                let mut inner_depth = depth.clone();
12468                if inlined {
12469                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12470                    inner_offset = next_offset;
12471                } else {
12472                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12473                    inner_depth.increment()?;
12474                }
12475                let val_ref = self.virtio_gpu.get_or_insert_with(|| {
12476                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12477                });
12478                fidl::decode!(
12479                    bool,
12480                    fidl::encoding::DefaultFuchsiaResourceDialect,
12481                    val_ref,
12482                    decoder,
12483                    inner_offset,
12484                    inner_depth
12485                )?;
12486                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12487                {
12488                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12489                }
12490                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12491                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12492                }
12493            }
12494
12495            next_offset += envelope_size;
12496            _next_ordinal_to_read += 1;
12497            if next_offset >= end_offset {
12498                return Ok(());
12499            }
12500
12501            // Decode unknown envelopes for gaps in ordinals.
12502            while _next_ordinal_to_read < 17 {
12503                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12504                _next_ordinal_to_read += 1;
12505                next_offset += envelope_size;
12506            }
12507
12508            let next_out_of_line = decoder.next_out_of_line();
12509            let handles_before = decoder.remaining_handles();
12510            if let Some((inlined, num_bytes, num_handles)) =
12511                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12512            {
12513                let member_inline_size =
12514                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12515                if inlined != (member_inline_size <= 4) {
12516                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12517                }
12518                let inner_offset;
12519                let mut inner_depth = depth.clone();
12520                if inlined {
12521                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12522                    inner_offset = next_offset;
12523                } else {
12524                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12525                    inner_depth.increment()?;
12526                }
12527                let val_ref = self.virtio_rng.get_or_insert_with(|| {
12528                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12529                });
12530                fidl::decode!(
12531                    bool,
12532                    fidl::encoding::DefaultFuchsiaResourceDialect,
12533                    val_ref,
12534                    decoder,
12535                    inner_offset,
12536                    inner_depth
12537                )?;
12538                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12539                {
12540                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12541                }
12542                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12543                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12544                }
12545            }
12546
12547            next_offset += envelope_size;
12548            _next_ordinal_to_read += 1;
12549            if next_offset >= end_offset {
12550                return Ok(());
12551            }
12552
12553            // Decode unknown envelopes for gaps in ordinals.
12554            while _next_ordinal_to_read < 18 {
12555                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12556                _next_ordinal_to_read += 1;
12557                next_offset += envelope_size;
12558            }
12559
12560            let next_out_of_line = decoder.next_out_of_line();
12561            let handles_before = decoder.remaining_handles();
12562            if let Some((inlined, num_bytes, num_handles)) =
12563                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12564            {
12565                let member_inline_size =
12566                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12567                if inlined != (member_inline_size <= 4) {
12568                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12569                }
12570                let inner_offset;
12571                let mut inner_depth = depth.clone();
12572                if inlined {
12573                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12574                    inner_offset = next_offset;
12575                } else {
12576                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12577                    inner_depth.increment()?;
12578                }
12579                let val_ref = self.virtio_vsock.get_or_insert_with(|| {
12580                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12581                });
12582                fidl::decode!(
12583                    bool,
12584                    fidl::encoding::DefaultFuchsiaResourceDialect,
12585                    val_ref,
12586                    decoder,
12587                    inner_offset,
12588                    inner_depth
12589                )?;
12590                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12591                {
12592                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12593                }
12594                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12595                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12596                }
12597            }
12598
12599            next_offset += envelope_size;
12600            _next_ordinal_to_read += 1;
12601            if next_offset >= end_offset {
12602                return Ok(());
12603            }
12604
12605            // Decode unknown envelopes for gaps in ordinals.
12606            while _next_ordinal_to_read < 19 {
12607                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12608                _next_ordinal_to_read += 1;
12609                next_offset += envelope_size;
12610            }
12611
12612            let next_out_of_line = decoder.next_out_of_line();
12613            let handles_before = decoder.remaining_handles();
12614            if let Some((inlined, num_bytes, num_handles)) =
12615                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12616            {
12617                let member_inline_size =
12618                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12619                if inlined != (member_inline_size <= 4) {
12620                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12621                }
12622                let inner_offset;
12623                let mut inner_depth = depth.clone();
12624                if inlined {
12625                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12626                    inner_offset = next_offset;
12627                } else {
12628                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12629                    inner_depth.increment()?;
12630                }
12631                let val_ref = self.virtio_sound.get_or_insert_with(|| {
12632                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12633                });
12634                fidl::decode!(
12635                    bool,
12636                    fidl::encoding::DefaultFuchsiaResourceDialect,
12637                    val_ref,
12638                    decoder,
12639                    inner_offset,
12640                    inner_depth
12641                )?;
12642                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12643                {
12644                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12645                }
12646                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12647                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12648                }
12649            }
12650
12651            next_offset += envelope_size;
12652            _next_ordinal_to_read += 1;
12653            if next_offset >= end_offset {
12654                return Ok(());
12655            }
12656
12657            // Decode unknown envelopes for gaps in ordinals.
12658            while _next_ordinal_to_read < 20 {
12659                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12660                _next_ordinal_to_read += 1;
12661                next_offset += envelope_size;
12662            }
12663
12664            let next_out_of_line = decoder.next_out_of_line();
12665            let handles_before = decoder.remaining_handles();
12666            if let Some((inlined, num_bytes, num_handles)) =
12667                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12668            {
12669                let member_inline_size =
12670                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12671                if inlined != (member_inline_size <= 4) {
12672                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12673                }
12674                let inner_offset;
12675                let mut inner_depth = depth.clone();
12676                if inlined {
12677                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12678                    inner_offset = next_offset;
12679                } else {
12680                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12681                    inner_depth.increment()?;
12682                }
12683                let val_ref = self.virtio_sound_input.get_or_insert_with(|| {
12684                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12685                });
12686                fidl::decode!(
12687                    bool,
12688                    fidl::encoding::DefaultFuchsiaResourceDialect,
12689                    val_ref,
12690                    decoder,
12691                    inner_offset,
12692                    inner_depth
12693                )?;
12694                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12695                {
12696                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12697                }
12698                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12699                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12700                }
12701            }
12702
12703            next_offset += envelope_size;
12704            _next_ordinal_to_read += 1;
12705            if next_offset >= end_offset {
12706                return Ok(());
12707            }
12708
12709            // Decode unknown envelopes for gaps in ordinals.
12710            while _next_ordinal_to_read < 21 {
12711                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12712                _next_ordinal_to_read += 1;
12713                next_offset += envelope_size;
12714            }
12715
12716            let next_out_of_line = decoder.next_out_of_line();
12717            let handles_before = decoder.remaining_handles();
12718            if let Some((inlined, num_bytes, num_handles)) =
12719                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12720            {
12721                let member_inline_size = <fidl::encoding::UnboundedVector<Listener> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12722                if inlined != (member_inline_size <= 4) {
12723                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12724                }
12725                let inner_offset;
12726                let mut inner_depth = depth.clone();
12727                if inlined {
12728                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12729                    inner_offset = next_offset;
12730                } else {
12731                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12732                    inner_depth.increment()?;
12733                }
12734                let val_ref = self.vsock_listeners.get_or_insert_with(|| {
12735                    fidl::new_empty!(
12736                        fidl::encoding::UnboundedVector<Listener>,
12737                        fidl::encoding::DefaultFuchsiaResourceDialect
12738                    )
12739                });
12740                fidl::decode!(
12741                    fidl::encoding::UnboundedVector<Listener>,
12742                    fidl::encoding::DefaultFuchsiaResourceDialect,
12743                    val_ref,
12744                    decoder,
12745                    inner_offset,
12746                    inner_depth
12747                )?;
12748                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12749                {
12750                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12751                }
12752                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12753                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12754                }
12755            }
12756
12757            next_offset += envelope_size;
12758            _next_ordinal_to_read += 1;
12759            if next_offset >= end_offset {
12760                return Ok(());
12761            }
12762
12763            // Decode unknown envelopes for gaps in ordinals.
12764            while _next_ordinal_to_read < 22 {
12765                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12766                _next_ordinal_to_read += 1;
12767                next_offset += envelope_size;
12768            }
12769
12770            let next_out_of_line = decoder.next_out_of_line();
12771            let handles_before = decoder.remaining_handles();
12772            if let Some((inlined, num_bytes, num_handles)) =
12773                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12774            {
12775                let member_inline_size =
12776                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12777                if inlined != (member_inline_size <= 4) {
12778                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12779                }
12780                let inner_offset;
12781                let mut inner_depth = depth.clone();
12782                if inlined {
12783                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12784                    inner_offset = next_offset;
12785                } else {
12786                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12787                    inner_depth.increment()?;
12788                }
12789                let val_ref = self.virtio_mem.get_or_insert_with(|| {
12790                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12791                });
12792                fidl::decode!(
12793                    bool,
12794                    fidl::encoding::DefaultFuchsiaResourceDialect,
12795                    val_ref,
12796                    decoder,
12797                    inner_offset,
12798                    inner_depth
12799                )?;
12800                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12801                {
12802                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12803                }
12804                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12805                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12806                }
12807            }
12808
12809            next_offset += envelope_size;
12810            _next_ordinal_to_read += 1;
12811            if next_offset >= end_offset {
12812                return Ok(());
12813            }
12814
12815            // Decode unknown envelopes for gaps in ordinals.
12816            while _next_ordinal_to_read < 23 {
12817                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12818                _next_ordinal_to_read += 1;
12819                next_offset += envelope_size;
12820            }
12821
12822            let next_out_of_line = decoder.next_out_of_line();
12823            let handles_before = decoder.remaining_handles();
12824            if let Some((inlined, num_bytes, num_handles)) =
12825                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12826            {
12827                let member_inline_size =
12828                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12829                if inlined != (member_inline_size <= 4) {
12830                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12831                }
12832                let inner_offset;
12833                let mut inner_depth = depth.clone();
12834                if inlined {
12835                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12836                    inner_offset = next_offset;
12837                } else {
12838                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12839                    inner_depth.increment()?;
12840                }
12841                let val_ref = self.virtio_mem_block_size.get_or_insert_with(|| {
12842                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12843                });
12844                fidl::decode!(
12845                    u64,
12846                    fidl::encoding::DefaultFuchsiaResourceDialect,
12847                    val_ref,
12848                    decoder,
12849                    inner_offset,
12850                    inner_depth
12851                )?;
12852                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12853                {
12854                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12855                }
12856                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12857                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12858                }
12859            }
12860
12861            next_offset += envelope_size;
12862            _next_ordinal_to_read += 1;
12863            if next_offset >= end_offset {
12864                return Ok(());
12865            }
12866
12867            // Decode unknown envelopes for gaps in ordinals.
12868            while _next_ordinal_to_read < 24 {
12869                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12870                _next_ordinal_to_read += 1;
12871                next_offset += envelope_size;
12872            }
12873
12874            let next_out_of_line = decoder.next_out_of_line();
12875            let handles_before = decoder.remaining_handles();
12876            if let Some((inlined, num_bytes, num_handles)) =
12877                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12878            {
12879                let member_inline_size =
12880                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12881                if inlined != (member_inline_size <= 4) {
12882                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12883                }
12884                let inner_offset;
12885                let mut inner_depth = depth.clone();
12886                if inlined {
12887                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12888                    inner_offset = next_offset;
12889                } else {
12890                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12891                    inner_depth.increment()?;
12892                }
12893                let val_ref = self.virtio_mem_region_size.get_or_insert_with(|| {
12894                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12895                });
12896                fidl::decode!(
12897                    u64,
12898                    fidl::encoding::DefaultFuchsiaResourceDialect,
12899                    val_ref,
12900                    decoder,
12901                    inner_offset,
12902                    inner_depth
12903                )?;
12904                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12905                {
12906                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12907                }
12908                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12909                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12910                }
12911            }
12912
12913            next_offset += envelope_size;
12914            _next_ordinal_to_read += 1;
12915            if next_offset >= end_offset {
12916                return Ok(());
12917            }
12918
12919            // Decode unknown envelopes for gaps in ordinals.
12920            while _next_ordinal_to_read < 25 {
12921                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12922                _next_ordinal_to_read += 1;
12923                next_offset += envelope_size;
12924            }
12925
12926            let next_out_of_line = decoder.next_out_of_line();
12927            let handles_before = decoder.remaining_handles();
12928            if let Some((inlined, num_bytes, num_handles)) =
12929                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12930            {
12931                let member_inline_size =
12932                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12933                if inlined != (member_inline_size <= 4) {
12934                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12935                }
12936                let inner_offset;
12937                let mut inner_depth = depth.clone();
12938                if inlined {
12939                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12940                    inner_offset = next_offset;
12941                } else {
12942                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12943                    inner_depth.increment()?;
12944                }
12945                let val_ref = self.virtio_mem_region_alignment.get_or_insert_with(|| {
12946                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12947                });
12948                fidl::decode!(
12949                    u64,
12950                    fidl::encoding::DefaultFuchsiaResourceDialect,
12951                    val_ref,
12952                    decoder,
12953                    inner_offset,
12954                    inner_depth
12955                )?;
12956                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12957                {
12958                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12959                }
12960                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12961                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12962                }
12963            }
12964
12965            next_offset += envelope_size;
12966
12967            // Decode the remaining unknown envelopes.
12968            while next_offset < end_offset {
12969                _next_ordinal_to_read += 1;
12970                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12971                next_offset += envelope_size;
12972            }
12973
12974            Ok(())
12975        }
12976    }
12977
12978    impl fidl::encoding::ResourceTypeMarker for BlockFormat {
12979        type Borrowed<'a> = &'a mut Self;
12980        fn take_or_borrow<'a>(
12981            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12982        ) -> Self::Borrowed<'a> {
12983            value
12984        }
12985    }
12986
12987    unsafe impl fidl::encoding::TypeMarker for BlockFormat {
12988        type Owned = Self;
12989
12990        #[inline(always)]
12991        fn inline_align(_context: fidl::encoding::Context) -> usize {
12992            8
12993        }
12994
12995        #[inline(always)]
12996        fn inline_size(_context: fidl::encoding::Context) -> usize {
12997            16
12998        }
12999    }
13000
13001    unsafe impl fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>
13002        for &mut BlockFormat
13003    {
13004        #[inline]
13005        unsafe fn encode(
13006            self,
13007            encoder: &mut fidl::encoding::Encoder<
13008                '_,
13009                fidl::encoding::DefaultFuchsiaResourceDialect,
13010            >,
13011            offset: usize,
13012            _depth: fidl::encoding::Depth,
13013        ) -> fidl::Result<()> {
13014            encoder.debug_check_bounds::<BlockFormat>(offset);
13015            encoder.write_num::<u64>(self.ordinal(), offset);
13016            match self {
13017                BlockFormat::File(ref mut val) => fidl::encoding::encode_in_envelope::<
13018                    fidl::encoding::Endpoint<
13019                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13020                    >,
13021                    fidl::encoding::DefaultFuchsiaResourceDialect,
13022                >(
13023                    <fidl::encoding::Endpoint<
13024                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13025                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13026                        val
13027                    ),
13028                    encoder,
13029                    offset + 8,
13030                    _depth,
13031                ),
13032                BlockFormat::Qcow(ref mut val) => fidl::encoding::encode_in_envelope::<
13033                    fidl::encoding::HandleType<
13034                        fidl::Channel,
13035                        { fidl::ObjectType::CHANNEL.into_raw() },
13036                        2147483648,
13037                    >,
13038                    fidl::encoding::DefaultFuchsiaResourceDialect,
13039                >(
13040                    <fidl::encoding::HandleType<
13041                        fidl::Channel,
13042                        { fidl::ObjectType::CHANNEL.into_raw() },
13043                        2147483648,
13044                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13045                        val
13046                    ),
13047                    encoder,
13048                    offset + 8,
13049                    _depth,
13050                ),
13051                BlockFormat::Block(ref mut val) => fidl::encoding::encode_in_envelope::<
13052                    fidl::encoding::Endpoint<
13053                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
13054                    >,
13055                    fidl::encoding::DefaultFuchsiaResourceDialect,
13056                >(
13057                    <fidl::encoding::Endpoint<
13058                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
13059                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13060                        val
13061                    ),
13062                    encoder,
13063                    offset + 8,
13064                    _depth,
13065                ),
13066            }
13067        }
13068    }
13069
13070    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockFormat {
13071        #[inline(always)]
13072        fn new_empty() -> Self {
13073            Self::File(fidl::new_empty!(
13074                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
13075                fidl::encoding::DefaultFuchsiaResourceDialect
13076            ))
13077        }
13078
13079        #[inline]
13080        unsafe fn decode(
13081            &mut self,
13082            decoder: &mut fidl::encoding::Decoder<
13083                '_,
13084                fidl::encoding::DefaultFuchsiaResourceDialect,
13085            >,
13086            offset: usize,
13087            mut depth: fidl::encoding::Depth,
13088        ) -> fidl::Result<()> {
13089            decoder.debug_check_bounds::<Self>(offset);
13090            #[allow(unused_variables)]
13091            let next_out_of_line = decoder.next_out_of_line();
13092            let handles_before = decoder.remaining_handles();
13093            let (ordinal, inlined, num_bytes, num_handles) =
13094                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
13095
13096            let member_inline_size = match ordinal {
13097                1 => <fidl::encoding::Endpoint<
13098                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13099                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13100                2 => <fidl::encoding::HandleType<
13101                    fidl::Channel,
13102                    { fidl::ObjectType::CHANNEL.into_raw() },
13103                    2147483648,
13104                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13105                3 => <fidl::encoding::Endpoint<
13106                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
13107                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13108                _ => return Err(fidl::Error::UnknownUnionTag),
13109            };
13110
13111            if inlined != (member_inline_size <= 4) {
13112                return Err(fidl::Error::InvalidInlineBitInEnvelope);
13113            }
13114            let _inner_offset;
13115            if inlined {
13116                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
13117                _inner_offset = offset + 8;
13118            } else {
13119                depth.increment()?;
13120                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13121            }
13122            match ordinal {
13123                1 => {
13124                    #[allow(irrefutable_let_patterns)]
13125                    if let BlockFormat::File(_) = self {
13126                        // Do nothing, read the value into the object
13127                    } else {
13128                        // Initialize `self` to the right variant
13129                        *self = BlockFormat::File(fidl::new_empty!(
13130                            fidl::encoding::Endpoint<
13131                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13132                            >,
13133                            fidl::encoding::DefaultFuchsiaResourceDialect
13134                        ));
13135                    }
13136                    #[allow(irrefutable_let_patterns)]
13137                    if let BlockFormat::File(ref mut val) = self {
13138                        fidl::decode!(
13139                            fidl::encoding::Endpoint<
13140                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13141                            >,
13142                            fidl::encoding::DefaultFuchsiaResourceDialect,
13143                            val,
13144                            decoder,
13145                            _inner_offset,
13146                            depth
13147                        )?;
13148                    } else {
13149                        unreachable!()
13150                    }
13151                }
13152                2 => {
13153                    #[allow(irrefutable_let_patterns)]
13154                    if let BlockFormat::Qcow(_) = self {
13155                        // Do nothing, read the value into the object
13156                    } else {
13157                        // Initialize `self` to the right variant
13158                        *self = BlockFormat::Qcow(
13159                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
13160                        );
13161                    }
13162                    #[allow(irrefutable_let_patterns)]
13163                    if let BlockFormat::Qcow(ref mut val) = self {
13164                        fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
13165                    } else {
13166                        unreachable!()
13167                    }
13168                }
13169                3 => {
13170                    #[allow(irrefutable_let_patterns)]
13171                    if let BlockFormat::Block(_) = self {
13172                        // Do nothing, read the value into the object
13173                    } else {
13174                        // Initialize `self` to the right variant
13175                        *self = BlockFormat::Block(fidl::new_empty!(
13176                            fidl::encoding::Endpoint<
13177                                fidl::endpoints::ClientEnd<
13178                                    fidl_fuchsia_hardware_block::BlockMarker,
13179                                >,
13180                            >,
13181                            fidl::encoding::DefaultFuchsiaResourceDialect
13182                        ));
13183                    }
13184                    #[allow(irrefutable_let_patterns)]
13185                    if let BlockFormat::Block(ref mut val) = self {
13186                        fidl::decode!(
13187                            fidl::encoding::Endpoint<
13188                                fidl::endpoints::ClientEnd<
13189                                    fidl_fuchsia_hardware_block::BlockMarker,
13190                                >,
13191                            >,
13192                            fidl::encoding::DefaultFuchsiaResourceDialect,
13193                            val,
13194                            decoder,
13195                            _inner_offset,
13196                            depth
13197                        )?;
13198                    } else {
13199                        unreachable!()
13200                    }
13201                }
13202                ordinal => panic!("unexpected ordinal {:?}", ordinal),
13203            }
13204            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
13205                return Err(fidl::Error::InvalidNumBytesInEnvelope);
13206            }
13207            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13208                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13209            }
13210            Ok(())
13211        }
13212    }
13213}