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
250impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockFormat {}
251
252#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
253pub struct BalloonControllerMarker;
254
255impl fidl::endpoints::ProtocolMarker for BalloonControllerMarker {
256    type Proxy = BalloonControllerProxy;
257    type RequestStream = BalloonControllerRequestStream;
258    #[cfg(target_os = "fuchsia")]
259    type SynchronousProxy = BalloonControllerSynchronousProxy;
260
261    const DEBUG_NAME: &'static str = "fuchsia.virtualization.BalloonController";
262}
263impl fidl::endpoints::DiscoverableProtocolMarker for BalloonControllerMarker {}
264
265pub trait BalloonControllerProxyInterface: Send + Sync {
266    type GetBalloonSizeResponseFut: std::future::Future<Output = Result<(u32, u32), fidl::Error>>
267        + Send;
268    fn r#get_balloon_size(&self) -> Self::GetBalloonSizeResponseFut;
269    fn r#request_num_pages(&self, requested_num_pages: u32) -> Result<(), fidl::Error>;
270    type GetMemStatsResponseFut: std::future::Future<Output = Result<(i32, Option<Vec<MemStat>>), fidl::Error>>
271        + Send;
272    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut;
273}
274#[derive(Debug)]
275#[cfg(target_os = "fuchsia")]
276pub struct BalloonControllerSynchronousProxy {
277    client: fidl::client::sync::Client,
278}
279
280#[cfg(target_os = "fuchsia")]
281impl fidl::endpoints::SynchronousProxy for BalloonControllerSynchronousProxy {
282    type Proxy = BalloonControllerProxy;
283    type Protocol = BalloonControllerMarker;
284
285    fn from_channel(inner: fidl::Channel) -> Self {
286        Self::new(inner)
287    }
288
289    fn into_channel(self) -> fidl::Channel {
290        self.client.into_channel()
291    }
292
293    fn as_channel(&self) -> &fidl::Channel {
294        self.client.as_channel()
295    }
296}
297
298#[cfg(target_os = "fuchsia")]
299impl BalloonControllerSynchronousProxy {
300    pub fn new(channel: fidl::Channel) -> Self {
301        let protocol_name =
302            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
303        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
304    }
305
306    pub fn into_channel(self) -> fidl::Channel {
307        self.client.into_channel()
308    }
309
310    /// Waits until an event arrives and returns it. It is safe for other
311    /// threads to make concurrent requests while waiting for an event.
312    pub fn wait_for_event(
313        &self,
314        deadline: zx::MonotonicInstant,
315    ) -> Result<BalloonControllerEvent, fidl::Error> {
316        BalloonControllerEvent::decode(self.client.wait_for_event(deadline)?)
317    }
318
319    /// Get the current and requested number of pages in the memory balloon.
320    ///
321    /// current_num_pages is the number of pages balloon has right now.
322    /// requested_num_pages is the desired number of pages in the balloon.
323    ///
324    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
325    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
326    pub fn r#get_balloon_size(
327        &self,
328        ___deadline: zx::MonotonicInstant,
329    ) -> Result<(u32, u32), fidl::Error> {
330        let _response = self
331            .client
332            .send_query::<fidl::encoding::EmptyPayload, BalloonControllerGetBalloonSizeResponse>(
333                (),
334                0x2bb2ebaa6ff64d0b,
335                fidl::encoding::DynamicFlags::empty(),
336                ___deadline,
337            )?;
338        Ok((_response.current_num_pages, _response.requested_num_pages))
339    }
340
341    /// Request a number of pages to be supplied to the memory balloon.
342    ///
343    /// If `requested_num_pages` is greater than the `current_num_pages` config
344    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
345    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
346    /// the guest driver MAY reclaim pages from the memory balloon.
347    pub fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
348        self.client.send::<BalloonControllerRequestNumPagesRequest>(
349            (requested_num_pages,),
350            0x55c444d65e1df1e8,
351            fidl::encoding::DynamicFlags::empty(),
352        )
353    }
354
355    /// Get memory statistics of the guest instance.
356    pub fn r#get_mem_stats(
357        &self,
358        ___deadline: zx::MonotonicInstant,
359    ) -> Result<(i32, Option<Vec<MemStat>>), fidl::Error> {
360        let _response = self
361            .client
362            .send_query::<fidl::encoding::EmptyPayload, BalloonControllerGetMemStatsResponse>(
363                (),
364                0x676199795cc01142,
365                fidl::encoding::DynamicFlags::empty(),
366                ___deadline,
367            )?;
368        Ok((_response.status, _response.mem_stats))
369    }
370}
371
372#[cfg(target_os = "fuchsia")]
373impl From<BalloonControllerSynchronousProxy> for zx::Handle {
374    fn from(value: BalloonControllerSynchronousProxy) -> Self {
375        value.into_channel().into()
376    }
377}
378
379#[cfg(target_os = "fuchsia")]
380impl From<fidl::Channel> for BalloonControllerSynchronousProxy {
381    fn from(value: fidl::Channel) -> Self {
382        Self::new(value)
383    }
384}
385
386#[derive(Debug, Clone)]
387pub struct BalloonControllerProxy {
388    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
389}
390
391impl fidl::endpoints::Proxy for BalloonControllerProxy {
392    type Protocol = BalloonControllerMarker;
393
394    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
395        Self::new(inner)
396    }
397
398    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
399        self.client.into_channel().map_err(|client| Self { client })
400    }
401
402    fn as_channel(&self) -> &::fidl::AsyncChannel {
403        self.client.as_channel()
404    }
405}
406
407impl BalloonControllerProxy {
408    /// Create a new Proxy for fuchsia.virtualization/BalloonController.
409    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
410        let protocol_name =
411            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
412        Self { client: fidl::client::Client::new(channel, protocol_name) }
413    }
414
415    /// Get a Stream of events from the remote end of the protocol.
416    ///
417    /// # Panics
418    ///
419    /// Panics if the event stream was already taken.
420    pub fn take_event_stream(&self) -> BalloonControllerEventStream {
421        BalloonControllerEventStream { event_receiver: self.client.take_event_receiver() }
422    }
423
424    /// Get the current and requested number of pages in the memory balloon.
425    ///
426    /// current_num_pages is the number of pages balloon has right now.
427    /// requested_num_pages is the desired number of pages in the balloon.
428    ///
429    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
430    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
431    pub fn r#get_balloon_size(
432        &self,
433    ) -> fidl::client::QueryResponseFut<(u32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
434    {
435        BalloonControllerProxyInterface::r#get_balloon_size(self)
436    }
437
438    /// Request a number of pages to be supplied to the memory balloon.
439    ///
440    /// If `requested_num_pages` is greater than the `current_num_pages` config
441    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
442    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
443    /// the guest driver MAY reclaim pages from the memory balloon.
444    pub fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
445        BalloonControllerProxyInterface::r#request_num_pages(self, requested_num_pages)
446    }
447
448    /// Get memory statistics of the guest instance.
449    pub fn r#get_mem_stats(
450        &self,
451    ) -> fidl::client::QueryResponseFut<
452        (i32, Option<Vec<MemStat>>),
453        fidl::encoding::DefaultFuchsiaResourceDialect,
454    > {
455        BalloonControllerProxyInterface::r#get_mem_stats(self)
456    }
457}
458
459impl BalloonControllerProxyInterface for BalloonControllerProxy {
460    type GetBalloonSizeResponseFut =
461        fidl::client::QueryResponseFut<(u32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
462    fn r#get_balloon_size(&self) -> Self::GetBalloonSizeResponseFut {
463        fn _decode(
464            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
465        ) -> Result<(u32, u32), fidl::Error> {
466            let _response = fidl::client::decode_transaction_body::<
467                BalloonControllerGetBalloonSizeResponse,
468                fidl::encoding::DefaultFuchsiaResourceDialect,
469                0x2bb2ebaa6ff64d0b,
470            >(_buf?)?;
471            Ok((_response.current_num_pages, _response.requested_num_pages))
472        }
473        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (u32, u32)>(
474            (),
475            0x2bb2ebaa6ff64d0b,
476            fidl::encoding::DynamicFlags::empty(),
477            _decode,
478        )
479    }
480
481    fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
482        self.client.send::<BalloonControllerRequestNumPagesRequest>(
483            (requested_num_pages,),
484            0x55c444d65e1df1e8,
485            fidl::encoding::DynamicFlags::empty(),
486        )
487    }
488
489    type GetMemStatsResponseFut = fidl::client::QueryResponseFut<
490        (i32, Option<Vec<MemStat>>),
491        fidl::encoding::DefaultFuchsiaResourceDialect,
492    >;
493    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut {
494        fn _decode(
495            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
496        ) -> Result<(i32, Option<Vec<MemStat>>), fidl::Error> {
497            let _response = fidl::client::decode_transaction_body::<
498                BalloonControllerGetMemStatsResponse,
499                fidl::encoding::DefaultFuchsiaResourceDialect,
500                0x676199795cc01142,
501            >(_buf?)?;
502            Ok((_response.status, _response.mem_stats))
503        }
504        self.client
505            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<Vec<MemStat>>)>(
506                (),
507                0x676199795cc01142,
508                fidl::encoding::DynamicFlags::empty(),
509                _decode,
510            )
511    }
512}
513
514pub struct BalloonControllerEventStream {
515    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
516}
517
518impl std::marker::Unpin for BalloonControllerEventStream {}
519
520impl futures::stream::FusedStream for BalloonControllerEventStream {
521    fn is_terminated(&self) -> bool {
522        self.event_receiver.is_terminated()
523    }
524}
525
526impl futures::Stream for BalloonControllerEventStream {
527    type Item = Result<BalloonControllerEvent, fidl::Error>;
528
529    fn poll_next(
530        mut self: std::pin::Pin<&mut Self>,
531        cx: &mut std::task::Context<'_>,
532    ) -> std::task::Poll<Option<Self::Item>> {
533        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
534            &mut self.event_receiver,
535            cx
536        )?) {
537            Some(buf) => std::task::Poll::Ready(Some(BalloonControllerEvent::decode(buf))),
538            None => std::task::Poll::Ready(None),
539        }
540    }
541}
542
543#[derive(Debug)]
544pub enum BalloonControllerEvent {}
545
546impl BalloonControllerEvent {
547    /// Decodes a message buffer as a [`BalloonControllerEvent`].
548    fn decode(
549        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
550    ) -> Result<BalloonControllerEvent, fidl::Error> {
551        let (bytes, _handles) = buf.split_mut();
552        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
553        debug_assert_eq!(tx_header.tx_id, 0);
554        match tx_header.ordinal {
555            _ => Err(fidl::Error::UnknownOrdinal {
556                ordinal: tx_header.ordinal,
557                protocol_name:
558                    <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
559            }),
560        }
561    }
562}
563
564/// A Stream of incoming requests for fuchsia.virtualization/BalloonController.
565pub struct BalloonControllerRequestStream {
566    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
567    is_terminated: bool,
568}
569
570impl std::marker::Unpin for BalloonControllerRequestStream {}
571
572impl futures::stream::FusedStream for BalloonControllerRequestStream {
573    fn is_terminated(&self) -> bool {
574        self.is_terminated
575    }
576}
577
578impl fidl::endpoints::RequestStream for BalloonControllerRequestStream {
579    type Protocol = BalloonControllerMarker;
580    type ControlHandle = BalloonControllerControlHandle;
581
582    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
583        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
584    }
585
586    fn control_handle(&self) -> Self::ControlHandle {
587        BalloonControllerControlHandle { inner: self.inner.clone() }
588    }
589
590    fn into_inner(
591        self,
592    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
593    {
594        (self.inner, self.is_terminated)
595    }
596
597    fn from_inner(
598        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
599        is_terminated: bool,
600    ) -> Self {
601        Self { inner, is_terminated }
602    }
603}
604
605impl futures::Stream for BalloonControllerRequestStream {
606    type Item = Result<BalloonControllerRequest, fidl::Error>;
607
608    fn poll_next(
609        mut self: std::pin::Pin<&mut Self>,
610        cx: &mut std::task::Context<'_>,
611    ) -> std::task::Poll<Option<Self::Item>> {
612        let this = &mut *self;
613        if this.inner.check_shutdown(cx) {
614            this.is_terminated = true;
615            return std::task::Poll::Ready(None);
616        }
617        if this.is_terminated {
618            panic!("polled BalloonControllerRequestStream after completion");
619        }
620        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
621            |bytes, handles| {
622                match this.inner.channel().read_etc(cx, bytes, handles) {
623                    std::task::Poll::Ready(Ok(())) => {}
624                    std::task::Poll::Pending => return std::task::Poll::Pending,
625                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
626                        this.is_terminated = true;
627                        return std::task::Poll::Ready(None);
628                    }
629                    std::task::Poll::Ready(Err(e)) => {
630                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
631                            e.into(),
632                        ))))
633                    }
634                }
635
636                // A message has been received from the channel
637                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
638
639                std::task::Poll::Ready(Some(match header.ordinal {
640                    0x2bb2ebaa6ff64d0b => {
641                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
642                        let mut req = fidl::new_empty!(
643                            fidl::encoding::EmptyPayload,
644                            fidl::encoding::DefaultFuchsiaResourceDialect
645                        );
646                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
647                        let control_handle =
648                            BalloonControllerControlHandle { inner: this.inner.clone() };
649                        Ok(BalloonControllerRequest::GetBalloonSize {
650                            responder: BalloonControllerGetBalloonSizeResponder {
651                                control_handle: std::mem::ManuallyDrop::new(control_handle),
652                                tx_id: header.tx_id,
653                            },
654                        })
655                    }
656                    0x55c444d65e1df1e8 => {
657                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
658                        let mut req = fidl::new_empty!(
659                            BalloonControllerRequestNumPagesRequest,
660                            fidl::encoding::DefaultFuchsiaResourceDialect
661                        );
662                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BalloonControllerRequestNumPagesRequest>(&header, _body_bytes, handles, &mut req)?;
663                        let control_handle =
664                            BalloonControllerControlHandle { inner: this.inner.clone() };
665                        Ok(BalloonControllerRequest::RequestNumPages {
666                            requested_num_pages: req.requested_num_pages,
667
668                            control_handle,
669                        })
670                    }
671                    0x676199795cc01142 => {
672                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
673                        let mut req = fidl::new_empty!(
674                            fidl::encoding::EmptyPayload,
675                            fidl::encoding::DefaultFuchsiaResourceDialect
676                        );
677                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
678                        let control_handle =
679                            BalloonControllerControlHandle { inner: this.inner.clone() };
680                        Ok(BalloonControllerRequest::GetMemStats {
681                            responder: BalloonControllerGetMemStatsResponder {
682                                control_handle: std::mem::ManuallyDrop::new(control_handle),
683                                tx_id: header.tx_id,
684                            },
685                        })
686                    }
687                    _ => Err(fidl::Error::UnknownOrdinal {
688                        ordinal: header.ordinal,
689                        protocol_name:
690                            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
691                    }),
692                }))
693            },
694        )
695    }
696}
697
698/// A `BalloonController` controls a guest instance's memory balloon.
699#[derive(Debug)]
700pub enum BalloonControllerRequest {
701    /// Get the current and requested number of pages in the memory balloon.
702    ///
703    /// current_num_pages is the number of pages balloon has right now.
704    /// requested_num_pages is the desired number of pages in the balloon.
705    ///
706    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
707    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
708    GetBalloonSize { responder: BalloonControllerGetBalloonSizeResponder },
709    /// Request a number of pages to be supplied to the memory balloon.
710    ///
711    /// If `requested_num_pages` is greater than the `current_num_pages` config
712    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
713    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
714    /// the guest driver MAY reclaim pages from the memory balloon.
715    RequestNumPages { requested_num_pages: u32, control_handle: BalloonControllerControlHandle },
716    /// Get memory statistics of the guest instance.
717    GetMemStats { responder: BalloonControllerGetMemStatsResponder },
718}
719
720impl BalloonControllerRequest {
721    #[allow(irrefutable_let_patterns)]
722    pub fn into_get_balloon_size(self) -> Option<(BalloonControllerGetBalloonSizeResponder)> {
723        if let BalloonControllerRequest::GetBalloonSize { responder } = self {
724            Some((responder))
725        } else {
726            None
727        }
728    }
729
730    #[allow(irrefutable_let_patterns)]
731    pub fn into_request_num_pages(self) -> Option<(u32, BalloonControllerControlHandle)> {
732        if let BalloonControllerRequest::RequestNumPages { requested_num_pages, control_handle } =
733            self
734        {
735            Some((requested_num_pages, control_handle))
736        } else {
737            None
738        }
739    }
740
741    #[allow(irrefutable_let_patterns)]
742    pub fn into_get_mem_stats(self) -> Option<(BalloonControllerGetMemStatsResponder)> {
743        if let BalloonControllerRequest::GetMemStats { responder } = self {
744            Some((responder))
745        } else {
746            None
747        }
748    }
749
750    /// Name of the method defined in FIDL
751    pub fn method_name(&self) -> &'static str {
752        match *self {
753            BalloonControllerRequest::GetBalloonSize { .. } => "get_balloon_size",
754            BalloonControllerRequest::RequestNumPages { .. } => "request_num_pages",
755            BalloonControllerRequest::GetMemStats { .. } => "get_mem_stats",
756        }
757    }
758}
759
760#[derive(Debug, Clone)]
761pub struct BalloonControllerControlHandle {
762    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
763}
764
765impl fidl::endpoints::ControlHandle for BalloonControllerControlHandle {
766    fn shutdown(&self) {
767        self.inner.shutdown()
768    }
769    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
770        self.inner.shutdown_with_epitaph(status)
771    }
772
773    fn is_closed(&self) -> bool {
774        self.inner.channel().is_closed()
775    }
776    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
777        self.inner.channel().on_closed()
778    }
779
780    #[cfg(target_os = "fuchsia")]
781    fn signal_peer(
782        &self,
783        clear_mask: zx::Signals,
784        set_mask: zx::Signals,
785    ) -> Result<(), zx_status::Status> {
786        use fidl::Peered;
787        self.inner.channel().signal_peer(clear_mask, set_mask)
788    }
789}
790
791impl BalloonControllerControlHandle {}
792
793#[must_use = "FIDL methods require a response to be sent"]
794#[derive(Debug)]
795pub struct BalloonControllerGetBalloonSizeResponder {
796    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
797    tx_id: u32,
798}
799
800/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
801/// if the responder is dropped without sending a response, so that the client
802/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
803impl std::ops::Drop for BalloonControllerGetBalloonSizeResponder {
804    fn drop(&mut self) {
805        self.control_handle.shutdown();
806        // Safety: drops once, never accessed again
807        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
808    }
809}
810
811impl fidl::endpoints::Responder for BalloonControllerGetBalloonSizeResponder {
812    type ControlHandle = BalloonControllerControlHandle;
813
814    fn control_handle(&self) -> &BalloonControllerControlHandle {
815        &self.control_handle
816    }
817
818    fn drop_without_shutdown(mut self) {
819        // Safety: drops once, never accessed again due to mem::forget
820        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
821        // Prevent Drop from running (which would shut down the channel)
822        std::mem::forget(self);
823    }
824}
825
826impl BalloonControllerGetBalloonSizeResponder {
827    /// Sends a response to the FIDL transaction.
828    ///
829    /// Sets the channel to shutdown if an error occurs.
830    pub fn send(
831        self,
832        mut current_num_pages: u32,
833        mut requested_num_pages: u32,
834    ) -> Result<(), fidl::Error> {
835        let _result = self.send_raw(current_num_pages, requested_num_pages);
836        if _result.is_err() {
837            self.control_handle.shutdown();
838        }
839        self.drop_without_shutdown();
840        _result
841    }
842
843    /// Similar to "send" but does not shutdown the channel if an error occurs.
844    pub fn send_no_shutdown_on_err(
845        self,
846        mut current_num_pages: u32,
847        mut requested_num_pages: u32,
848    ) -> Result<(), fidl::Error> {
849        let _result = self.send_raw(current_num_pages, requested_num_pages);
850        self.drop_without_shutdown();
851        _result
852    }
853
854    fn send_raw(
855        &self,
856        mut current_num_pages: u32,
857        mut requested_num_pages: u32,
858    ) -> Result<(), fidl::Error> {
859        self.control_handle.inner.send::<BalloonControllerGetBalloonSizeResponse>(
860            (current_num_pages, requested_num_pages),
861            self.tx_id,
862            0x2bb2ebaa6ff64d0b,
863            fidl::encoding::DynamicFlags::empty(),
864        )
865    }
866}
867
868#[must_use = "FIDL methods require a response to be sent"]
869#[derive(Debug)]
870pub struct BalloonControllerGetMemStatsResponder {
871    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
872    tx_id: u32,
873}
874
875/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
876/// if the responder is dropped without sending a response, so that the client
877/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
878impl std::ops::Drop for BalloonControllerGetMemStatsResponder {
879    fn drop(&mut self) {
880        self.control_handle.shutdown();
881        // Safety: drops once, never accessed again
882        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
883    }
884}
885
886impl fidl::endpoints::Responder for BalloonControllerGetMemStatsResponder {
887    type ControlHandle = BalloonControllerControlHandle;
888
889    fn control_handle(&self) -> &BalloonControllerControlHandle {
890        &self.control_handle
891    }
892
893    fn drop_without_shutdown(mut self) {
894        // Safety: drops once, never accessed again due to mem::forget
895        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
896        // Prevent Drop from running (which would shut down the channel)
897        std::mem::forget(self);
898    }
899}
900
901impl BalloonControllerGetMemStatsResponder {
902    /// Sends a response to the FIDL transaction.
903    ///
904    /// Sets the channel to shutdown if an error occurs.
905    pub fn send(
906        self,
907        mut status: i32,
908        mut mem_stats: Option<&[MemStat]>,
909    ) -> Result<(), fidl::Error> {
910        let _result = self.send_raw(status, mem_stats);
911        if _result.is_err() {
912            self.control_handle.shutdown();
913        }
914        self.drop_without_shutdown();
915        _result
916    }
917
918    /// Similar to "send" but does not shutdown the channel if an error occurs.
919    pub fn send_no_shutdown_on_err(
920        self,
921        mut status: i32,
922        mut mem_stats: Option<&[MemStat]>,
923    ) -> Result<(), fidl::Error> {
924        let _result = self.send_raw(status, mem_stats);
925        self.drop_without_shutdown();
926        _result
927    }
928
929    fn send_raw(
930        &self,
931        mut status: i32,
932        mut mem_stats: Option<&[MemStat]>,
933    ) -> Result<(), fidl::Error> {
934        self.control_handle.inner.send::<BalloonControllerGetMemStatsResponse>(
935            (status, mem_stats),
936            self.tx_id,
937            0x676199795cc01142,
938            fidl::encoding::DynamicFlags::empty(),
939        )
940    }
941}
942
943#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
944pub struct DebianGuestManagerMarker;
945
946impl fidl::endpoints::ProtocolMarker for DebianGuestManagerMarker {
947    type Proxy = DebianGuestManagerProxy;
948    type RequestStream = DebianGuestManagerRequestStream;
949    #[cfg(target_os = "fuchsia")]
950    type SynchronousProxy = DebianGuestManagerSynchronousProxy;
951
952    const DEBUG_NAME: &'static str = "fuchsia.virtualization.DebianGuestManager";
953}
954impl fidl::endpoints::DiscoverableProtocolMarker for DebianGuestManagerMarker {}
955
956pub trait DebianGuestManagerProxyInterface: Send + Sync {
957    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
958        + Send;
959    fn r#launch(
960        &self,
961        guest_config: GuestConfig,
962        controller: fidl::endpoints::ServerEnd<GuestMarker>,
963    ) -> Self::LaunchResponseFut;
964    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
965    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
966    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
967        + Send;
968    fn r#connect(
969        &self,
970        controller: fidl::endpoints::ServerEnd<GuestMarker>,
971    ) -> Self::ConnectResponseFut;
972    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
973    fn r#get_info(&self) -> Self::GetInfoResponseFut;
974}
975#[derive(Debug)]
976#[cfg(target_os = "fuchsia")]
977pub struct DebianGuestManagerSynchronousProxy {
978    client: fidl::client::sync::Client,
979}
980
981#[cfg(target_os = "fuchsia")]
982impl fidl::endpoints::SynchronousProxy for DebianGuestManagerSynchronousProxy {
983    type Proxy = DebianGuestManagerProxy;
984    type Protocol = DebianGuestManagerMarker;
985
986    fn from_channel(inner: fidl::Channel) -> Self {
987        Self::new(inner)
988    }
989
990    fn into_channel(self) -> fidl::Channel {
991        self.client.into_channel()
992    }
993
994    fn as_channel(&self) -> &fidl::Channel {
995        self.client.as_channel()
996    }
997}
998
999#[cfg(target_os = "fuchsia")]
1000impl DebianGuestManagerSynchronousProxy {
1001    pub fn new(channel: fidl::Channel) -> Self {
1002        let protocol_name =
1003            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1004        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1005    }
1006
1007    pub fn into_channel(self) -> fidl::Channel {
1008        self.client.into_channel()
1009    }
1010
1011    /// Waits until an event arrives and returns it. It is safe for other
1012    /// threads to make concurrent requests while waiting for an event.
1013    pub fn wait_for_event(
1014        &self,
1015        deadline: zx::MonotonicInstant,
1016    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1017        DebianGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
1018    }
1019
1020    /// Launch a new guest instance.
1021    ///
1022    /// Possible errors:
1023    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1024    ///         problems detected by the guest manager.
1025    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1026    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1027    ///         component logs for a more specific failure.
1028    pub fn r#launch(
1029        &self,
1030        mut guest_config: GuestConfig,
1031        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1032        ___deadline: zx::MonotonicInstant,
1033    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1034        let _response =
1035            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
1036                fidl::encoding::EmptyStruct,
1037                GuestManagerError,
1038            >>(
1039                (&mut guest_config, controller),
1040                0x394a2e29f750323e,
1041                fidl::encoding::DynamicFlags::empty(),
1042                ___deadline,
1043            )?;
1044        Ok(_response.map(|x| x))
1045    }
1046
1047    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1048    /// be used to launch another guest.
1049    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1050        let _response =
1051            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1052                (),
1053                0x3ad9a012982f872d,
1054                fidl::encoding::DynamicFlags::empty(),
1055                ___deadline,
1056            )?;
1057        Ok(_response)
1058    }
1059
1060    /// Connect to a currently running guest.
1061    ///
1062    /// Possible errors:
1063    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1064    ///         has launched before attempting to reconnect.
1065    pub fn r#connect(
1066        &self,
1067        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1068        ___deadline: zx::MonotonicInstant,
1069    ) -> Result<GuestManagerConnectResult, fidl::Error> {
1070        let _response =
1071            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
1072                fidl::encoding::EmptyStruct,
1073                GuestManagerError,
1074            >>(
1075                (controller,),
1076                0x4e489076e3bb15b4,
1077                fidl::encoding::DynamicFlags::empty(),
1078                ___deadline,
1079            )?;
1080        Ok(_response.map(|x| x))
1081    }
1082
1083    /// Query guest info
1084    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
1085        let _response =
1086            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
1087                (),
1088                0x76892614aea695dc,
1089                fidl::encoding::DynamicFlags::empty(),
1090                ___deadline,
1091            )?;
1092        Ok(_response.guest_info)
1093    }
1094}
1095
1096#[cfg(target_os = "fuchsia")]
1097impl From<DebianGuestManagerSynchronousProxy> for zx::Handle {
1098    fn from(value: DebianGuestManagerSynchronousProxy) -> Self {
1099        value.into_channel().into()
1100    }
1101}
1102
1103#[cfg(target_os = "fuchsia")]
1104impl From<fidl::Channel> for DebianGuestManagerSynchronousProxy {
1105    fn from(value: fidl::Channel) -> Self {
1106        Self::new(value)
1107    }
1108}
1109
1110#[derive(Debug, Clone)]
1111pub struct DebianGuestManagerProxy {
1112    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1113}
1114
1115impl fidl::endpoints::Proxy for DebianGuestManagerProxy {
1116    type Protocol = DebianGuestManagerMarker;
1117
1118    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1119        Self::new(inner)
1120    }
1121
1122    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1123        self.client.into_channel().map_err(|client| Self { client })
1124    }
1125
1126    fn as_channel(&self) -> &::fidl::AsyncChannel {
1127        self.client.as_channel()
1128    }
1129}
1130
1131impl DebianGuestManagerProxy {
1132    /// Create a new Proxy for fuchsia.virtualization/DebianGuestManager.
1133    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1134        let protocol_name =
1135            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1136        Self { client: fidl::client::Client::new(channel, protocol_name) }
1137    }
1138
1139    /// Get a Stream of events from the remote end of the protocol.
1140    ///
1141    /// # Panics
1142    ///
1143    /// Panics if the event stream was already taken.
1144    pub fn take_event_stream(&self) -> DebianGuestManagerEventStream {
1145        DebianGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
1146    }
1147
1148    /// Launch a new guest instance.
1149    ///
1150    /// Possible errors:
1151    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1152    ///         problems detected by the guest manager.
1153    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1154    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1155    ///         component logs for a more specific failure.
1156    pub fn r#launch(
1157        &self,
1158        mut guest_config: GuestConfig,
1159        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1160    ) -> fidl::client::QueryResponseFut<
1161        GuestManagerLaunchResult,
1162        fidl::encoding::DefaultFuchsiaResourceDialect,
1163    > {
1164        DebianGuestManagerProxyInterface::r#launch(self, guest_config, controller)
1165    }
1166
1167    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1168    /// be used to launch another guest.
1169    pub fn r#force_shutdown(
1170        &self,
1171    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1172        DebianGuestManagerProxyInterface::r#force_shutdown(self)
1173    }
1174
1175    /// Connect to a currently running guest.
1176    ///
1177    /// Possible errors:
1178    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1179    ///         has launched before attempting to reconnect.
1180    pub fn r#connect(
1181        &self,
1182        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1183    ) -> fidl::client::QueryResponseFut<
1184        GuestManagerConnectResult,
1185        fidl::encoding::DefaultFuchsiaResourceDialect,
1186    > {
1187        DebianGuestManagerProxyInterface::r#connect(self, controller)
1188    }
1189
1190    /// Query guest info
1191    pub fn r#get_info(
1192        &self,
1193    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1194    {
1195        DebianGuestManagerProxyInterface::r#get_info(self)
1196    }
1197}
1198
1199impl DebianGuestManagerProxyInterface for DebianGuestManagerProxy {
1200    type LaunchResponseFut = fidl::client::QueryResponseFut<
1201        GuestManagerLaunchResult,
1202        fidl::encoding::DefaultFuchsiaResourceDialect,
1203    >;
1204    fn r#launch(
1205        &self,
1206        mut guest_config: GuestConfig,
1207        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1208    ) -> Self::LaunchResponseFut {
1209        fn _decode(
1210            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1211        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1212            let _response = fidl::client::decode_transaction_body::<
1213                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1214                fidl::encoding::DefaultFuchsiaResourceDialect,
1215                0x394a2e29f750323e,
1216            >(_buf?)?;
1217            Ok(_response.map(|x| x))
1218        }
1219        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
1220            (&mut guest_config, controller),
1221            0x394a2e29f750323e,
1222            fidl::encoding::DynamicFlags::empty(),
1223            _decode,
1224        )
1225    }
1226
1227    type ForceShutdownResponseFut =
1228        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1229    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
1230        fn _decode(
1231            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1232        ) -> Result<(), fidl::Error> {
1233            let _response = fidl::client::decode_transaction_body::<
1234                fidl::encoding::EmptyPayload,
1235                fidl::encoding::DefaultFuchsiaResourceDialect,
1236                0x3ad9a012982f872d,
1237            >(_buf?)?;
1238            Ok(_response)
1239        }
1240        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1241            (),
1242            0x3ad9a012982f872d,
1243            fidl::encoding::DynamicFlags::empty(),
1244            _decode,
1245        )
1246    }
1247
1248    type ConnectResponseFut = fidl::client::QueryResponseFut<
1249        GuestManagerConnectResult,
1250        fidl::encoding::DefaultFuchsiaResourceDialect,
1251    >;
1252    fn r#connect(
1253        &self,
1254        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1255    ) -> Self::ConnectResponseFut {
1256        fn _decode(
1257            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1258        ) -> Result<GuestManagerConnectResult, fidl::Error> {
1259            let _response = fidl::client::decode_transaction_body::<
1260                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1261                fidl::encoding::DefaultFuchsiaResourceDialect,
1262                0x4e489076e3bb15b4,
1263            >(_buf?)?;
1264            Ok(_response.map(|x| x))
1265        }
1266        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
1267            (controller,),
1268            0x4e489076e3bb15b4,
1269            fidl::encoding::DynamicFlags::empty(),
1270            _decode,
1271        )
1272    }
1273
1274    type GetInfoResponseFut =
1275        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
1276    fn r#get_info(&self) -> Self::GetInfoResponseFut {
1277        fn _decode(
1278            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1279        ) -> Result<GuestInfo, fidl::Error> {
1280            let _response = fidl::client::decode_transaction_body::<
1281                GuestManagerGetInfoResponse,
1282                fidl::encoding::DefaultFuchsiaResourceDialect,
1283                0x76892614aea695dc,
1284            >(_buf?)?;
1285            Ok(_response.guest_info)
1286        }
1287        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
1288            (),
1289            0x76892614aea695dc,
1290            fidl::encoding::DynamicFlags::empty(),
1291            _decode,
1292        )
1293    }
1294}
1295
1296pub struct DebianGuestManagerEventStream {
1297    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1298}
1299
1300impl std::marker::Unpin for DebianGuestManagerEventStream {}
1301
1302impl futures::stream::FusedStream for DebianGuestManagerEventStream {
1303    fn is_terminated(&self) -> bool {
1304        self.event_receiver.is_terminated()
1305    }
1306}
1307
1308impl futures::Stream for DebianGuestManagerEventStream {
1309    type Item = Result<DebianGuestManagerEvent, fidl::Error>;
1310
1311    fn poll_next(
1312        mut self: std::pin::Pin<&mut Self>,
1313        cx: &mut std::task::Context<'_>,
1314    ) -> std::task::Poll<Option<Self::Item>> {
1315        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1316            &mut self.event_receiver,
1317            cx
1318        )?) {
1319            Some(buf) => std::task::Poll::Ready(Some(DebianGuestManagerEvent::decode(buf))),
1320            None => std::task::Poll::Ready(None),
1321        }
1322    }
1323}
1324
1325#[derive(Debug)]
1326pub enum DebianGuestManagerEvent {}
1327
1328impl DebianGuestManagerEvent {
1329    /// Decodes a message buffer as a [`DebianGuestManagerEvent`].
1330    fn decode(
1331        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1332    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1333        let (bytes, _handles) = buf.split_mut();
1334        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1335        debug_assert_eq!(tx_header.tx_id, 0);
1336        match tx_header.ordinal {
1337            _ => Err(fidl::Error::UnknownOrdinal {
1338                ordinal: tx_header.ordinal,
1339                protocol_name:
1340                    <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1341            }),
1342        }
1343    }
1344}
1345
1346/// A Stream of incoming requests for fuchsia.virtualization/DebianGuestManager.
1347pub struct DebianGuestManagerRequestStream {
1348    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1349    is_terminated: bool,
1350}
1351
1352impl std::marker::Unpin for DebianGuestManagerRequestStream {}
1353
1354impl futures::stream::FusedStream for DebianGuestManagerRequestStream {
1355    fn is_terminated(&self) -> bool {
1356        self.is_terminated
1357    }
1358}
1359
1360impl fidl::endpoints::RequestStream for DebianGuestManagerRequestStream {
1361    type Protocol = DebianGuestManagerMarker;
1362    type ControlHandle = DebianGuestManagerControlHandle;
1363
1364    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1365        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1366    }
1367
1368    fn control_handle(&self) -> Self::ControlHandle {
1369        DebianGuestManagerControlHandle { inner: self.inner.clone() }
1370    }
1371
1372    fn into_inner(
1373        self,
1374    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1375    {
1376        (self.inner, self.is_terminated)
1377    }
1378
1379    fn from_inner(
1380        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1381        is_terminated: bool,
1382    ) -> Self {
1383        Self { inner, is_terminated }
1384    }
1385}
1386
1387impl futures::Stream for DebianGuestManagerRequestStream {
1388    type Item = Result<DebianGuestManagerRequest, fidl::Error>;
1389
1390    fn poll_next(
1391        mut self: std::pin::Pin<&mut Self>,
1392        cx: &mut std::task::Context<'_>,
1393    ) -> std::task::Poll<Option<Self::Item>> {
1394        let this = &mut *self;
1395        if this.inner.check_shutdown(cx) {
1396            this.is_terminated = true;
1397            return std::task::Poll::Ready(None);
1398        }
1399        if this.is_terminated {
1400            panic!("polled DebianGuestManagerRequestStream after completion");
1401        }
1402        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1403            |bytes, handles| {
1404                match this.inner.channel().read_etc(cx, bytes, handles) {
1405                    std::task::Poll::Ready(Ok(())) => {}
1406                    std::task::Poll::Pending => return std::task::Poll::Pending,
1407                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1408                        this.is_terminated = true;
1409                        return std::task::Poll::Ready(None);
1410                    }
1411                    std::task::Poll::Ready(Err(e)) => {
1412                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1413                            e.into(),
1414                        ))))
1415                    }
1416                }
1417
1418                // A message has been received from the channel
1419                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1420
1421                std::task::Poll::Ready(Some(match header.ordinal {
1422                0x394a2e29f750323e => {
1423                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1424                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1425                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
1426                    let control_handle = DebianGuestManagerControlHandle {
1427                        inner: this.inner.clone(),
1428                    };
1429                    Ok(DebianGuestManagerRequest::Launch {guest_config: req.guest_config,
1430controller: req.controller,
1431
1432                        responder: DebianGuestManagerLaunchResponder {
1433                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1434                            tx_id: header.tx_id,
1435                        },
1436                    })
1437                }
1438                0x3ad9a012982f872d => {
1439                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1440                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1441                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1442                    let control_handle = DebianGuestManagerControlHandle {
1443                        inner: this.inner.clone(),
1444                    };
1445                    Ok(DebianGuestManagerRequest::ForceShutdown {
1446                        responder: DebianGuestManagerForceShutdownResponder {
1447                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1448                            tx_id: header.tx_id,
1449                        },
1450                    })
1451                }
1452                0x4e489076e3bb15b4 => {
1453                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1454                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1455                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1456                    let control_handle = DebianGuestManagerControlHandle {
1457                        inner: this.inner.clone(),
1458                    };
1459                    Ok(DebianGuestManagerRequest::Connect {controller: req.controller,
1460
1461                        responder: DebianGuestManagerConnectResponder {
1462                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1463                            tx_id: header.tx_id,
1464                        },
1465                    })
1466                }
1467                0x76892614aea695dc => {
1468                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1469                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1470                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1471                    let control_handle = DebianGuestManagerControlHandle {
1472                        inner: this.inner.clone(),
1473                    };
1474                    Ok(DebianGuestManagerRequest::GetInfo {
1475                        responder: DebianGuestManagerGetInfoResponder {
1476                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1477                            tx_id: header.tx_id,
1478                        },
1479                    })
1480                }
1481                _ => Err(fidl::Error::UnknownOrdinal {
1482                    ordinal: header.ordinal,
1483                    protocol_name: <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1484                }),
1485            }))
1486            },
1487        )
1488    }
1489}
1490
1491#[derive(Debug)]
1492pub enum DebianGuestManagerRequest {
1493    /// Launch a new guest instance.
1494    ///
1495    /// Possible errors:
1496    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1497    ///         problems detected by the guest manager.
1498    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1499    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1500    ///         component logs for a more specific failure.
1501    Launch {
1502        guest_config: GuestConfig,
1503        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1504        responder: DebianGuestManagerLaunchResponder,
1505    },
1506    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1507    /// be used to launch another guest.
1508    ForceShutdown { responder: DebianGuestManagerForceShutdownResponder },
1509    /// Connect to a currently running guest.
1510    ///
1511    /// Possible errors:
1512    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1513    ///         has launched before attempting to reconnect.
1514    Connect {
1515        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1516        responder: DebianGuestManagerConnectResponder,
1517    },
1518    /// Query guest info
1519    GetInfo { responder: DebianGuestManagerGetInfoResponder },
1520}
1521
1522impl DebianGuestManagerRequest {
1523    #[allow(irrefutable_let_patterns)]
1524    pub fn into_launch(
1525        self,
1526    ) -> Option<(
1527        GuestConfig,
1528        fidl::endpoints::ServerEnd<GuestMarker>,
1529        DebianGuestManagerLaunchResponder,
1530    )> {
1531        if let DebianGuestManagerRequest::Launch { guest_config, controller, responder } = self {
1532            Some((guest_config, controller, responder))
1533        } else {
1534            None
1535        }
1536    }
1537
1538    #[allow(irrefutable_let_patterns)]
1539    pub fn into_force_shutdown(self) -> Option<(DebianGuestManagerForceShutdownResponder)> {
1540        if let DebianGuestManagerRequest::ForceShutdown { responder } = self {
1541            Some((responder))
1542        } else {
1543            None
1544        }
1545    }
1546
1547    #[allow(irrefutable_let_patterns)]
1548    pub fn into_connect(
1549        self,
1550    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, DebianGuestManagerConnectResponder)> {
1551        if let DebianGuestManagerRequest::Connect { controller, responder } = self {
1552            Some((controller, responder))
1553        } else {
1554            None
1555        }
1556    }
1557
1558    #[allow(irrefutable_let_patterns)]
1559    pub fn into_get_info(self) -> Option<(DebianGuestManagerGetInfoResponder)> {
1560        if let DebianGuestManagerRequest::GetInfo { responder } = self {
1561            Some((responder))
1562        } else {
1563            None
1564        }
1565    }
1566
1567    /// Name of the method defined in FIDL
1568    pub fn method_name(&self) -> &'static str {
1569        match *self {
1570            DebianGuestManagerRequest::Launch { .. } => "launch",
1571            DebianGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
1572            DebianGuestManagerRequest::Connect { .. } => "connect",
1573            DebianGuestManagerRequest::GetInfo { .. } => "get_info",
1574        }
1575    }
1576}
1577
1578#[derive(Debug, Clone)]
1579pub struct DebianGuestManagerControlHandle {
1580    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1581}
1582
1583impl fidl::endpoints::ControlHandle for DebianGuestManagerControlHandle {
1584    fn shutdown(&self) {
1585        self.inner.shutdown()
1586    }
1587    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1588        self.inner.shutdown_with_epitaph(status)
1589    }
1590
1591    fn is_closed(&self) -> bool {
1592        self.inner.channel().is_closed()
1593    }
1594    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1595        self.inner.channel().on_closed()
1596    }
1597
1598    #[cfg(target_os = "fuchsia")]
1599    fn signal_peer(
1600        &self,
1601        clear_mask: zx::Signals,
1602        set_mask: zx::Signals,
1603    ) -> Result<(), zx_status::Status> {
1604        use fidl::Peered;
1605        self.inner.channel().signal_peer(clear_mask, set_mask)
1606    }
1607}
1608
1609impl DebianGuestManagerControlHandle {}
1610
1611#[must_use = "FIDL methods require a response to be sent"]
1612#[derive(Debug)]
1613pub struct DebianGuestManagerLaunchResponder {
1614    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1615    tx_id: u32,
1616}
1617
1618/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1619/// if the responder is dropped without sending a response, so that the client
1620/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1621impl std::ops::Drop for DebianGuestManagerLaunchResponder {
1622    fn drop(&mut self) {
1623        self.control_handle.shutdown();
1624        // Safety: drops once, never accessed again
1625        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1626    }
1627}
1628
1629impl fidl::endpoints::Responder for DebianGuestManagerLaunchResponder {
1630    type ControlHandle = DebianGuestManagerControlHandle;
1631
1632    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1633        &self.control_handle
1634    }
1635
1636    fn drop_without_shutdown(mut self) {
1637        // Safety: drops once, never accessed again due to mem::forget
1638        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1639        // Prevent Drop from running (which would shut down the channel)
1640        std::mem::forget(self);
1641    }
1642}
1643
1644impl DebianGuestManagerLaunchResponder {
1645    /// Sends a response to the FIDL transaction.
1646    ///
1647    /// Sets the channel to shutdown if an error occurs.
1648    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1649        let _result = self.send_raw(result);
1650        if _result.is_err() {
1651            self.control_handle.shutdown();
1652        }
1653        self.drop_without_shutdown();
1654        _result
1655    }
1656
1657    /// Similar to "send" but does not shutdown the channel if an error occurs.
1658    pub fn send_no_shutdown_on_err(
1659        self,
1660        mut result: Result<(), GuestManagerError>,
1661    ) -> Result<(), fidl::Error> {
1662        let _result = self.send_raw(result);
1663        self.drop_without_shutdown();
1664        _result
1665    }
1666
1667    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1668        self.control_handle.inner.send::<fidl::encoding::ResultType<
1669            fidl::encoding::EmptyStruct,
1670            GuestManagerError,
1671        >>(
1672            result,
1673            self.tx_id,
1674            0x394a2e29f750323e,
1675            fidl::encoding::DynamicFlags::empty(),
1676        )
1677    }
1678}
1679
1680#[must_use = "FIDL methods require a response to be sent"]
1681#[derive(Debug)]
1682pub struct DebianGuestManagerForceShutdownResponder {
1683    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1684    tx_id: u32,
1685}
1686
1687/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1688/// if the responder is dropped without sending a response, so that the client
1689/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1690impl std::ops::Drop for DebianGuestManagerForceShutdownResponder {
1691    fn drop(&mut self) {
1692        self.control_handle.shutdown();
1693        // Safety: drops once, never accessed again
1694        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1695    }
1696}
1697
1698impl fidl::endpoints::Responder for DebianGuestManagerForceShutdownResponder {
1699    type ControlHandle = DebianGuestManagerControlHandle;
1700
1701    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1702        &self.control_handle
1703    }
1704
1705    fn drop_without_shutdown(mut self) {
1706        // Safety: drops once, never accessed again due to mem::forget
1707        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1708        // Prevent Drop from running (which would shut down the channel)
1709        std::mem::forget(self);
1710    }
1711}
1712
1713impl DebianGuestManagerForceShutdownResponder {
1714    /// Sends a response to the FIDL transaction.
1715    ///
1716    /// Sets the channel to shutdown if an error occurs.
1717    pub fn send(self) -> Result<(), fidl::Error> {
1718        let _result = self.send_raw();
1719        if _result.is_err() {
1720            self.control_handle.shutdown();
1721        }
1722        self.drop_without_shutdown();
1723        _result
1724    }
1725
1726    /// Similar to "send" but does not shutdown the channel if an error occurs.
1727    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1728        let _result = self.send_raw();
1729        self.drop_without_shutdown();
1730        _result
1731    }
1732
1733    fn send_raw(&self) -> Result<(), fidl::Error> {
1734        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1735            (),
1736            self.tx_id,
1737            0x3ad9a012982f872d,
1738            fidl::encoding::DynamicFlags::empty(),
1739        )
1740    }
1741}
1742
1743#[must_use = "FIDL methods require a response to be sent"]
1744#[derive(Debug)]
1745pub struct DebianGuestManagerConnectResponder {
1746    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1747    tx_id: u32,
1748}
1749
1750/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1751/// if the responder is dropped without sending a response, so that the client
1752/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1753impl std::ops::Drop for DebianGuestManagerConnectResponder {
1754    fn drop(&mut self) {
1755        self.control_handle.shutdown();
1756        // Safety: drops once, never accessed again
1757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1758    }
1759}
1760
1761impl fidl::endpoints::Responder for DebianGuestManagerConnectResponder {
1762    type ControlHandle = DebianGuestManagerControlHandle;
1763
1764    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1765        &self.control_handle
1766    }
1767
1768    fn drop_without_shutdown(mut self) {
1769        // Safety: drops once, never accessed again due to mem::forget
1770        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1771        // Prevent Drop from running (which would shut down the channel)
1772        std::mem::forget(self);
1773    }
1774}
1775
1776impl DebianGuestManagerConnectResponder {
1777    /// Sends a response to the FIDL transaction.
1778    ///
1779    /// Sets the channel to shutdown if an error occurs.
1780    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1781        let _result = self.send_raw(result);
1782        if _result.is_err() {
1783            self.control_handle.shutdown();
1784        }
1785        self.drop_without_shutdown();
1786        _result
1787    }
1788
1789    /// Similar to "send" but does not shutdown the channel if an error occurs.
1790    pub fn send_no_shutdown_on_err(
1791        self,
1792        mut result: Result<(), GuestManagerError>,
1793    ) -> Result<(), fidl::Error> {
1794        let _result = self.send_raw(result);
1795        self.drop_without_shutdown();
1796        _result
1797    }
1798
1799    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1800        self.control_handle.inner.send::<fidl::encoding::ResultType<
1801            fidl::encoding::EmptyStruct,
1802            GuestManagerError,
1803        >>(
1804            result,
1805            self.tx_id,
1806            0x4e489076e3bb15b4,
1807            fidl::encoding::DynamicFlags::empty(),
1808        )
1809    }
1810}
1811
1812#[must_use = "FIDL methods require a response to be sent"]
1813#[derive(Debug)]
1814pub struct DebianGuestManagerGetInfoResponder {
1815    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1816    tx_id: u32,
1817}
1818
1819/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1820/// if the responder is dropped without sending a response, so that the client
1821/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1822impl std::ops::Drop for DebianGuestManagerGetInfoResponder {
1823    fn drop(&mut self) {
1824        self.control_handle.shutdown();
1825        // Safety: drops once, never accessed again
1826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1827    }
1828}
1829
1830impl fidl::endpoints::Responder for DebianGuestManagerGetInfoResponder {
1831    type ControlHandle = DebianGuestManagerControlHandle;
1832
1833    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1834        &self.control_handle
1835    }
1836
1837    fn drop_without_shutdown(mut self) {
1838        // Safety: drops once, never accessed again due to mem::forget
1839        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1840        // Prevent Drop from running (which would shut down the channel)
1841        std::mem::forget(self);
1842    }
1843}
1844
1845impl DebianGuestManagerGetInfoResponder {
1846    /// Sends a response to the FIDL transaction.
1847    ///
1848    /// Sets the channel to shutdown if an error occurs.
1849    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1850        let _result = self.send_raw(guest_info);
1851        if _result.is_err() {
1852            self.control_handle.shutdown();
1853        }
1854        self.drop_without_shutdown();
1855        _result
1856    }
1857
1858    /// Similar to "send" but does not shutdown the channel if an error occurs.
1859    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1860        let _result = self.send_raw(guest_info);
1861        self.drop_without_shutdown();
1862        _result
1863    }
1864
1865    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1866        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
1867            (guest_info,),
1868            self.tx_id,
1869            0x76892614aea695dc,
1870            fidl::encoding::DynamicFlags::empty(),
1871        )
1872    }
1873}
1874
1875#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1876pub struct GuestMarker;
1877
1878impl fidl::endpoints::ProtocolMarker for GuestMarker {
1879    type Proxy = GuestProxy;
1880    type RequestStream = GuestRequestStream;
1881    #[cfg(target_os = "fuchsia")]
1882    type SynchronousProxy = GuestSynchronousProxy;
1883
1884    const DEBUG_NAME: &'static str = "fuchsia.virtualization.Guest";
1885}
1886impl fidl::endpoints::DiscoverableProtocolMarker for GuestMarker {}
1887pub type GuestGetConsoleResult = Result<fidl::Socket, GuestError>;
1888pub type GuestGetHostVsockEndpointResult = Result<(), GuestError>;
1889pub type GuestGetBalloonControllerResult = Result<(), GuestError>;
1890pub type GuestGetMemControllerResult = Result<(), GuestError>;
1891
1892pub trait GuestProxyInterface: Send + Sync {
1893    type GetConsoleResponseFut: std::future::Future<Output = Result<GuestGetConsoleResult, fidl::Error>>
1894        + Send;
1895    fn r#get_console(&self) -> Self::GetConsoleResponseFut;
1896    type GetSerialResponseFut: std::future::Future<Output = Result<fidl::Socket, fidl::Error>>
1897        + Send;
1898    fn r#get_serial(&self) -> Self::GetSerialResponseFut;
1899    type GetHostVsockEndpointResponseFut: std::future::Future<Output = Result<GuestGetHostVsockEndpointResult, fidl::Error>>
1900        + Send;
1901    fn r#get_host_vsock_endpoint(
1902        &self,
1903        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
1904    ) -> Self::GetHostVsockEndpointResponseFut;
1905    type GetBalloonControllerResponseFut: std::future::Future<Output = Result<GuestGetBalloonControllerResult, fidl::Error>>
1906        + Send;
1907    fn r#get_balloon_controller(
1908        &self,
1909        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
1910    ) -> Self::GetBalloonControllerResponseFut;
1911    type GetMemControllerResponseFut: std::future::Future<Output = Result<GuestGetMemControllerResult, fidl::Error>>
1912        + Send;
1913    fn r#get_mem_controller(
1914        &self,
1915        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
1916    ) -> Self::GetMemControllerResponseFut;
1917}
1918#[derive(Debug)]
1919#[cfg(target_os = "fuchsia")]
1920pub struct GuestSynchronousProxy {
1921    client: fidl::client::sync::Client,
1922}
1923
1924#[cfg(target_os = "fuchsia")]
1925impl fidl::endpoints::SynchronousProxy for GuestSynchronousProxy {
1926    type Proxy = GuestProxy;
1927    type Protocol = GuestMarker;
1928
1929    fn from_channel(inner: fidl::Channel) -> Self {
1930        Self::new(inner)
1931    }
1932
1933    fn into_channel(self) -> fidl::Channel {
1934        self.client.into_channel()
1935    }
1936
1937    fn as_channel(&self) -> &fidl::Channel {
1938        self.client.as_channel()
1939    }
1940}
1941
1942#[cfg(target_os = "fuchsia")]
1943impl GuestSynchronousProxy {
1944    pub fn new(channel: fidl::Channel) -> Self {
1945        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1946        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1947    }
1948
1949    pub fn into_channel(self) -> fidl::Channel {
1950        self.client.into_channel()
1951    }
1952
1953    /// Waits until an event arrives and returns it. It is safe for other
1954    /// threads to make concurrent requests while waiting for an event.
1955    pub fn wait_for_event(
1956        &self,
1957        deadline: zx::MonotonicInstant,
1958    ) -> Result<GuestEvent, fidl::Error> {
1959        GuestEvent::decode(self.client.wait_for_event(deadline)?)
1960    }
1961
1962    /// Get a guest console.
1963    ///
1964    /// The details regarding what output is produced and what input is accepted
1965    /// are determined by each guest, but will typically be a read/write socket
1966    /// with a shell.
1967    ///
1968    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
1969    pub fn r#get_console(
1970        &self,
1971        ___deadline: zx::MonotonicInstant,
1972    ) -> Result<GuestGetConsoleResult, fidl::Error> {
1973        let _response = self.client.send_query::<
1974            fidl::encoding::EmptyPayload,
1975            fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
1976        >(
1977            (),
1978            0x48cbcecb7793806e,
1979            fidl::encoding::DynamicFlags::empty(),
1980            ___deadline,
1981        )?;
1982        Ok(_response.map(|x| x.socket))
1983    }
1984
1985    /// Get the socket for low-level guest debug logs.
1986    ///
1987    /// The details regarding what output is produced and what input is accepted
1988    /// are determined by each guest, but will typically be a read-only socket
1989    /// with the guest kernel's serial logs.
1990    pub fn r#get_serial(
1991        &self,
1992        ___deadline: zx::MonotonicInstant,
1993    ) -> Result<fidl::Socket, fidl::Error> {
1994        let _response =
1995            self.client.send_query::<fidl::encoding::EmptyPayload, GuestGetSerialResponse>(
1996                (),
1997                0xcdd541a160d7044,
1998                fidl::encoding::DynamicFlags::empty(),
1999                ___deadline,
2000            )?;
2001        Ok(_response.socket)
2002    }
2003
2004    /// Get the vsock endpoint for the guest.
2005    ///
2006    /// This endpoint can be used to register listeners for guest initiated connections, and
2007    /// to initiate connections from a client. If listeners need to be registered before the guest
2008    /// starts so that they are immediately available, set them via the guest config instead of
2009    /// using this endpoint.
2010    ///
2011    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2012    pub fn r#get_host_vsock_endpoint(
2013        &self,
2014        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2015        ___deadline: zx::MonotonicInstant,
2016    ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2017        let _response = self.client.send_query::<
2018            GuestGetHostVsockEndpointRequest,
2019            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2020        >(
2021            (endpoint,),
2022            0x766e96aeb9c28ed1,
2023            fidl::encoding::DynamicFlags::empty(),
2024            ___deadline,
2025        )?;
2026        Ok(_response.map(|x| x))
2027    }
2028
2029    /// Get the balloon controller endpoint for the guest.
2030    ///
2031    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2032    pub fn r#get_balloon_controller(
2033        &self,
2034        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2035        ___deadline: zx::MonotonicInstant,
2036    ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2037        let _response = self.client.send_query::<
2038            GuestGetBalloonControllerRequest,
2039            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2040        >(
2041            (controller,),
2042            0x7b210bff219ac84e,
2043            fidl::encoding::DynamicFlags::empty(),
2044            ___deadline,
2045        )?;
2046        Ok(_response.map(|x| x))
2047    }
2048
2049    /// Get the mem controller endpoint for the guest.
2050    ///
2051    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2052    pub fn r#get_mem_controller(
2053        &self,
2054        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2055        ___deadline: zx::MonotonicInstant,
2056    ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2057        let _response = self.client.send_query::<
2058            GuestGetMemControllerRequest,
2059            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2060        >(
2061            (controller,),
2062            0x170b19f4b867a01c,
2063            fidl::encoding::DynamicFlags::empty(),
2064            ___deadline,
2065        )?;
2066        Ok(_response.map(|x| x))
2067    }
2068}
2069
2070#[cfg(target_os = "fuchsia")]
2071impl From<GuestSynchronousProxy> for zx::Handle {
2072    fn from(value: GuestSynchronousProxy) -> Self {
2073        value.into_channel().into()
2074    }
2075}
2076
2077#[cfg(target_os = "fuchsia")]
2078impl From<fidl::Channel> for GuestSynchronousProxy {
2079    fn from(value: fidl::Channel) -> Self {
2080        Self::new(value)
2081    }
2082}
2083
2084#[derive(Debug, Clone)]
2085pub struct GuestProxy {
2086    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2087}
2088
2089impl fidl::endpoints::Proxy for GuestProxy {
2090    type Protocol = GuestMarker;
2091
2092    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2093        Self::new(inner)
2094    }
2095
2096    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2097        self.client.into_channel().map_err(|client| Self { client })
2098    }
2099
2100    fn as_channel(&self) -> &::fidl::AsyncChannel {
2101        self.client.as_channel()
2102    }
2103}
2104
2105impl GuestProxy {
2106    /// Create a new Proxy for fuchsia.virtualization/Guest.
2107    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2108        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2109        Self { client: fidl::client::Client::new(channel, protocol_name) }
2110    }
2111
2112    /// Get a Stream of events from the remote end of the protocol.
2113    ///
2114    /// # Panics
2115    ///
2116    /// Panics if the event stream was already taken.
2117    pub fn take_event_stream(&self) -> GuestEventStream {
2118        GuestEventStream { event_receiver: self.client.take_event_receiver() }
2119    }
2120
2121    /// Get a guest console.
2122    ///
2123    /// The details regarding what output is produced and what input is accepted
2124    /// are determined by each guest, but will typically be a read/write socket
2125    /// with a shell.
2126    ///
2127    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2128    pub fn r#get_console(
2129        &self,
2130    ) -> fidl::client::QueryResponseFut<
2131        GuestGetConsoleResult,
2132        fidl::encoding::DefaultFuchsiaResourceDialect,
2133    > {
2134        GuestProxyInterface::r#get_console(self)
2135    }
2136
2137    /// Get the socket for low-level guest debug logs.
2138    ///
2139    /// The details regarding what output is produced and what input is accepted
2140    /// are determined by each guest, but will typically be a read-only socket
2141    /// with the guest kernel's serial logs.
2142    pub fn r#get_serial(
2143        &self,
2144    ) -> fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>
2145    {
2146        GuestProxyInterface::r#get_serial(self)
2147    }
2148
2149    /// Get the vsock endpoint for the guest.
2150    ///
2151    /// This endpoint can be used to register listeners for guest initiated connections, and
2152    /// to initiate connections from a client. If listeners need to be registered before the guest
2153    /// starts so that they are immediately available, set them via the guest config instead of
2154    /// using this endpoint.
2155    ///
2156    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2157    pub fn r#get_host_vsock_endpoint(
2158        &self,
2159        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2160    ) -> fidl::client::QueryResponseFut<
2161        GuestGetHostVsockEndpointResult,
2162        fidl::encoding::DefaultFuchsiaResourceDialect,
2163    > {
2164        GuestProxyInterface::r#get_host_vsock_endpoint(self, endpoint)
2165    }
2166
2167    /// Get the balloon controller endpoint for the guest.
2168    ///
2169    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2170    pub fn r#get_balloon_controller(
2171        &self,
2172        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2173    ) -> fidl::client::QueryResponseFut<
2174        GuestGetBalloonControllerResult,
2175        fidl::encoding::DefaultFuchsiaResourceDialect,
2176    > {
2177        GuestProxyInterface::r#get_balloon_controller(self, controller)
2178    }
2179
2180    /// Get the mem controller endpoint for the guest.
2181    ///
2182    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2183    pub fn r#get_mem_controller(
2184        &self,
2185        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2186    ) -> fidl::client::QueryResponseFut<
2187        GuestGetMemControllerResult,
2188        fidl::encoding::DefaultFuchsiaResourceDialect,
2189    > {
2190        GuestProxyInterface::r#get_mem_controller(self, controller)
2191    }
2192}
2193
2194impl GuestProxyInterface for GuestProxy {
2195    type GetConsoleResponseFut = fidl::client::QueryResponseFut<
2196        GuestGetConsoleResult,
2197        fidl::encoding::DefaultFuchsiaResourceDialect,
2198    >;
2199    fn r#get_console(&self) -> Self::GetConsoleResponseFut {
2200        fn _decode(
2201            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2202        ) -> Result<GuestGetConsoleResult, fidl::Error> {
2203            let _response = fidl::client::decode_transaction_body::<
2204                fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
2205                fidl::encoding::DefaultFuchsiaResourceDialect,
2206                0x48cbcecb7793806e,
2207            >(_buf?)?;
2208            Ok(_response.map(|x| x.socket))
2209        }
2210        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestGetConsoleResult>(
2211            (),
2212            0x48cbcecb7793806e,
2213            fidl::encoding::DynamicFlags::empty(),
2214            _decode,
2215        )
2216    }
2217
2218    type GetSerialResponseFut =
2219        fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2220    fn r#get_serial(&self) -> Self::GetSerialResponseFut {
2221        fn _decode(
2222            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2223        ) -> Result<fidl::Socket, fidl::Error> {
2224            let _response = fidl::client::decode_transaction_body::<
2225                GuestGetSerialResponse,
2226                fidl::encoding::DefaultFuchsiaResourceDialect,
2227                0xcdd541a160d7044,
2228            >(_buf?)?;
2229            Ok(_response.socket)
2230        }
2231        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Socket>(
2232            (),
2233            0xcdd541a160d7044,
2234            fidl::encoding::DynamicFlags::empty(),
2235            _decode,
2236        )
2237    }
2238
2239    type GetHostVsockEndpointResponseFut = fidl::client::QueryResponseFut<
2240        GuestGetHostVsockEndpointResult,
2241        fidl::encoding::DefaultFuchsiaResourceDialect,
2242    >;
2243    fn r#get_host_vsock_endpoint(
2244        &self,
2245        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2246    ) -> Self::GetHostVsockEndpointResponseFut {
2247        fn _decode(
2248            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2249        ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2250            let _response = fidl::client::decode_transaction_body::<
2251                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2252                fidl::encoding::DefaultFuchsiaResourceDialect,
2253                0x766e96aeb9c28ed1,
2254            >(_buf?)?;
2255            Ok(_response.map(|x| x))
2256        }
2257        self.client.send_query_and_decode::<
2258            GuestGetHostVsockEndpointRequest,
2259            GuestGetHostVsockEndpointResult,
2260        >(
2261            (endpoint,),
2262            0x766e96aeb9c28ed1,
2263            fidl::encoding::DynamicFlags::empty(),
2264            _decode,
2265        )
2266    }
2267
2268    type GetBalloonControllerResponseFut = fidl::client::QueryResponseFut<
2269        GuestGetBalloonControllerResult,
2270        fidl::encoding::DefaultFuchsiaResourceDialect,
2271    >;
2272    fn r#get_balloon_controller(
2273        &self,
2274        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2275    ) -> Self::GetBalloonControllerResponseFut {
2276        fn _decode(
2277            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2278        ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2279            let _response = fidl::client::decode_transaction_body::<
2280                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2281                fidl::encoding::DefaultFuchsiaResourceDialect,
2282                0x7b210bff219ac84e,
2283            >(_buf?)?;
2284            Ok(_response.map(|x| x))
2285        }
2286        self.client.send_query_and_decode::<
2287            GuestGetBalloonControllerRequest,
2288            GuestGetBalloonControllerResult,
2289        >(
2290            (controller,),
2291            0x7b210bff219ac84e,
2292            fidl::encoding::DynamicFlags::empty(),
2293            _decode,
2294        )
2295    }
2296
2297    type GetMemControllerResponseFut = fidl::client::QueryResponseFut<
2298        GuestGetMemControllerResult,
2299        fidl::encoding::DefaultFuchsiaResourceDialect,
2300    >;
2301    fn r#get_mem_controller(
2302        &self,
2303        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2304    ) -> Self::GetMemControllerResponseFut {
2305        fn _decode(
2306            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2307        ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2308            let _response = fidl::client::decode_transaction_body::<
2309                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2310                fidl::encoding::DefaultFuchsiaResourceDialect,
2311                0x170b19f4b867a01c,
2312            >(_buf?)?;
2313            Ok(_response.map(|x| x))
2314        }
2315        self.client
2316            .send_query_and_decode::<GuestGetMemControllerRequest, GuestGetMemControllerResult>(
2317                (controller,),
2318                0x170b19f4b867a01c,
2319                fidl::encoding::DynamicFlags::empty(),
2320                _decode,
2321            )
2322    }
2323}
2324
2325pub struct GuestEventStream {
2326    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2327}
2328
2329impl std::marker::Unpin for GuestEventStream {}
2330
2331impl futures::stream::FusedStream for GuestEventStream {
2332    fn is_terminated(&self) -> bool {
2333        self.event_receiver.is_terminated()
2334    }
2335}
2336
2337impl futures::Stream for GuestEventStream {
2338    type Item = Result<GuestEvent, fidl::Error>;
2339
2340    fn poll_next(
2341        mut self: std::pin::Pin<&mut Self>,
2342        cx: &mut std::task::Context<'_>,
2343    ) -> std::task::Poll<Option<Self::Item>> {
2344        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2345            &mut self.event_receiver,
2346            cx
2347        )?) {
2348            Some(buf) => std::task::Poll::Ready(Some(GuestEvent::decode(buf))),
2349            None => std::task::Poll::Ready(None),
2350        }
2351    }
2352}
2353
2354#[derive(Debug)]
2355pub enum GuestEvent {}
2356
2357impl GuestEvent {
2358    /// Decodes a message buffer as a [`GuestEvent`].
2359    fn decode(
2360        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2361    ) -> Result<GuestEvent, fidl::Error> {
2362        let (bytes, _handles) = buf.split_mut();
2363        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2364        debug_assert_eq!(tx_header.tx_id, 0);
2365        match tx_header.ordinal {
2366            _ => Err(fidl::Error::UnknownOrdinal {
2367                ordinal: tx_header.ordinal,
2368                protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2369            }),
2370        }
2371    }
2372}
2373
2374/// A Stream of incoming requests for fuchsia.virtualization/Guest.
2375pub struct GuestRequestStream {
2376    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2377    is_terminated: bool,
2378}
2379
2380impl std::marker::Unpin for GuestRequestStream {}
2381
2382impl futures::stream::FusedStream for GuestRequestStream {
2383    fn is_terminated(&self) -> bool {
2384        self.is_terminated
2385    }
2386}
2387
2388impl fidl::endpoints::RequestStream for GuestRequestStream {
2389    type Protocol = GuestMarker;
2390    type ControlHandle = GuestControlHandle;
2391
2392    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2393        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2394    }
2395
2396    fn control_handle(&self) -> Self::ControlHandle {
2397        GuestControlHandle { inner: self.inner.clone() }
2398    }
2399
2400    fn into_inner(
2401        self,
2402    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2403    {
2404        (self.inner, self.is_terminated)
2405    }
2406
2407    fn from_inner(
2408        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2409        is_terminated: bool,
2410    ) -> Self {
2411        Self { inner, is_terminated }
2412    }
2413}
2414
2415impl futures::Stream for GuestRequestStream {
2416    type Item = Result<GuestRequest, fidl::Error>;
2417
2418    fn poll_next(
2419        mut self: std::pin::Pin<&mut Self>,
2420        cx: &mut std::task::Context<'_>,
2421    ) -> std::task::Poll<Option<Self::Item>> {
2422        let this = &mut *self;
2423        if this.inner.check_shutdown(cx) {
2424            this.is_terminated = true;
2425            return std::task::Poll::Ready(None);
2426        }
2427        if this.is_terminated {
2428            panic!("polled GuestRequestStream after completion");
2429        }
2430        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2431            |bytes, handles| {
2432                match this.inner.channel().read_etc(cx, bytes, handles) {
2433                    std::task::Poll::Ready(Ok(())) => {}
2434                    std::task::Poll::Pending => return std::task::Poll::Pending,
2435                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2436                        this.is_terminated = true;
2437                        return std::task::Poll::Ready(None);
2438                    }
2439                    std::task::Poll::Ready(Err(e)) => {
2440                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2441                            e.into(),
2442                        ))))
2443                    }
2444                }
2445
2446                // A message has been received from the channel
2447                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2448
2449                std::task::Poll::Ready(Some(match header.ordinal {
2450                    0x48cbcecb7793806e => {
2451                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2452                        let mut req = fidl::new_empty!(
2453                            fidl::encoding::EmptyPayload,
2454                            fidl::encoding::DefaultFuchsiaResourceDialect
2455                        );
2456                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2457                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2458                        Ok(GuestRequest::GetConsole {
2459                            responder: GuestGetConsoleResponder {
2460                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2461                                tx_id: header.tx_id,
2462                            },
2463                        })
2464                    }
2465                    0xcdd541a160d7044 => {
2466                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2467                        let mut req = fidl::new_empty!(
2468                            fidl::encoding::EmptyPayload,
2469                            fidl::encoding::DefaultFuchsiaResourceDialect
2470                        );
2471                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2472                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2473                        Ok(GuestRequest::GetSerial {
2474                            responder: GuestGetSerialResponder {
2475                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2476                                tx_id: header.tx_id,
2477                            },
2478                        })
2479                    }
2480                    0x766e96aeb9c28ed1 => {
2481                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2482                        let mut req = fidl::new_empty!(
2483                            GuestGetHostVsockEndpointRequest,
2484                            fidl::encoding::DefaultFuchsiaResourceDialect
2485                        );
2486                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetHostVsockEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
2487                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2488                        Ok(GuestRequest::GetHostVsockEndpoint {
2489                            endpoint: req.endpoint,
2490
2491                            responder: GuestGetHostVsockEndpointResponder {
2492                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2493                                tx_id: header.tx_id,
2494                            },
2495                        })
2496                    }
2497                    0x7b210bff219ac84e => {
2498                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2499                        let mut req = fidl::new_empty!(
2500                            GuestGetBalloonControllerRequest,
2501                            fidl::encoding::DefaultFuchsiaResourceDialect
2502                        );
2503                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetBalloonControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2504                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2505                        Ok(GuestRequest::GetBalloonController {
2506                            controller: req.controller,
2507
2508                            responder: GuestGetBalloonControllerResponder {
2509                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2510                                tx_id: header.tx_id,
2511                            },
2512                        })
2513                    }
2514                    0x170b19f4b867a01c => {
2515                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2516                        let mut req = fidl::new_empty!(
2517                            GuestGetMemControllerRequest,
2518                            fidl::encoding::DefaultFuchsiaResourceDialect
2519                        );
2520                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetMemControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2521                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2522                        Ok(GuestRequest::GetMemController {
2523                            controller: req.controller,
2524
2525                            responder: GuestGetMemControllerResponder {
2526                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2527                                tx_id: header.tx_id,
2528                            },
2529                        })
2530                    }
2531                    _ => Err(fidl::Error::UnknownOrdinal {
2532                        ordinal: header.ordinal,
2533                        protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2534                    }),
2535                }))
2536            },
2537        )
2538    }
2539}
2540
2541/// The guest client API providing high level access to guest features. When the guest terminates,
2542/// this channel will contain a ZX_OK epitaph on a clean shutdown, a ZX_ERR_INTERNAL epitaph on
2543/// an unexpected shutdown, and no epitaph if the component crashed.
2544#[derive(Debug)]
2545pub enum GuestRequest {
2546    /// Get a guest console.
2547    ///
2548    /// The details regarding what output is produced and what input is accepted
2549    /// are determined by each guest, but will typically be a read/write socket
2550    /// with a shell.
2551    ///
2552    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2553    GetConsole { responder: GuestGetConsoleResponder },
2554    /// Get the socket for low-level guest debug logs.
2555    ///
2556    /// The details regarding what output is produced and what input is accepted
2557    /// are determined by each guest, but will typically be a read-only socket
2558    /// with the guest kernel's serial logs.
2559    GetSerial { responder: GuestGetSerialResponder },
2560    /// Get the vsock endpoint for the guest.
2561    ///
2562    /// This endpoint can be used to register listeners for guest initiated connections, and
2563    /// to initiate connections from a client. If listeners need to be registered before the guest
2564    /// starts so that they are immediately available, set them via the guest config instead of
2565    /// using this endpoint.
2566    ///
2567    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2568    GetHostVsockEndpoint {
2569        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2570        responder: GuestGetHostVsockEndpointResponder,
2571    },
2572    /// Get the balloon controller endpoint for the guest.
2573    ///
2574    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2575    GetBalloonController {
2576        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2577        responder: GuestGetBalloonControllerResponder,
2578    },
2579    /// Get the mem controller endpoint for the guest.
2580    ///
2581    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2582    GetMemController {
2583        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2584        responder: GuestGetMemControllerResponder,
2585    },
2586}
2587
2588impl GuestRequest {
2589    #[allow(irrefutable_let_patterns)]
2590    pub fn into_get_console(self) -> Option<(GuestGetConsoleResponder)> {
2591        if let GuestRequest::GetConsole { responder } = self {
2592            Some((responder))
2593        } else {
2594            None
2595        }
2596    }
2597
2598    #[allow(irrefutable_let_patterns)]
2599    pub fn into_get_serial(self) -> Option<(GuestGetSerialResponder)> {
2600        if let GuestRequest::GetSerial { responder } = self {
2601            Some((responder))
2602        } else {
2603            None
2604        }
2605    }
2606
2607    #[allow(irrefutable_let_patterns)]
2608    pub fn into_get_host_vsock_endpoint(
2609        self,
2610    ) -> Option<(
2611        fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2612        GuestGetHostVsockEndpointResponder,
2613    )> {
2614        if let GuestRequest::GetHostVsockEndpoint { endpoint, responder } = self {
2615            Some((endpoint, responder))
2616        } else {
2617            None
2618        }
2619    }
2620
2621    #[allow(irrefutable_let_patterns)]
2622    pub fn into_get_balloon_controller(
2623        self,
2624    ) -> Option<(
2625        fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2626        GuestGetBalloonControllerResponder,
2627    )> {
2628        if let GuestRequest::GetBalloonController { controller, responder } = self {
2629            Some((controller, responder))
2630        } else {
2631            None
2632        }
2633    }
2634
2635    #[allow(irrefutable_let_patterns)]
2636    pub fn into_get_mem_controller(
2637        self,
2638    ) -> Option<(fidl::endpoints::ServerEnd<MemControllerMarker>, GuestGetMemControllerResponder)>
2639    {
2640        if let GuestRequest::GetMemController { controller, responder } = self {
2641            Some((controller, responder))
2642        } else {
2643            None
2644        }
2645    }
2646
2647    /// Name of the method defined in FIDL
2648    pub fn method_name(&self) -> &'static str {
2649        match *self {
2650            GuestRequest::GetConsole { .. } => "get_console",
2651            GuestRequest::GetSerial { .. } => "get_serial",
2652            GuestRequest::GetHostVsockEndpoint { .. } => "get_host_vsock_endpoint",
2653            GuestRequest::GetBalloonController { .. } => "get_balloon_controller",
2654            GuestRequest::GetMemController { .. } => "get_mem_controller",
2655        }
2656    }
2657}
2658
2659#[derive(Debug, Clone)]
2660pub struct GuestControlHandle {
2661    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2662}
2663
2664impl fidl::endpoints::ControlHandle for GuestControlHandle {
2665    fn shutdown(&self) {
2666        self.inner.shutdown()
2667    }
2668    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2669        self.inner.shutdown_with_epitaph(status)
2670    }
2671
2672    fn is_closed(&self) -> bool {
2673        self.inner.channel().is_closed()
2674    }
2675    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2676        self.inner.channel().on_closed()
2677    }
2678
2679    #[cfg(target_os = "fuchsia")]
2680    fn signal_peer(
2681        &self,
2682        clear_mask: zx::Signals,
2683        set_mask: zx::Signals,
2684    ) -> Result<(), zx_status::Status> {
2685        use fidl::Peered;
2686        self.inner.channel().signal_peer(clear_mask, set_mask)
2687    }
2688}
2689
2690impl GuestControlHandle {}
2691
2692#[must_use = "FIDL methods require a response to be sent"]
2693#[derive(Debug)]
2694pub struct GuestGetConsoleResponder {
2695    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2696    tx_id: u32,
2697}
2698
2699/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2700/// if the responder is dropped without sending a response, so that the client
2701/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2702impl std::ops::Drop for GuestGetConsoleResponder {
2703    fn drop(&mut self) {
2704        self.control_handle.shutdown();
2705        // Safety: drops once, never accessed again
2706        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2707    }
2708}
2709
2710impl fidl::endpoints::Responder for GuestGetConsoleResponder {
2711    type ControlHandle = GuestControlHandle;
2712
2713    fn control_handle(&self) -> &GuestControlHandle {
2714        &self.control_handle
2715    }
2716
2717    fn drop_without_shutdown(mut self) {
2718        // Safety: drops once, never accessed again due to mem::forget
2719        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2720        // Prevent Drop from running (which would shut down the channel)
2721        std::mem::forget(self);
2722    }
2723}
2724
2725impl GuestGetConsoleResponder {
2726    /// Sends a response to the FIDL transaction.
2727    ///
2728    /// Sets the channel to shutdown if an error occurs.
2729    pub fn send(self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2730        let _result = self.send_raw(result);
2731        if _result.is_err() {
2732            self.control_handle.shutdown();
2733        }
2734        self.drop_without_shutdown();
2735        _result
2736    }
2737
2738    /// Similar to "send" but does not shutdown the channel if an error occurs.
2739    pub fn send_no_shutdown_on_err(
2740        self,
2741        mut result: Result<fidl::Socket, GuestError>,
2742    ) -> Result<(), fidl::Error> {
2743        let _result = self.send_raw(result);
2744        self.drop_without_shutdown();
2745        _result
2746    }
2747
2748    fn send_raw(&self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2749        self.control_handle
2750            .inner
2751            .send::<fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>>(
2752                result.map(|socket| (socket,)),
2753                self.tx_id,
2754                0x48cbcecb7793806e,
2755                fidl::encoding::DynamicFlags::empty(),
2756            )
2757    }
2758}
2759
2760#[must_use = "FIDL methods require a response to be sent"]
2761#[derive(Debug)]
2762pub struct GuestGetSerialResponder {
2763    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2764    tx_id: u32,
2765}
2766
2767/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2768/// if the responder is dropped without sending a response, so that the client
2769/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2770impl std::ops::Drop for GuestGetSerialResponder {
2771    fn drop(&mut self) {
2772        self.control_handle.shutdown();
2773        // Safety: drops once, never accessed again
2774        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2775    }
2776}
2777
2778impl fidl::endpoints::Responder for GuestGetSerialResponder {
2779    type ControlHandle = GuestControlHandle;
2780
2781    fn control_handle(&self) -> &GuestControlHandle {
2782        &self.control_handle
2783    }
2784
2785    fn drop_without_shutdown(mut self) {
2786        // Safety: drops once, never accessed again due to mem::forget
2787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2788        // Prevent Drop from running (which would shut down the channel)
2789        std::mem::forget(self);
2790    }
2791}
2792
2793impl GuestGetSerialResponder {
2794    /// Sends a response to the FIDL transaction.
2795    ///
2796    /// Sets the channel to shutdown if an error occurs.
2797    pub fn send(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2798        let _result = self.send_raw(socket);
2799        if _result.is_err() {
2800            self.control_handle.shutdown();
2801        }
2802        self.drop_without_shutdown();
2803        _result
2804    }
2805
2806    /// Similar to "send" but does not shutdown the channel if an error occurs.
2807    pub fn send_no_shutdown_on_err(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2808        let _result = self.send_raw(socket);
2809        self.drop_without_shutdown();
2810        _result
2811    }
2812
2813    fn send_raw(&self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2814        self.control_handle.inner.send::<GuestGetSerialResponse>(
2815            (socket,),
2816            self.tx_id,
2817            0xcdd541a160d7044,
2818            fidl::encoding::DynamicFlags::empty(),
2819        )
2820    }
2821}
2822
2823#[must_use = "FIDL methods require a response to be sent"]
2824#[derive(Debug)]
2825pub struct GuestGetHostVsockEndpointResponder {
2826    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2827    tx_id: u32,
2828}
2829
2830/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2831/// if the responder is dropped without sending a response, so that the client
2832/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2833impl std::ops::Drop for GuestGetHostVsockEndpointResponder {
2834    fn drop(&mut self) {
2835        self.control_handle.shutdown();
2836        // Safety: drops once, never accessed again
2837        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2838    }
2839}
2840
2841impl fidl::endpoints::Responder for GuestGetHostVsockEndpointResponder {
2842    type ControlHandle = GuestControlHandle;
2843
2844    fn control_handle(&self) -> &GuestControlHandle {
2845        &self.control_handle
2846    }
2847
2848    fn drop_without_shutdown(mut self) {
2849        // Safety: drops once, never accessed again due to mem::forget
2850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2851        // Prevent Drop from running (which would shut down the channel)
2852        std::mem::forget(self);
2853    }
2854}
2855
2856impl GuestGetHostVsockEndpointResponder {
2857    /// Sends a response to the FIDL transaction.
2858    ///
2859    /// Sets the channel to shutdown if an error occurs.
2860    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2861        let _result = self.send_raw(result);
2862        if _result.is_err() {
2863            self.control_handle.shutdown();
2864        }
2865        self.drop_without_shutdown();
2866        _result
2867    }
2868
2869    /// Similar to "send" but does not shutdown the channel if an error occurs.
2870    pub fn send_no_shutdown_on_err(
2871        self,
2872        mut result: Result<(), GuestError>,
2873    ) -> Result<(), fidl::Error> {
2874        let _result = self.send_raw(result);
2875        self.drop_without_shutdown();
2876        _result
2877    }
2878
2879    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2880        self.control_handle
2881            .inner
2882            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2883                result,
2884                self.tx_id,
2885                0x766e96aeb9c28ed1,
2886                fidl::encoding::DynamicFlags::empty(),
2887            )
2888    }
2889}
2890
2891#[must_use = "FIDL methods require a response to be sent"]
2892#[derive(Debug)]
2893pub struct GuestGetBalloonControllerResponder {
2894    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2895    tx_id: u32,
2896}
2897
2898/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2899/// if the responder is dropped without sending a response, so that the client
2900/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2901impl std::ops::Drop for GuestGetBalloonControllerResponder {
2902    fn drop(&mut self) {
2903        self.control_handle.shutdown();
2904        // Safety: drops once, never accessed again
2905        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2906    }
2907}
2908
2909impl fidl::endpoints::Responder for GuestGetBalloonControllerResponder {
2910    type ControlHandle = GuestControlHandle;
2911
2912    fn control_handle(&self) -> &GuestControlHandle {
2913        &self.control_handle
2914    }
2915
2916    fn drop_without_shutdown(mut self) {
2917        // Safety: drops once, never accessed again due to mem::forget
2918        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2919        // Prevent Drop from running (which would shut down the channel)
2920        std::mem::forget(self);
2921    }
2922}
2923
2924impl GuestGetBalloonControllerResponder {
2925    /// Sends a response to the FIDL transaction.
2926    ///
2927    /// Sets the channel to shutdown if an error occurs.
2928    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2929        let _result = self.send_raw(result);
2930        if _result.is_err() {
2931            self.control_handle.shutdown();
2932        }
2933        self.drop_without_shutdown();
2934        _result
2935    }
2936
2937    /// Similar to "send" but does not shutdown the channel if an error occurs.
2938    pub fn send_no_shutdown_on_err(
2939        self,
2940        mut result: Result<(), GuestError>,
2941    ) -> Result<(), fidl::Error> {
2942        let _result = self.send_raw(result);
2943        self.drop_without_shutdown();
2944        _result
2945    }
2946
2947    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2948        self.control_handle
2949            .inner
2950            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2951                result,
2952                self.tx_id,
2953                0x7b210bff219ac84e,
2954                fidl::encoding::DynamicFlags::empty(),
2955            )
2956    }
2957}
2958
2959#[must_use = "FIDL methods require a response to be sent"]
2960#[derive(Debug)]
2961pub struct GuestGetMemControllerResponder {
2962    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2963    tx_id: u32,
2964}
2965
2966/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2967/// if the responder is dropped without sending a response, so that the client
2968/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2969impl std::ops::Drop for GuestGetMemControllerResponder {
2970    fn drop(&mut self) {
2971        self.control_handle.shutdown();
2972        // Safety: drops once, never accessed again
2973        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2974    }
2975}
2976
2977impl fidl::endpoints::Responder for GuestGetMemControllerResponder {
2978    type ControlHandle = GuestControlHandle;
2979
2980    fn control_handle(&self) -> &GuestControlHandle {
2981        &self.control_handle
2982    }
2983
2984    fn drop_without_shutdown(mut self) {
2985        // Safety: drops once, never accessed again due to mem::forget
2986        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2987        // Prevent Drop from running (which would shut down the channel)
2988        std::mem::forget(self);
2989    }
2990}
2991
2992impl GuestGetMemControllerResponder {
2993    /// Sends a response to the FIDL transaction.
2994    ///
2995    /// Sets the channel to shutdown if an error occurs.
2996    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2997        let _result = self.send_raw(result);
2998        if _result.is_err() {
2999            self.control_handle.shutdown();
3000        }
3001        self.drop_without_shutdown();
3002        _result
3003    }
3004
3005    /// Similar to "send" but does not shutdown the channel if an error occurs.
3006    pub fn send_no_shutdown_on_err(
3007        self,
3008        mut result: Result<(), GuestError>,
3009    ) -> Result<(), fidl::Error> {
3010        let _result = self.send_raw(result);
3011        self.drop_without_shutdown();
3012        _result
3013    }
3014
3015    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3016        self.control_handle
3017            .inner
3018            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3019                result,
3020                self.tx_id,
3021                0x170b19f4b867a01c,
3022                fidl::encoding::DynamicFlags::empty(),
3023            )
3024    }
3025}
3026
3027#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3028pub struct GuestLifecycleMarker;
3029
3030impl fidl::endpoints::ProtocolMarker for GuestLifecycleMarker {
3031    type Proxy = GuestLifecycleProxy;
3032    type RequestStream = GuestLifecycleRequestStream;
3033    #[cfg(target_os = "fuchsia")]
3034    type SynchronousProxy = GuestLifecycleSynchronousProxy;
3035
3036    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestLifecycle";
3037}
3038impl fidl::endpoints::DiscoverableProtocolMarker for GuestLifecycleMarker {}
3039pub type GuestLifecycleCreateResult = Result<(), GuestError>;
3040pub type GuestLifecycleRunResult = Result<(), GuestError>;
3041
3042pub trait GuestLifecycleProxyInterface: Send + Sync {
3043    type CreateResponseFut: std::future::Future<Output = Result<GuestLifecycleCreateResult, fidl::Error>>
3044        + Send;
3045    fn r#create(&self, guest_config: GuestConfig) -> Self::CreateResponseFut;
3046    fn r#bind(&self, guest: fidl::endpoints::ServerEnd<GuestMarker>) -> Result<(), fidl::Error>;
3047    type RunResponseFut: std::future::Future<Output = Result<GuestLifecycleRunResult, fidl::Error>>
3048        + Send;
3049    fn r#run(&self) -> Self::RunResponseFut;
3050    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3051    fn r#stop(&self) -> Self::StopResponseFut;
3052}
3053#[derive(Debug)]
3054#[cfg(target_os = "fuchsia")]
3055pub struct GuestLifecycleSynchronousProxy {
3056    client: fidl::client::sync::Client,
3057}
3058
3059#[cfg(target_os = "fuchsia")]
3060impl fidl::endpoints::SynchronousProxy for GuestLifecycleSynchronousProxy {
3061    type Proxy = GuestLifecycleProxy;
3062    type Protocol = GuestLifecycleMarker;
3063
3064    fn from_channel(inner: fidl::Channel) -> Self {
3065        Self::new(inner)
3066    }
3067
3068    fn into_channel(self) -> fidl::Channel {
3069        self.client.into_channel()
3070    }
3071
3072    fn as_channel(&self) -> &fidl::Channel {
3073        self.client.as_channel()
3074    }
3075}
3076
3077#[cfg(target_os = "fuchsia")]
3078impl GuestLifecycleSynchronousProxy {
3079    pub fn new(channel: fidl::Channel) -> Self {
3080        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3081        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3082    }
3083
3084    pub fn into_channel(self) -> fidl::Channel {
3085        self.client.into_channel()
3086    }
3087
3088    /// Waits until an event arrives and returns it. It is safe for other
3089    /// threads to make concurrent requests while waiting for an event.
3090    pub fn wait_for_event(
3091        &self,
3092        deadline: zx::MonotonicInstant,
3093    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3094        GuestLifecycleEvent::decode(self.client.wait_for_event(deadline)?)
3095    }
3096
3097    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3098    /// the kernel without starting the VCPU or device dispatch loops.
3099    ///
3100    /// Possible errors:
3101    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3102    ///         recreated.
3103    ///
3104    /// All other errors are related to VMM initialization.
3105    pub fn r#create(
3106        &self,
3107        mut guest_config: GuestConfig,
3108        ___deadline: zx::MonotonicInstant,
3109    ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3110        let _response = self.client.send_query::<
3111            GuestLifecycleCreateRequest,
3112            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3113        >(
3114            (&mut guest_config,),
3115            0x152719eed416ed41,
3116            fidl::encoding::DynamicFlags::empty(),
3117            ___deadline,
3118        )?;
3119        Ok(_response.map(|x| x))
3120    }
3121
3122    /// Binds to the Guest protocol for an initialized guest.
3123    ///
3124    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3125    /// will be immediately closed.
3126    pub fn r#bind(
3127        &self,
3128        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3129    ) -> Result<(), fidl::Error> {
3130        self.client.send::<GuestLifecycleBindRequest>(
3131            (guest,),
3132            0x57dd3e245f9598ed,
3133            fidl::encoding::DynamicFlags::empty(),
3134        )
3135    }
3136
3137    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3138    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3139    ///
3140    /// Possible errors:
3141    ///     - ALREADY_RUNING: The VMM has already been started.
3142    ///     - NOT_CREATED: Run was called before the VMM was created.
3143    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3144    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3145    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3146    pub fn r#run(
3147        &self,
3148        ___deadline: zx::MonotonicInstant,
3149    ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3150        let _response = self.client.send_query::<
3151            fidl::encoding::EmptyPayload,
3152            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3153        >(
3154            (),
3155            0x2907fef2ac775657,
3156            fidl::encoding::DynamicFlags::empty(),
3157            ___deadline,
3158        )?;
3159        Ok(_response.map(|x| x))
3160    }
3161
3162    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3163    /// Create and then Run can be called again.
3164    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3165        let _response =
3166            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
3167                (),
3168                0x27eef9c535ac8eb4,
3169                fidl::encoding::DynamicFlags::empty(),
3170                ___deadline,
3171            )?;
3172        Ok(_response)
3173    }
3174}
3175
3176#[cfg(target_os = "fuchsia")]
3177impl From<GuestLifecycleSynchronousProxy> for zx::Handle {
3178    fn from(value: GuestLifecycleSynchronousProxy) -> Self {
3179        value.into_channel().into()
3180    }
3181}
3182
3183#[cfg(target_os = "fuchsia")]
3184impl From<fidl::Channel> for GuestLifecycleSynchronousProxy {
3185    fn from(value: fidl::Channel) -> Self {
3186        Self::new(value)
3187    }
3188}
3189
3190#[derive(Debug, Clone)]
3191pub struct GuestLifecycleProxy {
3192    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3193}
3194
3195impl fidl::endpoints::Proxy for GuestLifecycleProxy {
3196    type Protocol = GuestLifecycleMarker;
3197
3198    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3199        Self::new(inner)
3200    }
3201
3202    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3203        self.client.into_channel().map_err(|client| Self { client })
3204    }
3205
3206    fn as_channel(&self) -> &::fidl::AsyncChannel {
3207        self.client.as_channel()
3208    }
3209}
3210
3211impl GuestLifecycleProxy {
3212    /// Create a new Proxy for fuchsia.virtualization/GuestLifecycle.
3213    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3214        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3215        Self { client: fidl::client::Client::new(channel, protocol_name) }
3216    }
3217
3218    /// Get a Stream of events from the remote end of the protocol.
3219    ///
3220    /// # Panics
3221    ///
3222    /// Panics if the event stream was already taken.
3223    pub fn take_event_stream(&self) -> GuestLifecycleEventStream {
3224        GuestLifecycleEventStream { event_receiver: self.client.take_event_receiver() }
3225    }
3226
3227    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3228    /// the kernel without starting the VCPU or device dispatch loops.
3229    ///
3230    /// Possible errors:
3231    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3232    ///         recreated.
3233    ///
3234    /// All other errors are related to VMM initialization.
3235    pub fn r#create(
3236        &self,
3237        mut guest_config: GuestConfig,
3238    ) -> fidl::client::QueryResponseFut<
3239        GuestLifecycleCreateResult,
3240        fidl::encoding::DefaultFuchsiaResourceDialect,
3241    > {
3242        GuestLifecycleProxyInterface::r#create(self, guest_config)
3243    }
3244
3245    /// Binds to the Guest protocol for an initialized guest.
3246    ///
3247    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3248    /// will be immediately closed.
3249    pub fn r#bind(
3250        &self,
3251        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3252    ) -> Result<(), fidl::Error> {
3253        GuestLifecycleProxyInterface::r#bind(self, guest)
3254    }
3255
3256    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3257    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3258    ///
3259    /// Possible errors:
3260    ///     - ALREADY_RUNING: The VMM has already been started.
3261    ///     - NOT_CREATED: Run was called before the VMM was created.
3262    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3263    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3264    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3265    pub fn r#run(
3266        &self,
3267    ) -> fidl::client::QueryResponseFut<
3268        GuestLifecycleRunResult,
3269        fidl::encoding::DefaultFuchsiaResourceDialect,
3270    > {
3271        GuestLifecycleProxyInterface::r#run(self)
3272    }
3273
3274    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3275    /// Create and then Run can be called again.
3276    pub fn r#stop(
3277        &self,
3278    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3279        GuestLifecycleProxyInterface::r#stop(self)
3280    }
3281}
3282
3283impl GuestLifecycleProxyInterface for GuestLifecycleProxy {
3284    type CreateResponseFut = fidl::client::QueryResponseFut<
3285        GuestLifecycleCreateResult,
3286        fidl::encoding::DefaultFuchsiaResourceDialect,
3287    >;
3288    fn r#create(&self, mut guest_config: GuestConfig) -> Self::CreateResponseFut {
3289        fn _decode(
3290            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3291        ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3292            let _response = fidl::client::decode_transaction_body::<
3293                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3294                fidl::encoding::DefaultFuchsiaResourceDialect,
3295                0x152719eed416ed41,
3296            >(_buf?)?;
3297            Ok(_response.map(|x| x))
3298        }
3299        self.client
3300            .send_query_and_decode::<GuestLifecycleCreateRequest, GuestLifecycleCreateResult>(
3301                (&mut guest_config,),
3302                0x152719eed416ed41,
3303                fidl::encoding::DynamicFlags::empty(),
3304                _decode,
3305            )
3306    }
3307
3308    fn r#bind(
3309        &self,
3310        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3311    ) -> Result<(), fidl::Error> {
3312        self.client.send::<GuestLifecycleBindRequest>(
3313            (guest,),
3314            0x57dd3e245f9598ed,
3315            fidl::encoding::DynamicFlags::empty(),
3316        )
3317    }
3318
3319    type RunResponseFut = fidl::client::QueryResponseFut<
3320        GuestLifecycleRunResult,
3321        fidl::encoding::DefaultFuchsiaResourceDialect,
3322    >;
3323    fn r#run(&self) -> Self::RunResponseFut {
3324        fn _decode(
3325            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3326        ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3327            let _response = fidl::client::decode_transaction_body::<
3328                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3329                fidl::encoding::DefaultFuchsiaResourceDialect,
3330                0x2907fef2ac775657,
3331            >(_buf?)?;
3332            Ok(_response.map(|x| x))
3333        }
3334        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestLifecycleRunResult>(
3335            (),
3336            0x2907fef2ac775657,
3337            fidl::encoding::DynamicFlags::empty(),
3338            _decode,
3339        )
3340    }
3341
3342    type StopResponseFut =
3343        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3344    fn r#stop(&self) -> Self::StopResponseFut {
3345        fn _decode(
3346            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3347        ) -> Result<(), fidl::Error> {
3348            let _response = fidl::client::decode_transaction_body::<
3349                fidl::encoding::EmptyPayload,
3350                fidl::encoding::DefaultFuchsiaResourceDialect,
3351                0x27eef9c535ac8eb4,
3352            >(_buf?)?;
3353            Ok(_response)
3354        }
3355        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3356            (),
3357            0x27eef9c535ac8eb4,
3358            fidl::encoding::DynamicFlags::empty(),
3359            _decode,
3360        )
3361    }
3362}
3363
3364pub struct GuestLifecycleEventStream {
3365    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3366}
3367
3368impl std::marker::Unpin for GuestLifecycleEventStream {}
3369
3370impl futures::stream::FusedStream for GuestLifecycleEventStream {
3371    fn is_terminated(&self) -> bool {
3372        self.event_receiver.is_terminated()
3373    }
3374}
3375
3376impl futures::Stream for GuestLifecycleEventStream {
3377    type Item = Result<GuestLifecycleEvent, fidl::Error>;
3378
3379    fn poll_next(
3380        mut self: std::pin::Pin<&mut Self>,
3381        cx: &mut std::task::Context<'_>,
3382    ) -> std::task::Poll<Option<Self::Item>> {
3383        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3384            &mut self.event_receiver,
3385            cx
3386        )?) {
3387            Some(buf) => std::task::Poll::Ready(Some(GuestLifecycleEvent::decode(buf))),
3388            None => std::task::Poll::Ready(None),
3389        }
3390    }
3391}
3392
3393#[derive(Debug)]
3394pub enum GuestLifecycleEvent {}
3395
3396impl GuestLifecycleEvent {
3397    /// Decodes a message buffer as a [`GuestLifecycleEvent`].
3398    fn decode(
3399        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3400    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3401        let (bytes, _handles) = buf.split_mut();
3402        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3403        debug_assert_eq!(tx_header.tx_id, 0);
3404        match tx_header.ordinal {
3405            _ => Err(fidl::Error::UnknownOrdinal {
3406                ordinal: tx_header.ordinal,
3407                protocol_name:
3408                    <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3409            }),
3410        }
3411    }
3412}
3413
3414/// A Stream of incoming requests for fuchsia.virtualization/GuestLifecycle.
3415pub struct GuestLifecycleRequestStream {
3416    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3417    is_terminated: bool,
3418}
3419
3420impl std::marker::Unpin for GuestLifecycleRequestStream {}
3421
3422impl futures::stream::FusedStream for GuestLifecycleRequestStream {
3423    fn is_terminated(&self) -> bool {
3424        self.is_terminated
3425    }
3426}
3427
3428impl fidl::endpoints::RequestStream for GuestLifecycleRequestStream {
3429    type Protocol = GuestLifecycleMarker;
3430    type ControlHandle = GuestLifecycleControlHandle;
3431
3432    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3433        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3434    }
3435
3436    fn control_handle(&self) -> Self::ControlHandle {
3437        GuestLifecycleControlHandle { inner: self.inner.clone() }
3438    }
3439
3440    fn into_inner(
3441        self,
3442    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3443    {
3444        (self.inner, self.is_terminated)
3445    }
3446
3447    fn from_inner(
3448        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3449        is_terminated: bool,
3450    ) -> Self {
3451        Self { inner, is_terminated }
3452    }
3453}
3454
3455impl futures::Stream for GuestLifecycleRequestStream {
3456    type Item = Result<GuestLifecycleRequest, fidl::Error>;
3457
3458    fn poll_next(
3459        mut self: std::pin::Pin<&mut Self>,
3460        cx: &mut std::task::Context<'_>,
3461    ) -> std::task::Poll<Option<Self::Item>> {
3462        let this = &mut *self;
3463        if this.inner.check_shutdown(cx) {
3464            this.is_terminated = true;
3465            return std::task::Poll::Ready(None);
3466        }
3467        if this.is_terminated {
3468            panic!("polled GuestLifecycleRequestStream after completion");
3469        }
3470        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3471            |bytes, handles| {
3472                match this.inner.channel().read_etc(cx, bytes, handles) {
3473                    std::task::Poll::Ready(Ok(())) => {}
3474                    std::task::Poll::Pending => return std::task::Poll::Pending,
3475                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3476                        this.is_terminated = true;
3477                        return std::task::Poll::Ready(None);
3478                    }
3479                    std::task::Poll::Ready(Err(e)) => {
3480                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3481                            e.into(),
3482                        ))))
3483                    }
3484                }
3485
3486                // A message has been received from the channel
3487                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3488
3489                std::task::Poll::Ready(Some(match header.ordinal {
3490                    0x152719eed416ed41 => {
3491                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3492                        let mut req = fidl::new_empty!(
3493                            GuestLifecycleCreateRequest,
3494                            fidl::encoding::DefaultFuchsiaResourceDialect
3495                        );
3496                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleCreateRequest>(&header, _body_bytes, handles, &mut req)?;
3497                        let control_handle =
3498                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3499                        Ok(GuestLifecycleRequest::Create {
3500                            guest_config: req.guest_config,
3501
3502                            responder: GuestLifecycleCreateResponder {
3503                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3504                                tx_id: header.tx_id,
3505                            },
3506                        })
3507                    }
3508                    0x57dd3e245f9598ed => {
3509                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3510                        let mut req = fidl::new_empty!(
3511                            GuestLifecycleBindRequest,
3512                            fidl::encoding::DefaultFuchsiaResourceDialect
3513                        );
3514                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleBindRequest>(&header, _body_bytes, handles, &mut req)?;
3515                        let control_handle =
3516                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3517                        Ok(GuestLifecycleRequest::Bind { guest: req.guest, control_handle })
3518                    }
3519                    0x2907fef2ac775657 => {
3520                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3521                        let mut req = fidl::new_empty!(
3522                            fidl::encoding::EmptyPayload,
3523                            fidl::encoding::DefaultFuchsiaResourceDialect
3524                        );
3525                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3526                        let control_handle =
3527                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3528                        Ok(GuestLifecycleRequest::Run {
3529                            responder: GuestLifecycleRunResponder {
3530                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3531                                tx_id: header.tx_id,
3532                            },
3533                        })
3534                    }
3535                    0x27eef9c535ac8eb4 => {
3536                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3537                        let mut req = fidl::new_empty!(
3538                            fidl::encoding::EmptyPayload,
3539                            fidl::encoding::DefaultFuchsiaResourceDialect
3540                        );
3541                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3542                        let control_handle =
3543                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3544                        Ok(GuestLifecycleRequest::Stop {
3545                            responder: GuestLifecycleStopResponder {
3546                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3547                                tx_id: header.tx_id,
3548                            },
3549                        })
3550                    }
3551                    _ => Err(fidl::Error::UnknownOrdinal {
3552                        ordinal: header.ordinal,
3553                        protocol_name:
3554                            <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3555                    }),
3556                }))
3557            },
3558        )
3559    }
3560}
3561
3562/// The guest control plane allowing for creating, starting, and stopping the guest.
3563#[derive(Debug)]
3564pub enum GuestLifecycleRequest {
3565    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3566    /// the kernel without starting the VCPU or device dispatch loops.
3567    ///
3568    /// Possible errors:
3569    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3570    ///         recreated.
3571    ///
3572    /// All other errors are related to VMM initialization.
3573    Create { guest_config: GuestConfig, responder: GuestLifecycleCreateResponder },
3574    /// Binds to the Guest protocol for an initialized guest.
3575    ///
3576    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3577    /// will be immediately closed.
3578    Bind {
3579        guest: fidl::endpoints::ServerEnd<GuestMarker>,
3580        control_handle: GuestLifecycleControlHandle,
3581    },
3582    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3583    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3584    ///
3585    /// Possible errors:
3586    ///     - ALREADY_RUNING: The VMM has already been started.
3587    ///     - NOT_CREATED: Run was called before the VMM was created.
3588    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3589    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3590    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3591    Run { responder: GuestLifecycleRunResponder },
3592    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3593    /// Create and then Run can be called again.
3594    Stop { responder: GuestLifecycleStopResponder },
3595}
3596
3597impl GuestLifecycleRequest {
3598    #[allow(irrefutable_let_patterns)]
3599    pub fn into_create(self) -> Option<(GuestConfig, GuestLifecycleCreateResponder)> {
3600        if let GuestLifecycleRequest::Create { guest_config, responder } = self {
3601            Some((guest_config, responder))
3602        } else {
3603            None
3604        }
3605    }
3606
3607    #[allow(irrefutable_let_patterns)]
3608    pub fn into_bind(
3609        self,
3610    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestLifecycleControlHandle)> {
3611        if let GuestLifecycleRequest::Bind { guest, control_handle } = self {
3612            Some((guest, control_handle))
3613        } else {
3614            None
3615        }
3616    }
3617
3618    #[allow(irrefutable_let_patterns)]
3619    pub fn into_run(self) -> Option<(GuestLifecycleRunResponder)> {
3620        if let GuestLifecycleRequest::Run { responder } = self {
3621            Some((responder))
3622        } else {
3623            None
3624        }
3625    }
3626
3627    #[allow(irrefutable_let_patterns)]
3628    pub fn into_stop(self) -> Option<(GuestLifecycleStopResponder)> {
3629        if let GuestLifecycleRequest::Stop { responder } = self {
3630            Some((responder))
3631        } else {
3632            None
3633        }
3634    }
3635
3636    /// Name of the method defined in FIDL
3637    pub fn method_name(&self) -> &'static str {
3638        match *self {
3639            GuestLifecycleRequest::Create { .. } => "create",
3640            GuestLifecycleRequest::Bind { .. } => "bind",
3641            GuestLifecycleRequest::Run { .. } => "run",
3642            GuestLifecycleRequest::Stop { .. } => "stop",
3643        }
3644    }
3645}
3646
3647#[derive(Debug, Clone)]
3648pub struct GuestLifecycleControlHandle {
3649    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3650}
3651
3652impl fidl::endpoints::ControlHandle for GuestLifecycleControlHandle {
3653    fn shutdown(&self) {
3654        self.inner.shutdown()
3655    }
3656    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3657        self.inner.shutdown_with_epitaph(status)
3658    }
3659
3660    fn is_closed(&self) -> bool {
3661        self.inner.channel().is_closed()
3662    }
3663    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3664        self.inner.channel().on_closed()
3665    }
3666
3667    #[cfg(target_os = "fuchsia")]
3668    fn signal_peer(
3669        &self,
3670        clear_mask: zx::Signals,
3671        set_mask: zx::Signals,
3672    ) -> Result<(), zx_status::Status> {
3673        use fidl::Peered;
3674        self.inner.channel().signal_peer(clear_mask, set_mask)
3675    }
3676}
3677
3678impl GuestLifecycleControlHandle {}
3679
3680#[must_use = "FIDL methods require a response to be sent"]
3681#[derive(Debug)]
3682pub struct GuestLifecycleCreateResponder {
3683    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3684    tx_id: u32,
3685}
3686
3687/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3688/// if the responder is dropped without sending a response, so that the client
3689/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3690impl std::ops::Drop for GuestLifecycleCreateResponder {
3691    fn drop(&mut self) {
3692        self.control_handle.shutdown();
3693        // Safety: drops once, never accessed again
3694        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3695    }
3696}
3697
3698impl fidl::endpoints::Responder for GuestLifecycleCreateResponder {
3699    type ControlHandle = GuestLifecycleControlHandle;
3700
3701    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3702        &self.control_handle
3703    }
3704
3705    fn drop_without_shutdown(mut self) {
3706        // Safety: drops once, never accessed again due to mem::forget
3707        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3708        // Prevent Drop from running (which would shut down the channel)
3709        std::mem::forget(self);
3710    }
3711}
3712
3713impl GuestLifecycleCreateResponder {
3714    /// Sends a response to the FIDL transaction.
3715    ///
3716    /// Sets the channel to shutdown if an error occurs.
3717    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3718        let _result = self.send_raw(result);
3719        if _result.is_err() {
3720            self.control_handle.shutdown();
3721        }
3722        self.drop_without_shutdown();
3723        _result
3724    }
3725
3726    /// Similar to "send" but does not shutdown the channel if an error occurs.
3727    pub fn send_no_shutdown_on_err(
3728        self,
3729        mut result: Result<(), GuestError>,
3730    ) -> Result<(), fidl::Error> {
3731        let _result = self.send_raw(result);
3732        self.drop_without_shutdown();
3733        _result
3734    }
3735
3736    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3737        self.control_handle
3738            .inner
3739            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3740                result,
3741                self.tx_id,
3742                0x152719eed416ed41,
3743                fidl::encoding::DynamicFlags::empty(),
3744            )
3745    }
3746}
3747
3748#[must_use = "FIDL methods require a response to be sent"]
3749#[derive(Debug)]
3750pub struct GuestLifecycleRunResponder {
3751    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3752    tx_id: u32,
3753}
3754
3755/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3756/// if the responder is dropped without sending a response, so that the client
3757/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3758impl std::ops::Drop for GuestLifecycleRunResponder {
3759    fn drop(&mut self) {
3760        self.control_handle.shutdown();
3761        // Safety: drops once, never accessed again
3762        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3763    }
3764}
3765
3766impl fidl::endpoints::Responder for GuestLifecycleRunResponder {
3767    type ControlHandle = GuestLifecycleControlHandle;
3768
3769    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3770        &self.control_handle
3771    }
3772
3773    fn drop_without_shutdown(mut self) {
3774        // Safety: drops once, never accessed again due to mem::forget
3775        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3776        // Prevent Drop from running (which would shut down the channel)
3777        std::mem::forget(self);
3778    }
3779}
3780
3781impl GuestLifecycleRunResponder {
3782    /// Sends a response to the FIDL transaction.
3783    ///
3784    /// Sets the channel to shutdown if an error occurs.
3785    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3786        let _result = self.send_raw(result);
3787        if _result.is_err() {
3788            self.control_handle.shutdown();
3789        }
3790        self.drop_without_shutdown();
3791        _result
3792    }
3793
3794    /// Similar to "send" but does not shutdown the channel if an error occurs.
3795    pub fn send_no_shutdown_on_err(
3796        self,
3797        mut result: Result<(), GuestError>,
3798    ) -> Result<(), fidl::Error> {
3799        let _result = self.send_raw(result);
3800        self.drop_without_shutdown();
3801        _result
3802    }
3803
3804    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3805        self.control_handle
3806            .inner
3807            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3808                result,
3809                self.tx_id,
3810                0x2907fef2ac775657,
3811                fidl::encoding::DynamicFlags::empty(),
3812            )
3813    }
3814}
3815
3816#[must_use = "FIDL methods require a response to be sent"]
3817#[derive(Debug)]
3818pub struct GuestLifecycleStopResponder {
3819    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3820    tx_id: u32,
3821}
3822
3823/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3824/// if the responder is dropped without sending a response, so that the client
3825/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3826impl std::ops::Drop for GuestLifecycleStopResponder {
3827    fn drop(&mut self) {
3828        self.control_handle.shutdown();
3829        // Safety: drops once, never accessed again
3830        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3831    }
3832}
3833
3834impl fidl::endpoints::Responder for GuestLifecycleStopResponder {
3835    type ControlHandle = GuestLifecycleControlHandle;
3836
3837    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3838        &self.control_handle
3839    }
3840
3841    fn drop_without_shutdown(mut self) {
3842        // Safety: drops once, never accessed again due to mem::forget
3843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3844        // Prevent Drop from running (which would shut down the channel)
3845        std::mem::forget(self);
3846    }
3847}
3848
3849impl GuestLifecycleStopResponder {
3850    /// Sends a response to the FIDL transaction.
3851    ///
3852    /// Sets the channel to shutdown if an error occurs.
3853    pub fn send(self) -> Result<(), fidl::Error> {
3854        let _result = self.send_raw();
3855        if _result.is_err() {
3856            self.control_handle.shutdown();
3857        }
3858        self.drop_without_shutdown();
3859        _result
3860    }
3861
3862    /// Similar to "send" but does not shutdown the channel if an error occurs.
3863    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3864        let _result = self.send_raw();
3865        self.drop_without_shutdown();
3866        _result
3867    }
3868
3869    fn send_raw(&self) -> Result<(), fidl::Error> {
3870        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3871            (),
3872            self.tx_id,
3873            0x27eef9c535ac8eb4,
3874            fidl::encoding::DynamicFlags::empty(),
3875        )
3876    }
3877}
3878
3879#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3880pub struct GuestManagerMarker;
3881
3882impl fidl::endpoints::ProtocolMarker for GuestManagerMarker {
3883    type Proxy = GuestManagerProxy;
3884    type RequestStream = GuestManagerRequestStream;
3885    #[cfg(target_os = "fuchsia")]
3886    type SynchronousProxy = GuestManagerSynchronousProxy;
3887
3888    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestManager";
3889}
3890impl fidl::endpoints::DiscoverableProtocolMarker for GuestManagerMarker {}
3891pub type GuestManagerLaunchResult = Result<(), GuestManagerError>;
3892pub type GuestManagerConnectResult = Result<(), GuestManagerError>;
3893
3894pub trait GuestManagerProxyInterface: Send + Sync {
3895    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
3896        + Send;
3897    fn r#launch(
3898        &self,
3899        guest_config: GuestConfig,
3900        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3901    ) -> Self::LaunchResponseFut;
3902    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3903    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
3904    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
3905        + Send;
3906    fn r#connect(
3907        &self,
3908        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3909    ) -> Self::ConnectResponseFut;
3910    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
3911    fn r#get_info(&self) -> Self::GetInfoResponseFut;
3912}
3913#[derive(Debug)]
3914#[cfg(target_os = "fuchsia")]
3915pub struct GuestManagerSynchronousProxy {
3916    client: fidl::client::sync::Client,
3917}
3918
3919#[cfg(target_os = "fuchsia")]
3920impl fidl::endpoints::SynchronousProxy for GuestManagerSynchronousProxy {
3921    type Proxy = GuestManagerProxy;
3922    type Protocol = GuestManagerMarker;
3923
3924    fn from_channel(inner: fidl::Channel) -> Self {
3925        Self::new(inner)
3926    }
3927
3928    fn into_channel(self) -> fidl::Channel {
3929        self.client.into_channel()
3930    }
3931
3932    fn as_channel(&self) -> &fidl::Channel {
3933        self.client.as_channel()
3934    }
3935}
3936
3937#[cfg(target_os = "fuchsia")]
3938impl GuestManagerSynchronousProxy {
3939    pub fn new(channel: fidl::Channel) -> Self {
3940        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3941        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3942    }
3943
3944    pub fn into_channel(self) -> fidl::Channel {
3945        self.client.into_channel()
3946    }
3947
3948    /// Waits until an event arrives and returns it. It is safe for other
3949    /// threads to make concurrent requests while waiting for an event.
3950    pub fn wait_for_event(
3951        &self,
3952        deadline: zx::MonotonicInstant,
3953    ) -> Result<GuestManagerEvent, fidl::Error> {
3954        GuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
3955    }
3956
3957    /// Launch a new guest instance.
3958    ///
3959    /// Possible errors:
3960    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
3961    ///         problems detected by the guest manager.
3962    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
3963    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
3964    ///         component logs for a more specific failure.
3965    pub fn r#launch(
3966        &self,
3967        mut guest_config: GuestConfig,
3968        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
3969        ___deadline: zx::MonotonicInstant,
3970    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
3971        let _response =
3972            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
3973                fidl::encoding::EmptyStruct,
3974                GuestManagerError,
3975            >>(
3976                (&mut guest_config, controller),
3977                0x394a2e29f750323e,
3978                fidl::encoding::DynamicFlags::empty(),
3979                ___deadline,
3980            )?;
3981        Ok(_response.map(|x| x))
3982    }
3983
3984    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
3985    /// be used to launch another guest.
3986    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3987        let _response =
3988            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
3989                (),
3990                0x3ad9a012982f872d,
3991                fidl::encoding::DynamicFlags::empty(),
3992                ___deadline,
3993            )?;
3994        Ok(_response)
3995    }
3996
3997    /// Connect to a currently running guest.
3998    ///
3999    /// Possible errors:
4000    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4001    ///         has launched before attempting to reconnect.
4002    pub fn r#connect(
4003        &self,
4004        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4005        ___deadline: zx::MonotonicInstant,
4006    ) -> Result<GuestManagerConnectResult, fidl::Error> {
4007        let _response =
4008            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
4009                fidl::encoding::EmptyStruct,
4010                GuestManagerError,
4011            >>(
4012                (controller,),
4013                0x4e489076e3bb15b4,
4014                fidl::encoding::DynamicFlags::empty(),
4015                ___deadline,
4016            )?;
4017        Ok(_response.map(|x| x))
4018    }
4019
4020    /// Query guest info
4021    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
4022        let _response =
4023            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
4024                (),
4025                0x76892614aea695dc,
4026                fidl::encoding::DynamicFlags::empty(),
4027                ___deadline,
4028            )?;
4029        Ok(_response.guest_info)
4030    }
4031}
4032
4033#[cfg(target_os = "fuchsia")]
4034impl From<GuestManagerSynchronousProxy> for zx::Handle {
4035    fn from(value: GuestManagerSynchronousProxy) -> Self {
4036        value.into_channel().into()
4037    }
4038}
4039
4040#[cfg(target_os = "fuchsia")]
4041impl From<fidl::Channel> for GuestManagerSynchronousProxy {
4042    fn from(value: fidl::Channel) -> Self {
4043        Self::new(value)
4044    }
4045}
4046
4047#[derive(Debug, Clone)]
4048pub struct GuestManagerProxy {
4049    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4050}
4051
4052impl fidl::endpoints::Proxy for GuestManagerProxy {
4053    type Protocol = GuestManagerMarker;
4054
4055    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4056        Self::new(inner)
4057    }
4058
4059    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4060        self.client.into_channel().map_err(|client| Self { client })
4061    }
4062
4063    fn as_channel(&self) -> &::fidl::AsyncChannel {
4064        self.client.as_channel()
4065    }
4066}
4067
4068impl GuestManagerProxy {
4069    /// Create a new Proxy for fuchsia.virtualization/GuestManager.
4070    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4071        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4072        Self { client: fidl::client::Client::new(channel, protocol_name) }
4073    }
4074
4075    /// Get a Stream of events from the remote end of the protocol.
4076    ///
4077    /// # Panics
4078    ///
4079    /// Panics if the event stream was already taken.
4080    pub fn take_event_stream(&self) -> GuestManagerEventStream {
4081        GuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
4082    }
4083
4084    /// Launch a new guest instance.
4085    ///
4086    /// Possible errors:
4087    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4088    ///         problems detected by the guest manager.
4089    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4090    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4091    ///         component logs for a more specific failure.
4092    pub fn r#launch(
4093        &self,
4094        mut guest_config: GuestConfig,
4095        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4096    ) -> fidl::client::QueryResponseFut<
4097        GuestManagerLaunchResult,
4098        fidl::encoding::DefaultFuchsiaResourceDialect,
4099    > {
4100        GuestManagerProxyInterface::r#launch(self, guest_config, controller)
4101    }
4102
4103    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4104    /// be used to launch another guest.
4105    pub fn r#force_shutdown(
4106        &self,
4107    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4108        GuestManagerProxyInterface::r#force_shutdown(self)
4109    }
4110
4111    /// Connect to a currently running guest.
4112    ///
4113    /// Possible errors:
4114    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4115    ///         has launched before attempting to reconnect.
4116    pub fn r#connect(
4117        &self,
4118        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4119    ) -> fidl::client::QueryResponseFut<
4120        GuestManagerConnectResult,
4121        fidl::encoding::DefaultFuchsiaResourceDialect,
4122    > {
4123        GuestManagerProxyInterface::r#connect(self, controller)
4124    }
4125
4126    /// Query guest info
4127    pub fn r#get_info(
4128        &self,
4129    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
4130    {
4131        GuestManagerProxyInterface::r#get_info(self)
4132    }
4133}
4134
4135impl GuestManagerProxyInterface for GuestManagerProxy {
4136    type LaunchResponseFut = fidl::client::QueryResponseFut<
4137        GuestManagerLaunchResult,
4138        fidl::encoding::DefaultFuchsiaResourceDialect,
4139    >;
4140    fn r#launch(
4141        &self,
4142        mut guest_config: GuestConfig,
4143        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4144    ) -> Self::LaunchResponseFut {
4145        fn _decode(
4146            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4147        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
4148            let _response = fidl::client::decode_transaction_body::<
4149                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4150                fidl::encoding::DefaultFuchsiaResourceDialect,
4151                0x394a2e29f750323e,
4152            >(_buf?)?;
4153            Ok(_response.map(|x| x))
4154        }
4155        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
4156            (&mut guest_config, controller),
4157            0x394a2e29f750323e,
4158            fidl::encoding::DynamicFlags::empty(),
4159            _decode,
4160        )
4161    }
4162
4163    type ForceShutdownResponseFut =
4164        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4165    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
4166        fn _decode(
4167            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4168        ) -> Result<(), fidl::Error> {
4169            let _response = fidl::client::decode_transaction_body::<
4170                fidl::encoding::EmptyPayload,
4171                fidl::encoding::DefaultFuchsiaResourceDialect,
4172                0x3ad9a012982f872d,
4173            >(_buf?)?;
4174            Ok(_response)
4175        }
4176        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
4177            (),
4178            0x3ad9a012982f872d,
4179            fidl::encoding::DynamicFlags::empty(),
4180            _decode,
4181        )
4182    }
4183
4184    type ConnectResponseFut = fidl::client::QueryResponseFut<
4185        GuestManagerConnectResult,
4186        fidl::encoding::DefaultFuchsiaResourceDialect,
4187    >;
4188    fn r#connect(
4189        &self,
4190        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4191    ) -> Self::ConnectResponseFut {
4192        fn _decode(
4193            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4194        ) -> Result<GuestManagerConnectResult, fidl::Error> {
4195            let _response = fidl::client::decode_transaction_body::<
4196                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4197                fidl::encoding::DefaultFuchsiaResourceDialect,
4198                0x4e489076e3bb15b4,
4199            >(_buf?)?;
4200            Ok(_response.map(|x| x))
4201        }
4202        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
4203            (controller,),
4204            0x4e489076e3bb15b4,
4205            fidl::encoding::DynamicFlags::empty(),
4206            _decode,
4207        )
4208    }
4209
4210    type GetInfoResponseFut =
4211        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
4212    fn r#get_info(&self) -> Self::GetInfoResponseFut {
4213        fn _decode(
4214            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4215        ) -> Result<GuestInfo, fidl::Error> {
4216            let _response = fidl::client::decode_transaction_body::<
4217                GuestManagerGetInfoResponse,
4218                fidl::encoding::DefaultFuchsiaResourceDialect,
4219                0x76892614aea695dc,
4220            >(_buf?)?;
4221            Ok(_response.guest_info)
4222        }
4223        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
4224            (),
4225            0x76892614aea695dc,
4226            fidl::encoding::DynamicFlags::empty(),
4227            _decode,
4228        )
4229    }
4230}
4231
4232pub struct GuestManagerEventStream {
4233    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4234}
4235
4236impl std::marker::Unpin for GuestManagerEventStream {}
4237
4238impl futures::stream::FusedStream for GuestManagerEventStream {
4239    fn is_terminated(&self) -> bool {
4240        self.event_receiver.is_terminated()
4241    }
4242}
4243
4244impl futures::Stream for GuestManagerEventStream {
4245    type Item = Result<GuestManagerEvent, fidl::Error>;
4246
4247    fn poll_next(
4248        mut self: std::pin::Pin<&mut Self>,
4249        cx: &mut std::task::Context<'_>,
4250    ) -> std::task::Poll<Option<Self::Item>> {
4251        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4252            &mut self.event_receiver,
4253            cx
4254        )?) {
4255            Some(buf) => std::task::Poll::Ready(Some(GuestManagerEvent::decode(buf))),
4256            None => std::task::Poll::Ready(None),
4257        }
4258    }
4259}
4260
4261#[derive(Debug)]
4262pub enum GuestManagerEvent {}
4263
4264impl GuestManagerEvent {
4265    /// Decodes a message buffer as a [`GuestManagerEvent`].
4266    fn decode(
4267        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4268    ) -> Result<GuestManagerEvent, fidl::Error> {
4269        let (bytes, _handles) = buf.split_mut();
4270        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4271        debug_assert_eq!(tx_header.tx_id, 0);
4272        match tx_header.ordinal {
4273            _ => Err(fidl::Error::UnknownOrdinal {
4274                ordinal: tx_header.ordinal,
4275                protocol_name: <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4276            }),
4277        }
4278    }
4279}
4280
4281/// A Stream of incoming requests for fuchsia.virtualization/GuestManager.
4282pub struct GuestManagerRequestStream {
4283    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4284    is_terminated: bool,
4285}
4286
4287impl std::marker::Unpin for GuestManagerRequestStream {}
4288
4289impl futures::stream::FusedStream for GuestManagerRequestStream {
4290    fn is_terminated(&self) -> bool {
4291        self.is_terminated
4292    }
4293}
4294
4295impl fidl::endpoints::RequestStream for GuestManagerRequestStream {
4296    type Protocol = GuestManagerMarker;
4297    type ControlHandle = GuestManagerControlHandle;
4298
4299    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4300        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4301    }
4302
4303    fn control_handle(&self) -> Self::ControlHandle {
4304        GuestManagerControlHandle { inner: self.inner.clone() }
4305    }
4306
4307    fn into_inner(
4308        self,
4309    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4310    {
4311        (self.inner, self.is_terminated)
4312    }
4313
4314    fn from_inner(
4315        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4316        is_terminated: bool,
4317    ) -> Self {
4318        Self { inner, is_terminated }
4319    }
4320}
4321
4322impl futures::Stream for GuestManagerRequestStream {
4323    type Item = Result<GuestManagerRequest, fidl::Error>;
4324
4325    fn poll_next(
4326        mut self: std::pin::Pin<&mut Self>,
4327        cx: &mut std::task::Context<'_>,
4328    ) -> std::task::Poll<Option<Self::Item>> {
4329        let this = &mut *self;
4330        if this.inner.check_shutdown(cx) {
4331            this.is_terminated = true;
4332            return std::task::Poll::Ready(None);
4333        }
4334        if this.is_terminated {
4335            panic!("polled GuestManagerRequestStream after completion");
4336        }
4337        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4338            |bytes, handles| {
4339                match this.inner.channel().read_etc(cx, bytes, handles) {
4340                    std::task::Poll::Ready(Ok(())) => {}
4341                    std::task::Poll::Pending => return std::task::Poll::Pending,
4342                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4343                        this.is_terminated = true;
4344                        return std::task::Poll::Ready(None);
4345                    }
4346                    std::task::Poll::Ready(Err(e)) => {
4347                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4348                            e.into(),
4349                        ))))
4350                    }
4351                }
4352
4353                // A message has been received from the channel
4354                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4355
4356                std::task::Poll::Ready(Some(match header.ordinal {
4357                    0x394a2e29f750323e => {
4358                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4359                        let mut req = fidl::new_empty!(
4360                            GuestManagerLaunchRequest,
4361                            fidl::encoding::DefaultFuchsiaResourceDialect
4362                        );
4363                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
4364                        let control_handle =
4365                            GuestManagerControlHandle { inner: this.inner.clone() };
4366                        Ok(GuestManagerRequest::Launch {
4367                            guest_config: req.guest_config,
4368                            controller: req.controller,
4369
4370                            responder: GuestManagerLaunchResponder {
4371                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4372                                tx_id: header.tx_id,
4373                            },
4374                        })
4375                    }
4376                    0x3ad9a012982f872d => {
4377                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4378                        let mut req = fidl::new_empty!(
4379                            fidl::encoding::EmptyPayload,
4380                            fidl::encoding::DefaultFuchsiaResourceDialect
4381                        );
4382                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4383                        let control_handle =
4384                            GuestManagerControlHandle { inner: this.inner.clone() };
4385                        Ok(GuestManagerRequest::ForceShutdown {
4386                            responder: GuestManagerForceShutdownResponder {
4387                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4388                                tx_id: header.tx_id,
4389                            },
4390                        })
4391                    }
4392                    0x4e489076e3bb15b4 => {
4393                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4394                        let mut req = fidl::new_empty!(
4395                            GuestManagerConnectRequest,
4396                            fidl::encoding::DefaultFuchsiaResourceDialect
4397                        );
4398                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
4399                        let control_handle =
4400                            GuestManagerControlHandle { inner: this.inner.clone() };
4401                        Ok(GuestManagerRequest::Connect {
4402                            controller: req.controller,
4403
4404                            responder: GuestManagerConnectResponder {
4405                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4406                                tx_id: header.tx_id,
4407                            },
4408                        })
4409                    }
4410                    0x76892614aea695dc => {
4411                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4412                        let mut req = fidl::new_empty!(
4413                            fidl::encoding::EmptyPayload,
4414                            fidl::encoding::DefaultFuchsiaResourceDialect
4415                        );
4416                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4417                        let control_handle =
4418                            GuestManagerControlHandle { inner: this.inner.clone() };
4419                        Ok(GuestManagerRequest::GetInfo {
4420                            responder: GuestManagerGetInfoResponder {
4421                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4422                                tx_id: header.tx_id,
4423                            },
4424                        })
4425                    }
4426                    _ => Err(fidl::Error::UnknownOrdinal {
4427                        ordinal: header.ordinal,
4428                        protocol_name:
4429                            <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4430                    }),
4431                }))
4432            },
4433        )
4434    }
4435}
4436
4437#[derive(Debug)]
4438pub enum GuestManagerRequest {
4439    /// Launch a new guest instance.
4440    ///
4441    /// Possible errors:
4442    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4443    ///         problems detected by the guest manager.
4444    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4445    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4446    ///         component logs for a more specific failure.
4447    Launch {
4448        guest_config: GuestConfig,
4449        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4450        responder: GuestManagerLaunchResponder,
4451    },
4452    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4453    /// be used to launch another guest.
4454    ForceShutdown { responder: GuestManagerForceShutdownResponder },
4455    /// Connect to a currently running guest.
4456    ///
4457    /// Possible errors:
4458    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4459    ///         has launched before attempting to reconnect.
4460    Connect {
4461        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4462        responder: GuestManagerConnectResponder,
4463    },
4464    /// Query guest info
4465    GetInfo { responder: GuestManagerGetInfoResponder },
4466}
4467
4468impl GuestManagerRequest {
4469    #[allow(irrefutable_let_patterns)]
4470    pub fn into_launch(
4471        self,
4472    ) -> Option<(GuestConfig, fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerLaunchResponder)>
4473    {
4474        if let GuestManagerRequest::Launch { guest_config, controller, responder } = self {
4475            Some((guest_config, controller, responder))
4476        } else {
4477            None
4478        }
4479    }
4480
4481    #[allow(irrefutable_let_patterns)]
4482    pub fn into_force_shutdown(self) -> Option<(GuestManagerForceShutdownResponder)> {
4483        if let GuestManagerRequest::ForceShutdown { responder } = self {
4484            Some((responder))
4485        } else {
4486            None
4487        }
4488    }
4489
4490    #[allow(irrefutable_let_patterns)]
4491    pub fn into_connect(
4492        self,
4493    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerConnectResponder)> {
4494        if let GuestManagerRequest::Connect { controller, responder } = self {
4495            Some((controller, responder))
4496        } else {
4497            None
4498        }
4499    }
4500
4501    #[allow(irrefutable_let_patterns)]
4502    pub fn into_get_info(self) -> Option<(GuestManagerGetInfoResponder)> {
4503        if let GuestManagerRequest::GetInfo { responder } = self {
4504            Some((responder))
4505        } else {
4506            None
4507        }
4508    }
4509
4510    /// Name of the method defined in FIDL
4511    pub fn method_name(&self) -> &'static str {
4512        match *self {
4513            GuestManagerRequest::Launch { .. } => "launch",
4514            GuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
4515            GuestManagerRequest::Connect { .. } => "connect",
4516            GuestManagerRequest::GetInfo { .. } => "get_info",
4517        }
4518    }
4519}
4520
4521#[derive(Debug, Clone)]
4522pub struct GuestManagerControlHandle {
4523    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4524}
4525
4526impl fidl::endpoints::ControlHandle for GuestManagerControlHandle {
4527    fn shutdown(&self) {
4528        self.inner.shutdown()
4529    }
4530    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4531        self.inner.shutdown_with_epitaph(status)
4532    }
4533
4534    fn is_closed(&self) -> bool {
4535        self.inner.channel().is_closed()
4536    }
4537    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4538        self.inner.channel().on_closed()
4539    }
4540
4541    #[cfg(target_os = "fuchsia")]
4542    fn signal_peer(
4543        &self,
4544        clear_mask: zx::Signals,
4545        set_mask: zx::Signals,
4546    ) -> Result<(), zx_status::Status> {
4547        use fidl::Peered;
4548        self.inner.channel().signal_peer(clear_mask, set_mask)
4549    }
4550}
4551
4552impl GuestManagerControlHandle {}
4553
4554#[must_use = "FIDL methods require a response to be sent"]
4555#[derive(Debug)]
4556pub struct GuestManagerLaunchResponder {
4557    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4558    tx_id: u32,
4559}
4560
4561/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4562/// if the responder is dropped without sending a response, so that the client
4563/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4564impl std::ops::Drop for GuestManagerLaunchResponder {
4565    fn drop(&mut self) {
4566        self.control_handle.shutdown();
4567        // Safety: drops once, never accessed again
4568        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4569    }
4570}
4571
4572impl fidl::endpoints::Responder for GuestManagerLaunchResponder {
4573    type ControlHandle = GuestManagerControlHandle;
4574
4575    fn control_handle(&self) -> &GuestManagerControlHandle {
4576        &self.control_handle
4577    }
4578
4579    fn drop_without_shutdown(mut self) {
4580        // Safety: drops once, never accessed again due to mem::forget
4581        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4582        // Prevent Drop from running (which would shut down the channel)
4583        std::mem::forget(self);
4584    }
4585}
4586
4587impl GuestManagerLaunchResponder {
4588    /// Sends a response to the FIDL transaction.
4589    ///
4590    /// Sets the channel to shutdown if an error occurs.
4591    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4592        let _result = self.send_raw(result);
4593        if _result.is_err() {
4594            self.control_handle.shutdown();
4595        }
4596        self.drop_without_shutdown();
4597        _result
4598    }
4599
4600    /// Similar to "send" but does not shutdown the channel if an error occurs.
4601    pub fn send_no_shutdown_on_err(
4602        self,
4603        mut result: Result<(), GuestManagerError>,
4604    ) -> Result<(), fidl::Error> {
4605        let _result = self.send_raw(result);
4606        self.drop_without_shutdown();
4607        _result
4608    }
4609
4610    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4611        self.control_handle.inner.send::<fidl::encoding::ResultType<
4612            fidl::encoding::EmptyStruct,
4613            GuestManagerError,
4614        >>(
4615            result,
4616            self.tx_id,
4617            0x394a2e29f750323e,
4618            fidl::encoding::DynamicFlags::empty(),
4619        )
4620    }
4621}
4622
4623#[must_use = "FIDL methods require a response to be sent"]
4624#[derive(Debug)]
4625pub struct GuestManagerForceShutdownResponder {
4626    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4627    tx_id: u32,
4628}
4629
4630/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4631/// if the responder is dropped without sending a response, so that the client
4632/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4633impl std::ops::Drop for GuestManagerForceShutdownResponder {
4634    fn drop(&mut self) {
4635        self.control_handle.shutdown();
4636        // Safety: drops once, never accessed again
4637        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4638    }
4639}
4640
4641impl fidl::endpoints::Responder for GuestManagerForceShutdownResponder {
4642    type ControlHandle = GuestManagerControlHandle;
4643
4644    fn control_handle(&self) -> &GuestManagerControlHandle {
4645        &self.control_handle
4646    }
4647
4648    fn drop_without_shutdown(mut self) {
4649        // Safety: drops once, never accessed again due to mem::forget
4650        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4651        // Prevent Drop from running (which would shut down the channel)
4652        std::mem::forget(self);
4653    }
4654}
4655
4656impl GuestManagerForceShutdownResponder {
4657    /// Sends a response to the FIDL transaction.
4658    ///
4659    /// Sets the channel to shutdown if an error occurs.
4660    pub fn send(self) -> Result<(), fidl::Error> {
4661        let _result = self.send_raw();
4662        if _result.is_err() {
4663            self.control_handle.shutdown();
4664        }
4665        self.drop_without_shutdown();
4666        _result
4667    }
4668
4669    /// Similar to "send" but does not shutdown the channel if an error occurs.
4670    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4671        let _result = self.send_raw();
4672        self.drop_without_shutdown();
4673        _result
4674    }
4675
4676    fn send_raw(&self) -> Result<(), fidl::Error> {
4677        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4678            (),
4679            self.tx_id,
4680            0x3ad9a012982f872d,
4681            fidl::encoding::DynamicFlags::empty(),
4682        )
4683    }
4684}
4685
4686#[must_use = "FIDL methods require a response to be sent"]
4687#[derive(Debug)]
4688pub struct GuestManagerConnectResponder {
4689    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4690    tx_id: u32,
4691}
4692
4693/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4694/// if the responder is dropped without sending a response, so that the client
4695/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4696impl std::ops::Drop for GuestManagerConnectResponder {
4697    fn drop(&mut self) {
4698        self.control_handle.shutdown();
4699        // Safety: drops once, never accessed again
4700        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4701    }
4702}
4703
4704impl fidl::endpoints::Responder for GuestManagerConnectResponder {
4705    type ControlHandle = GuestManagerControlHandle;
4706
4707    fn control_handle(&self) -> &GuestManagerControlHandle {
4708        &self.control_handle
4709    }
4710
4711    fn drop_without_shutdown(mut self) {
4712        // Safety: drops once, never accessed again due to mem::forget
4713        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4714        // Prevent Drop from running (which would shut down the channel)
4715        std::mem::forget(self);
4716    }
4717}
4718
4719impl GuestManagerConnectResponder {
4720    /// Sends a response to the FIDL transaction.
4721    ///
4722    /// Sets the channel to shutdown if an error occurs.
4723    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4724        let _result = self.send_raw(result);
4725        if _result.is_err() {
4726            self.control_handle.shutdown();
4727        }
4728        self.drop_without_shutdown();
4729        _result
4730    }
4731
4732    /// Similar to "send" but does not shutdown the channel if an error occurs.
4733    pub fn send_no_shutdown_on_err(
4734        self,
4735        mut result: Result<(), GuestManagerError>,
4736    ) -> Result<(), fidl::Error> {
4737        let _result = self.send_raw(result);
4738        self.drop_without_shutdown();
4739        _result
4740    }
4741
4742    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4743        self.control_handle.inner.send::<fidl::encoding::ResultType<
4744            fidl::encoding::EmptyStruct,
4745            GuestManagerError,
4746        >>(
4747            result,
4748            self.tx_id,
4749            0x4e489076e3bb15b4,
4750            fidl::encoding::DynamicFlags::empty(),
4751        )
4752    }
4753}
4754
4755#[must_use = "FIDL methods require a response to be sent"]
4756#[derive(Debug)]
4757pub struct GuestManagerGetInfoResponder {
4758    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4759    tx_id: u32,
4760}
4761
4762/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4763/// if the responder is dropped without sending a response, so that the client
4764/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4765impl std::ops::Drop for GuestManagerGetInfoResponder {
4766    fn drop(&mut self) {
4767        self.control_handle.shutdown();
4768        // Safety: drops once, never accessed again
4769        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4770    }
4771}
4772
4773impl fidl::endpoints::Responder for GuestManagerGetInfoResponder {
4774    type ControlHandle = GuestManagerControlHandle;
4775
4776    fn control_handle(&self) -> &GuestManagerControlHandle {
4777        &self.control_handle
4778    }
4779
4780    fn drop_without_shutdown(mut self) {
4781        // Safety: drops once, never accessed again due to mem::forget
4782        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4783        // Prevent Drop from running (which would shut down the channel)
4784        std::mem::forget(self);
4785    }
4786}
4787
4788impl GuestManagerGetInfoResponder {
4789    /// Sends a response to the FIDL transaction.
4790    ///
4791    /// Sets the channel to shutdown if an error occurs.
4792    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4793        let _result = self.send_raw(guest_info);
4794        if _result.is_err() {
4795            self.control_handle.shutdown();
4796        }
4797        self.drop_without_shutdown();
4798        _result
4799    }
4800
4801    /// Similar to "send" but does not shutdown the channel if an error occurs.
4802    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4803        let _result = self.send_raw(guest_info);
4804        self.drop_without_shutdown();
4805        _result
4806    }
4807
4808    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4809        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
4810            (guest_info,),
4811            self.tx_id,
4812            0x76892614aea695dc,
4813            fidl::encoding::DynamicFlags::empty(),
4814        )
4815    }
4816}
4817
4818#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4819pub struct HostVsockAcceptorMarker;
4820
4821impl fidl::endpoints::ProtocolMarker for HostVsockAcceptorMarker {
4822    type Proxy = HostVsockAcceptorProxy;
4823    type RequestStream = HostVsockAcceptorRequestStream;
4824    #[cfg(target_os = "fuchsia")]
4825    type SynchronousProxy = HostVsockAcceptorSynchronousProxy;
4826
4827    const DEBUG_NAME: &'static str = "(anonymous) HostVsockAcceptor";
4828}
4829pub type HostVsockAcceptorAcceptResult = Result<fidl::Socket, i32>;
4830
4831pub trait HostVsockAcceptorProxyInterface: Send + Sync {
4832    type AcceptResponseFut: std::future::Future<Output = Result<HostVsockAcceptorAcceptResult, fidl::Error>>
4833        + Send;
4834    fn r#accept(&self, src_cid: u32, src_port: u32, port: u32) -> Self::AcceptResponseFut;
4835}
4836#[derive(Debug)]
4837#[cfg(target_os = "fuchsia")]
4838pub struct HostVsockAcceptorSynchronousProxy {
4839    client: fidl::client::sync::Client,
4840}
4841
4842#[cfg(target_os = "fuchsia")]
4843impl fidl::endpoints::SynchronousProxy for HostVsockAcceptorSynchronousProxy {
4844    type Proxy = HostVsockAcceptorProxy;
4845    type Protocol = HostVsockAcceptorMarker;
4846
4847    fn from_channel(inner: fidl::Channel) -> Self {
4848        Self::new(inner)
4849    }
4850
4851    fn into_channel(self) -> fidl::Channel {
4852        self.client.into_channel()
4853    }
4854
4855    fn as_channel(&self) -> &fidl::Channel {
4856        self.client.as_channel()
4857    }
4858}
4859
4860#[cfg(target_os = "fuchsia")]
4861impl HostVsockAcceptorSynchronousProxy {
4862    pub fn new(channel: fidl::Channel) -> Self {
4863        let protocol_name =
4864            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4865        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4866    }
4867
4868    pub fn into_channel(self) -> fidl::Channel {
4869        self.client.into_channel()
4870    }
4871
4872    /// Waits until an event arrives and returns it. It is safe for other
4873    /// threads to make concurrent requests while waiting for an event.
4874    pub fn wait_for_event(
4875        &self,
4876        deadline: zx::MonotonicInstant,
4877    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
4878        HostVsockAcceptorEvent::decode(self.client.wait_for_event(deadline)?)
4879    }
4880
4881    pub fn r#accept(
4882        &self,
4883        mut src_cid: u32,
4884        mut src_port: u32,
4885        mut port: u32,
4886        ___deadline: zx::MonotonicInstant,
4887    ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
4888        let _response = self.client.send_query::<
4889            HostVsockAcceptorAcceptRequest,
4890            fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
4891        >(
4892            (src_cid, src_port, port,),
4893            0x6996ed935beaa2d7,
4894            fidl::encoding::DynamicFlags::empty(),
4895            ___deadline,
4896        )?;
4897        Ok(_response.map(|x| x.socket))
4898    }
4899}
4900
4901#[cfg(target_os = "fuchsia")]
4902impl From<HostVsockAcceptorSynchronousProxy> for zx::Handle {
4903    fn from(value: HostVsockAcceptorSynchronousProxy) -> Self {
4904        value.into_channel().into()
4905    }
4906}
4907
4908#[cfg(target_os = "fuchsia")]
4909impl From<fidl::Channel> for HostVsockAcceptorSynchronousProxy {
4910    fn from(value: fidl::Channel) -> Self {
4911        Self::new(value)
4912    }
4913}
4914
4915#[derive(Debug, Clone)]
4916pub struct HostVsockAcceptorProxy {
4917    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4918}
4919
4920impl fidl::endpoints::Proxy for HostVsockAcceptorProxy {
4921    type Protocol = HostVsockAcceptorMarker;
4922
4923    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4924        Self::new(inner)
4925    }
4926
4927    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4928        self.client.into_channel().map_err(|client| Self { client })
4929    }
4930
4931    fn as_channel(&self) -> &::fidl::AsyncChannel {
4932        self.client.as_channel()
4933    }
4934}
4935
4936impl HostVsockAcceptorProxy {
4937    /// Create a new Proxy for fuchsia.virtualization/HostVsockAcceptor.
4938    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4939        let protocol_name =
4940            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4941        Self { client: fidl::client::Client::new(channel, protocol_name) }
4942    }
4943
4944    /// Get a Stream of events from the remote end of the protocol.
4945    ///
4946    /// # Panics
4947    ///
4948    /// Panics if the event stream was already taken.
4949    pub fn take_event_stream(&self) -> HostVsockAcceptorEventStream {
4950        HostVsockAcceptorEventStream { event_receiver: self.client.take_event_receiver() }
4951    }
4952
4953    pub fn r#accept(
4954        &self,
4955        mut src_cid: u32,
4956        mut src_port: u32,
4957        mut port: u32,
4958    ) -> fidl::client::QueryResponseFut<
4959        HostVsockAcceptorAcceptResult,
4960        fidl::encoding::DefaultFuchsiaResourceDialect,
4961    > {
4962        HostVsockAcceptorProxyInterface::r#accept(self, src_cid, src_port, port)
4963    }
4964}
4965
4966impl HostVsockAcceptorProxyInterface for HostVsockAcceptorProxy {
4967    type AcceptResponseFut = fidl::client::QueryResponseFut<
4968        HostVsockAcceptorAcceptResult,
4969        fidl::encoding::DefaultFuchsiaResourceDialect,
4970    >;
4971    fn r#accept(
4972        &self,
4973        mut src_cid: u32,
4974        mut src_port: u32,
4975        mut port: u32,
4976    ) -> Self::AcceptResponseFut {
4977        fn _decode(
4978            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4979        ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
4980            let _response = fidl::client::decode_transaction_body::<
4981                fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
4982                fidl::encoding::DefaultFuchsiaResourceDialect,
4983                0x6996ed935beaa2d7,
4984            >(_buf?)?;
4985            Ok(_response.map(|x| x.socket))
4986        }
4987        self.client
4988            .send_query_and_decode::<HostVsockAcceptorAcceptRequest, HostVsockAcceptorAcceptResult>(
4989                (src_cid, src_port, port),
4990                0x6996ed935beaa2d7,
4991                fidl::encoding::DynamicFlags::empty(),
4992                _decode,
4993            )
4994    }
4995}
4996
4997pub struct HostVsockAcceptorEventStream {
4998    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4999}
5000
5001impl std::marker::Unpin for HostVsockAcceptorEventStream {}
5002
5003impl futures::stream::FusedStream for HostVsockAcceptorEventStream {
5004    fn is_terminated(&self) -> bool {
5005        self.event_receiver.is_terminated()
5006    }
5007}
5008
5009impl futures::Stream for HostVsockAcceptorEventStream {
5010    type Item = Result<HostVsockAcceptorEvent, fidl::Error>;
5011
5012    fn poll_next(
5013        mut self: std::pin::Pin<&mut Self>,
5014        cx: &mut std::task::Context<'_>,
5015    ) -> std::task::Poll<Option<Self::Item>> {
5016        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5017            &mut self.event_receiver,
5018            cx
5019        )?) {
5020            Some(buf) => std::task::Poll::Ready(Some(HostVsockAcceptorEvent::decode(buf))),
5021            None => std::task::Poll::Ready(None),
5022        }
5023    }
5024}
5025
5026#[derive(Debug)]
5027pub enum HostVsockAcceptorEvent {}
5028
5029impl HostVsockAcceptorEvent {
5030    /// Decodes a message buffer as a [`HostVsockAcceptorEvent`].
5031    fn decode(
5032        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5033    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
5034        let (bytes, _handles) = buf.split_mut();
5035        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5036        debug_assert_eq!(tx_header.tx_id, 0);
5037        match tx_header.ordinal {
5038            _ => Err(fidl::Error::UnknownOrdinal {
5039                ordinal: tx_header.ordinal,
5040                protocol_name:
5041                    <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5042            }),
5043        }
5044    }
5045}
5046
5047/// A Stream of incoming requests for fuchsia.virtualization/HostVsockAcceptor.
5048pub struct HostVsockAcceptorRequestStream {
5049    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5050    is_terminated: bool,
5051}
5052
5053impl std::marker::Unpin for HostVsockAcceptorRequestStream {}
5054
5055impl futures::stream::FusedStream for HostVsockAcceptorRequestStream {
5056    fn is_terminated(&self) -> bool {
5057        self.is_terminated
5058    }
5059}
5060
5061impl fidl::endpoints::RequestStream for HostVsockAcceptorRequestStream {
5062    type Protocol = HostVsockAcceptorMarker;
5063    type ControlHandle = HostVsockAcceptorControlHandle;
5064
5065    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5066        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5067    }
5068
5069    fn control_handle(&self) -> Self::ControlHandle {
5070        HostVsockAcceptorControlHandle { inner: self.inner.clone() }
5071    }
5072
5073    fn into_inner(
5074        self,
5075    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5076    {
5077        (self.inner, self.is_terminated)
5078    }
5079
5080    fn from_inner(
5081        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5082        is_terminated: bool,
5083    ) -> Self {
5084        Self { inner, is_terminated }
5085    }
5086}
5087
5088impl futures::Stream for HostVsockAcceptorRequestStream {
5089    type Item = Result<HostVsockAcceptorRequest, fidl::Error>;
5090
5091    fn poll_next(
5092        mut self: std::pin::Pin<&mut Self>,
5093        cx: &mut std::task::Context<'_>,
5094    ) -> std::task::Poll<Option<Self::Item>> {
5095        let this = &mut *self;
5096        if this.inner.check_shutdown(cx) {
5097            this.is_terminated = true;
5098            return std::task::Poll::Ready(None);
5099        }
5100        if this.is_terminated {
5101            panic!("polled HostVsockAcceptorRequestStream after completion");
5102        }
5103        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5104            |bytes, handles| {
5105                match this.inner.channel().read_etc(cx, bytes, handles) {
5106                    std::task::Poll::Ready(Ok(())) => {}
5107                    std::task::Poll::Pending => return std::task::Poll::Pending,
5108                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5109                        this.is_terminated = true;
5110                        return std::task::Poll::Ready(None);
5111                    }
5112                    std::task::Poll::Ready(Err(e)) => {
5113                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5114                            e.into(),
5115                        ))))
5116                    }
5117                }
5118
5119                // A message has been received from the channel
5120                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5121
5122                std::task::Poll::Ready(Some(match header.ordinal {
5123                    0x6996ed935beaa2d7 => {
5124                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5125                        let mut req = fidl::new_empty!(
5126                            HostVsockAcceptorAcceptRequest,
5127                            fidl::encoding::DefaultFuchsiaResourceDialect
5128                        );
5129                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockAcceptorAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
5130                        let control_handle =
5131                            HostVsockAcceptorControlHandle { inner: this.inner.clone() };
5132                        Ok(HostVsockAcceptorRequest::Accept {
5133                            src_cid: req.src_cid,
5134                            src_port: req.src_port,
5135                            port: req.port,
5136
5137                            responder: HostVsockAcceptorAcceptResponder {
5138                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5139                                tx_id: header.tx_id,
5140                            },
5141                        })
5142                    }
5143                    _ => Err(fidl::Error::UnknownOrdinal {
5144                        ordinal: header.ordinal,
5145                        protocol_name:
5146                            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5147                    }),
5148                }))
5149            },
5150        )
5151    }
5152}
5153
5154/// Exposed by a host capable of listening via vsocks. A variant of a
5155/// `GuestVsockAcceptor` that is responsible for creating the `socket` with which
5156/// to communicate.
5157#[derive(Debug)]
5158pub enum HostVsockAcceptorRequest {
5159    Accept { src_cid: u32, src_port: u32, port: u32, responder: HostVsockAcceptorAcceptResponder },
5160}
5161
5162impl HostVsockAcceptorRequest {
5163    #[allow(irrefutable_let_patterns)]
5164    pub fn into_accept(self) -> Option<(u32, u32, u32, HostVsockAcceptorAcceptResponder)> {
5165        if let HostVsockAcceptorRequest::Accept { src_cid, src_port, port, responder } = self {
5166            Some((src_cid, src_port, port, responder))
5167        } else {
5168            None
5169        }
5170    }
5171
5172    /// Name of the method defined in FIDL
5173    pub fn method_name(&self) -> &'static str {
5174        match *self {
5175            HostVsockAcceptorRequest::Accept { .. } => "accept",
5176        }
5177    }
5178}
5179
5180#[derive(Debug, Clone)]
5181pub struct HostVsockAcceptorControlHandle {
5182    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5183}
5184
5185impl fidl::endpoints::ControlHandle for HostVsockAcceptorControlHandle {
5186    fn shutdown(&self) {
5187        self.inner.shutdown()
5188    }
5189    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5190        self.inner.shutdown_with_epitaph(status)
5191    }
5192
5193    fn is_closed(&self) -> bool {
5194        self.inner.channel().is_closed()
5195    }
5196    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5197        self.inner.channel().on_closed()
5198    }
5199
5200    #[cfg(target_os = "fuchsia")]
5201    fn signal_peer(
5202        &self,
5203        clear_mask: zx::Signals,
5204        set_mask: zx::Signals,
5205    ) -> Result<(), zx_status::Status> {
5206        use fidl::Peered;
5207        self.inner.channel().signal_peer(clear_mask, set_mask)
5208    }
5209}
5210
5211impl HostVsockAcceptorControlHandle {}
5212
5213#[must_use = "FIDL methods require a response to be sent"]
5214#[derive(Debug)]
5215pub struct HostVsockAcceptorAcceptResponder {
5216    control_handle: std::mem::ManuallyDrop<HostVsockAcceptorControlHandle>,
5217    tx_id: u32,
5218}
5219
5220/// Set the the channel to be shutdown (see [`HostVsockAcceptorControlHandle::shutdown`])
5221/// if the responder is dropped without sending a response, so that the client
5222/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5223impl std::ops::Drop for HostVsockAcceptorAcceptResponder {
5224    fn drop(&mut self) {
5225        self.control_handle.shutdown();
5226        // Safety: drops once, never accessed again
5227        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5228    }
5229}
5230
5231impl fidl::endpoints::Responder for HostVsockAcceptorAcceptResponder {
5232    type ControlHandle = HostVsockAcceptorControlHandle;
5233
5234    fn control_handle(&self) -> &HostVsockAcceptorControlHandle {
5235        &self.control_handle
5236    }
5237
5238    fn drop_without_shutdown(mut self) {
5239        // Safety: drops once, never accessed again due to mem::forget
5240        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5241        // Prevent Drop from running (which would shut down the channel)
5242        std::mem::forget(self);
5243    }
5244}
5245
5246impl HostVsockAcceptorAcceptResponder {
5247    /// Sends a response to the FIDL transaction.
5248    ///
5249    /// Sets the channel to shutdown if an error occurs.
5250    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5251        let _result = self.send_raw(result);
5252        if _result.is_err() {
5253            self.control_handle.shutdown();
5254        }
5255        self.drop_without_shutdown();
5256        _result
5257    }
5258
5259    /// Similar to "send" but does not shutdown the channel if an error occurs.
5260    pub fn send_no_shutdown_on_err(
5261        self,
5262        mut result: Result<fidl::Socket, i32>,
5263    ) -> Result<(), fidl::Error> {
5264        let _result = self.send_raw(result);
5265        self.drop_without_shutdown();
5266        _result
5267    }
5268
5269    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5270        self.control_handle
5271            .inner
5272            .send::<fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>>(
5273                result.map(|socket| (socket,)),
5274                self.tx_id,
5275                0x6996ed935beaa2d7,
5276                fidl::encoding::DynamicFlags::empty(),
5277            )
5278    }
5279}
5280
5281#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5282pub struct HostVsockEndpointMarker;
5283
5284impl fidl::endpoints::ProtocolMarker for HostVsockEndpointMarker {
5285    type Proxy = HostVsockEndpointProxy;
5286    type RequestStream = HostVsockEndpointRequestStream;
5287    #[cfg(target_os = "fuchsia")]
5288    type SynchronousProxy = HostVsockEndpointSynchronousProxy;
5289
5290    const DEBUG_NAME: &'static str = "fuchsia.virtualization.HostVsockEndpoint";
5291}
5292impl fidl::endpoints::DiscoverableProtocolMarker for HostVsockEndpointMarker {}
5293pub type HostVsockEndpointListenResult = Result<(), i32>;
5294pub type HostVsockEndpointConnectResult = Result<fidl::Socket, i32>;
5295
5296pub trait HostVsockEndpointProxyInterface: Send + Sync {
5297    type ListenResponseFut: std::future::Future<Output = Result<HostVsockEndpointListenResult, fidl::Error>>
5298        + Send;
5299    fn r#listen(
5300        &self,
5301        port: u32,
5302        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5303    ) -> Self::ListenResponseFut;
5304    type ConnectResponseFut: std::future::Future<Output = Result<HostVsockEndpointConnectResult, fidl::Error>>
5305        + Send;
5306    fn r#connect(&self, guest_port: u32) -> Self::ConnectResponseFut;
5307}
5308#[derive(Debug)]
5309#[cfg(target_os = "fuchsia")]
5310pub struct HostVsockEndpointSynchronousProxy {
5311    client: fidl::client::sync::Client,
5312}
5313
5314#[cfg(target_os = "fuchsia")]
5315impl fidl::endpoints::SynchronousProxy for HostVsockEndpointSynchronousProxy {
5316    type Proxy = HostVsockEndpointProxy;
5317    type Protocol = HostVsockEndpointMarker;
5318
5319    fn from_channel(inner: fidl::Channel) -> Self {
5320        Self::new(inner)
5321    }
5322
5323    fn into_channel(self) -> fidl::Channel {
5324        self.client.into_channel()
5325    }
5326
5327    fn as_channel(&self) -> &fidl::Channel {
5328        self.client.as_channel()
5329    }
5330}
5331
5332#[cfg(target_os = "fuchsia")]
5333impl HostVsockEndpointSynchronousProxy {
5334    pub fn new(channel: fidl::Channel) -> Self {
5335        let protocol_name =
5336            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5337        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5338    }
5339
5340    pub fn into_channel(self) -> fidl::Channel {
5341        self.client.into_channel()
5342    }
5343
5344    /// Waits until an event arrives and returns it. It is safe for other
5345    /// threads to make concurrent requests while waiting for an event.
5346    pub fn wait_for_event(
5347        &self,
5348        deadline: zx::MonotonicInstant,
5349    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5350        HostVsockEndpointEvent::decode(self.client.wait_for_event(deadline)?)
5351    }
5352
5353    /// Instructs the device to listen for guest initiated connections to a given port by
5354    /// using `acceptor` when the guest creates a connection.
5355    ///
5356    /// Possible errors:
5357    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5358    pub fn r#listen(
5359        &self,
5360        mut port: u32,
5361        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5362        ___deadline: zx::MonotonicInstant,
5363    ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5364        let _response = self
5365            .client
5366            .send_query::<Listener, fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5367                (port, acceptor),
5368                0xfd88f3b4767f2c7,
5369                fidl::encoding::DynamicFlags::empty(),
5370                ___deadline,
5371            )?;
5372        Ok(_response.map(|x| x))
5373    }
5374
5375    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5376    /// ephemeral host port.
5377    ///
5378    /// Possible errors:
5379    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5380    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5381    ///
5382    /// Other errors are related to socket creation, see
5383    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5384    pub fn r#connect(
5385        &self,
5386        mut guest_port: u32,
5387        ___deadline: zx::MonotonicInstant,
5388    ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5389        let _response = self.client.send_query::<
5390            HostVsockEndpointConnectRequest,
5391            fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5392        >(
5393            (guest_port,),
5394            0x4d12e10e946b43e4,
5395            fidl::encoding::DynamicFlags::empty(),
5396            ___deadline,
5397        )?;
5398        Ok(_response.map(|x| x.socket))
5399    }
5400}
5401
5402#[cfg(target_os = "fuchsia")]
5403impl From<HostVsockEndpointSynchronousProxy> for zx::Handle {
5404    fn from(value: HostVsockEndpointSynchronousProxy) -> Self {
5405        value.into_channel().into()
5406    }
5407}
5408
5409#[cfg(target_os = "fuchsia")]
5410impl From<fidl::Channel> for HostVsockEndpointSynchronousProxy {
5411    fn from(value: fidl::Channel) -> Self {
5412        Self::new(value)
5413    }
5414}
5415
5416#[derive(Debug, Clone)]
5417pub struct HostVsockEndpointProxy {
5418    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5419}
5420
5421impl fidl::endpoints::Proxy for HostVsockEndpointProxy {
5422    type Protocol = HostVsockEndpointMarker;
5423
5424    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5425        Self::new(inner)
5426    }
5427
5428    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5429        self.client.into_channel().map_err(|client| Self { client })
5430    }
5431
5432    fn as_channel(&self) -> &::fidl::AsyncChannel {
5433        self.client.as_channel()
5434    }
5435}
5436
5437impl HostVsockEndpointProxy {
5438    /// Create a new Proxy for fuchsia.virtualization/HostVsockEndpoint.
5439    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5440        let protocol_name =
5441            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5442        Self { client: fidl::client::Client::new(channel, protocol_name) }
5443    }
5444
5445    /// Get a Stream of events from the remote end of the protocol.
5446    ///
5447    /// # Panics
5448    ///
5449    /// Panics if the event stream was already taken.
5450    pub fn take_event_stream(&self) -> HostVsockEndpointEventStream {
5451        HostVsockEndpointEventStream { event_receiver: self.client.take_event_receiver() }
5452    }
5453
5454    /// Instructs the device to listen for guest initiated connections to a given port by
5455    /// using `acceptor` when the guest creates a connection.
5456    ///
5457    /// Possible errors:
5458    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5459    pub fn r#listen(
5460        &self,
5461        mut port: u32,
5462        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5463    ) -> fidl::client::QueryResponseFut<
5464        HostVsockEndpointListenResult,
5465        fidl::encoding::DefaultFuchsiaResourceDialect,
5466    > {
5467        HostVsockEndpointProxyInterface::r#listen(self, port, acceptor)
5468    }
5469
5470    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5471    /// ephemeral host port.
5472    ///
5473    /// Possible errors:
5474    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5475    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5476    ///
5477    /// Other errors are related to socket creation, see
5478    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5479    pub fn r#connect(
5480        &self,
5481        mut guest_port: u32,
5482    ) -> fidl::client::QueryResponseFut<
5483        HostVsockEndpointConnectResult,
5484        fidl::encoding::DefaultFuchsiaResourceDialect,
5485    > {
5486        HostVsockEndpointProxyInterface::r#connect(self, guest_port)
5487    }
5488}
5489
5490impl HostVsockEndpointProxyInterface for HostVsockEndpointProxy {
5491    type ListenResponseFut = fidl::client::QueryResponseFut<
5492        HostVsockEndpointListenResult,
5493        fidl::encoding::DefaultFuchsiaResourceDialect,
5494    >;
5495    fn r#listen(
5496        &self,
5497        mut port: u32,
5498        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5499    ) -> Self::ListenResponseFut {
5500        fn _decode(
5501            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5502        ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5503            let _response = fidl::client::decode_transaction_body::<
5504                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5505                fidl::encoding::DefaultFuchsiaResourceDialect,
5506                0xfd88f3b4767f2c7,
5507            >(_buf?)?;
5508            Ok(_response.map(|x| x))
5509        }
5510        self.client.send_query_and_decode::<Listener, HostVsockEndpointListenResult>(
5511            (port, acceptor),
5512            0xfd88f3b4767f2c7,
5513            fidl::encoding::DynamicFlags::empty(),
5514            _decode,
5515        )
5516    }
5517
5518    type ConnectResponseFut = fidl::client::QueryResponseFut<
5519        HostVsockEndpointConnectResult,
5520        fidl::encoding::DefaultFuchsiaResourceDialect,
5521    >;
5522    fn r#connect(&self, mut guest_port: u32) -> Self::ConnectResponseFut {
5523        fn _decode(
5524            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5525        ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5526            let _response = fidl::client::decode_transaction_body::<
5527                fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5528                fidl::encoding::DefaultFuchsiaResourceDialect,
5529                0x4d12e10e946b43e4,
5530            >(_buf?)?;
5531            Ok(_response.map(|x| x.socket))
5532        }
5533        self.client.send_query_and_decode::<
5534            HostVsockEndpointConnectRequest,
5535            HostVsockEndpointConnectResult,
5536        >(
5537            (guest_port,),
5538            0x4d12e10e946b43e4,
5539            fidl::encoding::DynamicFlags::empty(),
5540            _decode,
5541        )
5542    }
5543}
5544
5545pub struct HostVsockEndpointEventStream {
5546    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5547}
5548
5549impl std::marker::Unpin for HostVsockEndpointEventStream {}
5550
5551impl futures::stream::FusedStream for HostVsockEndpointEventStream {
5552    fn is_terminated(&self) -> bool {
5553        self.event_receiver.is_terminated()
5554    }
5555}
5556
5557impl futures::Stream for HostVsockEndpointEventStream {
5558    type Item = Result<HostVsockEndpointEvent, fidl::Error>;
5559
5560    fn poll_next(
5561        mut self: std::pin::Pin<&mut Self>,
5562        cx: &mut std::task::Context<'_>,
5563    ) -> std::task::Poll<Option<Self::Item>> {
5564        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5565            &mut self.event_receiver,
5566            cx
5567        )?) {
5568            Some(buf) => std::task::Poll::Ready(Some(HostVsockEndpointEvent::decode(buf))),
5569            None => std::task::Poll::Ready(None),
5570        }
5571    }
5572}
5573
5574#[derive(Debug)]
5575pub enum HostVsockEndpointEvent {}
5576
5577impl HostVsockEndpointEvent {
5578    /// Decodes a message buffer as a [`HostVsockEndpointEvent`].
5579    fn decode(
5580        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5581    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5582        let (bytes, _handles) = buf.split_mut();
5583        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5584        debug_assert_eq!(tx_header.tx_id, 0);
5585        match tx_header.ordinal {
5586            _ => Err(fidl::Error::UnknownOrdinal {
5587                ordinal: tx_header.ordinal,
5588                protocol_name:
5589                    <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5590            }),
5591        }
5592    }
5593}
5594
5595/// A Stream of incoming requests for fuchsia.virtualization/HostVsockEndpoint.
5596pub struct HostVsockEndpointRequestStream {
5597    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5598    is_terminated: bool,
5599}
5600
5601impl std::marker::Unpin for HostVsockEndpointRequestStream {}
5602
5603impl futures::stream::FusedStream for HostVsockEndpointRequestStream {
5604    fn is_terminated(&self) -> bool {
5605        self.is_terminated
5606    }
5607}
5608
5609impl fidl::endpoints::RequestStream for HostVsockEndpointRequestStream {
5610    type Protocol = HostVsockEndpointMarker;
5611    type ControlHandle = HostVsockEndpointControlHandle;
5612
5613    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5614        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5615    }
5616
5617    fn control_handle(&self) -> Self::ControlHandle {
5618        HostVsockEndpointControlHandle { inner: self.inner.clone() }
5619    }
5620
5621    fn into_inner(
5622        self,
5623    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5624    {
5625        (self.inner, self.is_terminated)
5626    }
5627
5628    fn from_inner(
5629        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5630        is_terminated: bool,
5631    ) -> Self {
5632        Self { inner, is_terminated }
5633    }
5634}
5635
5636impl futures::Stream for HostVsockEndpointRequestStream {
5637    type Item = Result<HostVsockEndpointRequest, fidl::Error>;
5638
5639    fn poll_next(
5640        mut self: std::pin::Pin<&mut Self>,
5641        cx: &mut std::task::Context<'_>,
5642    ) -> std::task::Poll<Option<Self::Item>> {
5643        let this = &mut *self;
5644        if this.inner.check_shutdown(cx) {
5645            this.is_terminated = true;
5646            return std::task::Poll::Ready(None);
5647        }
5648        if this.is_terminated {
5649            panic!("polled HostVsockEndpointRequestStream after completion");
5650        }
5651        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5652            |bytes, handles| {
5653                match this.inner.channel().read_etc(cx, bytes, handles) {
5654                    std::task::Poll::Ready(Ok(())) => {}
5655                    std::task::Poll::Pending => return std::task::Poll::Pending,
5656                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5657                        this.is_terminated = true;
5658                        return std::task::Poll::Ready(None);
5659                    }
5660                    std::task::Poll::Ready(Err(e)) => {
5661                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5662                            e.into(),
5663                        ))))
5664                    }
5665                }
5666
5667                // A message has been received from the channel
5668                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5669
5670                std::task::Poll::Ready(Some(match header.ordinal {
5671                    0xfd88f3b4767f2c7 => {
5672                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5673                        let mut req = fidl::new_empty!(
5674                            Listener,
5675                            fidl::encoding::DefaultFuchsiaResourceDialect
5676                        );
5677                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Listener>(&header, _body_bytes, handles, &mut req)?;
5678                        let control_handle =
5679                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5680                        Ok(HostVsockEndpointRequest::Listen {
5681                            port: req.port,
5682                            acceptor: req.acceptor,
5683
5684                            responder: HostVsockEndpointListenResponder {
5685                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5686                                tx_id: header.tx_id,
5687                            },
5688                        })
5689                    }
5690                    0x4d12e10e946b43e4 => {
5691                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5692                        let mut req = fidl::new_empty!(
5693                            HostVsockEndpointConnectRequest,
5694                            fidl::encoding::DefaultFuchsiaResourceDialect
5695                        );
5696                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockEndpointConnectRequest>(&header, _body_bytes, handles, &mut req)?;
5697                        let control_handle =
5698                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5699                        Ok(HostVsockEndpointRequest::Connect {
5700                            guest_port: req.guest_port,
5701
5702                            responder: HostVsockEndpointConnectResponder {
5703                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5704                                tx_id: header.tx_id,
5705                            },
5706                        })
5707                    }
5708                    _ => Err(fidl::Error::UnknownOrdinal {
5709                        ordinal: header.ordinal,
5710                        protocol_name:
5711                            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5712                    }),
5713                }))
5714            },
5715        )
5716    }
5717}
5718
5719/// Exposed by a host to provide the ability for listeners to be multiplexed by
5720/// port and to manage dynamic port allocation for outbound connections.
5721#[derive(Debug)]
5722pub enum HostVsockEndpointRequest {
5723    /// Instructs the device to listen for guest initiated connections to a given port by
5724    /// using `acceptor` when the guest creates a connection.
5725    ///
5726    /// Possible errors:
5727    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5728    Listen {
5729        port: u32,
5730        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5731        responder: HostVsockEndpointListenResponder,
5732    },
5733    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5734    /// ephemeral host port.
5735    ///
5736    /// Possible errors:
5737    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5738    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5739    ///
5740    /// Other errors are related to socket creation, see
5741    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5742    Connect { guest_port: u32, responder: HostVsockEndpointConnectResponder },
5743}
5744
5745impl HostVsockEndpointRequest {
5746    #[allow(irrefutable_let_patterns)]
5747    pub fn into_listen(
5748        self,
5749    ) -> Option<(
5750        u32,
5751        fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5752        HostVsockEndpointListenResponder,
5753    )> {
5754        if let HostVsockEndpointRequest::Listen { port, acceptor, responder } = self {
5755            Some((port, acceptor, responder))
5756        } else {
5757            None
5758        }
5759    }
5760
5761    #[allow(irrefutable_let_patterns)]
5762    pub fn into_connect(self) -> Option<(u32, HostVsockEndpointConnectResponder)> {
5763        if let HostVsockEndpointRequest::Connect { guest_port, responder } = self {
5764            Some((guest_port, responder))
5765        } else {
5766            None
5767        }
5768    }
5769
5770    /// Name of the method defined in FIDL
5771    pub fn method_name(&self) -> &'static str {
5772        match *self {
5773            HostVsockEndpointRequest::Listen { .. } => "listen",
5774            HostVsockEndpointRequest::Connect { .. } => "connect",
5775        }
5776    }
5777}
5778
5779#[derive(Debug, Clone)]
5780pub struct HostVsockEndpointControlHandle {
5781    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5782}
5783
5784impl fidl::endpoints::ControlHandle for HostVsockEndpointControlHandle {
5785    fn shutdown(&self) {
5786        self.inner.shutdown()
5787    }
5788    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5789        self.inner.shutdown_with_epitaph(status)
5790    }
5791
5792    fn is_closed(&self) -> bool {
5793        self.inner.channel().is_closed()
5794    }
5795    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5796        self.inner.channel().on_closed()
5797    }
5798
5799    #[cfg(target_os = "fuchsia")]
5800    fn signal_peer(
5801        &self,
5802        clear_mask: zx::Signals,
5803        set_mask: zx::Signals,
5804    ) -> Result<(), zx_status::Status> {
5805        use fidl::Peered;
5806        self.inner.channel().signal_peer(clear_mask, set_mask)
5807    }
5808}
5809
5810impl HostVsockEndpointControlHandle {}
5811
5812#[must_use = "FIDL methods require a response to be sent"]
5813#[derive(Debug)]
5814pub struct HostVsockEndpointListenResponder {
5815    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5816    tx_id: u32,
5817}
5818
5819/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5820/// if the responder is dropped without sending a response, so that the client
5821/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5822impl std::ops::Drop for HostVsockEndpointListenResponder {
5823    fn drop(&mut self) {
5824        self.control_handle.shutdown();
5825        // Safety: drops once, never accessed again
5826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5827    }
5828}
5829
5830impl fidl::endpoints::Responder for HostVsockEndpointListenResponder {
5831    type ControlHandle = HostVsockEndpointControlHandle;
5832
5833    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5834        &self.control_handle
5835    }
5836
5837    fn drop_without_shutdown(mut self) {
5838        // Safety: drops once, never accessed again due to mem::forget
5839        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5840        // Prevent Drop from running (which would shut down the channel)
5841        std::mem::forget(self);
5842    }
5843}
5844
5845impl HostVsockEndpointListenResponder {
5846    /// Sends a response to the FIDL transaction.
5847    ///
5848    /// Sets the channel to shutdown if an error occurs.
5849    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5850        let _result = self.send_raw(result);
5851        if _result.is_err() {
5852            self.control_handle.shutdown();
5853        }
5854        self.drop_without_shutdown();
5855        _result
5856    }
5857
5858    /// Similar to "send" but does not shutdown the channel if an error occurs.
5859    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5860        let _result = self.send_raw(result);
5861        self.drop_without_shutdown();
5862        _result
5863    }
5864
5865    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5866        self.control_handle
5867            .inner
5868            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5869                result,
5870                self.tx_id,
5871                0xfd88f3b4767f2c7,
5872                fidl::encoding::DynamicFlags::empty(),
5873            )
5874    }
5875}
5876
5877#[must_use = "FIDL methods require a response to be sent"]
5878#[derive(Debug)]
5879pub struct HostVsockEndpointConnectResponder {
5880    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5881    tx_id: u32,
5882}
5883
5884/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5885/// if the responder is dropped without sending a response, so that the client
5886/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5887impl std::ops::Drop for HostVsockEndpointConnectResponder {
5888    fn drop(&mut self) {
5889        self.control_handle.shutdown();
5890        // Safety: drops once, never accessed again
5891        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5892    }
5893}
5894
5895impl fidl::endpoints::Responder for HostVsockEndpointConnectResponder {
5896    type ControlHandle = HostVsockEndpointControlHandle;
5897
5898    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5899        &self.control_handle
5900    }
5901
5902    fn drop_without_shutdown(mut self) {
5903        // Safety: drops once, never accessed again due to mem::forget
5904        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5905        // Prevent Drop from running (which would shut down the channel)
5906        std::mem::forget(self);
5907    }
5908}
5909
5910impl HostVsockEndpointConnectResponder {
5911    /// Sends a response to the FIDL transaction.
5912    ///
5913    /// Sets the channel to shutdown if an error occurs.
5914    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5915        let _result = self.send_raw(result);
5916        if _result.is_err() {
5917            self.control_handle.shutdown();
5918        }
5919        self.drop_without_shutdown();
5920        _result
5921    }
5922
5923    /// Similar to "send" but does not shutdown the channel if an error occurs.
5924    pub fn send_no_shutdown_on_err(
5925        self,
5926        mut result: Result<fidl::Socket, i32>,
5927    ) -> Result<(), fidl::Error> {
5928        let _result = self.send_raw(result);
5929        self.drop_without_shutdown();
5930        _result
5931    }
5932
5933    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5934        self.control_handle
5935            .inner
5936            .send::<fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>>(
5937                result.map(|socket| (socket,)),
5938                self.tx_id,
5939                0x4d12e10e946b43e4,
5940                fidl::encoding::DynamicFlags::empty(),
5941            )
5942    }
5943}
5944
5945#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5946pub struct LinuxManagerMarker;
5947
5948impl fidl::endpoints::ProtocolMarker for LinuxManagerMarker {
5949    type Proxy = LinuxManagerProxy;
5950    type RequestStream = LinuxManagerRequestStream;
5951    #[cfg(target_os = "fuchsia")]
5952    type SynchronousProxy = LinuxManagerSynchronousProxy;
5953
5954    const DEBUG_NAME: &'static str = "fuchsia.virtualization.LinuxManager";
5955}
5956impl fidl::endpoints::DiscoverableProtocolMarker for LinuxManagerMarker {}
5957pub type LinuxManagerStartAndGetLinuxGuestInfoResult = Result<LinuxGuestInfo, i32>;
5958pub type LinuxManagerWipeDataResult = Result<(), i32>;
5959
5960pub trait LinuxManagerProxyInterface: Send + Sync {
5961    type StartAndGetLinuxGuestInfoResponseFut: std::future::Future<
5962            Output = Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error>,
5963        > + Send;
5964    fn r#start_and_get_linux_guest_info(
5965        &self,
5966        label: &str,
5967    ) -> Self::StartAndGetLinuxGuestInfoResponseFut;
5968    type WipeDataResponseFut: std::future::Future<Output = Result<LinuxManagerWipeDataResult, fidl::Error>>
5969        + Send;
5970    fn r#wipe_data(&self) -> Self::WipeDataResponseFut;
5971    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error>;
5972}
5973#[derive(Debug)]
5974#[cfg(target_os = "fuchsia")]
5975pub struct LinuxManagerSynchronousProxy {
5976    client: fidl::client::sync::Client,
5977}
5978
5979#[cfg(target_os = "fuchsia")]
5980impl fidl::endpoints::SynchronousProxy for LinuxManagerSynchronousProxy {
5981    type Proxy = LinuxManagerProxy;
5982    type Protocol = LinuxManagerMarker;
5983
5984    fn from_channel(inner: fidl::Channel) -> Self {
5985        Self::new(inner)
5986    }
5987
5988    fn into_channel(self) -> fidl::Channel {
5989        self.client.into_channel()
5990    }
5991
5992    fn as_channel(&self) -> &fidl::Channel {
5993        self.client.as_channel()
5994    }
5995}
5996
5997#[cfg(target_os = "fuchsia")]
5998impl LinuxManagerSynchronousProxy {
5999    pub fn new(channel: fidl::Channel) -> Self {
6000        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6001        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6002    }
6003
6004    pub fn into_channel(self) -> fidl::Channel {
6005        self.client.into_channel()
6006    }
6007
6008    /// Waits until an event arrives and returns it. It is safe for other
6009    /// threads to make concurrent requests while waiting for an event.
6010    pub fn wait_for_event(
6011        &self,
6012        deadline: zx::MonotonicInstant,
6013    ) -> Result<LinuxManagerEvent, fidl::Error> {
6014        LinuxManagerEvent::decode(self.client.wait_for_event(deadline)?)
6015    }
6016
6017    /// Get Linux guest environment info.
6018    ///
6019    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6020    pub fn r#start_and_get_linux_guest_info(
6021        &self,
6022        mut label: &str,
6023        ___deadline: zx::MonotonicInstant,
6024    ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6025        let _response = self.client.send_query::<
6026            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6027            fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6028        >(
6029            (label,),
6030            0x11809ced100a2bea,
6031            fidl::encoding::DynamicFlags::empty(),
6032            ___deadline,
6033        )?;
6034        Ok(_response.map(|x| x.info))
6035    }
6036
6037    /// Clears the stateful data. This includes any installed containers and any user data
6038    /// they may contain.
6039    ///
6040    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6041    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6042    /// operation.
6043    pub fn r#wipe_data(
6044        &self,
6045        ___deadline: zx::MonotonicInstant,
6046    ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6047        let _response = self.client.send_query::<
6048            fidl::encoding::EmptyPayload,
6049            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6050        >(
6051            (),
6052            0x732c69394548a76a,
6053            fidl::encoding::DynamicFlags::empty(),
6054            ___deadline,
6055        )?;
6056        Ok(_response.map(|x| x))
6057    }
6058
6059    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6060    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6061    /// the epitaph) before attempting to launch another guest.
6062    ///
6063    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6064    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6065    /// a component crash).
6066    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6067        self.client.send::<fidl::encoding::EmptyPayload>(
6068            (),
6069            0x5dab12b50bc9909d,
6070            fidl::encoding::DynamicFlags::empty(),
6071        )
6072    }
6073}
6074
6075#[cfg(target_os = "fuchsia")]
6076impl From<LinuxManagerSynchronousProxy> for zx::Handle {
6077    fn from(value: LinuxManagerSynchronousProxy) -> Self {
6078        value.into_channel().into()
6079    }
6080}
6081
6082#[cfg(target_os = "fuchsia")]
6083impl From<fidl::Channel> for LinuxManagerSynchronousProxy {
6084    fn from(value: fidl::Channel) -> Self {
6085        Self::new(value)
6086    }
6087}
6088
6089#[derive(Debug, Clone)]
6090pub struct LinuxManagerProxy {
6091    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6092}
6093
6094impl fidl::endpoints::Proxy for LinuxManagerProxy {
6095    type Protocol = LinuxManagerMarker;
6096
6097    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6098        Self::new(inner)
6099    }
6100
6101    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6102        self.client.into_channel().map_err(|client| Self { client })
6103    }
6104
6105    fn as_channel(&self) -> &::fidl::AsyncChannel {
6106        self.client.as_channel()
6107    }
6108}
6109
6110impl LinuxManagerProxy {
6111    /// Create a new Proxy for fuchsia.virtualization/LinuxManager.
6112    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6113        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6114        Self { client: fidl::client::Client::new(channel, protocol_name) }
6115    }
6116
6117    /// Get a Stream of events from the remote end of the protocol.
6118    ///
6119    /// # Panics
6120    ///
6121    /// Panics if the event stream was already taken.
6122    pub fn take_event_stream(&self) -> LinuxManagerEventStream {
6123        LinuxManagerEventStream { event_receiver: self.client.take_event_receiver() }
6124    }
6125
6126    /// Get Linux guest environment info.
6127    ///
6128    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6129    pub fn r#start_and_get_linux_guest_info(
6130        &self,
6131        mut label: &str,
6132    ) -> fidl::client::QueryResponseFut<
6133        LinuxManagerStartAndGetLinuxGuestInfoResult,
6134        fidl::encoding::DefaultFuchsiaResourceDialect,
6135    > {
6136        LinuxManagerProxyInterface::r#start_and_get_linux_guest_info(self, label)
6137    }
6138
6139    /// Clears the stateful data. This includes any installed containers and any user data
6140    /// they may contain.
6141    ///
6142    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6143    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6144    /// operation.
6145    pub fn r#wipe_data(
6146        &self,
6147    ) -> fidl::client::QueryResponseFut<
6148        LinuxManagerWipeDataResult,
6149        fidl::encoding::DefaultFuchsiaResourceDialect,
6150    > {
6151        LinuxManagerProxyInterface::r#wipe_data(self)
6152    }
6153
6154    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6155    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6156    /// the epitaph) before attempting to launch another guest.
6157    ///
6158    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6159    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6160    /// a component crash).
6161    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6162        LinuxManagerProxyInterface::r#graceful_shutdown(self)
6163    }
6164}
6165
6166impl LinuxManagerProxyInterface for LinuxManagerProxy {
6167    type StartAndGetLinuxGuestInfoResponseFut = fidl::client::QueryResponseFut<
6168        LinuxManagerStartAndGetLinuxGuestInfoResult,
6169        fidl::encoding::DefaultFuchsiaResourceDialect,
6170    >;
6171    fn r#start_and_get_linux_guest_info(
6172        &self,
6173        mut label: &str,
6174    ) -> Self::StartAndGetLinuxGuestInfoResponseFut {
6175        fn _decode(
6176            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6177        ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6178            let _response = fidl::client::decode_transaction_body::<
6179                fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6180                fidl::encoding::DefaultFuchsiaResourceDialect,
6181                0x11809ced100a2bea,
6182            >(_buf?)?;
6183            Ok(_response.map(|x| x.info))
6184        }
6185        self.client.send_query_and_decode::<
6186            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6187            LinuxManagerStartAndGetLinuxGuestInfoResult,
6188        >(
6189            (label,),
6190            0x11809ced100a2bea,
6191            fidl::encoding::DynamicFlags::empty(),
6192            _decode,
6193        )
6194    }
6195
6196    type WipeDataResponseFut = fidl::client::QueryResponseFut<
6197        LinuxManagerWipeDataResult,
6198        fidl::encoding::DefaultFuchsiaResourceDialect,
6199    >;
6200    fn r#wipe_data(&self) -> Self::WipeDataResponseFut {
6201        fn _decode(
6202            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6203        ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6204            let _response = fidl::client::decode_transaction_body::<
6205                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6206                fidl::encoding::DefaultFuchsiaResourceDialect,
6207                0x732c69394548a76a,
6208            >(_buf?)?;
6209            Ok(_response.map(|x| x))
6210        }
6211        self.client
6212            .send_query_and_decode::<fidl::encoding::EmptyPayload, LinuxManagerWipeDataResult>(
6213                (),
6214                0x732c69394548a76a,
6215                fidl::encoding::DynamicFlags::empty(),
6216                _decode,
6217            )
6218    }
6219
6220    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6221        self.client.send::<fidl::encoding::EmptyPayload>(
6222            (),
6223            0x5dab12b50bc9909d,
6224            fidl::encoding::DynamicFlags::empty(),
6225        )
6226    }
6227}
6228
6229pub struct LinuxManagerEventStream {
6230    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6231}
6232
6233impl std::marker::Unpin for LinuxManagerEventStream {}
6234
6235impl futures::stream::FusedStream for LinuxManagerEventStream {
6236    fn is_terminated(&self) -> bool {
6237        self.event_receiver.is_terminated()
6238    }
6239}
6240
6241impl futures::Stream for LinuxManagerEventStream {
6242    type Item = Result<LinuxManagerEvent, fidl::Error>;
6243
6244    fn poll_next(
6245        mut self: std::pin::Pin<&mut Self>,
6246        cx: &mut std::task::Context<'_>,
6247    ) -> std::task::Poll<Option<Self::Item>> {
6248        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6249            &mut self.event_receiver,
6250            cx
6251        )?) {
6252            Some(buf) => std::task::Poll::Ready(Some(LinuxManagerEvent::decode(buf))),
6253            None => std::task::Poll::Ready(None),
6254        }
6255    }
6256}
6257
6258#[derive(Debug)]
6259pub enum LinuxManagerEvent {
6260    OnGuestInfoChanged { label: String, info: LinuxGuestInfo },
6261}
6262
6263impl LinuxManagerEvent {
6264    #[allow(irrefutable_let_patterns)]
6265    pub fn into_on_guest_info_changed(self) -> Option<(String, LinuxGuestInfo)> {
6266        if let LinuxManagerEvent::OnGuestInfoChanged { label, info } = self {
6267            Some((label, info))
6268        } else {
6269            None
6270        }
6271    }
6272
6273    /// Decodes a message buffer as a [`LinuxManagerEvent`].
6274    fn decode(
6275        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6276    ) -> Result<LinuxManagerEvent, fidl::Error> {
6277        let (bytes, _handles) = buf.split_mut();
6278        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6279        debug_assert_eq!(tx_header.tx_id, 0);
6280        match tx_header.ordinal {
6281            0x30a9be4c43d6a2d6 => {
6282                let mut out = fidl::new_empty!(
6283                    LinuxManagerOnGuestInfoChangedRequest,
6284                    fidl::encoding::DefaultFuchsiaResourceDialect
6285                );
6286                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerOnGuestInfoChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6287                Ok((LinuxManagerEvent::OnGuestInfoChanged { label: out.label, info: out.info }))
6288            }
6289            _ => Err(fidl::Error::UnknownOrdinal {
6290                ordinal: tx_header.ordinal,
6291                protocol_name: <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6292            }),
6293        }
6294    }
6295}
6296
6297/// A Stream of incoming requests for fuchsia.virtualization/LinuxManager.
6298pub struct LinuxManagerRequestStream {
6299    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6300    is_terminated: bool,
6301}
6302
6303impl std::marker::Unpin for LinuxManagerRequestStream {}
6304
6305impl futures::stream::FusedStream for LinuxManagerRequestStream {
6306    fn is_terminated(&self) -> bool {
6307        self.is_terminated
6308    }
6309}
6310
6311impl fidl::endpoints::RequestStream for LinuxManagerRequestStream {
6312    type Protocol = LinuxManagerMarker;
6313    type ControlHandle = LinuxManagerControlHandle;
6314
6315    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6316        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6317    }
6318
6319    fn control_handle(&self) -> Self::ControlHandle {
6320        LinuxManagerControlHandle { inner: self.inner.clone() }
6321    }
6322
6323    fn into_inner(
6324        self,
6325    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6326    {
6327        (self.inner, self.is_terminated)
6328    }
6329
6330    fn from_inner(
6331        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6332        is_terminated: bool,
6333    ) -> Self {
6334        Self { inner, is_terminated }
6335    }
6336}
6337
6338impl futures::Stream for LinuxManagerRequestStream {
6339    type Item = Result<LinuxManagerRequest, fidl::Error>;
6340
6341    fn poll_next(
6342        mut self: std::pin::Pin<&mut Self>,
6343        cx: &mut std::task::Context<'_>,
6344    ) -> std::task::Poll<Option<Self::Item>> {
6345        let this = &mut *self;
6346        if this.inner.check_shutdown(cx) {
6347            this.is_terminated = true;
6348            return std::task::Poll::Ready(None);
6349        }
6350        if this.is_terminated {
6351            panic!("polled LinuxManagerRequestStream after completion");
6352        }
6353        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6354            |bytes, handles| {
6355                match this.inner.channel().read_etc(cx, bytes, handles) {
6356                    std::task::Poll::Ready(Ok(())) => {}
6357                    std::task::Poll::Pending => return std::task::Poll::Pending,
6358                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6359                        this.is_terminated = true;
6360                        return std::task::Poll::Ready(None);
6361                    }
6362                    std::task::Poll::Ready(Err(e)) => {
6363                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6364                            e.into(),
6365                        ))))
6366                    }
6367                }
6368
6369                // A message has been received from the channel
6370                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6371
6372                std::task::Poll::Ready(Some(match header.ordinal {
6373                    0x11809ced100a2bea => {
6374                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6375                        let mut req = fidl::new_empty!(
6376                            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6377                            fidl::encoding::DefaultFuchsiaResourceDialect
6378                        );
6379                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerStartAndGetLinuxGuestInfoRequest>(&header, _body_bytes, handles, &mut req)?;
6380                        let control_handle =
6381                            LinuxManagerControlHandle { inner: this.inner.clone() };
6382                        Ok(LinuxManagerRequest::StartAndGetLinuxGuestInfo {
6383                            label: req.label,
6384
6385                            responder: LinuxManagerStartAndGetLinuxGuestInfoResponder {
6386                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6387                                tx_id: header.tx_id,
6388                            },
6389                        })
6390                    }
6391                    0x732c69394548a76a => {
6392                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6393                        let mut req = fidl::new_empty!(
6394                            fidl::encoding::EmptyPayload,
6395                            fidl::encoding::DefaultFuchsiaResourceDialect
6396                        );
6397                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6398                        let control_handle =
6399                            LinuxManagerControlHandle { inner: this.inner.clone() };
6400                        Ok(LinuxManagerRequest::WipeData {
6401                            responder: LinuxManagerWipeDataResponder {
6402                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6403                                tx_id: header.tx_id,
6404                            },
6405                        })
6406                    }
6407                    0x5dab12b50bc9909d => {
6408                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6409                        let mut req = fidl::new_empty!(
6410                            fidl::encoding::EmptyPayload,
6411                            fidl::encoding::DefaultFuchsiaResourceDialect
6412                        );
6413                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6414                        let control_handle =
6415                            LinuxManagerControlHandle { inner: this.inner.clone() };
6416                        Ok(LinuxManagerRequest::GracefulShutdown { control_handle })
6417                    }
6418                    _ => Err(fidl::Error::UnknownOrdinal {
6419                        ordinal: header.ordinal,
6420                        protocol_name:
6421                            <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6422                    }),
6423                }))
6424            },
6425        )
6426    }
6427}
6428
6429/// A `LinuxManager` provides access to the status of Linux guest instances.
6430#[derive(Debug)]
6431pub enum LinuxManagerRequest {
6432    /// Get Linux guest environment info.
6433    ///
6434    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6435    StartAndGetLinuxGuestInfo {
6436        label: String,
6437        responder: LinuxManagerStartAndGetLinuxGuestInfoResponder,
6438    },
6439    /// Clears the stateful data. This includes any installed containers and any user data
6440    /// they may contain.
6441    ///
6442    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6443    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6444    /// operation.
6445    WipeData { responder: LinuxManagerWipeDataResponder },
6446    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6447    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6448    /// the epitaph) before attempting to launch another guest.
6449    ///
6450    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6451    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6452    /// a component crash).
6453    GracefulShutdown { control_handle: LinuxManagerControlHandle },
6454}
6455
6456impl LinuxManagerRequest {
6457    #[allow(irrefutable_let_patterns)]
6458    pub fn into_start_and_get_linux_guest_info(
6459        self,
6460    ) -> Option<(String, LinuxManagerStartAndGetLinuxGuestInfoResponder)> {
6461        if let LinuxManagerRequest::StartAndGetLinuxGuestInfo { label, responder } = self {
6462            Some((label, responder))
6463        } else {
6464            None
6465        }
6466    }
6467
6468    #[allow(irrefutable_let_patterns)]
6469    pub fn into_wipe_data(self) -> Option<(LinuxManagerWipeDataResponder)> {
6470        if let LinuxManagerRequest::WipeData { responder } = self {
6471            Some((responder))
6472        } else {
6473            None
6474        }
6475    }
6476
6477    #[allow(irrefutable_let_patterns)]
6478    pub fn into_graceful_shutdown(self) -> Option<(LinuxManagerControlHandle)> {
6479        if let LinuxManagerRequest::GracefulShutdown { control_handle } = self {
6480            Some((control_handle))
6481        } else {
6482            None
6483        }
6484    }
6485
6486    /// Name of the method defined in FIDL
6487    pub fn method_name(&self) -> &'static str {
6488        match *self {
6489            LinuxManagerRequest::StartAndGetLinuxGuestInfo { .. } => {
6490                "start_and_get_linux_guest_info"
6491            }
6492            LinuxManagerRequest::WipeData { .. } => "wipe_data",
6493            LinuxManagerRequest::GracefulShutdown { .. } => "graceful_shutdown",
6494        }
6495    }
6496}
6497
6498#[derive(Debug, Clone)]
6499pub struct LinuxManagerControlHandle {
6500    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6501}
6502
6503impl fidl::endpoints::ControlHandle for LinuxManagerControlHandle {
6504    fn shutdown(&self) {
6505        self.inner.shutdown()
6506    }
6507    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6508        self.inner.shutdown_with_epitaph(status)
6509    }
6510
6511    fn is_closed(&self) -> bool {
6512        self.inner.channel().is_closed()
6513    }
6514    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6515        self.inner.channel().on_closed()
6516    }
6517
6518    #[cfg(target_os = "fuchsia")]
6519    fn signal_peer(
6520        &self,
6521        clear_mask: zx::Signals,
6522        set_mask: zx::Signals,
6523    ) -> Result<(), zx_status::Status> {
6524        use fidl::Peered;
6525        self.inner.channel().signal_peer(clear_mask, set_mask)
6526    }
6527}
6528
6529impl LinuxManagerControlHandle {
6530    pub fn send_on_guest_info_changed(
6531        &self,
6532        mut label: &str,
6533        mut info: &LinuxGuestInfo,
6534    ) -> Result<(), fidl::Error> {
6535        self.inner.send::<LinuxManagerOnGuestInfoChangedRequest>(
6536            (label, info),
6537            0,
6538            0x30a9be4c43d6a2d6,
6539            fidl::encoding::DynamicFlags::empty(),
6540        )
6541    }
6542}
6543
6544#[must_use = "FIDL methods require a response to be sent"]
6545#[derive(Debug)]
6546pub struct LinuxManagerStartAndGetLinuxGuestInfoResponder {
6547    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6548    tx_id: u32,
6549}
6550
6551/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6552/// if the responder is dropped without sending a response, so that the client
6553/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6554impl std::ops::Drop for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6555    fn drop(&mut self) {
6556        self.control_handle.shutdown();
6557        // Safety: drops once, never accessed again
6558        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6559    }
6560}
6561
6562impl fidl::endpoints::Responder for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6563    type ControlHandle = LinuxManagerControlHandle;
6564
6565    fn control_handle(&self) -> &LinuxManagerControlHandle {
6566        &self.control_handle
6567    }
6568
6569    fn drop_without_shutdown(mut self) {
6570        // Safety: drops once, never accessed again due to mem::forget
6571        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6572        // Prevent Drop from running (which would shut down the channel)
6573        std::mem::forget(self);
6574    }
6575}
6576
6577impl LinuxManagerStartAndGetLinuxGuestInfoResponder {
6578    /// Sends a response to the FIDL transaction.
6579    ///
6580    /// Sets the channel to shutdown if an error occurs.
6581    pub fn send(self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6582        let _result = self.send_raw(result);
6583        if _result.is_err() {
6584            self.control_handle.shutdown();
6585        }
6586        self.drop_without_shutdown();
6587        _result
6588    }
6589
6590    /// Similar to "send" but does not shutdown the channel if an error occurs.
6591    pub fn send_no_shutdown_on_err(
6592        self,
6593        mut result: Result<&LinuxGuestInfo, i32>,
6594    ) -> Result<(), fidl::Error> {
6595        let _result = self.send_raw(result);
6596        self.drop_without_shutdown();
6597        _result
6598    }
6599
6600    fn send_raw(&self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6601        self.control_handle.inner.send::<fidl::encoding::ResultType<
6602            LinuxManagerStartAndGetLinuxGuestInfoResponse,
6603            i32,
6604        >>(
6605            result.map(|info| (info,)),
6606            self.tx_id,
6607            0x11809ced100a2bea,
6608            fidl::encoding::DynamicFlags::empty(),
6609        )
6610    }
6611}
6612
6613#[must_use = "FIDL methods require a response to be sent"]
6614#[derive(Debug)]
6615pub struct LinuxManagerWipeDataResponder {
6616    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6617    tx_id: u32,
6618}
6619
6620/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6621/// if the responder is dropped without sending a response, so that the client
6622/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6623impl std::ops::Drop for LinuxManagerWipeDataResponder {
6624    fn drop(&mut self) {
6625        self.control_handle.shutdown();
6626        // Safety: drops once, never accessed again
6627        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6628    }
6629}
6630
6631impl fidl::endpoints::Responder for LinuxManagerWipeDataResponder {
6632    type ControlHandle = LinuxManagerControlHandle;
6633
6634    fn control_handle(&self) -> &LinuxManagerControlHandle {
6635        &self.control_handle
6636    }
6637
6638    fn drop_without_shutdown(mut self) {
6639        // Safety: drops once, never accessed again due to mem::forget
6640        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6641        // Prevent Drop from running (which would shut down the channel)
6642        std::mem::forget(self);
6643    }
6644}
6645
6646impl LinuxManagerWipeDataResponder {
6647    /// Sends a response to the FIDL transaction.
6648    ///
6649    /// Sets the channel to shutdown if an error occurs.
6650    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6651        let _result = self.send_raw(result);
6652        if _result.is_err() {
6653            self.control_handle.shutdown();
6654        }
6655        self.drop_without_shutdown();
6656        _result
6657    }
6658
6659    /// Similar to "send" but does not shutdown the channel if an error occurs.
6660    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6661        let _result = self.send_raw(result);
6662        self.drop_without_shutdown();
6663        _result
6664    }
6665
6666    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6667        self.control_handle
6668            .inner
6669            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6670                result,
6671                self.tx_id,
6672                0x732c69394548a76a,
6673                fidl::encoding::DynamicFlags::empty(),
6674            )
6675    }
6676}
6677
6678#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6679pub struct MemControllerMarker;
6680
6681impl fidl::endpoints::ProtocolMarker for MemControllerMarker {
6682    type Proxy = MemControllerProxy;
6683    type RequestStream = MemControllerRequestStream;
6684    #[cfg(target_os = "fuchsia")]
6685    type SynchronousProxy = MemControllerSynchronousProxy;
6686
6687    const DEBUG_NAME: &'static str = "fuchsia.virtualization.MemController";
6688}
6689impl fidl::endpoints::DiscoverableProtocolMarker for MemControllerMarker {}
6690
6691pub trait MemControllerProxyInterface: Send + Sync {
6692    type GetMemSizeResponseFut: std::future::Future<Output = Result<(u64, u64, u64, u64, u64), fidl::Error>>
6693        + Send;
6694    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut;
6695    fn r#request_size(&self, requested_size: u64) -> Result<(), fidl::Error>;
6696}
6697#[derive(Debug)]
6698#[cfg(target_os = "fuchsia")]
6699pub struct MemControllerSynchronousProxy {
6700    client: fidl::client::sync::Client,
6701}
6702
6703#[cfg(target_os = "fuchsia")]
6704impl fidl::endpoints::SynchronousProxy for MemControllerSynchronousProxy {
6705    type Proxy = MemControllerProxy;
6706    type Protocol = MemControllerMarker;
6707
6708    fn from_channel(inner: fidl::Channel) -> Self {
6709        Self::new(inner)
6710    }
6711
6712    fn into_channel(self) -> fidl::Channel {
6713        self.client.into_channel()
6714    }
6715
6716    fn as_channel(&self) -> &fidl::Channel {
6717        self.client.as_channel()
6718    }
6719}
6720
6721#[cfg(target_os = "fuchsia")]
6722impl MemControllerSynchronousProxy {
6723    pub fn new(channel: fidl::Channel) -> Self {
6724        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6725        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6726    }
6727
6728    pub fn into_channel(self) -> fidl::Channel {
6729        self.client.into_channel()
6730    }
6731
6732    /// Waits until an event arrives and returns it. It is safe for other
6733    /// threads to make concurrent requests while waiting for an event.
6734    pub fn wait_for_event(
6735        &self,
6736        deadline: zx::MonotonicInstant,
6737    ) -> Result<MemControllerEvent, fidl::Error> {
6738        MemControllerEvent::decode(self.client.wait_for_event(deadline)?)
6739    }
6740
6741    /// Get the configured region size, usable region size, plugged size and requestd size
6742    ///
6743    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6744    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6745    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6746    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6747    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6748    /// memory region.
6749    /// requested_size is the requested amount of plugged memory within the usable device-managed
6750    /// memory region.
6751    pub fn r#get_mem_size(
6752        &self,
6753        ___deadline: zx::MonotonicInstant,
6754    ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6755        let _response = self
6756            .client
6757            .send_query::<fidl::encoding::EmptyPayload, MemControllerGetMemSizeResponse>(
6758                (),
6759                0x6e9d496f9b66ea56,
6760                fidl::encoding::DynamicFlags::empty(),
6761                ___deadline,
6762            )?;
6763        Ok((
6764            _response.block_size,
6765            _response.region_size,
6766            _response.usable_region_size,
6767            _response.plugged_size,
6768            _response.requested_size,
6769        ))
6770    }
6771
6772    /// Update the requested size to plug or unplug memory
6773    ///
6774    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6775    /// configuration changed) by (un)plugging memory blocks.
6776    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6777        self.client.send::<MemControllerRequestSizeRequest>(
6778            (requested_size,),
6779            0x12f8e2cc21ee8102,
6780            fidl::encoding::DynamicFlags::empty(),
6781        )
6782    }
6783}
6784
6785#[cfg(target_os = "fuchsia")]
6786impl From<MemControllerSynchronousProxy> for zx::Handle {
6787    fn from(value: MemControllerSynchronousProxy) -> Self {
6788        value.into_channel().into()
6789    }
6790}
6791
6792#[cfg(target_os = "fuchsia")]
6793impl From<fidl::Channel> for MemControllerSynchronousProxy {
6794    fn from(value: fidl::Channel) -> Self {
6795        Self::new(value)
6796    }
6797}
6798
6799#[derive(Debug, Clone)]
6800pub struct MemControllerProxy {
6801    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6802}
6803
6804impl fidl::endpoints::Proxy for MemControllerProxy {
6805    type Protocol = MemControllerMarker;
6806
6807    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6808        Self::new(inner)
6809    }
6810
6811    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6812        self.client.into_channel().map_err(|client| Self { client })
6813    }
6814
6815    fn as_channel(&self) -> &::fidl::AsyncChannel {
6816        self.client.as_channel()
6817    }
6818}
6819
6820impl MemControllerProxy {
6821    /// Create a new Proxy for fuchsia.virtualization/MemController.
6822    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6823        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6824        Self { client: fidl::client::Client::new(channel, protocol_name) }
6825    }
6826
6827    /// Get a Stream of events from the remote end of the protocol.
6828    ///
6829    /// # Panics
6830    ///
6831    /// Panics if the event stream was already taken.
6832    pub fn take_event_stream(&self) -> MemControllerEventStream {
6833        MemControllerEventStream { event_receiver: self.client.take_event_receiver() }
6834    }
6835
6836    /// Get the configured region size, usable region size, plugged size and requestd size
6837    ///
6838    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6839    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6840    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6841    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6842    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6843    /// memory region.
6844    /// requested_size is the requested amount of plugged memory within the usable device-managed
6845    /// memory region.
6846    pub fn r#get_mem_size(
6847        &self,
6848    ) -> fidl::client::QueryResponseFut<
6849        (u64, u64, u64, u64, u64),
6850        fidl::encoding::DefaultFuchsiaResourceDialect,
6851    > {
6852        MemControllerProxyInterface::r#get_mem_size(self)
6853    }
6854
6855    /// Update the requested size to plug or unplug memory
6856    ///
6857    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6858    /// configuration changed) by (un)plugging memory blocks.
6859    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6860        MemControllerProxyInterface::r#request_size(self, requested_size)
6861    }
6862}
6863
6864impl MemControllerProxyInterface for MemControllerProxy {
6865    type GetMemSizeResponseFut = fidl::client::QueryResponseFut<
6866        (u64, u64, u64, u64, u64),
6867        fidl::encoding::DefaultFuchsiaResourceDialect,
6868    >;
6869    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut {
6870        fn _decode(
6871            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6872        ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6873            let _response = fidl::client::decode_transaction_body::<
6874                MemControllerGetMemSizeResponse,
6875                fidl::encoding::DefaultFuchsiaResourceDialect,
6876                0x6e9d496f9b66ea56,
6877            >(_buf?)?;
6878            Ok((
6879                _response.block_size,
6880                _response.region_size,
6881                _response.usable_region_size,
6882                _response.plugged_size,
6883                _response.requested_size,
6884            ))
6885        }
6886        self.client
6887            .send_query_and_decode::<fidl::encoding::EmptyPayload, (u64, u64, u64, u64, u64)>(
6888                (),
6889                0x6e9d496f9b66ea56,
6890                fidl::encoding::DynamicFlags::empty(),
6891                _decode,
6892            )
6893    }
6894
6895    fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6896        self.client.send::<MemControllerRequestSizeRequest>(
6897            (requested_size,),
6898            0x12f8e2cc21ee8102,
6899            fidl::encoding::DynamicFlags::empty(),
6900        )
6901    }
6902}
6903
6904pub struct MemControllerEventStream {
6905    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6906}
6907
6908impl std::marker::Unpin for MemControllerEventStream {}
6909
6910impl futures::stream::FusedStream for MemControllerEventStream {
6911    fn is_terminated(&self) -> bool {
6912        self.event_receiver.is_terminated()
6913    }
6914}
6915
6916impl futures::Stream for MemControllerEventStream {
6917    type Item = Result<MemControllerEvent, fidl::Error>;
6918
6919    fn poll_next(
6920        mut self: std::pin::Pin<&mut Self>,
6921        cx: &mut std::task::Context<'_>,
6922    ) -> std::task::Poll<Option<Self::Item>> {
6923        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6924            &mut self.event_receiver,
6925            cx
6926        )?) {
6927            Some(buf) => std::task::Poll::Ready(Some(MemControllerEvent::decode(buf))),
6928            None => std::task::Poll::Ready(None),
6929        }
6930    }
6931}
6932
6933#[derive(Debug)]
6934pub enum MemControllerEvent {}
6935
6936impl MemControllerEvent {
6937    /// Decodes a message buffer as a [`MemControllerEvent`].
6938    fn decode(
6939        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6940    ) -> Result<MemControllerEvent, fidl::Error> {
6941        let (bytes, _handles) = buf.split_mut();
6942        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6943        debug_assert_eq!(tx_header.tx_id, 0);
6944        match tx_header.ordinal {
6945            _ => Err(fidl::Error::UnknownOrdinal {
6946                ordinal: tx_header.ordinal,
6947                protocol_name: <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6948            }),
6949        }
6950    }
6951}
6952
6953/// A Stream of incoming requests for fuchsia.virtualization/MemController.
6954pub struct MemControllerRequestStream {
6955    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6956    is_terminated: bool,
6957}
6958
6959impl std::marker::Unpin for MemControllerRequestStream {}
6960
6961impl futures::stream::FusedStream for MemControllerRequestStream {
6962    fn is_terminated(&self) -> bool {
6963        self.is_terminated
6964    }
6965}
6966
6967impl fidl::endpoints::RequestStream for MemControllerRequestStream {
6968    type Protocol = MemControllerMarker;
6969    type ControlHandle = MemControllerControlHandle;
6970
6971    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6972        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6973    }
6974
6975    fn control_handle(&self) -> Self::ControlHandle {
6976        MemControllerControlHandle { inner: self.inner.clone() }
6977    }
6978
6979    fn into_inner(
6980        self,
6981    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6982    {
6983        (self.inner, self.is_terminated)
6984    }
6985
6986    fn from_inner(
6987        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6988        is_terminated: bool,
6989    ) -> Self {
6990        Self { inner, is_terminated }
6991    }
6992}
6993
6994impl futures::Stream for MemControllerRequestStream {
6995    type Item = Result<MemControllerRequest, fidl::Error>;
6996
6997    fn poll_next(
6998        mut self: std::pin::Pin<&mut Self>,
6999        cx: &mut std::task::Context<'_>,
7000    ) -> std::task::Poll<Option<Self::Item>> {
7001        let this = &mut *self;
7002        if this.inner.check_shutdown(cx) {
7003            this.is_terminated = true;
7004            return std::task::Poll::Ready(None);
7005        }
7006        if this.is_terminated {
7007            panic!("polled MemControllerRequestStream after completion");
7008        }
7009        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7010            |bytes, handles| {
7011                match this.inner.channel().read_etc(cx, bytes, handles) {
7012                    std::task::Poll::Ready(Ok(())) => {}
7013                    std::task::Poll::Pending => return std::task::Poll::Pending,
7014                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7015                        this.is_terminated = true;
7016                        return std::task::Poll::Ready(None);
7017                    }
7018                    std::task::Poll::Ready(Err(e)) => {
7019                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7020                            e.into(),
7021                        ))))
7022                    }
7023                }
7024
7025                // A message has been received from the channel
7026                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7027
7028                std::task::Poll::Ready(Some(match header.ordinal {
7029                    0x6e9d496f9b66ea56 => {
7030                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7031                        let mut req = fidl::new_empty!(
7032                            fidl::encoding::EmptyPayload,
7033                            fidl::encoding::DefaultFuchsiaResourceDialect
7034                        );
7035                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7036                        let control_handle =
7037                            MemControllerControlHandle { inner: this.inner.clone() };
7038                        Ok(MemControllerRequest::GetMemSize {
7039                            responder: MemControllerGetMemSizeResponder {
7040                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7041                                tx_id: header.tx_id,
7042                            },
7043                        })
7044                    }
7045                    0x12f8e2cc21ee8102 => {
7046                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7047                        let mut req = fidl::new_empty!(
7048                            MemControllerRequestSizeRequest,
7049                            fidl::encoding::DefaultFuchsiaResourceDialect
7050                        );
7051                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MemControllerRequestSizeRequest>(&header, _body_bytes, handles, &mut req)?;
7052                        let control_handle =
7053                            MemControllerControlHandle { inner: this.inner.clone() };
7054                        Ok(MemControllerRequest::RequestSize {
7055                            requested_size: req.requested_size,
7056
7057                            control_handle,
7058                        })
7059                    }
7060                    _ => Err(fidl::Error::UnknownOrdinal {
7061                        ordinal: header.ordinal,
7062                        protocol_name:
7063                            <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7064                    }),
7065                }))
7066            },
7067        )
7068    }
7069}
7070
7071/// A `MemController` controls a guest's virtio-mem
7072#[derive(Debug)]
7073pub enum MemControllerRequest {
7074    /// Get the configured region size, usable region size, plugged size and requestd size
7075    ///
7076    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
7077    /// region_size is the size of device-managed memory region in bytes. Cannot change.
7078    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
7079    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
7080    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
7081    /// memory region.
7082    /// requested_size is the requested amount of plugged memory within the usable device-managed
7083    /// memory region.
7084    GetMemSize { responder: MemControllerGetMemSizeResponder },
7085    /// Update the requested size to plug or unplug memory
7086    ///
7087    /// The driver SHOULD react to resize requests from the device (requested_size in the device
7088    /// configuration changed) by (un)plugging memory blocks.
7089    RequestSize { requested_size: u64, control_handle: MemControllerControlHandle },
7090}
7091
7092impl MemControllerRequest {
7093    #[allow(irrefutable_let_patterns)]
7094    pub fn into_get_mem_size(self) -> Option<(MemControllerGetMemSizeResponder)> {
7095        if let MemControllerRequest::GetMemSize { responder } = self {
7096            Some((responder))
7097        } else {
7098            None
7099        }
7100    }
7101
7102    #[allow(irrefutable_let_patterns)]
7103    pub fn into_request_size(self) -> Option<(u64, MemControllerControlHandle)> {
7104        if let MemControllerRequest::RequestSize { requested_size, control_handle } = self {
7105            Some((requested_size, control_handle))
7106        } else {
7107            None
7108        }
7109    }
7110
7111    /// Name of the method defined in FIDL
7112    pub fn method_name(&self) -> &'static str {
7113        match *self {
7114            MemControllerRequest::GetMemSize { .. } => "get_mem_size",
7115            MemControllerRequest::RequestSize { .. } => "request_size",
7116        }
7117    }
7118}
7119
7120#[derive(Debug, Clone)]
7121pub struct MemControllerControlHandle {
7122    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7123}
7124
7125impl fidl::endpoints::ControlHandle for MemControllerControlHandle {
7126    fn shutdown(&self) {
7127        self.inner.shutdown()
7128    }
7129    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7130        self.inner.shutdown_with_epitaph(status)
7131    }
7132
7133    fn is_closed(&self) -> bool {
7134        self.inner.channel().is_closed()
7135    }
7136    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7137        self.inner.channel().on_closed()
7138    }
7139
7140    #[cfg(target_os = "fuchsia")]
7141    fn signal_peer(
7142        &self,
7143        clear_mask: zx::Signals,
7144        set_mask: zx::Signals,
7145    ) -> Result<(), zx_status::Status> {
7146        use fidl::Peered;
7147        self.inner.channel().signal_peer(clear_mask, set_mask)
7148    }
7149}
7150
7151impl MemControllerControlHandle {}
7152
7153#[must_use = "FIDL methods require a response to be sent"]
7154#[derive(Debug)]
7155pub struct MemControllerGetMemSizeResponder {
7156    control_handle: std::mem::ManuallyDrop<MemControllerControlHandle>,
7157    tx_id: u32,
7158}
7159
7160/// Set the the channel to be shutdown (see [`MemControllerControlHandle::shutdown`])
7161/// if the responder is dropped without sending a response, so that the client
7162/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7163impl std::ops::Drop for MemControllerGetMemSizeResponder {
7164    fn drop(&mut self) {
7165        self.control_handle.shutdown();
7166        // Safety: drops once, never accessed again
7167        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7168    }
7169}
7170
7171impl fidl::endpoints::Responder for MemControllerGetMemSizeResponder {
7172    type ControlHandle = MemControllerControlHandle;
7173
7174    fn control_handle(&self) -> &MemControllerControlHandle {
7175        &self.control_handle
7176    }
7177
7178    fn drop_without_shutdown(mut self) {
7179        // Safety: drops once, never accessed again due to mem::forget
7180        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7181        // Prevent Drop from running (which would shut down the channel)
7182        std::mem::forget(self);
7183    }
7184}
7185
7186impl MemControllerGetMemSizeResponder {
7187    /// Sends a response to the FIDL transaction.
7188    ///
7189    /// Sets the channel to shutdown if an error occurs.
7190    pub fn send(
7191        self,
7192        mut block_size: u64,
7193        mut region_size: u64,
7194        mut usable_region_size: u64,
7195        mut plugged_size: u64,
7196        mut requested_size: u64,
7197    ) -> Result<(), fidl::Error> {
7198        let _result = self.send_raw(
7199            block_size,
7200            region_size,
7201            usable_region_size,
7202            plugged_size,
7203            requested_size,
7204        );
7205        if _result.is_err() {
7206            self.control_handle.shutdown();
7207        }
7208        self.drop_without_shutdown();
7209        _result
7210    }
7211
7212    /// Similar to "send" but does not shutdown the channel if an error occurs.
7213    pub fn send_no_shutdown_on_err(
7214        self,
7215        mut block_size: u64,
7216        mut region_size: u64,
7217        mut usable_region_size: u64,
7218        mut plugged_size: u64,
7219        mut requested_size: u64,
7220    ) -> Result<(), fidl::Error> {
7221        let _result = self.send_raw(
7222            block_size,
7223            region_size,
7224            usable_region_size,
7225            plugged_size,
7226            requested_size,
7227        );
7228        self.drop_without_shutdown();
7229        _result
7230    }
7231
7232    fn send_raw(
7233        &self,
7234        mut block_size: u64,
7235        mut region_size: u64,
7236        mut usable_region_size: u64,
7237        mut plugged_size: u64,
7238        mut requested_size: u64,
7239    ) -> Result<(), fidl::Error> {
7240        self.control_handle.inner.send::<MemControllerGetMemSizeResponse>(
7241            (block_size, region_size, usable_region_size, plugged_size, requested_size),
7242            self.tx_id,
7243            0x6e9d496f9b66ea56,
7244            fidl::encoding::DynamicFlags::empty(),
7245        )
7246    }
7247}
7248
7249#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7250pub struct TerminaGuestManagerMarker;
7251
7252impl fidl::endpoints::ProtocolMarker for TerminaGuestManagerMarker {
7253    type Proxy = TerminaGuestManagerProxy;
7254    type RequestStream = TerminaGuestManagerRequestStream;
7255    #[cfg(target_os = "fuchsia")]
7256    type SynchronousProxy = TerminaGuestManagerSynchronousProxy;
7257
7258    const DEBUG_NAME: &'static str = "fuchsia.virtualization.TerminaGuestManager";
7259}
7260impl fidl::endpoints::DiscoverableProtocolMarker for TerminaGuestManagerMarker {}
7261
7262pub trait TerminaGuestManagerProxyInterface: Send + Sync {
7263    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
7264        + Send;
7265    fn r#launch(
7266        &self,
7267        guest_config: GuestConfig,
7268        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7269    ) -> Self::LaunchResponseFut;
7270    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7271    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
7272    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
7273        + Send;
7274    fn r#connect(
7275        &self,
7276        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7277    ) -> Self::ConnectResponseFut;
7278    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
7279    fn r#get_info(&self) -> Self::GetInfoResponseFut;
7280}
7281#[derive(Debug)]
7282#[cfg(target_os = "fuchsia")]
7283pub struct TerminaGuestManagerSynchronousProxy {
7284    client: fidl::client::sync::Client,
7285}
7286
7287#[cfg(target_os = "fuchsia")]
7288impl fidl::endpoints::SynchronousProxy for TerminaGuestManagerSynchronousProxy {
7289    type Proxy = TerminaGuestManagerProxy;
7290    type Protocol = TerminaGuestManagerMarker;
7291
7292    fn from_channel(inner: fidl::Channel) -> Self {
7293        Self::new(inner)
7294    }
7295
7296    fn into_channel(self) -> fidl::Channel {
7297        self.client.into_channel()
7298    }
7299
7300    fn as_channel(&self) -> &fidl::Channel {
7301        self.client.as_channel()
7302    }
7303}
7304
7305#[cfg(target_os = "fuchsia")]
7306impl TerminaGuestManagerSynchronousProxy {
7307    pub fn new(channel: fidl::Channel) -> Self {
7308        let protocol_name =
7309            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7310        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7311    }
7312
7313    pub fn into_channel(self) -> fidl::Channel {
7314        self.client.into_channel()
7315    }
7316
7317    /// Waits until an event arrives and returns it. It is safe for other
7318    /// threads to make concurrent requests while waiting for an event.
7319    pub fn wait_for_event(
7320        &self,
7321        deadline: zx::MonotonicInstant,
7322    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7323        TerminaGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
7324    }
7325
7326    /// Launch a new guest instance.
7327    ///
7328    /// Possible errors:
7329    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7330    ///         problems detected by the guest manager.
7331    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7332    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7333    ///         component logs for a more specific failure.
7334    pub fn r#launch(
7335        &self,
7336        mut guest_config: GuestConfig,
7337        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7338        ___deadline: zx::MonotonicInstant,
7339    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7340        let _response =
7341            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
7342                fidl::encoding::EmptyStruct,
7343                GuestManagerError,
7344            >>(
7345                (&mut guest_config, controller),
7346                0x394a2e29f750323e,
7347                fidl::encoding::DynamicFlags::empty(),
7348                ___deadline,
7349            )?;
7350        Ok(_response.map(|x| x))
7351    }
7352
7353    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7354    /// be used to launch another guest.
7355    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
7356        let _response =
7357            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
7358                (),
7359                0x3ad9a012982f872d,
7360                fidl::encoding::DynamicFlags::empty(),
7361                ___deadline,
7362            )?;
7363        Ok(_response)
7364    }
7365
7366    /// Connect to a currently running guest.
7367    ///
7368    /// Possible errors:
7369    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7370    ///         has launched before attempting to reconnect.
7371    pub fn r#connect(
7372        &self,
7373        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7374        ___deadline: zx::MonotonicInstant,
7375    ) -> Result<GuestManagerConnectResult, fidl::Error> {
7376        let _response =
7377            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
7378                fidl::encoding::EmptyStruct,
7379                GuestManagerError,
7380            >>(
7381                (controller,),
7382                0x4e489076e3bb15b4,
7383                fidl::encoding::DynamicFlags::empty(),
7384                ___deadline,
7385            )?;
7386        Ok(_response.map(|x| x))
7387    }
7388
7389    /// Query guest info
7390    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
7391        let _response =
7392            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
7393                (),
7394                0x76892614aea695dc,
7395                fidl::encoding::DynamicFlags::empty(),
7396                ___deadline,
7397            )?;
7398        Ok(_response.guest_info)
7399    }
7400}
7401
7402#[cfg(target_os = "fuchsia")]
7403impl From<TerminaGuestManagerSynchronousProxy> for zx::Handle {
7404    fn from(value: TerminaGuestManagerSynchronousProxy) -> Self {
7405        value.into_channel().into()
7406    }
7407}
7408
7409#[cfg(target_os = "fuchsia")]
7410impl From<fidl::Channel> for TerminaGuestManagerSynchronousProxy {
7411    fn from(value: fidl::Channel) -> Self {
7412        Self::new(value)
7413    }
7414}
7415
7416#[derive(Debug, Clone)]
7417pub struct TerminaGuestManagerProxy {
7418    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7419}
7420
7421impl fidl::endpoints::Proxy for TerminaGuestManagerProxy {
7422    type Protocol = TerminaGuestManagerMarker;
7423
7424    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7425        Self::new(inner)
7426    }
7427
7428    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7429        self.client.into_channel().map_err(|client| Self { client })
7430    }
7431
7432    fn as_channel(&self) -> &::fidl::AsyncChannel {
7433        self.client.as_channel()
7434    }
7435}
7436
7437impl TerminaGuestManagerProxy {
7438    /// Create a new Proxy for fuchsia.virtualization/TerminaGuestManager.
7439    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7440        let protocol_name =
7441            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7442        Self { client: fidl::client::Client::new(channel, protocol_name) }
7443    }
7444
7445    /// Get a Stream of events from the remote end of the protocol.
7446    ///
7447    /// # Panics
7448    ///
7449    /// Panics if the event stream was already taken.
7450    pub fn take_event_stream(&self) -> TerminaGuestManagerEventStream {
7451        TerminaGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
7452    }
7453
7454    /// Launch a new guest instance.
7455    ///
7456    /// Possible errors:
7457    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7458    ///         problems detected by the guest manager.
7459    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7460    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7461    ///         component logs for a more specific failure.
7462    pub fn r#launch(
7463        &self,
7464        mut guest_config: GuestConfig,
7465        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7466    ) -> fidl::client::QueryResponseFut<
7467        GuestManagerLaunchResult,
7468        fidl::encoding::DefaultFuchsiaResourceDialect,
7469    > {
7470        TerminaGuestManagerProxyInterface::r#launch(self, guest_config, controller)
7471    }
7472
7473    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7474    /// be used to launch another guest.
7475    pub fn r#force_shutdown(
7476        &self,
7477    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7478        TerminaGuestManagerProxyInterface::r#force_shutdown(self)
7479    }
7480
7481    /// Connect to a currently running guest.
7482    ///
7483    /// Possible errors:
7484    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7485    ///         has launched before attempting to reconnect.
7486    pub fn r#connect(
7487        &self,
7488        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7489    ) -> fidl::client::QueryResponseFut<
7490        GuestManagerConnectResult,
7491        fidl::encoding::DefaultFuchsiaResourceDialect,
7492    > {
7493        TerminaGuestManagerProxyInterface::r#connect(self, controller)
7494    }
7495
7496    /// Query guest info
7497    pub fn r#get_info(
7498        &self,
7499    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
7500    {
7501        TerminaGuestManagerProxyInterface::r#get_info(self)
7502    }
7503}
7504
7505impl TerminaGuestManagerProxyInterface for TerminaGuestManagerProxy {
7506    type LaunchResponseFut = fidl::client::QueryResponseFut<
7507        GuestManagerLaunchResult,
7508        fidl::encoding::DefaultFuchsiaResourceDialect,
7509    >;
7510    fn r#launch(
7511        &self,
7512        mut guest_config: GuestConfig,
7513        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7514    ) -> Self::LaunchResponseFut {
7515        fn _decode(
7516            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7517        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7518            let _response = fidl::client::decode_transaction_body::<
7519                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7520                fidl::encoding::DefaultFuchsiaResourceDialect,
7521                0x394a2e29f750323e,
7522            >(_buf?)?;
7523            Ok(_response.map(|x| x))
7524        }
7525        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
7526            (&mut guest_config, controller),
7527            0x394a2e29f750323e,
7528            fidl::encoding::DynamicFlags::empty(),
7529            _decode,
7530        )
7531    }
7532
7533    type ForceShutdownResponseFut =
7534        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7535    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
7536        fn _decode(
7537            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7538        ) -> Result<(), fidl::Error> {
7539            let _response = fidl::client::decode_transaction_body::<
7540                fidl::encoding::EmptyPayload,
7541                fidl::encoding::DefaultFuchsiaResourceDialect,
7542                0x3ad9a012982f872d,
7543            >(_buf?)?;
7544            Ok(_response)
7545        }
7546        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7547            (),
7548            0x3ad9a012982f872d,
7549            fidl::encoding::DynamicFlags::empty(),
7550            _decode,
7551        )
7552    }
7553
7554    type ConnectResponseFut = fidl::client::QueryResponseFut<
7555        GuestManagerConnectResult,
7556        fidl::encoding::DefaultFuchsiaResourceDialect,
7557    >;
7558    fn r#connect(
7559        &self,
7560        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7561    ) -> Self::ConnectResponseFut {
7562        fn _decode(
7563            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7564        ) -> Result<GuestManagerConnectResult, fidl::Error> {
7565            let _response = fidl::client::decode_transaction_body::<
7566                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7567                fidl::encoding::DefaultFuchsiaResourceDialect,
7568                0x4e489076e3bb15b4,
7569            >(_buf?)?;
7570            Ok(_response.map(|x| x))
7571        }
7572        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
7573            (controller,),
7574            0x4e489076e3bb15b4,
7575            fidl::encoding::DynamicFlags::empty(),
7576            _decode,
7577        )
7578    }
7579
7580    type GetInfoResponseFut =
7581        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
7582    fn r#get_info(&self) -> Self::GetInfoResponseFut {
7583        fn _decode(
7584            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7585        ) -> Result<GuestInfo, fidl::Error> {
7586            let _response = fidl::client::decode_transaction_body::<
7587                GuestManagerGetInfoResponse,
7588                fidl::encoding::DefaultFuchsiaResourceDialect,
7589                0x76892614aea695dc,
7590            >(_buf?)?;
7591            Ok(_response.guest_info)
7592        }
7593        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
7594            (),
7595            0x76892614aea695dc,
7596            fidl::encoding::DynamicFlags::empty(),
7597            _decode,
7598        )
7599    }
7600}
7601
7602pub struct TerminaGuestManagerEventStream {
7603    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7604}
7605
7606impl std::marker::Unpin for TerminaGuestManagerEventStream {}
7607
7608impl futures::stream::FusedStream for TerminaGuestManagerEventStream {
7609    fn is_terminated(&self) -> bool {
7610        self.event_receiver.is_terminated()
7611    }
7612}
7613
7614impl futures::Stream for TerminaGuestManagerEventStream {
7615    type Item = Result<TerminaGuestManagerEvent, fidl::Error>;
7616
7617    fn poll_next(
7618        mut self: std::pin::Pin<&mut Self>,
7619        cx: &mut std::task::Context<'_>,
7620    ) -> std::task::Poll<Option<Self::Item>> {
7621        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7622            &mut self.event_receiver,
7623            cx
7624        )?) {
7625            Some(buf) => std::task::Poll::Ready(Some(TerminaGuestManagerEvent::decode(buf))),
7626            None => std::task::Poll::Ready(None),
7627        }
7628    }
7629}
7630
7631#[derive(Debug)]
7632pub enum TerminaGuestManagerEvent {}
7633
7634impl TerminaGuestManagerEvent {
7635    /// Decodes a message buffer as a [`TerminaGuestManagerEvent`].
7636    fn decode(
7637        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7638    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7639        let (bytes, _handles) = buf.split_mut();
7640        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7641        debug_assert_eq!(tx_header.tx_id, 0);
7642        match tx_header.ordinal {
7643            _ => Err(fidl::Error::UnknownOrdinal {
7644                ordinal: tx_header.ordinal,
7645                protocol_name:
7646                    <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7647            }),
7648        }
7649    }
7650}
7651
7652/// A Stream of incoming requests for fuchsia.virtualization/TerminaGuestManager.
7653pub struct TerminaGuestManagerRequestStream {
7654    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7655    is_terminated: bool,
7656}
7657
7658impl std::marker::Unpin for TerminaGuestManagerRequestStream {}
7659
7660impl futures::stream::FusedStream for TerminaGuestManagerRequestStream {
7661    fn is_terminated(&self) -> bool {
7662        self.is_terminated
7663    }
7664}
7665
7666impl fidl::endpoints::RequestStream for TerminaGuestManagerRequestStream {
7667    type Protocol = TerminaGuestManagerMarker;
7668    type ControlHandle = TerminaGuestManagerControlHandle;
7669
7670    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7671        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7672    }
7673
7674    fn control_handle(&self) -> Self::ControlHandle {
7675        TerminaGuestManagerControlHandle { inner: self.inner.clone() }
7676    }
7677
7678    fn into_inner(
7679        self,
7680    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7681    {
7682        (self.inner, self.is_terminated)
7683    }
7684
7685    fn from_inner(
7686        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7687        is_terminated: bool,
7688    ) -> Self {
7689        Self { inner, is_terminated }
7690    }
7691}
7692
7693impl futures::Stream for TerminaGuestManagerRequestStream {
7694    type Item = Result<TerminaGuestManagerRequest, fidl::Error>;
7695
7696    fn poll_next(
7697        mut self: std::pin::Pin<&mut Self>,
7698        cx: &mut std::task::Context<'_>,
7699    ) -> std::task::Poll<Option<Self::Item>> {
7700        let this = &mut *self;
7701        if this.inner.check_shutdown(cx) {
7702            this.is_terminated = true;
7703            return std::task::Poll::Ready(None);
7704        }
7705        if this.is_terminated {
7706            panic!("polled TerminaGuestManagerRequestStream after completion");
7707        }
7708        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7709            |bytes, handles| {
7710                match this.inner.channel().read_etc(cx, bytes, handles) {
7711                    std::task::Poll::Ready(Ok(())) => {}
7712                    std::task::Poll::Pending => return std::task::Poll::Pending,
7713                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7714                        this.is_terminated = true;
7715                        return std::task::Poll::Ready(None);
7716                    }
7717                    std::task::Poll::Ready(Err(e)) => {
7718                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7719                            e.into(),
7720                        ))))
7721                    }
7722                }
7723
7724                // A message has been received from the channel
7725                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7726
7727                std::task::Poll::Ready(Some(match header.ordinal {
7728                0x394a2e29f750323e => {
7729                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7730                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7731                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
7732                    let control_handle = TerminaGuestManagerControlHandle {
7733                        inner: this.inner.clone(),
7734                    };
7735                    Ok(TerminaGuestManagerRequest::Launch {guest_config: req.guest_config,
7736controller: req.controller,
7737
7738                        responder: TerminaGuestManagerLaunchResponder {
7739                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7740                            tx_id: header.tx_id,
7741                        },
7742                    })
7743                }
7744                0x3ad9a012982f872d => {
7745                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7746                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7747                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7748                    let control_handle = TerminaGuestManagerControlHandle {
7749                        inner: this.inner.clone(),
7750                    };
7751                    Ok(TerminaGuestManagerRequest::ForceShutdown {
7752                        responder: TerminaGuestManagerForceShutdownResponder {
7753                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7754                            tx_id: header.tx_id,
7755                        },
7756                    })
7757                }
7758                0x4e489076e3bb15b4 => {
7759                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7760                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7761                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
7762                    let control_handle = TerminaGuestManagerControlHandle {
7763                        inner: this.inner.clone(),
7764                    };
7765                    Ok(TerminaGuestManagerRequest::Connect {controller: req.controller,
7766
7767                        responder: TerminaGuestManagerConnectResponder {
7768                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7769                            tx_id: header.tx_id,
7770                        },
7771                    })
7772                }
7773                0x76892614aea695dc => {
7774                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7775                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7776                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7777                    let control_handle = TerminaGuestManagerControlHandle {
7778                        inner: this.inner.clone(),
7779                    };
7780                    Ok(TerminaGuestManagerRequest::GetInfo {
7781                        responder: TerminaGuestManagerGetInfoResponder {
7782                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7783                            tx_id: header.tx_id,
7784                        },
7785                    })
7786                }
7787                _ => Err(fidl::Error::UnknownOrdinal {
7788                    ordinal: header.ordinal,
7789                    protocol_name: <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7790                }),
7791            }))
7792            },
7793        )
7794    }
7795}
7796
7797#[derive(Debug)]
7798pub enum TerminaGuestManagerRequest {
7799    /// Launch a new guest instance.
7800    ///
7801    /// Possible errors:
7802    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7803    ///         problems detected by the guest manager.
7804    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7805    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7806    ///         component logs for a more specific failure.
7807    Launch {
7808        guest_config: GuestConfig,
7809        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7810        responder: TerminaGuestManagerLaunchResponder,
7811    },
7812    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7813    /// be used to launch another guest.
7814    ForceShutdown { responder: TerminaGuestManagerForceShutdownResponder },
7815    /// Connect to a currently running guest.
7816    ///
7817    /// Possible errors:
7818    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7819    ///         has launched before attempting to reconnect.
7820    Connect {
7821        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7822        responder: TerminaGuestManagerConnectResponder,
7823    },
7824    /// Query guest info
7825    GetInfo { responder: TerminaGuestManagerGetInfoResponder },
7826}
7827
7828impl TerminaGuestManagerRequest {
7829    #[allow(irrefutable_let_patterns)]
7830    pub fn into_launch(
7831        self,
7832    ) -> Option<(
7833        GuestConfig,
7834        fidl::endpoints::ServerEnd<GuestMarker>,
7835        TerminaGuestManagerLaunchResponder,
7836    )> {
7837        if let TerminaGuestManagerRequest::Launch { guest_config, controller, responder } = self {
7838            Some((guest_config, controller, responder))
7839        } else {
7840            None
7841        }
7842    }
7843
7844    #[allow(irrefutable_let_patterns)]
7845    pub fn into_force_shutdown(self) -> Option<(TerminaGuestManagerForceShutdownResponder)> {
7846        if let TerminaGuestManagerRequest::ForceShutdown { responder } = self {
7847            Some((responder))
7848        } else {
7849            None
7850        }
7851    }
7852
7853    #[allow(irrefutable_let_patterns)]
7854    pub fn into_connect(
7855        self,
7856    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, TerminaGuestManagerConnectResponder)>
7857    {
7858        if let TerminaGuestManagerRequest::Connect { controller, responder } = self {
7859            Some((controller, responder))
7860        } else {
7861            None
7862        }
7863    }
7864
7865    #[allow(irrefutable_let_patterns)]
7866    pub fn into_get_info(self) -> Option<(TerminaGuestManagerGetInfoResponder)> {
7867        if let TerminaGuestManagerRequest::GetInfo { responder } = self {
7868            Some((responder))
7869        } else {
7870            None
7871        }
7872    }
7873
7874    /// Name of the method defined in FIDL
7875    pub fn method_name(&self) -> &'static str {
7876        match *self {
7877            TerminaGuestManagerRequest::Launch { .. } => "launch",
7878            TerminaGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
7879            TerminaGuestManagerRequest::Connect { .. } => "connect",
7880            TerminaGuestManagerRequest::GetInfo { .. } => "get_info",
7881        }
7882    }
7883}
7884
7885#[derive(Debug, Clone)]
7886pub struct TerminaGuestManagerControlHandle {
7887    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7888}
7889
7890impl fidl::endpoints::ControlHandle for TerminaGuestManagerControlHandle {
7891    fn shutdown(&self) {
7892        self.inner.shutdown()
7893    }
7894    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7895        self.inner.shutdown_with_epitaph(status)
7896    }
7897
7898    fn is_closed(&self) -> bool {
7899        self.inner.channel().is_closed()
7900    }
7901    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7902        self.inner.channel().on_closed()
7903    }
7904
7905    #[cfg(target_os = "fuchsia")]
7906    fn signal_peer(
7907        &self,
7908        clear_mask: zx::Signals,
7909        set_mask: zx::Signals,
7910    ) -> Result<(), zx_status::Status> {
7911        use fidl::Peered;
7912        self.inner.channel().signal_peer(clear_mask, set_mask)
7913    }
7914}
7915
7916impl TerminaGuestManagerControlHandle {}
7917
7918#[must_use = "FIDL methods require a response to be sent"]
7919#[derive(Debug)]
7920pub struct TerminaGuestManagerLaunchResponder {
7921    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
7922    tx_id: u32,
7923}
7924
7925/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
7926/// if the responder is dropped without sending a response, so that the client
7927/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7928impl std::ops::Drop for TerminaGuestManagerLaunchResponder {
7929    fn drop(&mut self) {
7930        self.control_handle.shutdown();
7931        // Safety: drops once, never accessed again
7932        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7933    }
7934}
7935
7936impl fidl::endpoints::Responder for TerminaGuestManagerLaunchResponder {
7937    type ControlHandle = TerminaGuestManagerControlHandle;
7938
7939    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
7940        &self.control_handle
7941    }
7942
7943    fn drop_without_shutdown(mut self) {
7944        // Safety: drops once, never accessed again due to mem::forget
7945        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7946        // Prevent Drop from running (which would shut down the channel)
7947        std::mem::forget(self);
7948    }
7949}
7950
7951impl TerminaGuestManagerLaunchResponder {
7952    /// Sends a response to the FIDL transaction.
7953    ///
7954    /// Sets the channel to shutdown if an error occurs.
7955    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
7956        let _result = self.send_raw(result);
7957        if _result.is_err() {
7958            self.control_handle.shutdown();
7959        }
7960        self.drop_without_shutdown();
7961        _result
7962    }
7963
7964    /// Similar to "send" but does not shutdown the channel if an error occurs.
7965    pub fn send_no_shutdown_on_err(
7966        self,
7967        mut result: Result<(), GuestManagerError>,
7968    ) -> Result<(), fidl::Error> {
7969        let _result = self.send_raw(result);
7970        self.drop_without_shutdown();
7971        _result
7972    }
7973
7974    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
7975        self.control_handle.inner.send::<fidl::encoding::ResultType<
7976            fidl::encoding::EmptyStruct,
7977            GuestManagerError,
7978        >>(
7979            result,
7980            self.tx_id,
7981            0x394a2e29f750323e,
7982            fidl::encoding::DynamicFlags::empty(),
7983        )
7984    }
7985}
7986
7987#[must_use = "FIDL methods require a response to be sent"]
7988#[derive(Debug)]
7989pub struct TerminaGuestManagerForceShutdownResponder {
7990    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
7991    tx_id: u32,
7992}
7993
7994/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
7995/// if the responder is dropped without sending a response, so that the client
7996/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7997impl std::ops::Drop for TerminaGuestManagerForceShutdownResponder {
7998    fn drop(&mut self) {
7999        self.control_handle.shutdown();
8000        // Safety: drops once, never accessed again
8001        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8002    }
8003}
8004
8005impl fidl::endpoints::Responder for TerminaGuestManagerForceShutdownResponder {
8006    type ControlHandle = TerminaGuestManagerControlHandle;
8007
8008    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8009        &self.control_handle
8010    }
8011
8012    fn drop_without_shutdown(mut self) {
8013        // Safety: drops once, never accessed again due to mem::forget
8014        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8015        // Prevent Drop from running (which would shut down the channel)
8016        std::mem::forget(self);
8017    }
8018}
8019
8020impl TerminaGuestManagerForceShutdownResponder {
8021    /// Sends a response to the FIDL transaction.
8022    ///
8023    /// Sets the channel to shutdown if an error occurs.
8024    pub fn send(self) -> Result<(), fidl::Error> {
8025        let _result = self.send_raw();
8026        if _result.is_err() {
8027            self.control_handle.shutdown();
8028        }
8029        self.drop_without_shutdown();
8030        _result
8031    }
8032
8033    /// Similar to "send" but does not shutdown the channel if an error occurs.
8034    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8035        let _result = self.send_raw();
8036        self.drop_without_shutdown();
8037        _result
8038    }
8039
8040    fn send_raw(&self) -> Result<(), fidl::Error> {
8041        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8042            (),
8043            self.tx_id,
8044            0x3ad9a012982f872d,
8045            fidl::encoding::DynamicFlags::empty(),
8046        )
8047    }
8048}
8049
8050#[must_use = "FIDL methods require a response to be sent"]
8051#[derive(Debug)]
8052pub struct TerminaGuestManagerConnectResponder {
8053    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8054    tx_id: u32,
8055}
8056
8057/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8058/// if the responder is dropped without sending a response, so that the client
8059/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8060impl std::ops::Drop for TerminaGuestManagerConnectResponder {
8061    fn drop(&mut self) {
8062        self.control_handle.shutdown();
8063        // Safety: drops once, never accessed again
8064        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8065    }
8066}
8067
8068impl fidl::endpoints::Responder for TerminaGuestManagerConnectResponder {
8069    type ControlHandle = TerminaGuestManagerControlHandle;
8070
8071    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8072        &self.control_handle
8073    }
8074
8075    fn drop_without_shutdown(mut self) {
8076        // Safety: drops once, never accessed again due to mem::forget
8077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8078        // Prevent Drop from running (which would shut down the channel)
8079        std::mem::forget(self);
8080    }
8081}
8082
8083impl TerminaGuestManagerConnectResponder {
8084    /// Sends a response to the FIDL transaction.
8085    ///
8086    /// Sets the channel to shutdown if an error occurs.
8087    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8088        let _result = self.send_raw(result);
8089        if _result.is_err() {
8090            self.control_handle.shutdown();
8091        }
8092        self.drop_without_shutdown();
8093        _result
8094    }
8095
8096    /// Similar to "send" but does not shutdown the channel if an error occurs.
8097    pub fn send_no_shutdown_on_err(
8098        self,
8099        mut result: Result<(), GuestManagerError>,
8100    ) -> Result<(), fidl::Error> {
8101        let _result = self.send_raw(result);
8102        self.drop_without_shutdown();
8103        _result
8104    }
8105
8106    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8107        self.control_handle.inner.send::<fidl::encoding::ResultType<
8108            fidl::encoding::EmptyStruct,
8109            GuestManagerError,
8110        >>(
8111            result,
8112            self.tx_id,
8113            0x4e489076e3bb15b4,
8114            fidl::encoding::DynamicFlags::empty(),
8115        )
8116    }
8117}
8118
8119#[must_use = "FIDL methods require a response to be sent"]
8120#[derive(Debug)]
8121pub struct TerminaGuestManagerGetInfoResponder {
8122    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8123    tx_id: u32,
8124}
8125
8126/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8127/// if the responder is dropped without sending a response, so that the client
8128/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8129impl std::ops::Drop for TerminaGuestManagerGetInfoResponder {
8130    fn drop(&mut self) {
8131        self.control_handle.shutdown();
8132        // Safety: drops once, never accessed again
8133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8134    }
8135}
8136
8137impl fidl::endpoints::Responder for TerminaGuestManagerGetInfoResponder {
8138    type ControlHandle = TerminaGuestManagerControlHandle;
8139
8140    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8141        &self.control_handle
8142    }
8143
8144    fn drop_without_shutdown(mut self) {
8145        // Safety: drops once, never accessed again due to mem::forget
8146        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8147        // Prevent Drop from running (which would shut down the channel)
8148        std::mem::forget(self);
8149    }
8150}
8151
8152impl TerminaGuestManagerGetInfoResponder {
8153    /// Sends a response to the FIDL transaction.
8154    ///
8155    /// Sets the channel to shutdown if an error occurs.
8156    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8157        let _result = self.send_raw(guest_info);
8158        if _result.is_err() {
8159            self.control_handle.shutdown();
8160        }
8161        self.drop_without_shutdown();
8162        _result
8163    }
8164
8165    /// Similar to "send" but does not shutdown the channel if an error occurs.
8166    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8167        let _result = self.send_raw(guest_info);
8168        self.drop_without_shutdown();
8169        _result
8170    }
8171
8172    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8173        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
8174            (guest_info,),
8175            self.tx_id,
8176            0x76892614aea695dc,
8177            fidl::encoding::DynamicFlags::empty(),
8178        )
8179    }
8180}
8181
8182#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8183pub struct ZirconGuestManagerMarker;
8184
8185impl fidl::endpoints::ProtocolMarker for ZirconGuestManagerMarker {
8186    type Proxy = ZirconGuestManagerProxy;
8187    type RequestStream = ZirconGuestManagerRequestStream;
8188    #[cfg(target_os = "fuchsia")]
8189    type SynchronousProxy = ZirconGuestManagerSynchronousProxy;
8190
8191    const DEBUG_NAME: &'static str = "fuchsia.virtualization.ZirconGuestManager";
8192}
8193impl fidl::endpoints::DiscoverableProtocolMarker for ZirconGuestManagerMarker {}
8194
8195pub trait ZirconGuestManagerProxyInterface: Send + Sync {
8196    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
8197        + Send;
8198    fn r#launch(
8199        &self,
8200        guest_config: GuestConfig,
8201        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8202    ) -> Self::LaunchResponseFut;
8203    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8204    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
8205    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
8206        + Send;
8207    fn r#connect(
8208        &self,
8209        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8210    ) -> Self::ConnectResponseFut;
8211    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
8212    fn r#get_info(&self) -> Self::GetInfoResponseFut;
8213}
8214#[derive(Debug)]
8215#[cfg(target_os = "fuchsia")]
8216pub struct ZirconGuestManagerSynchronousProxy {
8217    client: fidl::client::sync::Client,
8218}
8219
8220#[cfg(target_os = "fuchsia")]
8221impl fidl::endpoints::SynchronousProxy for ZirconGuestManagerSynchronousProxy {
8222    type Proxy = ZirconGuestManagerProxy;
8223    type Protocol = ZirconGuestManagerMarker;
8224
8225    fn from_channel(inner: fidl::Channel) -> Self {
8226        Self::new(inner)
8227    }
8228
8229    fn into_channel(self) -> fidl::Channel {
8230        self.client.into_channel()
8231    }
8232
8233    fn as_channel(&self) -> &fidl::Channel {
8234        self.client.as_channel()
8235    }
8236}
8237
8238#[cfg(target_os = "fuchsia")]
8239impl ZirconGuestManagerSynchronousProxy {
8240    pub fn new(channel: fidl::Channel) -> Self {
8241        let protocol_name =
8242            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8243        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8244    }
8245
8246    pub fn into_channel(self) -> fidl::Channel {
8247        self.client.into_channel()
8248    }
8249
8250    /// Waits until an event arrives and returns it. It is safe for other
8251    /// threads to make concurrent requests while waiting for an event.
8252    pub fn wait_for_event(
8253        &self,
8254        deadline: zx::MonotonicInstant,
8255    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8256        ZirconGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
8257    }
8258
8259    /// Launch a new guest instance.
8260    ///
8261    /// Possible errors:
8262    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8263    ///         problems detected by the guest manager.
8264    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8265    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8266    ///         component logs for a more specific failure.
8267    pub fn r#launch(
8268        &self,
8269        mut guest_config: GuestConfig,
8270        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8271        ___deadline: zx::MonotonicInstant,
8272    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8273        let _response =
8274            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
8275                fidl::encoding::EmptyStruct,
8276                GuestManagerError,
8277            >>(
8278                (&mut guest_config, controller),
8279                0x394a2e29f750323e,
8280                fidl::encoding::DynamicFlags::empty(),
8281                ___deadline,
8282            )?;
8283        Ok(_response.map(|x| x))
8284    }
8285
8286    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8287    /// be used to launch another guest.
8288    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
8289        let _response =
8290            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
8291                (),
8292                0x3ad9a012982f872d,
8293                fidl::encoding::DynamicFlags::empty(),
8294                ___deadline,
8295            )?;
8296        Ok(_response)
8297    }
8298
8299    /// Connect to a currently running guest.
8300    ///
8301    /// Possible errors:
8302    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8303    ///         has launched before attempting to reconnect.
8304    pub fn r#connect(
8305        &self,
8306        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8307        ___deadline: zx::MonotonicInstant,
8308    ) -> Result<GuestManagerConnectResult, fidl::Error> {
8309        let _response =
8310            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
8311                fidl::encoding::EmptyStruct,
8312                GuestManagerError,
8313            >>(
8314                (controller,),
8315                0x4e489076e3bb15b4,
8316                fidl::encoding::DynamicFlags::empty(),
8317                ___deadline,
8318            )?;
8319        Ok(_response.map(|x| x))
8320    }
8321
8322    /// Query guest info
8323    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
8324        let _response =
8325            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
8326                (),
8327                0x76892614aea695dc,
8328                fidl::encoding::DynamicFlags::empty(),
8329                ___deadline,
8330            )?;
8331        Ok(_response.guest_info)
8332    }
8333}
8334
8335#[cfg(target_os = "fuchsia")]
8336impl From<ZirconGuestManagerSynchronousProxy> for zx::Handle {
8337    fn from(value: ZirconGuestManagerSynchronousProxy) -> Self {
8338        value.into_channel().into()
8339    }
8340}
8341
8342#[cfg(target_os = "fuchsia")]
8343impl From<fidl::Channel> for ZirconGuestManagerSynchronousProxy {
8344    fn from(value: fidl::Channel) -> Self {
8345        Self::new(value)
8346    }
8347}
8348
8349#[derive(Debug, Clone)]
8350pub struct ZirconGuestManagerProxy {
8351    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8352}
8353
8354impl fidl::endpoints::Proxy for ZirconGuestManagerProxy {
8355    type Protocol = ZirconGuestManagerMarker;
8356
8357    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8358        Self::new(inner)
8359    }
8360
8361    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8362        self.client.into_channel().map_err(|client| Self { client })
8363    }
8364
8365    fn as_channel(&self) -> &::fidl::AsyncChannel {
8366        self.client.as_channel()
8367    }
8368}
8369
8370impl ZirconGuestManagerProxy {
8371    /// Create a new Proxy for fuchsia.virtualization/ZirconGuestManager.
8372    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8373        let protocol_name =
8374            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8375        Self { client: fidl::client::Client::new(channel, protocol_name) }
8376    }
8377
8378    /// Get a Stream of events from the remote end of the protocol.
8379    ///
8380    /// # Panics
8381    ///
8382    /// Panics if the event stream was already taken.
8383    pub fn take_event_stream(&self) -> ZirconGuestManagerEventStream {
8384        ZirconGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
8385    }
8386
8387    /// Launch a new guest instance.
8388    ///
8389    /// Possible errors:
8390    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8391    ///         problems detected by the guest manager.
8392    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8393    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8394    ///         component logs for a more specific failure.
8395    pub fn r#launch(
8396        &self,
8397        mut guest_config: GuestConfig,
8398        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8399    ) -> fidl::client::QueryResponseFut<
8400        GuestManagerLaunchResult,
8401        fidl::encoding::DefaultFuchsiaResourceDialect,
8402    > {
8403        ZirconGuestManagerProxyInterface::r#launch(self, guest_config, controller)
8404    }
8405
8406    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8407    /// be used to launch another guest.
8408    pub fn r#force_shutdown(
8409        &self,
8410    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8411        ZirconGuestManagerProxyInterface::r#force_shutdown(self)
8412    }
8413
8414    /// Connect to a currently running guest.
8415    ///
8416    /// Possible errors:
8417    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8418    ///         has launched before attempting to reconnect.
8419    pub fn r#connect(
8420        &self,
8421        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8422    ) -> fidl::client::QueryResponseFut<
8423        GuestManagerConnectResult,
8424        fidl::encoding::DefaultFuchsiaResourceDialect,
8425    > {
8426        ZirconGuestManagerProxyInterface::r#connect(self, controller)
8427    }
8428
8429    /// Query guest info
8430    pub fn r#get_info(
8431        &self,
8432    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
8433    {
8434        ZirconGuestManagerProxyInterface::r#get_info(self)
8435    }
8436}
8437
8438impl ZirconGuestManagerProxyInterface for ZirconGuestManagerProxy {
8439    type LaunchResponseFut = fidl::client::QueryResponseFut<
8440        GuestManagerLaunchResult,
8441        fidl::encoding::DefaultFuchsiaResourceDialect,
8442    >;
8443    fn r#launch(
8444        &self,
8445        mut guest_config: GuestConfig,
8446        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8447    ) -> Self::LaunchResponseFut {
8448        fn _decode(
8449            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8450        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8451            let _response = fidl::client::decode_transaction_body::<
8452                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8453                fidl::encoding::DefaultFuchsiaResourceDialect,
8454                0x394a2e29f750323e,
8455            >(_buf?)?;
8456            Ok(_response.map(|x| x))
8457        }
8458        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
8459            (&mut guest_config, controller),
8460            0x394a2e29f750323e,
8461            fidl::encoding::DynamicFlags::empty(),
8462            _decode,
8463        )
8464    }
8465
8466    type ForceShutdownResponseFut =
8467        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8468    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
8469        fn _decode(
8470            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8471        ) -> Result<(), fidl::Error> {
8472            let _response = fidl::client::decode_transaction_body::<
8473                fidl::encoding::EmptyPayload,
8474                fidl::encoding::DefaultFuchsiaResourceDialect,
8475                0x3ad9a012982f872d,
8476            >(_buf?)?;
8477            Ok(_response)
8478        }
8479        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
8480            (),
8481            0x3ad9a012982f872d,
8482            fidl::encoding::DynamicFlags::empty(),
8483            _decode,
8484        )
8485    }
8486
8487    type ConnectResponseFut = fidl::client::QueryResponseFut<
8488        GuestManagerConnectResult,
8489        fidl::encoding::DefaultFuchsiaResourceDialect,
8490    >;
8491    fn r#connect(
8492        &self,
8493        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8494    ) -> Self::ConnectResponseFut {
8495        fn _decode(
8496            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8497        ) -> Result<GuestManagerConnectResult, fidl::Error> {
8498            let _response = fidl::client::decode_transaction_body::<
8499                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8500                fidl::encoding::DefaultFuchsiaResourceDialect,
8501                0x4e489076e3bb15b4,
8502            >(_buf?)?;
8503            Ok(_response.map(|x| x))
8504        }
8505        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
8506            (controller,),
8507            0x4e489076e3bb15b4,
8508            fidl::encoding::DynamicFlags::empty(),
8509            _decode,
8510        )
8511    }
8512
8513    type GetInfoResponseFut =
8514        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
8515    fn r#get_info(&self) -> Self::GetInfoResponseFut {
8516        fn _decode(
8517            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8518        ) -> Result<GuestInfo, fidl::Error> {
8519            let _response = fidl::client::decode_transaction_body::<
8520                GuestManagerGetInfoResponse,
8521                fidl::encoding::DefaultFuchsiaResourceDialect,
8522                0x76892614aea695dc,
8523            >(_buf?)?;
8524            Ok(_response.guest_info)
8525        }
8526        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
8527            (),
8528            0x76892614aea695dc,
8529            fidl::encoding::DynamicFlags::empty(),
8530            _decode,
8531        )
8532    }
8533}
8534
8535pub struct ZirconGuestManagerEventStream {
8536    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8537}
8538
8539impl std::marker::Unpin for ZirconGuestManagerEventStream {}
8540
8541impl futures::stream::FusedStream for ZirconGuestManagerEventStream {
8542    fn is_terminated(&self) -> bool {
8543        self.event_receiver.is_terminated()
8544    }
8545}
8546
8547impl futures::Stream for ZirconGuestManagerEventStream {
8548    type Item = Result<ZirconGuestManagerEvent, fidl::Error>;
8549
8550    fn poll_next(
8551        mut self: std::pin::Pin<&mut Self>,
8552        cx: &mut std::task::Context<'_>,
8553    ) -> std::task::Poll<Option<Self::Item>> {
8554        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8555            &mut self.event_receiver,
8556            cx
8557        )?) {
8558            Some(buf) => std::task::Poll::Ready(Some(ZirconGuestManagerEvent::decode(buf))),
8559            None => std::task::Poll::Ready(None),
8560        }
8561    }
8562}
8563
8564#[derive(Debug)]
8565pub enum ZirconGuestManagerEvent {}
8566
8567impl ZirconGuestManagerEvent {
8568    /// Decodes a message buffer as a [`ZirconGuestManagerEvent`].
8569    fn decode(
8570        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8571    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8572        let (bytes, _handles) = buf.split_mut();
8573        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8574        debug_assert_eq!(tx_header.tx_id, 0);
8575        match tx_header.ordinal {
8576            _ => Err(fidl::Error::UnknownOrdinal {
8577                ordinal: tx_header.ordinal,
8578                protocol_name:
8579                    <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8580            }),
8581        }
8582    }
8583}
8584
8585/// A Stream of incoming requests for fuchsia.virtualization/ZirconGuestManager.
8586pub struct ZirconGuestManagerRequestStream {
8587    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8588    is_terminated: bool,
8589}
8590
8591impl std::marker::Unpin for ZirconGuestManagerRequestStream {}
8592
8593impl futures::stream::FusedStream for ZirconGuestManagerRequestStream {
8594    fn is_terminated(&self) -> bool {
8595        self.is_terminated
8596    }
8597}
8598
8599impl fidl::endpoints::RequestStream for ZirconGuestManagerRequestStream {
8600    type Protocol = ZirconGuestManagerMarker;
8601    type ControlHandle = ZirconGuestManagerControlHandle;
8602
8603    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8604        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8605    }
8606
8607    fn control_handle(&self) -> Self::ControlHandle {
8608        ZirconGuestManagerControlHandle { inner: self.inner.clone() }
8609    }
8610
8611    fn into_inner(
8612        self,
8613    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8614    {
8615        (self.inner, self.is_terminated)
8616    }
8617
8618    fn from_inner(
8619        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8620        is_terminated: bool,
8621    ) -> Self {
8622        Self { inner, is_terminated }
8623    }
8624}
8625
8626impl futures::Stream for ZirconGuestManagerRequestStream {
8627    type Item = Result<ZirconGuestManagerRequest, fidl::Error>;
8628
8629    fn poll_next(
8630        mut self: std::pin::Pin<&mut Self>,
8631        cx: &mut std::task::Context<'_>,
8632    ) -> std::task::Poll<Option<Self::Item>> {
8633        let this = &mut *self;
8634        if this.inner.check_shutdown(cx) {
8635            this.is_terminated = true;
8636            return std::task::Poll::Ready(None);
8637        }
8638        if this.is_terminated {
8639            panic!("polled ZirconGuestManagerRequestStream after completion");
8640        }
8641        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8642            |bytes, handles| {
8643                match this.inner.channel().read_etc(cx, bytes, handles) {
8644                    std::task::Poll::Ready(Ok(())) => {}
8645                    std::task::Poll::Pending => return std::task::Poll::Pending,
8646                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8647                        this.is_terminated = true;
8648                        return std::task::Poll::Ready(None);
8649                    }
8650                    std::task::Poll::Ready(Err(e)) => {
8651                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8652                            e.into(),
8653                        ))))
8654                    }
8655                }
8656
8657                // A message has been received from the channel
8658                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8659
8660                std::task::Poll::Ready(Some(match header.ordinal {
8661                0x394a2e29f750323e => {
8662                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8663                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8664                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
8665                    let control_handle = ZirconGuestManagerControlHandle {
8666                        inner: this.inner.clone(),
8667                    };
8668                    Ok(ZirconGuestManagerRequest::Launch {guest_config: req.guest_config,
8669controller: req.controller,
8670
8671                        responder: ZirconGuestManagerLaunchResponder {
8672                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8673                            tx_id: header.tx_id,
8674                        },
8675                    })
8676                }
8677                0x3ad9a012982f872d => {
8678                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8679                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8680                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8681                    let control_handle = ZirconGuestManagerControlHandle {
8682                        inner: this.inner.clone(),
8683                    };
8684                    Ok(ZirconGuestManagerRequest::ForceShutdown {
8685                        responder: ZirconGuestManagerForceShutdownResponder {
8686                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8687                            tx_id: header.tx_id,
8688                        },
8689                    })
8690                }
8691                0x4e489076e3bb15b4 => {
8692                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8693                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8694                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
8695                    let control_handle = ZirconGuestManagerControlHandle {
8696                        inner: this.inner.clone(),
8697                    };
8698                    Ok(ZirconGuestManagerRequest::Connect {controller: req.controller,
8699
8700                        responder: ZirconGuestManagerConnectResponder {
8701                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8702                            tx_id: header.tx_id,
8703                        },
8704                    })
8705                }
8706                0x76892614aea695dc => {
8707                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8708                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8709                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8710                    let control_handle = ZirconGuestManagerControlHandle {
8711                        inner: this.inner.clone(),
8712                    };
8713                    Ok(ZirconGuestManagerRequest::GetInfo {
8714                        responder: ZirconGuestManagerGetInfoResponder {
8715                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8716                            tx_id: header.tx_id,
8717                        },
8718                    })
8719                }
8720                _ => Err(fidl::Error::UnknownOrdinal {
8721                    ordinal: header.ordinal,
8722                    protocol_name: <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8723                }),
8724            }))
8725            },
8726        )
8727    }
8728}
8729
8730#[derive(Debug)]
8731pub enum ZirconGuestManagerRequest {
8732    /// Launch a new guest instance.
8733    ///
8734    /// Possible errors:
8735    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8736    ///         problems detected by the guest manager.
8737    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8738    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8739    ///         component logs for a more specific failure.
8740    Launch {
8741        guest_config: GuestConfig,
8742        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8743        responder: ZirconGuestManagerLaunchResponder,
8744    },
8745    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8746    /// be used to launch another guest.
8747    ForceShutdown { responder: ZirconGuestManagerForceShutdownResponder },
8748    /// Connect to a currently running guest.
8749    ///
8750    /// Possible errors:
8751    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8752    ///         has launched before attempting to reconnect.
8753    Connect {
8754        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8755        responder: ZirconGuestManagerConnectResponder,
8756    },
8757    /// Query guest info
8758    GetInfo { responder: ZirconGuestManagerGetInfoResponder },
8759}
8760
8761impl ZirconGuestManagerRequest {
8762    #[allow(irrefutable_let_patterns)]
8763    pub fn into_launch(
8764        self,
8765    ) -> Option<(
8766        GuestConfig,
8767        fidl::endpoints::ServerEnd<GuestMarker>,
8768        ZirconGuestManagerLaunchResponder,
8769    )> {
8770        if let ZirconGuestManagerRequest::Launch { guest_config, controller, responder } = self {
8771            Some((guest_config, controller, responder))
8772        } else {
8773            None
8774        }
8775    }
8776
8777    #[allow(irrefutable_let_patterns)]
8778    pub fn into_force_shutdown(self) -> Option<(ZirconGuestManagerForceShutdownResponder)> {
8779        if let ZirconGuestManagerRequest::ForceShutdown { responder } = self {
8780            Some((responder))
8781        } else {
8782            None
8783        }
8784    }
8785
8786    #[allow(irrefutable_let_patterns)]
8787    pub fn into_connect(
8788        self,
8789    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, ZirconGuestManagerConnectResponder)> {
8790        if let ZirconGuestManagerRequest::Connect { controller, responder } = self {
8791            Some((controller, responder))
8792        } else {
8793            None
8794        }
8795    }
8796
8797    #[allow(irrefutable_let_patterns)]
8798    pub fn into_get_info(self) -> Option<(ZirconGuestManagerGetInfoResponder)> {
8799        if let ZirconGuestManagerRequest::GetInfo { responder } = self {
8800            Some((responder))
8801        } else {
8802            None
8803        }
8804    }
8805
8806    /// Name of the method defined in FIDL
8807    pub fn method_name(&self) -> &'static str {
8808        match *self {
8809            ZirconGuestManagerRequest::Launch { .. } => "launch",
8810            ZirconGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
8811            ZirconGuestManagerRequest::Connect { .. } => "connect",
8812            ZirconGuestManagerRequest::GetInfo { .. } => "get_info",
8813        }
8814    }
8815}
8816
8817#[derive(Debug, Clone)]
8818pub struct ZirconGuestManagerControlHandle {
8819    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8820}
8821
8822impl fidl::endpoints::ControlHandle for ZirconGuestManagerControlHandle {
8823    fn shutdown(&self) {
8824        self.inner.shutdown()
8825    }
8826    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8827        self.inner.shutdown_with_epitaph(status)
8828    }
8829
8830    fn is_closed(&self) -> bool {
8831        self.inner.channel().is_closed()
8832    }
8833    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8834        self.inner.channel().on_closed()
8835    }
8836
8837    #[cfg(target_os = "fuchsia")]
8838    fn signal_peer(
8839        &self,
8840        clear_mask: zx::Signals,
8841        set_mask: zx::Signals,
8842    ) -> Result<(), zx_status::Status> {
8843        use fidl::Peered;
8844        self.inner.channel().signal_peer(clear_mask, set_mask)
8845    }
8846}
8847
8848impl ZirconGuestManagerControlHandle {}
8849
8850#[must_use = "FIDL methods require a response to be sent"]
8851#[derive(Debug)]
8852pub struct ZirconGuestManagerLaunchResponder {
8853    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8854    tx_id: u32,
8855}
8856
8857/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8858/// if the responder is dropped without sending a response, so that the client
8859/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8860impl std::ops::Drop for ZirconGuestManagerLaunchResponder {
8861    fn drop(&mut self) {
8862        self.control_handle.shutdown();
8863        // Safety: drops once, never accessed again
8864        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8865    }
8866}
8867
8868impl fidl::endpoints::Responder for ZirconGuestManagerLaunchResponder {
8869    type ControlHandle = ZirconGuestManagerControlHandle;
8870
8871    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
8872        &self.control_handle
8873    }
8874
8875    fn drop_without_shutdown(mut self) {
8876        // Safety: drops once, never accessed again due to mem::forget
8877        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8878        // Prevent Drop from running (which would shut down the channel)
8879        std::mem::forget(self);
8880    }
8881}
8882
8883impl ZirconGuestManagerLaunchResponder {
8884    /// Sends a response to the FIDL transaction.
8885    ///
8886    /// Sets the channel to shutdown if an error occurs.
8887    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8888        let _result = self.send_raw(result);
8889        if _result.is_err() {
8890            self.control_handle.shutdown();
8891        }
8892        self.drop_without_shutdown();
8893        _result
8894    }
8895
8896    /// Similar to "send" but does not shutdown the channel if an error occurs.
8897    pub fn send_no_shutdown_on_err(
8898        self,
8899        mut result: Result<(), GuestManagerError>,
8900    ) -> Result<(), fidl::Error> {
8901        let _result = self.send_raw(result);
8902        self.drop_without_shutdown();
8903        _result
8904    }
8905
8906    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8907        self.control_handle.inner.send::<fidl::encoding::ResultType<
8908            fidl::encoding::EmptyStruct,
8909            GuestManagerError,
8910        >>(
8911            result,
8912            self.tx_id,
8913            0x394a2e29f750323e,
8914            fidl::encoding::DynamicFlags::empty(),
8915        )
8916    }
8917}
8918
8919#[must_use = "FIDL methods require a response to be sent"]
8920#[derive(Debug)]
8921pub struct ZirconGuestManagerForceShutdownResponder {
8922    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8923    tx_id: u32,
8924}
8925
8926/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8927/// if the responder is dropped without sending a response, so that the client
8928/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8929impl std::ops::Drop for ZirconGuestManagerForceShutdownResponder {
8930    fn drop(&mut self) {
8931        self.control_handle.shutdown();
8932        // Safety: drops once, never accessed again
8933        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8934    }
8935}
8936
8937impl fidl::endpoints::Responder for ZirconGuestManagerForceShutdownResponder {
8938    type ControlHandle = ZirconGuestManagerControlHandle;
8939
8940    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
8941        &self.control_handle
8942    }
8943
8944    fn drop_without_shutdown(mut self) {
8945        // Safety: drops once, never accessed again due to mem::forget
8946        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8947        // Prevent Drop from running (which would shut down the channel)
8948        std::mem::forget(self);
8949    }
8950}
8951
8952impl ZirconGuestManagerForceShutdownResponder {
8953    /// Sends a response to the FIDL transaction.
8954    ///
8955    /// Sets the channel to shutdown if an error occurs.
8956    pub fn send(self) -> Result<(), fidl::Error> {
8957        let _result = self.send_raw();
8958        if _result.is_err() {
8959            self.control_handle.shutdown();
8960        }
8961        self.drop_without_shutdown();
8962        _result
8963    }
8964
8965    /// Similar to "send" but does not shutdown the channel if an error occurs.
8966    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8967        let _result = self.send_raw();
8968        self.drop_without_shutdown();
8969        _result
8970    }
8971
8972    fn send_raw(&self) -> Result<(), fidl::Error> {
8973        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8974            (),
8975            self.tx_id,
8976            0x3ad9a012982f872d,
8977            fidl::encoding::DynamicFlags::empty(),
8978        )
8979    }
8980}
8981
8982#[must_use = "FIDL methods require a response to be sent"]
8983#[derive(Debug)]
8984pub struct ZirconGuestManagerConnectResponder {
8985    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8986    tx_id: u32,
8987}
8988
8989/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8990/// if the responder is dropped without sending a response, so that the client
8991/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8992impl std::ops::Drop for ZirconGuestManagerConnectResponder {
8993    fn drop(&mut self) {
8994        self.control_handle.shutdown();
8995        // Safety: drops once, never accessed again
8996        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8997    }
8998}
8999
9000impl fidl::endpoints::Responder for ZirconGuestManagerConnectResponder {
9001    type ControlHandle = ZirconGuestManagerControlHandle;
9002
9003    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9004        &self.control_handle
9005    }
9006
9007    fn drop_without_shutdown(mut self) {
9008        // Safety: drops once, never accessed again due to mem::forget
9009        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9010        // Prevent Drop from running (which would shut down the channel)
9011        std::mem::forget(self);
9012    }
9013}
9014
9015impl ZirconGuestManagerConnectResponder {
9016    /// Sends a response to the FIDL transaction.
9017    ///
9018    /// Sets the channel to shutdown if an error occurs.
9019    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9020        let _result = self.send_raw(result);
9021        if _result.is_err() {
9022            self.control_handle.shutdown();
9023        }
9024        self.drop_without_shutdown();
9025        _result
9026    }
9027
9028    /// Similar to "send" but does not shutdown the channel if an error occurs.
9029    pub fn send_no_shutdown_on_err(
9030        self,
9031        mut result: Result<(), GuestManagerError>,
9032    ) -> Result<(), fidl::Error> {
9033        let _result = self.send_raw(result);
9034        self.drop_without_shutdown();
9035        _result
9036    }
9037
9038    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9039        self.control_handle.inner.send::<fidl::encoding::ResultType<
9040            fidl::encoding::EmptyStruct,
9041            GuestManagerError,
9042        >>(
9043            result,
9044            self.tx_id,
9045            0x4e489076e3bb15b4,
9046            fidl::encoding::DynamicFlags::empty(),
9047        )
9048    }
9049}
9050
9051#[must_use = "FIDL methods require a response to be sent"]
9052#[derive(Debug)]
9053pub struct ZirconGuestManagerGetInfoResponder {
9054    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9055    tx_id: u32,
9056}
9057
9058/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9059/// if the responder is dropped without sending a response, so that the client
9060/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9061impl std::ops::Drop for ZirconGuestManagerGetInfoResponder {
9062    fn drop(&mut self) {
9063        self.control_handle.shutdown();
9064        // Safety: drops once, never accessed again
9065        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9066    }
9067}
9068
9069impl fidl::endpoints::Responder for ZirconGuestManagerGetInfoResponder {
9070    type ControlHandle = ZirconGuestManagerControlHandle;
9071
9072    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9073        &self.control_handle
9074    }
9075
9076    fn drop_without_shutdown(mut self) {
9077        // Safety: drops once, never accessed again due to mem::forget
9078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9079        // Prevent Drop from running (which would shut down the channel)
9080        std::mem::forget(self);
9081    }
9082}
9083
9084impl ZirconGuestManagerGetInfoResponder {
9085    /// Sends a response to the FIDL transaction.
9086    ///
9087    /// Sets the channel to shutdown if an error occurs.
9088    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9089        let _result = self.send_raw(guest_info);
9090        if _result.is_err() {
9091            self.control_handle.shutdown();
9092        }
9093        self.drop_without_shutdown();
9094        _result
9095    }
9096
9097    /// Similar to "send" but does not shutdown the channel if an error occurs.
9098    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9099        let _result = self.send_raw(guest_info);
9100        self.drop_without_shutdown();
9101        _result
9102    }
9103
9104    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9105        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
9106            (guest_info,),
9107            self.tx_id,
9108            0x76892614aea695dc,
9109            fidl::encoding::DynamicFlags::empty(),
9110        )
9111    }
9112}
9113
9114mod internal {
9115    use super::*;
9116
9117    impl fidl::encoding::ResourceTypeMarker for BlockSpec {
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 BlockSpec {
9127        type Owned = Self;
9128
9129        #[inline(always)]
9130        fn inline_align(_context: fidl::encoding::Context) -> usize {
9131            8
9132        }
9133
9134        #[inline(always)]
9135        fn inline_size(_context: fidl::encoding::Context) -> usize {
9136            40
9137        }
9138    }
9139
9140    unsafe impl fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9141        for &mut BlockSpec
9142    {
9143        #[inline]
9144        unsafe fn encode(
9145            self,
9146            encoder: &mut fidl::encoding::Encoder<
9147                '_,
9148                fidl::encoding::DefaultFuchsiaResourceDialect,
9149            >,
9150            offset: usize,
9151            _depth: fidl::encoding::Depth,
9152        ) -> fidl::Result<()> {
9153            encoder.debug_check_bounds::<BlockSpec>(offset);
9154            // Delegate to tuple encoding.
9155            fidl::encoding::Encode::<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9156                (
9157                    <fidl::encoding::BoundedString<20> as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
9158                    <BlockMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
9159                    <BlockFormat as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.format),
9160                ),
9161                encoder, offset, _depth
9162            )
9163        }
9164    }
9165    unsafe impl<
9166            T0: fidl::encoding::Encode<
9167                fidl::encoding::BoundedString<20>,
9168                fidl::encoding::DefaultFuchsiaResourceDialect,
9169            >,
9170            T1: fidl::encoding::Encode<BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect>,
9171            T2: fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>,
9172        > fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9173        for (T0, T1, T2)
9174    {
9175        #[inline]
9176        unsafe fn encode(
9177            self,
9178            encoder: &mut fidl::encoding::Encoder<
9179                '_,
9180                fidl::encoding::DefaultFuchsiaResourceDialect,
9181            >,
9182            offset: usize,
9183            depth: fidl::encoding::Depth,
9184        ) -> fidl::Result<()> {
9185            encoder.debug_check_bounds::<BlockSpec>(offset);
9186            // Zero out padding regions. There's no need to apply masks
9187            // because the unmasked parts will be overwritten by fields.
9188            unsafe {
9189                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9190                (ptr as *mut u64).write_unaligned(0);
9191            }
9192            // Write the fields.
9193            self.0.encode(encoder, offset + 0, depth)?;
9194            self.1.encode(encoder, offset + 16, depth)?;
9195            self.2.encode(encoder, offset + 24, depth)?;
9196            Ok(())
9197        }
9198    }
9199
9200    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockSpec {
9201        #[inline(always)]
9202        fn new_empty() -> Self {
9203            Self {
9204                id: fidl::new_empty!(
9205                    fidl::encoding::BoundedString<20>,
9206                    fidl::encoding::DefaultFuchsiaResourceDialect
9207                ),
9208                mode: fidl::new_empty!(BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect),
9209                format: fidl::new_empty!(
9210                    BlockFormat,
9211                    fidl::encoding::DefaultFuchsiaResourceDialect
9212                ),
9213            }
9214        }
9215
9216        #[inline]
9217        unsafe fn decode(
9218            &mut self,
9219            decoder: &mut fidl::encoding::Decoder<
9220                '_,
9221                fidl::encoding::DefaultFuchsiaResourceDialect,
9222            >,
9223            offset: usize,
9224            _depth: fidl::encoding::Depth,
9225        ) -> fidl::Result<()> {
9226            decoder.debug_check_bounds::<Self>(offset);
9227            // Verify that padding bytes are zero.
9228            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9229            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9230            let mask = 0xffffffff00000000u64;
9231            let maskedval = padval & mask;
9232            if maskedval != 0 {
9233                return Err(fidl::Error::NonZeroPadding {
9234                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9235                });
9236            }
9237            fidl::decode!(
9238                fidl::encoding::BoundedString<20>,
9239                fidl::encoding::DefaultFuchsiaResourceDialect,
9240                &mut self.id,
9241                decoder,
9242                offset + 0,
9243                _depth
9244            )?;
9245            fidl::decode!(
9246                BlockMode,
9247                fidl::encoding::DefaultFuchsiaResourceDialect,
9248                &mut self.mode,
9249                decoder,
9250                offset + 16,
9251                _depth
9252            )?;
9253            fidl::decode!(
9254                BlockFormat,
9255                fidl::encoding::DefaultFuchsiaResourceDialect,
9256                &mut self.format,
9257                decoder,
9258                offset + 24,
9259                _depth
9260            )?;
9261            Ok(())
9262        }
9263    }
9264
9265    impl fidl::encoding::ResourceTypeMarker for GuestGetBalloonControllerRequest {
9266        type Borrowed<'a> = &'a mut Self;
9267        fn take_or_borrow<'a>(
9268            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9269        ) -> Self::Borrowed<'a> {
9270            value
9271        }
9272    }
9273
9274    unsafe impl fidl::encoding::TypeMarker for GuestGetBalloonControllerRequest {
9275        type Owned = Self;
9276
9277        #[inline(always)]
9278        fn inline_align(_context: fidl::encoding::Context) -> usize {
9279            4
9280        }
9281
9282        #[inline(always)]
9283        fn inline_size(_context: fidl::encoding::Context) -> usize {
9284            4
9285        }
9286    }
9287
9288    unsafe impl
9289        fidl::encoding::Encode<
9290            GuestGetBalloonControllerRequest,
9291            fidl::encoding::DefaultFuchsiaResourceDialect,
9292        > for &mut GuestGetBalloonControllerRequest
9293    {
9294        #[inline]
9295        unsafe fn encode(
9296            self,
9297            encoder: &mut fidl::encoding::Encoder<
9298                '_,
9299                fidl::encoding::DefaultFuchsiaResourceDialect,
9300            >,
9301            offset: usize,
9302            _depth: fidl::encoding::Depth,
9303        ) -> fidl::Result<()> {
9304            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9305            // Delegate to tuple encoding.
9306            fidl::encoding::Encode::<GuestGetBalloonControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9307                (
9308                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9309                ),
9310                encoder, offset, _depth
9311            )
9312        }
9313    }
9314    unsafe impl<
9315            T0: fidl::encoding::Encode<
9316                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9317                fidl::encoding::DefaultFuchsiaResourceDialect,
9318            >,
9319        >
9320        fidl::encoding::Encode<
9321            GuestGetBalloonControllerRequest,
9322            fidl::encoding::DefaultFuchsiaResourceDialect,
9323        > for (T0,)
9324    {
9325        #[inline]
9326        unsafe fn encode(
9327            self,
9328            encoder: &mut fidl::encoding::Encoder<
9329                '_,
9330                fidl::encoding::DefaultFuchsiaResourceDialect,
9331            >,
9332            offset: usize,
9333            depth: fidl::encoding::Depth,
9334        ) -> fidl::Result<()> {
9335            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9336            // Zero out padding regions. There's no need to apply masks
9337            // because the unmasked parts will be overwritten by fields.
9338            // Write the fields.
9339            self.0.encode(encoder, offset + 0, depth)?;
9340            Ok(())
9341        }
9342    }
9343
9344    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9345        for GuestGetBalloonControllerRequest
9346    {
9347        #[inline(always)]
9348        fn new_empty() -> Self {
9349            Self {
9350                controller: fidl::new_empty!(
9351                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9352                    fidl::encoding::DefaultFuchsiaResourceDialect
9353                ),
9354            }
9355        }
9356
9357        #[inline]
9358        unsafe fn decode(
9359            &mut self,
9360            decoder: &mut fidl::encoding::Decoder<
9361                '_,
9362                fidl::encoding::DefaultFuchsiaResourceDialect,
9363            >,
9364            offset: usize,
9365            _depth: fidl::encoding::Depth,
9366        ) -> fidl::Result<()> {
9367            decoder.debug_check_bounds::<Self>(offset);
9368            // Verify that padding bytes are zero.
9369            fidl::decode!(
9370                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9371                fidl::encoding::DefaultFuchsiaResourceDialect,
9372                &mut self.controller,
9373                decoder,
9374                offset + 0,
9375                _depth
9376            )?;
9377            Ok(())
9378        }
9379    }
9380
9381    impl fidl::encoding::ResourceTypeMarker for GuestGetHostVsockEndpointRequest {
9382        type Borrowed<'a> = &'a mut Self;
9383        fn take_or_borrow<'a>(
9384            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9385        ) -> Self::Borrowed<'a> {
9386            value
9387        }
9388    }
9389
9390    unsafe impl fidl::encoding::TypeMarker for GuestGetHostVsockEndpointRequest {
9391        type Owned = Self;
9392
9393        #[inline(always)]
9394        fn inline_align(_context: fidl::encoding::Context) -> usize {
9395            4
9396        }
9397
9398        #[inline(always)]
9399        fn inline_size(_context: fidl::encoding::Context) -> usize {
9400            4
9401        }
9402    }
9403
9404    unsafe impl
9405        fidl::encoding::Encode<
9406            GuestGetHostVsockEndpointRequest,
9407            fidl::encoding::DefaultFuchsiaResourceDialect,
9408        > for &mut GuestGetHostVsockEndpointRequest
9409    {
9410        #[inline]
9411        unsafe fn encode(
9412            self,
9413            encoder: &mut fidl::encoding::Encoder<
9414                '_,
9415                fidl::encoding::DefaultFuchsiaResourceDialect,
9416            >,
9417            offset: usize,
9418            _depth: fidl::encoding::Depth,
9419        ) -> fidl::Result<()> {
9420            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9421            // Delegate to tuple encoding.
9422            fidl::encoding::Encode::<GuestGetHostVsockEndpointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9423                (
9424                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoint),
9425                ),
9426                encoder, offset, _depth
9427            )
9428        }
9429    }
9430    unsafe impl<
9431            T0: fidl::encoding::Encode<
9432                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9433                fidl::encoding::DefaultFuchsiaResourceDialect,
9434            >,
9435        >
9436        fidl::encoding::Encode<
9437            GuestGetHostVsockEndpointRequest,
9438            fidl::encoding::DefaultFuchsiaResourceDialect,
9439        > for (T0,)
9440    {
9441        #[inline]
9442        unsafe fn encode(
9443            self,
9444            encoder: &mut fidl::encoding::Encoder<
9445                '_,
9446                fidl::encoding::DefaultFuchsiaResourceDialect,
9447            >,
9448            offset: usize,
9449            depth: fidl::encoding::Depth,
9450        ) -> fidl::Result<()> {
9451            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9452            // Zero out padding regions. There's no need to apply masks
9453            // because the unmasked parts will be overwritten by fields.
9454            // Write the fields.
9455            self.0.encode(encoder, offset + 0, depth)?;
9456            Ok(())
9457        }
9458    }
9459
9460    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9461        for GuestGetHostVsockEndpointRequest
9462    {
9463        #[inline(always)]
9464        fn new_empty() -> Self {
9465            Self {
9466                endpoint: fidl::new_empty!(
9467                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9468                    fidl::encoding::DefaultFuchsiaResourceDialect
9469                ),
9470            }
9471        }
9472
9473        #[inline]
9474        unsafe fn decode(
9475            &mut self,
9476            decoder: &mut fidl::encoding::Decoder<
9477                '_,
9478                fidl::encoding::DefaultFuchsiaResourceDialect,
9479            >,
9480            offset: usize,
9481            _depth: fidl::encoding::Depth,
9482        ) -> fidl::Result<()> {
9483            decoder.debug_check_bounds::<Self>(offset);
9484            // Verify that padding bytes are zero.
9485            fidl::decode!(
9486                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9487                fidl::encoding::DefaultFuchsiaResourceDialect,
9488                &mut self.endpoint,
9489                decoder,
9490                offset + 0,
9491                _depth
9492            )?;
9493            Ok(())
9494        }
9495    }
9496
9497    impl fidl::encoding::ResourceTypeMarker for GuestGetMemControllerRequest {
9498        type Borrowed<'a> = &'a mut Self;
9499        fn take_or_borrow<'a>(
9500            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9501        ) -> Self::Borrowed<'a> {
9502            value
9503        }
9504    }
9505
9506    unsafe impl fidl::encoding::TypeMarker for GuestGetMemControllerRequest {
9507        type Owned = Self;
9508
9509        #[inline(always)]
9510        fn inline_align(_context: fidl::encoding::Context) -> usize {
9511            4
9512        }
9513
9514        #[inline(always)]
9515        fn inline_size(_context: fidl::encoding::Context) -> usize {
9516            4
9517        }
9518    }
9519
9520    unsafe impl
9521        fidl::encoding::Encode<
9522            GuestGetMemControllerRequest,
9523            fidl::encoding::DefaultFuchsiaResourceDialect,
9524        > for &mut GuestGetMemControllerRequest
9525    {
9526        #[inline]
9527        unsafe fn encode(
9528            self,
9529            encoder: &mut fidl::encoding::Encoder<
9530                '_,
9531                fidl::encoding::DefaultFuchsiaResourceDialect,
9532            >,
9533            offset: usize,
9534            _depth: fidl::encoding::Depth,
9535        ) -> fidl::Result<()> {
9536            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9537            // Delegate to tuple encoding.
9538            fidl::encoding::Encode::<GuestGetMemControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9539                (
9540                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9541                ),
9542                encoder, offset, _depth
9543            )
9544        }
9545    }
9546    unsafe impl<
9547            T0: fidl::encoding::Encode<
9548                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9549                fidl::encoding::DefaultFuchsiaResourceDialect,
9550            >,
9551        >
9552        fidl::encoding::Encode<
9553            GuestGetMemControllerRequest,
9554            fidl::encoding::DefaultFuchsiaResourceDialect,
9555        > for (T0,)
9556    {
9557        #[inline]
9558        unsafe fn encode(
9559            self,
9560            encoder: &mut fidl::encoding::Encoder<
9561                '_,
9562                fidl::encoding::DefaultFuchsiaResourceDialect,
9563            >,
9564            offset: usize,
9565            depth: fidl::encoding::Depth,
9566        ) -> fidl::Result<()> {
9567            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9568            // Zero out padding regions. There's no need to apply masks
9569            // because the unmasked parts will be overwritten by fields.
9570            // Write the fields.
9571            self.0.encode(encoder, offset + 0, depth)?;
9572            Ok(())
9573        }
9574    }
9575
9576    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9577        for GuestGetMemControllerRequest
9578    {
9579        #[inline(always)]
9580        fn new_empty() -> Self {
9581            Self {
9582                controller: fidl::new_empty!(
9583                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9584                    fidl::encoding::DefaultFuchsiaResourceDialect
9585                ),
9586            }
9587        }
9588
9589        #[inline]
9590        unsafe fn decode(
9591            &mut self,
9592            decoder: &mut fidl::encoding::Decoder<
9593                '_,
9594                fidl::encoding::DefaultFuchsiaResourceDialect,
9595            >,
9596            offset: usize,
9597            _depth: fidl::encoding::Depth,
9598        ) -> fidl::Result<()> {
9599            decoder.debug_check_bounds::<Self>(offset);
9600            // Verify that padding bytes are zero.
9601            fidl::decode!(
9602                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9603                fidl::encoding::DefaultFuchsiaResourceDialect,
9604                &mut self.controller,
9605                decoder,
9606                offset + 0,
9607                _depth
9608            )?;
9609            Ok(())
9610        }
9611    }
9612
9613    impl fidl::encoding::ResourceTypeMarker for GuestGetSerialResponse {
9614        type Borrowed<'a> = &'a mut Self;
9615        fn take_or_borrow<'a>(
9616            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9617        ) -> Self::Borrowed<'a> {
9618            value
9619        }
9620    }
9621
9622    unsafe impl fidl::encoding::TypeMarker for GuestGetSerialResponse {
9623        type Owned = Self;
9624
9625        #[inline(always)]
9626        fn inline_align(_context: fidl::encoding::Context) -> usize {
9627            4
9628        }
9629
9630        #[inline(always)]
9631        fn inline_size(_context: fidl::encoding::Context) -> usize {
9632            4
9633        }
9634    }
9635
9636    unsafe impl
9637        fidl::encoding::Encode<
9638            GuestGetSerialResponse,
9639            fidl::encoding::DefaultFuchsiaResourceDialect,
9640        > for &mut GuestGetSerialResponse
9641    {
9642        #[inline]
9643        unsafe fn encode(
9644            self,
9645            encoder: &mut fidl::encoding::Encoder<
9646                '_,
9647                fidl::encoding::DefaultFuchsiaResourceDialect,
9648            >,
9649            offset: usize,
9650            _depth: fidl::encoding::Depth,
9651        ) -> fidl::Result<()> {
9652            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9653            // Delegate to tuple encoding.
9654            fidl::encoding::Encode::<
9655                GuestGetSerialResponse,
9656                fidl::encoding::DefaultFuchsiaResourceDialect,
9657            >::encode(
9658                (<fidl::encoding::HandleType<
9659                    fidl::Socket,
9660                    { fidl::ObjectType::SOCKET.into_raw() },
9661                    2147483648,
9662                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9663                    &mut self.socket
9664                ),),
9665                encoder,
9666                offset,
9667                _depth,
9668            )
9669        }
9670    }
9671    unsafe impl<
9672            T0: fidl::encoding::Encode<
9673                fidl::encoding::HandleType<
9674                    fidl::Socket,
9675                    { fidl::ObjectType::SOCKET.into_raw() },
9676                    2147483648,
9677                >,
9678                fidl::encoding::DefaultFuchsiaResourceDialect,
9679            >,
9680        >
9681        fidl::encoding::Encode<
9682            GuestGetSerialResponse,
9683            fidl::encoding::DefaultFuchsiaResourceDialect,
9684        > for (T0,)
9685    {
9686        #[inline]
9687        unsafe fn encode(
9688            self,
9689            encoder: &mut fidl::encoding::Encoder<
9690                '_,
9691                fidl::encoding::DefaultFuchsiaResourceDialect,
9692            >,
9693            offset: usize,
9694            depth: fidl::encoding::Depth,
9695        ) -> fidl::Result<()> {
9696            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9697            // Zero out padding regions. There's no need to apply masks
9698            // because the unmasked parts will be overwritten by fields.
9699            // Write the fields.
9700            self.0.encode(encoder, offset + 0, depth)?;
9701            Ok(())
9702        }
9703    }
9704
9705    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9706        for GuestGetSerialResponse
9707    {
9708        #[inline(always)]
9709        fn new_empty() -> Self {
9710            Self {
9711                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9712            }
9713        }
9714
9715        #[inline]
9716        unsafe fn decode(
9717            &mut self,
9718            decoder: &mut fidl::encoding::Decoder<
9719                '_,
9720                fidl::encoding::DefaultFuchsiaResourceDialect,
9721            >,
9722            offset: usize,
9723            _depth: fidl::encoding::Depth,
9724        ) -> fidl::Result<()> {
9725            decoder.debug_check_bounds::<Self>(offset);
9726            // Verify that padding bytes are zero.
9727            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
9728            Ok(())
9729        }
9730    }
9731
9732    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleBindRequest {
9733        type Borrowed<'a> = &'a mut Self;
9734        fn take_or_borrow<'a>(
9735            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9736        ) -> Self::Borrowed<'a> {
9737            value
9738        }
9739    }
9740
9741    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleBindRequest {
9742        type Owned = Self;
9743
9744        #[inline(always)]
9745        fn inline_align(_context: fidl::encoding::Context) -> usize {
9746            4
9747        }
9748
9749        #[inline(always)]
9750        fn inline_size(_context: fidl::encoding::Context) -> usize {
9751            4
9752        }
9753    }
9754
9755    unsafe impl
9756        fidl::encoding::Encode<
9757            GuestLifecycleBindRequest,
9758            fidl::encoding::DefaultFuchsiaResourceDialect,
9759        > for &mut GuestLifecycleBindRequest
9760    {
9761        #[inline]
9762        unsafe fn encode(
9763            self,
9764            encoder: &mut fidl::encoding::Encoder<
9765                '_,
9766                fidl::encoding::DefaultFuchsiaResourceDialect,
9767            >,
9768            offset: usize,
9769            _depth: fidl::encoding::Depth,
9770        ) -> fidl::Result<()> {
9771            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9772            // Delegate to tuple encoding.
9773            fidl::encoding::Encode::<GuestLifecycleBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9774                (
9775                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest),
9776                ),
9777                encoder, offset, _depth
9778            )
9779        }
9780    }
9781    unsafe impl<
9782            T0: fidl::encoding::Encode<
9783                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9784                fidl::encoding::DefaultFuchsiaResourceDialect,
9785            >,
9786        >
9787        fidl::encoding::Encode<
9788            GuestLifecycleBindRequest,
9789            fidl::encoding::DefaultFuchsiaResourceDialect,
9790        > for (T0,)
9791    {
9792        #[inline]
9793        unsafe fn encode(
9794            self,
9795            encoder: &mut fidl::encoding::Encoder<
9796                '_,
9797                fidl::encoding::DefaultFuchsiaResourceDialect,
9798            >,
9799            offset: usize,
9800            depth: fidl::encoding::Depth,
9801        ) -> fidl::Result<()> {
9802            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9803            // Zero out padding regions. There's no need to apply masks
9804            // because the unmasked parts will be overwritten by fields.
9805            // Write the fields.
9806            self.0.encode(encoder, offset + 0, depth)?;
9807            Ok(())
9808        }
9809    }
9810
9811    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9812        for GuestLifecycleBindRequest
9813    {
9814        #[inline(always)]
9815        fn new_empty() -> Self {
9816            Self {
9817                guest: fidl::new_empty!(
9818                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9819                    fidl::encoding::DefaultFuchsiaResourceDialect
9820                ),
9821            }
9822        }
9823
9824        #[inline]
9825        unsafe fn decode(
9826            &mut self,
9827            decoder: &mut fidl::encoding::Decoder<
9828                '_,
9829                fidl::encoding::DefaultFuchsiaResourceDialect,
9830            >,
9831            offset: usize,
9832            _depth: fidl::encoding::Depth,
9833        ) -> fidl::Result<()> {
9834            decoder.debug_check_bounds::<Self>(offset);
9835            // Verify that padding bytes are zero.
9836            fidl::decode!(
9837                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9838                fidl::encoding::DefaultFuchsiaResourceDialect,
9839                &mut self.guest,
9840                decoder,
9841                offset + 0,
9842                _depth
9843            )?;
9844            Ok(())
9845        }
9846    }
9847
9848    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleCreateRequest {
9849        type Borrowed<'a> = &'a mut Self;
9850        fn take_or_borrow<'a>(
9851            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9852        ) -> Self::Borrowed<'a> {
9853            value
9854        }
9855    }
9856
9857    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleCreateRequest {
9858        type Owned = Self;
9859
9860        #[inline(always)]
9861        fn inline_align(_context: fidl::encoding::Context) -> usize {
9862            8
9863        }
9864
9865        #[inline(always)]
9866        fn inline_size(_context: fidl::encoding::Context) -> usize {
9867            16
9868        }
9869    }
9870
9871    unsafe impl
9872        fidl::encoding::Encode<
9873            GuestLifecycleCreateRequest,
9874            fidl::encoding::DefaultFuchsiaResourceDialect,
9875        > for &mut GuestLifecycleCreateRequest
9876    {
9877        #[inline]
9878        unsafe fn encode(
9879            self,
9880            encoder: &mut fidl::encoding::Encoder<
9881                '_,
9882                fidl::encoding::DefaultFuchsiaResourceDialect,
9883            >,
9884            offset: usize,
9885            _depth: fidl::encoding::Depth,
9886        ) -> fidl::Result<()> {
9887            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
9888            // Delegate to tuple encoding.
9889            fidl::encoding::Encode::<
9890                GuestLifecycleCreateRequest,
9891                fidl::encoding::DefaultFuchsiaResourceDialect,
9892            >::encode(
9893                (<GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9894                    &mut self.guest_config,
9895                ),),
9896                encoder,
9897                offset,
9898                _depth,
9899            )
9900        }
9901    }
9902    unsafe impl<
9903            T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
9904        >
9905        fidl::encoding::Encode<
9906            GuestLifecycleCreateRequest,
9907            fidl::encoding::DefaultFuchsiaResourceDialect,
9908        > for (T0,)
9909    {
9910        #[inline]
9911        unsafe fn encode(
9912            self,
9913            encoder: &mut fidl::encoding::Encoder<
9914                '_,
9915                fidl::encoding::DefaultFuchsiaResourceDialect,
9916            >,
9917            offset: usize,
9918            depth: fidl::encoding::Depth,
9919        ) -> fidl::Result<()> {
9920            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
9921            // Zero out padding regions. There's no need to apply masks
9922            // because the unmasked parts will be overwritten by fields.
9923            // Write the fields.
9924            self.0.encode(encoder, offset + 0, depth)?;
9925            Ok(())
9926        }
9927    }
9928
9929    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9930        for GuestLifecycleCreateRequest
9931    {
9932        #[inline(always)]
9933        fn new_empty() -> Self {
9934            Self {
9935                guest_config: fidl::new_empty!(
9936                    GuestConfig,
9937                    fidl::encoding::DefaultFuchsiaResourceDialect
9938                ),
9939            }
9940        }
9941
9942        #[inline]
9943        unsafe fn decode(
9944            &mut self,
9945            decoder: &mut fidl::encoding::Decoder<
9946                '_,
9947                fidl::encoding::DefaultFuchsiaResourceDialect,
9948            >,
9949            offset: usize,
9950            _depth: fidl::encoding::Depth,
9951        ) -> fidl::Result<()> {
9952            decoder.debug_check_bounds::<Self>(offset);
9953            // Verify that padding bytes are zero.
9954            fidl::decode!(
9955                GuestConfig,
9956                fidl::encoding::DefaultFuchsiaResourceDialect,
9957                &mut self.guest_config,
9958                decoder,
9959                offset + 0,
9960                _depth
9961            )?;
9962            Ok(())
9963        }
9964    }
9965
9966    impl fidl::encoding::ResourceTypeMarker for GuestManagerConnectRequest {
9967        type Borrowed<'a> = &'a mut Self;
9968        fn take_or_borrow<'a>(
9969            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9970        ) -> Self::Borrowed<'a> {
9971            value
9972        }
9973    }
9974
9975    unsafe impl fidl::encoding::TypeMarker for GuestManagerConnectRequest {
9976        type Owned = Self;
9977
9978        #[inline(always)]
9979        fn inline_align(_context: fidl::encoding::Context) -> usize {
9980            4
9981        }
9982
9983        #[inline(always)]
9984        fn inline_size(_context: fidl::encoding::Context) -> usize {
9985            4
9986        }
9987    }
9988
9989    unsafe impl
9990        fidl::encoding::Encode<
9991            GuestManagerConnectRequest,
9992            fidl::encoding::DefaultFuchsiaResourceDialect,
9993        > for &mut GuestManagerConnectRequest
9994    {
9995        #[inline]
9996        unsafe fn encode(
9997            self,
9998            encoder: &mut fidl::encoding::Encoder<
9999                '_,
10000                fidl::encoding::DefaultFuchsiaResourceDialect,
10001            >,
10002            offset: usize,
10003            _depth: fidl::encoding::Depth,
10004        ) -> fidl::Result<()> {
10005            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
10006            // Delegate to tuple encoding.
10007            fidl::encoding::Encode::<GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10008                (
10009                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10010                ),
10011                encoder, offset, _depth
10012            )
10013        }
10014    }
10015    unsafe impl<
10016            T0: fidl::encoding::Encode<
10017                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10018                fidl::encoding::DefaultFuchsiaResourceDialect,
10019            >,
10020        >
10021        fidl::encoding::Encode<
10022            GuestManagerConnectRequest,
10023            fidl::encoding::DefaultFuchsiaResourceDialect,
10024        > for (T0,)
10025    {
10026        #[inline]
10027        unsafe fn encode(
10028            self,
10029            encoder: &mut fidl::encoding::Encoder<
10030                '_,
10031                fidl::encoding::DefaultFuchsiaResourceDialect,
10032            >,
10033            offset: usize,
10034            depth: fidl::encoding::Depth,
10035        ) -> fidl::Result<()> {
10036            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
10037            // Zero out padding regions. There's no need to apply masks
10038            // because the unmasked parts will be overwritten by fields.
10039            // Write the fields.
10040            self.0.encode(encoder, offset + 0, depth)?;
10041            Ok(())
10042        }
10043    }
10044
10045    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10046        for GuestManagerConnectRequest
10047    {
10048        #[inline(always)]
10049        fn new_empty() -> Self {
10050            Self {
10051                controller: fidl::new_empty!(
10052                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10053                    fidl::encoding::DefaultFuchsiaResourceDialect
10054                ),
10055            }
10056        }
10057
10058        #[inline]
10059        unsafe fn decode(
10060            &mut self,
10061            decoder: &mut fidl::encoding::Decoder<
10062                '_,
10063                fidl::encoding::DefaultFuchsiaResourceDialect,
10064            >,
10065            offset: usize,
10066            _depth: fidl::encoding::Depth,
10067        ) -> fidl::Result<()> {
10068            decoder.debug_check_bounds::<Self>(offset);
10069            // Verify that padding bytes are zero.
10070            fidl::decode!(
10071                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10072                fidl::encoding::DefaultFuchsiaResourceDialect,
10073                &mut self.controller,
10074                decoder,
10075                offset + 0,
10076                _depth
10077            )?;
10078            Ok(())
10079        }
10080    }
10081
10082    impl fidl::encoding::ResourceTypeMarker for GuestManagerGetInfoResponse {
10083        type Borrowed<'a> = &'a mut Self;
10084        fn take_or_borrow<'a>(
10085            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10086        ) -> Self::Borrowed<'a> {
10087            value
10088        }
10089    }
10090
10091    unsafe impl fidl::encoding::TypeMarker for GuestManagerGetInfoResponse {
10092        type Owned = Self;
10093
10094        #[inline(always)]
10095        fn inline_align(_context: fidl::encoding::Context) -> usize {
10096            8
10097        }
10098
10099        #[inline(always)]
10100        fn inline_size(_context: fidl::encoding::Context) -> usize {
10101            16
10102        }
10103    }
10104
10105    unsafe impl
10106        fidl::encoding::Encode<
10107            GuestManagerGetInfoResponse,
10108            fidl::encoding::DefaultFuchsiaResourceDialect,
10109        > for &mut GuestManagerGetInfoResponse
10110    {
10111        #[inline]
10112        unsafe fn encode(
10113            self,
10114            encoder: &mut fidl::encoding::Encoder<
10115                '_,
10116                fidl::encoding::DefaultFuchsiaResourceDialect,
10117            >,
10118            offset: usize,
10119            _depth: fidl::encoding::Depth,
10120        ) -> fidl::Result<()> {
10121            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10122            // Delegate to tuple encoding.
10123            fidl::encoding::Encode::<
10124                GuestManagerGetInfoResponse,
10125                fidl::encoding::DefaultFuchsiaResourceDialect,
10126            >::encode(
10127                (<GuestInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.guest_info),),
10128                encoder,
10129                offset,
10130                _depth,
10131            )
10132        }
10133    }
10134    unsafe impl<T0: fidl::encoding::Encode<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>>
10135        fidl::encoding::Encode<
10136            GuestManagerGetInfoResponse,
10137            fidl::encoding::DefaultFuchsiaResourceDialect,
10138        > for (T0,)
10139    {
10140        #[inline]
10141        unsafe fn encode(
10142            self,
10143            encoder: &mut fidl::encoding::Encoder<
10144                '_,
10145                fidl::encoding::DefaultFuchsiaResourceDialect,
10146            >,
10147            offset: usize,
10148            depth: fidl::encoding::Depth,
10149        ) -> fidl::Result<()> {
10150            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10151            // Zero out padding regions. There's no need to apply masks
10152            // because the unmasked parts will be overwritten by fields.
10153            // Write the fields.
10154            self.0.encode(encoder, offset + 0, depth)?;
10155            Ok(())
10156        }
10157    }
10158
10159    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10160        for GuestManagerGetInfoResponse
10161    {
10162        #[inline(always)]
10163        fn new_empty() -> Self {
10164            Self {
10165                guest_info: fidl::new_empty!(
10166                    GuestInfo,
10167                    fidl::encoding::DefaultFuchsiaResourceDialect
10168                ),
10169            }
10170        }
10171
10172        #[inline]
10173        unsafe fn decode(
10174            &mut self,
10175            decoder: &mut fidl::encoding::Decoder<
10176                '_,
10177                fidl::encoding::DefaultFuchsiaResourceDialect,
10178            >,
10179            offset: usize,
10180            _depth: fidl::encoding::Depth,
10181        ) -> fidl::Result<()> {
10182            decoder.debug_check_bounds::<Self>(offset);
10183            // Verify that padding bytes are zero.
10184            fidl::decode!(
10185                GuestInfo,
10186                fidl::encoding::DefaultFuchsiaResourceDialect,
10187                &mut self.guest_info,
10188                decoder,
10189                offset + 0,
10190                _depth
10191            )?;
10192            Ok(())
10193        }
10194    }
10195
10196    impl fidl::encoding::ResourceTypeMarker for GuestManagerLaunchRequest {
10197        type Borrowed<'a> = &'a mut Self;
10198        fn take_or_borrow<'a>(
10199            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10200        ) -> Self::Borrowed<'a> {
10201            value
10202        }
10203    }
10204
10205    unsafe impl fidl::encoding::TypeMarker for GuestManagerLaunchRequest {
10206        type Owned = Self;
10207
10208        #[inline(always)]
10209        fn inline_align(_context: fidl::encoding::Context) -> usize {
10210            8
10211        }
10212
10213        #[inline(always)]
10214        fn inline_size(_context: fidl::encoding::Context) -> usize {
10215            24
10216        }
10217    }
10218
10219    unsafe impl
10220        fidl::encoding::Encode<
10221            GuestManagerLaunchRequest,
10222            fidl::encoding::DefaultFuchsiaResourceDialect,
10223        > for &mut GuestManagerLaunchRequest
10224    {
10225        #[inline]
10226        unsafe fn encode(
10227            self,
10228            encoder: &mut fidl::encoding::Encoder<
10229                '_,
10230                fidl::encoding::DefaultFuchsiaResourceDialect,
10231            >,
10232            offset: usize,
10233            _depth: fidl::encoding::Depth,
10234        ) -> fidl::Result<()> {
10235            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10236            // Delegate to tuple encoding.
10237            fidl::encoding::Encode::<GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10238                (
10239                    <GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest_config),
10240                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10241                ),
10242                encoder, offset, _depth
10243            )
10244        }
10245    }
10246    unsafe impl<
10247            T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
10248            T1: fidl::encoding::Encode<
10249                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10250                fidl::encoding::DefaultFuchsiaResourceDialect,
10251            >,
10252        >
10253        fidl::encoding::Encode<
10254            GuestManagerLaunchRequest,
10255            fidl::encoding::DefaultFuchsiaResourceDialect,
10256        > for (T0, T1)
10257    {
10258        #[inline]
10259        unsafe fn encode(
10260            self,
10261            encoder: &mut fidl::encoding::Encoder<
10262                '_,
10263                fidl::encoding::DefaultFuchsiaResourceDialect,
10264            >,
10265            offset: usize,
10266            depth: fidl::encoding::Depth,
10267        ) -> fidl::Result<()> {
10268            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10269            // Zero out padding regions. There's no need to apply masks
10270            // because the unmasked parts will be overwritten by fields.
10271            unsafe {
10272                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10273                (ptr as *mut u64).write_unaligned(0);
10274            }
10275            // Write the fields.
10276            self.0.encode(encoder, offset + 0, depth)?;
10277            self.1.encode(encoder, offset + 16, depth)?;
10278            Ok(())
10279        }
10280    }
10281
10282    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10283        for GuestManagerLaunchRequest
10284    {
10285        #[inline(always)]
10286        fn new_empty() -> Self {
10287            Self {
10288                guest_config: fidl::new_empty!(
10289                    GuestConfig,
10290                    fidl::encoding::DefaultFuchsiaResourceDialect
10291                ),
10292                controller: fidl::new_empty!(
10293                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10294                    fidl::encoding::DefaultFuchsiaResourceDialect
10295                ),
10296            }
10297        }
10298
10299        #[inline]
10300        unsafe fn decode(
10301            &mut self,
10302            decoder: &mut fidl::encoding::Decoder<
10303                '_,
10304                fidl::encoding::DefaultFuchsiaResourceDialect,
10305            >,
10306            offset: usize,
10307            _depth: fidl::encoding::Depth,
10308        ) -> fidl::Result<()> {
10309            decoder.debug_check_bounds::<Self>(offset);
10310            // Verify that padding bytes are zero.
10311            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10312            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10313            let mask = 0xffffffff00000000u64;
10314            let maskedval = padval & mask;
10315            if maskedval != 0 {
10316                return Err(fidl::Error::NonZeroPadding {
10317                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10318                });
10319            }
10320            fidl::decode!(
10321                GuestConfig,
10322                fidl::encoding::DefaultFuchsiaResourceDialect,
10323                &mut self.guest_config,
10324                decoder,
10325                offset + 0,
10326                _depth
10327            )?;
10328            fidl::decode!(
10329                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10330                fidl::encoding::DefaultFuchsiaResourceDialect,
10331                &mut self.controller,
10332                decoder,
10333                offset + 16,
10334                _depth
10335            )?;
10336            Ok(())
10337        }
10338    }
10339
10340    impl fidl::encoding::ResourceTypeMarker for GuestGetConsoleResponse {
10341        type Borrowed<'a> = &'a mut Self;
10342        fn take_or_borrow<'a>(
10343            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10344        ) -> Self::Borrowed<'a> {
10345            value
10346        }
10347    }
10348
10349    unsafe impl fidl::encoding::TypeMarker for GuestGetConsoleResponse {
10350        type Owned = Self;
10351
10352        #[inline(always)]
10353        fn inline_align(_context: fidl::encoding::Context) -> usize {
10354            4
10355        }
10356
10357        #[inline(always)]
10358        fn inline_size(_context: fidl::encoding::Context) -> usize {
10359            4
10360        }
10361    }
10362
10363    unsafe impl
10364        fidl::encoding::Encode<
10365            GuestGetConsoleResponse,
10366            fidl::encoding::DefaultFuchsiaResourceDialect,
10367        > for &mut GuestGetConsoleResponse
10368    {
10369        #[inline]
10370        unsafe fn encode(
10371            self,
10372            encoder: &mut fidl::encoding::Encoder<
10373                '_,
10374                fidl::encoding::DefaultFuchsiaResourceDialect,
10375            >,
10376            offset: usize,
10377            _depth: fidl::encoding::Depth,
10378        ) -> fidl::Result<()> {
10379            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10380            // Delegate to tuple encoding.
10381            fidl::encoding::Encode::<
10382                GuestGetConsoleResponse,
10383                fidl::encoding::DefaultFuchsiaResourceDialect,
10384            >::encode(
10385                (<fidl::encoding::HandleType<
10386                    fidl::Socket,
10387                    { fidl::ObjectType::SOCKET.into_raw() },
10388                    2147483648,
10389                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10390                    &mut self.socket
10391                ),),
10392                encoder,
10393                offset,
10394                _depth,
10395            )
10396        }
10397    }
10398    unsafe impl<
10399            T0: fidl::encoding::Encode<
10400                fidl::encoding::HandleType<
10401                    fidl::Socket,
10402                    { fidl::ObjectType::SOCKET.into_raw() },
10403                    2147483648,
10404                >,
10405                fidl::encoding::DefaultFuchsiaResourceDialect,
10406            >,
10407        >
10408        fidl::encoding::Encode<
10409            GuestGetConsoleResponse,
10410            fidl::encoding::DefaultFuchsiaResourceDialect,
10411        > for (T0,)
10412    {
10413        #[inline]
10414        unsafe fn encode(
10415            self,
10416            encoder: &mut fidl::encoding::Encoder<
10417                '_,
10418                fidl::encoding::DefaultFuchsiaResourceDialect,
10419            >,
10420            offset: usize,
10421            depth: fidl::encoding::Depth,
10422        ) -> fidl::Result<()> {
10423            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10424            // Zero out padding regions. There's no need to apply masks
10425            // because the unmasked parts will be overwritten by fields.
10426            // Write the fields.
10427            self.0.encode(encoder, offset + 0, depth)?;
10428            Ok(())
10429        }
10430    }
10431
10432    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10433        for GuestGetConsoleResponse
10434    {
10435        #[inline(always)]
10436        fn new_empty() -> Self {
10437            Self {
10438                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10439            }
10440        }
10441
10442        #[inline]
10443        unsafe fn decode(
10444            &mut self,
10445            decoder: &mut fidl::encoding::Decoder<
10446                '_,
10447                fidl::encoding::DefaultFuchsiaResourceDialect,
10448            >,
10449            offset: usize,
10450            _depth: fidl::encoding::Depth,
10451        ) -> fidl::Result<()> {
10452            decoder.debug_check_bounds::<Self>(offset);
10453            // Verify that padding bytes are zero.
10454            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10455            Ok(())
10456        }
10457    }
10458
10459    impl fidl::encoding::ResourceTypeMarker for HostVsockAcceptorAcceptResponse {
10460        type Borrowed<'a> = &'a mut Self;
10461        fn take_or_borrow<'a>(
10462            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10463        ) -> Self::Borrowed<'a> {
10464            value
10465        }
10466    }
10467
10468    unsafe impl fidl::encoding::TypeMarker for HostVsockAcceptorAcceptResponse {
10469        type Owned = Self;
10470
10471        #[inline(always)]
10472        fn inline_align(_context: fidl::encoding::Context) -> usize {
10473            4
10474        }
10475
10476        #[inline(always)]
10477        fn inline_size(_context: fidl::encoding::Context) -> usize {
10478            4
10479        }
10480    }
10481
10482    unsafe impl
10483        fidl::encoding::Encode<
10484            HostVsockAcceptorAcceptResponse,
10485            fidl::encoding::DefaultFuchsiaResourceDialect,
10486        > for &mut HostVsockAcceptorAcceptResponse
10487    {
10488        #[inline]
10489        unsafe fn encode(
10490            self,
10491            encoder: &mut fidl::encoding::Encoder<
10492                '_,
10493                fidl::encoding::DefaultFuchsiaResourceDialect,
10494            >,
10495            offset: usize,
10496            _depth: fidl::encoding::Depth,
10497        ) -> fidl::Result<()> {
10498            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10499            // Delegate to tuple encoding.
10500            fidl::encoding::Encode::<
10501                HostVsockAcceptorAcceptResponse,
10502                fidl::encoding::DefaultFuchsiaResourceDialect,
10503            >::encode(
10504                (<fidl::encoding::HandleType<
10505                    fidl::Socket,
10506                    { fidl::ObjectType::SOCKET.into_raw() },
10507                    2147483648,
10508                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10509                    &mut self.socket
10510                ),),
10511                encoder,
10512                offset,
10513                _depth,
10514            )
10515        }
10516    }
10517    unsafe impl<
10518            T0: fidl::encoding::Encode<
10519                fidl::encoding::HandleType<
10520                    fidl::Socket,
10521                    { fidl::ObjectType::SOCKET.into_raw() },
10522                    2147483648,
10523                >,
10524                fidl::encoding::DefaultFuchsiaResourceDialect,
10525            >,
10526        >
10527        fidl::encoding::Encode<
10528            HostVsockAcceptorAcceptResponse,
10529            fidl::encoding::DefaultFuchsiaResourceDialect,
10530        > for (T0,)
10531    {
10532        #[inline]
10533        unsafe fn encode(
10534            self,
10535            encoder: &mut fidl::encoding::Encoder<
10536                '_,
10537                fidl::encoding::DefaultFuchsiaResourceDialect,
10538            >,
10539            offset: usize,
10540            depth: fidl::encoding::Depth,
10541        ) -> fidl::Result<()> {
10542            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10543            // Zero out padding regions. There's no need to apply masks
10544            // because the unmasked parts will be overwritten by fields.
10545            // Write the fields.
10546            self.0.encode(encoder, offset + 0, depth)?;
10547            Ok(())
10548        }
10549    }
10550
10551    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10552        for HostVsockAcceptorAcceptResponse
10553    {
10554        #[inline(always)]
10555        fn new_empty() -> Self {
10556            Self {
10557                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10558            }
10559        }
10560
10561        #[inline]
10562        unsafe fn decode(
10563            &mut self,
10564            decoder: &mut fidl::encoding::Decoder<
10565                '_,
10566                fidl::encoding::DefaultFuchsiaResourceDialect,
10567            >,
10568            offset: usize,
10569            _depth: fidl::encoding::Depth,
10570        ) -> fidl::Result<()> {
10571            decoder.debug_check_bounds::<Self>(offset);
10572            // Verify that padding bytes are zero.
10573            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10574            Ok(())
10575        }
10576    }
10577
10578    impl fidl::encoding::ResourceTypeMarker for HostVsockEndpointConnectResponse {
10579        type Borrowed<'a> = &'a mut Self;
10580        fn take_or_borrow<'a>(
10581            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10582        ) -> Self::Borrowed<'a> {
10583            value
10584        }
10585    }
10586
10587    unsafe impl fidl::encoding::TypeMarker for HostVsockEndpointConnectResponse {
10588        type Owned = Self;
10589
10590        #[inline(always)]
10591        fn inline_align(_context: fidl::encoding::Context) -> usize {
10592            4
10593        }
10594
10595        #[inline(always)]
10596        fn inline_size(_context: fidl::encoding::Context) -> usize {
10597            4
10598        }
10599    }
10600
10601    unsafe impl
10602        fidl::encoding::Encode<
10603            HostVsockEndpointConnectResponse,
10604            fidl::encoding::DefaultFuchsiaResourceDialect,
10605        > for &mut HostVsockEndpointConnectResponse
10606    {
10607        #[inline]
10608        unsafe fn encode(
10609            self,
10610            encoder: &mut fidl::encoding::Encoder<
10611                '_,
10612                fidl::encoding::DefaultFuchsiaResourceDialect,
10613            >,
10614            offset: usize,
10615            _depth: fidl::encoding::Depth,
10616        ) -> fidl::Result<()> {
10617            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10618            // Delegate to tuple encoding.
10619            fidl::encoding::Encode::<
10620                HostVsockEndpointConnectResponse,
10621                fidl::encoding::DefaultFuchsiaResourceDialect,
10622            >::encode(
10623                (<fidl::encoding::HandleType<
10624                    fidl::Socket,
10625                    { fidl::ObjectType::SOCKET.into_raw() },
10626                    2147483648,
10627                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10628                    &mut self.socket
10629                ),),
10630                encoder,
10631                offset,
10632                _depth,
10633            )
10634        }
10635    }
10636    unsafe impl<
10637            T0: fidl::encoding::Encode<
10638                fidl::encoding::HandleType<
10639                    fidl::Socket,
10640                    { fidl::ObjectType::SOCKET.into_raw() },
10641                    2147483648,
10642                >,
10643                fidl::encoding::DefaultFuchsiaResourceDialect,
10644            >,
10645        >
10646        fidl::encoding::Encode<
10647            HostVsockEndpointConnectResponse,
10648            fidl::encoding::DefaultFuchsiaResourceDialect,
10649        > for (T0,)
10650    {
10651        #[inline]
10652        unsafe fn encode(
10653            self,
10654            encoder: &mut fidl::encoding::Encoder<
10655                '_,
10656                fidl::encoding::DefaultFuchsiaResourceDialect,
10657            >,
10658            offset: usize,
10659            depth: fidl::encoding::Depth,
10660        ) -> fidl::Result<()> {
10661            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10662            // Zero out padding regions. There's no need to apply masks
10663            // because the unmasked parts will be overwritten by fields.
10664            // Write the fields.
10665            self.0.encode(encoder, offset + 0, depth)?;
10666            Ok(())
10667        }
10668    }
10669
10670    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10671        for HostVsockEndpointConnectResponse
10672    {
10673        #[inline(always)]
10674        fn new_empty() -> Self {
10675            Self {
10676                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10677            }
10678        }
10679
10680        #[inline]
10681        unsafe fn decode(
10682            &mut self,
10683            decoder: &mut fidl::encoding::Decoder<
10684                '_,
10685                fidl::encoding::DefaultFuchsiaResourceDialect,
10686            >,
10687            offset: usize,
10688            _depth: fidl::encoding::Depth,
10689        ) -> fidl::Result<()> {
10690            decoder.debug_check_bounds::<Self>(offset);
10691            // Verify that padding bytes are zero.
10692            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10693            Ok(())
10694        }
10695    }
10696
10697    impl fidl::encoding::ResourceTypeMarker for Listener {
10698        type Borrowed<'a> = &'a mut Self;
10699        fn take_or_borrow<'a>(
10700            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10701        ) -> Self::Borrowed<'a> {
10702            value
10703        }
10704    }
10705
10706    unsafe impl fidl::encoding::TypeMarker for Listener {
10707        type Owned = Self;
10708
10709        #[inline(always)]
10710        fn inline_align(_context: fidl::encoding::Context) -> usize {
10711            4
10712        }
10713
10714        #[inline(always)]
10715        fn inline_size(_context: fidl::encoding::Context) -> usize {
10716            8
10717        }
10718    }
10719
10720    unsafe impl fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>
10721        for &mut Listener
10722    {
10723        #[inline]
10724        unsafe fn encode(
10725            self,
10726            encoder: &mut fidl::encoding::Encoder<
10727                '_,
10728                fidl::encoding::DefaultFuchsiaResourceDialect,
10729            >,
10730            offset: usize,
10731            _depth: fidl::encoding::Depth,
10732        ) -> fidl::Result<()> {
10733            encoder.debug_check_bounds::<Listener>(offset);
10734            // Delegate to tuple encoding.
10735            fidl::encoding::Encode::<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10736                (
10737                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.port),
10738                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.acceptor),
10739                ),
10740                encoder, offset, _depth
10741            )
10742        }
10743    }
10744    unsafe impl<
10745            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
10746            T1: fidl::encoding::Encode<
10747                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10748                fidl::encoding::DefaultFuchsiaResourceDialect,
10749            >,
10750        > fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>
10751        for (T0, T1)
10752    {
10753        #[inline]
10754        unsafe fn encode(
10755            self,
10756            encoder: &mut fidl::encoding::Encoder<
10757                '_,
10758                fidl::encoding::DefaultFuchsiaResourceDialect,
10759            >,
10760            offset: usize,
10761            depth: fidl::encoding::Depth,
10762        ) -> fidl::Result<()> {
10763            encoder.debug_check_bounds::<Listener>(offset);
10764            // Zero out padding regions. There's no need to apply masks
10765            // because the unmasked parts will be overwritten by fields.
10766            // Write the fields.
10767            self.0.encode(encoder, offset + 0, depth)?;
10768            self.1.encode(encoder, offset + 4, depth)?;
10769            Ok(())
10770        }
10771    }
10772
10773    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Listener {
10774        #[inline(always)]
10775        fn new_empty() -> Self {
10776            Self {
10777                port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
10778                acceptor: fidl::new_empty!(
10779                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10780                    fidl::encoding::DefaultFuchsiaResourceDialect
10781                ),
10782            }
10783        }
10784
10785        #[inline]
10786        unsafe fn decode(
10787            &mut self,
10788            decoder: &mut fidl::encoding::Decoder<
10789                '_,
10790                fidl::encoding::DefaultFuchsiaResourceDialect,
10791            >,
10792            offset: usize,
10793            _depth: fidl::encoding::Depth,
10794        ) -> fidl::Result<()> {
10795            decoder.debug_check_bounds::<Self>(offset);
10796            // Verify that padding bytes are zero.
10797            fidl::decode!(
10798                u32,
10799                fidl::encoding::DefaultFuchsiaResourceDialect,
10800                &mut self.port,
10801                decoder,
10802                offset + 0,
10803                _depth
10804            )?;
10805            fidl::decode!(
10806                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10807                fidl::encoding::DefaultFuchsiaResourceDialect,
10808                &mut self.acceptor,
10809                decoder,
10810                offset + 4,
10811                _depth
10812            )?;
10813            Ok(())
10814        }
10815    }
10816
10817    impl fidl::encoding::ResourceTypeMarker for WaylandDevice {
10818        type Borrowed<'a> = &'a mut Self;
10819        fn take_or_borrow<'a>(
10820            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10821        ) -> Self::Borrowed<'a> {
10822            value
10823        }
10824    }
10825
10826    unsafe impl fidl::encoding::TypeMarker for WaylandDevice {
10827        type Owned = Self;
10828
10829        #[inline(always)]
10830        fn inline_align(_context: fidl::encoding::Context) -> usize {
10831            8
10832        }
10833
10834        #[inline(always)]
10835        fn inline_size(_context: fidl::encoding::Context) -> usize {
10836            16
10837        }
10838    }
10839
10840    unsafe impl fidl::encoding::Encode<WaylandDevice, fidl::encoding::DefaultFuchsiaResourceDialect>
10841        for &mut WaylandDevice
10842    {
10843        #[inline]
10844        unsafe fn encode(
10845            self,
10846            encoder: &mut fidl::encoding::Encoder<
10847                '_,
10848                fidl::encoding::DefaultFuchsiaResourceDialect,
10849            >,
10850            offset: usize,
10851            _depth: fidl::encoding::Depth,
10852        ) -> fidl::Result<()> {
10853            encoder.debug_check_bounds::<WaylandDevice>(offset);
10854            // Delegate to tuple encoding.
10855            fidl::encoding::Encode::<WaylandDevice, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10856                (
10857                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.memory),
10858                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server),
10859                ),
10860                encoder, offset, _depth
10861            )
10862        }
10863    }
10864    unsafe impl<
10865            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
10866            T1: fidl::encoding::Encode<
10867                fidl::encoding::Optional<
10868                    fidl::encoding::Endpoint<
10869                        fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
10870                    >,
10871                >,
10872                fidl::encoding::DefaultFuchsiaResourceDialect,
10873            >,
10874        > fidl::encoding::Encode<WaylandDevice, fidl::encoding::DefaultFuchsiaResourceDialect>
10875        for (T0, T1)
10876    {
10877        #[inline]
10878        unsafe fn encode(
10879            self,
10880            encoder: &mut fidl::encoding::Encoder<
10881                '_,
10882                fidl::encoding::DefaultFuchsiaResourceDialect,
10883            >,
10884            offset: usize,
10885            depth: fidl::encoding::Depth,
10886        ) -> fidl::Result<()> {
10887            encoder.debug_check_bounds::<WaylandDevice>(offset);
10888            // Zero out padding regions. There's no need to apply masks
10889            // because the unmasked parts will be overwritten by fields.
10890            unsafe {
10891                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
10892                (ptr as *mut u64).write_unaligned(0);
10893            }
10894            // Write the fields.
10895            self.0.encode(encoder, offset + 0, depth)?;
10896            self.1.encode(encoder, offset + 8, depth)?;
10897            Ok(())
10898        }
10899    }
10900
10901    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for WaylandDevice {
10902        #[inline(always)]
10903        fn new_empty() -> Self {
10904            Self {
10905                memory: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
10906                server: fidl::new_empty!(
10907                    fidl::encoding::Optional<
10908                        fidl::encoding::Endpoint<
10909                            fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
10910                        >,
10911                    >,
10912                    fidl::encoding::DefaultFuchsiaResourceDialect
10913                ),
10914            }
10915        }
10916
10917        #[inline]
10918        unsafe fn decode(
10919            &mut self,
10920            decoder: &mut fidl::encoding::Decoder<
10921                '_,
10922                fidl::encoding::DefaultFuchsiaResourceDialect,
10923            >,
10924            offset: usize,
10925            _depth: fidl::encoding::Depth,
10926        ) -> fidl::Result<()> {
10927            decoder.debug_check_bounds::<Self>(offset);
10928            // Verify that padding bytes are zero.
10929            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
10930            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10931            let mask = 0xffffffff00000000u64;
10932            let maskedval = padval & mask;
10933            if maskedval != 0 {
10934                return Err(fidl::Error::NonZeroPadding {
10935                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
10936                });
10937            }
10938            fidl::decode!(
10939                u64,
10940                fidl::encoding::DefaultFuchsiaResourceDialect,
10941                &mut self.memory,
10942                decoder,
10943                offset + 0,
10944                _depth
10945            )?;
10946            fidl::decode!(
10947                fidl::encoding::Optional<
10948                    fidl::encoding::Endpoint<
10949                        fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
10950                    >,
10951                >,
10952                fidl::encoding::DefaultFuchsiaResourceDialect,
10953                &mut self.server,
10954                decoder,
10955                offset + 8,
10956                _depth
10957            )?;
10958            Ok(())
10959        }
10960    }
10961
10962    impl GuestConfig {
10963        #[inline(always)]
10964        fn max_ordinal_present(&self) -> u64 {
10965            if let Some(_) = self.virtio_mem_region_alignment {
10966                return 25;
10967            }
10968            if let Some(_) = self.virtio_mem_region_size {
10969                return 24;
10970            }
10971            if let Some(_) = self.virtio_mem_block_size {
10972                return 23;
10973            }
10974            if let Some(_) = self.virtio_mem {
10975                return 22;
10976            }
10977            if let Some(_) = self.vsock_listeners {
10978                return 21;
10979            }
10980            if let Some(_) = self.virtio_sound_input {
10981                return 20;
10982            }
10983            if let Some(_) = self.virtio_sound {
10984                return 19;
10985            }
10986            if let Some(_) = self.virtio_vsock {
10987                return 18;
10988            }
10989            if let Some(_) = self.virtio_rng {
10990                return 17;
10991            }
10992            if let Some(_) = self.virtio_gpu {
10993                return 16;
10994            }
10995            if let Some(_) = self.virtio_console {
10996                return 15;
10997            }
10998            if let Some(_) = self.virtio_balloon {
10999                return 14;
11000            }
11001            if let Some(_) = self.default_net {
11002                return 13;
11003            }
11004            if let Some(_) = self.magma_device {
11005                return 12;
11006            }
11007            if let Some(_) = self.wayland_device {
11008                return 11;
11009            }
11010            if let Some(_) = self.net_devices {
11011                return 10;
11012            }
11013            if let Some(_) = self.block_devices {
11014                return 9;
11015            }
11016            if let Some(_) = self.guest_memory {
11017                return 8;
11018            }
11019            if let Some(_) = self.cpus {
11020                return 7;
11021            }
11022            if let Some(_) = self.cmdline_add {
11023                return 6;
11024            }
11025            if let Some(_) = self.cmdline {
11026                return 5;
11027            }
11028            if let Some(_) = self.dtb_overlay {
11029                return 4;
11030            }
11031            if let Some(_) = self.ramdisk {
11032                return 3;
11033            }
11034            if let Some(_) = self.kernel {
11035                return 2;
11036            }
11037            if let Some(_) = self.kernel_type {
11038                return 1;
11039            }
11040            0
11041        }
11042    }
11043
11044    impl fidl::encoding::ResourceTypeMarker for GuestConfig {
11045        type Borrowed<'a> = &'a mut Self;
11046        fn take_or_borrow<'a>(
11047            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11048        ) -> Self::Borrowed<'a> {
11049            value
11050        }
11051    }
11052
11053    unsafe impl fidl::encoding::TypeMarker for GuestConfig {
11054        type Owned = Self;
11055
11056        #[inline(always)]
11057        fn inline_align(_context: fidl::encoding::Context) -> usize {
11058            8
11059        }
11060
11061        #[inline(always)]
11062        fn inline_size(_context: fidl::encoding::Context) -> usize {
11063            16
11064        }
11065    }
11066
11067    unsafe impl fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
11068        for &mut GuestConfig
11069    {
11070        unsafe fn encode(
11071            self,
11072            encoder: &mut fidl::encoding::Encoder<
11073                '_,
11074                fidl::encoding::DefaultFuchsiaResourceDialect,
11075            >,
11076            offset: usize,
11077            mut depth: fidl::encoding::Depth,
11078        ) -> fidl::Result<()> {
11079            encoder.debug_check_bounds::<GuestConfig>(offset);
11080            // Vector header
11081            let max_ordinal: u64 = self.max_ordinal_present();
11082            encoder.write_num(max_ordinal, offset);
11083            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11084            // Calling encoder.out_of_line_offset(0) is not allowed.
11085            if max_ordinal == 0 {
11086                return Ok(());
11087            }
11088            depth.increment()?;
11089            let envelope_size = 8;
11090            let bytes_len = max_ordinal as usize * envelope_size;
11091            #[allow(unused_variables)]
11092            let offset = encoder.out_of_line_offset(bytes_len);
11093            let mut _prev_end_offset: usize = 0;
11094            if 1 > max_ordinal {
11095                return Ok(());
11096            }
11097
11098            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11099            // are envelope_size bytes.
11100            let cur_offset: usize = (1 - 1) * envelope_size;
11101
11102            // Zero reserved fields.
11103            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11104
11105            // Safety:
11106            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11107            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11108            //   envelope_size bytes, there is always sufficient room.
11109            fidl::encoding::encode_in_envelope_optional::<
11110                KernelType,
11111                fidl::encoding::DefaultFuchsiaResourceDialect,
11112            >(
11113                self.kernel_type
11114                    .as_ref()
11115                    .map(<KernelType as fidl::encoding::ValueTypeMarker>::borrow),
11116                encoder,
11117                offset + cur_offset,
11118                depth,
11119            )?;
11120
11121            _prev_end_offset = cur_offset + envelope_size;
11122            if 2 > max_ordinal {
11123                return Ok(());
11124            }
11125
11126            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11127            // are envelope_size bytes.
11128            let cur_offset: usize = (2 - 1) * envelope_size;
11129
11130            // Zero reserved fields.
11131            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11132
11133            // Safety:
11134            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11135            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11136            //   envelope_size bytes, there is always sufficient room.
11137            fidl::encoding::encode_in_envelope_optional::<
11138                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11139                fidl::encoding::DefaultFuchsiaResourceDialect,
11140            >(
11141                self.kernel.as_mut().map(
11142                    <fidl::encoding::Endpoint<
11143                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11144                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11145                ),
11146                encoder,
11147                offset + cur_offset,
11148                depth,
11149            )?;
11150
11151            _prev_end_offset = cur_offset + envelope_size;
11152            if 3 > max_ordinal {
11153                return Ok(());
11154            }
11155
11156            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11157            // are envelope_size bytes.
11158            let cur_offset: usize = (3 - 1) * envelope_size;
11159
11160            // Zero reserved fields.
11161            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11162
11163            // Safety:
11164            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11165            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11166            //   envelope_size bytes, there is always sufficient room.
11167            fidl::encoding::encode_in_envelope_optional::<
11168                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11169                fidl::encoding::DefaultFuchsiaResourceDialect,
11170            >(
11171                self.ramdisk.as_mut().map(
11172                    <fidl::encoding::Endpoint<
11173                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11174                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11175                ),
11176                encoder,
11177                offset + cur_offset,
11178                depth,
11179            )?;
11180
11181            _prev_end_offset = cur_offset + envelope_size;
11182            if 4 > max_ordinal {
11183                return Ok(());
11184            }
11185
11186            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11187            // are envelope_size bytes.
11188            let cur_offset: usize = (4 - 1) * envelope_size;
11189
11190            // Zero reserved fields.
11191            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11192
11193            // Safety:
11194            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11195            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11196            //   envelope_size bytes, there is always sufficient room.
11197            fidl::encoding::encode_in_envelope_optional::<
11198                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11199                fidl::encoding::DefaultFuchsiaResourceDialect,
11200            >(
11201                self.dtb_overlay.as_mut().map(
11202                    <fidl::encoding::Endpoint<
11203                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11204                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11205                ),
11206                encoder,
11207                offset + cur_offset,
11208                depth,
11209            )?;
11210
11211            _prev_end_offset = cur_offset + envelope_size;
11212            if 5 > max_ordinal {
11213                return Ok(());
11214            }
11215
11216            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11217            // are envelope_size bytes.
11218            let cur_offset: usize = (5 - 1) * envelope_size;
11219
11220            // Zero reserved fields.
11221            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11222
11223            // Safety:
11224            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11225            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11226            //   envelope_size bytes, there is always sufficient room.
11227            fidl::encoding::encode_in_envelope_optional::<
11228                fidl::encoding::UnboundedString,
11229                fidl::encoding::DefaultFuchsiaResourceDialect,
11230            >(
11231                self.cmdline.as_ref().map(
11232                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
11233                ),
11234                encoder,
11235                offset + cur_offset,
11236                depth,
11237            )?;
11238
11239            _prev_end_offset = cur_offset + envelope_size;
11240            if 6 > max_ordinal {
11241                return Ok(());
11242            }
11243
11244            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11245            // are envelope_size bytes.
11246            let cur_offset: usize = (6 - 1) * envelope_size;
11247
11248            // Zero reserved fields.
11249            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11250
11251            // Safety:
11252            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11253            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11254            //   envelope_size bytes, there is always sufficient room.
11255            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11256            self.cmdline_add.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow),
11257            encoder, offset + cur_offset, depth
11258        )?;
11259
11260            _prev_end_offset = cur_offset + envelope_size;
11261            if 7 > max_ordinal {
11262                return Ok(());
11263            }
11264
11265            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11266            // are envelope_size bytes.
11267            let cur_offset: usize = (7 - 1) * envelope_size;
11268
11269            // Zero reserved fields.
11270            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11271
11272            // Safety:
11273            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11274            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11275            //   envelope_size bytes, there is always sufficient room.
11276            fidl::encoding::encode_in_envelope_optional::<
11277                u8,
11278                fidl::encoding::DefaultFuchsiaResourceDialect,
11279            >(
11280                self.cpus.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
11281                encoder,
11282                offset + cur_offset,
11283                depth,
11284            )?;
11285
11286            _prev_end_offset = cur_offset + envelope_size;
11287            if 8 > max_ordinal {
11288                return Ok(());
11289            }
11290
11291            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11292            // are envelope_size bytes.
11293            let cur_offset: usize = (8 - 1) * envelope_size;
11294
11295            // Zero reserved fields.
11296            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11297
11298            // Safety:
11299            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11300            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11301            //   envelope_size bytes, there is always sufficient room.
11302            fidl::encoding::encode_in_envelope_optional::<
11303                u64,
11304                fidl::encoding::DefaultFuchsiaResourceDialect,
11305            >(
11306                self.guest_memory.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11307                encoder,
11308                offset + cur_offset,
11309                depth,
11310            )?;
11311
11312            _prev_end_offset = cur_offset + envelope_size;
11313            if 9 > max_ordinal {
11314                return Ok(());
11315            }
11316
11317            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11318            // are envelope_size bytes.
11319            let cur_offset: usize = (9 - 1) * envelope_size;
11320
11321            // Zero reserved fields.
11322            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11323
11324            // Safety:
11325            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11326            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11327            //   envelope_size bytes, there is always sufficient room.
11328            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11329            self.block_devices.as_mut().map(<fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11330            encoder, offset + cur_offset, depth
11331        )?;
11332
11333            _prev_end_offset = cur_offset + envelope_size;
11334            if 10 > max_ordinal {
11335                return Ok(());
11336            }
11337
11338            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11339            // are envelope_size bytes.
11340            let cur_offset: usize = (10 - 1) * envelope_size;
11341
11342            // Zero reserved fields.
11343            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11344
11345            // Safety:
11346            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11347            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11348            //   envelope_size bytes, there is always sufficient room.
11349            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11350            self.net_devices.as_ref().map(<fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11351            encoder, offset + cur_offset, depth
11352        )?;
11353
11354            _prev_end_offset = cur_offset + envelope_size;
11355            if 11 > max_ordinal {
11356                return Ok(());
11357            }
11358
11359            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11360            // are envelope_size bytes.
11361            let cur_offset: usize = (11 - 1) * envelope_size;
11362
11363            // Zero reserved fields.
11364            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11365
11366            // Safety:
11367            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11368            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11369            //   envelope_size bytes, there is always sufficient room.
11370            fidl::encoding::encode_in_envelope_optional::<
11371                WaylandDevice,
11372                fidl::encoding::DefaultFuchsiaResourceDialect,
11373            >(
11374                self.wayland_device
11375                    .as_mut()
11376                    .map(<WaylandDevice as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11377                encoder,
11378                offset + cur_offset,
11379                depth,
11380            )?;
11381
11382            _prev_end_offset = cur_offset + envelope_size;
11383            if 12 > max_ordinal {
11384                return Ok(());
11385            }
11386
11387            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11388            // are envelope_size bytes.
11389            let cur_offset: usize = (12 - 1) * envelope_size;
11390
11391            // Zero reserved fields.
11392            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11393
11394            // Safety:
11395            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11396            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11397            //   envelope_size bytes, there is always sufficient room.
11398            fidl::encoding::encode_in_envelope_optional::<
11399                MagmaDevice,
11400                fidl::encoding::DefaultFuchsiaResourceDialect,
11401            >(
11402                self.magma_device
11403                    .as_ref()
11404                    .map(<MagmaDevice as fidl::encoding::ValueTypeMarker>::borrow),
11405                encoder,
11406                offset + cur_offset,
11407                depth,
11408            )?;
11409
11410            _prev_end_offset = cur_offset + envelope_size;
11411            if 13 > max_ordinal {
11412                return Ok(());
11413            }
11414
11415            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11416            // are envelope_size bytes.
11417            let cur_offset: usize = (13 - 1) * envelope_size;
11418
11419            // Zero reserved fields.
11420            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11421
11422            // Safety:
11423            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11424            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11425            //   envelope_size bytes, there is always sufficient room.
11426            fidl::encoding::encode_in_envelope_optional::<
11427                bool,
11428                fidl::encoding::DefaultFuchsiaResourceDialect,
11429            >(
11430                self.default_net.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11431                encoder,
11432                offset + cur_offset,
11433                depth,
11434            )?;
11435
11436            _prev_end_offset = cur_offset + envelope_size;
11437            if 14 > max_ordinal {
11438                return Ok(());
11439            }
11440
11441            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11442            // are envelope_size bytes.
11443            let cur_offset: usize = (14 - 1) * envelope_size;
11444
11445            // Zero reserved fields.
11446            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11447
11448            // Safety:
11449            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11450            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11451            //   envelope_size bytes, there is always sufficient room.
11452            fidl::encoding::encode_in_envelope_optional::<
11453                bool,
11454                fidl::encoding::DefaultFuchsiaResourceDialect,
11455            >(
11456                self.virtio_balloon.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11457                encoder,
11458                offset + cur_offset,
11459                depth,
11460            )?;
11461
11462            _prev_end_offset = cur_offset + envelope_size;
11463            if 15 > max_ordinal {
11464                return Ok(());
11465            }
11466
11467            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11468            // are envelope_size bytes.
11469            let cur_offset: usize = (15 - 1) * envelope_size;
11470
11471            // Zero reserved fields.
11472            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11473
11474            // Safety:
11475            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11476            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11477            //   envelope_size bytes, there is always sufficient room.
11478            fidl::encoding::encode_in_envelope_optional::<
11479                bool,
11480                fidl::encoding::DefaultFuchsiaResourceDialect,
11481            >(
11482                self.virtio_console.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11483                encoder,
11484                offset + cur_offset,
11485                depth,
11486            )?;
11487
11488            _prev_end_offset = cur_offset + envelope_size;
11489            if 16 > max_ordinal {
11490                return Ok(());
11491            }
11492
11493            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11494            // are envelope_size bytes.
11495            let cur_offset: usize = (16 - 1) * envelope_size;
11496
11497            // Zero reserved fields.
11498            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11499
11500            // Safety:
11501            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11502            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11503            //   envelope_size bytes, there is always sufficient room.
11504            fidl::encoding::encode_in_envelope_optional::<
11505                bool,
11506                fidl::encoding::DefaultFuchsiaResourceDialect,
11507            >(
11508                self.virtio_gpu.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11509                encoder,
11510                offset + cur_offset,
11511                depth,
11512            )?;
11513
11514            _prev_end_offset = cur_offset + envelope_size;
11515            if 17 > max_ordinal {
11516                return Ok(());
11517            }
11518
11519            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11520            // are envelope_size bytes.
11521            let cur_offset: usize = (17 - 1) * envelope_size;
11522
11523            // Zero reserved fields.
11524            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11525
11526            // Safety:
11527            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11528            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11529            //   envelope_size bytes, there is always sufficient room.
11530            fidl::encoding::encode_in_envelope_optional::<
11531                bool,
11532                fidl::encoding::DefaultFuchsiaResourceDialect,
11533            >(
11534                self.virtio_rng.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11535                encoder,
11536                offset + cur_offset,
11537                depth,
11538            )?;
11539
11540            _prev_end_offset = cur_offset + envelope_size;
11541            if 18 > max_ordinal {
11542                return Ok(());
11543            }
11544
11545            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11546            // are envelope_size bytes.
11547            let cur_offset: usize = (18 - 1) * envelope_size;
11548
11549            // Zero reserved fields.
11550            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11551
11552            // Safety:
11553            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11554            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11555            //   envelope_size bytes, there is always sufficient room.
11556            fidl::encoding::encode_in_envelope_optional::<
11557                bool,
11558                fidl::encoding::DefaultFuchsiaResourceDialect,
11559            >(
11560                self.virtio_vsock.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11561                encoder,
11562                offset + cur_offset,
11563                depth,
11564            )?;
11565
11566            _prev_end_offset = cur_offset + envelope_size;
11567            if 19 > max_ordinal {
11568                return Ok(());
11569            }
11570
11571            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11572            // are envelope_size bytes.
11573            let cur_offset: usize = (19 - 1) * envelope_size;
11574
11575            // Zero reserved fields.
11576            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11577
11578            // Safety:
11579            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11580            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11581            //   envelope_size bytes, there is always sufficient room.
11582            fidl::encoding::encode_in_envelope_optional::<
11583                bool,
11584                fidl::encoding::DefaultFuchsiaResourceDialect,
11585            >(
11586                self.virtio_sound.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11587                encoder,
11588                offset + cur_offset,
11589                depth,
11590            )?;
11591
11592            _prev_end_offset = cur_offset + envelope_size;
11593            if 20 > max_ordinal {
11594                return Ok(());
11595            }
11596
11597            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11598            // are envelope_size bytes.
11599            let cur_offset: usize = (20 - 1) * envelope_size;
11600
11601            // Zero reserved fields.
11602            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11603
11604            // Safety:
11605            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11606            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11607            //   envelope_size bytes, there is always sufficient room.
11608            fidl::encoding::encode_in_envelope_optional::<
11609                bool,
11610                fidl::encoding::DefaultFuchsiaResourceDialect,
11611            >(
11612                self.virtio_sound_input
11613                    .as_ref()
11614                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11615                encoder,
11616                offset + cur_offset,
11617                depth,
11618            )?;
11619
11620            _prev_end_offset = cur_offset + envelope_size;
11621            if 21 > max_ordinal {
11622                return Ok(());
11623            }
11624
11625            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11626            // are envelope_size bytes.
11627            let cur_offset: usize = (21 - 1) * envelope_size;
11628
11629            // Zero reserved fields.
11630            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11631
11632            // Safety:
11633            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11634            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11635            //   envelope_size bytes, there is always sufficient room.
11636            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Listener>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11637            self.vsock_listeners.as_mut().map(<fidl::encoding::UnboundedVector<Listener> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11638            encoder, offset + cur_offset, depth
11639        )?;
11640
11641            _prev_end_offset = cur_offset + envelope_size;
11642            if 22 > max_ordinal {
11643                return Ok(());
11644            }
11645
11646            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11647            // are envelope_size bytes.
11648            let cur_offset: usize = (22 - 1) * envelope_size;
11649
11650            // Zero reserved fields.
11651            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11652
11653            // Safety:
11654            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11655            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11656            //   envelope_size bytes, there is always sufficient room.
11657            fidl::encoding::encode_in_envelope_optional::<
11658                bool,
11659                fidl::encoding::DefaultFuchsiaResourceDialect,
11660            >(
11661                self.virtio_mem.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11662                encoder,
11663                offset + cur_offset,
11664                depth,
11665            )?;
11666
11667            _prev_end_offset = cur_offset + envelope_size;
11668            if 23 > max_ordinal {
11669                return Ok(());
11670            }
11671
11672            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11673            // are envelope_size bytes.
11674            let cur_offset: usize = (23 - 1) * envelope_size;
11675
11676            // Zero reserved fields.
11677            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11678
11679            // Safety:
11680            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11681            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11682            //   envelope_size bytes, there is always sufficient room.
11683            fidl::encoding::encode_in_envelope_optional::<
11684                u64,
11685                fidl::encoding::DefaultFuchsiaResourceDialect,
11686            >(
11687                self.virtio_mem_block_size
11688                    .as_ref()
11689                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11690                encoder,
11691                offset + cur_offset,
11692                depth,
11693            )?;
11694
11695            _prev_end_offset = cur_offset + envelope_size;
11696            if 24 > max_ordinal {
11697                return Ok(());
11698            }
11699
11700            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11701            // are envelope_size bytes.
11702            let cur_offset: usize = (24 - 1) * envelope_size;
11703
11704            // Zero reserved fields.
11705            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11706
11707            // Safety:
11708            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11709            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11710            //   envelope_size bytes, there is always sufficient room.
11711            fidl::encoding::encode_in_envelope_optional::<
11712                u64,
11713                fidl::encoding::DefaultFuchsiaResourceDialect,
11714            >(
11715                self.virtio_mem_region_size
11716                    .as_ref()
11717                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11718                encoder,
11719                offset + cur_offset,
11720                depth,
11721            )?;
11722
11723            _prev_end_offset = cur_offset + envelope_size;
11724            if 25 > max_ordinal {
11725                return Ok(());
11726            }
11727
11728            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11729            // are envelope_size bytes.
11730            let cur_offset: usize = (25 - 1) * envelope_size;
11731
11732            // Zero reserved fields.
11733            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11734
11735            // Safety:
11736            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11737            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11738            //   envelope_size bytes, there is always sufficient room.
11739            fidl::encoding::encode_in_envelope_optional::<
11740                u64,
11741                fidl::encoding::DefaultFuchsiaResourceDialect,
11742            >(
11743                self.virtio_mem_region_alignment
11744                    .as_ref()
11745                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11746                encoder,
11747                offset + cur_offset,
11748                depth,
11749            )?;
11750
11751            _prev_end_offset = cur_offset + envelope_size;
11752
11753            Ok(())
11754        }
11755    }
11756
11757    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for GuestConfig {
11758        #[inline(always)]
11759        fn new_empty() -> Self {
11760            Self::default()
11761        }
11762
11763        unsafe fn decode(
11764            &mut self,
11765            decoder: &mut fidl::encoding::Decoder<
11766                '_,
11767                fidl::encoding::DefaultFuchsiaResourceDialect,
11768            >,
11769            offset: usize,
11770            mut depth: fidl::encoding::Depth,
11771        ) -> fidl::Result<()> {
11772            decoder.debug_check_bounds::<Self>(offset);
11773            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11774                None => return Err(fidl::Error::NotNullable),
11775                Some(len) => len,
11776            };
11777            // Calling decoder.out_of_line_offset(0) is not allowed.
11778            if len == 0 {
11779                return Ok(());
11780            };
11781            depth.increment()?;
11782            let envelope_size = 8;
11783            let bytes_len = len * envelope_size;
11784            let offset = decoder.out_of_line_offset(bytes_len)?;
11785            // Decode the envelope for each type.
11786            let mut _next_ordinal_to_read = 0;
11787            let mut next_offset = offset;
11788            let end_offset = offset + bytes_len;
11789            _next_ordinal_to_read += 1;
11790            if next_offset >= end_offset {
11791                return Ok(());
11792            }
11793
11794            // Decode unknown envelopes for gaps in ordinals.
11795            while _next_ordinal_to_read < 1 {
11796                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11797                _next_ordinal_to_read += 1;
11798                next_offset += envelope_size;
11799            }
11800
11801            let next_out_of_line = decoder.next_out_of_line();
11802            let handles_before = decoder.remaining_handles();
11803            if let Some((inlined, num_bytes, num_handles)) =
11804                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11805            {
11806                let member_inline_size =
11807                    <KernelType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11808                if inlined != (member_inline_size <= 4) {
11809                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11810                }
11811                let inner_offset;
11812                let mut inner_depth = depth.clone();
11813                if inlined {
11814                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11815                    inner_offset = next_offset;
11816                } else {
11817                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11818                    inner_depth.increment()?;
11819                }
11820                let val_ref = self.kernel_type.get_or_insert_with(|| {
11821                    fidl::new_empty!(KernelType, fidl::encoding::DefaultFuchsiaResourceDialect)
11822                });
11823                fidl::decode!(
11824                    KernelType,
11825                    fidl::encoding::DefaultFuchsiaResourceDialect,
11826                    val_ref,
11827                    decoder,
11828                    inner_offset,
11829                    inner_depth
11830                )?;
11831                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11832                {
11833                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11834                }
11835                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11836                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11837                }
11838            }
11839
11840            next_offset += envelope_size;
11841            _next_ordinal_to_read += 1;
11842            if next_offset >= end_offset {
11843                return Ok(());
11844            }
11845
11846            // Decode unknown envelopes for gaps in ordinals.
11847            while _next_ordinal_to_read < 2 {
11848                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11849                _next_ordinal_to_read += 1;
11850                next_offset += envelope_size;
11851            }
11852
11853            let next_out_of_line = decoder.next_out_of_line();
11854            let handles_before = decoder.remaining_handles();
11855            if let Some((inlined, num_bytes, num_handles)) =
11856                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11857            {
11858                let member_inline_size = <fidl::encoding::Endpoint<
11859                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11860                > as fidl::encoding::TypeMarker>::inline_size(
11861                    decoder.context
11862                );
11863                if inlined != (member_inline_size <= 4) {
11864                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11865                }
11866                let inner_offset;
11867                let mut inner_depth = depth.clone();
11868                if inlined {
11869                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11870                    inner_offset = next_offset;
11871                } else {
11872                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11873                    inner_depth.increment()?;
11874                }
11875                let val_ref = self.kernel.get_or_insert_with(|| {
11876                    fidl::new_empty!(
11877                        fidl::encoding::Endpoint<
11878                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11879                        >,
11880                        fidl::encoding::DefaultFuchsiaResourceDialect
11881                    )
11882                });
11883                fidl::decode!(
11884                    fidl::encoding::Endpoint<
11885                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11886                    >,
11887                    fidl::encoding::DefaultFuchsiaResourceDialect,
11888                    val_ref,
11889                    decoder,
11890                    inner_offset,
11891                    inner_depth
11892                )?;
11893                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11894                {
11895                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11896                }
11897                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11898                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11899                }
11900            }
11901
11902            next_offset += envelope_size;
11903            _next_ordinal_to_read += 1;
11904            if next_offset >= end_offset {
11905                return Ok(());
11906            }
11907
11908            // Decode unknown envelopes for gaps in ordinals.
11909            while _next_ordinal_to_read < 3 {
11910                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11911                _next_ordinal_to_read += 1;
11912                next_offset += envelope_size;
11913            }
11914
11915            let next_out_of_line = decoder.next_out_of_line();
11916            let handles_before = decoder.remaining_handles();
11917            if let Some((inlined, num_bytes, num_handles)) =
11918                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11919            {
11920                let member_inline_size = <fidl::encoding::Endpoint<
11921                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11922                > as fidl::encoding::TypeMarker>::inline_size(
11923                    decoder.context
11924                );
11925                if inlined != (member_inline_size <= 4) {
11926                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11927                }
11928                let inner_offset;
11929                let mut inner_depth = depth.clone();
11930                if inlined {
11931                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11932                    inner_offset = next_offset;
11933                } else {
11934                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11935                    inner_depth.increment()?;
11936                }
11937                let val_ref = self.ramdisk.get_or_insert_with(|| {
11938                    fidl::new_empty!(
11939                        fidl::encoding::Endpoint<
11940                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11941                        >,
11942                        fidl::encoding::DefaultFuchsiaResourceDialect
11943                    )
11944                });
11945                fidl::decode!(
11946                    fidl::encoding::Endpoint<
11947                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11948                    >,
11949                    fidl::encoding::DefaultFuchsiaResourceDialect,
11950                    val_ref,
11951                    decoder,
11952                    inner_offset,
11953                    inner_depth
11954                )?;
11955                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11956                {
11957                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11958                }
11959                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11960                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11961                }
11962            }
11963
11964            next_offset += envelope_size;
11965            _next_ordinal_to_read += 1;
11966            if next_offset >= end_offset {
11967                return Ok(());
11968            }
11969
11970            // Decode unknown envelopes for gaps in ordinals.
11971            while _next_ordinal_to_read < 4 {
11972                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11973                _next_ordinal_to_read += 1;
11974                next_offset += envelope_size;
11975            }
11976
11977            let next_out_of_line = decoder.next_out_of_line();
11978            let handles_before = decoder.remaining_handles();
11979            if let Some((inlined, num_bytes, num_handles)) =
11980                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11981            {
11982                let member_inline_size = <fidl::encoding::Endpoint<
11983                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11984                > as fidl::encoding::TypeMarker>::inline_size(
11985                    decoder.context
11986                );
11987                if inlined != (member_inline_size <= 4) {
11988                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11989                }
11990                let inner_offset;
11991                let mut inner_depth = depth.clone();
11992                if inlined {
11993                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11994                    inner_offset = next_offset;
11995                } else {
11996                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11997                    inner_depth.increment()?;
11998                }
11999                let val_ref = self.dtb_overlay.get_or_insert_with(|| {
12000                    fidl::new_empty!(
12001                        fidl::encoding::Endpoint<
12002                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12003                        >,
12004                        fidl::encoding::DefaultFuchsiaResourceDialect
12005                    )
12006                });
12007                fidl::decode!(
12008                    fidl::encoding::Endpoint<
12009                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12010                    >,
12011                    fidl::encoding::DefaultFuchsiaResourceDialect,
12012                    val_ref,
12013                    decoder,
12014                    inner_offset,
12015                    inner_depth
12016                )?;
12017                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12018                {
12019                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12020                }
12021                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12022                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12023                }
12024            }
12025
12026            next_offset += envelope_size;
12027            _next_ordinal_to_read += 1;
12028            if next_offset >= end_offset {
12029                return Ok(());
12030            }
12031
12032            // Decode unknown envelopes for gaps in ordinals.
12033            while _next_ordinal_to_read < 5 {
12034                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12035                _next_ordinal_to_read += 1;
12036                next_offset += envelope_size;
12037            }
12038
12039            let next_out_of_line = decoder.next_out_of_line();
12040            let handles_before = decoder.remaining_handles();
12041            if let Some((inlined, num_bytes, num_handles)) =
12042                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12043            {
12044                let member_inline_size =
12045                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
12046                        decoder.context,
12047                    );
12048                if inlined != (member_inline_size <= 4) {
12049                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12050                }
12051                let inner_offset;
12052                let mut inner_depth = depth.clone();
12053                if inlined {
12054                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12055                    inner_offset = next_offset;
12056                } else {
12057                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12058                    inner_depth.increment()?;
12059                }
12060                let val_ref = self.cmdline.get_or_insert_with(|| {
12061                    fidl::new_empty!(
12062                        fidl::encoding::UnboundedString,
12063                        fidl::encoding::DefaultFuchsiaResourceDialect
12064                    )
12065                });
12066                fidl::decode!(
12067                    fidl::encoding::UnboundedString,
12068                    fidl::encoding::DefaultFuchsiaResourceDialect,
12069                    val_ref,
12070                    decoder,
12071                    inner_offset,
12072                    inner_depth
12073                )?;
12074                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12075                {
12076                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12077                }
12078                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12079                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12080                }
12081            }
12082
12083            next_offset += envelope_size;
12084            _next_ordinal_to_read += 1;
12085            if next_offset >= end_offset {
12086                return Ok(());
12087            }
12088
12089            // Decode unknown envelopes for gaps in ordinals.
12090            while _next_ordinal_to_read < 6 {
12091                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12092                _next_ordinal_to_read += 1;
12093                next_offset += envelope_size;
12094            }
12095
12096            let next_out_of_line = decoder.next_out_of_line();
12097            let handles_before = decoder.remaining_handles();
12098            if let Some((inlined, num_bytes, num_handles)) =
12099                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12100            {
12101                let member_inline_size = <fidl::encoding::UnboundedVector<
12102                    fidl::encoding::UnboundedString,
12103                > as fidl::encoding::TypeMarker>::inline_size(
12104                    decoder.context
12105                );
12106                if inlined != (member_inline_size <= 4) {
12107                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12108                }
12109                let inner_offset;
12110                let mut inner_depth = depth.clone();
12111                if inlined {
12112                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12113                    inner_offset = next_offset;
12114                } else {
12115                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12116                    inner_depth.increment()?;
12117                }
12118                let val_ref = self.cmdline_add.get_or_insert_with(|| {
12119                    fidl::new_empty!(
12120                        fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
12121                        fidl::encoding::DefaultFuchsiaResourceDialect
12122                    )
12123                });
12124                fidl::decode!(
12125                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
12126                    fidl::encoding::DefaultFuchsiaResourceDialect,
12127                    val_ref,
12128                    decoder,
12129                    inner_offset,
12130                    inner_depth
12131                )?;
12132                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12133                {
12134                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12135                }
12136                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12137                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12138                }
12139            }
12140
12141            next_offset += envelope_size;
12142            _next_ordinal_to_read += 1;
12143            if next_offset >= end_offset {
12144                return Ok(());
12145            }
12146
12147            // Decode unknown envelopes for gaps in ordinals.
12148            while _next_ordinal_to_read < 7 {
12149                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12150                _next_ordinal_to_read += 1;
12151                next_offset += envelope_size;
12152            }
12153
12154            let next_out_of_line = decoder.next_out_of_line();
12155            let handles_before = decoder.remaining_handles();
12156            if let Some((inlined, num_bytes, num_handles)) =
12157                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12158            {
12159                let member_inline_size =
12160                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12161                if inlined != (member_inline_size <= 4) {
12162                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12163                }
12164                let inner_offset;
12165                let mut inner_depth = depth.clone();
12166                if inlined {
12167                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12168                    inner_offset = next_offset;
12169                } else {
12170                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12171                    inner_depth.increment()?;
12172                }
12173                let val_ref = self.cpus.get_or_insert_with(|| {
12174                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12175                });
12176                fidl::decode!(
12177                    u8,
12178                    fidl::encoding::DefaultFuchsiaResourceDialect,
12179                    val_ref,
12180                    decoder,
12181                    inner_offset,
12182                    inner_depth
12183                )?;
12184                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12185                {
12186                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12187                }
12188                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12189                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12190                }
12191            }
12192
12193            next_offset += envelope_size;
12194            _next_ordinal_to_read += 1;
12195            if next_offset >= end_offset {
12196                return Ok(());
12197            }
12198
12199            // Decode unknown envelopes for gaps in ordinals.
12200            while _next_ordinal_to_read < 8 {
12201                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12202                _next_ordinal_to_read += 1;
12203                next_offset += envelope_size;
12204            }
12205
12206            let next_out_of_line = decoder.next_out_of_line();
12207            let handles_before = decoder.remaining_handles();
12208            if let Some((inlined, num_bytes, num_handles)) =
12209                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12210            {
12211                let member_inline_size =
12212                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12213                if inlined != (member_inline_size <= 4) {
12214                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12215                }
12216                let inner_offset;
12217                let mut inner_depth = depth.clone();
12218                if inlined {
12219                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12220                    inner_offset = next_offset;
12221                } else {
12222                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12223                    inner_depth.increment()?;
12224                }
12225                let val_ref = self.guest_memory.get_or_insert_with(|| {
12226                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12227                });
12228                fidl::decode!(
12229                    u64,
12230                    fidl::encoding::DefaultFuchsiaResourceDialect,
12231                    val_ref,
12232                    decoder,
12233                    inner_offset,
12234                    inner_depth
12235                )?;
12236                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12237                {
12238                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12239                }
12240                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12241                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12242                }
12243            }
12244
12245            next_offset += envelope_size;
12246            _next_ordinal_to_read += 1;
12247            if next_offset >= end_offset {
12248                return Ok(());
12249            }
12250
12251            // Decode unknown envelopes for gaps in ordinals.
12252            while _next_ordinal_to_read < 9 {
12253                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12254                _next_ordinal_to_read += 1;
12255                next_offset += envelope_size;
12256            }
12257
12258            let next_out_of_line = decoder.next_out_of_line();
12259            let handles_before = decoder.remaining_handles();
12260            if let Some((inlined, num_bytes, num_handles)) =
12261                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12262            {
12263                let member_inline_size = <fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12264                if inlined != (member_inline_size <= 4) {
12265                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12266                }
12267                let inner_offset;
12268                let mut inner_depth = depth.clone();
12269                if inlined {
12270                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12271                    inner_offset = next_offset;
12272                } else {
12273                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12274                    inner_depth.increment()?;
12275                }
12276                let val_ref =
12277                self.block_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12278                fidl::decode!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12279                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12280                {
12281                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12282                }
12283                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12284                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12285                }
12286            }
12287
12288            next_offset += envelope_size;
12289            _next_ordinal_to_read += 1;
12290            if next_offset >= end_offset {
12291                return Ok(());
12292            }
12293
12294            // Decode unknown envelopes for gaps in ordinals.
12295            while _next_ordinal_to_read < 10 {
12296                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12297                _next_ordinal_to_read += 1;
12298                next_offset += envelope_size;
12299            }
12300
12301            let next_out_of_line = decoder.next_out_of_line();
12302            let handles_before = decoder.remaining_handles();
12303            if let Some((inlined, num_bytes, num_handles)) =
12304                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12305            {
12306                let member_inline_size = <fidl::encoding::Vector<NetSpec, 32> 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 =
12320                self.net_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12321                fidl::decode!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12322                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12323                {
12324                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12325                }
12326                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12327                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12328                }
12329            }
12330
12331            next_offset += envelope_size;
12332            _next_ordinal_to_read += 1;
12333            if next_offset >= end_offset {
12334                return Ok(());
12335            }
12336
12337            // Decode unknown envelopes for gaps in ordinals.
12338            while _next_ordinal_to_read < 11 {
12339                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12340                _next_ordinal_to_read += 1;
12341                next_offset += envelope_size;
12342            }
12343
12344            let next_out_of_line = decoder.next_out_of_line();
12345            let handles_before = decoder.remaining_handles();
12346            if let Some((inlined, num_bytes, num_handles)) =
12347                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12348            {
12349                let member_inline_size =
12350                    <WaylandDevice as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12351                if inlined != (member_inline_size <= 4) {
12352                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12353                }
12354                let inner_offset;
12355                let mut inner_depth = depth.clone();
12356                if inlined {
12357                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12358                    inner_offset = next_offset;
12359                } else {
12360                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12361                    inner_depth.increment()?;
12362                }
12363                let val_ref = self.wayland_device.get_or_insert_with(|| {
12364                    fidl::new_empty!(WaylandDevice, fidl::encoding::DefaultFuchsiaResourceDialect)
12365                });
12366                fidl::decode!(
12367                    WaylandDevice,
12368                    fidl::encoding::DefaultFuchsiaResourceDialect,
12369                    val_ref,
12370                    decoder,
12371                    inner_offset,
12372                    inner_depth
12373                )?;
12374                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12375                {
12376                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12377                }
12378                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12379                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12380                }
12381            }
12382
12383            next_offset += envelope_size;
12384            _next_ordinal_to_read += 1;
12385            if next_offset >= end_offset {
12386                return Ok(());
12387            }
12388
12389            // Decode unknown envelopes for gaps in ordinals.
12390            while _next_ordinal_to_read < 12 {
12391                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12392                _next_ordinal_to_read += 1;
12393                next_offset += envelope_size;
12394            }
12395
12396            let next_out_of_line = decoder.next_out_of_line();
12397            let handles_before = decoder.remaining_handles();
12398            if let Some((inlined, num_bytes, num_handles)) =
12399                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12400            {
12401                let member_inline_size =
12402                    <MagmaDevice as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12403                if inlined != (member_inline_size <= 4) {
12404                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12405                }
12406                let inner_offset;
12407                let mut inner_depth = depth.clone();
12408                if inlined {
12409                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12410                    inner_offset = next_offset;
12411                } else {
12412                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12413                    inner_depth.increment()?;
12414                }
12415                let val_ref = self.magma_device.get_or_insert_with(|| {
12416                    fidl::new_empty!(MagmaDevice, fidl::encoding::DefaultFuchsiaResourceDialect)
12417                });
12418                fidl::decode!(
12419                    MagmaDevice,
12420                    fidl::encoding::DefaultFuchsiaResourceDialect,
12421                    val_ref,
12422                    decoder,
12423                    inner_offset,
12424                    inner_depth
12425                )?;
12426                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12427                {
12428                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12429                }
12430                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12431                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12432                }
12433            }
12434
12435            next_offset += envelope_size;
12436            _next_ordinal_to_read += 1;
12437            if next_offset >= end_offset {
12438                return Ok(());
12439            }
12440
12441            // Decode unknown envelopes for gaps in ordinals.
12442            while _next_ordinal_to_read < 13 {
12443                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12444                _next_ordinal_to_read += 1;
12445                next_offset += envelope_size;
12446            }
12447
12448            let next_out_of_line = decoder.next_out_of_line();
12449            let handles_before = decoder.remaining_handles();
12450            if let Some((inlined, num_bytes, num_handles)) =
12451                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12452            {
12453                let member_inline_size =
12454                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12455                if inlined != (member_inline_size <= 4) {
12456                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12457                }
12458                let inner_offset;
12459                let mut inner_depth = depth.clone();
12460                if inlined {
12461                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12462                    inner_offset = next_offset;
12463                } else {
12464                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12465                    inner_depth.increment()?;
12466                }
12467                let val_ref = self.default_net.get_or_insert_with(|| {
12468                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12469                });
12470                fidl::decode!(
12471                    bool,
12472                    fidl::encoding::DefaultFuchsiaResourceDialect,
12473                    val_ref,
12474                    decoder,
12475                    inner_offset,
12476                    inner_depth
12477                )?;
12478                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12479                {
12480                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12481                }
12482                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12483                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12484                }
12485            }
12486
12487            next_offset += envelope_size;
12488            _next_ordinal_to_read += 1;
12489            if next_offset >= end_offset {
12490                return Ok(());
12491            }
12492
12493            // Decode unknown envelopes for gaps in ordinals.
12494            while _next_ordinal_to_read < 14 {
12495                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12496                _next_ordinal_to_read += 1;
12497                next_offset += envelope_size;
12498            }
12499
12500            let next_out_of_line = decoder.next_out_of_line();
12501            let handles_before = decoder.remaining_handles();
12502            if let Some((inlined, num_bytes, num_handles)) =
12503                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12504            {
12505                let member_inline_size =
12506                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12507                if inlined != (member_inline_size <= 4) {
12508                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12509                }
12510                let inner_offset;
12511                let mut inner_depth = depth.clone();
12512                if inlined {
12513                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12514                    inner_offset = next_offset;
12515                } else {
12516                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12517                    inner_depth.increment()?;
12518                }
12519                let val_ref = self.virtio_balloon.get_or_insert_with(|| {
12520                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12521                });
12522                fidl::decode!(
12523                    bool,
12524                    fidl::encoding::DefaultFuchsiaResourceDialect,
12525                    val_ref,
12526                    decoder,
12527                    inner_offset,
12528                    inner_depth
12529                )?;
12530                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12531                {
12532                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12533                }
12534                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12535                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12536                }
12537            }
12538
12539            next_offset += envelope_size;
12540            _next_ordinal_to_read += 1;
12541            if next_offset >= end_offset {
12542                return Ok(());
12543            }
12544
12545            // Decode unknown envelopes for gaps in ordinals.
12546            while _next_ordinal_to_read < 15 {
12547                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12548                _next_ordinal_to_read += 1;
12549                next_offset += envelope_size;
12550            }
12551
12552            let next_out_of_line = decoder.next_out_of_line();
12553            let handles_before = decoder.remaining_handles();
12554            if let Some((inlined, num_bytes, num_handles)) =
12555                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12556            {
12557                let member_inline_size =
12558                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12559                if inlined != (member_inline_size <= 4) {
12560                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12561                }
12562                let inner_offset;
12563                let mut inner_depth = depth.clone();
12564                if inlined {
12565                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12566                    inner_offset = next_offset;
12567                } else {
12568                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12569                    inner_depth.increment()?;
12570                }
12571                let val_ref = self.virtio_console.get_or_insert_with(|| {
12572                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12573                });
12574                fidl::decode!(
12575                    bool,
12576                    fidl::encoding::DefaultFuchsiaResourceDialect,
12577                    val_ref,
12578                    decoder,
12579                    inner_offset,
12580                    inner_depth
12581                )?;
12582                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12583                {
12584                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12585                }
12586                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12587                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12588                }
12589            }
12590
12591            next_offset += envelope_size;
12592            _next_ordinal_to_read += 1;
12593            if next_offset >= end_offset {
12594                return Ok(());
12595            }
12596
12597            // Decode unknown envelopes for gaps in ordinals.
12598            while _next_ordinal_to_read < 16 {
12599                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12600                _next_ordinal_to_read += 1;
12601                next_offset += envelope_size;
12602            }
12603
12604            let next_out_of_line = decoder.next_out_of_line();
12605            let handles_before = decoder.remaining_handles();
12606            if let Some((inlined, num_bytes, num_handles)) =
12607                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12608            {
12609                let member_inline_size =
12610                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12611                if inlined != (member_inline_size <= 4) {
12612                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12613                }
12614                let inner_offset;
12615                let mut inner_depth = depth.clone();
12616                if inlined {
12617                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12618                    inner_offset = next_offset;
12619                } else {
12620                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12621                    inner_depth.increment()?;
12622                }
12623                let val_ref = self.virtio_gpu.get_or_insert_with(|| {
12624                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12625                });
12626                fidl::decode!(
12627                    bool,
12628                    fidl::encoding::DefaultFuchsiaResourceDialect,
12629                    val_ref,
12630                    decoder,
12631                    inner_offset,
12632                    inner_depth
12633                )?;
12634                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12635                {
12636                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12637                }
12638                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12639                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12640                }
12641            }
12642
12643            next_offset += envelope_size;
12644            _next_ordinal_to_read += 1;
12645            if next_offset >= end_offset {
12646                return Ok(());
12647            }
12648
12649            // Decode unknown envelopes for gaps in ordinals.
12650            while _next_ordinal_to_read < 17 {
12651                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12652                _next_ordinal_to_read += 1;
12653                next_offset += envelope_size;
12654            }
12655
12656            let next_out_of_line = decoder.next_out_of_line();
12657            let handles_before = decoder.remaining_handles();
12658            if let Some((inlined, num_bytes, num_handles)) =
12659                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12660            {
12661                let member_inline_size =
12662                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12663                if inlined != (member_inline_size <= 4) {
12664                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12665                }
12666                let inner_offset;
12667                let mut inner_depth = depth.clone();
12668                if inlined {
12669                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12670                    inner_offset = next_offset;
12671                } else {
12672                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12673                    inner_depth.increment()?;
12674                }
12675                let val_ref = self.virtio_rng.get_or_insert_with(|| {
12676                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12677                });
12678                fidl::decode!(
12679                    bool,
12680                    fidl::encoding::DefaultFuchsiaResourceDialect,
12681                    val_ref,
12682                    decoder,
12683                    inner_offset,
12684                    inner_depth
12685                )?;
12686                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12687                {
12688                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12689                }
12690                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12691                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12692                }
12693            }
12694
12695            next_offset += envelope_size;
12696            _next_ordinal_to_read += 1;
12697            if next_offset >= end_offset {
12698                return Ok(());
12699            }
12700
12701            // Decode unknown envelopes for gaps in ordinals.
12702            while _next_ordinal_to_read < 18 {
12703                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12704                _next_ordinal_to_read += 1;
12705                next_offset += envelope_size;
12706            }
12707
12708            let next_out_of_line = decoder.next_out_of_line();
12709            let handles_before = decoder.remaining_handles();
12710            if let Some((inlined, num_bytes, num_handles)) =
12711                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12712            {
12713                let member_inline_size =
12714                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12715                if inlined != (member_inline_size <= 4) {
12716                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12717                }
12718                let inner_offset;
12719                let mut inner_depth = depth.clone();
12720                if inlined {
12721                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12722                    inner_offset = next_offset;
12723                } else {
12724                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12725                    inner_depth.increment()?;
12726                }
12727                let val_ref = self.virtio_vsock.get_or_insert_with(|| {
12728                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12729                });
12730                fidl::decode!(
12731                    bool,
12732                    fidl::encoding::DefaultFuchsiaResourceDialect,
12733                    val_ref,
12734                    decoder,
12735                    inner_offset,
12736                    inner_depth
12737                )?;
12738                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12739                {
12740                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12741                }
12742                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12743                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12744                }
12745            }
12746
12747            next_offset += envelope_size;
12748            _next_ordinal_to_read += 1;
12749            if next_offset >= end_offset {
12750                return Ok(());
12751            }
12752
12753            // Decode unknown envelopes for gaps in ordinals.
12754            while _next_ordinal_to_read < 19 {
12755                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12756                _next_ordinal_to_read += 1;
12757                next_offset += envelope_size;
12758            }
12759
12760            let next_out_of_line = decoder.next_out_of_line();
12761            let handles_before = decoder.remaining_handles();
12762            if let Some((inlined, num_bytes, num_handles)) =
12763                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12764            {
12765                let member_inline_size =
12766                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12767                if inlined != (member_inline_size <= 4) {
12768                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12769                }
12770                let inner_offset;
12771                let mut inner_depth = depth.clone();
12772                if inlined {
12773                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12774                    inner_offset = next_offset;
12775                } else {
12776                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12777                    inner_depth.increment()?;
12778                }
12779                let val_ref = self.virtio_sound.get_or_insert_with(|| {
12780                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12781                });
12782                fidl::decode!(
12783                    bool,
12784                    fidl::encoding::DefaultFuchsiaResourceDialect,
12785                    val_ref,
12786                    decoder,
12787                    inner_offset,
12788                    inner_depth
12789                )?;
12790                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12791                {
12792                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12793                }
12794                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12795                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12796                }
12797            }
12798
12799            next_offset += envelope_size;
12800            _next_ordinal_to_read += 1;
12801            if next_offset >= end_offset {
12802                return Ok(());
12803            }
12804
12805            // Decode unknown envelopes for gaps in ordinals.
12806            while _next_ordinal_to_read < 20 {
12807                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12808                _next_ordinal_to_read += 1;
12809                next_offset += envelope_size;
12810            }
12811
12812            let next_out_of_line = decoder.next_out_of_line();
12813            let handles_before = decoder.remaining_handles();
12814            if let Some((inlined, num_bytes, num_handles)) =
12815                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12816            {
12817                let member_inline_size =
12818                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12819                if inlined != (member_inline_size <= 4) {
12820                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12821                }
12822                let inner_offset;
12823                let mut inner_depth = depth.clone();
12824                if inlined {
12825                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12826                    inner_offset = next_offset;
12827                } else {
12828                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12829                    inner_depth.increment()?;
12830                }
12831                let val_ref = self.virtio_sound_input.get_or_insert_with(|| {
12832                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12833                });
12834                fidl::decode!(
12835                    bool,
12836                    fidl::encoding::DefaultFuchsiaResourceDialect,
12837                    val_ref,
12838                    decoder,
12839                    inner_offset,
12840                    inner_depth
12841                )?;
12842                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12843                {
12844                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12845                }
12846                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12847                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12848                }
12849            }
12850
12851            next_offset += envelope_size;
12852            _next_ordinal_to_read += 1;
12853            if next_offset >= end_offset {
12854                return Ok(());
12855            }
12856
12857            // Decode unknown envelopes for gaps in ordinals.
12858            while _next_ordinal_to_read < 21 {
12859                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12860                _next_ordinal_to_read += 1;
12861                next_offset += envelope_size;
12862            }
12863
12864            let next_out_of_line = decoder.next_out_of_line();
12865            let handles_before = decoder.remaining_handles();
12866            if let Some((inlined, num_bytes, num_handles)) =
12867                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12868            {
12869                let member_inline_size = <fidl::encoding::UnboundedVector<Listener> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12870                if inlined != (member_inline_size <= 4) {
12871                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12872                }
12873                let inner_offset;
12874                let mut inner_depth = depth.clone();
12875                if inlined {
12876                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12877                    inner_offset = next_offset;
12878                } else {
12879                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12880                    inner_depth.increment()?;
12881                }
12882                let val_ref = self.vsock_listeners.get_or_insert_with(|| {
12883                    fidl::new_empty!(
12884                        fidl::encoding::UnboundedVector<Listener>,
12885                        fidl::encoding::DefaultFuchsiaResourceDialect
12886                    )
12887                });
12888                fidl::decode!(
12889                    fidl::encoding::UnboundedVector<Listener>,
12890                    fidl::encoding::DefaultFuchsiaResourceDialect,
12891                    val_ref,
12892                    decoder,
12893                    inner_offset,
12894                    inner_depth
12895                )?;
12896                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12897                {
12898                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12899                }
12900                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12901                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12902                }
12903            }
12904
12905            next_offset += envelope_size;
12906            _next_ordinal_to_read += 1;
12907            if next_offset >= end_offset {
12908                return Ok(());
12909            }
12910
12911            // Decode unknown envelopes for gaps in ordinals.
12912            while _next_ordinal_to_read < 22 {
12913                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12914                _next_ordinal_to_read += 1;
12915                next_offset += envelope_size;
12916            }
12917
12918            let next_out_of_line = decoder.next_out_of_line();
12919            let handles_before = decoder.remaining_handles();
12920            if let Some((inlined, num_bytes, num_handles)) =
12921                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12922            {
12923                let member_inline_size =
12924                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12925                if inlined != (member_inline_size <= 4) {
12926                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12927                }
12928                let inner_offset;
12929                let mut inner_depth = depth.clone();
12930                if inlined {
12931                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12932                    inner_offset = next_offset;
12933                } else {
12934                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12935                    inner_depth.increment()?;
12936                }
12937                let val_ref = self.virtio_mem.get_or_insert_with(|| {
12938                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12939                });
12940                fidl::decode!(
12941                    bool,
12942                    fidl::encoding::DefaultFuchsiaResourceDialect,
12943                    val_ref,
12944                    decoder,
12945                    inner_offset,
12946                    inner_depth
12947                )?;
12948                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12949                {
12950                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12951                }
12952                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12953                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12954                }
12955            }
12956
12957            next_offset += envelope_size;
12958            _next_ordinal_to_read += 1;
12959            if next_offset >= end_offset {
12960                return Ok(());
12961            }
12962
12963            // Decode unknown envelopes for gaps in ordinals.
12964            while _next_ordinal_to_read < 23 {
12965                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12966                _next_ordinal_to_read += 1;
12967                next_offset += envelope_size;
12968            }
12969
12970            let next_out_of_line = decoder.next_out_of_line();
12971            let handles_before = decoder.remaining_handles();
12972            if let Some((inlined, num_bytes, num_handles)) =
12973                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12974            {
12975                let member_inline_size =
12976                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12977                if inlined != (member_inline_size <= 4) {
12978                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12979                }
12980                let inner_offset;
12981                let mut inner_depth = depth.clone();
12982                if inlined {
12983                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12984                    inner_offset = next_offset;
12985                } else {
12986                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12987                    inner_depth.increment()?;
12988                }
12989                let val_ref = self.virtio_mem_block_size.get_or_insert_with(|| {
12990                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12991                });
12992                fidl::decode!(
12993                    u64,
12994                    fidl::encoding::DefaultFuchsiaResourceDialect,
12995                    val_ref,
12996                    decoder,
12997                    inner_offset,
12998                    inner_depth
12999                )?;
13000                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13001                {
13002                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13003                }
13004                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13005                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13006                }
13007            }
13008
13009            next_offset += envelope_size;
13010            _next_ordinal_to_read += 1;
13011            if next_offset >= end_offset {
13012                return Ok(());
13013            }
13014
13015            // Decode unknown envelopes for gaps in ordinals.
13016            while _next_ordinal_to_read < 24 {
13017                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13018                _next_ordinal_to_read += 1;
13019                next_offset += envelope_size;
13020            }
13021
13022            let next_out_of_line = decoder.next_out_of_line();
13023            let handles_before = decoder.remaining_handles();
13024            if let Some((inlined, num_bytes, num_handles)) =
13025                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13026            {
13027                let member_inline_size =
13028                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13029                if inlined != (member_inline_size <= 4) {
13030                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13031                }
13032                let inner_offset;
13033                let mut inner_depth = depth.clone();
13034                if inlined {
13035                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13036                    inner_offset = next_offset;
13037                } else {
13038                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13039                    inner_depth.increment()?;
13040                }
13041                let val_ref = self.virtio_mem_region_size.get_or_insert_with(|| {
13042                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
13043                });
13044                fidl::decode!(
13045                    u64,
13046                    fidl::encoding::DefaultFuchsiaResourceDialect,
13047                    val_ref,
13048                    decoder,
13049                    inner_offset,
13050                    inner_depth
13051                )?;
13052                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13053                {
13054                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13055                }
13056                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13057                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13058                }
13059            }
13060
13061            next_offset += envelope_size;
13062            _next_ordinal_to_read += 1;
13063            if next_offset >= end_offset {
13064                return Ok(());
13065            }
13066
13067            // Decode unknown envelopes for gaps in ordinals.
13068            while _next_ordinal_to_read < 25 {
13069                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13070                _next_ordinal_to_read += 1;
13071                next_offset += envelope_size;
13072            }
13073
13074            let next_out_of_line = decoder.next_out_of_line();
13075            let handles_before = decoder.remaining_handles();
13076            if let Some((inlined, num_bytes, num_handles)) =
13077                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13078            {
13079                let member_inline_size =
13080                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13081                if inlined != (member_inline_size <= 4) {
13082                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13083                }
13084                let inner_offset;
13085                let mut inner_depth = depth.clone();
13086                if inlined {
13087                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13088                    inner_offset = next_offset;
13089                } else {
13090                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13091                    inner_depth.increment()?;
13092                }
13093                let val_ref = self.virtio_mem_region_alignment.get_or_insert_with(|| {
13094                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
13095                });
13096                fidl::decode!(
13097                    u64,
13098                    fidl::encoding::DefaultFuchsiaResourceDialect,
13099                    val_ref,
13100                    decoder,
13101                    inner_offset,
13102                    inner_depth
13103                )?;
13104                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13105                {
13106                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13107                }
13108                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13109                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13110                }
13111            }
13112
13113            next_offset += envelope_size;
13114
13115            // Decode the remaining unknown envelopes.
13116            while next_offset < end_offset {
13117                _next_ordinal_to_read += 1;
13118                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13119                next_offset += envelope_size;
13120            }
13121
13122            Ok(())
13123        }
13124    }
13125
13126    impl fidl::encoding::ResourceTypeMarker for BlockFormat {
13127        type Borrowed<'a> = &'a mut Self;
13128        fn take_or_borrow<'a>(
13129            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13130        ) -> Self::Borrowed<'a> {
13131            value
13132        }
13133    }
13134
13135    unsafe impl fidl::encoding::TypeMarker for BlockFormat {
13136        type Owned = Self;
13137
13138        #[inline(always)]
13139        fn inline_align(_context: fidl::encoding::Context) -> usize {
13140            8
13141        }
13142
13143        #[inline(always)]
13144        fn inline_size(_context: fidl::encoding::Context) -> usize {
13145            16
13146        }
13147    }
13148
13149    unsafe impl fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>
13150        for &mut BlockFormat
13151    {
13152        #[inline]
13153        unsafe fn encode(
13154            self,
13155            encoder: &mut fidl::encoding::Encoder<
13156                '_,
13157                fidl::encoding::DefaultFuchsiaResourceDialect,
13158            >,
13159            offset: usize,
13160            _depth: fidl::encoding::Depth,
13161        ) -> fidl::Result<()> {
13162            encoder.debug_check_bounds::<BlockFormat>(offset);
13163            encoder.write_num::<u64>(self.ordinal(), offset);
13164            match self {
13165                BlockFormat::File(ref mut val) => fidl::encoding::encode_in_envelope::<
13166                    fidl::encoding::Endpoint<
13167                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13168                    >,
13169                    fidl::encoding::DefaultFuchsiaResourceDialect,
13170                >(
13171                    <fidl::encoding::Endpoint<
13172                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13173                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13174                        val
13175                    ),
13176                    encoder,
13177                    offset + 8,
13178                    _depth,
13179                ),
13180                BlockFormat::Qcow(ref mut val) => fidl::encoding::encode_in_envelope::<
13181                    fidl::encoding::HandleType<
13182                        fidl::Channel,
13183                        { fidl::ObjectType::CHANNEL.into_raw() },
13184                        2147483648,
13185                    >,
13186                    fidl::encoding::DefaultFuchsiaResourceDialect,
13187                >(
13188                    <fidl::encoding::HandleType<
13189                        fidl::Channel,
13190                        { fidl::ObjectType::CHANNEL.into_raw() },
13191                        2147483648,
13192                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13193                        val
13194                    ),
13195                    encoder,
13196                    offset + 8,
13197                    _depth,
13198                ),
13199                BlockFormat::Block(ref mut val) => fidl::encoding::encode_in_envelope::<
13200                    fidl::encoding::Endpoint<
13201                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
13202                    >,
13203                    fidl::encoding::DefaultFuchsiaResourceDialect,
13204                >(
13205                    <fidl::encoding::Endpoint<
13206                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
13207                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13208                        val
13209                    ),
13210                    encoder,
13211                    offset + 8,
13212                    _depth,
13213                ),
13214            }
13215        }
13216    }
13217
13218    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockFormat {
13219        #[inline(always)]
13220        fn new_empty() -> Self {
13221            Self::File(fidl::new_empty!(
13222                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
13223                fidl::encoding::DefaultFuchsiaResourceDialect
13224            ))
13225        }
13226
13227        #[inline]
13228        unsafe fn decode(
13229            &mut self,
13230            decoder: &mut fidl::encoding::Decoder<
13231                '_,
13232                fidl::encoding::DefaultFuchsiaResourceDialect,
13233            >,
13234            offset: usize,
13235            mut depth: fidl::encoding::Depth,
13236        ) -> fidl::Result<()> {
13237            decoder.debug_check_bounds::<Self>(offset);
13238            #[allow(unused_variables)]
13239            let next_out_of_line = decoder.next_out_of_line();
13240            let handles_before = decoder.remaining_handles();
13241            let (ordinal, inlined, num_bytes, num_handles) =
13242                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
13243
13244            let member_inline_size = match ordinal {
13245                1 => <fidl::encoding::Endpoint<
13246                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13247                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13248                2 => <fidl::encoding::HandleType<
13249                    fidl::Channel,
13250                    { fidl::ObjectType::CHANNEL.into_raw() },
13251                    2147483648,
13252                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13253                3 => <fidl::encoding::Endpoint<
13254                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
13255                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13256                _ => return Err(fidl::Error::UnknownUnionTag),
13257            };
13258
13259            if inlined != (member_inline_size <= 4) {
13260                return Err(fidl::Error::InvalidInlineBitInEnvelope);
13261            }
13262            let _inner_offset;
13263            if inlined {
13264                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
13265                _inner_offset = offset + 8;
13266            } else {
13267                depth.increment()?;
13268                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13269            }
13270            match ordinal {
13271                1 => {
13272                    #[allow(irrefutable_let_patterns)]
13273                    if let BlockFormat::File(_) = self {
13274                        // Do nothing, read the value into the object
13275                    } else {
13276                        // Initialize `self` to the right variant
13277                        *self = BlockFormat::File(fidl::new_empty!(
13278                            fidl::encoding::Endpoint<
13279                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13280                            >,
13281                            fidl::encoding::DefaultFuchsiaResourceDialect
13282                        ));
13283                    }
13284                    #[allow(irrefutable_let_patterns)]
13285                    if let BlockFormat::File(ref mut val) = self {
13286                        fidl::decode!(
13287                            fidl::encoding::Endpoint<
13288                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13289                            >,
13290                            fidl::encoding::DefaultFuchsiaResourceDialect,
13291                            val,
13292                            decoder,
13293                            _inner_offset,
13294                            depth
13295                        )?;
13296                    } else {
13297                        unreachable!()
13298                    }
13299                }
13300                2 => {
13301                    #[allow(irrefutable_let_patterns)]
13302                    if let BlockFormat::Qcow(_) = self {
13303                        // Do nothing, read the value into the object
13304                    } else {
13305                        // Initialize `self` to the right variant
13306                        *self = BlockFormat::Qcow(
13307                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
13308                        );
13309                    }
13310                    #[allow(irrefutable_let_patterns)]
13311                    if let BlockFormat::Qcow(ref mut val) = self {
13312                        fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
13313                    } else {
13314                        unreachable!()
13315                    }
13316                }
13317                3 => {
13318                    #[allow(irrefutable_let_patterns)]
13319                    if let BlockFormat::Block(_) = self {
13320                        // Do nothing, read the value into the object
13321                    } else {
13322                        // Initialize `self` to the right variant
13323                        *self = BlockFormat::Block(fidl::new_empty!(
13324                            fidl::encoding::Endpoint<
13325                                fidl::endpoints::ClientEnd<
13326                                    fidl_fuchsia_hardware_block::BlockMarker,
13327                                >,
13328                            >,
13329                            fidl::encoding::DefaultFuchsiaResourceDialect
13330                        ));
13331                    }
13332                    #[allow(irrefutable_let_patterns)]
13333                    if let BlockFormat::Block(ref mut val) = self {
13334                        fidl::decode!(
13335                            fidl::encoding::Endpoint<
13336                                fidl::endpoints::ClientEnd<
13337                                    fidl_fuchsia_hardware_block::BlockMarker,
13338                                >,
13339                            >,
13340                            fidl::encoding::DefaultFuchsiaResourceDialect,
13341                            val,
13342                            decoder,
13343                            _inner_offset,
13344                            depth
13345                        )?;
13346                    } else {
13347                        unreachable!()
13348                    }
13349                }
13350                ordinal => panic!("unexpected ordinal {:?}", ordinal),
13351            }
13352            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
13353                return Err(fidl::Error::InvalidNumBytesInEnvelope);
13354            }
13355            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13356                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13357            }
13358            Ok(())
13359        }
13360    }
13361}