Skip to main content

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/// The configuration required to start up a guest. When adding a new field, consider updating
145/// fuchsia.virtualization.GuestDescriptor which is an informational snapshot of this table.
146#[derive(Debug, Default, PartialEq)]
147pub struct GuestConfig {
148    /// Type of kernel to load. Cannot be changed from the command-line.
149    pub kernel_type: Option<KernelType>,
150    /// File to load the kernel from. Cannot be changed from the command-line.
151    pub kernel: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
152    /// File to load the initial RAM disk from. Cannot be changed from the
153    /// command-line.
154    pub ramdisk: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
155    /// File to load the dtb overlay for a Linux kernel from. Cannot be changed
156    /// from the command-line.
157    pub dtb_overlay: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
158    /// Kernel command-line to use. Cannot be changed from the command-line.
159    pub cmdline: Option<String>,
160    /// Additional kernel command-lines to append to the main command-line.
161    pub cmdline_add: Option<Vec<String>>,
162    /// The number of CPUs to provide to a guest.
163    pub cpus: Option<u8>,
164    /// Amount of guest memory required, in bytes. This value may be rounded up depending on
165    /// the system configuration.
166    pub guest_memory: Option<u64>,
167    /// A list of block devices to give a guest. Cannot be changed from the
168    /// command-line.
169    pub block_devices: Option<Vec<BlockSpec>>,
170    /// A list of specifications for network devices.
171    pub net_devices: Option<Vec<NetSpec>>,
172    /// "11: wayland_device WaylandDevice" was removed
173    /// "12: magma_device MagmaDevice" was removed
174    /// Whether to add a default network device.
175    pub default_net: Option<bool>,
176    /// Enable virtio-balloon.
177    pub virtio_balloon: Option<bool>,
178    /// Enable virtio-console.
179    pub virtio_console: Option<bool>,
180    /// Enable virtio-gpu.
181    pub virtio_gpu: Option<bool>,
182    /// Enable virtio-rng.
183    pub virtio_rng: Option<bool>,
184    /// Enable virtio-vsock.
185    pub virtio_vsock: Option<bool>,
186    /// Enable virtio-sound.
187    pub virtio_sound: Option<bool>,
188    /// Enable input streams (capture) for virtio-sound.
189    pub virtio_sound_input: Option<bool>,
190    /// Host ports to listen for guest initiated vsock connections on. This can be used for
191    /// simplicity if a Listener is known at config creation time, or if a Listener must be
192    /// available at the moment of guest creation for timing reasons.
193    ///
194    /// To add a Listener after a guest starts, see HostVsockEndpoint::Listen.
195    pub vsock_listeners: Option<Vec<Listener>>,
196    /// Enable virtio-mem
197    pub virtio_mem: Option<bool>,
198    /// Size of the dynamically (un)pluggable memory block.
199    /// Memory can be (un)plugged at this granularity.
200    /// Smaller block size increases changes of successful unplug at the cost of increasing
201    /// the size of tracking bitmap.
202    pub virtio_mem_block_size: Option<u64>,
203    /// Size of the entire dynamically pluggable memory region
204    pub virtio_mem_region_size: Option<u64>,
205    /// Required alignment of the dynamically pluggable memory region
206    pub virtio_mem_region_alignment: Option<u64>,
207    #[doc(hidden)]
208    pub __source_breaking: fidl::marker::SourceBreaking,
209}
210
211impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for GuestConfig {}
212
213#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
214pub enum BlockFormat {
215    /// File IO. All reads and writes go directly to disk as a flat file.
216    File(fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>),
217    /// QCOW image. All reads and writes go to a QCOW image.
218    Qcow(fidl::Channel),
219    /// Block IO. All reads and writes go to a block server.
220    Block(fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>),
221}
222
223impl BlockFormat {
224    #[inline]
225    pub fn ordinal(&self) -> u64 {
226        match *self {
227            Self::File(_) => 1,
228            Self::Qcow(_) => 2,
229            Self::Block(_) => 3,
230        }
231    }
232}
233
234impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockFormat {}
235
236#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
237pub struct BalloonControllerMarker;
238
239impl fidl::endpoints::ProtocolMarker for BalloonControllerMarker {
240    type Proxy = BalloonControllerProxy;
241    type RequestStream = BalloonControllerRequestStream;
242    #[cfg(target_os = "fuchsia")]
243    type SynchronousProxy = BalloonControllerSynchronousProxy;
244
245    const DEBUG_NAME: &'static str = "fuchsia.virtualization.BalloonController";
246}
247impl fidl::endpoints::DiscoverableProtocolMarker for BalloonControllerMarker {}
248
249pub trait BalloonControllerProxyInterface: Send + Sync {
250    type GetBalloonSizeResponseFut: std::future::Future<Output = Result<(u32, u32), fidl::Error>>
251        + Send;
252    fn r#get_balloon_size(&self) -> Self::GetBalloonSizeResponseFut;
253    fn r#request_num_pages(&self, requested_num_pages: u32) -> Result<(), fidl::Error>;
254    type GetMemStatsResponseFut: std::future::Future<Output = Result<(i32, Option<Vec<MemStat>>), fidl::Error>>
255        + Send;
256    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut;
257}
258#[derive(Debug)]
259#[cfg(target_os = "fuchsia")]
260pub struct BalloonControllerSynchronousProxy {
261    client: fidl::client::sync::Client,
262}
263
264#[cfg(target_os = "fuchsia")]
265impl fidl::endpoints::SynchronousProxy for BalloonControllerSynchronousProxy {
266    type Proxy = BalloonControllerProxy;
267    type Protocol = BalloonControllerMarker;
268
269    fn from_channel(inner: fidl::Channel) -> Self {
270        Self::new(inner)
271    }
272
273    fn into_channel(self) -> fidl::Channel {
274        self.client.into_channel()
275    }
276
277    fn as_channel(&self) -> &fidl::Channel {
278        self.client.as_channel()
279    }
280}
281
282#[cfg(target_os = "fuchsia")]
283impl BalloonControllerSynchronousProxy {
284    pub fn new(channel: fidl::Channel) -> Self {
285        Self { client: fidl::client::sync::Client::new(channel) }
286    }
287
288    pub fn into_channel(self) -> fidl::Channel {
289        self.client.into_channel()
290    }
291
292    /// Waits until an event arrives and returns it. It is safe for other
293    /// threads to make concurrent requests while waiting for an event.
294    pub fn wait_for_event(
295        &self,
296        deadline: zx::MonotonicInstant,
297    ) -> Result<BalloonControllerEvent, fidl::Error> {
298        BalloonControllerEvent::decode(
299            self.client.wait_for_event::<BalloonControllerMarker>(deadline)?,
300        )
301    }
302
303    /// Get the current and requested number of pages in the memory balloon.
304    ///
305    /// current_num_pages is the number of pages balloon has right now.
306    /// requested_num_pages is the desired number of pages in the balloon.
307    ///
308    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
309    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
310    pub fn r#get_balloon_size(
311        &self,
312        ___deadline: zx::MonotonicInstant,
313    ) -> Result<(u32, u32), fidl::Error> {
314        let _response = self.client.send_query::<
315            fidl::encoding::EmptyPayload,
316            BalloonControllerGetBalloonSizeResponse,
317            BalloonControllerMarker,
318        >(
319            (),
320            0x2bb2ebaa6ff64d0b,
321            fidl::encoding::DynamicFlags::empty(),
322            ___deadline,
323        )?;
324        Ok((_response.current_num_pages, _response.requested_num_pages))
325    }
326
327    /// Request a number of pages to be supplied to the memory balloon.
328    ///
329    /// If `requested_num_pages` is greater than the `current_num_pages` config
330    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
331    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
332    /// the guest driver MAY reclaim pages from the memory balloon.
333    pub fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
334        self.client.send::<BalloonControllerRequestNumPagesRequest>(
335            (requested_num_pages,),
336            0x55c444d65e1df1e8,
337            fidl::encoding::DynamicFlags::empty(),
338        )
339    }
340
341    /// Get memory statistics of the guest instance.
342    pub fn r#get_mem_stats(
343        &self,
344        ___deadline: zx::MonotonicInstant,
345    ) -> Result<(i32, Option<Vec<MemStat>>), fidl::Error> {
346        let _response = self.client.send_query::<
347            fidl::encoding::EmptyPayload,
348            BalloonControllerGetMemStatsResponse,
349            BalloonControllerMarker,
350        >(
351            (),
352            0x676199795cc01142,
353            fidl::encoding::DynamicFlags::empty(),
354            ___deadline,
355        )?;
356        Ok((_response.status, _response.mem_stats))
357    }
358}
359
360#[cfg(target_os = "fuchsia")]
361impl From<BalloonControllerSynchronousProxy> for zx::NullableHandle {
362    fn from(value: BalloonControllerSynchronousProxy) -> Self {
363        value.into_channel().into()
364    }
365}
366
367#[cfg(target_os = "fuchsia")]
368impl From<fidl::Channel> for BalloonControllerSynchronousProxy {
369    fn from(value: fidl::Channel) -> Self {
370        Self::new(value)
371    }
372}
373
374#[cfg(target_os = "fuchsia")]
375impl fidl::endpoints::FromClient for BalloonControllerSynchronousProxy {
376    type Protocol = BalloonControllerMarker;
377
378    fn from_client(value: fidl::endpoints::ClientEnd<BalloonControllerMarker>) -> Self {
379        Self::new(value.into_channel())
380    }
381}
382
383#[derive(Debug, Clone)]
384pub struct BalloonControllerProxy {
385    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
386}
387
388impl fidl::endpoints::Proxy for BalloonControllerProxy {
389    type Protocol = BalloonControllerMarker;
390
391    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
392        Self::new(inner)
393    }
394
395    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
396        self.client.into_channel().map_err(|client| Self { client })
397    }
398
399    fn as_channel(&self) -> &::fidl::AsyncChannel {
400        self.client.as_channel()
401    }
402}
403
404impl BalloonControllerProxy {
405    /// Create a new Proxy for fuchsia.virtualization/BalloonController.
406    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
407        let protocol_name =
408            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
409        Self { client: fidl::client::Client::new(channel, protocol_name) }
410    }
411
412    /// Get a Stream of events from the remote end of the protocol.
413    ///
414    /// # Panics
415    ///
416    /// Panics if the event stream was already taken.
417    pub fn take_event_stream(&self) -> BalloonControllerEventStream {
418        BalloonControllerEventStream { event_receiver: self.client.take_event_receiver() }
419    }
420
421    /// Get the current and requested number of pages in the memory balloon.
422    ///
423    /// current_num_pages is the number of pages balloon has right now.
424    /// requested_num_pages is the desired number of pages in the balloon.
425    ///
426    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
427    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
428    pub fn r#get_balloon_size(
429        &self,
430    ) -> fidl::client::QueryResponseFut<(u32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
431    {
432        BalloonControllerProxyInterface::r#get_balloon_size(self)
433    }
434
435    /// Request a number of pages to be supplied to the memory balloon.
436    ///
437    /// If `requested_num_pages` is greater than the `current_num_pages` config
438    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
439    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
440    /// the guest driver MAY reclaim pages from the memory balloon.
441    pub fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
442        BalloonControllerProxyInterface::r#request_num_pages(self, requested_num_pages)
443    }
444
445    /// Get memory statistics of the guest instance.
446    pub fn r#get_mem_stats(
447        &self,
448    ) -> fidl::client::QueryResponseFut<
449        (i32, Option<Vec<MemStat>>),
450        fidl::encoding::DefaultFuchsiaResourceDialect,
451    > {
452        BalloonControllerProxyInterface::r#get_mem_stats(self)
453    }
454}
455
456impl BalloonControllerProxyInterface for BalloonControllerProxy {
457    type GetBalloonSizeResponseFut =
458        fidl::client::QueryResponseFut<(u32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
459    fn r#get_balloon_size(&self) -> Self::GetBalloonSizeResponseFut {
460        fn _decode(
461            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
462        ) -> Result<(u32, u32), fidl::Error> {
463            let _response = fidl::client::decode_transaction_body::<
464                BalloonControllerGetBalloonSizeResponse,
465                fidl::encoding::DefaultFuchsiaResourceDialect,
466                0x2bb2ebaa6ff64d0b,
467            >(_buf?)?;
468            Ok((_response.current_num_pages, _response.requested_num_pages))
469        }
470        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (u32, u32)>(
471            (),
472            0x2bb2ebaa6ff64d0b,
473            fidl::encoding::DynamicFlags::empty(),
474            _decode,
475        )
476    }
477
478    fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
479        self.client.send::<BalloonControllerRequestNumPagesRequest>(
480            (requested_num_pages,),
481            0x55c444d65e1df1e8,
482            fidl::encoding::DynamicFlags::empty(),
483        )
484    }
485
486    type GetMemStatsResponseFut = fidl::client::QueryResponseFut<
487        (i32, Option<Vec<MemStat>>),
488        fidl::encoding::DefaultFuchsiaResourceDialect,
489    >;
490    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut {
491        fn _decode(
492            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
493        ) -> Result<(i32, Option<Vec<MemStat>>), fidl::Error> {
494            let _response = fidl::client::decode_transaction_body::<
495                BalloonControllerGetMemStatsResponse,
496                fidl::encoding::DefaultFuchsiaResourceDialect,
497                0x676199795cc01142,
498            >(_buf?)?;
499            Ok((_response.status, _response.mem_stats))
500        }
501        self.client
502            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<Vec<MemStat>>)>(
503                (),
504                0x676199795cc01142,
505                fidl::encoding::DynamicFlags::empty(),
506                _decode,
507            )
508    }
509}
510
511pub struct BalloonControllerEventStream {
512    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
513}
514
515impl std::marker::Unpin for BalloonControllerEventStream {}
516
517impl futures::stream::FusedStream for BalloonControllerEventStream {
518    fn is_terminated(&self) -> bool {
519        self.event_receiver.is_terminated()
520    }
521}
522
523impl futures::Stream for BalloonControllerEventStream {
524    type Item = Result<BalloonControllerEvent, fidl::Error>;
525
526    fn poll_next(
527        mut self: std::pin::Pin<&mut Self>,
528        cx: &mut std::task::Context<'_>,
529    ) -> std::task::Poll<Option<Self::Item>> {
530        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
531            &mut self.event_receiver,
532            cx
533        )?) {
534            Some(buf) => std::task::Poll::Ready(Some(BalloonControllerEvent::decode(buf))),
535            None => std::task::Poll::Ready(None),
536        }
537    }
538}
539
540#[derive(Debug)]
541pub enum BalloonControllerEvent {}
542
543impl BalloonControllerEvent {
544    /// Decodes a message buffer as a [`BalloonControllerEvent`].
545    fn decode(
546        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
547    ) -> Result<BalloonControllerEvent, fidl::Error> {
548        let (bytes, _handles) = buf.split_mut();
549        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
550        debug_assert_eq!(tx_header.tx_id, 0);
551        match tx_header.ordinal {
552            _ => Err(fidl::Error::UnknownOrdinal {
553                ordinal: tx_header.ordinal,
554                protocol_name:
555                    <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
556            }),
557        }
558    }
559}
560
561/// A Stream of incoming requests for fuchsia.virtualization/BalloonController.
562pub struct BalloonControllerRequestStream {
563    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
564    is_terminated: bool,
565}
566
567impl std::marker::Unpin for BalloonControllerRequestStream {}
568
569impl futures::stream::FusedStream for BalloonControllerRequestStream {
570    fn is_terminated(&self) -> bool {
571        self.is_terminated
572    }
573}
574
575impl fidl::endpoints::RequestStream for BalloonControllerRequestStream {
576    type Protocol = BalloonControllerMarker;
577    type ControlHandle = BalloonControllerControlHandle;
578
579    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
580        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
581    }
582
583    fn control_handle(&self) -> Self::ControlHandle {
584        BalloonControllerControlHandle { inner: self.inner.clone() }
585    }
586
587    fn into_inner(
588        self,
589    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
590    {
591        (self.inner, self.is_terminated)
592    }
593
594    fn from_inner(
595        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
596        is_terminated: bool,
597    ) -> Self {
598        Self { inner, is_terminated }
599    }
600}
601
602impl futures::Stream for BalloonControllerRequestStream {
603    type Item = Result<BalloonControllerRequest, fidl::Error>;
604
605    fn poll_next(
606        mut self: std::pin::Pin<&mut Self>,
607        cx: &mut std::task::Context<'_>,
608    ) -> std::task::Poll<Option<Self::Item>> {
609        let this = &mut *self;
610        if this.inner.check_shutdown(cx) {
611            this.is_terminated = true;
612            return std::task::Poll::Ready(None);
613        }
614        if this.is_terminated {
615            panic!("polled BalloonControllerRequestStream after completion");
616        }
617        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
618            |bytes, handles| {
619                match this.inner.channel().read_etc(cx, bytes, handles) {
620                    std::task::Poll::Ready(Ok(())) => {}
621                    std::task::Poll::Pending => return std::task::Poll::Pending,
622                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
623                        this.is_terminated = true;
624                        return std::task::Poll::Ready(None);
625                    }
626                    std::task::Poll::Ready(Err(e)) => {
627                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
628                            e.into(),
629                        ))));
630                    }
631                }
632
633                // A message has been received from the channel
634                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
635
636                std::task::Poll::Ready(Some(match header.ordinal {
637                    0x2bb2ebaa6ff64d0b => {
638                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
639                        let mut req = fidl::new_empty!(
640                            fidl::encoding::EmptyPayload,
641                            fidl::encoding::DefaultFuchsiaResourceDialect
642                        );
643                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
644                        let control_handle =
645                            BalloonControllerControlHandle { inner: this.inner.clone() };
646                        Ok(BalloonControllerRequest::GetBalloonSize {
647                            responder: BalloonControllerGetBalloonSizeResponder {
648                                control_handle: std::mem::ManuallyDrop::new(control_handle),
649                                tx_id: header.tx_id,
650                            },
651                        })
652                    }
653                    0x55c444d65e1df1e8 => {
654                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
655                        let mut req = fidl::new_empty!(
656                            BalloonControllerRequestNumPagesRequest,
657                            fidl::encoding::DefaultFuchsiaResourceDialect
658                        );
659                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BalloonControllerRequestNumPagesRequest>(&header, _body_bytes, handles, &mut req)?;
660                        let control_handle =
661                            BalloonControllerControlHandle { inner: this.inner.clone() };
662                        Ok(BalloonControllerRequest::RequestNumPages {
663                            requested_num_pages: req.requested_num_pages,
664
665                            control_handle,
666                        })
667                    }
668                    0x676199795cc01142 => {
669                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
670                        let mut req = fidl::new_empty!(
671                            fidl::encoding::EmptyPayload,
672                            fidl::encoding::DefaultFuchsiaResourceDialect
673                        );
674                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
675                        let control_handle =
676                            BalloonControllerControlHandle { inner: this.inner.clone() };
677                        Ok(BalloonControllerRequest::GetMemStats {
678                            responder: BalloonControllerGetMemStatsResponder {
679                                control_handle: std::mem::ManuallyDrop::new(control_handle),
680                                tx_id: header.tx_id,
681                            },
682                        })
683                    }
684                    _ => Err(fidl::Error::UnknownOrdinal {
685                        ordinal: header.ordinal,
686                        protocol_name:
687                            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
688                    }),
689                }))
690            },
691        )
692    }
693}
694
695/// A `BalloonController` controls a guest instance's memory balloon.
696#[derive(Debug)]
697pub enum BalloonControllerRequest {
698    /// Get the current and requested number of pages in the memory balloon.
699    ///
700    /// current_num_pages is the number of pages balloon has right now.
701    /// requested_num_pages is the desired number of pages in the balloon.
702    ///
703    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
704    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
705    GetBalloonSize { responder: BalloonControllerGetBalloonSizeResponder },
706    /// Request a number of pages to be supplied to the memory balloon.
707    ///
708    /// If `requested_num_pages` is greater than the `current_num_pages` config
709    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
710    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
711    /// the guest driver MAY reclaim pages from the memory balloon.
712    RequestNumPages { requested_num_pages: u32, control_handle: BalloonControllerControlHandle },
713    /// Get memory statistics of the guest instance.
714    GetMemStats { responder: BalloonControllerGetMemStatsResponder },
715}
716
717impl BalloonControllerRequest {
718    #[allow(irrefutable_let_patterns)]
719    pub fn into_get_balloon_size(self) -> Option<(BalloonControllerGetBalloonSizeResponder)> {
720        if let BalloonControllerRequest::GetBalloonSize { responder } = self {
721            Some((responder))
722        } else {
723            None
724        }
725    }
726
727    #[allow(irrefutable_let_patterns)]
728    pub fn into_request_num_pages(self) -> Option<(u32, BalloonControllerControlHandle)> {
729        if let BalloonControllerRequest::RequestNumPages { requested_num_pages, control_handle } =
730            self
731        {
732            Some((requested_num_pages, control_handle))
733        } else {
734            None
735        }
736    }
737
738    #[allow(irrefutable_let_patterns)]
739    pub fn into_get_mem_stats(self) -> Option<(BalloonControllerGetMemStatsResponder)> {
740        if let BalloonControllerRequest::GetMemStats { responder } = self {
741            Some((responder))
742        } else {
743            None
744        }
745    }
746
747    /// Name of the method defined in FIDL
748    pub fn method_name(&self) -> &'static str {
749        match *self {
750            BalloonControllerRequest::GetBalloonSize { .. } => "get_balloon_size",
751            BalloonControllerRequest::RequestNumPages { .. } => "request_num_pages",
752            BalloonControllerRequest::GetMemStats { .. } => "get_mem_stats",
753        }
754    }
755}
756
757#[derive(Debug, Clone)]
758pub struct BalloonControllerControlHandle {
759    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
760}
761
762impl fidl::endpoints::ControlHandle for BalloonControllerControlHandle {
763    fn shutdown(&self) {
764        self.inner.shutdown()
765    }
766
767    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
768        self.inner.shutdown_with_epitaph(status)
769    }
770
771    fn is_closed(&self) -> bool {
772        self.inner.channel().is_closed()
773    }
774    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
775        self.inner.channel().on_closed()
776    }
777
778    #[cfg(target_os = "fuchsia")]
779    fn signal_peer(
780        &self,
781        clear_mask: zx::Signals,
782        set_mask: zx::Signals,
783    ) -> Result<(), zx_status::Status> {
784        use fidl::Peered;
785        self.inner.channel().signal_peer(clear_mask, set_mask)
786    }
787}
788
789impl BalloonControllerControlHandle {}
790
791#[must_use = "FIDL methods require a response to be sent"]
792#[derive(Debug)]
793pub struct BalloonControllerGetBalloonSizeResponder {
794    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
795    tx_id: u32,
796}
797
798/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
799/// if the responder is dropped without sending a response, so that the client
800/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
801impl std::ops::Drop for BalloonControllerGetBalloonSizeResponder {
802    fn drop(&mut self) {
803        self.control_handle.shutdown();
804        // Safety: drops once, never accessed again
805        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
806    }
807}
808
809impl fidl::endpoints::Responder for BalloonControllerGetBalloonSizeResponder {
810    type ControlHandle = BalloonControllerControlHandle;
811
812    fn control_handle(&self) -> &BalloonControllerControlHandle {
813        &self.control_handle
814    }
815
816    fn drop_without_shutdown(mut self) {
817        // Safety: drops once, never accessed again due to mem::forget
818        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
819        // Prevent Drop from running (which would shut down the channel)
820        std::mem::forget(self);
821    }
822}
823
824impl BalloonControllerGetBalloonSizeResponder {
825    /// Sends a response to the FIDL transaction.
826    ///
827    /// Sets the channel to shutdown if an error occurs.
828    pub fn send(
829        self,
830        mut current_num_pages: u32,
831        mut requested_num_pages: u32,
832    ) -> Result<(), fidl::Error> {
833        let _result = self.send_raw(current_num_pages, requested_num_pages);
834        if _result.is_err() {
835            self.control_handle.shutdown();
836        }
837        self.drop_without_shutdown();
838        _result
839    }
840
841    /// Similar to "send" but does not shutdown the channel if an error occurs.
842    pub fn send_no_shutdown_on_err(
843        self,
844        mut current_num_pages: u32,
845        mut requested_num_pages: u32,
846    ) -> Result<(), fidl::Error> {
847        let _result = self.send_raw(current_num_pages, requested_num_pages);
848        self.drop_without_shutdown();
849        _result
850    }
851
852    fn send_raw(
853        &self,
854        mut current_num_pages: u32,
855        mut requested_num_pages: u32,
856    ) -> Result<(), fidl::Error> {
857        self.control_handle.inner.send::<BalloonControllerGetBalloonSizeResponse>(
858            (current_num_pages, requested_num_pages),
859            self.tx_id,
860            0x2bb2ebaa6ff64d0b,
861            fidl::encoding::DynamicFlags::empty(),
862        )
863    }
864}
865
866#[must_use = "FIDL methods require a response to be sent"]
867#[derive(Debug)]
868pub struct BalloonControllerGetMemStatsResponder {
869    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
870    tx_id: u32,
871}
872
873/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
874/// if the responder is dropped without sending a response, so that the client
875/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
876impl std::ops::Drop for BalloonControllerGetMemStatsResponder {
877    fn drop(&mut self) {
878        self.control_handle.shutdown();
879        // Safety: drops once, never accessed again
880        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
881    }
882}
883
884impl fidl::endpoints::Responder for BalloonControllerGetMemStatsResponder {
885    type ControlHandle = BalloonControllerControlHandle;
886
887    fn control_handle(&self) -> &BalloonControllerControlHandle {
888        &self.control_handle
889    }
890
891    fn drop_without_shutdown(mut self) {
892        // Safety: drops once, never accessed again due to mem::forget
893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
894        // Prevent Drop from running (which would shut down the channel)
895        std::mem::forget(self);
896    }
897}
898
899impl BalloonControllerGetMemStatsResponder {
900    /// Sends a response to the FIDL transaction.
901    ///
902    /// Sets the channel to shutdown if an error occurs.
903    pub fn send(
904        self,
905        mut status: i32,
906        mut mem_stats: Option<&[MemStat]>,
907    ) -> Result<(), fidl::Error> {
908        let _result = self.send_raw(status, mem_stats);
909        if _result.is_err() {
910            self.control_handle.shutdown();
911        }
912        self.drop_without_shutdown();
913        _result
914    }
915
916    /// Similar to "send" but does not shutdown the channel if an error occurs.
917    pub fn send_no_shutdown_on_err(
918        self,
919        mut status: i32,
920        mut mem_stats: Option<&[MemStat]>,
921    ) -> Result<(), fidl::Error> {
922        let _result = self.send_raw(status, mem_stats);
923        self.drop_without_shutdown();
924        _result
925    }
926
927    fn send_raw(
928        &self,
929        mut status: i32,
930        mut mem_stats: Option<&[MemStat]>,
931    ) -> Result<(), fidl::Error> {
932        self.control_handle.inner.send::<BalloonControllerGetMemStatsResponse>(
933            (status, mem_stats),
934            self.tx_id,
935            0x676199795cc01142,
936            fidl::encoding::DynamicFlags::empty(),
937        )
938    }
939}
940
941#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
942pub struct DebianGuestManagerMarker;
943
944impl fidl::endpoints::ProtocolMarker for DebianGuestManagerMarker {
945    type Proxy = DebianGuestManagerProxy;
946    type RequestStream = DebianGuestManagerRequestStream;
947    #[cfg(target_os = "fuchsia")]
948    type SynchronousProxy = DebianGuestManagerSynchronousProxy;
949
950    const DEBUG_NAME: &'static str = "fuchsia.virtualization.DebianGuestManager";
951}
952impl fidl::endpoints::DiscoverableProtocolMarker for DebianGuestManagerMarker {}
953
954pub trait DebianGuestManagerProxyInterface: Send + Sync {
955    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
956        + Send;
957    fn r#launch(
958        &self,
959        guest_config: GuestConfig,
960        controller: fidl::endpoints::ServerEnd<GuestMarker>,
961    ) -> Self::LaunchResponseFut;
962    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
963    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
964    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
965        + Send;
966    fn r#connect(
967        &self,
968        controller: fidl::endpoints::ServerEnd<GuestMarker>,
969    ) -> Self::ConnectResponseFut;
970    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
971    fn r#get_info(&self) -> Self::GetInfoResponseFut;
972}
973#[derive(Debug)]
974#[cfg(target_os = "fuchsia")]
975pub struct DebianGuestManagerSynchronousProxy {
976    client: fidl::client::sync::Client,
977}
978
979#[cfg(target_os = "fuchsia")]
980impl fidl::endpoints::SynchronousProxy for DebianGuestManagerSynchronousProxy {
981    type Proxy = DebianGuestManagerProxy;
982    type Protocol = DebianGuestManagerMarker;
983
984    fn from_channel(inner: fidl::Channel) -> Self {
985        Self::new(inner)
986    }
987
988    fn into_channel(self) -> fidl::Channel {
989        self.client.into_channel()
990    }
991
992    fn as_channel(&self) -> &fidl::Channel {
993        self.client.as_channel()
994    }
995}
996
997#[cfg(target_os = "fuchsia")]
998impl DebianGuestManagerSynchronousProxy {
999    pub fn new(channel: fidl::Channel) -> Self {
1000        Self { client: fidl::client::sync::Client::new(channel) }
1001    }
1002
1003    pub fn into_channel(self) -> fidl::Channel {
1004        self.client.into_channel()
1005    }
1006
1007    /// Waits until an event arrives and returns it. It is safe for other
1008    /// threads to make concurrent requests while waiting for an event.
1009    pub fn wait_for_event(
1010        &self,
1011        deadline: zx::MonotonicInstant,
1012    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1013        DebianGuestManagerEvent::decode(
1014            self.client.wait_for_event::<DebianGuestManagerMarker>(deadline)?,
1015        )
1016    }
1017
1018    /// Launch a new guest instance.
1019    ///
1020    /// Possible errors:
1021    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1022    ///         problems detected by the guest manager.
1023    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1024    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1025    ///         component logs for a more specific failure.
1026    pub fn r#launch(
1027        &self,
1028        mut guest_config: GuestConfig,
1029        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1030        ___deadline: zx::MonotonicInstant,
1031    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1032        let _response =
1033            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
1034                fidl::encoding::EmptyStruct,
1035                GuestManagerError,
1036            >, DebianGuestManagerMarker>(
1037                (&mut guest_config, controller),
1038                0x394a2e29f750323e,
1039                fidl::encoding::DynamicFlags::empty(),
1040                ___deadline,
1041            )?;
1042        Ok(_response.map(|x| x))
1043    }
1044
1045    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1046    /// be used to launch another guest.
1047    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1048        let _response = self.client.send_query::<
1049            fidl::encoding::EmptyPayload,
1050            fidl::encoding::EmptyPayload,
1051            DebianGuestManagerMarker,
1052        >(
1053            (),
1054            0x3ad9a012982f872d,
1055            fidl::encoding::DynamicFlags::empty(),
1056            ___deadline,
1057        )?;
1058        Ok(_response)
1059    }
1060
1061    /// Connect to a currently running guest.
1062    ///
1063    /// Possible errors:
1064    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1065    ///         has launched before attempting to reconnect.
1066    pub fn r#connect(
1067        &self,
1068        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1069        ___deadline: zx::MonotonicInstant,
1070    ) -> Result<GuestManagerConnectResult, fidl::Error> {
1071        let _response =
1072            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
1073                fidl::encoding::EmptyStruct,
1074                GuestManagerError,
1075            >, DebianGuestManagerMarker>(
1076                (controller,),
1077                0x4e489076e3bb15b4,
1078                fidl::encoding::DynamicFlags::empty(),
1079                ___deadline,
1080            )?;
1081        Ok(_response.map(|x| x))
1082    }
1083
1084    /// Query guest info
1085    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
1086        let _response = self.client.send_query::<
1087            fidl::encoding::EmptyPayload,
1088            GuestManagerGetInfoResponse,
1089            DebianGuestManagerMarker,
1090        >(
1091            (),
1092            0x76892614aea695dc,
1093            fidl::encoding::DynamicFlags::empty(),
1094            ___deadline,
1095        )?;
1096        Ok(_response.guest_info)
1097    }
1098}
1099
1100#[cfg(target_os = "fuchsia")]
1101impl From<DebianGuestManagerSynchronousProxy> for zx::NullableHandle {
1102    fn from(value: DebianGuestManagerSynchronousProxy) -> Self {
1103        value.into_channel().into()
1104    }
1105}
1106
1107#[cfg(target_os = "fuchsia")]
1108impl From<fidl::Channel> for DebianGuestManagerSynchronousProxy {
1109    fn from(value: fidl::Channel) -> Self {
1110        Self::new(value)
1111    }
1112}
1113
1114#[cfg(target_os = "fuchsia")]
1115impl fidl::endpoints::FromClient for DebianGuestManagerSynchronousProxy {
1116    type Protocol = DebianGuestManagerMarker;
1117
1118    fn from_client(value: fidl::endpoints::ClientEnd<DebianGuestManagerMarker>) -> Self {
1119        Self::new(value.into_channel())
1120    }
1121}
1122
1123#[derive(Debug, Clone)]
1124pub struct DebianGuestManagerProxy {
1125    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1126}
1127
1128impl fidl::endpoints::Proxy for DebianGuestManagerProxy {
1129    type Protocol = DebianGuestManagerMarker;
1130
1131    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1132        Self::new(inner)
1133    }
1134
1135    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1136        self.client.into_channel().map_err(|client| Self { client })
1137    }
1138
1139    fn as_channel(&self) -> &::fidl::AsyncChannel {
1140        self.client.as_channel()
1141    }
1142}
1143
1144impl DebianGuestManagerProxy {
1145    /// Create a new Proxy for fuchsia.virtualization/DebianGuestManager.
1146    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1147        let protocol_name =
1148            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1149        Self { client: fidl::client::Client::new(channel, protocol_name) }
1150    }
1151
1152    /// Get a Stream of events from the remote end of the protocol.
1153    ///
1154    /// # Panics
1155    ///
1156    /// Panics if the event stream was already taken.
1157    pub fn take_event_stream(&self) -> DebianGuestManagerEventStream {
1158        DebianGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
1159    }
1160
1161    /// Launch a new guest instance.
1162    ///
1163    /// Possible errors:
1164    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1165    ///         problems detected by the guest manager.
1166    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1167    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1168    ///         component logs for a more specific failure.
1169    pub fn r#launch(
1170        &self,
1171        mut guest_config: GuestConfig,
1172        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1173    ) -> fidl::client::QueryResponseFut<
1174        GuestManagerLaunchResult,
1175        fidl::encoding::DefaultFuchsiaResourceDialect,
1176    > {
1177        DebianGuestManagerProxyInterface::r#launch(self, guest_config, controller)
1178    }
1179
1180    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1181    /// be used to launch another guest.
1182    pub fn r#force_shutdown(
1183        &self,
1184    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1185        DebianGuestManagerProxyInterface::r#force_shutdown(self)
1186    }
1187
1188    /// Connect to a currently running guest.
1189    ///
1190    /// Possible errors:
1191    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1192    ///         has launched before attempting to reconnect.
1193    pub fn r#connect(
1194        &self,
1195        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1196    ) -> fidl::client::QueryResponseFut<
1197        GuestManagerConnectResult,
1198        fidl::encoding::DefaultFuchsiaResourceDialect,
1199    > {
1200        DebianGuestManagerProxyInterface::r#connect(self, controller)
1201    }
1202
1203    /// Query guest info
1204    pub fn r#get_info(
1205        &self,
1206    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1207    {
1208        DebianGuestManagerProxyInterface::r#get_info(self)
1209    }
1210}
1211
1212impl DebianGuestManagerProxyInterface for DebianGuestManagerProxy {
1213    type LaunchResponseFut = fidl::client::QueryResponseFut<
1214        GuestManagerLaunchResult,
1215        fidl::encoding::DefaultFuchsiaResourceDialect,
1216    >;
1217    fn r#launch(
1218        &self,
1219        mut guest_config: GuestConfig,
1220        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1221    ) -> Self::LaunchResponseFut {
1222        fn _decode(
1223            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1224        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1225            let _response = fidl::client::decode_transaction_body::<
1226                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1227                fidl::encoding::DefaultFuchsiaResourceDialect,
1228                0x394a2e29f750323e,
1229            >(_buf?)?;
1230            Ok(_response.map(|x| x))
1231        }
1232        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
1233            (&mut guest_config, controller),
1234            0x394a2e29f750323e,
1235            fidl::encoding::DynamicFlags::empty(),
1236            _decode,
1237        )
1238    }
1239
1240    type ForceShutdownResponseFut =
1241        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1242    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
1243        fn _decode(
1244            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1245        ) -> Result<(), fidl::Error> {
1246            let _response = fidl::client::decode_transaction_body::<
1247                fidl::encoding::EmptyPayload,
1248                fidl::encoding::DefaultFuchsiaResourceDialect,
1249                0x3ad9a012982f872d,
1250            >(_buf?)?;
1251            Ok(_response)
1252        }
1253        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1254            (),
1255            0x3ad9a012982f872d,
1256            fidl::encoding::DynamicFlags::empty(),
1257            _decode,
1258        )
1259    }
1260
1261    type ConnectResponseFut = fidl::client::QueryResponseFut<
1262        GuestManagerConnectResult,
1263        fidl::encoding::DefaultFuchsiaResourceDialect,
1264    >;
1265    fn r#connect(
1266        &self,
1267        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1268    ) -> Self::ConnectResponseFut {
1269        fn _decode(
1270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1271        ) -> Result<GuestManagerConnectResult, fidl::Error> {
1272            let _response = fidl::client::decode_transaction_body::<
1273                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1274                fidl::encoding::DefaultFuchsiaResourceDialect,
1275                0x4e489076e3bb15b4,
1276            >(_buf?)?;
1277            Ok(_response.map(|x| x))
1278        }
1279        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
1280            (controller,),
1281            0x4e489076e3bb15b4,
1282            fidl::encoding::DynamicFlags::empty(),
1283            _decode,
1284        )
1285    }
1286
1287    type GetInfoResponseFut =
1288        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
1289    fn r#get_info(&self) -> Self::GetInfoResponseFut {
1290        fn _decode(
1291            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1292        ) -> Result<GuestInfo, fidl::Error> {
1293            let _response = fidl::client::decode_transaction_body::<
1294                GuestManagerGetInfoResponse,
1295                fidl::encoding::DefaultFuchsiaResourceDialect,
1296                0x76892614aea695dc,
1297            >(_buf?)?;
1298            Ok(_response.guest_info)
1299        }
1300        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
1301            (),
1302            0x76892614aea695dc,
1303            fidl::encoding::DynamicFlags::empty(),
1304            _decode,
1305        )
1306    }
1307}
1308
1309pub struct DebianGuestManagerEventStream {
1310    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1311}
1312
1313impl std::marker::Unpin for DebianGuestManagerEventStream {}
1314
1315impl futures::stream::FusedStream for DebianGuestManagerEventStream {
1316    fn is_terminated(&self) -> bool {
1317        self.event_receiver.is_terminated()
1318    }
1319}
1320
1321impl futures::Stream for DebianGuestManagerEventStream {
1322    type Item = Result<DebianGuestManagerEvent, fidl::Error>;
1323
1324    fn poll_next(
1325        mut self: std::pin::Pin<&mut Self>,
1326        cx: &mut std::task::Context<'_>,
1327    ) -> std::task::Poll<Option<Self::Item>> {
1328        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1329            &mut self.event_receiver,
1330            cx
1331        )?) {
1332            Some(buf) => std::task::Poll::Ready(Some(DebianGuestManagerEvent::decode(buf))),
1333            None => std::task::Poll::Ready(None),
1334        }
1335    }
1336}
1337
1338#[derive(Debug)]
1339pub enum DebianGuestManagerEvent {}
1340
1341impl DebianGuestManagerEvent {
1342    /// Decodes a message buffer as a [`DebianGuestManagerEvent`].
1343    fn decode(
1344        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1345    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1346        let (bytes, _handles) = buf.split_mut();
1347        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1348        debug_assert_eq!(tx_header.tx_id, 0);
1349        match tx_header.ordinal {
1350            _ => Err(fidl::Error::UnknownOrdinal {
1351                ordinal: tx_header.ordinal,
1352                protocol_name:
1353                    <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1354            }),
1355        }
1356    }
1357}
1358
1359/// A Stream of incoming requests for fuchsia.virtualization/DebianGuestManager.
1360pub struct DebianGuestManagerRequestStream {
1361    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1362    is_terminated: bool,
1363}
1364
1365impl std::marker::Unpin for DebianGuestManagerRequestStream {}
1366
1367impl futures::stream::FusedStream for DebianGuestManagerRequestStream {
1368    fn is_terminated(&self) -> bool {
1369        self.is_terminated
1370    }
1371}
1372
1373impl fidl::endpoints::RequestStream for DebianGuestManagerRequestStream {
1374    type Protocol = DebianGuestManagerMarker;
1375    type ControlHandle = DebianGuestManagerControlHandle;
1376
1377    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1378        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1379    }
1380
1381    fn control_handle(&self) -> Self::ControlHandle {
1382        DebianGuestManagerControlHandle { inner: self.inner.clone() }
1383    }
1384
1385    fn into_inner(
1386        self,
1387    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1388    {
1389        (self.inner, self.is_terminated)
1390    }
1391
1392    fn from_inner(
1393        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1394        is_terminated: bool,
1395    ) -> Self {
1396        Self { inner, is_terminated }
1397    }
1398}
1399
1400impl futures::Stream for DebianGuestManagerRequestStream {
1401    type Item = Result<DebianGuestManagerRequest, fidl::Error>;
1402
1403    fn poll_next(
1404        mut self: std::pin::Pin<&mut Self>,
1405        cx: &mut std::task::Context<'_>,
1406    ) -> std::task::Poll<Option<Self::Item>> {
1407        let this = &mut *self;
1408        if this.inner.check_shutdown(cx) {
1409            this.is_terminated = true;
1410            return std::task::Poll::Ready(None);
1411        }
1412        if this.is_terminated {
1413            panic!("polled DebianGuestManagerRequestStream after completion");
1414        }
1415        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1416            |bytes, handles| {
1417                match this.inner.channel().read_etc(cx, bytes, handles) {
1418                    std::task::Poll::Ready(Ok(())) => {}
1419                    std::task::Poll::Pending => return std::task::Poll::Pending,
1420                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1421                        this.is_terminated = true;
1422                        return std::task::Poll::Ready(None);
1423                    }
1424                    std::task::Poll::Ready(Err(e)) => {
1425                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1426                            e.into(),
1427                        ))));
1428                    }
1429                }
1430
1431                // A message has been received from the channel
1432                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1433
1434                std::task::Poll::Ready(Some(match header.ordinal {
1435                0x394a2e29f750323e => {
1436                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1437                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1438                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
1439                    let control_handle = DebianGuestManagerControlHandle {
1440                        inner: this.inner.clone(),
1441                    };
1442                    Ok(DebianGuestManagerRequest::Launch {guest_config: req.guest_config,
1443controller: req.controller,
1444
1445                        responder: DebianGuestManagerLaunchResponder {
1446                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1447                            tx_id: header.tx_id,
1448                        },
1449                    })
1450                }
1451                0x3ad9a012982f872d => {
1452                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1453                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1454                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1455                    let control_handle = DebianGuestManagerControlHandle {
1456                        inner: this.inner.clone(),
1457                    };
1458                    Ok(DebianGuestManagerRequest::ForceShutdown {
1459                        responder: DebianGuestManagerForceShutdownResponder {
1460                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1461                            tx_id: header.tx_id,
1462                        },
1463                    })
1464                }
1465                0x4e489076e3bb15b4 => {
1466                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1467                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1468                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1469                    let control_handle = DebianGuestManagerControlHandle {
1470                        inner: this.inner.clone(),
1471                    };
1472                    Ok(DebianGuestManagerRequest::Connect {controller: req.controller,
1473
1474                        responder: DebianGuestManagerConnectResponder {
1475                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1476                            tx_id: header.tx_id,
1477                        },
1478                    })
1479                }
1480                0x76892614aea695dc => {
1481                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1482                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1483                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1484                    let control_handle = DebianGuestManagerControlHandle {
1485                        inner: this.inner.clone(),
1486                    };
1487                    Ok(DebianGuestManagerRequest::GetInfo {
1488                        responder: DebianGuestManagerGetInfoResponder {
1489                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1490                            tx_id: header.tx_id,
1491                        },
1492                    })
1493                }
1494                _ => Err(fidl::Error::UnknownOrdinal {
1495                    ordinal: header.ordinal,
1496                    protocol_name: <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1497                }),
1498            }))
1499            },
1500        )
1501    }
1502}
1503
1504#[derive(Debug)]
1505pub enum DebianGuestManagerRequest {
1506    /// Launch a new guest instance.
1507    ///
1508    /// Possible errors:
1509    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1510    ///         problems detected by the guest manager.
1511    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1512    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1513    ///         component logs for a more specific failure.
1514    Launch {
1515        guest_config: GuestConfig,
1516        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1517        responder: DebianGuestManagerLaunchResponder,
1518    },
1519    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1520    /// be used to launch another guest.
1521    ForceShutdown { responder: DebianGuestManagerForceShutdownResponder },
1522    /// Connect to a currently running guest.
1523    ///
1524    /// Possible errors:
1525    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1526    ///         has launched before attempting to reconnect.
1527    Connect {
1528        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1529        responder: DebianGuestManagerConnectResponder,
1530    },
1531    /// Query guest info
1532    GetInfo { responder: DebianGuestManagerGetInfoResponder },
1533}
1534
1535impl DebianGuestManagerRequest {
1536    #[allow(irrefutable_let_patterns)]
1537    pub fn into_launch(
1538        self,
1539    ) -> Option<(
1540        GuestConfig,
1541        fidl::endpoints::ServerEnd<GuestMarker>,
1542        DebianGuestManagerLaunchResponder,
1543    )> {
1544        if let DebianGuestManagerRequest::Launch { guest_config, controller, responder } = self {
1545            Some((guest_config, controller, responder))
1546        } else {
1547            None
1548        }
1549    }
1550
1551    #[allow(irrefutable_let_patterns)]
1552    pub fn into_force_shutdown(self) -> Option<(DebianGuestManagerForceShutdownResponder)> {
1553        if let DebianGuestManagerRequest::ForceShutdown { responder } = self {
1554            Some((responder))
1555        } else {
1556            None
1557        }
1558    }
1559
1560    #[allow(irrefutable_let_patterns)]
1561    pub fn into_connect(
1562        self,
1563    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, DebianGuestManagerConnectResponder)> {
1564        if let DebianGuestManagerRequest::Connect { controller, responder } = self {
1565            Some((controller, responder))
1566        } else {
1567            None
1568        }
1569    }
1570
1571    #[allow(irrefutable_let_patterns)]
1572    pub fn into_get_info(self) -> Option<(DebianGuestManagerGetInfoResponder)> {
1573        if let DebianGuestManagerRequest::GetInfo { responder } = self {
1574            Some((responder))
1575        } else {
1576            None
1577        }
1578    }
1579
1580    /// Name of the method defined in FIDL
1581    pub fn method_name(&self) -> &'static str {
1582        match *self {
1583            DebianGuestManagerRequest::Launch { .. } => "launch",
1584            DebianGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
1585            DebianGuestManagerRequest::Connect { .. } => "connect",
1586            DebianGuestManagerRequest::GetInfo { .. } => "get_info",
1587        }
1588    }
1589}
1590
1591#[derive(Debug, Clone)]
1592pub struct DebianGuestManagerControlHandle {
1593    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1594}
1595
1596impl fidl::endpoints::ControlHandle for DebianGuestManagerControlHandle {
1597    fn shutdown(&self) {
1598        self.inner.shutdown()
1599    }
1600
1601    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1602        self.inner.shutdown_with_epitaph(status)
1603    }
1604
1605    fn is_closed(&self) -> bool {
1606        self.inner.channel().is_closed()
1607    }
1608    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1609        self.inner.channel().on_closed()
1610    }
1611
1612    #[cfg(target_os = "fuchsia")]
1613    fn signal_peer(
1614        &self,
1615        clear_mask: zx::Signals,
1616        set_mask: zx::Signals,
1617    ) -> Result<(), zx_status::Status> {
1618        use fidl::Peered;
1619        self.inner.channel().signal_peer(clear_mask, set_mask)
1620    }
1621}
1622
1623impl DebianGuestManagerControlHandle {}
1624
1625#[must_use = "FIDL methods require a response to be sent"]
1626#[derive(Debug)]
1627pub struct DebianGuestManagerLaunchResponder {
1628    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1629    tx_id: u32,
1630}
1631
1632/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1633/// if the responder is dropped without sending a response, so that the client
1634/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1635impl std::ops::Drop for DebianGuestManagerLaunchResponder {
1636    fn drop(&mut self) {
1637        self.control_handle.shutdown();
1638        // Safety: drops once, never accessed again
1639        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1640    }
1641}
1642
1643impl fidl::endpoints::Responder for DebianGuestManagerLaunchResponder {
1644    type ControlHandle = DebianGuestManagerControlHandle;
1645
1646    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1647        &self.control_handle
1648    }
1649
1650    fn drop_without_shutdown(mut self) {
1651        // Safety: drops once, never accessed again due to mem::forget
1652        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1653        // Prevent Drop from running (which would shut down the channel)
1654        std::mem::forget(self);
1655    }
1656}
1657
1658impl DebianGuestManagerLaunchResponder {
1659    /// Sends a response to the FIDL transaction.
1660    ///
1661    /// Sets the channel to shutdown if an error occurs.
1662    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1663        let _result = self.send_raw(result);
1664        if _result.is_err() {
1665            self.control_handle.shutdown();
1666        }
1667        self.drop_without_shutdown();
1668        _result
1669    }
1670
1671    /// Similar to "send" but does not shutdown the channel if an error occurs.
1672    pub fn send_no_shutdown_on_err(
1673        self,
1674        mut result: Result<(), GuestManagerError>,
1675    ) -> Result<(), fidl::Error> {
1676        let _result = self.send_raw(result);
1677        self.drop_without_shutdown();
1678        _result
1679    }
1680
1681    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1682        self.control_handle.inner.send::<fidl::encoding::ResultType<
1683            fidl::encoding::EmptyStruct,
1684            GuestManagerError,
1685        >>(
1686            result,
1687            self.tx_id,
1688            0x394a2e29f750323e,
1689            fidl::encoding::DynamicFlags::empty(),
1690        )
1691    }
1692}
1693
1694#[must_use = "FIDL methods require a response to be sent"]
1695#[derive(Debug)]
1696pub struct DebianGuestManagerForceShutdownResponder {
1697    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1698    tx_id: u32,
1699}
1700
1701/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1702/// if the responder is dropped without sending a response, so that the client
1703/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1704impl std::ops::Drop for DebianGuestManagerForceShutdownResponder {
1705    fn drop(&mut self) {
1706        self.control_handle.shutdown();
1707        // Safety: drops once, never accessed again
1708        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1709    }
1710}
1711
1712impl fidl::endpoints::Responder for DebianGuestManagerForceShutdownResponder {
1713    type ControlHandle = DebianGuestManagerControlHandle;
1714
1715    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1716        &self.control_handle
1717    }
1718
1719    fn drop_without_shutdown(mut self) {
1720        // Safety: drops once, never accessed again due to mem::forget
1721        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1722        // Prevent Drop from running (which would shut down the channel)
1723        std::mem::forget(self);
1724    }
1725}
1726
1727impl DebianGuestManagerForceShutdownResponder {
1728    /// Sends a response to the FIDL transaction.
1729    ///
1730    /// Sets the channel to shutdown if an error occurs.
1731    pub fn send(self) -> Result<(), fidl::Error> {
1732        let _result = self.send_raw();
1733        if _result.is_err() {
1734            self.control_handle.shutdown();
1735        }
1736        self.drop_without_shutdown();
1737        _result
1738    }
1739
1740    /// Similar to "send" but does not shutdown the channel if an error occurs.
1741    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1742        let _result = self.send_raw();
1743        self.drop_without_shutdown();
1744        _result
1745    }
1746
1747    fn send_raw(&self) -> Result<(), fidl::Error> {
1748        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1749            (),
1750            self.tx_id,
1751            0x3ad9a012982f872d,
1752            fidl::encoding::DynamicFlags::empty(),
1753        )
1754    }
1755}
1756
1757#[must_use = "FIDL methods require a response to be sent"]
1758#[derive(Debug)]
1759pub struct DebianGuestManagerConnectResponder {
1760    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1761    tx_id: u32,
1762}
1763
1764/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1765/// if the responder is dropped without sending a response, so that the client
1766/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1767impl std::ops::Drop for DebianGuestManagerConnectResponder {
1768    fn drop(&mut self) {
1769        self.control_handle.shutdown();
1770        // Safety: drops once, never accessed again
1771        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1772    }
1773}
1774
1775impl fidl::endpoints::Responder for DebianGuestManagerConnectResponder {
1776    type ControlHandle = DebianGuestManagerControlHandle;
1777
1778    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1779        &self.control_handle
1780    }
1781
1782    fn drop_without_shutdown(mut self) {
1783        // Safety: drops once, never accessed again due to mem::forget
1784        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1785        // Prevent Drop from running (which would shut down the channel)
1786        std::mem::forget(self);
1787    }
1788}
1789
1790impl DebianGuestManagerConnectResponder {
1791    /// Sends a response to the FIDL transaction.
1792    ///
1793    /// Sets the channel to shutdown if an error occurs.
1794    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1795        let _result = self.send_raw(result);
1796        if _result.is_err() {
1797            self.control_handle.shutdown();
1798        }
1799        self.drop_without_shutdown();
1800        _result
1801    }
1802
1803    /// Similar to "send" but does not shutdown the channel if an error occurs.
1804    pub fn send_no_shutdown_on_err(
1805        self,
1806        mut result: Result<(), GuestManagerError>,
1807    ) -> Result<(), fidl::Error> {
1808        let _result = self.send_raw(result);
1809        self.drop_without_shutdown();
1810        _result
1811    }
1812
1813    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1814        self.control_handle.inner.send::<fidl::encoding::ResultType<
1815            fidl::encoding::EmptyStruct,
1816            GuestManagerError,
1817        >>(
1818            result,
1819            self.tx_id,
1820            0x4e489076e3bb15b4,
1821            fidl::encoding::DynamicFlags::empty(),
1822        )
1823    }
1824}
1825
1826#[must_use = "FIDL methods require a response to be sent"]
1827#[derive(Debug)]
1828pub struct DebianGuestManagerGetInfoResponder {
1829    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1830    tx_id: u32,
1831}
1832
1833/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1834/// if the responder is dropped without sending a response, so that the client
1835/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1836impl std::ops::Drop for DebianGuestManagerGetInfoResponder {
1837    fn drop(&mut self) {
1838        self.control_handle.shutdown();
1839        // Safety: drops once, never accessed again
1840        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1841    }
1842}
1843
1844impl fidl::endpoints::Responder for DebianGuestManagerGetInfoResponder {
1845    type ControlHandle = DebianGuestManagerControlHandle;
1846
1847    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1848        &self.control_handle
1849    }
1850
1851    fn drop_without_shutdown(mut self) {
1852        // Safety: drops once, never accessed again due to mem::forget
1853        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1854        // Prevent Drop from running (which would shut down the channel)
1855        std::mem::forget(self);
1856    }
1857}
1858
1859impl DebianGuestManagerGetInfoResponder {
1860    /// Sends a response to the FIDL transaction.
1861    ///
1862    /// Sets the channel to shutdown if an error occurs.
1863    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1864        let _result = self.send_raw(guest_info);
1865        if _result.is_err() {
1866            self.control_handle.shutdown();
1867        }
1868        self.drop_without_shutdown();
1869        _result
1870    }
1871
1872    /// Similar to "send" but does not shutdown the channel if an error occurs.
1873    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1874        let _result = self.send_raw(guest_info);
1875        self.drop_without_shutdown();
1876        _result
1877    }
1878
1879    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1880        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
1881            (guest_info,),
1882            self.tx_id,
1883            0x76892614aea695dc,
1884            fidl::encoding::DynamicFlags::empty(),
1885        )
1886    }
1887}
1888
1889#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1890pub struct GuestMarker;
1891
1892impl fidl::endpoints::ProtocolMarker for GuestMarker {
1893    type Proxy = GuestProxy;
1894    type RequestStream = GuestRequestStream;
1895    #[cfg(target_os = "fuchsia")]
1896    type SynchronousProxy = GuestSynchronousProxy;
1897
1898    const DEBUG_NAME: &'static str = "fuchsia.virtualization.Guest";
1899}
1900impl fidl::endpoints::DiscoverableProtocolMarker for GuestMarker {}
1901pub type GuestGetConsoleResult = Result<fidl::Socket, GuestError>;
1902pub type GuestGetHostVsockEndpointResult = Result<(), GuestError>;
1903pub type GuestGetBalloonControllerResult = Result<(), GuestError>;
1904pub type GuestGetMemControllerResult = Result<(), GuestError>;
1905
1906pub trait GuestProxyInterface: Send + Sync {
1907    type GetConsoleResponseFut: std::future::Future<Output = Result<GuestGetConsoleResult, fidl::Error>>
1908        + Send;
1909    fn r#get_console(&self) -> Self::GetConsoleResponseFut;
1910    type GetSerialResponseFut: std::future::Future<Output = Result<fidl::Socket, fidl::Error>>
1911        + Send;
1912    fn r#get_serial(&self) -> Self::GetSerialResponseFut;
1913    type GetHostVsockEndpointResponseFut: std::future::Future<Output = Result<GuestGetHostVsockEndpointResult, fidl::Error>>
1914        + Send;
1915    fn r#get_host_vsock_endpoint(
1916        &self,
1917        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
1918    ) -> Self::GetHostVsockEndpointResponseFut;
1919    type GetBalloonControllerResponseFut: std::future::Future<Output = Result<GuestGetBalloonControllerResult, fidl::Error>>
1920        + Send;
1921    fn r#get_balloon_controller(
1922        &self,
1923        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
1924    ) -> Self::GetBalloonControllerResponseFut;
1925    type GetMemControllerResponseFut: std::future::Future<Output = Result<GuestGetMemControllerResult, fidl::Error>>
1926        + Send;
1927    fn r#get_mem_controller(
1928        &self,
1929        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
1930    ) -> Self::GetMemControllerResponseFut;
1931}
1932#[derive(Debug)]
1933#[cfg(target_os = "fuchsia")]
1934pub struct GuestSynchronousProxy {
1935    client: fidl::client::sync::Client,
1936}
1937
1938#[cfg(target_os = "fuchsia")]
1939impl fidl::endpoints::SynchronousProxy for GuestSynchronousProxy {
1940    type Proxy = GuestProxy;
1941    type Protocol = GuestMarker;
1942
1943    fn from_channel(inner: fidl::Channel) -> Self {
1944        Self::new(inner)
1945    }
1946
1947    fn into_channel(self) -> fidl::Channel {
1948        self.client.into_channel()
1949    }
1950
1951    fn as_channel(&self) -> &fidl::Channel {
1952        self.client.as_channel()
1953    }
1954}
1955
1956#[cfg(target_os = "fuchsia")]
1957impl GuestSynchronousProxy {
1958    pub fn new(channel: fidl::Channel) -> Self {
1959        Self { client: fidl::client::sync::Client::new(channel) }
1960    }
1961
1962    pub fn into_channel(self) -> fidl::Channel {
1963        self.client.into_channel()
1964    }
1965
1966    /// Waits until an event arrives and returns it. It is safe for other
1967    /// threads to make concurrent requests while waiting for an event.
1968    pub fn wait_for_event(
1969        &self,
1970        deadline: zx::MonotonicInstant,
1971    ) -> Result<GuestEvent, fidl::Error> {
1972        GuestEvent::decode(self.client.wait_for_event::<GuestMarker>(deadline)?)
1973    }
1974
1975    /// Get a guest console.
1976    ///
1977    /// The details regarding what output is produced and what input is accepted
1978    /// are determined by each guest, but will typically be a read/write socket
1979    /// with a shell.
1980    ///
1981    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
1982    pub fn r#get_console(
1983        &self,
1984        ___deadline: zx::MonotonicInstant,
1985    ) -> Result<GuestGetConsoleResult, fidl::Error> {
1986        let _response = self.client.send_query::<
1987            fidl::encoding::EmptyPayload,
1988            fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
1989            GuestMarker,
1990        >(
1991            (),
1992            0x48cbcecb7793806e,
1993            fidl::encoding::DynamicFlags::empty(),
1994            ___deadline,
1995        )?;
1996        Ok(_response.map(|x| x.socket))
1997    }
1998
1999    /// Get the socket for low-level guest debug logs.
2000    ///
2001    /// The details regarding what output is produced and what input is accepted
2002    /// are determined by each guest, but will typically be a read-only socket
2003    /// with the guest kernel's serial logs.
2004    pub fn r#get_serial(
2005        &self,
2006        ___deadline: zx::MonotonicInstant,
2007    ) -> Result<fidl::Socket, fidl::Error> {
2008        let _response = self
2009            .client
2010            .send_query::<fidl::encoding::EmptyPayload, GuestGetSerialResponse, GuestMarker>(
2011                (),
2012                0xcdd541a160d7044,
2013                fidl::encoding::DynamicFlags::empty(),
2014                ___deadline,
2015            )?;
2016        Ok(_response.socket)
2017    }
2018
2019    /// Get the vsock endpoint for the guest.
2020    ///
2021    /// This endpoint can be used to register listeners for guest initiated connections, and
2022    /// to initiate connections from a client. If listeners need to be registered before the guest
2023    /// starts so that they are immediately available, set them via the guest config instead of
2024    /// using this endpoint.
2025    ///
2026    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2027    pub fn r#get_host_vsock_endpoint(
2028        &self,
2029        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2030        ___deadline: zx::MonotonicInstant,
2031    ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2032        let _response = self.client.send_query::<
2033            GuestGetHostVsockEndpointRequest,
2034            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2035            GuestMarker,
2036        >(
2037            (endpoint,),
2038            0x766e96aeb9c28ed1,
2039            fidl::encoding::DynamicFlags::empty(),
2040            ___deadline,
2041        )?;
2042        Ok(_response.map(|x| x))
2043    }
2044
2045    /// Get the balloon controller endpoint for the guest.
2046    ///
2047    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2048    pub fn r#get_balloon_controller(
2049        &self,
2050        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2051        ___deadline: zx::MonotonicInstant,
2052    ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2053        let _response = self.client.send_query::<
2054            GuestGetBalloonControllerRequest,
2055            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2056            GuestMarker,
2057        >(
2058            (controller,),
2059            0x7b210bff219ac84e,
2060            fidl::encoding::DynamicFlags::empty(),
2061            ___deadline,
2062        )?;
2063        Ok(_response.map(|x| x))
2064    }
2065
2066    /// Get the mem controller endpoint for the guest.
2067    ///
2068    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2069    pub fn r#get_mem_controller(
2070        &self,
2071        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2072        ___deadline: zx::MonotonicInstant,
2073    ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2074        let _response = self.client.send_query::<
2075            GuestGetMemControllerRequest,
2076            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2077            GuestMarker,
2078        >(
2079            (controller,),
2080            0x170b19f4b867a01c,
2081            fidl::encoding::DynamicFlags::empty(),
2082            ___deadline,
2083        )?;
2084        Ok(_response.map(|x| x))
2085    }
2086}
2087
2088#[cfg(target_os = "fuchsia")]
2089impl From<GuestSynchronousProxy> for zx::NullableHandle {
2090    fn from(value: GuestSynchronousProxy) -> Self {
2091        value.into_channel().into()
2092    }
2093}
2094
2095#[cfg(target_os = "fuchsia")]
2096impl From<fidl::Channel> for GuestSynchronousProxy {
2097    fn from(value: fidl::Channel) -> Self {
2098        Self::new(value)
2099    }
2100}
2101
2102#[cfg(target_os = "fuchsia")]
2103impl fidl::endpoints::FromClient for GuestSynchronousProxy {
2104    type Protocol = GuestMarker;
2105
2106    fn from_client(value: fidl::endpoints::ClientEnd<GuestMarker>) -> Self {
2107        Self::new(value.into_channel())
2108    }
2109}
2110
2111#[derive(Debug, Clone)]
2112pub struct GuestProxy {
2113    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2114}
2115
2116impl fidl::endpoints::Proxy for GuestProxy {
2117    type Protocol = GuestMarker;
2118
2119    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2120        Self::new(inner)
2121    }
2122
2123    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2124        self.client.into_channel().map_err(|client| Self { client })
2125    }
2126
2127    fn as_channel(&self) -> &::fidl::AsyncChannel {
2128        self.client.as_channel()
2129    }
2130}
2131
2132impl GuestProxy {
2133    /// Create a new Proxy for fuchsia.virtualization/Guest.
2134    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2135        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2136        Self { client: fidl::client::Client::new(channel, protocol_name) }
2137    }
2138
2139    /// Get a Stream of events from the remote end of the protocol.
2140    ///
2141    /// # Panics
2142    ///
2143    /// Panics if the event stream was already taken.
2144    pub fn take_event_stream(&self) -> GuestEventStream {
2145        GuestEventStream { event_receiver: self.client.take_event_receiver() }
2146    }
2147
2148    /// Get a guest console.
2149    ///
2150    /// The details regarding what output is produced and what input is accepted
2151    /// are determined by each guest, but will typically be a read/write socket
2152    /// with a shell.
2153    ///
2154    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2155    pub fn r#get_console(
2156        &self,
2157    ) -> fidl::client::QueryResponseFut<
2158        GuestGetConsoleResult,
2159        fidl::encoding::DefaultFuchsiaResourceDialect,
2160    > {
2161        GuestProxyInterface::r#get_console(self)
2162    }
2163
2164    /// Get the socket for low-level guest debug logs.
2165    ///
2166    /// The details regarding what output is produced and what input is accepted
2167    /// are determined by each guest, but will typically be a read-only socket
2168    /// with the guest kernel's serial logs.
2169    pub fn r#get_serial(
2170        &self,
2171    ) -> fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>
2172    {
2173        GuestProxyInterface::r#get_serial(self)
2174    }
2175
2176    /// Get the vsock endpoint for the guest.
2177    ///
2178    /// This endpoint can be used to register listeners for guest initiated connections, and
2179    /// to initiate connections from a client. If listeners need to be registered before the guest
2180    /// starts so that they are immediately available, set them via the guest config instead of
2181    /// using this endpoint.
2182    ///
2183    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2184    pub fn r#get_host_vsock_endpoint(
2185        &self,
2186        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2187    ) -> fidl::client::QueryResponseFut<
2188        GuestGetHostVsockEndpointResult,
2189        fidl::encoding::DefaultFuchsiaResourceDialect,
2190    > {
2191        GuestProxyInterface::r#get_host_vsock_endpoint(self, endpoint)
2192    }
2193
2194    /// Get the balloon controller endpoint for the guest.
2195    ///
2196    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2197    pub fn r#get_balloon_controller(
2198        &self,
2199        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2200    ) -> fidl::client::QueryResponseFut<
2201        GuestGetBalloonControllerResult,
2202        fidl::encoding::DefaultFuchsiaResourceDialect,
2203    > {
2204        GuestProxyInterface::r#get_balloon_controller(self, controller)
2205    }
2206
2207    /// Get the mem controller endpoint for the guest.
2208    ///
2209    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2210    pub fn r#get_mem_controller(
2211        &self,
2212        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2213    ) -> fidl::client::QueryResponseFut<
2214        GuestGetMemControllerResult,
2215        fidl::encoding::DefaultFuchsiaResourceDialect,
2216    > {
2217        GuestProxyInterface::r#get_mem_controller(self, controller)
2218    }
2219}
2220
2221impl GuestProxyInterface for GuestProxy {
2222    type GetConsoleResponseFut = fidl::client::QueryResponseFut<
2223        GuestGetConsoleResult,
2224        fidl::encoding::DefaultFuchsiaResourceDialect,
2225    >;
2226    fn r#get_console(&self) -> Self::GetConsoleResponseFut {
2227        fn _decode(
2228            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2229        ) -> Result<GuestGetConsoleResult, fidl::Error> {
2230            let _response = fidl::client::decode_transaction_body::<
2231                fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
2232                fidl::encoding::DefaultFuchsiaResourceDialect,
2233                0x48cbcecb7793806e,
2234            >(_buf?)?;
2235            Ok(_response.map(|x| x.socket))
2236        }
2237        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestGetConsoleResult>(
2238            (),
2239            0x48cbcecb7793806e,
2240            fidl::encoding::DynamicFlags::empty(),
2241            _decode,
2242        )
2243    }
2244
2245    type GetSerialResponseFut =
2246        fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2247    fn r#get_serial(&self) -> Self::GetSerialResponseFut {
2248        fn _decode(
2249            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2250        ) -> Result<fidl::Socket, fidl::Error> {
2251            let _response = fidl::client::decode_transaction_body::<
2252                GuestGetSerialResponse,
2253                fidl::encoding::DefaultFuchsiaResourceDialect,
2254                0xcdd541a160d7044,
2255            >(_buf?)?;
2256            Ok(_response.socket)
2257        }
2258        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Socket>(
2259            (),
2260            0xcdd541a160d7044,
2261            fidl::encoding::DynamicFlags::empty(),
2262            _decode,
2263        )
2264    }
2265
2266    type GetHostVsockEndpointResponseFut = fidl::client::QueryResponseFut<
2267        GuestGetHostVsockEndpointResult,
2268        fidl::encoding::DefaultFuchsiaResourceDialect,
2269    >;
2270    fn r#get_host_vsock_endpoint(
2271        &self,
2272        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2273    ) -> Self::GetHostVsockEndpointResponseFut {
2274        fn _decode(
2275            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2276        ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2277            let _response = fidl::client::decode_transaction_body::<
2278                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2279                fidl::encoding::DefaultFuchsiaResourceDialect,
2280                0x766e96aeb9c28ed1,
2281            >(_buf?)?;
2282            Ok(_response.map(|x| x))
2283        }
2284        self.client.send_query_and_decode::<
2285            GuestGetHostVsockEndpointRequest,
2286            GuestGetHostVsockEndpointResult,
2287        >(
2288            (endpoint,),
2289            0x766e96aeb9c28ed1,
2290            fidl::encoding::DynamicFlags::empty(),
2291            _decode,
2292        )
2293    }
2294
2295    type GetBalloonControllerResponseFut = fidl::client::QueryResponseFut<
2296        GuestGetBalloonControllerResult,
2297        fidl::encoding::DefaultFuchsiaResourceDialect,
2298    >;
2299    fn r#get_balloon_controller(
2300        &self,
2301        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2302    ) -> Self::GetBalloonControllerResponseFut {
2303        fn _decode(
2304            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2305        ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2306            let _response = fidl::client::decode_transaction_body::<
2307                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2308                fidl::encoding::DefaultFuchsiaResourceDialect,
2309                0x7b210bff219ac84e,
2310            >(_buf?)?;
2311            Ok(_response.map(|x| x))
2312        }
2313        self.client.send_query_and_decode::<
2314            GuestGetBalloonControllerRequest,
2315            GuestGetBalloonControllerResult,
2316        >(
2317            (controller,),
2318            0x7b210bff219ac84e,
2319            fidl::encoding::DynamicFlags::empty(),
2320            _decode,
2321        )
2322    }
2323
2324    type GetMemControllerResponseFut = fidl::client::QueryResponseFut<
2325        GuestGetMemControllerResult,
2326        fidl::encoding::DefaultFuchsiaResourceDialect,
2327    >;
2328    fn r#get_mem_controller(
2329        &self,
2330        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2331    ) -> Self::GetMemControllerResponseFut {
2332        fn _decode(
2333            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2334        ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2335            let _response = fidl::client::decode_transaction_body::<
2336                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2337                fidl::encoding::DefaultFuchsiaResourceDialect,
2338                0x170b19f4b867a01c,
2339            >(_buf?)?;
2340            Ok(_response.map(|x| x))
2341        }
2342        self.client
2343            .send_query_and_decode::<GuestGetMemControllerRequest, GuestGetMemControllerResult>(
2344                (controller,),
2345                0x170b19f4b867a01c,
2346                fidl::encoding::DynamicFlags::empty(),
2347                _decode,
2348            )
2349    }
2350}
2351
2352pub struct GuestEventStream {
2353    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2354}
2355
2356impl std::marker::Unpin for GuestEventStream {}
2357
2358impl futures::stream::FusedStream for GuestEventStream {
2359    fn is_terminated(&self) -> bool {
2360        self.event_receiver.is_terminated()
2361    }
2362}
2363
2364impl futures::Stream for GuestEventStream {
2365    type Item = Result<GuestEvent, fidl::Error>;
2366
2367    fn poll_next(
2368        mut self: std::pin::Pin<&mut Self>,
2369        cx: &mut std::task::Context<'_>,
2370    ) -> std::task::Poll<Option<Self::Item>> {
2371        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2372            &mut self.event_receiver,
2373            cx
2374        )?) {
2375            Some(buf) => std::task::Poll::Ready(Some(GuestEvent::decode(buf))),
2376            None => std::task::Poll::Ready(None),
2377        }
2378    }
2379}
2380
2381#[derive(Debug)]
2382pub enum GuestEvent {}
2383
2384impl GuestEvent {
2385    /// Decodes a message buffer as a [`GuestEvent`].
2386    fn decode(
2387        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2388    ) -> Result<GuestEvent, fidl::Error> {
2389        let (bytes, _handles) = buf.split_mut();
2390        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2391        debug_assert_eq!(tx_header.tx_id, 0);
2392        match tx_header.ordinal {
2393            _ => Err(fidl::Error::UnknownOrdinal {
2394                ordinal: tx_header.ordinal,
2395                protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2396            }),
2397        }
2398    }
2399}
2400
2401/// A Stream of incoming requests for fuchsia.virtualization/Guest.
2402pub struct GuestRequestStream {
2403    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2404    is_terminated: bool,
2405}
2406
2407impl std::marker::Unpin for GuestRequestStream {}
2408
2409impl futures::stream::FusedStream for GuestRequestStream {
2410    fn is_terminated(&self) -> bool {
2411        self.is_terminated
2412    }
2413}
2414
2415impl fidl::endpoints::RequestStream for GuestRequestStream {
2416    type Protocol = GuestMarker;
2417    type ControlHandle = GuestControlHandle;
2418
2419    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2420        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2421    }
2422
2423    fn control_handle(&self) -> Self::ControlHandle {
2424        GuestControlHandle { inner: self.inner.clone() }
2425    }
2426
2427    fn into_inner(
2428        self,
2429    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2430    {
2431        (self.inner, self.is_terminated)
2432    }
2433
2434    fn from_inner(
2435        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2436        is_terminated: bool,
2437    ) -> Self {
2438        Self { inner, is_terminated }
2439    }
2440}
2441
2442impl futures::Stream for GuestRequestStream {
2443    type Item = Result<GuestRequest, fidl::Error>;
2444
2445    fn poll_next(
2446        mut self: std::pin::Pin<&mut Self>,
2447        cx: &mut std::task::Context<'_>,
2448    ) -> std::task::Poll<Option<Self::Item>> {
2449        let this = &mut *self;
2450        if this.inner.check_shutdown(cx) {
2451            this.is_terminated = true;
2452            return std::task::Poll::Ready(None);
2453        }
2454        if this.is_terminated {
2455            panic!("polled GuestRequestStream after completion");
2456        }
2457        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2458            |bytes, handles| {
2459                match this.inner.channel().read_etc(cx, bytes, handles) {
2460                    std::task::Poll::Ready(Ok(())) => {}
2461                    std::task::Poll::Pending => return std::task::Poll::Pending,
2462                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2463                        this.is_terminated = true;
2464                        return std::task::Poll::Ready(None);
2465                    }
2466                    std::task::Poll::Ready(Err(e)) => {
2467                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2468                            e.into(),
2469                        ))));
2470                    }
2471                }
2472
2473                // A message has been received from the channel
2474                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2475
2476                std::task::Poll::Ready(Some(match header.ordinal {
2477                    0x48cbcecb7793806e => {
2478                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2479                        let mut req = fidl::new_empty!(
2480                            fidl::encoding::EmptyPayload,
2481                            fidl::encoding::DefaultFuchsiaResourceDialect
2482                        );
2483                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2484                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2485                        Ok(GuestRequest::GetConsole {
2486                            responder: GuestGetConsoleResponder {
2487                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2488                                tx_id: header.tx_id,
2489                            },
2490                        })
2491                    }
2492                    0xcdd541a160d7044 => {
2493                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2494                        let mut req = fidl::new_empty!(
2495                            fidl::encoding::EmptyPayload,
2496                            fidl::encoding::DefaultFuchsiaResourceDialect
2497                        );
2498                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2499                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2500                        Ok(GuestRequest::GetSerial {
2501                            responder: GuestGetSerialResponder {
2502                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2503                                tx_id: header.tx_id,
2504                            },
2505                        })
2506                    }
2507                    0x766e96aeb9c28ed1 => {
2508                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2509                        let mut req = fidl::new_empty!(
2510                            GuestGetHostVsockEndpointRequest,
2511                            fidl::encoding::DefaultFuchsiaResourceDialect
2512                        );
2513                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetHostVsockEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
2514                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2515                        Ok(GuestRequest::GetHostVsockEndpoint {
2516                            endpoint: req.endpoint,
2517
2518                            responder: GuestGetHostVsockEndpointResponder {
2519                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2520                                tx_id: header.tx_id,
2521                            },
2522                        })
2523                    }
2524                    0x7b210bff219ac84e => {
2525                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2526                        let mut req = fidl::new_empty!(
2527                            GuestGetBalloonControllerRequest,
2528                            fidl::encoding::DefaultFuchsiaResourceDialect
2529                        );
2530                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetBalloonControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2531                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2532                        Ok(GuestRequest::GetBalloonController {
2533                            controller: req.controller,
2534
2535                            responder: GuestGetBalloonControllerResponder {
2536                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2537                                tx_id: header.tx_id,
2538                            },
2539                        })
2540                    }
2541                    0x170b19f4b867a01c => {
2542                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2543                        let mut req = fidl::new_empty!(
2544                            GuestGetMemControllerRequest,
2545                            fidl::encoding::DefaultFuchsiaResourceDialect
2546                        );
2547                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetMemControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2548                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2549                        Ok(GuestRequest::GetMemController {
2550                            controller: req.controller,
2551
2552                            responder: GuestGetMemControllerResponder {
2553                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2554                                tx_id: header.tx_id,
2555                            },
2556                        })
2557                    }
2558                    _ => Err(fidl::Error::UnknownOrdinal {
2559                        ordinal: header.ordinal,
2560                        protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2561                    }),
2562                }))
2563            },
2564        )
2565    }
2566}
2567
2568/// The guest client API providing high level access to guest features. When the guest terminates,
2569/// this channel will contain a ZX_OK epitaph on a clean shutdown, a ZX_ERR_INTERNAL epitaph on
2570/// an unexpected shutdown, and no epitaph if the component crashed.
2571#[derive(Debug)]
2572pub enum GuestRequest {
2573    /// Get a guest console.
2574    ///
2575    /// The details regarding what output is produced and what input is accepted
2576    /// are determined by each guest, but will typically be a read/write socket
2577    /// with a shell.
2578    ///
2579    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2580    GetConsole { responder: GuestGetConsoleResponder },
2581    /// Get the socket for low-level guest debug logs.
2582    ///
2583    /// The details regarding what output is produced and what input is accepted
2584    /// are determined by each guest, but will typically be a read-only socket
2585    /// with the guest kernel's serial logs.
2586    GetSerial { responder: GuestGetSerialResponder },
2587    /// Get the vsock endpoint for the guest.
2588    ///
2589    /// This endpoint can be used to register listeners for guest initiated connections, and
2590    /// to initiate connections from a client. If listeners need to be registered before the guest
2591    /// starts so that they are immediately available, set them via the guest config instead of
2592    /// using this endpoint.
2593    ///
2594    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2595    GetHostVsockEndpoint {
2596        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2597        responder: GuestGetHostVsockEndpointResponder,
2598    },
2599    /// Get the balloon controller endpoint for the guest.
2600    ///
2601    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2602    GetBalloonController {
2603        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2604        responder: GuestGetBalloonControllerResponder,
2605    },
2606    /// Get the mem controller endpoint for the guest.
2607    ///
2608    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2609    GetMemController {
2610        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2611        responder: GuestGetMemControllerResponder,
2612    },
2613}
2614
2615impl GuestRequest {
2616    #[allow(irrefutable_let_patterns)]
2617    pub fn into_get_console(self) -> Option<(GuestGetConsoleResponder)> {
2618        if let GuestRequest::GetConsole { responder } = self { Some((responder)) } else { None }
2619    }
2620
2621    #[allow(irrefutable_let_patterns)]
2622    pub fn into_get_serial(self) -> Option<(GuestGetSerialResponder)> {
2623        if let GuestRequest::GetSerial { responder } = self { Some((responder)) } else { None }
2624    }
2625
2626    #[allow(irrefutable_let_patterns)]
2627    pub fn into_get_host_vsock_endpoint(
2628        self,
2629    ) -> Option<(
2630        fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2631        GuestGetHostVsockEndpointResponder,
2632    )> {
2633        if let GuestRequest::GetHostVsockEndpoint { endpoint, responder } = self {
2634            Some((endpoint, responder))
2635        } else {
2636            None
2637        }
2638    }
2639
2640    #[allow(irrefutable_let_patterns)]
2641    pub fn into_get_balloon_controller(
2642        self,
2643    ) -> Option<(
2644        fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2645        GuestGetBalloonControllerResponder,
2646    )> {
2647        if let GuestRequest::GetBalloonController { controller, responder } = self {
2648            Some((controller, responder))
2649        } else {
2650            None
2651        }
2652    }
2653
2654    #[allow(irrefutable_let_patterns)]
2655    pub fn into_get_mem_controller(
2656        self,
2657    ) -> Option<(fidl::endpoints::ServerEnd<MemControllerMarker>, GuestGetMemControllerResponder)>
2658    {
2659        if let GuestRequest::GetMemController { controller, responder } = self {
2660            Some((controller, responder))
2661        } else {
2662            None
2663        }
2664    }
2665
2666    /// Name of the method defined in FIDL
2667    pub fn method_name(&self) -> &'static str {
2668        match *self {
2669            GuestRequest::GetConsole { .. } => "get_console",
2670            GuestRequest::GetSerial { .. } => "get_serial",
2671            GuestRequest::GetHostVsockEndpoint { .. } => "get_host_vsock_endpoint",
2672            GuestRequest::GetBalloonController { .. } => "get_balloon_controller",
2673            GuestRequest::GetMemController { .. } => "get_mem_controller",
2674        }
2675    }
2676}
2677
2678#[derive(Debug, Clone)]
2679pub struct GuestControlHandle {
2680    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2681}
2682
2683impl fidl::endpoints::ControlHandle for GuestControlHandle {
2684    fn shutdown(&self) {
2685        self.inner.shutdown()
2686    }
2687
2688    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2689        self.inner.shutdown_with_epitaph(status)
2690    }
2691
2692    fn is_closed(&self) -> bool {
2693        self.inner.channel().is_closed()
2694    }
2695    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2696        self.inner.channel().on_closed()
2697    }
2698
2699    #[cfg(target_os = "fuchsia")]
2700    fn signal_peer(
2701        &self,
2702        clear_mask: zx::Signals,
2703        set_mask: zx::Signals,
2704    ) -> Result<(), zx_status::Status> {
2705        use fidl::Peered;
2706        self.inner.channel().signal_peer(clear_mask, set_mask)
2707    }
2708}
2709
2710impl GuestControlHandle {}
2711
2712#[must_use = "FIDL methods require a response to be sent"]
2713#[derive(Debug)]
2714pub struct GuestGetConsoleResponder {
2715    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2716    tx_id: u32,
2717}
2718
2719/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2720/// if the responder is dropped without sending a response, so that the client
2721/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2722impl std::ops::Drop for GuestGetConsoleResponder {
2723    fn drop(&mut self) {
2724        self.control_handle.shutdown();
2725        // Safety: drops once, never accessed again
2726        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2727    }
2728}
2729
2730impl fidl::endpoints::Responder for GuestGetConsoleResponder {
2731    type ControlHandle = GuestControlHandle;
2732
2733    fn control_handle(&self) -> &GuestControlHandle {
2734        &self.control_handle
2735    }
2736
2737    fn drop_without_shutdown(mut self) {
2738        // Safety: drops once, never accessed again due to mem::forget
2739        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2740        // Prevent Drop from running (which would shut down the channel)
2741        std::mem::forget(self);
2742    }
2743}
2744
2745impl GuestGetConsoleResponder {
2746    /// Sends a response to the FIDL transaction.
2747    ///
2748    /// Sets the channel to shutdown if an error occurs.
2749    pub fn send(self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2750        let _result = self.send_raw(result);
2751        if _result.is_err() {
2752            self.control_handle.shutdown();
2753        }
2754        self.drop_without_shutdown();
2755        _result
2756    }
2757
2758    /// Similar to "send" but does not shutdown the channel if an error occurs.
2759    pub fn send_no_shutdown_on_err(
2760        self,
2761        mut result: Result<fidl::Socket, GuestError>,
2762    ) -> Result<(), fidl::Error> {
2763        let _result = self.send_raw(result);
2764        self.drop_without_shutdown();
2765        _result
2766    }
2767
2768    fn send_raw(&self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2769        self.control_handle
2770            .inner
2771            .send::<fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>>(
2772                result.map(|socket| (socket,)),
2773                self.tx_id,
2774                0x48cbcecb7793806e,
2775                fidl::encoding::DynamicFlags::empty(),
2776            )
2777    }
2778}
2779
2780#[must_use = "FIDL methods require a response to be sent"]
2781#[derive(Debug)]
2782pub struct GuestGetSerialResponder {
2783    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2784    tx_id: u32,
2785}
2786
2787/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2788/// if the responder is dropped without sending a response, so that the client
2789/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2790impl std::ops::Drop for GuestGetSerialResponder {
2791    fn drop(&mut self) {
2792        self.control_handle.shutdown();
2793        // Safety: drops once, never accessed again
2794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2795    }
2796}
2797
2798impl fidl::endpoints::Responder for GuestGetSerialResponder {
2799    type ControlHandle = GuestControlHandle;
2800
2801    fn control_handle(&self) -> &GuestControlHandle {
2802        &self.control_handle
2803    }
2804
2805    fn drop_without_shutdown(mut self) {
2806        // Safety: drops once, never accessed again due to mem::forget
2807        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2808        // Prevent Drop from running (which would shut down the channel)
2809        std::mem::forget(self);
2810    }
2811}
2812
2813impl GuestGetSerialResponder {
2814    /// Sends a response to the FIDL transaction.
2815    ///
2816    /// Sets the channel to shutdown if an error occurs.
2817    pub fn send(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2818        let _result = self.send_raw(socket);
2819        if _result.is_err() {
2820            self.control_handle.shutdown();
2821        }
2822        self.drop_without_shutdown();
2823        _result
2824    }
2825
2826    /// Similar to "send" but does not shutdown the channel if an error occurs.
2827    pub fn send_no_shutdown_on_err(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2828        let _result = self.send_raw(socket);
2829        self.drop_without_shutdown();
2830        _result
2831    }
2832
2833    fn send_raw(&self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2834        self.control_handle.inner.send::<GuestGetSerialResponse>(
2835            (socket,),
2836            self.tx_id,
2837            0xcdd541a160d7044,
2838            fidl::encoding::DynamicFlags::empty(),
2839        )
2840    }
2841}
2842
2843#[must_use = "FIDL methods require a response to be sent"]
2844#[derive(Debug)]
2845pub struct GuestGetHostVsockEndpointResponder {
2846    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2847    tx_id: u32,
2848}
2849
2850/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2851/// if the responder is dropped without sending a response, so that the client
2852/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2853impl std::ops::Drop for GuestGetHostVsockEndpointResponder {
2854    fn drop(&mut self) {
2855        self.control_handle.shutdown();
2856        // Safety: drops once, never accessed again
2857        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2858    }
2859}
2860
2861impl fidl::endpoints::Responder for GuestGetHostVsockEndpointResponder {
2862    type ControlHandle = GuestControlHandle;
2863
2864    fn control_handle(&self) -> &GuestControlHandle {
2865        &self.control_handle
2866    }
2867
2868    fn drop_without_shutdown(mut self) {
2869        // Safety: drops once, never accessed again due to mem::forget
2870        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2871        // Prevent Drop from running (which would shut down the channel)
2872        std::mem::forget(self);
2873    }
2874}
2875
2876impl GuestGetHostVsockEndpointResponder {
2877    /// Sends a response to the FIDL transaction.
2878    ///
2879    /// Sets the channel to shutdown if an error occurs.
2880    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2881        let _result = self.send_raw(result);
2882        if _result.is_err() {
2883            self.control_handle.shutdown();
2884        }
2885        self.drop_without_shutdown();
2886        _result
2887    }
2888
2889    /// Similar to "send" but does not shutdown the channel if an error occurs.
2890    pub fn send_no_shutdown_on_err(
2891        self,
2892        mut result: Result<(), GuestError>,
2893    ) -> Result<(), fidl::Error> {
2894        let _result = self.send_raw(result);
2895        self.drop_without_shutdown();
2896        _result
2897    }
2898
2899    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2900        self.control_handle
2901            .inner
2902            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2903                result,
2904                self.tx_id,
2905                0x766e96aeb9c28ed1,
2906                fidl::encoding::DynamicFlags::empty(),
2907            )
2908    }
2909}
2910
2911#[must_use = "FIDL methods require a response to be sent"]
2912#[derive(Debug)]
2913pub struct GuestGetBalloonControllerResponder {
2914    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2915    tx_id: u32,
2916}
2917
2918/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2919/// if the responder is dropped without sending a response, so that the client
2920/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2921impl std::ops::Drop for GuestGetBalloonControllerResponder {
2922    fn drop(&mut self) {
2923        self.control_handle.shutdown();
2924        // Safety: drops once, never accessed again
2925        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2926    }
2927}
2928
2929impl fidl::endpoints::Responder for GuestGetBalloonControllerResponder {
2930    type ControlHandle = GuestControlHandle;
2931
2932    fn control_handle(&self) -> &GuestControlHandle {
2933        &self.control_handle
2934    }
2935
2936    fn drop_without_shutdown(mut self) {
2937        // Safety: drops once, never accessed again due to mem::forget
2938        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2939        // Prevent Drop from running (which would shut down the channel)
2940        std::mem::forget(self);
2941    }
2942}
2943
2944impl GuestGetBalloonControllerResponder {
2945    /// Sends a response to the FIDL transaction.
2946    ///
2947    /// Sets the channel to shutdown if an error occurs.
2948    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2949        let _result = self.send_raw(result);
2950        if _result.is_err() {
2951            self.control_handle.shutdown();
2952        }
2953        self.drop_without_shutdown();
2954        _result
2955    }
2956
2957    /// Similar to "send" but does not shutdown the channel if an error occurs.
2958    pub fn send_no_shutdown_on_err(
2959        self,
2960        mut result: Result<(), GuestError>,
2961    ) -> Result<(), fidl::Error> {
2962        let _result = self.send_raw(result);
2963        self.drop_without_shutdown();
2964        _result
2965    }
2966
2967    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2968        self.control_handle
2969            .inner
2970            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2971                result,
2972                self.tx_id,
2973                0x7b210bff219ac84e,
2974                fidl::encoding::DynamicFlags::empty(),
2975            )
2976    }
2977}
2978
2979#[must_use = "FIDL methods require a response to be sent"]
2980#[derive(Debug)]
2981pub struct GuestGetMemControllerResponder {
2982    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2983    tx_id: u32,
2984}
2985
2986/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2987/// if the responder is dropped without sending a response, so that the client
2988/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2989impl std::ops::Drop for GuestGetMemControllerResponder {
2990    fn drop(&mut self) {
2991        self.control_handle.shutdown();
2992        // Safety: drops once, never accessed again
2993        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2994    }
2995}
2996
2997impl fidl::endpoints::Responder for GuestGetMemControllerResponder {
2998    type ControlHandle = GuestControlHandle;
2999
3000    fn control_handle(&self) -> &GuestControlHandle {
3001        &self.control_handle
3002    }
3003
3004    fn drop_without_shutdown(mut self) {
3005        // Safety: drops once, never accessed again due to mem::forget
3006        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3007        // Prevent Drop from running (which would shut down the channel)
3008        std::mem::forget(self);
3009    }
3010}
3011
3012impl GuestGetMemControllerResponder {
3013    /// Sends a response to the FIDL transaction.
3014    ///
3015    /// Sets the channel to shutdown if an error occurs.
3016    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3017        let _result = self.send_raw(result);
3018        if _result.is_err() {
3019            self.control_handle.shutdown();
3020        }
3021        self.drop_without_shutdown();
3022        _result
3023    }
3024
3025    /// Similar to "send" but does not shutdown the channel if an error occurs.
3026    pub fn send_no_shutdown_on_err(
3027        self,
3028        mut result: Result<(), GuestError>,
3029    ) -> Result<(), fidl::Error> {
3030        let _result = self.send_raw(result);
3031        self.drop_without_shutdown();
3032        _result
3033    }
3034
3035    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3036        self.control_handle
3037            .inner
3038            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3039                result,
3040                self.tx_id,
3041                0x170b19f4b867a01c,
3042                fidl::encoding::DynamicFlags::empty(),
3043            )
3044    }
3045}
3046
3047#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3048pub struct GuestLifecycleMarker;
3049
3050impl fidl::endpoints::ProtocolMarker for GuestLifecycleMarker {
3051    type Proxy = GuestLifecycleProxy;
3052    type RequestStream = GuestLifecycleRequestStream;
3053    #[cfg(target_os = "fuchsia")]
3054    type SynchronousProxy = GuestLifecycleSynchronousProxy;
3055
3056    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestLifecycle";
3057}
3058impl fidl::endpoints::DiscoverableProtocolMarker for GuestLifecycleMarker {}
3059pub type GuestLifecycleCreateResult = Result<(), GuestError>;
3060pub type GuestLifecycleRunResult = Result<(), GuestError>;
3061
3062pub trait GuestLifecycleProxyInterface: Send + Sync {
3063    type CreateResponseFut: std::future::Future<Output = Result<GuestLifecycleCreateResult, fidl::Error>>
3064        + Send;
3065    fn r#create(&self, guest_config: GuestConfig) -> Self::CreateResponseFut;
3066    fn r#bind(&self, guest: fidl::endpoints::ServerEnd<GuestMarker>) -> Result<(), fidl::Error>;
3067    type RunResponseFut: std::future::Future<Output = Result<GuestLifecycleRunResult, fidl::Error>>
3068        + Send;
3069    fn r#run(&self) -> Self::RunResponseFut;
3070    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3071    fn r#stop(&self) -> Self::StopResponseFut;
3072}
3073#[derive(Debug)]
3074#[cfg(target_os = "fuchsia")]
3075pub struct GuestLifecycleSynchronousProxy {
3076    client: fidl::client::sync::Client,
3077}
3078
3079#[cfg(target_os = "fuchsia")]
3080impl fidl::endpoints::SynchronousProxy for GuestLifecycleSynchronousProxy {
3081    type Proxy = GuestLifecycleProxy;
3082    type Protocol = GuestLifecycleMarker;
3083
3084    fn from_channel(inner: fidl::Channel) -> Self {
3085        Self::new(inner)
3086    }
3087
3088    fn into_channel(self) -> fidl::Channel {
3089        self.client.into_channel()
3090    }
3091
3092    fn as_channel(&self) -> &fidl::Channel {
3093        self.client.as_channel()
3094    }
3095}
3096
3097#[cfg(target_os = "fuchsia")]
3098impl GuestLifecycleSynchronousProxy {
3099    pub fn new(channel: fidl::Channel) -> Self {
3100        Self { client: fidl::client::sync::Client::new(channel) }
3101    }
3102
3103    pub fn into_channel(self) -> fidl::Channel {
3104        self.client.into_channel()
3105    }
3106
3107    /// Waits until an event arrives and returns it. It is safe for other
3108    /// threads to make concurrent requests while waiting for an event.
3109    pub fn wait_for_event(
3110        &self,
3111        deadline: zx::MonotonicInstant,
3112    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3113        GuestLifecycleEvent::decode(self.client.wait_for_event::<GuestLifecycleMarker>(deadline)?)
3114    }
3115
3116    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3117    /// the kernel without starting the VCPU or device dispatch loops.
3118    ///
3119    /// Possible errors:
3120    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3121    ///         recreated.
3122    ///
3123    /// All other errors are related to VMM initialization.
3124    pub fn r#create(
3125        &self,
3126        mut guest_config: GuestConfig,
3127        ___deadline: zx::MonotonicInstant,
3128    ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3129        let _response = self.client.send_query::<
3130            GuestLifecycleCreateRequest,
3131            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3132            GuestLifecycleMarker,
3133        >(
3134            (&mut guest_config,),
3135            0x152719eed416ed41,
3136            fidl::encoding::DynamicFlags::empty(),
3137            ___deadline,
3138        )?;
3139        Ok(_response.map(|x| x))
3140    }
3141
3142    /// Binds to the Guest protocol for an initialized guest.
3143    ///
3144    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3145    /// will be immediately closed.
3146    pub fn r#bind(
3147        &self,
3148        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3149    ) -> Result<(), fidl::Error> {
3150        self.client.send::<GuestLifecycleBindRequest>(
3151            (guest,),
3152            0x57dd3e245f9598ed,
3153            fidl::encoding::DynamicFlags::empty(),
3154        )
3155    }
3156
3157    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3158    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3159    ///
3160    /// Possible errors:
3161    ///     - ALREADY_RUNING: The VMM has already been started.
3162    ///     - NOT_CREATED: Run was called before the VMM was created.
3163    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3164    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3165    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3166    pub fn r#run(
3167        &self,
3168        ___deadline: zx::MonotonicInstant,
3169    ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3170        let _response = self.client.send_query::<
3171            fidl::encoding::EmptyPayload,
3172            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3173            GuestLifecycleMarker,
3174        >(
3175            (),
3176            0x2907fef2ac775657,
3177            fidl::encoding::DynamicFlags::empty(),
3178            ___deadline,
3179        )?;
3180        Ok(_response.map(|x| x))
3181    }
3182
3183    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3184    /// Create and then Run can be called again.
3185    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3186        let _response = self.client.send_query::<
3187            fidl::encoding::EmptyPayload,
3188            fidl::encoding::EmptyPayload,
3189            GuestLifecycleMarker,
3190        >(
3191            (),
3192            0x27eef9c535ac8eb4,
3193            fidl::encoding::DynamicFlags::empty(),
3194            ___deadline,
3195        )?;
3196        Ok(_response)
3197    }
3198}
3199
3200#[cfg(target_os = "fuchsia")]
3201impl From<GuestLifecycleSynchronousProxy> for zx::NullableHandle {
3202    fn from(value: GuestLifecycleSynchronousProxy) -> Self {
3203        value.into_channel().into()
3204    }
3205}
3206
3207#[cfg(target_os = "fuchsia")]
3208impl From<fidl::Channel> for GuestLifecycleSynchronousProxy {
3209    fn from(value: fidl::Channel) -> Self {
3210        Self::new(value)
3211    }
3212}
3213
3214#[cfg(target_os = "fuchsia")]
3215impl fidl::endpoints::FromClient for GuestLifecycleSynchronousProxy {
3216    type Protocol = GuestLifecycleMarker;
3217
3218    fn from_client(value: fidl::endpoints::ClientEnd<GuestLifecycleMarker>) -> Self {
3219        Self::new(value.into_channel())
3220    }
3221}
3222
3223#[derive(Debug, Clone)]
3224pub struct GuestLifecycleProxy {
3225    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3226}
3227
3228impl fidl::endpoints::Proxy for GuestLifecycleProxy {
3229    type Protocol = GuestLifecycleMarker;
3230
3231    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3232        Self::new(inner)
3233    }
3234
3235    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3236        self.client.into_channel().map_err(|client| Self { client })
3237    }
3238
3239    fn as_channel(&self) -> &::fidl::AsyncChannel {
3240        self.client.as_channel()
3241    }
3242}
3243
3244impl GuestLifecycleProxy {
3245    /// Create a new Proxy for fuchsia.virtualization/GuestLifecycle.
3246    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3247        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3248        Self { client: fidl::client::Client::new(channel, protocol_name) }
3249    }
3250
3251    /// Get a Stream of events from the remote end of the protocol.
3252    ///
3253    /// # Panics
3254    ///
3255    /// Panics if the event stream was already taken.
3256    pub fn take_event_stream(&self) -> GuestLifecycleEventStream {
3257        GuestLifecycleEventStream { event_receiver: self.client.take_event_receiver() }
3258    }
3259
3260    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3261    /// the kernel without starting the VCPU or device dispatch loops.
3262    ///
3263    /// Possible errors:
3264    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3265    ///         recreated.
3266    ///
3267    /// All other errors are related to VMM initialization.
3268    pub fn r#create(
3269        &self,
3270        mut guest_config: GuestConfig,
3271    ) -> fidl::client::QueryResponseFut<
3272        GuestLifecycleCreateResult,
3273        fidl::encoding::DefaultFuchsiaResourceDialect,
3274    > {
3275        GuestLifecycleProxyInterface::r#create(self, guest_config)
3276    }
3277
3278    /// Binds to the Guest protocol for an initialized guest.
3279    ///
3280    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3281    /// will be immediately closed.
3282    pub fn r#bind(
3283        &self,
3284        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3285    ) -> Result<(), fidl::Error> {
3286        GuestLifecycleProxyInterface::r#bind(self, guest)
3287    }
3288
3289    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3290    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3291    ///
3292    /// Possible errors:
3293    ///     - ALREADY_RUNING: The VMM has already been started.
3294    ///     - NOT_CREATED: Run was called before the VMM was created.
3295    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3296    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3297    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3298    pub fn r#run(
3299        &self,
3300    ) -> fidl::client::QueryResponseFut<
3301        GuestLifecycleRunResult,
3302        fidl::encoding::DefaultFuchsiaResourceDialect,
3303    > {
3304        GuestLifecycleProxyInterface::r#run(self)
3305    }
3306
3307    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3308    /// Create and then Run can be called again.
3309    pub fn r#stop(
3310        &self,
3311    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3312        GuestLifecycleProxyInterface::r#stop(self)
3313    }
3314}
3315
3316impl GuestLifecycleProxyInterface for GuestLifecycleProxy {
3317    type CreateResponseFut = fidl::client::QueryResponseFut<
3318        GuestLifecycleCreateResult,
3319        fidl::encoding::DefaultFuchsiaResourceDialect,
3320    >;
3321    fn r#create(&self, mut guest_config: GuestConfig) -> Self::CreateResponseFut {
3322        fn _decode(
3323            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3324        ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3325            let _response = fidl::client::decode_transaction_body::<
3326                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3327                fidl::encoding::DefaultFuchsiaResourceDialect,
3328                0x152719eed416ed41,
3329            >(_buf?)?;
3330            Ok(_response.map(|x| x))
3331        }
3332        self.client
3333            .send_query_and_decode::<GuestLifecycleCreateRequest, GuestLifecycleCreateResult>(
3334                (&mut guest_config,),
3335                0x152719eed416ed41,
3336                fidl::encoding::DynamicFlags::empty(),
3337                _decode,
3338            )
3339    }
3340
3341    fn r#bind(
3342        &self,
3343        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3344    ) -> Result<(), fidl::Error> {
3345        self.client.send::<GuestLifecycleBindRequest>(
3346            (guest,),
3347            0x57dd3e245f9598ed,
3348            fidl::encoding::DynamicFlags::empty(),
3349        )
3350    }
3351
3352    type RunResponseFut = fidl::client::QueryResponseFut<
3353        GuestLifecycleRunResult,
3354        fidl::encoding::DefaultFuchsiaResourceDialect,
3355    >;
3356    fn r#run(&self) -> Self::RunResponseFut {
3357        fn _decode(
3358            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3359        ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3360            let _response = fidl::client::decode_transaction_body::<
3361                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3362                fidl::encoding::DefaultFuchsiaResourceDialect,
3363                0x2907fef2ac775657,
3364            >(_buf?)?;
3365            Ok(_response.map(|x| x))
3366        }
3367        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestLifecycleRunResult>(
3368            (),
3369            0x2907fef2ac775657,
3370            fidl::encoding::DynamicFlags::empty(),
3371            _decode,
3372        )
3373    }
3374
3375    type StopResponseFut =
3376        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3377    fn r#stop(&self) -> Self::StopResponseFut {
3378        fn _decode(
3379            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3380        ) -> Result<(), fidl::Error> {
3381            let _response = fidl::client::decode_transaction_body::<
3382                fidl::encoding::EmptyPayload,
3383                fidl::encoding::DefaultFuchsiaResourceDialect,
3384                0x27eef9c535ac8eb4,
3385            >(_buf?)?;
3386            Ok(_response)
3387        }
3388        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3389            (),
3390            0x27eef9c535ac8eb4,
3391            fidl::encoding::DynamicFlags::empty(),
3392            _decode,
3393        )
3394    }
3395}
3396
3397pub struct GuestLifecycleEventStream {
3398    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3399}
3400
3401impl std::marker::Unpin for GuestLifecycleEventStream {}
3402
3403impl futures::stream::FusedStream for GuestLifecycleEventStream {
3404    fn is_terminated(&self) -> bool {
3405        self.event_receiver.is_terminated()
3406    }
3407}
3408
3409impl futures::Stream for GuestLifecycleEventStream {
3410    type Item = Result<GuestLifecycleEvent, fidl::Error>;
3411
3412    fn poll_next(
3413        mut self: std::pin::Pin<&mut Self>,
3414        cx: &mut std::task::Context<'_>,
3415    ) -> std::task::Poll<Option<Self::Item>> {
3416        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3417            &mut self.event_receiver,
3418            cx
3419        )?) {
3420            Some(buf) => std::task::Poll::Ready(Some(GuestLifecycleEvent::decode(buf))),
3421            None => std::task::Poll::Ready(None),
3422        }
3423    }
3424}
3425
3426#[derive(Debug)]
3427pub enum GuestLifecycleEvent {}
3428
3429impl GuestLifecycleEvent {
3430    /// Decodes a message buffer as a [`GuestLifecycleEvent`].
3431    fn decode(
3432        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3433    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3434        let (bytes, _handles) = buf.split_mut();
3435        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3436        debug_assert_eq!(tx_header.tx_id, 0);
3437        match tx_header.ordinal {
3438            _ => Err(fidl::Error::UnknownOrdinal {
3439                ordinal: tx_header.ordinal,
3440                protocol_name:
3441                    <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3442            }),
3443        }
3444    }
3445}
3446
3447/// A Stream of incoming requests for fuchsia.virtualization/GuestLifecycle.
3448pub struct GuestLifecycleRequestStream {
3449    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3450    is_terminated: bool,
3451}
3452
3453impl std::marker::Unpin for GuestLifecycleRequestStream {}
3454
3455impl futures::stream::FusedStream for GuestLifecycleRequestStream {
3456    fn is_terminated(&self) -> bool {
3457        self.is_terminated
3458    }
3459}
3460
3461impl fidl::endpoints::RequestStream for GuestLifecycleRequestStream {
3462    type Protocol = GuestLifecycleMarker;
3463    type ControlHandle = GuestLifecycleControlHandle;
3464
3465    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3466        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3467    }
3468
3469    fn control_handle(&self) -> Self::ControlHandle {
3470        GuestLifecycleControlHandle { inner: self.inner.clone() }
3471    }
3472
3473    fn into_inner(
3474        self,
3475    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3476    {
3477        (self.inner, self.is_terminated)
3478    }
3479
3480    fn from_inner(
3481        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3482        is_terminated: bool,
3483    ) -> Self {
3484        Self { inner, is_terminated }
3485    }
3486}
3487
3488impl futures::Stream for GuestLifecycleRequestStream {
3489    type Item = Result<GuestLifecycleRequest, fidl::Error>;
3490
3491    fn poll_next(
3492        mut self: std::pin::Pin<&mut Self>,
3493        cx: &mut std::task::Context<'_>,
3494    ) -> std::task::Poll<Option<Self::Item>> {
3495        let this = &mut *self;
3496        if this.inner.check_shutdown(cx) {
3497            this.is_terminated = true;
3498            return std::task::Poll::Ready(None);
3499        }
3500        if this.is_terminated {
3501            panic!("polled GuestLifecycleRequestStream after completion");
3502        }
3503        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3504            |bytes, handles| {
3505                match this.inner.channel().read_etc(cx, bytes, handles) {
3506                    std::task::Poll::Ready(Ok(())) => {}
3507                    std::task::Poll::Pending => return std::task::Poll::Pending,
3508                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3509                        this.is_terminated = true;
3510                        return std::task::Poll::Ready(None);
3511                    }
3512                    std::task::Poll::Ready(Err(e)) => {
3513                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3514                            e.into(),
3515                        ))));
3516                    }
3517                }
3518
3519                // A message has been received from the channel
3520                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3521
3522                std::task::Poll::Ready(Some(match header.ordinal {
3523                    0x152719eed416ed41 => {
3524                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3525                        let mut req = fidl::new_empty!(
3526                            GuestLifecycleCreateRequest,
3527                            fidl::encoding::DefaultFuchsiaResourceDialect
3528                        );
3529                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleCreateRequest>(&header, _body_bytes, handles, &mut req)?;
3530                        let control_handle =
3531                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3532                        Ok(GuestLifecycleRequest::Create {
3533                            guest_config: req.guest_config,
3534
3535                            responder: GuestLifecycleCreateResponder {
3536                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3537                                tx_id: header.tx_id,
3538                            },
3539                        })
3540                    }
3541                    0x57dd3e245f9598ed => {
3542                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3543                        let mut req = fidl::new_empty!(
3544                            GuestLifecycleBindRequest,
3545                            fidl::encoding::DefaultFuchsiaResourceDialect
3546                        );
3547                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleBindRequest>(&header, _body_bytes, handles, &mut req)?;
3548                        let control_handle =
3549                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3550                        Ok(GuestLifecycleRequest::Bind { guest: req.guest, control_handle })
3551                    }
3552                    0x2907fef2ac775657 => {
3553                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3554                        let mut req = fidl::new_empty!(
3555                            fidl::encoding::EmptyPayload,
3556                            fidl::encoding::DefaultFuchsiaResourceDialect
3557                        );
3558                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3559                        let control_handle =
3560                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3561                        Ok(GuestLifecycleRequest::Run {
3562                            responder: GuestLifecycleRunResponder {
3563                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3564                                tx_id: header.tx_id,
3565                            },
3566                        })
3567                    }
3568                    0x27eef9c535ac8eb4 => {
3569                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3570                        let mut req = fidl::new_empty!(
3571                            fidl::encoding::EmptyPayload,
3572                            fidl::encoding::DefaultFuchsiaResourceDialect
3573                        );
3574                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3575                        let control_handle =
3576                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3577                        Ok(GuestLifecycleRequest::Stop {
3578                            responder: GuestLifecycleStopResponder {
3579                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3580                                tx_id: header.tx_id,
3581                            },
3582                        })
3583                    }
3584                    _ => Err(fidl::Error::UnknownOrdinal {
3585                        ordinal: header.ordinal,
3586                        protocol_name:
3587                            <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3588                    }),
3589                }))
3590            },
3591        )
3592    }
3593}
3594
3595/// The guest control plane allowing for creating, starting, and stopping the guest.
3596#[derive(Debug)]
3597pub enum GuestLifecycleRequest {
3598    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3599    /// the kernel without starting the VCPU or device dispatch loops.
3600    ///
3601    /// Possible errors:
3602    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3603    ///         recreated.
3604    ///
3605    /// All other errors are related to VMM initialization.
3606    Create { guest_config: GuestConfig, responder: GuestLifecycleCreateResponder },
3607    /// Binds to the Guest protocol for an initialized guest.
3608    ///
3609    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3610    /// will be immediately closed.
3611    Bind {
3612        guest: fidl::endpoints::ServerEnd<GuestMarker>,
3613        control_handle: GuestLifecycleControlHandle,
3614    },
3615    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3616    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3617    ///
3618    /// Possible errors:
3619    ///     - ALREADY_RUNING: The VMM has already been started.
3620    ///     - NOT_CREATED: Run was called before the VMM was created.
3621    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3622    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3623    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3624    Run { responder: GuestLifecycleRunResponder },
3625    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3626    /// Create and then Run can be called again.
3627    Stop { responder: GuestLifecycleStopResponder },
3628}
3629
3630impl GuestLifecycleRequest {
3631    #[allow(irrefutable_let_patterns)]
3632    pub fn into_create(self) -> Option<(GuestConfig, GuestLifecycleCreateResponder)> {
3633        if let GuestLifecycleRequest::Create { guest_config, responder } = self {
3634            Some((guest_config, responder))
3635        } else {
3636            None
3637        }
3638    }
3639
3640    #[allow(irrefutable_let_patterns)]
3641    pub fn into_bind(
3642        self,
3643    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestLifecycleControlHandle)> {
3644        if let GuestLifecycleRequest::Bind { guest, control_handle } = self {
3645            Some((guest, control_handle))
3646        } else {
3647            None
3648        }
3649    }
3650
3651    #[allow(irrefutable_let_patterns)]
3652    pub fn into_run(self) -> Option<(GuestLifecycleRunResponder)> {
3653        if let GuestLifecycleRequest::Run { responder } = self { Some((responder)) } else { None }
3654    }
3655
3656    #[allow(irrefutable_let_patterns)]
3657    pub fn into_stop(self) -> Option<(GuestLifecycleStopResponder)> {
3658        if let GuestLifecycleRequest::Stop { responder } = self { Some((responder)) } else { None }
3659    }
3660
3661    /// Name of the method defined in FIDL
3662    pub fn method_name(&self) -> &'static str {
3663        match *self {
3664            GuestLifecycleRequest::Create { .. } => "create",
3665            GuestLifecycleRequest::Bind { .. } => "bind",
3666            GuestLifecycleRequest::Run { .. } => "run",
3667            GuestLifecycleRequest::Stop { .. } => "stop",
3668        }
3669    }
3670}
3671
3672#[derive(Debug, Clone)]
3673pub struct GuestLifecycleControlHandle {
3674    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3675}
3676
3677impl fidl::endpoints::ControlHandle for GuestLifecycleControlHandle {
3678    fn shutdown(&self) {
3679        self.inner.shutdown()
3680    }
3681
3682    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3683        self.inner.shutdown_with_epitaph(status)
3684    }
3685
3686    fn is_closed(&self) -> bool {
3687        self.inner.channel().is_closed()
3688    }
3689    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3690        self.inner.channel().on_closed()
3691    }
3692
3693    #[cfg(target_os = "fuchsia")]
3694    fn signal_peer(
3695        &self,
3696        clear_mask: zx::Signals,
3697        set_mask: zx::Signals,
3698    ) -> Result<(), zx_status::Status> {
3699        use fidl::Peered;
3700        self.inner.channel().signal_peer(clear_mask, set_mask)
3701    }
3702}
3703
3704impl GuestLifecycleControlHandle {}
3705
3706#[must_use = "FIDL methods require a response to be sent"]
3707#[derive(Debug)]
3708pub struct GuestLifecycleCreateResponder {
3709    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3710    tx_id: u32,
3711}
3712
3713/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3714/// if the responder is dropped without sending a response, so that the client
3715/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3716impl std::ops::Drop for GuestLifecycleCreateResponder {
3717    fn drop(&mut self) {
3718        self.control_handle.shutdown();
3719        // Safety: drops once, never accessed again
3720        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3721    }
3722}
3723
3724impl fidl::endpoints::Responder for GuestLifecycleCreateResponder {
3725    type ControlHandle = GuestLifecycleControlHandle;
3726
3727    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3728        &self.control_handle
3729    }
3730
3731    fn drop_without_shutdown(mut self) {
3732        // Safety: drops once, never accessed again due to mem::forget
3733        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3734        // Prevent Drop from running (which would shut down the channel)
3735        std::mem::forget(self);
3736    }
3737}
3738
3739impl GuestLifecycleCreateResponder {
3740    /// Sends a response to the FIDL transaction.
3741    ///
3742    /// Sets the channel to shutdown if an error occurs.
3743    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3744        let _result = self.send_raw(result);
3745        if _result.is_err() {
3746            self.control_handle.shutdown();
3747        }
3748        self.drop_without_shutdown();
3749        _result
3750    }
3751
3752    /// Similar to "send" but does not shutdown the channel if an error occurs.
3753    pub fn send_no_shutdown_on_err(
3754        self,
3755        mut result: Result<(), GuestError>,
3756    ) -> Result<(), fidl::Error> {
3757        let _result = self.send_raw(result);
3758        self.drop_without_shutdown();
3759        _result
3760    }
3761
3762    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3763        self.control_handle
3764            .inner
3765            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3766                result,
3767                self.tx_id,
3768                0x152719eed416ed41,
3769                fidl::encoding::DynamicFlags::empty(),
3770            )
3771    }
3772}
3773
3774#[must_use = "FIDL methods require a response to be sent"]
3775#[derive(Debug)]
3776pub struct GuestLifecycleRunResponder {
3777    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3778    tx_id: u32,
3779}
3780
3781/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3782/// if the responder is dropped without sending a response, so that the client
3783/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3784impl std::ops::Drop for GuestLifecycleRunResponder {
3785    fn drop(&mut self) {
3786        self.control_handle.shutdown();
3787        // Safety: drops once, never accessed again
3788        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3789    }
3790}
3791
3792impl fidl::endpoints::Responder for GuestLifecycleRunResponder {
3793    type ControlHandle = GuestLifecycleControlHandle;
3794
3795    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3796        &self.control_handle
3797    }
3798
3799    fn drop_without_shutdown(mut self) {
3800        // Safety: drops once, never accessed again due to mem::forget
3801        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3802        // Prevent Drop from running (which would shut down the channel)
3803        std::mem::forget(self);
3804    }
3805}
3806
3807impl GuestLifecycleRunResponder {
3808    /// Sends a response to the FIDL transaction.
3809    ///
3810    /// Sets the channel to shutdown if an error occurs.
3811    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3812        let _result = self.send_raw(result);
3813        if _result.is_err() {
3814            self.control_handle.shutdown();
3815        }
3816        self.drop_without_shutdown();
3817        _result
3818    }
3819
3820    /// Similar to "send" but does not shutdown the channel if an error occurs.
3821    pub fn send_no_shutdown_on_err(
3822        self,
3823        mut result: Result<(), GuestError>,
3824    ) -> Result<(), fidl::Error> {
3825        let _result = self.send_raw(result);
3826        self.drop_without_shutdown();
3827        _result
3828    }
3829
3830    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3831        self.control_handle
3832            .inner
3833            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3834                result,
3835                self.tx_id,
3836                0x2907fef2ac775657,
3837                fidl::encoding::DynamicFlags::empty(),
3838            )
3839    }
3840}
3841
3842#[must_use = "FIDL methods require a response to be sent"]
3843#[derive(Debug)]
3844pub struct GuestLifecycleStopResponder {
3845    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3846    tx_id: u32,
3847}
3848
3849/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3850/// if the responder is dropped without sending a response, so that the client
3851/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3852impl std::ops::Drop for GuestLifecycleStopResponder {
3853    fn drop(&mut self) {
3854        self.control_handle.shutdown();
3855        // Safety: drops once, never accessed again
3856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3857    }
3858}
3859
3860impl fidl::endpoints::Responder for GuestLifecycleStopResponder {
3861    type ControlHandle = GuestLifecycleControlHandle;
3862
3863    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3864        &self.control_handle
3865    }
3866
3867    fn drop_without_shutdown(mut self) {
3868        // Safety: drops once, never accessed again due to mem::forget
3869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3870        // Prevent Drop from running (which would shut down the channel)
3871        std::mem::forget(self);
3872    }
3873}
3874
3875impl GuestLifecycleStopResponder {
3876    /// Sends a response to the FIDL transaction.
3877    ///
3878    /// Sets the channel to shutdown if an error occurs.
3879    pub fn send(self) -> Result<(), fidl::Error> {
3880        let _result = self.send_raw();
3881        if _result.is_err() {
3882            self.control_handle.shutdown();
3883        }
3884        self.drop_without_shutdown();
3885        _result
3886    }
3887
3888    /// Similar to "send" but does not shutdown the channel if an error occurs.
3889    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3890        let _result = self.send_raw();
3891        self.drop_without_shutdown();
3892        _result
3893    }
3894
3895    fn send_raw(&self) -> Result<(), fidl::Error> {
3896        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3897            (),
3898            self.tx_id,
3899            0x27eef9c535ac8eb4,
3900            fidl::encoding::DynamicFlags::empty(),
3901        )
3902    }
3903}
3904
3905#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3906pub struct GuestManagerMarker;
3907
3908impl fidl::endpoints::ProtocolMarker for GuestManagerMarker {
3909    type Proxy = GuestManagerProxy;
3910    type RequestStream = GuestManagerRequestStream;
3911    #[cfg(target_os = "fuchsia")]
3912    type SynchronousProxy = GuestManagerSynchronousProxy;
3913
3914    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestManager";
3915}
3916impl fidl::endpoints::DiscoverableProtocolMarker for GuestManagerMarker {}
3917pub type GuestManagerLaunchResult = Result<(), GuestManagerError>;
3918pub type GuestManagerConnectResult = Result<(), GuestManagerError>;
3919
3920pub trait GuestManagerProxyInterface: Send + Sync {
3921    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
3922        + Send;
3923    fn r#launch(
3924        &self,
3925        guest_config: GuestConfig,
3926        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3927    ) -> Self::LaunchResponseFut;
3928    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3929    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
3930    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
3931        + Send;
3932    fn r#connect(
3933        &self,
3934        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3935    ) -> Self::ConnectResponseFut;
3936    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
3937    fn r#get_info(&self) -> Self::GetInfoResponseFut;
3938}
3939#[derive(Debug)]
3940#[cfg(target_os = "fuchsia")]
3941pub struct GuestManagerSynchronousProxy {
3942    client: fidl::client::sync::Client,
3943}
3944
3945#[cfg(target_os = "fuchsia")]
3946impl fidl::endpoints::SynchronousProxy for GuestManagerSynchronousProxy {
3947    type Proxy = GuestManagerProxy;
3948    type Protocol = GuestManagerMarker;
3949
3950    fn from_channel(inner: fidl::Channel) -> Self {
3951        Self::new(inner)
3952    }
3953
3954    fn into_channel(self) -> fidl::Channel {
3955        self.client.into_channel()
3956    }
3957
3958    fn as_channel(&self) -> &fidl::Channel {
3959        self.client.as_channel()
3960    }
3961}
3962
3963#[cfg(target_os = "fuchsia")]
3964impl GuestManagerSynchronousProxy {
3965    pub fn new(channel: fidl::Channel) -> Self {
3966        Self { client: fidl::client::sync::Client::new(channel) }
3967    }
3968
3969    pub fn into_channel(self) -> fidl::Channel {
3970        self.client.into_channel()
3971    }
3972
3973    /// Waits until an event arrives and returns it. It is safe for other
3974    /// threads to make concurrent requests while waiting for an event.
3975    pub fn wait_for_event(
3976        &self,
3977        deadline: zx::MonotonicInstant,
3978    ) -> Result<GuestManagerEvent, fidl::Error> {
3979        GuestManagerEvent::decode(self.client.wait_for_event::<GuestManagerMarker>(deadline)?)
3980    }
3981
3982    /// Launch a new guest instance.
3983    ///
3984    /// Possible errors:
3985    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
3986    ///         problems detected by the guest manager.
3987    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
3988    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
3989    ///         component logs for a more specific failure.
3990    pub fn r#launch(
3991        &self,
3992        mut guest_config: GuestConfig,
3993        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
3994        ___deadline: zx::MonotonicInstant,
3995    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
3996        let _response =
3997            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
3998                fidl::encoding::EmptyStruct,
3999                GuestManagerError,
4000            >, GuestManagerMarker>(
4001                (&mut guest_config, controller),
4002                0x394a2e29f750323e,
4003                fidl::encoding::DynamicFlags::empty(),
4004                ___deadline,
4005            )?;
4006        Ok(_response.map(|x| x))
4007    }
4008
4009    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4010    /// be used to launch another guest.
4011    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
4012        let _response = self.client.send_query::<
4013            fidl::encoding::EmptyPayload,
4014            fidl::encoding::EmptyPayload,
4015            GuestManagerMarker,
4016        >(
4017            (),
4018            0x3ad9a012982f872d,
4019            fidl::encoding::DynamicFlags::empty(),
4020            ___deadline,
4021        )?;
4022        Ok(_response)
4023    }
4024
4025    /// Connect to a currently running guest.
4026    ///
4027    /// Possible errors:
4028    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4029    ///         has launched before attempting to reconnect.
4030    pub fn r#connect(
4031        &self,
4032        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4033        ___deadline: zx::MonotonicInstant,
4034    ) -> Result<GuestManagerConnectResult, fidl::Error> {
4035        let _response =
4036            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
4037                fidl::encoding::EmptyStruct,
4038                GuestManagerError,
4039            >, GuestManagerMarker>(
4040                (controller,),
4041                0x4e489076e3bb15b4,
4042                fidl::encoding::DynamicFlags::empty(),
4043                ___deadline,
4044            )?;
4045        Ok(_response.map(|x| x))
4046    }
4047
4048    /// Query guest info
4049    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
4050        let _response = self.client.send_query::<
4051            fidl::encoding::EmptyPayload,
4052            GuestManagerGetInfoResponse,
4053            GuestManagerMarker,
4054        >(
4055            (),
4056            0x76892614aea695dc,
4057            fidl::encoding::DynamicFlags::empty(),
4058            ___deadline,
4059        )?;
4060        Ok(_response.guest_info)
4061    }
4062}
4063
4064#[cfg(target_os = "fuchsia")]
4065impl From<GuestManagerSynchronousProxy> for zx::NullableHandle {
4066    fn from(value: GuestManagerSynchronousProxy) -> Self {
4067        value.into_channel().into()
4068    }
4069}
4070
4071#[cfg(target_os = "fuchsia")]
4072impl From<fidl::Channel> for GuestManagerSynchronousProxy {
4073    fn from(value: fidl::Channel) -> Self {
4074        Self::new(value)
4075    }
4076}
4077
4078#[cfg(target_os = "fuchsia")]
4079impl fidl::endpoints::FromClient for GuestManagerSynchronousProxy {
4080    type Protocol = GuestManagerMarker;
4081
4082    fn from_client(value: fidl::endpoints::ClientEnd<GuestManagerMarker>) -> Self {
4083        Self::new(value.into_channel())
4084    }
4085}
4086
4087#[derive(Debug, Clone)]
4088pub struct GuestManagerProxy {
4089    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4090}
4091
4092impl fidl::endpoints::Proxy for GuestManagerProxy {
4093    type Protocol = GuestManagerMarker;
4094
4095    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4096        Self::new(inner)
4097    }
4098
4099    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4100        self.client.into_channel().map_err(|client| Self { client })
4101    }
4102
4103    fn as_channel(&self) -> &::fidl::AsyncChannel {
4104        self.client.as_channel()
4105    }
4106}
4107
4108impl GuestManagerProxy {
4109    /// Create a new Proxy for fuchsia.virtualization/GuestManager.
4110    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4111        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4112        Self { client: fidl::client::Client::new(channel, protocol_name) }
4113    }
4114
4115    /// Get a Stream of events from the remote end of the protocol.
4116    ///
4117    /// # Panics
4118    ///
4119    /// Panics if the event stream was already taken.
4120    pub fn take_event_stream(&self) -> GuestManagerEventStream {
4121        GuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
4122    }
4123
4124    /// Launch a new guest instance.
4125    ///
4126    /// Possible errors:
4127    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4128    ///         problems detected by the guest manager.
4129    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4130    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4131    ///         component logs for a more specific failure.
4132    pub fn r#launch(
4133        &self,
4134        mut guest_config: GuestConfig,
4135        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4136    ) -> fidl::client::QueryResponseFut<
4137        GuestManagerLaunchResult,
4138        fidl::encoding::DefaultFuchsiaResourceDialect,
4139    > {
4140        GuestManagerProxyInterface::r#launch(self, guest_config, controller)
4141    }
4142
4143    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4144    /// be used to launch another guest.
4145    pub fn r#force_shutdown(
4146        &self,
4147    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4148        GuestManagerProxyInterface::r#force_shutdown(self)
4149    }
4150
4151    /// Connect to a currently running guest.
4152    ///
4153    /// Possible errors:
4154    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4155    ///         has launched before attempting to reconnect.
4156    pub fn r#connect(
4157        &self,
4158        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4159    ) -> fidl::client::QueryResponseFut<
4160        GuestManagerConnectResult,
4161        fidl::encoding::DefaultFuchsiaResourceDialect,
4162    > {
4163        GuestManagerProxyInterface::r#connect(self, controller)
4164    }
4165
4166    /// Query guest info
4167    pub fn r#get_info(
4168        &self,
4169    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
4170    {
4171        GuestManagerProxyInterface::r#get_info(self)
4172    }
4173}
4174
4175impl GuestManagerProxyInterface for GuestManagerProxy {
4176    type LaunchResponseFut = fidl::client::QueryResponseFut<
4177        GuestManagerLaunchResult,
4178        fidl::encoding::DefaultFuchsiaResourceDialect,
4179    >;
4180    fn r#launch(
4181        &self,
4182        mut guest_config: GuestConfig,
4183        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4184    ) -> Self::LaunchResponseFut {
4185        fn _decode(
4186            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4187        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
4188            let _response = fidl::client::decode_transaction_body::<
4189                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4190                fidl::encoding::DefaultFuchsiaResourceDialect,
4191                0x394a2e29f750323e,
4192            >(_buf?)?;
4193            Ok(_response.map(|x| x))
4194        }
4195        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
4196            (&mut guest_config, controller),
4197            0x394a2e29f750323e,
4198            fidl::encoding::DynamicFlags::empty(),
4199            _decode,
4200        )
4201    }
4202
4203    type ForceShutdownResponseFut =
4204        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4205    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
4206        fn _decode(
4207            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4208        ) -> Result<(), fidl::Error> {
4209            let _response = fidl::client::decode_transaction_body::<
4210                fidl::encoding::EmptyPayload,
4211                fidl::encoding::DefaultFuchsiaResourceDialect,
4212                0x3ad9a012982f872d,
4213            >(_buf?)?;
4214            Ok(_response)
4215        }
4216        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
4217            (),
4218            0x3ad9a012982f872d,
4219            fidl::encoding::DynamicFlags::empty(),
4220            _decode,
4221        )
4222    }
4223
4224    type ConnectResponseFut = fidl::client::QueryResponseFut<
4225        GuestManagerConnectResult,
4226        fidl::encoding::DefaultFuchsiaResourceDialect,
4227    >;
4228    fn r#connect(
4229        &self,
4230        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4231    ) -> Self::ConnectResponseFut {
4232        fn _decode(
4233            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4234        ) -> Result<GuestManagerConnectResult, fidl::Error> {
4235            let _response = fidl::client::decode_transaction_body::<
4236                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4237                fidl::encoding::DefaultFuchsiaResourceDialect,
4238                0x4e489076e3bb15b4,
4239            >(_buf?)?;
4240            Ok(_response.map(|x| x))
4241        }
4242        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
4243            (controller,),
4244            0x4e489076e3bb15b4,
4245            fidl::encoding::DynamicFlags::empty(),
4246            _decode,
4247        )
4248    }
4249
4250    type GetInfoResponseFut =
4251        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
4252    fn r#get_info(&self) -> Self::GetInfoResponseFut {
4253        fn _decode(
4254            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4255        ) -> Result<GuestInfo, fidl::Error> {
4256            let _response = fidl::client::decode_transaction_body::<
4257                GuestManagerGetInfoResponse,
4258                fidl::encoding::DefaultFuchsiaResourceDialect,
4259                0x76892614aea695dc,
4260            >(_buf?)?;
4261            Ok(_response.guest_info)
4262        }
4263        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
4264            (),
4265            0x76892614aea695dc,
4266            fidl::encoding::DynamicFlags::empty(),
4267            _decode,
4268        )
4269    }
4270}
4271
4272pub struct GuestManagerEventStream {
4273    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4274}
4275
4276impl std::marker::Unpin for GuestManagerEventStream {}
4277
4278impl futures::stream::FusedStream for GuestManagerEventStream {
4279    fn is_terminated(&self) -> bool {
4280        self.event_receiver.is_terminated()
4281    }
4282}
4283
4284impl futures::Stream for GuestManagerEventStream {
4285    type Item = Result<GuestManagerEvent, fidl::Error>;
4286
4287    fn poll_next(
4288        mut self: std::pin::Pin<&mut Self>,
4289        cx: &mut std::task::Context<'_>,
4290    ) -> std::task::Poll<Option<Self::Item>> {
4291        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4292            &mut self.event_receiver,
4293            cx
4294        )?) {
4295            Some(buf) => std::task::Poll::Ready(Some(GuestManagerEvent::decode(buf))),
4296            None => std::task::Poll::Ready(None),
4297        }
4298    }
4299}
4300
4301#[derive(Debug)]
4302pub enum GuestManagerEvent {}
4303
4304impl GuestManagerEvent {
4305    /// Decodes a message buffer as a [`GuestManagerEvent`].
4306    fn decode(
4307        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4308    ) -> Result<GuestManagerEvent, fidl::Error> {
4309        let (bytes, _handles) = buf.split_mut();
4310        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4311        debug_assert_eq!(tx_header.tx_id, 0);
4312        match tx_header.ordinal {
4313            _ => Err(fidl::Error::UnknownOrdinal {
4314                ordinal: tx_header.ordinal,
4315                protocol_name: <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4316            }),
4317        }
4318    }
4319}
4320
4321/// A Stream of incoming requests for fuchsia.virtualization/GuestManager.
4322pub struct GuestManagerRequestStream {
4323    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4324    is_terminated: bool,
4325}
4326
4327impl std::marker::Unpin for GuestManagerRequestStream {}
4328
4329impl futures::stream::FusedStream for GuestManagerRequestStream {
4330    fn is_terminated(&self) -> bool {
4331        self.is_terminated
4332    }
4333}
4334
4335impl fidl::endpoints::RequestStream for GuestManagerRequestStream {
4336    type Protocol = GuestManagerMarker;
4337    type ControlHandle = GuestManagerControlHandle;
4338
4339    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4340        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4341    }
4342
4343    fn control_handle(&self) -> Self::ControlHandle {
4344        GuestManagerControlHandle { inner: self.inner.clone() }
4345    }
4346
4347    fn into_inner(
4348        self,
4349    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4350    {
4351        (self.inner, self.is_terminated)
4352    }
4353
4354    fn from_inner(
4355        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4356        is_terminated: bool,
4357    ) -> Self {
4358        Self { inner, is_terminated }
4359    }
4360}
4361
4362impl futures::Stream for GuestManagerRequestStream {
4363    type Item = Result<GuestManagerRequest, fidl::Error>;
4364
4365    fn poll_next(
4366        mut self: std::pin::Pin<&mut Self>,
4367        cx: &mut std::task::Context<'_>,
4368    ) -> std::task::Poll<Option<Self::Item>> {
4369        let this = &mut *self;
4370        if this.inner.check_shutdown(cx) {
4371            this.is_terminated = true;
4372            return std::task::Poll::Ready(None);
4373        }
4374        if this.is_terminated {
4375            panic!("polled GuestManagerRequestStream after completion");
4376        }
4377        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4378            |bytes, handles| {
4379                match this.inner.channel().read_etc(cx, bytes, handles) {
4380                    std::task::Poll::Ready(Ok(())) => {}
4381                    std::task::Poll::Pending => return std::task::Poll::Pending,
4382                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4383                        this.is_terminated = true;
4384                        return std::task::Poll::Ready(None);
4385                    }
4386                    std::task::Poll::Ready(Err(e)) => {
4387                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4388                            e.into(),
4389                        ))));
4390                    }
4391                }
4392
4393                // A message has been received from the channel
4394                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4395
4396                std::task::Poll::Ready(Some(match header.ordinal {
4397                    0x394a2e29f750323e => {
4398                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4399                        let mut req = fidl::new_empty!(
4400                            GuestManagerLaunchRequest,
4401                            fidl::encoding::DefaultFuchsiaResourceDialect
4402                        );
4403                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
4404                        let control_handle =
4405                            GuestManagerControlHandle { inner: this.inner.clone() };
4406                        Ok(GuestManagerRequest::Launch {
4407                            guest_config: req.guest_config,
4408                            controller: req.controller,
4409
4410                            responder: GuestManagerLaunchResponder {
4411                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4412                                tx_id: header.tx_id,
4413                            },
4414                        })
4415                    }
4416                    0x3ad9a012982f872d => {
4417                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4418                        let mut req = fidl::new_empty!(
4419                            fidl::encoding::EmptyPayload,
4420                            fidl::encoding::DefaultFuchsiaResourceDialect
4421                        );
4422                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4423                        let control_handle =
4424                            GuestManagerControlHandle { inner: this.inner.clone() };
4425                        Ok(GuestManagerRequest::ForceShutdown {
4426                            responder: GuestManagerForceShutdownResponder {
4427                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4428                                tx_id: header.tx_id,
4429                            },
4430                        })
4431                    }
4432                    0x4e489076e3bb15b4 => {
4433                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4434                        let mut req = fidl::new_empty!(
4435                            GuestManagerConnectRequest,
4436                            fidl::encoding::DefaultFuchsiaResourceDialect
4437                        );
4438                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
4439                        let control_handle =
4440                            GuestManagerControlHandle { inner: this.inner.clone() };
4441                        Ok(GuestManagerRequest::Connect {
4442                            controller: req.controller,
4443
4444                            responder: GuestManagerConnectResponder {
4445                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4446                                tx_id: header.tx_id,
4447                            },
4448                        })
4449                    }
4450                    0x76892614aea695dc => {
4451                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4452                        let mut req = fidl::new_empty!(
4453                            fidl::encoding::EmptyPayload,
4454                            fidl::encoding::DefaultFuchsiaResourceDialect
4455                        );
4456                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4457                        let control_handle =
4458                            GuestManagerControlHandle { inner: this.inner.clone() };
4459                        Ok(GuestManagerRequest::GetInfo {
4460                            responder: GuestManagerGetInfoResponder {
4461                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4462                                tx_id: header.tx_id,
4463                            },
4464                        })
4465                    }
4466                    _ => Err(fidl::Error::UnknownOrdinal {
4467                        ordinal: header.ordinal,
4468                        protocol_name:
4469                            <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4470                    }),
4471                }))
4472            },
4473        )
4474    }
4475}
4476
4477#[derive(Debug)]
4478pub enum GuestManagerRequest {
4479    /// Launch a new guest instance.
4480    ///
4481    /// Possible errors:
4482    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4483    ///         problems detected by the guest manager.
4484    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4485    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4486    ///         component logs for a more specific failure.
4487    Launch {
4488        guest_config: GuestConfig,
4489        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4490        responder: GuestManagerLaunchResponder,
4491    },
4492    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4493    /// be used to launch another guest.
4494    ForceShutdown { responder: GuestManagerForceShutdownResponder },
4495    /// Connect to a currently running guest.
4496    ///
4497    /// Possible errors:
4498    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4499    ///         has launched before attempting to reconnect.
4500    Connect {
4501        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4502        responder: GuestManagerConnectResponder,
4503    },
4504    /// Query guest info
4505    GetInfo { responder: GuestManagerGetInfoResponder },
4506}
4507
4508impl GuestManagerRequest {
4509    #[allow(irrefutable_let_patterns)]
4510    pub fn into_launch(
4511        self,
4512    ) -> Option<(GuestConfig, fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerLaunchResponder)>
4513    {
4514        if let GuestManagerRequest::Launch { guest_config, controller, responder } = self {
4515            Some((guest_config, controller, responder))
4516        } else {
4517            None
4518        }
4519    }
4520
4521    #[allow(irrefutable_let_patterns)]
4522    pub fn into_force_shutdown(self) -> Option<(GuestManagerForceShutdownResponder)> {
4523        if let GuestManagerRequest::ForceShutdown { responder } = self {
4524            Some((responder))
4525        } else {
4526            None
4527        }
4528    }
4529
4530    #[allow(irrefutable_let_patterns)]
4531    pub fn into_connect(
4532        self,
4533    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerConnectResponder)> {
4534        if let GuestManagerRequest::Connect { controller, responder } = self {
4535            Some((controller, responder))
4536        } else {
4537            None
4538        }
4539    }
4540
4541    #[allow(irrefutable_let_patterns)]
4542    pub fn into_get_info(self) -> Option<(GuestManagerGetInfoResponder)> {
4543        if let GuestManagerRequest::GetInfo { responder } = self { Some((responder)) } else { None }
4544    }
4545
4546    /// Name of the method defined in FIDL
4547    pub fn method_name(&self) -> &'static str {
4548        match *self {
4549            GuestManagerRequest::Launch { .. } => "launch",
4550            GuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
4551            GuestManagerRequest::Connect { .. } => "connect",
4552            GuestManagerRequest::GetInfo { .. } => "get_info",
4553        }
4554    }
4555}
4556
4557#[derive(Debug, Clone)]
4558pub struct GuestManagerControlHandle {
4559    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4560}
4561
4562impl fidl::endpoints::ControlHandle for GuestManagerControlHandle {
4563    fn shutdown(&self) {
4564        self.inner.shutdown()
4565    }
4566
4567    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4568        self.inner.shutdown_with_epitaph(status)
4569    }
4570
4571    fn is_closed(&self) -> bool {
4572        self.inner.channel().is_closed()
4573    }
4574    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4575        self.inner.channel().on_closed()
4576    }
4577
4578    #[cfg(target_os = "fuchsia")]
4579    fn signal_peer(
4580        &self,
4581        clear_mask: zx::Signals,
4582        set_mask: zx::Signals,
4583    ) -> Result<(), zx_status::Status> {
4584        use fidl::Peered;
4585        self.inner.channel().signal_peer(clear_mask, set_mask)
4586    }
4587}
4588
4589impl GuestManagerControlHandle {}
4590
4591#[must_use = "FIDL methods require a response to be sent"]
4592#[derive(Debug)]
4593pub struct GuestManagerLaunchResponder {
4594    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4595    tx_id: u32,
4596}
4597
4598/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4599/// if the responder is dropped without sending a response, so that the client
4600/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4601impl std::ops::Drop for GuestManagerLaunchResponder {
4602    fn drop(&mut self) {
4603        self.control_handle.shutdown();
4604        // Safety: drops once, never accessed again
4605        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4606    }
4607}
4608
4609impl fidl::endpoints::Responder for GuestManagerLaunchResponder {
4610    type ControlHandle = GuestManagerControlHandle;
4611
4612    fn control_handle(&self) -> &GuestManagerControlHandle {
4613        &self.control_handle
4614    }
4615
4616    fn drop_without_shutdown(mut self) {
4617        // Safety: drops once, never accessed again due to mem::forget
4618        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4619        // Prevent Drop from running (which would shut down the channel)
4620        std::mem::forget(self);
4621    }
4622}
4623
4624impl GuestManagerLaunchResponder {
4625    /// Sends a response to the FIDL transaction.
4626    ///
4627    /// Sets the channel to shutdown if an error occurs.
4628    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4629        let _result = self.send_raw(result);
4630        if _result.is_err() {
4631            self.control_handle.shutdown();
4632        }
4633        self.drop_without_shutdown();
4634        _result
4635    }
4636
4637    /// Similar to "send" but does not shutdown the channel if an error occurs.
4638    pub fn send_no_shutdown_on_err(
4639        self,
4640        mut result: Result<(), GuestManagerError>,
4641    ) -> Result<(), fidl::Error> {
4642        let _result = self.send_raw(result);
4643        self.drop_without_shutdown();
4644        _result
4645    }
4646
4647    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4648        self.control_handle.inner.send::<fidl::encoding::ResultType<
4649            fidl::encoding::EmptyStruct,
4650            GuestManagerError,
4651        >>(
4652            result,
4653            self.tx_id,
4654            0x394a2e29f750323e,
4655            fidl::encoding::DynamicFlags::empty(),
4656        )
4657    }
4658}
4659
4660#[must_use = "FIDL methods require a response to be sent"]
4661#[derive(Debug)]
4662pub struct GuestManagerForceShutdownResponder {
4663    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4664    tx_id: u32,
4665}
4666
4667/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4668/// if the responder is dropped without sending a response, so that the client
4669/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4670impl std::ops::Drop for GuestManagerForceShutdownResponder {
4671    fn drop(&mut self) {
4672        self.control_handle.shutdown();
4673        // Safety: drops once, never accessed again
4674        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4675    }
4676}
4677
4678impl fidl::endpoints::Responder for GuestManagerForceShutdownResponder {
4679    type ControlHandle = GuestManagerControlHandle;
4680
4681    fn control_handle(&self) -> &GuestManagerControlHandle {
4682        &self.control_handle
4683    }
4684
4685    fn drop_without_shutdown(mut self) {
4686        // Safety: drops once, never accessed again due to mem::forget
4687        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4688        // Prevent Drop from running (which would shut down the channel)
4689        std::mem::forget(self);
4690    }
4691}
4692
4693impl GuestManagerForceShutdownResponder {
4694    /// Sends a response to the FIDL transaction.
4695    ///
4696    /// Sets the channel to shutdown if an error occurs.
4697    pub fn send(self) -> Result<(), fidl::Error> {
4698        let _result = self.send_raw();
4699        if _result.is_err() {
4700            self.control_handle.shutdown();
4701        }
4702        self.drop_without_shutdown();
4703        _result
4704    }
4705
4706    /// Similar to "send" but does not shutdown the channel if an error occurs.
4707    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4708        let _result = self.send_raw();
4709        self.drop_without_shutdown();
4710        _result
4711    }
4712
4713    fn send_raw(&self) -> Result<(), fidl::Error> {
4714        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4715            (),
4716            self.tx_id,
4717            0x3ad9a012982f872d,
4718            fidl::encoding::DynamicFlags::empty(),
4719        )
4720    }
4721}
4722
4723#[must_use = "FIDL methods require a response to be sent"]
4724#[derive(Debug)]
4725pub struct GuestManagerConnectResponder {
4726    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4727    tx_id: u32,
4728}
4729
4730/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4731/// if the responder is dropped without sending a response, so that the client
4732/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4733impl std::ops::Drop for GuestManagerConnectResponder {
4734    fn drop(&mut self) {
4735        self.control_handle.shutdown();
4736        // Safety: drops once, never accessed again
4737        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4738    }
4739}
4740
4741impl fidl::endpoints::Responder for GuestManagerConnectResponder {
4742    type ControlHandle = GuestManagerControlHandle;
4743
4744    fn control_handle(&self) -> &GuestManagerControlHandle {
4745        &self.control_handle
4746    }
4747
4748    fn drop_without_shutdown(mut self) {
4749        // Safety: drops once, never accessed again due to mem::forget
4750        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4751        // Prevent Drop from running (which would shut down the channel)
4752        std::mem::forget(self);
4753    }
4754}
4755
4756impl GuestManagerConnectResponder {
4757    /// Sends a response to the FIDL transaction.
4758    ///
4759    /// Sets the channel to shutdown if an error occurs.
4760    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4761        let _result = self.send_raw(result);
4762        if _result.is_err() {
4763            self.control_handle.shutdown();
4764        }
4765        self.drop_without_shutdown();
4766        _result
4767    }
4768
4769    /// Similar to "send" but does not shutdown the channel if an error occurs.
4770    pub fn send_no_shutdown_on_err(
4771        self,
4772        mut result: Result<(), GuestManagerError>,
4773    ) -> Result<(), fidl::Error> {
4774        let _result = self.send_raw(result);
4775        self.drop_without_shutdown();
4776        _result
4777    }
4778
4779    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4780        self.control_handle.inner.send::<fidl::encoding::ResultType<
4781            fidl::encoding::EmptyStruct,
4782            GuestManagerError,
4783        >>(
4784            result,
4785            self.tx_id,
4786            0x4e489076e3bb15b4,
4787            fidl::encoding::DynamicFlags::empty(),
4788        )
4789    }
4790}
4791
4792#[must_use = "FIDL methods require a response to be sent"]
4793#[derive(Debug)]
4794pub struct GuestManagerGetInfoResponder {
4795    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4796    tx_id: u32,
4797}
4798
4799/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4800/// if the responder is dropped without sending a response, so that the client
4801/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4802impl std::ops::Drop for GuestManagerGetInfoResponder {
4803    fn drop(&mut self) {
4804        self.control_handle.shutdown();
4805        // Safety: drops once, never accessed again
4806        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4807    }
4808}
4809
4810impl fidl::endpoints::Responder for GuestManagerGetInfoResponder {
4811    type ControlHandle = GuestManagerControlHandle;
4812
4813    fn control_handle(&self) -> &GuestManagerControlHandle {
4814        &self.control_handle
4815    }
4816
4817    fn drop_without_shutdown(mut self) {
4818        // Safety: drops once, never accessed again due to mem::forget
4819        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4820        // Prevent Drop from running (which would shut down the channel)
4821        std::mem::forget(self);
4822    }
4823}
4824
4825impl GuestManagerGetInfoResponder {
4826    /// Sends a response to the FIDL transaction.
4827    ///
4828    /// Sets the channel to shutdown if an error occurs.
4829    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4830        let _result = self.send_raw(guest_info);
4831        if _result.is_err() {
4832            self.control_handle.shutdown();
4833        }
4834        self.drop_without_shutdown();
4835        _result
4836    }
4837
4838    /// Similar to "send" but does not shutdown the channel if an error occurs.
4839    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4840        let _result = self.send_raw(guest_info);
4841        self.drop_without_shutdown();
4842        _result
4843    }
4844
4845    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4846        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
4847            (guest_info,),
4848            self.tx_id,
4849            0x76892614aea695dc,
4850            fidl::encoding::DynamicFlags::empty(),
4851        )
4852    }
4853}
4854
4855#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4856pub struct HostVsockAcceptorMarker;
4857
4858impl fidl::endpoints::ProtocolMarker for HostVsockAcceptorMarker {
4859    type Proxy = HostVsockAcceptorProxy;
4860    type RequestStream = HostVsockAcceptorRequestStream;
4861    #[cfg(target_os = "fuchsia")]
4862    type SynchronousProxy = HostVsockAcceptorSynchronousProxy;
4863
4864    const DEBUG_NAME: &'static str = "(anonymous) HostVsockAcceptor";
4865}
4866pub type HostVsockAcceptorAcceptResult = Result<fidl::Socket, i32>;
4867
4868pub trait HostVsockAcceptorProxyInterface: Send + Sync {
4869    type AcceptResponseFut: std::future::Future<Output = Result<HostVsockAcceptorAcceptResult, fidl::Error>>
4870        + Send;
4871    fn r#accept(&self, src_cid: u32, src_port: u32, port: u32) -> Self::AcceptResponseFut;
4872}
4873#[derive(Debug)]
4874#[cfg(target_os = "fuchsia")]
4875pub struct HostVsockAcceptorSynchronousProxy {
4876    client: fidl::client::sync::Client,
4877}
4878
4879#[cfg(target_os = "fuchsia")]
4880impl fidl::endpoints::SynchronousProxy for HostVsockAcceptorSynchronousProxy {
4881    type Proxy = HostVsockAcceptorProxy;
4882    type Protocol = HostVsockAcceptorMarker;
4883
4884    fn from_channel(inner: fidl::Channel) -> Self {
4885        Self::new(inner)
4886    }
4887
4888    fn into_channel(self) -> fidl::Channel {
4889        self.client.into_channel()
4890    }
4891
4892    fn as_channel(&self) -> &fidl::Channel {
4893        self.client.as_channel()
4894    }
4895}
4896
4897#[cfg(target_os = "fuchsia")]
4898impl HostVsockAcceptorSynchronousProxy {
4899    pub fn new(channel: fidl::Channel) -> Self {
4900        Self { client: fidl::client::sync::Client::new(channel) }
4901    }
4902
4903    pub fn into_channel(self) -> fidl::Channel {
4904        self.client.into_channel()
4905    }
4906
4907    /// Waits until an event arrives and returns it. It is safe for other
4908    /// threads to make concurrent requests while waiting for an event.
4909    pub fn wait_for_event(
4910        &self,
4911        deadline: zx::MonotonicInstant,
4912    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
4913        HostVsockAcceptorEvent::decode(
4914            self.client.wait_for_event::<HostVsockAcceptorMarker>(deadline)?,
4915        )
4916    }
4917
4918    pub fn r#accept(
4919        &self,
4920        mut src_cid: u32,
4921        mut src_port: u32,
4922        mut port: u32,
4923        ___deadline: zx::MonotonicInstant,
4924    ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
4925        let _response = self.client.send_query::<
4926            HostVsockAcceptorAcceptRequest,
4927            fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
4928            HostVsockAcceptorMarker,
4929        >(
4930            (src_cid, src_port, port,),
4931            0x6996ed935beaa2d7,
4932            fidl::encoding::DynamicFlags::empty(),
4933            ___deadline,
4934        )?;
4935        Ok(_response.map(|x| x.socket))
4936    }
4937}
4938
4939#[cfg(target_os = "fuchsia")]
4940impl From<HostVsockAcceptorSynchronousProxy> for zx::NullableHandle {
4941    fn from(value: HostVsockAcceptorSynchronousProxy) -> Self {
4942        value.into_channel().into()
4943    }
4944}
4945
4946#[cfg(target_os = "fuchsia")]
4947impl From<fidl::Channel> for HostVsockAcceptorSynchronousProxy {
4948    fn from(value: fidl::Channel) -> Self {
4949        Self::new(value)
4950    }
4951}
4952
4953#[cfg(target_os = "fuchsia")]
4954impl fidl::endpoints::FromClient for HostVsockAcceptorSynchronousProxy {
4955    type Protocol = HostVsockAcceptorMarker;
4956
4957    fn from_client(value: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>) -> Self {
4958        Self::new(value.into_channel())
4959    }
4960}
4961
4962#[derive(Debug, Clone)]
4963pub struct HostVsockAcceptorProxy {
4964    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4965}
4966
4967impl fidl::endpoints::Proxy for HostVsockAcceptorProxy {
4968    type Protocol = HostVsockAcceptorMarker;
4969
4970    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4971        Self::new(inner)
4972    }
4973
4974    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4975        self.client.into_channel().map_err(|client| Self { client })
4976    }
4977
4978    fn as_channel(&self) -> &::fidl::AsyncChannel {
4979        self.client.as_channel()
4980    }
4981}
4982
4983impl HostVsockAcceptorProxy {
4984    /// Create a new Proxy for fuchsia.virtualization/HostVsockAcceptor.
4985    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4986        let protocol_name =
4987            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4988        Self { client: fidl::client::Client::new(channel, protocol_name) }
4989    }
4990
4991    /// Get a Stream of events from the remote end of the protocol.
4992    ///
4993    /// # Panics
4994    ///
4995    /// Panics if the event stream was already taken.
4996    pub fn take_event_stream(&self) -> HostVsockAcceptorEventStream {
4997        HostVsockAcceptorEventStream { event_receiver: self.client.take_event_receiver() }
4998    }
4999
5000    pub fn r#accept(
5001        &self,
5002        mut src_cid: u32,
5003        mut src_port: u32,
5004        mut port: u32,
5005    ) -> fidl::client::QueryResponseFut<
5006        HostVsockAcceptorAcceptResult,
5007        fidl::encoding::DefaultFuchsiaResourceDialect,
5008    > {
5009        HostVsockAcceptorProxyInterface::r#accept(self, src_cid, src_port, port)
5010    }
5011}
5012
5013impl HostVsockAcceptorProxyInterface for HostVsockAcceptorProxy {
5014    type AcceptResponseFut = fidl::client::QueryResponseFut<
5015        HostVsockAcceptorAcceptResult,
5016        fidl::encoding::DefaultFuchsiaResourceDialect,
5017    >;
5018    fn r#accept(
5019        &self,
5020        mut src_cid: u32,
5021        mut src_port: u32,
5022        mut port: u32,
5023    ) -> Self::AcceptResponseFut {
5024        fn _decode(
5025            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5026        ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
5027            let _response = fidl::client::decode_transaction_body::<
5028                fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
5029                fidl::encoding::DefaultFuchsiaResourceDialect,
5030                0x6996ed935beaa2d7,
5031            >(_buf?)?;
5032            Ok(_response.map(|x| x.socket))
5033        }
5034        self.client
5035            .send_query_and_decode::<HostVsockAcceptorAcceptRequest, HostVsockAcceptorAcceptResult>(
5036                (src_cid, src_port, port),
5037                0x6996ed935beaa2d7,
5038                fidl::encoding::DynamicFlags::empty(),
5039                _decode,
5040            )
5041    }
5042}
5043
5044pub struct HostVsockAcceptorEventStream {
5045    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5046}
5047
5048impl std::marker::Unpin for HostVsockAcceptorEventStream {}
5049
5050impl futures::stream::FusedStream for HostVsockAcceptorEventStream {
5051    fn is_terminated(&self) -> bool {
5052        self.event_receiver.is_terminated()
5053    }
5054}
5055
5056impl futures::Stream for HostVsockAcceptorEventStream {
5057    type Item = Result<HostVsockAcceptorEvent, fidl::Error>;
5058
5059    fn poll_next(
5060        mut self: std::pin::Pin<&mut Self>,
5061        cx: &mut std::task::Context<'_>,
5062    ) -> std::task::Poll<Option<Self::Item>> {
5063        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5064            &mut self.event_receiver,
5065            cx
5066        )?) {
5067            Some(buf) => std::task::Poll::Ready(Some(HostVsockAcceptorEvent::decode(buf))),
5068            None => std::task::Poll::Ready(None),
5069        }
5070    }
5071}
5072
5073#[derive(Debug)]
5074pub enum HostVsockAcceptorEvent {}
5075
5076impl HostVsockAcceptorEvent {
5077    /// Decodes a message buffer as a [`HostVsockAcceptorEvent`].
5078    fn decode(
5079        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5080    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
5081        let (bytes, _handles) = buf.split_mut();
5082        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5083        debug_assert_eq!(tx_header.tx_id, 0);
5084        match tx_header.ordinal {
5085            _ => Err(fidl::Error::UnknownOrdinal {
5086                ordinal: tx_header.ordinal,
5087                protocol_name:
5088                    <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5089            }),
5090        }
5091    }
5092}
5093
5094/// A Stream of incoming requests for fuchsia.virtualization/HostVsockAcceptor.
5095pub struct HostVsockAcceptorRequestStream {
5096    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5097    is_terminated: bool,
5098}
5099
5100impl std::marker::Unpin for HostVsockAcceptorRequestStream {}
5101
5102impl futures::stream::FusedStream for HostVsockAcceptorRequestStream {
5103    fn is_terminated(&self) -> bool {
5104        self.is_terminated
5105    }
5106}
5107
5108impl fidl::endpoints::RequestStream for HostVsockAcceptorRequestStream {
5109    type Protocol = HostVsockAcceptorMarker;
5110    type ControlHandle = HostVsockAcceptorControlHandle;
5111
5112    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5113        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5114    }
5115
5116    fn control_handle(&self) -> Self::ControlHandle {
5117        HostVsockAcceptorControlHandle { inner: self.inner.clone() }
5118    }
5119
5120    fn into_inner(
5121        self,
5122    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5123    {
5124        (self.inner, self.is_terminated)
5125    }
5126
5127    fn from_inner(
5128        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5129        is_terminated: bool,
5130    ) -> Self {
5131        Self { inner, is_terminated }
5132    }
5133}
5134
5135impl futures::Stream for HostVsockAcceptorRequestStream {
5136    type Item = Result<HostVsockAcceptorRequest, fidl::Error>;
5137
5138    fn poll_next(
5139        mut self: std::pin::Pin<&mut Self>,
5140        cx: &mut std::task::Context<'_>,
5141    ) -> std::task::Poll<Option<Self::Item>> {
5142        let this = &mut *self;
5143        if this.inner.check_shutdown(cx) {
5144            this.is_terminated = true;
5145            return std::task::Poll::Ready(None);
5146        }
5147        if this.is_terminated {
5148            panic!("polled HostVsockAcceptorRequestStream after completion");
5149        }
5150        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5151            |bytes, handles| {
5152                match this.inner.channel().read_etc(cx, bytes, handles) {
5153                    std::task::Poll::Ready(Ok(())) => {}
5154                    std::task::Poll::Pending => return std::task::Poll::Pending,
5155                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5156                        this.is_terminated = true;
5157                        return std::task::Poll::Ready(None);
5158                    }
5159                    std::task::Poll::Ready(Err(e)) => {
5160                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5161                            e.into(),
5162                        ))));
5163                    }
5164                }
5165
5166                // A message has been received from the channel
5167                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5168
5169                std::task::Poll::Ready(Some(match header.ordinal {
5170                    0x6996ed935beaa2d7 => {
5171                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5172                        let mut req = fidl::new_empty!(
5173                            HostVsockAcceptorAcceptRequest,
5174                            fidl::encoding::DefaultFuchsiaResourceDialect
5175                        );
5176                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockAcceptorAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
5177                        let control_handle =
5178                            HostVsockAcceptorControlHandle { inner: this.inner.clone() };
5179                        Ok(HostVsockAcceptorRequest::Accept {
5180                            src_cid: req.src_cid,
5181                            src_port: req.src_port,
5182                            port: req.port,
5183
5184                            responder: HostVsockAcceptorAcceptResponder {
5185                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5186                                tx_id: header.tx_id,
5187                            },
5188                        })
5189                    }
5190                    _ => Err(fidl::Error::UnknownOrdinal {
5191                        ordinal: header.ordinal,
5192                        protocol_name:
5193                            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5194                    }),
5195                }))
5196            },
5197        )
5198    }
5199}
5200
5201/// Exposed by a host capable of listening via vsocks. A variant of a
5202/// `GuestVsockAcceptor` that is responsible for creating the `socket` with which
5203/// to communicate.
5204#[derive(Debug)]
5205pub enum HostVsockAcceptorRequest {
5206    Accept { src_cid: u32, src_port: u32, port: u32, responder: HostVsockAcceptorAcceptResponder },
5207}
5208
5209impl HostVsockAcceptorRequest {
5210    #[allow(irrefutable_let_patterns)]
5211    pub fn into_accept(self) -> Option<(u32, u32, u32, HostVsockAcceptorAcceptResponder)> {
5212        if let HostVsockAcceptorRequest::Accept { src_cid, src_port, port, responder } = self {
5213            Some((src_cid, src_port, port, responder))
5214        } else {
5215            None
5216        }
5217    }
5218
5219    /// Name of the method defined in FIDL
5220    pub fn method_name(&self) -> &'static str {
5221        match *self {
5222            HostVsockAcceptorRequest::Accept { .. } => "accept",
5223        }
5224    }
5225}
5226
5227#[derive(Debug, Clone)]
5228pub struct HostVsockAcceptorControlHandle {
5229    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5230}
5231
5232impl fidl::endpoints::ControlHandle for HostVsockAcceptorControlHandle {
5233    fn shutdown(&self) {
5234        self.inner.shutdown()
5235    }
5236
5237    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5238        self.inner.shutdown_with_epitaph(status)
5239    }
5240
5241    fn is_closed(&self) -> bool {
5242        self.inner.channel().is_closed()
5243    }
5244    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5245        self.inner.channel().on_closed()
5246    }
5247
5248    #[cfg(target_os = "fuchsia")]
5249    fn signal_peer(
5250        &self,
5251        clear_mask: zx::Signals,
5252        set_mask: zx::Signals,
5253    ) -> Result<(), zx_status::Status> {
5254        use fidl::Peered;
5255        self.inner.channel().signal_peer(clear_mask, set_mask)
5256    }
5257}
5258
5259impl HostVsockAcceptorControlHandle {}
5260
5261#[must_use = "FIDL methods require a response to be sent"]
5262#[derive(Debug)]
5263pub struct HostVsockAcceptorAcceptResponder {
5264    control_handle: std::mem::ManuallyDrop<HostVsockAcceptorControlHandle>,
5265    tx_id: u32,
5266}
5267
5268/// Set the the channel to be shutdown (see [`HostVsockAcceptorControlHandle::shutdown`])
5269/// if the responder is dropped without sending a response, so that the client
5270/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5271impl std::ops::Drop for HostVsockAcceptorAcceptResponder {
5272    fn drop(&mut self) {
5273        self.control_handle.shutdown();
5274        // Safety: drops once, never accessed again
5275        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5276    }
5277}
5278
5279impl fidl::endpoints::Responder for HostVsockAcceptorAcceptResponder {
5280    type ControlHandle = HostVsockAcceptorControlHandle;
5281
5282    fn control_handle(&self) -> &HostVsockAcceptorControlHandle {
5283        &self.control_handle
5284    }
5285
5286    fn drop_without_shutdown(mut self) {
5287        // Safety: drops once, never accessed again due to mem::forget
5288        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5289        // Prevent Drop from running (which would shut down the channel)
5290        std::mem::forget(self);
5291    }
5292}
5293
5294impl HostVsockAcceptorAcceptResponder {
5295    /// Sends a response to the FIDL transaction.
5296    ///
5297    /// Sets the channel to shutdown if an error occurs.
5298    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5299        let _result = self.send_raw(result);
5300        if _result.is_err() {
5301            self.control_handle.shutdown();
5302        }
5303        self.drop_without_shutdown();
5304        _result
5305    }
5306
5307    /// Similar to "send" but does not shutdown the channel if an error occurs.
5308    pub fn send_no_shutdown_on_err(
5309        self,
5310        mut result: Result<fidl::Socket, i32>,
5311    ) -> Result<(), fidl::Error> {
5312        let _result = self.send_raw(result);
5313        self.drop_without_shutdown();
5314        _result
5315    }
5316
5317    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5318        self.control_handle
5319            .inner
5320            .send::<fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>>(
5321                result.map(|socket| (socket,)),
5322                self.tx_id,
5323                0x6996ed935beaa2d7,
5324                fidl::encoding::DynamicFlags::empty(),
5325            )
5326    }
5327}
5328
5329#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5330pub struct HostVsockEndpointMarker;
5331
5332impl fidl::endpoints::ProtocolMarker for HostVsockEndpointMarker {
5333    type Proxy = HostVsockEndpointProxy;
5334    type RequestStream = HostVsockEndpointRequestStream;
5335    #[cfg(target_os = "fuchsia")]
5336    type SynchronousProxy = HostVsockEndpointSynchronousProxy;
5337
5338    const DEBUG_NAME: &'static str = "fuchsia.virtualization.HostVsockEndpoint";
5339}
5340impl fidl::endpoints::DiscoverableProtocolMarker for HostVsockEndpointMarker {}
5341pub type HostVsockEndpointListenResult = Result<(), i32>;
5342pub type HostVsockEndpointConnectResult = Result<fidl::Socket, i32>;
5343
5344pub trait HostVsockEndpointProxyInterface: Send + Sync {
5345    type ListenResponseFut: std::future::Future<Output = Result<HostVsockEndpointListenResult, fidl::Error>>
5346        + Send;
5347    fn r#listen(
5348        &self,
5349        port: u32,
5350        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5351    ) -> Self::ListenResponseFut;
5352    type ConnectResponseFut: std::future::Future<Output = Result<HostVsockEndpointConnectResult, fidl::Error>>
5353        + Send;
5354    fn r#connect(&self, guest_port: u32) -> Self::ConnectResponseFut;
5355}
5356#[derive(Debug)]
5357#[cfg(target_os = "fuchsia")]
5358pub struct HostVsockEndpointSynchronousProxy {
5359    client: fidl::client::sync::Client,
5360}
5361
5362#[cfg(target_os = "fuchsia")]
5363impl fidl::endpoints::SynchronousProxy for HostVsockEndpointSynchronousProxy {
5364    type Proxy = HostVsockEndpointProxy;
5365    type Protocol = HostVsockEndpointMarker;
5366
5367    fn from_channel(inner: fidl::Channel) -> Self {
5368        Self::new(inner)
5369    }
5370
5371    fn into_channel(self) -> fidl::Channel {
5372        self.client.into_channel()
5373    }
5374
5375    fn as_channel(&self) -> &fidl::Channel {
5376        self.client.as_channel()
5377    }
5378}
5379
5380#[cfg(target_os = "fuchsia")]
5381impl HostVsockEndpointSynchronousProxy {
5382    pub fn new(channel: fidl::Channel) -> Self {
5383        Self { client: fidl::client::sync::Client::new(channel) }
5384    }
5385
5386    pub fn into_channel(self) -> fidl::Channel {
5387        self.client.into_channel()
5388    }
5389
5390    /// Waits until an event arrives and returns it. It is safe for other
5391    /// threads to make concurrent requests while waiting for an event.
5392    pub fn wait_for_event(
5393        &self,
5394        deadline: zx::MonotonicInstant,
5395    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5396        HostVsockEndpointEvent::decode(
5397            self.client.wait_for_event::<HostVsockEndpointMarker>(deadline)?,
5398        )
5399    }
5400
5401    /// Instructs the device to listen for guest initiated connections to a given port by
5402    /// using `acceptor` when the guest creates a connection.
5403    ///
5404    /// Possible errors:
5405    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5406    pub fn r#listen(
5407        &self,
5408        mut port: u32,
5409        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5410        ___deadline: zx::MonotonicInstant,
5411    ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5412        let _response = self.client.send_query::<
5413            Listener,
5414            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5415            HostVsockEndpointMarker,
5416        >(
5417            (port, acceptor,),
5418            0xfd88f3b4767f2c7,
5419            fidl::encoding::DynamicFlags::empty(),
5420            ___deadline,
5421        )?;
5422        Ok(_response.map(|x| x))
5423    }
5424
5425    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5426    /// ephemeral host port.
5427    ///
5428    /// Possible errors:
5429    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5430    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5431    ///
5432    /// Other errors are related to socket creation, see
5433    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5434    pub fn r#connect(
5435        &self,
5436        mut guest_port: u32,
5437        ___deadline: zx::MonotonicInstant,
5438    ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5439        let _response = self.client.send_query::<
5440            HostVsockEndpointConnectRequest,
5441            fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5442            HostVsockEndpointMarker,
5443        >(
5444            (guest_port,),
5445            0x4d12e10e946b43e4,
5446            fidl::encoding::DynamicFlags::empty(),
5447            ___deadline,
5448        )?;
5449        Ok(_response.map(|x| x.socket))
5450    }
5451}
5452
5453#[cfg(target_os = "fuchsia")]
5454impl From<HostVsockEndpointSynchronousProxy> for zx::NullableHandle {
5455    fn from(value: HostVsockEndpointSynchronousProxy) -> Self {
5456        value.into_channel().into()
5457    }
5458}
5459
5460#[cfg(target_os = "fuchsia")]
5461impl From<fidl::Channel> for HostVsockEndpointSynchronousProxy {
5462    fn from(value: fidl::Channel) -> Self {
5463        Self::new(value)
5464    }
5465}
5466
5467#[cfg(target_os = "fuchsia")]
5468impl fidl::endpoints::FromClient for HostVsockEndpointSynchronousProxy {
5469    type Protocol = HostVsockEndpointMarker;
5470
5471    fn from_client(value: fidl::endpoints::ClientEnd<HostVsockEndpointMarker>) -> Self {
5472        Self::new(value.into_channel())
5473    }
5474}
5475
5476#[derive(Debug, Clone)]
5477pub struct HostVsockEndpointProxy {
5478    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5479}
5480
5481impl fidl::endpoints::Proxy for HostVsockEndpointProxy {
5482    type Protocol = HostVsockEndpointMarker;
5483
5484    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5485        Self::new(inner)
5486    }
5487
5488    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5489        self.client.into_channel().map_err(|client| Self { client })
5490    }
5491
5492    fn as_channel(&self) -> &::fidl::AsyncChannel {
5493        self.client.as_channel()
5494    }
5495}
5496
5497impl HostVsockEndpointProxy {
5498    /// Create a new Proxy for fuchsia.virtualization/HostVsockEndpoint.
5499    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5500        let protocol_name =
5501            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5502        Self { client: fidl::client::Client::new(channel, protocol_name) }
5503    }
5504
5505    /// Get a Stream of events from the remote end of the protocol.
5506    ///
5507    /// # Panics
5508    ///
5509    /// Panics if the event stream was already taken.
5510    pub fn take_event_stream(&self) -> HostVsockEndpointEventStream {
5511        HostVsockEndpointEventStream { event_receiver: self.client.take_event_receiver() }
5512    }
5513
5514    /// Instructs the device to listen for guest initiated connections to a given port by
5515    /// using `acceptor` when the guest creates a connection.
5516    ///
5517    /// Possible errors:
5518    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5519    pub fn r#listen(
5520        &self,
5521        mut port: u32,
5522        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5523    ) -> fidl::client::QueryResponseFut<
5524        HostVsockEndpointListenResult,
5525        fidl::encoding::DefaultFuchsiaResourceDialect,
5526    > {
5527        HostVsockEndpointProxyInterface::r#listen(self, port, acceptor)
5528    }
5529
5530    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5531    /// ephemeral host port.
5532    ///
5533    /// Possible errors:
5534    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5535    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5536    ///
5537    /// Other errors are related to socket creation, see
5538    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5539    pub fn r#connect(
5540        &self,
5541        mut guest_port: u32,
5542    ) -> fidl::client::QueryResponseFut<
5543        HostVsockEndpointConnectResult,
5544        fidl::encoding::DefaultFuchsiaResourceDialect,
5545    > {
5546        HostVsockEndpointProxyInterface::r#connect(self, guest_port)
5547    }
5548}
5549
5550impl HostVsockEndpointProxyInterface for HostVsockEndpointProxy {
5551    type ListenResponseFut = fidl::client::QueryResponseFut<
5552        HostVsockEndpointListenResult,
5553        fidl::encoding::DefaultFuchsiaResourceDialect,
5554    >;
5555    fn r#listen(
5556        &self,
5557        mut port: u32,
5558        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5559    ) -> Self::ListenResponseFut {
5560        fn _decode(
5561            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5562        ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5563            let _response = fidl::client::decode_transaction_body::<
5564                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5565                fidl::encoding::DefaultFuchsiaResourceDialect,
5566                0xfd88f3b4767f2c7,
5567            >(_buf?)?;
5568            Ok(_response.map(|x| x))
5569        }
5570        self.client.send_query_and_decode::<Listener, HostVsockEndpointListenResult>(
5571            (port, acceptor),
5572            0xfd88f3b4767f2c7,
5573            fidl::encoding::DynamicFlags::empty(),
5574            _decode,
5575        )
5576    }
5577
5578    type ConnectResponseFut = fidl::client::QueryResponseFut<
5579        HostVsockEndpointConnectResult,
5580        fidl::encoding::DefaultFuchsiaResourceDialect,
5581    >;
5582    fn r#connect(&self, mut guest_port: u32) -> Self::ConnectResponseFut {
5583        fn _decode(
5584            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5585        ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5586            let _response = fidl::client::decode_transaction_body::<
5587                fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5588                fidl::encoding::DefaultFuchsiaResourceDialect,
5589                0x4d12e10e946b43e4,
5590            >(_buf?)?;
5591            Ok(_response.map(|x| x.socket))
5592        }
5593        self.client.send_query_and_decode::<
5594            HostVsockEndpointConnectRequest,
5595            HostVsockEndpointConnectResult,
5596        >(
5597            (guest_port,),
5598            0x4d12e10e946b43e4,
5599            fidl::encoding::DynamicFlags::empty(),
5600            _decode,
5601        )
5602    }
5603}
5604
5605pub struct HostVsockEndpointEventStream {
5606    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5607}
5608
5609impl std::marker::Unpin for HostVsockEndpointEventStream {}
5610
5611impl futures::stream::FusedStream for HostVsockEndpointEventStream {
5612    fn is_terminated(&self) -> bool {
5613        self.event_receiver.is_terminated()
5614    }
5615}
5616
5617impl futures::Stream for HostVsockEndpointEventStream {
5618    type Item = Result<HostVsockEndpointEvent, fidl::Error>;
5619
5620    fn poll_next(
5621        mut self: std::pin::Pin<&mut Self>,
5622        cx: &mut std::task::Context<'_>,
5623    ) -> std::task::Poll<Option<Self::Item>> {
5624        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5625            &mut self.event_receiver,
5626            cx
5627        )?) {
5628            Some(buf) => std::task::Poll::Ready(Some(HostVsockEndpointEvent::decode(buf))),
5629            None => std::task::Poll::Ready(None),
5630        }
5631    }
5632}
5633
5634#[derive(Debug)]
5635pub enum HostVsockEndpointEvent {}
5636
5637impl HostVsockEndpointEvent {
5638    /// Decodes a message buffer as a [`HostVsockEndpointEvent`].
5639    fn decode(
5640        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5641    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5642        let (bytes, _handles) = buf.split_mut();
5643        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5644        debug_assert_eq!(tx_header.tx_id, 0);
5645        match tx_header.ordinal {
5646            _ => Err(fidl::Error::UnknownOrdinal {
5647                ordinal: tx_header.ordinal,
5648                protocol_name:
5649                    <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5650            }),
5651        }
5652    }
5653}
5654
5655/// A Stream of incoming requests for fuchsia.virtualization/HostVsockEndpoint.
5656pub struct HostVsockEndpointRequestStream {
5657    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5658    is_terminated: bool,
5659}
5660
5661impl std::marker::Unpin for HostVsockEndpointRequestStream {}
5662
5663impl futures::stream::FusedStream for HostVsockEndpointRequestStream {
5664    fn is_terminated(&self) -> bool {
5665        self.is_terminated
5666    }
5667}
5668
5669impl fidl::endpoints::RequestStream for HostVsockEndpointRequestStream {
5670    type Protocol = HostVsockEndpointMarker;
5671    type ControlHandle = HostVsockEndpointControlHandle;
5672
5673    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5674        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5675    }
5676
5677    fn control_handle(&self) -> Self::ControlHandle {
5678        HostVsockEndpointControlHandle { inner: self.inner.clone() }
5679    }
5680
5681    fn into_inner(
5682        self,
5683    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5684    {
5685        (self.inner, self.is_terminated)
5686    }
5687
5688    fn from_inner(
5689        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5690        is_terminated: bool,
5691    ) -> Self {
5692        Self { inner, is_terminated }
5693    }
5694}
5695
5696impl futures::Stream for HostVsockEndpointRequestStream {
5697    type Item = Result<HostVsockEndpointRequest, fidl::Error>;
5698
5699    fn poll_next(
5700        mut self: std::pin::Pin<&mut Self>,
5701        cx: &mut std::task::Context<'_>,
5702    ) -> std::task::Poll<Option<Self::Item>> {
5703        let this = &mut *self;
5704        if this.inner.check_shutdown(cx) {
5705            this.is_terminated = true;
5706            return std::task::Poll::Ready(None);
5707        }
5708        if this.is_terminated {
5709            panic!("polled HostVsockEndpointRequestStream after completion");
5710        }
5711        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5712            |bytes, handles| {
5713                match this.inner.channel().read_etc(cx, bytes, handles) {
5714                    std::task::Poll::Ready(Ok(())) => {}
5715                    std::task::Poll::Pending => return std::task::Poll::Pending,
5716                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5717                        this.is_terminated = true;
5718                        return std::task::Poll::Ready(None);
5719                    }
5720                    std::task::Poll::Ready(Err(e)) => {
5721                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5722                            e.into(),
5723                        ))));
5724                    }
5725                }
5726
5727                // A message has been received from the channel
5728                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5729
5730                std::task::Poll::Ready(Some(match header.ordinal {
5731                    0xfd88f3b4767f2c7 => {
5732                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5733                        let mut req = fidl::new_empty!(
5734                            Listener,
5735                            fidl::encoding::DefaultFuchsiaResourceDialect
5736                        );
5737                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Listener>(&header, _body_bytes, handles, &mut req)?;
5738                        let control_handle =
5739                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5740                        Ok(HostVsockEndpointRequest::Listen {
5741                            port: req.port,
5742                            acceptor: req.acceptor,
5743
5744                            responder: HostVsockEndpointListenResponder {
5745                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5746                                tx_id: header.tx_id,
5747                            },
5748                        })
5749                    }
5750                    0x4d12e10e946b43e4 => {
5751                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5752                        let mut req = fidl::new_empty!(
5753                            HostVsockEndpointConnectRequest,
5754                            fidl::encoding::DefaultFuchsiaResourceDialect
5755                        );
5756                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockEndpointConnectRequest>(&header, _body_bytes, handles, &mut req)?;
5757                        let control_handle =
5758                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5759                        Ok(HostVsockEndpointRequest::Connect {
5760                            guest_port: req.guest_port,
5761
5762                            responder: HostVsockEndpointConnectResponder {
5763                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5764                                tx_id: header.tx_id,
5765                            },
5766                        })
5767                    }
5768                    _ => Err(fidl::Error::UnknownOrdinal {
5769                        ordinal: header.ordinal,
5770                        protocol_name:
5771                            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5772                    }),
5773                }))
5774            },
5775        )
5776    }
5777}
5778
5779/// Exposed by a host to provide the ability for listeners to be multiplexed by
5780/// port and to manage dynamic port allocation for outbound connections.
5781#[derive(Debug)]
5782pub enum HostVsockEndpointRequest {
5783    /// Instructs the device to listen for guest initiated connections to a given port by
5784    /// using `acceptor` when the guest creates a connection.
5785    ///
5786    /// Possible errors:
5787    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5788    Listen {
5789        port: u32,
5790        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5791        responder: HostVsockEndpointListenResponder,
5792    },
5793    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5794    /// ephemeral host port.
5795    ///
5796    /// Possible errors:
5797    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5798    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5799    ///
5800    /// Other errors are related to socket creation, see
5801    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5802    Connect { guest_port: u32, responder: HostVsockEndpointConnectResponder },
5803}
5804
5805impl HostVsockEndpointRequest {
5806    #[allow(irrefutable_let_patterns)]
5807    pub fn into_listen(
5808        self,
5809    ) -> Option<(
5810        u32,
5811        fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5812        HostVsockEndpointListenResponder,
5813    )> {
5814        if let HostVsockEndpointRequest::Listen { port, acceptor, responder } = self {
5815            Some((port, acceptor, responder))
5816        } else {
5817            None
5818        }
5819    }
5820
5821    #[allow(irrefutable_let_patterns)]
5822    pub fn into_connect(self) -> Option<(u32, HostVsockEndpointConnectResponder)> {
5823        if let HostVsockEndpointRequest::Connect { guest_port, responder } = self {
5824            Some((guest_port, responder))
5825        } else {
5826            None
5827        }
5828    }
5829
5830    /// Name of the method defined in FIDL
5831    pub fn method_name(&self) -> &'static str {
5832        match *self {
5833            HostVsockEndpointRequest::Listen { .. } => "listen",
5834            HostVsockEndpointRequest::Connect { .. } => "connect",
5835        }
5836    }
5837}
5838
5839#[derive(Debug, Clone)]
5840pub struct HostVsockEndpointControlHandle {
5841    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5842}
5843
5844impl fidl::endpoints::ControlHandle for HostVsockEndpointControlHandle {
5845    fn shutdown(&self) {
5846        self.inner.shutdown()
5847    }
5848
5849    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5850        self.inner.shutdown_with_epitaph(status)
5851    }
5852
5853    fn is_closed(&self) -> bool {
5854        self.inner.channel().is_closed()
5855    }
5856    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5857        self.inner.channel().on_closed()
5858    }
5859
5860    #[cfg(target_os = "fuchsia")]
5861    fn signal_peer(
5862        &self,
5863        clear_mask: zx::Signals,
5864        set_mask: zx::Signals,
5865    ) -> Result<(), zx_status::Status> {
5866        use fidl::Peered;
5867        self.inner.channel().signal_peer(clear_mask, set_mask)
5868    }
5869}
5870
5871impl HostVsockEndpointControlHandle {}
5872
5873#[must_use = "FIDL methods require a response to be sent"]
5874#[derive(Debug)]
5875pub struct HostVsockEndpointListenResponder {
5876    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5877    tx_id: u32,
5878}
5879
5880/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5881/// if the responder is dropped without sending a response, so that the client
5882/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5883impl std::ops::Drop for HostVsockEndpointListenResponder {
5884    fn drop(&mut self) {
5885        self.control_handle.shutdown();
5886        // Safety: drops once, never accessed again
5887        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5888    }
5889}
5890
5891impl fidl::endpoints::Responder for HostVsockEndpointListenResponder {
5892    type ControlHandle = HostVsockEndpointControlHandle;
5893
5894    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5895        &self.control_handle
5896    }
5897
5898    fn drop_without_shutdown(mut self) {
5899        // Safety: drops once, never accessed again due to mem::forget
5900        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5901        // Prevent Drop from running (which would shut down the channel)
5902        std::mem::forget(self);
5903    }
5904}
5905
5906impl HostVsockEndpointListenResponder {
5907    /// Sends a response to the FIDL transaction.
5908    ///
5909    /// Sets the channel to shutdown if an error occurs.
5910    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5911        let _result = self.send_raw(result);
5912        if _result.is_err() {
5913            self.control_handle.shutdown();
5914        }
5915        self.drop_without_shutdown();
5916        _result
5917    }
5918
5919    /// Similar to "send" but does not shutdown the channel if an error occurs.
5920    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5921        let _result = self.send_raw(result);
5922        self.drop_without_shutdown();
5923        _result
5924    }
5925
5926    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5927        self.control_handle
5928            .inner
5929            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5930                result,
5931                self.tx_id,
5932                0xfd88f3b4767f2c7,
5933                fidl::encoding::DynamicFlags::empty(),
5934            )
5935    }
5936}
5937
5938#[must_use = "FIDL methods require a response to be sent"]
5939#[derive(Debug)]
5940pub struct HostVsockEndpointConnectResponder {
5941    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5942    tx_id: u32,
5943}
5944
5945/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5946/// if the responder is dropped without sending a response, so that the client
5947/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5948impl std::ops::Drop for HostVsockEndpointConnectResponder {
5949    fn drop(&mut self) {
5950        self.control_handle.shutdown();
5951        // Safety: drops once, never accessed again
5952        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5953    }
5954}
5955
5956impl fidl::endpoints::Responder for HostVsockEndpointConnectResponder {
5957    type ControlHandle = HostVsockEndpointControlHandle;
5958
5959    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5960        &self.control_handle
5961    }
5962
5963    fn drop_without_shutdown(mut self) {
5964        // Safety: drops once, never accessed again due to mem::forget
5965        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5966        // Prevent Drop from running (which would shut down the channel)
5967        std::mem::forget(self);
5968    }
5969}
5970
5971impl HostVsockEndpointConnectResponder {
5972    /// Sends a response to the FIDL transaction.
5973    ///
5974    /// Sets the channel to shutdown if an error occurs.
5975    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5976        let _result = self.send_raw(result);
5977        if _result.is_err() {
5978            self.control_handle.shutdown();
5979        }
5980        self.drop_without_shutdown();
5981        _result
5982    }
5983
5984    /// Similar to "send" but does not shutdown the channel if an error occurs.
5985    pub fn send_no_shutdown_on_err(
5986        self,
5987        mut result: Result<fidl::Socket, i32>,
5988    ) -> Result<(), fidl::Error> {
5989        let _result = self.send_raw(result);
5990        self.drop_without_shutdown();
5991        _result
5992    }
5993
5994    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5995        self.control_handle
5996            .inner
5997            .send::<fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>>(
5998                result.map(|socket| (socket,)),
5999                self.tx_id,
6000                0x4d12e10e946b43e4,
6001                fidl::encoding::DynamicFlags::empty(),
6002            )
6003    }
6004}
6005
6006#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6007pub struct LinuxManagerMarker;
6008
6009impl fidl::endpoints::ProtocolMarker for LinuxManagerMarker {
6010    type Proxy = LinuxManagerProxy;
6011    type RequestStream = LinuxManagerRequestStream;
6012    #[cfg(target_os = "fuchsia")]
6013    type SynchronousProxy = LinuxManagerSynchronousProxy;
6014
6015    const DEBUG_NAME: &'static str = "fuchsia.virtualization.LinuxManager";
6016}
6017impl fidl::endpoints::DiscoverableProtocolMarker for LinuxManagerMarker {}
6018pub type LinuxManagerStartAndGetLinuxGuestInfoResult = Result<LinuxGuestInfo, i32>;
6019pub type LinuxManagerWipeDataResult = Result<(), i32>;
6020
6021pub trait LinuxManagerProxyInterface: Send + Sync {
6022    type StartAndGetLinuxGuestInfoResponseFut: std::future::Future<
6023            Output = Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error>,
6024        > + Send;
6025    fn r#start_and_get_linux_guest_info(
6026        &self,
6027        label: &str,
6028    ) -> Self::StartAndGetLinuxGuestInfoResponseFut;
6029    type WipeDataResponseFut: std::future::Future<Output = Result<LinuxManagerWipeDataResult, fidl::Error>>
6030        + Send;
6031    fn r#wipe_data(&self) -> Self::WipeDataResponseFut;
6032    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error>;
6033}
6034#[derive(Debug)]
6035#[cfg(target_os = "fuchsia")]
6036pub struct LinuxManagerSynchronousProxy {
6037    client: fidl::client::sync::Client,
6038}
6039
6040#[cfg(target_os = "fuchsia")]
6041impl fidl::endpoints::SynchronousProxy for LinuxManagerSynchronousProxy {
6042    type Proxy = LinuxManagerProxy;
6043    type Protocol = LinuxManagerMarker;
6044
6045    fn from_channel(inner: fidl::Channel) -> Self {
6046        Self::new(inner)
6047    }
6048
6049    fn into_channel(self) -> fidl::Channel {
6050        self.client.into_channel()
6051    }
6052
6053    fn as_channel(&self) -> &fidl::Channel {
6054        self.client.as_channel()
6055    }
6056}
6057
6058#[cfg(target_os = "fuchsia")]
6059impl LinuxManagerSynchronousProxy {
6060    pub fn new(channel: fidl::Channel) -> Self {
6061        Self { client: fidl::client::sync::Client::new(channel) }
6062    }
6063
6064    pub fn into_channel(self) -> fidl::Channel {
6065        self.client.into_channel()
6066    }
6067
6068    /// Waits until an event arrives and returns it. It is safe for other
6069    /// threads to make concurrent requests while waiting for an event.
6070    pub fn wait_for_event(
6071        &self,
6072        deadline: zx::MonotonicInstant,
6073    ) -> Result<LinuxManagerEvent, fidl::Error> {
6074        LinuxManagerEvent::decode(self.client.wait_for_event::<LinuxManagerMarker>(deadline)?)
6075    }
6076
6077    /// Get Linux guest environment info.
6078    ///
6079    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6080    pub fn r#start_and_get_linux_guest_info(
6081        &self,
6082        mut label: &str,
6083        ___deadline: zx::MonotonicInstant,
6084    ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6085        let _response = self.client.send_query::<
6086            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6087            fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6088            LinuxManagerMarker,
6089        >(
6090            (label,),
6091            0x11809ced100a2bea,
6092            fidl::encoding::DynamicFlags::empty(),
6093            ___deadline,
6094        )?;
6095        Ok(_response.map(|x| x.info))
6096    }
6097
6098    /// Clears the stateful data. This includes any installed containers and any user data
6099    /// they may contain.
6100    ///
6101    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6102    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6103    /// operation.
6104    pub fn r#wipe_data(
6105        &self,
6106        ___deadline: zx::MonotonicInstant,
6107    ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6108        let _response = self.client.send_query::<
6109            fidl::encoding::EmptyPayload,
6110            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6111            LinuxManagerMarker,
6112        >(
6113            (),
6114            0x732c69394548a76a,
6115            fidl::encoding::DynamicFlags::empty(),
6116            ___deadline,
6117        )?;
6118        Ok(_response.map(|x| x))
6119    }
6120
6121    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6122    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6123    /// the epitaph) before attempting to launch another guest.
6124    ///
6125    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6126    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6127    /// a component crash).
6128    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6129        self.client.send::<fidl::encoding::EmptyPayload>(
6130            (),
6131            0x5dab12b50bc9909d,
6132            fidl::encoding::DynamicFlags::empty(),
6133        )
6134    }
6135}
6136
6137#[cfg(target_os = "fuchsia")]
6138impl From<LinuxManagerSynchronousProxy> for zx::NullableHandle {
6139    fn from(value: LinuxManagerSynchronousProxy) -> Self {
6140        value.into_channel().into()
6141    }
6142}
6143
6144#[cfg(target_os = "fuchsia")]
6145impl From<fidl::Channel> for LinuxManagerSynchronousProxy {
6146    fn from(value: fidl::Channel) -> Self {
6147        Self::new(value)
6148    }
6149}
6150
6151#[cfg(target_os = "fuchsia")]
6152impl fidl::endpoints::FromClient for LinuxManagerSynchronousProxy {
6153    type Protocol = LinuxManagerMarker;
6154
6155    fn from_client(value: fidl::endpoints::ClientEnd<LinuxManagerMarker>) -> Self {
6156        Self::new(value.into_channel())
6157    }
6158}
6159
6160#[derive(Debug, Clone)]
6161pub struct LinuxManagerProxy {
6162    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6163}
6164
6165impl fidl::endpoints::Proxy for LinuxManagerProxy {
6166    type Protocol = LinuxManagerMarker;
6167
6168    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6169        Self::new(inner)
6170    }
6171
6172    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6173        self.client.into_channel().map_err(|client| Self { client })
6174    }
6175
6176    fn as_channel(&self) -> &::fidl::AsyncChannel {
6177        self.client.as_channel()
6178    }
6179}
6180
6181impl LinuxManagerProxy {
6182    /// Create a new Proxy for fuchsia.virtualization/LinuxManager.
6183    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6184        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6185        Self { client: fidl::client::Client::new(channel, protocol_name) }
6186    }
6187
6188    /// Get a Stream of events from the remote end of the protocol.
6189    ///
6190    /// # Panics
6191    ///
6192    /// Panics if the event stream was already taken.
6193    pub fn take_event_stream(&self) -> LinuxManagerEventStream {
6194        LinuxManagerEventStream { event_receiver: self.client.take_event_receiver() }
6195    }
6196
6197    /// Get Linux guest environment info.
6198    ///
6199    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6200    pub fn r#start_and_get_linux_guest_info(
6201        &self,
6202        mut label: &str,
6203    ) -> fidl::client::QueryResponseFut<
6204        LinuxManagerStartAndGetLinuxGuestInfoResult,
6205        fidl::encoding::DefaultFuchsiaResourceDialect,
6206    > {
6207        LinuxManagerProxyInterface::r#start_and_get_linux_guest_info(self, label)
6208    }
6209
6210    /// Clears the stateful data. This includes any installed containers and any user data
6211    /// they may contain.
6212    ///
6213    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6214    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6215    /// operation.
6216    pub fn r#wipe_data(
6217        &self,
6218    ) -> fidl::client::QueryResponseFut<
6219        LinuxManagerWipeDataResult,
6220        fidl::encoding::DefaultFuchsiaResourceDialect,
6221    > {
6222        LinuxManagerProxyInterface::r#wipe_data(self)
6223    }
6224
6225    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6226    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6227    /// the epitaph) before attempting to launch another guest.
6228    ///
6229    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6230    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6231    /// a component crash).
6232    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6233        LinuxManagerProxyInterface::r#graceful_shutdown(self)
6234    }
6235}
6236
6237impl LinuxManagerProxyInterface for LinuxManagerProxy {
6238    type StartAndGetLinuxGuestInfoResponseFut = fidl::client::QueryResponseFut<
6239        LinuxManagerStartAndGetLinuxGuestInfoResult,
6240        fidl::encoding::DefaultFuchsiaResourceDialect,
6241    >;
6242    fn r#start_and_get_linux_guest_info(
6243        &self,
6244        mut label: &str,
6245    ) -> Self::StartAndGetLinuxGuestInfoResponseFut {
6246        fn _decode(
6247            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6248        ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6249            let _response = fidl::client::decode_transaction_body::<
6250                fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6251                fidl::encoding::DefaultFuchsiaResourceDialect,
6252                0x11809ced100a2bea,
6253            >(_buf?)?;
6254            Ok(_response.map(|x| x.info))
6255        }
6256        self.client.send_query_and_decode::<
6257            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6258            LinuxManagerStartAndGetLinuxGuestInfoResult,
6259        >(
6260            (label,),
6261            0x11809ced100a2bea,
6262            fidl::encoding::DynamicFlags::empty(),
6263            _decode,
6264        )
6265    }
6266
6267    type WipeDataResponseFut = fidl::client::QueryResponseFut<
6268        LinuxManagerWipeDataResult,
6269        fidl::encoding::DefaultFuchsiaResourceDialect,
6270    >;
6271    fn r#wipe_data(&self) -> Self::WipeDataResponseFut {
6272        fn _decode(
6273            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6274        ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6275            let _response = fidl::client::decode_transaction_body::<
6276                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6277                fidl::encoding::DefaultFuchsiaResourceDialect,
6278                0x732c69394548a76a,
6279            >(_buf?)?;
6280            Ok(_response.map(|x| x))
6281        }
6282        self.client
6283            .send_query_and_decode::<fidl::encoding::EmptyPayload, LinuxManagerWipeDataResult>(
6284                (),
6285                0x732c69394548a76a,
6286                fidl::encoding::DynamicFlags::empty(),
6287                _decode,
6288            )
6289    }
6290
6291    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6292        self.client.send::<fidl::encoding::EmptyPayload>(
6293            (),
6294            0x5dab12b50bc9909d,
6295            fidl::encoding::DynamicFlags::empty(),
6296        )
6297    }
6298}
6299
6300pub struct LinuxManagerEventStream {
6301    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6302}
6303
6304impl std::marker::Unpin for LinuxManagerEventStream {}
6305
6306impl futures::stream::FusedStream for LinuxManagerEventStream {
6307    fn is_terminated(&self) -> bool {
6308        self.event_receiver.is_terminated()
6309    }
6310}
6311
6312impl futures::Stream for LinuxManagerEventStream {
6313    type Item = Result<LinuxManagerEvent, fidl::Error>;
6314
6315    fn poll_next(
6316        mut self: std::pin::Pin<&mut Self>,
6317        cx: &mut std::task::Context<'_>,
6318    ) -> std::task::Poll<Option<Self::Item>> {
6319        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6320            &mut self.event_receiver,
6321            cx
6322        )?) {
6323            Some(buf) => std::task::Poll::Ready(Some(LinuxManagerEvent::decode(buf))),
6324            None => std::task::Poll::Ready(None),
6325        }
6326    }
6327}
6328
6329#[derive(Debug)]
6330pub enum LinuxManagerEvent {
6331    OnGuestInfoChanged { label: String, info: LinuxGuestInfo },
6332}
6333
6334impl LinuxManagerEvent {
6335    #[allow(irrefutable_let_patterns)]
6336    pub fn into_on_guest_info_changed(self) -> Option<(String, LinuxGuestInfo)> {
6337        if let LinuxManagerEvent::OnGuestInfoChanged { label, info } = self {
6338            Some((label, info))
6339        } else {
6340            None
6341        }
6342    }
6343
6344    /// Decodes a message buffer as a [`LinuxManagerEvent`].
6345    fn decode(
6346        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6347    ) -> Result<LinuxManagerEvent, fidl::Error> {
6348        let (bytes, _handles) = buf.split_mut();
6349        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6350        debug_assert_eq!(tx_header.tx_id, 0);
6351        match tx_header.ordinal {
6352            0x30a9be4c43d6a2d6 => {
6353                let mut out = fidl::new_empty!(
6354                    LinuxManagerOnGuestInfoChangedRequest,
6355                    fidl::encoding::DefaultFuchsiaResourceDialect
6356                );
6357                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerOnGuestInfoChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6358                Ok((LinuxManagerEvent::OnGuestInfoChanged { label: out.label, info: out.info }))
6359            }
6360            _ => Err(fidl::Error::UnknownOrdinal {
6361                ordinal: tx_header.ordinal,
6362                protocol_name: <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6363            }),
6364        }
6365    }
6366}
6367
6368/// A Stream of incoming requests for fuchsia.virtualization/LinuxManager.
6369pub struct LinuxManagerRequestStream {
6370    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6371    is_terminated: bool,
6372}
6373
6374impl std::marker::Unpin for LinuxManagerRequestStream {}
6375
6376impl futures::stream::FusedStream for LinuxManagerRequestStream {
6377    fn is_terminated(&self) -> bool {
6378        self.is_terminated
6379    }
6380}
6381
6382impl fidl::endpoints::RequestStream for LinuxManagerRequestStream {
6383    type Protocol = LinuxManagerMarker;
6384    type ControlHandle = LinuxManagerControlHandle;
6385
6386    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6387        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6388    }
6389
6390    fn control_handle(&self) -> Self::ControlHandle {
6391        LinuxManagerControlHandle { inner: self.inner.clone() }
6392    }
6393
6394    fn into_inner(
6395        self,
6396    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6397    {
6398        (self.inner, self.is_terminated)
6399    }
6400
6401    fn from_inner(
6402        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6403        is_terminated: bool,
6404    ) -> Self {
6405        Self { inner, is_terminated }
6406    }
6407}
6408
6409impl futures::Stream for LinuxManagerRequestStream {
6410    type Item = Result<LinuxManagerRequest, fidl::Error>;
6411
6412    fn poll_next(
6413        mut self: std::pin::Pin<&mut Self>,
6414        cx: &mut std::task::Context<'_>,
6415    ) -> std::task::Poll<Option<Self::Item>> {
6416        let this = &mut *self;
6417        if this.inner.check_shutdown(cx) {
6418            this.is_terminated = true;
6419            return std::task::Poll::Ready(None);
6420        }
6421        if this.is_terminated {
6422            panic!("polled LinuxManagerRequestStream after completion");
6423        }
6424        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6425            |bytes, handles| {
6426                match this.inner.channel().read_etc(cx, bytes, handles) {
6427                    std::task::Poll::Ready(Ok(())) => {}
6428                    std::task::Poll::Pending => return std::task::Poll::Pending,
6429                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6430                        this.is_terminated = true;
6431                        return std::task::Poll::Ready(None);
6432                    }
6433                    std::task::Poll::Ready(Err(e)) => {
6434                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6435                            e.into(),
6436                        ))));
6437                    }
6438                }
6439
6440                // A message has been received from the channel
6441                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6442
6443                std::task::Poll::Ready(Some(match header.ordinal {
6444                    0x11809ced100a2bea => {
6445                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6446                        let mut req = fidl::new_empty!(
6447                            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6448                            fidl::encoding::DefaultFuchsiaResourceDialect
6449                        );
6450                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerStartAndGetLinuxGuestInfoRequest>(&header, _body_bytes, handles, &mut req)?;
6451                        let control_handle =
6452                            LinuxManagerControlHandle { inner: this.inner.clone() };
6453                        Ok(LinuxManagerRequest::StartAndGetLinuxGuestInfo {
6454                            label: req.label,
6455
6456                            responder: LinuxManagerStartAndGetLinuxGuestInfoResponder {
6457                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6458                                tx_id: header.tx_id,
6459                            },
6460                        })
6461                    }
6462                    0x732c69394548a76a => {
6463                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6464                        let mut req = fidl::new_empty!(
6465                            fidl::encoding::EmptyPayload,
6466                            fidl::encoding::DefaultFuchsiaResourceDialect
6467                        );
6468                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6469                        let control_handle =
6470                            LinuxManagerControlHandle { inner: this.inner.clone() };
6471                        Ok(LinuxManagerRequest::WipeData {
6472                            responder: LinuxManagerWipeDataResponder {
6473                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6474                                tx_id: header.tx_id,
6475                            },
6476                        })
6477                    }
6478                    0x5dab12b50bc9909d => {
6479                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6480                        let mut req = fidl::new_empty!(
6481                            fidl::encoding::EmptyPayload,
6482                            fidl::encoding::DefaultFuchsiaResourceDialect
6483                        );
6484                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6485                        let control_handle =
6486                            LinuxManagerControlHandle { inner: this.inner.clone() };
6487                        Ok(LinuxManagerRequest::GracefulShutdown { control_handle })
6488                    }
6489                    _ => Err(fidl::Error::UnknownOrdinal {
6490                        ordinal: header.ordinal,
6491                        protocol_name:
6492                            <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6493                    }),
6494                }))
6495            },
6496        )
6497    }
6498}
6499
6500/// A `LinuxManager` provides access to the status of Linux guest instances.
6501#[derive(Debug)]
6502pub enum LinuxManagerRequest {
6503    /// Get Linux guest environment info.
6504    ///
6505    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6506    StartAndGetLinuxGuestInfo {
6507        label: String,
6508        responder: LinuxManagerStartAndGetLinuxGuestInfoResponder,
6509    },
6510    /// Clears the stateful data. This includes any installed containers and any user data
6511    /// they may contain.
6512    ///
6513    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6514    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6515    /// operation.
6516    WipeData { responder: LinuxManagerWipeDataResponder },
6517    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6518    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6519    /// the epitaph) before attempting to launch another guest.
6520    ///
6521    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6522    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6523    /// a component crash).
6524    GracefulShutdown { control_handle: LinuxManagerControlHandle },
6525}
6526
6527impl LinuxManagerRequest {
6528    #[allow(irrefutable_let_patterns)]
6529    pub fn into_start_and_get_linux_guest_info(
6530        self,
6531    ) -> Option<(String, LinuxManagerStartAndGetLinuxGuestInfoResponder)> {
6532        if let LinuxManagerRequest::StartAndGetLinuxGuestInfo { label, responder } = self {
6533            Some((label, responder))
6534        } else {
6535            None
6536        }
6537    }
6538
6539    #[allow(irrefutable_let_patterns)]
6540    pub fn into_wipe_data(self) -> Option<(LinuxManagerWipeDataResponder)> {
6541        if let LinuxManagerRequest::WipeData { responder } = self {
6542            Some((responder))
6543        } else {
6544            None
6545        }
6546    }
6547
6548    #[allow(irrefutable_let_patterns)]
6549    pub fn into_graceful_shutdown(self) -> Option<(LinuxManagerControlHandle)> {
6550        if let LinuxManagerRequest::GracefulShutdown { control_handle } = self {
6551            Some((control_handle))
6552        } else {
6553            None
6554        }
6555    }
6556
6557    /// Name of the method defined in FIDL
6558    pub fn method_name(&self) -> &'static str {
6559        match *self {
6560            LinuxManagerRequest::StartAndGetLinuxGuestInfo { .. } => {
6561                "start_and_get_linux_guest_info"
6562            }
6563            LinuxManagerRequest::WipeData { .. } => "wipe_data",
6564            LinuxManagerRequest::GracefulShutdown { .. } => "graceful_shutdown",
6565        }
6566    }
6567}
6568
6569#[derive(Debug, Clone)]
6570pub struct LinuxManagerControlHandle {
6571    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6572}
6573
6574impl fidl::endpoints::ControlHandle for LinuxManagerControlHandle {
6575    fn shutdown(&self) {
6576        self.inner.shutdown()
6577    }
6578
6579    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6580        self.inner.shutdown_with_epitaph(status)
6581    }
6582
6583    fn is_closed(&self) -> bool {
6584        self.inner.channel().is_closed()
6585    }
6586    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6587        self.inner.channel().on_closed()
6588    }
6589
6590    #[cfg(target_os = "fuchsia")]
6591    fn signal_peer(
6592        &self,
6593        clear_mask: zx::Signals,
6594        set_mask: zx::Signals,
6595    ) -> Result<(), zx_status::Status> {
6596        use fidl::Peered;
6597        self.inner.channel().signal_peer(clear_mask, set_mask)
6598    }
6599}
6600
6601impl LinuxManagerControlHandle {
6602    pub fn send_on_guest_info_changed(
6603        &self,
6604        mut label: &str,
6605        mut info: &LinuxGuestInfo,
6606    ) -> Result<(), fidl::Error> {
6607        self.inner.send::<LinuxManagerOnGuestInfoChangedRequest>(
6608            (label, info),
6609            0,
6610            0x30a9be4c43d6a2d6,
6611            fidl::encoding::DynamicFlags::empty(),
6612        )
6613    }
6614}
6615
6616#[must_use = "FIDL methods require a response to be sent"]
6617#[derive(Debug)]
6618pub struct LinuxManagerStartAndGetLinuxGuestInfoResponder {
6619    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6620    tx_id: u32,
6621}
6622
6623/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6624/// if the responder is dropped without sending a response, so that the client
6625/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6626impl std::ops::Drop for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6627    fn drop(&mut self) {
6628        self.control_handle.shutdown();
6629        // Safety: drops once, never accessed again
6630        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6631    }
6632}
6633
6634impl fidl::endpoints::Responder for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6635    type ControlHandle = LinuxManagerControlHandle;
6636
6637    fn control_handle(&self) -> &LinuxManagerControlHandle {
6638        &self.control_handle
6639    }
6640
6641    fn drop_without_shutdown(mut self) {
6642        // Safety: drops once, never accessed again due to mem::forget
6643        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6644        // Prevent Drop from running (which would shut down the channel)
6645        std::mem::forget(self);
6646    }
6647}
6648
6649impl LinuxManagerStartAndGetLinuxGuestInfoResponder {
6650    /// Sends a response to the FIDL transaction.
6651    ///
6652    /// Sets the channel to shutdown if an error occurs.
6653    pub fn send(self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6654        let _result = self.send_raw(result);
6655        if _result.is_err() {
6656            self.control_handle.shutdown();
6657        }
6658        self.drop_without_shutdown();
6659        _result
6660    }
6661
6662    /// Similar to "send" but does not shutdown the channel if an error occurs.
6663    pub fn send_no_shutdown_on_err(
6664        self,
6665        mut result: Result<&LinuxGuestInfo, i32>,
6666    ) -> Result<(), fidl::Error> {
6667        let _result = self.send_raw(result);
6668        self.drop_without_shutdown();
6669        _result
6670    }
6671
6672    fn send_raw(&self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6673        self.control_handle.inner.send::<fidl::encoding::ResultType<
6674            LinuxManagerStartAndGetLinuxGuestInfoResponse,
6675            i32,
6676        >>(
6677            result.map(|info| (info,)),
6678            self.tx_id,
6679            0x11809ced100a2bea,
6680            fidl::encoding::DynamicFlags::empty(),
6681        )
6682    }
6683}
6684
6685#[must_use = "FIDL methods require a response to be sent"]
6686#[derive(Debug)]
6687pub struct LinuxManagerWipeDataResponder {
6688    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6689    tx_id: u32,
6690}
6691
6692/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6693/// if the responder is dropped without sending a response, so that the client
6694/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6695impl std::ops::Drop for LinuxManagerWipeDataResponder {
6696    fn drop(&mut self) {
6697        self.control_handle.shutdown();
6698        // Safety: drops once, never accessed again
6699        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6700    }
6701}
6702
6703impl fidl::endpoints::Responder for LinuxManagerWipeDataResponder {
6704    type ControlHandle = LinuxManagerControlHandle;
6705
6706    fn control_handle(&self) -> &LinuxManagerControlHandle {
6707        &self.control_handle
6708    }
6709
6710    fn drop_without_shutdown(mut self) {
6711        // Safety: drops once, never accessed again due to mem::forget
6712        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6713        // Prevent Drop from running (which would shut down the channel)
6714        std::mem::forget(self);
6715    }
6716}
6717
6718impl LinuxManagerWipeDataResponder {
6719    /// Sends a response to the FIDL transaction.
6720    ///
6721    /// Sets the channel to shutdown if an error occurs.
6722    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6723        let _result = self.send_raw(result);
6724        if _result.is_err() {
6725            self.control_handle.shutdown();
6726        }
6727        self.drop_without_shutdown();
6728        _result
6729    }
6730
6731    /// Similar to "send" but does not shutdown the channel if an error occurs.
6732    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6733        let _result = self.send_raw(result);
6734        self.drop_without_shutdown();
6735        _result
6736    }
6737
6738    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6739        self.control_handle
6740            .inner
6741            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6742                result,
6743                self.tx_id,
6744                0x732c69394548a76a,
6745                fidl::encoding::DynamicFlags::empty(),
6746            )
6747    }
6748}
6749
6750#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6751pub struct MemControllerMarker;
6752
6753impl fidl::endpoints::ProtocolMarker for MemControllerMarker {
6754    type Proxy = MemControllerProxy;
6755    type RequestStream = MemControllerRequestStream;
6756    #[cfg(target_os = "fuchsia")]
6757    type SynchronousProxy = MemControllerSynchronousProxy;
6758
6759    const DEBUG_NAME: &'static str = "fuchsia.virtualization.MemController";
6760}
6761impl fidl::endpoints::DiscoverableProtocolMarker for MemControllerMarker {}
6762
6763pub trait MemControllerProxyInterface: Send + Sync {
6764    type GetMemSizeResponseFut: std::future::Future<Output = Result<(u64, u64, u64, u64, u64), fidl::Error>>
6765        + Send;
6766    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut;
6767    fn r#request_size(&self, requested_size: u64) -> Result<(), fidl::Error>;
6768}
6769#[derive(Debug)]
6770#[cfg(target_os = "fuchsia")]
6771pub struct MemControllerSynchronousProxy {
6772    client: fidl::client::sync::Client,
6773}
6774
6775#[cfg(target_os = "fuchsia")]
6776impl fidl::endpoints::SynchronousProxy for MemControllerSynchronousProxy {
6777    type Proxy = MemControllerProxy;
6778    type Protocol = MemControllerMarker;
6779
6780    fn from_channel(inner: fidl::Channel) -> Self {
6781        Self::new(inner)
6782    }
6783
6784    fn into_channel(self) -> fidl::Channel {
6785        self.client.into_channel()
6786    }
6787
6788    fn as_channel(&self) -> &fidl::Channel {
6789        self.client.as_channel()
6790    }
6791}
6792
6793#[cfg(target_os = "fuchsia")]
6794impl MemControllerSynchronousProxy {
6795    pub fn new(channel: fidl::Channel) -> Self {
6796        Self { client: fidl::client::sync::Client::new(channel) }
6797    }
6798
6799    pub fn into_channel(self) -> fidl::Channel {
6800        self.client.into_channel()
6801    }
6802
6803    /// Waits until an event arrives and returns it. It is safe for other
6804    /// threads to make concurrent requests while waiting for an event.
6805    pub fn wait_for_event(
6806        &self,
6807        deadline: zx::MonotonicInstant,
6808    ) -> Result<MemControllerEvent, fidl::Error> {
6809        MemControllerEvent::decode(self.client.wait_for_event::<MemControllerMarker>(deadline)?)
6810    }
6811
6812    /// Get the configured region size, usable region size, plugged size and requestd size
6813    ///
6814    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6815    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6816    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6817    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6818    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6819    /// memory region.
6820    /// requested_size is the requested amount of plugged memory within the usable device-managed
6821    /// memory region.
6822    pub fn r#get_mem_size(
6823        &self,
6824        ___deadline: zx::MonotonicInstant,
6825    ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6826        let _response = self.client.send_query::<
6827            fidl::encoding::EmptyPayload,
6828            MemControllerGetMemSizeResponse,
6829            MemControllerMarker,
6830        >(
6831            (),
6832            0x6e9d496f9b66ea56,
6833            fidl::encoding::DynamicFlags::empty(),
6834            ___deadline,
6835        )?;
6836        Ok((
6837            _response.block_size,
6838            _response.region_size,
6839            _response.usable_region_size,
6840            _response.plugged_size,
6841            _response.requested_size,
6842        ))
6843    }
6844
6845    /// Update the requested size to plug or unplug memory
6846    ///
6847    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6848    /// configuration changed) by (un)plugging memory blocks.
6849    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6850        self.client.send::<MemControllerRequestSizeRequest>(
6851            (requested_size,),
6852            0x12f8e2cc21ee8102,
6853            fidl::encoding::DynamicFlags::empty(),
6854        )
6855    }
6856}
6857
6858#[cfg(target_os = "fuchsia")]
6859impl From<MemControllerSynchronousProxy> for zx::NullableHandle {
6860    fn from(value: MemControllerSynchronousProxy) -> Self {
6861        value.into_channel().into()
6862    }
6863}
6864
6865#[cfg(target_os = "fuchsia")]
6866impl From<fidl::Channel> for MemControllerSynchronousProxy {
6867    fn from(value: fidl::Channel) -> Self {
6868        Self::new(value)
6869    }
6870}
6871
6872#[cfg(target_os = "fuchsia")]
6873impl fidl::endpoints::FromClient for MemControllerSynchronousProxy {
6874    type Protocol = MemControllerMarker;
6875
6876    fn from_client(value: fidl::endpoints::ClientEnd<MemControllerMarker>) -> Self {
6877        Self::new(value.into_channel())
6878    }
6879}
6880
6881#[derive(Debug, Clone)]
6882pub struct MemControllerProxy {
6883    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6884}
6885
6886impl fidl::endpoints::Proxy for MemControllerProxy {
6887    type Protocol = MemControllerMarker;
6888
6889    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6890        Self::new(inner)
6891    }
6892
6893    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6894        self.client.into_channel().map_err(|client| Self { client })
6895    }
6896
6897    fn as_channel(&self) -> &::fidl::AsyncChannel {
6898        self.client.as_channel()
6899    }
6900}
6901
6902impl MemControllerProxy {
6903    /// Create a new Proxy for fuchsia.virtualization/MemController.
6904    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6905        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6906        Self { client: fidl::client::Client::new(channel, protocol_name) }
6907    }
6908
6909    /// Get a Stream of events from the remote end of the protocol.
6910    ///
6911    /// # Panics
6912    ///
6913    /// Panics if the event stream was already taken.
6914    pub fn take_event_stream(&self) -> MemControllerEventStream {
6915        MemControllerEventStream { event_receiver: self.client.take_event_receiver() }
6916    }
6917
6918    /// Get the configured region size, usable region size, plugged size and requestd size
6919    ///
6920    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6921    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6922    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6923    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6924    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6925    /// memory region.
6926    /// requested_size is the requested amount of plugged memory within the usable device-managed
6927    /// memory region.
6928    pub fn r#get_mem_size(
6929        &self,
6930    ) -> fidl::client::QueryResponseFut<
6931        (u64, u64, u64, u64, u64),
6932        fidl::encoding::DefaultFuchsiaResourceDialect,
6933    > {
6934        MemControllerProxyInterface::r#get_mem_size(self)
6935    }
6936
6937    /// Update the requested size to plug or unplug memory
6938    ///
6939    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6940    /// configuration changed) by (un)plugging memory blocks.
6941    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6942        MemControllerProxyInterface::r#request_size(self, requested_size)
6943    }
6944}
6945
6946impl MemControllerProxyInterface for MemControllerProxy {
6947    type GetMemSizeResponseFut = fidl::client::QueryResponseFut<
6948        (u64, u64, u64, u64, u64),
6949        fidl::encoding::DefaultFuchsiaResourceDialect,
6950    >;
6951    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut {
6952        fn _decode(
6953            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6954        ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6955            let _response = fidl::client::decode_transaction_body::<
6956                MemControllerGetMemSizeResponse,
6957                fidl::encoding::DefaultFuchsiaResourceDialect,
6958                0x6e9d496f9b66ea56,
6959            >(_buf?)?;
6960            Ok((
6961                _response.block_size,
6962                _response.region_size,
6963                _response.usable_region_size,
6964                _response.plugged_size,
6965                _response.requested_size,
6966            ))
6967        }
6968        self.client
6969            .send_query_and_decode::<fidl::encoding::EmptyPayload, (u64, u64, u64, u64, u64)>(
6970                (),
6971                0x6e9d496f9b66ea56,
6972                fidl::encoding::DynamicFlags::empty(),
6973                _decode,
6974            )
6975    }
6976
6977    fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6978        self.client.send::<MemControllerRequestSizeRequest>(
6979            (requested_size,),
6980            0x12f8e2cc21ee8102,
6981            fidl::encoding::DynamicFlags::empty(),
6982        )
6983    }
6984}
6985
6986pub struct MemControllerEventStream {
6987    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6988}
6989
6990impl std::marker::Unpin for MemControllerEventStream {}
6991
6992impl futures::stream::FusedStream for MemControllerEventStream {
6993    fn is_terminated(&self) -> bool {
6994        self.event_receiver.is_terminated()
6995    }
6996}
6997
6998impl futures::Stream for MemControllerEventStream {
6999    type Item = Result<MemControllerEvent, fidl::Error>;
7000
7001    fn poll_next(
7002        mut self: std::pin::Pin<&mut Self>,
7003        cx: &mut std::task::Context<'_>,
7004    ) -> std::task::Poll<Option<Self::Item>> {
7005        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7006            &mut self.event_receiver,
7007            cx
7008        )?) {
7009            Some(buf) => std::task::Poll::Ready(Some(MemControllerEvent::decode(buf))),
7010            None => std::task::Poll::Ready(None),
7011        }
7012    }
7013}
7014
7015#[derive(Debug)]
7016pub enum MemControllerEvent {}
7017
7018impl MemControllerEvent {
7019    /// Decodes a message buffer as a [`MemControllerEvent`].
7020    fn decode(
7021        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7022    ) -> Result<MemControllerEvent, fidl::Error> {
7023        let (bytes, _handles) = buf.split_mut();
7024        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7025        debug_assert_eq!(tx_header.tx_id, 0);
7026        match tx_header.ordinal {
7027            _ => Err(fidl::Error::UnknownOrdinal {
7028                ordinal: tx_header.ordinal,
7029                protocol_name: <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7030            }),
7031        }
7032    }
7033}
7034
7035/// A Stream of incoming requests for fuchsia.virtualization/MemController.
7036pub struct MemControllerRequestStream {
7037    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7038    is_terminated: bool,
7039}
7040
7041impl std::marker::Unpin for MemControllerRequestStream {}
7042
7043impl futures::stream::FusedStream for MemControllerRequestStream {
7044    fn is_terminated(&self) -> bool {
7045        self.is_terminated
7046    }
7047}
7048
7049impl fidl::endpoints::RequestStream for MemControllerRequestStream {
7050    type Protocol = MemControllerMarker;
7051    type ControlHandle = MemControllerControlHandle;
7052
7053    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7054        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7055    }
7056
7057    fn control_handle(&self) -> Self::ControlHandle {
7058        MemControllerControlHandle { inner: self.inner.clone() }
7059    }
7060
7061    fn into_inner(
7062        self,
7063    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7064    {
7065        (self.inner, self.is_terminated)
7066    }
7067
7068    fn from_inner(
7069        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7070        is_terminated: bool,
7071    ) -> Self {
7072        Self { inner, is_terminated }
7073    }
7074}
7075
7076impl futures::Stream for MemControllerRequestStream {
7077    type Item = Result<MemControllerRequest, fidl::Error>;
7078
7079    fn poll_next(
7080        mut self: std::pin::Pin<&mut Self>,
7081        cx: &mut std::task::Context<'_>,
7082    ) -> std::task::Poll<Option<Self::Item>> {
7083        let this = &mut *self;
7084        if this.inner.check_shutdown(cx) {
7085            this.is_terminated = true;
7086            return std::task::Poll::Ready(None);
7087        }
7088        if this.is_terminated {
7089            panic!("polled MemControllerRequestStream after completion");
7090        }
7091        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7092            |bytes, handles| {
7093                match this.inner.channel().read_etc(cx, bytes, handles) {
7094                    std::task::Poll::Ready(Ok(())) => {}
7095                    std::task::Poll::Pending => return std::task::Poll::Pending,
7096                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7097                        this.is_terminated = true;
7098                        return std::task::Poll::Ready(None);
7099                    }
7100                    std::task::Poll::Ready(Err(e)) => {
7101                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7102                            e.into(),
7103                        ))));
7104                    }
7105                }
7106
7107                // A message has been received from the channel
7108                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7109
7110                std::task::Poll::Ready(Some(match header.ordinal {
7111                    0x6e9d496f9b66ea56 => {
7112                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7113                        let mut req = fidl::new_empty!(
7114                            fidl::encoding::EmptyPayload,
7115                            fidl::encoding::DefaultFuchsiaResourceDialect
7116                        );
7117                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7118                        let control_handle =
7119                            MemControllerControlHandle { inner: this.inner.clone() };
7120                        Ok(MemControllerRequest::GetMemSize {
7121                            responder: MemControllerGetMemSizeResponder {
7122                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7123                                tx_id: header.tx_id,
7124                            },
7125                        })
7126                    }
7127                    0x12f8e2cc21ee8102 => {
7128                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7129                        let mut req = fidl::new_empty!(
7130                            MemControllerRequestSizeRequest,
7131                            fidl::encoding::DefaultFuchsiaResourceDialect
7132                        );
7133                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MemControllerRequestSizeRequest>(&header, _body_bytes, handles, &mut req)?;
7134                        let control_handle =
7135                            MemControllerControlHandle { inner: this.inner.clone() };
7136                        Ok(MemControllerRequest::RequestSize {
7137                            requested_size: req.requested_size,
7138
7139                            control_handle,
7140                        })
7141                    }
7142                    _ => Err(fidl::Error::UnknownOrdinal {
7143                        ordinal: header.ordinal,
7144                        protocol_name:
7145                            <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7146                    }),
7147                }))
7148            },
7149        )
7150    }
7151}
7152
7153/// A `MemController` controls a guest's virtio-mem
7154#[derive(Debug)]
7155pub enum MemControllerRequest {
7156    /// Get the configured region size, usable region size, plugged size and requestd size
7157    ///
7158    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
7159    /// region_size is the size of device-managed memory region in bytes. Cannot change.
7160    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
7161    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
7162    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
7163    /// memory region.
7164    /// requested_size is the requested amount of plugged memory within the usable device-managed
7165    /// memory region.
7166    GetMemSize { responder: MemControllerGetMemSizeResponder },
7167    /// Update the requested size to plug or unplug memory
7168    ///
7169    /// The driver SHOULD react to resize requests from the device (requested_size in the device
7170    /// configuration changed) by (un)plugging memory blocks.
7171    RequestSize { requested_size: u64, control_handle: MemControllerControlHandle },
7172}
7173
7174impl MemControllerRequest {
7175    #[allow(irrefutable_let_patterns)]
7176    pub fn into_get_mem_size(self) -> Option<(MemControllerGetMemSizeResponder)> {
7177        if let MemControllerRequest::GetMemSize { responder } = self {
7178            Some((responder))
7179        } else {
7180            None
7181        }
7182    }
7183
7184    #[allow(irrefutable_let_patterns)]
7185    pub fn into_request_size(self) -> Option<(u64, MemControllerControlHandle)> {
7186        if let MemControllerRequest::RequestSize { requested_size, control_handle } = self {
7187            Some((requested_size, control_handle))
7188        } else {
7189            None
7190        }
7191    }
7192
7193    /// Name of the method defined in FIDL
7194    pub fn method_name(&self) -> &'static str {
7195        match *self {
7196            MemControllerRequest::GetMemSize { .. } => "get_mem_size",
7197            MemControllerRequest::RequestSize { .. } => "request_size",
7198        }
7199    }
7200}
7201
7202#[derive(Debug, Clone)]
7203pub struct MemControllerControlHandle {
7204    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7205}
7206
7207impl fidl::endpoints::ControlHandle for MemControllerControlHandle {
7208    fn shutdown(&self) {
7209        self.inner.shutdown()
7210    }
7211
7212    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7213        self.inner.shutdown_with_epitaph(status)
7214    }
7215
7216    fn is_closed(&self) -> bool {
7217        self.inner.channel().is_closed()
7218    }
7219    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7220        self.inner.channel().on_closed()
7221    }
7222
7223    #[cfg(target_os = "fuchsia")]
7224    fn signal_peer(
7225        &self,
7226        clear_mask: zx::Signals,
7227        set_mask: zx::Signals,
7228    ) -> Result<(), zx_status::Status> {
7229        use fidl::Peered;
7230        self.inner.channel().signal_peer(clear_mask, set_mask)
7231    }
7232}
7233
7234impl MemControllerControlHandle {}
7235
7236#[must_use = "FIDL methods require a response to be sent"]
7237#[derive(Debug)]
7238pub struct MemControllerGetMemSizeResponder {
7239    control_handle: std::mem::ManuallyDrop<MemControllerControlHandle>,
7240    tx_id: u32,
7241}
7242
7243/// Set the the channel to be shutdown (see [`MemControllerControlHandle::shutdown`])
7244/// if the responder is dropped without sending a response, so that the client
7245/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7246impl std::ops::Drop for MemControllerGetMemSizeResponder {
7247    fn drop(&mut self) {
7248        self.control_handle.shutdown();
7249        // Safety: drops once, never accessed again
7250        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7251    }
7252}
7253
7254impl fidl::endpoints::Responder for MemControllerGetMemSizeResponder {
7255    type ControlHandle = MemControllerControlHandle;
7256
7257    fn control_handle(&self) -> &MemControllerControlHandle {
7258        &self.control_handle
7259    }
7260
7261    fn drop_without_shutdown(mut self) {
7262        // Safety: drops once, never accessed again due to mem::forget
7263        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7264        // Prevent Drop from running (which would shut down the channel)
7265        std::mem::forget(self);
7266    }
7267}
7268
7269impl MemControllerGetMemSizeResponder {
7270    /// Sends a response to the FIDL transaction.
7271    ///
7272    /// Sets the channel to shutdown if an error occurs.
7273    pub fn send(
7274        self,
7275        mut block_size: u64,
7276        mut region_size: u64,
7277        mut usable_region_size: u64,
7278        mut plugged_size: u64,
7279        mut requested_size: u64,
7280    ) -> Result<(), fidl::Error> {
7281        let _result = self.send_raw(
7282            block_size,
7283            region_size,
7284            usable_region_size,
7285            plugged_size,
7286            requested_size,
7287        );
7288        if _result.is_err() {
7289            self.control_handle.shutdown();
7290        }
7291        self.drop_without_shutdown();
7292        _result
7293    }
7294
7295    /// Similar to "send" but does not shutdown the channel if an error occurs.
7296    pub fn send_no_shutdown_on_err(
7297        self,
7298        mut block_size: u64,
7299        mut region_size: u64,
7300        mut usable_region_size: u64,
7301        mut plugged_size: u64,
7302        mut requested_size: u64,
7303    ) -> Result<(), fidl::Error> {
7304        let _result = self.send_raw(
7305            block_size,
7306            region_size,
7307            usable_region_size,
7308            plugged_size,
7309            requested_size,
7310        );
7311        self.drop_without_shutdown();
7312        _result
7313    }
7314
7315    fn send_raw(
7316        &self,
7317        mut block_size: u64,
7318        mut region_size: u64,
7319        mut usable_region_size: u64,
7320        mut plugged_size: u64,
7321        mut requested_size: u64,
7322    ) -> Result<(), fidl::Error> {
7323        self.control_handle.inner.send::<MemControllerGetMemSizeResponse>(
7324            (block_size, region_size, usable_region_size, plugged_size, requested_size),
7325            self.tx_id,
7326            0x6e9d496f9b66ea56,
7327            fidl::encoding::DynamicFlags::empty(),
7328        )
7329    }
7330}
7331
7332#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7333pub struct TerminaGuestManagerMarker;
7334
7335impl fidl::endpoints::ProtocolMarker for TerminaGuestManagerMarker {
7336    type Proxy = TerminaGuestManagerProxy;
7337    type RequestStream = TerminaGuestManagerRequestStream;
7338    #[cfg(target_os = "fuchsia")]
7339    type SynchronousProxy = TerminaGuestManagerSynchronousProxy;
7340
7341    const DEBUG_NAME: &'static str = "fuchsia.virtualization.TerminaGuestManager";
7342}
7343impl fidl::endpoints::DiscoverableProtocolMarker for TerminaGuestManagerMarker {}
7344
7345pub trait TerminaGuestManagerProxyInterface: Send + Sync {
7346    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
7347        + Send;
7348    fn r#launch(
7349        &self,
7350        guest_config: GuestConfig,
7351        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7352    ) -> Self::LaunchResponseFut;
7353    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7354    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
7355    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
7356        + Send;
7357    fn r#connect(
7358        &self,
7359        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7360    ) -> Self::ConnectResponseFut;
7361    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
7362    fn r#get_info(&self) -> Self::GetInfoResponseFut;
7363}
7364#[derive(Debug)]
7365#[cfg(target_os = "fuchsia")]
7366pub struct TerminaGuestManagerSynchronousProxy {
7367    client: fidl::client::sync::Client,
7368}
7369
7370#[cfg(target_os = "fuchsia")]
7371impl fidl::endpoints::SynchronousProxy for TerminaGuestManagerSynchronousProxy {
7372    type Proxy = TerminaGuestManagerProxy;
7373    type Protocol = TerminaGuestManagerMarker;
7374
7375    fn from_channel(inner: fidl::Channel) -> Self {
7376        Self::new(inner)
7377    }
7378
7379    fn into_channel(self) -> fidl::Channel {
7380        self.client.into_channel()
7381    }
7382
7383    fn as_channel(&self) -> &fidl::Channel {
7384        self.client.as_channel()
7385    }
7386}
7387
7388#[cfg(target_os = "fuchsia")]
7389impl TerminaGuestManagerSynchronousProxy {
7390    pub fn new(channel: fidl::Channel) -> Self {
7391        Self { client: fidl::client::sync::Client::new(channel) }
7392    }
7393
7394    pub fn into_channel(self) -> fidl::Channel {
7395        self.client.into_channel()
7396    }
7397
7398    /// Waits until an event arrives and returns it. It is safe for other
7399    /// threads to make concurrent requests while waiting for an event.
7400    pub fn wait_for_event(
7401        &self,
7402        deadline: zx::MonotonicInstant,
7403    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7404        TerminaGuestManagerEvent::decode(
7405            self.client.wait_for_event::<TerminaGuestManagerMarker>(deadline)?,
7406        )
7407    }
7408
7409    /// Launch a new guest instance.
7410    ///
7411    /// Possible errors:
7412    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7413    ///         problems detected by the guest manager.
7414    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7415    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7416    ///         component logs for a more specific failure.
7417    pub fn r#launch(
7418        &self,
7419        mut guest_config: GuestConfig,
7420        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7421        ___deadline: zx::MonotonicInstant,
7422    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7423        let _response =
7424            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
7425                fidl::encoding::EmptyStruct,
7426                GuestManagerError,
7427            >, TerminaGuestManagerMarker>(
7428                (&mut guest_config, controller),
7429                0x394a2e29f750323e,
7430                fidl::encoding::DynamicFlags::empty(),
7431                ___deadline,
7432            )?;
7433        Ok(_response.map(|x| x))
7434    }
7435
7436    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7437    /// be used to launch another guest.
7438    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
7439        let _response = self.client.send_query::<
7440            fidl::encoding::EmptyPayload,
7441            fidl::encoding::EmptyPayload,
7442            TerminaGuestManagerMarker,
7443        >(
7444            (),
7445            0x3ad9a012982f872d,
7446            fidl::encoding::DynamicFlags::empty(),
7447            ___deadline,
7448        )?;
7449        Ok(_response)
7450    }
7451
7452    /// Connect to a currently running guest.
7453    ///
7454    /// Possible errors:
7455    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7456    ///         has launched before attempting to reconnect.
7457    pub fn r#connect(
7458        &self,
7459        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7460        ___deadline: zx::MonotonicInstant,
7461    ) -> Result<GuestManagerConnectResult, fidl::Error> {
7462        let _response =
7463            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
7464                fidl::encoding::EmptyStruct,
7465                GuestManagerError,
7466            >, TerminaGuestManagerMarker>(
7467                (controller,),
7468                0x4e489076e3bb15b4,
7469                fidl::encoding::DynamicFlags::empty(),
7470                ___deadline,
7471            )?;
7472        Ok(_response.map(|x| x))
7473    }
7474
7475    /// Query guest info
7476    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
7477        let _response = self.client.send_query::<
7478            fidl::encoding::EmptyPayload,
7479            GuestManagerGetInfoResponse,
7480            TerminaGuestManagerMarker,
7481        >(
7482            (),
7483            0x76892614aea695dc,
7484            fidl::encoding::DynamicFlags::empty(),
7485            ___deadline,
7486        )?;
7487        Ok(_response.guest_info)
7488    }
7489}
7490
7491#[cfg(target_os = "fuchsia")]
7492impl From<TerminaGuestManagerSynchronousProxy> for zx::NullableHandle {
7493    fn from(value: TerminaGuestManagerSynchronousProxy) -> Self {
7494        value.into_channel().into()
7495    }
7496}
7497
7498#[cfg(target_os = "fuchsia")]
7499impl From<fidl::Channel> for TerminaGuestManagerSynchronousProxy {
7500    fn from(value: fidl::Channel) -> Self {
7501        Self::new(value)
7502    }
7503}
7504
7505#[cfg(target_os = "fuchsia")]
7506impl fidl::endpoints::FromClient for TerminaGuestManagerSynchronousProxy {
7507    type Protocol = TerminaGuestManagerMarker;
7508
7509    fn from_client(value: fidl::endpoints::ClientEnd<TerminaGuestManagerMarker>) -> Self {
7510        Self::new(value.into_channel())
7511    }
7512}
7513
7514#[derive(Debug, Clone)]
7515pub struct TerminaGuestManagerProxy {
7516    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7517}
7518
7519impl fidl::endpoints::Proxy for TerminaGuestManagerProxy {
7520    type Protocol = TerminaGuestManagerMarker;
7521
7522    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7523        Self::new(inner)
7524    }
7525
7526    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7527        self.client.into_channel().map_err(|client| Self { client })
7528    }
7529
7530    fn as_channel(&self) -> &::fidl::AsyncChannel {
7531        self.client.as_channel()
7532    }
7533}
7534
7535impl TerminaGuestManagerProxy {
7536    /// Create a new Proxy for fuchsia.virtualization/TerminaGuestManager.
7537    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7538        let protocol_name =
7539            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7540        Self { client: fidl::client::Client::new(channel, protocol_name) }
7541    }
7542
7543    /// Get a Stream of events from the remote end of the protocol.
7544    ///
7545    /// # Panics
7546    ///
7547    /// Panics if the event stream was already taken.
7548    pub fn take_event_stream(&self) -> TerminaGuestManagerEventStream {
7549        TerminaGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
7550    }
7551
7552    /// Launch a new guest instance.
7553    ///
7554    /// Possible errors:
7555    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7556    ///         problems detected by the guest manager.
7557    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7558    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7559    ///         component logs for a more specific failure.
7560    pub fn r#launch(
7561        &self,
7562        mut guest_config: GuestConfig,
7563        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7564    ) -> fidl::client::QueryResponseFut<
7565        GuestManagerLaunchResult,
7566        fidl::encoding::DefaultFuchsiaResourceDialect,
7567    > {
7568        TerminaGuestManagerProxyInterface::r#launch(self, guest_config, controller)
7569    }
7570
7571    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7572    /// be used to launch another guest.
7573    pub fn r#force_shutdown(
7574        &self,
7575    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7576        TerminaGuestManagerProxyInterface::r#force_shutdown(self)
7577    }
7578
7579    /// Connect to a currently running guest.
7580    ///
7581    /// Possible errors:
7582    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7583    ///         has launched before attempting to reconnect.
7584    pub fn r#connect(
7585        &self,
7586        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7587    ) -> fidl::client::QueryResponseFut<
7588        GuestManagerConnectResult,
7589        fidl::encoding::DefaultFuchsiaResourceDialect,
7590    > {
7591        TerminaGuestManagerProxyInterface::r#connect(self, controller)
7592    }
7593
7594    /// Query guest info
7595    pub fn r#get_info(
7596        &self,
7597    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
7598    {
7599        TerminaGuestManagerProxyInterface::r#get_info(self)
7600    }
7601}
7602
7603impl TerminaGuestManagerProxyInterface for TerminaGuestManagerProxy {
7604    type LaunchResponseFut = fidl::client::QueryResponseFut<
7605        GuestManagerLaunchResult,
7606        fidl::encoding::DefaultFuchsiaResourceDialect,
7607    >;
7608    fn r#launch(
7609        &self,
7610        mut guest_config: GuestConfig,
7611        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7612    ) -> Self::LaunchResponseFut {
7613        fn _decode(
7614            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7615        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7616            let _response = fidl::client::decode_transaction_body::<
7617                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7618                fidl::encoding::DefaultFuchsiaResourceDialect,
7619                0x394a2e29f750323e,
7620            >(_buf?)?;
7621            Ok(_response.map(|x| x))
7622        }
7623        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
7624            (&mut guest_config, controller),
7625            0x394a2e29f750323e,
7626            fidl::encoding::DynamicFlags::empty(),
7627            _decode,
7628        )
7629    }
7630
7631    type ForceShutdownResponseFut =
7632        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7633    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
7634        fn _decode(
7635            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7636        ) -> Result<(), fidl::Error> {
7637            let _response = fidl::client::decode_transaction_body::<
7638                fidl::encoding::EmptyPayload,
7639                fidl::encoding::DefaultFuchsiaResourceDialect,
7640                0x3ad9a012982f872d,
7641            >(_buf?)?;
7642            Ok(_response)
7643        }
7644        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7645            (),
7646            0x3ad9a012982f872d,
7647            fidl::encoding::DynamicFlags::empty(),
7648            _decode,
7649        )
7650    }
7651
7652    type ConnectResponseFut = fidl::client::QueryResponseFut<
7653        GuestManagerConnectResult,
7654        fidl::encoding::DefaultFuchsiaResourceDialect,
7655    >;
7656    fn r#connect(
7657        &self,
7658        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7659    ) -> Self::ConnectResponseFut {
7660        fn _decode(
7661            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7662        ) -> Result<GuestManagerConnectResult, fidl::Error> {
7663            let _response = fidl::client::decode_transaction_body::<
7664                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7665                fidl::encoding::DefaultFuchsiaResourceDialect,
7666                0x4e489076e3bb15b4,
7667            >(_buf?)?;
7668            Ok(_response.map(|x| x))
7669        }
7670        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
7671            (controller,),
7672            0x4e489076e3bb15b4,
7673            fidl::encoding::DynamicFlags::empty(),
7674            _decode,
7675        )
7676    }
7677
7678    type GetInfoResponseFut =
7679        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
7680    fn r#get_info(&self) -> Self::GetInfoResponseFut {
7681        fn _decode(
7682            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7683        ) -> Result<GuestInfo, fidl::Error> {
7684            let _response = fidl::client::decode_transaction_body::<
7685                GuestManagerGetInfoResponse,
7686                fidl::encoding::DefaultFuchsiaResourceDialect,
7687                0x76892614aea695dc,
7688            >(_buf?)?;
7689            Ok(_response.guest_info)
7690        }
7691        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
7692            (),
7693            0x76892614aea695dc,
7694            fidl::encoding::DynamicFlags::empty(),
7695            _decode,
7696        )
7697    }
7698}
7699
7700pub struct TerminaGuestManagerEventStream {
7701    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7702}
7703
7704impl std::marker::Unpin for TerminaGuestManagerEventStream {}
7705
7706impl futures::stream::FusedStream for TerminaGuestManagerEventStream {
7707    fn is_terminated(&self) -> bool {
7708        self.event_receiver.is_terminated()
7709    }
7710}
7711
7712impl futures::Stream for TerminaGuestManagerEventStream {
7713    type Item = Result<TerminaGuestManagerEvent, fidl::Error>;
7714
7715    fn poll_next(
7716        mut self: std::pin::Pin<&mut Self>,
7717        cx: &mut std::task::Context<'_>,
7718    ) -> std::task::Poll<Option<Self::Item>> {
7719        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7720            &mut self.event_receiver,
7721            cx
7722        )?) {
7723            Some(buf) => std::task::Poll::Ready(Some(TerminaGuestManagerEvent::decode(buf))),
7724            None => std::task::Poll::Ready(None),
7725        }
7726    }
7727}
7728
7729#[derive(Debug)]
7730pub enum TerminaGuestManagerEvent {}
7731
7732impl TerminaGuestManagerEvent {
7733    /// Decodes a message buffer as a [`TerminaGuestManagerEvent`].
7734    fn decode(
7735        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7736    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7737        let (bytes, _handles) = buf.split_mut();
7738        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7739        debug_assert_eq!(tx_header.tx_id, 0);
7740        match tx_header.ordinal {
7741            _ => Err(fidl::Error::UnknownOrdinal {
7742                ordinal: tx_header.ordinal,
7743                protocol_name:
7744                    <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7745            }),
7746        }
7747    }
7748}
7749
7750/// A Stream of incoming requests for fuchsia.virtualization/TerminaGuestManager.
7751pub struct TerminaGuestManagerRequestStream {
7752    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7753    is_terminated: bool,
7754}
7755
7756impl std::marker::Unpin for TerminaGuestManagerRequestStream {}
7757
7758impl futures::stream::FusedStream for TerminaGuestManagerRequestStream {
7759    fn is_terminated(&self) -> bool {
7760        self.is_terminated
7761    }
7762}
7763
7764impl fidl::endpoints::RequestStream for TerminaGuestManagerRequestStream {
7765    type Protocol = TerminaGuestManagerMarker;
7766    type ControlHandle = TerminaGuestManagerControlHandle;
7767
7768    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7769        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7770    }
7771
7772    fn control_handle(&self) -> Self::ControlHandle {
7773        TerminaGuestManagerControlHandle { inner: self.inner.clone() }
7774    }
7775
7776    fn into_inner(
7777        self,
7778    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7779    {
7780        (self.inner, self.is_terminated)
7781    }
7782
7783    fn from_inner(
7784        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7785        is_terminated: bool,
7786    ) -> Self {
7787        Self { inner, is_terminated }
7788    }
7789}
7790
7791impl futures::Stream for TerminaGuestManagerRequestStream {
7792    type Item = Result<TerminaGuestManagerRequest, fidl::Error>;
7793
7794    fn poll_next(
7795        mut self: std::pin::Pin<&mut Self>,
7796        cx: &mut std::task::Context<'_>,
7797    ) -> std::task::Poll<Option<Self::Item>> {
7798        let this = &mut *self;
7799        if this.inner.check_shutdown(cx) {
7800            this.is_terminated = true;
7801            return std::task::Poll::Ready(None);
7802        }
7803        if this.is_terminated {
7804            panic!("polled TerminaGuestManagerRequestStream after completion");
7805        }
7806        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7807            |bytes, handles| {
7808                match this.inner.channel().read_etc(cx, bytes, handles) {
7809                    std::task::Poll::Ready(Ok(())) => {}
7810                    std::task::Poll::Pending => return std::task::Poll::Pending,
7811                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7812                        this.is_terminated = true;
7813                        return std::task::Poll::Ready(None);
7814                    }
7815                    std::task::Poll::Ready(Err(e)) => {
7816                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7817                            e.into(),
7818                        ))));
7819                    }
7820                }
7821
7822                // A message has been received from the channel
7823                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7824
7825                std::task::Poll::Ready(Some(match header.ordinal {
7826                0x394a2e29f750323e => {
7827                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7828                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7829                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
7830                    let control_handle = TerminaGuestManagerControlHandle {
7831                        inner: this.inner.clone(),
7832                    };
7833                    Ok(TerminaGuestManagerRequest::Launch {guest_config: req.guest_config,
7834controller: req.controller,
7835
7836                        responder: TerminaGuestManagerLaunchResponder {
7837                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7838                            tx_id: header.tx_id,
7839                        },
7840                    })
7841                }
7842                0x3ad9a012982f872d => {
7843                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7844                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7845                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7846                    let control_handle = TerminaGuestManagerControlHandle {
7847                        inner: this.inner.clone(),
7848                    };
7849                    Ok(TerminaGuestManagerRequest::ForceShutdown {
7850                        responder: TerminaGuestManagerForceShutdownResponder {
7851                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7852                            tx_id: header.tx_id,
7853                        },
7854                    })
7855                }
7856                0x4e489076e3bb15b4 => {
7857                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7858                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7859                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
7860                    let control_handle = TerminaGuestManagerControlHandle {
7861                        inner: this.inner.clone(),
7862                    };
7863                    Ok(TerminaGuestManagerRequest::Connect {controller: req.controller,
7864
7865                        responder: TerminaGuestManagerConnectResponder {
7866                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7867                            tx_id: header.tx_id,
7868                        },
7869                    })
7870                }
7871                0x76892614aea695dc => {
7872                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7873                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7874                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7875                    let control_handle = TerminaGuestManagerControlHandle {
7876                        inner: this.inner.clone(),
7877                    };
7878                    Ok(TerminaGuestManagerRequest::GetInfo {
7879                        responder: TerminaGuestManagerGetInfoResponder {
7880                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7881                            tx_id: header.tx_id,
7882                        },
7883                    })
7884                }
7885                _ => Err(fidl::Error::UnknownOrdinal {
7886                    ordinal: header.ordinal,
7887                    protocol_name: <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7888                }),
7889            }))
7890            },
7891        )
7892    }
7893}
7894
7895#[derive(Debug)]
7896pub enum TerminaGuestManagerRequest {
7897    /// Launch a new guest instance.
7898    ///
7899    /// Possible errors:
7900    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7901    ///         problems detected by the guest manager.
7902    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7903    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7904    ///         component logs for a more specific failure.
7905    Launch {
7906        guest_config: GuestConfig,
7907        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7908        responder: TerminaGuestManagerLaunchResponder,
7909    },
7910    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7911    /// be used to launch another guest.
7912    ForceShutdown { responder: TerminaGuestManagerForceShutdownResponder },
7913    /// Connect to a currently running guest.
7914    ///
7915    /// Possible errors:
7916    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7917    ///         has launched before attempting to reconnect.
7918    Connect {
7919        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7920        responder: TerminaGuestManagerConnectResponder,
7921    },
7922    /// Query guest info
7923    GetInfo { responder: TerminaGuestManagerGetInfoResponder },
7924}
7925
7926impl TerminaGuestManagerRequest {
7927    #[allow(irrefutable_let_patterns)]
7928    pub fn into_launch(
7929        self,
7930    ) -> Option<(
7931        GuestConfig,
7932        fidl::endpoints::ServerEnd<GuestMarker>,
7933        TerminaGuestManagerLaunchResponder,
7934    )> {
7935        if let TerminaGuestManagerRequest::Launch { guest_config, controller, responder } = self {
7936            Some((guest_config, controller, responder))
7937        } else {
7938            None
7939        }
7940    }
7941
7942    #[allow(irrefutable_let_patterns)]
7943    pub fn into_force_shutdown(self) -> Option<(TerminaGuestManagerForceShutdownResponder)> {
7944        if let TerminaGuestManagerRequest::ForceShutdown { responder } = self {
7945            Some((responder))
7946        } else {
7947            None
7948        }
7949    }
7950
7951    #[allow(irrefutable_let_patterns)]
7952    pub fn into_connect(
7953        self,
7954    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, TerminaGuestManagerConnectResponder)>
7955    {
7956        if let TerminaGuestManagerRequest::Connect { controller, responder } = self {
7957            Some((controller, responder))
7958        } else {
7959            None
7960        }
7961    }
7962
7963    #[allow(irrefutable_let_patterns)]
7964    pub fn into_get_info(self) -> Option<(TerminaGuestManagerGetInfoResponder)> {
7965        if let TerminaGuestManagerRequest::GetInfo { responder } = self {
7966            Some((responder))
7967        } else {
7968            None
7969        }
7970    }
7971
7972    /// Name of the method defined in FIDL
7973    pub fn method_name(&self) -> &'static str {
7974        match *self {
7975            TerminaGuestManagerRequest::Launch { .. } => "launch",
7976            TerminaGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
7977            TerminaGuestManagerRequest::Connect { .. } => "connect",
7978            TerminaGuestManagerRequest::GetInfo { .. } => "get_info",
7979        }
7980    }
7981}
7982
7983#[derive(Debug, Clone)]
7984pub struct TerminaGuestManagerControlHandle {
7985    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7986}
7987
7988impl fidl::endpoints::ControlHandle for TerminaGuestManagerControlHandle {
7989    fn shutdown(&self) {
7990        self.inner.shutdown()
7991    }
7992
7993    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7994        self.inner.shutdown_with_epitaph(status)
7995    }
7996
7997    fn is_closed(&self) -> bool {
7998        self.inner.channel().is_closed()
7999    }
8000    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8001        self.inner.channel().on_closed()
8002    }
8003
8004    #[cfg(target_os = "fuchsia")]
8005    fn signal_peer(
8006        &self,
8007        clear_mask: zx::Signals,
8008        set_mask: zx::Signals,
8009    ) -> Result<(), zx_status::Status> {
8010        use fidl::Peered;
8011        self.inner.channel().signal_peer(clear_mask, set_mask)
8012    }
8013}
8014
8015impl TerminaGuestManagerControlHandle {}
8016
8017#[must_use = "FIDL methods require a response to be sent"]
8018#[derive(Debug)]
8019pub struct TerminaGuestManagerLaunchResponder {
8020    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8021    tx_id: u32,
8022}
8023
8024/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8025/// if the responder is dropped without sending a response, so that the client
8026/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8027impl std::ops::Drop for TerminaGuestManagerLaunchResponder {
8028    fn drop(&mut self) {
8029        self.control_handle.shutdown();
8030        // Safety: drops once, never accessed again
8031        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8032    }
8033}
8034
8035impl fidl::endpoints::Responder for TerminaGuestManagerLaunchResponder {
8036    type ControlHandle = TerminaGuestManagerControlHandle;
8037
8038    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8039        &self.control_handle
8040    }
8041
8042    fn drop_without_shutdown(mut self) {
8043        // Safety: drops once, never accessed again due to mem::forget
8044        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8045        // Prevent Drop from running (which would shut down the channel)
8046        std::mem::forget(self);
8047    }
8048}
8049
8050impl TerminaGuestManagerLaunchResponder {
8051    /// Sends a response to the FIDL transaction.
8052    ///
8053    /// Sets the channel to shutdown if an error occurs.
8054    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8055        let _result = self.send_raw(result);
8056        if _result.is_err() {
8057            self.control_handle.shutdown();
8058        }
8059        self.drop_without_shutdown();
8060        _result
8061    }
8062
8063    /// Similar to "send" but does not shutdown the channel if an error occurs.
8064    pub fn send_no_shutdown_on_err(
8065        self,
8066        mut result: Result<(), GuestManagerError>,
8067    ) -> Result<(), fidl::Error> {
8068        let _result = self.send_raw(result);
8069        self.drop_without_shutdown();
8070        _result
8071    }
8072
8073    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8074        self.control_handle.inner.send::<fidl::encoding::ResultType<
8075            fidl::encoding::EmptyStruct,
8076            GuestManagerError,
8077        >>(
8078            result,
8079            self.tx_id,
8080            0x394a2e29f750323e,
8081            fidl::encoding::DynamicFlags::empty(),
8082        )
8083    }
8084}
8085
8086#[must_use = "FIDL methods require a response to be sent"]
8087#[derive(Debug)]
8088pub struct TerminaGuestManagerForceShutdownResponder {
8089    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8090    tx_id: u32,
8091}
8092
8093/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8094/// if the responder is dropped without sending a response, so that the client
8095/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8096impl std::ops::Drop for TerminaGuestManagerForceShutdownResponder {
8097    fn drop(&mut self) {
8098        self.control_handle.shutdown();
8099        // Safety: drops once, never accessed again
8100        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8101    }
8102}
8103
8104impl fidl::endpoints::Responder for TerminaGuestManagerForceShutdownResponder {
8105    type ControlHandle = TerminaGuestManagerControlHandle;
8106
8107    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8108        &self.control_handle
8109    }
8110
8111    fn drop_without_shutdown(mut self) {
8112        // Safety: drops once, never accessed again due to mem::forget
8113        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8114        // Prevent Drop from running (which would shut down the channel)
8115        std::mem::forget(self);
8116    }
8117}
8118
8119impl TerminaGuestManagerForceShutdownResponder {
8120    /// Sends a response to the FIDL transaction.
8121    ///
8122    /// Sets the channel to shutdown if an error occurs.
8123    pub fn send(self) -> Result<(), fidl::Error> {
8124        let _result = self.send_raw();
8125        if _result.is_err() {
8126            self.control_handle.shutdown();
8127        }
8128        self.drop_without_shutdown();
8129        _result
8130    }
8131
8132    /// Similar to "send" but does not shutdown the channel if an error occurs.
8133    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8134        let _result = self.send_raw();
8135        self.drop_without_shutdown();
8136        _result
8137    }
8138
8139    fn send_raw(&self) -> Result<(), fidl::Error> {
8140        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8141            (),
8142            self.tx_id,
8143            0x3ad9a012982f872d,
8144            fidl::encoding::DynamicFlags::empty(),
8145        )
8146    }
8147}
8148
8149#[must_use = "FIDL methods require a response to be sent"]
8150#[derive(Debug)]
8151pub struct TerminaGuestManagerConnectResponder {
8152    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8153    tx_id: u32,
8154}
8155
8156/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8157/// if the responder is dropped without sending a response, so that the client
8158/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8159impl std::ops::Drop for TerminaGuestManagerConnectResponder {
8160    fn drop(&mut self) {
8161        self.control_handle.shutdown();
8162        // Safety: drops once, never accessed again
8163        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8164    }
8165}
8166
8167impl fidl::endpoints::Responder for TerminaGuestManagerConnectResponder {
8168    type ControlHandle = TerminaGuestManagerControlHandle;
8169
8170    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8171        &self.control_handle
8172    }
8173
8174    fn drop_without_shutdown(mut self) {
8175        // Safety: drops once, never accessed again due to mem::forget
8176        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8177        // Prevent Drop from running (which would shut down the channel)
8178        std::mem::forget(self);
8179    }
8180}
8181
8182impl TerminaGuestManagerConnectResponder {
8183    /// Sends a response to the FIDL transaction.
8184    ///
8185    /// Sets the channel to shutdown if an error occurs.
8186    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8187        let _result = self.send_raw(result);
8188        if _result.is_err() {
8189            self.control_handle.shutdown();
8190        }
8191        self.drop_without_shutdown();
8192        _result
8193    }
8194
8195    /// Similar to "send" but does not shutdown the channel if an error occurs.
8196    pub fn send_no_shutdown_on_err(
8197        self,
8198        mut result: Result<(), GuestManagerError>,
8199    ) -> Result<(), fidl::Error> {
8200        let _result = self.send_raw(result);
8201        self.drop_without_shutdown();
8202        _result
8203    }
8204
8205    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8206        self.control_handle.inner.send::<fidl::encoding::ResultType<
8207            fidl::encoding::EmptyStruct,
8208            GuestManagerError,
8209        >>(
8210            result,
8211            self.tx_id,
8212            0x4e489076e3bb15b4,
8213            fidl::encoding::DynamicFlags::empty(),
8214        )
8215    }
8216}
8217
8218#[must_use = "FIDL methods require a response to be sent"]
8219#[derive(Debug)]
8220pub struct TerminaGuestManagerGetInfoResponder {
8221    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8222    tx_id: u32,
8223}
8224
8225/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8226/// if the responder is dropped without sending a response, so that the client
8227/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8228impl std::ops::Drop for TerminaGuestManagerGetInfoResponder {
8229    fn drop(&mut self) {
8230        self.control_handle.shutdown();
8231        // Safety: drops once, never accessed again
8232        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8233    }
8234}
8235
8236impl fidl::endpoints::Responder for TerminaGuestManagerGetInfoResponder {
8237    type ControlHandle = TerminaGuestManagerControlHandle;
8238
8239    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8240        &self.control_handle
8241    }
8242
8243    fn drop_without_shutdown(mut self) {
8244        // Safety: drops once, never accessed again due to mem::forget
8245        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8246        // Prevent Drop from running (which would shut down the channel)
8247        std::mem::forget(self);
8248    }
8249}
8250
8251impl TerminaGuestManagerGetInfoResponder {
8252    /// Sends a response to the FIDL transaction.
8253    ///
8254    /// Sets the channel to shutdown if an error occurs.
8255    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8256        let _result = self.send_raw(guest_info);
8257        if _result.is_err() {
8258            self.control_handle.shutdown();
8259        }
8260        self.drop_without_shutdown();
8261        _result
8262    }
8263
8264    /// Similar to "send" but does not shutdown the channel if an error occurs.
8265    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8266        let _result = self.send_raw(guest_info);
8267        self.drop_without_shutdown();
8268        _result
8269    }
8270
8271    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8272        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
8273            (guest_info,),
8274            self.tx_id,
8275            0x76892614aea695dc,
8276            fidl::encoding::DynamicFlags::empty(),
8277        )
8278    }
8279}
8280
8281#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8282pub struct ZirconGuestManagerMarker;
8283
8284impl fidl::endpoints::ProtocolMarker for ZirconGuestManagerMarker {
8285    type Proxy = ZirconGuestManagerProxy;
8286    type RequestStream = ZirconGuestManagerRequestStream;
8287    #[cfg(target_os = "fuchsia")]
8288    type SynchronousProxy = ZirconGuestManagerSynchronousProxy;
8289
8290    const DEBUG_NAME: &'static str = "fuchsia.virtualization.ZirconGuestManager";
8291}
8292impl fidl::endpoints::DiscoverableProtocolMarker for ZirconGuestManagerMarker {}
8293
8294pub trait ZirconGuestManagerProxyInterface: Send + Sync {
8295    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
8296        + Send;
8297    fn r#launch(
8298        &self,
8299        guest_config: GuestConfig,
8300        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8301    ) -> Self::LaunchResponseFut;
8302    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8303    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
8304    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
8305        + Send;
8306    fn r#connect(
8307        &self,
8308        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8309    ) -> Self::ConnectResponseFut;
8310    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
8311    fn r#get_info(&self) -> Self::GetInfoResponseFut;
8312}
8313#[derive(Debug)]
8314#[cfg(target_os = "fuchsia")]
8315pub struct ZirconGuestManagerSynchronousProxy {
8316    client: fidl::client::sync::Client,
8317}
8318
8319#[cfg(target_os = "fuchsia")]
8320impl fidl::endpoints::SynchronousProxy for ZirconGuestManagerSynchronousProxy {
8321    type Proxy = ZirconGuestManagerProxy;
8322    type Protocol = ZirconGuestManagerMarker;
8323
8324    fn from_channel(inner: fidl::Channel) -> Self {
8325        Self::new(inner)
8326    }
8327
8328    fn into_channel(self) -> fidl::Channel {
8329        self.client.into_channel()
8330    }
8331
8332    fn as_channel(&self) -> &fidl::Channel {
8333        self.client.as_channel()
8334    }
8335}
8336
8337#[cfg(target_os = "fuchsia")]
8338impl ZirconGuestManagerSynchronousProxy {
8339    pub fn new(channel: fidl::Channel) -> Self {
8340        Self { client: fidl::client::sync::Client::new(channel) }
8341    }
8342
8343    pub fn into_channel(self) -> fidl::Channel {
8344        self.client.into_channel()
8345    }
8346
8347    /// Waits until an event arrives and returns it. It is safe for other
8348    /// threads to make concurrent requests while waiting for an event.
8349    pub fn wait_for_event(
8350        &self,
8351        deadline: zx::MonotonicInstant,
8352    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8353        ZirconGuestManagerEvent::decode(
8354            self.client.wait_for_event::<ZirconGuestManagerMarker>(deadline)?,
8355        )
8356    }
8357
8358    /// Launch a new guest instance.
8359    ///
8360    /// Possible errors:
8361    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8362    ///         problems detected by the guest manager.
8363    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8364    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8365    ///         component logs for a more specific failure.
8366    pub fn r#launch(
8367        &self,
8368        mut guest_config: GuestConfig,
8369        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8370        ___deadline: zx::MonotonicInstant,
8371    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8372        let _response =
8373            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
8374                fidl::encoding::EmptyStruct,
8375                GuestManagerError,
8376            >, ZirconGuestManagerMarker>(
8377                (&mut guest_config, controller),
8378                0x394a2e29f750323e,
8379                fidl::encoding::DynamicFlags::empty(),
8380                ___deadline,
8381            )?;
8382        Ok(_response.map(|x| x))
8383    }
8384
8385    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8386    /// be used to launch another guest.
8387    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
8388        let _response = self.client.send_query::<
8389            fidl::encoding::EmptyPayload,
8390            fidl::encoding::EmptyPayload,
8391            ZirconGuestManagerMarker,
8392        >(
8393            (),
8394            0x3ad9a012982f872d,
8395            fidl::encoding::DynamicFlags::empty(),
8396            ___deadline,
8397        )?;
8398        Ok(_response)
8399    }
8400
8401    /// Connect to a currently running guest.
8402    ///
8403    /// Possible errors:
8404    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8405    ///         has launched before attempting to reconnect.
8406    pub fn r#connect(
8407        &self,
8408        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8409        ___deadline: zx::MonotonicInstant,
8410    ) -> Result<GuestManagerConnectResult, fidl::Error> {
8411        let _response =
8412            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
8413                fidl::encoding::EmptyStruct,
8414                GuestManagerError,
8415            >, ZirconGuestManagerMarker>(
8416                (controller,),
8417                0x4e489076e3bb15b4,
8418                fidl::encoding::DynamicFlags::empty(),
8419                ___deadline,
8420            )?;
8421        Ok(_response.map(|x| x))
8422    }
8423
8424    /// Query guest info
8425    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
8426        let _response = self.client.send_query::<
8427            fidl::encoding::EmptyPayload,
8428            GuestManagerGetInfoResponse,
8429            ZirconGuestManagerMarker,
8430        >(
8431            (),
8432            0x76892614aea695dc,
8433            fidl::encoding::DynamicFlags::empty(),
8434            ___deadline,
8435        )?;
8436        Ok(_response.guest_info)
8437    }
8438}
8439
8440#[cfg(target_os = "fuchsia")]
8441impl From<ZirconGuestManagerSynchronousProxy> for zx::NullableHandle {
8442    fn from(value: ZirconGuestManagerSynchronousProxy) -> Self {
8443        value.into_channel().into()
8444    }
8445}
8446
8447#[cfg(target_os = "fuchsia")]
8448impl From<fidl::Channel> for ZirconGuestManagerSynchronousProxy {
8449    fn from(value: fidl::Channel) -> Self {
8450        Self::new(value)
8451    }
8452}
8453
8454#[cfg(target_os = "fuchsia")]
8455impl fidl::endpoints::FromClient for ZirconGuestManagerSynchronousProxy {
8456    type Protocol = ZirconGuestManagerMarker;
8457
8458    fn from_client(value: fidl::endpoints::ClientEnd<ZirconGuestManagerMarker>) -> Self {
8459        Self::new(value.into_channel())
8460    }
8461}
8462
8463#[derive(Debug, Clone)]
8464pub struct ZirconGuestManagerProxy {
8465    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8466}
8467
8468impl fidl::endpoints::Proxy for ZirconGuestManagerProxy {
8469    type Protocol = ZirconGuestManagerMarker;
8470
8471    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8472        Self::new(inner)
8473    }
8474
8475    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8476        self.client.into_channel().map_err(|client| Self { client })
8477    }
8478
8479    fn as_channel(&self) -> &::fidl::AsyncChannel {
8480        self.client.as_channel()
8481    }
8482}
8483
8484impl ZirconGuestManagerProxy {
8485    /// Create a new Proxy for fuchsia.virtualization/ZirconGuestManager.
8486    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8487        let protocol_name =
8488            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8489        Self { client: fidl::client::Client::new(channel, protocol_name) }
8490    }
8491
8492    /// Get a Stream of events from the remote end of the protocol.
8493    ///
8494    /// # Panics
8495    ///
8496    /// Panics if the event stream was already taken.
8497    pub fn take_event_stream(&self) -> ZirconGuestManagerEventStream {
8498        ZirconGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
8499    }
8500
8501    /// Launch a new guest instance.
8502    ///
8503    /// Possible errors:
8504    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8505    ///         problems detected by the guest manager.
8506    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8507    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8508    ///         component logs for a more specific failure.
8509    pub fn r#launch(
8510        &self,
8511        mut guest_config: GuestConfig,
8512        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8513    ) -> fidl::client::QueryResponseFut<
8514        GuestManagerLaunchResult,
8515        fidl::encoding::DefaultFuchsiaResourceDialect,
8516    > {
8517        ZirconGuestManagerProxyInterface::r#launch(self, guest_config, controller)
8518    }
8519
8520    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8521    /// be used to launch another guest.
8522    pub fn r#force_shutdown(
8523        &self,
8524    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8525        ZirconGuestManagerProxyInterface::r#force_shutdown(self)
8526    }
8527
8528    /// Connect to a currently running guest.
8529    ///
8530    /// Possible errors:
8531    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8532    ///         has launched before attempting to reconnect.
8533    pub fn r#connect(
8534        &self,
8535        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8536    ) -> fidl::client::QueryResponseFut<
8537        GuestManagerConnectResult,
8538        fidl::encoding::DefaultFuchsiaResourceDialect,
8539    > {
8540        ZirconGuestManagerProxyInterface::r#connect(self, controller)
8541    }
8542
8543    /// Query guest info
8544    pub fn r#get_info(
8545        &self,
8546    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
8547    {
8548        ZirconGuestManagerProxyInterface::r#get_info(self)
8549    }
8550}
8551
8552impl ZirconGuestManagerProxyInterface for ZirconGuestManagerProxy {
8553    type LaunchResponseFut = fidl::client::QueryResponseFut<
8554        GuestManagerLaunchResult,
8555        fidl::encoding::DefaultFuchsiaResourceDialect,
8556    >;
8557    fn r#launch(
8558        &self,
8559        mut guest_config: GuestConfig,
8560        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8561    ) -> Self::LaunchResponseFut {
8562        fn _decode(
8563            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8564        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8565            let _response = fidl::client::decode_transaction_body::<
8566                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8567                fidl::encoding::DefaultFuchsiaResourceDialect,
8568                0x394a2e29f750323e,
8569            >(_buf?)?;
8570            Ok(_response.map(|x| x))
8571        }
8572        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
8573            (&mut guest_config, controller),
8574            0x394a2e29f750323e,
8575            fidl::encoding::DynamicFlags::empty(),
8576            _decode,
8577        )
8578    }
8579
8580    type ForceShutdownResponseFut =
8581        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8582    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
8583        fn _decode(
8584            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8585        ) -> Result<(), fidl::Error> {
8586            let _response = fidl::client::decode_transaction_body::<
8587                fidl::encoding::EmptyPayload,
8588                fidl::encoding::DefaultFuchsiaResourceDialect,
8589                0x3ad9a012982f872d,
8590            >(_buf?)?;
8591            Ok(_response)
8592        }
8593        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
8594            (),
8595            0x3ad9a012982f872d,
8596            fidl::encoding::DynamicFlags::empty(),
8597            _decode,
8598        )
8599    }
8600
8601    type ConnectResponseFut = fidl::client::QueryResponseFut<
8602        GuestManagerConnectResult,
8603        fidl::encoding::DefaultFuchsiaResourceDialect,
8604    >;
8605    fn r#connect(
8606        &self,
8607        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8608    ) -> Self::ConnectResponseFut {
8609        fn _decode(
8610            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8611        ) -> Result<GuestManagerConnectResult, fidl::Error> {
8612            let _response = fidl::client::decode_transaction_body::<
8613                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8614                fidl::encoding::DefaultFuchsiaResourceDialect,
8615                0x4e489076e3bb15b4,
8616            >(_buf?)?;
8617            Ok(_response.map(|x| x))
8618        }
8619        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
8620            (controller,),
8621            0x4e489076e3bb15b4,
8622            fidl::encoding::DynamicFlags::empty(),
8623            _decode,
8624        )
8625    }
8626
8627    type GetInfoResponseFut =
8628        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
8629    fn r#get_info(&self) -> Self::GetInfoResponseFut {
8630        fn _decode(
8631            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8632        ) -> Result<GuestInfo, fidl::Error> {
8633            let _response = fidl::client::decode_transaction_body::<
8634                GuestManagerGetInfoResponse,
8635                fidl::encoding::DefaultFuchsiaResourceDialect,
8636                0x76892614aea695dc,
8637            >(_buf?)?;
8638            Ok(_response.guest_info)
8639        }
8640        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
8641            (),
8642            0x76892614aea695dc,
8643            fidl::encoding::DynamicFlags::empty(),
8644            _decode,
8645        )
8646    }
8647}
8648
8649pub struct ZirconGuestManagerEventStream {
8650    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8651}
8652
8653impl std::marker::Unpin for ZirconGuestManagerEventStream {}
8654
8655impl futures::stream::FusedStream for ZirconGuestManagerEventStream {
8656    fn is_terminated(&self) -> bool {
8657        self.event_receiver.is_terminated()
8658    }
8659}
8660
8661impl futures::Stream for ZirconGuestManagerEventStream {
8662    type Item = Result<ZirconGuestManagerEvent, fidl::Error>;
8663
8664    fn poll_next(
8665        mut self: std::pin::Pin<&mut Self>,
8666        cx: &mut std::task::Context<'_>,
8667    ) -> std::task::Poll<Option<Self::Item>> {
8668        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8669            &mut self.event_receiver,
8670            cx
8671        )?) {
8672            Some(buf) => std::task::Poll::Ready(Some(ZirconGuestManagerEvent::decode(buf))),
8673            None => std::task::Poll::Ready(None),
8674        }
8675    }
8676}
8677
8678#[derive(Debug)]
8679pub enum ZirconGuestManagerEvent {}
8680
8681impl ZirconGuestManagerEvent {
8682    /// Decodes a message buffer as a [`ZirconGuestManagerEvent`].
8683    fn decode(
8684        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8685    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8686        let (bytes, _handles) = buf.split_mut();
8687        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8688        debug_assert_eq!(tx_header.tx_id, 0);
8689        match tx_header.ordinal {
8690            _ => Err(fidl::Error::UnknownOrdinal {
8691                ordinal: tx_header.ordinal,
8692                protocol_name:
8693                    <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8694            }),
8695        }
8696    }
8697}
8698
8699/// A Stream of incoming requests for fuchsia.virtualization/ZirconGuestManager.
8700pub struct ZirconGuestManagerRequestStream {
8701    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8702    is_terminated: bool,
8703}
8704
8705impl std::marker::Unpin for ZirconGuestManagerRequestStream {}
8706
8707impl futures::stream::FusedStream for ZirconGuestManagerRequestStream {
8708    fn is_terminated(&self) -> bool {
8709        self.is_terminated
8710    }
8711}
8712
8713impl fidl::endpoints::RequestStream for ZirconGuestManagerRequestStream {
8714    type Protocol = ZirconGuestManagerMarker;
8715    type ControlHandle = ZirconGuestManagerControlHandle;
8716
8717    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8718        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8719    }
8720
8721    fn control_handle(&self) -> Self::ControlHandle {
8722        ZirconGuestManagerControlHandle { inner: self.inner.clone() }
8723    }
8724
8725    fn into_inner(
8726        self,
8727    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8728    {
8729        (self.inner, self.is_terminated)
8730    }
8731
8732    fn from_inner(
8733        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8734        is_terminated: bool,
8735    ) -> Self {
8736        Self { inner, is_terminated }
8737    }
8738}
8739
8740impl futures::Stream for ZirconGuestManagerRequestStream {
8741    type Item = Result<ZirconGuestManagerRequest, fidl::Error>;
8742
8743    fn poll_next(
8744        mut self: std::pin::Pin<&mut Self>,
8745        cx: &mut std::task::Context<'_>,
8746    ) -> std::task::Poll<Option<Self::Item>> {
8747        let this = &mut *self;
8748        if this.inner.check_shutdown(cx) {
8749            this.is_terminated = true;
8750            return std::task::Poll::Ready(None);
8751        }
8752        if this.is_terminated {
8753            panic!("polled ZirconGuestManagerRequestStream after completion");
8754        }
8755        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8756            |bytes, handles| {
8757                match this.inner.channel().read_etc(cx, bytes, handles) {
8758                    std::task::Poll::Ready(Ok(())) => {}
8759                    std::task::Poll::Pending => return std::task::Poll::Pending,
8760                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8761                        this.is_terminated = true;
8762                        return std::task::Poll::Ready(None);
8763                    }
8764                    std::task::Poll::Ready(Err(e)) => {
8765                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8766                            e.into(),
8767                        ))));
8768                    }
8769                }
8770
8771                // A message has been received from the channel
8772                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8773
8774                std::task::Poll::Ready(Some(match header.ordinal {
8775                0x394a2e29f750323e => {
8776                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8777                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8778                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
8779                    let control_handle = ZirconGuestManagerControlHandle {
8780                        inner: this.inner.clone(),
8781                    };
8782                    Ok(ZirconGuestManagerRequest::Launch {guest_config: req.guest_config,
8783controller: req.controller,
8784
8785                        responder: ZirconGuestManagerLaunchResponder {
8786                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8787                            tx_id: header.tx_id,
8788                        },
8789                    })
8790                }
8791                0x3ad9a012982f872d => {
8792                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8793                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8794                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8795                    let control_handle = ZirconGuestManagerControlHandle {
8796                        inner: this.inner.clone(),
8797                    };
8798                    Ok(ZirconGuestManagerRequest::ForceShutdown {
8799                        responder: ZirconGuestManagerForceShutdownResponder {
8800                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8801                            tx_id: header.tx_id,
8802                        },
8803                    })
8804                }
8805                0x4e489076e3bb15b4 => {
8806                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8807                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8808                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
8809                    let control_handle = ZirconGuestManagerControlHandle {
8810                        inner: this.inner.clone(),
8811                    };
8812                    Ok(ZirconGuestManagerRequest::Connect {controller: req.controller,
8813
8814                        responder: ZirconGuestManagerConnectResponder {
8815                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8816                            tx_id: header.tx_id,
8817                        },
8818                    })
8819                }
8820                0x76892614aea695dc => {
8821                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8822                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8823                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8824                    let control_handle = ZirconGuestManagerControlHandle {
8825                        inner: this.inner.clone(),
8826                    };
8827                    Ok(ZirconGuestManagerRequest::GetInfo {
8828                        responder: ZirconGuestManagerGetInfoResponder {
8829                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8830                            tx_id: header.tx_id,
8831                        },
8832                    })
8833                }
8834                _ => Err(fidl::Error::UnknownOrdinal {
8835                    ordinal: header.ordinal,
8836                    protocol_name: <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8837                }),
8838            }))
8839            },
8840        )
8841    }
8842}
8843
8844#[derive(Debug)]
8845pub enum ZirconGuestManagerRequest {
8846    /// Launch a new guest instance.
8847    ///
8848    /// Possible errors:
8849    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8850    ///         problems detected by the guest manager.
8851    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8852    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8853    ///         component logs for a more specific failure.
8854    Launch {
8855        guest_config: GuestConfig,
8856        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8857        responder: ZirconGuestManagerLaunchResponder,
8858    },
8859    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8860    /// be used to launch another guest.
8861    ForceShutdown { responder: ZirconGuestManagerForceShutdownResponder },
8862    /// Connect to a currently running guest.
8863    ///
8864    /// Possible errors:
8865    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8866    ///         has launched before attempting to reconnect.
8867    Connect {
8868        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8869        responder: ZirconGuestManagerConnectResponder,
8870    },
8871    /// Query guest info
8872    GetInfo { responder: ZirconGuestManagerGetInfoResponder },
8873}
8874
8875impl ZirconGuestManagerRequest {
8876    #[allow(irrefutable_let_patterns)]
8877    pub fn into_launch(
8878        self,
8879    ) -> Option<(
8880        GuestConfig,
8881        fidl::endpoints::ServerEnd<GuestMarker>,
8882        ZirconGuestManagerLaunchResponder,
8883    )> {
8884        if let ZirconGuestManagerRequest::Launch { guest_config, controller, responder } = self {
8885            Some((guest_config, controller, responder))
8886        } else {
8887            None
8888        }
8889    }
8890
8891    #[allow(irrefutable_let_patterns)]
8892    pub fn into_force_shutdown(self) -> Option<(ZirconGuestManagerForceShutdownResponder)> {
8893        if let ZirconGuestManagerRequest::ForceShutdown { responder } = self {
8894            Some((responder))
8895        } else {
8896            None
8897        }
8898    }
8899
8900    #[allow(irrefutable_let_patterns)]
8901    pub fn into_connect(
8902        self,
8903    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, ZirconGuestManagerConnectResponder)> {
8904        if let ZirconGuestManagerRequest::Connect { controller, responder } = self {
8905            Some((controller, responder))
8906        } else {
8907            None
8908        }
8909    }
8910
8911    #[allow(irrefutable_let_patterns)]
8912    pub fn into_get_info(self) -> Option<(ZirconGuestManagerGetInfoResponder)> {
8913        if let ZirconGuestManagerRequest::GetInfo { responder } = self {
8914            Some((responder))
8915        } else {
8916            None
8917        }
8918    }
8919
8920    /// Name of the method defined in FIDL
8921    pub fn method_name(&self) -> &'static str {
8922        match *self {
8923            ZirconGuestManagerRequest::Launch { .. } => "launch",
8924            ZirconGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
8925            ZirconGuestManagerRequest::Connect { .. } => "connect",
8926            ZirconGuestManagerRequest::GetInfo { .. } => "get_info",
8927        }
8928    }
8929}
8930
8931#[derive(Debug, Clone)]
8932pub struct ZirconGuestManagerControlHandle {
8933    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8934}
8935
8936impl fidl::endpoints::ControlHandle for ZirconGuestManagerControlHandle {
8937    fn shutdown(&self) {
8938        self.inner.shutdown()
8939    }
8940
8941    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8942        self.inner.shutdown_with_epitaph(status)
8943    }
8944
8945    fn is_closed(&self) -> bool {
8946        self.inner.channel().is_closed()
8947    }
8948    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8949        self.inner.channel().on_closed()
8950    }
8951
8952    #[cfg(target_os = "fuchsia")]
8953    fn signal_peer(
8954        &self,
8955        clear_mask: zx::Signals,
8956        set_mask: zx::Signals,
8957    ) -> Result<(), zx_status::Status> {
8958        use fidl::Peered;
8959        self.inner.channel().signal_peer(clear_mask, set_mask)
8960    }
8961}
8962
8963impl ZirconGuestManagerControlHandle {}
8964
8965#[must_use = "FIDL methods require a response to be sent"]
8966#[derive(Debug)]
8967pub struct ZirconGuestManagerLaunchResponder {
8968    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8969    tx_id: u32,
8970}
8971
8972/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8973/// if the responder is dropped without sending a response, so that the client
8974/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8975impl std::ops::Drop for ZirconGuestManagerLaunchResponder {
8976    fn drop(&mut self) {
8977        self.control_handle.shutdown();
8978        // Safety: drops once, never accessed again
8979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8980    }
8981}
8982
8983impl fidl::endpoints::Responder for ZirconGuestManagerLaunchResponder {
8984    type ControlHandle = ZirconGuestManagerControlHandle;
8985
8986    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
8987        &self.control_handle
8988    }
8989
8990    fn drop_without_shutdown(mut self) {
8991        // Safety: drops once, never accessed again due to mem::forget
8992        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8993        // Prevent Drop from running (which would shut down the channel)
8994        std::mem::forget(self);
8995    }
8996}
8997
8998impl ZirconGuestManagerLaunchResponder {
8999    /// Sends a response to the FIDL transaction.
9000    ///
9001    /// Sets the channel to shutdown if an error occurs.
9002    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9003        let _result = self.send_raw(result);
9004        if _result.is_err() {
9005            self.control_handle.shutdown();
9006        }
9007        self.drop_without_shutdown();
9008        _result
9009    }
9010
9011    /// Similar to "send" but does not shutdown the channel if an error occurs.
9012    pub fn send_no_shutdown_on_err(
9013        self,
9014        mut result: Result<(), GuestManagerError>,
9015    ) -> Result<(), fidl::Error> {
9016        let _result = self.send_raw(result);
9017        self.drop_without_shutdown();
9018        _result
9019    }
9020
9021    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9022        self.control_handle.inner.send::<fidl::encoding::ResultType<
9023            fidl::encoding::EmptyStruct,
9024            GuestManagerError,
9025        >>(
9026            result,
9027            self.tx_id,
9028            0x394a2e29f750323e,
9029            fidl::encoding::DynamicFlags::empty(),
9030        )
9031    }
9032}
9033
9034#[must_use = "FIDL methods require a response to be sent"]
9035#[derive(Debug)]
9036pub struct ZirconGuestManagerForceShutdownResponder {
9037    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9038    tx_id: u32,
9039}
9040
9041/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9042/// if the responder is dropped without sending a response, so that the client
9043/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9044impl std::ops::Drop for ZirconGuestManagerForceShutdownResponder {
9045    fn drop(&mut self) {
9046        self.control_handle.shutdown();
9047        // Safety: drops once, never accessed again
9048        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9049    }
9050}
9051
9052impl fidl::endpoints::Responder for ZirconGuestManagerForceShutdownResponder {
9053    type ControlHandle = ZirconGuestManagerControlHandle;
9054
9055    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9056        &self.control_handle
9057    }
9058
9059    fn drop_without_shutdown(mut self) {
9060        // Safety: drops once, never accessed again due to mem::forget
9061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9062        // Prevent Drop from running (which would shut down the channel)
9063        std::mem::forget(self);
9064    }
9065}
9066
9067impl ZirconGuestManagerForceShutdownResponder {
9068    /// Sends a response to the FIDL transaction.
9069    ///
9070    /// Sets the channel to shutdown if an error occurs.
9071    pub fn send(self) -> Result<(), fidl::Error> {
9072        let _result = self.send_raw();
9073        if _result.is_err() {
9074            self.control_handle.shutdown();
9075        }
9076        self.drop_without_shutdown();
9077        _result
9078    }
9079
9080    /// Similar to "send" but does not shutdown the channel if an error occurs.
9081    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9082        let _result = self.send_raw();
9083        self.drop_without_shutdown();
9084        _result
9085    }
9086
9087    fn send_raw(&self) -> Result<(), fidl::Error> {
9088        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9089            (),
9090            self.tx_id,
9091            0x3ad9a012982f872d,
9092            fidl::encoding::DynamicFlags::empty(),
9093        )
9094    }
9095}
9096
9097#[must_use = "FIDL methods require a response to be sent"]
9098#[derive(Debug)]
9099pub struct ZirconGuestManagerConnectResponder {
9100    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9101    tx_id: u32,
9102}
9103
9104/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9105/// if the responder is dropped without sending a response, so that the client
9106/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9107impl std::ops::Drop for ZirconGuestManagerConnectResponder {
9108    fn drop(&mut self) {
9109        self.control_handle.shutdown();
9110        // Safety: drops once, never accessed again
9111        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9112    }
9113}
9114
9115impl fidl::endpoints::Responder for ZirconGuestManagerConnectResponder {
9116    type ControlHandle = ZirconGuestManagerControlHandle;
9117
9118    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9119        &self.control_handle
9120    }
9121
9122    fn drop_without_shutdown(mut self) {
9123        // Safety: drops once, never accessed again due to mem::forget
9124        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9125        // Prevent Drop from running (which would shut down the channel)
9126        std::mem::forget(self);
9127    }
9128}
9129
9130impl ZirconGuestManagerConnectResponder {
9131    /// Sends a response to the FIDL transaction.
9132    ///
9133    /// Sets the channel to shutdown if an error occurs.
9134    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9135        let _result = self.send_raw(result);
9136        if _result.is_err() {
9137            self.control_handle.shutdown();
9138        }
9139        self.drop_without_shutdown();
9140        _result
9141    }
9142
9143    /// Similar to "send" but does not shutdown the channel if an error occurs.
9144    pub fn send_no_shutdown_on_err(
9145        self,
9146        mut result: Result<(), GuestManagerError>,
9147    ) -> Result<(), fidl::Error> {
9148        let _result = self.send_raw(result);
9149        self.drop_without_shutdown();
9150        _result
9151    }
9152
9153    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9154        self.control_handle.inner.send::<fidl::encoding::ResultType<
9155            fidl::encoding::EmptyStruct,
9156            GuestManagerError,
9157        >>(
9158            result,
9159            self.tx_id,
9160            0x4e489076e3bb15b4,
9161            fidl::encoding::DynamicFlags::empty(),
9162        )
9163    }
9164}
9165
9166#[must_use = "FIDL methods require a response to be sent"]
9167#[derive(Debug)]
9168pub struct ZirconGuestManagerGetInfoResponder {
9169    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9170    tx_id: u32,
9171}
9172
9173/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9174/// if the responder is dropped without sending a response, so that the client
9175/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9176impl std::ops::Drop for ZirconGuestManagerGetInfoResponder {
9177    fn drop(&mut self) {
9178        self.control_handle.shutdown();
9179        // Safety: drops once, never accessed again
9180        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9181    }
9182}
9183
9184impl fidl::endpoints::Responder for ZirconGuestManagerGetInfoResponder {
9185    type ControlHandle = ZirconGuestManagerControlHandle;
9186
9187    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9188        &self.control_handle
9189    }
9190
9191    fn drop_without_shutdown(mut self) {
9192        // Safety: drops once, never accessed again due to mem::forget
9193        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9194        // Prevent Drop from running (which would shut down the channel)
9195        std::mem::forget(self);
9196    }
9197}
9198
9199impl ZirconGuestManagerGetInfoResponder {
9200    /// Sends a response to the FIDL transaction.
9201    ///
9202    /// Sets the channel to shutdown if an error occurs.
9203    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9204        let _result = self.send_raw(guest_info);
9205        if _result.is_err() {
9206            self.control_handle.shutdown();
9207        }
9208        self.drop_without_shutdown();
9209        _result
9210    }
9211
9212    /// Similar to "send" but does not shutdown the channel if an error occurs.
9213    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9214        let _result = self.send_raw(guest_info);
9215        self.drop_without_shutdown();
9216        _result
9217    }
9218
9219    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9220        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
9221            (guest_info,),
9222            self.tx_id,
9223            0x76892614aea695dc,
9224            fidl::encoding::DynamicFlags::empty(),
9225        )
9226    }
9227}
9228
9229mod internal {
9230    use super::*;
9231
9232    impl fidl::encoding::ResourceTypeMarker for BlockSpec {
9233        type Borrowed<'a> = &'a mut Self;
9234        fn take_or_borrow<'a>(
9235            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9236        ) -> Self::Borrowed<'a> {
9237            value
9238        }
9239    }
9240
9241    unsafe impl fidl::encoding::TypeMarker for BlockSpec {
9242        type Owned = Self;
9243
9244        #[inline(always)]
9245        fn inline_align(_context: fidl::encoding::Context) -> usize {
9246            8
9247        }
9248
9249        #[inline(always)]
9250        fn inline_size(_context: fidl::encoding::Context) -> usize {
9251            40
9252        }
9253    }
9254
9255    unsafe impl fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9256        for &mut BlockSpec
9257    {
9258        #[inline]
9259        unsafe fn encode(
9260            self,
9261            encoder: &mut fidl::encoding::Encoder<
9262                '_,
9263                fidl::encoding::DefaultFuchsiaResourceDialect,
9264            >,
9265            offset: usize,
9266            _depth: fidl::encoding::Depth,
9267        ) -> fidl::Result<()> {
9268            encoder.debug_check_bounds::<BlockSpec>(offset);
9269            // Delegate to tuple encoding.
9270            fidl::encoding::Encode::<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9271                (
9272                    <fidl::encoding::BoundedString<20> as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
9273                    <BlockMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
9274                    <BlockFormat as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.format),
9275                ),
9276                encoder, offset, _depth
9277            )
9278        }
9279    }
9280    unsafe impl<
9281        T0: fidl::encoding::Encode<
9282                fidl::encoding::BoundedString<20>,
9283                fidl::encoding::DefaultFuchsiaResourceDialect,
9284            >,
9285        T1: fidl::encoding::Encode<BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect>,
9286        T2: fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>,
9287    > fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9288        for (T0, T1, T2)
9289    {
9290        #[inline]
9291        unsafe fn encode(
9292            self,
9293            encoder: &mut fidl::encoding::Encoder<
9294                '_,
9295                fidl::encoding::DefaultFuchsiaResourceDialect,
9296            >,
9297            offset: usize,
9298            depth: fidl::encoding::Depth,
9299        ) -> fidl::Result<()> {
9300            encoder.debug_check_bounds::<BlockSpec>(offset);
9301            // Zero out padding regions. There's no need to apply masks
9302            // because the unmasked parts will be overwritten by fields.
9303            unsafe {
9304                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9305                (ptr as *mut u64).write_unaligned(0);
9306            }
9307            // Write the fields.
9308            self.0.encode(encoder, offset + 0, depth)?;
9309            self.1.encode(encoder, offset + 16, depth)?;
9310            self.2.encode(encoder, offset + 24, depth)?;
9311            Ok(())
9312        }
9313    }
9314
9315    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockSpec {
9316        #[inline(always)]
9317        fn new_empty() -> Self {
9318            Self {
9319                id: fidl::new_empty!(
9320                    fidl::encoding::BoundedString<20>,
9321                    fidl::encoding::DefaultFuchsiaResourceDialect
9322                ),
9323                mode: fidl::new_empty!(BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect),
9324                format: fidl::new_empty!(
9325                    BlockFormat,
9326                    fidl::encoding::DefaultFuchsiaResourceDialect
9327                ),
9328            }
9329        }
9330
9331        #[inline]
9332        unsafe fn decode(
9333            &mut self,
9334            decoder: &mut fidl::encoding::Decoder<
9335                '_,
9336                fidl::encoding::DefaultFuchsiaResourceDialect,
9337            >,
9338            offset: usize,
9339            _depth: fidl::encoding::Depth,
9340        ) -> fidl::Result<()> {
9341            decoder.debug_check_bounds::<Self>(offset);
9342            // Verify that padding bytes are zero.
9343            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9344            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9345            let mask = 0xffffffff00000000u64;
9346            let maskedval = padval & mask;
9347            if maskedval != 0 {
9348                return Err(fidl::Error::NonZeroPadding {
9349                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9350                });
9351            }
9352            fidl::decode!(
9353                fidl::encoding::BoundedString<20>,
9354                fidl::encoding::DefaultFuchsiaResourceDialect,
9355                &mut self.id,
9356                decoder,
9357                offset + 0,
9358                _depth
9359            )?;
9360            fidl::decode!(
9361                BlockMode,
9362                fidl::encoding::DefaultFuchsiaResourceDialect,
9363                &mut self.mode,
9364                decoder,
9365                offset + 16,
9366                _depth
9367            )?;
9368            fidl::decode!(
9369                BlockFormat,
9370                fidl::encoding::DefaultFuchsiaResourceDialect,
9371                &mut self.format,
9372                decoder,
9373                offset + 24,
9374                _depth
9375            )?;
9376            Ok(())
9377        }
9378    }
9379
9380    impl fidl::encoding::ResourceTypeMarker for GuestGetBalloonControllerRequest {
9381        type Borrowed<'a> = &'a mut Self;
9382        fn take_or_borrow<'a>(
9383            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9384        ) -> Self::Borrowed<'a> {
9385            value
9386        }
9387    }
9388
9389    unsafe impl fidl::encoding::TypeMarker for GuestGetBalloonControllerRequest {
9390        type Owned = Self;
9391
9392        #[inline(always)]
9393        fn inline_align(_context: fidl::encoding::Context) -> usize {
9394            4
9395        }
9396
9397        #[inline(always)]
9398        fn inline_size(_context: fidl::encoding::Context) -> usize {
9399            4
9400        }
9401    }
9402
9403    unsafe impl
9404        fidl::encoding::Encode<
9405            GuestGetBalloonControllerRequest,
9406            fidl::encoding::DefaultFuchsiaResourceDialect,
9407        > for &mut GuestGetBalloonControllerRequest
9408    {
9409        #[inline]
9410        unsafe fn encode(
9411            self,
9412            encoder: &mut fidl::encoding::Encoder<
9413                '_,
9414                fidl::encoding::DefaultFuchsiaResourceDialect,
9415            >,
9416            offset: usize,
9417            _depth: fidl::encoding::Depth,
9418        ) -> fidl::Result<()> {
9419            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9420            // Delegate to tuple encoding.
9421            fidl::encoding::Encode::<GuestGetBalloonControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9422                (
9423                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9424                ),
9425                encoder, offset, _depth
9426            )
9427        }
9428    }
9429    unsafe impl<
9430        T0: fidl::encoding::Encode<
9431                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9432                fidl::encoding::DefaultFuchsiaResourceDialect,
9433            >,
9434    >
9435        fidl::encoding::Encode<
9436            GuestGetBalloonControllerRequest,
9437            fidl::encoding::DefaultFuchsiaResourceDialect,
9438        > for (T0,)
9439    {
9440        #[inline]
9441        unsafe fn encode(
9442            self,
9443            encoder: &mut fidl::encoding::Encoder<
9444                '_,
9445                fidl::encoding::DefaultFuchsiaResourceDialect,
9446            >,
9447            offset: usize,
9448            depth: fidl::encoding::Depth,
9449        ) -> fidl::Result<()> {
9450            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9451            // Zero out padding regions. There's no need to apply masks
9452            // because the unmasked parts will be overwritten by fields.
9453            // Write the fields.
9454            self.0.encode(encoder, offset + 0, depth)?;
9455            Ok(())
9456        }
9457    }
9458
9459    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9460        for GuestGetBalloonControllerRequest
9461    {
9462        #[inline(always)]
9463        fn new_empty() -> Self {
9464            Self {
9465                controller: fidl::new_empty!(
9466                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9467                    fidl::encoding::DefaultFuchsiaResourceDialect
9468                ),
9469            }
9470        }
9471
9472        #[inline]
9473        unsafe fn decode(
9474            &mut self,
9475            decoder: &mut fidl::encoding::Decoder<
9476                '_,
9477                fidl::encoding::DefaultFuchsiaResourceDialect,
9478            >,
9479            offset: usize,
9480            _depth: fidl::encoding::Depth,
9481        ) -> fidl::Result<()> {
9482            decoder.debug_check_bounds::<Self>(offset);
9483            // Verify that padding bytes are zero.
9484            fidl::decode!(
9485                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9486                fidl::encoding::DefaultFuchsiaResourceDialect,
9487                &mut self.controller,
9488                decoder,
9489                offset + 0,
9490                _depth
9491            )?;
9492            Ok(())
9493        }
9494    }
9495
9496    impl fidl::encoding::ResourceTypeMarker for GuestGetHostVsockEndpointRequest {
9497        type Borrowed<'a> = &'a mut Self;
9498        fn take_or_borrow<'a>(
9499            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9500        ) -> Self::Borrowed<'a> {
9501            value
9502        }
9503    }
9504
9505    unsafe impl fidl::encoding::TypeMarker for GuestGetHostVsockEndpointRequest {
9506        type Owned = Self;
9507
9508        #[inline(always)]
9509        fn inline_align(_context: fidl::encoding::Context) -> usize {
9510            4
9511        }
9512
9513        #[inline(always)]
9514        fn inline_size(_context: fidl::encoding::Context) -> usize {
9515            4
9516        }
9517    }
9518
9519    unsafe impl
9520        fidl::encoding::Encode<
9521            GuestGetHostVsockEndpointRequest,
9522            fidl::encoding::DefaultFuchsiaResourceDialect,
9523        > for &mut GuestGetHostVsockEndpointRequest
9524    {
9525        #[inline]
9526        unsafe fn encode(
9527            self,
9528            encoder: &mut fidl::encoding::Encoder<
9529                '_,
9530                fidl::encoding::DefaultFuchsiaResourceDialect,
9531            >,
9532            offset: usize,
9533            _depth: fidl::encoding::Depth,
9534        ) -> fidl::Result<()> {
9535            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9536            // Delegate to tuple encoding.
9537            fidl::encoding::Encode::<GuestGetHostVsockEndpointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9538                (
9539                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoint),
9540                ),
9541                encoder, offset, _depth
9542            )
9543        }
9544    }
9545    unsafe impl<
9546        T0: fidl::encoding::Encode<
9547                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9548                fidl::encoding::DefaultFuchsiaResourceDialect,
9549            >,
9550    >
9551        fidl::encoding::Encode<
9552            GuestGetHostVsockEndpointRequest,
9553            fidl::encoding::DefaultFuchsiaResourceDialect,
9554        > for (T0,)
9555    {
9556        #[inline]
9557        unsafe fn encode(
9558            self,
9559            encoder: &mut fidl::encoding::Encoder<
9560                '_,
9561                fidl::encoding::DefaultFuchsiaResourceDialect,
9562            >,
9563            offset: usize,
9564            depth: fidl::encoding::Depth,
9565        ) -> fidl::Result<()> {
9566            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9567            // Zero out padding regions. There's no need to apply masks
9568            // because the unmasked parts will be overwritten by fields.
9569            // Write the fields.
9570            self.0.encode(encoder, offset + 0, depth)?;
9571            Ok(())
9572        }
9573    }
9574
9575    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9576        for GuestGetHostVsockEndpointRequest
9577    {
9578        #[inline(always)]
9579        fn new_empty() -> Self {
9580            Self {
9581                endpoint: fidl::new_empty!(
9582                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9583                    fidl::encoding::DefaultFuchsiaResourceDialect
9584                ),
9585            }
9586        }
9587
9588        #[inline]
9589        unsafe fn decode(
9590            &mut self,
9591            decoder: &mut fidl::encoding::Decoder<
9592                '_,
9593                fidl::encoding::DefaultFuchsiaResourceDialect,
9594            >,
9595            offset: usize,
9596            _depth: fidl::encoding::Depth,
9597        ) -> fidl::Result<()> {
9598            decoder.debug_check_bounds::<Self>(offset);
9599            // Verify that padding bytes are zero.
9600            fidl::decode!(
9601                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9602                fidl::encoding::DefaultFuchsiaResourceDialect,
9603                &mut self.endpoint,
9604                decoder,
9605                offset + 0,
9606                _depth
9607            )?;
9608            Ok(())
9609        }
9610    }
9611
9612    impl fidl::encoding::ResourceTypeMarker for GuestGetMemControllerRequest {
9613        type Borrowed<'a> = &'a mut Self;
9614        fn take_or_borrow<'a>(
9615            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9616        ) -> Self::Borrowed<'a> {
9617            value
9618        }
9619    }
9620
9621    unsafe impl fidl::encoding::TypeMarker for GuestGetMemControllerRequest {
9622        type Owned = Self;
9623
9624        #[inline(always)]
9625        fn inline_align(_context: fidl::encoding::Context) -> usize {
9626            4
9627        }
9628
9629        #[inline(always)]
9630        fn inline_size(_context: fidl::encoding::Context) -> usize {
9631            4
9632        }
9633    }
9634
9635    unsafe impl
9636        fidl::encoding::Encode<
9637            GuestGetMemControllerRequest,
9638            fidl::encoding::DefaultFuchsiaResourceDialect,
9639        > for &mut GuestGetMemControllerRequest
9640    {
9641        #[inline]
9642        unsafe fn encode(
9643            self,
9644            encoder: &mut fidl::encoding::Encoder<
9645                '_,
9646                fidl::encoding::DefaultFuchsiaResourceDialect,
9647            >,
9648            offset: usize,
9649            _depth: fidl::encoding::Depth,
9650        ) -> fidl::Result<()> {
9651            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9652            // Delegate to tuple encoding.
9653            fidl::encoding::Encode::<GuestGetMemControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9654                (
9655                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9656                ),
9657                encoder, offset, _depth
9658            )
9659        }
9660    }
9661    unsafe impl<
9662        T0: fidl::encoding::Encode<
9663                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9664                fidl::encoding::DefaultFuchsiaResourceDialect,
9665            >,
9666    >
9667        fidl::encoding::Encode<
9668            GuestGetMemControllerRequest,
9669            fidl::encoding::DefaultFuchsiaResourceDialect,
9670        > for (T0,)
9671    {
9672        #[inline]
9673        unsafe fn encode(
9674            self,
9675            encoder: &mut fidl::encoding::Encoder<
9676                '_,
9677                fidl::encoding::DefaultFuchsiaResourceDialect,
9678            >,
9679            offset: usize,
9680            depth: fidl::encoding::Depth,
9681        ) -> fidl::Result<()> {
9682            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9683            // Zero out padding regions. There's no need to apply masks
9684            // because the unmasked parts will be overwritten by fields.
9685            // Write the fields.
9686            self.0.encode(encoder, offset + 0, depth)?;
9687            Ok(())
9688        }
9689    }
9690
9691    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9692        for GuestGetMemControllerRequest
9693    {
9694        #[inline(always)]
9695        fn new_empty() -> Self {
9696            Self {
9697                controller: fidl::new_empty!(
9698                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9699                    fidl::encoding::DefaultFuchsiaResourceDialect
9700                ),
9701            }
9702        }
9703
9704        #[inline]
9705        unsafe fn decode(
9706            &mut self,
9707            decoder: &mut fidl::encoding::Decoder<
9708                '_,
9709                fidl::encoding::DefaultFuchsiaResourceDialect,
9710            >,
9711            offset: usize,
9712            _depth: fidl::encoding::Depth,
9713        ) -> fidl::Result<()> {
9714            decoder.debug_check_bounds::<Self>(offset);
9715            // Verify that padding bytes are zero.
9716            fidl::decode!(
9717                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9718                fidl::encoding::DefaultFuchsiaResourceDialect,
9719                &mut self.controller,
9720                decoder,
9721                offset + 0,
9722                _depth
9723            )?;
9724            Ok(())
9725        }
9726    }
9727
9728    impl fidl::encoding::ResourceTypeMarker for GuestGetSerialResponse {
9729        type Borrowed<'a> = &'a mut Self;
9730        fn take_or_borrow<'a>(
9731            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9732        ) -> Self::Borrowed<'a> {
9733            value
9734        }
9735    }
9736
9737    unsafe impl fidl::encoding::TypeMarker for GuestGetSerialResponse {
9738        type Owned = Self;
9739
9740        #[inline(always)]
9741        fn inline_align(_context: fidl::encoding::Context) -> usize {
9742            4
9743        }
9744
9745        #[inline(always)]
9746        fn inline_size(_context: fidl::encoding::Context) -> usize {
9747            4
9748        }
9749    }
9750
9751    unsafe impl
9752        fidl::encoding::Encode<
9753            GuestGetSerialResponse,
9754            fidl::encoding::DefaultFuchsiaResourceDialect,
9755        > for &mut GuestGetSerialResponse
9756    {
9757        #[inline]
9758        unsafe fn encode(
9759            self,
9760            encoder: &mut fidl::encoding::Encoder<
9761                '_,
9762                fidl::encoding::DefaultFuchsiaResourceDialect,
9763            >,
9764            offset: usize,
9765            _depth: fidl::encoding::Depth,
9766        ) -> fidl::Result<()> {
9767            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9768            // Delegate to tuple encoding.
9769            fidl::encoding::Encode::<
9770                GuestGetSerialResponse,
9771                fidl::encoding::DefaultFuchsiaResourceDialect,
9772            >::encode(
9773                (<fidl::encoding::HandleType<
9774                    fidl::Socket,
9775                    { fidl::ObjectType::SOCKET.into_raw() },
9776                    2147483648,
9777                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9778                    &mut self.socket
9779                ),),
9780                encoder,
9781                offset,
9782                _depth,
9783            )
9784        }
9785    }
9786    unsafe impl<
9787        T0: fidl::encoding::Encode<
9788                fidl::encoding::HandleType<
9789                    fidl::Socket,
9790                    { fidl::ObjectType::SOCKET.into_raw() },
9791                    2147483648,
9792                >,
9793                fidl::encoding::DefaultFuchsiaResourceDialect,
9794            >,
9795    >
9796        fidl::encoding::Encode<
9797            GuestGetSerialResponse,
9798            fidl::encoding::DefaultFuchsiaResourceDialect,
9799        > for (T0,)
9800    {
9801        #[inline]
9802        unsafe fn encode(
9803            self,
9804            encoder: &mut fidl::encoding::Encoder<
9805                '_,
9806                fidl::encoding::DefaultFuchsiaResourceDialect,
9807            >,
9808            offset: usize,
9809            depth: fidl::encoding::Depth,
9810        ) -> fidl::Result<()> {
9811            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9812            // Zero out padding regions. There's no need to apply masks
9813            // because the unmasked parts will be overwritten by fields.
9814            // Write the fields.
9815            self.0.encode(encoder, offset + 0, depth)?;
9816            Ok(())
9817        }
9818    }
9819
9820    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9821        for GuestGetSerialResponse
9822    {
9823        #[inline(always)]
9824        fn new_empty() -> Self {
9825            Self {
9826                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9827            }
9828        }
9829
9830        #[inline]
9831        unsafe fn decode(
9832            &mut self,
9833            decoder: &mut fidl::encoding::Decoder<
9834                '_,
9835                fidl::encoding::DefaultFuchsiaResourceDialect,
9836            >,
9837            offset: usize,
9838            _depth: fidl::encoding::Depth,
9839        ) -> fidl::Result<()> {
9840            decoder.debug_check_bounds::<Self>(offset);
9841            // Verify that padding bytes are zero.
9842            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
9843            Ok(())
9844        }
9845    }
9846
9847    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleBindRequest {
9848        type Borrowed<'a> = &'a mut Self;
9849        fn take_or_borrow<'a>(
9850            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9851        ) -> Self::Borrowed<'a> {
9852            value
9853        }
9854    }
9855
9856    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleBindRequest {
9857        type Owned = Self;
9858
9859        #[inline(always)]
9860        fn inline_align(_context: fidl::encoding::Context) -> usize {
9861            4
9862        }
9863
9864        #[inline(always)]
9865        fn inline_size(_context: fidl::encoding::Context) -> usize {
9866            4
9867        }
9868    }
9869
9870    unsafe impl
9871        fidl::encoding::Encode<
9872            GuestLifecycleBindRequest,
9873            fidl::encoding::DefaultFuchsiaResourceDialect,
9874        > for &mut GuestLifecycleBindRequest
9875    {
9876        #[inline]
9877        unsafe fn encode(
9878            self,
9879            encoder: &mut fidl::encoding::Encoder<
9880                '_,
9881                fidl::encoding::DefaultFuchsiaResourceDialect,
9882            >,
9883            offset: usize,
9884            _depth: fidl::encoding::Depth,
9885        ) -> fidl::Result<()> {
9886            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9887            // Delegate to tuple encoding.
9888            fidl::encoding::Encode::<GuestLifecycleBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9889                (
9890                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest),
9891                ),
9892                encoder, offset, _depth
9893            )
9894        }
9895    }
9896    unsafe impl<
9897        T0: fidl::encoding::Encode<
9898                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9899                fidl::encoding::DefaultFuchsiaResourceDialect,
9900            >,
9901    >
9902        fidl::encoding::Encode<
9903            GuestLifecycleBindRequest,
9904            fidl::encoding::DefaultFuchsiaResourceDialect,
9905        > for (T0,)
9906    {
9907        #[inline]
9908        unsafe fn encode(
9909            self,
9910            encoder: &mut fidl::encoding::Encoder<
9911                '_,
9912                fidl::encoding::DefaultFuchsiaResourceDialect,
9913            >,
9914            offset: usize,
9915            depth: fidl::encoding::Depth,
9916        ) -> fidl::Result<()> {
9917            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9918            // Zero out padding regions. There's no need to apply masks
9919            // because the unmasked parts will be overwritten by fields.
9920            // Write the fields.
9921            self.0.encode(encoder, offset + 0, depth)?;
9922            Ok(())
9923        }
9924    }
9925
9926    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9927        for GuestLifecycleBindRequest
9928    {
9929        #[inline(always)]
9930        fn new_empty() -> Self {
9931            Self {
9932                guest: fidl::new_empty!(
9933                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9934                    fidl::encoding::DefaultFuchsiaResourceDialect
9935                ),
9936            }
9937        }
9938
9939        #[inline]
9940        unsafe fn decode(
9941            &mut self,
9942            decoder: &mut fidl::encoding::Decoder<
9943                '_,
9944                fidl::encoding::DefaultFuchsiaResourceDialect,
9945            >,
9946            offset: usize,
9947            _depth: fidl::encoding::Depth,
9948        ) -> fidl::Result<()> {
9949            decoder.debug_check_bounds::<Self>(offset);
9950            // Verify that padding bytes are zero.
9951            fidl::decode!(
9952                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9953                fidl::encoding::DefaultFuchsiaResourceDialect,
9954                &mut self.guest,
9955                decoder,
9956                offset + 0,
9957                _depth
9958            )?;
9959            Ok(())
9960        }
9961    }
9962
9963    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleCreateRequest {
9964        type Borrowed<'a> = &'a mut Self;
9965        fn take_or_borrow<'a>(
9966            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9967        ) -> Self::Borrowed<'a> {
9968            value
9969        }
9970    }
9971
9972    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleCreateRequest {
9973        type Owned = Self;
9974
9975        #[inline(always)]
9976        fn inline_align(_context: fidl::encoding::Context) -> usize {
9977            8
9978        }
9979
9980        #[inline(always)]
9981        fn inline_size(_context: fidl::encoding::Context) -> usize {
9982            16
9983        }
9984    }
9985
9986    unsafe impl
9987        fidl::encoding::Encode<
9988            GuestLifecycleCreateRequest,
9989            fidl::encoding::DefaultFuchsiaResourceDialect,
9990        > for &mut GuestLifecycleCreateRequest
9991    {
9992        #[inline]
9993        unsafe fn encode(
9994            self,
9995            encoder: &mut fidl::encoding::Encoder<
9996                '_,
9997                fidl::encoding::DefaultFuchsiaResourceDialect,
9998            >,
9999            offset: usize,
10000            _depth: fidl::encoding::Depth,
10001        ) -> fidl::Result<()> {
10002            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
10003            // Delegate to tuple encoding.
10004            fidl::encoding::Encode::<
10005                GuestLifecycleCreateRequest,
10006                fidl::encoding::DefaultFuchsiaResourceDialect,
10007            >::encode(
10008                (<GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10009                    &mut self.guest_config,
10010                ),),
10011                encoder,
10012                offset,
10013                _depth,
10014            )
10015        }
10016    }
10017    unsafe impl<
10018        T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
10019    >
10020        fidl::encoding::Encode<
10021            GuestLifecycleCreateRequest,
10022            fidl::encoding::DefaultFuchsiaResourceDialect,
10023        > for (T0,)
10024    {
10025        #[inline]
10026        unsafe fn encode(
10027            self,
10028            encoder: &mut fidl::encoding::Encoder<
10029                '_,
10030                fidl::encoding::DefaultFuchsiaResourceDialect,
10031            >,
10032            offset: usize,
10033            depth: fidl::encoding::Depth,
10034        ) -> fidl::Result<()> {
10035            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
10036            // Zero out padding regions. There's no need to apply masks
10037            // because the unmasked parts will be overwritten by fields.
10038            // Write the fields.
10039            self.0.encode(encoder, offset + 0, depth)?;
10040            Ok(())
10041        }
10042    }
10043
10044    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10045        for GuestLifecycleCreateRequest
10046    {
10047        #[inline(always)]
10048        fn new_empty() -> Self {
10049            Self {
10050                guest_config: fidl::new_empty!(
10051                    GuestConfig,
10052                    fidl::encoding::DefaultFuchsiaResourceDialect
10053                ),
10054            }
10055        }
10056
10057        #[inline]
10058        unsafe fn decode(
10059            &mut self,
10060            decoder: &mut fidl::encoding::Decoder<
10061                '_,
10062                fidl::encoding::DefaultFuchsiaResourceDialect,
10063            >,
10064            offset: usize,
10065            _depth: fidl::encoding::Depth,
10066        ) -> fidl::Result<()> {
10067            decoder.debug_check_bounds::<Self>(offset);
10068            // Verify that padding bytes are zero.
10069            fidl::decode!(
10070                GuestConfig,
10071                fidl::encoding::DefaultFuchsiaResourceDialect,
10072                &mut self.guest_config,
10073                decoder,
10074                offset + 0,
10075                _depth
10076            )?;
10077            Ok(())
10078        }
10079    }
10080
10081    impl fidl::encoding::ResourceTypeMarker for GuestManagerConnectRequest {
10082        type Borrowed<'a> = &'a mut Self;
10083        fn take_or_borrow<'a>(
10084            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10085        ) -> Self::Borrowed<'a> {
10086            value
10087        }
10088    }
10089
10090    unsafe impl fidl::encoding::TypeMarker for GuestManagerConnectRequest {
10091        type Owned = Self;
10092
10093        #[inline(always)]
10094        fn inline_align(_context: fidl::encoding::Context) -> usize {
10095            4
10096        }
10097
10098        #[inline(always)]
10099        fn inline_size(_context: fidl::encoding::Context) -> usize {
10100            4
10101        }
10102    }
10103
10104    unsafe impl
10105        fidl::encoding::Encode<
10106            GuestManagerConnectRequest,
10107            fidl::encoding::DefaultFuchsiaResourceDialect,
10108        > for &mut GuestManagerConnectRequest
10109    {
10110        #[inline]
10111        unsafe fn encode(
10112            self,
10113            encoder: &mut fidl::encoding::Encoder<
10114                '_,
10115                fidl::encoding::DefaultFuchsiaResourceDialect,
10116            >,
10117            offset: usize,
10118            _depth: fidl::encoding::Depth,
10119        ) -> fidl::Result<()> {
10120            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
10121            // Delegate to tuple encoding.
10122            fidl::encoding::Encode::<GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10123                (
10124                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10125                ),
10126                encoder, offset, _depth
10127            )
10128        }
10129    }
10130    unsafe impl<
10131        T0: fidl::encoding::Encode<
10132                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10133                fidl::encoding::DefaultFuchsiaResourceDialect,
10134            >,
10135    >
10136        fidl::encoding::Encode<
10137            GuestManagerConnectRequest,
10138            fidl::encoding::DefaultFuchsiaResourceDialect,
10139        > for (T0,)
10140    {
10141        #[inline]
10142        unsafe fn encode(
10143            self,
10144            encoder: &mut fidl::encoding::Encoder<
10145                '_,
10146                fidl::encoding::DefaultFuchsiaResourceDialect,
10147            >,
10148            offset: usize,
10149            depth: fidl::encoding::Depth,
10150        ) -> fidl::Result<()> {
10151            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
10152            // Zero out padding regions. There's no need to apply masks
10153            // because the unmasked parts will be overwritten by fields.
10154            // Write the fields.
10155            self.0.encode(encoder, offset + 0, depth)?;
10156            Ok(())
10157        }
10158    }
10159
10160    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10161        for GuestManagerConnectRequest
10162    {
10163        #[inline(always)]
10164        fn new_empty() -> Self {
10165            Self {
10166                controller: fidl::new_empty!(
10167                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10168                    fidl::encoding::DefaultFuchsiaResourceDialect
10169                ),
10170            }
10171        }
10172
10173        #[inline]
10174        unsafe fn decode(
10175            &mut self,
10176            decoder: &mut fidl::encoding::Decoder<
10177                '_,
10178                fidl::encoding::DefaultFuchsiaResourceDialect,
10179            >,
10180            offset: usize,
10181            _depth: fidl::encoding::Depth,
10182        ) -> fidl::Result<()> {
10183            decoder.debug_check_bounds::<Self>(offset);
10184            // Verify that padding bytes are zero.
10185            fidl::decode!(
10186                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10187                fidl::encoding::DefaultFuchsiaResourceDialect,
10188                &mut self.controller,
10189                decoder,
10190                offset + 0,
10191                _depth
10192            )?;
10193            Ok(())
10194        }
10195    }
10196
10197    impl fidl::encoding::ResourceTypeMarker for GuestManagerGetInfoResponse {
10198        type Borrowed<'a> = &'a mut Self;
10199        fn take_or_borrow<'a>(
10200            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10201        ) -> Self::Borrowed<'a> {
10202            value
10203        }
10204    }
10205
10206    unsafe impl fidl::encoding::TypeMarker for GuestManagerGetInfoResponse {
10207        type Owned = Self;
10208
10209        #[inline(always)]
10210        fn inline_align(_context: fidl::encoding::Context) -> usize {
10211            8
10212        }
10213
10214        #[inline(always)]
10215        fn inline_size(_context: fidl::encoding::Context) -> usize {
10216            16
10217        }
10218    }
10219
10220    unsafe impl
10221        fidl::encoding::Encode<
10222            GuestManagerGetInfoResponse,
10223            fidl::encoding::DefaultFuchsiaResourceDialect,
10224        > for &mut GuestManagerGetInfoResponse
10225    {
10226        #[inline]
10227        unsafe fn encode(
10228            self,
10229            encoder: &mut fidl::encoding::Encoder<
10230                '_,
10231                fidl::encoding::DefaultFuchsiaResourceDialect,
10232            >,
10233            offset: usize,
10234            _depth: fidl::encoding::Depth,
10235        ) -> fidl::Result<()> {
10236            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10237            // Delegate to tuple encoding.
10238            fidl::encoding::Encode::<
10239                GuestManagerGetInfoResponse,
10240                fidl::encoding::DefaultFuchsiaResourceDialect,
10241            >::encode(
10242                (<GuestInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.guest_info),),
10243                encoder,
10244                offset,
10245                _depth,
10246            )
10247        }
10248    }
10249    unsafe impl<
10250        T0: fidl::encoding::Encode<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10251    >
10252        fidl::encoding::Encode<
10253            GuestManagerGetInfoResponse,
10254            fidl::encoding::DefaultFuchsiaResourceDialect,
10255        > for (T0,)
10256    {
10257        #[inline]
10258        unsafe fn encode(
10259            self,
10260            encoder: &mut fidl::encoding::Encoder<
10261                '_,
10262                fidl::encoding::DefaultFuchsiaResourceDialect,
10263            >,
10264            offset: usize,
10265            depth: fidl::encoding::Depth,
10266        ) -> fidl::Result<()> {
10267            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10268            // Zero out padding regions. There's no need to apply masks
10269            // because the unmasked parts will be overwritten by fields.
10270            // Write the fields.
10271            self.0.encode(encoder, offset + 0, depth)?;
10272            Ok(())
10273        }
10274    }
10275
10276    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10277        for GuestManagerGetInfoResponse
10278    {
10279        #[inline(always)]
10280        fn new_empty() -> Self {
10281            Self {
10282                guest_info: fidl::new_empty!(
10283                    GuestInfo,
10284                    fidl::encoding::DefaultFuchsiaResourceDialect
10285                ),
10286            }
10287        }
10288
10289        #[inline]
10290        unsafe fn decode(
10291            &mut self,
10292            decoder: &mut fidl::encoding::Decoder<
10293                '_,
10294                fidl::encoding::DefaultFuchsiaResourceDialect,
10295            >,
10296            offset: usize,
10297            _depth: fidl::encoding::Depth,
10298        ) -> fidl::Result<()> {
10299            decoder.debug_check_bounds::<Self>(offset);
10300            // Verify that padding bytes are zero.
10301            fidl::decode!(
10302                GuestInfo,
10303                fidl::encoding::DefaultFuchsiaResourceDialect,
10304                &mut self.guest_info,
10305                decoder,
10306                offset + 0,
10307                _depth
10308            )?;
10309            Ok(())
10310        }
10311    }
10312
10313    impl fidl::encoding::ResourceTypeMarker for GuestManagerLaunchRequest {
10314        type Borrowed<'a> = &'a mut Self;
10315        fn take_or_borrow<'a>(
10316            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10317        ) -> Self::Borrowed<'a> {
10318            value
10319        }
10320    }
10321
10322    unsafe impl fidl::encoding::TypeMarker for GuestManagerLaunchRequest {
10323        type Owned = Self;
10324
10325        #[inline(always)]
10326        fn inline_align(_context: fidl::encoding::Context) -> usize {
10327            8
10328        }
10329
10330        #[inline(always)]
10331        fn inline_size(_context: fidl::encoding::Context) -> usize {
10332            24
10333        }
10334    }
10335
10336    unsafe impl
10337        fidl::encoding::Encode<
10338            GuestManagerLaunchRequest,
10339            fidl::encoding::DefaultFuchsiaResourceDialect,
10340        > for &mut GuestManagerLaunchRequest
10341    {
10342        #[inline]
10343        unsafe fn encode(
10344            self,
10345            encoder: &mut fidl::encoding::Encoder<
10346                '_,
10347                fidl::encoding::DefaultFuchsiaResourceDialect,
10348            >,
10349            offset: usize,
10350            _depth: fidl::encoding::Depth,
10351        ) -> fidl::Result<()> {
10352            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10353            // Delegate to tuple encoding.
10354            fidl::encoding::Encode::<GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10355                (
10356                    <GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest_config),
10357                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10358                ),
10359                encoder, offset, _depth
10360            )
10361        }
10362    }
10363    unsafe impl<
10364        T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
10365        T1: fidl::encoding::Encode<
10366                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10367                fidl::encoding::DefaultFuchsiaResourceDialect,
10368            >,
10369    >
10370        fidl::encoding::Encode<
10371            GuestManagerLaunchRequest,
10372            fidl::encoding::DefaultFuchsiaResourceDialect,
10373        > for (T0, T1)
10374    {
10375        #[inline]
10376        unsafe fn encode(
10377            self,
10378            encoder: &mut fidl::encoding::Encoder<
10379                '_,
10380                fidl::encoding::DefaultFuchsiaResourceDialect,
10381            >,
10382            offset: usize,
10383            depth: fidl::encoding::Depth,
10384        ) -> fidl::Result<()> {
10385            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10386            // Zero out padding regions. There's no need to apply masks
10387            // because the unmasked parts will be overwritten by fields.
10388            unsafe {
10389                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10390                (ptr as *mut u64).write_unaligned(0);
10391            }
10392            // Write the fields.
10393            self.0.encode(encoder, offset + 0, depth)?;
10394            self.1.encode(encoder, offset + 16, depth)?;
10395            Ok(())
10396        }
10397    }
10398
10399    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10400        for GuestManagerLaunchRequest
10401    {
10402        #[inline(always)]
10403        fn new_empty() -> Self {
10404            Self {
10405                guest_config: fidl::new_empty!(
10406                    GuestConfig,
10407                    fidl::encoding::DefaultFuchsiaResourceDialect
10408                ),
10409                controller: fidl::new_empty!(
10410                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10411                    fidl::encoding::DefaultFuchsiaResourceDialect
10412                ),
10413            }
10414        }
10415
10416        #[inline]
10417        unsafe fn decode(
10418            &mut self,
10419            decoder: &mut fidl::encoding::Decoder<
10420                '_,
10421                fidl::encoding::DefaultFuchsiaResourceDialect,
10422            >,
10423            offset: usize,
10424            _depth: fidl::encoding::Depth,
10425        ) -> fidl::Result<()> {
10426            decoder.debug_check_bounds::<Self>(offset);
10427            // Verify that padding bytes are zero.
10428            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10429            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10430            let mask = 0xffffffff00000000u64;
10431            let maskedval = padval & mask;
10432            if maskedval != 0 {
10433                return Err(fidl::Error::NonZeroPadding {
10434                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10435                });
10436            }
10437            fidl::decode!(
10438                GuestConfig,
10439                fidl::encoding::DefaultFuchsiaResourceDialect,
10440                &mut self.guest_config,
10441                decoder,
10442                offset + 0,
10443                _depth
10444            )?;
10445            fidl::decode!(
10446                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10447                fidl::encoding::DefaultFuchsiaResourceDialect,
10448                &mut self.controller,
10449                decoder,
10450                offset + 16,
10451                _depth
10452            )?;
10453            Ok(())
10454        }
10455    }
10456
10457    impl fidl::encoding::ResourceTypeMarker for GuestGetConsoleResponse {
10458        type Borrowed<'a> = &'a mut Self;
10459        fn take_or_borrow<'a>(
10460            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10461        ) -> Self::Borrowed<'a> {
10462            value
10463        }
10464    }
10465
10466    unsafe impl fidl::encoding::TypeMarker for GuestGetConsoleResponse {
10467        type Owned = Self;
10468
10469        #[inline(always)]
10470        fn inline_align(_context: fidl::encoding::Context) -> usize {
10471            4
10472        }
10473
10474        #[inline(always)]
10475        fn inline_size(_context: fidl::encoding::Context) -> usize {
10476            4
10477        }
10478    }
10479
10480    unsafe impl
10481        fidl::encoding::Encode<
10482            GuestGetConsoleResponse,
10483            fidl::encoding::DefaultFuchsiaResourceDialect,
10484        > for &mut GuestGetConsoleResponse
10485    {
10486        #[inline]
10487        unsafe fn encode(
10488            self,
10489            encoder: &mut fidl::encoding::Encoder<
10490                '_,
10491                fidl::encoding::DefaultFuchsiaResourceDialect,
10492            >,
10493            offset: usize,
10494            _depth: fidl::encoding::Depth,
10495        ) -> fidl::Result<()> {
10496            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10497            // Delegate to tuple encoding.
10498            fidl::encoding::Encode::<
10499                GuestGetConsoleResponse,
10500                fidl::encoding::DefaultFuchsiaResourceDialect,
10501            >::encode(
10502                (<fidl::encoding::HandleType<
10503                    fidl::Socket,
10504                    { fidl::ObjectType::SOCKET.into_raw() },
10505                    2147483648,
10506                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10507                    &mut self.socket
10508                ),),
10509                encoder,
10510                offset,
10511                _depth,
10512            )
10513        }
10514    }
10515    unsafe impl<
10516        T0: fidl::encoding::Encode<
10517                fidl::encoding::HandleType<
10518                    fidl::Socket,
10519                    { fidl::ObjectType::SOCKET.into_raw() },
10520                    2147483648,
10521                >,
10522                fidl::encoding::DefaultFuchsiaResourceDialect,
10523            >,
10524    >
10525        fidl::encoding::Encode<
10526            GuestGetConsoleResponse,
10527            fidl::encoding::DefaultFuchsiaResourceDialect,
10528        > for (T0,)
10529    {
10530        #[inline]
10531        unsafe fn encode(
10532            self,
10533            encoder: &mut fidl::encoding::Encoder<
10534                '_,
10535                fidl::encoding::DefaultFuchsiaResourceDialect,
10536            >,
10537            offset: usize,
10538            depth: fidl::encoding::Depth,
10539        ) -> fidl::Result<()> {
10540            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10541            // Zero out padding regions. There's no need to apply masks
10542            // because the unmasked parts will be overwritten by fields.
10543            // Write the fields.
10544            self.0.encode(encoder, offset + 0, depth)?;
10545            Ok(())
10546        }
10547    }
10548
10549    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10550        for GuestGetConsoleResponse
10551    {
10552        #[inline(always)]
10553        fn new_empty() -> Self {
10554            Self {
10555                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10556            }
10557        }
10558
10559        #[inline]
10560        unsafe fn decode(
10561            &mut self,
10562            decoder: &mut fidl::encoding::Decoder<
10563                '_,
10564                fidl::encoding::DefaultFuchsiaResourceDialect,
10565            >,
10566            offset: usize,
10567            _depth: fidl::encoding::Depth,
10568        ) -> fidl::Result<()> {
10569            decoder.debug_check_bounds::<Self>(offset);
10570            // Verify that padding bytes are zero.
10571            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10572            Ok(())
10573        }
10574    }
10575
10576    impl fidl::encoding::ResourceTypeMarker for HostVsockAcceptorAcceptResponse {
10577        type Borrowed<'a> = &'a mut Self;
10578        fn take_or_borrow<'a>(
10579            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10580        ) -> Self::Borrowed<'a> {
10581            value
10582        }
10583    }
10584
10585    unsafe impl fidl::encoding::TypeMarker for HostVsockAcceptorAcceptResponse {
10586        type Owned = Self;
10587
10588        #[inline(always)]
10589        fn inline_align(_context: fidl::encoding::Context) -> usize {
10590            4
10591        }
10592
10593        #[inline(always)]
10594        fn inline_size(_context: fidl::encoding::Context) -> usize {
10595            4
10596        }
10597    }
10598
10599    unsafe impl
10600        fidl::encoding::Encode<
10601            HostVsockAcceptorAcceptResponse,
10602            fidl::encoding::DefaultFuchsiaResourceDialect,
10603        > for &mut HostVsockAcceptorAcceptResponse
10604    {
10605        #[inline]
10606        unsafe fn encode(
10607            self,
10608            encoder: &mut fidl::encoding::Encoder<
10609                '_,
10610                fidl::encoding::DefaultFuchsiaResourceDialect,
10611            >,
10612            offset: usize,
10613            _depth: fidl::encoding::Depth,
10614        ) -> fidl::Result<()> {
10615            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10616            // Delegate to tuple encoding.
10617            fidl::encoding::Encode::<
10618                HostVsockAcceptorAcceptResponse,
10619                fidl::encoding::DefaultFuchsiaResourceDialect,
10620            >::encode(
10621                (<fidl::encoding::HandleType<
10622                    fidl::Socket,
10623                    { fidl::ObjectType::SOCKET.into_raw() },
10624                    2147483648,
10625                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10626                    &mut self.socket
10627                ),),
10628                encoder,
10629                offset,
10630                _depth,
10631            )
10632        }
10633    }
10634    unsafe impl<
10635        T0: fidl::encoding::Encode<
10636                fidl::encoding::HandleType<
10637                    fidl::Socket,
10638                    { fidl::ObjectType::SOCKET.into_raw() },
10639                    2147483648,
10640                >,
10641                fidl::encoding::DefaultFuchsiaResourceDialect,
10642            >,
10643    >
10644        fidl::encoding::Encode<
10645            HostVsockAcceptorAcceptResponse,
10646            fidl::encoding::DefaultFuchsiaResourceDialect,
10647        > for (T0,)
10648    {
10649        #[inline]
10650        unsafe fn encode(
10651            self,
10652            encoder: &mut fidl::encoding::Encoder<
10653                '_,
10654                fidl::encoding::DefaultFuchsiaResourceDialect,
10655            >,
10656            offset: usize,
10657            depth: fidl::encoding::Depth,
10658        ) -> fidl::Result<()> {
10659            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10660            // Zero out padding regions. There's no need to apply masks
10661            // because the unmasked parts will be overwritten by fields.
10662            // Write the fields.
10663            self.0.encode(encoder, offset + 0, depth)?;
10664            Ok(())
10665        }
10666    }
10667
10668    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10669        for HostVsockAcceptorAcceptResponse
10670    {
10671        #[inline(always)]
10672        fn new_empty() -> Self {
10673            Self {
10674                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10675            }
10676        }
10677
10678        #[inline]
10679        unsafe fn decode(
10680            &mut self,
10681            decoder: &mut fidl::encoding::Decoder<
10682                '_,
10683                fidl::encoding::DefaultFuchsiaResourceDialect,
10684            >,
10685            offset: usize,
10686            _depth: fidl::encoding::Depth,
10687        ) -> fidl::Result<()> {
10688            decoder.debug_check_bounds::<Self>(offset);
10689            // Verify that padding bytes are zero.
10690            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10691            Ok(())
10692        }
10693    }
10694
10695    impl fidl::encoding::ResourceTypeMarker for HostVsockEndpointConnectResponse {
10696        type Borrowed<'a> = &'a mut Self;
10697        fn take_or_borrow<'a>(
10698            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10699        ) -> Self::Borrowed<'a> {
10700            value
10701        }
10702    }
10703
10704    unsafe impl fidl::encoding::TypeMarker for HostVsockEndpointConnectResponse {
10705        type Owned = Self;
10706
10707        #[inline(always)]
10708        fn inline_align(_context: fidl::encoding::Context) -> usize {
10709            4
10710        }
10711
10712        #[inline(always)]
10713        fn inline_size(_context: fidl::encoding::Context) -> usize {
10714            4
10715        }
10716    }
10717
10718    unsafe impl
10719        fidl::encoding::Encode<
10720            HostVsockEndpointConnectResponse,
10721            fidl::encoding::DefaultFuchsiaResourceDialect,
10722        > for &mut HostVsockEndpointConnectResponse
10723    {
10724        #[inline]
10725        unsafe fn encode(
10726            self,
10727            encoder: &mut fidl::encoding::Encoder<
10728                '_,
10729                fidl::encoding::DefaultFuchsiaResourceDialect,
10730            >,
10731            offset: usize,
10732            _depth: fidl::encoding::Depth,
10733        ) -> fidl::Result<()> {
10734            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10735            // Delegate to tuple encoding.
10736            fidl::encoding::Encode::<
10737                HostVsockEndpointConnectResponse,
10738                fidl::encoding::DefaultFuchsiaResourceDialect,
10739            >::encode(
10740                (<fidl::encoding::HandleType<
10741                    fidl::Socket,
10742                    { fidl::ObjectType::SOCKET.into_raw() },
10743                    2147483648,
10744                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10745                    &mut self.socket
10746                ),),
10747                encoder,
10748                offset,
10749                _depth,
10750            )
10751        }
10752    }
10753    unsafe impl<
10754        T0: fidl::encoding::Encode<
10755                fidl::encoding::HandleType<
10756                    fidl::Socket,
10757                    { fidl::ObjectType::SOCKET.into_raw() },
10758                    2147483648,
10759                >,
10760                fidl::encoding::DefaultFuchsiaResourceDialect,
10761            >,
10762    >
10763        fidl::encoding::Encode<
10764            HostVsockEndpointConnectResponse,
10765            fidl::encoding::DefaultFuchsiaResourceDialect,
10766        > for (T0,)
10767    {
10768        #[inline]
10769        unsafe fn encode(
10770            self,
10771            encoder: &mut fidl::encoding::Encoder<
10772                '_,
10773                fidl::encoding::DefaultFuchsiaResourceDialect,
10774            >,
10775            offset: usize,
10776            depth: fidl::encoding::Depth,
10777        ) -> fidl::Result<()> {
10778            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10779            // Zero out padding regions. There's no need to apply masks
10780            // because the unmasked parts will be overwritten by fields.
10781            // Write the fields.
10782            self.0.encode(encoder, offset + 0, depth)?;
10783            Ok(())
10784        }
10785    }
10786
10787    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10788        for HostVsockEndpointConnectResponse
10789    {
10790        #[inline(always)]
10791        fn new_empty() -> Self {
10792            Self {
10793                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10794            }
10795        }
10796
10797        #[inline]
10798        unsafe fn decode(
10799            &mut self,
10800            decoder: &mut fidl::encoding::Decoder<
10801                '_,
10802                fidl::encoding::DefaultFuchsiaResourceDialect,
10803            >,
10804            offset: usize,
10805            _depth: fidl::encoding::Depth,
10806        ) -> fidl::Result<()> {
10807            decoder.debug_check_bounds::<Self>(offset);
10808            // Verify that padding bytes are zero.
10809            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10810            Ok(())
10811        }
10812    }
10813
10814    impl fidl::encoding::ResourceTypeMarker for Listener {
10815        type Borrowed<'a> = &'a mut Self;
10816        fn take_or_borrow<'a>(
10817            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10818        ) -> Self::Borrowed<'a> {
10819            value
10820        }
10821    }
10822
10823    unsafe impl fidl::encoding::TypeMarker for Listener {
10824        type Owned = Self;
10825
10826        #[inline(always)]
10827        fn inline_align(_context: fidl::encoding::Context) -> usize {
10828            4
10829        }
10830
10831        #[inline(always)]
10832        fn inline_size(_context: fidl::encoding::Context) -> usize {
10833            8
10834        }
10835    }
10836
10837    unsafe impl fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>
10838        for &mut Listener
10839    {
10840        #[inline]
10841        unsafe fn encode(
10842            self,
10843            encoder: &mut fidl::encoding::Encoder<
10844                '_,
10845                fidl::encoding::DefaultFuchsiaResourceDialect,
10846            >,
10847            offset: usize,
10848            _depth: fidl::encoding::Depth,
10849        ) -> fidl::Result<()> {
10850            encoder.debug_check_bounds::<Listener>(offset);
10851            // Delegate to tuple encoding.
10852            fidl::encoding::Encode::<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10853                (
10854                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.port),
10855                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.acceptor),
10856                ),
10857                encoder, offset, _depth
10858            )
10859        }
10860    }
10861    unsafe impl<
10862        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
10863        T1: fidl::encoding::Encode<
10864                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10865                fidl::encoding::DefaultFuchsiaResourceDialect,
10866            >,
10867    > fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0, T1)
10868    {
10869        #[inline]
10870        unsafe fn encode(
10871            self,
10872            encoder: &mut fidl::encoding::Encoder<
10873                '_,
10874                fidl::encoding::DefaultFuchsiaResourceDialect,
10875            >,
10876            offset: usize,
10877            depth: fidl::encoding::Depth,
10878        ) -> fidl::Result<()> {
10879            encoder.debug_check_bounds::<Listener>(offset);
10880            // Zero out padding regions. There's no need to apply masks
10881            // because the unmasked parts will be overwritten by fields.
10882            // Write the fields.
10883            self.0.encode(encoder, offset + 0, depth)?;
10884            self.1.encode(encoder, offset + 4, depth)?;
10885            Ok(())
10886        }
10887    }
10888
10889    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Listener {
10890        #[inline(always)]
10891        fn new_empty() -> Self {
10892            Self {
10893                port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
10894                acceptor: fidl::new_empty!(
10895                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10896                    fidl::encoding::DefaultFuchsiaResourceDialect
10897                ),
10898            }
10899        }
10900
10901        #[inline]
10902        unsafe fn decode(
10903            &mut self,
10904            decoder: &mut fidl::encoding::Decoder<
10905                '_,
10906                fidl::encoding::DefaultFuchsiaResourceDialect,
10907            >,
10908            offset: usize,
10909            _depth: fidl::encoding::Depth,
10910        ) -> fidl::Result<()> {
10911            decoder.debug_check_bounds::<Self>(offset);
10912            // Verify that padding bytes are zero.
10913            fidl::decode!(
10914                u32,
10915                fidl::encoding::DefaultFuchsiaResourceDialect,
10916                &mut self.port,
10917                decoder,
10918                offset + 0,
10919                _depth
10920            )?;
10921            fidl::decode!(
10922                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10923                fidl::encoding::DefaultFuchsiaResourceDialect,
10924                &mut self.acceptor,
10925                decoder,
10926                offset + 4,
10927                _depth
10928            )?;
10929            Ok(())
10930        }
10931    }
10932
10933    impl GuestConfig {
10934        #[inline(always)]
10935        fn max_ordinal_present(&self) -> u64 {
10936            if let Some(_) = self.virtio_mem_region_alignment {
10937                return 25;
10938            }
10939            if let Some(_) = self.virtio_mem_region_size {
10940                return 24;
10941            }
10942            if let Some(_) = self.virtio_mem_block_size {
10943                return 23;
10944            }
10945            if let Some(_) = self.virtio_mem {
10946                return 22;
10947            }
10948            if let Some(_) = self.vsock_listeners {
10949                return 21;
10950            }
10951            if let Some(_) = self.virtio_sound_input {
10952                return 20;
10953            }
10954            if let Some(_) = self.virtio_sound {
10955                return 19;
10956            }
10957            if let Some(_) = self.virtio_vsock {
10958                return 18;
10959            }
10960            if let Some(_) = self.virtio_rng {
10961                return 17;
10962            }
10963            if let Some(_) = self.virtio_gpu {
10964                return 16;
10965            }
10966            if let Some(_) = self.virtio_console {
10967                return 15;
10968            }
10969            if let Some(_) = self.virtio_balloon {
10970                return 14;
10971            }
10972            if let Some(_) = self.default_net {
10973                return 13;
10974            }
10975            if let Some(_) = self.net_devices {
10976                return 10;
10977            }
10978            if let Some(_) = self.block_devices {
10979                return 9;
10980            }
10981            if let Some(_) = self.guest_memory {
10982                return 8;
10983            }
10984            if let Some(_) = self.cpus {
10985                return 7;
10986            }
10987            if let Some(_) = self.cmdline_add {
10988                return 6;
10989            }
10990            if let Some(_) = self.cmdline {
10991                return 5;
10992            }
10993            if let Some(_) = self.dtb_overlay {
10994                return 4;
10995            }
10996            if let Some(_) = self.ramdisk {
10997                return 3;
10998            }
10999            if let Some(_) = self.kernel {
11000                return 2;
11001            }
11002            if let Some(_) = self.kernel_type {
11003                return 1;
11004            }
11005            0
11006        }
11007    }
11008
11009    impl fidl::encoding::ResourceTypeMarker for GuestConfig {
11010        type Borrowed<'a> = &'a mut Self;
11011        fn take_or_borrow<'a>(
11012            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11013        ) -> Self::Borrowed<'a> {
11014            value
11015        }
11016    }
11017
11018    unsafe impl fidl::encoding::TypeMarker for GuestConfig {
11019        type Owned = Self;
11020
11021        #[inline(always)]
11022        fn inline_align(_context: fidl::encoding::Context) -> usize {
11023            8
11024        }
11025
11026        #[inline(always)]
11027        fn inline_size(_context: fidl::encoding::Context) -> usize {
11028            16
11029        }
11030    }
11031
11032    unsafe impl fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
11033        for &mut GuestConfig
11034    {
11035        unsafe fn encode(
11036            self,
11037            encoder: &mut fidl::encoding::Encoder<
11038                '_,
11039                fidl::encoding::DefaultFuchsiaResourceDialect,
11040            >,
11041            offset: usize,
11042            mut depth: fidl::encoding::Depth,
11043        ) -> fidl::Result<()> {
11044            encoder.debug_check_bounds::<GuestConfig>(offset);
11045            // Vector header
11046            let max_ordinal: u64 = self.max_ordinal_present();
11047            encoder.write_num(max_ordinal, offset);
11048            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11049            // Calling encoder.out_of_line_offset(0) is not allowed.
11050            if max_ordinal == 0 {
11051                return Ok(());
11052            }
11053            depth.increment()?;
11054            let envelope_size = 8;
11055            let bytes_len = max_ordinal as usize * envelope_size;
11056            #[allow(unused_variables)]
11057            let offset = encoder.out_of_line_offset(bytes_len);
11058            let mut _prev_end_offset: usize = 0;
11059            if 1 > max_ordinal {
11060                return Ok(());
11061            }
11062
11063            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11064            // are envelope_size bytes.
11065            let cur_offset: usize = (1 - 1) * envelope_size;
11066
11067            // Zero reserved fields.
11068            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11069
11070            // Safety:
11071            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11072            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11073            //   envelope_size bytes, there is always sufficient room.
11074            fidl::encoding::encode_in_envelope_optional::<
11075                KernelType,
11076                fidl::encoding::DefaultFuchsiaResourceDialect,
11077            >(
11078                self.kernel_type
11079                    .as_ref()
11080                    .map(<KernelType as fidl::encoding::ValueTypeMarker>::borrow),
11081                encoder,
11082                offset + cur_offset,
11083                depth,
11084            )?;
11085
11086            _prev_end_offset = cur_offset + envelope_size;
11087            if 2 > max_ordinal {
11088                return Ok(());
11089            }
11090
11091            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11092            // are envelope_size bytes.
11093            let cur_offset: usize = (2 - 1) * envelope_size;
11094
11095            // Zero reserved fields.
11096            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11097
11098            // Safety:
11099            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11100            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11101            //   envelope_size bytes, there is always sufficient room.
11102            fidl::encoding::encode_in_envelope_optional::<
11103                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11104                fidl::encoding::DefaultFuchsiaResourceDialect,
11105            >(
11106                self.kernel.as_mut().map(
11107                    <fidl::encoding::Endpoint<
11108                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11109                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11110                ),
11111                encoder,
11112                offset + cur_offset,
11113                depth,
11114            )?;
11115
11116            _prev_end_offset = cur_offset + envelope_size;
11117            if 3 > max_ordinal {
11118                return Ok(());
11119            }
11120
11121            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11122            // are envelope_size bytes.
11123            let cur_offset: usize = (3 - 1) * envelope_size;
11124
11125            // Zero reserved fields.
11126            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11127
11128            // Safety:
11129            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11130            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11131            //   envelope_size bytes, there is always sufficient room.
11132            fidl::encoding::encode_in_envelope_optional::<
11133                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11134                fidl::encoding::DefaultFuchsiaResourceDialect,
11135            >(
11136                self.ramdisk.as_mut().map(
11137                    <fidl::encoding::Endpoint<
11138                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11139                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11140                ),
11141                encoder,
11142                offset + cur_offset,
11143                depth,
11144            )?;
11145
11146            _prev_end_offset = cur_offset + envelope_size;
11147            if 4 > max_ordinal {
11148                return Ok(());
11149            }
11150
11151            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11152            // are envelope_size bytes.
11153            let cur_offset: usize = (4 - 1) * envelope_size;
11154
11155            // Zero reserved fields.
11156            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11157
11158            // Safety:
11159            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11160            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11161            //   envelope_size bytes, there is always sufficient room.
11162            fidl::encoding::encode_in_envelope_optional::<
11163                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11164                fidl::encoding::DefaultFuchsiaResourceDialect,
11165            >(
11166                self.dtb_overlay.as_mut().map(
11167                    <fidl::encoding::Endpoint<
11168                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11169                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11170                ),
11171                encoder,
11172                offset + cur_offset,
11173                depth,
11174            )?;
11175
11176            _prev_end_offset = cur_offset + envelope_size;
11177            if 5 > max_ordinal {
11178                return Ok(());
11179            }
11180
11181            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11182            // are envelope_size bytes.
11183            let cur_offset: usize = (5 - 1) * envelope_size;
11184
11185            // Zero reserved fields.
11186            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11187
11188            // Safety:
11189            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11190            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11191            //   envelope_size bytes, there is always sufficient room.
11192            fidl::encoding::encode_in_envelope_optional::<
11193                fidl::encoding::UnboundedString,
11194                fidl::encoding::DefaultFuchsiaResourceDialect,
11195            >(
11196                self.cmdline.as_ref().map(
11197                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
11198                ),
11199                encoder,
11200                offset + cur_offset,
11201                depth,
11202            )?;
11203
11204            _prev_end_offset = cur_offset + envelope_size;
11205            if 6 > max_ordinal {
11206                return Ok(());
11207            }
11208
11209            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11210            // are envelope_size bytes.
11211            let cur_offset: usize = (6 - 1) * envelope_size;
11212
11213            // Zero reserved fields.
11214            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11215
11216            // Safety:
11217            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11218            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11219            //   envelope_size bytes, there is always sufficient room.
11220            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11221            self.cmdline_add.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow),
11222            encoder, offset + cur_offset, depth
11223        )?;
11224
11225            _prev_end_offset = cur_offset + envelope_size;
11226            if 7 > max_ordinal {
11227                return Ok(());
11228            }
11229
11230            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11231            // are envelope_size bytes.
11232            let cur_offset: usize = (7 - 1) * envelope_size;
11233
11234            // Zero reserved fields.
11235            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11236
11237            // Safety:
11238            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11239            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11240            //   envelope_size bytes, there is always sufficient room.
11241            fidl::encoding::encode_in_envelope_optional::<
11242                u8,
11243                fidl::encoding::DefaultFuchsiaResourceDialect,
11244            >(
11245                self.cpus.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
11246                encoder,
11247                offset + cur_offset,
11248                depth,
11249            )?;
11250
11251            _prev_end_offset = cur_offset + envelope_size;
11252            if 8 > max_ordinal {
11253                return Ok(());
11254            }
11255
11256            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11257            // are envelope_size bytes.
11258            let cur_offset: usize = (8 - 1) * envelope_size;
11259
11260            // Zero reserved fields.
11261            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11262
11263            // Safety:
11264            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11265            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11266            //   envelope_size bytes, there is always sufficient room.
11267            fidl::encoding::encode_in_envelope_optional::<
11268                u64,
11269                fidl::encoding::DefaultFuchsiaResourceDialect,
11270            >(
11271                self.guest_memory.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11272                encoder,
11273                offset + cur_offset,
11274                depth,
11275            )?;
11276
11277            _prev_end_offset = cur_offset + envelope_size;
11278            if 9 > max_ordinal {
11279                return Ok(());
11280            }
11281
11282            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11283            // are envelope_size bytes.
11284            let cur_offset: usize = (9 - 1) * envelope_size;
11285
11286            // Zero reserved fields.
11287            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11288
11289            // Safety:
11290            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11291            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11292            //   envelope_size bytes, there is always sufficient room.
11293            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11294            self.block_devices.as_mut().map(<fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11295            encoder, offset + cur_offset, depth
11296        )?;
11297
11298            _prev_end_offset = cur_offset + envelope_size;
11299            if 10 > max_ordinal {
11300                return Ok(());
11301            }
11302
11303            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11304            // are envelope_size bytes.
11305            let cur_offset: usize = (10 - 1) * envelope_size;
11306
11307            // Zero reserved fields.
11308            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11309
11310            // Safety:
11311            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11312            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11313            //   envelope_size bytes, there is always sufficient room.
11314            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11315            self.net_devices.as_ref().map(<fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11316            encoder, offset + cur_offset, depth
11317        )?;
11318
11319            _prev_end_offset = cur_offset + envelope_size;
11320            if 13 > max_ordinal {
11321                return Ok(());
11322            }
11323
11324            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11325            // are envelope_size bytes.
11326            let cur_offset: usize = (13 - 1) * envelope_size;
11327
11328            // Zero reserved fields.
11329            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11330
11331            // Safety:
11332            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11333            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11334            //   envelope_size bytes, there is always sufficient room.
11335            fidl::encoding::encode_in_envelope_optional::<
11336                bool,
11337                fidl::encoding::DefaultFuchsiaResourceDialect,
11338            >(
11339                self.default_net.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11340                encoder,
11341                offset + cur_offset,
11342                depth,
11343            )?;
11344
11345            _prev_end_offset = cur_offset + envelope_size;
11346            if 14 > max_ordinal {
11347                return Ok(());
11348            }
11349
11350            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11351            // are envelope_size bytes.
11352            let cur_offset: usize = (14 - 1) * envelope_size;
11353
11354            // Zero reserved fields.
11355            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11356
11357            // Safety:
11358            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11359            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11360            //   envelope_size bytes, there is always sufficient room.
11361            fidl::encoding::encode_in_envelope_optional::<
11362                bool,
11363                fidl::encoding::DefaultFuchsiaResourceDialect,
11364            >(
11365                self.virtio_balloon.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11366                encoder,
11367                offset + cur_offset,
11368                depth,
11369            )?;
11370
11371            _prev_end_offset = cur_offset + envelope_size;
11372            if 15 > max_ordinal {
11373                return Ok(());
11374            }
11375
11376            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11377            // are envelope_size bytes.
11378            let cur_offset: usize = (15 - 1) * envelope_size;
11379
11380            // Zero reserved fields.
11381            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11382
11383            // Safety:
11384            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11385            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11386            //   envelope_size bytes, there is always sufficient room.
11387            fidl::encoding::encode_in_envelope_optional::<
11388                bool,
11389                fidl::encoding::DefaultFuchsiaResourceDialect,
11390            >(
11391                self.virtio_console.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11392                encoder,
11393                offset + cur_offset,
11394                depth,
11395            )?;
11396
11397            _prev_end_offset = cur_offset + envelope_size;
11398            if 16 > max_ordinal {
11399                return Ok(());
11400            }
11401
11402            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11403            // are envelope_size bytes.
11404            let cur_offset: usize = (16 - 1) * envelope_size;
11405
11406            // Zero reserved fields.
11407            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11408
11409            // Safety:
11410            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11411            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11412            //   envelope_size bytes, there is always sufficient room.
11413            fidl::encoding::encode_in_envelope_optional::<
11414                bool,
11415                fidl::encoding::DefaultFuchsiaResourceDialect,
11416            >(
11417                self.virtio_gpu.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11418                encoder,
11419                offset + cur_offset,
11420                depth,
11421            )?;
11422
11423            _prev_end_offset = cur_offset + envelope_size;
11424            if 17 > max_ordinal {
11425                return Ok(());
11426            }
11427
11428            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11429            // are envelope_size bytes.
11430            let cur_offset: usize = (17 - 1) * envelope_size;
11431
11432            // Zero reserved fields.
11433            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11434
11435            // Safety:
11436            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11437            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11438            //   envelope_size bytes, there is always sufficient room.
11439            fidl::encoding::encode_in_envelope_optional::<
11440                bool,
11441                fidl::encoding::DefaultFuchsiaResourceDialect,
11442            >(
11443                self.virtio_rng.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11444                encoder,
11445                offset + cur_offset,
11446                depth,
11447            )?;
11448
11449            _prev_end_offset = cur_offset + envelope_size;
11450            if 18 > max_ordinal {
11451                return Ok(());
11452            }
11453
11454            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11455            // are envelope_size bytes.
11456            let cur_offset: usize = (18 - 1) * envelope_size;
11457
11458            // Zero reserved fields.
11459            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11460
11461            // Safety:
11462            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11463            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11464            //   envelope_size bytes, there is always sufficient room.
11465            fidl::encoding::encode_in_envelope_optional::<
11466                bool,
11467                fidl::encoding::DefaultFuchsiaResourceDialect,
11468            >(
11469                self.virtio_vsock.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11470                encoder,
11471                offset + cur_offset,
11472                depth,
11473            )?;
11474
11475            _prev_end_offset = cur_offset + envelope_size;
11476            if 19 > max_ordinal {
11477                return Ok(());
11478            }
11479
11480            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11481            // are envelope_size bytes.
11482            let cur_offset: usize = (19 - 1) * envelope_size;
11483
11484            // Zero reserved fields.
11485            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11486
11487            // Safety:
11488            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11489            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11490            //   envelope_size bytes, there is always sufficient room.
11491            fidl::encoding::encode_in_envelope_optional::<
11492                bool,
11493                fidl::encoding::DefaultFuchsiaResourceDialect,
11494            >(
11495                self.virtio_sound.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11496                encoder,
11497                offset + cur_offset,
11498                depth,
11499            )?;
11500
11501            _prev_end_offset = cur_offset + envelope_size;
11502            if 20 > max_ordinal {
11503                return Ok(());
11504            }
11505
11506            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11507            // are envelope_size bytes.
11508            let cur_offset: usize = (20 - 1) * envelope_size;
11509
11510            // Zero reserved fields.
11511            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11512
11513            // Safety:
11514            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11515            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11516            //   envelope_size bytes, there is always sufficient room.
11517            fidl::encoding::encode_in_envelope_optional::<
11518                bool,
11519                fidl::encoding::DefaultFuchsiaResourceDialect,
11520            >(
11521                self.virtio_sound_input
11522                    .as_ref()
11523                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11524                encoder,
11525                offset + cur_offset,
11526                depth,
11527            )?;
11528
11529            _prev_end_offset = cur_offset + envelope_size;
11530            if 21 > max_ordinal {
11531                return Ok(());
11532            }
11533
11534            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11535            // are envelope_size bytes.
11536            let cur_offset: usize = (21 - 1) * envelope_size;
11537
11538            // Zero reserved fields.
11539            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11540
11541            // Safety:
11542            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11543            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11544            //   envelope_size bytes, there is always sufficient room.
11545            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Listener>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11546            self.vsock_listeners.as_mut().map(<fidl::encoding::UnboundedVector<Listener> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11547            encoder, offset + cur_offset, depth
11548        )?;
11549
11550            _prev_end_offset = cur_offset + envelope_size;
11551            if 22 > max_ordinal {
11552                return Ok(());
11553            }
11554
11555            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11556            // are envelope_size bytes.
11557            let cur_offset: usize = (22 - 1) * envelope_size;
11558
11559            // Zero reserved fields.
11560            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11561
11562            // Safety:
11563            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11564            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11565            //   envelope_size bytes, there is always sufficient room.
11566            fidl::encoding::encode_in_envelope_optional::<
11567                bool,
11568                fidl::encoding::DefaultFuchsiaResourceDialect,
11569            >(
11570                self.virtio_mem.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11571                encoder,
11572                offset + cur_offset,
11573                depth,
11574            )?;
11575
11576            _prev_end_offset = cur_offset + envelope_size;
11577            if 23 > max_ordinal {
11578                return Ok(());
11579            }
11580
11581            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11582            // are envelope_size bytes.
11583            let cur_offset: usize = (23 - 1) * envelope_size;
11584
11585            // Zero reserved fields.
11586            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11587
11588            // Safety:
11589            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11590            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11591            //   envelope_size bytes, there is always sufficient room.
11592            fidl::encoding::encode_in_envelope_optional::<
11593                u64,
11594                fidl::encoding::DefaultFuchsiaResourceDialect,
11595            >(
11596                self.virtio_mem_block_size
11597                    .as_ref()
11598                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11599                encoder,
11600                offset + cur_offset,
11601                depth,
11602            )?;
11603
11604            _prev_end_offset = cur_offset + envelope_size;
11605            if 24 > max_ordinal {
11606                return Ok(());
11607            }
11608
11609            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11610            // are envelope_size bytes.
11611            let cur_offset: usize = (24 - 1) * envelope_size;
11612
11613            // Zero reserved fields.
11614            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11615
11616            // Safety:
11617            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11618            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11619            //   envelope_size bytes, there is always sufficient room.
11620            fidl::encoding::encode_in_envelope_optional::<
11621                u64,
11622                fidl::encoding::DefaultFuchsiaResourceDialect,
11623            >(
11624                self.virtio_mem_region_size
11625                    .as_ref()
11626                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11627                encoder,
11628                offset + cur_offset,
11629                depth,
11630            )?;
11631
11632            _prev_end_offset = cur_offset + envelope_size;
11633            if 25 > max_ordinal {
11634                return Ok(());
11635            }
11636
11637            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11638            // are envelope_size bytes.
11639            let cur_offset: usize = (25 - 1) * envelope_size;
11640
11641            // Zero reserved fields.
11642            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11643
11644            // Safety:
11645            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11646            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11647            //   envelope_size bytes, there is always sufficient room.
11648            fidl::encoding::encode_in_envelope_optional::<
11649                u64,
11650                fidl::encoding::DefaultFuchsiaResourceDialect,
11651            >(
11652                self.virtio_mem_region_alignment
11653                    .as_ref()
11654                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11655                encoder,
11656                offset + cur_offset,
11657                depth,
11658            )?;
11659
11660            _prev_end_offset = cur_offset + envelope_size;
11661
11662            Ok(())
11663        }
11664    }
11665
11666    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for GuestConfig {
11667        #[inline(always)]
11668        fn new_empty() -> Self {
11669            Self::default()
11670        }
11671
11672        unsafe fn decode(
11673            &mut self,
11674            decoder: &mut fidl::encoding::Decoder<
11675                '_,
11676                fidl::encoding::DefaultFuchsiaResourceDialect,
11677            >,
11678            offset: usize,
11679            mut depth: fidl::encoding::Depth,
11680        ) -> fidl::Result<()> {
11681            decoder.debug_check_bounds::<Self>(offset);
11682            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11683                None => return Err(fidl::Error::NotNullable),
11684                Some(len) => len,
11685            };
11686            // Calling decoder.out_of_line_offset(0) is not allowed.
11687            if len == 0 {
11688                return Ok(());
11689            };
11690            depth.increment()?;
11691            let envelope_size = 8;
11692            let bytes_len = len * envelope_size;
11693            let offset = decoder.out_of_line_offset(bytes_len)?;
11694            // Decode the envelope for each type.
11695            let mut _next_ordinal_to_read = 0;
11696            let mut next_offset = offset;
11697            let end_offset = offset + bytes_len;
11698            _next_ordinal_to_read += 1;
11699            if next_offset >= end_offset {
11700                return Ok(());
11701            }
11702
11703            // Decode unknown envelopes for gaps in ordinals.
11704            while _next_ordinal_to_read < 1 {
11705                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11706                _next_ordinal_to_read += 1;
11707                next_offset += envelope_size;
11708            }
11709
11710            let next_out_of_line = decoder.next_out_of_line();
11711            let handles_before = decoder.remaining_handles();
11712            if let Some((inlined, num_bytes, num_handles)) =
11713                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11714            {
11715                let member_inline_size =
11716                    <KernelType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11717                if inlined != (member_inline_size <= 4) {
11718                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11719                }
11720                let inner_offset;
11721                let mut inner_depth = depth.clone();
11722                if inlined {
11723                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11724                    inner_offset = next_offset;
11725                } else {
11726                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11727                    inner_depth.increment()?;
11728                }
11729                let val_ref = self.kernel_type.get_or_insert_with(|| {
11730                    fidl::new_empty!(KernelType, fidl::encoding::DefaultFuchsiaResourceDialect)
11731                });
11732                fidl::decode!(
11733                    KernelType,
11734                    fidl::encoding::DefaultFuchsiaResourceDialect,
11735                    val_ref,
11736                    decoder,
11737                    inner_offset,
11738                    inner_depth
11739                )?;
11740                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11741                {
11742                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11743                }
11744                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11745                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11746                }
11747            }
11748
11749            next_offset += envelope_size;
11750            _next_ordinal_to_read += 1;
11751            if next_offset >= end_offset {
11752                return Ok(());
11753            }
11754
11755            // Decode unknown envelopes for gaps in ordinals.
11756            while _next_ordinal_to_read < 2 {
11757                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11758                _next_ordinal_to_read += 1;
11759                next_offset += envelope_size;
11760            }
11761
11762            let next_out_of_line = decoder.next_out_of_line();
11763            let handles_before = decoder.remaining_handles();
11764            if let Some((inlined, num_bytes, num_handles)) =
11765                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11766            {
11767                let member_inline_size = <fidl::encoding::Endpoint<
11768                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11769                > as fidl::encoding::TypeMarker>::inline_size(
11770                    decoder.context
11771                );
11772                if inlined != (member_inline_size <= 4) {
11773                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11774                }
11775                let inner_offset;
11776                let mut inner_depth = depth.clone();
11777                if inlined {
11778                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11779                    inner_offset = next_offset;
11780                } else {
11781                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11782                    inner_depth.increment()?;
11783                }
11784                let val_ref = self.kernel.get_or_insert_with(|| {
11785                    fidl::new_empty!(
11786                        fidl::encoding::Endpoint<
11787                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11788                        >,
11789                        fidl::encoding::DefaultFuchsiaResourceDialect
11790                    )
11791                });
11792                fidl::decode!(
11793                    fidl::encoding::Endpoint<
11794                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11795                    >,
11796                    fidl::encoding::DefaultFuchsiaResourceDialect,
11797                    val_ref,
11798                    decoder,
11799                    inner_offset,
11800                    inner_depth
11801                )?;
11802                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11803                {
11804                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11805                }
11806                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11807                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11808                }
11809            }
11810
11811            next_offset += envelope_size;
11812            _next_ordinal_to_read += 1;
11813            if next_offset >= end_offset {
11814                return Ok(());
11815            }
11816
11817            // Decode unknown envelopes for gaps in ordinals.
11818            while _next_ordinal_to_read < 3 {
11819                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11820                _next_ordinal_to_read += 1;
11821                next_offset += envelope_size;
11822            }
11823
11824            let next_out_of_line = decoder.next_out_of_line();
11825            let handles_before = decoder.remaining_handles();
11826            if let Some((inlined, num_bytes, num_handles)) =
11827                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11828            {
11829                let member_inline_size = <fidl::encoding::Endpoint<
11830                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11831                > as fidl::encoding::TypeMarker>::inline_size(
11832                    decoder.context
11833                );
11834                if inlined != (member_inline_size <= 4) {
11835                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11836                }
11837                let inner_offset;
11838                let mut inner_depth = depth.clone();
11839                if inlined {
11840                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11841                    inner_offset = next_offset;
11842                } else {
11843                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11844                    inner_depth.increment()?;
11845                }
11846                let val_ref = self.ramdisk.get_or_insert_with(|| {
11847                    fidl::new_empty!(
11848                        fidl::encoding::Endpoint<
11849                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11850                        >,
11851                        fidl::encoding::DefaultFuchsiaResourceDialect
11852                    )
11853                });
11854                fidl::decode!(
11855                    fidl::encoding::Endpoint<
11856                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11857                    >,
11858                    fidl::encoding::DefaultFuchsiaResourceDialect,
11859                    val_ref,
11860                    decoder,
11861                    inner_offset,
11862                    inner_depth
11863                )?;
11864                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11865                {
11866                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11867                }
11868                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11869                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11870                }
11871            }
11872
11873            next_offset += envelope_size;
11874            _next_ordinal_to_read += 1;
11875            if next_offset >= end_offset {
11876                return Ok(());
11877            }
11878
11879            // Decode unknown envelopes for gaps in ordinals.
11880            while _next_ordinal_to_read < 4 {
11881                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11882                _next_ordinal_to_read += 1;
11883                next_offset += envelope_size;
11884            }
11885
11886            let next_out_of_line = decoder.next_out_of_line();
11887            let handles_before = decoder.remaining_handles();
11888            if let Some((inlined, num_bytes, num_handles)) =
11889                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11890            {
11891                let member_inline_size = <fidl::encoding::Endpoint<
11892                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11893                > as fidl::encoding::TypeMarker>::inline_size(
11894                    decoder.context
11895                );
11896                if inlined != (member_inline_size <= 4) {
11897                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11898                }
11899                let inner_offset;
11900                let mut inner_depth = depth.clone();
11901                if inlined {
11902                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11903                    inner_offset = next_offset;
11904                } else {
11905                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11906                    inner_depth.increment()?;
11907                }
11908                let val_ref = self.dtb_overlay.get_or_insert_with(|| {
11909                    fidl::new_empty!(
11910                        fidl::encoding::Endpoint<
11911                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11912                        >,
11913                        fidl::encoding::DefaultFuchsiaResourceDialect
11914                    )
11915                });
11916                fidl::decode!(
11917                    fidl::encoding::Endpoint<
11918                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11919                    >,
11920                    fidl::encoding::DefaultFuchsiaResourceDialect,
11921                    val_ref,
11922                    decoder,
11923                    inner_offset,
11924                    inner_depth
11925                )?;
11926                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11927                {
11928                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11929                }
11930                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11931                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11932                }
11933            }
11934
11935            next_offset += envelope_size;
11936            _next_ordinal_to_read += 1;
11937            if next_offset >= end_offset {
11938                return Ok(());
11939            }
11940
11941            // Decode unknown envelopes for gaps in ordinals.
11942            while _next_ordinal_to_read < 5 {
11943                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11944                _next_ordinal_to_read += 1;
11945                next_offset += envelope_size;
11946            }
11947
11948            let next_out_of_line = decoder.next_out_of_line();
11949            let handles_before = decoder.remaining_handles();
11950            if let Some((inlined, num_bytes, num_handles)) =
11951                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11952            {
11953                let member_inline_size =
11954                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
11955                        decoder.context,
11956                    );
11957                if inlined != (member_inline_size <= 4) {
11958                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11959                }
11960                let inner_offset;
11961                let mut inner_depth = depth.clone();
11962                if inlined {
11963                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11964                    inner_offset = next_offset;
11965                } else {
11966                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11967                    inner_depth.increment()?;
11968                }
11969                let val_ref = self.cmdline.get_or_insert_with(|| {
11970                    fidl::new_empty!(
11971                        fidl::encoding::UnboundedString,
11972                        fidl::encoding::DefaultFuchsiaResourceDialect
11973                    )
11974                });
11975                fidl::decode!(
11976                    fidl::encoding::UnboundedString,
11977                    fidl::encoding::DefaultFuchsiaResourceDialect,
11978                    val_ref,
11979                    decoder,
11980                    inner_offset,
11981                    inner_depth
11982                )?;
11983                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11984                {
11985                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11986                }
11987                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11988                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11989                }
11990            }
11991
11992            next_offset += envelope_size;
11993            _next_ordinal_to_read += 1;
11994            if next_offset >= end_offset {
11995                return Ok(());
11996            }
11997
11998            // Decode unknown envelopes for gaps in ordinals.
11999            while _next_ordinal_to_read < 6 {
12000                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12001                _next_ordinal_to_read += 1;
12002                next_offset += envelope_size;
12003            }
12004
12005            let next_out_of_line = decoder.next_out_of_line();
12006            let handles_before = decoder.remaining_handles();
12007            if let Some((inlined, num_bytes, num_handles)) =
12008                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12009            {
12010                let member_inline_size = <fidl::encoding::UnboundedVector<
12011                    fidl::encoding::UnboundedString,
12012                > as fidl::encoding::TypeMarker>::inline_size(
12013                    decoder.context
12014                );
12015                if inlined != (member_inline_size <= 4) {
12016                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12017                }
12018                let inner_offset;
12019                let mut inner_depth = depth.clone();
12020                if inlined {
12021                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12022                    inner_offset = next_offset;
12023                } else {
12024                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12025                    inner_depth.increment()?;
12026                }
12027                let val_ref = self.cmdline_add.get_or_insert_with(|| {
12028                    fidl::new_empty!(
12029                        fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
12030                        fidl::encoding::DefaultFuchsiaResourceDialect
12031                    )
12032                });
12033                fidl::decode!(
12034                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
12035                    fidl::encoding::DefaultFuchsiaResourceDialect,
12036                    val_ref,
12037                    decoder,
12038                    inner_offset,
12039                    inner_depth
12040                )?;
12041                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12042                {
12043                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12044                }
12045                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12046                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12047                }
12048            }
12049
12050            next_offset += envelope_size;
12051            _next_ordinal_to_read += 1;
12052            if next_offset >= end_offset {
12053                return Ok(());
12054            }
12055
12056            // Decode unknown envelopes for gaps in ordinals.
12057            while _next_ordinal_to_read < 7 {
12058                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12059                _next_ordinal_to_read += 1;
12060                next_offset += envelope_size;
12061            }
12062
12063            let next_out_of_line = decoder.next_out_of_line();
12064            let handles_before = decoder.remaining_handles();
12065            if let Some((inlined, num_bytes, num_handles)) =
12066                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12067            {
12068                let member_inline_size =
12069                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12070                if inlined != (member_inline_size <= 4) {
12071                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12072                }
12073                let inner_offset;
12074                let mut inner_depth = depth.clone();
12075                if inlined {
12076                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12077                    inner_offset = next_offset;
12078                } else {
12079                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12080                    inner_depth.increment()?;
12081                }
12082                let val_ref = self.cpus.get_or_insert_with(|| {
12083                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12084                });
12085                fidl::decode!(
12086                    u8,
12087                    fidl::encoding::DefaultFuchsiaResourceDialect,
12088                    val_ref,
12089                    decoder,
12090                    inner_offset,
12091                    inner_depth
12092                )?;
12093                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12094                {
12095                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12096                }
12097                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12098                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12099                }
12100            }
12101
12102            next_offset += envelope_size;
12103            _next_ordinal_to_read += 1;
12104            if next_offset >= end_offset {
12105                return Ok(());
12106            }
12107
12108            // Decode unknown envelopes for gaps in ordinals.
12109            while _next_ordinal_to_read < 8 {
12110                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12111                _next_ordinal_to_read += 1;
12112                next_offset += envelope_size;
12113            }
12114
12115            let next_out_of_line = decoder.next_out_of_line();
12116            let handles_before = decoder.remaining_handles();
12117            if let Some((inlined, num_bytes, num_handles)) =
12118                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12119            {
12120                let member_inline_size =
12121                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12122                if inlined != (member_inline_size <= 4) {
12123                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12124                }
12125                let inner_offset;
12126                let mut inner_depth = depth.clone();
12127                if inlined {
12128                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12129                    inner_offset = next_offset;
12130                } else {
12131                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12132                    inner_depth.increment()?;
12133                }
12134                let val_ref = self.guest_memory.get_or_insert_with(|| {
12135                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12136                });
12137                fidl::decode!(
12138                    u64,
12139                    fidl::encoding::DefaultFuchsiaResourceDialect,
12140                    val_ref,
12141                    decoder,
12142                    inner_offset,
12143                    inner_depth
12144                )?;
12145                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12146                {
12147                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12148                }
12149                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12150                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12151                }
12152            }
12153
12154            next_offset += envelope_size;
12155            _next_ordinal_to_read += 1;
12156            if next_offset >= end_offset {
12157                return Ok(());
12158            }
12159
12160            // Decode unknown envelopes for gaps in ordinals.
12161            while _next_ordinal_to_read < 9 {
12162                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12163                _next_ordinal_to_read += 1;
12164                next_offset += envelope_size;
12165            }
12166
12167            let next_out_of_line = decoder.next_out_of_line();
12168            let handles_before = decoder.remaining_handles();
12169            if let Some((inlined, num_bytes, num_handles)) =
12170                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12171            {
12172                let member_inline_size = <fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12173                if inlined != (member_inline_size <= 4) {
12174                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12175                }
12176                let inner_offset;
12177                let mut inner_depth = depth.clone();
12178                if inlined {
12179                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12180                    inner_offset = next_offset;
12181                } else {
12182                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12183                    inner_depth.increment()?;
12184                }
12185                let val_ref =
12186                self.block_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12187                fidl::decode!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12188                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12189                {
12190                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12191                }
12192                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12193                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12194                }
12195            }
12196
12197            next_offset += envelope_size;
12198            _next_ordinal_to_read += 1;
12199            if next_offset >= end_offset {
12200                return Ok(());
12201            }
12202
12203            // Decode unknown envelopes for gaps in ordinals.
12204            while _next_ordinal_to_read < 10 {
12205                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12206                _next_ordinal_to_read += 1;
12207                next_offset += envelope_size;
12208            }
12209
12210            let next_out_of_line = decoder.next_out_of_line();
12211            let handles_before = decoder.remaining_handles();
12212            if let Some((inlined, num_bytes, num_handles)) =
12213                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12214            {
12215                let member_inline_size = <fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12216                if inlined != (member_inline_size <= 4) {
12217                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12218                }
12219                let inner_offset;
12220                let mut inner_depth = depth.clone();
12221                if inlined {
12222                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12223                    inner_offset = next_offset;
12224                } else {
12225                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12226                    inner_depth.increment()?;
12227                }
12228                let val_ref =
12229                self.net_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12230                fidl::decode!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12231                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12232                {
12233                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12234                }
12235                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12236                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12237                }
12238            }
12239
12240            next_offset += envelope_size;
12241            _next_ordinal_to_read += 1;
12242            if next_offset >= end_offset {
12243                return Ok(());
12244            }
12245
12246            // Decode unknown envelopes for gaps in ordinals.
12247            while _next_ordinal_to_read < 13 {
12248                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12249                _next_ordinal_to_read += 1;
12250                next_offset += envelope_size;
12251            }
12252
12253            let next_out_of_line = decoder.next_out_of_line();
12254            let handles_before = decoder.remaining_handles();
12255            if let Some((inlined, num_bytes, num_handles)) =
12256                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12257            {
12258                let member_inline_size =
12259                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12260                if inlined != (member_inline_size <= 4) {
12261                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12262                }
12263                let inner_offset;
12264                let mut inner_depth = depth.clone();
12265                if inlined {
12266                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12267                    inner_offset = next_offset;
12268                } else {
12269                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12270                    inner_depth.increment()?;
12271                }
12272                let val_ref = self.default_net.get_or_insert_with(|| {
12273                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12274                });
12275                fidl::decode!(
12276                    bool,
12277                    fidl::encoding::DefaultFuchsiaResourceDialect,
12278                    val_ref,
12279                    decoder,
12280                    inner_offset,
12281                    inner_depth
12282                )?;
12283                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12284                {
12285                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12286                }
12287                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12288                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12289                }
12290            }
12291
12292            next_offset += envelope_size;
12293            _next_ordinal_to_read += 1;
12294            if next_offset >= end_offset {
12295                return Ok(());
12296            }
12297
12298            // Decode unknown envelopes for gaps in ordinals.
12299            while _next_ordinal_to_read < 14 {
12300                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12301                _next_ordinal_to_read += 1;
12302                next_offset += envelope_size;
12303            }
12304
12305            let next_out_of_line = decoder.next_out_of_line();
12306            let handles_before = decoder.remaining_handles();
12307            if let Some((inlined, num_bytes, num_handles)) =
12308                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12309            {
12310                let member_inline_size =
12311                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12312                if inlined != (member_inline_size <= 4) {
12313                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12314                }
12315                let inner_offset;
12316                let mut inner_depth = depth.clone();
12317                if inlined {
12318                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12319                    inner_offset = next_offset;
12320                } else {
12321                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12322                    inner_depth.increment()?;
12323                }
12324                let val_ref = self.virtio_balloon.get_or_insert_with(|| {
12325                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12326                });
12327                fidl::decode!(
12328                    bool,
12329                    fidl::encoding::DefaultFuchsiaResourceDialect,
12330                    val_ref,
12331                    decoder,
12332                    inner_offset,
12333                    inner_depth
12334                )?;
12335                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12336                {
12337                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12338                }
12339                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12340                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12341                }
12342            }
12343
12344            next_offset += envelope_size;
12345            _next_ordinal_to_read += 1;
12346            if next_offset >= end_offset {
12347                return Ok(());
12348            }
12349
12350            // Decode unknown envelopes for gaps in ordinals.
12351            while _next_ordinal_to_read < 15 {
12352                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12353                _next_ordinal_to_read += 1;
12354                next_offset += envelope_size;
12355            }
12356
12357            let next_out_of_line = decoder.next_out_of_line();
12358            let handles_before = decoder.remaining_handles();
12359            if let Some((inlined, num_bytes, num_handles)) =
12360                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12361            {
12362                let member_inline_size =
12363                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12364                if inlined != (member_inline_size <= 4) {
12365                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12366                }
12367                let inner_offset;
12368                let mut inner_depth = depth.clone();
12369                if inlined {
12370                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12371                    inner_offset = next_offset;
12372                } else {
12373                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12374                    inner_depth.increment()?;
12375                }
12376                let val_ref = self.virtio_console.get_or_insert_with(|| {
12377                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12378                });
12379                fidl::decode!(
12380                    bool,
12381                    fidl::encoding::DefaultFuchsiaResourceDialect,
12382                    val_ref,
12383                    decoder,
12384                    inner_offset,
12385                    inner_depth
12386                )?;
12387                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12388                {
12389                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12390                }
12391                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12392                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12393                }
12394            }
12395
12396            next_offset += envelope_size;
12397            _next_ordinal_to_read += 1;
12398            if next_offset >= end_offset {
12399                return Ok(());
12400            }
12401
12402            // Decode unknown envelopes for gaps in ordinals.
12403            while _next_ordinal_to_read < 16 {
12404                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12405                _next_ordinal_to_read += 1;
12406                next_offset += envelope_size;
12407            }
12408
12409            let next_out_of_line = decoder.next_out_of_line();
12410            let handles_before = decoder.remaining_handles();
12411            if let Some((inlined, num_bytes, num_handles)) =
12412                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12413            {
12414                let member_inline_size =
12415                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12416                if inlined != (member_inline_size <= 4) {
12417                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12418                }
12419                let inner_offset;
12420                let mut inner_depth = depth.clone();
12421                if inlined {
12422                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12423                    inner_offset = next_offset;
12424                } else {
12425                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12426                    inner_depth.increment()?;
12427                }
12428                let val_ref = self.virtio_gpu.get_or_insert_with(|| {
12429                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12430                });
12431                fidl::decode!(
12432                    bool,
12433                    fidl::encoding::DefaultFuchsiaResourceDialect,
12434                    val_ref,
12435                    decoder,
12436                    inner_offset,
12437                    inner_depth
12438                )?;
12439                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12440                {
12441                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12442                }
12443                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12444                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12445                }
12446            }
12447
12448            next_offset += envelope_size;
12449            _next_ordinal_to_read += 1;
12450            if next_offset >= end_offset {
12451                return Ok(());
12452            }
12453
12454            // Decode unknown envelopes for gaps in ordinals.
12455            while _next_ordinal_to_read < 17 {
12456                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12457                _next_ordinal_to_read += 1;
12458                next_offset += envelope_size;
12459            }
12460
12461            let next_out_of_line = decoder.next_out_of_line();
12462            let handles_before = decoder.remaining_handles();
12463            if let Some((inlined, num_bytes, num_handles)) =
12464                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12465            {
12466                let member_inline_size =
12467                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12468                if inlined != (member_inline_size <= 4) {
12469                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12470                }
12471                let inner_offset;
12472                let mut inner_depth = depth.clone();
12473                if inlined {
12474                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12475                    inner_offset = next_offset;
12476                } else {
12477                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12478                    inner_depth.increment()?;
12479                }
12480                let val_ref = self.virtio_rng.get_or_insert_with(|| {
12481                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12482                });
12483                fidl::decode!(
12484                    bool,
12485                    fidl::encoding::DefaultFuchsiaResourceDialect,
12486                    val_ref,
12487                    decoder,
12488                    inner_offset,
12489                    inner_depth
12490                )?;
12491                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12492                {
12493                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12494                }
12495                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12496                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12497                }
12498            }
12499
12500            next_offset += envelope_size;
12501            _next_ordinal_to_read += 1;
12502            if next_offset >= end_offset {
12503                return Ok(());
12504            }
12505
12506            // Decode unknown envelopes for gaps in ordinals.
12507            while _next_ordinal_to_read < 18 {
12508                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12509                _next_ordinal_to_read += 1;
12510                next_offset += envelope_size;
12511            }
12512
12513            let next_out_of_line = decoder.next_out_of_line();
12514            let handles_before = decoder.remaining_handles();
12515            if let Some((inlined, num_bytes, num_handles)) =
12516                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12517            {
12518                let member_inline_size =
12519                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12520                if inlined != (member_inline_size <= 4) {
12521                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12522                }
12523                let inner_offset;
12524                let mut inner_depth = depth.clone();
12525                if inlined {
12526                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12527                    inner_offset = next_offset;
12528                } else {
12529                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12530                    inner_depth.increment()?;
12531                }
12532                let val_ref = self.virtio_vsock.get_or_insert_with(|| {
12533                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12534                });
12535                fidl::decode!(
12536                    bool,
12537                    fidl::encoding::DefaultFuchsiaResourceDialect,
12538                    val_ref,
12539                    decoder,
12540                    inner_offset,
12541                    inner_depth
12542                )?;
12543                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12544                {
12545                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12546                }
12547                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12548                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12549                }
12550            }
12551
12552            next_offset += envelope_size;
12553            _next_ordinal_to_read += 1;
12554            if next_offset >= end_offset {
12555                return Ok(());
12556            }
12557
12558            // Decode unknown envelopes for gaps in ordinals.
12559            while _next_ordinal_to_read < 19 {
12560                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12561                _next_ordinal_to_read += 1;
12562                next_offset += envelope_size;
12563            }
12564
12565            let next_out_of_line = decoder.next_out_of_line();
12566            let handles_before = decoder.remaining_handles();
12567            if let Some((inlined, num_bytes, num_handles)) =
12568                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12569            {
12570                let member_inline_size =
12571                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12572                if inlined != (member_inline_size <= 4) {
12573                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12574                }
12575                let inner_offset;
12576                let mut inner_depth = depth.clone();
12577                if inlined {
12578                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12579                    inner_offset = next_offset;
12580                } else {
12581                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12582                    inner_depth.increment()?;
12583                }
12584                let val_ref = self.virtio_sound.get_or_insert_with(|| {
12585                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12586                });
12587                fidl::decode!(
12588                    bool,
12589                    fidl::encoding::DefaultFuchsiaResourceDialect,
12590                    val_ref,
12591                    decoder,
12592                    inner_offset,
12593                    inner_depth
12594                )?;
12595                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12596                {
12597                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12598                }
12599                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12600                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12601                }
12602            }
12603
12604            next_offset += envelope_size;
12605            _next_ordinal_to_read += 1;
12606            if next_offset >= end_offset {
12607                return Ok(());
12608            }
12609
12610            // Decode unknown envelopes for gaps in ordinals.
12611            while _next_ordinal_to_read < 20 {
12612                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12613                _next_ordinal_to_read += 1;
12614                next_offset += envelope_size;
12615            }
12616
12617            let next_out_of_line = decoder.next_out_of_line();
12618            let handles_before = decoder.remaining_handles();
12619            if let Some((inlined, num_bytes, num_handles)) =
12620                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12621            {
12622                let member_inline_size =
12623                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12624                if inlined != (member_inline_size <= 4) {
12625                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12626                }
12627                let inner_offset;
12628                let mut inner_depth = depth.clone();
12629                if inlined {
12630                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12631                    inner_offset = next_offset;
12632                } else {
12633                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12634                    inner_depth.increment()?;
12635                }
12636                let val_ref = self.virtio_sound_input.get_or_insert_with(|| {
12637                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12638                });
12639                fidl::decode!(
12640                    bool,
12641                    fidl::encoding::DefaultFuchsiaResourceDialect,
12642                    val_ref,
12643                    decoder,
12644                    inner_offset,
12645                    inner_depth
12646                )?;
12647                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12648                {
12649                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12650                }
12651                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12652                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12653                }
12654            }
12655
12656            next_offset += envelope_size;
12657            _next_ordinal_to_read += 1;
12658            if next_offset >= end_offset {
12659                return Ok(());
12660            }
12661
12662            // Decode unknown envelopes for gaps in ordinals.
12663            while _next_ordinal_to_read < 21 {
12664                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12665                _next_ordinal_to_read += 1;
12666                next_offset += envelope_size;
12667            }
12668
12669            let next_out_of_line = decoder.next_out_of_line();
12670            let handles_before = decoder.remaining_handles();
12671            if let Some((inlined, num_bytes, num_handles)) =
12672                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12673            {
12674                let member_inline_size = <fidl::encoding::UnboundedVector<Listener> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12675                if inlined != (member_inline_size <= 4) {
12676                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12677                }
12678                let inner_offset;
12679                let mut inner_depth = depth.clone();
12680                if inlined {
12681                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12682                    inner_offset = next_offset;
12683                } else {
12684                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12685                    inner_depth.increment()?;
12686                }
12687                let val_ref = self.vsock_listeners.get_or_insert_with(|| {
12688                    fidl::new_empty!(
12689                        fidl::encoding::UnboundedVector<Listener>,
12690                        fidl::encoding::DefaultFuchsiaResourceDialect
12691                    )
12692                });
12693                fidl::decode!(
12694                    fidl::encoding::UnboundedVector<Listener>,
12695                    fidl::encoding::DefaultFuchsiaResourceDialect,
12696                    val_ref,
12697                    decoder,
12698                    inner_offset,
12699                    inner_depth
12700                )?;
12701                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12702                {
12703                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12704                }
12705                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12706                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12707                }
12708            }
12709
12710            next_offset += envelope_size;
12711            _next_ordinal_to_read += 1;
12712            if next_offset >= end_offset {
12713                return Ok(());
12714            }
12715
12716            // Decode unknown envelopes for gaps in ordinals.
12717            while _next_ordinal_to_read < 22 {
12718                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12719                _next_ordinal_to_read += 1;
12720                next_offset += envelope_size;
12721            }
12722
12723            let next_out_of_line = decoder.next_out_of_line();
12724            let handles_before = decoder.remaining_handles();
12725            if let Some((inlined, num_bytes, num_handles)) =
12726                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12727            {
12728                let member_inline_size =
12729                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12730                if inlined != (member_inline_size <= 4) {
12731                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12732                }
12733                let inner_offset;
12734                let mut inner_depth = depth.clone();
12735                if inlined {
12736                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12737                    inner_offset = next_offset;
12738                } else {
12739                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12740                    inner_depth.increment()?;
12741                }
12742                let val_ref = self.virtio_mem.get_or_insert_with(|| {
12743                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12744                });
12745                fidl::decode!(
12746                    bool,
12747                    fidl::encoding::DefaultFuchsiaResourceDialect,
12748                    val_ref,
12749                    decoder,
12750                    inner_offset,
12751                    inner_depth
12752                )?;
12753                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12754                {
12755                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12756                }
12757                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12758                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12759                }
12760            }
12761
12762            next_offset += envelope_size;
12763            _next_ordinal_to_read += 1;
12764            if next_offset >= end_offset {
12765                return Ok(());
12766            }
12767
12768            // Decode unknown envelopes for gaps in ordinals.
12769            while _next_ordinal_to_read < 23 {
12770                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12771                _next_ordinal_to_read += 1;
12772                next_offset += envelope_size;
12773            }
12774
12775            let next_out_of_line = decoder.next_out_of_line();
12776            let handles_before = decoder.remaining_handles();
12777            if let Some((inlined, num_bytes, num_handles)) =
12778                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12779            {
12780                let member_inline_size =
12781                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12782                if inlined != (member_inline_size <= 4) {
12783                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12784                }
12785                let inner_offset;
12786                let mut inner_depth = depth.clone();
12787                if inlined {
12788                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12789                    inner_offset = next_offset;
12790                } else {
12791                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12792                    inner_depth.increment()?;
12793                }
12794                let val_ref = self.virtio_mem_block_size.get_or_insert_with(|| {
12795                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12796                });
12797                fidl::decode!(
12798                    u64,
12799                    fidl::encoding::DefaultFuchsiaResourceDialect,
12800                    val_ref,
12801                    decoder,
12802                    inner_offset,
12803                    inner_depth
12804                )?;
12805                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12806                {
12807                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12808                }
12809                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12810                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12811                }
12812            }
12813
12814            next_offset += envelope_size;
12815            _next_ordinal_to_read += 1;
12816            if next_offset >= end_offset {
12817                return Ok(());
12818            }
12819
12820            // Decode unknown envelopes for gaps in ordinals.
12821            while _next_ordinal_to_read < 24 {
12822                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12823                _next_ordinal_to_read += 1;
12824                next_offset += envelope_size;
12825            }
12826
12827            let next_out_of_line = decoder.next_out_of_line();
12828            let handles_before = decoder.remaining_handles();
12829            if let Some((inlined, num_bytes, num_handles)) =
12830                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12831            {
12832                let member_inline_size =
12833                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12834                if inlined != (member_inline_size <= 4) {
12835                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12836                }
12837                let inner_offset;
12838                let mut inner_depth = depth.clone();
12839                if inlined {
12840                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12841                    inner_offset = next_offset;
12842                } else {
12843                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12844                    inner_depth.increment()?;
12845                }
12846                let val_ref = self.virtio_mem_region_size.get_or_insert_with(|| {
12847                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12848                });
12849                fidl::decode!(
12850                    u64,
12851                    fidl::encoding::DefaultFuchsiaResourceDialect,
12852                    val_ref,
12853                    decoder,
12854                    inner_offset,
12855                    inner_depth
12856                )?;
12857                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12858                {
12859                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12860                }
12861                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12862                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12863                }
12864            }
12865
12866            next_offset += envelope_size;
12867            _next_ordinal_to_read += 1;
12868            if next_offset >= end_offset {
12869                return Ok(());
12870            }
12871
12872            // Decode unknown envelopes for gaps in ordinals.
12873            while _next_ordinal_to_read < 25 {
12874                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12875                _next_ordinal_to_read += 1;
12876                next_offset += envelope_size;
12877            }
12878
12879            let next_out_of_line = decoder.next_out_of_line();
12880            let handles_before = decoder.remaining_handles();
12881            if let Some((inlined, num_bytes, num_handles)) =
12882                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12883            {
12884                let member_inline_size =
12885                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12886                if inlined != (member_inline_size <= 4) {
12887                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12888                }
12889                let inner_offset;
12890                let mut inner_depth = depth.clone();
12891                if inlined {
12892                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12893                    inner_offset = next_offset;
12894                } else {
12895                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12896                    inner_depth.increment()?;
12897                }
12898                let val_ref = self.virtio_mem_region_alignment.get_or_insert_with(|| {
12899                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12900                });
12901                fidl::decode!(
12902                    u64,
12903                    fidl::encoding::DefaultFuchsiaResourceDialect,
12904                    val_ref,
12905                    decoder,
12906                    inner_offset,
12907                    inner_depth
12908                )?;
12909                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12910                {
12911                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12912                }
12913                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12914                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12915                }
12916            }
12917
12918            next_offset += envelope_size;
12919
12920            // Decode the remaining unknown envelopes.
12921            while next_offset < end_offset {
12922                _next_ordinal_to_read += 1;
12923                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12924                next_offset += envelope_size;
12925            }
12926
12927            Ok(())
12928        }
12929    }
12930
12931    impl fidl::encoding::ResourceTypeMarker for BlockFormat {
12932        type Borrowed<'a> = &'a mut Self;
12933        fn take_or_borrow<'a>(
12934            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12935        ) -> Self::Borrowed<'a> {
12936            value
12937        }
12938    }
12939
12940    unsafe impl fidl::encoding::TypeMarker for BlockFormat {
12941        type Owned = Self;
12942
12943        #[inline(always)]
12944        fn inline_align(_context: fidl::encoding::Context) -> usize {
12945            8
12946        }
12947
12948        #[inline(always)]
12949        fn inline_size(_context: fidl::encoding::Context) -> usize {
12950            16
12951        }
12952    }
12953
12954    unsafe impl fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>
12955        for &mut BlockFormat
12956    {
12957        #[inline]
12958        unsafe fn encode(
12959            self,
12960            encoder: &mut fidl::encoding::Encoder<
12961                '_,
12962                fidl::encoding::DefaultFuchsiaResourceDialect,
12963            >,
12964            offset: usize,
12965            _depth: fidl::encoding::Depth,
12966        ) -> fidl::Result<()> {
12967            encoder.debug_check_bounds::<BlockFormat>(offset);
12968            encoder.write_num::<u64>(self.ordinal(), offset);
12969            match self {
12970                BlockFormat::File(ref mut val) => fidl::encoding::encode_in_envelope::<
12971                    fidl::encoding::Endpoint<
12972                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12973                    >,
12974                    fidl::encoding::DefaultFuchsiaResourceDialect,
12975                >(
12976                    <fidl::encoding::Endpoint<
12977                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12978                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12979                        val
12980                    ),
12981                    encoder,
12982                    offset + 8,
12983                    _depth,
12984                ),
12985                BlockFormat::Qcow(ref mut val) => fidl::encoding::encode_in_envelope::<
12986                    fidl::encoding::HandleType<
12987                        fidl::Channel,
12988                        { fidl::ObjectType::CHANNEL.into_raw() },
12989                        2147483648,
12990                    >,
12991                    fidl::encoding::DefaultFuchsiaResourceDialect,
12992                >(
12993                    <fidl::encoding::HandleType<
12994                        fidl::Channel,
12995                        { fidl::ObjectType::CHANNEL.into_raw() },
12996                        2147483648,
12997                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12998                        val
12999                    ),
13000                    encoder,
13001                    offset + 8,
13002                    _depth,
13003                ),
13004                BlockFormat::Block(ref mut val) => fidl::encoding::encode_in_envelope::<
13005                    fidl::encoding::Endpoint<
13006                        fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13007                    >,
13008                    fidl::encoding::DefaultFuchsiaResourceDialect,
13009                >(
13010                    <fidl::encoding::Endpoint<
13011                        fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13012                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13013                        val
13014                    ),
13015                    encoder,
13016                    offset + 8,
13017                    _depth,
13018                ),
13019            }
13020        }
13021    }
13022
13023    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockFormat {
13024        #[inline(always)]
13025        fn new_empty() -> Self {
13026            Self::File(fidl::new_empty!(
13027                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
13028                fidl::encoding::DefaultFuchsiaResourceDialect
13029            ))
13030        }
13031
13032        #[inline]
13033        unsafe fn decode(
13034            &mut self,
13035            decoder: &mut fidl::encoding::Decoder<
13036                '_,
13037                fidl::encoding::DefaultFuchsiaResourceDialect,
13038            >,
13039            offset: usize,
13040            mut depth: fidl::encoding::Depth,
13041        ) -> fidl::Result<()> {
13042            decoder.debug_check_bounds::<Self>(offset);
13043            #[allow(unused_variables)]
13044            let next_out_of_line = decoder.next_out_of_line();
13045            let handles_before = decoder.remaining_handles();
13046            let (ordinal, inlined, num_bytes, num_handles) =
13047                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
13048
13049            let member_inline_size = match ordinal {
13050                1 => <fidl::encoding::Endpoint<
13051                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13052                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13053                2 => <fidl::encoding::HandleType<
13054                    fidl::Channel,
13055                    { fidl::ObjectType::CHANNEL.into_raw() },
13056                    2147483648,
13057                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13058                3 => <fidl::encoding::Endpoint<
13059                    fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13060                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13061                _ => return Err(fidl::Error::UnknownUnionTag),
13062            };
13063
13064            if inlined != (member_inline_size <= 4) {
13065                return Err(fidl::Error::InvalidInlineBitInEnvelope);
13066            }
13067            let _inner_offset;
13068            if inlined {
13069                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
13070                _inner_offset = offset + 8;
13071            } else {
13072                depth.increment()?;
13073                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13074            }
13075            match ordinal {
13076                1 => {
13077                    #[allow(irrefutable_let_patterns)]
13078                    if let BlockFormat::File(_) = self {
13079                        // Do nothing, read the value into the object
13080                    } else {
13081                        // Initialize `self` to the right variant
13082                        *self = BlockFormat::File(fidl::new_empty!(
13083                            fidl::encoding::Endpoint<
13084                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13085                            >,
13086                            fidl::encoding::DefaultFuchsiaResourceDialect
13087                        ));
13088                    }
13089                    #[allow(irrefutable_let_patterns)]
13090                    if let BlockFormat::File(ref mut val) = self {
13091                        fidl::decode!(
13092                            fidl::encoding::Endpoint<
13093                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13094                            >,
13095                            fidl::encoding::DefaultFuchsiaResourceDialect,
13096                            val,
13097                            decoder,
13098                            _inner_offset,
13099                            depth
13100                        )?;
13101                    } else {
13102                        unreachable!()
13103                    }
13104                }
13105                2 => {
13106                    #[allow(irrefutable_let_patterns)]
13107                    if let BlockFormat::Qcow(_) = self {
13108                        // Do nothing, read the value into the object
13109                    } else {
13110                        // Initialize `self` to the right variant
13111                        *self = BlockFormat::Qcow(
13112                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
13113                        );
13114                    }
13115                    #[allow(irrefutable_let_patterns)]
13116                    if let BlockFormat::Qcow(ref mut val) = self {
13117                        fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
13118                    } else {
13119                        unreachable!()
13120                    }
13121                }
13122                3 => {
13123                    #[allow(irrefutable_let_patterns)]
13124                    if let BlockFormat::Block(_) = self {
13125                        // Do nothing, read the value into the object
13126                    } else {
13127                        // Initialize `self` to the right variant
13128                        *self = BlockFormat::Block(fidl::new_empty!(
13129                            fidl::encoding::Endpoint<
13130                                fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13131                            >,
13132                            fidl::encoding::DefaultFuchsiaResourceDialect
13133                        ));
13134                    }
13135                    #[allow(irrefutable_let_patterns)]
13136                    if let BlockFormat::Block(ref mut val) = self {
13137                        fidl::decode!(
13138                            fidl::encoding::Endpoint<
13139                                fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13140                            >,
13141                            fidl::encoding::DefaultFuchsiaResourceDialect,
13142                            val,
13143                            decoder,
13144                            _inner_offset,
13145                            depth
13146                        )?;
13147                    } else {
13148                        unreachable!()
13149                    }
13150                }
13151                ordinal => panic!("unexpected ordinal {:?}", ordinal),
13152            }
13153            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
13154                return Err(fidl::Error::InvalidNumBytesInEnvelope);
13155            }
13156            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13157                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13158            }
13159            Ok(())
13160        }
13161    }
13162}