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_hardware_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        let protocol_name =
286            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
287        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
288    }
289
290    pub fn into_channel(self) -> fidl::Channel {
291        self.client.into_channel()
292    }
293
294    /// Waits until an event arrives and returns it. It is safe for other
295    /// threads to make concurrent requests while waiting for an event.
296    pub fn wait_for_event(
297        &self,
298        deadline: zx::MonotonicInstant,
299    ) -> Result<BalloonControllerEvent, fidl::Error> {
300        BalloonControllerEvent::decode(self.client.wait_for_event(deadline)?)
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
315            .client
316            .send_query::<fidl::encoding::EmptyPayload, BalloonControllerGetBalloonSizeResponse>(
317                (),
318                0x2bb2ebaa6ff64d0b,
319                fidl::encoding::DynamicFlags::empty(),
320                ___deadline,
321            )?;
322        Ok((_response.current_num_pages, _response.requested_num_pages))
323    }
324
325    /// Request a number of pages to be supplied to the memory balloon.
326    ///
327    /// If `requested_num_pages` is greater than the `current_num_pages` config
328    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
329    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
330    /// the guest driver MAY reclaim pages from the memory balloon.
331    pub fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
332        self.client.send::<BalloonControllerRequestNumPagesRequest>(
333            (requested_num_pages,),
334            0x55c444d65e1df1e8,
335            fidl::encoding::DynamicFlags::empty(),
336        )
337    }
338
339    /// Get memory statistics of the guest instance.
340    pub fn r#get_mem_stats(
341        &self,
342        ___deadline: zx::MonotonicInstant,
343    ) -> Result<(i32, Option<Vec<MemStat>>), fidl::Error> {
344        let _response = self
345            .client
346            .send_query::<fidl::encoding::EmptyPayload, BalloonControllerGetMemStatsResponse>(
347                (),
348                0x676199795cc01142,
349                fidl::encoding::DynamicFlags::empty(),
350                ___deadline,
351            )?;
352        Ok((_response.status, _response.mem_stats))
353    }
354}
355
356#[cfg(target_os = "fuchsia")]
357impl From<BalloonControllerSynchronousProxy> for zx::Handle {
358    fn from(value: BalloonControllerSynchronousProxy) -> Self {
359        value.into_channel().into()
360    }
361}
362
363#[cfg(target_os = "fuchsia")]
364impl From<fidl::Channel> for BalloonControllerSynchronousProxy {
365    fn from(value: fidl::Channel) -> Self {
366        Self::new(value)
367    }
368}
369
370#[cfg(target_os = "fuchsia")]
371impl fidl::endpoints::FromClient for BalloonControllerSynchronousProxy {
372    type Protocol = BalloonControllerMarker;
373
374    fn from_client(value: fidl::endpoints::ClientEnd<BalloonControllerMarker>) -> Self {
375        Self::new(value.into_channel())
376    }
377}
378
379#[derive(Debug, Clone)]
380pub struct BalloonControllerProxy {
381    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
382}
383
384impl fidl::endpoints::Proxy for BalloonControllerProxy {
385    type Protocol = BalloonControllerMarker;
386
387    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
388        Self::new(inner)
389    }
390
391    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
392        self.client.into_channel().map_err(|client| Self { client })
393    }
394
395    fn as_channel(&self) -> &::fidl::AsyncChannel {
396        self.client.as_channel()
397    }
398}
399
400impl BalloonControllerProxy {
401    /// Create a new Proxy for fuchsia.virtualization/BalloonController.
402    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
403        let protocol_name =
404            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
405        Self { client: fidl::client::Client::new(channel, protocol_name) }
406    }
407
408    /// Get a Stream of events from the remote end of the protocol.
409    ///
410    /// # Panics
411    ///
412    /// Panics if the event stream was already taken.
413    pub fn take_event_stream(&self) -> BalloonControllerEventStream {
414        BalloonControllerEventStream { event_receiver: self.client.take_event_receiver() }
415    }
416
417    /// Get the current and requested number of pages in the memory balloon.
418    ///
419    /// current_num_pages is the number of pages balloon has right now.
420    /// requested_num_pages is the desired number of pages in the balloon.
421    ///
422    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
423    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
424    pub fn r#get_balloon_size(
425        &self,
426    ) -> fidl::client::QueryResponseFut<(u32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
427    {
428        BalloonControllerProxyInterface::r#get_balloon_size(self)
429    }
430
431    /// Request a number of pages to be supplied to the memory balloon.
432    ///
433    /// If `requested_num_pages` is greater than the `current_num_pages` config
434    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
435    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
436    /// the guest driver MAY reclaim pages from the memory balloon.
437    pub fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
438        BalloonControllerProxyInterface::r#request_num_pages(self, requested_num_pages)
439    }
440
441    /// Get memory statistics of the guest instance.
442    pub fn r#get_mem_stats(
443        &self,
444    ) -> fidl::client::QueryResponseFut<
445        (i32, Option<Vec<MemStat>>),
446        fidl::encoding::DefaultFuchsiaResourceDialect,
447    > {
448        BalloonControllerProxyInterface::r#get_mem_stats(self)
449    }
450}
451
452impl BalloonControllerProxyInterface for BalloonControllerProxy {
453    type GetBalloonSizeResponseFut =
454        fidl::client::QueryResponseFut<(u32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
455    fn r#get_balloon_size(&self) -> Self::GetBalloonSizeResponseFut {
456        fn _decode(
457            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
458        ) -> Result<(u32, u32), fidl::Error> {
459            let _response = fidl::client::decode_transaction_body::<
460                BalloonControllerGetBalloonSizeResponse,
461                fidl::encoding::DefaultFuchsiaResourceDialect,
462                0x2bb2ebaa6ff64d0b,
463            >(_buf?)?;
464            Ok((_response.current_num_pages, _response.requested_num_pages))
465        }
466        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (u32, u32)>(
467            (),
468            0x2bb2ebaa6ff64d0b,
469            fidl::encoding::DynamicFlags::empty(),
470            _decode,
471        )
472    }
473
474    fn r#request_num_pages(&self, mut requested_num_pages: u32) -> Result<(), fidl::Error> {
475        self.client.send::<BalloonControllerRequestNumPagesRequest>(
476            (requested_num_pages,),
477            0x55c444d65e1df1e8,
478            fidl::encoding::DynamicFlags::empty(),
479        )
480    }
481
482    type GetMemStatsResponseFut = fidl::client::QueryResponseFut<
483        (i32, Option<Vec<MemStat>>),
484        fidl::encoding::DefaultFuchsiaResourceDialect,
485    >;
486    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut {
487        fn _decode(
488            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
489        ) -> Result<(i32, Option<Vec<MemStat>>), fidl::Error> {
490            let _response = fidl::client::decode_transaction_body::<
491                BalloonControllerGetMemStatsResponse,
492                fidl::encoding::DefaultFuchsiaResourceDialect,
493                0x676199795cc01142,
494            >(_buf?)?;
495            Ok((_response.status, _response.mem_stats))
496        }
497        self.client
498            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<Vec<MemStat>>)>(
499                (),
500                0x676199795cc01142,
501                fidl::encoding::DynamicFlags::empty(),
502                _decode,
503            )
504    }
505}
506
507pub struct BalloonControllerEventStream {
508    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
509}
510
511impl std::marker::Unpin for BalloonControllerEventStream {}
512
513impl futures::stream::FusedStream for BalloonControllerEventStream {
514    fn is_terminated(&self) -> bool {
515        self.event_receiver.is_terminated()
516    }
517}
518
519impl futures::Stream for BalloonControllerEventStream {
520    type Item = Result<BalloonControllerEvent, fidl::Error>;
521
522    fn poll_next(
523        mut self: std::pin::Pin<&mut Self>,
524        cx: &mut std::task::Context<'_>,
525    ) -> std::task::Poll<Option<Self::Item>> {
526        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
527            &mut self.event_receiver,
528            cx
529        )?) {
530            Some(buf) => std::task::Poll::Ready(Some(BalloonControllerEvent::decode(buf))),
531            None => std::task::Poll::Ready(None),
532        }
533    }
534}
535
536#[derive(Debug)]
537pub enum BalloonControllerEvent {}
538
539impl BalloonControllerEvent {
540    /// Decodes a message buffer as a [`BalloonControllerEvent`].
541    fn decode(
542        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
543    ) -> Result<BalloonControllerEvent, fidl::Error> {
544        let (bytes, _handles) = buf.split_mut();
545        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
546        debug_assert_eq!(tx_header.tx_id, 0);
547        match tx_header.ordinal {
548            _ => Err(fidl::Error::UnknownOrdinal {
549                ordinal: tx_header.ordinal,
550                protocol_name:
551                    <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
552            }),
553        }
554    }
555}
556
557/// A Stream of incoming requests for fuchsia.virtualization/BalloonController.
558pub struct BalloonControllerRequestStream {
559    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
560    is_terminated: bool,
561}
562
563impl std::marker::Unpin for BalloonControllerRequestStream {}
564
565impl futures::stream::FusedStream for BalloonControllerRequestStream {
566    fn is_terminated(&self) -> bool {
567        self.is_terminated
568    }
569}
570
571impl fidl::endpoints::RequestStream for BalloonControllerRequestStream {
572    type Protocol = BalloonControllerMarker;
573    type ControlHandle = BalloonControllerControlHandle;
574
575    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
576        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
577    }
578
579    fn control_handle(&self) -> Self::ControlHandle {
580        BalloonControllerControlHandle { inner: self.inner.clone() }
581    }
582
583    fn into_inner(
584        self,
585    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
586    {
587        (self.inner, self.is_terminated)
588    }
589
590    fn from_inner(
591        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
592        is_terminated: bool,
593    ) -> Self {
594        Self { inner, is_terminated }
595    }
596}
597
598impl futures::Stream for BalloonControllerRequestStream {
599    type Item = Result<BalloonControllerRequest, fidl::Error>;
600
601    fn poll_next(
602        mut self: std::pin::Pin<&mut Self>,
603        cx: &mut std::task::Context<'_>,
604    ) -> std::task::Poll<Option<Self::Item>> {
605        let this = &mut *self;
606        if this.inner.check_shutdown(cx) {
607            this.is_terminated = true;
608            return std::task::Poll::Ready(None);
609        }
610        if this.is_terminated {
611            panic!("polled BalloonControllerRequestStream after completion");
612        }
613        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
614            |bytes, handles| {
615                match this.inner.channel().read_etc(cx, bytes, handles) {
616                    std::task::Poll::Ready(Ok(())) => {}
617                    std::task::Poll::Pending => return std::task::Poll::Pending,
618                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
619                        this.is_terminated = true;
620                        return std::task::Poll::Ready(None);
621                    }
622                    std::task::Poll::Ready(Err(e)) => {
623                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
624                            e.into(),
625                        ))));
626                    }
627                }
628
629                // A message has been received from the channel
630                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
631
632                std::task::Poll::Ready(Some(match header.ordinal {
633                    0x2bb2ebaa6ff64d0b => {
634                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
635                        let mut req = fidl::new_empty!(
636                            fidl::encoding::EmptyPayload,
637                            fidl::encoding::DefaultFuchsiaResourceDialect
638                        );
639                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
640                        let control_handle =
641                            BalloonControllerControlHandle { inner: this.inner.clone() };
642                        Ok(BalloonControllerRequest::GetBalloonSize {
643                            responder: BalloonControllerGetBalloonSizeResponder {
644                                control_handle: std::mem::ManuallyDrop::new(control_handle),
645                                tx_id: header.tx_id,
646                            },
647                        })
648                    }
649                    0x55c444d65e1df1e8 => {
650                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
651                        let mut req = fidl::new_empty!(
652                            BalloonControllerRequestNumPagesRequest,
653                            fidl::encoding::DefaultFuchsiaResourceDialect
654                        );
655                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BalloonControllerRequestNumPagesRequest>(&header, _body_bytes, handles, &mut req)?;
656                        let control_handle =
657                            BalloonControllerControlHandle { inner: this.inner.clone() };
658                        Ok(BalloonControllerRequest::RequestNumPages {
659                            requested_num_pages: req.requested_num_pages,
660
661                            control_handle,
662                        })
663                    }
664                    0x676199795cc01142 => {
665                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
666                        let mut req = fidl::new_empty!(
667                            fidl::encoding::EmptyPayload,
668                            fidl::encoding::DefaultFuchsiaResourceDialect
669                        );
670                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
671                        let control_handle =
672                            BalloonControllerControlHandle { inner: this.inner.clone() };
673                        Ok(BalloonControllerRequest::GetMemStats {
674                            responder: BalloonControllerGetMemStatsResponder {
675                                control_handle: std::mem::ManuallyDrop::new(control_handle),
676                                tx_id: header.tx_id,
677                            },
678                        })
679                    }
680                    _ => Err(fidl::Error::UnknownOrdinal {
681                        ordinal: header.ordinal,
682                        protocol_name:
683                            <BalloonControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
684                    }),
685                }))
686            },
687        )
688    }
689}
690
691/// A `BalloonController` controls a guest instance's memory balloon.
692#[derive(Debug)]
693pub enum BalloonControllerRequest {
694    /// Get the current and requested number of pages in the memory balloon.
695    ///
696    /// current_num_pages is the number of pages balloon has right now.
697    /// requested_num_pages is the desired number of pages in the balloon.
698    ///
699    /// 'current_num_pages' corresponds to the 'actual' virtio-balloon config field
700    /// 'requested_num_pages' corresponds to the 'num_pages' virtio-balloon config field.
701    GetBalloonSize { responder: BalloonControllerGetBalloonSizeResponder },
702    /// Request a number of pages to be supplied to the memory balloon.
703    ///
704    /// If `requested_num_pages` is greater than the `current_num_pages` config
705    /// value, the guest driver SHOULD provide additional pages to the memory balloon.
706    /// If `requested_num_pages` is less than the 'current_num_pages' config value,
707    /// the guest driver MAY reclaim pages from the memory balloon.
708    RequestNumPages { requested_num_pages: u32, control_handle: BalloonControllerControlHandle },
709    /// Get memory statistics of the guest instance.
710    GetMemStats { responder: BalloonControllerGetMemStatsResponder },
711}
712
713impl BalloonControllerRequest {
714    #[allow(irrefutable_let_patterns)]
715    pub fn into_get_balloon_size(self) -> Option<(BalloonControllerGetBalloonSizeResponder)> {
716        if let BalloonControllerRequest::GetBalloonSize { responder } = self {
717            Some((responder))
718        } else {
719            None
720        }
721    }
722
723    #[allow(irrefutable_let_patterns)]
724    pub fn into_request_num_pages(self) -> Option<(u32, BalloonControllerControlHandle)> {
725        if let BalloonControllerRequest::RequestNumPages { requested_num_pages, control_handle } =
726            self
727        {
728            Some((requested_num_pages, control_handle))
729        } else {
730            None
731        }
732    }
733
734    #[allow(irrefutable_let_patterns)]
735    pub fn into_get_mem_stats(self) -> Option<(BalloonControllerGetMemStatsResponder)> {
736        if let BalloonControllerRequest::GetMemStats { responder } = self {
737            Some((responder))
738        } else {
739            None
740        }
741    }
742
743    /// Name of the method defined in FIDL
744    pub fn method_name(&self) -> &'static str {
745        match *self {
746            BalloonControllerRequest::GetBalloonSize { .. } => "get_balloon_size",
747            BalloonControllerRequest::RequestNumPages { .. } => "request_num_pages",
748            BalloonControllerRequest::GetMemStats { .. } => "get_mem_stats",
749        }
750    }
751}
752
753#[derive(Debug, Clone)]
754pub struct BalloonControllerControlHandle {
755    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
756}
757
758impl fidl::endpoints::ControlHandle for BalloonControllerControlHandle {
759    fn shutdown(&self) {
760        self.inner.shutdown()
761    }
762    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
763        self.inner.shutdown_with_epitaph(status)
764    }
765
766    fn is_closed(&self) -> bool {
767        self.inner.channel().is_closed()
768    }
769    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
770        self.inner.channel().on_closed()
771    }
772
773    #[cfg(target_os = "fuchsia")]
774    fn signal_peer(
775        &self,
776        clear_mask: zx::Signals,
777        set_mask: zx::Signals,
778    ) -> Result<(), zx_status::Status> {
779        use fidl::Peered;
780        self.inner.channel().signal_peer(clear_mask, set_mask)
781    }
782}
783
784impl BalloonControllerControlHandle {}
785
786#[must_use = "FIDL methods require a response to be sent"]
787#[derive(Debug)]
788pub struct BalloonControllerGetBalloonSizeResponder {
789    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
790    tx_id: u32,
791}
792
793/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
794/// if the responder is dropped without sending a response, so that the client
795/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
796impl std::ops::Drop for BalloonControllerGetBalloonSizeResponder {
797    fn drop(&mut self) {
798        self.control_handle.shutdown();
799        // Safety: drops once, never accessed again
800        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
801    }
802}
803
804impl fidl::endpoints::Responder for BalloonControllerGetBalloonSizeResponder {
805    type ControlHandle = BalloonControllerControlHandle;
806
807    fn control_handle(&self) -> &BalloonControllerControlHandle {
808        &self.control_handle
809    }
810
811    fn drop_without_shutdown(mut self) {
812        // Safety: drops once, never accessed again due to mem::forget
813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
814        // Prevent Drop from running (which would shut down the channel)
815        std::mem::forget(self);
816    }
817}
818
819impl BalloonControllerGetBalloonSizeResponder {
820    /// Sends a response to the FIDL transaction.
821    ///
822    /// Sets the channel to shutdown if an error occurs.
823    pub fn send(
824        self,
825        mut current_num_pages: u32,
826        mut requested_num_pages: u32,
827    ) -> Result<(), fidl::Error> {
828        let _result = self.send_raw(current_num_pages, requested_num_pages);
829        if _result.is_err() {
830            self.control_handle.shutdown();
831        }
832        self.drop_without_shutdown();
833        _result
834    }
835
836    /// Similar to "send" but does not shutdown the channel if an error occurs.
837    pub fn send_no_shutdown_on_err(
838        self,
839        mut current_num_pages: u32,
840        mut requested_num_pages: u32,
841    ) -> Result<(), fidl::Error> {
842        let _result = self.send_raw(current_num_pages, requested_num_pages);
843        self.drop_without_shutdown();
844        _result
845    }
846
847    fn send_raw(
848        &self,
849        mut current_num_pages: u32,
850        mut requested_num_pages: u32,
851    ) -> Result<(), fidl::Error> {
852        self.control_handle.inner.send::<BalloonControllerGetBalloonSizeResponse>(
853            (current_num_pages, requested_num_pages),
854            self.tx_id,
855            0x2bb2ebaa6ff64d0b,
856            fidl::encoding::DynamicFlags::empty(),
857        )
858    }
859}
860
861#[must_use = "FIDL methods require a response to be sent"]
862#[derive(Debug)]
863pub struct BalloonControllerGetMemStatsResponder {
864    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
865    tx_id: u32,
866}
867
868/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
869/// if the responder is dropped without sending a response, so that the client
870/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
871impl std::ops::Drop for BalloonControllerGetMemStatsResponder {
872    fn drop(&mut self) {
873        self.control_handle.shutdown();
874        // Safety: drops once, never accessed again
875        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
876    }
877}
878
879impl fidl::endpoints::Responder for BalloonControllerGetMemStatsResponder {
880    type ControlHandle = BalloonControllerControlHandle;
881
882    fn control_handle(&self) -> &BalloonControllerControlHandle {
883        &self.control_handle
884    }
885
886    fn drop_without_shutdown(mut self) {
887        // Safety: drops once, never accessed again due to mem::forget
888        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
889        // Prevent Drop from running (which would shut down the channel)
890        std::mem::forget(self);
891    }
892}
893
894impl BalloonControllerGetMemStatsResponder {
895    /// Sends a response to the FIDL transaction.
896    ///
897    /// Sets the channel to shutdown if an error occurs.
898    pub fn send(
899        self,
900        mut status: i32,
901        mut mem_stats: Option<&[MemStat]>,
902    ) -> Result<(), fidl::Error> {
903        let _result = self.send_raw(status, mem_stats);
904        if _result.is_err() {
905            self.control_handle.shutdown();
906        }
907        self.drop_without_shutdown();
908        _result
909    }
910
911    /// Similar to "send" but does not shutdown the channel if an error occurs.
912    pub fn send_no_shutdown_on_err(
913        self,
914        mut status: i32,
915        mut mem_stats: Option<&[MemStat]>,
916    ) -> Result<(), fidl::Error> {
917        let _result = self.send_raw(status, mem_stats);
918        self.drop_without_shutdown();
919        _result
920    }
921
922    fn send_raw(
923        &self,
924        mut status: i32,
925        mut mem_stats: Option<&[MemStat]>,
926    ) -> Result<(), fidl::Error> {
927        self.control_handle.inner.send::<BalloonControllerGetMemStatsResponse>(
928            (status, mem_stats),
929            self.tx_id,
930            0x676199795cc01142,
931            fidl::encoding::DynamicFlags::empty(),
932        )
933    }
934}
935
936#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
937pub struct DebianGuestManagerMarker;
938
939impl fidl::endpoints::ProtocolMarker for DebianGuestManagerMarker {
940    type Proxy = DebianGuestManagerProxy;
941    type RequestStream = DebianGuestManagerRequestStream;
942    #[cfg(target_os = "fuchsia")]
943    type SynchronousProxy = DebianGuestManagerSynchronousProxy;
944
945    const DEBUG_NAME: &'static str = "fuchsia.virtualization.DebianGuestManager";
946}
947impl fidl::endpoints::DiscoverableProtocolMarker for DebianGuestManagerMarker {}
948
949pub trait DebianGuestManagerProxyInterface: Send + Sync {
950    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
951        + Send;
952    fn r#launch(
953        &self,
954        guest_config: GuestConfig,
955        controller: fidl::endpoints::ServerEnd<GuestMarker>,
956    ) -> Self::LaunchResponseFut;
957    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
958    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
959    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
960        + Send;
961    fn r#connect(
962        &self,
963        controller: fidl::endpoints::ServerEnd<GuestMarker>,
964    ) -> Self::ConnectResponseFut;
965    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
966    fn r#get_info(&self) -> Self::GetInfoResponseFut;
967}
968#[derive(Debug)]
969#[cfg(target_os = "fuchsia")]
970pub struct DebianGuestManagerSynchronousProxy {
971    client: fidl::client::sync::Client,
972}
973
974#[cfg(target_os = "fuchsia")]
975impl fidl::endpoints::SynchronousProxy for DebianGuestManagerSynchronousProxy {
976    type Proxy = DebianGuestManagerProxy;
977    type Protocol = DebianGuestManagerMarker;
978
979    fn from_channel(inner: fidl::Channel) -> Self {
980        Self::new(inner)
981    }
982
983    fn into_channel(self) -> fidl::Channel {
984        self.client.into_channel()
985    }
986
987    fn as_channel(&self) -> &fidl::Channel {
988        self.client.as_channel()
989    }
990}
991
992#[cfg(target_os = "fuchsia")]
993impl DebianGuestManagerSynchronousProxy {
994    pub fn new(channel: fidl::Channel) -> Self {
995        let protocol_name =
996            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
997        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
998    }
999
1000    pub fn into_channel(self) -> fidl::Channel {
1001        self.client.into_channel()
1002    }
1003
1004    /// Waits until an event arrives and returns it. It is safe for other
1005    /// threads to make concurrent requests while waiting for an event.
1006    pub fn wait_for_event(
1007        &self,
1008        deadline: zx::MonotonicInstant,
1009    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1010        DebianGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
1011    }
1012
1013    /// Launch a new guest instance.
1014    ///
1015    /// Possible errors:
1016    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1017    ///         problems detected by the guest manager.
1018    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1019    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1020    ///         component logs for a more specific failure.
1021    pub fn r#launch(
1022        &self,
1023        mut guest_config: GuestConfig,
1024        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1025        ___deadline: zx::MonotonicInstant,
1026    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1027        let _response =
1028            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
1029                fidl::encoding::EmptyStruct,
1030                GuestManagerError,
1031            >>(
1032                (&mut guest_config, controller),
1033                0x394a2e29f750323e,
1034                fidl::encoding::DynamicFlags::empty(),
1035                ___deadline,
1036            )?;
1037        Ok(_response.map(|x| x))
1038    }
1039
1040    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1041    /// be used to launch another guest.
1042    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1043        let _response =
1044            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1045                (),
1046                0x3ad9a012982f872d,
1047                fidl::encoding::DynamicFlags::empty(),
1048                ___deadline,
1049            )?;
1050        Ok(_response)
1051    }
1052
1053    /// Connect to a currently running guest.
1054    ///
1055    /// Possible errors:
1056    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1057    ///         has launched before attempting to reconnect.
1058    pub fn r#connect(
1059        &self,
1060        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1061        ___deadline: zx::MonotonicInstant,
1062    ) -> Result<GuestManagerConnectResult, fidl::Error> {
1063        let _response =
1064            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
1065                fidl::encoding::EmptyStruct,
1066                GuestManagerError,
1067            >>(
1068                (controller,),
1069                0x4e489076e3bb15b4,
1070                fidl::encoding::DynamicFlags::empty(),
1071                ___deadline,
1072            )?;
1073        Ok(_response.map(|x| x))
1074    }
1075
1076    /// Query guest info
1077    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
1078        let _response =
1079            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
1080                (),
1081                0x76892614aea695dc,
1082                fidl::encoding::DynamicFlags::empty(),
1083                ___deadline,
1084            )?;
1085        Ok(_response.guest_info)
1086    }
1087}
1088
1089#[cfg(target_os = "fuchsia")]
1090impl From<DebianGuestManagerSynchronousProxy> for zx::Handle {
1091    fn from(value: DebianGuestManagerSynchronousProxy) -> Self {
1092        value.into_channel().into()
1093    }
1094}
1095
1096#[cfg(target_os = "fuchsia")]
1097impl From<fidl::Channel> for DebianGuestManagerSynchronousProxy {
1098    fn from(value: fidl::Channel) -> Self {
1099        Self::new(value)
1100    }
1101}
1102
1103#[cfg(target_os = "fuchsia")]
1104impl fidl::endpoints::FromClient for DebianGuestManagerSynchronousProxy {
1105    type Protocol = DebianGuestManagerMarker;
1106
1107    fn from_client(value: fidl::endpoints::ClientEnd<DebianGuestManagerMarker>) -> Self {
1108        Self::new(value.into_channel())
1109    }
1110}
1111
1112#[derive(Debug, Clone)]
1113pub struct DebianGuestManagerProxy {
1114    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1115}
1116
1117impl fidl::endpoints::Proxy for DebianGuestManagerProxy {
1118    type Protocol = DebianGuestManagerMarker;
1119
1120    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1121        Self::new(inner)
1122    }
1123
1124    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1125        self.client.into_channel().map_err(|client| Self { client })
1126    }
1127
1128    fn as_channel(&self) -> &::fidl::AsyncChannel {
1129        self.client.as_channel()
1130    }
1131}
1132
1133impl DebianGuestManagerProxy {
1134    /// Create a new Proxy for fuchsia.virtualization/DebianGuestManager.
1135    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1136        let protocol_name =
1137            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1138        Self { client: fidl::client::Client::new(channel, protocol_name) }
1139    }
1140
1141    /// Get a Stream of events from the remote end of the protocol.
1142    ///
1143    /// # Panics
1144    ///
1145    /// Panics if the event stream was already taken.
1146    pub fn take_event_stream(&self) -> DebianGuestManagerEventStream {
1147        DebianGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
1148    }
1149
1150    /// Launch a new guest instance.
1151    ///
1152    /// Possible errors:
1153    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1154    ///         problems detected by the guest manager.
1155    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1156    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1157    ///         component logs for a more specific failure.
1158    pub fn r#launch(
1159        &self,
1160        mut guest_config: GuestConfig,
1161        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1162    ) -> fidl::client::QueryResponseFut<
1163        GuestManagerLaunchResult,
1164        fidl::encoding::DefaultFuchsiaResourceDialect,
1165    > {
1166        DebianGuestManagerProxyInterface::r#launch(self, guest_config, controller)
1167    }
1168
1169    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1170    /// be used to launch another guest.
1171    pub fn r#force_shutdown(
1172        &self,
1173    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1174        DebianGuestManagerProxyInterface::r#force_shutdown(self)
1175    }
1176
1177    /// Connect to a currently running guest.
1178    ///
1179    /// Possible errors:
1180    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1181    ///         has launched before attempting to reconnect.
1182    pub fn r#connect(
1183        &self,
1184        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1185    ) -> fidl::client::QueryResponseFut<
1186        GuestManagerConnectResult,
1187        fidl::encoding::DefaultFuchsiaResourceDialect,
1188    > {
1189        DebianGuestManagerProxyInterface::r#connect(self, controller)
1190    }
1191
1192    /// Query guest info
1193    pub fn r#get_info(
1194        &self,
1195    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1196    {
1197        DebianGuestManagerProxyInterface::r#get_info(self)
1198    }
1199}
1200
1201impl DebianGuestManagerProxyInterface for DebianGuestManagerProxy {
1202    type LaunchResponseFut = fidl::client::QueryResponseFut<
1203        GuestManagerLaunchResult,
1204        fidl::encoding::DefaultFuchsiaResourceDialect,
1205    >;
1206    fn r#launch(
1207        &self,
1208        mut guest_config: GuestConfig,
1209        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1210    ) -> Self::LaunchResponseFut {
1211        fn _decode(
1212            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1213        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1214            let _response = fidl::client::decode_transaction_body::<
1215                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1216                fidl::encoding::DefaultFuchsiaResourceDialect,
1217                0x394a2e29f750323e,
1218            >(_buf?)?;
1219            Ok(_response.map(|x| x))
1220        }
1221        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
1222            (&mut guest_config, controller),
1223            0x394a2e29f750323e,
1224            fidl::encoding::DynamicFlags::empty(),
1225            _decode,
1226        )
1227    }
1228
1229    type ForceShutdownResponseFut =
1230        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1231    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
1232        fn _decode(
1233            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1234        ) -> Result<(), fidl::Error> {
1235            let _response = fidl::client::decode_transaction_body::<
1236                fidl::encoding::EmptyPayload,
1237                fidl::encoding::DefaultFuchsiaResourceDialect,
1238                0x3ad9a012982f872d,
1239            >(_buf?)?;
1240            Ok(_response)
1241        }
1242        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1243            (),
1244            0x3ad9a012982f872d,
1245            fidl::encoding::DynamicFlags::empty(),
1246            _decode,
1247        )
1248    }
1249
1250    type ConnectResponseFut = fidl::client::QueryResponseFut<
1251        GuestManagerConnectResult,
1252        fidl::encoding::DefaultFuchsiaResourceDialect,
1253    >;
1254    fn r#connect(
1255        &self,
1256        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1257    ) -> Self::ConnectResponseFut {
1258        fn _decode(
1259            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1260        ) -> Result<GuestManagerConnectResult, fidl::Error> {
1261            let _response = fidl::client::decode_transaction_body::<
1262                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1263                fidl::encoding::DefaultFuchsiaResourceDialect,
1264                0x4e489076e3bb15b4,
1265            >(_buf?)?;
1266            Ok(_response.map(|x| x))
1267        }
1268        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
1269            (controller,),
1270            0x4e489076e3bb15b4,
1271            fidl::encoding::DynamicFlags::empty(),
1272            _decode,
1273        )
1274    }
1275
1276    type GetInfoResponseFut =
1277        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
1278    fn r#get_info(&self) -> Self::GetInfoResponseFut {
1279        fn _decode(
1280            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1281        ) -> Result<GuestInfo, fidl::Error> {
1282            let _response = fidl::client::decode_transaction_body::<
1283                GuestManagerGetInfoResponse,
1284                fidl::encoding::DefaultFuchsiaResourceDialect,
1285                0x76892614aea695dc,
1286            >(_buf?)?;
1287            Ok(_response.guest_info)
1288        }
1289        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
1290            (),
1291            0x76892614aea695dc,
1292            fidl::encoding::DynamicFlags::empty(),
1293            _decode,
1294        )
1295    }
1296}
1297
1298pub struct DebianGuestManagerEventStream {
1299    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1300}
1301
1302impl std::marker::Unpin for DebianGuestManagerEventStream {}
1303
1304impl futures::stream::FusedStream for DebianGuestManagerEventStream {
1305    fn is_terminated(&self) -> bool {
1306        self.event_receiver.is_terminated()
1307    }
1308}
1309
1310impl futures::Stream for DebianGuestManagerEventStream {
1311    type Item = Result<DebianGuestManagerEvent, fidl::Error>;
1312
1313    fn poll_next(
1314        mut self: std::pin::Pin<&mut Self>,
1315        cx: &mut std::task::Context<'_>,
1316    ) -> std::task::Poll<Option<Self::Item>> {
1317        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1318            &mut self.event_receiver,
1319            cx
1320        )?) {
1321            Some(buf) => std::task::Poll::Ready(Some(DebianGuestManagerEvent::decode(buf))),
1322            None => std::task::Poll::Ready(None),
1323        }
1324    }
1325}
1326
1327#[derive(Debug)]
1328pub enum DebianGuestManagerEvent {}
1329
1330impl DebianGuestManagerEvent {
1331    /// Decodes a message buffer as a [`DebianGuestManagerEvent`].
1332    fn decode(
1333        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1334    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1335        let (bytes, _handles) = buf.split_mut();
1336        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1337        debug_assert_eq!(tx_header.tx_id, 0);
1338        match tx_header.ordinal {
1339            _ => Err(fidl::Error::UnknownOrdinal {
1340                ordinal: tx_header.ordinal,
1341                protocol_name:
1342                    <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1343            }),
1344        }
1345    }
1346}
1347
1348/// A Stream of incoming requests for fuchsia.virtualization/DebianGuestManager.
1349pub struct DebianGuestManagerRequestStream {
1350    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1351    is_terminated: bool,
1352}
1353
1354impl std::marker::Unpin for DebianGuestManagerRequestStream {}
1355
1356impl futures::stream::FusedStream for DebianGuestManagerRequestStream {
1357    fn is_terminated(&self) -> bool {
1358        self.is_terminated
1359    }
1360}
1361
1362impl fidl::endpoints::RequestStream for DebianGuestManagerRequestStream {
1363    type Protocol = DebianGuestManagerMarker;
1364    type ControlHandle = DebianGuestManagerControlHandle;
1365
1366    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1367        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1368    }
1369
1370    fn control_handle(&self) -> Self::ControlHandle {
1371        DebianGuestManagerControlHandle { inner: self.inner.clone() }
1372    }
1373
1374    fn into_inner(
1375        self,
1376    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1377    {
1378        (self.inner, self.is_terminated)
1379    }
1380
1381    fn from_inner(
1382        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1383        is_terminated: bool,
1384    ) -> Self {
1385        Self { inner, is_terminated }
1386    }
1387}
1388
1389impl futures::Stream for DebianGuestManagerRequestStream {
1390    type Item = Result<DebianGuestManagerRequest, fidl::Error>;
1391
1392    fn poll_next(
1393        mut self: std::pin::Pin<&mut Self>,
1394        cx: &mut std::task::Context<'_>,
1395    ) -> std::task::Poll<Option<Self::Item>> {
1396        let this = &mut *self;
1397        if this.inner.check_shutdown(cx) {
1398            this.is_terminated = true;
1399            return std::task::Poll::Ready(None);
1400        }
1401        if this.is_terminated {
1402            panic!("polled DebianGuestManagerRequestStream after completion");
1403        }
1404        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1405            |bytes, handles| {
1406                match this.inner.channel().read_etc(cx, bytes, handles) {
1407                    std::task::Poll::Ready(Ok(())) => {}
1408                    std::task::Poll::Pending => return std::task::Poll::Pending,
1409                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1410                        this.is_terminated = true;
1411                        return std::task::Poll::Ready(None);
1412                    }
1413                    std::task::Poll::Ready(Err(e)) => {
1414                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1415                            e.into(),
1416                        ))));
1417                    }
1418                }
1419
1420                // A message has been received from the channel
1421                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1422
1423                std::task::Poll::Ready(Some(match header.ordinal {
1424                0x394a2e29f750323e => {
1425                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1426                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1427                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
1428                    let control_handle = DebianGuestManagerControlHandle {
1429                        inner: this.inner.clone(),
1430                    };
1431                    Ok(DebianGuestManagerRequest::Launch {guest_config: req.guest_config,
1432controller: req.controller,
1433
1434                        responder: DebianGuestManagerLaunchResponder {
1435                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1436                            tx_id: header.tx_id,
1437                        },
1438                    })
1439                }
1440                0x3ad9a012982f872d => {
1441                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1442                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1443                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1444                    let control_handle = DebianGuestManagerControlHandle {
1445                        inner: this.inner.clone(),
1446                    };
1447                    Ok(DebianGuestManagerRequest::ForceShutdown {
1448                        responder: DebianGuestManagerForceShutdownResponder {
1449                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1450                            tx_id: header.tx_id,
1451                        },
1452                    })
1453                }
1454                0x4e489076e3bb15b4 => {
1455                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1456                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1457                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1458                    let control_handle = DebianGuestManagerControlHandle {
1459                        inner: this.inner.clone(),
1460                    };
1461                    Ok(DebianGuestManagerRequest::Connect {controller: req.controller,
1462
1463                        responder: DebianGuestManagerConnectResponder {
1464                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1465                            tx_id: header.tx_id,
1466                        },
1467                    })
1468                }
1469                0x76892614aea695dc => {
1470                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1471                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1472                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1473                    let control_handle = DebianGuestManagerControlHandle {
1474                        inner: this.inner.clone(),
1475                    };
1476                    Ok(DebianGuestManagerRequest::GetInfo {
1477                        responder: DebianGuestManagerGetInfoResponder {
1478                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1479                            tx_id: header.tx_id,
1480                        },
1481                    })
1482                }
1483                _ => Err(fidl::Error::UnknownOrdinal {
1484                    ordinal: header.ordinal,
1485                    protocol_name: <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1486                }),
1487            }))
1488            },
1489        )
1490    }
1491}
1492
1493#[derive(Debug)]
1494pub enum DebianGuestManagerRequest {
1495    /// Launch a new guest instance.
1496    ///
1497    /// Possible errors:
1498    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1499    ///         problems detected by the guest manager.
1500    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1501    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1502    ///         component logs for a more specific failure.
1503    Launch {
1504        guest_config: GuestConfig,
1505        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1506        responder: DebianGuestManagerLaunchResponder,
1507    },
1508    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1509    /// be used to launch another guest.
1510    ForceShutdown { responder: DebianGuestManagerForceShutdownResponder },
1511    /// Connect to a currently running guest.
1512    ///
1513    /// Possible errors:
1514    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1515    ///         has launched before attempting to reconnect.
1516    Connect {
1517        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1518        responder: DebianGuestManagerConnectResponder,
1519    },
1520    /// Query guest info
1521    GetInfo { responder: DebianGuestManagerGetInfoResponder },
1522}
1523
1524impl DebianGuestManagerRequest {
1525    #[allow(irrefutable_let_patterns)]
1526    pub fn into_launch(
1527        self,
1528    ) -> Option<(
1529        GuestConfig,
1530        fidl::endpoints::ServerEnd<GuestMarker>,
1531        DebianGuestManagerLaunchResponder,
1532    )> {
1533        if let DebianGuestManagerRequest::Launch { guest_config, controller, responder } = self {
1534            Some((guest_config, controller, responder))
1535        } else {
1536            None
1537        }
1538    }
1539
1540    #[allow(irrefutable_let_patterns)]
1541    pub fn into_force_shutdown(self) -> Option<(DebianGuestManagerForceShutdownResponder)> {
1542        if let DebianGuestManagerRequest::ForceShutdown { responder } = self {
1543            Some((responder))
1544        } else {
1545            None
1546        }
1547    }
1548
1549    #[allow(irrefutable_let_patterns)]
1550    pub fn into_connect(
1551        self,
1552    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, DebianGuestManagerConnectResponder)> {
1553        if let DebianGuestManagerRequest::Connect { controller, responder } = self {
1554            Some((controller, responder))
1555        } else {
1556            None
1557        }
1558    }
1559
1560    #[allow(irrefutable_let_patterns)]
1561    pub fn into_get_info(self) -> Option<(DebianGuestManagerGetInfoResponder)> {
1562        if let DebianGuestManagerRequest::GetInfo { responder } = self {
1563            Some((responder))
1564        } else {
1565            None
1566        }
1567    }
1568
1569    /// Name of the method defined in FIDL
1570    pub fn method_name(&self) -> &'static str {
1571        match *self {
1572            DebianGuestManagerRequest::Launch { .. } => "launch",
1573            DebianGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
1574            DebianGuestManagerRequest::Connect { .. } => "connect",
1575            DebianGuestManagerRequest::GetInfo { .. } => "get_info",
1576        }
1577    }
1578}
1579
1580#[derive(Debug, Clone)]
1581pub struct DebianGuestManagerControlHandle {
1582    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1583}
1584
1585impl fidl::endpoints::ControlHandle for DebianGuestManagerControlHandle {
1586    fn shutdown(&self) {
1587        self.inner.shutdown()
1588    }
1589    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1590        self.inner.shutdown_with_epitaph(status)
1591    }
1592
1593    fn is_closed(&self) -> bool {
1594        self.inner.channel().is_closed()
1595    }
1596    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1597        self.inner.channel().on_closed()
1598    }
1599
1600    #[cfg(target_os = "fuchsia")]
1601    fn signal_peer(
1602        &self,
1603        clear_mask: zx::Signals,
1604        set_mask: zx::Signals,
1605    ) -> Result<(), zx_status::Status> {
1606        use fidl::Peered;
1607        self.inner.channel().signal_peer(clear_mask, set_mask)
1608    }
1609}
1610
1611impl DebianGuestManagerControlHandle {}
1612
1613#[must_use = "FIDL methods require a response to be sent"]
1614#[derive(Debug)]
1615pub struct DebianGuestManagerLaunchResponder {
1616    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1617    tx_id: u32,
1618}
1619
1620/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1621/// if the responder is dropped without sending a response, so that the client
1622/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1623impl std::ops::Drop for DebianGuestManagerLaunchResponder {
1624    fn drop(&mut self) {
1625        self.control_handle.shutdown();
1626        // Safety: drops once, never accessed again
1627        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1628    }
1629}
1630
1631impl fidl::endpoints::Responder for DebianGuestManagerLaunchResponder {
1632    type ControlHandle = DebianGuestManagerControlHandle;
1633
1634    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1635        &self.control_handle
1636    }
1637
1638    fn drop_without_shutdown(mut self) {
1639        // Safety: drops once, never accessed again due to mem::forget
1640        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1641        // Prevent Drop from running (which would shut down the channel)
1642        std::mem::forget(self);
1643    }
1644}
1645
1646impl DebianGuestManagerLaunchResponder {
1647    /// Sends a response to the FIDL transaction.
1648    ///
1649    /// Sets the channel to shutdown if an error occurs.
1650    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1651        let _result = self.send_raw(result);
1652        if _result.is_err() {
1653            self.control_handle.shutdown();
1654        }
1655        self.drop_without_shutdown();
1656        _result
1657    }
1658
1659    /// Similar to "send" but does not shutdown the channel if an error occurs.
1660    pub fn send_no_shutdown_on_err(
1661        self,
1662        mut result: Result<(), GuestManagerError>,
1663    ) -> Result<(), fidl::Error> {
1664        let _result = self.send_raw(result);
1665        self.drop_without_shutdown();
1666        _result
1667    }
1668
1669    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1670        self.control_handle.inner.send::<fidl::encoding::ResultType<
1671            fidl::encoding::EmptyStruct,
1672            GuestManagerError,
1673        >>(
1674            result,
1675            self.tx_id,
1676            0x394a2e29f750323e,
1677            fidl::encoding::DynamicFlags::empty(),
1678        )
1679    }
1680}
1681
1682#[must_use = "FIDL methods require a response to be sent"]
1683#[derive(Debug)]
1684pub struct DebianGuestManagerForceShutdownResponder {
1685    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1686    tx_id: u32,
1687}
1688
1689/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1690/// if the responder is dropped without sending a response, so that the client
1691/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1692impl std::ops::Drop for DebianGuestManagerForceShutdownResponder {
1693    fn drop(&mut self) {
1694        self.control_handle.shutdown();
1695        // Safety: drops once, never accessed again
1696        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1697    }
1698}
1699
1700impl fidl::endpoints::Responder for DebianGuestManagerForceShutdownResponder {
1701    type ControlHandle = DebianGuestManagerControlHandle;
1702
1703    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1704        &self.control_handle
1705    }
1706
1707    fn drop_without_shutdown(mut self) {
1708        // Safety: drops once, never accessed again due to mem::forget
1709        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1710        // Prevent Drop from running (which would shut down the channel)
1711        std::mem::forget(self);
1712    }
1713}
1714
1715impl DebianGuestManagerForceShutdownResponder {
1716    /// Sends a response to the FIDL transaction.
1717    ///
1718    /// Sets the channel to shutdown if an error occurs.
1719    pub fn send(self) -> Result<(), fidl::Error> {
1720        let _result = self.send_raw();
1721        if _result.is_err() {
1722            self.control_handle.shutdown();
1723        }
1724        self.drop_without_shutdown();
1725        _result
1726    }
1727
1728    /// Similar to "send" but does not shutdown the channel if an error occurs.
1729    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1730        let _result = self.send_raw();
1731        self.drop_without_shutdown();
1732        _result
1733    }
1734
1735    fn send_raw(&self) -> Result<(), fidl::Error> {
1736        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1737            (),
1738            self.tx_id,
1739            0x3ad9a012982f872d,
1740            fidl::encoding::DynamicFlags::empty(),
1741        )
1742    }
1743}
1744
1745#[must_use = "FIDL methods require a response to be sent"]
1746#[derive(Debug)]
1747pub struct DebianGuestManagerConnectResponder {
1748    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1749    tx_id: u32,
1750}
1751
1752/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1753/// if the responder is dropped without sending a response, so that the client
1754/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1755impl std::ops::Drop for DebianGuestManagerConnectResponder {
1756    fn drop(&mut self) {
1757        self.control_handle.shutdown();
1758        // Safety: drops once, never accessed again
1759        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1760    }
1761}
1762
1763impl fidl::endpoints::Responder for DebianGuestManagerConnectResponder {
1764    type ControlHandle = DebianGuestManagerControlHandle;
1765
1766    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1767        &self.control_handle
1768    }
1769
1770    fn drop_without_shutdown(mut self) {
1771        // Safety: drops once, never accessed again due to mem::forget
1772        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1773        // Prevent Drop from running (which would shut down the channel)
1774        std::mem::forget(self);
1775    }
1776}
1777
1778impl DebianGuestManagerConnectResponder {
1779    /// Sends a response to the FIDL transaction.
1780    ///
1781    /// Sets the channel to shutdown if an error occurs.
1782    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1783        let _result = self.send_raw(result);
1784        if _result.is_err() {
1785            self.control_handle.shutdown();
1786        }
1787        self.drop_without_shutdown();
1788        _result
1789    }
1790
1791    /// Similar to "send" but does not shutdown the channel if an error occurs.
1792    pub fn send_no_shutdown_on_err(
1793        self,
1794        mut result: Result<(), GuestManagerError>,
1795    ) -> Result<(), fidl::Error> {
1796        let _result = self.send_raw(result);
1797        self.drop_without_shutdown();
1798        _result
1799    }
1800
1801    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1802        self.control_handle.inner.send::<fidl::encoding::ResultType<
1803            fidl::encoding::EmptyStruct,
1804            GuestManagerError,
1805        >>(
1806            result,
1807            self.tx_id,
1808            0x4e489076e3bb15b4,
1809            fidl::encoding::DynamicFlags::empty(),
1810        )
1811    }
1812}
1813
1814#[must_use = "FIDL methods require a response to be sent"]
1815#[derive(Debug)]
1816pub struct DebianGuestManagerGetInfoResponder {
1817    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1818    tx_id: u32,
1819}
1820
1821/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1822/// if the responder is dropped without sending a response, so that the client
1823/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1824impl std::ops::Drop for DebianGuestManagerGetInfoResponder {
1825    fn drop(&mut self) {
1826        self.control_handle.shutdown();
1827        // Safety: drops once, never accessed again
1828        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1829    }
1830}
1831
1832impl fidl::endpoints::Responder for DebianGuestManagerGetInfoResponder {
1833    type ControlHandle = DebianGuestManagerControlHandle;
1834
1835    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1836        &self.control_handle
1837    }
1838
1839    fn drop_without_shutdown(mut self) {
1840        // Safety: drops once, never accessed again due to mem::forget
1841        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1842        // Prevent Drop from running (which would shut down the channel)
1843        std::mem::forget(self);
1844    }
1845}
1846
1847impl DebianGuestManagerGetInfoResponder {
1848    /// Sends a response to the FIDL transaction.
1849    ///
1850    /// Sets the channel to shutdown if an error occurs.
1851    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1852        let _result = self.send_raw(guest_info);
1853        if _result.is_err() {
1854            self.control_handle.shutdown();
1855        }
1856        self.drop_without_shutdown();
1857        _result
1858    }
1859
1860    /// Similar to "send" but does not shutdown the channel if an error occurs.
1861    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1862        let _result = self.send_raw(guest_info);
1863        self.drop_without_shutdown();
1864        _result
1865    }
1866
1867    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1868        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
1869            (guest_info,),
1870            self.tx_id,
1871            0x76892614aea695dc,
1872            fidl::encoding::DynamicFlags::empty(),
1873        )
1874    }
1875}
1876
1877#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1878pub struct GuestMarker;
1879
1880impl fidl::endpoints::ProtocolMarker for GuestMarker {
1881    type Proxy = GuestProxy;
1882    type RequestStream = GuestRequestStream;
1883    #[cfg(target_os = "fuchsia")]
1884    type SynchronousProxy = GuestSynchronousProxy;
1885
1886    const DEBUG_NAME: &'static str = "fuchsia.virtualization.Guest";
1887}
1888impl fidl::endpoints::DiscoverableProtocolMarker for GuestMarker {}
1889pub type GuestGetConsoleResult = Result<fidl::Socket, GuestError>;
1890pub type GuestGetHostVsockEndpointResult = Result<(), GuestError>;
1891pub type GuestGetBalloonControllerResult = Result<(), GuestError>;
1892pub type GuestGetMemControllerResult = Result<(), GuestError>;
1893
1894pub trait GuestProxyInterface: Send + Sync {
1895    type GetConsoleResponseFut: std::future::Future<Output = Result<GuestGetConsoleResult, fidl::Error>>
1896        + Send;
1897    fn r#get_console(&self) -> Self::GetConsoleResponseFut;
1898    type GetSerialResponseFut: std::future::Future<Output = Result<fidl::Socket, fidl::Error>>
1899        + Send;
1900    fn r#get_serial(&self) -> Self::GetSerialResponseFut;
1901    type GetHostVsockEndpointResponseFut: std::future::Future<Output = Result<GuestGetHostVsockEndpointResult, fidl::Error>>
1902        + Send;
1903    fn r#get_host_vsock_endpoint(
1904        &self,
1905        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
1906    ) -> Self::GetHostVsockEndpointResponseFut;
1907    type GetBalloonControllerResponseFut: std::future::Future<Output = Result<GuestGetBalloonControllerResult, fidl::Error>>
1908        + Send;
1909    fn r#get_balloon_controller(
1910        &self,
1911        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
1912    ) -> Self::GetBalloonControllerResponseFut;
1913    type GetMemControllerResponseFut: std::future::Future<Output = Result<GuestGetMemControllerResult, fidl::Error>>
1914        + Send;
1915    fn r#get_mem_controller(
1916        &self,
1917        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
1918    ) -> Self::GetMemControllerResponseFut;
1919}
1920#[derive(Debug)]
1921#[cfg(target_os = "fuchsia")]
1922pub struct GuestSynchronousProxy {
1923    client: fidl::client::sync::Client,
1924}
1925
1926#[cfg(target_os = "fuchsia")]
1927impl fidl::endpoints::SynchronousProxy for GuestSynchronousProxy {
1928    type Proxy = GuestProxy;
1929    type Protocol = GuestMarker;
1930
1931    fn from_channel(inner: fidl::Channel) -> Self {
1932        Self::new(inner)
1933    }
1934
1935    fn into_channel(self) -> fidl::Channel {
1936        self.client.into_channel()
1937    }
1938
1939    fn as_channel(&self) -> &fidl::Channel {
1940        self.client.as_channel()
1941    }
1942}
1943
1944#[cfg(target_os = "fuchsia")]
1945impl GuestSynchronousProxy {
1946    pub fn new(channel: fidl::Channel) -> Self {
1947        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1948        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1949    }
1950
1951    pub fn into_channel(self) -> fidl::Channel {
1952        self.client.into_channel()
1953    }
1954
1955    /// Waits until an event arrives and returns it. It is safe for other
1956    /// threads to make concurrent requests while waiting for an event.
1957    pub fn wait_for_event(
1958        &self,
1959        deadline: zx::MonotonicInstant,
1960    ) -> Result<GuestEvent, fidl::Error> {
1961        GuestEvent::decode(self.client.wait_for_event(deadline)?)
1962    }
1963
1964    /// Get a guest console.
1965    ///
1966    /// The details regarding what output is produced and what input is accepted
1967    /// are determined by each guest, but will typically be a read/write socket
1968    /// with a shell.
1969    ///
1970    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
1971    pub fn r#get_console(
1972        &self,
1973        ___deadline: zx::MonotonicInstant,
1974    ) -> Result<GuestGetConsoleResult, fidl::Error> {
1975        let _response = self.client.send_query::<
1976            fidl::encoding::EmptyPayload,
1977            fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
1978        >(
1979            (),
1980            0x48cbcecb7793806e,
1981            fidl::encoding::DynamicFlags::empty(),
1982            ___deadline,
1983        )?;
1984        Ok(_response.map(|x| x.socket))
1985    }
1986
1987    /// Get the socket for low-level guest debug logs.
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-only socket
1991    /// with the guest kernel's serial logs.
1992    pub fn r#get_serial(
1993        &self,
1994        ___deadline: zx::MonotonicInstant,
1995    ) -> Result<fidl::Socket, fidl::Error> {
1996        let _response =
1997            self.client.send_query::<fidl::encoding::EmptyPayload, GuestGetSerialResponse>(
1998                (),
1999                0xcdd541a160d7044,
2000                fidl::encoding::DynamicFlags::empty(),
2001                ___deadline,
2002            )?;
2003        Ok(_response.socket)
2004    }
2005
2006    /// Get the vsock endpoint for the guest.
2007    ///
2008    /// This endpoint can be used to register listeners for guest initiated connections, and
2009    /// to initiate connections from a client. If listeners need to be registered before the guest
2010    /// starts so that they are immediately available, set them via the guest config instead of
2011    /// using this endpoint.
2012    ///
2013    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2014    pub fn r#get_host_vsock_endpoint(
2015        &self,
2016        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2017        ___deadline: zx::MonotonicInstant,
2018    ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2019        let _response = self.client.send_query::<
2020            GuestGetHostVsockEndpointRequest,
2021            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2022        >(
2023            (endpoint,),
2024            0x766e96aeb9c28ed1,
2025            fidl::encoding::DynamicFlags::empty(),
2026            ___deadline,
2027        )?;
2028        Ok(_response.map(|x| x))
2029    }
2030
2031    /// Get the balloon controller endpoint for the guest.
2032    ///
2033    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2034    pub fn r#get_balloon_controller(
2035        &self,
2036        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2037        ___deadline: zx::MonotonicInstant,
2038    ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2039        let _response = self.client.send_query::<
2040            GuestGetBalloonControllerRequest,
2041            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2042        >(
2043            (controller,),
2044            0x7b210bff219ac84e,
2045            fidl::encoding::DynamicFlags::empty(),
2046            ___deadline,
2047        )?;
2048        Ok(_response.map(|x| x))
2049    }
2050
2051    /// Get the mem controller endpoint for the guest.
2052    ///
2053    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2054    pub fn r#get_mem_controller(
2055        &self,
2056        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2057        ___deadline: zx::MonotonicInstant,
2058    ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2059        let _response = self.client.send_query::<
2060            GuestGetMemControllerRequest,
2061            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2062        >(
2063            (controller,),
2064            0x170b19f4b867a01c,
2065            fidl::encoding::DynamicFlags::empty(),
2066            ___deadline,
2067        )?;
2068        Ok(_response.map(|x| x))
2069    }
2070}
2071
2072#[cfg(target_os = "fuchsia")]
2073impl From<GuestSynchronousProxy> for zx::Handle {
2074    fn from(value: GuestSynchronousProxy) -> Self {
2075        value.into_channel().into()
2076    }
2077}
2078
2079#[cfg(target_os = "fuchsia")]
2080impl From<fidl::Channel> for GuestSynchronousProxy {
2081    fn from(value: fidl::Channel) -> Self {
2082        Self::new(value)
2083    }
2084}
2085
2086#[cfg(target_os = "fuchsia")]
2087impl fidl::endpoints::FromClient for GuestSynchronousProxy {
2088    type Protocol = GuestMarker;
2089
2090    fn from_client(value: fidl::endpoints::ClientEnd<GuestMarker>) -> Self {
2091        Self::new(value.into_channel())
2092    }
2093}
2094
2095#[derive(Debug, Clone)]
2096pub struct GuestProxy {
2097    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2098}
2099
2100impl fidl::endpoints::Proxy for GuestProxy {
2101    type Protocol = GuestMarker;
2102
2103    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2104        Self::new(inner)
2105    }
2106
2107    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2108        self.client.into_channel().map_err(|client| Self { client })
2109    }
2110
2111    fn as_channel(&self) -> &::fidl::AsyncChannel {
2112        self.client.as_channel()
2113    }
2114}
2115
2116impl GuestProxy {
2117    /// Create a new Proxy for fuchsia.virtualization/Guest.
2118    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2119        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2120        Self { client: fidl::client::Client::new(channel, protocol_name) }
2121    }
2122
2123    /// Get a Stream of events from the remote end of the protocol.
2124    ///
2125    /// # Panics
2126    ///
2127    /// Panics if the event stream was already taken.
2128    pub fn take_event_stream(&self) -> GuestEventStream {
2129        GuestEventStream { event_receiver: self.client.take_event_receiver() }
2130    }
2131
2132    /// Get a guest console.
2133    ///
2134    /// The details regarding what output is produced and what input is accepted
2135    /// are determined by each guest, but will typically be a read/write socket
2136    /// with a shell.
2137    ///
2138    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2139    pub fn r#get_console(
2140        &self,
2141    ) -> fidl::client::QueryResponseFut<
2142        GuestGetConsoleResult,
2143        fidl::encoding::DefaultFuchsiaResourceDialect,
2144    > {
2145        GuestProxyInterface::r#get_console(self)
2146    }
2147
2148    /// Get the socket for low-level guest debug logs.
2149    ///
2150    /// The details regarding what output is produced and what input is accepted
2151    /// are determined by each guest, but will typically be a read-only socket
2152    /// with the guest kernel's serial logs.
2153    pub fn r#get_serial(
2154        &self,
2155    ) -> fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>
2156    {
2157        GuestProxyInterface::r#get_serial(self)
2158    }
2159
2160    /// Get the vsock endpoint for the guest.
2161    ///
2162    /// This endpoint can be used to register listeners for guest initiated connections, and
2163    /// to initiate connections from a client. If listeners need to be registered before the guest
2164    /// starts so that they are immediately available, set them via the guest config instead of
2165    /// using this endpoint.
2166    ///
2167    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2168    pub fn r#get_host_vsock_endpoint(
2169        &self,
2170        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2171    ) -> fidl::client::QueryResponseFut<
2172        GuestGetHostVsockEndpointResult,
2173        fidl::encoding::DefaultFuchsiaResourceDialect,
2174    > {
2175        GuestProxyInterface::r#get_host_vsock_endpoint(self, endpoint)
2176    }
2177
2178    /// Get the balloon controller endpoint for the guest.
2179    ///
2180    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2181    pub fn r#get_balloon_controller(
2182        &self,
2183        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2184    ) -> fidl::client::QueryResponseFut<
2185        GuestGetBalloonControllerResult,
2186        fidl::encoding::DefaultFuchsiaResourceDialect,
2187    > {
2188        GuestProxyInterface::r#get_balloon_controller(self, controller)
2189    }
2190
2191    /// Get the mem controller endpoint for the guest.
2192    ///
2193    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2194    pub fn r#get_mem_controller(
2195        &self,
2196        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2197    ) -> fidl::client::QueryResponseFut<
2198        GuestGetMemControllerResult,
2199        fidl::encoding::DefaultFuchsiaResourceDialect,
2200    > {
2201        GuestProxyInterface::r#get_mem_controller(self, controller)
2202    }
2203}
2204
2205impl GuestProxyInterface for GuestProxy {
2206    type GetConsoleResponseFut = fidl::client::QueryResponseFut<
2207        GuestGetConsoleResult,
2208        fidl::encoding::DefaultFuchsiaResourceDialect,
2209    >;
2210    fn r#get_console(&self) -> Self::GetConsoleResponseFut {
2211        fn _decode(
2212            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2213        ) -> Result<GuestGetConsoleResult, fidl::Error> {
2214            let _response = fidl::client::decode_transaction_body::<
2215                fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
2216                fidl::encoding::DefaultFuchsiaResourceDialect,
2217                0x48cbcecb7793806e,
2218            >(_buf?)?;
2219            Ok(_response.map(|x| x.socket))
2220        }
2221        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestGetConsoleResult>(
2222            (),
2223            0x48cbcecb7793806e,
2224            fidl::encoding::DynamicFlags::empty(),
2225            _decode,
2226        )
2227    }
2228
2229    type GetSerialResponseFut =
2230        fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2231    fn r#get_serial(&self) -> Self::GetSerialResponseFut {
2232        fn _decode(
2233            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2234        ) -> Result<fidl::Socket, fidl::Error> {
2235            let _response = fidl::client::decode_transaction_body::<
2236                GuestGetSerialResponse,
2237                fidl::encoding::DefaultFuchsiaResourceDialect,
2238                0xcdd541a160d7044,
2239            >(_buf?)?;
2240            Ok(_response.socket)
2241        }
2242        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Socket>(
2243            (),
2244            0xcdd541a160d7044,
2245            fidl::encoding::DynamicFlags::empty(),
2246            _decode,
2247        )
2248    }
2249
2250    type GetHostVsockEndpointResponseFut = fidl::client::QueryResponseFut<
2251        GuestGetHostVsockEndpointResult,
2252        fidl::encoding::DefaultFuchsiaResourceDialect,
2253    >;
2254    fn r#get_host_vsock_endpoint(
2255        &self,
2256        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2257    ) -> Self::GetHostVsockEndpointResponseFut {
2258        fn _decode(
2259            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2260        ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2261            let _response = fidl::client::decode_transaction_body::<
2262                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2263                fidl::encoding::DefaultFuchsiaResourceDialect,
2264                0x766e96aeb9c28ed1,
2265            >(_buf?)?;
2266            Ok(_response.map(|x| x))
2267        }
2268        self.client.send_query_and_decode::<
2269            GuestGetHostVsockEndpointRequest,
2270            GuestGetHostVsockEndpointResult,
2271        >(
2272            (endpoint,),
2273            0x766e96aeb9c28ed1,
2274            fidl::encoding::DynamicFlags::empty(),
2275            _decode,
2276        )
2277    }
2278
2279    type GetBalloonControllerResponseFut = fidl::client::QueryResponseFut<
2280        GuestGetBalloonControllerResult,
2281        fidl::encoding::DefaultFuchsiaResourceDialect,
2282    >;
2283    fn r#get_balloon_controller(
2284        &self,
2285        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2286    ) -> Self::GetBalloonControllerResponseFut {
2287        fn _decode(
2288            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2289        ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2290            let _response = fidl::client::decode_transaction_body::<
2291                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2292                fidl::encoding::DefaultFuchsiaResourceDialect,
2293                0x7b210bff219ac84e,
2294            >(_buf?)?;
2295            Ok(_response.map(|x| x))
2296        }
2297        self.client.send_query_and_decode::<
2298            GuestGetBalloonControllerRequest,
2299            GuestGetBalloonControllerResult,
2300        >(
2301            (controller,),
2302            0x7b210bff219ac84e,
2303            fidl::encoding::DynamicFlags::empty(),
2304            _decode,
2305        )
2306    }
2307
2308    type GetMemControllerResponseFut = fidl::client::QueryResponseFut<
2309        GuestGetMemControllerResult,
2310        fidl::encoding::DefaultFuchsiaResourceDialect,
2311    >;
2312    fn r#get_mem_controller(
2313        &self,
2314        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2315    ) -> Self::GetMemControllerResponseFut {
2316        fn _decode(
2317            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2318        ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2319            let _response = fidl::client::decode_transaction_body::<
2320                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2321                fidl::encoding::DefaultFuchsiaResourceDialect,
2322                0x170b19f4b867a01c,
2323            >(_buf?)?;
2324            Ok(_response.map(|x| x))
2325        }
2326        self.client
2327            .send_query_and_decode::<GuestGetMemControllerRequest, GuestGetMemControllerResult>(
2328                (controller,),
2329                0x170b19f4b867a01c,
2330                fidl::encoding::DynamicFlags::empty(),
2331                _decode,
2332            )
2333    }
2334}
2335
2336pub struct GuestEventStream {
2337    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2338}
2339
2340impl std::marker::Unpin for GuestEventStream {}
2341
2342impl futures::stream::FusedStream for GuestEventStream {
2343    fn is_terminated(&self) -> bool {
2344        self.event_receiver.is_terminated()
2345    }
2346}
2347
2348impl futures::Stream for GuestEventStream {
2349    type Item = Result<GuestEvent, fidl::Error>;
2350
2351    fn poll_next(
2352        mut self: std::pin::Pin<&mut Self>,
2353        cx: &mut std::task::Context<'_>,
2354    ) -> std::task::Poll<Option<Self::Item>> {
2355        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2356            &mut self.event_receiver,
2357            cx
2358        )?) {
2359            Some(buf) => std::task::Poll::Ready(Some(GuestEvent::decode(buf))),
2360            None => std::task::Poll::Ready(None),
2361        }
2362    }
2363}
2364
2365#[derive(Debug)]
2366pub enum GuestEvent {}
2367
2368impl GuestEvent {
2369    /// Decodes a message buffer as a [`GuestEvent`].
2370    fn decode(
2371        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2372    ) -> Result<GuestEvent, fidl::Error> {
2373        let (bytes, _handles) = buf.split_mut();
2374        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2375        debug_assert_eq!(tx_header.tx_id, 0);
2376        match tx_header.ordinal {
2377            _ => Err(fidl::Error::UnknownOrdinal {
2378                ordinal: tx_header.ordinal,
2379                protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2380            }),
2381        }
2382    }
2383}
2384
2385/// A Stream of incoming requests for fuchsia.virtualization/Guest.
2386pub struct GuestRequestStream {
2387    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2388    is_terminated: bool,
2389}
2390
2391impl std::marker::Unpin for GuestRequestStream {}
2392
2393impl futures::stream::FusedStream for GuestRequestStream {
2394    fn is_terminated(&self) -> bool {
2395        self.is_terminated
2396    }
2397}
2398
2399impl fidl::endpoints::RequestStream for GuestRequestStream {
2400    type Protocol = GuestMarker;
2401    type ControlHandle = GuestControlHandle;
2402
2403    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2404        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2405    }
2406
2407    fn control_handle(&self) -> Self::ControlHandle {
2408        GuestControlHandle { inner: self.inner.clone() }
2409    }
2410
2411    fn into_inner(
2412        self,
2413    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2414    {
2415        (self.inner, self.is_terminated)
2416    }
2417
2418    fn from_inner(
2419        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2420        is_terminated: bool,
2421    ) -> Self {
2422        Self { inner, is_terminated }
2423    }
2424}
2425
2426impl futures::Stream for GuestRequestStream {
2427    type Item = Result<GuestRequest, fidl::Error>;
2428
2429    fn poll_next(
2430        mut self: std::pin::Pin<&mut Self>,
2431        cx: &mut std::task::Context<'_>,
2432    ) -> std::task::Poll<Option<Self::Item>> {
2433        let this = &mut *self;
2434        if this.inner.check_shutdown(cx) {
2435            this.is_terminated = true;
2436            return std::task::Poll::Ready(None);
2437        }
2438        if this.is_terminated {
2439            panic!("polled GuestRequestStream after completion");
2440        }
2441        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2442            |bytes, handles| {
2443                match this.inner.channel().read_etc(cx, bytes, handles) {
2444                    std::task::Poll::Ready(Ok(())) => {}
2445                    std::task::Poll::Pending => return std::task::Poll::Pending,
2446                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2447                        this.is_terminated = true;
2448                        return std::task::Poll::Ready(None);
2449                    }
2450                    std::task::Poll::Ready(Err(e)) => {
2451                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2452                            e.into(),
2453                        ))));
2454                    }
2455                }
2456
2457                // A message has been received from the channel
2458                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2459
2460                std::task::Poll::Ready(Some(match header.ordinal {
2461                    0x48cbcecb7793806e => {
2462                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2463                        let mut req = fidl::new_empty!(
2464                            fidl::encoding::EmptyPayload,
2465                            fidl::encoding::DefaultFuchsiaResourceDialect
2466                        );
2467                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2468                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2469                        Ok(GuestRequest::GetConsole {
2470                            responder: GuestGetConsoleResponder {
2471                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2472                                tx_id: header.tx_id,
2473                            },
2474                        })
2475                    }
2476                    0xcdd541a160d7044 => {
2477                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2478                        let mut req = fidl::new_empty!(
2479                            fidl::encoding::EmptyPayload,
2480                            fidl::encoding::DefaultFuchsiaResourceDialect
2481                        );
2482                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2483                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2484                        Ok(GuestRequest::GetSerial {
2485                            responder: GuestGetSerialResponder {
2486                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2487                                tx_id: header.tx_id,
2488                            },
2489                        })
2490                    }
2491                    0x766e96aeb9c28ed1 => {
2492                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2493                        let mut req = fidl::new_empty!(
2494                            GuestGetHostVsockEndpointRequest,
2495                            fidl::encoding::DefaultFuchsiaResourceDialect
2496                        );
2497                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetHostVsockEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
2498                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2499                        Ok(GuestRequest::GetHostVsockEndpoint {
2500                            endpoint: req.endpoint,
2501
2502                            responder: GuestGetHostVsockEndpointResponder {
2503                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2504                                tx_id: header.tx_id,
2505                            },
2506                        })
2507                    }
2508                    0x7b210bff219ac84e => {
2509                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2510                        let mut req = fidl::new_empty!(
2511                            GuestGetBalloonControllerRequest,
2512                            fidl::encoding::DefaultFuchsiaResourceDialect
2513                        );
2514                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetBalloonControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2515                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2516                        Ok(GuestRequest::GetBalloonController {
2517                            controller: req.controller,
2518
2519                            responder: GuestGetBalloonControllerResponder {
2520                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2521                                tx_id: header.tx_id,
2522                            },
2523                        })
2524                    }
2525                    0x170b19f4b867a01c => {
2526                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2527                        let mut req = fidl::new_empty!(
2528                            GuestGetMemControllerRequest,
2529                            fidl::encoding::DefaultFuchsiaResourceDialect
2530                        );
2531                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetMemControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2532                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2533                        Ok(GuestRequest::GetMemController {
2534                            controller: req.controller,
2535
2536                            responder: GuestGetMemControllerResponder {
2537                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2538                                tx_id: header.tx_id,
2539                            },
2540                        })
2541                    }
2542                    _ => Err(fidl::Error::UnknownOrdinal {
2543                        ordinal: header.ordinal,
2544                        protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2545                    }),
2546                }))
2547            },
2548        )
2549    }
2550}
2551
2552/// The guest client API providing high level access to guest features. When the guest terminates,
2553/// this channel will contain a ZX_OK epitaph on a clean shutdown, a ZX_ERR_INTERNAL epitaph on
2554/// an unexpected shutdown, and no epitaph if the component crashed.
2555#[derive(Debug)]
2556pub enum GuestRequest {
2557    /// Get a guest console.
2558    ///
2559    /// The details regarding what output is produced and what input is accepted
2560    /// are determined by each guest, but will typically be a read/write socket
2561    /// with a shell.
2562    ///
2563    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2564    GetConsole { responder: GuestGetConsoleResponder },
2565    /// Get the socket for low-level guest debug logs.
2566    ///
2567    /// The details regarding what output is produced and what input is accepted
2568    /// are determined by each guest, but will typically be a read-only socket
2569    /// with the guest kernel's serial logs.
2570    GetSerial { responder: GuestGetSerialResponder },
2571    /// Get the vsock endpoint for the guest.
2572    ///
2573    /// This endpoint can be used to register listeners for guest initiated connections, and
2574    /// to initiate connections from a client. If listeners need to be registered before the guest
2575    /// starts so that they are immediately available, set them via the guest config instead of
2576    /// using this endpoint.
2577    ///
2578    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2579    GetHostVsockEndpoint {
2580        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2581        responder: GuestGetHostVsockEndpointResponder,
2582    },
2583    /// Get the balloon controller endpoint for the guest.
2584    ///
2585    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2586    GetBalloonController {
2587        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2588        responder: GuestGetBalloonControllerResponder,
2589    },
2590    /// Get the mem controller endpoint for the guest.
2591    ///
2592    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2593    GetMemController {
2594        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2595        responder: GuestGetMemControllerResponder,
2596    },
2597}
2598
2599impl GuestRequest {
2600    #[allow(irrefutable_let_patterns)]
2601    pub fn into_get_console(self) -> Option<(GuestGetConsoleResponder)> {
2602        if let GuestRequest::GetConsole { responder } = self { Some((responder)) } else { None }
2603    }
2604
2605    #[allow(irrefutable_let_patterns)]
2606    pub fn into_get_serial(self) -> Option<(GuestGetSerialResponder)> {
2607        if let GuestRequest::GetSerial { responder } = self { Some((responder)) } else { None }
2608    }
2609
2610    #[allow(irrefutable_let_patterns)]
2611    pub fn into_get_host_vsock_endpoint(
2612        self,
2613    ) -> Option<(
2614        fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2615        GuestGetHostVsockEndpointResponder,
2616    )> {
2617        if let GuestRequest::GetHostVsockEndpoint { endpoint, responder } = self {
2618            Some((endpoint, responder))
2619        } else {
2620            None
2621        }
2622    }
2623
2624    #[allow(irrefutable_let_patterns)]
2625    pub fn into_get_balloon_controller(
2626        self,
2627    ) -> Option<(
2628        fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2629        GuestGetBalloonControllerResponder,
2630    )> {
2631        if let GuestRequest::GetBalloonController { controller, responder } = self {
2632            Some((controller, responder))
2633        } else {
2634            None
2635        }
2636    }
2637
2638    #[allow(irrefutable_let_patterns)]
2639    pub fn into_get_mem_controller(
2640        self,
2641    ) -> Option<(fidl::endpoints::ServerEnd<MemControllerMarker>, GuestGetMemControllerResponder)>
2642    {
2643        if let GuestRequest::GetMemController { controller, responder } = self {
2644            Some((controller, responder))
2645        } else {
2646            None
2647        }
2648    }
2649
2650    /// Name of the method defined in FIDL
2651    pub fn method_name(&self) -> &'static str {
2652        match *self {
2653            GuestRequest::GetConsole { .. } => "get_console",
2654            GuestRequest::GetSerial { .. } => "get_serial",
2655            GuestRequest::GetHostVsockEndpoint { .. } => "get_host_vsock_endpoint",
2656            GuestRequest::GetBalloonController { .. } => "get_balloon_controller",
2657            GuestRequest::GetMemController { .. } => "get_mem_controller",
2658        }
2659    }
2660}
2661
2662#[derive(Debug, Clone)]
2663pub struct GuestControlHandle {
2664    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2665}
2666
2667impl fidl::endpoints::ControlHandle for GuestControlHandle {
2668    fn shutdown(&self) {
2669        self.inner.shutdown()
2670    }
2671    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2672        self.inner.shutdown_with_epitaph(status)
2673    }
2674
2675    fn is_closed(&self) -> bool {
2676        self.inner.channel().is_closed()
2677    }
2678    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2679        self.inner.channel().on_closed()
2680    }
2681
2682    #[cfg(target_os = "fuchsia")]
2683    fn signal_peer(
2684        &self,
2685        clear_mask: zx::Signals,
2686        set_mask: zx::Signals,
2687    ) -> Result<(), zx_status::Status> {
2688        use fidl::Peered;
2689        self.inner.channel().signal_peer(clear_mask, set_mask)
2690    }
2691}
2692
2693impl GuestControlHandle {}
2694
2695#[must_use = "FIDL methods require a response to be sent"]
2696#[derive(Debug)]
2697pub struct GuestGetConsoleResponder {
2698    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2699    tx_id: u32,
2700}
2701
2702/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2703/// if the responder is dropped without sending a response, so that the client
2704/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2705impl std::ops::Drop for GuestGetConsoleResponder {
2706    fn drop(&mut self) {
2707        self.control_handle.shutdown();
2708        // Safety: drops once, never accessed again
2709        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2710    }
2711}
2712
2713impl fidl::endpoints::Responder for GuestGetConsoleResponder {
2714    type ControlHandle = GuestControlHandle;
2715
2716    fn control_handle(&self) -> &GuestControlHandle {
2717        &self.control_handle
2718    }
2719
2720    fn drop_without_shutdown(mut self) {
2721        // Safety: drops once, never accessed again due to mem::forget
2722        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2723        // Prevent Drop from running (which would shut down the channel)
2724        std::mem::forget(self);
2725    }
2726}
2727
2728impl GuestGetConsoleResponder {
2729    /// Sends a response to the FIDL transaction.
2730    ///
2731    /// Sets the channel to shutdown if an error occurs.
2732    pub fn send(self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2733        let _result = self.send_raw(result);
2734        if _result.is_err() {
2735            self.control_handle.shutdown();
2736        }
2737        self.drop_without_shutdown();
2738        _result
2739    }
2740
2741    /// Similar to "send" but does not shutdown the channel if an error occurs.
2742    pub fn send_no_shutdown_on_err(
2743        self,
2744        mut result: Result<fidl::Socket, GuestError>,
2745    ) -> Result<(), fidl::Error> {
2746        let _result = self.send_raw(result);
2747        self.drop_without_shutdown();
2748        _result
2749    }
2750
2751    fn send_raw(&self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2752        self.control_handle
2753            .inner
2754            .send::<fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>>(
2755                result.map(|socket| (socket,)),
2756                self.tx_id,
2757                0x48cbcecb7793806e,
2758                fidl::encoding::DynamicFlags::empty(),
2759            )
2760    }
2761}
2762
2763#[must_use = "FIDL methods require a response to be sent"]
2764#[derive(Debug)]
2765pub struct GuestGetSerialResponder {
2766    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2767    tx_id: u32,
2768}
2769
2770/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2771/// if the responder is dropped without sending a response, so that the client
2772/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2773impl std::ops::Drop for GuestGetSerialResponder {
2774    fn drop(&mut self) {
2775        self.control_handle.shutdown();
2776        // Safety: drops once, never accessed again
2777        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2778    }
2779}
2780
2781impl fidl::endpoints::Responder for GuestGetSerialResponder {
2782    type ControlHandle = GuestControlHandle;
2783
2784    fn control_handle(&self) -> &GuestControlHandle {
2785        &self.control_handle
2786    }
2787
2788    fn drop_without_shutdown(mut self) {
2789        // Safety: drops once, never accessed again due to mem::forget
2790        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2791        // Prevent Drop from running (which would shut down the channel)
2792        std::mem::forget(self);
2793    }
2794}
2795
2796impl GuestGetSerialResponder {
2797    /// Sends a response to the FIDL transaction.
2798    ///
2799    /// Sets the channel to shutdown if an error occurs.
2800    pub fn send(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2801        let _result = self.send_raw(socket);
2802        if _result.is_err() {
2803            self.control_handle.shutdown();
2804        }
2805        self.drop_without_shutdown();
2806        _result
2807    }
2808
2809    /// Similar to "send" but does not shutdown the channel if an error occurs.
2810    pub fn send_no_shutdown_on_err(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2811        let _result = self.send_raw(socket);
2812        self.drop_without_shutdown();
2813        _result
2814    }
2815
2816    fn send_raw(&self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2817        self.control_handle.inner.send::<GuestGetSerialResponse>(
2818            (socket,),
2819            self.tx_id,
2820            0xcdd541a160d7044,
2821            fidl::encoding::DynamicFlags::empty(),
2822        )
2823    }
2824}
2825
2826#[must_use = "FIDL methods require a response to be sent"]
2827#[derive(Debug)]
2828pub struct GuestGetHostVsockEndpointResponder {
2829    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2830    tx_id: u32,
2831}
2832
2833/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2834/// if the responder is dropped without sending a response, so that the client
2835/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2836impl std::ops::Drop for GuestGetHostVsockEndpointResponder {
2837    fn drop(&mut self) {
2838        self.control_handle.shutdown();
2839        // Safety: drops once, never accessed again
2840        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2841    }
2842}
2843
2844impl fidl::endpoints::Responder for GuestGetHostVsockEndpointResponder {
2845    type ControlHandle = GuestControlHandle;
2846
2847    fn control_handle(&self) -> &GuestControlHandle {
2848        &self.control_handle
2849    }
2850
2851    fn drop_without_shutdown(mut self) {
2852        // Safety: drops once, never accessed again due to mem::forget
2853        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2854        // Prevent Drop from running (which would shut down the channel)
2855        std::mem::forget(self);
2856    }
2857}
2858
2859impl GuestGetHostVsockEndpointResponder {
2860    /// Sends a response to the FIDL transaction.
2861    ///
2862    /// Sets the channel to shutdown if an error occurs.
2863    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2864        let _result = self.send_raw(result);
2865        if _result.is_err() {
2866            self.control_handle.shutdown();
2867        }
2868        self.drop_without_shutdown();
2869        _result
2870    }
2871
2872    /// Similar to "send" but does not shutdown the channel if an error occurs.
2873    pub fn send_no_shutdown_on_err(
2874        self,
2875        mut result: Result<(), GuestError>,
2876    ) -> Result<(), fidl::Error> {
2877        let _result = self.send_raw(result);
2878        self.drop_without_shutdown();
2879        _result
2880    }
2881
2882    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2883        self.control_handle
2884            .inner
2885            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2886                result,
2887                self.tx_id,
2888                0x766e96aeb9c28ed1,
2889                fidl::encoding::DynamicFlags::empty(),
2890            )
2891    }
2892}
2893
2894#[must_use = "FIDL methods require a response to be sent"]
2895#[derive(Debug)]
2896pub struct GuestGetBalloonControllerResponder {
2897    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2898    tx_id: u32,
2899}
2900
2901/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2902/// if the responder is dropped without sending a response, so that the client
2903/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2904impl std::ops::Drop for GuestGetBalloonControllerResponder {
2905    fn drop(&mut self) {
2906        self.control_handle.shutdown();
2907        // Safety: drops once, never accessed again
2908        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2909    }
2910}
2911
2912impl fidl::endpoints::Responder for GuestGetBalloonControllerResponder {
2913    type ControlHandle = GuestControlHandle;
2914
2915    fn control_handle(&self) -> &GuestControlHandle {
2916        &self.control_handle
2917    }
2918
2919    fn drop_without_shutdown(mut self) {
2920        // Safety: drops once, never accessed again due to mem::forget
2921        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2922        // Prevent Drop from running (which would shut down the channel)
2923        std::mem::forget(self);
2924    }
2925}
2926
2927impl GuestGetBalloonControllerResponder {
2928    /// Sends a response to the FIDL transaction.
2929    ///
2930    /// Sets the channel to shutdown if an error occurs.
2931    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2932        let _result = self.send_raw(result);
2933        if _result.is_err() {
2934            self.control_handle.shutdown();
2935        }
2936        self.drop_without_shutdown();
2937        _result
2938    }
2939
2940    /// Similar to "send" but does not shutdown the channel if an error occurs.
2941    pub fn send_no_shutdown_on_err(
2942        self,
2943        mut result: Result<(), GuestError>,
2944    ) -> Result<(), fidl::Error> {
2945        let _result = self.send_raw(result);
2946        self.drop_without_shutdown();
2947        _result
2948    }
2949
2950    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2951        self.control_handle
2952            .inner
2953            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2954                result,
2955                self.tx_id,
2956                0x7b210bff219ac84e,
2957                fidl::encoding::DynamicFlags::empty(),
2958            )
2959    }
2960}
2961
2962#[must_use = "FIDL methods require a response to be sent"]
2963#[derive(Debug)]
2964pub struct GuestGetMemControllerResponder {
2965    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2966    tx_id: u32,
2967}
2968
2969/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2970/// if the responder is dropped without sending a response, so that the client
2971/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2972impl std::ops::Drop for GuestGetMemControllerResponder {
2973    fn drop(&mut self) {
2974        self.control_handle.shutdown();
2975        // Safety: drops once, never accessed again
2976        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2977    }
2978}
2979
2980impl fidl::endpoints::Responder for GuestGetMemControllerResponder {
2981    type ControlHandle = GuestControlHandle;
2982
2983    fn control_handle(&self) -> &GuestControlHandle {
2984        &self.control_handle
2985    }
2986
2987    fn drop_without_shutdown(mut self) {
2988        // Safety: drops once, never accessed again due to mem::forget
2989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2990        // Prevent Drop from running (which would shut down the channel)
2991        std::mem::forget(self);
2992    }
2993}
2994
2995impl GuestGetMemControllerResponder {
2996    /// Sends a response to the FIDL transaction.
2997    ///
2998    /// Sets the channel to shutdown if an error occurs.
2999    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3000        let _result = self.send_raw(result);
3001        if _result.is_err() {
3002            self.control_handle.shutdown();
3003        }
3004        self.drop_without_shutdown();
3005        _result
3006    }
3007
3008    /// Similar to "send" but does not shutdown the channel if an error occurs.
3009    pub fn send_no_shutdown_on_err(
3010        self,
3011        mut result: Result<(), GuestError>,
3012    ) -> Result<(), fidl::Error> {
3013        let _result = self.send_raw(result);
3014        self.drop_without_shutdown();
3015        _result
3016    }
3017
3018    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3019        self.control_handle
3020            .inner
3021            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3022                result,
3023                self.tx_id,
3024                0x170b19f4b867a01c,
3025                fidl::encoding::DynamicFlags::empty(),
3026            )
3027    }
3028}
3029
3030#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3031pub struct GuestLifecycleMarker;
3032
3033impl fidl::endpoints::ProtocolMarker for GuestLifecycleMarker {
3034    type Proxy = GuestLifecycleProxy;
3035    type RequestStream = GuestLifecycleRequestStream;
3036    #[cfg(target_os = "fuchsia")]
3037    type SynchronousProxy = GuestLifecycleSynchronousProxy;
3038
3039    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestLifecycle";
3040}
3041impl fidl::endpoints::DiscoverableProtocolMarker for GuestLifecycleMarker {}
3042pub type GuestLifecycleCreateResult = Result<(), GuestError>;
3043pub type GuestLifecycleRunResult = Result<(), GuestError>;
3044
3045pub trait GuestLifecycleProxyInterface: Send + Sync {
3046    type CreateResponseFut: std::future::Future<Output = Result<GuestLifecycleCreateResult, fidl::Error>>
3047        + Send;
3048    fn r#create(&self, guest_config: GuestConfig) -> Self::CreateResponseFut;
3049    fn r#bind(&self, guest: fidl::endpoints::ServerEnd<GuestMarker>) -> Result<(), fidl::Error>;
3050    type RunResponseFut: std::future::Future<Output = Result<GuestLifecycleRunResult, fidl::Error>>
3051        + Send;
3052    fn r#run(&self) -> Self::RunResponseFut;
3053    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3054    fn r#stop(&self) -> Self::StopResponseFut;
3055}
3056#[derive(Debug)]
3057#[cfg(target_os = "fuchsia")]
3058pub struct GuestLifecycleSynchronousProxy {
3059    client: fidl::client::sync::Client,
3060}
3061
3062#[cfg(target_os = "fuchsia")]
3063impl fidl::endpoints::SynchronousProxy for GuestLifecycleSynchronousProxy {
3064    type Proxy = GuestLifecycleProxy;
3065    type Protocol = GuestLifecycleMarker;
3066
3067    fn from_channel(inner: fidl::Channel) -> Self {
3068        Self::new(inner)
3069    }
3070
3071    fn into_channel(self) -> fidl::Channel {
3072        self.client.into_channel()
3073    }
3074
3075    fn as_channel(&self) -> &fidl::Channel {
3076        self.client.as_channel()
3077    }
3078}
3079
3080#[cfg(target_os = "fuchsia")]
3081impl GuestLifecycleSynchronousProxy {
3082    pub fn new(channel: fidl::Channel) -> Self {
3083        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3084        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3085    }
3086
3087    pub fn into_channel(self) -> fidl::Channel {
3088        self.client.into_channel()
3089    }
3090
3091    /// Waits until an event arrives and returns it. It is safe for other
3092    /// threads to make concurrent requests while waiting for an event.
3093    pub fn wait_for_event(
3094        &self,
3095        deadline: zx::MonotonicInstant,
3096    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3097        GuestLifecycleEvent::decode(self.client.wait_for_event(deadline)?)
3098    }
3099
3100    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3101    /// the kernel without starting the VCPU or device dispatch loops.
3102    ///
3103    /// Possible errors:
3104    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3105    ///         recreated.
3106    ///
3107    /// All other errors are related to VMM initialization.
3108    pub fn r#create(
3109        &self,
3110        mut guest_config: GuestConfig,
3111        ___deadline: zx::MonotonicInstant,
3112    ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3113        let _response = self.client.send_query::<
3114            GuestLifecycleCreateRequest,
3115            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3116        >(
3117            (&mut guest_config,),
3118            0x152719eed416ed41,
3119            fidl::encoding::DynamicFlags::empty(),
3120            ___deadline,
3121        )?;
3122        Ok(_response.map(|x| x))
3123    }
3124
3125    /// Binds to the Guest protocol for an initialized guest.
3126    ///
3127    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3128    /// will be immediately closed.
3129    pub fn r#bind(
3130        &self,
3131        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3132    ) -> Result<(), fidl::Error> {
3133        self.client.send::<GuestLifecycleBindRequest>(
3134            (guest,),
3135            0x57dd3e245f9598ed,
3136            fidl::encoding::DynamicFlags::empty(),
3137        )
3138    }
3139
3140    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3141    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3142    ///
3143    /// Possible errors:
3144    ///     - ALREADY_RUNING: The VMM has already been started.
3145    ///     - NOT_CREATED: Run was called before the VMM was created.
3146    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3147    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3148    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3149    pub fn r#run(
3150        &self,
3151        ___deadline: zx::MonotonicInstant,
3152    ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3153        let _response = self.client.send_query::<
3154            fidl::encoding::EmptyPayload,
3155            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3156        >(
3157            (),
3158            0x2907fef2ac775657,
3159            fidl::encoding::DynamicFlags::empty(),
3160            ___deadline,
3161        )?;
3162        Ok(_response.map(|x| x))
3163    }
3164
3165    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3166    /// Create and then Run can be called again.
3167    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3168        let _response =
3169            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
3170                (),
3171                0x27eef9c535ac8eb4,
3172                fidl::encoding::DynamicFlags::empty(),
3173                ___deadline,
3174            )?;
3175        Ok(_response)
3176    }
3177}
3178
3179#[cfg(target_os = "fuchsia")]
3180impl From<GuestLifecycleSynchronousProxy> for zx::Handle {
3181    fn from(value: GuestLifecycleSynchronousProxy) -> Self {
3182        value.into_channel().into()
3183    }
3184}
3185
3186#[cfg(target_os = "fuchsia")]
3187impl From<fidl::Channel> for GuestLifecycleSynchronousProxy {
3188    fn from(value: fidl::Channel) -> Self {
3189        Self::new(value)
3190    }
3191}
3192
3193#[cfg(target_os = "fuchsia")]
3194impl fidl::endpoints::FromClient for GuestLifecycleSynchronousProxy {
3195    type Protocol = GuestLifecycleMarker;
3196
3197    fn from_client(value: fidl::endpoints::ClientEnd<GuestLifecycleMarker>) -> Self {
3198        Self::new(value.into_channel())
3199    }
3200}
3201
3202#[derive(Debug, Clone)]
3203pub struct GuestLifecycleProxy {
3204    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3205}
3206
3207impl fidl::endpoints::Proxy for GuestLifecycleProxy {
3208    type Protocol = GuestLifecycleMarker;
3209
3210    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3211        Self::new(inner)
3212    }
3213
3214    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3215        self.client.into_channel().map_err(|client| Self { client })
3216    }
3217
3218    fn as_channel(&self) -> &::fidl::AsyncChannel {
3219        self.client.as_channel()
3220    }
3221}
3222
3223impl GuestLifecycleProxy {
3224    /// Create a new Proxy for fuchsia.virtualization/GuestLifecycle.
3225    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3226        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3227        Self { client: fidl::client::Client::new(channel, protocol_name) }
3228    }
3229
3230    /// Get a Stream of events from the remote end of the protocol.
3231    ///
3232    /// # Panics
3233    ///
3234    /// Panics if the event stream was already taken.
3235    pub fn take_event_stream(&self) -> GuestLifecycleEventStream {
3236        GuestLifecycleEventStream { event_receiver: self.client.take_event_receiver() }
3237    }
3238
3239    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3240    /// the kernel without starting the VCPU or device dispatch loops.
3241    ///
3242    /// Possible errors:
3243    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3244    ///         recreated.
3245    ///
3246    /// All other errors are related to VMM initialization.
3247    pub fn r#create(
3248        &self,
3249        mut guest_config: GuestConfig,
3250    ) -> fidl::client::QueryResponseFut<
3251        GuestLifecycleCreateResult,
3252        fidl::encoding::DefaultFuchsiaResourceDialect,
3253    > {
3254        GuestLifecycleProxyInterface::r#create(self, guest_config)
3255    }
3256
3257    /// Binds to the Guest protocol for an initialized guest.
3258    ///
3259    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3260    /// will be immediately closed.
3261    pub fn r#bind(
3262        &self,
3263        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3264    ) -> Result<(), fidl::Error> {
3265        GuestLifecycleProxyInterface::r#bind(self, guest)
3266    }
3267
3268    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3269    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3270    ///
3271    /// Possible errors:
3272    ///     - ALREADY_RUNING: The VMM has already been started.
3273    ///     - NOT_CREATED: Run was called before the VMM was created.
3274    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3275    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3276    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3277    pub fn r#run(
3278        &self,
3279    ) -> fidl::client::QueryResponseFut<
3280        GuestLifecycleRunResult,
3281        fidl::encoding::DefaultFuchsiaResourceDialect,
3282    > {
3283        GuestLifecycleProxyInterface::r#run(self)
3284    }
3285
3286    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3287    /// Create and then Run can be called again.
3288    pub fn r#stop(
3289        &self,
3290    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3291        GuestLifecycleProxyInterface::r#stop(self)
3292    }
3293}
3294
3295impl GuestLifecycleProxyInterface for GuestLifecycleProxy {
3296    type CreateResponseFut = fidl::client::QueryResponseFut<
3297        GuestLifecycleCreateResult,
3298        fidl::encoding::DefaultFuchsiaResourceDialect,
3299    >;
3300    fn r#create(&self, mut guest_config: GuestConfig) -> Self::CreateResponseFut {
3301        fn _decode(
3302            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3303        ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3304            let _response = fidl::client::decode_transaction_body::<
3305                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3306                fidl::encoding::DefaultFuchsiaResourceDialect,
3307                0x152719eed416ed41,
3308            >(_buf?)?;
3309            Ok(_response.map(|x| x))
3310        }
3311        self.client
3312            .send_query_and_decode::<GuestLifecycleCreateRequest, GuestLifecycleCreateResult>(
3313                (&mut guest_config,),
3314                0x152719eed416ed41,
3315                fidl::encoding::DynamicFlags::empty(),
3316                _decode,
3317            )
3318    }
3319
3320    fn r#bind(
3321        &self,
3322        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3323    ) -> Result<(), fidl::Error> {
3324        self.client.send::<GuestLifecycleBindRequest>(
3325            (guest,),
3326            0x57dd3e245f9598ed,
3327            fidl::encoding::DynamicFlags::empty(),
3328        )
3329    }
3330
3331    type RunResponseFut = fidl::client::QueryResponseFut<
3332        GuestLifecycleRunResult,
3333        fidl::encoding::DefaultFuchsiaResourceDialect,
3334    >;
3335    fn r#run(&self) -> Self::RunResponseFut {
3336        fn _decode(
3337            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3338        ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3339            let _response = fidl::client::decode_transaction_body::<
3340                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3341                fidl::encoding::DefaultFuchsiaResourceDialect,
3342                0x2907fef2ac775657,
3343            >(_buf?)?;
3344            Ok(_response.map(|x| x))
3345        }
3346        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestLifecycleRunResult>(
3347            (),
3348            0x2907fef2ac775657,
3349            fidl::encoding::DynamicFlags::empty(),
3350            _decode,
3351        )
3352    }
3353
3354    type StopResponseFut =
3355        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3356    fn r#stop(&self) -> Self::StopResponseFut {
3357        fn _decode(
3358            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3359        ) -> Result<(), fidl::Error> {
3360            let _response = fidl::client::decode_transaction_body::<
3361                fidl::encoding::EmptyPayload,
3362                fidl::encoding::DefaultFuchsiaResourceDialect,
3363                0x27eef9c535ac8eb4,
3364            >(_buf?)?;
3365            Ok(_response)
3366        }
3367        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3368            (),
3369            0x27eef9c535ac8eb4,
3370            fidl::encoding::DynamicFlags::empty(),
3371            _decode,
3372        )
3373    }
3374}
3375
3376pub struct GuestLifecycleEventStream {
3377    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3378}
3379
3380impl std::marker::Unpin for GuestLifecycleEventStream {}
3381
3382impl futures::stream::FusedStream for GuestLifecycleEventStream {
3383    fn is_terminated(&self) -> bool {
3384        self.event_receiver.is_terminated()
3385    }
3386}
3387
3388impl futures::Stream for GuestLifecycleEventStream {
3389    type Item = Result<GuestLifecycleEvent, fidl::Error>;
3390
3391    fn poll_next(
3392        mut self: std::pin::Pin<&mut Self>,
3393        cx: &mut std::task::Context<'_>,
3394    ) -> std::task::Poll<Option<Self::Item>> {
3395        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3396            &mut self.event_receiver,
3397            cx
3398        )?) {
3399            Some(buf) => std::task::Poll::Ready(Some(GuestLifecycleEvent::decode(buf))),
3400            None => std::task::Poll::Ready(None),
3401        }
3402    }
3403}
3404
3405#[derive(Debug)]
3406pub enum GuestLifecycleEvent {}
3407
3408impl GuestLifecycleEvent {
3409    /// Decodes a message buffer as a [`GuestLifecycleEvent`].
3410    fn decode(
3411        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3412    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3413        let (bytes, _handles) = buf.split_mut();
3414        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3415        debug_assert_eq!(tx_header.tx_id, 0);
3416        match tx_header.ordinal {
3417            _ => Err(fidl::Error::UnknownOrdinal {
3418                ordinal: tx_header.ordinal,
3419                protocol_name:
3420                    <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3421            }),
3422        }
3423    }
3424}
3425
3426/// A Stream of incoming requests for fuchsia.virtualization/GuestLifecycle.
3427pub struct GuestLifecycleRequestStream {
3428    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3429    is_terminated: bool,
3430}
3431
3432impl std::marker::Unpin for GuestLifecycleRequestStream {}
3433
3434impl futures::stream::FusedStream for GuestLifecycleRequestStream {
3435    fn is_terminated(&self) -> bool {
3436        self.is_terminated
3437    }
3438}
3439
3440impl fidl::endpoints::RequestStream for GuestLifecycleRequestStream {
3441    type Protocol = GuestLifecycleMarker;
3442    type ControlHandle = GuestLifecycleControlHandle;
3443
3444    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3445        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3446    }
3447
3448    fn control_handle(&self) -> Self::ControlHandle {
3449        GuestLifecycleControlHandle { inner: self.inner.clone() }
3450    }
3451
3452    fn into_inner(
3453        self,
3454    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3455    {
3456        (self.inner, self.is_terminated)
3457    }
3458
3459    fn from_inner(
3460        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3461        is_terminated: bool,
3462    ) -> Self {
3463        Self { inner, is_terminated }
3464    }
3465}
3466
3467impl futures::Stream for GuestLifecycleRequestStream {
3468    type Item = Result<GuestLifecycleRequest, fidl::Error>;
3469
3470    fn poll_next(
3471        mut self: std::pin::Pin<&mut Self>,
3472        cx: &mut std::task::Context<'_>,
3473    ) -> std::task::Poll<Option<Self::Item>> {
3474        let this = &mut *self;
3475        if this.inner.check_shutdown(cx) {
3476            this.is_terminated = true;
3477            return std::task::Poll::Ready(None);
3478        }
3479        if this.is_terminated {
3480            panic!("polled GuestLifecycleRequestStream after completion");
3481        }
3482        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3483            |bytes, handles| {
3484                match this.inner.channel().read_etc(cx, bytes, handles) {
3485                    std::task::Poll::Ready(Ok(())) => {}
3486                    std::task::Poll::Pending => return std::task::Poll::Pending,
3487                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3488                        this.is_terminated = true;
3489                        return std::task::Poll::Ready(None);
3490                    }
3491                    std::task::Poll::Ready(Err(e)) => {
3492                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3493                            e.into(),
3494                        ))));
3495                    }
3496                }
3497
3498                // A message has been received from the channel
3499                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3500
3501                std::task::Poll::Ready(Some(match header.ordinal {
3502                    0x152719eed416ed41 => {
3503                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3504                        let mut req = fidl::new_empty!(
3505                            GuestLifecycleCreateRequest,
3506                            fidl::encoding::DefaultFuchsiaResourceDialect
3507                        );
3508                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleCreateRequest>(&header, _body_bytes, handles, &mut req)?;
3509                        let control_handle =
3510                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3511                        Ok(GuestLifecycleRequest::Create {
3512                            guest_config: req.guest_config,
3513
3514                            responder: GuestLifecycleCreateResponder {
3515                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3516                                tx_id: header.tx_id,
3517                            },
3518                        })
3519                    }
3520                    0x57dd3e245f9598ed => {
3521                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3522                        let mut req = fidl::new_empty!(
3523                            GuestLifecycleBindRequest,
3524                            fidl::encoding::DefaultFuchsiaResourceDialect
3525                        );
3526                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleBindRequest>(&header, _body_bytes, handles, &mut req)?;
3527                        let control_handle =
3528                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3529                        Ok(GuestLifecycleRequest::Bind { guest: req.guest, control_handle })
3530                    }
3531                    0x2907fef2ac775657 => {
3532                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3533                        let mut req = fidl::new_empty!(
3534                            fidl::encoding::EmptyPayload,
3535                            fidl::encoding::DefaultFuchsiaResourceDialect
3536                        );
3537                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3538                        let control_handle =
3539                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3540                        Ok(GuestLifecycleRequest::Run {
3541                            responder: GuestLifecycleRunResponder {
3542                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3543                                tx_id: header.tx_id,
3544                            },
3545                        })
3546                    }
3547                    0x27eef9c535ac8eb4 => {
3548                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3549                        let mut req = fidl::new_empty!(
3550                            fidl::encoding::EmptyPayload,
3551                            fidl::encoding::DefaultFuchsiaResourceDialect
3552                        );
3553                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3554                        let control_handle =
3555                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3556                        Ok(GuestLifecycleRequest::Stop {
3557                            responder: GuestLifecycleStopResponder {
3558                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3559                                tx_id: header.tx_id,
3560                            },
3561                        })
3562                    }
3563                    _ => Err(fidl::Error::UnknownOrdinal {
3564                        ordinal: header.ordinal,
3565                        protocol_name:
3566                            <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3567                    }),
3568                }))
3569            },
3570        )
3571    }
3572}
3573
3574/// The guest control plane allowing for creating, starting, and stopping the guest.
3575#[derive(Debug)]
3576pub enum GuestLifecycleRequest {
3577    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3578    /// the kernel without starting the VCPU or device dispatch loops.
3579    ///
3580    /// Possible errors:
3581    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3582    ///         recreated.
3583    ///
3584    /// All other errors are related to VMM initialization.
3585    Create { guest_config: GuestConfig, responder: GuestLifecycleCreateResponder },
3586    /// Binds to the Guest protocol for an initialized guest.
3587    ///
3588    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3589    /// will be immediately closed.
3590    Bind {
3591        guest: fidl::endpoints::ServerEnd<GuestMarker>,
3592        control_handle: GuestLifecycleControlHandle,
3593    },
3594    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3595    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3596    ///
3597    /// Possible errors:
3598    ///     - ALREADY_RUNING: The VMM has already been started.
3599    ///     - NOT_CREATED: Run was called before the VMM was created.
3600    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3601    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3602    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3603    Run { responder: GuestLifecycleRunResponder },
3604    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3605    /// Create and then Run can be called again.
3606    Stop { responder: GuestLifecycleStopResponder },
3607}
3608
3609impl GuestLifecycleRequest {
3610    #[allow(irrefutable_let_patterns)]
3611    pub fn into_create(self) -> Option<(GuestConfig, GuestLifecycleCreateResponder)> {
3612        if let GuestLifecycleRequest::Create { guest_config, responder } = self {
3613            Some((guest_config, responder))
3614        } else {
3615            None
3616        }
3617    }
3618
3619    #[allow(irrefutable_let_patterns)]
3620    pub fn into_bind(
3621        self,
3622    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestLifecycleControlHandle)> {
3623        if let GuestLifecycleRequest::Bind { guest, control_handle } = self {
3624            Some((guest, control_handle))
3625        } else {
3626            None
3627        }
3628    }
3629
3630    #[allow(irrefutable_let_patterns)]
3631    pub fn into_run(self) -> Option<(GuestLifecycleRunResponder)> {
3632        if let GuestLifecycleRequest::Run { responder } = self { Some((responder)) } else { None }
3633    }
3634
3635    #[allow(irrefutable_let_patterns)]
3636    pub fn into_stop(self) -> Option<(GuestLifecycleStopResponder)> {
3637        if let GuestLifecycleRequest::Stop { responder } = self { Some((responder)) } else { None }
3638    }
3639
3640    /// Name of the method defined in FIDL
3641    pub fn method_name(&self) -> &'static str {
3642        match *self {
3643            GuestLifecycleRequest::Create { .. } => "create",
3644            GuestLifecycleRequest::Bind { .. } => "bind",
3645            GuestLifecycleRequest::Run { .. } => "run",
3646            GuestLifecycleRequest::Stop { .. } => "stop",
3647        }
3648    }
3649}
3650
3651#[derive(Debug, Clone)]
3652pub struct GuestLifecycleControlHandle {
3653    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3654}
3655
3656impl fidl::endpoints::ControlHandle for GuestLifecycleControlHandle {
3657    fn shutdown(&self) {
3658        self.inner.shutdown()
3659    }
3660    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3661        self.inner.shutdown_with_epitaph(status)
3662    }
3663
3664    fn is_closed(&self) -> bool {
3665        self.inner.channel().is_closed()
3666    }
3667    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3668        self.inner.channel().on_closed()
3669    }
3670
3671    #[cfg(target_os = "fuchsia")]
3672    fn signal_peer(
3673        &self,
3674        clear_mask: zx::Signals,
3675        set_mask: zx::Signals,
3676    ) -> Result<(), zx_status::Status> {
3677        use fidl::Peered;
3678        self.inner.channel().signal_peer(clear_mask, set_mask)
3679    }
3680}
3681
3682impl GuestLifecycleControlHandle {}
3683
3684#[must_use = "FIDL methods require a response to be sent"]
3685#[derive(Debug)]
3686pub struct GuestLifecycleCreateResponder {
3687    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3688    tx_id: u32,
3689}
3690
3691/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3692/// if the responder is dropped without sending a response, so that the client
3693/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3694impl std::ops::Drop for GuestLifecycleCreateResponder {
3695    fn drop(&mut self) {
3696        self.control_handle.shutdown();
3697        // Safety: drops once, never accessed again
3698        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3699    }
3700}
3701
3702impl fidl::endpoints::Responder for GuestLifecycleCreateResponder {
3703    type ControlHandle = GuestLifecycleControlHandle;
3704
3705    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3706        &self.control_handle
3707    }
3708
3709    fn drop_without_shutdown(mut self) {
3710        // Safety: drops once, never accessed again due to mem::forget
3711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3712        // Prevent Drop from running (which would shut down the channel)
3713        std::mem::forget(self);
3714    }
3715}
3716
3717impl GuestLifecycleCreateResponder {
3718    /// Sends a response to the FIDL transaction.
3719    ///
3720    /// Sets the channel to shutdown if an error occurs.
3721    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3722        let _result = self.send_raw(result);
3723        if _result.is_err() {
3724            self.control_handle.shutdown();
3725        }
3726        self.drop_without_shutdown();
3727        _result
3728    }
3729
3730    /// Similar to "send" but does not shutdown the channel if an error occurs.
3731    pub fn send_no_shutdown_on_err(
3732        self,
3733        mut result: Result<(), GuestError>,
3734    ) -> Result<(), fidl::Error> {
3735        let _result = self.send_raw(result);
3736        self.drop_without_shutdown();
3737        _result
3738    }
3739
3740    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3741        self.control_handle
3742            .inner
3743            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3744                result,
3745                self.tx_id,
3746                0x152719eed416ed41,
3747                fidl::encoding::DynamicFlags::empty(),
3748            )
3749    }
3750}
3751
3752#[must_use = "FIDL methods require a response to be sent"]
3753#[derive(Debug)]
3754pub struct GuestLifecycleRunResponder {
3755    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3756    tx_id: u32,
3757}
3758
3759/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3760/// if the responder is dropped without sending a response, so that the client
3761/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3762impl std::ops::Drop for GuestLifecycleRunResponder {
3763    fn drop(&mut self) {
3764        self.control_handle.shutdown();
3765        // Safety: drops once, never accessed again
3766        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3767    }
3768}
3769
3770impl fidl::endpoints::Responder for GuestLifecycleRunResponder {
3771    type ControlHandle = GuestLifecycleControlHandle;
3772
3773    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3774        &self.control_handle
3775    }
3776
3777    fn drop_without_shutdown(mut self) {
3778        // Safety: drops once, never accessed again due to mem::forget
3779        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3780        // Prevent Drop from running (which would shut down the channel)
3781        std::mem::forget(self);
3782    }
3783}
3784
3785impl GuestLifecycleRunResponder {
3786    /// Sends a response to the FIDL transaction.
3787    ///
3788    /// Sets the channel to shutdown if an error occurs.
3789    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3790        let _result = self.send_raw(result);
3791        if _result.is_err() {
3792            self.control_handle.shutdown();
3793        }
3794        self.drop_without_shutdown();
3795        _result
3796    }
3797
3798    /// Similar to "send" but does not shutdown the channel if an error occurs.
3799    pub fn send_no_shutdown_on_err(
3800        self,
3801        mut result: Result<(), GuestError>,
3802    ) -> Result<(), fidl::Error> {
3803        let _result = self.send_raw(result);
3804        self.drop_without_shutdown();
3805        _result
3806    }
3807
3808    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3809        self.control_handle
3810            .inner
3811            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3812                result,
3813                self.tx_id,
3814                0x2907fef2ac775657,
3815                fidl::encoding::DynamicFlags::empty(),
3816            )
3817    }
3818}
3819
3820#[must_use = "FIDL methods require a response to be sent"]
3821#[derive(Debug)]
3822pub struct GuestLifecycleStopResponder {
3823    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3824    tx_id: u32,
3825}
3826
3827/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3828/// if the responder is dropped without sending a response, so that the client
3829/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3830impl std::ops::Drop for GuestLifecycleStopResponder {
3831    fn drop(&mut self) {
3832        self.control_handle.shutdown();
3833        // Safety: drops once, never accessed again
3834        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3835    }
3836}
3837
3838impl fidl::endpoints::Responder for GuestLifecycleStopResponder {
3839    type ControlHandle = GuestLifecycleControlHandle;
3840
3841    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3842        &self.control_handle
3843    }
3844
3845    fn drop_without_shutdown(mut self) {
3846        // Safety: drops once, never accessed again due to mem::forget
3847        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3848        // Prevent Drop from running (which would shut down the channel)
3849        std::mem::forget(self);
3850    }
3851}
3852
3853impl GuestLifecycleStopResponder {
3854    /// Sends a response to the FIDL transaction.
3855    ///
3856    /// Sets the channel to shutdown if an error occurs.
3857    pub fn send(self) -> Result<(), fidl::Error> {
3858        let _result = self.send_raw();
3859        if _result.is_err() {
3860            self.control_handle.shutdown();
3861        }
3862        self.drop_without_shutdown();
3863        _result
3864    }
3865
3866    /// Similar to "send" but does not shutdown the channel if an error occurs.
3867    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3868        let _result = self.send_raw();
3869        self.drop_without_shutdown();
3870        _result
3871    }
3872
3873    fn send_raw(&self) -> Result<(), fidl::Error> {
3874        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3875            (),
3876            self.tx_id,
3877            0x27eef9c535ac8eb4,
3878            fidl::encoding::DynamicFlags::empty(),
3879        )
3880    }
3881}
3882
3883#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3884pub struct GuestManagerMarker;
3885
3886impl fidl::endpoints::ProtocolMarker for GuestManagerMarker {
3887    type Proxy = GuestManagerProxy;
3888    type RequestStream = GuestManagerRequestStream;
3889    #[cfg(target_os = "fuchsia")]
3890    type SynchronousProxy = GuestManagerSynchronousProxy;
3891
3892    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestManager";
3893}
3894impl fidl::endpoints::DiscoverableProtocolMarker for GuestManagerMarker {}
3895pub type GuestManagerLaunchResult = Result<(), GuestManagerError>;
3896pub type GuestManagerConnectResult = Result<(), GuestManagerError>;
3897
3898pub trait GuestManagerProxyInterface: Send + Sync {
3899    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
3900        + Send;
3901    fn r#launch(
3902        &self,
3903        guest_config: GuestConfig,
3904        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3905    ) -> Self::LaunchResponseFut;
3906    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3907    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
3908    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
3909        + Send;
3910    fn r#connect(
3911        &self,
3912        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3913    ) -> Self::ConnectResponseFut;
3914    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
3915    fn r#get_info(&self) -> Self::GetInfoResponseFut;
3916}
3917#[derive(Debug)]
3918#[cfg(target_os = "fuchsia")]
3919pub struct GuestManagerSynchronousProxy {
3920    client: fidl::client::sync::Client,
3921}
3922
3923#[cfg(target_os = "fuchsia")]
3924impl fidl::endpoints::SynchronousProxy for GuestManagerSynchronousProxy {
3925    type Proxy = GuestManagerProxy;
3926    type Protocol = GuestManagerMarker;
3927
3928    fn from_channel(inner: fidl::Channel) -> Self {
3929        Self::new(inner)
3930    }
3931
3932    fn into_channel(self) -> fidl::Channel {
3933        self.client.into_channel()
3934    }
3935
3936    fn as_channel(&self) -> &fidl::Channel {
3937        self.client.as_channel()
3938    }
3939}
3940
3941#[cfg(target_os = "fuchsia")]
3942impl GuestManagerSynchronousProxy {
3943    pub fn new(channel: fidl::Channel) -> Self {
3944        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3945        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3946    }
3947
3948    pub fn into_channel(self) -> fidl::Channel {
3949        self.client.into_channel()
3950    }
3951
3952    /// Waits until an event arrives and returns it. It is safe for other
3953    /// threads to make concurrent requests while waiting for an event.
3954    pub fn wait_for_event(
3955        &self,
3956        deadline: zx::MonotonicInstant,
3957    ) -> Result<GuestManagerEvent, fidl::Error> {
3958        GuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
3959    }
3960
3961    /// Launch a new guest instance.
3962    ///
3963    /// Possible errors:
3964    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
3965    ///         problems detected by the guest manager.
3966    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
3967    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
3968    ///         component logs for a more specific failure.
3969    pub fn r#launch(
3970        &self,
3971        mut guest_config: GuestConfig,
3972        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
3973        ___deadline: zx::MonotonicInstant,
3974    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
3975        let _response =
3976            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
3977                fidl::encoding::EmptyStruct,
3978                GuestManagerError,
3979            >>(
3980                (&mut guest_config, controller),
3981                0x394a2e29f750323e,
3982                fidl::encoding::DynamicFlags::empty(),
3983                ___deadline,
3984            )?;
3985        Ok(_response.map(|x| x))
3986    }
3987
3988    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
3989    /// be used to launch another guest.
3990    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3991        let _response =
3992            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
3993                (),
3994                0x3ad9a012982f872d,
3995                fidl::encoding::DynamicFlags::empty(),
3996                ___deadline,
3997            )?;
3998        Ok(_response)
3999    }
4000
4001    /// Connect to a currently running guest.
4002    ///
4003    /// Possible errors:
4004    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4005    ///         has launched before attempting to reconnect.
4006    pub fn r#connect(
4007        &self,
4008        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4009        ___deadline: zx::MonotonicInstant,
4010    ) -> Result<GuestManagerConnectResult, fidl::Error> {
4011        let _response =
4012            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
4013                fidl::encoding::EmptyStruct,
4014                GuestManagerError,
4015            >>(
4016                (controller,),
4017                0x4e489076e3bb15b4,
4018                fidl::encoding::DynamicFlags::empty(),
4019                ___deadline,
4020            )?;
4021        Ok(_response.map(|x| x))
4022    }
4023
4024    /// Query guest info
4025    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
4026        let _response =
4027            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
4028                (),
4029                0x76892614aea695dc,
4030                fidl::encoding::DynamicFlags::empty(),
4031                ___deadline,
4032            )?;
4033        Ok(_response.guest_info)
4034    }
4035}
4036
4037#[cfg(target_os = "fuchsia")]
4038impl From<GuestManagerSynchronousProxy> for zx::Handle {
4039    fn from(value: GuestManagerSynchronousProxy) -> Self {
4040        value.into_channel().into()
4041    }
4042}
4043
4044#[cfg(target_os = "fuchsia")]
4045impl From<fidl::Channel> for GuestManagerSynchronousProxy {
4046    fn from(value: fidl::Channel) -> Self {
4047        Self::new(value)
4048    }
4049}
4050
4051#[cfg(target_os = "fuchsia")]
4052impl fidl::endpoints::FromClient for GuestManagerSynchronousProxy {
4053    type Protocol = GuestManagerMarker;
4054
4055    fn from_client(value: fidl::endpoints::ClientEnd<GuestManagerMarker>) -> Self {
4056        Self::new(value.into_channel())
4057    }
4058}
4059
4060#[derive(Debug, Clone)]
4061pub struct GuestManagerProxy {
4062    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4063}
4064
4065impl fidl::endpoints::Proxy for GuestManagerProxy {
4066    type Protocol = GuestManagerMarker;
4067
4068    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4069        Self::new(inner)
4070    }
4071
4072    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4073        self.client.into_channel().map_err(|client| Self { client })
4074    }
4075
4076    fn as_channel(&self) -> &::fidl::AsyncChannel {
4077        self.client.as_channel()
4078    }
4079}
4080
4081impl GuestManagerProxy {
4082    /// Create a new Proxy for fuchsia.virtualization/GuestManager.
4083    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4084        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4085        Self { client: fidl::client::Client::new(channel, protocol_name) }
4086    }
4087
4088    /// Get a Stream of events from the remote end of the protocol.
4089    ///
4090    /// # Panics
4091    ///
4092    /// Panics if the event stream was already taken.
4093    pub fn take_event_stream(&self) -> GuestManagerEventStream {
4094        GuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
4095    }
4096
4097    /// Launch a new guest instance.
4098    ///
4099    /// Possible errors:
4100    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4101    ///         problems detected by the guest manager.
4102    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4103    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4104    ///         component logs for a more specific failure.
4105    pub fn r#launch(
4106        &self,
4107        mut guest_config: GuestConfig,
4108        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4109    ) -> fidl::client::QueryResponseFut<
4110        GuestManagerLaunchResult,
4111        fidl::encoding::DefaultFuchsiaResourceDialect,
4112    > {
4113        GuestManagerProxyInterface::r#launch(self, guest_config, controller)
4114    }
4115
4116    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4117    /// be used to launch another guest.
4118    pub fn r#force_shutdown(
4119        &self,
4120    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4121        GuestManagerProxyInterface::r#force_shutdown(self)
4122    }
4123
4124    /// Connect to a currently running guest.
4125    ///
4126    /// Possible errors:
4127    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4128    ///         has launched before attempting to reconnect.
4129    pub fn r#connect(
4130        &self,
4131        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4132    ) -> fidl::client::QueryResponseFut<
4133        GuestManagerConnectResult,
4134        fidl::encoding::DefaultFuchsiaResourceDialect,
4135    > {
4136        GuestManagerProxyInterface::r#connect(self, controller)
4137    }
4138
4139    /// Query guest info
4140    pub fn r#get_info(
4141        &self,
4142    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
4143    {
4144        GuestManagerProxyInterface::r#get_info(self)
4145    }
4146}
4147
4148impl GuestManagerProxyInterface for GuestManagerProxy {
4149    type LaunchResponseFut = fidl::client::QueryResponseFut<
4150        GuestManagerLaunchResult,
4151        fidl::encoding::DefaultFuchsiaResourceDialect,
4152    >;
4153    fn r#launch(
4154        &self,
4155        mut guest_config: GuestConfig,
4156        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4157    ) -> Self::LaunchResponseFut {
4158        fn _decode(
4159            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4160        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
4161            let _response = fidl::client::decode_transaction_body::<
4162                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4163                fidl::encoding::DefaultFuchsiaResourceDialect,
4164                0x394a2e29f750323e,
4165            >(_buf?)?;
4166            Ok(_response.map(|x| x))
4167        }
4168        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
4169            (&mut guest_config, controller),
4170            0x394a2e29f750323e,
4171            fidl::encoding::DynamicFlags::empty(),
4172            _decode,
4173        )
4174    }
4175
4176    type ForceShutdownResponseFut =
4177        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4178    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
4179        fn _decode(
4180            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4181        ) -> Result<(), fidl::Error> {
4182            let _response = fidl::client::decode_transaction_body::<
4183                fidl::encoding::EmptyPayload,
4184                fidl::encoding::DefaultFuchsiaResourceDialect,
4185                0x3ad9a012982f872d,
4186            >(_buf?)?;
4187            Ok(_response)
4188        }
4189        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
4190            (),
4191            0x3ad9a012982f872d,
4192            fidl::encoding::DynamicFlags::empty(),
4193            _decode,
4194        )
4195    }
4196
4197    type ConnectResponseFut = fidl::client::QueryResponseFut<
4198        GuestManagerConnectResult,
4199        fidl::encoding::DefaultFuchsiaResourceDialect,
4200    >;
4201    fn r#connect(
4202        &self,
4203        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4204    ) -> Self::ConnectResponseFut {
4205        fn _decode(
4206            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4207        ) -> Result<GuestManagerConnectResult, fidl::Error> {
4208            let _response = fidl::client::decode_transaction_body::<
4209                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4210                fidl::encoding::DefaultFuchsiaResourceDialect,
4211                0x4e489076e3bb15b4,
4212            >(_buf?)?;
4213            Ok(_response.map(|x| x))
4214        }
4215        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
4216            (controller,),
4217            0x4e489076e3bb15b4,
4218            fidl::encoding::DynamicFlags::empty(),
4219            _decode,
4220        )
4221    }
4222
4223    type GetInfoResponseFut =
4224        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
4225    fn r#get_info(&self) -> Self::GetInfoResponseFut {
4226        fn _decode(
4227            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4228        ) -> Result<GuestInfo, fidl::Error> {
4229            let _response = fidl::client::decode_transaction_body::<
4230                GuestManagerGetInfoResponse,
4231                fidl::encoding::DefaultFuchsiaResourceDialect,
4232                0x76892614aea695dc,
4233            >(_buf?)?;
4234            Ok(_response.guest_info)
4235        }
4236        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
4237            (),
4238            0x76892614aea695dc,
4239            fidl::encoding::DynamicFlags::empty(),
4240            _decode,
4241        )
4242    }
4243}
4244
4245pub struct GuestManagerEventStream {
4246    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4247}
4248
4249impl std::marker::Unpin for GuestManagerEventStream {}
4250
4251impl futures::stream::FusedStream for GuestManagerEventStream {
4252    fn is_terminated(&self) -> bool {
4253        self.event_receiver.is_terminated()
4254    }
4255}
4256
4257impl futures::Stream for GuestManagerEventStream {
4258    type Item = Result<GuestManagerEvent, fidl::Error>;
4259
4260    fn poll_next(
4261        mut self: std::pin::Pin<&mut Self>,
4262        cx: &mut std::task::Context<'_>,
4263    ) -> std::task::Poll<Option<Self::Item>> {
4264        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4265            &mut self.event_receiver,
4266            cx
4267        )?) {
4268            Some(buf) => std::task::Poll::Ready(Some(GuestManagerEvent::decode(buf))),
4269            None => std::task::Poll::Ready(None),
4270        }
4271    }
4272}
4273
4274#[derive(Debug)]
4275pub enum GuestManagerEvent {}
4276
4277impl GuestManagerEvent {
4278    /// Decodes a message buffer as a [`GuestManagerEvent`].
4279    fn decode(
4280        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4281    ) -> Result<GuestManagerEvent, fidl::Error> {
4282        let (bytes, _handles) = buf.split_mut();
4283        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4284        debug_assert_eq!(tx_header.tx_id, 0);
4285        match tx_header.ordinal {
4286            _ => Err(fidl::Error::UnknownOrdinal {
4287                ordinal: tx_header.ordinal,
4288                protocol_name: <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4289            }),
4290        }
4291    }
4292}
4293
4294/// A Stream of incoming requests for fuchsia.virtualization/GuestManager.
4295pub struct GuestManagerRequestStream {
4296    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4297    is_terminated: bool,
4298}
4299
4300impl std::marker::Unpin for GuestManagerRequestStream {}
4301
4302impl futures::stream::FusedStream for GuestManagerRequestStream {
4303    fn is_terminated(&self) -> bool {
4304        self.is_terminated
4305    }
4306}
4307
4308impl fidl::endpoints::RequestStream for GuestManagerRequestStream {
4309    type Protocol = GuestManagerMarker;
4310    type ControlHandle = GuestManagerControlHandle;
4311
4312    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4313        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4314    }
4315
4316    fn control_handle(&self) -> Self::ControlHandle {
4317        GuestManagerControlHandle { inner: self.inner.clone() }
4318    }
4319
4320    fn into_inner(
4321        self,
4322    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4323    {
4324        (self.inner, self.is_terminated)
4325    }
4326
4327    fn from_inner(
4328        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4329        is_terminated: bool,
4330    ) -> Self {
4331        Self { inner, is_terminated }
4332    }
4333}
4334
4335impl futures::Stream for GuestManagerRequestStream {
4336    type Item = Result<GuestManagerRequest, fidl::Error>;
4337
4338    fn poll_next(
4339        mut self: std::pin::Pin<&mut Self>,
4340        cx: &mut std::task::Context<'_>,
4341    ) -> std::task::Poll<Option<Self::Item>> {
4342        let this = &mut *self;
4343        if this.inner.check_shutdown(cx) {
4344            this.is_terminated = true;
4345            return std::task::Poll::Ready(None);
4346        }
4347        if this.is_terminated {
4348            panic!("polled GuestManagerRequestStream after completion");
4349        }
4350        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4351            |bytes, handles| {
4352                match this.inner.channel().read_etc(cx, bytes, handles) {
4353                    std::task::Poll::Ready(Ok(())) => {}
4354                    std::task::Poll::Pending => return std::task::Poll::Pending,
4355                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4356                        this.is_terminated = true;
4357                        return std::task::Poll::Ready(None);
4358                    }
4359                    std::task::Poll::Ready(Err(e)) => {
4360                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4361                            e.into(),
4362                        ))));
4363                    }
4364                }
4365
4366                // A message has been received from the channel
4367                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4368
4369                std::task::Poll::Ready(Some(match header.ordinal {
4370                    0x394a2e29f750323e => {
4371                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4372                        let mut req = fidl::new_empty!(
4373                            GuestManagerLaunchRequest,
4374                            fidl::encoding::DefaultFuchsiaResourceDialect
4375                        );
4376                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
4377                        let control_handle =
4378                            GuestManagerControlHandle { inner: this.inner.clone() };
4379                        Ok(GuestManagerRequest::Launch {
4380                            guest_config: req.guest_config,
4381                            controller: req.controller,
4382
4383                            responder: GuestManagerLaunchResponder {
4384                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4385                                tx_id: header.tx_id,
4386                            },
4387                        })
4388                    }
4389                    0x3ad9a012982f872d => {
4390                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4391                        let mut req = fidl::new_empty!(
4392                            fidl::encoding::EmptyPayload,
4393                            fidl::encoding::DefaultFuchsiaResourceDialect
4394                        );
4395                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4396                        let control_handle =
4397                            GuestManagerControlHandle { inner: this.inner.clone() };
4398                        Ok(GuestManagerRequest::ForceShutdown {
4399                            responder: GuestManagerForceShutdownResponder {
4400                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4401                                tx_id: header.tx_id,
4402                            },
4403                        })
4404                    }
4405                    0x4e489076e3bb15b4 => {
4406                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4407                        let mut req = fidl::new_empty!(
4408                            GuestManagerConnectRequest,
4409                            fidl::encoding::DefaultFuchsiaResourceDialect
4410                        );
4411                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
4412                        let control_handle =
4413                            GuestManagerControlHandle { inner: this.inner.clone() };
4414                        Ok(GuestManagerRequest::Connect {
4415                            controller: req.controller,
4416
4417                            responder: GuestManagerConnectResponder {
4418                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4419                                tx_id: header.tx_id,
4420                            },
4421                        })
4422                    }
4423                    0x76892614aea695dc => {
4424                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4425                        let mut req = fidl::new_empty!(
4426                            fidl::encoding::EmptyPayload,
4427                            fidl::encoding::DefaultFuchsiaResourceDialect
4428                        );
4429                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4430                        let control_handle =
4431                            GuestManagerControlHandle { inner: this.inner.clone() };
4432                        Ok(GuestManagerRequest::GetInfo {
4433                            responder: GuestManagerGetInfoResponder {
4434                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4435                                tx_id: header.tx_id,
4436                            },
4437                        })
4438                    }
4439                    _ => Err(fidl::Error::UnknownOrdinal {
4440                        ordinal: header.ordinal,
4441                        protocol_name:
4442                            <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4443                    }),
4444                }))
4445            },
4446        )
4447    }
4448}
4449
4450#[derive(Debug)]
4451pub enum GuestManagerRequest {
4452    /// Launch a new guest instance.
4453    ///
4454    /// Possible errors:
4455    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4456    ///         problems detected by the guest manager.
4457    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4458    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4459    ///         component logs for a more specific failure.
4460    Launch {
4461        guest_config: GuestConfig,
4462        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4463        responder: GuestManagerLaunchResponder,
4464    },
4465    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4466    /// be used to launch another guest.
4467    ForceShutdown { responder: GuestManagerForceShutdownResponder },
4468    /// Connect to a currently running guest.
4469    ///
4470    /// Possible errors:
4471    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4472    ///         has launched before attempting to reconnect.
4473    Connect {
4474        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4475        responder: GuestManagerConnectResponder,
4476    },
4477    /// Query guest info
4478    GetInfo { responder: GuestManagerGetInfoResponder },
4479}
4480
4481impl GuestManagerRequest {
4482    #[allow(irrefutable_let_patterns)]
4483    pub fn into_launch(
4484        self,
4485    ) -> Option<(GuestConfig, fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerLaunchResponder)>
4486    {
4487        if let GuestManagerRequest::Launch { guest_config, controller, responder } = self {
4488            Some((guest_config, controller, responder))
4489        } else {
4490            None
4491        }
4492    }
4493
4494    #[allow(irrefutable_let_patterns)]
4495    pub fn into_force_shutdown(self) -> Option<(GuestManagerForceShutdownResponder)> {
4496        if let GuestManagerRequest::ForceShutdown { responder } = self {
4497            Some((responder))
4498        } else {
4499            None
4500        }
4501    }
4502
4503    #[allow(irrefutable_let_patterns)]
4504    pub fn into_connect(
4505        self,
4506    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerConnectResponder)> {
4507        if let GuestManagerRequest::Connect { controller, responder } = self {
4508            Some((controller, responder))
4509        } else {
4510            None
4511        }
4512    }
4513
4514    #[allow(irrefutable_let_patterns)]
4515    pub fn into_get_info(self) -> Option<(GuestManagerGetInfoResponder)> {
4516        if let GuestManagerRequest::GetInfo { responder } = self { Some((responder)) } else { None }
4517    }
4518
4519    /// Name of the method defined in FIDL
4520    pub fn method_name(&self) -> &'static str {
4521        match *self {
4522            GuestManagerRequest::Launch { .. } => "launch",
4523            GuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
4524            GuestManagerRequest::Connect { .. } => "connect",
4525            GuestManagerRequest::GetInfo { .. } => "get_info",
4526        }
4527    }
4528}
4529
4530#[derive(Debug, Clone)]
4531pub struct GuestManagerControlHandle {
4532    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4533}
4534
4535impl fidl::endpoints::ControlHandle for GuestManagerControlHandle {
4536    fn shutdown(&self) {
4537        self.inner.shutdown()
4538    }
4539    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4540        self.inner.shutdown_with_epitaph(status)
4541    }
4542
4543    fn is_closed(&self) -> bool {
4544        self.inner.channel().is_closed()
4545    }
4546    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4547        self.inner.channel().on_closed()
4548    }
4549
4550    #[cfg(target_os = "fuchsia")]
4551    fn signal_peer(
4552        &self,
4553        clear_mask: zx::Signals,
4554        set_mask: zx::Signals,
4555    ) -> Result<(), zx_status::Status> {
4556        use fidl::Peered;
4557        self.inner.channel().signal_peer(clear_mask, set_mask)
4558    }
4559}
4560
4561impl GuestManagerControlHandle {}
4562
4563#[must_use = "FIDL methods require a response to be sent"]
4564#[derive(Debug)]
4565pub struct GuestManagerLaunchResponder {
4566    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4567    tx_id: u32,
4568}
4569
4570/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4571/// if the responder is dropped without sending a response, so that the client
4572/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4573impl std::ops::Drop for GuestManagerLaunchResponder {
4574    fn drop(&mut self) {
4575        self.control_handle.shutdown();
4576        // Safety: drops once, never accessed again
4577        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4578    }
4579}
4580
4581impl fidl::endpoints::Responder for GuestManagerLaunchResponder {
4582    type ControlHandle = GuestManagerControlHandle;
4583
4584    fn control_handle(&self) -> &GuestManagerControlHandle {
4585        &self.control_handle
4586    }
4587
4588    fn drop_without_shutdown(mut self) {
4589        // Safety: drops once, never accessed again due to mem::forget
4590        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4591        // Prevent Drop from running (which would shut down the channel)
4592        std::mem::forget(self);
4593    }
4594}
4595
4596impl GuestManagerLaunchResponder {
4597    /// Sends a response to the FIDL transaction.
4598    ///
4599    /// Sets the channel to shutdown if an error occurs.
4600    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4601        let _result = self.send_raw(result);
4602        if _result.is_err() {
4603            self.control_handle.shutdown();
4604        }
4605        self.drop_without_shutdown();
4606        _result
4607    }
4608
4609    /// Similar to "send" but does not shutdown the channel if an error occurs.
4610    pub fn send_no_shutdown_on_err(
4611        self,
4612        mut result: Result<(), GuestManagerError>,
4613    ) -> Result<(), fidl::Error> {
4614        let _result = self.send_raw(result);
4615        self.drop_without_shutdown();
4616        _result
4617    }
4618
4619    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4620        self.control_handle.inner.send::<fidl::encoding::ResultType<
4621            fidl::encoding::EmptyStruct,
4622            GuestManagerError,
4623        >>(
4624            result,
4625            self.tx_id,
4626            0x394a2e29f750323e,
4627            fidl::encoding::DynamicFlags::empty(),
4628        )
4629    }
4630}
4631
4632#[must_use = "FIDL methods require a response to be sent"]
4633#[derive(Debug)]
4634pub struct GuestManagerForceShutdownResponder {
4635    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4636    tx_id: u32,
4637}
4638
4639/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4640/// if the responder is dropped without sending a response, so that the client
4641/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4642impl std::ops::Drop for GuestManagerForceShutdownResponder {
4643    fn drop(&mut self) {
4644        self.control_handle.shutdown();
4645        // Safety: drops once, never accessed again
4646        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4647    }
4648}
4649
4650impl fidl::endpoints::Responder for GuestManagerForceShutdownResponder {
4651    type ControlHandle = GuestManagerControlHandle;
4652
4653    fn control_handle(&self) -> &GuestManagerControlHandle {
4654        &self.control_handle
4655    }
4656
4657    fn drop_without_shutdown(mut self) {
4658        // Safety: drops once, never accessed again due to mem::forget
4659        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4660        // Prevent Drop from running (which would shut down the channel)
4661        std::mem::forget(self);
4662    }
4663}
4664
4665impl GuestManagerForceShutdownResponder {
4666    /// Sends a response to the FIDL transaction.
4667    ///
4668    /// Sets the channel to shutdown if an error occurs.
4669    pub fn send(self) -> Result<(), fidl::Error> {
4670        let _result = self.send_raw();
4671        if _result.is_err() {
4672            self.control_handle.shutdown();
4673        }
4674        self.drop_without_shutdown();
4675        _result
4676    }
4677
4678    /// Similar to "send" but does not shutdown the channel if an error occurs.
4679    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4680        let _result = self.send_raw();
4681        self.drop_without_shutdown();
4682        _result
4683    }
4684
4685    fn send_raw(&self) -> Result<(), fidl::Error> {
4686        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4687            (),
4688            self.tx_id,
4689            0x3ad9a012982f872d,
4690            fidl::encoding::DynamicFlags::empty(),
4691        )
4692    }
4693}
4694
4695#[must_use = "FIDL methods require a response to be sent"]
4696#[derive(Debug)]
4697pub struct GuestManagerConnectResponder {
4698    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4699    tx_id: u32,
4700}
4701
4702/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4703/// if the responder is dropped without sending a response, so that the client
4704/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4705impl std::ops::Drop for GuestManagerConnectResponder {
4706    fn drop(&mut self) {
4707        self.control_handle.shutdown();
4708        // Safety: drops once, never accessed again
4709        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4710    }
4711}
4712
4713impl fidl::endpoints::Responder for GuestManagerConnectResponder {
4714    type ControlHandle = GuestManagerControlHandle;
4715
4716    fn control_handle(&self) -> &GuestManagerControlHandle {
4717        &self.control_handle
4718    }
4719
4720    fn drop_without_shutdown(mut self) {
4721        // Safety: drops once, never accessed again due to mem::forget
4722        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4723        // Prevent Drop from running (which would shut down the channel)
4724        std::mem::forget(self);
4725    }
4726}
4727
4728impl GuestManagerConnectResponder {
4729    /// Sends a response to the FIDL transaction.
4730    ///
4731    /// Sets the channel to shutdown if an error occurs.
4732    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4733        let _result = self.send_raw(result);
4734        if _result.is_err() {
4735            self.control_handle.shutdown();
4736        }
4737        self.drop_without_shutdown();
4738        _result
4739    }
4740
4741    /// Similar to "send" but does not shutdown the channel if an error occurs.
4742    pub fn send_no_shutdown_on_err(
4743        self,
4744        mut result: Result<(), GuestManagerError>,
4745    ) -> Result<(), fidl::Error> {
4746        let _result = self.send_raw(result);
4747        self.drop_without_shutdown();
4748        _result
4749    }
4750
4751    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4752        self.control_handle.inner.send::<fidl::encoding::ResultType<
4753            fidl::encoding::EmptyStruct,
4754            GuestManagerError,
4755        >>(
4756            result,
4757            self.tx_id,
4758            0x4e489076e3bb15b4,
4759            fidl::encoding::DynamicFlags::empty(),
4760        )
4761    }
4762}
4763
4764#[must_use = "FIDL methods require a response to be sent"]
4765#[derive(Debug)]
4766pub struct GuestManagerGetInfoResponder {
4767    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4768    tx_id: u32,
4769}
4770
4771/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4772/// if the responder is dropped without sending a response, so that the client
4773/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4774impl std::ops::Drop for GuestManagerGetInfoResponder {
4775    fn drop(&mut self) {
4776        self.control_handle.shutdown();
4777        // Safety: drops once, never accessed again
4778        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4779    }
4780}
4781
4782impl fidl::endpoints::Responder for GuestManagerGetInfoResponder {
4783    type ControlHandle = GuestManagerControlHandle;
4784
4785    fn control_handle(&self) -> &GuestManagerControlHandle {
4786        &self.control_handle
4787    }
4788
4789    fn drop_without_shutdown(mut self) {
4790        // Safety: drops once, never accessed again due to mem::forget
4791        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4792        // Prevent Drop from running (which would shut down the channel)
4793        std::mem::forget(self);
4794    }
4795}
4796
4797impl GuestManagerGetInfoResponder {
4798    /// Sends a response to the FIDL transaction.
4799    ///
4800    /// Sets the channel to shutdown if an error occurs.
4801    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4802        let _result = self.send_raw(guest_info);
4803        if _result.is_err() {
4804            self.control_handle.shutdown();
4805        }
4806        self.drop_without_shutdown();
4807        _result
4808    }
4809
4810    /// Similar to "send" but does not shutdown the channel if an error occurs.
4811    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4812        let _result = self.send_raw(guest_info);
4813        self.drop_without_shutdown();
4814        _result
4815    }
4816
4817    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4818        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
4819            (guest_info,),
4820            self.tx_id,
4821            0x76892614aea695dc,
4822            fidl::encoding::DynamicFlags::empty(),
4823        )
4824    }
4825}
4826
4827#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4828pub struct HostVsockAcceptorMarker;
4829
4830impl fidl::endpoints::ProtocolMarker for HostVsockAcceptorMarker {
4831    type Proxy = HostVsockAcceptorProxy;
4832    type RequestStream = HostVsockAcceptorRequestStream;
4833    #[cfg(target_os = "fuchsia")]
4834    type SynchronousProxy = HostVsockAcceptorSynchronousProxy;
4835
4836    const DEBUG_NAME: &'static str = "(anonymous) HostVsockAcceptor";
4837}
4838pub type HostVsockAcceptorAcceptResult = Result<fidl::Socket, i32>;
4839
4840pub trait HostVsockAcceptorProxyInterface: Send + Sync {
4841    type AcceptResponseFut: std::future::Future<Output = Result<HostVsockAcceptorAcceptResult, fidl::Error>>
4842        + Send;
4843    fn r#accept(&self, src_cid: u32, src_port: u32, port: u32) -> Self::AcceptResponseFut;
4844}
4845#[derive(Debug)]
4846#[cfg(target_os = "fuchsia")]
4847pub struct HostVsockAcceptorSynchronousProxy {
4848    client: fidl::client::sync::Client,
4849}
4850
4851#[cfg(target_os = "fuchsia")]
4852impl fidl::endpoints::SynchronousProxy for HostVsockAcceptorSynchronousProxy {
4853    type Proxy = HostVsockAcceptorProxy;
4854    type Protocol = HostVsockAcceptorMarker;
4855
4856    fn from_channel(inner: fidl::Channel) -> Self {
4857        Self::new(inner)
4858    }
4859
4860    fn into_channel(self) -> fidl::Channel {
4861        self.client.into_channel()
4862    }
4863
4864    fn as_channel(&self) -> &fidl::Channel {
4865        self.client.as_channel()
4866    }
4867}
4868
4869#[cfg(target_os = "fuchsia")]
4870impl HostVsockAcceptorSynchronousProxy {
4871    pub fn new(channel: fidl::Channel) -> Self {
4872        let protocol_name =
4873            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4874        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4875    }
4876
4877    pub fn into_channel(self) -> fidl::Channel {
4878        self.client.into_channel()
4879    }
4880
4881    /// Waits until an event arrives and returns it. It is safe for other
4882    /// threads to make concurrent requests while waiting for an event.
4883    pub fn wait_for_event(
4884        &self,
4885        deadline: zx::MonotonicInstant,
4886    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
4887        HostVsockAcceptorEvent::decode(self.client.wait_for_event(deadline)?)
4888    }
4889
4890    pub fn r#accept(
4891        &self,
4892        mut src_cid: u32,
4893        mut src_port: u32,
4894        mut port: u32,
4895        ___deadline: zx::MonotonicInstant,
4896    ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
4897        let _response = self.client.send_query::<
4898            HostVsockAcceptorAcceptRequest,
4899            fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
4900        >(
4901            (src_cid, src_port, port,),
4902            0x6996ed935beaa2d7,
4903            fidl::encoding::DynamicFlags::empty(),
4904            ___deadline,
4905        )?;
4906        Ok(_response.map(|x| x.socket))
4907    }
4908}
4909
4910#[cfg(target_os = "fuchsia")]
4911impl From<HostVsockAcceptorSynchronousProxy> for zx::Handle {
4912    fn from(value: HostVsockAcceptorSynchronousProxy) -> Self {
4913        value.into_channel().into()
4914    }
4915}
4916
4917#[cfg(target_os = "fuchsia")]
4918impl From<fidl::Channel> for HostVsockAcceptorSynchronousProxy {
4919    fn from(value: fidl::Channel) -> Self {
4920        Self::new(value)
4921    }
4922}
4923
4924#[cfg(target_os = "fuchsia")]
4925impl fidl::endpoints::FromClient for HostVsockAcceptorSynchronousProxy {
4926    type Protocol = HostVsockAcceptorMarker;
4927
4928    fn from_client(value: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>) -> Self {
4929        Self::new(value.into_channel())
4930    }
4931}
4932
4933#[derive(Debug, Clone)]
4934pub struct HostVsockAcceptorProxy {
4935    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4936}
4937
4938impl fidl::endpoints::Proxy for HostVsockAcceptorProxy {
4939    type Protocol = HostVsockAcceptorMarker;
4940
4941    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4942        Self::new(inner)
4943    }
4944
4945    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4946        self.client.into_channel().map_err(|client| Self { client })
4947    }
4948
4949    fn as_channel(&self) -> &::fidl::AsyncChannel {
4950        self.client.as_channel()
4951    }
4952}
4953
4954impl HostVsockAcceptorProxy {
4955    /// Create a new Proxy for fuchsia.virtualization/HostVsockAcceptor.
4956    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4957        let protocol_name =
4958            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4959        Self { client: fidl::client::Client::new(channel, protocol_name) }
4960    }
4961
4962    /// Get a Stream of events from the remote end of the protocol.
4963    ///
4964    /// # Panics
4965    ///
4966    /// Panics if the event stream was already taken.
4967    pub fn take_event_stream(&self) -> HostVsockAcceptorEventStream {
4968        HostVsockAcceptorEventStream { event_receiver: self.client.take_event_receiver() }
4969    }
4970
4971    pub fn r#accept(
4972        &self,
4973        mut src_cid: u32,
4974        mut src_port: u32,
4975        mut port: u32,
4976    ) -> fidl::client::QueryResponseFut<
4977        HostVsockAcceptorAcceptResult,
4978        fidl::encoding::DefaultFuchsiaResourceDialect,
4979    > {
4980        HostVsockAcceptorProxyInterface::r#accept(self, src_cid, src_port, port)
4981    }
4982}
4983
4984impl HostVsockAcceptorProxyInterface for HostVsockAcceptorProxy {
4985    type AcceptResponseFut = fidl::client::QueryResponseFut<
4986        HostVsockAcceptorAcceptResult,
4987        fidl::encoding::DefaultFuchsiaResourceDialect,
4988    >;
4989    fn r#accept(
4990        &self,
4991        mut src_cid: u32,
4992        mut src_port: u32,
4993        mut port: u32,
4994    ) -> Self::AcceptResponseFut {
4995        fn _decode(
4996            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4997        ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
4998            let _response = fidl::client::decode_transaction_body::<
4999                fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
5000                fidl::encoding::DefaultFuchsiaResourceDialect,
5001                0x6996ed935beaa2d7,
5002            >(_buf?)?;
5003            Ok(_response.map(|x| x.socket))
5004        }
5005        self.client
5006            .send_query_and_decode::<HostVsockAcceptorAcceptRequest, HostVsockAcceptorAcceptResult>(
5007                (src_cid, src_port, port),
5008                0x6996ed935beaa2d7,
5009                fidl::encoding::DynamicFlags::empty(),
5010                _decode,
5011            )
5012    }
5013}
5014
5015pub struct HostVsockAcceptorEventStream {
5016    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5017}
5018
5019impl std::marker::Unpin for HostVsockAcceptorEventStream {}
5020
5021impl futures::stream::FusedStream for HostVsockAcceptorEventStream {
5022    fn is_terminated(&self) -> bool {
5023        self.event_receiver.is_terminated()
5024    }
5025}
5026
5027impl futures::Stream for HostVsockAcceptorEventStream {
5028    type Item = Result<HostVsockAcceptorEvent, fidl::Error>;
5029
5030    fn poll_next(
5031        mut self: std::pin::Pin<&mut Self>,
5032        cx: &mut std::task::Context<'_>,
5033    ) -> std::task::Poll<Option<Self::Item>> {
5034        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5035            &mut self.event_receiver,
5036            cx
5037        )?) {
5038            Some(buf) => std::task::Poll::Ready(Some(HostVsockAcceptorEvent::decode(buf))),
5039            None => std::task::Poll::Ready(None),
5040        }
5041    }
5042}
5043
5044#[derive(Debug)]
5045pub enum HostVsockAcceptorEvent {}
5046
5047impl HostVsockAcceptorEvent {
5048    /// Decodes a message buffer as a [`HostVsockAcceptorEvent`].
5049    fn decode(
5050        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5051    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
5052        let (bytes, _handles) = buf.split_mut();
5053        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5054        debug_assert_eq!(tx_header.tx_id, 0);
5055        match tx_header.ordinal {
5056            _ => Err(fidl::Error::UnknownOrdinal {
5057                ordinal: tx_header.ordinal,
5058                protocol_name:
5059                    <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5060            }),
5061        }
5062    }
5063}
5064
5065/// A Stream of incoming requests for fuchsia.virtualization/HostVsockAcceptor.
5066pub struct HostVsockAcceptorRequestStream {
5067    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5068    is_terminated: bool,
5069}
5070
5071impl std::marker::Unpin for HostVsockAcceptorRequestStream {}
5072
5073impl futures::stream::FusedStream for HostVsockAcceptorRequestStream {
5074    fn is_terminated(&self) -> bool {
5075        self.is_terminated
5076    }
5077}
5078
5079impl fidl::endpoints::RequestStream for HostVsockAcceptorRequestStream {
5080    type Protocol = HostVsockAcceptorMarker;
5081    type ControlHandle = HostVsockAcceptorControlHandle;
5082
5083    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5084        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5085    }
5086
5087    fn control_handle(&self) -> Self::ControlHandle {
5088        HostVsockAcceptorControlHandle { inner: self.inner.clone() }
5089    }
5090
5091    fn into_inner(
5092        self,
5093    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5094    {
5095        (self.inner, self.is_terminated)
5096    }
5097
5098    fn from_inner(
5099        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5100        is_terminated: bool,
5101    ) -> Self {
5102        Self { inner, is_terminated }
5103    }
5104}
5105
5106impl futures::Stream for HostVsockAcceptorRequestStream {
5107    type Item = Result<HostVsockAcceptorRequest, fidl::Error>;
5108
5109    fn poll_next(
5110        mut self: std::pin::Pin<&mut Self>,
5111        cx: &mut std::task::Context<'_>,
5112    ) -> std::task::Poll<Option<Self::Item>> {
5113        let this = &mut *self;
5114        if this.inner.check_shutdown(cx) {
5115            this.is_terminated = true;
5116            return std::task::Poll::Ready(None);
5117        }
5118        if this.is_terminated {
5119            panic!("polled HostVsockAcceptorRequestStream after completion");
5120        }
5121        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5122            |bytes, handles| {
5123                match this.inner.channel().read_etc(cx, bytes, handles) {
5124                    std::task::Poll::Ready(Ok(())) => {}
5125                    std::task::Poll::Pending => return std::task::Poll::Pending,
5126                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5127                        this.is_terminated = true;
5128                        return std::task::Poll::Ready(None);
5129                    }
5130                    std::task::Poll::Ready(Err(e)) => {
5131                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5132                            e.into(),
5133                        ))));
5134                    }
5135                }
5136
5137                // A message has been received from the channel
5138                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5139
5140                std::task::Poll::Ready(Some(match header.ordinal {
5141                    0x6996ed935beaa2d7 => {
5142                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5143                        let mut req = fidl::new_empty!(
5144                            HostVsockAcceptorAcceptRequest,
5145                            fidl::encoding::DefaultFuchsiaResourceDialect
5146                        );
5147                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockAcceptorAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
5148                        let control_handle =
5149                            HostVsockAcceptorControlHandle { inner: this.inner.clone() };
5150                        Ok(HostVsockAcceptorRequest::Accept {
5151                            src_cid: req.src_cid,
5152                            src_port: req.src_port,
5153                            port: req.port,
5154
5155                            responder: HostVsockAcceptorAcceptResponder {
5156                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5157                                tx_id: header.tx_id,
5158                            },
5159                        })
5160                    }
5161                    _ => Err(fidl::Error::UnknownOrdinal {
5162                        ordinal: header.ordinal,
5163                        protocol_name:
5164                            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5165                    }),
5166                }))
5167            },
5168        )
5169    }
5170}
5171
5172/// Exposed by a host capable of listening via vsocks. A variant of a
5173/// `GuestVsockAcceptor` that is responsible for creating the `socket` with which
5174/// to communicate.
5175#[derive(Debug)]
5176pub enum HostVsockAcceptorRequest {
5177    Accept { src_cid: u32, src_port: u32, port: u32, responder: HostVsockAcceptorAcceptResponder },
5178}
5179
5180impl HostVsockAcceptorRequest {
5181    #[allow(irrefutable_let_patterns)]
5182    pub fn into_accept(self) -> Option<(u32, u32, u32, HostVsockAcceptorAcceptResponder)> {
5183        if let HostVsockAcceptorRequest::Accept { src_cid, src_port, port, responder } = self {
5184            Some((src_cid, src_port, port, responder))
5185        } else {
5186            None
5187        }
5188    }
5189
5190    /// Name of the method defined in FIDL
5191    pub fn method_name(&self) -> &'static str {
5192        match *self {
5193            HostVsockAcceptorRequest::Accept { .. } => "accept",
5194        }
5195    }
5196}
5197
5198#[derive(Debug, Clone)]
5199pub struct HostVsockAcceptorControlHandle {
5200    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5201}
5202
5203impl fidl::endpoints::ControlHandle for HostVsockAcceptorControlHandle {
5204    fn shutdown(&self) {
5205        self.inner.shutdown()
5206    }
5207    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5208        self.inner.shutdown_with_epitaph(status)
5209    }
5210
5211    fn is_closed(&self) -> bool {
5212        self.inner.channel().is_closed()
5213    }
5214    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5215        self.inner.channel().on_closed()
5216    }
5217
5218    #[cfg(target_os = "fuchsia")]
5219    fn signal_peer(
5220        &self,
5221        clear_mask: zx::Signals,
5222        set_mask: zx::Signals,
5223    ) -> Result<(), zx_status::Status> {
5224        use fidl::Peered;
5225        self.inner.channel().signal_peer(clear_mask, set_mask)
5226    }
5227}
5228
5229impl HostVsockAcceptorControlHandle {}
5230
5231#[must_use = "FIDL methods require a response to be sent"]
5232#[derive(Debug)]
5233pub struct HostVsockAcceptorAcceptResponder {
5234    control_handle: std::mem::ManuallyDrop<HostVsockAcceptorControlHandle>,
5235    tx_id: u32,
5236}
5237
5238/// Set the the channel to be shutdown (see [`HostVsockAcceptorControlHandle::shutdown`])
5239/// if the responder is dropped without sending a response, so that the client
5240/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5241impl std::ops::Drop for HostVsockAcceptorAcceptResponder {
5242    fn drop(&mut self) {
5243        self.control_handle.shutdown();
5244        // Safety: drops once, never accessed again
5245        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5246    }
5247}
5248
5249impl fidl::endpoints::Responder for HostVsockAcceptorAcceptResponder {
5250    type ControlHandle = HostVsockAcceptorControlHandle;
5251
5252    fn control_handle(&self) -> &HostVsockAcceptorControlHandle {
5253        &self.control_handle
5254    }
5255
5256    fn drop_without_shutdown(mut self) {
5257        // Safety: drops once, never accessed again due to mem::forget
5258        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5259        // Prevent Drop from running (which would shut down the channel)
5260        std::mem::forget(self);
5261    }
5262}
5263
5264impl HostVsockAcceptorAcceptResponder {
5265    /// Sends a response to the FIDL transaction.
5266    ///
5267    /// Sets the channel to shutdown if an error occurs.
5268    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5269        let _result = self.send_raw(result);
5270        if _result.is_err() {
5271            self.control_handle.shutdown();
5272        }
5273        self.drop_without_shutdown();
5274        _result
5275    }
5276
5277    /// Similar to "send" but does not shutdown the channel if an error occurs.
5278    pub fn send_no_shutdown_on_err(
5279        self,
5280        mut result: Result<fidl::Socket, i32>,
5281    ) -> Result<(), fidl::Error> {
5282        let _result = self.send_raw(result);
5283        self.drop_without_shutdown();
5284        _result
5285    }
5286
5287    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5288        self.control_handle
5289            .inner
5290            .send::<fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>>(
5291                result.map(|socket| (socket,)),
5292                self.tx_id,
5293                0x6996ed935beaa2d7,
5294                fidl::encoding::DynamicFlags::empty(),
5295            )
5296    }
5297}
5298
5299#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5300pub struct HostVsockEndpointMarker;
5301
5302impl fidl::endpoints::ProtocolMarker for HostVsockEndpointMarker {
5303    type Proxy = HostVsockEndpointProxy;
5304    type RequestStream = HostVsockEndpointRequestStream;
5305    #[cfg(target_os = "fuchsia")]
5306    type SynchronousProxy = HostVsockEndpointSynchronousProxy;
5307
5308    const DEBUG_NAME: &'static str = "fuchsia.virtualization.HostVsockEndpoint";
5309}
5310impl fidl::endpoints::DiscoverableProtocolMarker for HostVsockEndpointMarker {}
5311pub type HostVsockEndpointListenResult = Result<(), i32>;
5312pub type HostVsockEndpointConnectResult = Result<fidl::Socket, i32>;
5313
5314pub trait HostVsockEndpointProxyInterface: Send + Sync {
5315    type ListenResponseFut: std::future::Future<Output = Result<HostVsockEndpointListenResult, fidl::Error>>
5316        + Send;
5317    fn r#listen(
5318        &self,
5319        port: u32,
5320        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5321    ) -> Self::ListenResponseFut;
5322    type ConnectResponseFut: std::future::Future<Output = Result<HostVsockEndpointConnectResult, fidl::Error>>
5323        + Send;
5324    fn r#connect(&self, guest_port: u32) -> Self::ConnectResponseFut;
5325}
5326#[derive(Debug)]
5327#[cfg(target_os = "fuchsia")]
5328pub struct HostVsockEndpointSynchronousProxy {
5329    client: fidl::client::sync::Client,
5330}
5331
5332#[cfg(target_os = "fuchsia")]
5333impl fidl::endpoints::SynchronousProxy for HostVsockEndpointSynchronousProxy {
5334    type Proxy = HostVsockEndpointProxy;
5335    type Protocol = HostVsockEndpointMarker;
5336
5337    fn from_channel(inner: fidl::Channel) -> Self {
5338        Self::new(inner)
5339    }
5340
5341    fn into_channel(self) -> fidl::Channel {
5342        self.client.into_channel()
5343    }
5344
5345    fn as_channel(&self) -> &fidl::Channel {
5346        self.client.as_channel()
5347    }
5348}
5349
5350#[cfg(target_os = "fuchsia")]
5351impl HostVsockEndpointSynchronousProxy {
5352    pub fn new(channel: fidl::Channel) -> Self {
5353        let protocol_name =
5354            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5355        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5356    }
5357
5358    pub fn into_channel(self) -> fidl::Channel {
5359        self.client.into_channel()
5360    }
5361
5362    /// Waits until an event arrives and returns it. It is safe for other
5363    /// threads to make concurrent requests while waiting for an event.
5364    pub fn wait_for_event(
5365        &self,
5366        deadline: zx::MonotonicInstant,
5367    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5368        HostVsockEndpointEvent::decode(self.client.wait_for_event(deadline)?)
5369    }
5370
5371    /// Instructs the device to listen for guest initiated connections to a given port by
5372    /// using `acceptor` when the guest creates a connection.
5373    ///
5374    /// Possible errors:
5375    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5376    pub fn r#listen(
5377        &self,
5378        mut port: u32,
5379        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5380        ___deadline: zx::MonotonicInstant,
5381    ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5382        let _response = self
5383            .client
5384            .send_query::<Listener, fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5385                (port, acceptor),
5386                0xfd88f3b4767f2c7,
5387                fidl::encoding::DynamicFlags::empty(),
5388                ___deadline,
5389            )?;
5390        Ok(_response.map(|x| x))
5391    }
5392
5393    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5394    /// ephemeral host port.
5395    ///
5396    /// Possible errors:
5397    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5398    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5399    ///
5400    /// Other errors are related to socket creation, see
5401    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5402    pub fn r#connect(
5403        &self,
5404        mut guest_port: u32,
5405        ___deadline: zx::MonotonicInstant,
5406    ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5407        let _response = self.client.send_query::<
5408            HostVsockEndpointConnectRequest,
5409            fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5410        >(
5411            (guest_port,),
5412            0x4d12e10e946b43e4,
5413            fidl::encoding::DynamicFlags::empty(),
5414            ___deadline,
5415        )?;
5416        Ok(_response.map(|x| x.socket))
5417    }
5418}
5419
5420#[cfg(target_os = "fuchsia")]
5421impl From<HostVsockEndpointSynchronousProxy> for zx::Handle {
5422    fn from(value: HostVsockEndpointSynchronousProxy) -> Self {
5423        value.into_channel().into()
5424    }
5425}
5426
5427#[cfg(target_os = "fuchsia")]
5428impl From<fidl::Channel> for HostVsockEndpointSynchronousProxy {
5429    fn from(value: fidl::Channel) -> Self {
5430        Self::new(value)
5431    }
5432}
5433
5434#[cfg(target_os = "fuchsia")]
5435impl fidl::endpoints::FromClient for HostVsockEndpointSynchronousProxy {
5436    type Protocol = HostVsockEndpointMarker;
5437
5438    fn from_client(value: fidl::endpoints::ClientEnd<HostVsockEndpointMarker>) -> Self {
5439        Self::new(value.into_channel())
5440    }
5441}
5442
5443#[derive(Debug, Clone)]
5444pub struct HostVsockEndpointProxy {
5445    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5446}
5447
5448impl fidl::endpoints::Proxy for HostVsockEndpointProxy {
5449    type Protocol = HostVsockEndpointMarker;
5450
5451    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5452        Self::new(inner)
5453    }
5454
5455    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5456        self.client.into_channel().map_err(|client| Self { client })
5457    }
5458
5459    fn as_channel(&self) -> &::fidl::AsyncChannel {
5460        self.client.as_channel()
5461    }
5462}
5463
5464impl HostVsockEndpointProxy {
5465    /// Create a new Proxy for fuchsia.virtualization/HostVsockEndpoint.
5466    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5467        let protocol_name =
5468            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5469        Self { client: fidl::client::Client::new(channel, protocol_name) }
5470    }
5471
5472    /// Get a Stream of events from the remote end of the protocol.
5473    ///
5474    /// # Panics
5475    ///
5476    /// Panics if the event stream was already taken.
5477    pub fn take_event_stream(&self) -> HostVsockEndpointEventStream {
5478        HostVsockEndpointEventStream { event_receiver: self.client.take_event_receiver() }
5479    }
5480
5481    /// Instructs the device to listen for guest initiated connections to a given port by
5482    /// using `acceptor` when the guest creates a connection.
5483    ///
5484    /// Possible errors:
5485    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5486    pub fn r#listen(
5487        &self,
5488        mut port: u32,
5489        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5490    ) -> fidl::client::QueryResponseFut<
5491        HostVsockEndpointListenResult,
5492        fidl::encoding::DefaultFuchsiaResourceDialect,
5493    > {
5494        HostVsockEndpointProxyInterface::r#listen(self, port, acceptor)
5495    }
5496
5497    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5498    /// ephemeral host port.
5499    ///
5500    /// Possible errors:
5501    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5502    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5503    ///
5504    /// Other errors are related to socket creation, see
5505    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5506    pub fn r#connect(
5507        &self,
5508        mut guest_port: u32,
5509    ) -> fidl::client::QueryResponseFut<
5510        HostVsockEndpointConnectResult,
5511        fidl::encoding::DefaultFuchsiaResourceDialect,
5512    > {
5513        HostVsockEndpointProxyInterface::r#connect(self, guest_port)
5514    }
5515}
5516
5517impl HostVsockEndpointProxyInterface for HostVsockEndpointProxy {
5518    type ListenResponseFut = fidl::client::QueryResponseFut<
5519        HostVsockEndpointListenResult,
5520        fidl::encoding::DefaultFuchsiaResourceDialect,
5521    >;
5522    fn r#listen(
5523        &self,
5524        mut port: u32,
5525        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5526    ) -> Self::ListenResponseFut {
5527        fn _decode(
5528            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5529        ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5530            let _response = fidl::client::decode_transaction_body::<
5531                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5532                fidl::encoding::DefaultFuchsiaResourceDialect,
5533                0xfd88f3b4767f2c7,
5534            >(_buf?)?;
5535            Ok(_response.map(|x| x))
5536        }
5537        self.client.send_query_and_decode::<Listener, HostVsockEndpointListenResult>(
5538            (port, acceptor),
5539            0xfd88f3b4767f2c7,
5540            fidl::encoding::DynamicFlags::empty(),
5541            _decode,
5542        )
5543    }
5544
5545    type ConnectResponseFut = fidl::client::QueryResponseFut<
5546        HostVsockEndpointConnectResult,
5547        fidl::encoding::DefaultFuchsiaResourceDialect,
5548    >;
5549    fn r#connect(&self, mut guest_port: u32) -> Self::ConnectResponseFut {
5550        fn _decode(
5551            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5552        ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5553            let _response = fidl::client::decode_transaction_body::<
5554                fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5555                fidl::encoding::DefaultFuchsiaResourceDialect,
5556                0x4d12e10e946b43e4,
5557            >(_buf?)?;
5558            Ok(_response.map(|x| x.socket))
5559        }
5560        self.client.send_query_and_decode::<
5561            HostVsockEndpointConnectRequest,
5562            HostVsockEndpointConnectResult,
5563        >(
5564            (guest_port,),
5565            0x4d12e10e946b43e4,
5566            fidl::encoding::DynamicFlags::empty(),
5567            _decode,
5568        )
5569    }
5570}
5571
5572pub struct HostVsockEndpointEventStream {
5573    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5574}
5575
5576impl std::marker::Unpin for HostVsockEndpointEventStream {}
5577
5578impl futures::stream::FusedStream for HostVsockEndpointEventStream {
5579    fn is_terminated(&self) -> bool {
5580        self.event_receiver.is_terminated()
5581    }
5582}
5583
5584impl futures::Stream for HostVsockEndpointEventStream {
5585    type Item = Result<HostVsockEndpointEvent, fidl::Error>;
5586
5587    fn poll_next(
5588        mut self: std::pin::Pin<&mut Self>,
5589        cx: &mut std::task::Context<'_>,
5590    ) -> std::task::Poll<Option<Self::Item>> {
5591        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5592            &mut self.event_receiver,
5593            cx
5594        )?) {
5595            Some(buf) => std::task::Poll::Ready(Some(HostVsockEndpointEvent::decode(buf))),
5596            None => std::task::Poll::Ready(None),
5597        }
5598    }
5599}
5600
5601#[derive(Debug)]
5602pub enum HostVsockEndpointEvent {}
5603
5604impl HostVsockEndpointEvent {
5605    /// Decodes a message buffer as a [`HostVsockEndpointEvent`].
5606    fn decode(
5607        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5608    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5609        let (bytes, _handles) = buf.split_mut();
5610        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5611        debug_assert_eq!(tx_header.tx_id, 0);
5612        match tx_header.ordinal {
5613            _ => Err(fidl::Error::UnknownOrdinal {
5614                ordinal: tx_header.ordinal,
5615                protocol_name:
5616                    <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5617            }),
5618        }
5619    }
5620}
5621
5622/// A Stream of incoming requests for fuchsia.virtualization/HostVsockEndpoint.
5623pub struct HostVsockEndpointRequestStream {
5624    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5625    is_terminated: bool,
5626}
5627
5628impl std::marker::Unpin for HostVsockEndpointRequestStream {}
5629
5630impl futures::stream::FusedStream for HostVsockEndpointRequestStream {
5631    fn is_terminated(&self) -> bool {
5632        self.is_terminated
5633    }
5634}
5635
5636impl fidl::endpoints::RequestStream for HostVsockEndpointRequestStream {
5637    type Protocol = HostVsockEndpointMarker;
5638    type ControlHandle = HostVsockEndpointControlHandle;
5639
5640    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5641        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5642    }
5643
5644    fn control_handle(&self) -> Self::ControlHandle {
5645        HostVsockEndpointControlHandle { inner: self.inner.clone() }
5646    }
5647
5648    fn into_inner(
5649        self,
5650    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5651    {
5652        (self.inner, self.is_terminated)
5653    }
5654
5655    fn from_inner(
5656        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5657        is_terminated: bool,
5658    ) -> Self {
5659        Self { inner, is_terminated }
5660    }
5661}
5662
5663impl futures::Stream for HostVsockEndpointRequestStream {
5664    type Item = Result<HostVsockEndpointRequest, fidl::Error>;
5665
5666    fn poll_next(
5667        mut self: std::pin::Pin<&mut Self>,
5668        cx: &mut std::task::Context<'_>,
5669    ) -> std::task::Poll<Option<Self::Item>> {
5670        let this = &mut *self;
5671        if this.inner.check_shutdown(cx) {
5672            this.is_terminated = true;
5673            return std::task::Poll::Ready(None);
5674        }
5675        if this.is_terminated {
5676            panic!("polled HostVsockEndpointRequestStream after completion");
5677        }
5678        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5679            |bytes, handles| {
5680                match this.inner.channel().read_etc(cx, bytes, handles) {
5681                    std::task::Poll::Ready(Ok(())) => {}
5682                    std::task::Poll::Pending => return std::task::Poll::Pending,
5683                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5684                        this.is_terminated = true;
5685                        return std::task::Poll::Ready(None);
5686                    }
5687                    std::task::Poll::Ready(Err(e)) => {
5688                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5689                            e.into(),
5690                        ))));
5691                    }
5692                }
5693
5694                // A message has been received from the channel
5695                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5696
5697                std::task::Poll::Ready(Some(match header.ordinal {
5698                    0xfd88f3b4767f2c7 => {
5699                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5700                        let mut req = fidl::new_empty!(
5701                            Listener,
5702                            fidl::encoding::DefaultFuchsiaResourceDialect
5703                        );
5704                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Listener>(&header, _body_bytes, handles, &mut req)?;
5705                        let control_handle =
5706                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5707                        Ok(HostVsockEndpointRequest::Listen {
5708                            port: req.port,
5709                            acceptor: req.acceptor,
5710
5711                            responder: HostVsockEndpointListenResponder {
5712                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5713                                tx_id: header.tx_id,
5714                            },
5715                        })
5716                    }
5717                    0x4d12e10e946b43e4 => {
5718                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5719                        let mut req = fidl::new_empty!(
5720                            HostVsockEndpointConnectRequest,
5721                            fidl::encoding::DefaultFuchsiaResourceDialect
5722                        );
5723                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockEndpointConnectRequest>(&header, _body_bytes, handles, &mut req)?;
5724                        let control_handle =
5725                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5726                        Ok(HostVsockEndpointRequest::Connect {
5727                            guest_port: req.guest_port,
5728
5729                            responder: HostVsockEndpointConnectResponder {
5730                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5731                                tx_id: header.tx_id,
5732                            },
5733                        })
5734                    }
5735                    _ => Err(fidl::Error::UnknownOrdinal {
5736                        ordinal: header.ordinal,
5737                        protocol_name:
5738                            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5739                    }),
5740                }))
5741            },
5742        )
5743    }
5744}
5745
5746/// Exposed by a host to provide the ability for listeners to be multiplexed by
5747/// port and to manage dynamic port allocation for outbound connections.
5748#[derive(Debug)]
5749pub enum HostVsockEndpointRequest {
5750    /// Instructs the device to listen for guest initiated connections to a given port by
5751    /// using `acceptor` when the guest creates a connection.
5752    ///
5753    /// Possible errors:
5754    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5755    Listen {
5756        port: u32,
5757        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5758        responder: HostVsockEndpointListenResponder,
5759    },
5760    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5761    /// ephemeral host port.
5762    ///
5763    /// Possible errors:
5764    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5765    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5766    ///
5767    /// Other errors are related to socket creation, see
5768    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5769    Connect { guest_port: u32, responder: HostVsockEndpointConnectResponder },
5770}
5771
5772impl HostVsockEndpointRequest {
5773    #[allow(irrefutable_let_patterns)]
5774    pub fn into_listen(
5775        self,
5776    ) -> Option<(
5777        u32,
5778        fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5779        HostVsockEndpointListenResponder,
5780    )> {
5781        if let HostVsockEndpointRequest::Listen { port, acceptor, responder } = self {
5782            Some((port, acceptor, responder))
5783        } else {
5784            None
5785        }
5786    }
5787
5788    #[allow(irrefutable_let_patterns)]
5789    pub fn into_connect(self) -> Option<(u32, HostVsockEndpointConnectResponder)> {
5790        if let HostVsockEndpointRequest::Connect { guest_port, responder } = self {
5791            Some((guest_port, responder))
5792        } else {
5793            None
5794        }
5795    }
5796
5797    /// Name of the method defined in FIDL
5798    pub fn method_name(&self) -> &'static str {
5799        match *self {
5800            HostVsockEndpointRequest::Listen { .. } => "listen",
5801            HostVsockEndpointRequest::Connect { .. } => "connect",
5802        }
5803    }
5804}
5805
5806#[derive(Debug, Clone)]
5807pub struct HostVsockEndpointControlHandle {
5808    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5809}
5810
5811impl fidl::endpoints::ControlHandle for HostVsockEndpointControlHandle {
5812    fn shutdown(&self) {
5813        self.inner.shutdown()
5814    }
5815    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5816        self.inner.shutdown_with_epitaph(status)
5817    }
5818
5819    fn is_closed(&self) -> bool {
5820        self.inner.channel().is_closed()
5821    }
5822    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5823        self.inner.channel().on_closed()
5824    }
5825
5826    #[cfg(target_os = "fuchsia")]
5827    fn signal_peer(
5828        &self,
5829        clear_mask: zx::Signals,
5830        set_mask: zx::Signals,
5831    ) -> Result<(), zx_status::Status> {
5832        use fidl::Peered;
5833        self.inner.channel().signal_peer(clear_mask, set_mask)
5834    }
5835}
5836
5837impl HostVsockEndpointControlHandle {}
5838
5839#[must_use = "FIDL methods require a response to be sent"]
5840#[derive(Debug)]
5841pub struct HostVsockEndpointListenResponder {
5842    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5843    tx_id: u32,
5844}
5845
5846/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5847/// if the responder is dropped without sending a response, so that the client
5848/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5849impl std::ops::Drop for HostVsockEndpointListenResponder {
5850    fn drop(&mut self) {
5851        self.control_handle.shutdown();
5852        // Safety: drops once, never accessed again
5853        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5854    }
5855}
5856
5857impl fidl::endpoints::Responder for HostVsockEndpointListenResponder {
5858    type ControlHandle = HostVsockEndpointControlHandle;
5859
5860    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5861        &self.control_handle
5862    }
5863
5864    fn drop_without_shutdown(mut self) {
5865        // Safety: drops once, never accessed again due to mem::forget
5866        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5867        // Prevent Drop from running (which would shut down the channel)
5868        std::mem::forget(self);
5869    }
5870}
5871
5872impl HostVsockEndpointListenResponder {
5873    /// Sends a response to the FIDL transaction.
5874    ///
5875    /// Sets the channel to shutdown if an error occurs.
5876    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5877        let _result = self.send_raw(result);
5878        if _result.is_err() {
5879            self.control_handle.shutdown();
5880        }
5881        self.drop_without_shutdown();
5882        _result
5883    }
5884
5885    /// Similar to "send" but does not shutdown the channel if an error occurs.
5886    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5887        let _result = self.send_raw(result);
5888        self.drop_without_shutdown();
5889        _result
5890    }
5891
5892    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5893        self.control_handle
5894            .inner
5895            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5896                result,
5897                self.tx_id,
5898                0xfd88f3b4767f2c7,
5899                fidl::encoding::DynamicFlags::empty(),
5900            )
5901    }
5902}
5903
5904#[must_use = "FIDL methods require a response to be sent"]
5905#[derive(Debug)]
5906pub struct HostVsockEndpointConnectResponder {
5907    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5908    tx_id: u32,
5909}
5910
5911/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5912/// if the responder is dropped without sending a response, so that the client
5913/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5914impl std::ops::Drop for HostVsockEndpointConnectResponder {
5915    fn drop(&mut self) {
5916        self.control_handle.shutdown();
5917        // Safety: drops once, never accessed again
5918        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5919    }
5920}
5921
5922impl fidl::endpoints::Responder for HostVsockEndpointConnectResponder {
5923    type ControlHandle = HostVsockEndpointControlHandle;
5924
5925    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5926        &self.control_handle
5927    }
5928
5929    fn drop_without_shutdown(mut self) {
5930        // Safety: drops once, never accessed again due to mem::forget
5931        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5932        // Prevent Drop from running (which would shut down the channel)
5933        std::mem::forget(self);
5934    }
5935}
5936
5937impl HostVsockEndpointConnectResponder {
5938    /// Sends a response to the FIDL transaction.
5939    ///
5940    /// Sets the channel to shutdown if an error occurs.
5941    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5942        let _result = self.send_raw(result);
5943        if _result.is_err() {
5944            self.control_handle.shutdown();
5945        }
5946        self.drop_without_shutdown();
5947        _result
5948    }
5949
5950    /// Similar to "send" but does not shutdown the channel if an error occurs.
5951    pub fn send_no_shutdown_on_err(
5952        self,
5953        mut result: Result<fidl::Socket, i32>,
5954    ) -> Result<(), fidl::Error> {
5955        let _result = self.send_raw(result);
5956        self.drop_without_shutdown();
5957        _result
5958    }
5959
5960    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5961        self.control_handle
5962            .inner
5963            .send::<fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>>(
5964                result.map(|socket| (socket,)),
5965                self.tx_id,
5966                0x4d12e10e946b43e4,
5967                fidl::encoding::DynamicFlags::empty(),
5968            )
5969    }
5970}
5971
5972#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5973pub struct LinuxManagerMarker;
5974
5975impl fidl::endpoints::ProtocolMarker for LinuxManagerMarker {
5976    type Proxy = LinuxManagerProxy;
5977    type RequestStream = LinuxManagerRequestStream;
5978    #[cfg(target_os = "fuchsia")]
5979    type SynchronousProxy = LinuxManagerSynchronousProxy;
5980
5981    const DEBUG_NAME: &'static str = "fuchsia.virtualization.LinuxManager";
5982}
5983impl fidl::endpoints::DiscoverableProtocolMarker for LinuxManagerMarker {}
5984pub type LinuxManagerStartAndGetLinuxGuestInfoResult = Result<LinuxGuestInfo, i32>;
5985pub type LinuxManagerWipeDataResult = Result<(), i32>;
5986
5987pub trait LinuxManagerProxyInterface: Send + Sync {
5988    type StartAndGetLinuxGuestInfoResponseFut: std::future::Future<
5989            Output = Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error>,
5990        > + Send;
5991    fn r#start_and_get_linux_guest_info(
5992        &self,
5993        label: &str,
5994    ) -> Self::StartAndGetLinuxGuestInfoResponseFut;
5995    type WipeDataResponseFut: std::future::Future<Output = Result<LinuxManagerWipeDataResult, fidl::Error>>
5996        + Send;
5997    fn r#wipe_data(&self) -> Self::WipeDataResponseFut;
5998    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error>;
5999}
6000#[derive(Debug)]
6001#[cfg(target_os = "fuchsia")]
6002pub struct LinuxManagerSynchronousProxy {
6003    client: fidl::client::sync::Client,
6004}
6005
6006#[cfg(target_os = "fuchsia")]
6007impl fidl::endpoints::SynchronousProxy for LinuxManagerSynchronousProxy {
6008    type Proxy = LinuxManagerProxy;
6009    type Protocol = LinuxManagerMarker;
6010
6011    fn from_channel(inner: fidl::Channel) -> Self {
6012        Self::new(inner)
6013    }
6014
6015    fn into_channel(self) -> fidl::Channel {
6016        self.client.into_channel()
6017    }
6018
6019    fn as_channel(&self) -> &fidl::Channel {
6020        self.client.as_channel()
6021    }
6022}
6023
6024#[cfg(target_os = "fuchsia")]
6025impl LinuxManagerSynchronousProxy {
6026    pub fn new(channel: fidl::Channel) -> Self {
6027        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6028        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6029    }
6030
6031    pub fn into_channel(self) -> fidl::Channel {
6032        self.client.into_channel()
6033    }
6034
6035    /// Waits until an event arrives and returns it. It is safe for other
6036    /// threads to make concurrent requests while waiting for an event.
6037    pub fn wait_for_event(
6038        &self,
6039        deadline: zx::MonotonicInstant,
6040    ) -> Result<LinuxManagerEvent, fidl::Error> {
6041        LinuxManagerEvent::decode(self.client.wait_for_event(deadline)?)
6042    }
6043
6044    /// Get Linux guest environment info.
6045    ///
6046    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6047    pub fn r#start_and_get_linux_guest_info(
6048        &self,
6049        mut label: &str,
6050        ___deadline: zx::MonotonicInstant,
6051    ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6052        let _response = self.client.send_query::<
6053            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6054            fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6055        >(
6056            (label,),
6057            0x11809ced100a2bea,
6058            fidl::encoding::DynamicFlags::empty(),
6059            ___deadline,
6060        )?;
6061        Ok(_response.map(|x| x.info))
6062    }
6063
6064    /// Clears the stateful data. This includes any installed containers and any user data
6065    /// they may contain.
6066    ///
6067    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6068    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6069    /// operation.
6070    pub fn r#wipe_data(
6071        &self,
6072        ___deadline: zx::MonotonicInstant,
6073    ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6074        let _response = self.client.send_query::<
6075            fidl::encoding::EmptyPayload,
6076            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6077        >(
6078            (),
6079            0x732c69394548a76a,
6080            fidl::encoding::DynamicFlags::empty(),
6081            ___deadline,
6082        )?;
6083        Ok(_response.map(|x| x))
6084    }
6085
6086    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6087    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6088    /// the epitaph) before attempting to launch another guest.
6089    ///
6090    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6091    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6092    /// a component crash).
6093    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6094        self.client.send::<fidl::encoding::EmptyPayload>(
6095            (),
6096            0x5dab12b50bc9909d,
6097            fidl::encoding::DynamicFlags::empty(),
6098        )
6099    }
6100}
6101
6102#[cfg(target_os = "fuchsia")]
6103impl From<LinuxManagerSynchronousProxy> for zx::Handle {
6104    fn from(value: LinuxManagerSynchronousProxy) -> Self {
6105        value.into_channel().into()
6106    }
6107}
6108
6109#[cfg(target_os = "fuchsia")]
6110impl From<fidl::Channel> for LinuxManagerSynchronousProxy {
6111    fn from(value: fidl::Channel) -> Self {
6112        Self::new(value)
6113    }
6114}
6115
6116#[cfg(target_os = "fuchsia")]
6117impl fidl::endpoints::FromClient for LinuxManagerSynchronousProxy {
6118    type Protocol = LinuxManagerMarker;
6119
6120    fn from_client(value: fidl::endpoints::ClientEnd<LinuxManagerMarker>) -> Self {
6121        Self::new(value.into_channel())
6122    }
6123}
6124
6125#[derive(Debug, Clone)]
6126pub struct LinuxManagerProxy {
6127    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6128}
6129
6130impl fidl::endpoints::Proxy for LinuxManagerProxy {
6131    type Protocol = LinuxManagerMarker;
6132
6133    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6134        Self::new(inner)
6135    }
6136
6137    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6138        self.client.into_channel().map_err(|client| Self { client })
6139    }
6140
6141    fn as_channel(&self) -> &::fidl::AsyncChannel {
6142        self.client.as_channel()
6143    }
6144}
6145
6146impl LinuxManagerProxy {
6147    /// Create a new Proxy for fuchsia.virtualization/LinuxManager.
6148    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6149        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6150        Self { client: fidl::client::Client::new(channel, protocol_name) }
6151    }
6152
6153    /// Get a Stream of events from the remote end of the protocol.
6154    ///
6155    /// # Panics
6156    ///
6157    /// Panics if the event stream was already taken.
6158    pub fn take_event_stream(&self) -> LinuxManagerEventStream {
6159        LinuxManagerEventStream { event_receiver: self.client.take_event_receiver() }
6160    }
6161
6162    /// Get Linux guest environment info.
6163    ///
6164    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6165    pub fn r#start_and_get_linux_guest_info(
6166        &self,
6167        mut label: &str,
6168    ) -> fidl::client::QueryResponseFut<
6169        LinuxManagerStartAndGetLinuxGuestInfoResult,
6170        fidl::encoding::DefaultFuchsiaResourceDialect,
6171    > {
6172        LinuxManagerProxyInterface::r#start_and_get_linux_guest_info(self, label)
6173    }
6174
6175    /// Clears the stateful data. This includes any installed containers and any user data
6176    /// they may contain.
6177    ///
6178    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6179    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6180    /// operation.
6181    pub fn r#wipe_data(
6182        &self,
6183    ) -> fidl::client::QueryResponseFut<
6184        LinuxManagerWipeDataResult,
6185        fidl::encoding::DefaultFuchsiaResourceDialect,
6186    > {
6187        LinuxManagerProxyInterface::r#wipe_data(self)
6188    }
6189
6190    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6191    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6192    /// the epitaph) before attempting to launch another guest.
6193    ///
6194    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6195    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6196    /// a component crash).
6197    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6198        LinuxManagerProxyInterface::r#graceful_shutdown(self)
6199    }
6200}
6201
6202impl LinuxManagerProxyInterface for LinuxManagerProxy {
6203    type StartAndGetLinuxGuestInfoResponseFut = fidl::client::QueryResponseFut<
6204        LinuxManagerStartAndGetLinuxGuestInfoResult,
6205        fidl::encoding::DefaultFuchsiaResourceDialect,
6206    >;
6207    fn r#start_and_get_linux_guest_info(
6208        &self,
6209        mut label: &str,
6210    ) -> Self::StartAndGetLinuxGuestInfoResponseFut {
6211        fn _decode(
6212            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6213        ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6214            let _response = fidl::client::decode_transaction_body::<
6215                fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6216                fidl::encoding::DefaultFuchsiaResourceDialect,
6217                0x11809ced100a2bea,
6218            >(_buf?)?;
6219            Ok(_response.map(|x| x.info))
6220        }
6221        self.client.send_query_and_decode::<
6222            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6223            LinuxManagerStartAndGetLinuxGuestInfoResult,
6224        >(
6225            (label,),
6226            0x11809ced100a2bea,
6227            fidl::encoding::DynamicFlags::empty(),
6228            _decode,
6229        )
6230    }
6231
6232    type WipeDataResponseFut = fidl::client::QueryResponseFut<
6233        LinuxManagerWipeDataResult,
6234        fidl::encoding::DefaultFuchsiaResourceDialect,
6235    >;
6236    fn r#wipe_data(&self) -> Self::WipeDataResponseFut {
6237        fn _decode(
6238            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6239        ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6240            let _response = fidl::client::decode_transaction_body::<
6241                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6242                fidl::encoding::DefaultFuchsiaResourceDialect,
6243                0x732c69394548a76a,
6244            >(_buf?)?;
6245            Ok(_response.map(|x| x))
6246        }
6247        self.client
6248            .send_query_and_decode::<fidl::encoding::EmptyPayload, LinuxManagerWipeDataResult>(
6249                (),
6250                0x732c69394548a76a,
6251                fidl::encoding::DynamicFlags::empty(),
6252                _decode,
6253            )
6254    }
6255
6256    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6257        self.client.send::<fidl::encoding::EmptyPayload>(
6258            (),
6259            0x5dab12b50bc9909d,
6260            fidl::encoding::DynamicFlags::empty(),
6261        )
6262    }
6263}
6264
6265pub struct LinuxManagerEventStream {
6266    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6267}
6268
6269impl std::marker::Unpin for LinuxManagerEventStream {}
6270
6271impl futures::stream::FusedStream for LinuxManagerEventStream {
6272    fn is_terminated(&self) -> bool {
6273        self.event_receiver.is_terminated()
6274    }
6275}
6276
6277impl futures::Stream for LinuxManagerEventStream {
6278    type Item = Result<LinuxManagerEvent, fidl::Error>;
6279
6280    fn poll_next(
6281        mut self: std::pin::Pin<&mut Self>,
6282        cx: &mut std::task::Context<'_>,
6283    ) -> std::task::Poll<Option<Self::Item>> {
6284        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6285            &mut self.event_receiver,
6286            cx
6287        )?) {
6288            Some(buf) => std::task::Poll::Ready(Some(LinuxManagerEvent::decode(buf))),
6289            None => std::task::Poll::Ready(None),
6290        }
6291    }
6292}
6293
6294#[derive(Debug)]
6295pub enum LinuxManagerEvent {
6296    OnGuestInfoChanged { label: String, info: LinuxGuestInfo },
6297}
6298
6299impl LinuxManagerEvent {
6300    #[allow(irrefutable_let_patterns)]
6301    pub fn into_on_guest_info_changed(self) -> Option<(String, LinuxGuestInfo)> {
6302        if let LinuxManagerEvent::OnGuestInfoChanged { label, info } = self {
6303            Some((label, info))
6304        } else {
6305            None
6306        }
6307    }
6308
6309    /// Decodes a message buffer as a [`LinuxManagerEvent`].
6310    fn decode(
6311        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6312    ) -> Result<LinuxManagerEvent, fidl::Error> {
6313        let (bytes, _handles) = buf.split_mut();
6314        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6315        debug_assert_eq!(tx_header.tx_id, 0);
6316        match tx_header.ordinal {
6317            0x30a9be4c43d6a2d6 => {
6318                let mut out = fidl::new_empty!(
6319                    LinuxManagerOnGuestInfoChangedRequest,
6320                    fidl::encoding::DefaultFuchsiaResourceDialect
6321                );
6322                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerOnGuestInfoChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6323                Ok((LinuxManagerEvent::OnGuestInfoChanged { label: out.label, info: out.info }))
6324            }
6325            _ => Err(fidl::Error::UnknownOrdinal {
6326                ordinal: tx_header.ordinal,
6327                protocol_name: <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6328            }),
6329        }
6330    }
6331}
6332
6333/// A Stream of incoming requests for fuchsia.virtualization/LinuxManager.
6334pub struct LinuxManagerRequestStream {
6335    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6336    is_terminated: bool,
6337}
6338
6339impl std::marker::Unpin for LinuxManagerRequestStream {}
6340
6341impl futures::stream::FusedStream for LinuxManagerRequestStream {
6342    fn is_terminated(&self) -> bool {
6343        self.is_terminated
6344    }
6345}
6346
6347impl fidl::endpoints::RequestStream for LinuxManagerRequestStream {
6348    type Protocol = LinuxManagerMarker;
6349    type ControlHandle = LinuxManagerControlHandle;
6350
6351    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6352        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6353    }
6354
6355    fn control_handle(&self) -> Self::ControlHandle {
6356        LinuxManagerControlHandle { inner: self.inner.clone() }
6357    }
6358
6359    fn into_inner(
6360        self,
6361    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6362    {
6363        (self.inner, self.is_terminated)
6364    }
6365
6366    fn from_inner(
6367        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6368        is_terminated: bool,
6369    ) -> Self {
6370        Self { inner, is_terminated }
6371    }
6372}
6373
6374impl futures::Stream for LinuxManagerRequestStream {
6375    type Item = Result<LinuxManagerRequest, fidl::Error>;
6376
6377    fn poll_next(
6378        mut self: std::pin::Pin<&mut Self>,
6379        cx: &mut std::task::Context<'_>,
6380    ) -> std::task::Poll<Option<Self::Item>> {
6381        let this = &mut *self;
6382        if this.inner.check_shutdown(cx) {
6383            this.is_terminated = true;
6384            return std::task::Poll::Ready(None);
6385        }
6386        if this.is_terminated {
6387            panic!("polled LinuxManagerRequestStream after completion");
6388        }
6389        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6390            |bytes, handles| {
6391                match this.inner.channel().read_etc(cx, bytes, handles) {
6392                    std::task::Poll::Ready(Ok(())) => {}
6393                    std::task::Poll::Pending => return std::task::Poll::Pending,
6394                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6395                        this.is_terminated = true;
6396                        return std::task::Poll::Ready(None);
6397                    }
6398                    std::task::Poll::Ready(Err(e)) => {
6399                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6400                            e.into(),
6401                        ))));
6402                    }
6403                }
6404
6405                // A message has been received from the channel
6406                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6407
6408                std::task::Poll::Ready(Some(match header.ordinal {
6409                    0x11809ced100a2bea => {
6410                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6411                        let mut req = fidl::new_empty!(
6412                            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6413                            fidl::encoding::DefaultFuchsiaResourceDialect
6414                        );
6415                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerStartAndGetLinuxGuestInfoRequest>(&header, _body_bytes, handles, &mut req)?;
6416                        let control_handle =
6417                            LinuxManagerControlHandle { inner: this.inner.clone() };
6418                        Ok(LinuxManagerRequest::StartAndGetLinuxGuestInfo {
6419                            label: req.label,
6420
6421                            responder: LinuxManagerStartAndGetLinuxGuestInfoResponder {
6422                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6423                                tx_id: header.tx_id,
6424                            },
6425                        })
6426                    }
6427                    0x732c69394548a76a => {
6428                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6429                        let mut req = fidl::new_empty!(
6430                            fidl::encoding::EmptyPayload,
6431                            fidl::encoding::DefaultFuchsiaResourceDialect
6432                        );
6433                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6434                        let control_handle =
6435                            LinuxManagerControlHandle { inner: this.inner.clone() };
6436                        Ok(LinuxManagerRequest::WipeData {
6437                            responder: LinuxManagerWipeDataResponder {
6438                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6439                                tx_id: header.tx_id,
6440                            },
6441                        })
6442                    }
6443                    0x5dab12b50bc9909d => {
6444                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6445                        let mut req = fidl::new_empty!(
6446                            fidl::encoding::EmptyPayload,
6447                            fidl::encoding::DefaultFuchsiaResourceDialect
6448                        );
6449                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6450                        let control_handle =
6451                            LinuxManagerControlHandle { inner: this.inner.clone() };
6452                        Ok(LinuxManagerRequest::GracefulShutdown { control_handle })
6453                    }
6454                    _ => Err(fidl::Error::UnknownOrdinal {
6455                        ordinal: header.ordinal,
6456                        protocol_name:
6457                            <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6458                    }),
6459                }))
6460            },
6461        )
6462    }
6463}
6464
6465/// A `LinuxManager` provides access to the status of Linux guest instances.
6466#[derive(Debug)]
6467pub enum LinuxManagerRequest {
6468    /// Get Linux guest environment info.
6469    ///
6470    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6471    StartAndGetLinuxGuestInfo {
6472        label: String,
6473        responder: LinuxManagerStartAndGetLinuxGuestInfoResponder,
6474    },
6475    /// Clears the stateful data. This includes any installed containers and any user data
6476    /// they may contain.
6477    ///
6478    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6479    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6480    /// operation.
6481    WipeData { responder: LinuxManagerWipeDataResponder },
6482    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6483    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6484    /// the epitaph) before attempting to launch another guest.
6485    ///
6486    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6487    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6488    /// a component crash).
6489    GracefulShutdown { control_handle: LinuxManagerControlHandle },
6490}
6491
6492impl LinuxManagerRequest {
6493    #[allow(irrefutable_let_patterns)]
6494    pub fn into_start_and_get_linux_guest_info(
6495        self,
6496    ) -> Option<(String, LinuxManagerStartAndGetLinuxGuestInfoResponder)> {
6497        if let LinuxManagerRequest::StartAndGetLinuxGuestInfo { label, responder } = self {
6498            Some((label, responder))
6499        } else {
6500            None
6501        }
6502    }
6503
6504    #[allow(irrefutable_let_patterns)]
6505    pub fn into_wipe_data(self) -> Option<(LinuxManagerWipeDataResponder)> {
6506        if let LinuxManagerRequest::WipeData { responder } = self {
6507            Some((responder))
6508        } else {
6509            None
6510        }
6511    }
6512
6513    #[allow(irrefutable_let_patterns)]
6514    pub fn into_graceful_shutdown(self) -> Option<(LinuxManagerControlHandle)> {
6515        if let LinuxManagerRequest::GracefulShutdown { control_handle } = self {
6516            Some((control_handle))
6517        } else {
6518            None
6519        }
6520    }
6521
6522    /// Name of the method defined in FIDL
6523    pub fn method_name(&self) -> &'static str {
6524        match *self {
6525            LinuxManagerRequest::StartAndGetLinuxGuestInfo { .. } => {
6526                "start_and_get_linux_guest_info"
6527            }
6528            LinuxManagerRequest::WipeData { .. } => "wipe_data",
6529            LinuxManagerRequest::GracefulShutdown { .. } => "graceful_shutdown",
6530        }
6531    }
6532}
6533
6534#[derive(Debug, Clone)]
6535pub struct LinuxManagerControlHandle {
6536    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6537}
6538
6539impl fidl::endpoints::ControlHandle for LinuxManagerControlHandle {
6540    fn shutdown(&self) {
6541        self.inner.shutdown()
6542    }
6543    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6544        self.inner.shutdown_with_epitaph(status)
6545    }
6546
6547    fn is_closed(&self) -> bool {
6548        self.inner.channel().is_closed()
6549    }
6550    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6551        self.inner.channel().on_closed()
6552    }
6553
6554    #[cfg(target_os = "fuchsia")]
6555    fn signal_peer(
6556        &self,
6557        clear_mask: zx::Signals,
6558        set_mask: zx::Signals,
6559    ) -> Result<(), zx_status::Status> {
6560        use fidl::Peered;
6561        self.inner.channel().signal_peer(clear_mask, set_mask)
6562    }
6563}
6564
6565impl LinuxManagerControlHandle {
6566    pub fn send_on_guest_info_changed(
6567        &self,
6568        mut label: &str,
6569        mut info: &LinuxGuestInfo,
6570    ) -> Result<(), fidl::Error> {
6571        self.inner.send::<LinuxManagerOnGuestInfoChangedRequest>(
6572            (label, info),
6573            0,
6574            0x30a9be4c43d6a2d6,
6575            fidl::encoding::DynamicFlags::empty(),
6576        )
6577    }
6578}
6579
6580#[must_use = "FIDL methods require a response to be sent"]
6581#[derive(Debug)]
6582pub struct LinuxManagerStartAndGetLinuxGuestInfoResponder {
6583    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6584    tx_id: u32,
6585}
6586
6587/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6588/// if the responder is dropped without sending a response, so that the client
6589/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6590impl std::ops::Drop for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6591    fn drop(&mut self) {
6592        self.control_handle.shutdown();
6593        // Safety: drops once, never accessed again
6594        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6595    }
6596}
6597
6598impl fidl::endpoints::Responder for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6599    type ControlHandle = LinuxManagerControlHandle;
6600
6601    fn control_handle(&self) -> &LinuxManagerControlHandle {
6602        &self.control_handle
6603    }
6604
6605    fn drop_without_shutdown(mut self) {
6606        // Safety: drops once, never accessed again due to mem::forget
6607        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6608        // Prevent Drop from running (which would shut down the channel)
6609        std::mem::forget(self);
6610    }
6611}
6612
6613impl LinuxManagerStartAndGetLinuxGuestInfoResponder {
6614    /// Sends a response to the FIDL transaction.
6615    ///
6616    /// Sets the channel to shutdown if an error occurs.
6617    pub fn send(self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6618        let _result = self.send_raw(result);
6619        if _result.is_err() {
6620            self.control_handle.shutdown();
6621        }
6622        self.drop_without_shutdown();
6623        _result
6624    }
6625
6626    /// Similar to "send" but does not shutdown the channel if an error occurs.
6627    pub fn send_no_shutdown_on_err(
6628        self,
6629        mut result: Result<&LinuxGuestInfo, i32>,
6630    ) -> Result<(), fidl::Error> {
6631        let _result = self.send_raw(result);
6632        self.drop_without_shutdown();
6633        _result
6634    }
6635
6636    fn send_raw(&self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6637        self.control_handle.inner.send::<fidl::encoding::ResultType<
6638            LinuxManagerStartAndGetLinuxGuestInfoResponse,
6639            i32,
6640        >>(
6641            result.map(|info| (info,)),
6642            self.tx_id,
6643            0x11809ced100a2bea,
6644            fidl::encoding::DynamicFlags::empty(),
6645        )
6646    }
6647}
6648
6649#[must_use = "FIDL methods require a response to be sent"]
6650#[derive(Debug)]
6651pub struct LinuxManagerWipeDataResponder {
6652    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6653    tx_id: u32,
6654}
6655
6656/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6657/// if the responder is dropped without sending a response, so that the client
6658/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6659impl std::ops::Drop for LinuxManagerWipeDataResponder {
6660    fn drop(&mut self) {
6661        self.control_handle.shutdown();
6662        // Safety: drops once, never accessed again
6663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6664    }
6665}
6666
6667impl fidl::endpoints::Responder for LinuxManagerWipeDataResponder {
6668    type ControlHandle = LinuxManagerControlHandle;
6669
6670    fn control_handle(&self) -> &LinuxManagerControlHandle {
6671        &self.control_handle
6672    }
6673
6674    fn drop_without_shutdown(mut self) {
6675        // Safety: drops once, never accessed again due to mem::forget
6676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6677        // Prevent Drop from running (which would shut down the channel)
6678        std::mem::forget(self);
6679    }
6680}
6681
6682impl LinuxManagerWipeDataResponder {
6683    /// Sends a response to the FIDL transaction.
6684    ///
6685    /// Sets the channel to shutdown if an error occurs.
6686    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6687        let _result = self.send_raw(result);
6688        if _result.is_err() {
6689            self.control_handle.shutdown();
6690        }
6691        self.drop_without_shutdown();
6692        _result
6693    }
6694
6695    /// Similar to "send" but does not shutdown the channel if an error occurs.
6696    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6697        let _result = self.send_raw(result);
6698        self.drop_without_shutdown();
6699        _result
6700    }
6701
6702    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6703        self.control_handle
6704            .inner
6705            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6706                result,
6707                self.tx_id,
6708                0x732c69394548a76a,
6709                fidl::encoding::DynamicFlags::empty(),
6710            )
6711    }
6712}
6713
6714#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6715pub struct MemControllerMarker;
6716
6717impl fidl::endpoints::ProtocolMarker for MemControllerMarker {
6718    type Proxy = MemControllerProxy;
6719    type RequestStream = MemControllerRequestStream;
6720    #[cfg(target_os = "fuchsia")]
6721    type SynchronousProxy = MemControllerSynchronousProxy;
6722
6723    const DEBUG_NAME: &'static str = "fuchsia.virtualization.MemController";
6724}
6725impl fidl::endpoints::DiscoverableProtocolMarker for MemControllerMarker {}
6726
6727pub trait MemControllerProxyInterface: Send + Sync {
6728    type GetMemSizeResponseFut: std::future::Future<Output = Result<(u64, u64, u64, u64, u64), fidl::Error>>
6729        + Send;
6730    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut;
6731    fn r#request_size(&self, requested_size: u64) -> Result<(), fidl::Error>;
6732}
6733#[derive(Debug)]
6734#[cfg(target_os = "fuchsia")]
6735pub struct MemControllerSynchronousProxy {
6736    client: fidl::client::sync::Client,
6737}
6738
6739#[cfg(target_os = "fuchsia")]
6740impl fidl::endpoints::SynchronousProxy for MemControllerSynchronousProxy {
6741    type Proxy = MemControllerProxy;
6742    type Protocol = MemControllerMarker;
6743
6744    fn from_channel(inner: fidl::Channel) -> Self {
6745        Self::new(inner)
6746    }
6747
6748    fn into_channel(self) -> fidl::Channel {
6749        self.client.into_channel()
6750    }
6751
6752    fn as_channel(&self) -> &fidl::Channel {
6753        self.client.as_channel()
6754    }
6755}
6756
6757#[cfg(target_os = "fuchsia")]
6758impl MemControllerSynchronousProxy {
6759    pub fn new(channel: fidl::Channel) -> Self {
6760        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6761        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6762    }
6763
6764    pub fn into_channel(self) -> fidl::Channel {
6765        self.client.into_channel()
6766    }
6767
6768    /// Waits until an event arrives and returns it. It is safe for other
6769    /// threads to make concurrent requests while waiting for an event.
6770    pub fn wait_for_event(
6771        &self,
6772        deadline: zx::MonotonicInstant,
6773    ) -> Result<MemControllerEvent, fidl::Error> {
6774        MemControllerEvent::decode(self.client.wait_for_event(deadline)?)
6775    }
6776
6777    /// Get the configured region size, usable region size, plugged size and requestd size
6778    ///
6779    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6780    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6781    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6782    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6783    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6784    /// memory region.
6785    /// requested_size is the requested amount of plugged memory within the usable device-managed
6786    /// memory region.
6787    pub fn r#get_mem_size(
6788        &self,
6789        ___deadline: zx::MonotonicInstant,
6790    ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6791        let _response = self
6792            .client
6793            .send_query::<fidl::encoding::EmptyPayload, MemControllerGetMemSizeResponse>(
6794                (),
6795                0x6e9d496f9b66ea56,
6796                fidl::encoding::DynamicFlags::empty(),
6797                ___deadline,
6798            )?;
6799        Ok((
6800            _response.block_size,
6801            _response.region_size,
6802            _response.usable_region_size,
6803            _response.plugged_size,
6804            _response.requested_size,
6805        ))
6806    }
6807
6808    /// Update the requested size to plug or unplug memory
6809    ///
6810    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6811    /// configuration changed) by (un)plugging memory blocks.
6812    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6813        self.client.send::<MemControllerRequestSizeRequest>(
6814            (requested_size,),
6815            0x12f8e2cc21ee8102,
6816            fidl::encoding::DynamicFlags::empty(),
6817        )
6818    }
6819}
6820
6821#[cfg(target_os = "fuchsia")]
6822impl From<MemControllerSynchronousProxy> for zx::Handle {
6823    fn from(value: MemControllerSynchronousProxy) -> Self {
6824        value.into_channel().into()
6825    }
6826}
6827
6828#[cfg(target_os = "fuchsia")]
6829impl From<fidl::Channel> for MemControllerSynchronousProxy {
6830    fn from(value: fidl::Channel) -> Self {
6831        Self::new(value)
6832    }
6833}
6834
6835#[cfg(target_os = "fuchsia")]
6836impl fidl::endpoints::FromClient for MemControllerSynchronousProxy {
6837    type Protocol = MemControllerMarker;
6838
6839    fn from_client(value: fidl::endpoints::ClientEnd<MemControllerMarker>) -> Self {
6840        Self::new(value.into_channel())
6841    }
6842}
6843
6844#[derive(Debug, Clone)]
6845pub struct MemControllerProxy {
6846    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6847}
6848
6849impl fidl::endpoints::Proxy for MemControllerProxy {
6850    type Protocol = MemControllerMarker;
6851
6852    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6853        Self::new(inner)
6854    }
6855
6856    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6857        self.client.into_channel().map_err(|client| Self { client })
6858    }
6859
6860    fn as_channel(&self) -> &::fidl::AsyncChannel {
6861        self.client.as_channel()
6862    }
6863}
6864
6865impl MemControllerProxy {
6866    /// Create a new Proxy for fuchsia.virtualization/MemController.
6867    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6868        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6869        Self { client: fidl::client::Client::new(channel, protocol_name) }
6870    }
6871
6872    /// Get a Stream of events from the remote end of the protocol.
6873    ///
6874    /// # Panics
6875    ///
6876    /// Panics if the event stream was already taken.
6877    pub fn take_event_stream(&self) -> MemControllerEventStream {
6878        MemControllerEventStream { event_receiver: self.client.take_event_receiver() }
6879    }
6880
6881    /// Get the configured region size, usable region size, plugged size and requestd size
6882    ///
6883    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6884    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6885    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6886    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6887    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6888    /// memory region.
6889    /// requested_size is the requested amount of plugged memory within the usable device-managed
6890    /// memory region.
6891    pub fn r#get_mem_size(
6892        &self,
6893    ) -> fidl::client::QueryResponseFut<
6894        (u64, u64, u64, u64, u64),
6895        fidl::encoding::DefaultFuchsiaResourceDialect,
6896    > {
6897        MemControllerProxyInterface::r#get_mem_size(self)
6898    }
6899
6900    /// Update the requested size to plug or unplug memory
6901    ///
6902    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6903    /// configuration changed) by (un)plugging memory blocks.
6904    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6905        MemControllerProxyInterface::r#request_size(self, requested_size)
6906    }
6907}
6908
6909impl MemControllerProxyInterface for MemControllerProxy {
6910    type GetMemSizeResponseFut = fidl::client::QueryResponseFut<
6911        (u64, u64, u64, u64, u64),
6912        fidl::encoding::DefaultFuchsiaResourceDialect,
6913    >;
6914    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut {
6915        fn _decode(
6916            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6917        ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6918            let _response = fidl::client::decode_transaction_body::<
6919                MemControllerGetMemSizeResponse,
6920                fidl::encoding::DefaultFuchsiaResourceDialect,
6921                0x6e9d496f9b66ea56,
6922            >(_buf?)?;
6923            Ok((
6924                _response.block_size,
6925                _response.region_size,
6926                _response.usable_region_size,
6927                _response.plugged_size,
6928                _response.requested_size,
6929            ))
6930        }
6931        self.client
6932            .send_query_and_decode::<fidl::encoding::EmptyPayload, (u64, u64, u64, u64, u64)>(
6933                (),
6934                0x6e9d496f9b66ea56,
6935                fidl::encoding::DynamicFlags::empty(),
6936                _decode,
6937            )
6938    }
6939
6940    fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6941        self.client.send::<MemControllerRequestSizeRequest>(
6942            (requested_size,),
6943            0x12f8e2cc21ee8102,
6944            fidl::encoding::DynamicFlags::empty(),
6945        )
6946    }
6947}
6948
6949pub struct MemControllerEventStream {
6950    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6951}
6952
6953impl std::marker::Unpin for MemControllerEventStream {}
6954
6955impl futures::stream::FusedStream for MemControllerEventStream {
6956    fn is_terminated(&self) -> bool {
6957        self.event_receiver.is_terminated()
6958    }
6959}
6960
6961impl futures::Stream for MemControllerEventStream {
6962    type Item = Result<MemControllerEvent, fidl::Error>;
6963
6964    fn poll_next(
6965        mut self: std::pin::Pin<&mut Self>,
6966        cx: &mut std::task::Context<'_>,
6967    ) -> std::task::Poll<Option<Self::Item>> {
6968        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6969            &mut self.event_receiver,
6970            cx
6971        )?) {
6972            Some(buf) => std::task::Poll::Ready(Some(MemControllerEvent::decode(buf))),
6973            None => std::task::Poll::Ready(None),
6974        }
6975    }
6976}
6977
6978#[derive(Debug)]
6979pub enum MemControllerEvent {}
6980
6981impl MemControllerEvent {
6982    /// Decodes a message buffer as a [`MemControllerEvent`].
6983    fn decode(
6984        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6985    ) -> Result<MemControllerEvent, fidl::Error> {
6986        let (bytes, _handles) = buf.split_mut();
6987        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6988        debug_assert_eq!(tx_header.tx_id, 0);
6989        match tx_header.ordinal {
6990            _ => Err(fidl::Error::UnknownOrdinal {
6991                ordinal: tx_header.ordinal,
6992                protocol_name: <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6993            }),
6994        }
6995    }
6996}
6997
6998/// A Stream of incoming requests for fuchsia.virtualization/MemController.
6999pub struct MemControllerRequestStream {
7000    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7001    is_terminated: bool,
7002}
7003
7004impl std::marker::Unpin for MemControllerRequestStream {}
7005
7006impl futures::stream::FusedStream for MemControllerRequestStream {
7007    fn is_terminated(&self) -> bool {
7008        self.is_terminated
7009    }
7010}
7011
7012impl fidl::endpoints::RequestStream for MemControllerRequestStream {
7013    type Protocol = MemControllerMarker;
7014    type ControlHandle = MemControllerControlHandle;
7015
7016    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7017        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7018    }
7019
7020    fn control_handle(&self) -> Self::ControlHandle {
7021        MemControllerControlHandle { inner: self.inner.clone() }
7022    }
7023
7024    fn into_inner(
7025        self,
7026    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7027    {
7028        (self.inner, self.is_terminated)
7029    }
7030
7031    fn from_inner(
7032        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7033        is_terminated: bool,
7034    ) -> Self {
7035        Self { inner, is_terminated }
7036    }
7037}
7038
7039impl futures::Stream for MemControllerRequestStream {
7040    type Item = Result<MemControllerRequest, fidl::Error>;
7041
7042    fn poll_next(
7043        mut self: std::pin::Pin<&mut Self>,
7044        cx: &mut std::task::Context<'_>,
7045    ) -> std::task::Poll<Option<Self::Item>> {
7046        let this = &mut *self;
7047        if this.inner.check_shutdown(cx) {
7048            this.is_terminated = true;
7049            return std::task::Poll::Ready(None);
7050        }
7051        if this.is_terminated {
7052            panic!("polled MemControllerRequestStream after completion");
7053        }
7054        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7055            |bytes, handles| {
7056                match this.inner.channel().read_etc(cx, bytes, handles) {
7057                    std::task::Poll::Ready(Ok(())) => {}
7058                    std::task::Poll::Pending => return std::task::Poll::Pending,
7059                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7060                        this.is_terminated = true;
7061                        return std::task::Poll::Ready(None);
7062                    }
7063                    std::task::Poll::Ready(Err(e)) => {
7064                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7065                            e.into(),
7066                        ))));
7067                    }
7068                }
7069
7070                // A message has been received from the channel
7071                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7072
7073                std::task::Poll::Ready(Some(match header.ordinal {
7074                    0x6e9d496f9b66ea56 => {
7075                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7076                        let mut req = fidl::new_empty!(
7077                            fidl::encoding::EmptyPayload,
7078                            fidl::encoding::DefaultFuchsiaResourceDialect
7079                        );
7080                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7081                        let control_handle =
7082                            MemControllerControlHandle { inner: this.inner.clone() };
7083                        Ok(MemControllerRequest::GetMemSize {
7084                            responder: MemControllerGetMemSizeResponder {
7085                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7086                                tx_id: header.tx_id,
7087                            },
7088                        })
7089                    }
7090                    0x12f8e2cc21ee8102 => {
7091                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7092                        let mut req = fidl::new_empty!(
7093                            MemControllerRequestSizeRequest,
7094                            fidl::encoding::DefaultFuchsiaResourceDialect
7095                        );
7096                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MemControllerRequestSizeRequest>(&header, _body_bytes, handles, &mut req)?;
7097                        let control_handle =
7098                            MemControllerControlHandle { inner: this.inner.clone() };
7099                        Ok(MemControllerRequest::RequestSize {
7100                            requested_size: req.requested_size,
7101
7102                            control_handle,
7103                        })
7104                    }
7105                    _ => Err(fidl::Error::UnknownOrdinal {
7106                        ordinal: header.ordinal,
7107                        protocol_name:
7108                            <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7109                    }),
7110                }))
7111            },
7112        )
7113    }
7114}
7115
7116/// A `MemController` controls a guest's virtio-mem
7117#[derive(Debug)]
7118pub enum MemControllerRequest {
7119    /// Get the configured region size, usable region size, plugged size and requestd size
7120    ///
7121    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
7122    /// region_size is the size of device-managed memory region in bytes. Cannot change.
7123    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
7124    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
7125    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
7126    /// memory region.
7127    /// requested_size is the requested amount of plugged memory within the usable device-managed
7128    /// memory region.
7129    GetMemSize { responder: MemControllerGetMemSizeResponder },
7130    /// Update the requested size to plug or unplug memory
7131    ///
7132    /// The driver SHOULD react to resize requests from the device (requested_size in the device
7133    /// configuration changed) by (un)plugging memory blocks.
7134    RequestSize { requested_size: u64, control_handle: MemControllerControlHandle },
7135}
7136
7137impl MemControllerRequest {
7138    #[allow(irrefutable_let_patterns)]
7139    pub fn into_get_mem_size(self) -> Option<(MemControllerGetMemSizeResponder)> {
7140        if let MemControllerRequest::GetMemSize { responder } = self {
7141            Some((responder))
7142        } else {
7143            None
7144        }
7145    }
7146
7147    #[allow(irrefutable_let_patterns)]
7148    pub fn into_request_size(self) -> Option<(u64, MemControllerControlHandle)> {
7149        if let MemControllerRequest::RequestSize { requested_size, control_handle } = self {
7150            Some((requested_size, control_handle))
7151        } else {
7152            None
7153        }
7154    }
7155
7156    /// Name of the method defined in FIDL
7157    pub fn method_name(&self) -> &'static str {
7158        match *self {
7159            MemControllerRequest::GetMemSize { .. } => "get_mem_size",
7160            MemControllerRequest::RequestSize { .. } => "request_size",
7161        }
7162    }
7163}
7164
7165#[derive(Debug, Clone)]
7166pub struct MemControllerControlHandle {
7167    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7168}
7169
7170impl fidl::endpoints::ControlHandle for MemControllerControlHandle {
7171    fn shutdown(&self) {
7172        self.inner.shutdown()
7173    }
7174    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7175        self.inner.shutdown_with_epitaph(status)
7176    }
7177
7178    fn is_closed(&self) -> bool {
7179        self.inner.channel().is_closed()
7180    }
7181    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7182        self.inner.channel().on_closed()
7183    }
7184
7185    #[cfg(target_os = "fuchsia")]
7186    fn signal_peer(
7187        &self,
7188        clear_mask: zx::Signals,
7189        set_mask: zx::Signals,
7190    ) -> Result<(), zx_status::Status> {
7191        use fidl::Peered;
7192        self.inner.channel().signal_peer(clear_mask, set_mask)
7193    }
7194}
7195
7196impl MemControllerControlHandle {}
7197
7198#[must_use = "FIDL methods require a response to be sent"]
7199#[derive(Debug)]
7200pub struct MemControllerGetMemSizeResponder {
7201    control_handle: std::mem::ManuallyDrop<MemControllerControlHandle>,
7202    tx_id: u32,
7203}
7204
7205/// Set the the channel to be shutdown (see [`MemControllerControlHandle::shutdown`])
7206/// if the responder is dropped without sending a response, so that the client
7207/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7208impl std::ops::Drop for MemControllerGetMemSizeResponder {
7209    fn drop(&mut self) {
7210        self.control_handle.shutdown();
7211        // Safety: drops once, never accessed again
7212        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7213    }
7214}
7215
7216impl fidl::endpoints::Responder for MemControllerGetMemSizeResponder {
7217    type ControlHandle = MemControllerControlHandle;
7218
7219    fn control_handle(&self) -> &MemControllerControlHandle {
7220        &self.control_handle
7221    }
7222
7223    fn drop_without_shutdown(mut self) {
7224        // Safety: drops once, never accessed again due to mem::forget
7225        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7226        // Prevent Drop from running (which would shut down the channel)
7227        std::mem::forget(self);
7228    }
7229}
7230
7231impl MemControllerGetMemSizeResponder {
7232    /// Sends a response to the FIDL transaction.
7233    ///
7234    /// Sets the channel to shutdown if an error occurs.
7235    pub fn send(
7236        self,
7237        mut block_size: u64,
7238        mut region_size: u64,
7239        mut usable_region_size: u64,
7240        mut plugged_size: u64,
7241        mut requested_size: u64,
7242    ) -> Result<(), fidl::Error> {
7243        let _result = self.send_raw(
7244            block_size,
7245            region_size,
7246            usable_region_size,
7247            plugged_size,
7248            requested_size,
7249        );
7250        if _result.is_err() {
7251            self.control_handle.shutdown();
7252        }
7253        self.drop_without_shutdown();
7254        _result
7255    }
7256
7257    /// Similar to "send" but does not shutdown the channel if an error occurs.
7258    pub fn send_no_shutdown_on_err(
7259        self,
7260        mut block_size: u64,
7261        mut region_size: u64,
7262        mut usable_region_size: u64,
7263        mut plugged_size: u64,
7264        mut requested_size: u64,
7265    ) -> Result<(), fidl::Error> {
7266        let _result = self.send_raw(
7267            block_size,
7268            region_size,
7269            usable_region_size,
7270            plugged_size,
7271            requested_size,
7272        );
7273        self.drop_without_shutdown();
7274        _result
7275    }
7276
7277    fn send_raw(
7278        &self,
7279        mut block_size: u64,
7280        mut region_size: u64,
7281        mut usable_region_size: u64,
7282        mut plugged_size: u64,
7283        mut requested_size: u64,
7284    ) -> Result<(), fidl::Error> {
7285        self.control_handle.inner.send::<MemControllerGetMemSizeResponse>(
7286            (block_size, region_size, usable_region_size, plugged_size, requested_size),
7287            self.tx_id,
7288            0x6e9d496f9b66ea56,
7289            fidl::encoding::DynamicFlags::empty(),
7290        )
7291    }
7292}
7293
7294#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7295pub struct TerminaGuestManagerMarker;
7296
7297impl fidl::endpoints::ProtocolMarker for TerminaGuestManagerMarker {
7298    type Proxy = TerminaGuestManagerProxy;
7299    type RequestStream = TerminaGuestManagerRequestStream;
7300    #[cfg(target_os = "fuchsia")]
7301    type SynchronousProxy = TerminaGuestManagerSynchronousProxy;
7302
7303    const DEBUG_NAME: &'static str = "fuchsia.virtualization.TerminaGuestManager";
7304}
7305impl fidl::endpoints::DiscoverableProtocolMarker for TerminaGuestManagerMarker {}
7306
7307pub trait TerminaGuestManagerProxyInterface: Send + Sync {
7308    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
7309        + Send;
7310    fn r#launch(
7311        &self,
7312        guest_config: GuestConfig,
7313        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7314    ) -> Self::LaunchResponseFut;
7315    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7316    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
7317    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
7318        + Send;
7319    fn r#connect(
7320        &self,
7321        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7322    ) -> Self::ConnectResponseFut;
7323    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
7324    fn r#get_info(&self) -> Self::GetInfoResponseFut;
7325}
7326#[derive(Debug)]
7327#[cfg(target_os = "fuchsia")]
7328pub struct TerminaGuestManagerSynchronousProxy {
7329    client: fidl::client::sync::Client,
7330}
7331
7332#[cfg(target_os = "fuchsia")]
7333impl fidl::endpoints::SynchronousProxy for TerminaGuestManagerSynchronousProxy {
7334    type Proxy = TerminaGuestManagerProxy;
7335    type Protocol = TerminaGuestManagerMarker;
7336
7337    fn from_channel(inner: fidl::Channel) -> Self {
7338        Self::new(inner)
7339    }
7340
7341    fn into_channel(self) -> fidl::Channel {
7342        self.client.into_channel()
7343    }
7344
7345    fn as_channel(&self) -> &fidl::Channel {
7346        self.client.as_channel()
7347    }
7348}
7349
7350#[cfg(target_os = "fuchsia")]
7351impl TerminaGuestManagerSynchronousProxy {
7352    pub fn new(channel: fidl::Channel) -> Self {
7353        let protocol_name =
7354            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7355        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7356    }
7357
7358    pub fn into_channel(self) -> fidl::Channel {
7359        self.client.into_channel()
7360    }
7361
7362    /// Waits until an event arrives and returns it. It is safe for other
7363    /// threads to make concurrent requests while waiting for an event.
7364    pub fn wait_for_event(
7365        &self,
7366        deadline: zx::MonotonicInstant,
7367    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7368        TerminaGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
7369    }
7370
7371    /// Launch a new guest instance.
7372    ///
7373    /// Possible errors:
7374    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7375    ///         problems detected by the guest manager.
7376    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7377    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7378    ///         component logs for a more specific failure.
7379    pub fn r#launch(
7380        &self,
7381        mut guest_config: GuestConfig,
7382        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7383        ___deadline: zx::MonotonicInstant,
7384    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7385        let _response =
7386            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
7387                fidl::encoding::EmptyStruct,
7388                GuestManagerError,
7389            >>(
7390                (&mut guest_config, controller),
7391                0x394a2e29f750323e,
7392                fidl::encoding::DynamicFlags::empty(),
7393                ___deadline,
7394            )?;
7395        Ok(_response.map(|x| x))
7396    }
7397
7398    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7399    /// be used to launch another guest.
7400    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
7401        let _response =
7402            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
7403                (),
7404                0x3ad9a012982f872d,
7405                fidl::encoding::DynamicFlags::empty(),
7406                ___deadline,
7407            )?;
7408        Ok(_response)
7409    }
7410
7411    /// Connect to a currently running guest.
7412    ///
7413    /// Possible errors:
7414    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7415    ///         has launched before attempting to reconnect.
7416    pub fn r#connect(
7417        &self,
7418        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7419        ___deadline: zx::MonotonicInstant,
7420    ) -> Result<GuestManagerConnectResult, fidl::Error> {
7421        let _response =
7422            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
7423                fidl::encoding::EmptyStruct,
7424                GuestManagerError,
7425            >>(
7426                (controller,),
7427                0x4e489076e3bb15b4,
7428                fidl::encoding::DynamicFlags::empty(),
7429                ___deadline,
7430            )?;
7431        Ok(_response.map(|x| x))
7432    }
7433
7434    /// Query guest info
7435    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
7436        let _response =
7437            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
7438                (),
7439                0x76892614aea695dc,
7440                fidl::encoding::DynamicFlags::empty(),
7441                ___deadline,
7442            )?;
7443        Ok(_response.guest_info)
7444    }
7445}
7446
7447#[cfg(target_os = "fuchsia")]
7448impl From<TerminaGuestManagerSynchronousProxy> for zx::Handle {
7449    fn from(value: TerminaGuestManagerSynchronousProxy) -> Self {
7450        value.into_channel().into()
7451    }
7452}
7453
7454#[cfg(target_os = "fuchsia")]
7455impl From<fidl::Channel> for TerminaGuestManagerSynchronousProxy {
7456    fn from(value: fidl::Channel) -> Self {
7457        Self::new(value)
7458    }
7459}
7460
7461#[cfg(target_os = "fuchsia")]
7462impl fidl::endpoints::FromClient for TerminaGuestManagerSynchronousProxy {
7463    type Protocol = TerminaGuestManagerMarker;
7464
7465    fn from_client(value: fidl::endpoints::ClientEnd<TerminaGuestManagerMarker>) -> Self {
7466        Self::new(value.into_channel())
7467    }
7468}
7469
7470#[derive(Debug, Clone)]
7471pub struct TerminaGuestManagerProxy {
7472    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7473}
7474
7475impl fidl::endpoints::Proxy for TerminaGuestManagerProxy {
7476    type Protocol = TerminaGuestManagerMarker;
7477
7478    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7479        Self::new(inner)
7480    }
7481
7482    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7483        self.client.into_channel().map_err(|client| Self { client })
7484    }
7485
7486    fn as_channel(&self) -> &::fidl::AsyncChannel {
7487        self.client.as_channel()
7488    }
7489}
7490
7491impl TerminaGuestManagerProxy {
7492    /// Create a new Proxy for fuchsia.virtualization/TerminaGuestManager.
7493    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7494        let protocol_name =
7495            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7496        Self { client: fidl::client::Client::new(channel, protocol_name) }
7497    }
7498
7499    /// Get a Stream of events from the remote end of the protocol.
7500    ///
7501    /// # Panics
7502    ///
7503    /// Panics if the event stream was already taken.
7504    pub fn take_event_stream(&self) -> TerminaGuestManagerEventStream {
7505        TerminaGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
7506    }
7507
7508    /// Launch a new guest instance.
7509    ///
7510    /// Possible errors:
7511    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7512    ///         problems detected by the guest manager.
7513    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7514    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7515    ///         component logs for a more specific failure.
7516    pub fn r#launch(
7517        &self,
7518        mut guest_config: GuestConfig,
7519        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7520    ) -> fidl::client::QueryResponseFut<
7521        GuestManagerLaunchResult,
7522        fidl::encoding::DefaultFuchsiaResourceDialect,
7523    > {
7524        TerminaGuestManagerProxyInterface::r#launch(self, guest_config, controller)
7525    }
7526
7527    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7528    /// be used to launch another guest.
7529    pub fn r#force_shutdown(
7530        &self,
7531    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7532        TerminaGuestManagerProxyInterface::r#force_shutdown(self)
7533    }
7534
7535    /// Connect to a currently running guest.
7536    ///
7537    /// Possible errors:
7538    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7539    ///         has launched before attempting to reconnect.
7540    pub fn r#connect(
7541        &self,
7542        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7543    ) -> fidl::client::QueryResponseFut<
7544        GuestManagerConnectResult,
7545        fidl::encoding::DefaultFuchsiaResourceDialect,
7546    > {
7547        TerminaGuestManagerProxyInterface::r#connect(self, controller)
7548    }
7549
7550    /// Query guest info
7551    pub fn r#get_info(
7552        &self,
7553    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
7554    {
7555        TerminaGuestManagerProxyInterface::r#get_info(self)
7556    }
7557}
7558
7559impl TerminaGuestManagerProxyInterface for TerminaGuestManagerProxy {
7560    type LaunchResponseFut = fidl::client::QueryResponseFut<
7561        GuestManagerLaunchResult,
7562        fidl::encoding::DefaultFuchsiaResourceDialect,
7563    >;
7564    fn r#launch(
7565        &self,
7566        mut guest_config: GuestConfig,
7567        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7568    ) -> Self::LaunchResponseFut {
7569        fn _decode(
7570            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7571        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7572            let _response = fidl::client::decode_transaction_body::<
7573                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7574                fidl::encoding::DefaultFuchsiaResourceDialect,
7575                0x394a2e29f750323e,
7576            >(_buf?)?;
7577            Ok(_response.map(|x| x))
7578        }
7579        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
7580            (&mut guest_config, controller),
7581            0x394a2e29f750323e,
7582            fidl::encoding::DynamicFlags::empty(),
7583            _decode,
7584        )
7585    }
7586
7587    type ForceShutdownResponseFut =
7588        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7589    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
7590        fn _decode(
7591            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7592        ) -> Result<(), fidl::Error> {
7593            let _response = fidl::client::decode_transaction_body::<
7594                fidl::encoding::EmptyPayload,
7595                fidl::encoding::DefaultFuchsiaResourceDialect,
7596                0x3ad9a012982f872d,
7597            >(_buf?)?;
7598            Ok(_response)
7599        }
7600        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7601            (),
7602            0x3ad9a012982f872d,
7603            fidl::encoding::DynamicFlags::empty(),
7604            _decode,
7605        )
7606    }
7607
7608    type ConnectResponseFut = fidl::client::QueryResponseFut<
7609        GuestManagerConnectResult,
7610        fidl::encoding::DefaultFuchsiaResourceDialect,
7611    >;
7612    fn r#connect(
7613        &self,
7614        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7615    ) -> Self::ConnectResponseFut {
7616        fn _decode(
7617            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7618        ) -> Result<GuestManagerConnectResult, fidl::Error> {
7619            let _response = fidl::client::decode_transaction_body::<
7620                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7621                fidl::encoding::DefaultFuchsiaResourceDialect,
7622                0x4e489076e3bb15b4,
7623            >(_buf?)?;
7624            Ok(_response.map(|x| x))
7625        }
7626        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
7627            (controller,),
7628            0x4e489076e3bb15b4,
7629            fidl::encoding::DynamicFlags::empty(),
7630            _decode,
7631        )
7632    }
7633
7634    type GetInfoResponseFut =
7635        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
7636    fn r#get_info(&self) -> Self::GetInfoResponseFut {
7637        fn _decode(
7638            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7639        ) -> Result<GuestInfo, fidl::Error> {
7640            let _response = fidl::client::decode_transaction_body::<
7641                GuestManagerGetInfoResponse,
7642                fidl::encoding::DefaultFuchsiaResourceDialect,
7643                0x76892614aea695dc,
7644            >(_buf?)?;
7645            Ok(_response.guest_info)
7646        }
7647        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
7648            (),
7649            0x76892614aea695dc,
7650            fidl::encoding::DynamicFlags::empty(),
7651            _decode,
7652        )
7653    }
7654}
7655
7656pub struct TerminaGuestManagerEventStream {
7657    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7658}
7659
7660impl std::marker::Unpin for TerminaGuestManagerEventStream {}
7661
7662impl futures::stream::FusedStream for TerminaGuestManagerEventStream {
7663    fn is_terminated(&self) -> bool {
7664        self.event_receiver.is_terminated()
7665    }
7666}
7667
7668impl futures::Stream for TerminaGuestManagerEventStream {
7669    type Item = Result<TerminaGuestManagerEvent, fidl::Error>;
7670
7671    fn poll_next(
7672        mut self: std::pin::Pin<&mut Self>,
7673        cx: &mut std::task::Context<'_>,
7674    ) -> std::task::Poll<Option<Self::Item>> {
7675        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7676            &mut self.event_receiver,
7677            cx
7678        )?) {
7679            Some(buf) => std::task::Poll::Ready(Some(TerminaGuestManagerEvent::decode(buf))),
7680            None => std::task::Poll::Ready(None),
7681        }
7682    }
7683}
7684
7685#[derive(Debug)]
7686pub enum TerminaGuestManagerEvent {}
7687
7688impl TerminaGuestManagerEvent {
7689    /// Decodes a message buffer as a [`TerminaGuestManagerEvent`].
7690    fn decode(
7691        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7692    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7693        let (bytes, _handles) = buf.split_mut();
7694        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7695        debug_assert_eq!(tx_header.tx_id, 0);
7696        match tx_header.ordinal {
7697            _ => Err(fidl::Error::UnknownOrdinal {
7698                ordinal: tx_header.ordinal,
7699                protocol_name:
7700                    <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7701            }),
7702        }
7703    }
7704}
7705
7706/// A Stream of incoming requests for fuchsia.virtualization/TerminaGuestManager.
7707pub struct TerminaGuestManagerRequestStream {
7708    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7709    is_terminated: bool,
7710}
7711
7712impl std::marker::Unpin for TerminaGuestManagerRequestStream {}
7713
7714impl futures::stream::FusedStream for TerminaGuestManagerRequestStream {
7715    fn is_terminated(&self) -> bool {
7716        self.is_terminated
7717    }
7718}
7719
7720impl fidl::endpoints::RequestStream for TerminaGuestManagerRequestStream {
7721    type Protocol = TerminaGuestManagerMarker;
7722    type ControlHandle = TerminaGuestManagerControlHandle;
7723
7724    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7725        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7726    }
7727
7728    fn control_handle(&self) -> Self::ControlHandle {
7729        TerminaGuestManagerControlHandle { inner: self.inner.clone() }
7730    }
7731
7732    fn into_inner(
7733        self,
7734    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7735    {
7736        (self.inner, self.is_terminated)
7737    }
7738
7739    fn from_inner(
7740        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7741        is_terminated: bool,
7742    ) -> Self {
7743        Self { inner, is_terminated }
7744    }
7745}
7746
7747impl futures::Stream for TerminaGuestManagerRequestStream {
7748    type Item = Result<TerminaGuestManagerRequest, fidl::Error>;
7749
7750    fn poll_next(
7751        mut self: std::pin::Pin<&mut Self>,
7752        cx: &mut std::task::Context<'_>,
7753    ) -> std::task::Poll<Option<Self::Item>> {
7754        let this = &mut *self;
7755        if this.inner.check_shutdown(cx) {
7756            this.is_terminated = true;
7757            return std::task::Poll::Ready(None);
7758        }
7759        if this.is_terminated {
7760            panic!("polled TerminaGuestManagerRequestStream after completion");
7761        }
7762        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7763            |bytes, handles| {
7764                match this.inner.channel().read_etc(cx, bytes, handles) {
7765                    std::task::Poll::Ready(Ok(())) => {}
7766                    std::task::Poll::Pending => return std::task::Poll::Pending,
7767                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7768                        this.is_terminated = true;
7769                        return std::task::Poll::Ready(None);
7770                    }
7771                    std::task::Poll::Ready(Err(e)) => {
7772                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7773                            e.into(),
7774                        ))));
7775                    }
7776                }
7777
7778                // A message has been received from the channel
7779                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7780
7781                std::task::Poll::Ready(Some(match header.ordinal {
7782                0x394a2e29f750323e => {
7783                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7784                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7785                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
7786                    let control_handle = TerminaGuestManagerControlHandle {
7787                        inner: this.inner.clone(),
7788                    };
7789                    Ok(TerminaGuestManagerRequest::Launch {guest_config: req.guest_config,
7790controller: req.controller,
7791
7792                        responder: TerminaGuestManagerLaunchResponder {
7793                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7794                            tx_id: header.tx_id,
7795                        },
7796                    })
7797                }
7798                0x3ad9a012982f872d => {
7799                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7800                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7801                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7802                    let control_handle = TerminaGuestManagerControlHandle {
7803                        inner: this.inner.clone(),
7804                    };
7805                    Ok(TerminaGuestManagerRequest::ForceShutdown {
7806                        responder: TerminaGuestManagerForceShutdownResponder {
7807                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7808                            tx_id: header.tx_id,
7809                        },
7810                    })
7811                }
7812                0x4e489076e3bb15b4 => {
7813                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7814                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7815                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
7816                    let control_handle = TerminaGuestManagerControlHandle {
7817                        inner: this.inner.clone(),
7818                    };
7819                    Ok(TerminaGuestManagerRequest::Connect {controller: req.controller,
7820
7821                        responder: TerminaGuestManagerConnectResponder {
7822                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7823                            tx_id: header.tx_id,
7824                        },
7825                    })
7826                }
7827                0x76892614aea695dc => {
7828                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7829                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7830                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7831                    let control_handle = TerminaGuestManagerControlHandle {
7832                        inner: this.inner.clone(),
7833                    };
7834                    Ok(TerminaGuestManagerRequest::GetInfo {
7835                        responder: TerminaGuestManagerGetInfoResponder {
7836                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7837                            tx_id: header.tx_id,
7838                        },
7839                    })
7840                }
7841                _ => Err(fidl::Error::UnknownOrdinal {
7842                    ordinal: header.ordinal,
7843                    protocol_name: <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7844                }),
7845            }))
7846            },
7847        )
7848    }
7849}
7850
7851#[derive(Debug)]
7852pub enum TerminaGuestManagerRequest {
7853    /// Launch a new guest instance.
7854    ///
7855    /// Possible errors:
7856    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7857    ///         problems detected by the guest manager.
7858    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7859    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7860    ///         component logs for a more specific failure.
7861    Launch {
7862        guest_config: GuestConfig,
7863        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7864        responder: TerminaGuestManagerLaunchResponder,
7865    },
7866    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7867    /// be used to launch another guest.
7868    ForceShutdown { responder: TerminaGuestManagerForceShutdownResponder },
7869    /// Connect to a currently running guest.
7870    ///
7871    /// Possible errors:
7872    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7873    ///         has launched before attempting to reconnect.
7874    Connect {
7875        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7876        responder: TerminaGuestManagerConnectResponder,
7877    },
7878    /// Query guest info
7879    GetInfo { responder: TerminaGuestManagerGetInfoResponder },
7880}
7881
7882impl TerminaGuestManagerRequest {
7883    #[allow(irrefutable_let_patterns)]
7884    pub fn into_launch(
7885        self,
7886    ) -> Option<(
7887        GuestConfig,
7888        fidl::endpoints::ServerEnd<GuestMarker>,
7889        TerminaGuestManagerLaunchResponder,
7890    )> {
7891        if let TerminaGuestManagerRequest::Launch { guest_config, controller, responder } = self {
7892            Some((guest_config, controller, responder))
7893        } else {
7894            None
7895        }
7896    }
7897
7898    #[allow(irrefutable_let_patterns)]
7899    pub fn into_force_shutdown(self) -> Option<(TerminaGuestManagerForceShutdownResponder)> {
7900        if let TerminaGuestManagerRequest::ForceShutdown { responder } = self {
7901            Some((responder))
7902        } else {
7903            None
7904        }
7905    }
7906
7907    #[allow(irrefutable_let_patterns)]
7908    pub fn into_connect(
7909        self,
7910    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, TerminaGuestManagerConnectResponder)>
7911    {
7912        if let TerminaGuestManagerRequest::Connect { controller, responder } = self {
7913            Some((controller, responder))
7914        } else {
7915            None
7916        }
7917    }
7918
7919    #[allow(irrefutable_let_patterns)]
7920    pub fn into_get_info(self) -> Option<(TerminaGuestManagerGetInfoResponder)> {
7921        if let TerminaGuestManagerRequest::GetInfo { responder } = self {
7922            Some((responder))
7923        } else {
7924            None
7925        }
7926    }
7927
7928    /// Name of the method defined in FIDL
7929    pub fn method_name(&self) -> &'static str {
7930        match *self {
7931            TerminaGuestManagerRequest::Launch { .. } => "launch",
7932            TerminaGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
7933            TerminaGuestManagerRequest::Connect { .. } => "connect",
7934            TerminaGuestManagerRequest::GetInfo { .. } => "get_info",
7935        }
7936    }
7937}
7938
7939#[derive(Debug, Clone)]
7940pub struct TerminaGuestManagerControlHandle {
7941    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7942}
7943
7944impl fidl::endpoints::ControlHandle for TerminaGuestManagerControlHandle {
7945    fn shutdown(&self) {
7946        self.inner.shutdown()
7947    }
7948    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7949        self.inner.shutdown_with_epitaph(status)
7950    }
7951
7952    fn is_closed(&self) -> bool {
7953        self.inner.channel().is_closed()
7954    }
7955    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7956        self.inner.channel().on_closed()
7957    }
7958
7959    #[cfg(target_os = "fuchsia")]
7960    fn signal_peer(
7961        &self,
7962        clear_mask: zx::Signals,
7963        set_mask: zx::Signals,
7964    ) -> Result<(), zx_status::Status> {
7965        use fidl::Peered;
7966        self.inner.channel().signal_peer(clear_mask, set_mask)
7967    }
7968}
7969
7970impl TerminaGuestManagerControlHandle {}
7971
7972#[must_use = "FIDL methods require a response to be sent"]
7973#[derive(Debug)]
7974pub struct TerminaGuestManagerLaunchResponder {
7975    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
7976    tx_id: u32,
7977}
7978
7979/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
7980/// if the responder is dropped without sending a response, so that the client
7981/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7982impl std::ops::Drop for TerminaGuestManagerLaunchResponder {
7983    fn drop(&mut self) {
7984        self.control_handle.shutdown();
7985        // Safety: drops once, never accessed again
7986        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7987    }
7988}
7989
7990impl fidl::endpoints::Responder for TerminaGuestManagerLaunchResponder {
7991    type ControlHandle = TerminaGuestManagerControlHandle;
7992
7993    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
7994        &self.control_handle
7995    }
7996
7997    fn drop_without_shutdown(mut self) {
7998        // Safety: drops once, never accessed again due to mem::forget
7999        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8000        // Prevent Drop from running (which would shut down the channel)
8001        std::mem::forget(self);
8002    }
8003}
8004
8005impl TerminaGuestManagerLaunchResponder {
8006    /// Sends a response to the FIDL transaction.
8007    ///
8008    /// Sets the channel to shutdown if an error occurs.
8009    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8010        let _result = self.send_raw(result);
8011        if _result.is_err() {
8012            self.control_handle.shutdown();
8013        }
8014        self.drop_without_shutdown();
8015        _result
8016    }
8017
8018    /// Similar to "send" but does not shutdown the channel if an error occurs.
8019    pub fn send_no_shutdown_on_err(
8020        self,
8021        mut result: Result<(), GuestManagerError>,
8022    ) -> Result<(), fidl::Error> {
8023        let _result = self.send_raw(result);
8024        self.drop_without_shutdown();
8025        _result
8026    }
8027
8028    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8029        self.control_handle.inner.send::<fidl::encoding::ResultType<
8030            fidl::encoding::EmptyStruct,
8031            GuestManagerError,
8032        >>(
8033            result,
8034            self.tx_id,
8035            0x394a2e29f750323e,
8036            fidl::encoding::DynamicFlags::empty(),
8037        )
8038    }
8039}
8040
8041#[must_use = "FIDL methods require a response to be sent"]
8042#[derive(Debug)]
8043pub struct TerminaGuestManagerForceShutdownResponder {
8044    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8045    tx_id: u32,
8046}
8047
8048/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8049/// if the responder is dropped without sending a response, so that the client
8050/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8051impl std::ops::Drop for TerminaGuestManagerForceShutdownResponder {
8052    fn drop(&mut self) {
8053        self.control_handle.shutdown();
8054        // Safety: drops once, never accessed again
8055        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8056    }
8057}
8058
8059impl fidl::endpoints::Responder for TerminaGuestManagerForceShutdownResponder {
8060    type ControlHandle = TerminaGuestManagerControlHandle;
8061
8062    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8063        &self.control_handle
8064    }
8065
8066    fn drop_without_shutdown(mut self) {
8067        // Safety: drops once, never accessed again due to mem::forget
8068        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8069        // Prevent Drop from running (which would shut down the channel)
8070        std::mem::forget(self);
8071    }
8072}
8073
8074impl TerminaGuestManagerForceShutdownResponder {
8075    /// Sends a response to the FIDL transaction.
8076    ///
8077    /// Sets the channel to shutdown if an error occurs.
8078    pub fn send(self) -> Result<(), fidl::Error> {
8079        let _result = self.send_raw();
8080        if _result.is_err() {
8081            self.control_handle.shutdown();
8082        }
8083        self.drop_without_shutdown();
8084        _result
8085    }
8086
8087    /// Similar to "send" but does not shutdown the channel if an error occurs.
8088    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8089        let _result = self.send_raw();
8090        self.drop_without_shutdown();
8091        _result
8092    }
8093
8094    fn send_raw(&self) -> Result<(), fidl::Error> {
8095        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8096            (),
8097            self.tx_id,
8098            0x3ad9a012982f872d,
8099            fidl::encoding::DynamicFlags::empty(),
8100        )
8101    }
8102}
8103
8104#[must_use = "FIDL methods require a response to be sent"]
8105#[derive(Debug)]
8106pub struct TerminaGuestManagerConnectResponder {
8107    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8108    tx_id: u32,
8109}
8110
8111/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8112/// if the responder is dropped without sending a response, so that the client
8113/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8114impl std::ops::Drop for TerminaGuestManagerConnectResponder {
8115    fn drop(&mut self) {
8116        self.control_handle.shutdown();
8117        // Safety: drops once, never accessed again
8118        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8119    }
8120}
8121
8122impl fidl::endpoints::Responder for TerminaGuestManagerConnectResponder {
8123    type ControlHandle = TerminaGuestManagerControlHandle;
8124
8125    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8126        &self.control_handle
8127    }
8128
8129    fn drop_without_shutdown(mut self) {
8130        // Safety: drops once, never accessed again due to mem::forget
8131        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8132        // Prevent Drop from running (which would shut down the channel)
8133        std::mem::forget(self);
8134    }
8135}
8136
8137impl TerminaGuestManagerConnectResponder {
8138    /// Sends a response to the FIDL transaction.
8139    ///
8140    /// Sets the channel to shutdown if an error occurs.
8141    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8142        let _result = self.send_raw(result);
8143        if _result.is_err() {
8144            self.control_handle.shutdown();
8145        }
8146        self.drop_without_shutdown();
8147        _result
8148    }
8149
8150    /// Similar to "send" but does not shutdown the channel if an error occurs.
8151    pub fn send_no_shutdown_on_err(
8152        self,
8153        mut result: Result<(), GuestManagerError>,
8154    ) -> Result<(), fidl::Error> {
8155        let _result = self.send_raw(result);
8156        self.drop_without_shutdown();
8157        _result
8158    }
8159
8160    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8161        self.control_handle.inner.send::<fidl::encoding::ResultType<
8162            fidl::encoding::EmptyStruct,
8163            GuestManagerError,
8164        >>(
8165            result,
8166            self.tx_id,
8167            0x4e489076e3bb15b4,
8168            fidl::encoding::DynamicFlags::empty(),
8169        )
8170    }
8171}
8172
8173#[must_use = "FIDL methods require a response to be sent"]
8174#[derive(Debug)]
8175pub struct TerminaGuestManagerGetInfoResponder {
8176    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8177    tx_id: u32,
8178}
8179
8180/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8181/// if the responder is dropped without sending a response, so that the client
8182/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8183impl std::ops::Drop for TerminaGuestManagerGetInfoResponder {
8184    fn drop(&mut self) {
8185        self.control_handle.shutdown();
8186        // Safety: drops once, never accessed again
8187        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8188    }
8189}
8190
8191impl fidl::endpoints::Responder for TerminaGuestManagerGetInfoResponder {
8192    type ControlHandle = TerminaGuestManagerControlHandle;
8193
8194    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8195        &self.control_handle
8196    }
8197
8198    fn drop_without_shutdown(mut self) {
8199        // Safety: drops once, never accessed again due to mem::forget
8200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8201        // Prevent Drop from running (which would shut down the channel)
8202        std::mem::forget(self);
8203    }
8204}
8205
8206impl TerminaGuestManagerGetInfoResponder {
8207    /// Sends a response to the FIDL transaction.
8208    ///
8209    /// Sets the channel to shutdown if an error occurs.
8210    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8211        let _result = self.send_raw(guest_info);
8212        if _result.is_err() {
8213            self.control_handle.shutdown();
8214        }
8215        self.drop_without_shutdown();
8216        _result
8217    }
8218
8219    /// Similar to "send" but does not shutdown the channel if an error occurs.
8220    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8221        let _result = self.send_raw(guest_info);
8222        self.drop_without_shutdown();
8223        _result
8224    }
8225
8226    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8227        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
8228            (guest_info,),
8229            self.tx_id,
8230            0x76892614aea695dc,
8231            fidl::encoding::DynamicFlags::empty(),
8232        )
8233    }
8234}
8235
8236#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8237pub struct ZirconGuestManagerMarker;
8238
8239impl fidl::endpoints::ProtocolMarker for ZirconGuestManagerMarker {
8240    type Proxy = ZirconGuestManagerProxy;
8241    type RequestStream = ZirconGuestManagerRequestStream;
8242    #[cfg(target_os = "fuchsia")]
8243    type SynchronousProxy = ZirconGuestManagerSynchronousProxy;
8244
8245    const DEBUG_NAME: &'static str = "fuchsia.virtualization.ZirconGuestManager";
8246}
8247impl fidl::endpoints::DiscoverableProtocolMarker for ZirconGuestManagerMarker {}
8248
8249pub trait ZirconGuestManagerProxyInterface: Send + Sync {
8250    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
8251        + Send;
8252    fn r#launch(
8253        &self,
8254        guest_config: GuestConfig,
8255        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8256    ) -> Self::LaunchResponseFut;
8257    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8258    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
8259    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
8260        + Send;
8261    fn r#connect(
8262        &self,
8263        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8264    ) -> Self::ConnectResponseFut;
8265    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
8266    fn r#get_info(&self) -> Self::GetInfoResponseFut;
8267}
8268#[derive(Debug)]
8269#[cfg(target_os = "fuchsia")]
8270pub struct ZirconGuestManagerSynchronousProxy {
8271    client: fidl::client::sync::Client,
8272}
8273
8274#[cfg(target_os = "fuchsia")]
8275impl fidl::endpoints::SynchronousProxy for ZirconGuestManagerSynchronousProxy {
8276    type Proxy = ZirconGuestManagerProxy;
8277    type Protocol = ZirconGuestManagerMarker;
8278
8279    fn from_channel(inner: fidl::Channel) -> Self {
8280        Self::new(inner)
8281    }
8282
8283    fn into_channel(self) -> fidl::Channel {
8284        self.client.into_channel()
8285    }
8286
8287    fn as_channel(&self) -> &fidl::Channel {
8288        self.client.as_channel()
8289    }
8290}
8291
8292#[cfg(target_os = "fuchsia")]
8293impl ZirconGuestManagerSynchronousProxy {
8294    pub fn new(channel: fidl::Channel) -> Self {
8295        let protocol_name =
8296            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8297        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8298    }
8299
8300    pub fn into_channel(self) -> fidl::Channel {
8301        self.client.into_channel()
8302    }
8303
8304    /// Waits until an event arrives and returns it. It is safe for other
8305    /// threads to make concurrent requests while waiting for an event.
8306    pub fn wait_for_event(
8307        &self,
8308        deadline: zx::MonotonicInstant,
8309    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8310        ZirconGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
8311    }
8312
8313    /// Launch a new guest instance.
8314    ///
8315    /// Possible errors:
8316    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8317    ///         problems detected by the guest manager.
8318    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8319    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8320    ///         component logs for a more specific failure.
8321    pub fn r#launch(
8322        &self,
8323        mut guest_config: GuestConfig,
8324        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8325        ___deadline: zx::MonotonicInstant,
8326    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8327        let _response =
8328            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
8329                fidl::encoding::EmptyStruct,
8330                GuestManagerError,
8331            >>(
8332                (&mut guest_config, controller),
8333                0x394a2e29f750323e,
8334                fidl::encoding::DynamicFlags::empty(),
8335                ___deadline,
8336            )?;
8337        Ok(_response.map(|x| x))
8338    }
8339
8340    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8341    /// be used to launch another guest.
8342    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
8343        let _response =
8344            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
8345                (),
8346                0x3ad9a012982f872d,
8347                fidl::encoding::DynamicFlags::empty(),
8348                ___deadline,
8349            )?;
8350        Ok(_response)
8351    }
8352
8353    /// Connect to a currently running guest.
8354    ///
8355    /// Possible errors:
8356    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8357    ///         has launched before attempting to reconnect.
8358    pub fn r#connect(
8359        &self,
8360        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8361        ___deadline: zx::MonotonicInstant,
8362    ) -> Result<GuestManagerConnectResult, fidl::Error> {
8363        let _response =
8364            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
8365                fidl::encoding::EmptyStruct,
8366                GuestManagerError,
8367            >>(
8368                (controller,),
8369                0x4e489076e3bb15b4,
8370                fidl::encoding::DynamicFlags::empty(),
8371                ___deadline,
8372            )?;
8373        Ok(_response.map(|x| x))
8374    }
8375
8376    /// Query guest info
8377    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
8378        let _response =
8379            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
8380                (),
8381                0x76892614aea695dc,
8382                fidl::encoding::DynamicFlags::empty(),
8383                ___deadline,
8384            )?;
8385        Ok(_response.guest_info)
8386    }
8387}
8388
8389#[cfg(target_os = "fuchsia")]
8390impl From<ZirconGuestManagerSynchronousProxy> for zx::Handle {
8391    fn from(value: ZirconGuestManagerSynchronousProxy) -> Self {
8392        value.into_channel().into()
8393    }
8394}
8395
8396#[cfg(target_os = "fuchsia")]
8397impl From<fidl::Channel> for ZirconGuestManagerSynchronousProxy {
8398    fn from(value: fidl::Channel) -> Self {
8399        Self::new(value)
8400    }
8401}
8402
8403#[cfg(target_os = "fuchsia")]
8404impl fidl::endpoints::FromClient for ZirconGuestManagerSynchronousProxy {
8405    type Protocol = ZirconGuestManagerMarker;
8406
8407    fn from_client(value: fidl::endpoints::ClientEnd<ZirconGuestManagerMarker>) -> Self {
8408        Self::new(value.into_channel())
8409    }
8410}
8411
8412#[derive(Debug, Clone)]
8413pub struct ZirconGuestManagerProxy {
8414    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8415}
8416
8417impl fidl::endpoints::Proxy for ZirconGuestManagerProxy {
8418    type Protocol = ZirconGuestManagerMarker;
8419
8420    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8421        Self::new(inner)
8422    }
8423
8424    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8425        self.client.into_channel().map_err(|client| Self { client })
8426    }
8427
8428    fn as_channel(&self) -> &::fidl::AsyncChannel {
8429        self.client.as_channel()
8430    }
8431}
8432
8433impl ZirconGuestManagerProxy {
8434    /// Create a new Proxy for fuchsia.virtualization/ZirconGuestManager.
8435    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8436        let protocol_name =
8437            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8438        Self { client: fidl::client::Client::new(channel, protocol_name) }
8439    }
8440
8441    /// Get a Stream of events from the remote end of the protocol.
8442    ///
8443    /// # Panics
8444    ///
8445    /// Panics if the event stream was already taken.
8446    pub fn take_event_stream(&self) -> ZirconGuestManagerEventStream {
8447        ZirconGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
8448    }
8449
8450    /// Launch a new guest instance.
8451    ///
8452    /// Possible errors:
8453    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8454    ///         problems detected by the guest manager.
8455    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8456    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8457    ///         component logs for a more specific failure.
8458    pub fn r#launch(
8459        &self,
8460        mut guest_config: GuestConfig,
8461        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8462    ) -> fidl::client::QueryResponseFut<
8463        GuestManagerLaunchResult,
8464        fidl::encoding::DefaultFuchsiaResourceDialect,
8465    > {
8466        ZirconGuestManagerProxyInterface::r#launch(self, guest_config, controller)
8467    }
8468
8469    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8470    /// be used to launch another guest.
8471    pub fn r#force_shutdown(
8472        &self,
8473    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8474        ZirconGuestManagerProxyInterface::r#force_shutdown(self)
8475    }
8476
8477    /// Connect to a currently running guest.
8478    ///
8479    /// Possible errors:
8480    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8481    ///         has launched before attempting to reconnect.
8482    pub fn r#connect(
8483        &self,
8484        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8485    ) -> fidl::client::QueryResponseFut<
8486        GuestManagerConnectResult,
8487        fidl::encoding::DefaultFuchsiaResourceDialect,
8488    > {
8489        ZirconGuestManagerProxyInterface::r#connect(self, controller)
8490    }
8491
8492    /// Query guest info
8493    pub fn r#get_info(
8494        &self,
8495    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
8496    {
8497        ZirconGuestManagerProxyInterface::r#get_info(self)
8498    }
8499}
8500
8501impl ZirconGuestManagerProxyInterface for ZirconGuestManagerProxy {
8502    type LaunchResponseFut = fidl::client::QueryResponseFut<
8503        GuestManagerLaunchResult,
8504        fidl::encoding::DefaultFuchsiaResourceDialect,
8505    >;
8506    fn r#launch(
8507        &self,
8508        mut guest_config: GuestConfig,
8509        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8510    ) -> Self::LaunchResponseFut {
8511        fn _decode(
8512            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8513        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8514            let _response = fidl::client::decode_transaction_body::<
8515                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8516                fidl::encoding::DefaultFuchsiaResourceDialect,
8517                0x394a2e29f750323e,
8518            >(_buf?)?;
8519            Ok(_response.map(|x| x))
8520        }
8521        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
8522            (&mut guest_config, controller),
8523            0x394a2e29f750323e,
8524            fidl::encoding::DynamicFlags::empty(),
8525            _decode,
8526        )
8527    }
8528
8529    type ForceShutdownResponseFut =
8530        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8531    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
8532        fn _decode(
8533            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8534        ) -> Result<(), fidl::Error> {
8535            let _response = fidl::client::decode_transaction_body::<
8536                fidl::encoding::EmptyPayload,
8537                fidl::encoding::DefaultFuchsiaResourceDialect,
8538                0x3ad9a012982f872d,
8539            >(_buf?)?;
8540            Ok(_response)
8541        }
8542        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
8543            (),
8544            0x3ad9a012982f872d,
8545            fidl::encoding::DynamicFlags::empty(),
8546            _decode,
8547        )
8548    }
8549
8550    type ConnectResponseFut = fidl::client::QueryResponseFut<
8551        GuestManagerConnectResult,
8552        fidl::encoding::DefaultFuchsiaResourceDialect,
8553    >;
8554    fn r#connect(
8555        &self,
8556        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8557    ) -> Self::ConnectResponseFut {
8558        fn _decode(
8559            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8560        ) -> Result<GuestManagerConnectResult, fidl::Error> {
8561            let _response = fidl::client::decode_transaction_body::<
8562                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8563                fidl::encoding::DefaultFuchsiaResourceDialect,
8564                0x4e489076e3bb15b4,
8565            >(_buf?)?;
8566            Ok(_response.map(|x| x))
8567        }
8568        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
8569            (controller,),
8570            0x4e489076e3bb15b4,
8571            fidl::encoding::DynamicFlags::empty(),
8572            _decode,
8573        )
8574    }
8575
8576    type GetInfoResponseFut =
8577        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
8578    fn r#get_info(&self) -> Self::GetInfoResponseFut {
8579        fn _decode(
8580            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8581        ) -> Result<GuestInfo, fidl::Error> {
8582            let _response = fidl::client::decode_transaction_body::<
8583                GuestManagerGetInfoResponse,
8584                fidl::encoding::DefaultFuchsiaResourceDialect,
8585                0x76892614aea695dc,
8586            >(_buf?)?;
8587            Ok(_response.guest_info)
8588        }
8589        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
8590            (),
8591            0x76892614aea695dc,
8592            fidl::encoding::DynamicFlags::empty(),
8593            _decode,
8594        )
8595    }
8596}
8597
8598pub struct ZirconGuestManagerEventStream {
8599    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8600}
8601
8602impl std::marker::Unpin for ZirconGuestManagerEventStream {}
8603
8604impl futures::stream::FusedStream for ZirconGuestManagerEventStream {
8605    fn is_terminated(&self) -> bool {
8606        self.event_receiver.is_terminated()
8607    }
8608}
8609
8610impl futures::Stream for ZirconGuestManagerEventStream {
8611    type Item = Result<ZirconGuestManagerEvent, fidl::Error>;
8612
8613    fn poll_next(
8614        mut self: std::pin::Pin<&mut Self>,
8615        cx: &mut std::task::Context<'_>,
8616    ) -> std::task::Poll<Option<Self::Item>> {
8617        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8618            &mut self.event_receiver,
8619            cx
8620        )?) {
8621            Some(buf) => std::task::Poll::Ready(Some(ZirconGuestManagerEvent::decode(buf))),
8622            None => std::task::Poll::Ready(None),
8623        }
8624    }
8625}
8626
8627#[derive(Debug)]
8628pub enum ZirconGuestManagerEvent {}
8629
8630impl ZirconGuestManagerEvent {
8631    /// Decodes a message buffer as a [`ZirconGuestManagerEvent`].
8632    fn decode(
8633        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8634    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8635        let (bytes, _handles) = buf.split_mut();
8636        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8637        debug_assert_eq!(tx_header.tx_id, 0);
8638        match tx_header.ordinal {
8639            _ => Err(fidl::Error::UnknownOrdinal {
8640                ordinal: tx_header.ordinal,
8641                protocol_name:
8642                    <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8643            }),
8644        }
8645    }
8646}
8647
8648/// A Stream of incoming requests for fuchsia.virtualization/ZirconGuestManager.
8649pub struct ZirconGuestManagerRequestStream {
8650    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8651    is_terminated: bool,
8652}
8653
8654impl std::marker::Unpin for ZirconGuestManagerRequestStream {}
8655
8656impl futures::stream::FusedStream for ZirconGuestManagerRequestStream {
8657    fn is_terminated(&self) -> bool {
8658        self.is_terminated
8659    }
8660}
8661
8662impl fidl::endpoints::RequestStream for ZirconGuestManagerRequestStream {
8663    type Protocol = ZirconGuestManagerMarker;
8664    type ControlHandle = ZirconGuestManagerControlHandle;
8665
8666    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8667        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8668    }
8669
8670    fn control_handle(&self) -> Self::ControlHandle {
8671        ZirconGuestManagerControlHandle { inner: self.inner.clone() }
8672    }
8673
8674    fn into_inner(
8675        self,
8676    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8677    {
8678        (self.inner, self.is_terminated)
8679    }
8680
8681    fn from_inner(
8682        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8683        is_terminated: bool,
8684    ) -> Self {
8685        Self { inner, is_terminated }
8686    }
8687}
8688
8689impl futures::Stream for ZirconGuestManagerRequestStream {
8690    type Item = Result<ZirconGuestManagerRequest, fidl::Error>;
8691
8692    fn poll_next(
8693        mut self: std::pin::Pin<&mut Self>,
8694        cx: &mut std::task::Context<'_>,
8695    ) -> std::task::Poll<Option<Self::Item>> {
8696        let this = &mut *self;
8697        if this.inner.check_shutdown(cx) {
8698            this.is_terminated = true;
8699            return std::task::Poll::Ready(None);
8700        }
8701        if this.is_terminated {
8702            panic!("polled ZirconGuestManagerRequestStream after completion");
8703        }
8704        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8705            |bytes, handles| {
8706                match this.inner.channel().read_etc(cx, bytes, handles) {
8707                    std::task::Poll::Ready(Ok(())) => {}
8708                    std::task::Poll::Pending => return std::task::Poll::Pending,
8709                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8710                        this.is_terminated = true;
8711                        return std::task::Poll::Ready(None);
8712                    }
8713                    std::task::Poll::Ready(Err(e)) => {
8714                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8715                            e.into(),
8716                        ))));
8717                    }
8718                }
8719
8720                // A message has been received from the channel
8721                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8722
8723                std::task::Poll::Ready(Some(match header.ordinal {
8724                0x394a2e29f750323e => {
8725                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8726                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8727                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
8728                    let control_handle = ZirconGuestManagerControlHandle {
8729                        inner: this.inner.clone(),
8730                    };
8731                    Ok(ZirconGuestManagerRequest::Launch {guest_config: req.guest_config,
8732controller: req.controller,
8733
8734                        responder: ZirconGuestManagerLaunchResponder {
8735                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8736                            tx_id: header.tx_id,
8737                        },
8738                    })
8739                }
8740                0x3ad9a012982f872d => {
8741                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8742                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8743                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8744                    let control_handle = ZirconGuestManagerControlHandle {
8745                        inner: this.inner.clone(),
8746                    };
8747                    Ok(ZirconGuestManagerRequest::ForceShutdown {
8748                        responder: ZirconGuestManagerForceShutdownResponder {
8749                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8750                            tx_id: header.tx_id,
8751                        },
8752                    })
8753                }
8754                0x4e489076e3bb15b4 => {
8755                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8756                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8757                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
8758                    let control_handle = ZirconGuestManagerControlHandle {
8759                        inner: this.inner.clone(),
8760                    };
8761                    Ok(ZirconGuestManagerRequest::Connect {controller: req.controller,
8762
8763                        responder: ZirconGuestManagerConnectResponder {
8764                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8765                            tx_id: header.tx_id,
8766                        },
8767                    })
8768                }
8769                0x76892614aea695dc => {
8770                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8771                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8772                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8773                    let control_handle = ZirconGuestManagerControlHandle {
8774                        inner: this.inner.clone(),
8775                    };
8776                    Ok(ZirconGuestManagerRequest::GetInfo {
8777                        responder: ZirconGuestManagerGetInfoResponder {
8778                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8779                            tx_id: header.tx_id,
8780                        },
8781                    })
8782                }
8783                _ => Err(fidl::Error::UnknownOrdinal {
8784                    ordinal: header.ordinal,
8785                    protocol_name: <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8786                }),
8787            }))
8788            },
8789        )
8790    }
8791}
8792
8793#[derive(Debug)]
8794pub enum ZirconGuestManagerRequest {
8795    /// Launch a new guest instance.
8796    ///
8797    /// Possible errors:
8798    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8799    ///         problems detected by the guest manager.
8800    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8801    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8802    ///         component logs for a more specific failure.
8803    Launch {
8804        guest_config: GuestConfig,
8805        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8806        responder: ZirconGuestManagerLaunchResponder,
8807    },
8808    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8809    /// be used to launch another guest.
8810    ForceShutdown { responder: ZirconGuestManagerForceShutdownResponder },
8811    /// Connect to a currently running guest.
8812    ///
8813    /// Possible errors:
8814    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8815    ///         has launched before attempting to reconnect.
8816    Connect {
8817        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8818        responder: ZirconGuestManagerConnectResponder,
8819    },
8820    /// Query guest info
8821    GetInfo { responder: ZirconGuestManagerGetInfoResponder },
8822}
8823
8824impl ZirconGuestManagerRequest {
8825    #[allow(irrefutable_let_patterns)]
8826    pub fn into_launch(
8827        self,
8828    ) -> Option<(
8829        GuestConfig,
8830        fidl::endpoints::ServerEnd<GuestMarker>,
8831        ZirconGuestManagerLaunchResponder,
8832    )> {
8833        if let ZirconGuestManagerRequest::Launch { guest_config, controller, responder } = self {
8834            Some((guest_config, controller, responder))
8835        } else {
8836            None
8837        }
8838    }
8839
8840    #[allow(irrefutable_let_patterns)]
8841    pub fn into_force_shutdown(self) -> Option<(ZirconGuestManagerForceShutdownResponder)> {
8842        if let ZirconGuestManagerRequest::ForceShutdown { responder } = self {
8843            Some((responder))
8844        } else {
8845            None
8846        }
8847    }
8848
8849    #[allow(irrefutable_let_patterns)]
8850    pub fn into_connect(
8851        self,
8852    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, ZirconGuestManagerConnectResponder)> {
8853        if let ZirconGuestManagerRequest::Connect { controller, responder } = self {
8854            Some((controller, responder))
8855        } else {
8856            None
8857        }
8858    }
8859
8860    #[allow(irrefutable_let_patterns)]
8861    pub fn into_get_info(self) -> Option<(ZirconGuestManagerGetInfoResponder)> {
8862        if let ZirconGuestManagerRequest::GetInfo { responder } = self {
8863            Some((responder))
8864        } else {
8865            None
8866        }
8867    }
8868
8869    /// Name of the method defined in FIDL
8870    pub fn method_name(&self) -> &'static str {
8871        match *self {
8872            ZirconGuestManagerRequest::Launch { .. } => "launch",
8873            ZirconGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
8874            ZirconGuestManagerRequest::Connect { .. } => "connect",
8875            ZirconGuestManagerRequest::GetInfo { .. } => "get_info",
8876        }
8877    }
8878}
8879
8880#[derive(Debug, Clone)]
8881pub struct ZirconGuestManagerControlHandle {
8882    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8883}
8884
8885impl fidl::endpoints::ControlHandle for ZirconGuestManagerControlHandle {
8886    fn shutdown(&self) {
8887        self.inner.shutdown()
8888    }
8889    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8890        self.inner.shutdown_with_epitaph(status)
8891    }
8892
8893    fn is_closed(&self) -> bool {
8894        self.inner.channel().is_closed()
8895    }
8896    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8897        self.inner.channel().on_closed()
8898    }
8899
8900    #[cfg(target_os = "fuchsia")]
8901    fn signal_peer(
8902        &self,
8903        clear_mask: zx::Signals,
8904        set_mask: zx::Signals,
8905    ) -> Result<(), zx_status::Status> {
8906        use fidl::Peered;
8907        self.inner.channel().signal_peer(clear_mask, set_mask)
8908    }
8909}
8910
8911impl ZirconGuestManagerControlHandle {}
8912
8913#[must_use = "FIDL methods require a response to be sent"]
8914#[derive(Debug)]
8915pub struct ZirconGuestManagerLaunchResponder {
8916    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8917    tx_id: u32,
8918}
8919
8920/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8921/// if the responder is dropped without sending a response, so that the client
8922/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8923impl std::ops::Drop for ZirconGuestManagerLaunchResponder {
8924    fn drop(&mut self) {
8925        self.control_handle.shutdown();
8926        // Safety: drops once, never accessed again
8927        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8928    }
8929}
8930
8931impl fidl::endpoints::Responder for ZirconGuestManagerLaunchResponder {
8932    type ControlHandle = ZirconGuestManagerControlHandle;
8933
8934    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
8935        &self.control_handle
8936    }
8937
8938    fn drop_without_shutdown(mut self) {
8939        // Safety: drops once, never accessed again due to mem::forget
8940        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8941        // Prevent Drop from running (which would shut down the channel)
8942        std::mem::forget(self);
8943    }
8944}
8945
8946impl ZirconGuestManagerLaunchResponder {
8947    /// Sends a response to the FIDL transaction.
8948    ///
8949    /// Sets the channel to shutdown if an error occurs.
8950    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8951        let _result = self.send_raw(result);
8952        if _result.is_err() {
8953            self.control_handle.shutdown();
8954        }
8955        self.drop_without_shutdown();
8956        _result
8957    }
8958
8959    /// Similar to "send" but does not shutdown the channel if an error occurs.
8960    pub fn send_no_shutdown_on_err(
8961        self,
8962        mut result: Result<(), GuestManagerError>,
8963    ) -> Result<(), fidl::Error> {
8964        let _result = self.send_raw(result);
8965        self.drop_without_shutdown();
8966        _result
8967    }
8968
8969    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8970        self.control_handle.inner.send::<fidl::encoding::ResultType<
8971            fidl::encoding::EmptyStruct,
8972            GuestManagerError,
8973        >>(
8974            result,
8975            self.tx_id,
8976            0x394a2e29f750323e,
8977            fidl::encoding::DynamicFlags::empty(),
8978        )
8979    }
8980}
8981
8982#[must_use = "FIDL methods require a response to be sent"]
8983#[derive(Debug)]
8984pub struct ZirconGuestManagerForceShutdownResponder {
8985    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8986    tx_id: u32,
8987}
8988
8989/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8990/// if the responder is dropped without sending a response, so that the client
8991/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8992impl std::ops::Drop for ZirconGuestManagerForceShutdownResponder {
8993    fn drop(&mut self) {
8994        self.control_handle.shutdown();
8995        // Safety: drops once, never accessed again
8996        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8997    }
8998}
8999
9000impl fidl::endpoints::Responder for ZirconGuestManagerForceShutdownResponder {
9001    type ControlHandle = ZirconGuestManagerControlHandle;
9002
9003    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9004        &self.control_handle
9005    }
9006
9007    fn drop_without_shutdown(mut self) {
9008        // Safety: drops once, never accessed again due to mem::forget
9009        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9010        // Prevent Drop from running (which would shut down the channel)
9011        std::mem::forget(self);
9012    }
9013}
9014
9015impl ZirconGuestManagerForceShutdownResponder {
9016    /// Sends a response to the FIDL transaction.
9017    ///
9018    /// Sets the channel to shutdown if an error occurs.
9019    pub fn send(self) -> Result<(), fidl::Error> {
9020        let _result = self.send_raw();
9021        if _result.is_err() {
9022            self.control_handle.shutdown();
9023        }
9024        self.drop_without_shutdown();
9025        _result
9026    }
9027
9028    /// Similar to "send" but does not shutdown the channel if an error occurs.
9029    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9030        let _result = self.send_raw();
9031        self.drop_without_shutdown();
9032        _result
9033    }
9034
9035    fn send_raw(&self) -> Result<(), fidl::Error> {
9036        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9037            (),
9038            self.tx_id,
9039            0x3ad9a012982f872d,
9040            fidl::encoding::DynamicFlags::empty(),
9041        )
9042    }
9043}
9044
9045#[must_use = "FIDL methods require a response to be sent"]
9046#[derive(Debug)]
9047pub struct ZirconGuestManagerConnectResponder {
9048    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9049    tx_id: u32,
9050}
9051
9052/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9053/// if the responder is dropped without sending a response, so that the client
9054/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9055impl std::ops::Drop for ZirconGuestManagerConnectResponder {
9056    fn drop(&mut self) {
9057        self.control_handle.shutdown();
9058        // Safety: drops once, never accessed again
9059        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9060    }
9061}
9062
9063impl fidl::endpoints::Responder for ZirconGuestManagerConnectResponder {
9064    type ControlHandle = ZirconGuestManagerControlHandle;
9065
9066    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9067        &self.control_handle
9068    }
9069
9070    fn drop_without_shutdown(mut self) {
9071        // Safety: drops once, never accessed again due to mem::forget
9072        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9073        // Prevent Drop from running (which would shut down the channel)
9074        std::mem::forget(self);
9075    }
9076}
9077
9078impl ZirconGuestManagerConnectResponder {
9079    /// Sends a response to the FIDL transaction.
9080    ///
9081    /// Sets the channel to shutdown if an error occurs.
9082    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9083        let _result = self.send_raw(result);
9084        if _result.is_err() {
9085            self.control_handle.shutdown();
9086        }
9087        self.drop_without_shutdown();
9088        _result
9089    }
9090
9091    /// Similar to "send" but does not shutdown the channel if an error occurs.
9092    pub fn send_no_shutdown_on_err(
9093        self,
9094        mut result: Result<(), GuestManagerError>,
9095    ) -> Result<(), fidl::Error> {
9096        let _result = self.send_raw(result);
9097        self.drop_without_shutdown();
9098        _result
9099    }
9100
9101    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9102        self.control_handle.inner.send::<fidl::encoding::ResultType<
9103            fidl::encoding::EmptyStruct,
9104            GuestManagerError,
9105        >>(
9106            result,
9107            self.tx_id,
9108            0x4e489076e3bb15b4,
9109            fidl::encoding::DynamicFlags::empty(),
9110        )
9111    }
9112}
9113
9114#[must_use = "FIDL methods require a response to be sent"]
9115#[derive(Debug)]
9116pub struct ZirconGuestManagerGetInfoResponder {
9117    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9118    tx_id: u32,
9119}
9120
9121/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9122/// if the responder is dropped without sending a response, so that the client
9123/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9124impl std::ops::Drop for ZirconGuestManagerGetInfoResponder {
9125    fn drop(&mut self) {
9126        self.control_handle.shutdown();
9127        // Safety: drops once, never accessed again
9128        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9129    }
9130}
9131
9132impl fidl::endpoints::Responder for ZirconGuestManagerGetInfoResponder {
9133    type ControlHandle = ZirconGuestManagerControlHandle;
9134
9135    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9136        &self.control_handle
9137    }
9138
9139    fn drop_without_shutdown(mut self) {
9140        // Safety: drops once, never accessed again due to mem::forget
9141        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9142        // Prevent Drop from running (which would shut down the channel)
9143        std::mem::forget(self);
9144    }
9145}
9146
9147impl ZirconGuestManagerGetInfoResponder {
9148    /// Sends a response to the FIDL transaction.
9149    ///
9150    /// Sets the channel to shutdown if an error occurs.
9151    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9152        let _result = self.send_raw(guest_info);
9153        if _result.is_err() {
9154            self.control_handle.shutdown();
9155        }
9156        self.drop_without_shutdown();
9157        _result
9158    }
9159
9160    /// Similar to "send" but does not shutdown the channel if an error occurs.
9161    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9162        let _result = self.send_raw(guest_info);
9163        self.drop_without_shutdown();
9164        _result
9165    }
9166
9167    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9168        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
9169            (guest_info,),
9170            self.tx_id,
9171            0x76892614aea695dc,
9172            fidl::encoding::DynamicFlags::empty(),
9173        )
9174    }
9175}
9176
9177mod internal {
9178    use super::*;
9179
9180    impl fidl::encoding::ResourceTypeMarker for BlockSpec {
9181        type Borrowed<'a> = &'a mut Self;
9182        fn take_or_borrow<'a>(
9183            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9184        ) -> Self::Borrowed<'a> {
9185            value
9186        }
9187    }
9188
9189    unsafe impl fidl::encoding::TypeMarker for BlockSpec {
9190        type Owned = Self;
9191
9192        #[inline(always)]
9193        fn inline_align(_context: fidl::encoding::Context) -> usize {
9194            8
9195        }
9196
9197        #[inline(always)]
9198        fn inline_size(_context: fidl::encoding::Context) -> usize {
9199            40
9200        }
9201    }
9202
9203    unsafe impl fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9204        for &mut BlockSpec
9205    {
9206        #[inline]
9207        unsafe fn encode(
9208            self,
9209            encoder: &mut fidl::encoding::Encoder<
9210                '_,
9211                fidl::encoding::DefaultFuchsiaResourceDialect,
9212            >,
9213            offset: usize,
9214            _depth: fidl::encoding::Depth,
9215        ) -> fidl::Result<()> {
9216            encoder.debug_check_bounds::<BlockSpec>(offset);
9217            // Delegate to tuple encoding.
9218            fidl::encoding::Encode::<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9219                (
9220                    <fidl::encoding::BoundedString<20> as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
9221                    <BlockMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
9222                    <BlockFormat as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.format),
9223                ),
9224                encoder, offset, _depth
9225            )
9226        }
9227    }
9228    unsafe impl<
9229        T0: fidl::encoding::Encode<
9230                fidl::encoding::BoundedString<20>,
9231                fidl::encoding::DefaultFuchsiaResourceDialect,
9232            >,
9233        T1: fidl::encoding::Encode<BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect>,
9234        T2: fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>,
9235    > fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9236        for (T0, T1, T2)
9237    {
9238        #[inline]
9239        unsafe fn encode(
9240            self,
9241            encoder: &mut fidl::encoding::Encoder<
9242                '_,
9243                fidl::encoding::DefaultFuchsiaResourceDialect,
9244            >,
9245            offset: usize,
9246            depth: fidl::encoding::Depth,
9247        ) -> fidl::Result<()> {
9248            encoder.debug_check_bounds::<BlockSpec>(offset);
9249            // Zero out padding regions. There's no need to apply masks
9250            // because the unmasked parts will be overwritten by fields.
9251            unsafe {
9252                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9253                (ptr as *mut u64).write_unaligned(0);
9254            }
9255            // Write the fields.
9256            self.0.encode(encoder, offset + 0, depth)?;
9257            self.1.encode(encoder, offset + 16, depth)?;
9258            self.2.encode(encoder, offset + 24, depth)?;
9259            Ok(())
9260        }
9261    }
9262
9263    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockSpec {
9264        #[inline(always)]
9265        fn new_empty() -> Self {
9266            Self {
9267                id: fidl::new_empty!(
9268                    fidl::encoding::BoundedString<20>,
9269                    fidl::encoding::DefaultFuchsiaResourceDialect
9270                ),
9271                mode: fidl::new_empty!(BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect),
9272                format: fidl::new_empty!(
9273                    BlockFormat,
9274                    fidl::encoding::DefaultFuchsiaResourceDialect
9275                ),
9276            }
9277        }
9278
9279        #[inline]
9280        unsafe fn decode(
9281            &mut self,
9282            decoder: &mut fidl::encoding::Decoder<
9283                '_,
9284                fidl::encoding::DefaultFuchsiaResourceDialect,
9285            >,
9286            offset: usize,
9287            _depth: fidl::encoding::Depth,
9288        ) -> fidl::Result<()> {
9289            decoder.debug_check_bounds::<Self>(offset);
9290            // Verify that padding bytes are zero.
9291            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9292            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9293            let mask = 0xffffffff00000000u64;
9294            let maskedval = padval & mask;
9295            if maskedval != 0 {
9296                return Err(fidl::Error::NonZeroPadding {
9297                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9298                });
9299            }
9300            fidl::decode!(
9301                fidl::encoding::BoundedString<20>,
9302                fidl::encoding::DefaultFuchsiaResourceDialect,
9303                &mut self.id,
9304                decoder,
9305                offset + 0,
9306                _depth
9307            )?;
9308            fidl::decode!(
9309                BlockMode,
9310                fidl::encoding::DefaultFuchsiaResourceDialect,
9311                &mut self.mode,
9312                decoder,
9313                offset + 16,
9314                _depth
9315            )?;
9316            fidl::decode!(
9317                BlockFormat,
9318                fidl::encoding::DefaultFuchsiaResourceDialect,
9319                &mut self.format,
9320                decoder,
9321                offset + 24,
9322                _depth
9323            )?;
9324            Ok(())
9325        }
9326    }
9327
9328    impl fidl::encoding::ResourceTypeMarker for GuestGetBalloonControllerRequest {
9329        type Borrowed<'a> = &'a mut Self;
9330        fn take_or_borrow<'a>(
9331            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9332        ) -> Self::Borrowed<'a> {
9333            value
9334        }
9335    }
9336
9337    unsafe impl fidl::encoding::TypeMarker for GuestGetBalloonControllerRequest {
9338        type Owned = Self;
9339
9340        #[inline(always)]
9341        fn inline_align(_context: fidl::encoding::Context) -> usize {
9342            4
9343        }
9344
9345        #[inline(always)]
9346        fn inline_size(_context: fidl::encoding::Context) -> usize {
9347            4
9348        }
9349    }
9350
9351    unsafe impl
9352        fidl::encoding::Encode<
9353            GuestGetBalloonControllerRequest,
9354            fidl::encoding::DefaultFuchsiaResourceDialect,
9355        > for &mut GuestGetBalloonControllerRequest
9356    {
9357        #[inline]
9358        unsafe fn encode(
9359            self,
9360            encoder: &mut fidl::encoding::Encoder<
9361                '_,
9362                fidl::encoding::DefaultFuchsiaResourceDialect,
9363            >,
9364            offset: usize,
9365            _depth: fidl::encoding::Depth,
9366        ) -> fidl::Result<()> {
9367            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9368            // Delegate to tuple encoding.
9369            fidl::encoding::Encode::<GuestGetBalloonControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9370                (
9371                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9372                ),
9373                encoder, offset, _depth
9374            )
9375        }
9376    }
9377    unsafe impl<
9378        T0: fidl::encoding::Encode<
9379                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9380                fidl::encoding::DefaultFuchsiaResourceDialect,
9381            >,
9382    >
9383        fidl::encoding::Encode<
9384            GuestGetBalloonControllerRequest,
9385            fidl::encoding::DefaultFuchsiaResourceDialect,
9386        > for (T0,)
9387    {
9388        #[inline]
9389        unsafe fn encode(
9390            self,
9391            encoder: &mut fidl::encoding::Encoder<
9392                '_,
9393                fidl::encoding::DefaultFuchsiaResourceDialect,
9394            >,
9395            offset: usize,
9396            depth: fidl::encoding::Depth,
9397        ) -> fidl::Result<()> {
9398            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9399            // Zero out padding regions. There's no need to apply masks
9400            // because the unmasked parts will be overwritten by fields.
9401            // Write the fields.
9402            self.0.encode(encoder, offset + 0, depth)?;
9403            Ok(())
9404        }
9405    }
9406
9407    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9408        for GuestGetBalloonControllerRequest
9409    {
9410        #[inline(always)]
9411        fn new_empty() -> Self {
9412            Self {
9413                controller: fidl::new_empty!(
9414                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9415                    fidl::encoding::DefaultFuchsiaResourceDialect
9416                ),
9417            }
9418        }
9419
9420        #[inline]
9421        unsafe fn decode(
9422            &mut self,
9423            decoder: &mut fidl::encoding::Decoder<
9424                '_,
9425                fidl::encoding::DefaultFuchsiaResourceDialect,
9426            >,
9427            offset: usize,
9428            _depth: fidl::encoding::Depth,
9429        ) -> fidl::Result<()> {
9430            decoder.debug_check_bounds::<Self>(offset);
9431            // Verify that padding bytes are zero.
9432            fidl::decode!(
9433                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9434                fidl::encoding::DefaultFuchsiaResourceDialect,
9435                &mut self.controller,
9436                decoder,
9437                offset + 0,
9438                _depth
9439            )?;
9440            Ok(())
9441        }
9442    }
9443
9444    impl fidl::encoding::ResourceTypeMarker for GuestGetHostVsockEndpointRequest {
9445        type Borrowed<'a> = &'a mut Self;
9446        fn take_or_borrow<'a>(
9447            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9448        ) -> Self::Borrowed<'a> {
9449            value
9450        }
9451    }
9452
9453    unsafe impl fidl::encoding::TypeMarker for GuestGetHostVsockEndpointRequest {
9454        type Owned = Self;
9455
9456        #[inline(always)]
9457        fn inline_align(_context: fidl::encoding::Context) -> usize {
9458            4
9459        }
9460
9461        #[inline(always)]
9462        fn inline_size(_context: fidl::encoding::Context) -> usize {
9463            4
9464        }
9465    }
9466
9467    unsafe impl
9468        fidl::encoding::Encode<
9469            GuestGetHostVsockEndpointRequest,
9470            fidl::encoding::DefaultFuchsiaResourceDialect,
9471        > for &mut GuestGetHostVsockEndpointRequest
9472    {
9473        #[inline]
9474        unsafe fn encode(
9475            self,
9476            encoder: &mut fidl::encoding::Encoder<
9477                '_,
9478                fidl::encoding::DefaultFuchsiaResourceDialect,
9479            >,
9480            offset: usize,
9481            _depth: fidl::encoding::Depth,
9482        ) -> fidl::Result<()> {
9483            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9484            // Delegate to tuple encoding.
9485            fidl::encoding::Encode::<GuestGetHostVsockEndpointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9486                (
9487                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoint),
9488                ),
9489                encoder, offset, _depth
9490            )
9491        }
9492    }
9493    unsafe impl<
9494        T0: fidl::encoding::Encode<
9495                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9496                fidl::encoding::DefaultFuchsiaResourceDialect,
9497            >,
9498    >
9499        fidl::encoding::Encode<
9500            GuestGetHostVsockEndpointRequest,
9501            fidl::encoding::DefaultFuchsiaResourceDialect,
9502        > for (T0,)
9503    {
9504        #[inline]
9505        unsafe fn encode(
9506            self,
9507            encoder: &mut fidl::encoding::Encoder<
9508                '_,
9509                fidl::encoding::DefaultFuchsiaResourceDialect,
9510            >,
9511            offset: usize,
9512            depth: fidl::encoding::Depth,
9513        ) -> fidl::Result<()> {
9514            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9515            // Zero out padding regions. There's no need to apply masks
9516            // because the unmasked parts will be overwritten by fields.
9517            // Write the fields.
9518            self.0.encode(encoder, offset + 0, depth)?;
9519            Ok(())
9520        }
9521    }
9522
9523    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9524        for GuestGetHostVsockEndpointRequest
9525    {
9526        #[inline(always)]
9527        fn new_empty() -> Self {
9528            Self {
9529                endpoint: fidl::new_empty!(
9530                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9531                    fidl::encoding::DefaultFuchsiaResourceDialect
9532                ),
9533            }
9534        }
9535
9536        #[inline]
9537        unsafe fn decode(
9538            &mut self,
9539            decoder: &mut fidl::encoding::Decoder<
9540                '_,
9541                fidl::encoding::DefaultFuchsiaResourceDialect,
9542            >,
9543            offset: usize,
9544            _depth: fidl::encoding::Depth,
9545        ) -> fidl::Result<()> {
9546            decoder.debug_check_bounds::<Self>(offset);
9547            // Verify that padding bytes are zero.
9548            fidl::decode!(
9549                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9550                fidl::encoding::DefaultFuchsiaResourceDialect,
9551                &mut self.endpoint,
9552                decoder,
9553                offset + 0,
9554                _depth
9555            )?;
9556            Ok(())
9557        }
9558    }
9559
9560    impl fidl::encoding::ResourceTypeMarker for GuestGetMemControllerRequest {
9561        type Borrowed<'a> = &'a mut Self;
9562        fn take_or_borrow<'a>(
9563            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9564        ) -> Self::Borrowed<'a> {
9565            value
9566        }
9567    }
9568
9569    unsafe impl fidl::encoding::TypeMarker for GuestGetMemControllerRequest {
9570        type Owned = Self;
9571
9572        #[inline(always)]
9573        fn inline_align(_context: fidl::encoding::Context) -> usize {
9574            4
9575        }
9576
9577        #[inline(always)]
9578        fn inline_size(_context: fidl::encoding::Context) -> usize {
9579            4
9580        }
9581    }
9582
9583    unsafe impl
9584        fidl::encoding::Encode<
9585            GuestGetMemControllerRequest,
9586            fidl::encoding::DefaultFuchsiaResourceDialect,
9587        > for &mut GuestGetMemControllerRequest
9588    {
9589        #[inline]
9590        unsafe fn encode(
9591            self,
9592            encoder: &mut fidl::encoding::Encoder<
9593                '_,
9594                fidl::encoding::DefaultFuchsiaResourceDialect,
9595            >,
9596            offset: usize,
9597            _depth: fidl::encoding::Depth,
9598        ) -> fidl::Result<()> {
9599            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9600            // Delegate to tuple encoding.
9601            fidl::encoding::Encode::<GuestGetMemControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9602                (
9603                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9604                ),
9605                encoder, offset, _depth
9606            )
9607        }
9608    }
9609    unsafe impl<
9610        T0: fidl::encoding::Encode<
9611                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9612                fidl::encoding::DefaultFuchsiaResourceDialect,
9613            >,
9614    >
9615        fidl::encoding::Encode<
9616            GuestGetMemControllerRequest,
9617            fidl::encoding::DefaultFuchsiaResourceDialect,
9618        > for (T0,)
9619    {
9620        #[inline]
9621        unsafe fn encode(
9622            self,
9623            encoder: &mut fidl::encoding::Encoder<
9624                '_,
9625                fidl::encoding::DefaultFuchsiaResourceDialect,
9626            >,
9627            offset: usize,
9628            depth: fidl::encoding::Depth,
9629        ) -> fidl::Result<()> {
9630            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9631            // Zero out padding regions. There's no need to apply masks
9632            // because the unmasked parts will be overwritten by fields.
9633            // Write the fields.
9634            self.0.encode(encoder, offset + 0, depth)?;
9635            Ok(())
9636        }
9637    }
9638
9639    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9640        for GuestGetMemControllerRequest
9641    {
9642        #[inline(always)]
9643        fn new_empty() -> Self {
9644            Self {
9645                controller: fidl::new_empty!(
9646                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9647                    fidl::encoding::DefaultFuchsiaResourceDialect
9648                ),
9649            }
9650        }
9651
9652        #[inline]
9653        unsafe fn decode(
9654            &mut self,
9655            decoder: &mut fidl::encoding::Decoder<
9656                '_,
9657                fidl::encoding::DefaultFuchsiaResourceDialect,
9658            >,
9659            offset: usize,
9660            _depth: fidl::encoding::Depth,
9661        ) -> fidl::Result<()> {
9662            decoder.debug_check_bounds::<Self>(offset);
9663            // Verify that padding bytes are zero.
9664            fidl::decode!(
9665                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9666                fidl::encoding::DefaultFuchsiaResourceDialect,
9667                &mut self.controller,
9668                decoder,
9669                offset + 0,
9670                _depth
9671            )?;
9672            Ok(())
9673        }
9674    }
9675
9676    impl fidl::encoding::ResourceTypeMarker for GuestGetSerialResponse {
9677        type Borrowed<'a> = &'a mut Self;
9678        fn take_or_borrow<'a>(
9679            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9680        ) -> Self::Borrowed<'a> {
9681            value
9682        }
9683    }
9684
9685    unsafe impl fidl::encoding::TypeMarker for GuestGetSerialResponse {
9686        type Owned = Self;
9687
9688        #[inline(always)]
9689        fn inline_align(_context: fidl::encoding::Context) -> usize {
9690            4
9691        }
9692
9693        #[inline(always)]
9694        fn inline_size(_context: fidl::encoding::Context) -> usize {
9695            4
9696        }
9697    }
9698
9699    unsafe impl
9700        fidl::encoding::Encode<
9701            GuestGetSerialResponse,
9702            fidl::encoding::DefaultFuchsiaResourceDialect,
9703        > for &mut GuestGetSerialResponse
9704    {
9705        #[inline]
9706        unsafe fn encode(
9707            self,
9708            encoder: &mut fidl::encoding::Encoder<
9709                '_,
9710                fidl::encoding::DefaultFuchsiaResourceDialect,
9711            >,
9712            offset: usize,
9713            _depth: fidl::encoding::Depth,
9714        ) -> fidl::Result<()> {
9715            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9716            // Delegate to tuple encoding.
9717            fidl::encoding::Encode::<
9718                GuestGetSerialResponse,
9719                fidl::encoding::DefaultFuchsiaResourceDialect,
9720            >::encode(
9721                (<fidl::encoding::HandleType<
9722                    fidl::Socket,
9723                    { fidl::ObjectType::SOCKET.into_raw() },
9724                    2147483648,
9725                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9726                    &mut self.socket
9727                ),),
9728                encoder,
9729                offset,
9730                _depth,
9731            )
9732        }
9733    }
9734    unsafe impl<
9735        T0: fidl::encoding::Encode<
9736                fidl::encoding::HandleType<
9737                    fidl::Socket,
9738                    { fidl::ObjectType::SOCKET.into_raw() },
9739                    2147483648,
9740                >,
9741                fidl::encoding::DefaultFuchsiaResourceDialect,
9742            >,
9743    >
9744        fidl::encoding::Encode<
9745            GuestGetSerialResponse,
9746            fidl::encoding::DefaultFuchsiaResourceDialect,
9747        > for (T0,)
9748    {
9749        #[inline]
9750        unsafe fn encode(
9751            self,
9752            encoder: &mut fidl::encoding::Encoder<
9753                '_,
9754                fidl::encoding::DefaultFuchsiaResourceDialect,
9755            >,
9756            offset: usize,
9757            depth: fidl::encoding::Depth,
9758        ) -> fidl::Result<()> {
9759            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9760            // Zero out padding regions. There's no need to apply masks
9761            // because the unmasked parts will be overwritten by fields.
9762            // Write the fields.
9763            self.0.encode(encoder, offset + 0, depth)?;
9764            Ok(())
9765        }
9766    }
9767
9768    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9769        for GuestGetSerialResponse
9770    {
9771        #[inline(always)]
9772        fn new_empty() -> Self {
9773            Self {
9774                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9775            }
9776        }
9777
9778        #[inline]
9779        unsafe fn decode(
9780            &mut self,
9781            decoder: &mut fidl::encoding::Decoder<
9782                '_,
9783                fidl::encoding::DefaultFuchsiaResourceDialect,
9784            >,
9785            offset: usize,
9786            _depth: fidl::encoding::Depth,
9787        ) -> fidl::Result<()> {
9788            decoder.debug_check_bounds::<Self>(offset);
9789            // Verify that padding bytes are zero.
9790            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
9791            Ok(())
9792        }
9793    }
9794
9795    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleBindRequest {
9796        type Borrowed<'a> = &'a mut Self;
9797        fn take_or_borrow<'a>(
9798            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9799        ) -> Self::Borrowed<'a> {
9800            value
9801        }
9802    }
9803
9804    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleBindRequest {
9805        type Owned = Self;
9806
9807        #[inline(always)]
9808        fn inline_align(_context: fidl::encoding::Context) -> usize {
9809            4
9810        }
9811
9812        #[inline(always)]
9813        fn inline_size(_context: fidl::encoding::Context) -> usize {
9814            4
9815        }
9816    }
9817
9818    unsafe impl
9819        fidl::encoding::Encode<
9820            GuestLifecycleBindRequest,
9821            fidl::encoding::DefaultFuchsiaResourceDialect,
9822        > for &mut GuestLifecycleBindRequest
9823    {
9824        #[inline]
9825        unsafe fn encode(
9826            self,
9827            encoder: &mut fidl::encoding::Encoder<
9828                '_,
9829                fidl::encoding::DefaultFuchsiaResourceDialect,
9830            >,
9831            offset: usize,
9832            _depth: fidl::encoding::Depth,
9833        ) -> fidl::Result<()> {
9834            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9835            // Delegate to tuple encoding.
9836            fidl::encoding::Encode::<GuestLifecycleBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9837                (
9838                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest),
9839                ),
9840                encoder, offset, _depth
9841            )
9842        }
9843    }
9844    unsafe impl<
9845        T0: fidl::encoding::Encode<
9846                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9847                fidl::encoding::DefaultFuchsiaResourceDialect,
9848            >,
9849    >
9850        fidl::encoding::Encode<
9851            GuestLifecycleBindRequest,
9852            fidl::encoding::DefaultFuchsiaResourceDialect,
9853        > for (T0,)
9854    {
9855        #[inline]
9856        unsafe fn encode(
9857            self,
9858            encoder: &mut fidl::encoding::Encoder<
9859                '_,
9860                fidl::encoding::DefaultFuchsiaResourceDialect,
9861            >,
9862            offset: usize,
9863            depth: fidl::encoding::Depth,
9864        ) -> fidl::Result<()> {
9865            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9866            // Zero out padding regions. There's no need to apply masks
9867            // because the unmasked parts will be overwritten by fields.
9868            // Write the fields.
9869            self.0.encode(encoder, offset + 0, depth)?;
9870            Ok(())
9871        }
9872    }
9873
9874    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9875        for GuestLifecycleBindRequest
9876    {
9877        #[inline(always)]
9878        fn new_empty() -> Self {
9879            Self {
9880                guest: fidl::new_empty!(
9881                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9882                    fidl::encoding::DefaultFuchsiaResourceDialect
9883                ),
9884            }
9885        }
9886
9887        #[inline]
9888        unsafe fn decode(
9889            &mut self,
9890            decoder: &mut fidl::encoding::Decoder<
9891                '_,
9892                fidl::encoding::DefaultFuchsiaResourceDialect,
9893            >,
9894            offset: usize,
9895            _depth: fidl::encoding::Depth,
9896        ) -> fidl::Result<()> {
9897            decoder.debug_check_bounds::<Self>(offset);
9898            // Verify that padding bytes are zero.
9899            fidl::decode!(
9900                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9901                fidl::encoding::DefaultFuchsiaResourceDialect,
9902                &mut self.guest,
9903                decoder,
9904                offset + 0,
9905                _depth
9906            )?;
9907            Ok(())
9908        }
9909    }
9910
9911    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleCreateRequest {
9912        type Borrowed<'a> = &'a mut Self;
9913        fn take_or_borrow<'a>(
9914            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9915        ) -> Self::Borrowed<'a> {
9916            value
9917        }
9918    }
9919
9920    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleCreateRequest {
9921        type Owned = Self;
9922
9923        #[inline(always)]
9924        fn inline_align(_context: fidl::encoding::Context) -> usize {
9925            8
9926        }
9927
9928        #[inline(always)]
9929        fn inline_size(_context: fidl::encoding::Context) -> usize {
9930            16
9931        }
9932    }
9933
9934    unsafe impl
9935        fidl::encoding::Encode<
9936            GuestLifecycleCreateRequest,
9937            fidl::encoding::DefaultFuchsiaResourceDialect,
9938        > for &mut GuestLifecycleCreateRequest
9939    {
9940        #[inline]
9941        unsafe fn encode(
9942            self,
9943            encoder: &mut fidl::encoding::Encoder<
9944                '_,
9945                fidl::encoding::DefaultFuchsiaResourceDialect,
9946            >,
9947            offset: usize,
9948            _depth: fidl::encoding::Depth,
9949        ) -> fidl::Result<()> {
9950            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
9951            // Delegate to tuple encoding.
9952            fidl::encoding::Encode::<
9953                GuestLifecycleCreateRequest,
9954                fidl::encoding::DefaultFuchsiaResourceDialect,
9955            >::encode(
9956                (<GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9957                    &mut self.guest_config,
9958                ),),
9959                encoder,
9960                offset,
9961                _depth,
9962            )
9963        }
9964    }
9965    unsafe impl<
9966        T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
9967    >
9968        fidl::encoding::Encode<
9969            GuestLifecycleCreateRequest,
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::<GuestLifecycleCreateRequest>(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 GuestLifecycleCreateRequest
9994    {
9995        #[inline(always)]
9996        fn new_empty() -> Self {
9997            Self {
9998                guest_config: fidl::new_empty!(
9999                    GuestConfig,
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                GuestConfig,
10019                fidl::encoding::DefaultFuchsiaResourceDialect,
10020                &mut self.guest_config,
10021                decoder,
10022                offset + 0,
10023                _depth
10024            )?;
10025            Ok(())
10026        }
10027    }
10028
10029    impl fidl::encoding::ResourceTypeMarker for GuestManagerConnectRequest {
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 GuestManagerConnectRequest {
10039        type Owned = Self;
10040
10041        #[inline(always)]
10042        fn inline_align(_context: fidl::encoding::Context) -> usize {
10043            4
10044        }
10045
10046        #[inline(always)]
10047        fn inline_size(_context: fidl::encoding::Context) -> usize {
10048            4
10049        }
10050    }
10051
10052    unsafe impl
10053        fidl::encoding::Encode<
10054            GuestManagerConnectRequest,
10055            fidl::encoding::DefaultFuchsiaResourceDialect,
10056        > for &mut GuestManagerConnectRequest
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::<GuestManagerConnectRequest>(offset);
10069            // Delegate to tuple encoding.
10070            fidl::encoding::Encode::<GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10071                (
10072                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10073                ),
10074                encoder, offset, _depth
10075            )
10076        }
10077    }
10078    unsafe impl<
10079        T0: fidl::encoding::Encode<
10080                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10081                fidl::encoding::DefaultFuchsiaResourceDialect,
10082            >,
10083    >
10084        fidl::encoding::Encode<
10085            GuestManagerConnectRequest,
10086            fidl::encoding::DefaultFuchsiaResourceDialect,
10087        > for (T0,)
10088    {
10089        #[inline]
10090        unsafe fn encode(
10091            self,
10092            encoder: &mut fidl::encoding::Encoder<
10093                '_,
10094                fidl::encoding::DefaultFuchsiaResourceDialect,
10095            >,
10096            offset: usize,
10097            depth: fidl::encoding::Depth,
10098        ) -> fidl::Result<()> {
10099            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
10100            // Zero out padding regions. There's no need to apply masks
10101            // because the unmasked parts will be overwritten by fields.
10102            // Write the fields.
10103            self.0.encode(encoder, offset + 0, depth)?;
10104            Ok(())
10105        }
10106    }
10107
10108    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10109        for GuestManagerConnectRequest
10110    {
10111        #[inline(always)]
10112        fn new_empty() -> Self {
10113            Self {
10114                controller: fidl::new_empty!(
10115                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10116                    fidl::encoding::DefaultFuchsiaResourceDialect
10117                ),
10118            }
10119        }
10120
10121        #[inline]
10122        unsafe fn decode(
10123            &mut self,
10124            decoder: &mut fidl::encoding::Decoder<
10125                '_,
10126                fidl::encoding::DefaultFuchsiaResourceDialect,
10127            >,
10128            offset: usize,
10129            _depth: fidl::encoding::Depth,
10130        ) -> fidl::Result<()> {
10131            decoder.debug_check_bounds::<Self>(offset);
10132            // Verify that padding bytes are zero.
10133            fidl::decode!(
10134                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10135                fidl::encoding::DefaultFuchsiaResourceDialect,
10136                &mut self.controller,
10137                decoder,
10138                offset + 0,
10139                _depth
10140            )?;
10141            Ok(())
10142        }
10143    }
10144
10145    impl fidl::encoding::ResourceTypeMarker for GuestManagerGetInfoResponse {
10146        type Borrowed<'a> = &'a mut Self;
10147        fn take_or_borrow<'a>(
10148            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10149        ) -> Self::Borrowed<'a> {
10150            value
10151        }
10152    }
10153
10154    unsafe impl fidl::encoding::TypeMarker for GuestManagerGetInfoResponse {
10155        type Owned = Self;
10156
10157        #[inline(always)]
10158        fn inline_align(_context: fidl::encoding::Context) -> usize {
10159            8
10160        }
10161
10162        #[inline(always)]
10163        fn inline_size(_context: fidl::encoding::Context) -> usize {
10164            16
10165        }
10166    }
10167
10168    unsafe impl
10169        fidl::encoding::Encode<
10170            GuestManagerGetInfoResponse,
10171            fidl::encoding::DefaultFuchsiaResourceDialect,
10172        > for &mut GuestManagerGetInfoResponse
10173    {
10174        #[inline]
10175        unsafe fn encode(
10176            self,
10177            encoder: &mut fidl::encoding::Encoder<
10178                '_,
10179                fidl::encoding::DefaultFuchsiaResourceDialect,
10180            >,
10181            offset: usize,
10182            _depth: fidl::encoding::Depth,
10183        ) -> fidl::Result<()> {
10184            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10185            // Delegate to tuple encoding.
10186            fidl::encoding::Encode::<
10187                GuestManagerGetInfoResponse,
10188                fidl::encoding::DefaultFuchsiaResourceDialect,
10189            >::encode(
10190                (<GuestInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.guest_info),),
10191                encoder,
10192                offset,
10193                _depth,
10194            )
10195        }
10196    }
10197    unsafe impl<
10198        T0: fidl::encoding::Encode<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10199    >
10200        fidl::encoding::Encode<
10201            GuestManagerGetInfoResponse,
10202            fidl::encoding::DefaultFuchsiaResourceDialect,
10203        > for (T0,)
10204    {
10205        #[inline]
10206        unsafe fn encode(
10207            self,
10208            encoder: &mut fidl::encoding::Encoder<
10209                '_,
10210                fidl::encoding::DefaultFuchsiaResourceDialect,
10211            >,
10212            offset: usize,
10213            depth: fidl::encoding::Depth,
10214        ) -> fidl::Result<()> {
10215            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10216            // Zero out padding regions. There's no need to apply masks
10217            // because the unmasked parts will be overwritten by fields.
10218            // Write the fields.
10219            self.0.encode(encoder, offset + 0, depth)?;
10220            Ok(())
10221        }
10222    }
10223
10224    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10225        for GuestManagerGetInfoResponse
10226    {
10227        #[inline(always)]
10228        fn new_empty() -> Self {
10229            Self {
10230                guest_info: fidl::new_empty!(
10231                    GuestInfo,
10232                    fidl::encoding::DefaultFuchsiaResourceDialect
10233                ),
10234            }
10235        }
10236
10237        #[inline]
10238        unsafe fn decode(
10239            &mut self,
10240            decoder: &mut fidl::encoding::Decoder<
10241                '_,
10242                fidl::encoding::DefaultFuchsiaResourceDialect,
10243            >,
10244            offset: usize,
10245            _depth: fidl::encoding::Depth,
10246        ) -> fidl::Result<()> {
10247            decoder.debug_check_bounds::<Self>(offset);
10248            // Verify that padding bytes are zero.
10249            fidl::decode!(
10250                GuestInfo,
10251                fidl::encoding::DefaultFuchsiaResourceDialect,
10252                &mut self.guest_info,
10253                decoder,
10254                offset + 0,
10255                _depth
10256            )?;
10257            Ok(())
10258        }
10259    }
10260
10261    impl fidl::encoding::ResourceTypeMarker for GuestManagerLaunchRequest {
10262        type Borrowed<'a> = &'a mut Self;
10263        fn take_or_borrow<'a>(
10264            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10265        ) -> Self::Borrowed<'a> {
10266            value
10267        }
10268    }
10269
10270    unsafe impl fidl::encoding::TypeMarker for GuestManagerLaunchRequest {
10271        type Owned = Self;
10272
10273        #[inline(always)]
10274        fn inline_align(_context: fidl::encoding::Context) -> usize {
10275            8
10276        }
10277
10278        #[inline(always)]
10279        fn inline_size(_context: fidl::encoding::Context) -> usize {
10280            24
10281        }
10282    }
10283
10284    unsafe impl
10285        fidl::encoding::Encode<
10286            GuestManagerLaunchRequest,
10287            fidl::encoding::DefaultFuchsiaResourceDialect,
10288        > for &mut GuestManagerLaunchRequest
10289    {
10290        #[inline]
10291        unsafe fn encode(
10292            self,
10293            encoder: &mut fidl::encoding::Encoder<
10294                '_,
10295                fidl::encoding::DefaultFuchsiaResourceDialect,
10296            >,
10297            offset: usize,
10298            _depth: fidl::encoding::Depth,
10299        ) -> fidl::Result<()> {
10300            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10301            // Delegate to tuple encoding.
10302            fidl::encoding::Encode::<GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10303                (
10304                    <GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest_config),
10305                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10306                ),
10307                encoder, offset, _depth
10308            )
10309        }
10310    }
10311    unsafe impl<
10312        T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
10313        T1: fidl::encoding::Encode<
10314                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10315                fidl::encoding::DefaultFuchsiaResourceDialect,
10316            >,
10317    >
10318        fidl::encoding::Encode<
10319            GuestManagerLaunchRequest,
10320            fidl::encoding::DefaultFuchsiaResourceDialect,
10321        > for (T0, T1)
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::<GuestManagerLaunchRequest>(offset);
10334            // Zero out padding regions. There's no need to apply masks
10335            // because the unmasked parts will be overwritten by fields.
10336            unsafe {
10337                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10338                (ptr as *mut u64).write_unaligned(0);
10339            }
10340            // Write the fields.
10341            self.0.encode(encoder, offset + 0, depth)?;
10342            self.1.encode(encoder, offset + 16, depth)?;
10343            Ok(())
10344        }
10345    }
10346
10347    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10348        for GuestManagerLaunchRequest
10349    {
10350        #[inline(always)]
10351        fn new_empty() -> Self {
10352            Self {
10353                guest_config: fidl::new_empty!(
10354                    GuestConfig,
10355                    fidl::encoding::DefaultFuchsiaResourceDialect
10356                ),
10357                controller: fidl::new_empty!(
10358                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10359                    fidl::encoding::DefaultFuchsiaResourceDialect
10360                ),
10361            }
10362        }
10363
10364        #[inline]
10365        unsafe fn decode(
10366            &mut self,
10367            decoder: &mut fidl::encoding::Decoder<
10368                '_,
10369                fidl::encoding::DefaultFuchsiaResourceDialect,
10370            >,
10371            offset: usize,
10372            _depth: fidl::encoding::Depth,
10373        ) -> fidl::Result<()> {
10374            decoder.debug_check_bounds::<Self>(offset);
10375            // Verify that padding bytes are zero.
10376            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10377            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10378            let mask = 0xffffffff00000000u64;
10379            let maskedval = padval & mask;
10380            if maskedval != 0 {
10381                return Err(fidl::Error::NonZeroPadding {
10382                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10383                });
10384            }
10385            fidl::decode!(
10386                GuestConfig,
10387                fidl::encoding::DefaultFuchsiaResourceDialect,
10388                &mut self.guest_config,
10389                decoder,
10390                offset + 0,
10391                _depth
10392            )?;
10393            fidl::decode!(
10394                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10395                fidl::encoding::DefaultFuchsiaResourceDialect,
10396                &mut self.controller,
10397                decoder,
10398                offset + 16,
10399                _depth
10400            )?;
10401            Ok(())
10402        }
10403    }
10404
10405    impl fidl::encoding::ResourceTypeMarker for GuestGetConsoleResponse {
10406        type Borrowed<'a> = &'a mut Self;
10407        fn take_or_borrow<'a>(
10408            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10409        ) -> Self::Borrowed<'a> {
10410            value
10411        }
10412    }
10413
10414    unsafe impl fidl::encoding::TypeMarker for GuestGetConsoleResponse {
10415        type Owned = Self;
10416
10417        #[inline(always)]
10418        fn inline_align(_context: fidl::encoding::Context) -> usize {
10419            4
10420        }
10421
10422        #[inline(always)]
10423        fn inline_size(_context: fidl::encoding::Context) -> usize {
10424            4
10425        }
10426    }
10427
10428    unsafe impl
10429        fidl::encoding::Encode<
10430            GuestGetConsoleResponse,
10431            fidl::encoding::DefaultFuchsiaResourceDialect,
10432        > for &mut GuestGetConsoleResponse
10433    {
10434        #[inline]
10435        unsafe fn encode(
10436            self,
10437            encoder: &mut fidl::encoding::Encoder<
10438                '_,
10439                fidl::encoding::DefaultFuchsiaResourceDialect,
10440            >,
10441            offset: usize,
10442            _depth: fidl::encoding::Depth,
10443        ) -> fidl::Result<()> {
10444            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10445            // Delegate to tuple encoding.
10446            fidl::encoding::Encode::<
10447                GuestGetConsoleResponse,
10448                fidl::encoding::DefaultFuchsiaResourceDialect,
10449            >::encode(
10450                (<fidl::encoding::HandleType<
10451                    fidl::Socket,
10452                    { fidl::ObjectType::SOCKET.into_raw() },
10453                    2147483648,
10454                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10455                    &mut self.socket
10456                ),),
10457                encoder,
10458                offset,
10459                _depth,
10460            )
10461        }
10462    }
10463    unsafe impl<
10464        T0: fidl::encoding::Encode<
10465                fidl::encoding::HandleType<
10466                    fidl::Socket,
10467                    { fidl::ObjectType::SOCKET.into_raw() },
10468                    2147483648,
10469                >,
10470                fidl::encoding::DefaultFuchsiaResourceDialect,
10471            >,
10472    >
10473        fidl::encoding::Encode<
10474            GuestGetConsoleResponse,
10475            fidl::encoding::DefaultFuchsiaResourceDialect,
10476        > for (T0,)
10477    {
10478        #[inline]
10479        unsafe fn encode(
10480            self,
10481            encoder: &mut fidl::encoding::Encoder<
10482                '_,
10483                fidl::encoding::DefaultFuchsiaResourceDialect,
10484            >,
10485            offset: usize,
10486            depth: fidl::encoding::Depth,
10487        ) -> fidl::Result<()> {
10488            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10489            // Zero out padding regions. There's no need to apply masks
10490            // because the unmasked parts will be overwritten by fields.
10491            // Write the fields.
10492            self.0.encode(encoder, offset + 0, depth)?;
10493            Ok(())
10494        }
10495    }
10496
10497    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10498        for GuestGetConsoleResponse
10499    {
10500        #[inline(always)]
10501        fn new_empty() -> Self {
10502            Self {
10503                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10504            }
10505        }
10506
10507        #[inline]
10508        unsafe fn decode(
10509            &mut self,
10510            decoder: &mut fidl::encoding::Decoder<
10511                '_,
10512                fidl::encoding::DefaultFuchsiaResourceDialect,
10513            >,
10514            offset: usize,
10515            _depth: fidl::encoding::Depth,
10516        ) -> fidl::Result<()> {
10517            decoder.debug_check_bounds::<Self>(offset);
10518            // Verify that padding bytes are zero.
10519            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10520            Ok(())
10521        }
10522    }
10523
10524    impl fidl::encoding::ResourceTypeMarker for HostVsockAcceptorAcceptResponse {
10525        type Borrowed<'a> = &'a mut Self;
10526        fn take_or_borrow<'a>(
10527            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10528        ) -> Self::Borrowed<'a> {
10529            value
10530        }
10531    }
10532
10533    unsafe impl fidl::encoding::TypeMarker for HostVsockAcceptorAcceptResponse {
10534        type Owned = Self;
10535
10536        #[inline(always)]
10537        fn inline_align(_context: fidl::encoding::Context) -> usize {
10538            4
10539        }
10540
10541        #[inline(always)]
10542        fn inline_size(_context: fidl::encoding::Context) -> usize {
10543            4
10544        }
10545    }
10546
10547    unsafe impl
10548        fidl::encoding::Encode<
10549            HostVsockAcceptorAcceptResponse,
10550            fidl::encoding::DefaultFuchsiaResourceDialect,
10551        > for &mut HostVsockAcceptorAcceptResponse
10552    {
10553        #[inline]
10554        unsafe fn encode(
10555            self,
10556            encoder: &mut fidl::encoding::Encoder<
10557                '_,
10558                fidl::encoding::DefaultFuchsiaResourceDialect,
10559            >,
10560            offset: usize,
10561            _depth: fidl::encoding::Depth,
10562        ) -> fidl::Result<()> {
10563            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10564            // Delegate to tuple encoding.
10565            fidl::encoding::Encode::<
10566                HostVsockAcceptorAcceptResponse,
10567                fidl::encoding::DefaultFuchsiaResourceDialect,
10568            >::encode(
10569                (<fidl::encoding::HandleType<
10570                    fidl::Socket,
10571                    { fidl::ObjectType::SOCKET.into_raw() },
10572                    2147483648,
10573                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10574                    &mut self.socket
10575                ),),
10576                encoder,
10577                offset,
10578                _depth,
10579            )
10580        }
10581    }
10582    unsafe impl<
10583        T0: fidl::encoding::Encode<
10584                fidl::encoding::HandleType<
10585                    fidl::Socket,
10586                    { fidl::ObjectType::SOCKET.into_raw() },
10587                    2147483648,
10588                >,
10589                fidl::encoding::DefaultFuchsiaResourceDialect,
10590            >,
10591    >
10592        fidl::encoding::Encode<
10593            HostVsockAcceptorAcceptResponse,
10594            fidl::encoding::DefaultFuchsiaResourceDialect,
10595        > for (T0,)
10596    {
10597        #[inline]
10598        unsafe fn encode(
10599            self,
10600            encoder: &mut fidl::encoding::Encoder<
10601                '_,
10602                fidl::encoding::DefaultFuchsiaResourceDialect,
10603            >,
10604            offset: usize,
10605            depth: fidl::encoding::Depth,
10606        ) -> fidl::Result<()> {
10607            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10608            // Zero out padding regions. There's no need to apply masks
10609            // because the unmasked parts will be overwritten by fields.
10610            // Write the fields.
10611            self.0.encode(encoder, offset + 0, depth)?;
10612            Ok(())
10613        }
10614    }
10615
10616    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10617        for HostVsockAcceptorAcceptResponse
10618    {
10619        #[inline(always)]
10620        fn new_empty() -> Self {
10621            Self {
10622                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10623            }
10624        }
10625
10626        #[inline]
10627        unsafe fn decode(
10628            &mut self,
10629            decoder: &mut fidl::encoding::Decoder<
10630                '_,
10631                fidl::encoding::DefaultFuchsiaResourceDialect,
10632            >,
10633            offset: usize,
10634            _depth: fidl::encoding::Depth,
10635        ) -> fidl::Result<()> {
10636            decoder.debug_check_bounds::<Self>(offset);
10637            // Verify that padding bytes are zero.
10638            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10639            Ok(())
10640        }
10641    }
10642
10643    impl fidl::encoding::ResourceTypeMarker for HostVsockEndpointConnectResponse {
10644        type Borrowed<'a> = &'a mut Self;
10645        fn take_or_borrow<'a>(
10646            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10647        ) -> Self::Borrowed<'a> {
10648            value
10649        }
10650    }
10651
10652    unsafe impl fidl::encoding::TypeMarker for HostVsockEndpointConnectResponse {
10653        type Owned = Self;
10654
10655        #[inline(always)]
10656        fn inline_align(_context: fidl::encoding::Context) -> usize {
10657            4
10658        }
10659
10660        #[inline(always)]
10661        fn inline_size(_context: fidl::encoding::Context) -> usize {
10662            4
10663        }
10664    }
10665
10666    unsafe impl
10667        fidl::encoding::Encode<
10668            HostVsockEndpointConnectResponse,
10669            fidl::encoding::DefaultFuchsiaResourceDialect,
10670        > for &mut HostVsockEndpointConnectResponse
10671    {
10672        #[inline]
10673        unsafe fn encode(
10674            self,
10675            encoder: &mut fidl::encoding::Encoder<
10676                '_,
10677                fidl::encoding::DefaultFuchsiaResourceDialect,
10678            >,
10679            offset: usize,
10680            _depth: fidl::encoding::Depth,
10681        ) -> fidl::Result<()> {
10682            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10683            // Delegate to tuple encoding.
10684            fidl::encoding::Encode::<
10685                HostVsockEndpointConnectResponse,
10686                fidl::encoding::DefaultFuchsiaResourceDialect,
10687            >::encode(
10688                (<fidl::encoding::HandleType<
10689                    fidl::Socket,
10690                    { fidl::ObjectType::SOCKET.into_raw() },
10691                    2147483648,
10692                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10693                    &mut self.socket
10694                ),),
10695                encoder,
10696                offset,
10697                _depth,
10698            )
10699        }
10700    }
10701    unsafe impl<
10702        T0: fidl::encoding::Encode<
10703                fidl::encoding::HandleType<
10704                    fidl::Socket,
10705                    { fidl::ObjectType::SOCKET.into_raw() },
10706                    2147483648,
10707                >,
10708                fidl::encoding::DefaultFuchsiaResourceDialect,
10709            >,
10710    >
10711        fidl::encoding::Encode<
10712            HostVsockEndpointConnectResponse,
10713            fidl::encoding::DefaultFuchsiaResourceDialect,
10714        > for (T0,)
10715    {
10716        #[inline]
10717        unsafe fn encode(
10718            self,
10719            encoder: &mut fidl::encoding::Encoder<
10720                '_,
10721                fidl::encoding::DefaultFuchsiaResourceDialect,
10722            >,
10723            offset: usize,
10724            depth: fidl::encoding::Depth,
10725        ) -> fidl::Result<()> {
10726            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10727            // Zero out padding regions. There's no need to apply masks
10728            // because the unmasked parts will be overwritten by fields.
10729            // Write the fields.
10730            self.0.encode(encoder, offset + 0, depth)?;
10731            Ok(())
10732        }
10733    }
10734
10735    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10736        for HostVsockEndpointConnectResponse
10737    {
10738        #[inline(always)]
10739        fn new_empty() -> Self {
10740            Self {
10741                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10742            }
10743        }
10744
10745        #[inline]
10746        unsafe fn decode(
10747            &mut self,
10748            decoder: &mut fidl::encoding::Decoder<
10749                '_,
10750                fidl::encoding::DefaultFuchsiaResourceDialect,
10751            >,
10752            offset: usize,
10753            _depth: fidl::encoding::Depth,
10754        ) -> fidl::Result<()> {
10755            decoder.debug_check_bounds::<Self>(offset);
10756            // Verify that padding bytes are zero.
10757            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10758            Ok(())
10759        }
10760    }
10761
10762    impl fidl::encoding::ResourceTypeMarker for Listener {
10763        type Borrowed<'a> = &'a mut Self;
10764        fn take_or_borrow<'a>(
10765            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10766        ) -> Self::Borrowed<'a> {
10767            value
10768        }
10769    }
10770
10771    unsafe impl fidl::encoding::TypeMarker for Listener {
10772        type Owned = Self;
10773
10774        #[inline(always)]
10775        fn inline_align(_context: fidl::encoding::Context) -> usize {
10776            4
10777        }
10778
10779        #[inline(always)]
10780        fn inline_size(_context: fidl::encoding::Context) -> usize {
10781            8
10782        }
10783    }
10784
10785    unsafe impl fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>
10786        for &mut Listener
10787    {
10788        #[inline]
10789        unsafe fn encode(
10790            self,
10791            encoder: &mut fidl::encoding::Encoder<
10792                '_,
10793                fidl::encoding::DefaultFuchsiaResourceDialect,
10794            >,
10795            offset: usize,
10796            _depth: fidl::encoding::Depth,
10797        ) -> fidl::Result<()> {
10798            encoder.debug_check_bounds::<Listener>(offset);
10799            // Delegate to tuple encoding.
10800            fidl::encoding::Encode::<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10801                (
10802                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.port),
10803                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.acceptor),
10804                ),
10805                encoder, offset, _depth
10806            )
10807        }
10808    }
10809    unsafe impl<
10810        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
10811        T1: fidl::encoding::Encode<
10812                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10813                fidl::encoding::DefaultFuchsiaResourceDialect,
10814            >,
10815    > fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0, T1)
10816    {
10817        #[inline]
10818        unsafe fn encode(
10819            self,
10820            encoder: &mut fidl::encoding::Encoder<
10821                '_,
10822                fidl::encoding::DefaultFuchsiaResourceDialect,
10823            >,
10824            offset: usize,
10825            depth: fidl::encoding::Depth,
10826        ) -> fidl::Result<()> {
10827            encoder.debug_check_bounds::<Listener>(offset);
10828            // Zero out padding regions. There's no need to apply masks
10829            // because the unmasked parts will be overwritten by fields.
10830            // Write the fields.
10831            self.0.encode(encoder, offset + 0, depth)?;
10832            self.1.encode(encoder, offset + 4, depth)?;
10833            Ok(())
10834        }
10835    }
10836
10837    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Listener {
10838        #[inline(always)]
10839        fn new_empty() -> Self {
10840            Self {
10841                port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
10842                acceptor: fidl::new_empty!(
10843                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10844                    fidl::encoding::DefaultFuchsiaResourceDialect
10845                ),
10846            }
10847        }
10848
10849        #[inline]
10850        unsafe fn decode(
10851            &mut self,
10852            decoder: &mut fidl::encoding::Decoder<
10853                '_,
10854                fidl::encoding::DefaultFuchsiaResourceDialect,
10855            >,
10856            offset: usize,
10857            _depth: fidl::encoding::Depth,
10858        ) -> fidl::Result<()> {
10859            decoder.debug_check_bounds::<Self>(offset);
10860            // Verify that padding bytes are zero.
10861            fidl::decode!(
10862                u32,
10863                fidl::encoding::DefaultFuchsiaResourceDialect,
10864                &mut self.port,
10865                decoder,
10866                offset + 0,
10867                _depth
10868            )?;
10869            fidl::decode!(
10870                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10871                fidl::encoding::DefaultFuchsiaResourceDialect,
10872                &mut self.acceptor,
10873                decoder,
10874                offset + 4,
10875                _depth
10876            )?;
10877            Ok(())
10878        }
10879    }
10880
10881    impl GuestConfig {
10882        #[inline(always)]
10883        fn max_ordinal_present(&self) -> u64 {
10884            if let Some(_) = self.virtio_mem_region_alignment {
10885                return 25;
10886            }
10887            if let Some(_) = self.virtio_mem_region_size {
10888                return 24;
10889            }
10890            if let Some(_) = self.virtio_mem_block_size {
10891                return 23;
10892            }
10893            if let Some(_) = self.virtio_mem {
10894                return 22;
10895            }
10896            if let Some(_) = self.vsock_listeners {
10897                return 21;
10898            }
10899            if let Some(_) = self.virtio_sound_input {
10900                return 20;
10901            }
10902            if let Some(_) = self.virtio_sound {
10903                return 19;
10904            }
10905            if let Some(_) = self.virtio_vsock {
10906                return 18;
10907            }
10908            if let Some(_) = self.virtio_rng {
10909                return 17;
10910            }
10911            if let Some(_) = self.virtio_gpu {
10912                return 16;
10913            }
10914            if let Some(_) = self.virtio_console {
10915                return 15;
10916            }
10917            if let Some(_) = self.virtio_balloon {
10918                return 14;
10919            }
10920            if let Some(_) = self.default_net {
10921                return 13;
10922            }
10923            if let Some(_) = self.net_devices {
10924                return 10;
10925            }
10926            if let Some(_) = self.block_devices {
10927                return 9;
10928            }
10929            if let Some(_) = self.guest_memory {
10930                return 8;
10931            }
10932            if let Some(_) = self.cpus {
10933                return 7;
10934            }
10935            if let Some(_) = self.cmdline_add {
10936                return 6;
10937            }
10938            if let Some(_) = self.cmdline {
10939                return 5;
10940            }
10941            if let Some(_) = self.dtb_overlay {
10942                return 4;
10943            }
10944            if let Some(_) = self.ramdisk {
10945                return 3;
10946            }
10947            if let Some(_) = self.kernel {
10948                return 2;
10949            }
10950            if let Some(_) = self.kernel_type {
10951                return 1;
10952            }
10953            0
10954        }
10955    }
10956
10957    impl fidl::encoding::ResourceTypeMarker for GuestConfig {
10958        type Borrowed<'a> = &'a mut Self;
10959        fn take_or_borrow<'a>(
10960            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10961        ) -> Self::Borrowed<'a> {
10962            value
10963        }
10964    }
10965
10966    unsafe impl fidl::encoding::TypeMarker for GuestConfig {
10967        type Owned = Self;
10968
10969        #[inline(always)]
10970        fn inline_align(_context: fidl::encoding::Context) -> usize {
10971            8
10972        }
10973
10974        #[inline(always)]
10975        fn inline_size(_context: fidl::encoding::Context) -> usize {
10976            16
10977        }
10978    }
10979
10980    unsafe impl fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
10981        for &mut GuestConfig
10982    {
10983        unsafe fn encode(
10984            self,
10985            encoder: &mut fidl::encoding::Encoder<
10986                '_,
10987                fidl::encoding::DefaultFuchsiaResourceDialect,
10988            >,
10989            offset: usize,
10990            mut depth: fidl::encoding::Depth,
10991        ) -> fidl::Result<()> {
10992            encoder.debug_check_bounds::<GuestConfig>(offset);
10993            // Vector header
10994            let max_ordinal: u64 = self.max_ordinal_present();
10995            encoder.write_num(max_ordinal, offset);
10996            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10997            // Calling encoder.out_of_line_offset(0) is not allowed.
10998            if max_ordinal == 0 {
10999                return Ok(());
11000            }
11001            depth.increment()?;
11002            let envelope_size = 8;
11003            let bytes_len = max_ordinal as usize * envelope_size;
11004            #[allow(unused_variables)]
11005            let offset = encoder.out_of_line_offset(bytes_len);
11006            let mut _prev_end_offset: usize = 0;
11007            if 1 > max_ordinal {
11008                return Ok(());
11009            }
11010
11011            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11012            // are envelope_size bytes.
11013            let cur_offset: usize = (1 - 1) * envelope_size;
11014
11015            // Zero reserved fields.
11016            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11017
11018            // Safety:
11019            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11020            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11021            //   envelope_size bytes, there is always sufficient room.
11022            fidl::encoding::encode_in_envelope_optional::<
11023                KernelType,
11024                fidl::encoding::DefaultFuchsiaResourceDialect,
11025            >(
11026                self.kernel_type
11027                    .as_ref()
11028                    .map(<KernelType as fidl::encoding::ValueTypeMarker>::borrow),
11029                encoder,
11030                offset + cur_offset,
11031                depth,
11032            )?;
11033
11034            _prev_end_offset = cur_offset + envelope_size;
11035            if 2 > max_ordinal {
11036                return Ok(());
11037            }
11038
11039            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11040            // are envelope_size bytes.
11041            let cur_offset: usize = (2 - 1) * envelope_size;
11042
11043            // Zero reserved fields.
11044            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11045
11046            // Safety:
11047            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11048            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11049            //   envelope_size bytes, there is always sufficient room.
11050            fidl::encoding::encode_in_envelope_optional::<
11051                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11052                fidl::encoding::DefaultFuchsiaResourceDialect,
11053            >(
11054                self.kernel.as_mut().map(
11055                    <fidl::encoding::Endpoint<
11056                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11057                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11058                ),
11059                encoder,
11060                offset + cur_offset,
11061                depth,
11062            )?;
11063
11064            _prev_end_offset = cur_offset + envelope_size;
11065            if 3 > max_ordinal {
11066                return Ok(());
11067            }
11068
11069            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11070            // are envelope_size bytes.
11071            let cur_offset: usize = (3 - 1) * envelope_size;
11072
11073            // Zero reserved fields.
11074            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11075
11076            // Safety:
11077            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11078            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11079            //   envelope_size bytes, there is always sufficient room.
11080            fidl::encoding::encode_in_envelope_optional::<
11081                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11082                fidl::encoding::DefaultFuchsiaResourceDialect,
11083            >(
11084                self.ramdisk.as_mut().map(
11085                    <fidl::encoding::Endpoint<
11086                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11087                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11088                ),
11089                encoder,
11090                offset + cur_offset,
11091                depth,
11092            )?;
11093
11094            _prev_end_offset = cur_offset + envelope_size;
11095            if 4 > max_ordinal {
11096                return Ok(());
11097            }
11098
11099            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11100            // are envelope_size bytes.
11101            let cur_offset: usize = (4 - 1) * envelope_size;
11102
11103            // Zero reserved fields.
11104            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11105
11106            // Safety:
11107            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11108            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11109            //   envelope_size bytes, there is always sufficient room.
11110            fidl::encoding::encode_in_envelope_optional::<
11111                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11112                fidl::encoding::DefaultFuchsiaResourceDialect,
11113            >(
11114                self.dtb_overlay.as_mut().map(
11115                    <fidl::encoding::Endpoint<
11116                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11117                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11118                ),
11119                encoder,
11120                offset + cur_offset,
11121                depth,
11122            )?;
11123
11124            _prev_end_offset = cur_offset + envelope_size;
11125            if 5 > 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 = (5 - 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                fidl::encoding::UnboundedString,
11142                fidl::encoding::DefaultFuchsiaResourceDialect,
11143            >(
11144                self.cmdline.as_ref().map(
11145                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
11146                ),
11147                encoder,
11148                offset + cur_offset,
11149                depth,
11150            )?;
11151
11152            _prev_end_offset = cur_offset + envelope_size;
11153            if 6 > 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 = (6 - 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::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11169            self.cmdline_add.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow),
11170            encoder, offset + cur_offset, depth
11171        )?;
11172
11173            _prev_end_offset = cur_offset + envelope_size;
11174            if 7 > max_ordinal {
11175                return Ok(());
11176            }
11177
11178            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11179            // are envelope_size bytes.
11180            let cur_offset: usize = (7 - 1) * envelope_size;
11181
11182            // Zero reserved fields.
11183            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11184
11185            // Safety:
11186            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11187            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11188            //   envelope_size bytes, there is always sufficient room.
11189            fidl::encoding::encode_in_envelope_optional::<
11190                u8,
11191                fidl::encoding::DefaultFuchsiaResourceDialect,
11192            >(
11193                self.cpus.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
11194                encoder,
11195                offset + cur_offset,
11196                depth,
11197            )?;
11198
11199            _prev_end_offset = cur_offset + envelope_size;
11200            if 8 > max_ordinal {
11201                return Ok(());
11202            }
11203
11204            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11205            // are envelope_size bytes.
11206            let cur_offset: usize = (8 - 1) * envelope_size;
11207
11208            // Zero reserved fields.
11209            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11210
11211            // Safety:
11212            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11213            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11214            //   envelope_size bytes, there is always sufficient room.
11215            fidl::encoding::encode_in_envelope_optional::<
11216                u64,
11217                fidl::encoding::DefaultFuchsiaResourceDialect,
11218            >(
11219                self.guest_memory.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11220                encoder,
11221                offset + cur_offset,
11222                depth,
11223            )?;
11224
11225            _prev_end_offset = cur_offset + envelope_size;
11226            if 9 > max_ordinal {
11227                return Ok(());
11228            }
11229
11230            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11231            // are envelope_size bytes.
11232            let cur_offset: usize = (9 - 1) * envelope_size;
11233
11234            // Zero reserved fields.
11235            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11236
11237            // Safety:
11238            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11239            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11240            //   envelope_size bytes, there is always sufficient room.
11241            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11242            self.block_devices.as_mut().map(<fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11243            encoder, offset + cur_offset, depth
11244        )?;
11245
11246            _prev_end_offset = cur_offset + envelope_size;
11247            if 10 > max_ordinal {
11248                return Ok(());
11249            }
11250
11251            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11252            // are envelope_size bytes.
11253            let cur_offset: usize = (10 - 1) * envelope_size;
11254
11255            // Zero reserved fields.
11256            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11257
11258            // Safety:
11259            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11260            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11261            //   envelope_size bytes, there is always sufficient room.
11262            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11263            self.net_devices.as_ref().map(<fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11264            encoder, offset + cur_offset, depth
11265        )?;
11266
11267            _prev_end_offset = cur_offset + envelope_size;
11268            if 13 > max_ordinal {
11269                return Ok(());
11270            }
11271
11272            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11273            // are envelope_size bytes.
11274            let cur_offset: usize = (13 - 1) * envelope_size;
11275
11276            // Zero reserved fields.
11277            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11278
11279            // Safety:
11280            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11281            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11282            //   envelope_size bytes, there is always sufficient room.
11283            fidl::encoding::encode_in_envelope_optional::<
11284                bool,
11285                fidl::encoding::DefaultFuchsiaResourceDialect,
11286            >(
11287                self.default_net.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11288                encoder,
11289                offset + cur_offset,
11290                depth,
11291            )?;
11292
11293            _prev_end_offset = cur_offset + envelope_size;
11294            if 14 > max_ordinal {
11295                return Ok(());
11296            }
11297
11298            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11299            // are envelope_size bytes.
11300            let cur_offset: usize = (14 - 1) * envelope_size;
11301
11302            // Zero reserved fields.
11303            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11304
11305            // Safety:
11306            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11307            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11308            //   envelope_size bytes, there is always sufficient room.
11309            fidl::encoding::encode_in_envelope_optional::<
11310                bool,
11311                fidl::encoding::DefaultFuchsiaResourceDialect,
11312            >(
11313                self.virtio_balloon.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11314                encoder,
11315                offset + cur_offset,
11316                depth,
11317            )?;
11318
11319            _prev_end_offset = cur_offset + envelope_size;
11320            if 15 > max_ordinal {
11321                return Ok(());
11322            }
11323
11324            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11325            // are envelope_size bytes.
11326            let cur_offset: usize = (15 - 1) * envelope_size;
11327
11328            // Zero reserved fields.
11329            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11330
11331            // Safety:
11332            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11333            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11334            //   envelope_size bytes, there is always sufficient room.
11335            fidl::encoding::encode_in_envelope_optional::<
11336                bool,
11337                fidl::encoding::DefaultFuchsiaResourceDialect,
11338            >(
11339                self.virtio_console.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11340                encoder,
11341                offset + cur_offset,
11342                depth,
11343            )?;
11344
11345            _prev_end_offset = cur_offset + envelope_size;
11346            if 16 > max_ordinal {
11347                return Ok(());
11348            }
11349
11350            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11351            // are envelope_size bytes.
11352            let cur_offset: usize = (16 - 1) * envelope_size;
11353
11354            // Zero reserved fields.
11355            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11356
11357            // Safety:
11358            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11359            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11360            //   envelope_size bytes, there is always sufficient room.
11361            fidl::encoding::encode_in_envelope_optional::<
11362                bool,
11363                fidl::encoding::DefaultFuchsiaResourceDialect,
11364            >(
11365                self.virtio_gpu.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11366                encoder,
11367                offset + cur_offset,
11368                depth,
11369            )?;
11370
11371            _prev_end_offset = cur_offset + envelope_size;
11372            if 17 > max_ordinal {
11373                return Ok(());
11374            }
11375
11376            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11377            // are envelope_size bytes.
11378            let cur_offset: usize = (17 - 1) * envelope_size;
11379
11380            // Zero reserved fields.
11381            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11382
11383            // Safety:
11384            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11385            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11386            //   envelope_size bytes, there is always sufficient room.
11387            fidl::encoding::encode_in_envelope_optional::<
11388                bool,
11389                fidl::encoding::DefaultFuchsiaResourceDialect,
11390            >(
11391                self.virtio_rng.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11392                encoder,
11393                offset + cur_offset,
11394                depth,
11395            )?;
11396
11397            _prev_end_offset = cur_offset + envelope_size;
11398            if 18 > max_ordinal {
11399                return Ok(());
11400            }
11401
11402            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11403            // are envelope_size bytes.
11404            let cur_offset: usize = (18 - 1) * envelope_size;
11405
11406            // Zero reserved fields.
11407            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11408
11409            // Safety:
11410            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11411            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11412            //   envelope_size bytes, there is always sufficient room.
11413            fidl::encoding::encode_in_envelope_optional::<
11414                bool,
11415                fidl::encoding::DefaultFuchsiaResourceDialect,
11416            >(
11417                self.virtio_vsock.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11418                encoder,
11419                offset + cur_offset,
11420                depth,
11421            )?;
11422
11423            _prev_end_offset = cur_offset + envelope_size;
11424            if 19 > max_ordinal {
11425                return Ok(());
11426            }
11427
11428            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11429            // are envelope_size bytes.
11430            let cur_offset: usize = (19 - 1) * envelope_size;
11431
11432            // Zero reserved fields.
11433            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11434
11435            // Safety:
11436            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11437            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11438            //   envelope_size bytes, there is always sufficient room.
11439            fidl::encoding::encode_in_envelope_optional::<
11440                bool,
11441                fidl::encoding::DefaultFuchsiaResourceDialect,
11442            >(
11443                self.virtio_sound.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11444                encoder,
11445                offset + cur_offset,
11446                depth,
11447            )?;
11448
11449            _prev_end_offset = cur_offset + envelope_size;
11450            if 20 > max_ordinal {
11451                return Ok(());
11452            }
11453
11454            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11455            // are envelope_size bytes.
11456            let cur_offset: usize = (20 - 1) * envelope_size;
11457
11458            // Zero reserved fields.
11459            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11460
11461            // Safety:
11462            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11463            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11464            //   envelope_size bytes, there is always sufficient room.
11465            fidl::encoding::encode_in_envelope_optional::<
11466                bool,
11467                fidl::encoding::DefaultFuchsiaResourceDialect,
11468            >(
11469                self.virtio_sound_input
11470                    .as_ref()
11471                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11472                encoder,
11473                offset + cur_offset,
11474                depth,
11475            )?;
11476
11477            _prev_end_offset = cur_offset + envelope_size;
11478            if 21 > max_ordinal {
11479                return Ok(());
11480            }
11481
11482            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11483            // are envelope_size bytes.
11484            let cur_offset: usize = (21 - 1) * envelope_size;
11485
11486            // Zero reserved fields.
11487            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11488
11489            // Safety:
11490            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11491            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11492            //   envelope_size bytes, there is always sufficient room.
11493            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Listener>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11494            self.vsock_listeners.as_mut().map(<fidl::encoding::UnboundedVector<Listener> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11495            encoder, offset + cur_offset, depth
11496        )?;
11497
11498            _prev_end_offset = cur_offset + envelope_size;
11499            if 22 > max_ordinal {
11500                return Ok(());
11501            }
11502
11503            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11504            // are envelope_size bytes.
11505            let cur_offset: usize = (22 - 1) * envelope_size;
11506
11507            // Zero reserved fields.
11508            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11509
11510            // Safety:
11511            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11512            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11513            //   envelope_size bytes, there is always sufficient room.
11514            fidl::encoding::encode_in_envelope_optional::<
11515                bool,
11516                fidl::encoding::DefaultFuchsiaResourceDialect,
11517            >(
11518                self.virtio_mem.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11519                encoder,
11520                offset + cur_offset,
11521                depth,
11522            )?;
11523
11524            _prev_end_offset = cur_offset + envelope_size;
11525            if 23 > max_ordinal {
11526                return Ok(());
11527            }
11528
11529            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11530            // are envelope_size bytes.
11531            let cur_offset: usize = (23 - 1) * envelope_size;
11532
11533            // Zero reserved fields.
11534            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11535
11536            // Safety:
11537            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11538            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11539            //   envelope_size bytes, there is always sufficient room.
11540            fidl::encoding::encode_in_envelope_optional::<
11541                u64,
11542                fidl::encoding::DefaultFuchsiaResourceDialect,
11543            >(
11544                self.virtio_mem_block_size
11545                    .as_ref()
11546                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11547                encoder,
11548                offset + cur_offset,
11549                depth,
11550            )?;
11551
11552            _prev_end_offset = cur_offset + envelope_size;
11553            if 24 > max_ordinal {
11554                return Ok(());
11555            }
11556
11557            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11558            // are envelope_size bytes.
11559            let cur_offset: usize = (24 - 1) * envelope_size;
11560
11561            // Zero reserved fields.
11562            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11563
11564            // Safety:
11565            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11566            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11567            //   envelope_size bytes, there is always sufficient room.
11568            fidl::encoding::encode_in_envelope_optional::<
11569                u64,
11570                fidl::encoding::DefaultFuchsiaResourceDialect,
11571            >(
11572                self.virtio_mem_region_size
11573                    .as_ref()
11574                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11575                encoder,
11576                offset + cur_offset,
11577                depth,
11578            )?;
11579
11580            _prev_end_offset = cur_offset + envelope_size;
11581            if 25 > max_ordinal {
11582                return Ok(());
11583            }
11584
11585            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11586            // are envelope_size bytes.
11587            let cur_offset: usize = (25 - 1) * envelope_size;
11588
11589            // Zero reserved fields.
11590            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11591
11592            // Safety:
11593            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11594            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11595            //   envelope_size bytes, there is always sufficient room.
11596            fidl::encoding::encode_in_envelope_optional::<
11597                u64,
11598                fidl::encoding::DefaultFuchsiaResourceDialect,
11599            >(
11600                self.virtio_mem_region_alignment
11601                    .as_ref()
11602                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11603                encoder,
11604                offset + cur_offset,
11605                depth,
11606            )?;
11607
11608            _prev_end_offset = cur_offset + envelope_size;
11609
11610            Ok(())
11611        }
11612    }
11613
11614    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for GuestConfig {
11615        #[inline(always)]
11616        fn new_empty() -> Self {
11617            Self::default()
11618        }
11619
11620        unsafe fn decode(
11621            &mut self,
11622            decoder: &mut fidl::encoding::Decoder<
11623                '_,
11624                fidl::encoding::DefaultFuchsiaResourceDialect,
11625            >,
11626            offset: usize,
11627            mut depth: fidl::encoding::Depth,
11628        ) -> fidl::Result<()> {
11629            decoder.debug_check_bounds::<Self>(offset);
11630            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11631                None => return Err(fidl::Error::NotNullable),
11632                Some(len) => len,
11633            };
11634            // Calling decoder.out_of_line_offset(0) is not allowed.
11635            if len == 0 {
11636                return Ok(());
11637            };
11638            depth.increment()?;
11639            let envelope_size = 8;
11640            let bytes_len = len * envelope_size;
11641            let offset = decoder.out_of_line_offset(bytes_len)?;
11642            // Decode the envelope for each type.
11643            let mut _next_ordinal_to_read = 0;
11644            let mut next_offset = offset;
11645            let end_offset = offset + bytes_len;
11646            _next_ordinal_to_read += 1;
11647            if next_offset >= end_offset {
11648                return Ok(());
11649            }
11650
11651            // Decode unknown envelopes for gaps in ordinals.
11652            while _next_ordinal_to_read < 1 {
11653                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11654                _next_ordinal_to_read += 1;
11655                next_offset += envelope_size;
11656            }
11657
11658            let next_out_of_line = decoder.next_out_of_line();
11659            let handles_before = decoder.remaining_handles();
11660            if let Some((inlined, num_bytes, num_handles)) =
11661                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11662            {
11663                let member_inline_size =
11664                    <KernelType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11665                if inlined != (member_inline_size <= 4) {
11666                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11667                }
11668                let inner_offset;
11669                let mut inner_depth = depth.clone();
11670                if inlined {
11671                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11672                    inner_offset = next_offset;
11673                } else {
11674                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11675                    inner_depth.increment()?;
11676                }
11677                let val_ref = self.kernel_type.get_or_insert_with(|| {
11678                    fidl::new_empty!(KernelType, fidl::encoding::DefaultFuchsiaResourceDialect)
11679                });
11680                fidl::decode!(
11681                    KernelType,
11682                    fidl::encoding::DefaultFuchsiaResourceDialect,
11683                    val_ref,
11684                    decoder,
11685                    inner_offset,
11686                    inner_depth
11687                )?;
11688                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11689                {
11690                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11691                }
11692                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11693                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11694                }
11695            }
11696
11697            next_offset += envelope_size;
11698            _next_ordinal_to_read += 1;
11699            if next_offset >= end_offset {
11700                return Ok(());
11701            }
11702
11703            // Decode unknown envelopes for gaps in ordinals.
11704            while _next_ordinal_to_read < 2 {
11705                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11706                _next_ordinal_to_read += 1;
11707                next_offset += envelope_size;
11708            }
11709
11710            let next_out_of_line = decoder.next_out_of_line();
11711            let handles_before = decoder.remaining_handles();
11712            if let Some((inlined, num_bytes, num_handles)) =
11713                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11714            {
11715                let member_inline_size = <fidl::encoding::Endpoint<
11716                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11717                > as fidl::encoding::TypeMarker>::inline_size(
11718                    decoder.context
11719                );
11720                if inlined != (member_inline_size <= 4) {
11721                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11722                }
11723                let inner_offset;
11724                let mut inner_depth = depth.clone();
11725                if inlined {
11726                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11727                    inner_offset = next_offset;
11728                } else {
11729                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11730                    inner_depth.increment()?;
11731                }
11732                let val_ref = self.kernel.get_or_insert_with(|| {
11733                    fidl::new_empty!(
11734                        fidl::encoding::Endpoint<
11735                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11736                        >,
11737                        fidl::encoding::DefaultFuchsiaResourceDialect
11738                    )
11739                });
11740                fidl::decode!(
11741                    fidl::encoding::Endpoint<
11742                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11743                    >,
11744                    fidl::encoding::DefaultFuchsiaResourceDialect,
11745                    val_ref,
11746                    decoder,
11747                    inner_offset,
11748                    inner_depth
11749                )?;
11750                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11751                {
11752                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11753                }
11754                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11755                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11756                }
11757            }
11758
11759            next_offset += envelope_size;
11760            _next_ordinal_to_read += 1;
11761            if next_offset >= end_offset {
11762                return Ok(());
11763            }
11764
11765            // Decode unknown envelopes for gaps in ordinals.
11766            while _next_ordinal_to_read < 3 {
11767                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11768                _next_ordinal_to_read += 1;
11769                next_offset += envelope_size;
11770            }
11771
11772            let next_out_of_line = decoder.next_out_of_line();
11773            let handles_before = decoder.remaining_handles();
11774            if let Some((inlined, num_bytes, num_handles)) =
11775                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11776            {
11777                let member_inline_size = <fidl::encoding::Endpoint<
11778                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11779                > as fidl::encoding::TypeMarker>::inline_size(
11780                    decoder.context
11781                );
11782                if inlined != (member_inline_size <= 4) {
11783                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11784                }
11785                let inner_offset;
11786                let mut inner_depth = depth.clone();
11787                if inlined {
11788                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11789                    inner_offset = next_offset;
11790                } else {
11791                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11792                    inner_depth.increment()?;
11793                }
11794                let val_ref = self.ramdisk.get_or_insert_with(|| {
11795                    fidl::new_empty!(
11796                        fidl::encoding::Endpoint<
11797                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11798                        >,
11799                        fidl::encoding::DefaultFuchsiaResourceDialect
11800                    )
11801                });
11802                fidl::decode!(
11803                    fidl::encoding::Endpoint<
11804                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11805                    >,
11806                    fidl::encoding::DefaultFuchsiaResourceDialect,
11807                    val_ref,
11808                    decoder,
11809                    inner_offset,
11810                    inner_depth
11811                )?;
11812                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11813                {
11814                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11815                }
11816                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11817                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11818                }
11819            }
11820
11821            next_offset += envelope_size;
11822            _next_ordinal_to_read += 1;
11823            if next_offset >= end_offset {
11824                return Ok(());
11825            }
11826
11827            // Decode unknown envelopes for gaps in ordinals.
11828            while _next_ordinal_to_read < 4 {
11829                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11830                _next_ordinal_to_read += 1;
11831                next_offset += envelope_size;
11832            }
11833
11834            let next_out_of_line = decoder.next_out_of_line();
11835            let handles_before = decoder.remaining_handles();
11836            if let Some((inlined, num_bytes, num_handles)) =
11837                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11838            {
11839                let member_inline_size = <fidl::encoding::Endpoint<
11840                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11841                > as fidl::encoding::TypeMarker>::inline_size(
11842                    decoder.context
11843                );
11844                if inlined != (member_inline_size <= 4) {
11845                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11846                }
11847                let inner_offset;
11848                let mut inner_depth = depth.clone();
11849                if inlined {
11850                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11851                    inner_offset = next_offset;
11852                } else {
11853                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11854                    inner_depth.increment()?;
11855                }
11856                let val_ref = self.dtb_overlay.get_or_insert_with(|| {
11857                    fidl::new_empty!(
11858                        fidl::encoding::Endpoint<
11859                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11860                        >,
11861                        fidl::encoding::DefaultFuchsiaResourceDialect
11862                    )
11863                });
11864                fidl::decode!(
11865                    fidl::encoding::Endpoint<
11866                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11867                    >,
11868                    fidl::encoding::DefaultFuchsiaResourceDialect,
11869                    val_ref,
11870                    decoder,
11871                    inner_offset,
11872                    inner_depth
11873                )?;
11874                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11875                {
11876                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11877                }
11878                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11879                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11880                }
11881            }
11882
11883            next_offset += envelope_size;
11884            _next_ordinal_to_read += 1;
11885            if next_offset >= end_offset {
11886                return Ok(());
11887            }
11888
11889            // Decode unknown envelopes for gaps in ordinals.
11890            while _next_ordinal_to_read < 5 {
11891                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11892                _next_ordinal_to_read += 1;
11893                next_offset += envelope_size;
11894            }
11895
11896            let next_out_of_line = decoder.next_out_of_line();
11897            let handles_before = decoder.remaining_handles();
11898            if let Some((inlined, num_bytes, num_handles)) =
11899                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11900            {
11901                let member_inline_size =
11902                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
11903                        decoder.context,
11904                    );
11905                if inlined != (member_inline_size <= 4) {
11906                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11907                }
11908                let inner_offset;
11909                let mut inner_depth = depth.clone();
11910                if inlined {
11911                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11912                    inner_offset = next_offset;
11913                } else {
11914                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11915                    inner_depth.increment()?;
11916                }
11917                let val_ref = self.cmdline.get_or_insert_with(|| {
11918                    fidl::new_empty!(
11919                        fidl::encoding::UnboundedString,
11920                        fidl::encoding::DefaultFuchsiaResourceDialect
11921                    )
11922                });
11923                fidl::decode!(
11924                    fidl::encoding::UnboundedString,
11925                    fidl::encoding::DefaultFuchsiaResourceDialect,
11926                    val_ref,
11927                    decoder,
11928                    inner_offset,
11929                    inner_depth
11930                )?;
11931                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11932                {
11933                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11934                }
11935                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11936                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11937                }
11938            }
11939
11940            next_offset += envelope_size;
11941            _next_ordinal_to_read += 1;
11942            if next_offset >= end_offset {
11943                return Ok(());
11944            }
11945
11946            // Decode unknown envelopes for gaps in ordinals.
11947            while _next_ordinal_to_read < 6 {
11948                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11949                _next_ordinal_to_read += 1;
11950                next_offset += envelope_size;
11951            }
11952
11953            let next_out_of_line = decoder.next_out_of_line();
11954            let handles_before = decoder.remaining_handles();
11955            if let Some((inlined, num_bytes, num_handles)) =
11956                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11957            {
11958                let member_inline_size = <fidl::encoding::UnboundedVector<
11959                    fidl::encoding::UnboundedString,
11960                > as fidl::encoding::TypeMarker>::inline_size(
11961                    decoder.context
11962                );
11963                if inlined != (member_inline_size <= 4) {
11964                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11965                }
11966                let inner_offset;
11967                let mut inner_depth = depth.clone();
11968                if inlined {
11969                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11970                    inner_offset = next_offset;
11971                } else {
11972                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11973                    inner_depth.increment()?;
11974                }
11975                let val_ref = self.cmdline_add.get_or_insert_with(|| {
11976                    fidl::new_empty!(
11977                        fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
11978                        fidl::encoding::DefaultFuchsiaResourceDialect
11979                    )
11980                });
11981                fidl::decode!(
11982                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
11983                    fidl::encoding::DefaultFuchsiaResourceDialect,
11984                    val_ref,
11985                    decoder,
11986                    inner_offset,
11987                    inner_depth
11988                )?;
11989                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11990                {
11991                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11992                }
11993                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11994                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11995                }
11996            }
11997
11998            next_offset += envelope_size;
11999            _next_ordinal_to_read += 1;
12000            if next_offset >= end_offset {
12001                return Ok(());
12002            }
12003
12004            // Decode unknown envelopes for gaps in ordinals.
12005            while _next_ordinal_to_read < 7 {
12006                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12007                _next_ordinal_to_read += 1;
12008                next_offset += envelope_size;
12009            }
12010
12011            let next_out_of_line = decoder.next_out_of_line();
12012            let handles_before = decoder.remaining_handles();
12013            if let Some((inlined, num_bytes, num_handles)) =
12014                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12015            {
12016                let member_inline_size =
12017                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12018                if inlined != (member_inline_size <= 4) {
12019                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12020                }
12021                let inner_offset;
12022                let mut inner_depth = depth.clone();
12023                if inlined {
12024                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12025                    inner_offset = next_offset;
12026                } else {
12027                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12028                    inner_depth.increment()?;
12029                }
12030                let val_ref = self.cpus.get_or_insert_with(|| {
12031                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12032                });
12033                fidl::decode!(
12034                    u8,
12035                    fidl::encoding::DefaultFuchsiaResourceDialect,
12036                    val_ref,
12037                    decoder,
12038                    inner_offset,
12039                    inner_depth
12040                )?;
12041                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12042                {
12043                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12044                }
12045                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12046                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12047                }
12048            }
12049
12050            next_offset += envelope_size;
12051            _next_ordinal_to_read += 1;
12052            if next_offset >= end_offset {
12053                return Ok(());
12054            }
12055
12056            // Decode unknown envelopes for gaps in ordinals.
12057            while _next_ordinal_to_read < 8 {
12058                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12059                _next_ordinal_to_read += 1;
12060                next_offset += envelope_size;
12061            }
12062
12063            let next_out_of_line = decoder.next_out_of_line();
12064            let handles_before = decoder.remaining_handles();
12065            if let Some((inlined, num_bytes, num_handles)) =
12066                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12067            {
12068                let member_inline_size =
12069                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12070                if inlined != (member_inline_size <= 4) {
12071                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12072                }
12073                let inner_offset;
12074                let mut inner_depth = depth.clone();
12075                if inlined {
12076                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12077                    inner_offset = next_offset;
12078                } else {
12079                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12080                    inner_depth.increment()?;
12081                }
12082                let val_ref = self.guest_memory.get_or_insert_with(|| {
12083                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12084                });
12085                fidl::decode!(
12086                    u64,
12087                    fidl::encoding::DefaultFuchsiaResourceDialect,
12088                    val_ref,
12089                    decoder,
12090                    inner_offset,
12091                    inner_depth
12092                )?;
12093                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12094                {
12095                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12096                }
12097                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12098                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12099                }
12100            }
12101
12102            next_offset += envelope_size;
12103            _next_ordinal_to_read += 1;
12104            if next_offset >= end_offset {
12105                return Ok(());
12106            }
12107
12108            // Decode unknown envelopes for gaps in ordinals.
12109            while _next_ordinal_to_read < 9 {
12110                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12111                _next_ordinal_to_read += 1;
12112                next_offset += envelope_size;
12113            }
12114
12115            let next_out_of_line = decoder.next_out_of_line();
12116            let handles_before = decoder.remaining_handles();
12117            if let Some((inlined, num_bytes, num_handles)) =
12118                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12119            {
12120                let member_inline_size = <fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12121                if inlined != (member_inline_size <= 4) {
12122                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12123                }
12124                let inner_offset;
12125                let mut inner_depth = depth.clone();
12126                if inlined {
12127                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12128                    inner_offset = next_offset;
12129                } else {
12130                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12131                    inner_depth.increment()?;
12132                }
12133                let val_ref =
12134                self.block_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12135                fidl::decode!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12136                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12137                {
12138                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12139                }
12140                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12141                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12142                }
12143            }
12144
12145            next_offset += envelope_size;
12146            _next_ordinal_to_read += 1;
12147            if next_offset >= end_offset {
12148                return Ok(());
12149            }
12150
12151            // Decode unknown envelopes for gaps in ordinals.
12152            while _next_ordinal_to_read < 10 {
12153                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12154                _next_ordinal_to_read += 1;
12155                next_offset += envelope_size;
12156            }
12157
12158            let next_out_of_line = decoder.next_out_of_line();
12159            let handles_before = decoder.remaining_handles();
12160            if let Some((inlined, num_bytes, num_handles)) =
12161                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12162            {
12163                let member_inline_size = <fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12164                if inlined != (member_inline_size <= 4) {
12165                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12166                }
12167                let inner_offset;
12168                let mut inner_depth = depth.clone();
12169                if inlined {
12170                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12171                    inner_offset = next_offset;
12172                } else {
12173                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12174                    inner_depth.increment()?;
12175                }
12176                let val_ref =
12177                self.net_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12178                fidl::decode!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12179                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12180                {
12181                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12182                }
12183                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12184                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12185                }
12186            }
12187
12188            next_offset += envelope_size;
12189            _next_ordinal_to_read += 1;
12190            if next_offset >= end_offset {
12191                return Ok(());
12192            }
12193
12194            // Decode unknown envelopes for gaps in ordinals.
12195            while _next_ordinal_to_read < 13 {
12196                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12197                _next_ordinal_to_read += 1;
12198                next_offset += envelope_size;
12199            }
12200
12201            let next_out_of_line = decoder.next_out_of_line();
12202            let handles_before = decoder.remaining_handles();
12203            if let Some((inlined, num_bytes, num_handles)) =
12204                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12205            {
12206                let member_inline_size =
12207                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12208                if inlined != (member_inline_size <= 4) {
12209                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12210                }
12211                let inner_offset;
12212                let mut inner_depth = depth.clone();
12213                if inlined {
12214                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12215                    inner_offset = next_offset;
12216                } else {
12217                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12218                    inner_depth.increment()?;
12219                }
12220                let val_ref = self.default_net.get_or_insert_with(|| {
12221                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12222                });
12223                fidl::decode!(
12224                    bool,
12225                    fidl::encoding::DefaultFuchsiaResourceDialect,
12226                    val_ref,
12227                    decoder,
12228                    inner_offset,
12229                    inner_depth
12230                )?;
12231                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12232                {
12233                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12234                }
12235                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12236                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12237                }
12238            }
12239
12240            next_offset += envelope_size;
12241            _next_ordinal_to_read += 1;
12242            if next_offset >= end_offset {
12243                return Ok(());
12244            }
12245
12246            // Decode unknown envelopes for gaps in ordinals.
12247            while _next_ordinal_to_read < 14 {
12248                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12249                _next_ordinal_to_read += 1;
12250                next_offset += envelope_size;
12251            }
12252
12253            let next_out_of_line = decoder.next_out_of_line();
12254            let handles_before = decoder.remaining_handles();
12255            if let Some((inlined, num_bytes, num_handles)) =
12256                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12257            {
12258                let member_inline_size =
12259                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12260                if inlined != (member_inline_size <= 4) {
12261                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12262                }
12263                let inner_offset;
12264                let mut inner_depth = depth.clone();
12265                if inlined {
12266                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12267                    inner_offset = next_offset;
12268                } else {
12269                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12270                    inner_depth.increment()?;
12271                }
12272                let val_ref = self.virtio_balloon.get_or_insert_with(|| {
12273                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12274                });
12275                fidl::decode!(
12276                    bool,
12277                    fidl::encoding::DefaultFuchsiaResourceDialect,
12278                    val_ref,
12279                    decoder,
12280                    inner_offset,
12281                    inner_depth
12282                )?;
12283                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12284                {
12285                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12286                }
12287                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12288                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12289                }
12290            }
12291
12292            next_offset += envelope_size;
12293            _next_ordinal_to_read += 1;
12294            if next_offset >= end_offset {
12295                return Ok(());
12296            }
12297
12298            // Decode unknown envelopes for gaps in ordinals.
12299            while _next_ordinal_to_read < 15 {
12300                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12301                _next_ordinal_to_read += 1;
12302                next_offset += envelope_size;
12303            }
12304
12305            let next_out_of_line = decoder.next_out_of_line();
12306            let handles_before = decoder.remaining_handles();
12307            if let Some((inlined, num_bytes, num_handles)) =
12308                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12309            {
12310                let member_inline_size =
12311                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12312                if inlined != (member_inline_size <= 4) {
12313                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12314                }
12315                let inner_offset;
12316                let mut inner_depth = depth.clone();
12317                if inlined {
12318                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12319                    inner_offset = next_offset;
12320                } else {
12321                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12322                    inner_depth.increment()?;
12323                }
12324                let val_ref = self.virtio_console.get_or_insert_with(|| {
12325                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12326                });
12327                fidl::decode!(
12328                    bool,
12329                    fidl::encoding::DefaultFuchsiaResourceDialect,
12330                    val_ref,
12331                    decoder,
12332                    inner_offset,
12333                    inner_depth
12334                )?;
12335                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12336                {
12337                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12338                }
12339                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12340                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12341                }
12342            }
12343
12344            next_offset += envelope_size;
12345            _next_ordinal_to_read += 1;
12346            if next_offset >= end_offset {
12347                return Ok(());
12348            }
12349
12350            // Decode unknown envelopes for gaps in ordinals.
12351            while _next_ordinal_to_read < 16 {
12352                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12353                _next_ordinal_to_read += 1;
12354                next_offset += envelope_size;
12355            }
12356
12357            let next_out_of_line = decoder.next_out_of_line();
12358            let handles_before = decoder.remaining_handles();
12359            if let Some((inlined, num_bytes, num_handles)) =
12360                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12361            {
12362                let member_inline_size =
12363                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12364                if inlined != (member_inline_size <= 4) {
12365                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12366                }
12367                let inner_offset;
12368                let mut inner_depth = depth.clone();
12369                if inlined {
12370                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12371                    inner_offset = next_offset;
12372                } else {
12373                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12374                    inner_depth.increment()?;
12375                }
12376                let val_ref = self.virtio_gpu.get_or_insert_with(|| {
12377                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12378                });
12379                fidl::decode!(
12380                    bool,
12381                    fidl::encoding::DefaultFuchsiaResourceDialect,
12382                    val_ref,
12383                    decoder,
12384                    inner_offset,
12385                    inner_depth
12386                )?;
12387                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12388                {
12389                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12390                }
12391                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12392                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12393                }
12394            }
12395
12396            next_offset += envelope_size;
12397            _next_ordinal_to_read += 1;
12398            if next_offset >= end_offset {
12399                return Ok(());
12400            }
12401
12402            // Decode unknown envelopes for gaps in ordinals.
12403            while _next_ordinal_to_read < 17 {
12404                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12405                _next_ordinal_to_read += 1;
12406                next_offset += envelope_size;
12407            }
12408
12409            let next_out_of_line = decoder.next_out_of_line();
12410            let handles_before = decoder.remaining_handles();
12411            if let Some((inlined, num_bytes, num_handles)) =
12412                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12413            {
12414                let member_inline_size =
12415                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12416                if inlined != (member_inline_size <= 4) {
12417                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12418                }
12419                let inner_offset;
12420                let mut inner_depth = depth.clone();
12421                if inlined {
12422                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12423                    inner_offset = next_offset;
12424                } else {
12425                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12426                    inner_depth.increment()?;
12427                }
12428                let val_ref = self.virtio_rng.get_or_insert_with(|| {
12429                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12430                });
12431                fidl::decode!(
12432                    bool,
12433                    fidl::encoding::DefaultFuchsiaResourceDialect,
12434                    val_ref,
12435                    decoder,
12436                    inner_offset,
12437                    inner_depth
12438                )?;
12439                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12440                {
12441                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12442                }
12443                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12444                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12445                }
12446            }
12447
12448            next_offset += envelope_size;
12449            _next_ordinal_to_read += 1;
12450            if next_offset >= end_offset {
12451                return Ok(());
12452            }
12453
12454            // Decode unknown envelopes for gaps in ordinals.
12455            while _next_ordinal_to_read < 18 {
12456                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12457                _next_ordinal_to_read += 1;
12458                next_offset += envelope_size;
12459            }
12460
12461            let next_out_of_line = decoder.next_out_of_line();
12462            let handles_before = decoder.remaining_handles();
12463            if let Some((inlined, num_bytes, num_handles)) =
12464                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12465            {
12466                let member_inline_size =
12467                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12468                if inlined != (member_inline_size <= 4) {
12469                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12470                }
12471                let inner_offset;
12472                let mut inner_depth = depth.clone();
12473                if inlined {
12474                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12475                    inner_offset = next_offset;
12476                } else {
12477                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12478                    inner_depth.increment()?;
12479                }
12480                let val_ref = self.virtio_vsock.get_or_insert_with(|| {
12481                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12482                });
12483                fidl::decode!(
12484                    bool,
12485                    fidl::encoding::DefaultFuchsiaResourceDialect,
12486                    val_ref,
12487                    decoder,
12488                    inner_offset,
12489                    inner_depth
12490                )?;
12491                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12492                {
12493                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12494                }
12495                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12496                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12497                }
12498            }
12499
12500            next_offset += envelope_size;
12501            _next_ordinal_to_read += 1;
12502            if next_offset >= end_offset {
12503                return Ok(());
12504            }
12505
12506            // Decode unknown envelopes for gaps in ordinals.
12507            while _next_ordinal_to_read < 19 {
12508                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12509                _next_ordinal_to_read += 1;
12510                next_offset += envelope_size;
12511            }
12512
12513            let next_out_of_line = decoder.next_out_of_line();
12514            let handles_before = decoder.remaining_handles();
12515            if let Some((inlined, num_bytes, num_handles)) =
12516                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12517            {
12518                let member_inline_size =
12519                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12520                if inlined != (member_inline_size <= 4) {
12521                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12522                }
12523                let inner_offset;
12524                let mut inner_depth = depth.clone();
12525                if inlined {
12526                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12527                    inner_offset = next_offset;
12528                } else {
12529                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12530                    inner_depth.increment()?;
12531                }
12532                let val_ref = self.virtio_sound.get_or_insert_with(|| {
12533                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12534                });
12535                fidl::decode!(
12536                    bool,
12537                    fidl::encoding::DefaultFuchsiaResourceDialect,
12538                    val_ref,
12539                    decoder,
12540                    inner_offset,
12541                    inner_depth
12542                )?;
12543                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12544                {
12545                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12546                }
12547                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12548                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12549                }
12550            }
12551
12552            next_offset += envelope_size;
12553            _next_ordinal_to_read += 1;
12554            if next_offset >= end_offset {
12555                return Ok(());
12556            }
12557
12558            // Decode unknown envelopes for gaps in ordinals.
12559            while _next_ordinal_to_read < 20 {
12560                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12561                _next_ordinal_to_read += 1;
12562                next_offset += envelope_size;
12563            }
12564
12565            let next_out_of_line = decoder.next_out_of_line();
12566            let handles_before = decoder.remaining_handles();
12567            if let Some((inlined, num_bytes, num_handles)) =
12568                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12569            {
12570                let member_inline_size =
12571                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12572                if inlined != (member_inline_size <= 4) {
12573                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12574                }
12575                let inner_offset;
12576                let mut inner_depth = depth.clone();
12577                if inlined {
12578                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12579                    inner_offset = next_offset;
12580                } else {
12581                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12582                    inner_depth.increment()?;
12583                }
12584                let val_ref = self.virtio_sound_input.get_or_insert_with(|| {
12585                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12586                });
12587                fidl::decode!(
12588                    bool,
12589                    fidl::encoding::DefaultFuchsiaResourceDialect,
12590                    val_ref,
12591                    decoder,
12592                    inner_offset,
12593                    inner_depth
12594                )?;
12595                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12596                {
12597                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12598                }
12599                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12600                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12601                }
12602            }
12603
12604            next_offset += envelope_size;
12605            _next_ordinal_to_read += 1;
12606            if next_offset >= end_offset {
12607                return Ok(());
12608            }
12609
12610            // Decode unknown envelopes for gaps in ordinals.
12611            while _next_ordinal_to_read < 21 {
12612                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12613                _next_ordinal_to_read += 1;
12614                next_offset += envelope_size;
12615            }
12616
12617            let next_out_of_line = decoder.next_out_of_line();
12618            let handles_before = decoder.remaining_handles();
12619            if let Some((inlined, num_bytes, num_handles)) =
12620                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12621            {
12622                let member_inline_size = <fidl::encoding::UnboundedVector<Listener> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12623                if inlined != (member_inline_size <= 4) {
12624                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12625                }
12626                let inner_offset;
12627                let mut inner_depth = depth.clone();
12628                if inlined {
12629                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12630                    inner_offset = next_offset;
12631                } else {
12632                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12633                    inner_depth.increment()?;
12634                }
12635                let val_ref = self.vsock_listeners.get_or_insert_with(|| {
12636                    fidl::new_empty!(
12637                        fidl::encoding::UnboundedVector<Listener>,
12638                        fidl::encoding::DefaultFuchsiaResourceDialect
12639                    )
12640                });
12641                fidl::decode!(
12642                    fidl::encoding::UnboundedVector<Listener>,
12643                    fidl::encoding::DefaultFuchsiaResourceDialect,
12644                    val_ref,
12645                    decoder,
12646                    inner_offset,
12647                    inner_depth
12648                )?;
12649                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12650                {
12651                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12652                }
12653                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12654                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12655                }
12656            }
12657
12658            next_offset += envelope_size;
12659            _next_ordinal_to_read += 1;
12660            if next_offset >= end_offset {
12661                return Ok(());
12662            }
12663
12664            // Decode unknown envelopes for gaps in ordinals.
12665            while _next_ordinal_to_read < 22 {
12666                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12667                _next_ordinal_to_read += 1;
12668                next_offset += envelope_size;
12669            }
12670
12671            let next_out_of_line = decoder.next_out_of_line();
12672            let handles_before = decoder.remaining_handles();
12673            if let Some((inlined, num_bytes, num_handles)) =
12674                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12675            {
12676                let member_inline_size =
12677                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12678                if inlined != (member_inline_size <= 4) {
12679                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12680                }
12681                let inner_offset;
12682                let mut inner_depth = depth.clone();
12683                if inlined {
12684                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12685                    inner_offset = next_offset;
12686                } else {
12687                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12688                    inner_depth.increment()?;
12689                }
12690                let val_ref = self.virtio_mem.get_or_insert_with(|| {
12691                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12692                });
12693                fidl::decode!(
12694                    bool,
12695                    fidl::encoding::DefaultFuchsiaResourceDialect,
12696                    val_ref,
12697                    decoder,
12698                    inner_offset,
12699                    inner_depth
12700                )?;
12701                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12702                {
12703                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12704                }
12705                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12706                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12707                }
12708            }
12709
12710            next_offset += envelope_size;
12711            _next_ordinal_to_read += 1;
12712            if next_offset >= end_offset {
12713                return Ok(());
12714            }
12715
12716            // Decode unknown envelopes for gaps in ordinals.
12717            while _next_ordinal_to_read < 23 {
12718                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12719                _next_ordinal_to_read += 1;
12720                next_offset += envelope_size;
12721            }
12722
12723            let next_out_of_line = decoder.next_out_of_line();
12724            let handles_before = decoder.remaining_handles();
12725            if let Some((inlined, num_bytes, num_handles)) =
12726                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12727            {
12728                let member_inline_size =
12729                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12730                if inlined != (member_inline_size <= 4) {
12731                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12732                }
12733                let inner_offset;
12734                let mut inner_depth = depth.clone();
12735                if inlined {
12736                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12737                    inner_offset = next_offset;
12738                } else {
12739                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12740                    inner_depth.increment()?;
12741                }
12742                let val_ref = self.virtio_mem_block_size.get_or_insert_with(|| {
12743                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12744                });
12745                fidl::decode!(
12746                    u64,
12747                    fidl::encoding::DefaultFuchsiaResourceDialect,
12748                    val_ref,
12749                    decoder,
12750                    inner_offset,
12751                    inner_depth
12752                )?;
12753                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12754                {
12755                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12756                }
12757                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12758                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12759                }
12760            }
12761
12762            next_offset += envelope_size;
12763            _next_ordinal_to_read += 1;
12764            if next_offset >= end_offset {
12765                return Ok(());
12766            }
12767
12768            // Decode unknown envelopes for gaps in ordinals.
12769            while _next_ordinal_to_read < 24 {
12770                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12771                _next_ordinal_to_read += 1;
12772                next_offset += envelope_size;
12773            }
12774
12775            let next_out_of_line = decoder.next_out_of_line();
12776            let handles_before = decoder.remaining_handles();
12777            if let Some((inlined, num_bytes, num_handles)) =
12778                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12779            {
12780                let member_inline_size =
12781                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12782                if inlined != (member_inline_size <= 4) {
12783                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12784                }
12785                let inner_offset;
12786                let mut inner_depth = depth.clone();
12787                if inlined {
12788                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12789                    inner_offset = next_offset;
12790                } else {
12791                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12792                    inner_depth.increment()?;
12793                }
12794                let val_ref = self.virtio_mem_region_size.get_or_insert_with(|| {
12795                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12796                });
12797                fidl::decode!(
12798                    u64,
12799                    fidl::encoding::DefaultFuchsiaResourceDialect,
12800                    val_ref,
12801                    decoder,
12802                    inner_offset,
12803                    inner_depth
12804                )?;
12805                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12806                {
12807                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12808                }
12809                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12810                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12811                }
12812            }
12813
12814            next_offset += envelope_size;
12815            _next_ordinal_to_read += 1;
12816            if next_offset >= end_offset {
12817                return Ok(());
12818            }
12819
12820            // Decode unknown envelopes for gaps in ordinals.
12821            while _next_ordinal_to_read < 25 {
12822                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12823                _next_ordinal_to_read += 1;
12824                next_offset += envelope_size;
12825            }
12826
12827            let next_out_of_line = decoder.next_out_of_line();
12828            let handles_before = decoder.remaining_handles();
12829            if let Some((inlined, num_bytes, num_handles)) =
12830                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12831            {
12832                let member_inline_size =
12833                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12834                if inlined != (member_inline_size <= 4) {
12835                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12836                }
12837                let inner_offset;
12838                let mut inner_depth = depth.clone();
12839                if inlined {
12840                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12841                    inner_offset = next_offset;
12842                } else {
12843                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12844                    inner_depth.increment()?;
12845                }
12846                let val_ref = self.virtio_mem_region_alignment.get_or_insert_with(|| {
12847                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12848                });
12849                fidl::decode!(
12850                    u64,
12851                    fidl::encoding::DefaultFuchsiaResourceDialect,
12852                    val_ref,
12853                    decoder,
12854                    inner_offset,
12855                    inner_depth
12856                )?;
12857                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12858                {
12859                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12860                }
12861                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12862                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12863                }
12864            }
12865
12866            next_offset += envelope_size;
12867
12868            // Decode the remaining unknown envelopes.
12869            while next_offset < end_offset {
12870                _next_ordinal_to_read += 1;
12871                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12872                next_offset += envelope_size;
12873            }
12874
12875            Ok(())
12876        }
12877    }
12878
12879    impl fidl::encoding::ResourceTypeMarker for BlockFormat {
12880        type Borrowed<'a> = &'a mut Self;
12881        fn take_or_borrow<'a>(
12882            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12883        ) -> Self::Borrowed<'a> {
12884            value
12885        }
12886    }
12887
12888    unsafe impl fidl::encoding::TypeMarker for BlockFormat {
12889        type Owned = Self;
12890
12891        #[inline(always)]
12892        fn inline_align(_context: fidl::encoding::Context) -> usize {
12893            8
12894        }
12895
12896        #[inline(always)]
12897        fn inline_size(_context: fidl::encoding::Context) -> usize {
12898            16
12899        }
12900    }
12901
12902    unsafe impl fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>
12903        for &mut BlockFormat
12904    {
12905        #[inline]
12906        unsafe fn encode(
12907            self,
12908            encoder: &mut fidl::encoding::Encoder<
12909                '_,
12910                fidl::encoding::DefaultFuchsiaResourceDialect,
12911            >,
12912            offset: usize,
12913            _depth: fidl::encoding::Depth,
12914        ) -> fidl::Result<()> {
12915            encoder.debug_check_bounds::<BlockFormat>(offset);
12916            encoder.write_num::<u64>(self.ordinal(), offset);
12917            match self {
12918                BlockFormat::File(ref mut val) => fidl::encoding::encode_in_envelope::<
12919                    fidl::encoding::Endpoint<
12920                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12921                    >,
12922                    fidl::encoding::DefaultFuchsiaResourceDialect,
12923                >(
12924                    <fidl::encoding::Endpoint<
12925                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12926                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12927                        val
12928                    ),
12929                    encoder,
12930                    offset + 8,
12931                    _depth,
12932                ),
12933                BlockFormat::Qcow(ref mut val) => fidl::encoding::encode_in_envelope::<
12934                    fidl::encoding::HandleType<
12935                        fidl::Channel,
12936                        { fidl::ObjectType::CHANNEL.into_raw() },
12937                        2147483648,
12938                    >,
12939                    fidl::encoding::DefaultFuchsiaResourceDialect,
12940                >(
12941                    <fidl::encoding::HandleType<
12942                        fidl::Channel,
12943                        { fidl::ObjectType::CHANNEL.into_raw() },
12944                        2147483648,
12945                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12946                        val
12947                    ),
12948                    encoder,
12949                    offset + 8,
12950                    _depth,
12951                ),
12952                BlockFormat::Block(ref mut val) => fidl::encoding::encode_in_envelope::<
12953                    fidl::encoding::Endpoint<
12954                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
12955                    >,
12956                    fidl::encoding::DefaultFuchsiaResourceDialect,
12957                >(
12958                    <fidl::encoding::Endpoint<
12959                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
12960                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12961                        val
12962                    ),
12963                    encoder,
12964                    offset + 8,
12965                    _depth,
12966                ),
12967            }
12968        }
12969    }
12970
12971    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockFormat {
12972        #[inline(always)]
12973        fn new_empty() -> Self {
12974            Self::File(fidl::new_empty!(
12975                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
12976                fidl::encoding::DefaultFuchsiaResourceDialect
12977            ))
12978        }
12979
12980        #[inline]
12981        unsafe fn decode(
12982            &mut self,
12983            decoder: &mut fidl::encoding::Decoder<
12984                '_,
12985                fidl::encoding::DefaultFuchsiaResourceDialect,
12986            >,
12987            offset: usize,
12988            mut depth: fidl::encoding::Depth,
12989        ) -> fidl::Result<()> {
12990            decoder.debug_check_bounds::<Self>(offset);
12991            #[allow(unused_variables)]
12992            let next_out_of_line = decoder.next_out_of_line();
12993            let handles_before = decoder.remaining_handles();
12994            let (ordinal, inlined, num_bytes, num_handles) =
12995                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
12996
12997            let member_inline_size = match ordinal {
12998                1 => <fidl::encoding::Endpoint<
12999                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13000                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13001                2 => <fidl::encoding::HandleType<
13002                    fidl::Channel,
13003                    { fidl::ObjectType::CHANNEL.into_raw() },
13004                    2147483648,
13005                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13006                3 => <fidl::encoding::Endpoint<
13007                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
13008                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13009                _ => return Err(fidl::Error::UnknownUnionTag),
13010            };
13011
13012            if inlined != (member_inline_size <= 4) {
13013                return Err(fidl::Error::InvalidInlineBitInEnvelope);
13014            }
13015            let _inner_offset;
13016            if inlined {
13017                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
13018                _inner_offset = offset + 8;
13019            } else {
13020                depth.increment()?;
13021                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13022            }
13023            match ordinal {
13024                1 => {
13025                    #[allow(irrefutable_let_patterns)]
13026                    if let BlockFormat::File(_) = self {
13027                        // Do nothing, read the value into the object
13028                    } else {
13029                        // Initialize `self` to the right variant
13030                        *self = BlockFormat::File(fidl::new_empty!(
13031                            fidl::encoding::Endpoint<
13032                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13033                            >,
13034                            fidl::encoding::DefaultFuchsiaResourceDialect
13035                        ));
13036                    }
13037                    #[allow(irrefutable_let_patterns)]
13038                    if let BlockFormat::File(ref mut val) = self {
13039                        fidl::decode!(
13040                            fidl::encoding::Endpoint<
13041                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13042                            >,
13043                            fidl::encoding::DefaultFuchsiaResourceDialect,
13044                            val,
13045                            decoder,
13046                            _inner_offset,
13047                            depth
13048                        )?;
13049                    } else {
13050                        unreachable!()
13051                    }
13052                }
13053                2 => {
13054                    #[allow(irrefutable_let_patterns)]
13055                    if let BlockFormat::Qcow(_) = self {
13056                        // Do nothing, read the value into the object
13057                    } else {
13058                        // Initialize `self` to the right variant
13059                        *self = BlockFormat::Qcow(
13060                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
13061                        );
13062                    }
13063                    #[allow(irrefutable_let_patterns)]
13064                    if let BlockFormat::Qcow(ref mut val) = self {
13065                        fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
13066                    } else {
13067                        unreachable!()
13068                    }
13069                }
13070                3 => {
13071                    #[allow(irrefutable_let_patterns)]
13072                    if let BlockFormat::Block(_) = self {
13073                        // Do nothing, read the value into the object
13074                    } else {
13075                        // Initialize `self` to the right variant
13076                        *self = BlockFormat::Block(fidl::new_empty!(
13077                            fidl::encoding::Endpoint<
13078                                fidl::endpoints::ClientEnd<
13079                                    fidl_fuchsia_hardware_block::BlockMarker,
13080                                >,
13081                            >,
13082                            fidl::encoding::DefaultFuchsiaResourceDialect
13083                        ));
13084                    }
13085                    #[allow(irrefutable_let_patterns)]
13086                    if let BlockFormat::Block(ref mut val) = self {
13087                        fidl::decode!(
13088                            fidl::encoding::Endpoint<
13089                                fidl::endpoints::ClientEnd<
13090                                    fidl_fuchsia_hardware_block::BlockMarker,
13091                                >,
13092                            >,
13093                            fidl::encoding::DefaultFuchsiaResourceDialect,
13094                            val,
13095                            decoder,
13096                            _inner_offset,
13097                            depth
13098                        )?;
13099                    } else {
13100                        unreachable!()
13101                    }
13102                }
13103                ordinal => panic!("unexpected ordinal {:?}", ordinal),
13104            }
13105            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
13106                return Err(fidl::Error::InvalidNumBytesInEnvelope);
13107            }
13108            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13109                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13110            }
13111            Ok(())
13112        }
13113    }
13114}