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 BalloonControllerControlHandle {
763    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
764        self.inner.shutdown_with_epitaph(status.into())
765    }
766}
767
768impl fidl::endpoints::ControlHandle for BalloonControllerControlHandle {
769    fn shutdown(&self) {
770        self.inner.shutdown()
771    }
772
773    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
774        self.inner.shutdown_with_epitaph(status)
775    }
776
777    fn is_closed(&self) -> bool {
778        self.inner.channel().is_closed()
779    }
780    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
781        self.inner.channel().on_closed()
782    }
783
784    #[cfg(target_os = "fuchsia")]
785    fn signal_peer(
786        &self,
787        clear_mask: zx::Signals,
788        set_mask: zx::Signals,
789    ) -> Result<(), zx_status::Status> {
790        use fidl::Peered;
791        self.inner.channel().signal_peer(clear_mask, set_mask)
792    }
793}
794
795impl BalloonControllerControlHandle {}
796
797#[must_use = "FIDL methods require a response to be sent"]
798#[derive(Debug)]
799pub struct BalloonControllerGetBalloonSizeResponder {
800    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
801    tx_id: u32,
802}
803
804/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
805/// if the responder is dropped without sending a response, so that the client
806/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
807impl std::ops::Drop for BalloonControllerGetBalloonSizeResponder {
808    fn drop(&mut self) {
809        self.control_handle.shutdown();
810        // Safety: drops once, never accessed again
811        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
812    }
813}
814
815impl fidl::endpoints::Responder for BalloonControllerGetBalloonSizeResponder {
816    type ControlHandle = BalloonControllerControlHandle;
817
818    fn control_handle(&self) -> &BalloonControllerControlHandle {
819        &self.control_handle
820    }
821
822    fn drop_without_shutdown(mut self) {
823        // Safety: drops once, never accessed again due to mem::forget
824        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
825        // Prevent Drop from running (which would shut down the channel)
826        std::mem::forget(self);
827    }
828}
829
830impl BalloonControllerGetBalloonSizeResponder {
831    /// Sends a response to the FIDL transaction.
832    ///
833    /// Sets the channel to shutdown if an error occurs.
834    pub fn send(
835        self,
836        mut current_num_pages: u32,
837        mut requested_num_pages: u32,
838    ) -> Result<(), fidl::Error> {
839        let _result = self.send_raw(current_num_pages, requested_num_pages);
840        if _result.is_err() {
841            self.control_handle.shutdown();
842        }
843        self.drop_without_shutdown();
844        _result
845    }
846
847    /// Similar to "send" but does not shutdown the channel if an error occurs.
848    pub fn send_no_shutdown_on_err(
849        self,
850        mut current_num_pages: u32,
851        mut requested_num_pages: u32,
852    ) -> Result<(), fidl::Error> {
853        let _result = self.send_raw(current_num_pages, requested_num_pages);
854        self.drop_without_shutdown();
855        _result
856    }
857
858    fn send_raw(
859        &self,
860        mut current_num_pages: u32,
861        mut requested_num_pages: u32,
862    ) -> Result<(), fidl::Error> {
863        self.control_handle.inner.send::<BalloonControllerGetBalloonSizeResponse>(
864            (current_num_pages, requested_num_pages),
865            self.tx_id,
866            0x2bb2ebaa6ff64d0b,
867            fidl::encoding::DynamicFlags::empty(),
868        )
869    }
870}
871
872#[must_use = "FIDL methods require a response to be sent"]
873#[derive(Debug)]
874pub struct BalloonControllerGetMemStatsResponder {
875    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
876    tx_id: u32,
877}
878
879/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
880/// if the responder is dropped without sending a response, so that the client
881/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
882impl std::ops::Drop for BalloonControllerGetMemStatsResponder {
883    fn drop(&mut self) {
884        self.control_handle.shutdown();
885        // Safety: drops once, never accessed again
886        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
887    }
888}
889
890impl fidl::endpoints::Responder for BalloonControllerGetMemStatsResponder {
891    type ControlHandle = BalloonControllerControlHandle;
892
893    fn control_handle(&self) -> &BalloonControllerControlHandle {
894        &self.control_handle
895    }
896
897    fn drop_without_shutdown(mut self) {
898        // Safety: drops once, never accessed again due to mem::forget
899        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
900        // Prevent Drop from running (which would shut down the channel)
901        std::mem::forget(self);
902    }
903}
904
905impl BalloonControllerGetMemStatsResponder {
906    /// Sends a response to the FIDL transaction.
907    ///
908    /// Sets the channel to shutdown if an error occurs.
909    pub fn send(
910        self,
911        mut status: i32,
912        mut mem_stats: Option<&[MemStat]>,
913    ) -> Result<(), fidl::Error> {
914        let _result = self.send_raw(status, mem_stats);
915        if _result.is_err() {
916            self.control_handle.shutdown();
917        }
918        self.drop_without_shutdown();
919        _result
920    }
921
922    /// Similar to "send" but does not shutdown the channel if an error occurs.
923    pub fn send_no_shutdown_on_err(
924        self,
925        mut status: i32,
926        mut mem_stats: Option<&[MemStat]>,
927    ) -> Result<(), fidl::Error> {
928        let _result = self.send_raw(status, mem_stats);
929        self.drop_without_shutdown();
930        _result
931    }
932
933    fn send_raw(
934        &self,
935        mut status: i32,
936        mut mem_stats: Option<&[MemStat]>,
937    ) -> Result<(), fidl::Error> {
938        self.control_handle.inner.send::<BalloonControllerGetMemStatsResponse>(
939            (status, mem_stats),
940            self.tx_id,
941            0x676199795cc01142,
942            fidl::encoding::DynamicFlags::empty(),
943        )
944    }
945}
946
947#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
948pub struct DebianGuestManagerMarker;
949
950impl fidl::endpoints::ProtocolMarker for DebianGuestManagerMarker {
951    type Proxy = DebianGuestManagerProxy;
952    type RequestStream = DebianGuestManagerRequestStream;
953    #[cfg(target_os = "fuchsia")]
954    type SynchronousProxy = DebianGuestManagerSynchronousProxy;
955
956    const DEBUG_NAME: &'static str = "fuchsia.virtualization.DebianGuestManager";
957}
958impl fidl::endpoints::DiscoverableProtocolMarker for DebianGuestManagerMarker {}
959
960pub trait DebianGuestManagerProxyInterface: Send + Sync {
961    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
962        + Send;
963    fn r#launch(
964        &self,
965        guest_config: GuestConfig,
966        controller: fidl::endpoints::ServerEnd<GuestMarker>,
967    ) -> Self::LaunchResponseFut;
968    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
969    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
970    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
971        + Send;
972    fn r#connect(
973        &self,
974        controller: fidl::endpoints::ServerEnd<GuestMarker>,
975    ) -> Self::ConnectResponseFut;
976    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
977    fn r#get_info(&self) -> Self::GetInfoResponseFut;
978}
979#[derive(Debug)]
980#[cfg(target_os = "fuchsia")]
981pub struct DebianGuestManagerSynchronousProxy {
982    client: fidl::client::sync::Client,
983}
984
985#[cfg(target_os = "fuchsia")]
986impl fidl::endpoints::SynchronousProxy for DebianGuestManagerSynchronousProxy {
987    type Proxy = DebianGuestManagerProxy;
988    type Protocol = DebianGuestManagerMarker;
989
990    fn from_channel(inner: fidl::Channel) -> Self {
991        Self::new(inner)
992    }
993
994    fn into_channel(self) -> fidl::Channel {
995        self.client.into_channel()
996    }
997
998    fn as_channel(&self) -> &fidl::Channel {
999        self.client.as_channel()
1000    }
1001}
1002
1003#[cfg(target_os = "fuchsia")]
1004impl DebianGuestManagerSynchronousProxy {
1005    pub fn new(channel: fidl::Channel) -> Self {
1006        Self { client: fidl::client::sync::Client::new(channel) }
1007    }
1008
1009    pub fn into_channel(self) -> fidl::Channel {
1010        self.client.into_channel()
1011    }
1012
1013    /// Waits until an event arrives and returns it. It is safe for other
1014    /// threads to make concurrent requests while waiting for an event.
1015    pub fn wait_for_event(
1016        &self,
1017        deadline: zx::MonotonicInstant,
1018    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1019        DebianGuestManagerEvent::decode(
1020            self.client.wait_for_event::<DebianGuestManagerMarker>(deadline)?,
1021        )
1022    }
1023
1024    /// Launch a new guest instance.
1025    ///
1026    /// Possible errors:
1027    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1028    ///         problems detected by the guest manager.
1029    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1030    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1031    ///         component logs for a more specific failure.
1032    pub fn r#launch(
1033        &self,
1034        mut guest_config: GuestConfig,
1035        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1036        ___deadline: zx::MonotonicInstant,
1037    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1038        let _response =
1039            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
1040                fidl::encoding::EmptyStruct,
1041                GuestManagerError,
1042            >, DebianGuestManagerMarker>(
1043                (&mut guest_config, controller),
1044                0x394a2e29f750323e,
1045                fidl::encoding::DynamicFlags::empty(),
1046                ___deadline,
1047            )?;
1048        Ok(_response.map(|x| x))
1049    }
1050
1051    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1052    /// be used to launch another guest.
1053    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1054        let _response = self.client.send_query::<
1055            fidl::encoding::EmptyPayload,
1056            fidl::encoding::EmptyPayload,
1057            DebianGuestManagerMarker,
1058        >(
1059            (),
1060            0x3ad9a012982f872d,
1061            fidl::encoding::DynamicFlags::empty(),
1062            ___deadline,
1063        )?;
1064        Ok(_response)
1065    }
1066
1067    /// Connect to a currently running guest.
1068    ///
1069    /// Possible errors:
1070    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1071    ///         has launched before attempting to reconnect.
1072    pub fn r#connect(
1073        &self,
1074        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1075        ___deadline: zx::MonotonicInstant,
1076    ) -> Result<GuestManagerConnectResult, fidl::Error> {
1077        let _response =
1078            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
1079                fidl::encoding::EmptyStruct,
1080                GuestManagerError,
1081            >, DebianGuestManagerMarker>(
1082                (controller,),
1083                0x4e489076e3bb15b4,
1084                fidl::encoding::DynamicFlags::empty(),
1085                ___deadline,
1086            )?;
1087        Ok(_response.map(|x| x))
1088    }
1089
1090    /// Query guest info
1091    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
1092        let _response = self.client.send_query::<
1093            fidl::encoding::EmptyPayload,
1094            GuestManagerGetInfoResponse,
1095            DebianGuestManagerMarker,
1096        >(
1097            (),
1098            0x76892614aea695dc,
1099            fidl::encoding::DynamicFlags::empty(),
1100            ___deadline,
1101        )?;
1102        Ok(_response.guest_info)
1103    }
1104}
1105
1106#[cfg(target_os = "fuchsia")]
1107impl From<DebianGuestManagerSynchronousProxy> for zx::NullableHandle {
1108    fn from(value: DebianGuestManagerSynchronousProxy) -> Self {
1109        value.into_channel().into()
1110    }
1111}
1112
1113#[cfg(target_os = "fuchsia")]
1114impl From<fidl::Channel> for DebianGuestManagerSynchronousProxy {
1115    fn from(value: fidl::Channel) -> Self {
1116        Self::new(value)
1117    }
1118}
1119
1120#[cfg(target_os = "fuchsia")]
1121impl fidl::endpoints::FromClient for DebianGuestManagerSynchronousProxy {
1122    type Protocol = DebianGuestManagerMarker;
1123
1124    fn from_client(value: fidl::endpoints::ClientEnd<DebianGuestManagerMarker>) -> Self {
1125        Self::new(value.into_channel())
1126    }
1127}
1128
1129#[derive(Debug, Clone)]
1130pub struct DebianGuestManagerProxy {
1131    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1132}
1133
1134impl fidl::endpoints::Proxy for DebianGuestManagerProxy {
1135    type Protocol = DebianGuestManagerMarker;
1136
1137    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1138        Self::new(inner)
1139    }
1140
1141    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1142        self.client.into_channel().map_err(|client| Self { client })
1143    }
1144
1145    fn as_channel(&self) -> &::fidl::AsyncChannel {
1146        self.client.as_channel()
1147    }
1148}
1149
1150impl DebianGuestManagerProxy {
1151    /// Create a new Proxy for fuchsia.virtualization/DebianGuestManager.
1152    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1153        let protocol_name =
1154            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1155        Self { client: fidl::client::Client::new(channel, protocol_name) }
1156    }
1157
1158    /// Get a Stream of events from the remote end of the protocol.
1159    ///
1160    /// # Panics
1161    ///
1162    /// Panics if the event stream was already taken.
1163    pub fn take_event_stream(&self) -> DebianGuestManagerEventStream {
1164        DebianGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
1165    }
1166
1167    /// Launch a new guest instance.
1168    ///
1169    /// Possible errors:
1170    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1171    ///         problems detected by the guest manager.
1172    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1173    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1174    ///         component logs for a more specific failure.
1175    pub fn r#launch(
1176        &self,
1177        mut guest_config: GuestConfig,
1178        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1179    ) -> fidl::client::QueryResponseFut<
1180        GuestManagerLaunchResult,
1181        fidl::encoding::DefaultFuchsiaResourceDialect,
1182    > {
1183        DebianGuestManagerProxyInterface::r#launch(self, guest_config, controller)
1184    }
1185
1186    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1187    /// be used to launch another guest.
1188    pub fn r#force_shutdown(
1189        &self,
1190    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1191        DebianGuestManagerProxyInterface::r#force_shutdown(self)
1192    }
1193
1194    /// Connect to a currently running guest.
1195    ///
1196    /// Possible errors:
1197    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1198    ///         has launched before attempting to reconnect.
1199    pub fn r#connect(
1200        &self,
1201        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1202    ) -> fidl::client::QueryResponseFut<
1203        GuestManagerConnectResult,
1204        fidl::encoding::DefaultFuchsiaResourceDialect,
1205    > {
1206        DebianGuestManagerProxyInterface::r#connect(self, controller)
1207    }
1208
1209    /// Query guest info
1210    pub fn r#get_info(
1211        &self,
1212    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1213    {
1214        DebianGuestManagerProxyInterface::r#get_info(self)
1215    }
1216}
1217
1218impl DebianGuestManagerProxyInterface for DebianGuestManagerProxy {
1219    type LaunchResponseFut = fidl::client::QueryResponseFut<
1220        GuestManagerLaunchResult,
1221        fidl::encoding::DefaultFuchsiaResourceDialect,
1222    >;
1223    fn r#launch(
1224        &self,
1225        mut guest_config: GuestConfig,
1226        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1227    ) -> Self::LaunchResponseFut {
1228        fn _decode(
1229            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1230        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1231            let _response = fidl::client::decode_transaction_body::<
1232                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1233                fidl::encoding::DefaultFuchsiaResourceDialect,
1234                0x394a2e29f750323e,
1235            >(_buf?)?;
1236            Ok(_response.map(|x| x))
1237        }
1238        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
1239            (&mut guest_config, controller),
1240            0x394a2e29f750323e,
1241            fidl::encoding::DynamicFlags::empty(),
1242            _decode,
1243        )
1244    }
1245
1246    type ForceShutdownResponseFut =
1247        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1248    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
1249        fn _decode(
1250            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1251        ) -> Result<(), fidl::Error> {
1252            let _response = fidl::client::decode_transaction_body::<
1253                fidl::encoding::EmptyPayload,
1254                fidl::encoding::DefaultFuchsiaResourceDialect,
1255                0x3ad9a012982f872d,
1256            >(_buf?)?;
1257            Ok(_response)
1258        }
1259        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1260            (),
1261            0x3ad9a012982f872d,
1262            fidl::encoding::DynamicFlags::empty(),
1263            _decode,
1264        )
1265    }
1266
1267    type ConnectResponseFut = fidl::client::QueryResponseFut<
1268        GuestManagerConnectResult,
1269        fidl::encoding::DefaultFuchsiaResourceDialect,
1270    >;
1271    fn r#connect(
1272        &self,
1273        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1274    ) -> Self::ConnectResponseFut {
1275        fn _decode(
1276            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1277        ) -> Result<GuestManagerConnectResult, fidl::Error> {
1278            let _response = fidl::client::decode_transaction_body::<
1279                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1280                fidl::encoding::DefaultFuchsiaResourceDialect,
1281                0x4e489076e3bb15b4,
1282            >(_buf?)?;
1283            Ok(_response.map(|x| x))
1284        }
1285        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
1286            (controller,),
1287            0x4e489076e3bb15b4,
1288            fidl::encoding::DynamicFlags::empty(),
1289            _decode,
1290        )
1291    }
1292
1293    type GetInfoResponseFut =
1294        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
1295    fn r#get_info(&self) -> Self::GetInfoResponseFut {
1296        fn _decode(
1297            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1298        ) -> Result<GuestInfo, fidl::Error> {
1299            let _response = fidl::client::decode_transaction_body::<
1300                GuestManagerGetInfoResponse,
1301                fidl::encoding::DefaultFuchsiaResourceDialect,
1302                0x76892614aea695dc,
1303            >(_buf?)?;
1304            Ok(_response.guest_info)
1305        }
1306        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
1307            (),
1308            0x76892614aea695dc,
1309            fidl::encoding::DynamicFlags::empty(),
1310            _decode,
1311        )
1312    }
1313}
1314
1315pub struct DebianGuestManagerEventStream {
1316    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1317}
1318
1319impl std::marker::Unpin for DebianGuestManagerEventStream {}
1320
1321impl futures::stream::FusedStream for DebianGuestManagerEventStream {
1322    fn is_terminated(&self) -> bool {
1323        self.event_receiver.is_terminated()
1324    }
1325}
1326
1327impl futures::Stream for DebianGuestManagerEventStream {
1328    type Item = Result<DebianGuestManagerEvent, fidl::Error>;
1329
1330    fn poll_next(
1331        mut self: std::pin::Pin<&mut Self>,
1332        cx: &mut std::task::Context<'_>,
1333    ) -> std::task::Poll<Option<Self::Item>> {
1334        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1335            &mut self.event_receiver,
1336            cx
1337        )?) {
1338            Some(buf) => std::task::Poll::Ready(Some(DebianGuestManagerEvent::decode(buf))),
1339            None => std::task::Poll::Ready(None),
1340        }
1341    }
1342}
1343
1344#[derive(Debug)]
1345pub enum DebianGuestManagerEvent {}
1346
1347impl DebianGuestManagerEvent {
1348    /// Decodes a message buffer as a [`DebianGuestManagerEvent`].
1349    fn decode(
1350        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1351    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1352        let (bytes, _handles) = buf.split_mut();
1353        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1354        debug_assert_eq!(tx_header.tx_id, 0);
1355        match tx_header.ordinal {
1356            _ => Err(fidl::Error::UnknownOrdinal {
1357                ordinal: tx_header.ordinal,
1358                protocol_name:
1359                    <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1360            }),
1361        }
1362    }
1363}
1364
1365/// A Stream of incoming requests for fuchsia.virtualization/DebianGuestManager.
1366pub struct DebianGuestManagerRequestStream {
1367    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1368    is_terminated: bool,
1369}
1370
1371impl std::marker::Unpin for DebianGuestManagerRequestStream {}
1372
1373impl futures::stream::FusedStream for DebianGuestManagerRequestStream {
1374    fn is_terminated(&self) -> bool {
1375        self.is_terminated
1376    }
1377}
1378
1379impl fidl::endpoints::RequestStream for DebianGuestManagerRequestStream {
1380    type Protocol = DebianGuestManagerMarker;
1381    type ControlHandle = DebianGuestManagerControlHandle;
1382
1383    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1384        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1385    }
1386
1387    fn control_handle(&self) -> Self::ControlHandle {
1388        DebianGuestManagerControlHandle { inner: self.inner.clone() }
1389    }
1390
1391    fn into_inner(
1392        self,
1393    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1394    {
1395        (self.inner, self.is_terminated)
1396    }
1397
1398    fn from_inner(
1399        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1400        is_terminated: bool,
1401    ) -> Self {
1402        Self { inner, is_terminated }
1403    }
1404}
1405
1406impl futures::Stream for DebianGuestManagerRequestStream {
1407    type Item = Result<DebianGuestManagerRequest, fidl::Error>;
1408
1409    fn poll_next(
1410        mut self: std::pin::Pin<&mut Self>,
1411        cx: &mut std::task::Context<'_>,
1412    ) -> std::task::Poll<Option<Self::Item>> {
1413        let this = &mut *self;
1414        if this.inner.check_shutdown(cx) {
1415            this.is_terminated = true;
1416            return std::task::Poll::Ready(None);
1417        }
1418        if this.is_terminated {
1419            panic!("polled DebianGuestManagerRequestStream after completion");
1420        }
1421        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1422            |bytes, handles| {
1423                match this.inner.channel().read_etc(cx, bytes, handles) {
1424                    std::task::Poll::Ready(Ok(())) => {}
1425                    std::task::Poll::Pending => return std::task::Poll::Pending,
1426                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1427                        this.is_terminated = true;
1428                        return std::task::Poll::Ready(None);
1429                    }
1430                    std::task::Poll::Ready(Err(e)) => {
1431                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1432                            e.into(),
1433                        ))));
1434                    }
1435                }
1436
1437                // A message has been received from the channel
1438                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1439
1440                std::task::Poll::Ready(Some(match header.ordinal {
1441                0x394a2e29f750323e => {
1442                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1443                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1444                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
1445                    let control_handle = DebianGuestManagerControlHandle {
1446                        inner: this.inner.clone(),
1447                    };
1448                    Ok(DebianGuestManagerRequest::Launch {guest_config: req.guest_config,
1449controller: req.controller,
1450
1451                        responder: DebianGuestManagerLaunchResponder {
1452                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1453                            tx_id: header.tx_id,
1454                        },
1455                    })
1456                }
1457                0x3ad9a012982f872d => {
1458                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1459                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1460                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1461                    let control_handle = DebianGuestManagerControlHandle {
1462                        inner: this.inner.clone(),
1463                    };
1464                    Ok(DebianGuestManagerRequest::ForceShutdown {
1465                        responder: DebianGuestManagerForceShutdownResponder {
1466                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1467                            tx_id: header.tx_id,
1468                        },
1469                    })
1470                }
1471                0x4e489076e3bb15b4 => {
1472                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1473                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1474                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1475                    let control_handle = DebianGuestManagerControlHandle {
1476                        inner: this.inner.clone(),
1477                    };
1478                    Ok(DebianGuestManagerRequest::Connect {controller: req.controller,
1479
1480                        responder: DebianGuestManagerConnectResponder {
1481                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1482                            tx_id: header.tx_id,
1483                        },
1484                    })
1485                }
1486                0x76892614aea695dc => {
1487                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1488                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1489                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1490                    let control_handle = DebianGuestManagerControlHandle {
1491                        inner: this.inner.clone(),
1492                    };
1493                    Ok(DebianGuestManagerRequest::GetInfo {
1494                        responder: DebianGuestManagerGetInfoResponder {
1495                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1496                            tx_id: header.tx_id,
1497                        },
1498                    })
1499                }
1500                _ => Err(fidl::Error::UnknownOrdinal {
1501                    ordinal: header.ordinal,
1502                    protocol_name: <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1503                }),
1504            }))
1505            },
1506        )
1507    }
1508}
1509
1510#[derive(Debug)]
1511pub enum DebianGuestManagerRequest {
1512    /// Launch a new guest instance.
1513    ///
1514    /// Possible errors:
1515    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1516    ///         problems detected by the guest manager.
1517    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1518    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1519    ///         component logs for a more specific failure.
1520    Launch {
1521        guest_config: GuestConfig,
1522        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1523        responder: DebianGuestManagerLaunchResponder,
1524    },
1525    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1526    /// be used to launch another guest.
1527    ForceShutdown { responder: DebianGuestManagerForceShutdownResponder },
1528    /// Connect to a currently running guest.
1529    ///
1530    /// Possible errors:
1531    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1532    ///         has launched before attempting to reconnect.
1533    Connect {
1534        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1535        responder: DebianGuestManagerConnectResponder,
1536    },
1537    /// Query guest info
1538    GetInfo { responder: DebianGuestManagerGetInfoResponder },
1539}
1540
1541impl DebianGuestManagerRequest {
1542    #[allow(irrefutable_let_patterns)]
1543    pub fn into_launch(
1544        self,
1545    ) -> Option<(
1546        GuestConfig,
1547        fidl::endpoints::ServerEnd<GuestMarker>,
1548        DebianGuestManagerLaunchResponder,
1549    )> {
1550        if let DebianGuestManagerRequest::Launch { guest_config, controller, responder } = self {
1551            Some((guest_config, controller, responder))
1552        } else {
1553            None
1554        }
1555    }
1556
1557    #[allow(irrefutable_let_patterns)]
1558    pub fn into_force_shutdown(self) -> Option<(DebianGuestManagerForceShutdownResponder)> {
1559        if let DebianGuestManagerRequest::ForceShutdown { responder } = self {
1560            Some((responder))
1561        } else {
1562            None
1563        }
1564    }
1565
1566    #[allow(irrefutable_let_patterns)]
1567    pub fn into_connect(
1568        self,
1569    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, DebianGuestManagerConnectResponder)> {
1570        if let DebianGuestManagerRequest::Connect { controller, responder } = self {
1571            Some((controller, responder))
1572        } else {
1573            None
1574        }
1575    }
1576
1577    #[allow(irrefutable_let_patterns)]
1578    pub fn into_get_info(self) -> Option<(DebianGuestManagerGetInfoResponder)> {
1579        if let DebianGuestManagerRequest::GetInfo { responder } = self {
1580            Some((responder))
1581        } else {
1582            None
1583        }
1584    }
1585
1586    /// Name of the method defined in FIDL
1587    pub fn method_name(&self) -> &'static str {
1588        match *self {
1589            DebianGuestManagerRequest::Launch { .. } => "launch",
1590            DebianGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
1591            DebianGuestManagerRequest::Connect { .. } => "connect",
1592            DebianGuestManagerRequest::GetInfo { .. } => "get_info",
1593        }
1594    }
1595}
1596
1597#[derive(Debug, Clone)]
1598pub struct DebianGuestManagerControlHandle {
1599    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1600}
1601
1602impl DebianGuestManagerControlHandle {
1603    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1604        self.inner.shutdown_with_epitaph(status.into())
1605    }
1606}
1607
1608impl fidl::endpoints::ControlHandle for DebianGuestManagerControlHandle {
1609    fn shutdown(&self) {
1610        self.inner.shutdown()
1611    }
1612
1613    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1614        self.inner.shutdown_with_epitaph(status)
1615    }
1616
1617    fn is_closed(&self) -> bool {
1618        self.inner.channel().is_closed()
1619    }
1620    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1621        self.inner.channel().on_closed()
1622    }
1623
1624    #[cfg(target_os = "fuchsia")]
1625    fn signal_peer(
1626        &self,
1627        clear_mask: zx::Signals,
1628        set_mask: zx::Signals,
1629    ) -> Result<(), zx_status::Status> {
1630        use fidl::Peered;
1631        self.inner.channel().signal_peer(clear_mask, set_mask)
1632    }
1633}
1634
1635impl DebianGuestManagerControlHandle {}
1636
1637#[must_use = "FIDL methods require a response to be sent"]
1638#[derive(Debug)]
1639pub struct DebianGuestManagerLaunchResponder {
1640    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1641    tx_id: u32,
1642}
1643
1644/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1645/// if the responder is dropped without sending a response, so that the client
1646/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1647impl std::ops::Drop for DebianGuestManagerLaunchResponder {
1648    fn drop(&mut self) {
1649        self.control_handle.shutdown();
1650        // Safety: drops once, never accessed again
1651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1652    }
1653}
1654
1655impl fidl::endpoints::Responder for DebianGuestManagerLaunchResponder {
1656    type ControlHandle = DebianGuestManagerControlHandle;
1657
1658    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1659        &self.control_handle
1660    }
1661
1662    fn drop_without_shutdown(mut self) {
1663        // Safety: drops once, never accessed again due to mem::forget
1664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1665        // Prevent Drop from running (which would shut down the channel)
1666        std::mem::forget(self);
1667    }
1668}
1669
1670impl DebianGuestManagerLaunchResponder {
1671    /// Sends a response to the FIDL transaction.
1672    ///
1673    /// Sets the channel to shutdown if an error occurs.
1674    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1675        let _result = self.send_raw(result);
1676        if _result.is_err() {
1677            self.control_handle.shutdown();
1678        }
1679        self.drop_without_shutdown();
1680        _result
1681    }
1682
1683    /// Similar to "send" but does not shutdown the channel if an error occurs.
1684    pub fn send_no_shutdown_on_err(
1685        self,
1686        mut result: Result<(), GuestManagerError>,
1687    ) -> Result<(), fidl::Error> {
1688        let _result = self.send_raw(result);
1689        self.drop_without_shutdown();
1690        _result
1691    }
1692
1693    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1694        self.control_handle.inner.send::<fidl::encoding::ResultType<
1695            fidl::encoding::EmptyStruct,
1696            GuestManagerError,
1697        >>(
1698            result,
1699            self.tx_id,
1700            0x394a2e29f750323e,
1701            fidl::encoding::DynamicFlags::empty(),
1702        )
1703    }
1704}
1705
1706#[must_use = "FIDL methods require a response to be sent"]
1707#[derive(Debug)]
1708pub struct DebianGuestManagerForceShutdownResponder {
1709    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1710    tx_id: u32,
1711}
1712
1713/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1714/// if the responder is dropped without sending a response, so that the client
1715/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1716impl std::ops::Drop for DebianGuestManagerForceShutdownResponder {
1717    fn drop(&mut self) {
1718        self.control_handle.shutdown();
1719        // Safety: drops once, never accessed again
1720        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1721    }
1722}
1723
1724impl fidl::endpoints::Responder for DebianGuestManagerForceShutdownResponder {
1725    type ControlHandle = DebianGuestManagerControlHandle;
1726
1727    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1728        &self.control_handle
1729    }
1730
1731    fn drop_without_shutdown(mut self) {
1732        // Safety: drops once, never accessed again due to mem::forget
1733        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1734        // Prevent Drop from running (which would shut down the channel)
1735        std::mem::forget(self);
1736    }
1737}
1738
1739impl DebianGuestManagerForceShutdownResponder {
1740    /// Sends a response to the FIDL transaction.
1741    ///
1742    /// Sets the channel to shutdown if an error occurs.
1743    pub fn send(self) -> Result<(), fidl::Error> {
1744        let _result = self.send_raw();
1745        if _result.is_err() {
1746            self.control_handle.shutdown();
1747        }
1748        self.drop_without_shutdown();
1749        _result
1750    }
1751
1752    /// Similar to "send" but does not shutdown the channel if an error occurs.
1753    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1754        let _result = self.send_raw();
1755        self.drop_without_shutdown();
1756        _result
1757    }
1758
1759    fn send_raw(&self) -> Result<(), fidl::Error> {
1760        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1761            (),
1762            self.tx_id,
1763            0x3ad9a012982f872d,
1764            fidl::encoding::DynamicFlags::empty(),
1765        )
1766    }
1767}
1768
1769#[must_use = "FIDL methods require a response to be sent"]
1770#[derive(Debug)]
1771pub struct DebianGuestManagerConnectResponder {
1772    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1773    tx_id: u32,
1774}
1775
1776/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1777/// if the responder is dropped without sending a response, so that the client
1778/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1779impl std::ops::Drop for DebianGuestManagerConnectResponder {
1780    fn drop(&mut self) {
1781        self.control_handle.shutdown();
1782        // Safety: drops once, never accessed again
1783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1784    }
1785}
1786
1787impl fidl::endpoints::Responder for DebianGuestManagerConnectResponder {
1788    type ControlHandle = DebianGuestManagerControlHandle;
1789
1790    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1791        &self.control_handle
1792    }
1793
1794    fn drop_without_shutdown(mut self) {
1795        // Safety: drops once, never accessed again due to mem::forget
1796        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1797        // Prevent Drop from running (which would shut down the channel)
1798        std::mem::forget(self);
1799    }
1800}
1801
1802impl DebianGuestManagerConnectResponder {
1803    /// Sends a response to the FIDL transaction.
1804    ///
1805    /// Sets the channel to shutdown if an error occurs.
1806    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1807        let _result = self.send_raw(result);
1808        if _result.is_err() {
1809            self.control_handle.shutdown();
1810        }
1811        self.drop_without_shutdown();
1812        _result
1813    }
1814
1815    /// Similar to "send" but does not shutdown the channel if an error occurs.
1816    pub fn send_no_shutdown_on_err(
1817        self,
1818        mut result: Result<(), GuestManagerError>,
1819    ) -> Result<(), fidl::Error> {
1820        let _result = self.send_raw(result);
1821        self.drop_without_shutdown();
1822        _result
1823    }
1824
1825    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1826        self.control_handle.inner.send::<fidl::encoding::ResultType<
1827            fidl::encoding::EmptyStruct,
1828            GuestManagerError,
1829        >>(
1830            result,
1831            self.tx_id,
1832            0x4e489076e3bb15b4,
1833            fidl::encoding::DynamicFlags::empty(),
1834        )
1835    }
1836}
1837
1838#[must_use = "FIDL methods require a response to be sent"]
1839#[derive(Debug)]
1840pub struct DebianGuestManagerGetInfoResponder {
1841    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1842    tx_id: u32,
1843}
1844
1845/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1846/// if the responder is dropped without sending a response, so that the client
1847/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1848impl std::ops::Drop for DebianGuestManagerGetInfoResponder {
1849    fn drop(&mut self) {
1850        self.control_handle.shutdown();
1851        // Safety: drops once, never accessed again
1852        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1853    }
1854}
1855
1856impl fidl::endpoints::Responder for DebianGuestManagerGetInfoResponder {
1857    type ControlHandle = DebianGuestManagerControlHandle;
1858
1859    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1860        &self.control_handle
1861    }
1862
1863    fn drop_without_shutdown(mut self) {
1864        // Safety: drops once, never accessed again due to mem::forget
1865        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1866        // Prevent Drop from running (which would shut down the channel)
1867        std::mem::forget(self);
1868    }
1869}
1870
1871impl DebianGuestManagerGetInfoResponder {
1872    /// Sends a response to the FIDL transaction.
1873    ///
1874    /// Sets the channel to shutdown if an error occurs.
1875    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1876        let _result = self.send_raw(guest_info);
1877        if _result.is_err() {
1878            self.control_handle.shutdown();
1879        }
1880        self.drop_without_shutdown();
1881        _result
1882    }
1883
1884    /// Similar to "send" but does not shutdown the channel if an error occurs.
1885    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1886        let _result = self.send_raw(guest_info);
1887        self.drop_without_shutdown();
1888        _result
1889    }
1890
1891    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1892        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
1893            (guest_info,),
1894            self.tx_id,
1895            0x76892614aea695dc,
1896            fidl::encoding::DynamicFlags::empty(),
1897        )
1898    }
1899}
1900
1901#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1902pub struct GuestMarker;
1903
1904impl fidl::endpoints::ProtocolMarker for GuestMarker {
1905    type Proxy = GuestProxy;
1906    type RequestStream = GuestRequestStream;
1907    #[cfg(target_os = "fuchsia")]
1908    type SynchronousProxy = GuestSynchronousProxy;
1909
1910    const DEBUG_NAME: &'static str = "fuchsia.virtualization.Guest";
1911}
1912impl fidl::endpoints::DiscoverableProtocolMarker for GuestMarker {}
1913pub type GuestGetConsoleResult = Result<fidl::Socket, GuestError>;
1914pub type GuestGetHostVsockEndpointResult = Result<(), GuestError>;
1915pub type GuestGetBalloonControllerResult = Result<(), GuestError>;
1916pub type GuestGetMemControllerResult = Result<(), GuestError>;
1917
1918pub trait GuestProxyInterface: Send + Sync {
1919    type GetConsoleResponseFut: std::future::Future<Output = Result<GuestGetConsoleResult, fidl::Error>>
1920        + Send;
1921    fn r#get_console(&self) -> Self::GetConsoleResponseFut;
1922    type GetSerialResponseFut: std::future::Future<Output = Result<fidl::Socket, fidl::Error>>
1923        + Send;
1924    fn r#get_serial(&self) -> Self::GetSerialResponseFut;
1925    type GetHostVsockEndpointResponseFut: std::future::Future<Output = Result<GuestGetHostVsockEndpointResult, fidl::Error>>
1926        + Send;
1927    fn r#get_host_vsock_endpoint(
1928        &self,
1929        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
1930    ) -> Self::GetHostVsockEndpointResponseFut;
1931    type GetBalloonControllerResponseFut: std::future::Future<Output = Result<GuestGetBalloonControllerResult, fidl::Error>>
1932        + Send;
1933    fn r#get_balloon_controller(
1934        &self,
1935        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
1936    ) -> Self::GetBalloonControllerResponseFut;
1937    type GetMemControllerResponseFut: std::future::Future<Output = Result<GuestGetMemControllerResult, fidl::Error>>
1938        + Send;
1939    fn r#get_mem_controller(
1940        &self,
1941        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
1942    ) -> Self::GetMemControllerResponseFut;
1943}
1944#[derive(Debug)]
1945#[cfg(target_os = "fuchsia")]
1946pub struct GuestSynchronousProxy {
1947    client: fidl::client::sync::Client,
1948}
1949
1950#[cfg(target_os = "fuchsia")]
1951impl fidl::endpoints::SynchronousProxy for GuestSynchronousProxy {
1952    type Proxy = GuestProxy;
1953    type Protocol = GuestMarker;
1954
1955    fn from_channel(inner: fidl::Channel) -> Self {
1956        Self::new(inner)
1957    }
1958
1959    fn into_channel(self) -> fidl::Channel {
1960        self.client.into_channel()
1961    }
1962
1963    fn as_channel(&self) -> &fidl::Channel {
1964        self.client.as_channel()
1965    }
1966}
1967
1968#[cfg(target_os = "fuchsia")]
1969impl GuestSynchronousProxy {
1970    pub fn new(channel: fidl::Channel) -> Self {
1971        Self { client: fidl::client::sync::Client::new(channel) }
1972    }
1973
1974    pub fn into_channel(self) -> fidl::Channel {
1975        self.client.into_channel()
1976    }
1977
1978    /// Waits until an event arrives and returns it. It is safe for other
1979    /// threads to make concurrent requests while waiting for an event.
1980    pub fn wait_for_event(
1981        &self,
1982        deadline: zx::MonotonicInstant,
1983    ) -> Result<GuestEvent, fidl::Error> {
1984        GuestEvent::decode(self.client.wait_for_event::<GuestMarker>(deadline)?)
1985    }
1986
1987    /// Get a guest console.
1988    ///
1989    /// The details regarding what output is produced and what input is accepted
1990    /// are determined by each guest, but will typically be a read/write socket
1991    /// with a shell.
1992    ///
1993    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
1994    pub fn r#get_console(
1995        &self,
1996        ___deadline: zx::MonotonicInstant,
1997    ) -> Result<GuestGetConsoleResult, fidl::Error> {
1998        let _response = self.client.send_query::<
1999            fidl::encoding::EmptyPayload,
2000            fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
2001            GuestMarker,
2002        >(
2003            (),
2004            0x48cbcecb7793806e,
2005            fidl::encoding::DynamicFlags::empty(),
2006            ___deadline,
2007        )?;
2008        Ok(_response.map(|x| x.socket))
2009    }
2010
2011    /// Get the socket for low-level guest debug logs.
2012    ///
2013    /// The details regarding what output is produced and what input is accepted
2014    /// are determined by each guest, but will typically be a read-only socket
2015    /// with the guest kernel's serial logs.
2016    pub fn r#get_serial(
2017        &self,
2018        ___deadline: zx::MonotonicInstant,
2019    ) -> Result<fidl::Socket, fidl::Error> {
2020        let _response = self
2021            .client
2022            .send_query::<fidl::encoding::EmptyPayload, GuestGetSerialResponse, GuestMarker>(
2023                (),
2024                0xcdd541a160d7044,
2025                fidl::encoding::DynamicFlags::empty(),
2026                ___deadline,
2027            )?;
2028        Ok(_response.socket)
2029    }
2030
2031    /// Get the vsock endpoint for the guest.
2032    ///
2033    /// This endpoint can be used to register listeners for guest initiated connections, and
2034    /// to initiate connections from a client. If listeners need to be registered before the guest
2035    /// starts so that they are immediately available, set them via the guest config instead of
2036    /// using this endpoint.
2037    ///
2038    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2039    pub fn r#get_host_vsock_endpoint(
2040        &self,
2041        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2042        ___deadline: zx::MonotonicInstant,
2043    ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2044        let _response = self.client.send_query::<
2045            GuestGetHostVsockEndpointRequest,
2046            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2047            GuestMarker,
2048        >(
2049            (endpoint,),
2050            0x766e96aeb9c28ed1,
2051            fidl::encoding::DynamicFlags::empty(),
2052            ___deadline,
2053        )?;
2054        Ok(_response.map(|x| x))
2055    }
2056
2057    /// Get the balloon controller endpoint for the guest.
2058    ///
2059    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2060    pub fn r#get_balloon_controller(
2061        &self,
2062        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2063        ___deadline: zx::MonotonicInstant,
2064    ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2065        let _response = self.client.send_query::<
2066            GuestGetBalloonControllerRequest,
2067            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2068            GuestMarker,
2069        >(
2070            (controller,),
2071            0x7b210bff219ac84e,
2072            fidl::encoding::DynamicFlags::empty(),
2073            ___deadline,
2074        )?;
2075        Ok(_response.map(|x| x))
2076    }
2077
2078    /// Get the mem controller endpoint for the guest.
2079    ///
2080    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2081    pub fn r#get_mem_controller(
2082        &self,
2083        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2084        ___deadline: zx::MonotonicInstant,
2085    ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2086        let _response = self.client.send_query::<
2087            GuestGetMemControllerRequest,
2088            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2089            GuestMarker,
2090        >(
2091            (controller,),
2092            0x170b19f4b867a01c,
2093            fidl::encoding::DynamicFlags::empty(),
2094            ___deadline,
2095        )?;
2096        Ok(_response.map(|x| x))
2097    }
2098}
2099
2100#[cfg(target_os = "fuchsia")]
2101impl From<GuestSynchronousProxy> for zx::NullableHandle {
2102    fn from(value: GuestSynchronousProxy) -> Self {
2103        value.into_channel().into()
2104    }
2105}
2106
2107#[cfg(target_os = "fuchsia")]
2108impl From<fidl::Channel> for GuestSynchronousProxy {
2109    fn from(value: fidl::Channel) -> Self {
2110        Self::new(value)
2111    }
2112}
2113
2114#[cfg(target_os = "fuchsia")]
2115impl fidl::endpoints::FromClient for GuestSynchronousProxy {
2116    type Protocol = GuestMarker;
2117
2118    fn from_client(value: fidl::endpoints::ClientEnd<GuestMarker>) -> Self {
2119        Self::new(value.into_channel())
2120    }
2121}
2122
2123#[derive(Debug, Clone)]
2124pub struct GuestProxy {
2125    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2126}
2127
2128impl fidl::endpoints::Proxy for GuestProxy {
2129    type Protocol = GuestMarker;
2130
2131    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2132        Self::new(inner)
2133    }
2134
2135    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2136        self.client.into_channel().map_err(|client| Self { client })
2137    }
2138
2139    fn as_channel(&self) -> &::fidl::AsyncChannel {
2140        self.client.as_channel()
2141    }
2142}
2143
2144impl GuestProxy {
2145    /// Create a new Proxy for fuchsia.virtualization/Guest.
2146    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2147        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2148        Self { client: fidl::client::Client::new(channel, protocol_name) }
2149    }
2150
2151    /// Get a Stream of events from the remote end of the protocol.
2152    ///
2153    /// # Panics
2154    ///
2155    /// Panics if the event stream was already taken.
2156    pub fn take_event_stream(&self) -> GuestEventStream {
2157        GuestEventStream { event_receiver: self.client.take_event_receiver() }
2158    }
2159
2160    /// Get a guest console.
2161    ///
2162    /// The details regarding what output is produced and what input is accepted
2163    /// are determined by each guest, but will typically be a read/write socket
2164    /// with a shell.
2165    ///
2166    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2167    pub fn r#get_console(
2168        &self,
2169    ) -> fidl::client::QueryResponseFut<
2170        GuestGetConsoleResult,
2171        fidl::encoding::DefaultFuchsiaResourceDialect,
2172    > {
2173        GuestProxyInterface::r#get_console(self)
2174    }
2175
2176    /// Get the socket for low-level guest debug logs.
2177    ///
2178    /// The details regarding what output is produced and what input is accepted
2179    /// are determined by each guest, but will typically be a read-only socket
2180    /// with the guest kernel's serial logs.
2181    pub fn r#get_serial(
2182        &self,
2183    ) -> fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>
2184    {
2185        GuestProxyInterface::r#get_serial(self)
2186    }
2187
2188    /// Get the vsock endpoint for the guest.
2189    ///
2190    /// This endpoint can be used to register listeners for guest initiated connections, and
2191    /// to initiate connections from a client. If listeners need to be registered before the guest
2192    /// starts so that they are immediately available, set them via the guest config instead of
2193    /// using this endpoint.
2194    ///
2195    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2196    pub fn r#get_host_vsock_endpoint(
2197        &self,
2198        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2199    ) -> fidl::client::QueryResponseFut<
2200        GuestGetHostVsockEndpointResult,
2201        fidl::encoding::DefaultFuchsiaResourceDialect,
2202    > {
2203        GuestProxyInterface::r#get_host_vsock_endpoint(self, endpoint)
2204    }
2205
2206    /// Get the balloon controller endpoint for the guest.
2207    ///
2208    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2209    pub fn r#get_balloon_controller(
2210        &self,
2211        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2212    ) -> fidl::client::QueryResponseFut<
2213        GuestGetBalloonControllerResult,
2214        fidl::encoding::DefaultFuchsiaResourceDialect,
2215    > {
2216        GuestProxyInterface::r#get_balloon_controller(self, controller)
2217    }
2218
2219    /// Get the mem controller endpoint for the guest.
2220    ///
2221    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2222    pub fn r#get_mem_controller(
2223        &self,
2224        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2225    ) -> fidl::client::QueryResponseFut<
2226        GuestGetMemControllerResult,
2227        fidl::encoding::DefaultFuchsiaResourceDialect,
2228    > {
2229        GuestProxyInterface::r#get_mem_controller(self, controller)
2230    }
2231}
2232
2233impl GuestProxyInterface for GuestProxy {
2234    type GetConsoleResponseFut = fidl::client::QueryResponseFut<
2235        GuestGetConsoleResult,
2236        fidl::encoding::DefaultFuchsiaResourceDialect,
2237    >;
2238    fn r#get_console(&self) -> Self::GetConsoleResponseFut {
2239        fn _decode(
2240            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2241        ) -> Result<GuestGetConsoleResult, fidl::Error> {
2242            let _response = fidl::client::decode_transaction_body::<
2243                fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
2244                fidl::encoding::DefaultFuchsiaResourceDialect,
2245                0x48cbcecb7793806e,
2246            >(_buf?)?;
2247            Ok(_response.map(|x| x.socket))
2248        }
2249        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestGetConsoleResult>(
2250            (),
2251            0x48cbcecb7793806e,
2252            fidl::encoding::DynamicFlags::empty(),
2253            _decode,
2254        )
2255    }
2256
2257    type GetSerialResponseFut =
2258        fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2259    fn r#get_serial(&self) -> Self::GetSerialResponseFut {
2260        fn _decode(
2261            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2262        ) -> Result<fidl::Socket, fidl::Error> {
2263            let _response = fidl::client::decode_transaction_body::<
2264                GuestGetSerialResponse,
2265                fidl::encoding::DefaultFuchsiaResourceDialect,
2266                0xcdd541a160d7044,
2267            >(_buf?)?;
2268            Ok(_response.socket)
2269        }
2270        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Socket>(
2271            (),
2272            0xcdd541a160d7044,
2273            fidl::encoding::DynamicFlags::empty(),
2274            _decode,
2275        )
2276    }
2277
2278    type GetHostVsockEndpointResponseFut = fidl::client::QueryResponseFut<
2279        GuestGetHostVsockEndpointResult,
2280        fidl::encoding::DefaultFuchsiaResourceDialect,
2281    >;
2282    fn r#get_host_vsock_endpoint(
2283        &self,
2284        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2285    ) -> Self::GetHostVsockEndpointResponseFut {
2286        fn _decode(
2287            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2288        ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2289            let _response = fidl::client::decode_transaction_body::<
2290                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2291                fidl::encoding::DefaultFuchsiaResourceDialect,
2292                0x766e96aeb9c28ed1,
2293            >(_buf?)?;
2294            Ok(_response.map(|x| x))
2295        }
2296        self.client.send_query_and_decode::<
2297            GuestGetHostVsockEndpointRequest,
2298            GuestGetHostVsockEndpointResult,
2299        >(
2300            (endpoint,),
2301            0x766e96aeb9c28ed1,
2302            fidl::encoding::DynamicFlags::empty(),
2303            _decode,
2304        )
2305    }
2306
2307    type GetBalloonControllerResponseFut = fidl::client::QueryResponseFut<
2308        GuestGetBalloonControllerResult,
2309        fidl::encoding::DefaultFuchsiaResourceDialect,
2310    >;
2311    fn r#get_balloon_controller(
2312        &self,
2313        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2314    ) -> Self::GetBalloonControllerResponseFut {
2315        fn _decode(
2316            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2317        ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2318            let _response = fidl::client::decode_transaction_body::<
2319                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2320                fidl::encoding::DefaultFuchsiaResourceDialect,
2321                0x7b210bff219ac84e,
2322            >(_buf?)?;
2323            Ok(_response.map(|x| x))
2324        }
2325        self.client.send_query_and_decode::<
2326            GuestGetBalloonControllerRequest,
2327            GuestGetBalloonControllerResult,
2328        >(
2329            (controller,),
2330            0x7b210bff219ac84e,
2331            fidl::encoding::DynamicFlags::empty(),
2332            _decode,
2333        )
2334    }
2335
2336    type GetMemControllerResponseFut = fidl::client::QueryResponseFut<
2337        GuestGetMemControllerResult,
2338        fidl::encoding::DefaultFuchsiaResourceDialect,
2339    >;
2340    fn r#get_mem_controller(
2341        &self,
2342        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2343    ) -> Self::GetMemControllerResponseFut {
2344        fn _decode(
2345            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2346        ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2347            let _response = fidl::client::decode_transaction_body::<
2348                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2349                fidl::encoding::DefaultFuchsiaResourceDialect,
2350                0x170b19f4b867a01c,
2351            >(_buf?)?;
2352            Ok(_response.map(|x| x))
2353        }
2354        self.client
2355            .send_query_and_decode::<GuestGetMemControllerRequest, GuestGetMemControllerResult>(
2356                (controller,),
2357                0x170b19f4b867a01c,
2358                fidl::encoding::DynamicFlags::empty(),
2359                _decode,
2360            )
2361    }
2362}
2363
2364pub struct GuestEventStream {
2365    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2366}
2367
2368impl std::marker::Unpin for GuestEventStream {}
2369
2370impl futures::stream::FusedStream for GuestEventStream {
2371    fn is_terminated(&self) -> bool {
2372        self.event_receiver.is_terminated()
2373    }
2374}
2375
2376impl futures::Stream for GuestEventStream {
2377    type Item = Result<GuestEvent, fidl::Error>;
2378
2379    fn poll_next(
2380        mut self: std::pin::Pin<&mut Self>,
2381        cx: &mut std::task::Context<'_>,
2382    ) -> std::task::Poll<Option<Self::Item>> {
2383        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2384            &mut self.event_receiver,
2385            cx
2386        )?) {
2387            Some(buf) => std::task::Poll::Ready(Some(GuestEvent::decode(buf))),
2388            None => std::task::Poll::Ready(None),
2389        }
2390    }
2391}
2392
2393#[derive(Debug)]
2394pub enum GuestEvent {}
2395
2396impl GuestEvent {
2397    /// Decodes a message buffer as a [`GuestEvent`].
2398    fn decode(
2399        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2400    ) -> Result<GuestEvent, fidl::Error> {
2401        let (bytes, _handles) = buf.split_mut();
2402        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2403        debug_assert_eq!(tx_header.tx_id, 0);
2404        match tx_header.ordinal {
2405            _ => Err(fidl::Error::UnknownOrdinal {
2406                ordinal: tx_header.ordinal,
2407                protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2408            }),
2409        }
2410    }
2411}
2412
2413/// A Stream of incoming requests for fuchsia.virtualization/Guest.
2414pub struct GuestRequestStream {
2415    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2416    is_terminated: bool,
2417}
2418
2419impl std::marker::Unpin for GuestRequestStream {}
2420
2421impl futures::stream::FusedStream for GuestRequestStream {
2422    fn is_terminated(&self) -> bool {
2423        self.is_terminated
2424    }
2425}
2426
2427impl fidl::endpoints::RequestStream for GuestRequestStream {
2428    type Protocol = GuestMarker;
2429    type ControlHandle = GuestControlHandle;
2430
2431    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2432        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2433    }
2434
2435    fn control_handle(&self) -> Self::ControlHandle {
2436        GuestControlHandle { inner: self.inner.clone() }
2437    }
2438
2439    fn into_inner(
2440        self,
2441    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2442    {
2443        (self.inner, self.is_terminated)
2444    }
2445
2446    fn from_inner(
2447        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2448        is_terminated: bool,
2449    ) -> Self {
2450        Self { inner, is_terminated }
2451    }
2452}
2453
2454impl futures::Stream for GuestRequestStream {
2455    type Item = Result<GuestRequest, fidl::Error>;
2456
2457    fn poll_next(
2458        mut self: std::pin::Pin<&mut Self>,
2459        cx: &mut std::task::Context<'_>,
2460    ) -> std::task::Poll<Option<Self::Item>> {
2461        let this = &mut *self;
2462        if this.inner.check_shutdown(cx) {
2463            this.is_terminated = true;
2464            return std::task::Poll::Ready(None);
2465        }
2466        if this.is_terminated {
2467            panic!("polled GuestRequestStream after completion");
2468        }
2469        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2470            |bytes, handles| {
2471                match this.inner.channel().read_etc(cx, bytes, handles) {
2472                    std::task::Poll::Ready(Ok(())) => {}
2473                    std::task::Poll::Pending => return std::task::Poll::Pending,
2474                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2475                        this.is_terminated = true;
2476                        return std::task::Poll::Ready(None);
2477                    }
2478                    std::task::Poll::Ready(Err(e)) => {
2479                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2480                            e.into(),
2481                        ))));
2482                    }
2483                }
2484
2485                // A message has been received from the channel
2486                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2487
2488                std::task::Poll::Ready(Some(match header.ordinal {
2489                    0x48cbcecb7793806e => {
2490                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2491                        let mut req = fidl::new_empty!(
2492                            fidl::encoding::EmptyPayload,
2493                            fidl::encoding::DefaultFuchsiaResourceDialect
2494                        );
2495                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2496                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2497                        Ok(GuestRequest::GetConsole {
2498                            responder: GuestGetConsoleResponder {
2499                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2500                                tx_id: header.tx_id,
2501                            },
2502                        })
2503                    }
2504                    0xcdd541a160d7044 => {
2505                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2506                        let mut req = fidl::new_empty!(
2507                            fidl::encoding::EmptyPayload,
2508                            fidl::encoding::DefaultFuchsiaResourceDialect
2509                        );
2510                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2511                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2512                        Ok(GuestRequest::GetSerial {
2513                            responder: GuestGetSerialResponder {
2514                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2515                                tx_id: header.tx_id,
2516                            },
2517                        })
2518                    }
2519                    0x766e96aeb9c28ed1 => {
2520                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2521                        let mut req = fidl::new_empty!(
2522                            GuestGetHostVsockEndpointRequest,
2523                            fidl::encoding::DefaultFuchsiaResourceDialect
2524                        );
2525                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetHostVsockEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
2526                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2527                        Ok(GuestRequest::GetHostVsockEndpoint {
2528                            endpoint: req.endpoint,
2529
2530                            responder: GuestGetHostVsockEndpointResponder {
2531                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2532                                tx_id: header.tx_id,
2533                            },
2534                        })
2535                    }
2536                    0x7b210bff219ac84e => {
2537                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2538                        let mut req = fidl::new_empty!(
2539                            GuestGetBalloonControllerRequest,
2540                            fidl::encoding::DefaultFuchsiaResourceDialect
2541                        );
2542                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetBalloonControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2543                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2544                        Ok(GuestRequest::GetBalloonController {
2545                            controller: req.controller,
2546
2547                            responder: GuestGetBalloonControllerResponder {
2548                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2549                                tx_id: header.tx_id,
2550                            },
2551                        })
2552                    }
2553                    0x170b19f4b867a01c => {
2554                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2555                        let mut req = fidl::new_empty!(
2556                            GuestGetMemControllerRequest,
2557                            fidl::encoding::DefaultFuchsiaResourceDialect
2558                        );
2559                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetMemControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2560                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2561                        Ok(GuestRequest::GetMemController {
2562                            controller: req.controller,
2563
2564                            responder: GuestGetMemControllerResponder {
2565                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2566                                tx_id: header.tx_id,
2567                            },
2568                        })
2569                    }
2570                    _ => Err(fidl::Error::UnknownOrdinal {
2571                        ordinal: header.ordinal,
2572                        protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2573                    }),
2574                }))
2575            },
2576        )
2577    }
2578}
2579
2580/// The guest client API providing high level access to guest features. When the guest terminates,
2581/// this channel will contain a ZX_OK epitaph on a clean shutdown, a ZX_ERR_INTERNAL epitaph on
2582/// an unexpected shutdown, and no epitaph if the component crashed.
2583#[derive(Debug)]
2584pub enum GuestRequest {
2585    /// Get a guest console.
2586    ///
2587    /// The details regarding what output is produced and what input is accepted
2588    /// are determined by each guest, but will typically be a read/write socket
2589    /// with a shell.
2590    ///
2591    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2592    GetConsole { responder: GuestGetConsoleResponder },
2593    /// Get the socket for low-level guest debug logs.
2594    ///
2595    /// The details regarding what output is produced and what input is accepted
2596    /// are determined by each guest, but will typically be a read-only socket
2597    /// with the guest kernel's serial logs.
2598    GetSerial { responder: GuestGetSerialResponder },
2599    /// Get the vsock endpoint for the guest.
2600    ///
2601    /// This endpoint can be used to register listeners for guest initiated connections, and
2602    /// to initiate connections from a client. If listeners need to be registered before the guest
2603    /// starts so that they are immediately available, set them via the guest config instead of
2604    /// using this endpoint.
2605    ///
2606    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2607    GetHostVsockEndpoint {
2608        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2609        responder: GuestGetHostVsockEndpointResponder,
2610    },
2611    /// Get the balloon controller endpoint for the guest.
2612    ///
2613    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2614    GetBalloonController {
2615        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2616        responder: GuestGetBalloonControllerResponder,
2617    },
2618    /// Get the mem controller endpoint for the guest.
2619    ///
2620    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2621    GetMemController {
2622        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2623        responder: GuestGetMemControllerResponder,
2624    },
2625}
2626
2627impl GuestRequest {
2628    #[allow(irrefutable_let_patterns)]
2629    pub fn into_get_console(self) -> Option<(GuestGetConsoleResponder)> {
2630        if let GuestRequest::GetConsole { responder } = self { Some((responder)) } else { None }
2631    }
2632
2633    #[allow(irrefutable_let_patterns)]
2634    pub fn into_get_serial(self) -> Option<(GuestGetSerialResponder)> {
2635        if let GuestRequest::GetSerial { responder } = self { Some((responder)) } else { None }
2636    }
2637
2638    #[allow(irrefutable_let_patterns)]
2639    pub fn into_get_host_vsock_endpoint(
2640        self,
2641    ) -> Option<(
2642        fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2643        GuestGetHostVsockEndpointResponder,
2644    )> {
2645        if let GuestRequest::GetHostVsockEndpoint { endpoint, responder } = self {
2646            Some((endpoint, responder))
2647        } else {
2648            None
2649        }
2650    }
2651
2652    #[allow(irrefutable_let_patterns)]
2653    pub fn into_get_balloon_controller(
2654        self,
2655    ) -> Option<(
2656        fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2657        GuestGetBalloonControllerResponder,
2658    )> {
2659        if let GuestRequest::GetBalloonController { controller, responder } = self {
2660            Some((controller, responder))
2661        } else {
2662            None
2663        }
2664    }
2665
2666    #[allow(irrefutable_let_patterns)]
2667    pub fn into_get_mem_controller(
2668        self,
2669    ) -> Option<(fidl::endpoints::ServerEnd<MemControllerMarker>, GuestGetMemControllerResponder)>
2670    {
2671        if let GuestRequest::GetMemController { controller, responder } = self {
2672            Some((controller, responder))
2673        } else {
2674            None
2675        }
2676    }
2677
2678    /// Name of the method defined in FIDL
2679    pub fn method_name(&self) -> &'static str {
2680        match *self {
2681            GuestRequest::GetConsole { .. } => "get_console",
2682            GuestRequest::GetSerial { .. } => "get_serial",
2683            GuestRequest::GetHostVsockEndpoint { .. } => "get_host_vsock_endpoint",
2684            GuestRequest::GetBalloonController { .. } => "get_balloon_controller",
2685            GuestRequest::GetMemController { .. } => "get_mem_controller",
2686        }
2687    }
2688}
2689
2690#[derive(Debug, Clone)]
2691pub struct GuestControlHandle {
2692    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2693}
2694
2695impl GuestControlHandle {
2696    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2697        self.inner.shutdown_with_epitaph(status.into())
2698    }
2699}
2700
2701impl fidl::endpoints::ControlHandle for GuestControlHandle {
2702    fn shutdown(&self) {
2703        self.inner.shutdown()
2704    }
2705
2706    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2707        self.inner.shutdown_with_epitaph(status)
2708    }
2709
2710    fn is_closed(&self) -> bool {
2711        self.inner.channel().is_closed()
2712    }
2713    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2714        self.inner.channel().on_closed()
2715    }
2716
2717    #[cfg(target_os = "fuchsia")]
2718    fn signal_peer(
2719        &self,
2720        clear_mask: zx::Signals,
2721        set_mask: zx::Signals,
2722    ) -> Result<(), zx_status::Status> {
2723        use fidl::Peered;
2724        self.inner.channel().signal_peer(clear_mask, set_mask)
2725    }
2726}
2727
2728impl GuestControlHandle {}
2729
2730#[must_use = "FIDL methods require a response to be sent"]
2731#[derive(Debug)]
2732pub struct GuestGetConsoleResponder {
2733    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2734    tx_id: u32,
2735}
2736
2737/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2738/// if the responder is dropped without sending a response, so that the client
2739/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2740impl std::ops::Drop for GuestGetConsoleResponder {
2741    fn drop(&mut self) {
2742        self.control_handle.shutdown();
2743        // Safety: drops once, never accessed again
2744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2745    }
2746}
2747
2748impl fidl::endpoints::Responder for GuestGetConsoleResponder {
2749    type ControlHandle = GuestControlHandle;
2750
2751    fn control_handle(&self) -> &GuestControlHandle {
2752        &self.control_handle
2753    }
2754
2755    fn drop_without_shutdown(mut self) {
2756        // Safety: drops once, never accessed again due to mem::forget
2757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2758        // Prevent Drop from running (which would shut down the channel)
2759        std::mem::forget(self);
2760    }
2761}
2762
2763impl GuestGetConsoleResponder {
2764    /// Sends a response to the FIDL transaction.
2765    ///
2766    /// Sets the channel to shutdown if an error occurs.
2767    pub fn send(self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2768        let _result = self.send_raw(result);
2769        if _result.is_err() {
2770            self.control_handle.shutdown();
2771        }
2772        self.drop_without_shutdown();
2773        _result
2774    }
2775
2776    /// Similar to "send" but does not shutdown the channel if an error occurs.
2777    pub fn send_no_shutdown_on_err(
2778        self,
2779        mut result: Result<fidl::Socket, GuestError>,
2780    ) -> Result<(), fidl::Error> {
2781        let _result = self.send_raw(result);
2782        self.drop_without_shutdown();
2783        _result
2784    }
2785
2786    fn send_raw(&self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2787        self.control_handle
2788            .inner
2789            .send::<fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>>(
2790                result.map(|socket| (socket,)),
2791                self.tx_id,
2792                0x48cbcecb7793806e,
2793                fidl::encoding::DynamicFlags::empty(),
2794            )
2795    }
2796}
2797
2798#[must_use = "FIDL methods require a response to be sent"]
2799#[derive(Debug)]
2800pub struct GuestGetSerialResponder {
2801    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2802    tx_id: u32,
2803}
2804
2805/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2806/// if the responder is dropped without sending a response, so that the client
2807/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2808impl std::ops::Drop for GuestGetSerialResponder {
2809    fn drop(&mut self) {
2810        self.control_handle.shutdown();
2811        // Safety: drops once, never accessed again
2812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2813    }
2814}
2815
2816impl fidl::endpoints::Responder for GuestGetSerialResponder {
2817    type ControlHandle = GuestControlHandle;
2818
2819    fn control_handle(&self) -> &GuestControlHandle {
2820        &self.control_handle
2821    }
2822
2823    fn drop_without_shutdown(mut self) {
2824        // Safety: drops once, never accessed again due to mem::forget
2825        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2826        // Prevent Drop from running (which would shut down the channel)
2827        std::mem::forget(self);
2828    }
2829}
2830
2831impl GuestGetSerialResponder {
2832    /// Sends a response to the FIDL transaction.
2833    ///
2834    /// Sets the channel to shutdown if an error occurs.
2835    pub fn send(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2836        let _result = self.send_raw(socket);
2837        if _result.is_err() {
2838            self.control_handle.shutdown();
2839        }
2840        self.drop_without_shutdown();
2841        _result
2842    }
2843
2844    /// Similar to "send" but does not shutdown the channel if an error occurs.
2845    pub fn send_no_shutdown_on_err(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2846        let _result = self.send_raw(socket);
2847        self.drop_without_shutdown();
2848        _result
2849    }
2850
2851    fn send_raw(&self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2852        self.control_handle.inner.send::<GuestGetSerialResponse>(
2853            (socket,),
2854            self.tx_id,
2855            0xcdd541a160d7044,
2856            fidl::encoding::DynamicFlags::empty(),
2857        )
2858    }
2859}
2860
2861#[must_use = "FIDL methods require a response to be sent"]
2862#[derive(Debug)]
2863pub struct GuestGetHostVsockEndpointResponder {
2864    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2865    tx_id: u32,
2866}
2867
2868/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2869/// if the responder is dropped without sending a response, so that the client
2870/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2871impl std::ops::Drop for GuestGetHostVsockEndpointResponder {
2872    fn drop(&mut self) {
2873        self.control_handle.shutdown();
2874        // Safety: drops once, never accessed again
2875        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2876    }
2877}
2878
2879impl fidl::endpoints::Responder for GuestGetHostVsockEndpointResponder {
2880    type ControlHandle = GuestControlHandle;
2881
2882    fn control_handle(&self) -> &GuestControlHandle {
2883        &self.control_handle
2884    }
2885
2886    fn drop_without_shutdown(mut self) {
2887        // Safety: drops once, never accessed again due to mem::forget
2888        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2889        // Prevent Drop from running (which would shut down the channel)
2890        std::mem::forget(self);
2891    }
2892}
2893
2894impl GuestGetHostVsockEndpointResponder {
2895    /// Sends a response to the FIDL transaction.
2896    ///
2897    /// Sets the channel to shutdown if an error occurs.
2898    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2899        let _result = self.send_raw(result);
2900        if _result.is_err() {
2901            self.control_handle.shutdown();
2902        }
2903        self.drop_without_shutdown();
2904        _result
2905    }
2906
2907    /// Similar to "send" but does not shutdown the channel if an error occurs.
2908    pub fn send_no_shutdown_on_err(
2909        self,
2910        mut result: Result<(), GuestError>,
2911    ) -> Result<(), fidl::Error> {
2912        let _result = self.send_raw(result);
2913        self.drop_without_shutdown();
2914        _result
2915    }
2916
2917    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2918        self.control_handle
2919            .inner
2920            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2921                result,
2922                self.tx_id,
2923                0x766e96aeb9c28ed1,
2924                fidl::encoding::DynamicFlags::empty(),
2925            )
2926    }
2927}
2928
2929#[must_use = "FIDL methods require a response to be sent"]
2930#[derive(Debug)]
2931pub struct GuestGetBalloonControllerResponder {
2932    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2933    tx_id: u32,
2934}
2935
2936/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2937/// if the responder is dropped without sending a response, so that the client
2938/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2939impl std::ops::Drop for GuestGetBalloonControllerResponder {
2940    fn drop(&mut self) {
2941        self.control_handle.shutdown();
2942        // Safety: drops once, never accessed again
2943        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2944    }
2945}
2946
2947impl fidl::endpoints::Responder for GuestGetBalloonControllerResponder {
2948    type ControlHandle = GuestControlHandle;
2949
2950    fn control_handle(&self) -> &GuestControlHandle {
2951        &self.control_handle
2952    }
2953
2954    fn drop_without_shutdown(mut self) {
2955        // Safety: drops once, never accessed again due to mem::forget
2956        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2957        // Prevent Drop from running (which would shut down the channel)
2958        std::mem::forget(self);
2959    }
2960}
2961
2962impl GuestGetBalloonControllerResponder {
2963    /// Sends a response to the FIDL transaction.
2964    ///
2965    /// Sets the channel to shutdown if an error occurs.
2966    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2967        let _result = self.send_raw(result);
2968        if _result.is_err() {
2969            self.control_handle.shutdown();
2970        }
2971        self.drop_without_shutdown();
2972        _result
2973    }
2974
2975    /// Similar to "send" but does not shutdown the channel if an error occurs.
2976    pub fn send_no_shutdown_on_err(
2977        self,
2978        mut result: Result<(), GuestError>,
2979    ) -> Result<(), fidl::Error> {
2980        let _result = self.send_raw(result);
2981        self.drop_without_shutdown();
2982        _result
2983    }
2984
2985    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2986        self.control_handle
2987            .inner
2988            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2989                result,
2990                self.tx_id,
2991                0x7b210bff219ac84e,
2992                fidl::encoding::DynamicFlags::empty(),
2993            )
2994    }
2995}
2996
2997#[must_use = "FIDL methods require a response to be sent"]
2998#[derive(Debug)]
2999pub struct GuestGetMemControllerResponder {
3000    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
3001    tx_id: u32,
3002}
3003
3004/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
3005/// if the responder is dropped without sending a response, so that the client
3006/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3007impl std::ops::Drop for GuestGetMemControllerResponder {
3008    fn drop(&mut self) {
3009        self.control_handle.shutdown();
3010        // Safety: drops once, never accessed again
3011        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3012    }
3013}
3014
3015impl fidl::endpoints::Responder for GuestGetMemControllerResponder {
3016    type ControlHandle = GuestControlHandle;
3017
3018    fn control_handle(&self) -> &GuestControlHandle {
3019        &self.control_handle
3020    }
3021
3022    fn drop_without_shutdown(mut self) {
3023        // Safety: drops once, never accessed again due to mem::forget
3024        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3025        // Prevent Drop from running (which would shut down the channel)
3026        std::mem::forget(self);
3027    }
3028}
3029
3030impl GuestGetMemControllerResponder {
3031    /// Sends a response to the FIDL transaction.
3032    ///
3033    /// Sets the channel to shutdown if an error occurs.
3034    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3035        let _result = self.send_raw(result);
3036        if _result.is_err() {
3037            self.control_handle.shutdown();
3038        }
3039        self.drop_without_shutdown();
3040        _result
3041    }
3042
3043    /// Similar to "send" but does not shutdown the channel if an error occurs.
3044    pub fn send_no_shutdown_on_err(
3045        self,
3046        mut result: Result<(), GuestError>,
3047    ) -> Result<(), fidl::Error> {
3048        let _result = self.send_raw(result);
3049        self.drop_without_shutdown();
3050        _result
3051    }
3052
3053    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3054        self.control_handle
3055            .inner
3056            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3057                result,
3058                self.tx_id,
3059                0x170b19f4b867a01c,
3060                fidl::encoding::DynamicFlags::empty(),
3061            )
3062    }
3063}
3064
3065#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3066pub struct GuestLifecycleMarker;
3067
3068impl fidl::endpoints::ProtocolMarker for GuestLifecycleMarker {
3069    type Proxy = GuestLifecycleProxy;
3070    type RequestStream = GuestLifecycleRequestStream;
3071    #[cfg(target_os = "fuchsia")]
3072    type SynchronousProxy = GuestLifecycleSynchronousProxy;
3073
3074    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestLifecycle";
3075}
3076impl fidl::endpoints::DiscoverableProtocolMarker for GuestLifecycleMarker {}
3077pub type GuestLifecycleCreateResult = Result<(), GuestError>;
3078pub type GuestLifecycleRunResult = Result<(), GuestError>;
3079
3080pub trait GuestLifecycleProxyInterface: Send + Sync {
3081    type CreateResponseFut: std::future::Future<Output = Result<GuestLifecycleCreateResult, fidl::Error>>
3082        + Send;
3083    fn r#create(&self, guest_config: GuestConfig) -> Self::CreateResponseFut;
3084    fn r#bind(&self, guest: fidl::endpoints::ServerEnd<GuestMarker>) -> Result<(), fidl::Error>;
3085    type RunResponseFut: std::future::Future<Output = Result<GuestLifecycleRunResult, fidl::Error>>
3086        + Send;
3087    fn r#run(&self) -> Self::RunResponseFut;
3088    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3089    fn r#stop(&self) -> Self::StopResponseFut;
3090}
3091#[derive(Debug)]
3092#[cfg(target_os = "fuchsia")]
3093pub struct GuestLifecycleSynchronousProxy {
3094    client: fidl::client::sync::Client,
3095}
3096
3097#[cfg(target_os = "fuchsia")]
3098impl fidl::endpoints::SynchronousProxy for GuestLifecycleSynchronousProxy {
3099    type Proxy = GuestLifecycleProxy;
3100    type Protocol = GuestLifecycleMarker;
3101
3102    fn from_channel(inner: fidl::Channel) -> Self {
3103        Self::new(inner)
3104    }
3105
3106    fn into_channel(self) -> fidl::Channel {
3107        self.client.into_channel()
3108    }
3109
3110    fn as_channel(&self) -> &fidl::Channel {
3111        self.client.as_channel()
3112    }
3113}
3114
3115#[cfg(target_os = "fuchsia")]
3116impl GuestLifecycleSynchronousProxy {
3117    pub fn new(channel: fidl::Channel) -> Self {
3118        Self { client: fidl::client::sync::Client::new(channel) }
3119    }
3120
3121    pub fn into_channel(self) -> fidl::Channel {
3122        self.client.into_channel()
3123    }
3124
3125    /// Waits until an event arrives and returns it. It is safe for other
3126    /// threads to make concurrent requests while waiting for an event.
3127    pub fn wait_for_event(
3128        &self,
3129        deadline: zx::MonotonicInstant,
3130    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3131        GuestLifecycleEvent::decode(self.client.wait_for_event::<GuestLifecycleMarker>(deadline)?)
3132    }
3133
3134    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3135    /// the kernel without starting the VCPU or device dispatch loops.
3136    ///
3137    /// Possible errors:
3138    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3139    ///         recreated.
3140    ///
3141    /// All other errors are related to VMM initialization.
3142    pub fn r#create(
3143        &self,
3144        mut guest_config: GuestConfig,
3145        ___deadline: zx::MonotonicInstant,
3146    ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3147        let _response = self.client.send_query::<
3148            GuestLifecycleCreateRequest,
3149            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3150            GuestLifecycleMarker,
3151        >(
3152            (&mut guest_config,),
3153            0x152719eed416ed41,
3154            fidl::encoding::DynamicFlags::empty(),
3155            ___deadline,
3156        )?;
3157        Ok(_response.map(|x| x))
3158    }
3159
3160    /// Binds to the Guest protocol for an initialized guest.
3161    ///
3162    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3163    /// will be immediately closed.
3164    pub fn r#bind(
3165        &self,
3166        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3167    ) -> Result<(), fidl::Error> {
3168        self.client.send::<GuestLifecycleBindRequest>(
3169            (guest,),
3170            0x57dd3e245f9598ed,
3171            fidl::encoding::DynamicFlags::empty(),
3172        )
3173    }
3174
3175    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3176    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3177    ///
3178    /// Possible errors:
3179    ///     - ALREADY_RUNING: The VMM has already been started.
3180    ///     - NOT_CREATED: Run was called before the VMM was created.
3181    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3182    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3183    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3184    pub fn r#run(
3185        &self,
3186        ___deadline: zx::MonotonicInstant,
3187    ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3188        let _response = self.client.send_query::<
3189            fidl::encoding::EmptyPayload,
3190            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3191            GuestLifecycleMarker,
3192        >(
3193            (),
3194            0x2907fef2ac775657,
3195            fidl::encoding::DynamicFlags::empty(),
3196            ___deadline,
3197        )?;
3198        Ok(_response.map(|x| x))
3199    }
3200
3201    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3202    /// Create and then Run can be called again.
3203    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3204        let _response = self.client.send_query::<
3205            fidl::encoding::EmptyPayload,
3206            fidl::encoding::EmptyPayload,
3207            GuestLifecycleMarker,
3208        >(
3209            (),
3210            0x27eef9c535ac8eb4,
3211            fidl::encoding::DynamicFlags::empty(),
3212            ___deadline,
3213        )?;
3214        Ok(_response)
3215    }
3216}
3217
3218#[cfg(target_os = "fuchsia")]
3219impl From<GuestLifecycleSynchronousProxy> for zx::NullableHandle {
3220    fn from(value: GuestLifecycleSynchronousProxy) -> Self {
3221        value.into_channel().into()
3222    }
3223}
3224
3225#[cfg(target_os = "fuchsia")]
3226impl From<fidl::Channel> for GuestLifecycleSynchronousProxy {
3227    fn from(value: fidl::Channel) -> Self {
3228        Self::new(value)
3229    }
3230}
3231
3232#[cfg(target_os = "fuchsia")]
3233impl fidl::endpoints::FromClient for GuestLifecycleSynchronousProxy {
3234    type Protocol = GuestLifecycleMarker;
3235
3236    fn from_client(value: fidl::endpoints::ClientEnd<GuestLifecycleMarker>) -> Self {
3237        Self::new(value.into_channel())
3238    }
3239}
3240
3241#[derive(Debug, Clone)]
3242pub struct GuestLifecycleProxy {
3243    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3244}
3245
3246impl fidl::endpoints::Proxy for GuestLifecycleProxy {
3247    type Protocol = GuestLifecycleMarker;
3248
3249    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3250        Self::new(inner)
3251    }
3252
3253    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3254        self.client.into_channel().map_err(|client| Self { client })
3255    }
3256
3257    fn as_channel(&self) -> &::fidl::AsyncChannel {
3258        self.client.as_channel()
3259    }
3260}
3261
3262impl GuestLifecycleProxy {
3263    /// Create a new Proxy for fuchsia.virtualization/GuestLifecycle.
3264    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3265        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3266        Self { client: fidl::client::Client::new(channel, protocol_name) }
3267    }
3268
3269    /// Get a Stream of events from the remote end of the protocol.
3270    ///
3271    /// # Panics
3272    ///
3273    /// Panics if the event stream was already taken.
3274    pub fn take_event_stream(&self) -> GuestLifecycleEventStream {
3275        GuestLifecycleEventStream { event_receiver: self.client.take_event_receiver() }
3276    }
3277
3278    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3279    /// the kernel without starting the VCPU or device dispatch loops.
3280    ///
3281    /// Possible errors:
3282    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3283    ///         recreated.
3284    ///
3285    /// All other errors are related to VMM initialization.
3286    pub fn r#create(
3287        &self,
3288        mut guest_config: GuestConfig,
3289    ) -> fidl::client::QueryResponseFut<
3290        GuestLifecycleCreateResult,
3291        fidl::encoding::DefaultFuchsiaResourceDialect,
3292    > {
3293        GuestLifecycleProxyInterface::r#create(self, guest_config)
3294    }
3295
3296    /// Binds to the Guest protocol for an initialized guest.
3297    ///
3298    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3299    /// will be immediately closed.
3300    pub fn r#bind(
3301        &self,
3302        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3303    ) -> Result<(), fidl::Error> {
3304        GuestLifecycleProxyInterface::r#bind(self, guest)
3305    }
3306
3307    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3308    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3309    ///
3310    /// Possible errors:
3311    ///     - ALREADY_RUNING: The VMM has already been started.
3312    ///     - NOT_CREATED: Run was called before the VMM was created.
3313    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3314    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3315    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3316    pub fn r#run(
3317        &self,
3318    ) -> fidl::client::QueryResponseFut<
3319        GuestLifecycleRunResult,
3320        fidl::encoding::DefaultFuchsiaResourceDialect,
3321    > {
3322        GuestLifecycleProxyInterface::r#run(self)
3323    }
3324
3325    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3326    /// Create and then Run can be called again.
3327    pub fn r#stop(
3328        &self,
3329    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3330        GuestLifecycleProxyInterface::r#stop(self)
3331    }
3332}
3333
3334impl GuestLifecycleProxyInterface for GuestLifecycleProxy {
3335    type CreateResponseFut = fidl::client::QueryResponseFut<
3336        GuestLifecycleCreateResult,
3337        fidl::encoding::DefaultFuchsiaResourceDialect,
3338    >;
3339    fn r#create(&self, mut guest_config: GuestConfig) -> Self::CreateResponseFut {
3340        fn _decode(
3341            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3342        ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3343            let _response = fidl::client::decode_transaction_body::<
3344                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3345                fidl::encoding::DefaultFuchsiaResourceDialect,
3346                0x152719eed416ed41,
3347            >(_buf?)?;
3348            Ok(_response.map(|x| x))
3349        }
3350        self.client
3351            .send_query_and_decode::<GuestLifecycleCreateRequest, GuestLifecycleCreateResult>(
3352                (&mut guest_config,),
3353                0x152719eed416ed41,
3354                fidl::encoding::DynamicFlags::empty(),
3355                _decode,
3356            )
3357    }
3358
3359    fn r#bind(
3360        &self,
3361        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3362    ) -> Result<(), fidl::Error> {
3363        self.client.send::<GuestLifecycleBindRequest>(
3364            (guest,),
3365            0x57dd3e245f9598ed,
3366            fidl::encoding::DynamicFlags::empty(),
3367        )
3368    }
3369
3370    type RunResponseFut = fidl::client::QueryResponseFut<
3371        GuestLifecycleRunResult,
3372        fidl::encoding::DefaultFuchsiaResourceDialect,
3373    >;
3374    fn r#run(&self) -> Self::RunResponseFut {
3375        fn _decode(
3376            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3377        ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3378            let _response = fidl::client::decode_transaction_body::<
3379                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3380                fidl::encoding::DefaultFuchsiaResourceDialect,
3381                0x2907fef2ac775657,
3382            >(_buf?)?;
3383            Ok(_response.map(|x| x))
3384        }
3385        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestLifecycleRunResult>(
3386            (),
3387            0x2907fef2ac775657,
3388            fidl::encoding::DynamicFlags::empty(),
3389            _decode,
3390        )
3391    }
3392
3393    type StopResponseFut =
3394        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3395    fn r#stop(&self) -> Self::StopResponseFut {
3396        fn _decode(
3397            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3398        ) -> Result<(), fidl::Error> {
3399            let _response = fidl::client::decode_transaction_body::<
3400                fidl::encoding::EmptyPayload,
3401                fidl::encoding::DefaultFuchsiaResourceDialect,
3402                0x27eef9c535ac8eb4,
3403            >(_buf?)?;
3404            Ok(_response)
3405        }
3406        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3407            (),
3408            0x27eef9c535ac8eb4,
3409            fidl::encoding::DynamicFlags::empty(),
3410            _decode,
3411        )
3412    }
3413}
3414
3415pub struct GuestLifecycleEventStream {
3416    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3417}
3418
3419impl std::marker::Unpin for GuestLifecycleEventStream {}
3420
3421impl futures::stream::FusedStream for GuestLifecycleEventStream {
3422    fn is_terminated(&self) -> bool {
3423        self.event_receiver.is_terminated()
3424    }
3425}
3426
3427impl futures::Stream for GuestLifecycleEventStream {
3428    type Item = Result<GuestLifecycleEvent, fidl::Error>;
3429
3430    fn poll_next(
3431        mut self: std::pin::Pin<&mut Self>,
3432        cx: &mut std::task::Context<'_>,
3433    ) -> std::task::Poll<Option<Self::Item>> {
3434        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3435            &mut self.event_receiver,
3436            cx
3437        )?) {
3438            Some(buf) => std::task::Poll::Ready(Some(GuestLifecycleEvent::decode(buf))),
3439            None => std::task::Poll::Ready(None),
3440        }
3441    }
3442}
3443
3444#[derive(Debug)]
3445pub enum GuestLifecycleEvent {}
3446
3447impl GuestLifecycleEvent {
3448    /// Decodes a message buffer as a [`GuestLifecycleEvent`].
3449    fn decode(
3450        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3451    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3452        let (bytes, _handles) = buf.split_mut();
3453        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3454        debug_assert_eq!(tx_header.tx_id, 0);
3455        match tx_header.ordinal {
3456            _ => Err(fidl::Error::UnknownOrdinal {
3457                ordinal: tx_header.ordinal,
3458                protocol_name:
3459                    <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3460            }),
3461        }
3462    }
3463}
3464
3465/// A Stream of incoming requests for fuchsia.virtualization/GuestLifecycle.
3466pub struct GuestLifecycleRequestStream {
3467    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3468    is_terminated: bool,
3469}
3470
3471impl std::marker::Unpin for GuestLifecycleRequestStream {}
3472
3473impl futures::stream::FusedStream for GuestLifecycleRequestStream {
3474    fn is_terminated(&self) -> bool {
3475        self.is_terminated
3476    }
3477}
3478
3479impl fidl::endpoints::RequestStream for GuestLifecycleRequestStream {
3480    type Protocol = GuestLifecycleMarker;
3481    type ControlHandle = GuestLifecycleControlHandle;
3482
3483    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3484        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3485    }
3486
3487    fn control_handle(&self) -> Self::ControlHandle {
3488        GuestLifecycleControlHandle { inner: self.inner.clone() }
3489    }
3490
3491    fn into_inner(
3492        self,
3493    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3494    {
3495        (self.inner, self.is_terminated)
3496    }
3497
3498    fn from_inner(
3499        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3500        is_terminated: bool,
3501    ) -> Self {
3502        Self { inner, is_terminated }
3503    }
3504}
3505
3506impl futures::Stream for GuestLifecycleRequestStream {
3507    type Item = Result<GuestLifecycleRequest, fidl::Error>;
3508
3509    fn poll_next(
3510        mut self: std::pin::Pin<&mut Self>,
3511        cx: &mut std::task::Context<'_>,
3512    ) -> std::task::Poll<Option<Self::Item>> {
3513        let this = &mut *self;
3514        if this.inner.check_shutdown(cx) {
3515            this.is_terminated = true;
3516            return std::task::Poll::Ready(None);
3517        }
3518        if this.is_terminated {
3519            panic!("polled GuestLifecycleRequestStream after completion");
3520        }
3521        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3522            |bytes, handles| {
3523                match this.inner.channel().read_etc(cx, bytes, handles) {
3524                    std::task::Poll::Ready(Ok(())) => {}
3525                    std::task::Poll::Pending => return std::task::Poll::Pending,
3526                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3527                        this.is_terminated = true;
3528                        return std::task::Poll::Ready(None);
3529                    }
3530                    std::task::Poll::Ready(Err(e)) => {
3531                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3532                            e.into(),
3533                        ))));
3534                    }
3535                }
3536
3537                // A message has been received from the channel
3538                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3539
3540                std::task::Poll::Ready(Some(match header.ordinal {
3541                    0x152719eed416ed41 => {
3542                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3543                        let mut req = fidl::new_empty!(
3544                            GuestLifecycleCreateRequest,
3545                            fidl::encoding::DefaultFuchsiaResourceDialect
3546                        );
3547                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleCreateRequest>(&header, _body_bytes, handles, &mut req)?;
3548                        let control_handle =
3549                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3550                        Ok(GuestLifecycleRequest::Create {
3551                            guest_config: req.guest_config,
3552
3553                            responder: GuestLifecycleCreateResponder {
3554                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3555                                tx_id: header.tx_id,
3556                            },
3557                        })
3558                    }
3559                    0x57dd3e245f9598ed => {
3560                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3561                        let mut req = fidl::new_empty!(
3562                            GuestLifecycleBindRequest,
3563                            fidl::encoding::DefaultFuchsiaResourceDialect
3564                        );
3565                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleBindRequest>(&header, _body_bytes, handles, &mut req)?;
3566                        let control_handle =
3567                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3568                        Ok(GuestLifecycleRequest::Bind { guest: req.guest, control_handle })
3569                    }
3570                    0x2907fef2ac775657 => {
3571                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3572                        let mut req = fidl::new_empty!(
3573                            fidl::encoding::EmptyPayload,
3574                            fidl::encoding::DefaultFuchsiaResourceDialect
3575                        );
3576                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3577                        let control_handle =
3578                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3579                        Ok(GuestLifecycleRequest::Run {
3580                            responder: GuestLifecycleRunResponder {
3581                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3582                                tx_id: header.tx_id,
3583                            },
3584                        })
3585                    }
3586                    0x27eef9c535ac8eb4 => {
3587                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3588                        let mut req = fidl::new_empty!(
3589                            fidl::encoding::EmptyPayload,
3590                            fidl::encoding::DefaultFuchsiaResourceDialect
3591                        );
3592                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3593                        let control_handle =
3594                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3595                        Ok(GuestLifecycleRequest::Stop {
3596                            responder: GuestLifecycleStopResponder {
3597                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3598                                tx_id: header.tx_id,
3599                            },
3600                        })
3601                    }
3602                    _ => Err(fidl::Error::UnknownOrdinal {
3603                        ordinal: header.ordinal,
3604                        protocol_name:
3605                            <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3606                    }),
3607                }))
3608            },
3609        )
3610    }
3611}
3612
3613/// The guest control plane allowing for creating, starting, and stopping the guest.
3614#[derive(Debug)]
3615pub enum GuestLifecycleRequest {
3616    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3617    /// the kernel without starting the VCPU or device dispatch loops.
3618    ///
3619    /// Possible errors:
3620    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3621    ///         recreated.
3622    ///
3623    /// All other errors are related to VMM initialization.
3624    Create { guest_config: GuestConfig, responder: GuestLifecycleCreateResponder },
3625    /// Binds to the Guest protocol for an initialized guest.
3626    ///
3627    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3628    /// will be immediately closed.
3629    Bind {
3630        guest: fidl::endpoints::ServerEnd<GuestMarker>,
3631        control_handle: GuestLifecycleControlHandle,
3632    },
3633    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3634    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3635    ///
3636    /// Possible errors:
3637    ///     - ALREADY_RUNING: The VMM has already been started.
3638    ///     - NOT_CREATED: Run was called before the VMM was created.
3639    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3640    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3641    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3642    Run { responder: GuestLifecycleRunResponder },
3643    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3644    /// Create and then Run can be called again.
3645    Stop { responder: GuestLifecycleStopResponder },
3646}
3647
3648impl GuestLifecycleRequest {
3649    #[allow(irrefutable_let_patterns)]
3650    pub fn into_create(self) -> Option<(GuestConfig, GuestLifecycleCreateResponder)> {
3651        if let GuestLifecycleRequest::Create { guest_config, responder } = self {
3652            Some((guest_config, responder))
3653        } else {
3654            None
3655        }
3656    }
3657
3658    #[allow(irrefutable_let_patterns)]
3659    pub fn into_bind(
3660        self,
3661    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestLifecycleControlHandle)> {
3662        if let GuestLifecycleRequest::Bind { guest, control_handle } = self {
3663            Some((guest, control_handle))
3664        } else {
3665            None
3666        }
3667    }
3668
3669    #[allow(irrefutable_let_patterns)]
3670    pub fn into_run(self) -> Option<(GuestLifecycleRunResponder)> {
3671        if let GuestLifecycleRequest::Run { responder } = self { Some((responder)) } else { None }
3672    }
3673
3674    #[allow(irrefutable_let_patterns)]
3675    pub fn into_stop(self) -> Option<(GuestLifecycleStopResponder)> {
3676        if let GuestLifecycleRequest::Stop { responder } = self { Some((responder)) } else { None }
3677    }
3678
3679    /// Name of the method defined in FIDL
3680    pub fn method_name(&self) -> &'static str {
3681        match *self {
3682            GuestLifecycleRequest::Create { .. } => "create",
3683            GuestLifecycleRequest::Bind { .. } => "bind",
3684            GuestLifecycleRequest::Run { .. } => "run",
3685            GuestLifecycleRequest::Stop { .. } => "stop",
3686        }
3687    }
3688}
3689
3690#[derive(Debug, Clone)]
3691pub struct GuestLifecycleControlHandle {
3692    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3693}
3694
3695impl GuestLifecycleControlHandle {
3696    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3697        self.inner.shutdown_with_epitaph(status.into())
3698    }
3699}
3700
3701impl fidl::endpoints::ControlHandle for GuestLifecycleControlHandle {
3702    fn shutdown(&self) {
3703        self.inner.shutdown()
3704    }
3705
3706    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3707        self.inner.shutdown_with_epitaph(status)
3708    }
3709
3710    fn is_closed(&self) -> bool {
3711        self.inner.channel().is_closed()
3712    }
3713    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3714        self.inner.channel().on_closed()
3715    }
3716
3717    #[cfg(target_os = "fuchsia")]
3718    fn signal_peer(
3719        &self,
3720        clear_mask: zx::Signals,
3721        set_mask: zx::Signals,
3722    ) -> Result<(), zx_status::Status> {
3723        use fidl::Peered;
3724        self.inner.channel().signal_peer(clear_mask, set_mask)
3725    }
3726}
3727
3728impl GuestLifecycleControlHandle {}
3729
3730#[must_use = "FIDL methods require a response to be sent"]
3731#[derive(Debug)]
3732pub struct GuestLifecycleCreateResponder {
3733    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3734    tx_id: u32,
3735}
3736
3737/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3738/// if the responder is dropped without sending a response, so that the client
3739/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3740impl std::ops::Drop for GuestLifecycleCreateResponder {
3741    fn drop(&mut self) {
3742        self.control_handle.shutdown();
3743        // Safety: drops once, never accessed again
3744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3745    }
3746}
3747
3748impl fidl::endpoints::Responder for GuestLifecycleCreateResponder {
3749    type ControlHandle = GuestLifecycleControlHandle;
3750
3751    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3752        &self.control_handle
3753    }
3754
3755    fn drop_without_shutdown(mut self) {
3756        // Safety: drops once, never accessed again due to mem::forget
3757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3758        // Prevent Drop from running (which would shut down the channel)
3759        std::mem::forget(self);
3760    }
3761}
3762
3763impl GuestLifecycleCreateResponder {
3764    /// Sends a response to the FIDL transaction.
3765    ///
3766    /// Sets the channel to shutdown if an error occurs.
3767    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3768        let _result = self.send_raw(result);
3769        if _result.is_err() {
3770            self.control_handle.shutdown();
3771        }
3772        self.drop_without_shutdown();
3773        _result
3774    }
3775
3776    /// Similar to "send" but does not shutdown the channel if an error occurs.
3777    pub fn send_no_shutdown_on_err(
3778        self,
3779        mut result: Result<(), GuestError>,
3780    ) -> Result<(), fidl::Error> {
3781        let _result = self.send_raw(result);
3782        self.drop_without_shutdown();
3783        _result
3784    }
3785
3786    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3787        self.control_handle
3788            .inner
3789            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3790                result,
3791                self.tx_id,
3792                0x152719eed416ed41,
3793                fidl::encoding::DynamicFlags::empty(),
3794            )
3795    }
3796}
3797
3798#[must_use = "FIDL methods require a response to be sent"]
3799#[derive(Debug)]
3800pub struct GuestLifecycleRunResponder {
3801    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3802    tx_id: u32,
3803}
3804
3805/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3806/// if the responder is dropped without sending a response, so that the client
3807/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3808impl std::ops::Drop for GuestLifecycleRunResponder {
3809    fn drop(&mut self) {
3810        self.control_handle.shutdown();
3811        // Safety: drops once, never accessed again
3812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3813    }
3814}
3815
3816impl fidl::endpoints::Responder for GuestLifecycleRunResponder {
3817    type ControlHandle = GuestLifecycleControlHandle;
3818
3819    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3820        &self.control_handle
3821    }
3822
3823    fn drop_without_shutdown(mut self) {
3824        // Safety: drops once, never accessed again due to mem::forget
3825        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3826        // Prevent Drop from running (which would shut down the channel)
3827        std::mem::forget(self);
3828    }
3829}
3830
3831impl GuestLifecycleRunResponder {
3832    /// Sends a response to the FIDL transaction.
3833    ///
3834    /// Sets the channel to shutdown if an error occurs.
3835    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3836        let _result = self.send_raw(result);
3837        if _result.is_err() {
3838            self.control_handle.shutdown();
3839        }
3840        self.drop_without_shutdown();
3841        _result
3842    }
3843
3844    /// Similar to "send" but does not shutdown the channel if an error occurs.
3845    pub fn send_no_shutdown_on_err(
3846        self,
3847        mut result: Result<(), GuestError>,
3848    ) -> Result<(), fidl::Error> {
3849        let _result = self.send_raw(result);
3850        self.drop_without_shutdown();
3851        _result
3852    }
3853
3854    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3855        self.control_handle
3856            .inner
3857            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3858                result,
3859                self.tx_id,
3860                0x2907fef2ac775657,
3861                fidl::encoding::DynamicFlags::empty(),
3862            )
3863    }
3864}
3865
3866#[must_use = "FIDL methods require a response to be sent"]
3867#[derive(Debug)]
3868pub struct GuestLifecycleStopResponder {
3869    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3870    tx_id: u32,
3871}
3872
3873/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3874/// if the responder is dropped without sending a response, so that the client
3875/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3876impl std::ops::Drop for GuestLifecycleStopResponder {
3877    fn drop(&mut self) {
3878        self.control_handle.shutdown();
3879        // Safety: drops once, never accessed again
3880        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3881    }
3882}
3883
3884impl fidl::endpoints::Responder for GuestLifecycleStopResponder {
3885    type ControlHandle = GuestLifecycleControlHandle;
3886
3887    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3888        &self.control_handle
3889    }
3890
3891    fn drop_without_shutdown(mut self) {
3892        // Safety: drops once, never accessed again due to mem::forget
3893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3894        // Prevent Drop from running (which would shut down the channel)
3895        std::mem::forget(self);
3896    }
3897}
3898
3899impl GuestLifecycleStopResponder {
3900    /// Sends a response to the FIDL transaction.
3901    ///
3902    /// Sets the channel to shutdown if an error occurs.
3903    pub fn send(self) -> Result<(), fidl::Error> {
3904        let _result = self.send_raw();
3905        if _result.is_err() {
3906            self.control_handle.shutdown();
3907        }
3908        self.drop_without_shutdown();
3909        _result
3910    }
3911
3912    /// Similar to "send" but does not shutdown the channel if an error occurs.
3913    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3914        let _result = self.send_raw();
3915        self.drop_without_shutdown();
3916        _result
3917    }
3918
3919    fn send_raw(&self) -> Result<(), fidl::Error> {
3920        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3921            (),
3922            self.tx_id,
3923            0x27eef9c535ac8eb4,
3924            fidl::encoding::DynamicFlags::empty(),
3925        )
3926    }
3927}
3928
3929#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3930pub struct GuestManagerMarker;
3931
3932impl fidl::endpoints::ProtocolMarker for GuestManagerMarker {
3933    type Proxy = GuestManagerProxy;
3934    type RequestStream = GuestManagerRequestStream;
3935    #[cfg(target_os = "fuchsia")]
3936    type SynchronousProxy = GuestManagerSynchronousProxy;
3937
3938    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestManager";
3939}
3940impl fidl::endpoints::DiscoverableProtocolMarker for GuestManagerMarker {}
3941pub type GuestManagerLaunchResult = Result<(), GuestManagerError>;
3942pub type GuestManagerConnectResult = Result<(), GuestManagerError>;
3943
3944pub trait GuestManagerProxyInterface: Send + Sync {
3945    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
3946        + Send;
3947    fn r#launch(
3948        &self,
3949        guest_config: GuestConfig,
3950        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3951    ) -> Self::LaunchResponseFut;
3952    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3953    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
3954    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
3955        + Send;
3956    fn r#connect(
3957        &self,
3958        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3959    ) -> Self::ConnectResponseFut;
3960    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
3961    fn r#get_info(&self) -> Self::GetInfoResponseFut;
3962}
3963#[derive(Debug)]
3964#[cfg(target_os = "fuchsia")]
3965pub struct GuestManagerSynchronousProxy {
3966    client: fidl::client::sync::Client,
3967}
3968
3969#[cfg(target_os = "fuchsia")]
3970impl fidl::endpoints::SynchronousProxy for GuestManagerSynchronousProxy {
3971    type Proxy = GuestManagerProxy;
3972    type Protocol = GuestManagerMarker;
3973
3974    fn from_channel(inner: fidl::Channel) -> Self {
3975        Self::new(inner)
3976    }
3977
3978    fn into_channel(self) -> fidl::Channel {
3979        self.client.into_channel()
3980    }
3981
3982    fn as_channel(&self) -> &fidl::Channel {
3983        self.client.as_channel()
3984    }
3985}
3986
3987#[cfg(target_os = "fuchsia")]
3988impl GuestManagerSynchronousProxy {
3989    pub fn new(channel: fidl::Channel) -> Self {
3990        Self { client: fidl::client::sync::Client::new(channel) }
3991    }
3992
3993    pub fn into_channel(self) -> fidl::Channel {
3994        self.client.into_channel()
3995    }
3996
3997    /// Waits until an event arrives and returns it. It is safe for other
3998    /// threads to make concurrent requests while waiting for an event.
3999    pub fn wait_for_event(
4000        &self,
4001        deadline: zx::MonotonicInstant,
4002    ) -> Result<GuestManagerEvent, fidl::Error> {
4003        GuestManagerEvent::decode(self.client.wait_for_event::<GuestManagerMarker>(deadline)?)
4004    }
4005
4006    /// Launch a new guest instance.
4007    ///
4008    /// Possible errors:
4009    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4010    ///         problems detected by the guest manager.
4011    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4012    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4013    ///         component logs for a more specific failure.
4014    pub fn r#launch(
4015        &self,
4016        mut guest_config: GuestConfig,
4017        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4018        ___deadline: zx::MonotonicInstant,
4019    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
4020        let _response =
4021            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
4022                fidl::encoding::EmptyStruct,
4023                GuestManagerError,
4024            >, GuestManagerMarker>(
4025                (&mut guest_config, controller),
4026                0x394a2e29f750323e,
4027                fidl::encoding::DynamicFlags::empty(),
4028                ___deadline,
4029            )?;
4030        Ok(_response.map(|x| x))
4031    }
4032
4033    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4034    /// be used to launch another guest.
4035    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
4036        let _response = self.client.send_query::<
4037            fidl::encoding::EmptyPayload,
4038            fidl::encoding::EmptyPayload,
4039            GuestManagerMarker,
4040        >(
4041            (),
4042            0x3ad9a012982f872d,
4043            fidl::encoding::DynamicFlags::empty(),
4044            ___deadline,
4045        )?;
4046        Ok(_response)
4047    }
4048
4049    /// Connect to a currently running guest.
4050    ///
4051    /// Possible errors:
4052    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4053    ///         has launched before attempting to reconnect.
4054    pub fn r#connect(
4055        &self,
4056        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4057        ___deadline: zx::MonotonicInstant,
4058    ) -> Result<GuestManagerConnectResult, fidl::Error> {
4059        let _response =
4060            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
4061                fidl::encoding::EmptyStruct,
4062                GuestManagerError,
4063            >, GuestManagerMarker>(
4064                (controller,),
4065                0x4e489076e3bb15b4,
4066                fidl::encoding::DynamicFlags::empty(),
4067                ___deadline,
4068            )?;
4069        Ok(_response.map(|x| x))
4070    }
4071
4072    /// Query guest info
4073    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
4074        let _response = self.client.send_query::<
4075            fidl::encoding::EmptyPayload,
4076            GuestManagerGetInfoResponse,
4077            GuestManagerMarker,
4078        >(
4079            (),
4080            0x76892614aea695dc,
4081            fidl::encoding::DynamicFlags::empty(),
4082            ___deadline,
4083        )?;
4084        Ok(_response.guest_info)
4085    }
4086}
4087
4088#[cfg(target_os = "fuchsia")]
4089impl From<GuestManagerSynchronousProxy> for zx::NullableHandle {
4090    fn from(value: GuestManagerSynchronousProxy) -> Self {
4091        value.into_channel().into()
4092    }
4093}
4094
4095#[cfg(target_os = "fuchsia")]
4096impl From<fidl::Channel> for GuestManagerSynchronousProxy {
4097    fn from(value: fidl::Channel) -> Self {
4098        Self::new(value)
4099    }
4100}
4101
4102#[cfg(target_os = "fuchsia")]
4103impl fidl::endpoints::FromClient for GuestManagerSynchronousProxy {
4104    type Protocol = GuestManagerMarker;
4105
4106    fn from_client(value: fidl::endpoints::ClientEnd<GuestManagerMarker>) -> Self {
4107        Self::new(value.into_channel())
4108    }
4109}
4110
4111#[derive(Debug, Clone)]
4112pub struct GuestManagerProxy {
4113    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4114}
4115
4116impl fidl::endpoints::Proxy for GuestManagerProxy {
4117    type Protocol = GuestManagerMarker;
4118
4119    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4120        Self::new(inner)
4121    }
4122
4123    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4124        self.client.into_channel().map_err(|client| Self { client })
4125    }
4126
4127    fn as_channel(&self) -> &::fidl::AsyncChannel {
4128        self.client.as_channel()
4129    }
4130}
4131
4132impl GuestManagerProxy {
4133    /// Create a new Proxy for fuchsia.virtualization/GuestManager.
4134    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4135        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4136        Self { client: fidl::client::Client::new(channel, protocol_name) }
4137    }
4138
4139    /// Get a Stream of events from the remote end of the protocol.
4140    ///
4141    /// # Panics
4142    ///
4143    /// Panics if the event stream was already taken.
4144    pub fn take_event_stream(&self) -> GuestManagerEventStream {
4145        GuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
4146    }
4147
4148    /// Launch a new guest instance.
4149    ///
4150    /// Possible errors:
4151    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4152    ///         problems detected by the guest manager.
4153    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4154    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4155    ///         component logs for a more specific failure.
4156    pub fn r#launch(
4157        &self,
4158        mut guest_config: GuestConfig,
4159        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4160    ) -> fidl::client::QueryResponseFut<
4161        GuestManagerLaunchResult,
4162        fidl::encoding::DefaultFuchsiaResourceDialect,
4163    > {
4164        GuestManagerProxyInterface::r#launch(self, guest_config, controller)
4165    }
4166
4167    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4168    /// be used to launch another guest.
4169    pub fn r#force_shutdown(
4170        &self,
4171    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4172        GuestManagerProxyInterface::r#force_shutdown(self)
4173    }
4174
4175    /// Connect to a currently running guest.
4176    ///
4177    /// Possible errors:
4178    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4179    ///         has launched before attempting to reconnect.
4180    pub fn r#connect(
4181        &self,
4182        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4183    ) -> fidl::client::QueryResponseFut<
4184        GuestManagerConnectResult,
4185        fidl::encoding::DefaultFuchsiaResourceDialect,
4186    > {
4187        GuestManagerProxyInterface::r#connect(self, controller)
4188    }
4189
4190    /// Query guest info
4191    pub fn r#get_info(
4192        &self,
4193    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
4194    {
4195        GuestManagerProxyInterface::r#get_info(self)
4196    }
4197}
4198
4199impl GuestManagerProxyInterface for GuestManagerProxy {
4200    type LaunchResponseFut = fidl::client::QueryResponseFut<
4201        GuestManagerLaunchResult,
4202        fidl::encoding::DefaultFuchsiaResourceDialect,
4203    >;
4204    fn r#launch(
4205        &self,
4206        mut guest_config: GuestConfig,
4207        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4208    ) -> Self::LaunchResponseFut {
4209        fn _decode(
4210            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4211        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
4212            let _response = fidl::client::decode_transaction_body::<
4213                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4214                fidl::encoding::DefaultFuchsiaResourceDialect,
4215                0x394a2e29f750323e,
4216            >(_buf?)?;
4217            Ok(_response.map(|x| x))
4218        }
4219        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
4220            (&mut guest_config, controller),
4221            0x394a2e29f750323e,
4222            fidl::encoding::DynamicFlags::empty(),
4223            _decode,
4224        )
4225    }
4226
4227    type ForceShutdownResponseFut =
4228        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4229    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
4230        fn _decode(
4231            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4232        ) -> Result<(), fidl::Error> {
4233            let _response = fidl::client::decode_transaction_body::<
4234                fidl::encoding::EmptyPayload,
4235                fidl::encoding::DefaultFuchsiaResourceDialect,
4236                0x3ad9a012982f872d,
4237            >(_buf?)?;
4238            Ok(_response)
4239        }
4240        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
4241            (),
4242            0x3ad9a012982f872d,
4243            fidl::encoding::DynamicFlags::empty(),
4244            _decode,
4245        )
4246    }
4247
4248    type ConnectResponseFut = fidl::client::QueryResponseFut<
4249        GuestManagerConnectResult,
4250        fidl::encoding::DefaultFuchsiaResourceDialect,
4251    >;
4252    fn r#connect(
4253        &self,
4254        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4255    ) -> Self::ConnectResponseFut {
4256        fn _decode(
4257            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4258        ) -> Result<GuestManagerConnectResult, fidl::Error> {
4259            let _response = fidl::client::decode_transaction_body::<
4260                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4261                fidl::encoding::DefaultFuchsiaResourceDialect,
4262                0x4e489076e3bb15b4,
4263            >(_buf?)?;
4264            Ok(_response.map(|x| x))
4265        }
4266        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
4267            (controller,),
4268            0x4e489076e3bb15b4,
4269            fidl::encoding::DynamicFlags::empty(),
4270            _decode,
4271        )
4272    }
4273
4274    type GetInfoResponseFut =
4275        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
4276    fn r#get_info(&self) -> Self::GetInfoResponseFut {
4277        fn _decode(
4278            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4279        ) -> Result<GuestInfo, fidl::Error> {
4280            let _response = fidl::client::decode_transaction_body::<
4281                GuestManagerGetInfoResponse,
4282                fidl::encoding::DefaultFuchsiaResourceDialect,
4283                0x76892614aea695dc,
4284            >(_buf?)?;
4285            Ok(_response.guest_info)
4286        }
4287        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
4288            (),
4289            0x76892614aea695dc,
4290            fidl::encoding::DynamicFlags::empty(),
4291            _decode,
4292        )
4293    }
4294}
4295
4296pub struct GuestManagerEventStream {
4297    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4298}
4299
4300impl std::marker::Unpin for GuestManagerEventStream {}
4301
4302impl futures::stream::FusedStream for GuestManagerEventStream {
4303    fn is_terminated(&self) -> bool {
4304        self.event_receiver.is_terminated()
4305    }
4306}
4307
4308impl futures::Stream for GuestManagerEventStream {
4309    type Item = Result<GuestManagerEvent, fidl::Error>;
4310
4311    fn poll_next(
4312        mut self: std::pin::Pin<&mut Self>,
4313        cx: &mut std::task::Context<'_>,
4314    ) -> std::task::Poll<Option<Self::Item>> {
4315        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4316            &mut self.event_receiver,
4317            cx
4318        )?) {
4319            Some(buf) => std::task::Poll::Ready(Some(GuestManagerEvent::decode(buf))),
4320            None => std::task::Poll::Ready(None),
4321        }
4322    }
4323}
4324
4325#[derive(Debug)]
4326pub enum GuestManagerEvent {}
4327
4328impl GuestManagerEvent {
4329    /// Decodes a message buffer as a [`GuestManagerEvent`].
4330    fn decode(
4331        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4332    ) -> Result<GuestManagerEvent, fidl::Error> {
4333        let (bytes, _handles) = buf.split_mut();
4334        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4335        debug_assert_eq!(tx_header.tx_id, 0);
4336        match tx_header.ordinal {
4337            _ => Err(fidl::Error::UnknownOrdinal {
4338                ordinal: tx_header.ordinal,
4339                protocol_name: <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4340            }),
4341        }
4342    }
4343}
4344
4345/// A Stream of incoming requests for fuchsia.virtualization/GuestManager.
4346pub struct GuestManagerRequestStream {
4347    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4348    is_terminated: bool,
4349}
4350
4351impl std::marker::Unpin for GuestManagerRequestStream {}
4352
4353impl futures::stream::FusedStream for GuestManagerRequestStream {
4354    fn is_terminated(&self) -> bool {
4355        self.is_terminated
4356    }
4357}
4358
4359impl fidl::endpoints::RequestStream for GuestManagerRequestStream {
4360    type Protocol = GuestManagerMarker;
4361    type ControlHandle = GuestManagerControlHandle;
4362
4363    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4364        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4365    }
4366
4367    fn control_handle(&self) -> Self::ControlHandle {
4368        GuestManagerControlHandle { inner: self.inner.clone() }
4369    }
4370
4371    fn into_inner(
4372        self,
4373    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4374    {
4375        (self.inner, self.is_terminated)
4376    }
4377
4378    fn from_inner(
4379        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4380        is_terminated: bool,
4381    ) -> Self {
4382        Self { inner, is_terminated }
4383    }
4384}
4385
4386impl futures::Stream for GuestManagerRequestStream {
4387    type Item = Result<GuestManagerRequest, fidl::Error>;
4388
4389    fn poll_next(
4390        mut self: std::pin::Pin<&mut Self>,
4391        cx: &mut std::task::Context<'_>,
4392    ) -> std::task::Poll<Option<Self::Item>> {
4393        let this = &mut *self;
4394        if this.inner.check_shutdown(cx) {
4395            this.is_terminated = true;
4396            return std::task::Poll::Ready(None);
4397        }
4398        if this.is_terminated {
4399            panic!("polled GuestManagerRequestStream after completion");
4400        }
4401        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4402            |bytes, handles| {
4403                match this.inner.channel().read_etc(cx, bytes, handles) {
4404                    std::task::Poll::Ready(Ok(())) => {}
4405                    std::task::Poll::Pending => return std::task::Poll::Pending,
4406                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4407                        this.is_terminated = true;
4408                        return std::task::Poll::Ready(None);
4409                    }
4410                    std::task::Poll::Ready(Err(e)) => {
4411                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4412                            e.into(),
4413                        ))));
4414                    }
4415                }
4416
4417                // A message has been received from the channel
4418                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4419
4420                std::task::Poll::Ready(Some(match header.ordinal {
4421                    0x394a2e29f750323e => {
4422                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4423                        let mut req = fidl::new_empty!(
4424                            GuestManagerLaunchRequest,
4425                            fidl::encoding::DefaultFuchsiaResourceDialect
4426                        );
4427                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
4428                        let control_handle =
4429                            GuestManagerControlHandle { inner: this.inner.clone() };
4430                        Ok(GuestManagerRequest::Launch {
4431                            guest_config: req.guest_config,
4432                            controller: req.controller,
4433
4434                            responder: GuestManagerLaunchResponder {
4435                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4436                                tx_id: header.tx_id,
4437                            },
4438                        })
4439                    }
4440                    0x3ad9a012982f872d => {
4441                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4442                        let mut req = fidl::new_empty!(
4443                            fidl::encoding::EmptyPayload,
4444                            fidl::encoding::DefaultFuchsiaResourceDialect
4445                        );
4446                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4447                        let control_handle =
4448                            GuestManagerControlHandle { inner: this.inner.clone() };
4449                        Ok(GuestManagerRequest::ForceShutdown {
4450                            responder: GuestManagerForceShutdownResponder {
4451                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4452                                tx_id: header.tx_id,
4453                            },
4454                        })
4455                    }
4456                    0x4e489076e3bb15b4 => {
4457                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4458                        let mut req = fidl::new_empty!(
4459                            GuestManagerConnectRequest,
4460                            fidl::encoding::DefaultFuchsiaResourceDialect
4461                        );
4462                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
4463                        let control_handle =
4464                            GuestManagerControlHandle { inner: this.inner.clone() };
4465                        Ok(GuestManagerRequest::Connect {
4466                            controller: req.controller,
4467
4468                            responder: GuestManagerConnectResponder {
4469                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4470                                tx_id: header.tx_id,
4471                            },
4472                        })
4473                    }
4474                    0x76892614aea695dc => {
4475                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4476                        let mut req = fidl::new_empty!(
4477                            fidl::encoding::EmptyPayload,
4478                            fidl::encoding::DefaultFuchsiaResourceDialect
4479                        );
4480                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4481                        let control_handle =
4482                            GuestManagerControlHandle { inner: this.inner.clone() };
4483                        Ok(GuestManagerRequest::GetInfo {
4484                            responder: GuestManagerGetInfoResponder {
4485                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4486                                tx_id: header.tx_id,
4487                            },
4488                        })
4489                    }
4490                    _ => Err(fidl::Error::UnknownOrdinal {
4491                        ordinal: header.ordinal,
4492                        protocol_name:
4493                            <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4494                    }),
4495                }))
4496            },
4497        )
4498    }
4499}
4500
4501#[derive(Debug)]
4502pub enum GuestManagerRequest {
4503    /// Launch a new guest instance.
4504    ///
4505    /// Possible errors:
4506    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4507    ///         problems detected by the guest manager.
4508    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4509    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4510    ///         component logs for a more specific failure.
4511    Launch {
4512        guest_config: GuestConfig,
4513        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4514        responder: GuestManagerLaunchResponder,
4515    },
4516    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4517    /// be used to launch another guest.
4518    ForceShutdown { responder: GuestManagerForceShutdownResponder },
4519    /// Connect to a currently running guest.
4520    ///
4521    /// Possible errors:
4522    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4523    ///         has launched before attempting to reconnect.
4524    Connect {
4525        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4526        responder: GuestManagerConnectResponder,
4527    },
4528    /// Query guest info
4529    GetInfo { responder: GuestManagerGetInfoResponder },
4530}
4531
4532impl GuestManagerRequest {
4533    #[allow(irrefutable_let_patterns)]
4534    pub fn into_launch(
4535        self,
4536    ) -> Option<(GuestConfig, fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerLaunchResponder)>
4537    {
4538        if let GuestManagerRequest::Launch { guest_config, controller, responder } = self {
4539            Some((guest_config, controller, responder))
4540        } else {
4541            None
4542        }
4543    }
4544
4545    #[allow(irrefutable_let_patterns)]
4546    pub fn into_force_shutdown(self) -> Option<(GuestManagerForceShutdownResponder)> {
4547        if let GuestManagerRequest::ForceShutdown { responder } = self {
4548            Some((responder))
4549        } else {
4550            None
4551        }
4552    }
4553
4554    #[allow(irrefutable_let_patterns)]
4555    pub fn into_connect(
4556        self,
4557    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerConnectResponder)> {
4558        if let GuestManagerRequest::Connect { controller, responder } = self {
4559            Some((controller, responder))
4560        } else {
4561            None
4562        }
4563    }
4564
4565    #[allow(irrefutable_let_patterns)]
4566    pub fn into_get_info(self) -> Option<(GuestManagerGetInfoResponder)> {
4567        if let GuestManagerRequest::GetInfo { responder } = self { Some((responder)) } else { None }
4568    }
4569
4570    /// Name of the method defined in FIDL
4571    pub fn method_name(&self) -> &'static str {
4572        match *self {
4573            GuestManagerRequest::Launch { .. } => "launch",
4574            GuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
4575            GuestManagerRequest::Connect { .. } => "connect",
4576            GuestManagerRequest::GetInfo { .. } => "get_info",
4577        }
4578    }
4579}
4580
4581#[derive(Debug, Clone)]
4582pub struct GuestManagerControlHandle {
4583    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4584}
4585
4586impl GuestManagerControlHandle {
4587    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4588        self.inner.shutdown_with_epitaph(status.into())
4589    }
4590}
4591
4592impl fidl::endpoints::ControlHandle for GuestManagerControlHandle {
4593    fn shutdown(&self) {
4594        self.inner.shutdown()
4595    }
4596
4597    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4598        self.inner.shutdown_with_epitaph(status)
4599    }
4600
4601    fn is_closed(&self) -> bool {
4602        self.inner.channel().is_closed()
4603    }
4604    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4605        self.inner.channel().on_closed()
4606    }
4607
4608    #[cfg(target_os = "fuchsia")]
4609    fn signal_peer(
4610        &self,
4611        clear_mask: zx::Signals,
4612        set_mask: zx::Signals,
4613    ) -> Result<(), zx_status::Status> {
4614        use fidl::Peered;
4615        self.inner.channel().signal_peer(clear_mask, set_mask)
4616    }
4617}
4618
4619impl GuestManagerControlHandle {}
4620
4621#[must_use = "FIDL methods require a response to be sent"]
4622#[derive(Debug)]
4623pub struct GuestManagerLaunchResponder {
4624    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4625    tx_id: u32,
4626}
4627
4628/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4629/// if the responder is dropped without sending a response, so that the client
4630/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4631impl std::ops::Drop for GuestManagerLaunchResponder {
4632    fn drop(&mut self) {
4633        self.control_handle.shutdown();
4634        // Safety: drops once, never accessed again
4635        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4636    }
4637}
4638
4639impl fidl::endpoints::Responder for GuestManagerLaunchResponder {
4640    type ControlHandle = GuestManagerControlHandle;
4641
4642    fn control_handle(&self) -> &GuestManagerControlHandle {
4643        &self.control_handle
4644    }
4645
4646    fn drop_without_shutdown(mut self) {
4647        // Safety: drops once, never accessed again due to mem::forget
4648        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4649        // Prevent Drop from running (which would shut down the channel)
4650        std::mem::forget(self);
4651    }
4652}
4653
4654impl GuestManagerLaunchResponder {
4655    /// Sends a response to the FIDL transaction.
4656    ///
4657    /// Sets the channel to shutdown if an error occurs.
4658    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4659        let _result = self.send_raw(result);
4660        if _result.is_err() {
4661            self.control_handle.shutdown();
4662        }
4663        self.drop_without_shutdown();
4664        _result
4665    }
4666
4667    /// Similar to "send" but does not shutdown the channel if an error occurs.
4668    pub fn send_no_shutdown_on_err(
4669        self,
4670        mut result: Result<(), GuestManagerError>,
4671    ) -> Result<(), fidl::Error> {
4672        let _result = self.send_raw(result);
4673        self.drop_without_shutdown();
4674        _result
4675    }
4676
4677    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4678        self.control_handle.inner.send::<fidl::encoding::ResultType<
4679            fidl::encoding::EmptyStruct,
4680            GuestManagerError,
4681        >>(
4682            result,
4683            self.tx_id,
4684            0x394a2e29f750323e,
4685            fidl::encoding::DynamicFlags::empty(),
4686        )
4687    }
4688}
4689
4690#[must_use = "FIDL methods require a response to be sent"]
4691#[derive(Debug)]
4692pub struct GuestManagerForceShutdownResponder {
4693    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4694    tx_id: u32,
4695}
4696
4697/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4698/// if the responder is dropped without sending a response, so that the client
4699/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4700impl std::ops::Drop for GuestManagerForceShutdownResponder {
4701    fn drop(&mut self) {
4702        self.control_handle.shutdown();
4703        // Safety: drops once, never accessed again
4704        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4705    }
4706}
4707
4708impl fidl::endpoints::Responder for GuestManagerForceShutdownResponder {
4709    type ControlHandle = GuestManagerControlHandle;
4710
4711    fn control_handle(&self) -> &GuestManagerControlHandle {
4712        &self.control_handle
4713    }
4714
4715    fn drop_without_shutdown(mut self) {
4716        // Safety: drops once, never accessed again due to mem::forget
4717        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4718        // Prevent Drop from running (which would shut down the channel)
4719        std::mem::forget(self);
4720    }
4721}
4722
4723impl GuestManagerForceShutdownResponder {
4724    /// Sends a response to the FIDL transaction.
4725    ///
4726    /// Sets the channel to shutdown if an error occurs.
4727    pub fn send(self) -> Result<(), fidl::Error> {
4728        let _result = self.send_raw();
4729        if _result.is_err() {
4730            self.control_handle.shutdown();
4731        }
4732        self.drop_without_shutdown();
4733        _result
4734    }
4735
4736    /// Similar to "send" but does not shutdown the channel if an error occurs.
4737    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4738        let _result = self.send_raw();
4739        self.drop_without_shutdown();
4740        _result
4741    }
4742
4743    fn send_raw(&self) -> Result<(), fidl::Error> {
4744        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4745            (),
4746            self.tx_id,
4747            0x3ad9a012982f872d,
4748            fidl::encoding::DynamicFlags::empty(),
4749        )
4750    }
4751}
4752
4753#[must_use = "FIDL methods require a response to be sent"]
4754#[derive(Debug)]
4755pub struct GuestManagerConnectResponder {
4756    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4757    tx_id: u32,
4758}
4759
4760/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4761/// if the responder is dropped without sending a response, so that the client
4762/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4763impl std::ops::Drop for GuestManagerConnectResponder {
4764    fn drop(&mut self) {
4765        self.control_handle.shutdown();
4766        // Safety: drops once, never accessed again
4767        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4768    }
4769}
4770
4771impl fidl::endpoints::Responder for GuestManagerConnectResponder {
4772    type ControlHandle = GuestManagerControlHandle;
4773
4774    fn control_handle(&self) -> &GuestManagerControlHandle {
4775        &self.control_handle
4776    }
4777
4778    fn drop_without_shutdown(mut self) {
4779        // Safety: drops once, never accessed again due to mem::forget
4780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4781        // Prevent Drop from running (which would shut down the channel)
4782        std::mem::forget(self);
4783    }
4784}
4785
4786impl GuestManagerConnectResponder {
4787    /// Sends a response to the FIDL transaction.
4788    ///
4789    /// Sets the channel to shutdown if an error occurs.
4790    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4791        let _result = self.send_raw(result);
4792        if _result.is_err() {
4793            self.control_handle.shutdown();
4794        }
4795        self.drop_without_shutdown();
4796        _result
4797    }
4798
4799    /// Similar to "send" but does not shutdown the channel if an error occurs.
4800    pub fn send_no_shutdown_on_err(
4801        self,
4802        mut result: Result<(), GuestManagerError>,
4803    ) -> Result<(), fidl::Error> {
4804        let _result = self.send_raw(result);
4805        self.drop_without_shutdown();
4806        _result
4807    }
4808
4809    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4810        self.control_handle.inner.send::<fidl::encoding::ResultType<
4811            fidl::encoding::EmptyStruct,
4812            GuestManagerError,
4813        >>(
4814            result,
4815            self.tx_id,
4816            0x4e489076e3bb15b4,
4817            fidl::encoding::DynamicFlags::empty(),
4818        )
4819    }
4820}
4821
4822#[must_use = "FIDL methods require a response to be sent"]
4823#[derive(Debug)]
4824pub struct GuestManagerGetInfoResponder {
4825    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4826    tx_id: u32,
4827}
4828
4829/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4830/// if the responder is dropped without sending a response, so that the client
4831/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4832impl std::ops::Drop for GuestManagerGetInfoResponder {
4833    fn drop(&mut self) {
4834        self.control_handle.shutdown();
4835        // Safety: drops once, never accessed again
4836        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4837    }
4838}
4839
4840impl fidl::endpoints::Responder for GuestManagerGetInfoResponder {
4841    type ControlHandle = GuestManagerControlHandle;
4842
4843    fn control_handle(&self) -> &GuestManagerControlHandle {
4844        &self.control_handle
4845    }
4846
4847    fn drop_without_shutdown(mut self) {
4848        // Safety: drops once, never accessed again due to mem::forget
4849        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4850        // Prevent Drop from running (which would shut down the channel)
4851        std::mem::forget(self);
4852    }
4853}
4854
4855impl GuestManagerGetInfoResponder {
4856    /// Sends a response to the FIDL transaction.
4857    ///
4858    /// Sets the channel to shutdown if an error occurs.
4859    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4860        let _result = self.send_raw(guest_info);
4861        if _result.is_err() {
4862            self.control_handle.shutdown();
4863        }
4864        self.drop_without_shutdown();
4865        _result
4866    }
4867
4868    /// Similar to "send" but does not shutdown the channel if an error occurs.
4869    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4870        let _result = self.send_raw(guest_info);
4871        self.drop_without_shutdown();
4872        _result
4873    }
4874
4875    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4876        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
4877            (guest_info,),
4878            self.tx_id,
4879            0x76892614aea695dc,
4880            fidl::encoding::DynamicFlags::empty(),
4881        )
4882    }
4883}
4884
4885#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4886pub struct HostVsockAcceptorMarker;
4887
4888impl fidl::endpoints::ProtocolMarker for HostVsockAcceptorMarker {
4889    type Proxy = HostVsockAcceptorProxy;
4890    type RequestStream = HostVsockAcceptorRequestStream;
4891    #[cfg(target_os = "fuchsia")]
4892    type SynchronousProxy = HostVsockAcceptorSynchronousProxy;
4893
4894    const DEBUG_NAME: &'static str = "(anonymous) HostVsockAcceptor";
4895}
4896pub type HostVsockAcceptorAcceptResult = Result<fidl::Socket, i32>;
4897
4898pub trait HostVsockAcceptorProxyInterface: Send + Sync {
4899    type AcceptResponseFut: std::future::Future<Output = Result<HostVsockAcceptorAcceptResult, fidl::Error>>
4900        + Send;
4901    fn r#accept(&self, src_cid: u32, src_port: u32, port: u32) -> Self::AcceptResponseFut;
4902}
4903#[derive(Debug)]
4904#[cfg(target_os = "fuchsia")]
4905pub struct HostVsockAcceptorSynchronousProxy {
4906    client: fidl::client::sync::Client,
4907}
4908
4909#[cfg(target_os = "fuchsia")]
4910impl fidl::endpoints::SynchronousProxy for HostVsockAcceptorSynchronousProxy {
4911    type Proxy = HostVsockAcceptorProxy;
4912    type Protocol = HostVsockAcceptorMarker;
4913
4914    fn from_channel(inner: fidl::Channel) -> Self {
4915        Self::new(inner)
4916    }
4917
4918    fn into_channel(self) -> fidl::Channel {
4919        self.client.into_channel()
4920    }
4921
4922    fn as_channel(&self) -> &fidl::Channel {
4923        self.client.as_channel()
4924    }
4925}
4926
4927#[cfg(target_os = "fuchsia")]
4928impl HostVsockAcceptorSynchronousProxy {
4929    pub fn new(channel: fidl::Channel) -> Self {
4930        Self { client: fidl::client::sync::Client::new(channel) }
4931    }
4932
4933    pub fn into_channel(self) -> fidl::Channel {
4934        self.client.into_channel()
4935    }
4936
4937    /// Waits until an event arrives and returns it. It is safe for other
4938    /// threads to make concurrent requests while waiting for an event.
4939    pub fn wait_for_event(
4940        &self,
4941        deadline: zx::MonotonicInstant,
4942    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
4943        HostVsockAcceptorEvent::decode(
4944            self.client.wait_for_event::<HostVsockAcceptorMarker>(deadline)?,
4945        )
4946    }
4947
4948    pub fn r#accept(
4949        &self,
4950        mut src_cid: u32,
4951        mut src_port: u32,
4952        mut port: u32,
4953        ___deadline: zx::MonotonicInstant,
4954    ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
4955        let _response = self.client.send_query::<
4956            HostVsockAcceptorAcceptRequest,
4957            fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
4958            HostVsockAcceptorMarker,
4959        >(
4960            (src_cid, src_port, port,),
4961            0x6996ed935beaa2d7,
4962            fidl::encoding::DynamicFlags::empty(),
4963            ___deadline,
4964        )?;
4965        Ok(_response.map(|x| x.socket))
4966    }
4967}
4968
4969#[cfg(target_os = "fuchsia")]
4970impl From<HostVsockAcceptorSynchronousProxy> for zx::NullableHandle {
4971    fn from(value: HostVsockAcceptorSynchronousProxy) -> Self {
4972        value.into_channel().into()
4973    }
4974}
4975
4976#[cfg(target_os = "fuchsia")]
4977impl From<fidl::Channel> for HostVsockAcceptorSynchronousProxy {
4978    fn from(value: fidl::Channel) -> Self {
4979        Self::new(value)
4980    }
4981}
4982
4983#[cfg(target_os = "fuchsia")]
4984impl fidl::endpoints::FromClient for HostVsockAcceptorSynchronousProxy {
4985    type Protocol = HostVsockAcceptorMarker;
4986
4987    fn from_client(value: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>) -> Self {
4988        Self::new(value.into_channel())
4989    }
4990}
4991
4992#[derive(Debug, Clone)]
4993pub struct HostVsockAcceptorProxy {
4994    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4995}
4996
4997impl fidl::endpoints::Proxy for HostVsockAcceptorProxy {
4998    type Protocol = HostVsockAcceptorMarker;
4999
5000    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5001        Self::new(inner)
5002    }
5003
5004    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5005        self.client.into_channel().map_err(|client| Self { client })
5006    }
5007
5008    fn as_channel(&self) -> &::fidl::AsyncChannel {
5009        self.client.as_channel()
5010    }
5011}
5012
5013impl HostVsockAcceptorProxy {
5014    /// Create a new Proxy for fuchsia.virtualization/HostVsockAcceptor.
5015    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5016        let protocol_name =
5017            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5018        Self { client: fidl::client::Client::new(channel, protocol_name) }
5019    }
5020
5021    /// Get a Stream of events from the remote end of the protocol.
5022    ///
5023    /// # Panics
5024    ///
5025    /// Panics if the event stream was already taken.
5026    pub fn take_event_stream(&self) -> HostVsockAcceptorEventStream {
5027        HostVsockAcceptorEventStream { event_receiver: self.client.take_event_receiver() }
5028    }
5029
5030    pub fn r#accept(
5031        &self,
5032        mut src_cid: u32,
5033        mut src_port: u32,
5034        mut port: u32,
5035    ) -> fidl::client::QueryResponseFut<
5036        HostVsockAcceptorAcceptResult,
5037        fidl::encoding::DefaultFuchsiaResourceDialect,
5038    > {
5039        HostVsockAcceptorProxyInterface::r#accept(self, src_cid, src_port, port)
5040    }
5041}
5042
5043impl HostVsockAcceptorProxyInterface for HostVsockAcceptorProxy {
5044    type AcceptResponseFut = fidl::client::QueryResponseFut<
5045        HostVsockAcceptorAcceptResult,
5046        fidl::encoding::DefaultFuchsiaResourceDialect,
5047    >;
5048    fn r#accept(
5049        &self,
5050        mut src_cid: u32,
5051        mut src_port: u32,
5052        mut port: u32,
5053    ) -> Self::AcceptResponseFut {
5054        fn _decode(
5055            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5056        ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
5057            let _response = fidl::client::decode_transaction_body::<
5058                fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
5059                fidl::encoding::DefaultFuchsiaResourceDialect,
5060                0x6996ed935beaa2d7,
5061            >(_buf?)?;
5062            Ok(_response.map(|x| x.socket))
5063        }
5064        self.client
5065            .send_query_and_decode::<HostVsockAcceptorAcceptRequest, HostVsockAcceptorAcceptResult>(
5066                (src_cid, src_port, port),
5067                0x6996ed935beaa2d7,
5068                fidl::encoding::DynamicFlags::empty(),
5069                _decode,
5070            )
5071    }
5072}
5073
5074pub struct HostVsockAcceptorEventStream {
5075    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5076}
5077
5078impl std::marker::Unpin for HostVsockAcceptorEventStream {}
5079
5080impl futures::stream::FusedStream for HostVsockAcceptorEventStream {
5081    fn is_terminated(&self) -> bool {
5082        self.event_receiver.is_terminated()
5083    }
5084}
5085
5086impl futures::Stream for HostVsockAcceptorEventStream {
5087    type Item = Result<HostVsockAcceptorEvent, fidl::Error>;
5088
5089    fn poll_next(
5090        mut self: std::pin::Pin<&mut Self>,
5091        cx: &mut std::task::Context<'_>,
5092    ) -> std::task::Poll<Option<Self::Item>> {
5093        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5094            &mut self.event_receiver,
5095            cx
5096        )?) {
5097            Some(buf) => std::task::Poll::Ready(Some(HostVsockAcceptorEvent::decode(buf))),
5098            None => std::task::Poll::Ready(None),
5099        }
5100    }
5101}
5102
5103#[derive(Debug)]
5104pub enum HostVsockAcceptorEvent {}
5105
5106impl HostVsockAcceptorEvent {
5107    /// Decodes a message buffer as a [`HostVsockAcceptorEvent`].
5108    fn decode(
5109        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5110    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
5111        let (bytes, _handles) = buf.split_mut();
5112        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5113        debug_assert_eq!(tx_header.tx_id, 0);
5114        match tx_header.ordinal {
5115            _ => Err(fidl::Error::UnknownOrdinal {
5116                ordinal: tx_header.ordinal,
5117                protocol_name:
5118                    <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5119            }),
5120        }
5121    }
5122}
5123
5124/// A Stream of incoming requests for fuchsia.virtualization/HostVsockAcceptor.
5125pub struct HostVsockAcceptorRequestStream {
5126    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5127    is_terminated: bool,
5128}
5129
5130impl std::marker::Unpin for HostVsockAcceptorRequestStream {}
5131
5132impl futures::stream::FusedStream for HostVsockAcceptorRequestStream {
5133    fn is_terminated(&self) -> bool {
5134        self.is_terminated
5135    }
5136}
5137
5138impl fidl::endpoints::RequestStream for HostVsockAcceptorRequestStream {
5139    type Protocol = HostVsockAcceptorMarker;
5140    type ControlHandle = HostVsockAcceptorControlHandle;
5141
5142    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5143        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5144    }
5145
5146    fn control_handle(&self) -> Self::ControlHandle {
5147        HostVsockAcceptorControlHandle { inner: self.inner.clone() }
5148    }
5149
5150    fn into_inner(
5151        self,
5152    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5153    {
5154        (self.inner, self.is_terminated)
5155    }
5156
5157    fn from_inner(
5158        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5159        is_terminated: bool,
5160    ) -> Self {
5161        Self { inner, is_terminated }
5162    }
5163}
5164
5165impl futures::Stream for HostVsockAcceptorRequestStream {
5166    type Item = Result<HostVsockAcceptorRequest, fidl::Error>;
5167
5168    fn poll_next(
5169        mut self: std::pin::Pin<&mut Self>,
5170        cx: &mut std::task::Context<'_>,
5171    ) -> std::task::Poll<Option<Self::Item>> {
5172        let this = &mut *self;
5173        if this.inner.check_shutdown(cx) {
5174            this.is_terminated = true;
5175            return std::task::Poll::Ready(None);
5176        }
5177        if this.is_terminated {
5178            panic!("polled HostVsockAcceptorRequestStream after completion");
5179        }
5180        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5181            |bytes, handles| {
5182                match this.inner.channel().read_etc(cx, bytes, handles) {
5183                    std::task::Poll::Ready(Ok(())) => {}
5184                    std::task::Poll::Pending => return std::task::Poll::Pending,
5185                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5186                        this.is_terminated = true;
5187                        return std::task::Poll::Ready(None);
5188                    }
5189                    std::task::Poll::Ready(Err(e)) => {
5190                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5191                            e.into(),
5192                        ))));
5193                    }
5194                }
5195
5196                // A message has been received from the channel
5197                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5198
5199                std::task::Poll::Ready(Some(match header.ordinal {
5200                    0x6996ed935beaa2d7 => {
5201                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5202                        let mut req = fidl::new_empty!(
5203                            HostVsockAcceptorAcceptRequest,
5204                            fidl::encoding::DefaultFuchsiaResourceDialect
5205                        );
5206                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockAcceptorAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
5207                        let control_handle =
5208                            HostVsockAcceptorControlHandle { inner: this.inner.clone() };
5209                        Ok(HostVsockAcceptorRequest::Accept {
5210                            src_cid: req.src_cid,
5211                            src_port: req.src_port,
5212                            port: req.port,
5213
5214                            responder: HostVsockAcceptorAcceptResponder {
5215                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5216                                tx_id: header.tx_id,
5217                            },
5218                        })
5219                    }
5220                    _ => Err(fidl::Error::UnknownOrdinal {
5221                        ordinal: header.ordinal,
5222                        protocol_name:
5223                            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5224                    }),
5225                }))
5226            },
5227        )
5228    }
5229}
5230
5231/// Exposed by a host capable of listening via vsocks. A variant of a
5232/// `GuestVsockAcceptor` that is responsible for creating the `socket` with which
5233/// to communicate.
5234#[derive(Debug)]
5235pub enum HostVsockAcceptorRequest {
5236    Accept { src_cid: u32, src_port: u32, port: u32, responder: HostVsockAcceptorAcceptResponder },
5237}
5238
5239impl HostVsockAcceptorRequest {
5240    #[allow(irrefutable_let_patterns)]
5241    pub fn into_accept(self) -> Option<(u32, u32, u32, HostVsockAcceptorAcceptResponder)> {
5242        if let HostVsockAcceptorRequest::Accept { src_cid, src_port, port, responder } = self {
5243            Some((src_cid, src_port, port, responder))
5244        } else {
5245            None
5246        }
5247    }
5248
5249    /// Name of the method defined in FIDL
5250    pub fn method_name(&self) -> &'static str {
5251        match *self {
5252            HostVsockAcceptorRequest::Accept { .. } => "accept",
5253        }
5254    }
5255}
5256
5257#[derive(Debug, Clone)]
5258pub struct HostVsockAcceptorControlHandle {
5259    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5260}
5261
5262impl HostVsockAcceptorControlHandle {
5263    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5264        self.inner.shutdown_with_epitaph(status.into())
5265    }
5266}
5267
5268impl fidl::endpoints::ControlHandle for HostVsockAcceptorControlHandle {
5269    fn shutdown(&self) {
5270        self.inner.shutdown()
5271    }
5272
5273    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5274        self.inner.shutdown_with_epitaph(status)
5275    }
5276
5277    fn is_closed(&self) -> bool {
5278        self.inner.channel().is_closed()
5279    }
5280    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5281        self.inner.channel().on_closed()
5282    }
5283
5284    #[cfg(target_os = "fuchsia")]
5285    fn signal_peer(
5286        &self,
5287        clear_mask: zx::Signals,
5288        set_mask: zx::Signals,
5289    ) -> Result<(), zx_status::Status> {
5290        use fidl::Peered;
5291        self.inner.channel().signal_peer(clear_mask, set_mask)
5292    }
5293}
5294
5295impl HostVsockAcceptorControlHandle {}
5296
5297#[must_use = "FIDL methods require a response to be sent"]
5298#[derive(Debug)]
5299pub struct HostVsockAcceptorAcceptResponder {
5300    control_handle: std::mem::ManuallyDrop<HostVsockAcceptorControlHandle>,
5301    tx_id: u32,
5302}
5303
5304/// Set the the channel to be shutdown (see [`HostVsockAcceptorControlHandle::shutdown`])
5305/// if the responder is dropped without sending a response, so that the client
5306/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5307impl std::ops::Drop for HostVsockAcceptorAcceptResponder {
5308    fn drop(&mut self) {
5309        self.control_handle.shutdown();
5310        // Safety: drops once, never accessed again
5311        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5312    }
5313}
5314
5315impl fidl::endpoints::Responder for HostVsockAcceptorAcceptResponder {
5316    type ControlHandle = HostVsockAcceptorControlHandle;
5317
5318    fn control_handle(&self) -> &HostVsockAcceptorControlHandle {
5319        &self.control_handle
5320    }
5321
5322    fn drop_without_shutdown(mut self) {
5323        // Safety: drops once, never accessed again due to mem::forget
5324        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5325        // Prevent Drop from running (which would shut down the channel)
5326        std::mem::forget(self);
5327    }
5328}
5329
5330impl HostVsockAcceptorAcceptResponder {
5331    /// Sends a response to the FIDL transaction.
5332    ///
5333    /// Sets the channel to shutdown if an error occurs.
5334    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5335        let _result = self.send_raw(result);
5336        if _result.is_err() {
5337            self.control_handle.shutdown();
5338        }
5339        self.drop_without_shutdown();
5340        _result
5341    }
5342
5343    /// Similar to "send" but does not shutdown the channel if an error occurs.
5344    pub fn send_no_shutdown_on_err(
5345        self,
5346        mut result: Result<fidl::Socket, i32>,
5347    ) -> Result<(), fidl::Error> {
5348        let _result = self.send_raw(result);
5349        self.drop_without_shutdown();
5350        _result
5351    }
5352
5353    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5354        self.control_handle
5355            .inner
5356            .send::<fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>>(
5357                result.map(|socket| (socket,)),
5358                self.tx_id,
5359                0x6996ed935beaa2d7,
5360                fidl::encoding::DynamicFlags::empty(),
5361            )
5362    }
5363}
5364
5365#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5366pub struct HostVsockEndpointMarker;
5367
5368impl fidl::endpoints::ProtocolMarker for HostVsockEndpointMarker {
5369    type Proxy = HostVsockEndpointProxy;
5370    type RequestStream = HostVsockEndpointRequestStream;
5371    #[cfg(target_os = "fuchsia")]
5372    type SynchronousProxy = HostVsockEndpointSynchronousProxy;
5373
5374    const DEBUG_NAME: &'static str = "fuchsia.virtualization.HostVsockEndpoint";
5375}
5376impl fidl::endpoints::DiscoverableProtocolMarker for HostVsockEndpointMarker {}
5377pub type HostVsockEndpointListenResult = Result<(), i32>;
5378pub type HostVsockEndpointConnectResult = Result<fidl::Socket, i32>;
5379
5380pub trait HostVsockEndpointProxyInterface: Send + Sync {
5381    type ListenResponseFut: std::future::Future<Output = Result<HostVsockEndpointListenResult, fidl::Error>>
5382        + Send;
5383    fn r#listen(
5384        &self,
5385        port: u32,
5386        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5387    ) -> Self::ListenResponseFut;
5388    type ConnectResponseFut: std::future::Future<Output = Result<HostVsockEndpointConnectResult, fidl::Error>>
5389        + Send;
5390    fn r#connect(&self, guest_port: u32) -> Self::ConnectResponseFut;
5391}
5392#[derive(Debug)]
5393#[cfg(target_os = "fuchsia")]
5394pub struct HostVsockEndpointSynchronousProxy {
5395    client: fidl::client::sync::Client,
5396}
5397
5398#[cfg(target_os = "fuchsia")]
5399impl fidl::endpoints::SynchronousProxy for HostVsockEndpointSynchronousProxy {
5400    type Proxy = HostVsockEndpointProxy;
5401    type Protocol = HostVsockEndpointMarker;
5402
5403    fn from_channel(inner: fidl::Channel) -> Self {
5404        Self::new(inner)
5405    }
5406
5407    fn into_channel(self) -> fidl::Channel {
5408        self.client.into_channel()
5409    }
5410
5411    fn as_channel(&self) -> &fidl::Channel {
5412        self.client.as_channel()
5413    }
5414}
5415
5416#[cfg(target_os = "fuchsia")]
5417impl HostVsockEndpointSynchronousProxy {
5418    pub fn new(channel: fidl::Channel) -> Self {
5419        Self { client: fidl::client::sync::Client::new(channel) }
5420    }
5421
5422    pub fn into_channel(self) -> fidl::Channel {
5423        self.client.into_channel()
5424    }
5425
5426    /// Waits until an event arrives and returns it. It is safe for other
5427    /// threads to make concurrent requests while waiting for an event.
5428    pub fn wait_for_event(
5429        &self,
5430        deadline: zx::MonotonicInstant,
5431    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5432        HostVsockEndpointEvent::decode(
5433            self.client.wait_for_event::<HostVsockEndpointMarker>(deadline)?,
5434        )
5435    }
5436
5437    /// Instructs the device to listen for guest initiated connections to a given port by
5438    /// using `acceptor` when the guest creates a connection.
5439    ///
5440    /// Possible errors:
5441    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5442    pub fn r#listen(
5443        &self,
5444        mut port: u32,
5445        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5446        ___deadline: zx::MonotonicInstant,
5447    ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5448        let _response = self.client.send_query::<
5449            Listener,
5450            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5451            HostVsockEndpointMarker,
5452        >(
5453            (port, acceptor,),
5454            0xfd88f3b4767f2c7,
5455            fidl::encoding::DynamicFlags::empty(),
5456            ___deadline,
5457        )?;
5458        Ok(_response.map(|x| x))
5459    }
5460
5461    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5462    /// ephemeral host port.
5463    ///
5464    /// Possible errors:
5465    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5466    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5467    ///
5468    /// Other errors are related to socket creation, see
5469    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5470    pub fn r#connect(
5471        &self,
5472        mut guest_port: u32,
5473        ___deadline: zx::MonotonicInstant,
5474    ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5475        let _response = self.client.send_query::<
5476            HostVsockEndpointConnectRequest,
5477            fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5478            HostVsockEndpointMarker,
5479        >(
5480            (guest_port,),
5481            0x4d12e10e946b43e4,
5482            fidl::encoding::DynamicFlags::empty(),
5483            ___deadline,
5484        )?;
5485        Ok(_response.map(|x| x.socket))
5486    }
5487}
5488
5489#[cfg(target_os = "fuchsia")]
5490impl From<HostVsockEndpointSynchronousProxy> for zx::NullableHandle {
5491    fn from(value: HostVsockEndpointSynchronousProxy) -> Self {
5492        value.into_channel().into()
5493    }
5494}
5495
5496#[cfg(target_os = "fuchsia")]
5497impl From<fidl::Channel> for HostVsockEndpointSynchronousProxy {
5498    fn from(value: fidl::Channel) -> Self {
5499        Self::new(value)
5500    }
5501}
5502
5503#[cfg(target_os = "fuchsia")]
5504impl fidl::endpoints::FromClient for HostVsockEndpointSynchronousProxy {
5505    type Protocol = HostVsockEndpointMarker;
5506
5507    fn from_client(value: fidl::endpoints::ClientEnd<HostVsockEndpointMarker>) -> Self {
5508        Self::new(value.into_channel())
5509    }
5510}
5511
5512#[derive(Debug, Clone)]
5513pub struct HostVsockEndpointProxy {
5514    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5515}
5516
5517impl fidl::endpoints::Proxy for HostVsockEndpointProxy {
5518    type Protocol = HostVsockEndpointMarker;
5519
5520    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5521        Self::new(inner)
5522    }
5523
5524    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5525        self.client.into_channel().map_err(|client| Self { client })
5526    }
5527
5528    fn as_channel(&self) -> &::fidl::AsyncChannel {
5529        self.client.as_channel()
5530    }
5531}
5532
5533impl HostVsockEndpointProxy {
5534    /// Create a new Proxy for fuchsia.virtualization/HostVsockEndpoint.
5535    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5536        let protocol_name =
5537            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5538        Self { client: fidl::client::Client::new(channel, protocol_name) }
5539    }
5540
5541    /// Get a Stream of events from the remote end of the protocol.
5542    ///
5543    /// # Panics
5544    ///
5545    /// Panics if the event stream was already taken.
5546    pub fn take_event_stream(&self) -> HostVsockEndpointEventStream {
5547        HostVsockEndpointEventStream { event_receiver: self.client.take_event_receiver() }
5548    }
5549
5550    /// Instructs the device to listen for guest initiated connections to a given port by
5551    /// using `acceptor` when the guest creates a connection.
5552    ///
5553    /// Possible errors:
5554    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5555    pub fn r#listen(
5556        &self,
5557        mut port: u32,
5558        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5559    ) -> fidl::client::QueryResponseFut<
5560        HostVsockEndpointListenResult,
5561        fidl::encoding::DefaultFuchsiaResourceDialect,
5562    > {
5563        HostVsockEndpointProxyInterface::r#listen(self, port, acceptor)
5564    }
5565
5566    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5567    /// ephemeral host port.
5568    ///
5569    /// Possible errors:
5570    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5571    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5572    ///
5573    /// Other errors are related to socket creation, see
5574    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5575    pub fn r#connect(
5576        &self,
5577        mut guest_port: u32,
5578    ) -> fidl::client::QueryResponseFut<
5579        HostVsockEndpointConnectResult,
5580        fidl::encoding::DefaultFuchsiaResourceDialect,
5581    > {
5582        HostVsockEndpointProxyInterface::r#connect(self, guest_port)
5583    }
5584}
5585
5586impl HostVsockEndpointProxyInterface for HostVsockEndpointProxy {
5587    type ListenResponseFut = fidl::client::QueryResponseFut<
5588        HostVsockEndpointListenResult,
5589        fidl::encoding::DefaultFuchsiaResourceDialect,
5590    >;
5591    fn r#listen(
5592        &self,
5593        mut port: u32,
5594        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5595    ) -> Self::ListenResponseFut {
5596        fn _decode(
5597            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5598        ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5599            let _response = fidl::client::decode_transaction_body::<
5600                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5601                fidl::encoding::DefaultFuchsiaResourceDialect,
5602                0xfd88f3b4767f2c7,
5603            >(_buf?)?;
5604            Ok(_response.map(|x| x))
5605        }
5606        self.client.send_query_and_decode::<Listener, HostVsockEndpointListenResult>(
5607            (port, acceptor),
5608            0xfd88f3b4767f2c7,
5609            fidl::encoding::DynamicFlags::empty(),
5610            _decode,
5611        )
5612    }
5613
5614    type ConnectResponseFut = fidl::client::QueryResponseFut<
5615        HostVsockEndpointConnectResult,
5616        fidl::encoding::DefaultFuchsiaResourceDialect,
5617    >;
5618    fn r#connect(&self, mut guest_port: u32) -> Self::ConnectResponseFut {
5619        fn _decode(
5620            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5621        ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5622            let _response = fidl::client::decode_transaction_body::<
5623                fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5624                fidl::encoding::DefaultFuchsiaResourceDialect,
5625                0x4d12e10e946b43e4,
5626            >(_buf?)?;
5627            Ok(_response.map(|x| x.socket))
5628        }
5629        self.client.send_query_and_decode::<
5630            HostVsockEndpointConnectRequest,
5631            HostVsockEndpointConnectResult,
5632        >(
5633            (guest_port,),
5634            0x4d12e10e946b43e4,
5635            fidl::encoding::DynamicFlags::empty(),
5636            _decode,
5637        )
5638    }
5639}
5640
5641pub struct HostVsockEndpointEventStream {
5642    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5643}
5644
5645impl std::marker::Unpin for HostVsockEndpointEventStream {}
5646
5647impl futures::stream::FusedStream for HostVsockEndpointEventStream {
5648    fn is_terminated(&self) -> bool {
5649        self.event_receiver.is_terminated()
5650    }
5651}
5652
5653impl futures::Stream for HostVsockEndpointEventStream {
5654    type Item = Result<HostVsockEndpointEvent, fidl::Error>;
5655
5656    fn poll_next(
5657        mut self: std::pin::Pin<&mut Self>,
5658        cx: &mut std::task::Context<'_>,
5659    ) -> std::task::Poll<Option<Self::Item>> {
5660        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5661            &mut self.event_receiver,
5662            cx
5663        )?) {
5664            Some(buf) => std::task::Poll::Ready(Some(HostVsockEndpointEvent::decode(buf))),
5665            None => std::task::Poll::Ready(None),
5666        }
5667    }
5668}
5669
5670#[derive(Debug)]
5671pub enum HostVsockEndpointEvent {}
5672
5673impl HostVsockEndpointEvent {
5674    /// Decodes a message buffer as a [`HostVsockEndpointEvent`].
5675    fn decode(
5676        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5677    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5678        let (bytes, _handles) = buf.split_mut();
5679        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5680        debug_assert_eq!(tx_header.tx_id, 0);
5681        match tx_header.ordinal {
5682            _ => Err(fidl::Error::UnknownOrdinal {
5683                ordinal: tx_header.ordinal,
5684                protocol_name:
5685                    <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5686            }),
5687        }
5688    }
5689}
5690
5691/// A Stream of incoming requests for fuchsia.virtualization/HostVsockEndpoint.
5692pub struct HostVsockEndpointRequestStream {
5693    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5694    is_terminated: bool,
5695}
5696
5697impl std::marker::Unpin for HostVsockEndpointRequestStream {}
5698
5699impl futures::stream::FusedStream for HostVsockEndpointRequestStream {
5700    fn is_terminated(&self) -> bool {
5701        self.is_terminated
5702    }
5703}
5704
5705impl fidl::endpoints::RequestStream for HostVsockEndpointRequestStream {
5706    type Protocol = HostVsockEndpointMarker;
5707    type ControlHandle = HostVsockEndpointControlHandle;
5708
5709    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5710        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5711    }
5712
5713    fn control_handle(&self) -> Self::ControlHandle {
5714        HostVsockEndpointControlHandle { inner: self.inner.clone() }
5715    }
5716
5717    fn into_inner(
5718        self,
5719    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5720    {
5721        (self.inner, self.is_terminated)
5722    }
5723
5724    fn from_inner(
5725        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5726        is_terminated: bool,
5727    ) -> Self {
5728        Self { inner, is_terminated }
5729    }
5730}
5731
5732impl futures::Stream for HostVsockEndpointRequestStream {
5733    type Item = Result<HostVsockEndpointRequest, fidl::Error>;
5734
5735    fn poll_next(
5736        mut self: std::pin::Pin<&mut Self>,
5737        cx: &mut std::task::Context<'_>,
5738    ) -> std::task::Poll<Option<Self::Item>> {
5739        let this = &mut *self;
5740        if this.inner.check_shutdown(cx) {
5741            this.is_terminated = true;
5742            return std::task::Poll::Ready(None);
5743        }
5744        if this.is_terminated {
5745            panic!("polled HostVsockEndpointRequestStream after completion");
5746        }
5747        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5748            |bytes, handles| {
5749                match this.inner.channel().read_etc(cx, bytes, handles) {
5750                    std::task::Poll::Ready(Ok(())) => {}
5751                    std::task::Poll::Pending => return std::task::Poll::Pending,
5752                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5753                        this.is_terminated = true;
5754                        return std::task::Poll::Ready(None);
5755                    }
5756                    std::task::Poll::Ready(Err(e)) => {
5757                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5758                            e.into(),
5759                        ))));
5760                    }
5761                }
5762
5763                // A message has been received from the channel
5764                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5765
5766                std::task::Poll::Ready(Some(match header.ordinal {
5767                    0xfd88f3b4767f2c7 => {
5768                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5769                        let mut req = fidl::new_empty!(
5770                            Listener,
5771                            fidl::encoding::DefaultFuchsiaResourceDialect
5772                        );
5773                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Listener>(&header, _body_bytes, handles, &mut req)?;
5774                        let control_handle =
5775                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5776                        Ok(HostVsockEndpointRequest::Listen {
5777                            port: req.port,
5778                            acceptor: req.acceptor,
5779
5780                            responder: HostVsockEndpointListenResponder {
5781                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5782                                tx_id: header.tx_id,
5783                            },
5784                        })
5785                    }
5786                    0x4d12e10e946b43e4 => {
5787                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5788                        let mut req = fidl::new_empty!(
5789                            HostVsockEndpointConnectRequest,
5790                            fidl::encoding::DefaultFuchsiaResourceDialect
5791                        );
5792                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockEndpointConnectRequest>(&header, _body_bytes, handles, &mut req)?;
5793                        let control_handle =
5794                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5795                        Ok(HostVsockEndpointRequest::Connect {
5796                            guest_port: req.guest_port,
5797
5798                            responder: HostVsockEndpointConnectResponder {
5799                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5800                                tx_id: header.tx_id,
5801                            },
5802                        })
5803                    }
5804                    _ => Err(fidl::Error::UnknownOrdinal {
5805                        ordinal: header.ordinal,
5806                        protocol_name:
5807                            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5808                    }),
5809                }))
5810            },
5811        )
5812    }
5813}
5814
5815/// Exposed by a host to provide the ability for listeners to be multiplexed by
5816/// port and to manage dynamic port allocation for outbound connections.
5817#[derive(Debug)]
5818pub enum HostVsockEndpointRequest {
5819    /// Instructs the device to listen for guest initiated connections to a given port by
5820    /// using `acceptor` when the guest creates a connection.
5821    ///
5822    /// Possible errors:
5823    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5824    Listen {
5825        port: u32,
5826        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5827        responder: HostVsockEndpointListenResponder,
5828    },
5829    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5830    /// ephemeral host port.
5831    ///
5832    /// Possible errors:
5833    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5834    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5835    ///
5836    /// Other errors are related to socket creation, see
5837    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5838    Connect { guest_port: u32, responder: HostVsockEndpointConnectResponder },
5839}
5840
5841impl HostVsockEndpointRequest {
5842    #[allow(irrefutable_let_patterns)]
5843    pub fn into_listen(
5844        self,
5845    ) -> Option<(
5846        u32,
5847        fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5848        HostVsockEndpointListenResponder,
5849    )> {
5850        if let HostVsockEndpointRequest::Listen { port, acceptor, responder } = self {
5851            Some((port, acceptor, responder))
5852        } else {
5853            None
5854        }
5855    }
5856
5857    #[allow(irrefutable_let_patterns)]
5858    pub fn into_connect(self) -> Option<(u32, HostVsockEndpointConnectResponder)> {
5859        if let HostVsockEndpointRequest::Connect { guest_port, responder } = self {
5860            Some((guest_port, responder))
5861        } else {
5862            None
5863        }
5864    }
5865
5866    /// Name of the method defined in FIDL
5867    pub fn method_name(&self) -> &'static str {
5868        match *self {
5869            HostVsockEndpointRequest::Listen { .. } => "listen",
5870            HostVsockEndpointRequest::Connect { .. } => "connect",
5871        }
5872    }
5873}
5874
5875#[derive(Debug, Clone)]
5876pub struct HostVsockEndpointControlHandle {
5877    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5878}
5879
5880impl HostVsockEndpointControlHandle {
5881    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5882        self.inner.shutdown_with_epitaph(status.into())
5883    }
5884}
5885
5886impl fidl::endpoints::ControlHandle for HostVsockEndpointControlHandle {
5887    fn shutdown(&self) {
5888        self.inner.shutdown()
5889    }
5890
5891    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5892        self.inner.shutdown_with_epitaph(status)
5893    }
5894
5895    fn is_closed(&self) -> bool {
5896        self.inner.channel().is_closed()
5897    }
5898    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5899        self.inner.channel().on_closed()
5900    }
5901
5902    #[cfg(target_os = "fuchsia")]
5903    fn signal_peer(
5904        &self,
5905        clear_mask: zx::Signals,
5906        set_mask: zx::Signals,
5907    ) -> Result<(), zx_status::Status> {
5908        use fidl::Peered;
5909        self.inner.channel().signal_peer(clear_mask, set_mask)
5910    }
5911}
5912
5913impl HostVsockEndpointControlHandle {}
5914
5915#[must_use = "FIDL methods require a response to be sent"]
5916#[derive(Debug)]
5917pub struct HostVsockEndpointListenResponder {
5918    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5919    tx_id: u32,
5920}
5921
5922/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5923/// if the responder is dropped without sending a response, so that the client
5924/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5925impl std::ops::Drop for HostVsockEndpointListenResponder {
5926    fn drop(&mut self) {
5927        self.control_handle.shutdown();
5928        // Safety: drops once, never accessed again
5929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5930    }
5931}
5932
5933impl fidl::endpoints::Responder for HostVsockEndpointListenResponder {
5934    type ControlHandle = HostVsockEndpointControlHandle;
5935
5936    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5937        &self.control_handle
5938    }
5939
5940    fn drop_without_shutdown(mut self) {
5941        // Safety: drops once, never accessed again due to mem::forget
5942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5943        // Prevent Drop from running (which would shut down the channel)
5944        std::mem::forget(self);
5945    }
5946}
5947
5948impl HostVsockEndpointListenResponder {
5949    /// Sends a response to the FIDL transaction.
5950    ///
5951    /// Sets the channel to shutdown if an error occurs.
5952    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5953        let _result = self.send_raw(result);
5954        if _result.is_err() {
5955            self.control_handle.shutdown();
5956        }
5957        self.drop_without_shutdown();
5958        _result
5959    }
5960
5961    /// Similar to "send" but does not shutdown the channel if an error occurs.
5962    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5963        let _result = self.send_raw(result);
5964        self.drop_without_shutdown();
5965        _result
5966    }
5967
5968    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5969        self.control_handle
5970            .inner
5971            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5972                result,
5973                self.tx_id,
5974                0xfd88f3b4767f2c7,
5975                fidl::encoding::DynamicFlags::empty(),
5976            )
5977    }
5978}
5979
5980#[must_use = "FIDL methods require a response to be sent"]
5981#[derive(Debug)]
5982pub struct HostVsockEndpointConnectResponder {
5983    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5984    tx_id: u32,
5985}
5986
5987/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5988/// if the responder is dropped without sending a response, so that the client
5989/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5990impl std::ops::Drop for HostVsockEndpointConnectResponder {
5991    fn drop(&mut self) {
5992        self.control_handle.shutdown();
5993        // Safety: drops once, never accessed again
5994        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5995    }
5996}
5997
5998impl fidl::endpoints::Responder for HostVsockEndpointConnectResponder {
5999    type ControlHandle = HostVsockEndpointControlHandle;
6000
6001    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
6002        &self.control_handle
6003    }
6004
6005    fn drop_without_shutdown(mut self) {
6006        // Safety: drops once, never accessed again due to mem::forget
6007        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6008        // Prevent Drop from running (which would shut down the channel)
6009        std::mem::forget(self);
6010    }
6011}
6012
6013impl HostVsockEndpointConnectResponder {
6014    /// Sends a response to the FIDL transaction.
6015    ///
6016    /// Sets the channel to shutdown if an error occurs.
6017    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
6018        let _result = self.send_raw(result);
6019        if _result.is_err() {
6020            self.control_handle.shutdown();
6021        }
6022        self.drop_without_shutdown();
6023        _result
6024    }
6025
6026    /// Similar to "send" but does not shutdown the channel if an error occurs.
6027    pub fn send_no_shutdown_on_err(
6028        self,
6029        mut result: Result<fidl::Socket, i32>,
6030    ) -> Result<(), fidl::Error> {
6031        let _result = self.send_raw(result);
6032        self.drop_without_shutdown();
6033        _result
6034    }
6035
6036    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
6037        self.control_handle
6038            .inner
6039            .send::<fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>>(
6040                result.map(|socket| (socket,)),
6041                self.tx_id,
6042                0x4d12e10e946b43e4,
6043                fidl::encoding::DynamicFlags::empty(),
6044            )
6045    }
6046}
6047
6048#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6049pub struct LinuxManagerMarker;
6050
6051impl fidl::endpoints::ProtocolMarker for LinuxManagerMarker {
6052    type Proxy = LinuxManagerProxy;
6053    type RequestStream = LinuxManagerRequestStream;
6054    #[cfg(target_os = "fuchsia")]
6055    type SynchronousProxy = LinuxManagerSynchronousProxy;
6056
6057    const DEBUG_NAME: &'static str = "fuchsia.virtualization.LinuxManager";
6058}
6059impl fidl::endpoints::DiscoverableProtocolMarker for LinuxManagerMarker {}
6060pub type LinuxManagerStartAndGetLinuxGuestInfoResult = Result<LinuxGuestInfo, i32>;
6061pub type LinuxManagerWipeDataResult = Result<(), i32>;
6062
6063pub trait LinuxManagerProxyInterface: Send + Sync {
6064    type StartAndGetLinuxGuestInfoResponseFut: std::future::Future<
6065            Output = Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error>,
6066        > + Send;
6067    fn r#start_and_get_linux_guest_info(
6068        &self,
6069        label: &str,
6070    ) -> Self::StartAndGetLinuxGuestInfoResponseFut;
6071    type WipeDataResponseFut: std::future::Future<Output = Result<LinuxManagerWipeDataResult, fidl::Error>>
6072        + Send;
6073    fn r#wipe_data(&self) -> Self::WipeDataResponseFut;
6074    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error>;
6075}
6076#[derive(Debug)]
6077#[cfg(target_os = "fuchsia")]
6078pub struct LinuxManagerSynchronousProxy {
6079    client: fidl::client::sync::Client,
6080}
6081
6082#[cfg(target_os = "fuchsia")]
6083impl fidl::endpoints::SynchronousProxy for LinuxManagerSynchronousProxy {
6084    type Proxy = LinuxManagerProxy;
6085    type Protocol = LinuxManagerMarker;
6086
6087    fn from_channel(inner: fidl::Channel) -> Self {
6088        Self::new(inner)
6089    }
6090
6091    fn into_channel(self) -> fidl::Channel {
6092        self.client.into_channel()
6093    }
6094
6095    fn as_channel(&self) -> &fidl::Channel {
6096        self.client.as_channel()
6097    }
6098}
6099
6100#[cfg(target_os = "fuchsia")]
6101impl LinuxManagerSynchronousProxy {
6102    pub fn new(channel: fidl::Channel) -> Self {
6103        Self { client: fidl::client::sync::Client::new(channel) }
6104    }
6105
6106    pub fn into_channel(self) -> fidl::Channel {
6107        self.client.into_channel()
6108    }
6109
6110    /// Waits until an event arrives and returns it. It is safe for other
6111    /// threads to make concurrent requests while waiting for an event.
6112    pub fn wait_for_event(
6113        &self,
6114        deadline: zx::MonotonicInstant,
6115    ) -> Result<LinuxManagerEvent, fidl::Error> {
6116        LinuxManagerEvent::decode(self.client.wait_for_event::<LinuxManagerMarker>(deadline)?)
6117    }
6118
6119    /// Get Linux guest environment info.
6120    ///
6121    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6122    pub fn r#start_and_get_linux_guest_info(
6123        &self,
6124        mut label: &str,
6125        ___deadline: zx::MonotonicInstant,
6126    ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6127        let _response = self.client.send_query::<
6128            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6129            fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6130            LinuxManagerMarker,
6131        >(
6132            (label,),
6133            0x11809ced100a2bea,
6134            fidl::encoding::DynamicFlags::empty(),
6135            ___deadline,
6136        )?;
6137        Ok(_response.map(|x| x.info))
6138    }
6139
6140    /// Clears the stateful data. This includes any installed containers and any user data
6141    /// they may contain.
6142    ///
6143    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6144    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6145    /// operation.
6146    pub fn r#wipe_data(
6147        &self,
6148        ___deadline: zx::MonotonicInstant,
6149    ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6150        let _response = self.client.send_query::<
6151            fidl::encoding::EmptyPayload,
6152            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6153            LinuxManagerMarker,
6154        >(
6155            (),
6156            0x732c69394548a76a,
6157            fidl::encoding::DynamicFlags::empty(),
6158            ___deadline,
6159        )?;
6160        Ok(_response.map(|x| x))
6161    }
6162
6163    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6164    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6165    /// the epitaph) before attempting to launch another guest.
6166    ///
6167    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6168    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6169    /// a component crash).
6170    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6171        self.client.send::<fidl::encoding::EmptyPayload>(
6172            (),
6173            0x5dab12b50bc9909d,
6174            fidl::encoding::DynamicFlags::empty(),
6175        )
6176    }
6177}
6178
6179#[cfg(target_os = "fuchsia")]
6180impl From<LinuxManagerSynchronousProxy> for zx::NullableHandle {
6181    fn from(value: LinuxManagerSynchronousProxy) -> Self {
6182        value.into_channel().into()
6183    }
6184}
6185
6186#[cfg(target_os = "fuchsia")]
6187impl From<fidl::Channel> for LinuxManagerSynchronousProxy {
6188    fn from(value: fidl::Channel) -> Self {
6189        Self::new(value)
6190    }
6191}
6192
6193#[cfg(target_os = "fuchsia")]
6194impl fidl::endpoints::FromClient for LinuxManagerSynchronousProxy {
6195    type Protocol = LinuxManagerMarker;
6196
6197    fn from_client(value: fidl::endpoints::ClientEnd<LinuxManagerMarker>) -> Self {
6198        Self::new(value.into_channel())
6199    }
6200}
6201
6202#[derive(Debug, Clone)]
6203pub struct LinuxManagerProxy {
6204    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6205}
6206
6207impl fidl::endpoints::Proxy for LinuxManagerProxy {
6208    type Protocol = LinuxManagerMarker;
6209
6210    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6211        Self::new(inner)
6212    }
6213
6214    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6215        self.client.into_channel().map_err(|client| Self { client })
6216    }
6217
6218    fn as_channel(&self) -> &::fidl::AsyncChannel {
6219        self.client.as_channel()
6220    }
6221}
6222
6223impl LinuxManagerProxy {
6224    /// Create a new Proxy for fuchsia.virtualization/LinuxManager.
6225    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6226        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6227        Self { client: fidl::client::Client::new(channel, protocol_name) }
6228    }
6229
6230    /// Get a Stream of events from the remote end of the protocol.
6231    ///
6232    /// # Panics
6233    ///
6234    /// Panics if the event stream was already taken.
6235    pub fn take_event_stream(&self) -> LinuxManagerEventStream {
6236        LinuxManagerEventStream { event_receiver: self.client.take_event_receiver() }
6237    }
6238
6239    /// Get Linux guest environment info.
6240    ///
6241    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6242    pub fn r#start_and_get_linux_guest_info(
6243        &self,
6244        mut label: &str,
6245    ) -> fidl::client::QueryResponseFut<
6246        LinuxManagerStartAndGetLinuxGuestInfoResult,
6247        fidl::encoding::DefaultFuchsiaResourceDialect,
6248    > {
6249        LinuxManagerProxyInterface::r#start_and_get_linux_guest_info(self, label)
6250    }
6251
6252    /// Clears the stateful data. This includes any installed containers and any user data
6253    /// they may contain.
6254    ///
6255    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6256    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6257    /// operation.
6258    pub fn r#wipe_data(
6259        &self,
6260    ) -> fidl::client::QueryResponseFut<
6261        LinuxManagerWipeDataResult,
6262        fidl::encoding::DefaultFuchsiaResourceDialect,
6263    > {
6264        LinuxManagerProxyInterface::r#wipe_data(self)
6265    }
6266
6267    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6268    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6269    /// the epitaph) before attempting to launch another guest.
6270    ///
6271    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6272    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6273    /// a component crash).
6274    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6275        LinuxManagerProxyInterface::r#graceful_shutdown(self)
6276    }
6277}
6278
6279impl LinuxManagerProxyInterface for LinuxManagerProxy {
6280    type StartAndGetLinuxGuestInfoResponseFut = fidl::client::QueryResponseFut<
6281        LinuxManagerStartAndGetLinuxGuestInfoResult,
6282        fidl::encoding::DefaultFuchsiaResourceDialect,
6283    >;
6284    fn r#start_and_get_linux_guest_info(
6285        &self,
6286        mut label: &str,
6287    ) -> Self::StartAndGetLinuxGuestInfoResponseFut {
6288        fn _decode(
6289            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6290        ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6291            let _response = fidl::client::decode_transaction_body::<
6292                fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6293                fidl::encoding::DefaultFuchsiaResourceDialect,
6294                0x11809ced100a2bea,
6295            >(_buf?)?;
6296            Ok(_response.map(|x| x.info))
6297        }
6298        self.client.send_query_and_decode::<
6299            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6300            LinuxManagerStartAndGetLinuxGuestInfoResult,
6301        >(
6302            (label,),
6303            0x11809ced100a2bea,
6304            fidl::encoding::DynamicFlags::empty(),
6305            _decode,
6306        )
6307    }
6308
6309    type WipeDataResponseFut = fidl::client::QueryResponseFut<
6310        LinuxManagerWipeDataResult,
6311        fidl::encoding::DefaultFuchsiaResourceDialect,
6312    >;
6313    fn r#wipe_data(&self) -> Self::WipeDataResponseFut {
6314        fn _decode(
6315            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6316        ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6317            let _response = fidl::client::decode_transaction_body::<
6318                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6319                fidl::encoding::DefaultFuchsiaResourceDialect,
6320                0x732c69394548a76a,
6321            >(_buf?)?;
6322            Ok(_response.map(|x| x))
6323        }
6324        self.client
6325            .send_query_and_decode::<fidl::encoding::EmptyPayload, LinuxManagerWipeDataResult>(
6326                (),
6327                0x732c69394548a76a,
6328                fidl::encoding::DynamicFlags::empty(),
6329                _decode,
6330            )
6331    }
6332
6333    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6334        self.client.send::<fidl::encoding::EmptyPayload>(
6335            (),
6336            0x5dab12b50bc9909d,
6337            fidl::encoding::DynamicFlags::empty(),
6338        )
6339    }
6340}
6341
6342pub struct LinuxManagerEventStream {
6343    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6344}
6345
6346impl std::marker::Unpin for LinuxManagerEventStream {}
6347
6348impl futures::stream::FusedStream for LinuxManagerEventStream {
6349    fn is_terminated(&self) -> bool {
6350        self.event_receiver.is_terminated()
6351    }
6352}
6353
6354impl futures::Stream for LinuxManagerEventStream {
6355    type Item = Result<LinuxManagerEvent, fidl::Error>;
6356
6357    fn poll_next(
6358        mut self: std::pin::Pin<&mut Self>,
6359        cx: &mut std::task::Context<'_>,
6360    ) -> std::task::Poll<Option<Self::Item>> {
6361        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6362            &mut self.event_receiver,
6363            cx
6364        )?) {
6365            Some(buf) => std::task::Poll::Ready(Some(LinuxManagerEvent::decode(buf))),
6366            None => std::task::Poll::Ready(None),
6367        }
6368    }
6369}
6370
6371#[derive(Debug)]
6372pub enum LinuxManagerEvent {
6373    OnGuestInfoChanged { label: String, info: LinuxGuestInfo },
6374}
6375
6376impl LinuxManagerEvent {
6377    #[allow(irrefutable_let_patterns)]
6378    pub fn into_on_guest_info_changed(self) -> Option<(String, LinuxGuestInfo)> {
6379        if let LinuxManagerEvent::OnGuestInfoChanged { label, info } = self {
6380            Some((label, info))
6381        } else {
6382            None
6383        }
6384    }
6385
6386    /// Decodes a message buffer as a [`LinuxManagerEvent`].
6387    fn decode(
6388        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6389    ) -> Result<LinuxManagerEvent, fidl::Error> {
6390        let (bytes, _handles) = buf.split_mut();
6391        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6392        debug_assert_eq!(tx_header.tx_id, 0);
6393        match tx_header.ordinal {
6394            0x30a9be4c43d6a2d6 => {
6395                let mut out = fidl::new_empty!(
6396                    LinuxManagerOnGuestInfoChangedRequest,
6397                    fidl::encoding::DefaultFuchsiaResourceDialect
6398                );
6399                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerOnGuestInfoChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6400                Ok((LinuxManagerEvent::OnGuestInfoChanged { label: out.label, info: out.info }))
6401            }
6402            _ => Err(fidl::Error::UnknownOrdinal {
6403                ordinal: tx_header.ordinal,
6404                protocol_name: <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6405            }),
6406        }
6407    }
6408}
6409
6410/// A Stream of incoming requests for fuchsia.virtualization/LinuxManager.
6411pub struct LinuxManagerRequestStream {
6412    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6413    is_terminated: bool,
6414}
6415
6416impl std::marker::Unpin for LinuxManagerRequestStream {}
6417
6418impl futures::stream::FusedStream for LinuxManagerRequestStream {
6419    fn is_terminated(&self) -> bool {
6420        self.is_terminated
6421    }
6422}
6423
6424impl fidl::endpoints::RequestStream for LinuxManagerRequestStream {
6425    type Protocol = LinuxManagerMarker;
6426    type ControlHandle = LinuxManagerControlHandle;
6427
6428    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6429        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6430    }
6431
6432    fn control_handle(&self) -> Self::ControlHandle {
6433        LinuxManagerControlHandle { inner: self.inner.clone() }
6434    }
6435
6436    fn into_inner(
6437        self,
6438    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6439    {
6440        (self.inner, self.is_terminated)
6441    }
6442
6443    fn from_inner(
6444        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6445        is_terminated: bool,
6446    ) -> Self {
6447        Self { inner, is_terminated }
6448    }
6449}
6450
6451impl futures::Stream for LinuxManagerRequestStream {
6452    type Item = Result<LinuxManagerRequest, fidl::Error>;
6453
6454    fn poll_next(
6455        mut self: std::pin::Pin<&mut Self>,
6456        cx: &mut std::task::Context<'_>,
6457    ) -> std::task::Poll<Option<Self::Item>> {
6458        let this = &mut *self;
6459        if this.inner.check_shutdown(cx) {
6460            this.is_terminated = true;
6461            return std::task::Poll::Ready(None);
6462        }
6463        if this.is_terminated {
6464            panic!("polled LinuxManagerRequestStream after completion");
6465        }
6466        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6467            |bytes, handles| {
6468                match this.inner.channel().read_etc(cx, bytes, handles) {
6469                    std::task::Poll::Ready(Ok(())) => {}
6470                    std::task::Poll::Pending => return std::task::Poll::Pending,
6471                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6472                        this.is_terminated = true;
6473                        return std::task::Poll::Ready(None);
6474                    }
6475                    std::task::Poll::Ready(Err(e)) => {
6476                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6477                            e.into(),
6478                        ))));
6479                    }
6480                }
6481
6482                // A message has been received from the channel
6483                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6484
6485                std::task::Poll::Ready(Some(match header.ordinal {
6486                    0x11809ced100a2bea => {
6487                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6488                        let mut req = fidl::new_empty!(
6489                            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6490                            fidl::encoding::DefaultFuchsiaResourceDialect
6491                        );
6492                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerStartAndGetLinuxGuestInfoRequest>(&header, _body_bytes, handles, &mut req)?;
6493                        let control_handle =
6494                            LinuxManagerControlHandle { inner: this.inner.clone() };
6495                        Ok(LinuxManagerRequest::StartAndGetLinuxGuestInfo {
6496                            label: req.label,
6497
6498                            responder: LinuxManagerStartAndGetLinuxGuestInfoResponder {
6499                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6500                                tx_id: header.tx_id,
6501                            },
6502                        })
6503                    }
6504                    0x732c69394548a76a => {
6505                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6506                        let mut req = fidl::new_empty!(
6507                            fidl::encoding::EmptyPayload,
6508                            fidl::encoding::DefaultFuchsiaResourceDialect
6509                        );
6510                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6511                        let control_handle =
6512                            LinuxManagerControlHandle { inner: this.inner.clone() };
6513                        Ok(LinuxManagerRequest::WipeData {
6514                            responder: LinuxManagerWipeDataResponder {
6515                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6516                                tx_id: header.tx_id,
6517                            },
6518                        })
6519                    }
6520                    0x5dab12b50bc9909d => {
6521                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6522                        let mut req = fidl::new_empty!(
6523                            fidl::encoding::EmptyPayload,
6524                            fidl::encoding::DefaultFuchsiaResourceDialect
6525                        );
6526                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6527                        let control_handle =
6528                            LinuxManagerControlHandle { inner: this.inner.clone() };
6529                        Ok(LinuxManagerRequest::GracefulShutdown { control_handle })
6530                    }
6531                    _ => Err(fidl::Error::UnknownOrdinal {
6532                        ordinal: header.ordinal,
6533                        protocol_name:
6534                            <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6535                    }),
6536                }))
6537            },
6538        )
6539    }
6540}
6541
6542/// A `LinuxManager` provides access to the status of Linux guest instances.
6543#[derive(Debug)]
6544pub enum LinuxManagerRequest {
6545    /// Get Linux guest environment info.
6546    ///
6547    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6548    StartAndGetLinuxGuestInfo {
6549        label: String,
6550        responder: LinuxManagerStartAndGetLinuxGuestInfoResponder,
6551    },
6552    /// Clears the stateful data. This includes any installed containers and any user data
6553    /// they may contain.
6554    ///
6555    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6556    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6557    /// operation.
6558    WipeData { responder: LinuxManagerWipeDataResponder },
6559    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6560    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6561    /// the epitaph) before attempting to launch another guest.
6562    ///
6563    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6564    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6565    /// a component crash).
6566    GracefulShutdown { control_handle: LinuxManagerControlHandle },
6567}
6568
6569impl LinuxManagerRequest {
6570    #[allow(irrefutable_let_patterns)]
6571    pub fn into_start_and_get_linux_guest_info(
6572        self,
6573    ) -> Option<(String, LinuxManagerStartAndGetLinuxGuestInfoResponder)> {
6574        if let LinuxManagerRequest::StartAndGetLinuxGuestInfo { label, responder } = self {
6575            Some((label, responder))
6576        } else {
6577            None
6578        }
6579    }
6580
6581    #[allow(irrefutable_let_patterns)]
6582    pub fn into_wipe_data(self) -> Option<(LinuxManagerWipeDataResponder)> {
6583        if let LinuxManagerRequest::WipeData { responder } = self {
6584            Some((responder))
6585        } else {
6586            None
6587        }
6588    }
6589
6590    #[allow(irrefutable_let_patterns)]
6591    pub fn into_graceful_shutdown(self) -> Option<(LinuxManagerControlHandle)> {
6592        if let LinuxManagerRequest::GracefulShutdown { control_handle } = self {
6593            Some((control_handle))
6594        } else {
6595            None
6596        }
6597    }
6598
6599    /// Name of the method defined in FIDL
6600    pub fn method_name(&self) -> &'static str {
6601        match *self {
6602            LinuxManagerRequest::StartAndGetLinuxGuestInfo { .. } => {
6603                "start_and_get_linux_guest_info"
6604            }
6605            LinuxManagerRequest::WipeData { .. } => "wipe_data",
6606            LinuxManagerRequest::GracefulShutdown { .. } => "graceful_shutdown",
6607        }
6608    }
6609}
6610
6611#[derive(Debug, Clone)]
6612pub struct LinuxManagerControlHandle {
6613    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6614}
6615
6616impl LinuxManagerControlHandle {
6617    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6618        self.inner.shutdown_with_epitaph(status.into())
6619    }
6620}
6621
6622impl fidl::endpoints::ControlHandle for LinuxManagerControlHandle {
6623    fn shutdown(&self) {
6624        self.inner.shutdown()
6625    }
6626
6627    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6628        self.inner.shutdown_with_epitaph(status)
6629    }
6630
6631    fn is_closed(&self) -> bool {
6632        self.inner.channel().is_closed()
6633    }
6634    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6635        self.inner.channel().on_closed()
6636    }
6637
6638    #[cfg(target_os = "fuchsia")]
6639    fn signal_peer(
6640        &self,
6641        clear_mask: zx::Signals,
6642        set_mask: zx::Signals,
6643    ) -> Result<(), zx_status::Status> {
6644        use fidl::Peered;
6645        self.inner.channel().signal_peer(clear_mask, set_mask)
6646    }
6647}
6648
6649impl LinuxManagerControlHandle {
6650    pub fn send_on_guest_info_changed(
6651        &self,
6652        mut label: &str,
6653        mut info: &LinuxGuestInfo,
6654    ) -> Result<(), fidl::Error> {
6655        self.inner.send::<LinuxManagerOnGuestInfoChangedRequest>(
6656            (label, info),
6657            0,
6658            0x30a9be4c43d6a2d6,
6659            fidl::encoding::DynamicFlags::empty(),
6660        )
6661    }
6662}
6663
6664#[must_use = "FIDL methods require a response to be sent"]
6665#[derive(Debug)]
6666pub struct LinuxManagerStartAndGetLinuxGuestInfoResponder {
6667    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6668    tx_id: u32,
6669}
6670
6671/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6672/// if the responder is dropped without sending a response, so that the client
6673/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6674impl std::ops::Drop for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6675    fn drop(&mut self) {
6676        self.control_handle.shutdown();
6677        // Safety: drops once, never accessed again
6678        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6679    }
6680}
6681
6682impl fidl::endpoints::Responder for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6683    type ControlHandle = LinuxManagerControlHandle;
6684
6685    fn control_handle(&self) -> &LinuxManagerControlHandle {
6686        &self.control_handle
6687    }
6688
6689    fn drop_without_shutdown(mut self) {
6690        // Safety: drops once, never accessed again due to mem::forget
6691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6692        // Prevent Drop from running (which would shut down the channel)
6693        std::mem::forget(self);
6694    }
6695}
6696
6697impl LinuxManagerStartAndGetLinuxGuestInfoResponder {
6698    /// Sends a response to the FIDL transaction.
6699    ///
6700    /// Sets the channel to shutdown if an error occurs.
6701    pub fn send(self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6702        let _result = self.send_raw(result);
6703        if _result.is_err() {
6704            self.control_handle.shutdown();
6705        }
6706        self.drop_without_shutdown();
6707        _result
6708    }
6709
6710    /// Similar to "send" but does not shutdown the channel if an error occurs.
6711    pub fn send_no_shutdown_on_err(
6712        self,
6713        mut result: Result<&LinuxGuestInfo, i32>,
6714    ) -> Result<(), fidl::Error> {
6715        let _result = self.send_raw(result);
6716        self.drop_without_shutdown();
6717        _result
6718    }
6719
6720    fn send_raw(&self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6721        self.control_handle.inner.send::<fidl::encoding::ResultType<
6722            LinuxManagerStartAndGetLinuxGuestInfoResponse,
6723            i32,
6724        >>(
6725            result.map(|info| (info,)),
6726            self.tx_id,
6727            0x11809ced100a2bea,
6728            fidl::encoding::DynamicFlags::empty(),
6729        )
6730    }
6731}
6732
6733#[must_use = "FIDL methods require a response to be sent"]
6734#[derive(Debug)]
6735pub struct LinuxManagerWipeDataResponder {
6736    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6737    tx_id: u32,
6738}
6739
6740/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6741/// if the responder is dropped without sending a response, so that the client
6742/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6743impl std::ops::Drop for LinuxManagerWipeDataResponder {
6744    fn drop(&mut self) {
6745        self.control_handle.shutdown();
6746        // Safety: drops once, never accessed again
6747        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6748    }
6749}
6750
6751impl fidl::endpoints::Responder for LinuxManagerWipeDataResponder {
6752    type ControlHandle = LinuxManagerControlHandle;
6753
6754    fn control_handle(&self) -> &LinuxManagerControlHandle {
6755        &self.control_handle
6756    }
6757
6758    fn drop_without_shutdown(mut self) {
6759        // Safety: drops once, never accessed again due to mem::forget
6760        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6761        // Prevent Drop from running (which would shut down the channel)
6762        std::mem::forget(self);
6763    }
6764}
6765
6766impl LinuxManagerWipeDataResponder {
6767    /// Sends a response to the FIDL transaction.
6768    ///
6769    /// Sets the channel to shutdown if an error occurs.
6770    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6771        let _result = self.send_raw(result);
6772        if _result.is_err() {
6773            self.control_handle.shutdown();
6774        }
6775        self.drop_without_shutdown();
6776        _result
6777    }
6778
6779    /// Similar to "send" but does not shutdown the channel if an error occurs.
6780    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6781        let _result = self.send_raw(result);
6782        self.drop_without_shutdown();
6783        _result
6784    }
6785
6786    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6787        self.control_handle
6788            .inner
6789            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6790                result,
6791                self.tx_id,
6792                0x732c69394548a76a,
6793                fidl::encoding::DynamicFlags::empty(),
6794            )
6795    }
6796}
6797
6798#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6799pub struct MemControllerMarker;
6800
6801impl fidl::endpoints::ProtocolMarker for MemControllerMarker {
6802    type Proxy = MemControllerProxy;
6803    type RequestStream = MemControllerRequestStream;
6804    #[cfg(target_os = "fuchsia")]
6805    type SynchronousProxy = MemControllerSynchronousProxy;
6806
6807    const DEBUG_NAME: &'static str = "fuchsia.virtualization.MemController";
6808}
6809impl fidl::endpoints::DiscoverableProtocolMarker for MemControllerMarker {}
6810
6811pub trait MemControllerProxyInterface: Send + Sync {
6812    type GetMemSizeResponseFut: std::future::Future<Output = Result<(u64, u64, u64, u64, u64), fidl::Error>>
6813        + Send;
6814    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut;
6815    fn r#request_size(&self, requested_size: u64) -> Result<(), fidl::Error>;
6816}
6817#[derive(Debug)]
6818#[cfg(target_os = "fuchsia")]
6819pub struct MemControllerSynchronousProxy {
6820    client: fidl::client::sync::Client,
6821}
6822
6823#[cfg(target_os = "fuchsia")]
6824impl fidl::endpoints::SynchronousProxy for MemControllerSynchronousProxy {
6825    type Proxy = MemControllerProxy;
6826    type Protocol = MemControllerMarker;
6827
6828    fn from_channel(inner: fidl::Channel) -> Self {
6829        Self::new(inner)
6830    }
6831
6832    fn into_channel(self) -> fidl::Channel {
6833        self.client.into_channel()
6834    }
6835
6836    fn as_channel(&self) -> &fidl::Channel {
6837        self.client.as_channel()
6838    }
6839}
6840
6841#[cfg(target_os = "fuchsia")]
6842impl MemControllerSynchronousProxy {
6843    pub fn new(channel: fidl::Channel) -> Self {
6844        Self { client: fidl::client::sync::Client::new(channel) }
6845    }
6846
6847    pub fn into_channel(self) -> fidl::Channel {
6848        self.client.into_channel()
6849    }
6850
6851    /// Waits until an event arrives and returns it. It is safe for other
6852    /// threads to make concurrent requests while waiting for an event.
6853    pub fn wait_for_event(
6854        &self,
6855        deadline: zx::MonotonicInstant,
6856    ) -> Result<MemControllerEvent, fidl::Error> {
6857        MemControllerEvent::decode(self.client.wait_for_event::<MemControllerMarker>(deadline)?)
6858    }
6859
6860    /// Get the configured region size, usable region size, plugged size and requestd size
6861    ///
6862    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6863    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6864    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6865    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6866    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6867    /// memory region.
6868    /// requested_size is the requested amount of plugged memory within the usable device-managed
6869    /// memory region.
6870    pub fn r#get_mem_size(
6871        &self,
6872        ___deadline: zx::MonotonicInstant,
6873    ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6874        let _response = self.client.send_query::<
6875            fidl::encoding::EmptyPayload,
6876            MemControllerGetMemSizeResponse,
6877            MemControllerMarker,
6878        >(
6879            (),
6880            0x6e9d496f9b66ea56,
6881            fidl::encoding::DynamicFlags::empty(),
6882            ___deadline,
6883        )?;
6884        Ok((
6885            _response.block_size,
6886            _response.region_size,
6887            _response.usable_region_size,
6888            _response.plugged_size,
6889            _response.requested_size,
6890        ))
6891    }
6892
6893    /// Update the requested size to plug or unplug memory
6894    ///
6895    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6896    /// configuration changed) by (un)plugging memory blocks.
6897    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6898        self.client.send::<MemControllerRequestSizeRequest>(
6899            (requested_size,),
6900            0x12f8e2cc21ee8102,
6901            fidl::encoding::DynamicFlags::empty(),
6902        )
6903    }
6904}
6905
6906#[cfg(target_os = "fuchsia")]
6907impl From<MemControllerSynchronousProxy> for zx::NullableHandle {
6908    fn from(value: MemControllerSynchronousProxy) -> Self {
6909        value.into_channel().into()
6910    }
6911}
6912
6913#[cfg(target_os = "fuchsia")]
6914impl From<fidl::Channel> for MemControllerSynchronousProxy {
6915    fn from(value: fidl::Channel) -> Self {
6916        Self::new(value)
6917    }
6918}
6919
6920#[cfg(target_os = "fuchsia")]
6921impl fidl::endpoints::FromClient for MemControllerSynchronousProxy {
6922    type Protocol = MemControllerMarker;
6923
6924    fn from_client(value: fidl::endpoints::ClientEnd<MemControllerMarker>) -> Self {
6925        Self::new(value.into_channel())
6926    }
6927}
6928
6929#[derive(Debug, Clone)]
6930pub struct MemControllerProxy {
6931    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6932}
6933
6934impl fidl::endpoints::Proxy for MemControllerProxy {
6935    type Protocol = MemControllerMarker;
6936
6937    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6938        Self::new(inner)
6939    }
6940
6941    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6942        self.client.into_channel().map_err(|client| Self { client })
6943    }
6944
6945    fn as_channel(&self) -> &::fidl::AsyncChannel {
6946        self.client.as_channel()
6947    }
6948}
6949
6950impl MemControllerProxy {
6951    /// Create a new Proxy for fuchsia.virtualization/MemController.
6952    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6953        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6954        Self { client: fidl::client::Client::new(channel, protocol_name) }
6955    }
6956
6957    /// Get a Stream of events from the remote end of the protocol.
6958    ///
6959    /// # Panics
6960    ///
6961    /// Panics if the event stream was already taken.
6962    pub fn take_event_stream(&self) -> MemControllerEventStream {
6963        MemControllerEventStream { event_receiver: self.client.take_event_receiver() }
6964    }
6965
6966    /// Get the configured region size, usable region size, plugged size and requestd size
6967    ///
6968    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6969    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6970    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6971    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6972    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6973    /// memory region.
6974    /// requested_size is the requested amount of plugged memory within the usable device-managed
6975    /// memory region.
6976    pub fn r#get_mem_size(
6977        &self,
6978    ) -> fidl::client::QueryResponseFut<
6979        (u64, u64, u64, u64, u64),
6980        fidl::encoding::DefaultFuchsiaResourceDialect,
6981    > {
6982        MemControllerProxyInterface::r#get_mem_size(self)
6983    }
6984
6985    /// Update the requested size to plug or unplug memory
6986    ///
6987    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6988    /// configuration changed) by (un)plugging memory blocks.
6989    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6990        MemControllerProxyInterface::r#request_size(self, requested_size)
6991    }
6992}
6993
6994impl MemControllerProxyInterface for MemControllerProxy {
6995    type GetMemSizeResponseFut = fidl::client::QueryResponseFut<
6996        (u64, u64, u64, u64, u64),
6997        fidl::encoding::DefaultFuchsiaResourceDialect,
6998    >;
6999    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut {
7000        fn _decode(
7001            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7002        ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
7003            let _response = fidl::client::decode_transaction_body::<
7004                MemControllerGetMemSizeResponse,
7005                fidl::encoding::DefaultFuchsiaResourceDialect,
7006                0x6e9d496f9b66ea56,
7007            >(_buf?)?;
7008            Ok((
7009                _response.block_size,
7010                _response.region_size,
7011                _response.usable_region_size,
7012                _response.plugged_size,
7013                _response.requested_size,
7014            ))
7015        }
7016        self.client
7017            .send_query_and_decode::<fidl::encoding::EmptyPayload, (u64, u64, u64, u64, u64)>(
7018                (),
7019                0x6e9d496f9b66ea56,
7020                fidl::encoding::DynamicFlags::empty(),
7021                _decode,
7022            )
7023    }
7024
7025    fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
7026        self.client.send::<MemControllerRequestSizeRequest>(
7027            (requested_size,),
7028            0x12f8e2cc21ee8102,
7029            fidl::encoding::DynamicFlags::empty(),
7030        )
7031    }
7032}
7033
7034pub struct MemControllerEventStream {
7035    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7036}
7037
7038impl std::marker::Unpin for MemControllerEventStream {}
7039
7040impl futures::stream::FusedStream for MemControllerEventStream {
7041    fn is_terminated(&self) -> bool {
7042        self.event_receiver.is_terminated()
7043    }
7044}
7045
7046impl futures::Stream for MemControllerEventStream {
7047    type Item = Result<MemControllerEvent, fidl::Error>;
7048
7049    fn poll_next(
7050        mut self: std::pin::Pin<&mut Self>,
7051        cx: &mut std::task::Context<'_>,
7052    ) -> std::task::Poll<Option<Self::Item>> {
7053        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7054            &mut self.event_receiver,
7055            cx
7056        )?) {
7057            Some(buf) => std::task::Poll::Ready(Some(MemControllerEvent::decode(buf))),
7058            None => std::task::Poll::Ready(None),
7059        }
7060    }
7061}
7062
7063#[derive(Debug)]
7064pub enum MemControllerEvent {}
7065
7066impl MemControllerEvent {
7067    /// Decodes a message buffer as a [`MemControllerEvent`].
7068    fn decode(
7069        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7070    ) -> Result<MemControllerEvent, fidl::Error> {
7071        let (bytes, _handles) = buf.split_mut();
7072        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7073        debug_assert_eq!(tx_header.tx_id, 0);
7074        match tx_header.ordinal {
7075            _ => Err(fidl::Error::UnknownOrdinal {
7076                ordinal: tx_header.ordinal,
7077                protocol_name: <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7078            }),
7079        }
7080    }
7081}
7082
7083/// A Stream of incoming requests for fuchsia.virtualization/MemController.
7084pub struct MemControllerRequestStream {
7085    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7086    is_terminated: bool,
7087}
7088
7089impl std::marker::Unpin for MemControllerRequestStream {}
7090
7091impl futures::stream::FusedStream for MemControllerRequestStream {
7092    fn is_terminated(&self) -> bool {
7093        self.is_terminated
7094    }
7095}
7096
7097impl fidl::endpoints::RequestStream for MemControllerRequestStream {
7098    type Protocol = MemControllerMarker;
7099    type ControlHandle = MemControllerControlHandle;
7100
7101    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7102        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7103    }
7104
7105    fn control_handle(&self) -> Self::ControlHandle {
7106        MemControllerControlHandle { inner: self.inner.clone() }
7107    }
7108
7109    fn into_inner(
7110        self,
7111    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7112    {
7113        (self.inner, self.is_terminated)
7114    }
7115
7116    fn from_inner(
7117        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7118        is_terminated: bool,
7119    ) -> Self {
7120        Self { inner, is_terminated }
7121    }
7122}
7123
7124impl futures::Stream for MemControllerRequestStream {
7125    type Item = Result<MemControllerRequest, fidl::Error>;
7126
7127    fn poll_next(
7128        mut self: std::pin::Pin<&mut Self>,
7129        cx: &mut std::task::Context<'_>,
7130    ) -> std::task::Poll<Option<Self::Item>> {
7131        let this = &mut *self;
7132        if this.inner.check_shutdown(cx) {
7133            this.is_terminated = true;
7134            return std::task::Poll::Ready(None);
7135        }
7136        if this.is_terminated {
7137            panic!("polled MemControllerRequestStream after completion");
7138        }
7139        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7140            |bytes, handles| {
7141                match this.inner.channel().read_etc(cx, bytes, handles) {
7142                    std::task::Poll::Ready(Ok(())) => {}
7143                    std::task::Poll::Pending => return std::task::Poll::Pending,
7144                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7145                        this.is_terminated = true;
7146                        return std::task::Poll::Ready(None);
7147                    }
7148                    std::task::Poll::Ready(Err(e)) => {
7149                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7150                            e.into(),
7151                        ))));
7152                    }
7153                }
7154
7155                // A message has been received from the channel
7156                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7157
7158                std::task::Poll::Ready(Some(match header.ordinal {
7159                    0x6e9d496f9b66ea56 => {
7160                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7161                        let mut req = fidl::new_empty!(
7162                            fidl::encoding::EmptyPayload,
7163                            fidl::encoding::DefaultFuchsiaResourceDialect
7164                        );
7165                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7166                        let control_handle =
7167                            MemControllerControlHandle { inner: this.inner.clone() };
7168                        Ok(MemControllerRequest::GetMemSize {
7169                            responder: MemControllerGetMemSizeResponder {
7170                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7171                                tx_id: header.tx_id,
7172                            },
7173                        })
7174                    }
7175                    0x12f8e2cc21ee8102 => {
7176                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7177                        let mut req = fidl::new_empty!(
7178                            MemControllerRequestSizeRequest,
7179                            fidl::encoding::DefaultFuchsiaResourceDialect
7180                        );
7181                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MemControllerRequestSizeRequest>(&header, _body_bytes, handles, &mut req)?;
7182                        let control_handle =
7183                            MemControllerControlHandle { inner: this.inner.clone() };
7184                        Ok(MemControllerRequest::RequestSize {
7185                            requested_size: req.requested_size,
7186
7187                            control_handle,
7188                        })
7189                    }
7190                    _ => Err(fidl::Error::UnknownOrdinal {
7191                        ordinal: header.ordinal,
7192                        protocol_name:
7193                            <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7194                    }),
7195                }))
7196            },
7197        )
7198    }
7199}
7200
7201/// A `MemController` controls a guest's virtio-mem
7202#[derive(Debug)]
7203pub enum MemControllerRequest {
7204    /// Get the configured region size, usable region size, plugged size and requestd size
7205    ///
7206    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
7207    /// region_size is the size of device-managed memory region in bytes. Cannot change.
7208    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
7209    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
7210    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
7211    /// memory region.
7212    /// requested_size is the requested amount of plugged memory within the usable device-managed
7213    /// memory region.
7214    GetMemSize { responder: MemControllerGetMemSizeResponder },
7215    /// Update the requested size to plug or unplug memory
7216    ///
7217    /// The driver SHOULD react to resize requests from the device (requested_size in the device
7218    /// configuration changed) by (un)plugging memory blocks.
7219    RequestSize { requested_size: u64, control_handle: MemControllerControlHandle },
7220}
7221
7222impl MemControllerRequest {
7223    #[allow(irrefutable_let_patterns)]
7224    pub fn into_get_mem_size(self) -> Option<(MemControllerGetMemSizeResponder)> {
7225        if let MemControllerRequest::GetMemSize { responder } = self {
7226            Some((responder))
7227        } else {
7228            None
7229        }
7230    }
7231
7232    #[allow(irrefutable_let_patterns)]
7233    pub fn into_request_size(self) -> Option<(u64, MemControllerControlHandle)> {
7234        if let MemControllerRequest::RequestSize { requested_size, control_handle } = self {
7235            Some((requested_size, control_handle))
7236        } else {
7237            None
7238        }
7239    }
7240
7241    /// Name of the method defined in FIDL
7242    pub fn method_name(&self) -> &'static str {
7243        match *self {
7244            MemControllerRequest::GetMemSize { .. } => "get_mem_size",
7245            MemControllerRequest::RequestSize { .. } => "request_size",
7246        }
7247    }
7248}
7249
7250#[derive(Debug, Clone)]
7251pub struct MemControllerControlHandle {
7252    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7253}
7254
7255impl MemControllerControlHandle {
7256    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
7257        self.inner.shutdown_with_epitaph(status.into())
7258    }
7259}
7260
7261impl fidl::endpoints::ControlHandle for MemControllerControlHandle {
7262    fn shutdown(&self) {
7263        self.inner.shutdown()
7264    }
7265
7266    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
7267        self.inner.shutdown_with_epitaph(status)
7268    }
7269
7270    fn is_closed(&self) -> bool {
7271        self.inner.channel().is_closed()
7272    }
7273    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7274        self.inner.channel().on_closed()
7275    }
7276
7277    #[cfg(target_os = "fuchsia")]
7278    fn signal_peer(
7279        &self,
7280        clear_mask: zx::Signals,
7281        set_mask: zx::Signals,
7282    ) -> Result<(), zx_status::Status> {
7283        use fidl::Peered;
7284        self.inner.channel().signal_peer(clear_mask, set_mask)
7285    }
7286}
7287
7288impl MemControllerControlHandle {}
7289
7290#[must_use = "FIDL methods require a response to be sent"]
7291#[derive(Debug)]
7292pub struct MemControllerGetMemSizeResponder {
7293    control_handle: std::mem::ManuallyDrop<MemControllerControlHandle>,
7294    tx_id: u32,
7295}
7296
7297/// Set the the channel to be shutdown (see [`MemControllerControlHandle::shutdown`])
7298/// if the responder is dropped without sending a response, so that the client
7299/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7300impl std::ops::Drop for MemControllerGetMemSizeResponder {
7301    fn drop(&mut self) {
7302        self.control_handle.shutdown();
7303        // Safety: drops once, never accessed again
7304        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7305    }
7306}
7307
7308impl fidl::endpoints::Responder for MemControllerGetMemSizeResponder {
7309    type ControlHandle = MemControllerControlHandle;
7310
7311    fn control_handle(&self) -> &MemControllerControlHandle {
7312        &self.control_handle
7313    }
7314
7315    fn drop_without_shutdown(mut self) {
7316        // Safety: drops once, never accessed again due to mem::forget
7317        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7318        // Prevent Drop from running (which would shut down the channel)
7319        std::mem::forget(self);
7320    }
7321}
7322
7323impl MemControllerGetMemSizeResponder {
7324    /// Sends a response to the FIDL transaction.
7325    ///
7326    /// Sets the channel to shutdown if an error occurs.
7327    pub fn send(
7328        self,
7329        mut block_size: u64,
7330        mut region_size: u64,
7331        mut usable_region_size: u64,
7332        mut plugged_size: u64,
7333        mut requested_size: u64,
7334    ) -> Result<(), fidl::Error> {
7335        let _result = self.send_raw(
7336            block_size,
7337            region_size,
7338            usable_region_size,
7339            plugged_size,
7340            requested_size,
7341        );
7342        if _result.is_err() {
7343            self.control_handle.shutdown();
7344        }
7345        self.drop_without_shutdown();
7346        _result
7347    }
7348
7349    /// Similar to "send" but does not shutdown the channel if an error occurs.
7350    pub fn send_no_shutdown_on_err(
7351        self,
7352        mut block_size: u64,
7353        mut region_size: u64,
7354        mut usable_region_size: u64,
7355        mut plugged_size: u64,
7356        mut requested_size: u64,
7357    ) -> Result<(), fidl::Error> {
7358        let _result = self.send_raw(
7359            block_size,
7360            region_size,
7361            usable_region_size,
7362            plugged_size,
7363            requested_size,
7364        );
7365        self.drop_without_shutdown();
7366        _result
7367    }
7368
7369    fn send_raw(
7370        &self,
7371        mut block_size: u64,
7372        mut region_size: u64,
7373        mut usable_region_size: u64,
7374        mut plugged_size: u64,
7375        mut requested_size: u64,
7376    ) -> Result<(), fidl::Error> {
7377        self.control_handle.inner.send::<MemControllerGetMemSizeResponse>(
7378            (block_size, region_size, usable_region_size, plugged_size, requested_size),
7379            self.tx_id,
7380            0x6e9d496f9b66ea56,
7381            fidl::encoding::DynamicFlags::empty(),
7382        )
7383    }
7384}
7385
7386#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7387pub struct TerminaGuestManagerMarker;
7388
7389impl fidl::endpoints::ProtocolMarker for TerminaGuestManagerMarker {
7390    type Proxy = TerminaGuestManagerProxy;
7391    type RequestStream = TerminaGuestManagerRequestStream;
7392    #[cfg(target_os = "fuchsia")]
7393    type SynchronousProxy = TerminaGuestManagerSynchronousProxy;
7394
7395    const DEBUG_NAME: &'static str = "fuchsia.virtualization.TerminaGuestManager";
7396}
7397impl fidl::endpoints::DiscoverableProtocolMarker for TerminaGuestManagerMarker {}
7398
7399pub trait TerminaGuestManagerProxyInterface: Send + Sync {
7400    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
7401        + Send;
7402    fn r#launch(
7403        &self,
7404        guest_config: GuestConfig,
7405        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7406    ) -> Self::LaunchResponseFut;
7407    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7408    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
7409    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
7410        + Send;
7411    fn r#connect(
7412        &self,
7413        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7414    ) -> Self::ConnectResponseFut;
7415    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
7416    fn r#get_info(&self) -> Self::GetInfoResponseFut;
7417}
7418#[derive(Debug)]
7419#[cfg(target_os = "fuchsia")]
7420pub struct TerminaGuestManagerSynchronousProxy {
7421    client: fidl::client::sync::Client,
7422}
7423
7424#[cfg(target_os = "fuchsia")]
7425impl fidl::endpoints::SynchronousProxy for TerminaGuestManagerSynchronousProxy {
7426    type Proxy = TerminaGuestManagerProxy;
7427    type Protocol = TerminaGuestManagerMarker;
7428
7429    fn from_channel(inner: fidl::Channel) -> Self {
7430        Self::new(inner)
7431    }
7432
7433    fn into_channel(self) -> fidl::Channel {
7434        self.client.into_channel()
7435    }
7436
7437    fn as_channel(&self) -> &fidl::Channel {
7438        self.client.as_channel()
7439    }
7440}
7441
7442#[cfg(target_os = "fuchsia")]
7443impl TerminaGuestManagerSynchronousProxy {
7444    pub fn new(channel: fidl::Channel) -> Self {
7445        Self { client: fidl::client::sync::Client::new(channel) }
7446    }
7447
7448    pub fn into_channel(self) -> fidl::Channel {
7449        self.client.into_channel()
7450    }
7451
7452    /// Waits until an event arrives and returns it. It is safe for other
7453    /// threads to make concurrent requests while waiting for an event.
7454    pub fn wait_for_event(
7455        &self,
7456        deadline: zx::MonotonicInstant,
7457    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7458        TerminaGuestManagerEvent::decode(
7459            self.client.wait_for_event::<TerminaGuestManagerMarker>(deadline)?,
7460        )
7461    }
7462
7463    /// Launch a new guest instance.
7464    ///
7465    /// Possible errors:
7466    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7467    ///         problems detected by the guest manager.
7468    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7469    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7470    ///         component logs for a more specific failure.
7471    pub fn r#launch(
7472        &self,
7473        mut guest_config: GuestConfig,
7474        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7475        ___deadline: zx::MonotonicInstant,
7476    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7477        let _response =
7478            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
7479                fidl::encoding::EmptyStruct,
7480                GuestManagerError,
7481            >, TerminaGuestManagerMarker>(
7482                (&mut guest_config, controller),
7483                0x394a2e29f750323e,
7484                fidl::encoding::DynamicFlags::empty(),
7485                ___deadline,
7486            )?;
7487        Ok(_response.map(|x| x))
7488    }
7489
7490    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7491    /// be used to launch another guest.
7492    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
7493        let _response = self.client.send_query::<
7494            fidl::encoding::EmptyPayload,
7495            fidl::encoding::EmptyPayload,
7496            TerminaGuestManagerMarker,
7497        >(
7498            (),
7499            0x3ad9a012982f872d,
7500            fidl::encoding::DynamicFlags::empty(),
7501            ___deadline,
7502        )?;
7503        Ok(_response)
7504    }
7505
7506    /// Connect to a currently running guest.
7507    ///
7508    /// Possible errors:
7509    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7510    ///         has launched before attempting to reconnect.
7511    pub fn r#connect(
7512        &self,
7513        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7514        ___deadline: zx::MonotonicInstant,
7515    ) -> Result<GuestManagerConnectResult, fidl::Error> {
7516        let _response =
7517            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
7518                fidl::encoding::EmptyStruct,
7519                GuestManagerError,
7520            >, TerminaGuestManagerMarker>(
7521                (controller,),
7522                0x4e489076e3bb15b4,
7523                fidl::encoding::DynamicFlags::empty(),
7524                ___deadline,
7525            )?;
7526        Ok(_response.map(|x| x))
7527    }
7528
7529    /// Query guest info
7530    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
7531        let _response = self.client.send_query::<
7532            fidl::encoding::EmptyPayload,
7533            GuestManagerGetInfoResponse,
7534            TerminaGuestManagerMarker,
7535        >(
7536            (),
7537            0x76892614aea695dc,
7538            fidl::encoding::DynamicFlags::empty(),
7539            ___deadline,
7540        )?;
7541        Ok(_response.guest_info)
7542    }
7543}
7544
7545#[cfg(target_os = "fuchsia")]
7546impl From<TerminaGuestManagerSynchronousProxy> for zx::NullableHandle {
7547    fn from(value: TerminaGuestManagerSynchronousProxy) -> Self {
7548        value.into_channel().into()
7549    }
7550}
7551
7552#[cfg(target_os = "fuchsia")]
7553impl From<fidl::Channel> for TerminaGuestManagerSynchronousProxy {
7554    fn from(value: fidl::Channel) -> Self {
7555        Self::new(value)
7556    }
7557}
7558
7559#[cfg(target_os = "fuchsia")]
7560impl fidl::endpoints::FromClient for TerminaGuestManagerSynchronousProxy {
7561    type Protocol = TerminaGuestManagerMarker;
7562
7563    fn from_client(value: fidl::endpoints::ClientEnd<TerminaGuestManagerMarker>) -> Self {
7564        Self::new(value.into_channel())
7565    }
7566}
7567
7568#[derive(Debug, Clone)]
7569pub struct TerminaGuestManagerProxy {
7570    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7571}
7572
7573impl fidl::endpoints::Proxy for TerminaGuestManagerProxy {
7574    type Protocol = TerminaGuestManagerMarker;
7575
7576    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7577        Self::new(inner)
7578    }
7579
7580    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7581        self.client.into_channel().map_err(|client| Self { client })
7582    }
7583
7584    fn as_channel(&self) -> &::fidl::AsyncChannel {
7585        self.client.as_channel()
7586    }
7587}
7588
7589impl TerminaGuestManagerProxy {
7590    /// Create a new Proxy for fuchsia.virtualization/TerminaGuestManager.
7591    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7592        let protocol_name =
7593            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7594        Self { client: fidl::client::Client::new(channel, protocol_name) }
7595    }
7596
7597    /// Get a Stream of events from the remote end of the protocol.
7598    ///
7599    /// # Panics
7600    ///
7601    /// Panics if the event stream was already taken.
7602    pub fn take_event_stream(&self) -> TerminaGuestManagerEventStream {
7603        TerminaGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
7604    }
7605
7606    /// Launch a new guest instance.
7607    ///
7608    /// Possible errors:
7609    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7610    ///         problems detected by the guest manager.
7611    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7612    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7613    ///         component logs for a more specific failure.
7614    pub fn r#launch(
7615        &self,
7616        mut guest_config: GuestConfig,
7617        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7618    ) -> fidl::client::QueryResponseFut<
7619        GuestManagerLaunchResult,
7620        fidl::encoding::DefaultFuchsiaResourceDialect,
7621    > {
7622        TerminaGuestManagerProxyInterface::r#launch(self, guest_config, controller)
7623    }
7624
7625    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7626    /// be used to launch another guest.
7627    pub fn r#force_shutdown(
7628        &self,
7629    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7630        TerminaGuestManagerProxyInterface::r#force_shutdown(self)
7631    }
7632
7633    /// Connect to a currently running guest.
7634    ///
7635    /// Possible errors:
7636    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7637    ///         has launched before attempting to reconnect.
7638    pub fn r#connect(
7639        &self,
7640        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7641    ) -> fidl::client::QueryResponseFut<
7642        GuestManagerConnectResult,
7643        fidl::encoding::DefaultFuchsiaResourceDialect,
7644    > {
7645        TerminaGuestManagerProxyInterface::r#connect(self, controller)
7646    }
7647
7648    /// Query guest info
7649    pub fn r#get_info(
7650        &self,
7651    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
7652    {
7653        TerminaGuestManagerProxyInterface::r#get_info(self)
7654    }
7655}
7656
7657impl TerminaGuestManagerProxyInterface for TerminaGuestManagerProxy {
7658    type LaunchResponseFut = fidl::client::QueryResponseFut<
7659        GuestManagerLaunchResult,
7660        fidl::encoding::DefaultFuchsiaResourceDialect,
7661    >;
7662    fn r#launch(
7663        &self,
7664        mut guest_config: GuestConfig,
7665        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7666    ) -> Self::LaunchResponseFut {
7667        fn _decode(
7668            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7669        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7670            let _response = fidl::client::decode_transaction_body::<
7671                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7672                fidl::encoding::DefaultFuchsiaResourceDialect,
7673                0x394a2e29f750323e,
7674            >(_buf?)?;
7675            Ok(_response.map(|x| x))
7676        }
7677        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
7678            (&mut guest_config, controller),
7679            0x394a2e29f750323e,
7680            fidl::encoding::DynamicFlags::empty(),
7681            _decode,
7682        )
7683    }
7684
7685    type ForceShutdownResponseFut =
7686        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7687    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
7688        fn _decode(
7689            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7690        ) -> Result<(), fidl::Error> {
7691            let _response = fidl::client::decode_transaction_body::<
7692                fidl::encoding::EmptyPayload,
7693                fidl::encoding::DefaultFuchsiaResourceDialect,
7694                0x3ad9a012982f872d,
7695            >(_buf?)?;
7696            Ok(_response)
7697        }
7698        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7699            (),
7700            0x3ad9a012982f872d,
7701            fidl::encoding::DynamicFlags::empty(),
7702            _decode,
7703        )
7704    }
7705
7706    type ConnectResponseFut = fidl::client::QueryResponseFut<
7707        GuestManagerConnectResult,
7708        fidl::encoding::DefaultFuchsiaResourceDialect,
7709    >;
7710    fn r#connect(
7711        &self,
7712        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7713    ) -> Self::ConnectResponseFut {
7714        fn _decode(
7715            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7716        ) -> Result<GuestManagerConnectResult, fidl::Error> {
7717            let _response = fidl::client::decode_transaction_body::<
7718                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7719                fidl::encoding::DefaultFuchsiaResourceDialect,
7720                0x4e489076e3bb15b4,
7721            >(_buf?)?;
7722            Ok(_response.map(|x| x))
7723        }
7724        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
7725            (controller,),
7726            0x4e489076e3bb15b4,
7727            fidl::encoding::DynamicFlags::empty(),
7728            _decode,
7729        )
7730    }
7731
7732    type GetInfoResponseFut =
7733        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
7734    fn r#get_info(&self) -> Self::GetInfoResponseFut {
7735        fn _decode(
7736            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7737        ) -> Result<GuestInfo, fidl::Error> {
7738            let _response = fidl::client::decode_transaction_body::<
7739                GuestManagerGetInfoResponse,
7740                fidl::encoding::DefaultFuchsiaResourceDialect,
7741                0x76892614aea695dc,
7742            >(_buf?)?;
7743            Ok(_response.guest_info)
7744        }
7745        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
7746            (),
7747            0x76892614aea695dc,
7748            fidl::encoding::DynamicFlags::empty(),
7749            _decode,
7750        )
7751    }
7752}
7753
7754pub struct TerminaGuestManagerEventStream {
7755    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7756}
7757
7758impl std::marker::Unpin for TerminaGuestManagerEventStream {}
7759
7760impl futures::stream::FusedStream for TerminaGuestManagerEventStream {
7761    fn is_terminated(&self) -> bool {
7762        self.event_receiver.is_terminated()
7763    }
7764}
7765
7766impl futures::Stream for TerminaGuestManagerEventStream {
7767    type Item = Result<TerminaGuestManagerEvent, fidl::Error>;
7768
7769    fn poll_next(
7770        mut self: std::pin::Pin<&mut Self>,
7771        cx: &mut std::task::Context<'_>,
7772    ) -> std::task::Poll<Option<Self::Item>> {
7773        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7774            &mut self.event_receiver,
7775            cx
7776        )?) {
7777            Some(buf) => std::task::Poll::Ready(Some(TerminaGuestManagerEvent::decode(buf))),
7778            None => std::task::Poll::Ready(None),
7779        }
7780    }
7781}
7782
7783#[derive(Debug)]
7784pub enum TerminaGuestManagerEvent {}
7785
7786impl TerminaGuestManagerEvent {
7787    /// Decodes a message buffer as a [`TerminaGuestManagerEvent`].
7788    fn decode(
7789        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7790    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7791        let (bytes, _handles) = buf.split_mut();
7792        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7793        debug_assert_eq!(tx_header.tx_id, 0);
7794        match tx_header.ordinal {
7795            _ => Err(fidl::Error::UnknownOrdinal {
7796                ordinal: tx_header.ordinal,
7797                protocol_name:
7798                    <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7799            }),
7800        }
7801    }
7802}
7803
7804/// A Stream of incoming requests for fuchsia.virtualization/TerminaGuestManager.
7805pub struct TerminaGuestManagerRequestStream {
7806    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7807    is_terminated: bool,
7808}
7809
7810impl std::marker::Unpin for TerminaGuestManagerRequestStream {}
7811
7812impl futures::stream::FusedStream for TerminaGuestManagerRequestStream {
7813    fn is_terminated(&self) -> bool {
7814        self.is_terminated
7815    }
7816}
7817
7818impl fidl::endpoints::RequestStream for TerminaGuestManagerRequestStream {
7819    type Protocol = TerminaGuestManagerMarker;
7820    type ControlHandle = TerminaGuestManagerControlHandle;
7821
7822    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7823        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7824    }
7825
7826    fn control_handle(&self) -> Self::ControlHandle {
7827        TerminaGuestManagerControlHandle { inner: self.inner.clone() }
7828    }
7829
7830    fn into_inner(
7831        self,
7832    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7833    {
7834        (self.inner, self.is_terminated)
7835    }
7836
7837    fn from_inner(
7838        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7839        is_terminated: bool,
7840    ) -> Self {
7841        Self { inner, is_terminated }
7842    }
7843}
7844
7845impl futures::Stream for TerminaGuestManagerRequestStream {
7846    type Item = Result<TerminaGuestManagerRequest, fidl::Error>;
7847
7848    fn poll_next(
7849        mut self: std::pin::Pin<&mut Self>,
7850        cx: &mut std::task::Context<'_>,
7851    ) -> std::task::Poll<Option<Self::Item>> {
7852        let this = &mut *self;
7853        if this.inner.check_shutdown(cx) {
7854            this.is_terminated = true;
7855            return std::task::Poll::Ready(None);
7856        }
7857        if this.is_terminated {
7858            panic!("polled TerminaGuestManagerRequestStream after completion");
7859        }
7860        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7861            |bytes, handles| {
7862                match this.inner.channel().read_etc(cx, bytes, handles) {
7863                    std::task::Poll::Ready(Ok(())) => {}
7864                    std::task::Poll::Pending => return std::task::Poll::Pending,
7865                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7866                        this.is_terminated = true;
7867                        return std::task::Poll::Ready(None);
7868                    }
7869                    std::task::Poll::Ready(Err(e)) => {
7870                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7871                            e.into(),
7872                        ))));
7873                    }
7874                }
7875
7876                // A message has been received from the channel
7877                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7878
7879                std::task::Poll::Ready(Some(match header.ordinal {
7880                0x394a2e29f750323e => {
7881                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7882                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7883                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
7884                    let control_handle = TerminaGuestManagerControlHandle {
7885                        inner: this.inner.clone(),
7886                    };
7887                    Ok(TerminaGuestManagerRequest::Launch {guest_config: req.guest_config,
7888controller: req.controller,
7889
7890                        responder: TerminaGuestManagerLaunchResponder {
7891                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7892                            tx_id: header.tx_id,
7893                        },
7894                    })
7895                }
7896                0x3ad9a012982f872d => {
7897                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7898                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7899                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7900                    let control_handle = TerminaGuestManagerControlHandle {
7901                        inner: this.inner.clone(),
7902                    };
7903                    Ok(TerminaGuestManagerRequest::ForceShutdown {
7904                        responder: TerminaGuestManagerForceShutdownResponder {
7905                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7906                            tx_id: header.tx_id,
7907                        },
7908                    })
7909                }
7910                0x4e489076e3bb15b4 => {
7911                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7912                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7913                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
7914                    let control_handle = TerminaGuestManagerControlHandle {
7915                        inner: this.inner.clone(),
7916                    };
7917                    Ok(TerminaGuestManagerRequest::Connect {controller: req.controller,
7918
7919                        responder: TerminaGuestManagerConnectResponder {
7920                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7921                            tx_id: header.tx_id,
7922                        },
7923                    })
7924                }
7925                0x76892614aea695dc => {
7926                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7927                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7928                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7929                    let control_handle = TerminaGuestManagerControlHandle {
7930                        inner: this.inner.clone(),
7931                    };
7932                    Ok(TerminaGuestManagerRequest::GetInfo {
7933                        responder: TerminaGuestManagerGetInfoResponder {
7934                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7935                            tx_id: header.tx_id,
7936                        },
7937                    })
7938                }
7939                _ => Err(fidl::Error::UnknownOrdinal {
7940                    ordinal: header.ordinal,
7941                    protocol_name: <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7942                }),
7943            }))
7944            },
7945        )
7946    }
7947}
7948
7949#[derive(Debug)]
7950pub enum TerminaGuestManagerRequest {
7951    /// Launch a new guest instance.
7952    ///
7953    /// Possible errors:
7954    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7955    ///         problems detected by the guest manager.
7956    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7957    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7958    ///         component logs for a more specific failure.
7959    Launch {
7960        guest_config: GuestConfig,
7961        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7962        responder: TerminaGuestManagerLaunchResponder,
7963    },
7964    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7965    /// be used to launch another guest.
7966    ForceShutdown { responder: TerminaGuestManagerForceShutdownResponder },
7967    /// Connect to a currently running guest.
7968    ///
7969    /// Possible errors:
7970    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7971    ///         has launched before attempting to reconnect.
7972    Connect {
7973        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7974        responder: TerminaGuestManagerConnectResponder,
7975    },
7976    /// Query guest info
7977    GetInfo { responder: TerminaGuestManagerGetInfoResponder },
7978}
7979
7980impl TerminaGuestManagerRequest {
7981    #[allow(irrefutable_let_patterns)]
7982    pub fn into_launch(
7983        self,
7984    ) -> Option<(
7985        GuestConfig,
7986        fidl::endpoints::ServerEnd<GuestMarker>,
7987        TerminaGuestManagerLaunchResponder,
7988    )> {
7989        if let TerminaGuestManagerRequest::Launch { guest_config, controller, responder } = self {
7990            Some((guest_config, controller, responder))
7991        } else {
7992            None
7993        }
7994    }
7995
7996    #[allow(irrefutable_let_patterns)]
7997    pub fn into_force_shutdown(self) -> Option<(TerminaGuestManagerForceShutdownResponder)> {
7998        if let TerminaGuestManagerRequest::ForceShutdown { responder } = self {
7999            Some((responder))
8000        } else {
8001            None
8002        }
8003    }
8004
8005    #[allow(irrefutable_let_patterns)]
8006    pub fn into_connect(
8007        self,
8008    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, TerminaGuestManagerConnectResponder)>
8009    {
8010        if let TerminaGuestManagerRequest::Connect { controller, responder } = self {
8011            Some((controller, responder))
8012        } else {
8013            None
8014        }
8015    }
8016
8017    #[allow(irrefutable_let_patterns)]
8018    pub fn into_get_info(self) -> Option<(TerminaGuestManagerGetInfoResponder)> {
8019        if let TerminaGuestManagerRequest::GetInfo { responder } = self {
8020            Some((responder))
8021        } else {
8022            None
8023        }
8024    }
8025
8026    /// Name of the method defined in FIDL
8027    pub fn method_name(&self) -> &'static str {
8028        match *self {
8029            TerminaGuestManagerRequest::Launch { .. } => "launch",
8030            TerminaGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
8031            TerminaGuestManagerRequest::Connect { .. } => "connect",
8032            TerminaGuestManagerRequest::GetInfo { .. } => "get_info",
8033        }
8034    }
8035}
8036
8037#[derive(Debug, Clone)]
8038pub struct TerminaGuestManagerControlHandle {
8039    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8040}
8041
8042impl TerminaGuestManagerControlHandle {
8043    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
8044        self.inner.shutdown_with_epitaph(status.into())
8045    }
8046}
8047
8048impl fidl::endpoints::ControlHandle for TerminaGuestManagerControlHandle {
8049    fn shutdown(&self) {
8050        self.inner.shutdown()
8051    }
8052
8053    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
8054        self.inner.shutdown_with_epitaph(status)
8055    }
8056
8057    fn is_closed(&self) -> bool {
8058        self.inner.channel().is_closed()
8059    }
8060    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8061        self.inner.channel().on_closed()
8062    }
8063
8064    #[cfg(target_os = "fuchsia")]
8065    fn signal_peer(
8066        &self,
8067        clear_mask: zx::Signals,
8068        set_mask: zx::Signals,
8069    ) -> Result<(), zx_status::Status> {
8070        use fidl::Peered;
8071        self.inner.channel().signal_peer(clear_mask, set_mask)
8072    }
8073}
8074
8075impl TerminaGuestManagerControlHandle {}
8076
8077#[must_use = "FIDL methods require a response to be sent"]
8078#[derive(Debug)]
8079pub struct TerminaGuestManagerLaunchResponder {
8080    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8081    tx_id: u32,
8082}
8083
8084/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8085/// if the responder is dropped without sending a response, so that the client
8086/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8087impl std::ops::Drop for TerminaGuestManagerLaunchResponder {
8088    fn drop(&mut self) {
8089        self.control_handle.shutdown();
8090        // Safety: drops once, never accessed again
8091        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8092    }
8093}
8094
8095impl fidl::endpoints::Responder for TerminaGuestManagerLaunchResponder {
8096    type ControlHandle = TerminaGuestManagerControlHandle;
8097
8098    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8099        &self.control_handle
8100    }
8101
8102    fn drop_without_shutdown(mut self) {
8103        // Safety: drops once, never accessed again due to mem::forget
8104        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8105        // Prevent Drop from running (which would shut down the channel)
8106        std::mem::forget(self);
8107    }
8108}
8109
8110impl TerminaGuestManagerLaunchResponder {
8111    /// Sends a response to the FIDL transaction.
8112    ///
8113    /// Sets the channel to shutdown if an error occurs.
8114    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8115        let _result = self.send_raw(result);
8116        if _result.is_err() {
8117            self.control_handle.shutdown();
8118        }
8119        self.drop_without_shutdown();
8120        _result
8121    }
8122
8123    /// Similar to "send" but does not shutdown the channel if an error occurs.
8124    pub fn send_no_shutdown_on_err(
8125        self,
8126        mut result: Result<(), GuestManagerError>,
8127    ) -> Result<(), fidl::Error> {
8128        let _result = self.send_raw(result);
8129        self.drop_without_shutdown();
8130        _result
8131    }
8132
8133    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8134        self.control_handle.inner.send::<fidl::encoding::ResultType<
8135            fidl::encoding::EmptyStruct,
8136            GuestManagerError,
8137        >>(
8138            result,
8139            self.tx_id,
8140            0x394a2e29f750323e,
8141            fidl::encoding::DynamicFlags::empty(),
8142        )
8143    }
8144}
8145
8146#[must_use = "FIDL methods require a response to be sent"]
8147#[derive(Debug)]
8148pub struct TerminaGuestManagerForceShutdownResponder {
8149    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8150    tx_id: u32,
8151}
8152
8153/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8154/// if the responder is dropped without sending a response, so that the client
8155/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8156impl std::ops::Drop for TerminaGuestManagerForceShutdownResponder {
8157    fn drop(&mut self) {
8158        self.control_handle.shutdown();
8159        // Safety: drops once, never accessed again
8160        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8161    }
8162}
8163
8164impl fidl::endpoints::Responder for TerminaGuestManagerForceShutdownResponder {
8165    type ControlHandle = TerminaGuestManagerControlHandle;
8166
8167    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8168        &self.control_handle
8169    }
8170
8171    fn drop_without_shutdown(mut self) {
8172        // Safety: drops once, never accessed again due to mem::forget
8173        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8174        // Prevent Drop from running (which would shut down the channel)
8175        std::mem::forget(self);
8176    }
8177}
8178
8179impl TerminaGuestManagerForceShutdownResponder {
8180    /// Sends a response to the FIDL transaction.
8181    ///
8182    /// Sets the channel to shutdown if an error occurs.
8183    pub fn send(self) -> Result<(), fidl::Error> {
8184        let _result = self.send_raw();
8185        if _result.is_err() {
8186            self.control_handle.shutdown();
8187        }
8188        self.drop_without_shutdown();
8189        _result
8190    }
8191
8192    /// Similar to "send" but does not shutdown the channel if an error occurs.
8193    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8194        let _result = self.send_raw();
8195        self.drop_without_shutdown();
8196        _result
8197    }
8198
8199    fn send_raw(&self) -> Result<(), fidl::Error> {
8200        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8201            (),
8202            self.tx_id,
8203            0x3ad9a012982f872d,
8204            fidl::encoding::DynamicFlags::empty(),
8205        )
8206    }
8207}
8208
8209#[must_use = "FIDL methods require a response to be sent"]
8210#[derive(Debug)]
8211pub struct TerminaGuestManagerConnectResponder {
8212    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8213    tx_id: u32,
8214}
8215
8216/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8217/// if the responder is dropped without sending a response, so that the client
8218/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8219impl std::ops::Drop for TerminaGuestManagerConnectResponder {
8220    fn drop(&mut self) {
8221        self.control_handle.shutdown();
8222        // Safety: drops once, never accessed again
8223        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8224    }
8225}
8226
8227impl fidl::endpoints::Responder for TerminaGuestManagerConnectResponder {
8228    type ControlHandle = TerminaGuestManagerControlHandle;
8229
8230    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8231        &self.control_handle
8232    }
8233
8234    fn drop_without_shutdown(mut self) {
8235        // Safety: drops once, never accessed again due to mem::forget
8236        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8237        // Prevent Drop from running (which would shut down the channel)
8238        std::mem::forget(self);
8239    }
8240}
8241
8242impl TerminaGuestManagerConnectResponder {
8243    /// Sends a response to the FIDL transaction.
8244    ///
8245    /// Sets the channel to shutdown if an error occurs.
8246    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8247        let _result = self.send_raw(result);
8248        if _result.is_err() {
8249            self.control_handle.shutdown();
8250        }
8251        self.drop_without_shutdown();
8252        _result
8253    }
8254
8255    /// Similar to "send" but does not shutdown the channel if an error occurs.
8256    pub fn send_no_shutdown_on_err(
8257        self,
8258        mut result: Result<(), GuestManagerError>,
8259    ) -> Result<(), fidl::Error> {
8260        let _result = self.send_raw(result);
8261        self.drop_without_shutdown();
8262        _result
8263    }
8264
8265    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8266        self.control_handle.inner.send::<fidl::encoding::ResultType<
8267            fidl::encoding::EmptyStruct,
8268            GuestManagerError,
8269        >>(
8270            result,
8271            self.tx_id,
8272            0x4e489076e3bb15b4,
8273            fidl::encoding::DynamicFlags::empty(),
8274        )
8275    }
8276}
8277
8278#[must_use = "FIDL methods require a response to be sent"]
8279#[derive(Debug)]
8280pub struct TerminaGuestManagerGetInfoResponder {
8281    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8282    tx_id: u32,
8283}
8284
8285/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8286/// if the responder is dropped without sending a response, so that the client
8287/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8288impl std::ops::Drop for TerminaGuestManagerGetInfoResponder {
8289    fn drop(&mut self) {
8290        self.control_handle.shutdown();
8291        // Safety: drops once, never accessed again
8292        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8293    }
8294}
8295
8296impl fidl::endpoints::Responder for TerminaGuestManagerGetInfoResponder {
8297    type ControlHandle = TerminaGuestManagerControlHandle;
8298
8299    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8300        &self.control_handle
8301    }
8302
8303    fn drop_without_shutdown(mut self) {
8304        // Safety: drops once, never accessed again due to mem::forget
8305        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8306        // Prevent Drop from running (which would shut down the channel)
8307        std::mem::forget(self);
8308    }
8309}
8310
8311impl TerminaGuestManagerGetInfoResponder {
8312    /// Sends a response to the FIDL transaction.
8313    ///
8314    /// Sets the channel to shutdown if an error occurs.
8315    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8316        let _result = self.send_raw(guest_info);
8317        if _result.is_err() {
8318            self.control_handle.shutdown();
8319        }
8320        self.drop_without_shutdown();
8321        _result
8322    }
8323
8324    /// Similar to "send" but does not shutdown the channel if an error occurs.
8325    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8326        let _result = self.send_raw(guest_info);
8327        self.drop_without_shutdown();
8328        _result
8329    }
8330
8331    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8332        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
8333            (guest_info,),
8334            self.tx_id,
8335            0x76892614aea695dc,
8336            fidl::encoding::DynamicFlags::empty(),
8337        )
8338    }
8339}
8340
8341#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8342pub struct ZirconGuestManagerMarker;
8343
8344impl fidl::endpoints::ProtocolMarker for ZirconGuestManagerMarker {
8345    type Proxy = ZirconGuestManagerProxy;
8346    type RequestStream = ZirconGuestManagerRequestStream;
8347    #[cfg(target_os = "fuchsia")]
8348    type SynchronousProxy = ZirconGuestManagerSynchronousProxy;
8349
8350    const DEBUG_NAME: &'static str = "fuchsia.virtualization.ZirconGuestManager";
8351}
8352impl fidl::endpoints::DiscoverableProtocolMarker for ZirconGuestManagerMarker {}
8353
8354pub trait ZirconGuestManagerProxyInterface: Send + Sync {
8355    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
8356        + Send;
8357    fn r#launch(
8358        &self,
8359        guest_config: GuestConfig,
8360        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8361    ) -> Self::LaunchResponseFut;
8362    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8363    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
8364    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
8365        + Send;
8366    fn r#connect(
8367        &self,
8368        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8369    ) -> Self::ConnectResponseFut;
8370    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
8371    fn r#get_info(&self) -> Self::GetInfoResponseFut;
8372}
8373#[derive(Debug)]
8374#[cfg(target_os = "fuchsia")]
8375pub struct ZirconGuestManagerSynchronousProxy {
8376    client: fidl::client::sync::Client,
8377}
8378
8379#[cfg(target_os = "fuchsia")]
8380impl fidl::endpoints::SynchronousProxy for ZirconGuestManagerSynchronousProxy {
8381    type Proxy = ZirconGuestManagerProxy;
8382    type Protocol = ZirconGuestManagerMarker;
8383
8384    fn from_channel(inner: fidl::Channel) -> Self {
8385        Self::new(inner)
8386    }
8387
8388    fn into_channel(self) -> fidl::Channel {
8389        self.client.into_channel()
8390    }
8391
8392    fn as_channel(&self) -> &fidl::Channel {
8393        self.client.as_channel()
8394    }
8395}
8396
8397#[cfg(target_os = "fuchsia")]
8398impl ZirconGuestManagerSynchronousProxy {
8399    pub fn new(channel: fidl::Channel) -> Self {
8400        Self { client: fidl::client::sync::Client::new(channel) }
8401    }
8402
8403    pub fn into_channel(self) -> fidl::Channel {
8404        self.client.into_channel()
8405    }
8406
8407    /// Waits until an event arrives and returns it. It is safe for other
8408    /// threads to make concurrent requests while waiting for an event.
8409    pub fn wait_for_event(
8410        &self,
8411        deadline: zx::MonotonicInstant,
8412    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8413        ZirconGuestManagerEvent::decode(
8414            self.client.wait_for_event::<ZirconGuestManagerMarker>(deadline)?,
8415        )
8416    }
8417
8418    /// Launch a new guest instance.
8419    ///
8420    /// Possible errors:
8421    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8422    ///         problems detected by the guest manager.
8423    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8424    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8425    ///         component logs for a more specific failure.
8426    pub fn r#launch(
8427        &self,
8428        mut guest_config: GuestConfig,
8429        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8430        ___deadline: zx::MonotonicInstant,
8431    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8432        let _response =
8433            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
8434                fidl::encoding::EmptyStruct,
8435                GuestManagerError,
8436            >, ZirconGuestManagerMarker>(
8437                (&mut guest_config, controller),
8438                0x394a2e29f750323e,
8439                fidl::encoding::DynamicFlags::empty(),
8440                ___deadline,
8441            )?;
8442        Ok(_response.map(|x| x))
8443    }
8444
8445    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8446    /// be used to launch another guest.
8447    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
8448        let _response = self.client.send_query::<
8449            fidl::encoding::EmptyPayload,
8450            fidl::encoding::EmptyPayload,
8451            ZirconGuestManagerMarker,
8452        >(
8453            (),
8454            0x3ad9a012982f872d,
8455            fidl::encoding::DynamicFlags::empty(),
8456            ___deadline,
8457        )?;
8458        Ok(_response)
8459    }
8460
8461    /// Connect to a currently running guest.
8462    ///
8463    /// Possible errors:
8464    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8465    ///         has launched before attempting to reconnect.
8466    pub fn r#connect(
8467        &self,
8468        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8469        ___deadline: zx::MonotonicInstant,
8470    ) -> Result<GuestManagerConnectResult, fidl::Error> {
8471        let _response =
8472            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
8473                fidl::encoding::EmptyStruct,
8474                GuestManagerError,
8475            >, ZirconGuestManagerMarker>(
8476                (controller,),
8477                0x4e489076e3bb15b4,
8478                fidl::encoding::DynamicFlags::empty(),
8479                ___deadline,
8480            )?;
8481        Ok(_response.map(|x| x))
8482    }
8483
8484    /// Query guest info
8485    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
8486        let _response = self.client.send_query::<
8487            fidl::encoding::EmptyPayload,
8488            GuestManagerGetInfoResponse,
8489            ZirconGuestManagerMarker,
8490        >(
8491            (),
8492            0x76892614aea695dc,
8493            fidl::encoding::DynamicFlags::empty(),
8494            ___deadline,
8495        )?;
8496        Ok(_response.guest_info)
8497    }
8498}
8499
8500#[cfg(target_os = "fuchsia")]
8501impl From<ZirconGuestManagerSynchronousProxy> for zx::NullableHandle {
8502    fn from(value: ZirconGuestManagerSynchronousProxy) -> Self {
8503        value.into_channel().into()
8504    }
8505}
8506
8507#[cfg(target_os = "fuchsia")]
8508impl From<fidl::Channel> for ZirconGuestManagerSynchronousProxy {
8509    fn from(value: fidl::Channel) -> Self {
8510        Self::new(value)
8511    }
8512}
8513
8514#[cfg(target_os = "fuchsia")]
8515impl fidl::endpoints::FromClient for ZirconGuestManagerSynchronousProxy {
8516    type Protocol = ZirconGuestManagerMarker;
8517
8518    fn from_client(value: fidl::endpoints::ClientEnd<ZirconGuestManagerMarker>) -> Self {
8519        Self::new(value.into_channel())
8520    }
8521}
8522
8523#[derive(Debug, Clone)]
8524pub struct ZirconGuestManagerProxy {
8525    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8526}
8527
8528impl fidl::endpoints::Proxy for ZirconGuestManagerProxy {
8529    type Protocol = ZirconGuestManagerMarker;
8530
8531    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8532        Self::new(inner)
8533    }
8534
8535    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8536        self.client.into_channel().map_err(|client| Self { client })
8537    }
8538
8539    fn as_channel(&self) -> &::fidl::AsyncChannel {
8540        self.client.as_channel()
8541    }
8542}
8543
8544impl ZirconGuestManagerProxy {
8545    /// Create a new Proxy for fuchsia.virtualization/ZirconGuestManager.
8546    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8547        let protocol_name =
8548            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8549        Self { client: fidl::client::Client::new(channel, protocol_name) }
8550    }
8551
8552    /// Get a Stream of events from the remote end of the protocol.
8553    ///
8554    /// # Panics
8555    ///
8556    /// Panics if the event stream was already taken.
8557    pub fn take_event_stream(&self) -> ZirconGuestManagerEventStream {
8558        ZirconGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
8559    }
8560
8561    /// Launch a new guest instance.
8562    ///
8563    /// Possible errors:
8564    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8565    ///         problems detected by the guest manager.
8566    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8567    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8568    ///         component logs for a more specific failure.
8569    pub fn r#launch(
8570        &self,
8571        mut guest_config: GuestConfig,
8572        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8573    ) -> fidl::client::QueryResponseFut<
8574        GuestManagerLaunchResult,
8575        fidl::encoding::DefaultFuchsiaResourceDialect,
8576    > {
8577        ZirconGuestManagerProxyInterface::r#launch(self, guest_config, controller)
8578    }
8579
8580    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8581    /// be used to launch another guest.
8582    pub fn r#force_shutdown(
8583        &self,
8584    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8585        ZirconGuestManagerProxyInterface::r#force_shutdown(self)
8586    }
8587
8588    /// Connect to a currently running guest.
8589    ///
8590    /// Possible errors:
8591    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8592    ///         has launched before attempting to reconnect.
8593    pub fn r#connect(
8594        &self,
8595        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8596    ) -> fidl::client::QueryResponseFut<
8597        GuestManagerConnectResult,
8598        fidl::encoding::DefaultFuchsiaResourceDialect,
8599    > {
8600        ZirconGuestManagerProxyInterface::r#connect(self, controller)
8601    }
8602
8603    /// Query guest info
8604    pub fn r#get_info(
8605        &self,
8606    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
8607    {
8608        ZirconGuestManagerProxyInterface::r#get_info(self)
8609    }
8610}
8611
8612impl ZirconGuestManagerProxyInterface for ZirconGuestManagerProxy {
8613    type LaunchResponseFut = fidl::client::QueryResponseFut<
8614        GuestManagerLaunchResult,
8615        fidl::encoding::DefaultFuchsiaResourceDialect,
8616    >;
8617    fn r#launch(
8618        &self,
8619        mut guest_config: GuestConfig,
8620        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8621    ) -> Self::LaunchResponseFut {
8622        fn _decode(
8623            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8624        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8625            let _response = fidl::client::decode_transaction_body::<
8626                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8627                fidl::encoding::DefaultFuchsiaResourceDialect,
8628                0x394a2e29f750323e,
8629            >(_buf?)?;
8630            Ok(_response.map(|x| x))
8631        }
8632        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
8633            (&mut guest_config, controller),
8634            0x394a2e29f750323e,
8635            fidl::encoding::DynamicFlags::empty(),
8636            _decode,
8637        )
8638    }
8639
8640    type ForceShutdownResponseFut =
8641        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8642    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
8643        fn _decode(
8644            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8645        ) -> Result<(), fidl::Error> {
8646            let _response = fidl::client::decode_transaction_body::<
8647                fidl::encoding::EmptyPayload,
8648                fidl::encoding::DefaultFuchsiaResourceDialect,
8649                0x3ad9a012982f872d,
8650            >(_buf?)?;
8651            Ok(_response)
8652        }
8653        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
8654            (),
8655            0x3ad9a012982f872d,
8656            fidl::encoding::DynamicFlags::empty(),
8657            _decode,
8658        )
8659    }
8660
8661    type ConnectResponseFut = fidl::client::QueryResponseFut<
8662        GuestManagerConnectResult,
8663        fidl::encoding::DefaultFuchsiaResourceDialect,
8664    >;
8665    fn r#connect(
8666        &self,
8667        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8668    ) -> Self::ConnectResponseFut {
8669        fn _decode(
8670            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8671        ) -> Result<GuestManagerConnectResult, fidl::Error> {
8672            let _response = fidl::client::decode_transaction_body::<
8673                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8674                fidl::encoding::DefaultFuchsiaResourceDialect,
8675                0x4e489076e3bb15b4,
8676            >(_buf?)?;
8677            Ok(_response.map(|x| x))
8678        }
8679        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
8680            (controller,),
8681            0x4e489076e3bb15b4,
8682            fidl::encoding::DynamicFlags::empty(),
8683            _decode,
8684        )
8685    }
8686
8687    type GetInfoResponseFut =
8688        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
8689    fn r#get_info(&self) -> Self::GetInfoResponseFut {
8690        fn _decode(
8691            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8692        ) -> Result<GuestInfo, fidl::Error> {
8693            let _response = fidl::client::decode_transaction_body::<
8694                GuestManagerGetInfoResponse,
8695                fidl::encoding::DefaultFuchsiaResourceDialect,
8696                0x76892614aea695dc,
8697            >(_buf?)?;
8698            Ok(_response.guest_info)
8699        }
8700        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
8701            (),
8702            0x76892614aea695dc,
8703            fidl::encoding::DynamicFlags::empty(),
8704            _decode,
8705        )
8706    }
8707}
8708
8709pub struct ZirconGuestManagerEventStream {
8710    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8711}
8712
8713impl std::marker::Unpin for ZirconGuestManagerEventStream {}
8714
8715impl futures::stream::FusedStream for ZirconGuestManagerEventStream {
8716    fn is_terminated(&self) -> bool {
8717        self.event_receiver.is_terminated()
8718    }
8719}
8720
8721impl futures::Stream for ZirconGuestManagerEventStream {
8722    type Item = Result<ZirconGuestManagerEvent, fidl::Error>;
8723
8724    fn poll_next(
8725        mut self: std::pin::Pin<&mut Self>,
8726        cx: &mut std::task::Context<'_>,
8727    ) -> std::task::Poll<Option<Self::Item>> {
8728        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8729            &mut self.event_receiver,
8730            cx
8731        )?) {
8732            Some(buf) => std::task::Poll::Ready(Some(ZirconGuestManagerEvent::decode(buf))),
8733            None => std::task::Poll::Ready(None),
8734        }
8735    }
8736}
8737
8738#[derive(Debug)]
8739pub enum ZirconGuestManagerEvent {}
8740
8741impl ZirconGuestManagerEvent {
8742    /// Decodes a message buffer as a [`ZirconGuestManagerEvent`].
8743    fn decode(
8744        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8745    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8746        let (bytes, _handles) = buf.split_mut();
8747        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8748        debug_assert_eq!(tx_header.tx_id, 0);
8749        match tx_header.ordinal {
8750            _ => Err(fidl::Error::UnknownOrdinal {
8751                ordinal: tx_header.ordinal,
8752                protocol_name:
8753                    <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8754            }),
8755        }
8756    }
8757}
8758
8759/// A Stream of incoming requests for fuchsia.virtualization/ZirconGuestManager.
8760pub struct ZirconGuestManagerRequestStream {
8761    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8762    is_terminated: bool,
8763}
8764
8765impl std::marker::Unpin for ZirconGuestManagerRequestStream {}
8766
8767impl futures::stream::FusedStream for ZirconGuestManagerRequestStream {
8768    fn is_terminated(&self) -> bool {
8769        self.is_terminated
8770    }
8771}
8772
8773impl fidl::endpoints::RequestStream for ZirconGuestManagerRequestStream {
8774    type Protocol = ZirconGuestManagerMarker;
8775    type ControlHandle = ZirconGuestManagerControlHandle;
8776
8777    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8778        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8779    }
8780
8781    fn control_handle(&self) -> Self::ControlHandle {
8782        ZirconGuestManagerControlHandle { inner: self.inner.clone() }
8783    }
8784
8785    fn into_inner(
8786        self,
8787    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8788    {
8789        (self.inner, self.is_terminated)
8790    }
8791
8792    fn from_inner(
8793        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8794        is_terminated: bool,
8795    ) -> Self {
8796        Self { inner, is_terminated }
8797    }
8798}
8799
8800impl futures::Stream for ZirconGuestManagerRequestStream {
8801    type Item = Result<ZirconGuestManagerRequest, fidl::Error>;
8802
8803    fn poll_next(
8804        mut self: std::pin::Pin<&mut Self>,
8805        cx: &mut std::task::Context<'_>,
8806    ) -> std::task::Poll<Option<Self::Item>> {
8807        let this = &mut *self;
8808        if this.inner.check_shutdown(cx) {
8809            this.is_terminated = true;
8810            return std::task::Poll::Ready(None);
8811        }
8812        if this.is_terminated {
8813            panic!("polled ZirconGuestManagerRequestStream after completion");
8814        }
8815        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8816            |bytes, handles| {
8817                match this.inner.channel().read_etc(cx, bytes, handles) {
8818                    std::task::Poll::Ready(Ok(())) => {}
8819                    std::task::Poll::Pending => return std::task::Poll::Pending,
8820                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8821                        this.is_terminated = true;
8822                        return std::task::Poll::Ready(None);
8823                    }
8824                    std::task::Poll::Ready(Err(e)) => {
8825                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8826                            e.into(),
8827                        ))));
8828                    }
8829                }
8830
8831                // A message has been received from the channel
8832                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8833
8834                std::task::Poll::Ready(Some(match header.ordinal {
8835                0x394a2e29f750323e => {
8836                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8837                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8838                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
8839                    let control_handle = ZirconGuestManagerControlHandle {
8840                        inner: this.inner.clone(),
8841                    };
8842                    Ok(ZirconGuestManagerRequest::Launch {guest_config: req.guest_config,
8843controller: req.controller,
8844
8845                        responder: ZirconGuestManagerLaunchResponder {
8846                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8847                            tx_id: header.tx_id,
8848                        },
8849                    })
8850                }
8851                0x3ad9a012982f872d => {
8852                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8853                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8854                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8855                    let control_handle = ZirconGuestManagerControlHandle {
8856                        inner: this.inner.clone(),
8857                    };
8858                    Ok(ZirconGuestManagerRequest::ForceShutdown {
8859                        responder: ZirconGuestManagerForceShutdownResponder {
8860                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8861                            tx_id: header.tx_id,
8862                        },
8863                    })
8864                }
8865                0x4e489076e3bb15b4 => {
8866                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8867                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8868                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
8869                    let control_handle = ZirconGuestManagerControlHandle {
8870                        inner: this.inner.clone(),
8871                    };
8872                    Ok(ZirconGuestManagerRequest::Connect {controller: req.controller,
8873
8874                        responder: ZirconGuestManagerConnectResponder {
8875                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8876                            tx_id: header.tx_id,
8877                        },
8878                    })
8879                }
8880                0x76892614aea695dc => {
8881                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8882                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8883                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8884                    let control_handle = ZirconGuestManagerControlHandle {
8885                        inner: this.inner.clone(),
8886                    };
8887                    Ok(ZirconGuestManagerRequest::GetInfo {
8888                        responder: ZirconGuestManagerGetInfoResponder {
8889                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8890                            tx_id: header.tx_id,
8891                        },
8892                    })
8893                }
8894                _ => Err(fidl::Error::UnknownOrdinal {
8895                    ordinal: header.ordinal,
8896                    protocol_name: <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8897                }),
8898            }))
8899            },
8900        )
8901    }
8902}
8903
8904#[derive(Debug)]
8905pub enum ZirconGuestManagerRequest {
8906    /// Launch a new guest instance.
8907    ///
8908    /// Possible errors:
8909    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8910    ///         problems detected by the guest manager.
8911    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8912    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8913    ///         component logs for a more specific failure.
8914    Launch {
8915        guest_config: GuestConfig,
8916        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8917        responder: ZirconGuestManagerLaunchResponder,
8918    },
8919    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8920    /// be used to launch another guest.
8921    ForceShutdown { responder: ZirconGuestManagerForceShutdownResponder },
8922    /// Connect to a currently running guest.
8923    ///
8924    /// Possible errors:
8925    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8926    ///         has launched before attempting to reconnect.
8927    Connect {
8928        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8929        responder: ZirconGuestManagerConnectResponder,
8930    },
8931    /// Query guest info
8932    GetInfo { responder: ZirconGuestManagerGetInfoResponder },
8933}
8934
8935impl ZirconGuestManagerRequest {
8936    #[allow(irrefutable_let_patterns)]
8937    pub fn into_launch(
8938        self,
8939    ) -> Option<(
8940        GuestConfig,
8941        fidl::endpoints::ServerEnd<GuestMarker>,
8942        ZirconGuestManagerLaunchResponder,
8943    )> {
8944        if let ZirconGuestManagerRequest::Launch { guest_config, controller, responder } = self {
8945            Some((guest_config, controller, responder))
8946        } else {
8947            None
8948        }
8949    }
8950
8951    #[allow(irrefutable_let_patterns)]
8952    pub fn into_force_shutdown(self) -> Option<(ZirconGuestManagerForceShutdownResponder)> {
8953        if let ZirconGuestManagerRequest::ForceShutdown { responder } = self {
8954            Some((responder))
8955        } else {
8956            None
8957        }
8958    }
8959
8960    #[allow(irrefutable_let_patterns)]
8961    pub fn into_connect(
8962        self,
8963    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, ZirconGuestManagerConnectResponder)> {
8964        if let ZirconGuestManagerRequest::Connect { controller, responder } = self {
8965            Some((controller, responder))
8966        } else {
8967            None
8968        }
8969    }
8970
8971    #[allow(irrefutable_let_patterns)]
8972    pub fn into_get_info(self) -> Option<(ZirconGuestManagerGetInfoResponder)> {
8973        if let ZirconGuestManagerRequest::GetInfo { responder } = self {
8974            Some((responder))
8975        } else {
8976            None
8977        }
8978    }
8979
8980    /// Name of the method defined in FIDL
8981    pub fn method_name(&self) -> &'static str {
8982        match *self {
8983            ZirconGuestManagerRequest::Launch { .. } => "launch",
8984            ZirconGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
8985            ZirconGuestManagerRequest::Connect { .. } => "connect",
8986            ZirconGuestManagerRequest::GetInfo { .. } => "get_info",
8987        }
8988    }
8989}
8990
8991#[derive(Debug, Clone)]
8992pub struct ZirconGuestManagerControlHandle {
8993    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8994}
8995
8996impl ZirconGuestManagerControlHandle {
8997    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
8998        self.inner.shutdown_with_epitaph(status.into())
8999    }
9000}
9001
9002impl fidl::endpoints::ControlHandle for ZirconGuestManagerControlHandle {
9003    fn shutdown(&self) {
9004        self.inner.shutdown()
9005    }
9006
9007    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
9008        self.inner.shutdown_with_epitaph(status)
9009    }
9010
9011    fn is_closed(&self) -> bool {
9012        self.inner.channel().is_closed()
9013    }
9014    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9015        self.inner.channel().on_closed()
9016    }
9017
9018    #[cfg(target_os = "fuchsia")]
9019    fn signal_peer(
9020        &self,
9021        clear_mask: zx::Signals,
9022        set_mask: zx::Signals,
9023    ) -> Result<(), zx_status::Status> {
9024        use fidl::Peered;
9025        self.inner.channel().signal_peer(clear_mask, set_mask)
9026    }
9027}
9028
9029impl ZirconGuestManagerControlHandle {}
9030
9031#[must_use = "FIDL methods require a response to be sent"]
9032#[derive(Debug)]
9033pub struct ZirconGuestManagerLaunchResponder {
9034    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9035    tx_id: u32,
9036}
9037
9038/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9039/// if the responder is dropped without sending a response, so that the client
9040/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9041impl std::ops::Drop for ZirconGuestManagerLaunchResponder {
9042    fn drop(&mut self) {
9043        self.control_handle.shutdown();
9044        // Safety: drops once, never accessed again
9045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9046    }
9047}
9048
9049impl fidl::endpoints::Responder for ZirconGuestManagerLaunchResponder {
9050    type ControlHandle = ZirconGuestManagerControlHandle;
9051
9052    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9053        &self.control_handle
9054    }
9055
9056    fn drop_without_shutdown(mut self) {
9057        // Safety: drops once, never accessed again due to mem::forget
9058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9059        // Prevent Drop from running (which would shut down the channel)
9060        std::mem::forget(self);
9061    }
9062}
9063
9064impl ZirconGuestManagerLaunchResponder {
9065    /// Sends a response to the FIDL transaction.
9066    ///
9067    /// Sets the channel to shutdown if an error occurs.
9068    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9069        let _result = self.send_raw(result);
9070        if _result.is_err() {
9071            self.control_handle.shutdown();
9072        }
9073        self.drop_without_shutdown();
9074        _result
9075    }
9076
9077    /// Similar to "send" but does not shutdown the channel if an error occurs.
9078    pub fn send_no_shutdown_on_err(
9079        self,
9080        mut result: Result<(), GuestManagerError>,
9081    ) -> Result<(), fidl::Error> {
9082        let _result = self.send_raw(result);
9083        self.drop_without_shutdown();
9084        _result
9085    }
9086
9087    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9088        self.control_handle.inner.send::<fidl::encoding::ResultType<
9089            fidl::encoding::EmptyStruct,
9090            GuestManagerError,
9091        >>(
9092            result,
9093            self.tx_id,
9094            0x394a2e29f750323e,
9095            fidl::encoding::DynamicFlags::empty(),
9096        )
9097    }
9098}
9099
9100#[must_use = "FIDL methods require a response to be sent"]
9101#[derive(Debug)]
9102pub struct ZirconGuestManagerForceShutdownResponder {
9103    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9104    tx_id: u32,
9105}
9106
9107/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9108/// if the responder is dropped without sending a response, so that the client
9109/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9110impl std::ops::Drop for ZirconGuestManagerForceShutdownResponder {
9111    fn drop(&mut self) {
9112        self.control_handle.shutdown();
9113        // Safety: drops once, never accessed again
9114        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9115    }
9116}
9117
9118impl fidl::endpoints::Responder for ZirconGuestManagerForceShutdownResponder {
9119    type ControlHandle = ZirconGuestManagerControlHandle;
9120
9121    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9122        &self.control_handle
9123    }
9124
9125    fn drop_without_shutdown(mut self) {
9126        // Safety: drops once, never accessed again due to mem::forget
9127        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9128        // Prevent Drop from running (which would shut down the channel)
9129        std::mem::forget(self);
9130    }
9131}
9132
9133impl ZirconGuestManagerForceShutdownResponder {
9134    /// Sends a response to the FIDL transaction.
9135    ///
9136    /// Sets the channel to shutdown if an error occurs.
9137    pub fn send(self) -> Result<(), fidl::Error> {
9138        let _result = self.send_raw();
9139        if _result.is_err() {
9140            self.control_handle.shutdown();
9141        }
9142        self.drop_without_shutdown();
9143        _result
9144    }
9145
9146    /// Similar to "send" but does not shutdown the channel if an error occurs.
9147    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9148        let _result = self.send_raw();
9149        self.drop_without_shutdown();
9150        _result
9151    }
9152
9153    fn send_raw(&self) -> Result<(), fidl::Error> {
9154        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9155            (),
9156            self.tx_id,
9157            0x3ad9a012982f872d,
9158            fidl::encoding::DynamicFlags::empty(),
9159        )
9160    }
9161}
9162
9163#[must_use = "FIDL methods require a response to be sent"]
9164#[derive(Debug)]
9165pub struct ZirconGuestManagerConnectResponder {
9166    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9167    tx_id: u32,
9168}
9169
9170/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9171/// if the responder is dropped without sending a response, so that the client
9172/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9173impl std::ops::Drop for ZirconGuestManagerConnectResponder {
9174    fn drop(&mut self) {
9175        self.control_handle.shutdown();
9176        // Safety: drops once, never accessed again
9177        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9178    }
9179}
9180
9181impl fidl::endpoints::Responder for ZirconGuestManagerConnectResponder {
9182    type ControlHandle = ZirconGuestManagerControlHandle;
9183
9184    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9185        &self.control_handle
9186    }
9187
9188    fn drop_without_shutdown(mut self) {
9189        // Safety: drops once, never accessed again due to mem::forget
9190        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9191        // Prevent Drop from running (which would shut down the channel)
9192        std::mem::forget(self);
9193    }
9194}
9195
9196impl ZirconGuestManagerConnectResponder {
9197    /// Sends a response to the FIDL transaction.
9198    ///
9199    /// Sets the channel to shutdown if an error occurs.
9200    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9201        let _result = self.send_raw(result);
9202        if _result.is_err() {
9203            self.control_handle.shutdown();
9204        }
9205        self.drop_without_shutdown();
9206        _result
9207    }
9208
9209    /// Similar to "send" but does not shutdown the channel if an error occurs.
9210    pub fn send_no_shutdown_on_err(
9211        self,
9212        mut result: Result<(), GuestManagerError>,
9213    ) -> Result<(), fidl::Error> {
9214        let _result = self.send_raw(result);
9215        self.drop_without_shutdown();
9216        _result
9217    }
9218
9219    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9220        self.control_handle.inner.send::<fidl::encoding::ResultType<
9221            fidl::encoding::EmptyStruct,
9222            GuestManagerError,
9223        >>(
9224            result,
9225            self.tx_id,
9226            0x4e489076e3bb15b4,
9227            fidl::encoding::DynamicFlags::empty(),
9228        )
9229    }
9230}
9231
9232#[must_use = "FIDL methods require a response to be sent"]
9233#[derive(Debug)]
9234pub struct ZirconGuestManagerGetInfoResponder {
9235    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9236    tx_id: u32,
9237}
9238
9239/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9240/// if the responder is dropped without sending a response, so that the client
9241/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9242impl std::ops::Drop for ZirconGuestManagerGetInfoResponder {
9243    fn drop(&mut self) {
9244        self.control_handle.shutdown();
9245        // Safety: drops once, never accessed again
9246        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9247    }
9248}
9249
9250impl fidl::endpoints::Responder for ZirconGuestManagerGetInfoResponder {
9251    type ControlHandle = ZirconGuestManagerControlHandle;
9252
9253    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9254        &self.control_handle
9255    }
9256
9257    fn drop_without_shutdown(mut self) {
9258        // Safety: drops once, never accessed again due to mem::forget
9259        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9260        // Prevent Drop from running (which would shut down the channel)
9261        std::mem::forget(self);
9262    }
9263}
9264
9265impl ZirconGuestManagerGetInfoResponder {
9266    /// Sends a response to the FIDL transaction.
9267    ///
9268    /// Sets the channel to shutdown if an error occurs.
9269    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9270        let _result = self.send_raw(guest_info);
9271        if _result.is_err() {
9272            self.control_handle.shutdown();
9273        }
9274        self.drop_without_shutdown();
9275        _result
9276    }
9277
9278    /// Similar to "send" but does not shutdown the channel if an error occurs.
9279    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9280        let _result = self.send_raw(guest_info);
9281        self.drop_without_shutdown();
9282        _result
9283    }
9284
9285    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9286        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
9287            (guest_info,),
9288            self.tx_id,
9289            0x76892614aea695dc,
9290            fidl::encoding::DynamicFlags::empty(),
9291        )
9292    }
9293}
9294
9295mod internal {
9296    use super::*;
9297
9298    impl fidl::encoding::ResourceTypeMarker for BlockSpec {
9299        type Borrowed<'a> = &'a mut Self;
9300        fn take_or_borrow<'a>(
9301            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9302        ) -> Self::Borrowed<'a> {
9303            value
9304        }
9305    }
9306
9307    unsafe impl fidl::encoding::TypeMarker for BlockSpec {
9308        type Owned = Self;
9309
9310        #[inline(always)]
9311        fn inline_align(_context: fidl::encoding::Context) -> usize {
9312            8
9313        }
9314
9315        #[inline(always)]
9316        fn inline_size(_context: fidl::encoding::Context) -> usize {
9317            40
9318        }
9319    }
9320
9321    unsafe impl fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9322        for &mut BlockSpec
9323    {
9324        #[inline]
9325        unsafe fn encode(
9326            self,
9327            encoder: &mut fidl::encoding::Encoder<
9328                '_,
9329                fidl::encoding::DefaultFuchsiaResourceDialect,
9330            >,
9331            offset: usize,
9332            _depth: fidl::encoding::Depth,
9333        ) -> fidl::Result<()> {
9334            encoder.debug_check_bounds::<BlockSpec>(offset);
9335            // Delegate to tuple encoding.
9336            fidl::encoding::Encode::<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9337                (
9338                    <fidl::encoding::BoundedString<20> as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
9339                    <BlockMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
9340                    <BlockFormat as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.format),
9341                ),
9342                encoder, offset, _depth
9343            )
9344        }
9345    }
9346    unsafe impl<
9347        T0: fidl::encoding::Encode<
9348                fidl::encoding::BoundedString<20>,
9349                fidl::encoding::DefaultFuchsiaResourceDialect,
9350            >,
9351        T1: fidl::encoding::Encode<BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect>,
9352        T2: fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>,
9353    > fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9354        for (T0, T1, T2)
9355    {
9356        #[inline]
9357        unsafe fn encode(
9358            self,
9359            encoder: &mut fidl::encoding::Encoder<
9360                '_,
9361                fidl::encoding::DefaultFuchsiaResourceDialect,
9362            >,
9363            offset: usize,
9364            depth: fidl::encoding::Depth,
9365        ) -> fidl::Result<()> {
9366            encoder.debug_check_bounds::<BlockSpec>(offset);
9367            // Zero out padding regions. There's no need to apply masks
9368            // because the unmasked parts will be overwritten by fields.
9369            unsafe {
9370                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9371                (ptr as *mut u64).write_unaligned(0);
9372            }
9373            // Write the fields.
9374            self.0.encode(encoder, offset + 0, depth)?;
9375            self.1.encode(encoder, offset + 16, depth)?;
9376            self.2.encode(encoder, offset + 24, depth)?;
9377            Ok(())
9378        }
9379    }
9380
9381    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockSpec {
9382        #[inline(always)]
9383        fn new_empty() -> Self {
9384            Self {
9385                id: fidl::new_empty!(
9386                    fidl::encoding::BoundedString<20>,
9387                    fidl::encoding::DefaultFuchsiaResourceDialect
9388                ),
9389                mode: fidl::new_empty!(BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect),
9390                format: fidl::new_empty!(
9391                    BlockFormat,
9392                    fidl::encoding::DefaultFuchsiaResourceDialect
9393                ),
9394            }
9395        }
9396
9397        #[inline]
9398        unsafe fn decode(
9399            &mut self,
9400            decoder: &mut fidl::encoding::Decoder<
9401                '_,
9402                fidl::encoding::DefaultFuchsiaResourceDialect,
9403            >,
9404            offset: usize,
9405            _depth: fidl::encoding::Depth,
9406        ) -> fidl::Result<()> {
9407            decoder.debug_check_bounds::<Self>(offset);
9408            // Verify that padding bytes are zero.
9409            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9410            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9411            let mask = 0xffffffff00000000u64;
9412            let maskedval = padval & mask;
9413            if maskedval != 0 {
9414                return Err(fidl::Error::NonZeroPadding {
9415                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9416                });
9417            }
9418            fidl::decode!(
9419                fidl::encoding::BoundedString<20>,
9420                fidl::encoding::DefaultFuchsiaResourceDialect,
9421                &mut self.id,
9422                decoder,
9423                offset + 0,
9424                _depth
9425            )?;
9426            fidl::decode!(
9427                BlockMode,
9428                fidl::encoding::DefaultFuchsiaResourceDialect,
9429                &mut self.mode,
9430                decoder,
9431                offset + 16,
9432                _depth
9433            )?;
9434            fidl::decode!(
9435                BlockFormat,
9436                fidl::encoding::DefaultFuchsiaResourceDialect,
9437                &mut self.format,
9438                decoder,
9439                offset + 24,
9440                _depth
9441            )?;
9442            Ok(())
9443        }
9444    }
9445
9446    impl fidl::encoding::ResourceTypeMarker for GuestGetBalloonControllerRequest {
9447        type Borrowed<'a> = &'a mut Self;
9448        fn take_or_borrow<'a>(
9449            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9450        ) -> Self::Borrowed<'a> {
9451            value
9452        }
9453    }
9454
9455    unsafe impl fidl::encoding::TypeMarker for GuestGetBalloonControllerRequest {
9456        type Owned = Self;
9457
9458        #[inline(always)]
9459        fn inline_align(_context: fidl::encoding::Context) -> usize {
9460            4
9461        }
9462
9463        #[inline(always)]
9464        fn inline_size(_context: fidl::encoding::Context) -> usize {
9465            4
9466        }
9467    }
9468
9469    unsafe impl
9470        fidl::encoding::Encode<
9471            GuestGetBalloonControllerRequest,
9472            fidl::encoding::DefaultFuchsiaResourceDialect,
9473        > for &mut GuestGetBalloonControllerRequest
9474    {
9475        #[inline]
9476        unsafe fn encode(
9477            self,
9478            encoder: &mut fidl::encoding::Encoder<
9479                '_,
9480                fidl::encoding::DefaultFuchsiaResourceDialect,
9481            >,
9482            offset: usize,
9483            _depth: fidl::encoding::Depth,
9484        ) -> fidl::Result<()> {
9485            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9486            // Delegate to tuple encoding.
9487            fidl::encoding::Encode::<GuestGetBalloonControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9488                (
9489                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9490                ),
9491                encoder, offset, _depth
9492            )
9493        }
9494    }
9495    unsafe impl<
9496        T0: fidl::encoding::Encode<
9497                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9498                fidl::encoding::DefaultFuchsiaResourceDialect,
9499            >,
9500    >
9501        fidl::encoding::Encode<
9502            GuestGetBalloonControllerRequest,
9503            fidl::encoding::DefaultFuchsiaResourceDialect,
9504        > for (T0,)
9505    {
9506        #[inline]
9507        unsafe fn encode(
9508            self,
9509            encoder: &mut fidl::encoding::Encoder<
9510                '_,
9511                fidl::encoding::DefaultFuchsiaResourceDialect,
9512            >,
9513            offset: usize,
9514            depth: fidl::encoding::Depth,
9515        ) -> fidl::Result<()> {
9516            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9517            // Zero out padding regions. There's no need to apply masks
9518            // because the unmasked parts will be overwritten by fields.
9519            // Write the fields.
9520            self.0.encode(encoder, offset + 0, depth)?;
9521            Ok(())
9522        }
9523    }
9524
9525    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9526        for GuestGetBalloonControllerRequest
9527    {
9528        #[inline(always)]
9529        fn new_empty() -> Self {
9530            Self {
9531                controller: fidl::new_empty!(
9532                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9533                    fidl::encoding::DefaultFuchsiaResourceDialect
9534                ),
9535            }
9536        }
9537
9538        #[inline]
9539        unsafe fn decode(
9540            &mut self,
9541            decoder: &mut fidl::encoding::Decoder<
9542                '_,
9543                fidl::encoding::DefaultFuchsiaResourceDialect,
9544            >,
9545            offset: usize,
9546            _depth: fidl::encoding::Depth,
9547        ) -> fidl::Result<()> {
9548            decoder.debug_check_bounds::<Self>(offset);
9549            // Verify that padding bytes are zero.
9550            fidl::decode!(
9551                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9552                fidl::encoding::DefaultFuchsiaResourceDialect,
9553                &mut self.controller,
9554                decoder,
9555                offset + 0,
9556                _depth
9557            )?;
9558            Ok(())
9559        }
9560    }
9561
9562    impl fidl::encoding::ResourceTypeMarker for GuestGetHostVsockEndpointRequest {
9563        type Borrowed<'a> = &'a mut Self;
9564        fn take_or_borrow<'a>(
9565            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9566        ) -> Self::Borrowed<'a> {
9567            value
9568        }
9569    }
9570
9571    unsafe impl fidl::encoding::TypeMarker for GuestGetHostVsockEndpointRequest {
9572        type Owned = Self;
9573
9574        #[inline(always)]
9575        fn inline_align(_context: fidl::encoding::Context) -> usize {
9576            4
9577        }
9578
9579        #[inline(always)]
9580        fn inline_size(_context: fidl::encoding::Context) -> usize {
9581            4
9582        }
9583    }
9584
9585    unsafe impl
9586        fidl::encoding::Encode<
9587            GuestGetHostVsockEndpointRequest,
9588            fidl::encoding::DefaultFuchsiaResourceDialect,
9589        > for &mut GuestGetHostVsockEndpointRequest
9590    {
9591        #[inline]
9592        unsafe fn encode(
9593            self,
9594            encoder: &mut fidl::encoding::Encoder<
9595                '_,
9596                fidl::encoding::DefaultFuchsiaResourceDialect,
9597            >,
9598            offset: usize,
9599            _depth: fidl::encoding::Depth,
9600        ) -> fidl::Result<()> {
9601            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9602            // Delegate to tuple encoding.
9603            fidl::encoding::Encode::<GuestGetHostVsockEndpointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9604                (
9605                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoint),
9606                ),
9607                encoder, offset, _depth
9608            )
9609        }
9610    }
9611    unsafe impl<
9612        T0: fidl::encoding::Encode<
9613                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9614                fidl::encoding::DefaultFuchsiaResourceDialect,
9615            >,
9616    >
9617        fidl::encoding::Encode<
9618            GuestGetHostVsockEndpointRequest,
9619            fidl::encoding::DefaultFuchsiaResourceDialect,
9620        > for (T0,)
9621    {
9622        #[inline]
9623        unsafe fn encode(
9624            self,
9625            encoder: &mut fidl::encoding::Encoder<
9626                '_,
9627                fidl::encoding::DefaultFuchsiaResourceDialect,
9628            >,
9629            offset: usize,
9630            depth: fidl::encoding::Depth,
9631        ) -> fidl::Result<()> {
9632            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9633            // Zero out padding regions. There's no need to apply masks
9634            // because the unmasked parts will be overwritten by fields.
9635            // Write the fields.
9636            self.0.encode(encoder, offset + 0, depth)?;
9637            Ok(())
9638        }
9639    }
9640
9641    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9642        for GuestGetHostVsockEndpointRequest
9643    {
9644        #[inline(always)]
9645        fn new_empty() -> Self {
9646            Self {
9647                endpoint: fidl::new_empty!(
9648                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9649                    fidl::encoding::DefaultFuchsiaResourceDialect
9650                ),
9651            }
9652        }
9653
9654        #[inline]
9655        unsafe fn decode(
9656            &mut self,
9657            decoder: &mut fidl::encoding::Decoder<
9658                '_,
9659                fidl::encoding::DefaultFuchsiaResourceDialect,
9660            >,
9661            offset: usize,
9662            _depth: fidl::encoding::Depth,
9663        ) -> fidl::Result<()> {
9664            decoder.debug_check_bounds::<Self>(offset);
9665            // Verify that padding bytes are zero.
9666            fidl::decode!(
9667                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9668                fidl::encoding::DefaultFuchsiaResourceDialect,
9669                &mut self.endpoint,
9670                decoder,
9671                offset + 0,
9672                _depth
9673            )?;
9674            Ok(())
9675        }
9676    }
9677
9678    impl fidl::encoding::ResourceTypeMarker for GuestGetMemControllerRequest {
9679        type Borrowed<'a> = &'a mut Self;
9680        fn take_or_borrow<'a>(
9681            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9682        ) -> Self::Borrowed<'a> {
9683            value
9684        }
9685    }
9686
9687    unsafe impl fidl::encoding::TypeMarker for GuestGetMemControllerRequest {
9688        type Owned = Self;
9689
9690        #[inline(always)]
9691        fn inline_align(_context: fidl::encoding::Context) -> usize {
9692            4
9693        }
9694
9695        #[inline(always)]
9696        fn inline_size(_context: fidl::encoding::Context) -> usize {
9697            4
9698        }
9699    }
9700
9701    unsafe impl
9702        fidl::encoding::Encode<
9703            GuestGetMemControllerRequest,
9704            fidl::encoding::DefaultFuchsiaResourceDialect,
9705        > for &mut GuestGetMemControllerRequest
9706    {
9707        #[inline]
9708        unsafe fn encode(
9709            self,
9710            encoder: &mut fidl::encoding::Encoder<
9711                '_,
9712                fidl::encoding::DefaultFuchsiaResourceDialect,
9713            >,
9714            offset: usize,
9715            _depth: fidl::encoding::Depth,
9716        ) -> fidl::Result<()> {
9717            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9718            // Delegate to tuple encoding.
9719            fidl::encoding::Encode::<GuestGetMemControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9720                (
9721                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9722                ),
9723                encoder, offset, _depth
9724            )
9725        }
9726    }
9727    unsafe impl<
9728        T0: fidl::encoding::Encode<
9729                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9730                fidl::encoding::DefaultFuchsiaResourceDialect,
9731            >,
9732    >
9733        fidl::encoding::Encode<
9734            GuestGetMemControllerRequest,
9735            fidl::encoding::DefaultFuchsiaResourceDialect,
9736        > for (T0,)
9737    {
9738        #[inline]
9739        unsafe fn encode(
9740            self,
9741            encoder: &mut fidl::encoding::Encoder<
9742                '_,
9743                fidl::encoding::DefaultFuchsiaResourceDialect,
9744            >,
9745            offset: usize,
9746            depth: fidl::encoding::Depth,
9747        ) -> fidl::Result<()> {
9748            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9749            // Zero out padding regions. There's no need to apply masks
9750            // because the unmasked parts will be overwritten by fields.
9751            // Write the fields.
9752            self.0.encode(encoder, offset + 0, depth)?;
9753            Ok(())
9754        }
9755    }
9756
9757    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9758        for GuestGetMemControllerRequest
9759    {
9760        #[inline(always)]
9761        fn new_empty() -> Self {
9762            Self {
9763                controller: fidl::new_empty!(
9764                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9765                    fidl::encoding::DefaultFuchsiaResourceDialect
9766                ),
9767            }
9768        }
9769
9770        #[inline]
9771        unsafe fn decode(
9772            &mut self,
9773            decoder: &mut fidl::encoding::Decoder<
9774                '_,
9775                fidl::encoding::DefaultFuchsiaResourceDialect,
9776            >,
9777            offset: usize,
9778            _depth: fidl::encoding::Depth,
9779        ) -> fidl::Result<()> {
9780            decoder.debug_check_bounds::<Self>(offset);
9781            // Verify that padding bytes are zero.
9782            fidl::decode!(
9783                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9784                fidl::encoding::DefaultFuchsiaResourceDialect,
9785                &mut self.controller,
9786                decoder,
9787                offset + 0,
9788                _depth
9789            )?;
9790            Ok(())
9791        }
9792    }
9793
9794    impl fidl::encoding::ResourceTypeMarker for GuestGetSerialResponse {
9795        type Borrowed<'a> = &'a mut Self;
9796        fn take_or_borrow<'a>(
9797            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9798        ) -> Self::Borrowed<'a> {
9799            value
9800        }
9801    }
9802
9803    unsafe impl fidl::encoding::TypeMarker for GuestGetSerialResponse {
9804        type Owned = Self;
9805
9806        #[inline(always)]
9807        fn inline_align(_context: fidl::encoding::Context) -> usize {
9808            4
9809        }
9810
9811        #[inline(always)]
9812        fn inline_size(_context: fidl::encoding::Context) -> usize {
9813            4
9814        }
9815    }
9816
9817    unsafe impl
9818        fidl::encoding::Encode<
9819            GuestGetSerialResponse,
9820            fidl::encoding::DefaultFuchsiaResourceDialect,
9821        > for &mut GuestGetSerialResponse
9822    {
9823        #[inline]
9824        unsafe fn encode(
9825            self,
9826            encoder: &mut fidl::encoding::Encoder<
9827                '_,
9828                fidl::encoding::DefaultFuchsiaResourceDialect,
9829            >,
9830            offset: usize,
9831            _depth: fidl::encoding::Depth,
9832        ) -> fidl::Result<()> {
9833            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9834            // Delegate to tuple encoding.
9835            fidl::encoding::Encode::<
9836                GuestGetSerialResponse,
9837                fidl::encoding::DefaultFuchsiaResourceDialect,
9838            >::encode(
9839                (<fidl::encoding::HandleType<
9840                    fidl::Socket,
9841                    { fidl::ObjectType::SOCKET.into_raw() },
9842                    2147483648,
9843                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9844                    &mut self.socket
9845                ),),
9846                encoder,
9847                offset,
9848                _depth,
9849            )
9850        }
9851    }
9852    unsafe impl<
9853        T0: fidl::encoding::Encode<
9854                fidl::encoding::HandleType<
9855                    fidl::Socket,
9856                    { fidl::ObjectType::SOCKET.into_raw() },
9857                    2147483648,
9858                >,
9859                fidl::encoding::DefaultFuchsiaResourceDialect,
9860            >,
9861    >
9862        fidl::encoding::Encode<
9863            GuestGetSerialResponse,
9864            fidl::encoding::DefaultFuchsiaResourceDialect,
9865        > for (T0,)
9866    {
9867        #[inline]
9868        unsafe fn encode(
9869            self,
9870            encoder: &mut fidl::encoding::Encoder<
9871                '_,
9872                fidl::encoding::DefaultFuchsiaResourceDialect,
9873            >,
9874            offset: usize,
9875            depth: fidl::encoding::Depth,
9876        ) -> fidl::Result<()> {
9877            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9878            // Zero out padding regions. There's no need to apply masks
9879            // because the unmasked parts will be overwritten by fields.
9880            // Write the fields.
9881            self.0.encode(encoder, offset + 0, depth)?;
9882            Ok(())
9883        }
9884    }
9885
9886    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9887        for GuestGetSerialResponse
9888    {
9889        #[inline(always)]
9890        fn new_empty() -> Self {
9891            Self {
9892                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9893            }
9894        }
9895
9896        #[inline]
9897        unsafe fn decode(
9898            &mut self,
9899            decoder: &mut fidl::encoding::Decoder<
9900                '_,
9901                fidl::encoding::DefaultFuchsiaResourceDialect,
9902            >,
9903            offset: usize,
9904            _depth: fidl::encoding::Depth,
9905        ) -> fidl::Result<()> {
9906            decoder.debug_check_bounds::<Self>(offset);
9907            // Verify that padding bytes are zero.
9908            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
9909            Ok(())
9910        }
9911    }
9912
9913    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleBindRequest {
9914        type Borrowed<'a> = &'a mut Self;
9915        fn take_or_borrow<'a>(
9916            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9917        ) -> Self::Borrowed<'a> {
9918            value
9919        }
9920    }
9921
9922    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleBindRequest {
9923        type Owned = Self;
9924
9925        #[inline(always)]
9926        fn inline_align(_context: fidl::encoding::Context) -> usize {
9927            4
9928        }
9929
9930        #[inline(always)]
9931        fn inline_size(_context: fidl::encoding::Context) -> usize {
9932            4
9933        }
9934    }
9935
9936    unsafe impl
9937        fidl::encoding::Encode<
9938            GuestLifecycleBindRequest,
9939            fidl::encoding::DefaultFuchsiaResourceDialect,
9940        > for &mut GuestLifecycleBindRequest
9941    {
9942        #[inline]
9943        unsafe fn encode(
9944            self,
9945            encoder: &mut fidl::encoding::Encoder<
9946                '_,
9947                fidl::encoding::DefaultFuchsiaResourceDialect,
9948            >,
9949            offset: usize,
9950            _depth: fidl::encoding::Depth,
9951        ) -> fidl::Result<()> {
9952            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9953            // Delegate to tuple encoding.
9954            fidl::encoding::Encode::<GuestLifecycleBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9955                (
9956                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest),
9957                ),
9958                encoder, offset, _depth
9959            )
9960        }
9961    }
9962    unsafe impl<
9963        T0: fidl::encoding::Encode<
9964                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9965                fidl::encoding::DefaultFuchsiaResourceDialect,
9966            >,
9967    >
9968        fidl::encoding::Encode<
9969            GuestLifecycleBindRequest,
9970            fidl::encoding::DefaultFuchsiaResourceDialect,
9971        > for (T0,)
9972    {
9973        #[inline]
9974        unsafe fn encode(
9975            self,
9976            encoder: &mut fidl::encoding::Encoder<
9977                '_,
9978                fidl::encoding::DefaultFuchsiaResourceDialect,
9979            >,
9980            offset: usize,
9981            depth: fidl::encoding::Depth,
9982        ) -> fidl::Result<()> {
9983            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9984            // Zero out padding regions. There's no need to apply masks
9985            // because the unmasked parts will be overwritten by fields.
9986            // Write the fields.
9987            self.0.encode(encoder, offset + 0, depth)?;
9988            Ok(())
9989        }
9990    }
9991
9992    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9993        for GuestLifecycleBindRequest
9994    {
9995        #[inline(always)]
9996        fn new_empty() -> Self {
9997            Self {
9998                guest: fidl::new_empty!(
9999                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10000                    fidl::encoding::DefaultFuchsiaResourceDialect
10001                ),
10002            }
10003        }
10004
10005        #[inline]
10006        unsafe fn decode(
10007            &mut self,
10008            decoder: &mut fidl::encoding::Decoder<
10009                '_,
10010                fidl::encoding::DefaultFuchsiaResourceDialect,
10011            >,
10012            offset: usize,
10013            _depth: fidl::encoding::Depth,
10014        ) -> fidl::Result<()> {
10015            decoder.debug_check_bounds::<Self>(offset);
10016            // Verify that padding bytes are zero.
10017            fidl::decode!(
10018                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10019                fidl::encoding::DefaultFuchsiaResourceDialect,
10020                &mut self.guest,
10021                decoder,
10022                offset + 0,
10023                _depth
10024            )?;
10025            Ok(())
10026        }
10027    }
10028
10029    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleCreateRequest {
10030        type Borrowed<'a> = &'a mut Self;
10031        fn take_or_borrow<'a>(
10032            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10033        ) -> Self::Borrowed<'a> {
10034            value
10035        }
10036    }
10037
10038    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleCreateRequest {
10039        type Owned = Self;
10040
10041        #[inline(always)]
10042        fn inline_align(_context: fidl::encoding::Context) -> usize {
10043            8
10044        }
10045
10046        #[inline(always)]
10047        fn inline_size(_context: fidl::encoding::Context) -> usize {
10048            16
10049        }
10050    }
10051
10052    unsafe impl
10053        fidl::encoding::Encode<
10054            GuestLifecycleCreateRequest,
10055            fidl::encoding::DefaultFuchsiaResourceDialect,
10056        > for &mut GuestLifecycleCreateRequest
10057    {
10058        #[inline]
10059        unsafe fn encode(
10060            self,
10061            encoder: &mut fidl::encoding::Encoder<
10062                '_,
10063                fidl::encoding::DefaultFuchsiaResourceDialect,
10064            >,
10065            offset: usize,
10066            _depth: fidl::encoding::Depth,
10067        ) -> fidl::Result<()> {
10068            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
10069            // Delegate to tuple encoding.
10070            fidl::encoding::Encode::<
10071                GuestLifecycleCreateRequest,
10072                fidl::encoding::DefaultFuchsiaResourceDialect,
10073            >::encode(
10074                (<GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10075                    &mut self.guest_config,
10076                ),),
10077                encoder,
10078                offset,
10079                _depth,
10080            )
10081        }
10082    }
10083    unsafe impl<
10084        T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
10085    >
10086        fidl::encoding::Encode<
10087            GuestLifecycleCreateRequest,
10088            fidl::encoding::DefaultFuchsiaResourceDialect,
10089        > for (T0,)
10090    {
10091        #[inline]
10092        unsafe fn encode(
10093            self,
10094            encoder: &mut fidl::encoding::Encoder<
10095                '_,
10096                fidl::encoding::DefaultFuchsiaResourceDialect,
10097            >,
10098            offset: usize,
10099            depth: fidl::encoding::Depth,
10100        ) -> fidl::Result<()> {
10101            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
10102            // Zero out padding regions. There's no need to apply masks
10103            // because the unmasked parts will be overwritten by fields.
10104            // Write the fields.
10105            self.0.encode(encoder, offset + 0, depth)?;
10106            Ok(())
10107        }
10108    }
10109
10110    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10111        for GuestLifecycleCreateRequest
10112    {
10113        #[inline(always)]
10114        fn new_empty() -> Self {
10115            Self {
10116                guest_config: fidl::new_empty!(
10117                    GuestConfig,
10118                    fidl::encoding::DefaultFuchsiaResourceDialect
10119                ),
10120            }
10121        }
10122
10123        #[inline]
10124        unsafe fn decode(
10125            &mut self,
10126            decoder: &mut fidl::encoding::Decoder<
10127                '_,
10128                fidl::encoding::DefaultFuchsiaResourceDialect,
10129            >,
10130            offset: usize,
10131            _depth: fidl::encoding::Depth,
10132        ) -> fidl::Result<()> {
10133            decoder.debug_check_bounds::<Self>(offset);
10134            // Verify that padding bytes are zero.
10135            fidl::decode!(
10136                GuestConfig,
10137                fidl::encoding::DefaultFuchsiaResourceDialect,
10138                &mut self.guest_config,
10139                decoder,
10140                offset + 0,
10141                _depth
10142            )?;
10143            Ok(())
10144        }
10145    }
10146
10147    impl fidl::encoding::ResourceTypeMarker for GuestManagerConnectRequest {
10148        type Borrowed<'a> = &'a mut Self;
10149        fn take_or_borrow<'a>(
10150            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10151        ) -> Self::Borrowed<'a> {
10152            value
10153        }
10154    }
10155
10156    unsafe impl fidl::encoding::TypeMarker for GuestManagerConnectRequest {
10157        type Owned = Self;
10158
10159        #[inline(always)]
10160        fn inline_align(_context: fidl::encoding::Context) -> usize {
10161            4
10162        }
10163
10164        #[inline(always)]
10165        fn inline_size(_context: fidl::encoding::Context) -> usize {
10166            4
10167        }
10168    }
10169
10170    unsafe impl
10171        fidl::encoding::Encode<
10172            GuestManagerConnectRequest,
10173            fidl::encoding::DefaultFuchsiaResourceDialect,
10174        > for &mut GuestManagerConnectRequest
10175    {
10176        #[inline]
10177        unsafe fn encode(
10178            self,
10179            encoder: &mut fidl::encoding::Encoder<
10180                '_,
10181                fidl::encoding::DefaultFuchsiaResourceDialect,
10182            >,
10183            offset: usize,
10184            _depth: fidl::encoding::Depth,
10185        ) -> fidl::Result<()> {
10186            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
10187            // Delegate to tuple encoding.
10188            fidl::encoding::Encode::<GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10189                (
10190                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10191                ),
10192                encoder, offset, _depth
10193            )
10194        }
10195    }
10196    unsafe impl<
10197        T0: fidl::encoding::Encode<
10198                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10199                fidl::encoding::DefaultFuchsiaResourceDialect,
10200            >,
10201    >
10202        fidl::encoding::Encode<
10203            GuestManagerConnectRequest,
10204            fidl::encoding::DefaultFuchsiaResourceDialect,
10205        > for (T0,)
10206    {
10207        #[inline]
10208        unsafe fn encode(
10209            self,
10210            encoder: &mut fidl::encoding::Encoder<
10211                '_,
10212                fidl::encoding::DefaultFuchsiaResourceDialect,
10213            >,
10214            offset: usize,
10215            depth: fidl::encoding::Depth,
10216        ) -> fidl::Result<()> {
10217            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
10218            // Zero out padding regions. There's no need to apply masks
10219            // because the unmasked parts will be overwritten by fields.
10220            // Write the fields.
10221            self.0.encode(encoder, offset + 0, depth)?;
10222            Ok(())
10223        }
10224    }
10225
10226    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10227        for GuestManagerConnectRequest
10228    {
10229        #[inline(always)]
10230        fn new_empty() -> Self {
10231            Self {
10232                controller: fidl::new_empty!(
10233                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10234                    fidl::encoding::DefaultFuchsiaResourceDialect
10235                ),
10236            }
10237        }
10238
10239        #[inline]
10240        unsafe fn decode(
10241            &mut self,
10242            decoder: &mut fidl::encoding::Decoder<
10243                '_,
10244                fidl::encoding::DefaultFuchsiaResourceDialect,
10245            >,
10246            offset: usize,
10247            _depth: fidl::encoding::Depth,
10248        ) -> fidl::Result<()> {
10249            decoder.debug_check_bounds::<Self>(offset);
10250            // Verify that padding bytes are zero.
10251            fidl::decode!(
10252                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10253                fidl::encoding::DefaultFuchsiaResourceDialect,
10254                &mut self.controller,
10255                decoder,
10256                offset + 0,
10257                _depth
10258            )?;
10259            Ok(())
10260        }
10261    }
10262
10263    impl fidl::encoding::ResourceTypeMarker for GuestManagerGetInfoResponse {
10264        type Borrowed<'a> = &'a mut Self;
10265        fn take_or_borrow<'a>(
10266            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10267        ) -> Self::Borrowed<'a> {
10268            value
10269        }
10270    }
10271
10272    unsafe impl fidl::encoding::TypeMarker for GuestManagerGetInfoResponse {
10273        type Owned = Self;
10274
10275        #[inline(always)]
10276        fn inline_align(_context: fidl::encoding::Context) -> usize {
10277            8
10278        }
10279
10280        #[inline(always)]
10281        fn inline_size(_context: fidl::encoding::Context) -> usize {
10282            16
10283        }
10284    }
10285
10286    unsafe impl
10287        fidl::encoding::Encode<
10288            GuestManagerGetInfoResponse,
10289            fidl::encoding::DefaultFuchsiaResourceDialect,
10290        > for &mut GuestManagerGetInfoResponse
10291    {
10292        #[inline]
10293        unsafe fn encode(
10294            self,
10295            encoder: &mut fidl::encoding::Encoder<
10296                '_,
10297                fidl::encoding::DefaultFuchsiaResourceDialect,
10298            >,
10299            offset: usize,
10300            _depth: fidl::encoding::Depth,
10301        ) -> fidl::Result<()> {
10302            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10303            // Delegate to tuple encoding.
10304            fidl::encoding::Encode::<
10305                GuestManagerGetInfoResponse,
10306                fidl::encoding::DefaultFuchsiaResourceDialect,
10307            >::encode(
10308                (<GuestInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.guest_info),),
10309                encoder,
10310                offset,
10311                _depth,
10312            )
10313        }
10314    }
10315    unsafe impl<
10316        T0: fidl::encoding::Encode<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10317    >
10318        fidl::encoding::Encode<
10319            GuestManagerGetInfoResponse,
10320            fidl::encoding::DefaultFuchsiaResourceDialect,
10321        > for (T0,)
10322    {
10323        #[inline]
10324        unsafe fn encode(
10325            self,
10326            encoder: &mut fidl::encoding::Encoder<
10327                '_,
10328                fidl::encoding::DefaultFuchsiaResourceDialect,
10329            >,
10330            offset: usize,
10331            depth: fidl::encoding::Depth,
10332        ) -> fidl::Result<()> {
10333            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10334            // Zero out padding regions. There's no need to apply masks
10335            // because the unmasked parts will be overwritten by fields.
10336            // Write the fields.
10337            self.0.encode(encoder, offset + 0, depth)?;
10338            Ok(())
10339        }
10340    }
10341
10342    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10343        for GuestManagerGetInfoResponse
10344    {
10345        #[inline(always)]
10346        fn new_empty() -> Self {
10347            Self {
10348                guest_info: fidl::new_empty!(
10349                    GuestInfo,
10350                    fidl::encoding::DefaultFuchsiaResourceDialect
10351                ),
10352            }
10353        }
10354
10355        #[inline]
10356        unsafe fn decode(
10357            &mut self,
10358            decoder: &mut fidl::encoding::Decoder<
10359                '_,
10360                fidl::encoding::DefaultFuchsiaResourceDialect,
10361            >,
10362            offset: usize,
10363            _depth: fidl::encoding::Depth,
10364        ) -> fidl::Result<()> {
10365            decoder.debug_check_bounds::<Self>(offset);
10366            // Verify that padding bytes are zero.
10367            fidl::decode!(
10368                GuestInfo,
10369                fidl::encoding::DefaultFuchsiaResourceDialect,
10370                &mut self.guest_info,
10371                decoder,
10372                offset + 0,
10373                _depth
10374            )?;
10375            Ok(())
10376        }
10377    }
10378
10379    impl fidl::encoding::ResourceTypeMarker for GuestManagerLaunchRequest {
10380        type Borrowed<'a> = &'a mut Self;
10381        fn take_or_borrow<'a>(
10382            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10383        ) -> Self::Borrowed<'a> {
10384            value
10385        }
10386    }
10387
10388    unsafe impl fidl::encoding::TypeMarker for GuestManagerLaunchRequest {
10389        type Owned = Self;
10390
10391        #[inline(always)]
10392        fn inline_align(_context: fidl::encoding::Context) -> usize {
10393            8
10394        }
10395
10396        #[inline(always)]
10397        fn inline_size(_context: fidl::encoding::Context) -> usize {
10398            24
10399        }
10400    }
10401
10402    unsafe impl
10403        fidl::encoding::Encode<
10404            GuestManagerLaunchRequest,
10405            fidl::encoding::DefaultFuchsiaResourceDialect,
10406        > for &mut GuestManagerLaunchRequest
10407    {
10408        #[inline]
10409        unsafe fn encode(
10410            self,
10411            encoder: &mut fidl::encoding::Encoder<
10412                '_,
10413                fidl::encoding::DefaultFuchsiaResourceDialect,
10414            >,
10415            offset: usize,
10416            _depth: fidl::encoding::Depth,
10417        ) -> fidl::Result<()> {
10418            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10419            // Delegate to tuple encoding.
10420            fidl::encoding::Encode::<GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10421                (
10422                    <GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest_config),
10423                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10424                ),
10425                encoder, offset, _depth
10426            )
10427        }
10428    }
10429    unsafe impl<
10430        T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
10431        T1: fidl::encoding::Encode<
10432                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10433                fidl::encoding::DefaultFuchsiaResourceDialect,
10434            >,
10435    >
10436        fidl::encoding::Encode<
10437            GuestManagerLaunchRequest,
10438            fidl::encoding::DefaultFuchsiaResourceDialect,
10439        > for (T0, T1)
10440    {
10441        #[inline]
10442        unsafe fn encode(
10443            self,
10444            encoder: &mut fidl::encoding::Encoder<
10445                '_,
10446                fidl::encoding::DefaultFuchsiaResourceDialect,
10447            >,
10448            offset: usize,
10449            depth: fidl::encoding::Depth,
10450        ) -> fidl::Result<()> {
10451            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10452            // Zero out padding regions. There's no need to apply masks
10453            // because the unmasked parts will be overwritten by fields.
10454            unsafe {
10455                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10456                (ptr as *mut u64).write_unaligned(0);
10457            }
10458            // Write the fields.
10459            self.0.encode(encoder, offset + 0, depth)?;
10460            self.1.encode(encoder, offset + 16, depth)?;
10461            Ok(())
10462        }
10463    }
10464
10465    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10466        for GuestManagerLaunchRequest
10467    {
10468        #[inline(always)]
10469        fn new_empty() -> Self {
10470            Self {
10471                guest_config: fidl::new_empty!(
10472                    GuestConfig,
10473                    fidl::encoding::DefaultFuchsiaResourceDialect
10474                ),
10475                controller: fidl::new_empty!(
10476                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10477                    fidl::encoding::DefaultFuchsiaResourceDialect
10478                ),
10479            }
10480        }
10481
10482        #[inline]
10483        unsafe fn decode(
10484            &mut self,
10485            decoder: &mut fidl::encoding::Decoder<
10486                '_,
10487                fidl::encoding::DefaultFuchsiaResourceDialect,
10488            >,
10489            offset: usize,
10490            _depth: fidl::encoding::Depth,
10491        ) -> fidl::Result<()> {
10492            decoder.debug_check_bounds::<Self>(offset);
10493            // Verify that padding bytes are zero.
10494            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10495            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10496            let mask = 0xffffffff00000000u64;
10497            let maskedval = padval & mask;
10498            if maskedval != 0 {
10499                return Err(fidl::Error::NonZeroPadding {
10500                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10501                });
10502            }
10503            fidl::decode!(
10504                GuestConfig,
10505                fidl::encoding::DefaultFuchsiaResourceDialect,
10506                &mut self.guest_config,
10507                decoder,
10508                offset + 0,
10509                _depth
10510            )?;
10511            fidl::decode!(
10512                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10513                fidl::encoding::DefaultFuchsiaResourceDialect,
10514                &mut self.controller,
10515                decoder,
10516                offset + 16,
10517                _depth
10518            )?;
10519            Ok(())
10520        }
10521    }
10522
10523    impl fidl::encoding::ResourceTypeMarker for GuestGetConsoleResponse {
10524        type Borrowed<'a> = &'a mut Self;
10525        fn take_or_borrow<'a>(
10526            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10527        ) -> Self::Borrowed<'a> {
10528            value
10529        }
10530    }
10531
10532    unsafe impl fidl::encoding::TypeMarker for GuestGetConsoleResponse {
10533        type Owned = Self;
10534
10535        #[inline(always)]
10536        fn inline_align(_context: fidl::encoding::Context) -> usize {
10537            4
10538        }
10539
10540        #[inline(always)]
10541        fn inline_size(_context: fidl::encoding::Context) -> usize {
10542            4
10543        }
10544    }
10545
10546    unsafe impl
10547        fidl::encoding::Encode<
10548            GuestGetConsoleResponse,
10549            fidl::encoding::DefaultFuchsiaResourceDialect,
10550        > for &mut GuestGetConsoleResponse
10551    {
10552        #[inline]
10553        unsafe fn encode(
10554            self,
10555            encoder: &mut fidl::encoding::Encoder<
10556                '_,
10557                fidl::encoding::DefaultFuchsiaResourceDialect,
10558            >,
10559            offset: usize,
10560            _depth: fidl::encoding::Depth,
10561        ) -> fidl::Result<()> {
10562            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10563            // Delegate to tuple encoding.
10564            fidl::encoding::Encode::<
10565                GuestGetConsoleResponse,
10566                fidl::encoding::DefaultFuchsiaResourceDialect,
10567            >::encode(
10568                (<fidl::encoding::HandleType<
10569                    fidl::Socket,
10570                    { fidl::ObjectType::SOCKET.into_raw() },
10571                    2147483648,
10572                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10573                    &mut self.socket
10574                ),),
10575                encoder,
10576                offset,
10577                _depth,
10578            )
10579        }
10580    }
10581    unsafe impl<
10582        T0: fidl::encoding::Encode<
10583                fidl::encoding::HandleType<
10584                    fidl::Socket,
10585                    { fidl::ObjectType::SOCKET.into_raw() },
10586                    2147483648,
10587                >,
10588                fidl::encoding::DefaultFuchsiaResourceDialect,
10589            >,
10590    >
10591        fidl::encoding::Encode<
10592            GuestGetConsoleResponse,
10593            fidl::encoding::DefaultFuchsiaResourceDialect,
10594        > for (T0,)
10595    {
10596        #[inline]
10597        unsafe fn encode(
10598            self,
10599            encoder: &mut fidl::encoding::Encoder<
10600                '_,
10601                fidl::encoding::DefaultFuchsiaResourceDialect,
10602            >,
10603            offset: usize,
10604            depth: fidl::encoding::Depth,
10605        ) -> fidl::Result<()> {
10606            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10607            // Zero out padding regions. There's no need to apply masks
10608            // because the unmasked parts will be overwritten by fields.
10609            // Write the fields.
10610            self.0.encode(encoder, offset + 0, depth)?;
10611            Ok(())
10612        }
10613    }
10614
10615    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10616        for GuestGetConsoleResponse
10617    {
10618        #[inline(always)]
10619        fn new_empty() -> Self {
10620            Self {
10621                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10622            }
10623        }
10624
10625        #[inline]
10626        unsafe fn decode(
10627            &mut self,
10628            decoder: &mut fidl::encoding::Decoder<
10629                '_,
10630                fidl::encoding::DefaultFuchsiaResourceDialect,
10631            >,
10632            offset: usize,
10633            _depth: fidl::encoding::Depth,
10634        ) -> fidl::Result<()> {
10635            decoder.debug_check_bounds::<Self>(offset);
10636            // Verify that padding bytes are zero.
10637            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10638            Ok(())
10639        }
10640    }
10641
10642    impl fidl::encoding::ResourceTypeMarker for HostVsockAcceptorAcceptResponse {
10643        type Borrowed<'a> = &'a mut Self;
10644        fn take_or_borrow<'a>(
10645            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10646        ) -> Self::Borrowed<'a> {
10647            value
10648        }
10649    }
10650
10651    unsafe impl fidl::encoding::TypeMarker for HostVsockAcceptorAcceptResponse {
10652        type Owned = Self;
10653
10654        #[inline(always)]
10655        fn inline_align(_context: fidl::encoding::Context) -> usize {
10656            4
10657        }
10658
10659        #[inline(always)]
10660        fn inline_size(_context: fidl::encoding::Context) -> usize {
10661            4
10662        }
10663    }
10664
10665    unsafe impl
10666        fidl::encoding::Encode<
10667            HostVsockAcceptorAcceptResponse,
10668            fidl::encoding::DefaultFuchsiaResourceDialect,
10669        > for &mut HostVsockAcceptorAcceptResponse
10670    {
10671        #[inline]
10672        unsafe fn encode(
10673            self,
10674            encoder: &mut fidl::encoding::Encoder<
10675                '_,
10676                fidl::encoding::DefaultFuchsiaResourceDialect,
10677            >,
10678            offset: usize,
10679            _depth: fidl::encoding::Depth,
10680        ) -> fidl::Result<()> {
10681            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10682            // Delegate to tuple encoding.
10683            fidl::encoding::Encode::<
10684                HostVsockAcceptorAcceptResponse,
10685                fidl::encoding::DefaultFuchsiaResourceDialect,
10686            >::encode(
10687                (<fidl::encoding::HandleType<
10688                    fidl::Socket,
10689                    { fidl::ObjectType::SOCKET.into_raw() },
10690                    2147483648,
10691                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10692                    &mut self.socket
10693                ),),
10694                encoder,
10695                offset,
10696                _depth,
10697            )
10698        }
10699    }
10700    unsafe impl<
10701        T0: fidl::encoding::Encode<
10702                fidl::encoding::HandleType<
10703                    fidl::Socket,
10704                    { fidl::ObjectType::SOCKET.into_raw() },
10705                    2147483648,
10706                >,
10707                fidl::encoding::DefaultFuchsiaResourceDialect,
10708            >,
10709    >
10710        fidl::encoding::Encode<
10711            HostVsockAcceptorAcceptResponse,
10712            fidl::encoding::DefaultFuchsiaResourceDialect,
10713        > for (T0,)
10714    {
10715        #[inline]
10716        unsafe fn encode(
10717            self,
10718            encoder: &mut fidl::encoding::Encoder<
10719                '_,
10720                fidl::encoding::DefaultFuchsiaResourceDialect,
10721            >,
10722            offset: usize,
10723            depth: fidl::encoding::Depth,
10724        ) -> fidl::Result<()> {
10725            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10726            // Zero out padding regions. There's no need to apply masks
10727            // because the unmasked parts will be overwritten by fields.
10728            // Write the fields.
10729            self.0.encode(encoder, offset + 0, depth)?;
10730            Ok(())
10731        }
10732    }
10733
10734    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10735        for HostVsockAcceptorAcceptResponse
10736    {
10737        #[inline(always)]
10738        fn new_empty() -> Self {
10739            Self {
10740                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10741            }
10742        }
10743
10744        #[inline]
10745        unsafe fn decode(
10746            &mut self,
10747            decoder: &mut fidl::encoding::Decoder<
10748                '_,
10749                fidl::encoding::DefaultFuchsiaResourceDialect,
10750            >,
10751            offset: usize,
10752            _depth: fidl::encoding::Depth,
10753        ) -> fidl::Result<()> {
10754            decoder.debug_check_bounds::<Self>(offset);
10755            // Verify that padding bytes are zero.
10756            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10757            Ok(())
10758        }
10759    }
10760
10761    impl fidl::encoding::ResourceTypeMarker for HostVsockEndpointConnectResponse {
10762        type Borrowed<'a> = &'a mut Self;
10763        fn take_or_borrow<'a>(
10764            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10765        ) -> Self::Borrowed<'a> {
10766            value
10767        }
10768    }
10769
10770    unsafe impl fidl::encoding::TypeMarker for HostVsockEndpointConnectResponse {
10771        type Owned = Self;
10772
10773        #[inline(always)]
10774        fn inline_align(_context: fidl::encoding::Context) -> usize {
10775            4
10776        }
10777
10778        #[inline(always)]
10779        fn inline_size(_context: fidl::encoding::Context) -> usize {
10780            4
10781        }
10782    }
10783
10784    unsafe impl
10785        fidl::encoding::Encode<
10786            HostVsockEndpointConnectResponse,
10787            fidl::encoding::DefaultFuchsiaResourceDialect,
10788        > for &mut HostVsockEndpointConnectResponse
10789    {
10790        #[inline]
10791        unsafe fn encode(
10792            self,
10793            encoder: &mut fidl::encoding::Encoder<
10794                '_,
10795                fidl::encoding::DefaultFuchsiaResourceDialect,
10796            >,
10797            offset: usize,
10798            _depth: fidl::encoding::Depth,
10799        ) -> fidl::Result<()> {
10800            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10801            // Delegate to tuple encoding.
10802            fidl::encoding::Encode::<
10803                HostVsockEndpointConnectResponse,
10804                fidl::encoding::DefaultFuchsiaResourceDialect,
10805            >::encode(
10806                (<fidl::encoding::HandleType<
10807                    fidl::Socket,
10808                    { fidl::ObjectType::SOCKET.into_raw() },
10809                    2147483648,
10810                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10811                    &mut self.socket
10812                ),),
10813                encoder,
10814                offset,
10815                _depth,
10816            )
10817        }
10818    }
10819    unsafe impl<
10820        T0: fidl::encoding::Encode<
10821                fidl::encoding::HandleType<
10822                    fidl::Socket,
10823                    { fidl::ObjectType::SOCKET.into_raw() },
10824                    2147483648,
10825                >,
10826                fidl::encoding::DefaultFuchsiaResourceDialect,
10827            >,
10828    >
10829        fidl::encoding::Encode<
10830            HostVsockEndpointConnectResponse,
10831            fidl::encoding::DefaultFuchsiaResourceDialect,
10832        > for (T0,)
10833    {
10834        #[inline]
10835        unsafe fn encode(
10836            self,
10837            encoder: &mut fidl::encoding::Encoder<
10838                '_,
10839                fidl::encoding::DefaultFuchsiaResourceDialect,
10840            >,
10841            offset: usize,
10842            depth: fidl::encoding::Depth,
10843        ) -> fidl::Result<()> {
10844            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10845            // Zero out padding regions. There's no need to apply masks
10846            // because the unmasked parts will be overwritten by fields.
10847            // Write the fields.
10848            self.0.encode(encoder, offset + 0, depth)?;
10849            Ok(())
10850        }
10851    }
10852
10853    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10854        for HostVsockEndpointConnectResponse
10855    {
10856        #[inline(always)]
10857        fn new_empty() -> Self {
10858            Self {
10859                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10860            }
10861        }
10862
10863        #[inline]
10864        unsafe fn decode(
10865            &mut self,
10866            decoder: &mut fidl::encoding::Decoder<
10867                '_,
10868                fidl::encoding::DefaultFuchsiaResourceDialect,
10869            >,
10870            offset: usize,
10871            _depth: fidl::encoding::Depth,
10872        ) -> fidl::Result<()> {
10873            decoder.debug_check_bounds::<Self>(offset);
10874            // Verify that padding bytes are zero.
10875            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10876            Ok(())
10877        }
10878    }
10879
10880    impl fidl::encoding::ResourceTypeMarker for Listener {
10881        type Borrowed<'a> = &'a mut Self;
10882        fn take_or_borrow<'a>(
10883            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10884        ) -> Self::Borrowed<'a> {
10885            value
10886        }
10887    }
10888
10889    unsafe impl fidl::encoding::TypeMarker for Listener {
10890        type Owned = Self;
10891
10892        #[inline(always)]
10893        fn inline_align(_context: fidl::encoding::Context) -> usize {
10894            4
10895        }
10896
10897        #[inline(always)]
10898        fn inline_size(_context: fidl::encoding::Context) -> usize {
10899            8
10900        }
10901    }
10902
10903    unsafe impl fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>
10904        for &mut Listener
10905    {
10906        #[inline]
10907        unsafe fn encode(
10908            self,
10909            encoder: &mut fidl::encoding::Encoder<
10910                '_,
10911                fidl::encoding::DefaultFuchsiaResourceDialect,
10912            >,
10913            offset: usize,
10914            _depth: fidl::encoding::Depth,
10915        ) -> fidl::Result<()> {
10916            encoder.debug_check_bounds::<Listener>(offset);
10917            // Delegate to tuple encoding.
10918            fidl::encoding::Encode::<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10919                (
10920                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.port),
10921                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.acceptor),
10922                ),
10923                encoder, offset, _depth
10924            )
10925        }
10926    }
10927    unsafe impl<
10928        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
10929        T1: fidl::encoding::Encode<
10930                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10931                fidl::encoding::DefaultFuchsiaResourceDialect,
10932            >,
10933    > fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0, T1)
10934    {
10935        #[inline]
10936        unsafe fn encode(
10937            self,
10938            encoder: &mut fidl::encoding::Encoder<
10939                '_,
10940                fidl::encoding::DefaultFuchsiaResourceDialect,
10941            >,
10942            offset: usize,
10943            depth: fidl::encoding::Depth,
10944        ) -> fidl::Result<()> {
10945            encoder.debug_check_bounds::<Listener>(offset);
10946            // Zero out padding regions. There's no need to apply masks
10947            // because the unmasked parts will be overwritten by fields.
10948            // Write the fields.
10949            self.0.encode(encoder, offset + 0, depth)?;
10950            self.1.encode(encoder, offset + 4, depth)?;
10951            Ok(())
10952        }
10953    }
10954
10955    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Listener {
10956        #[inline(always)]
10957        fn new_empty() -> Self {
10958            Self {
10959                port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
10960                acceptor: fidl::new_empty!(
10961                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10962                    fidl::encoding::DefaultFuchsiaResourceDialect
10963                ),
10964            }
10965        }
10966
10967        #[inline]
10968        unsafe fn decode(
10969            &mut self,
10970            decoder: &mut fidl::encoding::Decoder<
10971                '_,
10972                fidl::encoding::DefaultFuchsiaResourceDialect,
10973            >,
10974            offset: usize,
10975            _depth: fidl::encoding::Depth,
10976        ) -> fidl::Result<()> {
10977            decoder.debug_check_bounds::<Self>(offset);
10978            // Verify that padding bytes are zero.
10979            fidl::decode!(
10980                u32,
10981                fidl::encoding::DefaultFuchsiaResourceDialect,
10982                &mut self.port,
10983                decoder,
10984                offset + 0,
10985                _depth
10986            )?;
10987            fidl::decode!(
10988                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10989                fidl::encoding::DefaultFuchsiaResourceDialect,
10990                &mut self.acceptor,
10991                decoder,
10992                offset + 4,
10993                _depth
10994            )?;
10995            Ok(())
10996        }
10997    }
10998
10999    impl GuestConfig {
11000        #[inline(always)]
11001        fn max_ordinal_present(&self) -> u64 {
11002            if let Some(_) = self.virtio_mem_region_alignment {
11003                return 25;
11004            }
11005            if let Some(_) = self.virtio_mem_region_size {
11006                return 24;
11007            }
11008            if let Some(_) = self.virtio_mem_block_size {
11009                return 23;
11010            }
11011            if let Some(_) = self.virtio_mem {
11012                return 22;
11013            }
11014            if let Some(_) = self.vsock_listeners {
11015                return 21;
11016            }
11017            if let Some(_) = self.virtio_sound_input {
11018                return 20;
11019            }
11020            if let Some(_) = self.virtio_sound {
11021                return 19;
11022            }
11023            if let Some(_) = self.virtio_vsock {
11024                return 18;
11025            }
11026            if let Some(_) = self.virtio_rng {
11027                return 17;
11028            }
11029            if let Some(_) = self.virtio_gpu {
11030                return 16;
11031            }
11032            if let Some(_) = self.virtio_console {
11033                return 15;
11034            }
11035            if let Some(_) = self.virtio_balloon {
11036                return 14;
11037            }
11038            if let Some(_) = self.default_net {
11039                return 13;
11040            }
11041            if let Some(_) = self.net_devices {
11042                return 10;
11043            }
11044            if let Some(_) = self.block_devices {
11045                return 9;
11046            }
11047            if let Some(_) = self.guest_memory {
11048                return 8;
11049            }
11050            if let Some(_) = self.cpus {
11051                return 7;
11052            }
11053            if let Some(_) = self.cmdline_add {
11054                return 6;
11055            }
11056            if let Some(_) = self.cmdline {
11057                return 5;
11058            }
11059            if let Some(_) = self.dtb_overlay {
11060                return 4;
11061            }
11062            if let Some(_) = self.ramdisk {
11063                return 3;
11064            }
11065            if let Some(_) = self.kernel {
11066                return 2;
11067            }
11068            if let Some(_) = self.kernel_type {
11069                return 1;
11070            }
11071            0
11072        }
11073    }
11074
11075    impl fidl::encoding::ResourceTypeMarker for GuestConfig {
11076        type Borrowed<'a> = &'a mut Self;
11077        fn take_or_borrow<'a>(
11078            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11079        ) -> Self::Borrowed<'a> {
11080            value
11081        }
11082    }
11083
11084    unsafe impl fidl::encoding::TypeMarker for GuestConfig {
11085        type Owned = Self;
11086
11087        #[inline(always)]
11088        fn inline_align(_context: fidl::encoding::Context) -> usize {
11089            8
11090        }
11091
11092        #[inline(always)]
11093        fn inline_size(_context: fidl::encoding::Context) -> usize {
11094            16
11095        }
11096    }
11097
11098    unsafe impl fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
11099        for &mut GuestConfig
11100    {
11101        unsafe fn encode(
11102            self,
11103            encoder: &mut fidl::encoding::Encoder<
11104                '_,
11105                fidl::encoding::DefaultFuchsiaResourceDialect,
11106            >,
11107            offset: usize,
11108            mut depth: fidl::encoding::Depth,
11109        ) -> fidl::Result<()> {
11110            encoder.debug_check_bounds::<GuestConfig>(offset);
11111            // Vector header
11112            let max_ordinal: u64 = self.max_ordinal_present();
11113            encoder.write_num(max_ordinal, offset);
11114            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11115            // Calling encoder.out_of_line_offset(0) is not allowed.
11116            if max_ordinal == 0 {
11117                return Ok(());
11118            }
11119            depth.increment()?;
11120            let envelope_size = 8;
11121            let bytes_len = max_ordinal as usize * envelope_size;
11122            #[allow(unused_variables)]
11123            let offset = encoder.out_of_line_offset(bytes_len);
11124            let mut _prev_end_offset: usize = 0;
11125            if 1 > max_ordinal {
11126                return Ok(());
11127            }
11128
11129            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11130            // are envelope_size bytes.
11131            let cur_offset: usize = (1 - 1) * envelope_size;
11132
11133            // Zero reserved fields.
11134            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11135
11136            // Safety:
11137            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11138            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11139            //   envelope_size bytes, there is always sufficient room.
11140            fidl::encoding::encode_in_envelope_optional::<
11141                KernelType,
11142                fidl::encoding::DefaultFuchsiaResourceDialect,
11143            >(
11144                self.kernel_type
11145                    .as_ref()
11146                    .map(<KernelType as fidl::encoding::ValueTypeMarker>::borrow),
11147                encoder,
11148                offset + cur_offset,
11149                depth,
11150            )?;
11151
11152            _prev_end_offset = cur_offset + envelope_size;
11153            if 2 > max_ordinal {
11154                return Ok(());
11155            }
11156
11157            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11158            // are envelope_size bytes.
11159            let cur_offset: usize = (2 - 1) * envelope_size;
11160
11161            // Zero reserved fields.
11162            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11163
11164            // Safety:
11165            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11166            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11167            //   envelope_size bytes, there is always sufficient room.
11168            fidl::encoding::encode_in_envelope_optional::<
11169                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11170                fidl::encoding::DefaultFuchsiaResourceDialect,
11171            >(
11172                self.kernel.as_mut().map(
11173                    <fidl::encoding::Endpoint<
11174                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11175                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11176                ),
11177                encoder,
11178                offset + cur_offset,
11179                depth,
11180            )?;
11181
11182            _prev_end_offset = cur_offset + envelope_size;
11183            if 3 > max_ordinal {
11184                return Ok(());
11185            }
11186
11187            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11188            // are envelope_size bytes.
11189            let cur_offset: usize = (3 - 1) * envelope_size;
11190
11191            // Zero reserved fields.
11192            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11193
11194            // Safety:
11195            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11196            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11197            //   envelope_size bytes, there is always sufficient room.
11198            fidl::encoding::encode_in_envelope_optional::<
11199                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11200                fidl::encoding::DefaultFuchsiaResourceDialect,
11201            >(
11202                self.ramdisk.as_mut().map(
11203                    <fidl::encoding::Endpoint<
11204                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11205                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11206                ),
11207                encoder,
11208                offset + cur_offset,
11209                depth,
11210            )?;
11211
11212            _prev_end_offset = cur_offset + envelope_size;
11213            if 4 > max_ordinal {
11214                return Ok(());
11215            }
11216
11217            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11218            // are envelope_size bytes.
11219            let cur_offset: usize = (4 - 1) * envelope_size;
11220
11221            // Zero reserved fields.
11222            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11223
11224            // Safety:
11225            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11226            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11227            //   envelope_size bytes, there is always sufficient room.
11228            fidl::encoding::encode_in_envelope_optional::<
11229                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11230                fidl::encoding::DefaultFuchsiaResourceDialect,
11231            >(
11232                self.dtb_overlay.as_mut().map(
11233                    <fidl::encoding::Endpoint<
11234                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11235                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11236                ),
11237                encoder,
11238                offset + cur_offset,
11239                depth,
11240            )?;
11241
11242            _prev_end_offset = cur_offset + envelope_size;
11243            if 5 > max_ordinal {
11244                return Ok(());
11245            }
11246
11247            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11248            // are envelope_size bytes.
11249            let cur_offset: usize = (5 - 1) * envelope_size;
11250
11251            // Zero reserved fields.
11252            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11253
11254            // Safety:
11255            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11256            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11257            //   envelope_size bytes, there is always sufficient room.
11258            fidl::encoding::encode_in_envelope_optional::<
11259                fidl::encoding::UnboundedString,
11260                fidl::encoding::DefaultFuchsiaResourceDialect,
11261            >(
11262                self.cmdline.as_ref().map(
11263                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
11264                ),
11265                encoder,
11266                offset + cur_offset,
11267                depth,
11268            )?;
11269
11270            _prev_end_offset = cur_offset + envelope_size;
11271            if 6 > max_ordinal {
11272                return Ok(());
11273            }
11274
11275            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11276            // are envelope_size bytes.
11277            let cur_offset: usize = (6 - 1) * envelope_size;
11278
11279            // Zero reserved fields.
11280            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11281
11282            // Safety:
11283            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11284            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11285            //   envelope_size bytes, there is always sufficient room.
11286            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11287            self.cmdline_add.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow),
11288            encoder, offset + cur_offset, depth
11289        )?;
11290
11291            _prev_end_offset = cur_offset + envelope_size;
11292            if 7 > max_ordinal {
11293                return Ok(());
11294            }
11295
11296            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11297            // are envelope_size bytes.
11298            let cur_offset: usize = (7 - 1) * envelope_size;
11299
11300            // Zero reserved fields.
11301            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11302
11303            // Safety:
11304            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11305            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11306            //   envelope_size bytes, there is always sufficient room.
11307            fidl::encoding::encode_in_envelope_optional::<
11308                u8,
11309                fidl::encoding::DefaultFuchsiaResourceDialect,
11310            >(
11311                self.cpus.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
11312                encoder,
11313                offset + cur_offset,
11314                depth,
11315            )?;
11316
11317            _prev_end_offset = cur_offset + envelope_size;
11318            if 8 > max_ordinal {
11319                return Ok(());
11320            }
11321
11322            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11323            // are envelope_size bytes.
11324            let cur_offset: usize = (8 - 1) * envelope_size;
11325
11326            // Zero reserved fields.
11327            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11328
11329            // Safety:
11330            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11331            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11332            //   envelope_size bytes, there is always sufficient room.
11333            fidl::encoding::encode_in_envelope_optional::<
11334                u64,
11335                fidl::encoding::DefaultFuchsiaResourceDialect,
11336            >(
11337                self.guest_memory.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11338                encoder,
11339                offset + cur_offset,
11340                depth,
11341            )?;
11342
11343            _prev_end_offset = cur_offset + envelope_size;
11344            if 9 > max_ordinal {
11345                return Ok(());
11346            }
11347
11348            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11349            // are envelope_size bytes.
11350            let cur_offset: usize = (9 - 1) * envelope_size;
11351
11352            // Zero reserved fields.
11353            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11354
11355            // Safety:
11356            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11357            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11358            //   envelope_size bytes, there is always sufficient room.
11359            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11360            self.block_devices.as_mut().map(<fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11361            encoder, offset + cur_offset, depth
11362        )?;
11363
11364            _prev_end_offset = cur_offset + envelope_size;
11365            if 10 > max_ordinal {
11366                return Ok(());
11367            }
11368
11369            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11370            // are envelope_size bytes.
11371            let cur_offset: usize = (10 - 1) * envelope_size;
11372
11373            // Zero reserved fields.
11374            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11375
11376            // Safety:
11377            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11378            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11379            //   envelope_size bytes, there is always sufficient room.
11380            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11381            self.net_devices.as_ref().map(<fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11382            encoder, offset + cur_offset, depth
11383        )?;
11384
11385            _prev_end_offset = cur_offset + envelope_size;
11386            if 13 > max_ordinal {
11387                return Ok(());
11388            }
11389
11390            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11391            // are envelope_size bytes.
11392            let cur_offset: usize = (13 - 1) * envelope_size;
11393
11394            // Zero reserved fields.
11395            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11396
11397            // Safety:
11398            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11399            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11400            //   envelope_size bytes, there is always sufficient room.
11401            fidl::encoding::encode_in_envelope_optional::<
11402                bool,
11403                fidl::encoding::DefaultFuchsiaResourceDialect,
11404            >(
11405                self.default_net.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11406                encoder,
11407                offset + cur_offset,
11408                depth,
11409            )?;
11410
11411            _prev_end_offset = cur_offset + envelope_size;
11412            if 14 > max_ordinal {
11413                return Ok(());
11414            }
11415
11416            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11417            // are envelope_size bytes.
11418            let cur_offset: usize = (14 - 1) * envelope_size;
11419
11420            // Zero reserved fields.
11421            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11422
11423            // Safety:
11424            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11425            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11426            //   envelope_size bytes, there is always sufficient room.
11427            fidl::encoding::encode_in_envelope_optional::<
11428                bool,
11429                fidl::encoding::DefaultFuchsiaResourceDialect,
11430            >(
11431                self.virtio_balloon.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11432                encoder,
11433                offset + cur_offset,
11434                depth,
11435            )?;
11436
11437            _prev_end_offset = cur_offset + envelope_size;
11438            if 15 > max_ordinal {
11439                return Ok(());
11440            }
11441
11442            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11443            // are envelope_size bytes.
11444            let cur_offset: usize = (15 - 1) * envelope_size;
11445
11446            // Zero reserved fields.
11447            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11448
11449            // Safety:
11450            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11451            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11452            //   envelope_size bytes, there is always sufficient room.
11453            fidl::encoding::encode_in_envelope_optional::<
11454                bool,
11455                fidl::encoding::DefaultFuchsiaResourceDialect,
11456            >(
11457                self.virtio_console.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11458                encoder,
11459                offset + cur_offset,
11460                depth,
11461            )?;
11462
11463            _prev_end_offset = cur_offset + envelope_size;
11464            if 16 > max_ordinal {
11465                return Ok(());
11466            }
11467
11468            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11469            // are envelope_size bytes.
11470            let cur_offset: usize = (16 - 1) * envelope_size;
11471
11472            // Zero reserved fields.
11473            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11474
11475            // Safety:
11476            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11477            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11478            //   envelope_size bytes, there is always sufficient room.
11479            fidl::encoding::encode_in_envelope_optional::<
11480                bool,
11481                fidl::encoding::DefaultFuchsiaResourceDialect,
11482            >(
11483                self.virtio_gpu.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11484                encoder,
11485                offset + cur_offset,
11486                depth,
11487            )?;
11488
11489            _prev_end_offset = cur_offset + envelope_size;
11490            if 17 > max_ordinal {
11491                return Ok(());
11492            }
11493
11494            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11495            // are envelope_size bytes.
11496            let cur_offset: usize = (17 - 1) * envelope_size;
11497
11498            // Zero reserved fields.
11499            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11500
11501            // Safety:
11502            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11503            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11504            //   envelope_size bytes, there is always sufficient room.
11505            fidl::encoding::encode_in_envelope_optional::<
11506                bool,
11507                fidl::encoding::DefaultFuchsiaResourceDialect,
11508            >(
11509                self.virtio_rng.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11510                encoder,
11511                offset + cur_offset,
11512                depth,
11513            )?;
11514
11515            _prev_end_offset = cur_offset + envelope_size;
11516            if 18 > max_ordinal {
11517                return Ok(());
11518            }
11519
11520            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11521            // are envelope_size bytes.
11522            let cur_offset: usize = (18 - 1) * envelope_size;
11523
11524            // Zero reserved fields.
11525            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11526
11527            // Safety:
11528            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11529            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11530            //   envelope_size bytes, there is always sufficient room.
11531            fidl::encoding::encode_in_envelope_optional::<
11532                bool,
11533                fidl::encoding::DefaultFuchsiaResourceDialect,
11534            >(
11535                self.virtio_vsock.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11536                encoder,
11537                offset + cur_offset,
11538                depth,
11539            )?;
11540
11541            _prev_end_offset = cur_offset + envelope_size;
11542            if 19 > max_ordinal {
11543                return Ok(());
11544            }
11545
11546            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11547            // are envelope_size bytes.
11548            let cur_offset: usize = (19 - 1) * envelope_size;
11549
11550            // Zero reserved fields.
11551            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11552
11553            // Safety:
11554            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11555            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11556            //   envelope_size bytes, there is always sufficient room.
11557            fidl::encoding::encode_in_envelope_optional::<
11558                bool,
11559                fidl::encoding::DefaultFuchsiaResourceDialect,
11560            >(
11561                self.virtio_sound.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11562                encoder,
11563                offset + cur_offset,
11564                depth,
11565            )?;
11566
11567            _prev_end_offset = cur_offset + envelope_size;
11568            if 20 > max_ordinal {
11569                return Ok(());
11570            }
11571
11572            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11573            // are envelope_size bytes.
11574            let cur_offset: usize = (20 - 1) * envelope_size;
11575
11576            // Zero reserved fields.
11577            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11578
11579            // Safety:
11580            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11581            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11582            //   envelope_size bytes, there is always sufficient room.
11583            fidl::encoding::encode_in_envelope_optional::<
11584                bool,
11585                fidl::encoding::DefaultFuchsiaResourceDialect,
11586            >(
11587                self.virtio_sound_input
11588                    .as_ref()
11589                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11590                encoder,
11591                offset + cur_offset,
11592                depth,
11593            )?;
11594
11595            _prev_end_offset = cur_offset + envelope_size;
11596            if 21 > max_ordinal {
11597                return Ok(());
11598            }
11599
11600            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11601            // are envelope_size bytes.
11602            let cur_offset: usize = (21 - 1) * envelope_size;
11603
11604            // Zero reserved fields.
11605            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11606
11607            // Safety:
11608            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11609            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11610            //   envelope_size bytes, there is always sufficient room.
11611            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Listener>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11612            self.vsock_listeners.as_mut().map(<fidl::encoding::UnboundedVector<Listener> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11613            encoder, offset + cur_offset, depth
11614        )?;
11615
11616            _prev_end_offset = cur_offset + envelope_size;
11617            if 22 > max_ordinal {
11618                return Ok(());
11619            }
11620
11621            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11622            // are envelope_size bytes.
11623            let cur_offset: usize = (22 - 1) * envelope_size;
11624
11625            // Zero reserved fields.
11626            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11627
11628            // Safety:
11629            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11630            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11631            //   envelope_size bytes, there is always sufficient room.
11632            fidl::encoding::encode_in_envelope_optional::<
11633                bool,
11634                fidl::encoding::DefaultFuchsiaResourceDialect,
11635            >(
11636                self.virtio_mem.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11637                encoder,
11638                offset + cur_offset,
11639                depth,
11640            )?;
11641
11642            _prev_end_offset = cur_offset + envelope_size;
11643            if 23 > max_ordinal {
11644                return Ok(());
11645            }
11646
11647            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11648            // are envelope_size bytes.
11649            let cur_offset: usize = (23 - 1) * envelope_size;
11650
11651            // Zero reserved fields.
11652            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11653
11654            // Safety:
11655            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11656            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11657            //   envelope_size bytes, there is always sufficient room.
11658            fidl::encoding::encode_in_envelope_optional::<
11659                u64,
11660                fidl::encoding::DefaultFuchsiaResourceDialect,
11661            >(
11662                self.virtio_mem_block_size
11663                    .as_ref()
11664                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11665                encoder,
11666                offset + cur_offset,
11667                depth,
11668            )?;
11669
11670            _prev_end_offset = cur_offset + envelope_size;
11671            if 24 > max_ordinal {
11672                return Ok(());
11673            }
11674
11675            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11676            // are envelope_size bytes.
11677            let cur_offset: usize = (24 - 1) * envelope_size;
11678
11679            // Zero reserved fields.
11680            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11681
11682            // Safety:
11683            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11684            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11685            //   envelope_size bytes, there is always sufficient room.
11686            fidl::encoding::encode_in_envelope_optional::<
11687                u64,
11688                fidl::encoding::DefaultFuchsiaResourceDialect,
11689            >(
11690                self.virtio_mem_region_size
11691                    .as_ref()
11692                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11693                encoder,
11694                offset + cur_offset,
11695                depth,
11696            )?;
11697
11698            _prev_end_offset = cur_offset + envelope_size;
11699            if 25 > max_ordinal {
11700                return Ok(());
11701            }
11702
11703            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11704            // are envelope_size bytes.
11705            let cur_offset: usize = (25 - 1) * envelope_size;
11706
11707            // Zero reserved fields.
11708            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11709
11710            // Safety:
11711            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11712            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11713            //   envelope_size bytes, there is always sufficient room.
11714            fidl::encoding::encode_in_envelope_optional::<
11715                u64,
11716                fidl::encoding::DefaultFuchsiaResourceDialect,
11717            >(
11718                self.virtio_mem_region_alignment
11719                    .as_ref()
11720                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11721                encoder,
11722                offset + cur_offset,
11723                depth,
11724            )?;
11725
11726            _prev_end_offset = cur_offset + envelope_size;
11727
11728            Ok(())
11729        }
11730    }
11731
11732    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for GuestConfig {
11733        #[inline(always)]
11734        fn new_empty() -> Self {
11735            Self::default()
11736        }
11737
11738        unsafe fn decode(
11739            &mut self,
11740            decoder: &mut fidl::encoding::Decoder<
11741                '_,
11742                fidl::encoding::DefaultFuchsiaResourceDialect,
11743            >,
11744            offset: usize,
11745            mut depth: fidl::encoding::Depth,
11746        ) -> fidl::Result<()> {
11747            decoder.debug_check_bounds::<Self>(offset);
11748            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11749                None => return Err(fidl::Error::NotNullable),
11750                Some(len) => len,
11751            };
11752            // Calling decoder.out_of_line_offset(0) is not allowed.
11753            if len == 0 {
11754                return Ok(());
11755            };
11756            depth.increment()?;
11757            let envelope_size = 8;
11758            let bytes_len = len * envelope_size;
11759            let offset = decoder.out_of_line_offset(bytes_len)?;
11760            // Decode the envelope for each type.
11761            let mut _next_ordinal_to_read = 0;
11762            let mut next_offset = offset;
11763            let end_offset = offset + bytes_len;
11764            _next_ordinal_to_read += 1;
11765            if next_offset >= end_offset {
11766                return Ok(());
11767            }
11768
11769            // Decode unknown envelopes for gaps in ordinals.
11770            while _next_ordinal_to_read < 1 {
11771                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11772                _next_ordinal_to_read += 1;
11773                next_offset += envelope_size;
11774            }
11775
11776            let next_out_of_line = decoder.next_out_of_line();
11777            let handles_before = decoder.remaining_handles();
11778            if let Some((inlined, num_bytes, num_handles)) =
11779                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11780            {
11781                let member_inline_size =
11782                    <KernelType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11783                if inlined != (member_inline_size <= 4) {
11784                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11785                }
11786                let inner_offset;
11787                let mut inner_depth = depth.clone();
11788                if inlined {
11789                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11790                    inner_offset = next_offset;
11791                } else {
11792                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11793                    inner_depth.increment()?;
11794                }
11795                let val_ref = self.kernel_type.get_or_insert_with(|| {
11796                    fidl::new_empty!(KernelType, fidl::encoding::DefaultFuchsiaResourceDialect)
11797                });
11798                fidl::decode!(
11799                    KernelType,
11800                    fidl::encoding::DefaultFuchsiaResourceDialect,
11801                    val_ref,
11802                    decoder,
11803                    inner_offset,
11804                    inner_depth
11805                )?;
11806                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11807                {
11808                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11809                }
11810                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11811                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11812                }
11813            }
11814
11815            next_offset += envelope_size;
11816            _next_ordinal_to_read += 1;
11817            if next_offset >= end_offset {
11818                return Ok(());
11819            }
11820
11821            // Decode unknown envelopes for gaps in ordinals.
11822            while _next_ordinal_to_read < 2 {
11823                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11824                _next_ordinal_to_read += 1;
11825                next_offset += envelope_size;
11826            }
11827
11828            let next_out_of_line = decoder.next_out_of_line();
11829            let handles_before = decoder.remaining_handles();
11830            if let Some((inlined, num_bytes, num_handles)) =
11831                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11832            {
11833                let member_inline_size = <fidl::encoding::Endpoint<
11834                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11835                > as fidl::encoding::TypeMarker>::inline_size(
11836                    decoder.context
11837                );
11838                if inlined != (member_inline_size <= 4) {
11839                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11840                }
11841                let inner_offset;
11842                let mut inner_depth = depth.clone();
11843                if inlined {
11844                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11845                    inner_offset = next_offset;
11846                } else {
11847                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11848                    inner_depth.increment()?;
11849                }
11850                let val_ref = self.kernel.get_or_insert_with(|| {
11851                    fidl::new_empty!(
11852                        fidl::encoding::Endpoint<
11853                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11854                        >,
11855                        fidl::encoding::DefaultFuchsiaResourceDialect
11856                    )
11857                });
11858                fidl::decode!(
11859                    fidl::encoding::Endpoint<
11860                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11861                    >,
11862                    fidl::encoding::DefaultFuchsiaResourceDialect,
11863                    val_ref,
11864                    decoder,
11865                    inner_offset,
11866                    inner_depth
11867                )?;
11868                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11869                {
11870                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11871                }
11872                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11873                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11874                }
11875            }
11876
11877            next_offset += envelope_size;
11878            _next_ordinal_to_read += 1;
11879            if next_offset >= end_offset {
11880                return Ok(());
11881            }
11882
11883            // Decode unknown envelopes for gaps in ordinals.
11884            while _next_ordinal_to_read < 3 {
11885                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11886                _next_ordinal_to_read += 1;
11887                next_offset += envelope_size;
11888            }
11889
11890            let next_out_of_line = decoder.next_out_of_line();
11891            let handles_before = decoder.remaining_handles();
11892            if let Some((inlined, num_bytes, num_handles)) =
11893                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11894            {
11895                let member_inline_size = <fidl::encoding::Endpoint<
11896                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11897                > as fidl::encoding::TypeMarker>::inline_size(
11898                    decoder.context
11899                );
11900                if inlined != (member_inline_size <= 4) {
11901                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11902                }
11903                let inner_offset;
11904                let mut inner_depth = depth.clone();
11905                if inlined {
11906                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11907                    inner_offset = next_offset;
11908                } else {
11909                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11910                    inner_depth.increment()?;
11911                }
11912                let val_ref = self.ramdisk.get_or_insert_with(|| {
11913                    fidl::new_empty!(
11914                        fidl::encoding::Endpoint<
11915                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11916                        >,
11917                        fidl::encoding::DefaultFuchsiaResourceDialect
11918                    )
11919                });
11920                fidl::decode!(
11921                    fidl::encoding::Endpoint<
11922                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11923                    >,
11924                    fidl::encoding::DefaultFuchsiaResourceDialect,
11925                    val_ref,
11926                    decoder,
11927                    inner_offset,
11928                    inner_depth
11929                )?;
11930                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11931                {
11932                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11933                }
11934                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11935                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11936                }
11937            }
11938
11939            next_offset += envelope_size;
11940            _next_ordinal_to_read += 1;
11941            if next_offset >= end_offset {
11942                return Ok(());
11943            }
11944
11945            // Decode unknown envelopes for gaps in ordinals.
11946            while _next_ordinal_to_read < 4 {
11947                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11948                _next_ordinal_to_read += 1;
11949                next_offset += envelope_size;
11950            }
11951
11952            let next_out_of_line = decoder.next_out_of_line();
11953            let handles_before = decoder.remaining_handles();
11954            if let Some((inlined, num_bytes, num_handles)) =
11955                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11956            {
11957                let member_inline_size = <fidl::encoding::Endpoint<
11958                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11959                > as fidl::encoding::TypeMarker>::inline_size(
11960                    decoder.context
11961                );
11962                if inlined != (member_inline_size <= 4) {
11963                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11964                }
11965                let inner_offset;
11966                let mut inner_depth = depth.clone();
11967                if inlined {
11968                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11969                    inner_offset = next_offset;
11970                } else {
11971                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11972                    inner_depth.increment()?;
11973                }
11974                let val_ref = self.dtb_overlay.get_or_insert_with(|| {
11975                    fidl::new_empty!(
11976                        fidl::encoding::Endpoint<
11977                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11978                        >,
11979                        fidl::encoding::DefaultFuchsiaResourceDialect
11980                    )
11981                });
11982                fidl::decode!(
11983                    fidl::encoding::Endpoint<
11984                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11985                    >,
11986                    fidl::encoding::DefaultFuchsiaResourceDialect,
11987                    val_ref,
11988                    decoder,
11989                    inner_offset,
11990                    inner_depth
11991                )?;
11992                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11993                {
11994                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11995                }
11996                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11997                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11998                }
11999            }
12000
12001            next_offset += envelope_size;
12002            _next_ordinal_to_read += 1;
12003            if next_offset >= end_offset {
12004                return Ok(());
12005            }
12006
12007            // Decode unknown envelopes for gaps in ordinals.
12008            while _next_ordinal_to_read < 5 {
12009                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12010                _next_ordinal_to_read += 1;
12011                next_offset += envelope_size;
12012            }
12013
12014            let next_out_of_line = decoder.next_out_of_line();
12015            let handles_before = decoder.remaining_handles();
12016            if let Some((inlined, num_bytes, num_handles)) =
12017                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12018            {
12019                let member_inline_size =
12020                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
12021                        decoder.context,
12022                    );
12023                if inlined != (member_inline_size <= 4) {
12024                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12025                }
12026                let inner_offset;
12027                let mut inner_depth = depth.clone();
12028                if inlined {
12029                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12030                    inner_offset = next_offset;
12031                } else {
12032                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12033                    inner_depth.increment()?;
12034                }
12035                let val_ref = self.cmdline.get_or_insert_with(|| {
12036                    fidl::new_empty!(
12037                        fidl::encoding::UnboundedString,
12038                        fidl::encoding::DefaultFuchsiaResourceDialect
12039                    )
12040                });
12041                fidl::decode!(
12042                    fidl::encoding::UnboundedString,
12043                    fidl::encoding::DefaultFuchsiaResourceDialect,
12044                    val_ref,
12045                    decoder,
12046                    inner_offset,
12047                    inner_depth
12048                )?;
12049                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12050                {
12051                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12052                }
12053                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12054                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12055                }
12056            }
12057
12058            next_offset += envelope_size;
12059            _next_ordinal_to_read += 1;
12060            if next_offset >= end_offset {
12061                return Ok(());
12062            }
12063
12064            // Decode unknown envelopes for gaps in ordinals.
12065            while _next_ordinal_to_read < 6 {
12066                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12067                _next_ordinal_to_read += 1;
12068                next_offset += envelope_size;
12069            }
12070
12071            let next_out_of_line = decoder.next_out_of_line();
12072            let handles_before = decoder.remaining_handles();
12073            if let Some((inlined, num_bytes, num_handles)) =
12074                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12075            {
12076                let member_inline_size = <fidl::encoding::UnboundedVector<
12077                    fidl::encoding::UnboundedString,
12078                > as fidl::encoding::TypeMarker>::inline_size(
12079                    decoder.context
12080                );
12081                if inlined != (member_inline_size <= 4) {
12082                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12083                }
12084                let inner_offset;
12085                let mut inner_depth = depth.clone();
12086                if inlined {
12087                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12088                    inner_offset = next_offset;
12089                } else {
12090                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12091                    inner_depth.increment()?;
12092                }
12093                let val_ref = self.cmdline_add.get_or_insert_with(|| {
12094                    fidl::new_empty!(
12095                        fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
12096                        fidl::encoding::DefaultFuchsiaResourceDialect
12097                    )
12098                });
12099                fidl::decode!(
12100                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
12101                    fidl::encoding::DefaultFuchsiaResourceDialect,
12102                    val_ref,
12103                    decoder,
12104                    inner_offset,
12105                    inner_depth
12106                )?;
12107                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12108                {
12109                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12110                }
12111                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12112                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12113                }
12114            }
12115
12116            next_offset += envelope_size;
12117            _next_ordinal_to_read += 1;
12118            if next_offset >= end_offset {
12119                return Ok(());
12120            }
12121
12122            // Decode unknown envelopes for gaps in ordinals.
12123            while _next_ordinal_to_read < 7 {
12124                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12125                _next_ordinal_to_read += 1;
12126                next_offset += envelope_size;
12127            }
12128
12129            let next_out_of_line = decoder.next_out_of_line();
12130            let handles_before = decoder.remaining_handles();
12131            if let Some((inlined, num_bytes, num_handles)) =
12132                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12133            {
12134                let member_inline_size =
12135                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12136                if inlined != (member_inline_size <= 4) {
12137                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12138                }
12139                let inner_offset;
12140                let mut inner_depth = depth.clone();
12141                if inlined {
12142                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12143                    inner_offset = next_offset;
12144                } else {
12145                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12146                    inner_depth.increment()?;
12147                }
12148                let val_ref = self.cpus.get_or_insert_with(|| {
12149                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12150                });
12151                fidl::decode!(
12152                    u8,
12153                    fidl::encoding::DefaultFuchsiaResourceDialect,
12154                    val_ref,
12155                    decoder,
12156                    inner_offset,
12157                    inner_depth
12158                )?;
12159                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12160                {
12161                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12162                }
12163                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12164                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12165                }
12166            }
12167
12168            next_offset += envelope_size;
12169            _next_ordinal_to_read += 1;
12170            if next_offset >= end_offset {
12171                return Ok(());
12172            }
12173
12174            // Decode unknown envelopes for gaps in ordinals.
12175            while _next_ordinal_to_read < 8 {
12176                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12177                _next_ordinal_to_read += 1;
12178                next_offset += envelope_size;
12179            }
12180
12181            let next_out_of_line = decoder.next_out_of_line();
12182            let handles_before = decoder.remaining_handles();
12183            if let Some((inlined, num_bytes, num_handles)) =
12184                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12185            {
12186                let member_inline_size =
12187                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12188                if inlined != (member_inline_size <= 4) {
12189                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12190                }
12191                let inner_offset;
12192                let mut inner_depth = depth.clone();
12193                if inlined {
12194                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12195                    inner_offset = next_offset;
12196                } else {
12197                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12198                    inner_depth.increment()?;
12199                }
12200                let val_ref = self.guest_memory.get_or_insert_with(|| {
12201                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12202                });
12203                fidl::decode!(
12204                    u64,
12205                    fidl::encoding::DefaultFuchsiaResourceDialect,
12206                    val_ref,
12207                    decoder,
12208                    inner_offset,
12209                    inner_depth
12210                )?;
12211                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12212                {
12213                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12214                }
12215                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12216                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12217                }
12218            }
12219
12220            next_offset += envelope_size;
12221            _next_ordinal_to_read += 1;
12222            if next_offset >= end_offset {
12223                return Ok(());
12224            }
12225
12226            // Decode unknown envelopes for gaps in ordinals.
12227            while _next_ordinal_to_read < 9 {
12228                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12229                _next_ordinal_to_read += 1;
12230                next_offset += envelope_size;
12231            }
12232
12233            let next_out_of_line = decoder.next_out_of_line();
12234            let handles_before = decoder.remaining_handles();
12235            if let Some((inlined, num_bytes, num_handles)) =
12236                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12237            {
12238                let member_inline_size = <fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12239                if inlined != (member_inline_size <= 4) {
12240                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12241                }
12242                let inner_offset;
12243                let mut inner_depth = depth.clone();
12244                if inlined {
12245                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12246                    inner_offset = next_offset;
12247                } else {
12248                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12249                    inner_depth.increment()?;
12250                }
12251                let val_ref =
12252                self.block_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12253                fidl::decode!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12254                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12255                {
12256                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12257                }
12258                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12259                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12260                }
12261            }
12262
12263            next_offset += envelope_size;
12264            _next_ordinal_to_read += 1;
12265            if next_offset >= end_offset {
12266                return Ok(());
12267            }
12268
12269            // Decode unknown envelopes for gaps in ordinals.
12270            while _next_ordinal_to_read < 10 {
12271                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12272                _next_ordinal_to_read += 1;
12273                next_offset += envelope_size;
12274            }
12275
12276            let next_out_of_line = decoder.next_out_of_line();
12277            let handles_before = decoder.remaining_handles();
12278            if let Some((inlined, num_bytes, num_handles)) =
12279                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12280            {
12281                let member_inline_size = <fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12282                if inlined != (member_inline_size <= 4) {
12283                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12284                }
12285                let inner_offset;
12286                let mut inner_depth = depth.clone();
12287                if inlined {
12288                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12289                    inner_offset = next_offset;
12290                } else {
12291                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12292                    inner_depth.increment()?;
12293                }
12294                let val_ref =
12295                self.net_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12296                fidl::decode!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12297                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12298                {
12299                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12300                }
12301                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12302                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12303                }
12304            }
12305
12306            next_offset += envelope_size;
12307            _next_ordinal_to_read += 1;
12308            if next_offset >= end_offset {
12309                return Ok(());
12310            }
12311
12312            // Decode unknown envelopes for gaps in ordinals.
12313            while _next_ordinal_to_read < 13 {
12314                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12315                _next_ordinal_to_read += 1;
12316                next_offset += envelope_size;
12317            }
12318
12319            let next_out_of_line = decoder.next_out_of_line();
12320            let handles_before = decoder.remaining_handles();
12321            if let Some((inlined, num_bytes, num_handles)) =
12322                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12323            {
12324                let member_inline_size =
12325                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12326                if inlined != (member_inline_size <= 4) {
12327                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12328                }
12329                let inner_offset;
12330                let mut inner_depth = depth.clone();
12331                if inlined {
12332                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12333                    inner_offset = next_offset;
12334                } else {
12335                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12336                    inner_depth.increment()?;
12337                }
12338                let val_ref = self.default_net.get_or_insert_with(|| {
12339                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12340                });
12341                fidl::decode!(
12342                    bool,
12343                    fidl::encoding::DefaultFuchsiaResourceDialect,
12344                    val_ref,
12345                    decoder,
12346                    inner_offset,
12347                    inner_depth
12348                )?;
12349                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12350                {
12351                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12352                }
12353                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12354                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12355                }
12356            }
12357
12358            next_offset += envelope_size;
12359            _next_ordinal_to_read += 1;
12360            if next_offset >= end_offset {
12361                return Ok(());
12362            }
12363
12364            // Decode unknown envelopes for gaps in ordinals.
12365            while _next_ordinal_to_read < 14 {
12366                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12367                _next_ordinal_to_read += 1;
12368                next_offset += envelope_size;
12369            }
12370
12371            let next_out_of_line = decoder.next_out_of_line();
12372            let handles_before = decoder.remaining_handles();
12373            if let Some((inlined, num_bytes, num_handles)) =
12374                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12375            {
12376                let member_inline_size =
12377                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12378                if inlined != (member_inline_size <= 4) {
12379                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12380                }
12381                let inner_offset;
12382                let mut inner_depth = depth.clone();
12383                if inlined {
12384                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12385                    inner_offset = next_offset;
12386                } else {
12387                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12388                    inner_depth.increment()?;
12389                }
12390                let val_ref = self.virtio_balloon.get_or_insert_with(|| {
12391                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12392                });
12393                fidl::decode!(
12394                    bool,
12395                    fidl::encoding::DefaultFuchsiaResourceDialect,
12396                    val_ref,
12397                    decoder,
12398                    inner_offset,
12399                    inner_depth
12400                )?;
12401                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12402                {
12403                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12404                }
12405                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12406                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12407                }
12408            }
12409
12410            next_offset += envelope_size;
12411            _next_ordinal_to_read += 1;
12412            if next_offset >= end_offset {
12413                return Ok(());
12414            }
12415
12416            // Decode unknown envelopes for gaps in ordinals.
12417            while _next_ordinal_to_read < 15 {
12418                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12419                _next_ordinal_to_read += 1;
12420                next_offset += envelope_size;
12421            }
12422
12423            let next_out_of_line = decoder.next_out_of_line();
12424            let handles_before = decoder.remaining_handles();
12425            if let Some((inlined, num_bytes, num_handles)) =
12426                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12427            {
12428                let member_inline_size =
12429                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12430                if inlined != (member_inline_size <= 4) {
12431                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12432                }
12433                let inner_offset;
12434                let mut inner_depth = depth.clone();
12435                if inlined {
12436                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12437                    inner_offset = next_offset;
12438                } else {
12439                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12440                    inner_depth.increment()?;
12441                }
12442                let val_ref = self.virtio_console.get_or_insert_with(|| {
12443                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12444                });
12445                fidl::decode!(
12446                    bool,
12447                    fidl::encoding::DefaultFuchsiaResourceDialect,
12448                    val_ref,
12449                    decoder,
12450                    inner_offset,
12451                    inner_depth
12452                )?;
12453                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12454                {
12455                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12456                }
12457                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12458                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12459                }
12460            }
12461
12462            next_offset += envelope_size;
12463            _next_ordinal_to_read += 1;
12464            if next_offset >= end_offset {
12465                return Ok(());
12466            }
12467
12468            // Decode unknown envelopes for gaps in ordinals.
12469            while _next_ordinal_to_read < 16 {
12470                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12471                _next_ordinal_to_read += 1;
12472                next_offset += envelope_size;
12473            }
12474
12475            let next_out_of_line = decoder.next_out_of_line();
12476            let handles_before = decoder.remaining_handles();
12477            if let Some((inlined, num_bytes, num_handles)) =
12478                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12479            {
12480                let member_inline_size =
12481                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12482                if inlined != (member_inline_size <= 4) {
12483                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12484                }
12485                let inner_offset;
12486                let mut inner_depth = depth.clone();
12487                if inlined {
12488                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12489                    inner_offset = next_offset;
12490                } else {
12491                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12492                    inner_depth.increment()?;
12493                }
12494                let val_ref = self.virtio_gpu.get_or_insert_with(|| {
12495                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12496                });
12497                fidl::decode!(
12498                    bool,
12499                    fidl::encoding::DefaultFuchsiaResourceDialect,
12500                    val_ref,
12501                    decoder,
12502                    inner_offset,
12503                    inner_depth
12504                )?;
12505                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12506                {
12507                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12508                }
12509                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12510                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12511                }
12512            }
12513
12514            next_offset += envelope_size;
12515            _next_ordinal_to_read += 1;
12516            if next_offset >= end_offset {
12517                return Ok(());
12518            }
12519
12520            // Decode unknown envelopes for gaps in ordinals.
12521            while _next_ordinal_to_read < 17 {
12522                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12523                _next_ordinal_to_read += 1;
12524                next_offset += envelope_size;
12525            }
12526
12527            let next_out_of_line = decoder.next_out_of_line();
12528            let handles_before = decoder.remaining_handles();
12529            if let Some((inlined, num_bytes, num_handles)) =
12530                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12531            {
12532                let member_inline_size =
12533                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12534                if inlined != (member_inline_size <= 4) {
12535                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12536                }
12537                let inner_offset;
12538                let mut inner_depth = depth.clone();
12539                if inlined {
12540                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12541                    inner_offset = next_offset;
12542                } else {
12543                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12544                    inner_depth.increment()?;
12545                }
12546                let val_ref = self.virtio_rng.get_or_insert_with(|| {
12547                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12548                });
12549                fidl::decode!(
12550                    bool,
12551                    fidl::encoding::DefaultFuchsiaResourceDialect,
12552                    val_ref,
12553                    decoder,
12554                    inner_offset,
12555                    inner_depth
12556                )?;
12557                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12558                {
12559                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12560                }
12561                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12562                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12563                }
12564            }
12565
12566            next_offset += envelope_size;
12567            _next_ordinal_to_read += 1;
12568            if next_offset >= end_offset {
12569                return Ok(());
12570            }
12571
12572            // Decode unknown envelopes for gaps in ordinals.
12573            while _next_ordinal_to_read < 18 {
12574                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12575                _next_ordinal_to_read += 1;
12576                next_offset += envelope_size;
12577            }
12578
12579            let next_out_of_line = decoder.next_out_of_line();
12580            let handles_before = decoder.remaining_handles();
12581            if let Some((inlined, num_bytes, num_handles)) =
12582                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12583            {
12584                let member_inline_size =
12585                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12586                if inlined != (member_inline_size <= 4) {
12587                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12588                }
12589                let inner_offset;
12590                let mut inner_depth = depth.clone();
12591                if inlined {
12592                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12593                    inner_offset = next_offset;
12594                } else {
12595                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12596                    inner_depth.increment()?;
12597                }
12598                let val_ref = self.virtio_vsock.get_or_insert_with(|| {
12599                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12600                });
12601                fidl::decode!(
12602                    bool,
12603                    fidl::encoding::DefaultFuchsiaResourceDialect,
12604                    val_ref,
12605                    decoder,
12606                    inner_offset,
12607                    inner_depth
12608                )?;
12609                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12610                {
12611                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12612                }
12613                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12614                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12615                }
12616            }
12617
12618            next_offset += envelope_size;
12619            _next_ordinal_to_read += 1;
12620            if next_offset >= end_offset {
12621                return Ok(());
12622            }
12623
12624            // Decode unknown envelopes for gaps in ordinals.
12625            while _next_ordinal_to_read < 19 {
12626                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12627                _next_ordinal_to_read += 1;
12628                next_offset += envelope_size;
12629            }
12630
12631            let next_out_of_line = decoder.next_out_of_line();
12632            let handles_before = decoder.remaining_handles();
12633            if let Some((inlined, num_bytes, num_handles)) =
12634                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12635            {
12636                let member_inline_size =
12637                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12638                if inlined != (member_inline_size <= 4) {
12639                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12640                }
12641                let inner_offset;
12642                let mut inner_depth = depth.clone();
12643                if inlined {
12644                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12645                    inner_offset = next_offset;
12646                } else {
12647                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12648                    inner_depth.increment()?;
12649                }
12650                let val_ref = self.virtio_sound.get_or_insert_with(|| {
12651                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12652                });
12653                fidl::decode!(
12654                    bool,
12655                    fidl::encoding::DefaultFuchsiaResourceDialect,
12656                    val_ref,
12657                    decoder,
12658                    inner_offset,
12659                    inner_depth
12660                )?;
12661                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12662                {
12663                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12664                }
12665                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12666                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12667                }
12668            }
12669
12670            next_offset += envelope_size;
12671            _next_ordinal_to_read += 1;
12672            if next_offset >= end_offset {
12673                return Ok(());
12674            }
12675
12676            // Decode unknown envelopes for gaps in ordinals.
12677            while _next_ordinal_to_read < 20 {
12678                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12679                _next_ordinal_to_read += 1;
12680                next_offset += envelope_size;
12681            }
12682
12683            let next_out_of_line = decoder.next_out_of_line();
12684            let handles_before = decoder.remaining_handles();
12685            if let Some((inlined, num_bytes, num_handles)) =
12686                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12687            {
12688                let member_inline_size =
12689                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12690                if inlined != (member_inline_size <= 4) {
12691                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12692                }
12693                let inner_offset;
12694                let mut inner_depth = depth.clone();
12695                if inlined {
12696                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12697                    inner_offset = next_offset;
12698                } else {
12699                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12700                    inner_depth.increment()?;
12701                }
12702                let val_ref = self.virtio_sound_input.get_or_insert_with(|| {
12703                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12704                });
12705                fidl::decode!(
12706                    bool,
12707                    fidl::encoding::DefaultFuchsiaResourceDialect,
12708                    val_ref,
12709                    decoder,
12710                    inner_offset,
12711                    inner_depth
12712                )?;
12713                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12714                {
12715                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12716                }
12717                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12718                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12719                }
12720            }
12721
12722            next_offset += envelope_size;
12723            _next_ordinal_to_read += 1;
12724            if next_offset >= end_offset {
12725                return Ok(());
12726            }
12727
12728            // Decode unknown envelopes for gaps in ordinals.
12729            while _next_ordinal_to_read < 21 {
12730                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12731                _next_ordinal_to_read += 1;
12732                next_offset += envelope_size;
12733            }
12734
12735            let next_out_of_line = decoder.next_out_of_line();
12736            let handles_before = decoder.remaining_handles();
12737            if let Some((inlined, num_bytes, num_handles)) =
12738                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12739            {
12740                let member_inline_size = <fidl::encoding::UnboundedVector<Listener> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12741                if inlined != (member_inline_size <= 4) {
12742                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12743                }
12744                let inner_offset;
12745                let mut inner_depth = depth.clone();
12746                if inlined {
12747                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12748                    inner_offset = next_offset;
12749                } else {
12750                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12751                    inner_depth.increment()?;
12752                }
12753                let val_ref = self.vsock_listeners.get_or_insert_with(|| {
12754                    fidl::new_empty!(
12755                        fidl::encoding::UnboundedVector<Listener>,
12756                        fidl::encoding::DefaultFuchsiaResourceDialect
12757                    )
12758                });
12759                fidl::decode!(
12760                    fidl::encoding::UnboundedVector<Listener>,
12761                    fidl::encoding::DefaultFuchsiaResourceDialect,
12762                    val_ref,
12763                    decoder,
12764                    inner_offset,
12765                    inner_depth
12766                )?;
12767                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12768                {
12769                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12770                }
12771                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12772                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12773                }
12774            }
12775
12776            next_offset += envelope_size;
12777            _next_ordinal_to_read += 1;
12778            if next_offset >= end_offset {
12779                return Ok(());
12780            }
12781
12782            // Decode unknown envelopes for gaps in ordinals.
12783            while _next_ordinal_to_read < 22 {
12784                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12785                _next_ordinal_to_read += 1;
12786                next_offset += envelope_size;
12787            }
12788
12789            let next_out_of_line = decoder.next_out_of_line();
12790            let handles_before = decoder.remaining_handles();
12791            if let Some((inlined, num_bytes, num_handles)) =
12792                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12793            {
12794                let member_inline_size =
12795                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12796                if inlined != (member_inline_size <= 4) {
12797                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12798                }
12799                let inner_offset;
12800                let mut inner_depth = depth.clone();
12801                if inlined {
12802                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12803                    inner_offset = next_offset;
12804                } else {
12805                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12806                    inner_depth.increment()?;
12807                }
12808                let val_ref = self.virtio_mem.get_or_insert_with(|| {
12809                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12810                });
12811                fidl::decode!(
12812                    bool,
12813                    fidl::encoding::DefaultFuchsiaResourceDialect,
12814                    val_ref,
12815                    decoder,
12816                    inner_offset,
12817                    inner_depth
12818                )?;
12819                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12820                {
12821                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12822                }
12823                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12824                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12825                }
12826            }
12827
12828            next_offset += envelope_size;
12829            _next_ordinal_to_read += 1;
12830            if next_offset >= end_offset {
12831                return Ok(());
12832            }
12833
12834            // Decode unknown envelopes for gaps in ordinals.
12835            while _next_ordinal_to_read < 23 {
12836                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12837                _next_ordinal_to_read += 1;
12838                next_offset += envelope_size;
12839            }
12840
12841            let next_out_of_line = decoder.next_out_of_line();
12842            let handles_before = decoder.remaining_handles();
12843            if let Some((inlined, num_bytes, num_handles)) =
12844                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12845            {
12846                let member_inline_size =
12847                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12848                if inlined != (member_inline_size <= 4) {
12849                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12850                }
12851                let inner_offset;
12852                let mut inner_depth = depth.clone();
12853                if inlined {
12854                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12855                    inner_offset = next_offset;
12856                } else {
12857                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12858                    inner_depth.increment()?;
12859                }
12860                let val_ref = self.virtio_mem_block_size.get_or_insert_with(|| {
12861                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12862                });
12863                fidl::decode!(
12864                    u64,
12865                    fidl::encoding::DefaultFuchsiaResourceDialect,
12866                    val_ref,
12867                    decoder,
12868                    inner_offset,
12869                    inner_depth
12870                )?;
12871                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12872                {
12873                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12874                }
12875                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12876                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12877                }
12878            }
12879
12880            next_offset += envelope_size;
12881            _next_ordinal_to_read += 1;
12882            if next_offset >= end_offset {
12883                return Ok(());
12884            }
12885
12886            // Decode unknown envelopes for gaps in ordinals.
12887            while _next_ordinal_to_read < 24 {
12888                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12889                _next_ordinal_to_read += 1;
12890                next_offset += envelope_size;
12891            }
12892
12893            let next_out_of_line = decoder.next_out_of_line();
12894            let handles_before = decoder.remaining_handles();
12895            if let Some((inlined, num_bytes, num_handles)) =
12896                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12897            {
12898                let member_inline_size =
12899                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12900                if inlined != (member_inline_size <= 4) {
12901                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12902                }
12903                let inner_offset;
12904                let mut inner_depth = depth.clone();
12905                if inlined {
12906                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12907                    inner_offset = next_offset;
12908                } else {
12909                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12910                    inner_depth.increment()?;
12911                }
12912                let val_ref = self.virtio_mem_region_size.get_or_insert_with(|| {
12913                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12914                });
12915                fidl::decode!(
12916                    u64,
12917                    fidl::encoding::DefaultFuchsiaResourceDialect,
12918                    val_ref,
12919                    decoder,
12920                    inner_offset,
12921                    inner_depth
12922                )?;
12923                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12924                {
12925                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12926                }
12927                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12928                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12929                }
12930            }
12931
12932            next_offset += envelope_size;
12933            _next_ordinal_to_read += 1;
12934            if next_offset >= end_offset {
12935                return Ok(());
12936            }
12937
12938            // Decode unknown envelopes for gaps in ordinals.
12939            while _next_ordinal_to_read < 25 {
12940                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12941                _next_ordinal_to_read += 1;
12942                next_offset += envelope_size;
12943            }
12944
12945            let next_out_of_line = decoder.next_out_of_line();
12946            let handles_before = decoder.remaining_handles();
12947            if let Some((inlined, num_bytes, num_handles)) =
12948                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12949            {
12950                let member_inline_size =
12951                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12952                if inlined != (member_inline_size <= 4) {
12953                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12954                }
12955                let inner_offset;
12956                let mut inner_depth = depth.clone();
12957                if inlined {
12958                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12959                    inner_offset = next_offset;
12960                } else {
12961                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12962                    inner_depth.increment()?;
12963                }
12964                let val_ref = self.virtio_mem_region_alignment.get_or_insert_with(|| {
12965                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12966                });
12967                fidl::decode!(
12968                    u64,
12969                    fidl::encoding::DefaultFuchsiaResourceDialect,
12970                    val_ref,
12971                    decoder,
12972                    inner_offset,
12973                    inner_depth
12974                )?;
12975                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12976                {
12977                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12978                }
12979                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12980                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12981                }
12982            }
12983
12984            next_offset += envelope_size;
12985
12986            // Decode the remaining unknown envelopes.
12987            while next_offset < end_offset {
12988                _next_ordinal_to_read += 1;
12989                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12990                next_offset += envelope_size;
12991            }
12992
12993            Ok(())
12994        }
12995    }
12996
12997    impl fidl::encoding::ResourceTypeMarker for BlockFormat {
12998        type Borrowed<'a> = &'a mut Self;
12999        fn take_or_borrow<'a>(
13000            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13001        ) -> Self::Borrowed<'a> {
13002            value
13003        }
13004    }
13005
13006    unsafe impl fidl::encoding::TypeMarker for BlockFormat {
13007        type Owned = Self;
13008
13009        #[inline(always)]
13010        fn inline_align(_context: fidl::encoding::Context) -> usize {
13011            8
13012        }
13013
13014        #[inline(always)]
13015        fn inline_size(_context: fidl::encoding::Context) -> usize {
13016            16
13017        }
13018    }
13019
13020    unsafe impl fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>
13021        for &mut BlockFormat
13022    {
13023        #[inline]
13024        unsafe fn encode(
13025            self,
13026            encoder: &mut fidl::encoding::Encoder<
13027                '_,
13028                fidl::encoding::DefaultFuchsiaResourceDialect,
13029            >,
13030            offset: usize,
13031            _depth: fidl::encoding::Depth,
13032        ) -> fidl::Result<()> {
13033            encoder.debug_check_bounds::<BlockFormat>(offset);
13034            encoder.write_num::<u64>(self.ordinal(), offset);
13035            match self {
13036                BlockFormat::File(ref mut val) => fidl::encoding::encode_in_envelope::<
13037                    fidl::encoding::Endpoint<
13038                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13039                    >,
13040                    fidl::encoding::DefaultFuchsiaResourceDialect,
13041                >(
13042                    <fidl::encoding::Endpoint<
13043                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13044                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13045                        val
13046                    ),
13047                    encoder,
13048                    offset + 8,
13049                    _depth,
13050                ),
13051                BlockFormat::Qcow(ref mut val) => fidl::encoding::encode_in_envelope::<
13052                    fidl::encoding::HandleType<
13053                        fidl::Channel,
13054                        { fidl::ObjectType::CHANNEL.into_raw() },
13055                        2147483648,
13056                    >,
13057                    fidl::encoding::DefaultFuchsiaResourceDialect,
13058                >(
13059                    <fidl::encoding::HandleType<
13060                        fidl::Channel,
13061                        { fidl::ObjectType::CHANNEL.into_raw() },
13062                        2147483648,
13063                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13064                        val
13065                    ),
13066                    encoder,
13067                    offset + 8,
13068                    _depth,
13069                ),
13070                BlockFormat::Block(ref mut val) => fidl::encoding::encode_in_envelope::<
13071                    fidl::encoding::Endpoint<
13072                        fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13073                    >,
13074                    fidl::encoding::DefaultFuchsiaResourceDialect,
13075                >(
13076                    <fidl::encoding::Endpoint<
13077                        fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13078                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13079                        val
13080                    ),
13081                    encoder,
13082                    offset + 8,
13083                    _depth,
13084                ),
13085            }
13086        }
13087    }
13088
13089    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockFormat {
13090        #[inline(always)]
13091        fn new_empty() -> Self {
13092            Self::File(fidl::new_empty!(
13093                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
13094                fidl::encoding::DefaultFuchsiaResourceDialect
13095            ))
13096        }
13097
13098        #[inline]
13099        unsafe fn decode(
13100            &mut self,
13101            decoder: &mut fidl::encoding::Decoder<
13102                '_,
13103                fidl::encoding::DefaultFuchsiaResourceDialect,
13104            >,
13105            offset: usize,
13106            mut depth: fidl::encoding::Depth,
13107        ) -> fidl::Result<()> {
13108            decoder.debug_check_bounds::<Self>(offset);
13109            #[allow(unused_variables)]
13110            let next_out_of_line = decoder.next_out_of_line();
13111            let handles_before = decoder.remaining_handles();
13112            let (ordinal, inlined, num_bytes, num_handles) =
13113                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
13114
13115            let member_inline_size = match ordinal {
13116                1 => <fidl::encoding::Endpoint<
13117                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13118                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13119                2 => <fidl::encoding::HandleType<
13120                    fidl::Channel,
13121                    { fidl::ObjectType::CHANNEL.into_raw() },
13122                    2147483648,
13123                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13124                3 => <fidl::encoding::Endpoint<
13125                    fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13126                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13127                _ => return Err(fidl::Error::UnknownUnionTag),
13128            };
13129
13130            if inlined != (member_inline_size <= 4) {
13131                return Err(fidl::Error::InvalidInlineBitInEnvelope);
13132            }
13133            let _inner_offset;
13134            if inlined {
13135                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
13136                _inner_offset = offset + 8;
13137            } else {
13138                depth.increment()?;
13139                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13140            }
13141            match ordinal {
13142                1 => {
13143                    #[allow(irrefutable_let_patterns)]
13144                    if let BlockFormat::File(_) = self {
13145                        // Do nothing, read the value into the object
13146                    } else {
13147                        // Initialize `self` to the right variant
13148                        *self = BlockFormat::File(fidl::new_empty!(
13149                            fidl::encoding::Endpoint<
13150                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13151                            >,
13152                            fidl::encoding::DefaultFuchsiaResourceDialect
13153                        ));
13154                    }
13155                    #[allow(irrefutable_let_patterns)]
13156                    if let BlockFormat::File(ref mut val) = self {
13157                        fidl::decode!(
13158                            fidl::encoding::Endpoint<
13159                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13160                            >,
13161                            fidl::encoding::DefaultFuchsiaResourceDialect,
13162                            val,
13163                            decoder,
13164                            _inner_offset,
13165                            depth
13166                        )?;
13167                    } else {
13168                        unreachable!()
13169                    }
13170                }
13171                2 => {
13172                    #[allow(irrefutable_let_patterns)]
13173                    if let BlockFormat::Qcow(_) = self {
13174                        // Do nothing, read the value into the object
13175                    } else {
13176                        // Initialize `self` to the right variant
13177                        *self = BlockFormat::Qcow(
13178                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
13179                        );
13180                    }
13181                    #[allow(irrefutable_let_patterns)]
13182                    if let BlockFormat::Qcow(ref mut val) = self {
13183                        fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
13184                    } else {
13185                        unreachable!()
13186                    }
13187                }
13188                3 => {
13189                    #[allow(irrefutable_let_patterns)]
13190                    if let BlockFormat::Block(_) = self {
13191                        // Do nothing, read the value into the object
13192                    } else {
13193                        // Initialize `self` to the right variant
13194                        *self = BlockFormat::Block(fidl::new_empty!(
13195                            fidl::encoding::Endpoint<
13196                                fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13197                            >,
13198                            fidl::encoding::DefaultFuchsiaResourceDialect
13199                        ));
13200                    }
13201                    #[allow(irrefutable_let_patterns)]
13202                    if let BlockFormat::Block(ref mut val) = self {
13203                        fidl::decode!(
13204                            fidl::encoding::Endpoint<
13205                                fidl::endpoints::ClientEnd<fidl_fuchsia_storage_block::BlockMarker>,
13206                            >,
13207                            fidl::encoding::DefaultFuchsiaResourceDialect,
13208                            val,
13209                            decoder,
13210                            _inner_offset,
13211                            depth
13212                        )?;
13213                    } else {
13214                        unreachable!()
13215                    }
13216                }
13217                ordinal => panic!("unexpected ordinal {:?}", ordinal),
13218            }
13219            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
13220                return Err(fidl::Error::InvalidNumBytesInEnvelope);
13221            }
13222            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13223                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13224            }
13225            Ok(())
13226        }
13227    }
13228}