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::NullableHandle {
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
763    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
764        self.inner.shutdown_with_epitaph(status)
765    }
766
767    fn is_closed(&self) -> bool {
768        self.inner.channel().is_closed()
769    }
770    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
771        self.inner.channel().on_closed()
772    }
773
774    #[cfg(target_os = "fuchsia")]
775    fn signal_peer(
776        &self,
777        clear_mask: zx::Signals,
778        set_mask: zx::Signals,
779    ) -> Result<(), zx_status::Status> {
780        use fidl::Peered;
781        self.inner.channel().signal_peer(clear_mask, set_mask)
782    }
783}
784
785impl BalloonControllerControlHandle {}
786
787#[must_use = "FIDL methods require a response to be sent"]
788#[derive(Debug)]
789pub struct BalloonControllerGetBalloonSizeResponder {
790    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
791    tx_id: u32,
792}
793
794/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
795/// if the responder is dropped without sending a response, so that the client
796/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
797impl std::ops::Drop for BalloonControllerGetBalloonSizeResponder {
798    fn drop(&mut self) {
799        self.control_handle.shutdown();
800        // Safety: drops once, never accessed again
801        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
802    }
803}
804
805impl fidl::endpoints::Responder for BalloonControllerGetBalloonSizeResponder {
806    type ControlHandle = BalloonControllerControlHandle;
807
808    fn control_handle(&self) -> &BalloonControllerControlHandle {
809        &self.control_handle
810    }
811
812    fn drop_without_shutdown(mut self) {
813        // Safety: drops once, never accessed again due to mem::forget
814        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
815        // Prevent Drop from running (which would shut down the channel)
816        std::mem::forget(self);
817    }
818}
819
820impl BalloonControllerGetBalloonSizeResponder {
821    /// Sends a response to the FIDL transaction.
822    ///
823    /// Sets the channel to shutdown if an error occurs.
824    pub fn send(
825        self,
826        mut current_num_pages: u32,
827        mut requested_num_pages: u32,
828    ) -> Result<(), fidl::Error> {
829        let _result = self.send_raw(current_num_pages, requested_num_pages);
830        if _result.is_err() {
831            self.control_handle.shutdown();
832        }
833        self.drop_without_shutdown();
834        _result
835    }
836
837    /// Similar to "send" but does not shutdown the channel if an error occurs.
838    pub fn send_no_shutdown_on_err(
839        self,
840        mut current_num_pages: u32,
841        mut requested_num_pages: u32,
842    ) -> Result<(), fidl::Error> {
843        let _result = self.send_raw(current_num_pages, requested_num_pages);
844        self.drop_without_shutdown();
845        _result
846    }
847
848    fn send_raw(
849        &self,
850        mut current_num_pages: u32,
851        mut requested_num_pages: u32,
852    ) -> Result<(), fidl::Error> {
853        self.control_handle.inner.send::<BalloonControllerGetBalloonSizeResponse>(
854            (current_num_pages, requested_num_pages),
855            self.tx_id,
856            0x2bb2ebaa6ff64d0b,
857            fidl::encoding::DynamicFlags::empty(),
858        )
859    }
860}
861
862#[must_use = "FIDL methods require a response to be sent"]
863#[derive(Debug)]
864pub struct BalloonControllerGetMemStatsResponder {
865    control_handle: std::mem::ManuallyDrop<BalloonControllerControlHandle>,
866    tx_id: u32,
867}
868
869/// Set the the channel to be shutdown (see [`BalloonControllerControlHandle::shutdown`])
870/// if the responder is dropped without sending a response, so that the client
871/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
872impl std::ops::Drop for BalloonControllerGetMemStatsResponder {
873    fn drop(&mut self) {
874        self.control_handle.shutdown();
875        // Safety: drops once, never accessed again
876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877    }
878}
879
880impl fidl::endpoints::Responder for BalloonControllerGetMemStatsResponder {
881    type ControlHandle = BalloonControllerControlHandle;
882
883    fn control_handle(&self) -> &BalloonControllerControlHandle {
884        &self.control_handle
885    }
886
887    fn drop_without_shutdown(mut self) {
888        // Safety: drops once, never accessed again due to mem::forget
889        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
890        // Prevent Drop from running (which would shut down the channel)
891        std::mem::forget(self);
892    }
893}
894
895impl BalloonControllerGetMemStatsResponder {
896    /// Sends a response to the FIDL transaction.
897    ///
898    /// Sets the channel to shutdown if an error occurs.
899    pub fn send(
900        self,
901        mut status: i32,
902        mut mem_stats: Option<&[MemStat]>,
903    ) -> Result<(), fidl::Error> {
904        let _result = self.send_raw(status, mem_stats);
905        if _result.is_err() {
906            self.control_handle.shutdown();
907        }
908        self.drop_without_shutdown();
909        _result
910    }
911
912    /// Similar to "send" but does not shutdown the channel if an error occurs.
913    pub fn send_no_shutdown_on_err(
914        self,
915        mut status: i32,
916        mut mem_stats: Option<&[MemStat]>,
917    ) -> Result<(), fidl::Error> {
918        let _result = self.send_raw(status, mem_stats);
919        self.drop_without_shutdown();
920        _result
921    }
922
923    fn send_raw(
924        &self,
925        mut status: i32,
926        mut mem_stats: Option<&[MemStat]>,
927    ) -> Result<(), fidl::Error> {
928        self.control_handle.inner.send::<BalloonControllerGetMemStatsResponse>(
929            (status, mem_stats),
930            self.tx_id,
931            0x676199795cc01142,
932            fidl::encoding::DynamicFlags::empty(),
933        )
934    }
935}
936
937#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
938pub struct DebianGuestManagerMarker;
939
940impl fidl::endpoints::ProtocolMarker for DebianGuestManagerMarker {
941    type Proxy = DebianGuestManagerProxy;
942    type RequestStream = DebianGuestManagerRequestStream;
943    #[cfg(target_os = "fuchsia")]
944    type SynchronousProxy = DebianGuestManagerSynchronousProxy;
945
946    const DEBUG_NAME: &'static str = "fuchsia.virtualization.DebianGuestManager";
947}
948impl fidl::endpoints::DiscoverableProtocolMarker for DebianGuestManagerMarker {}
949
950pub trait DebianGuestManagerProxyInterface: Send + Sync {
951    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
952        + Send;
953    fn r#launch(
954        &self,
955        guest_config: GuestConfig,
956        controller: fidl::endpoints::ServerEnd<GuestMarker>,
957    ) -> Self::LaunchResponseFut;
958    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
959    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
960    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
961        + Send;
962    fn r#connect(
963        &self,
964        controller: fidl::endpoints::ServerEnd<GuestMarker>,
965    ) -> Self::ConnectResponseFut;
966    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
967    fn r#get_info(&self) -> Self::GetInfoResponseFut;
968}
969#[derive(Debug)]
970#[cfg(target_os = "fuchsia")]
971pub struct DebianGuestManagerSynchronousProxy {
972    client: fidl::client::sync::Client,
973}
974
975#[cfg(target_os = "fuchsia")]
976impl fidl::endpoints::SynchronousProxy for DebianGuestManagerSynchronousProxy {
977    type Proxy = DebianGuestManagerProxy;
978    type Protocol = DebianGuestManagerMarker;
979
980    fn from_channel(inner: fidl::Channel) -> Self {
981        Self::new(inner)
982    }
983
984    fn into_channel(self) -> fidl::Channel {
985        self.client.into_channel()
986    }
987
988    fn as_channel(&self) -> &fidl::Channel {
989        self.client.as_channel()
990    }
991}
992
993#[cfg(target_os = "fuchsia")]
994impl DebianGuestManagerSynchronousProxy {
995    pub fn new(channel: fidl::Channel) -> Self {
996        let protocol_name =
997            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
998        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
999    }
1000
1001    pub fn into_channel(self) -> fidl::Channel {
1002        self.client.into_channel()
1003    }
1004
1005    /// Waits until an event arrives and returns it. It is safe for other
1006    /// threads to make concurrent requests while waiting for an event.
1007    pub fn wait_for_event(
1008        &self,
1009        deadline: zx::MonotonicInstant,
1010    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1011        DebianGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
1012    }
1013
1014    /// Launch a new guest instance.
1015    ///
1016    /// Possible errors:
1017    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1018    ///         problems detected by the guest manager.
1019    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1020    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1021    ///         component logs for a more specific failure.
1022    pub fn r#launch(
1023        &self,
1024        mut guest_config: GuestConfig,
1025        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1026        ___deadline: zx::MonotonicInstant,
1027    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1028        let _response =
1029            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
1030                fidl::encoding::EmptyStruct,
1031                GuestManagerError,
1032            >>(
1033                (&mut guest_config, controller),
1034                0x394a2e29f750323e,
1035                fidl::encoding::DynamicFlags::empty(),
1036                ___deadline,
1037            )?;
1038        Ok(_response.map(|x| x))
1039    }
1040
1041    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1042    /// be used to launch another guest.
1043    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1044        let _response =
1045            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1046                (),
1047                0x3ad9a012982f872d,
1048                fidl::encoding::DynamicFlags::empty(),
1049                ___deadline,
1050            )?;
1051        Ok(_response)
1052    }
1053
1054    /// Connect to a currently running guest.
1055    ///
1056    /// Possible errors:
1057    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1058    ///         has launched before attempting to reconnect.
1059    pub fn r#connect(
1060        &self,
1061        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1062        ___deadline: zx::MonotonicInstant,
1063    ) -> Result<GuestManagerConnectResult, fidl::Error> {
1064        let _response =
1065            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
1066                fidl::encoding::EmptyStruct,
1067                GuestManagerError,
1068            >>(
1069                (controller,),
1070                0x4e489076e3bb15b4,
1071                fidl::encoding::DynamicFlags::empty(),
1072                ___deadline,
1073            )?;
1074        Ok(_response.map(|x| x))
1075    }
1076
1077    /// Query guest info
1078    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
1079        let _response =
1080            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
1081                (),
1082                0x76892614aea695dc,
1083                fidl::encoding::DynamicFlags::empty(),
1084                ___deadline,
1085            )?;
1086        Ok(_response.guest_info)
1087    }
1088}
1089
1090#[cfg(target_os = "fuchsia")]
1091impl From<DebianGuestManagerSynchronousProxy> for zx::NullableHandle {
1092    fn from(value: DebianGuestManagerSynchronousProxy) -> Self {
1093        value.into_channel().into()
1094    }
1095}
1096
1097#[cfg(target_os = "fuchsia")]
1098impl From<fidl::Channel> for DebianGuestManagerSynchronousProxy {
1099    fn from(value: fidl::Channel) -> Self {
1100        Self::new(value)
1101    }
1102}
1103
1104#[cfg(target_os = "fuchsia")]
1105impl fidl::endpoints::FromClient for DebianGuestManagerSynchronousProxy {
1106    type Protocol = DebianGuestManagerMarker;
1107
1108    fn from_client(value: fidl::endpoints::ClientEnd<DebianGuestManagerMarker>) -> Self {
1109        Self::new(value.into_channel())
1110    }
1111}
1112
1113#[derive(Debug, Clone)]
1114pub struct DebianGuestManagerProxy {
1115    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1116}
1117
1118impl fidl::endpoints::Proxy for DebianGuestManagerProxy {
1119    type Protocol = DebianGuestManagerMarker;
1120
1121    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1122        Self::new(inner)
1123    }
1124
1125    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1126        self.client.into_channel().map_err(|client| Self { client })
1127    }
1128
1129    fn as_channel(&self) -> &::fidl::AsyncChannel {
1130        self.client.as_channel()
1131    }
1132}
1133
1134impl DebianGuestManagerProxy {
1135    /// Create a new Proxy for fuchsia.virtualization/DebianGuestManager.
1136    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1137        let protocol_name =
1138            <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1139        Self { client: fidl::client::Client::new(channel, protocol_name) }
1140    }
1141
1142    /// Get a Stream of events from the remote end of the protocol.
1143    ///
1144    /// # Panics
1145    ///
1146    /// Panics if the event stream was already taken.
1147    pub fn take_event_stream(&self) -> DebianGuestManagerEventStream {
1148        DebianGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
1149    }
1150
1151    /// Launch a new guest instance.
1152    ///
1153    /// Possible errors:
1154    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1155    ///         problems detected by the guest manager.
1156    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1157    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1158    ///         component logs for a more specific failure.
1159    pub fn r#launch(
1160        &self,
1161        mut guest_config: GuestConfig,
1162        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1163    ) -> fidl::client::QueryResponseFut<
1164        GuestManagerLaunchResult,
1165        fidl::encoding::DefaultFuchsiaResourceDialect,
1166    > {
1167        DebianGuestManagerProxyInterface::r#launch(self, guest_config, controller)
1168    }
1169
1170    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1171    /// be used to launch another guest.
1172    pub fn r#force_shutdown(
1173        &self,
1174    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1175        DebianGuestManagerProxyInterface::r#force_shutdown(self)
1176    }
1177
1178    /// Connect to a currently running guest.
1179    ///
1180    /// Possible errors:
1181    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1182    ///         has launched before attempting to reconnect.
1183    pub fn r#connect(
1184        &self,
1185        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1186    ) -> fidl::client::QueryResponseFut<
1187        GuestManagerConnectResult,
1188        fidl::encoding::DefaultFuchsiaResourceDialect,
1189    > {
1190        DebianGuestManagerProxyInterface::r#connect(self, controller)
1191    }
1192
1193    /// Query guest info
1194    pub fn r#get_info(
1195        &self,
1196    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1197    {
1198        DebianGuestManagerProxyInterface::r#get_info(self)
1199    }
1200}
1201
1202impl DebianGuestManagerProxyInterface for DebianGuestManagerProxy {
1203    type LaunchResponseFut = fidl::client::QueryResponseFut<
1204        GuestManagerLaunchResult,
1205        fidl::encoding::DefaultFuchsiaResourceDialect,
1206    >;
1207    fn r#launch(
1208        &self,
1209        mut guest_config: GuestConfig,
1210        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1211    ) -> Self::LaunchResponseFut {
1212        fn _decode(
1213            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1214        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
1215            let _response = fidl::client::decode_transaction_body::<
1216                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1217                fidl::encoding::DefaultFuchsiaResourceDialect,
1218                0x394a2e29f750323e,
1219            >(_buf?)?;
1220            Ok(_response.map(|x| x))
1221        }
1222        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
1223            (&mut guest_config, controller),
1224            0x394a2e29f750323e,
1225            fidl::encoding::DynamicFlags::empty(),
1226            _decode,
1227        )
1228    }
1229
1230    type ForceShutdownResponseFut =
1231        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1232    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
1233        fn _decode(
1234            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1235        ) -> Result<(), fidl::Error> {
1236            let _response = fidl::client::decode_transaction_body::<
1237                fidl::encoding::EmptyPayload,
1238                fidl::encoding::DefaultFuchsiaResourceDialect,
1239                0x3ad9a012982f872d,
1240            >(_buf?)?;
1241            Ok(_response)
1242        }
1243        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1244            (),
1245            0x3ad9a012982f872d,
1246            fidl::encoding::DynamicFlags::empty(),
1247            _decode,
1248        )
1249    }
1250
1251    type ConnectResponseFut = fidl::client::QueryResponseFut<
1252        GuestManagerConnectResult,
1253        fidl::encoding::DefaultFuchsiaResourceDialect,
1254    >;
1255    fn r#connect(
1256        &self,
1257        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
1258    ) -> Self::ConnectResponseFut {
1259        fn _decode(
1260            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1261        ) -> Result<GuestManagerConnectResult, fidl::Error> {
1262            let _response = fidl::client::decode_transaction_body::<
1263                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
1264                fidl::encoding::DefaultFuchsiaResourceDialect,
1265                0x4e489076e3bb15b4,
1266            >(_buf?)?;
1267            Ok(_response.map(|x| x))
1268        }
1269        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
1270            (controller,),
1271            0x4e489076e3bb15b4,
1272            fidl::encoding::DynamicFlags::empty(),
1273            _decode,
1274        )
1275    }
1276
1277    type GetInfoResponseFut =
1278        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
1279    fn r#get_info(&self) -> Self::GetInfoResponseFut {
1280        fn _decode(
1281            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1282        ) -> Result<GuestInfo, fidl::Error> {
1283            let _response = fidl::client::decode_transaction_body::<
1284                GuestManagerGetInfoResponse,
1285                fidl::encoding::DefaultFuchsiaResourceDialect,
1286                0x76892614aea695dc,
1287            >(_buf?)?;
1288            Ok(_response.guest_info)
1289        }
1290        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
1291            (),
1292            0x76892614aea695dc,
1293            fidl::encoding::DynamicFlags::empty(),
1294            _decode,
1295        )
1296    }
1297}
1298
1299pub struct DebianGuestManagerEventStream {
1300    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1301}
1302
1303impl std::marker::Unpin for DebianGuestManagerEventStream {}
1304
1305impl futures::stream::FusedStream for DebianGuestManagerEventStream {
1306    fn is_terminated(&self) -> bool {
1307        self.event_receiver.is_terminated()
1308    }
1309}
1310
1311impl futures::Stream for DebianGuestManagerEventStream {
1312    type Item = Result<DebianGuestManagerEvent, fidl::Error>;
1313
1314    fn poll_next(
1315        mut self: std::pin::Pin<&mut Self>,
1316        cx: &mut std::task::Context<'_>,
1317    ) -> std::task::Poll<Option<Self::Item>> {
1318        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1319            &mut self.event_receiver,
1320            cx
1321        )?) {
1322            Some(buf) => std::task::Poll::Ready(Some(DebianGuestManagerEvent::decode(buf))),
1323            None => std::task::Poll::Ready(None),
1324        }
1325    }
1326}
1327
1328#[derive(Debug)]
1329pub enum DebianGuestManagerEvent {}
1330
1331impl DebianGuestManagerEvent {
1332    /// Decodes a message buffer as a [`DebianGuestManagerEvent`].
1333    fn decode(
1334        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1335    ) -> Result<DebianGuestManagerEvent, fidl::Error> {
1336        let (bytes, _handles) = buf.split_mut();
1337        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1338        debug_assert_eq!(tx_header.tx_id, 0);
1339        match tx_header.ordinal {
1340            _ => Err(fidl::Error::UnknownOrdinal {
1341                ordinal: tx_header.ordinal,
1342                protocol_name:
1343                    <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1344            }),
1345        }
1346    }
1347}
1348
1349/// A Stream of incoming requests for fuchsia.virtualization/DebianGuestManager.
1350pub struct DebianGuestManagerRequestStream {
1351    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1352    is_terminated: bool,
1353}
1354
1355impl std::marker::Unpin for DebianGuestManagerRequestStream {}
1356
1357impl futures::stream::FusedStream for DebianGuestManagerRequestStream {
1358    fn is_terminated(&self) -> bool {
1359        self.is_terminated
1360    }
1361}
1362
1363impl fidl::endpoints::RequestStream for DebianGuestManagerRequestStream {
1364    type Protocol = DebianGuestManagerMarker;
1365    type ControlHandle = DebianGuestManagerControlHandle;
1366
1367    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1368        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1369    }
1370
1371    fn control_handle(&self) -> Self::ControlHandle {
1372        DebianGuestManagerControlHandle { inner: self.inner.clone() }
1373    }
1374
1375    fn into_inner(
1376        self,
1377    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1378    {
1379        (self.inner, self.is_terminated)
1380    }
1381
1382    fn from_inner(
1383        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1384        is_terminated: bool,
1385    ) -> Self {
1386        Self { inner, is_terminated }
1387    }
1388}
1389
1390impl futures::Stream for DebianGuestManagerRequestStream {
1391    type Item = Result<DebianGuestManagerRequest, fidl::Error>;
1392
1393    fn poll_next(
1394        mut self: std::pin::Pin<&mut Self>,
1395        cx: &mut std::task::Context<'_>,
1396    ) -> std::task::Poll<Option<Self::Item>> {
1397        let this = &mut *self;
1398        if this.inner.check_shutdown(cx) {
1399            this.is_terminated = true;
1400            return std::task::Poll::Ready(None);
1401        }
1402        if this.is_terminated {
1403            panic!("polled DebianGuestManagerRequestStream after completion");
1404        }
1405        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1406            |bytes, handles| {
1407                match this.inner.channel().read_etc(cx, bytes, handles) {
1408                    std::task::Poll::Ready(Ok(())) => {}
1409                    std::task::Poll::Pending => return std::task::Poll::Pending,
1410                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1411                        this.is_terminated = true;
1412                        return std::task::Poll::Ready(None);
1413                    }
1414                    std::task::Poll::Ready(Err(e)) => {
1415                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1416                            e.into(),
1417                        ))));
1418                    }
1419                }
1420
1421                // A message has been received from the channel
1422                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1423
1424                std::task::Poll::Ready(Some(match header.ordinal {
1425                0x394a2e29f750323e => {
1426                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1427                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1428                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
1429                    let control_handle = DebianGuestManagerControlHandle {
1430                        inner: this.inner.clone(),
1431                    };
1432                    Ok(DebianGuestManagerRequest::Launch {guest_config: req.guest_config,
1433controller: req.controller,
1434
1435                        responder: DebianGuestManagerLaunchResponder {
1436                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1437                            tx_id: header.tx_id,
1438                        },
1439                    })
1440                }
1441                0x3ad9a012982f872d => {
1442                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1443                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1444                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1445                    let control_handle = DebianGuestManagerControlHandle {
1446                        inner: this.inner.clone(),
1447                    };
1448                    Ok(DebianGuestManagerRequest::ForceShutdown {
1449                        responder: DebianGuestManagerForceShutdownResponder {
1450                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1451                            tx_id: header.tx_id,
1452                        },
1453                    })
1454                }
1455                0x4e489076e3bb15b4 => {
1456                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1457                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1458                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1459                    let control_handle = DebianGuestManagerControlHandle {
1460                        inner: this.inner.clone(),
1461                    };
1462                    Ok(DebianGuestManagerRequest::Connect {controller: req.controller,
1463
1464                        responder: DebianGuestManagerConnectResponder {
1465                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1466                            tx_id: header.tx_id,
1467                        },
1468                    })
1469                }
1470                0x76892614aea695dc => {
1471                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1472                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1473                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1474                    let control_handle = DebianGuestManagerControlHandle {
1475                        inner: this.inner.clone(),
1476                    };
1477                    Ok(DebianGuestManagerRequest::GetInfo {
1478                        responder: DebianGuestManagerGetInfoResponder {
1479                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1480                            tx_id: header.tx_id,
1481                        },
1482                    })
1483                }
1484                _ => Err(fidl::Error::UnknownOrdinal {
1485                    ordinal: header.ordinal,
1486                    protocol_name: <DebianGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1487                }),
1488            }))
1489            },
1490        )
1491    }
1492}
1493
1494#[derive(Debug)]
1495pub enum DebianGuestManagerRequest {
1496    /// Launch a new guest instance.
1497    ///
1498    /// Possible errors:
1499    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
1500    ///         problems detected by the guest manager.
1501    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
1502    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
1503    ///         component logs for a more specific failure.
1504    Launch {
1505        guest_config: GuestConfig,
1506        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1507        responder: DebianGuestManagerLaunchResponder,
1508    },
1509    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
1510    /// be used to launch another guest.
1511    ForceShutdown { responder: DebianGuestManagerForceShutdownResponder },
1512    /// Connect to a currently running guest.
1513    ///
1514    /// Possible errors:
1515    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
1516    ///         has launched before attempting to reconnect.
1517    Connect {
1518        controller: fidl::endpoints::ServerEnd<GuestMarker>,
1519        responder: DebianGuestManagerConnectResponder,
1520    },
1521    /// Query guest info
1522    GetInfo { responder: DebianGuestManagerGetInfoResponder },
1523}
1524
1525impl DebianGuestManagerRequest {
1526    #[allow(irrefutable_let_patterns)]
1527    pub fn into_launch(
1528        self,
1529    ) -> Option<(
1530        GuestConfig,
1531        fidl::endpoints::ServerEnd<GuestMarker>,
1532        DebianGuestManagerLaunchResponder,
1533    )> {
1534        if let DebianGuestManagerRequest::Launch { guest_config, controller, responder } = self {
1535            Some((guest_config, controller, responder))
1536        } else {
1537            None
1538        }
1539    }
1540
1541    #[allow(irrefutable_let_patterns)]
1542    pub fn into_force_shutdown(self) -> Option<(DebianGuestManagerForceShutdownResponder)> {
1543        if let DebianGuestManagerRequest::ForceShutdown { responder } = self {
1544            Some((responder))
1545        } else {
1546            None
1547        }
1548    }
1549
1550    #[allow(irrefutable_let_patterns)]
1551    pub fn into_connect(
1552        self,
1553    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, DebianGuestManagerConnectResponder)> {
1554        if let DebianGuestManagerRequest::Connect { controller, responder } = self {
1555            Some((controller, responder))
1556        } else {
1557            None
1558        }
1559    }
1560
1561    #[allow(irrefutable_let_patterns)]
1562    pub fn into_get_info(self) -> Option<(DebianGuestManagerGetInfoResponder)> {
1563        if let DebianGuestManagerRequest::GetInfo { responder } = self {
1564            Some((responder))
1565        } else {
1566            None
1567        }
1568    }
1569
1570    /// Name of the method defined in FIDL
1571    pub fn method_name(&self) -> &'static str {
1572        match *self {
1573            DebianGuestManagerRequest::Launch { .. } => "launch",
1574            DebianGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
1575            DebianGuestManagerRequest::Connect { .. } => "connect",
1576            DebianGuestManagerRequest::GetInfo { .. } => "get_info",
1577        }
1578    }
1579}
1580
1581#[derive(Debug, Clone)]
1582pub struct DebianGuestManagerControlHandle {
1583    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1584}
1585
1586impl fidl::endpoints::ControlHandle for DebianGuestManagerControlHandle {
1587    fn shutdown(&self) {
1588        self.inner.shutdown()
1589    }
1590
1591    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1592        self.inner.shutdown_with_epitaph(status)
1593    }
1594
1595    fn is_closed(&self) -> bool {
1596        self.inner.channel().is_closed()
1597    }
1598    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1599        self.inner.channel().on_closed()
1600    }
1601
1602    #[cfg(target_os = "fuchsia")]
1603    fn signal_peer(
1604        &self,
1605        clear_mask: zx::Signals,
1606        set_mask: zx::Signals,
1607    ) -> Result<(), zx_status::Status> {
1608        use fidl::Peered;
1609        self.inner.channel().signal_peer(clear_mask, set_mask)
1610    }
1611}
1612
1613impl DebianGuestManagerControlHandle {}
1614
1615#[must_use = "FIDL methods require a response to be sent"]
1616#[derive(Debug)]
1617pub struct DebianGuestManagerLaunchResponder {
1618    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1619    tx_id: u32,
1620}
1621
1622/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1623/// if the responder is dropped without sending a response, so that the client
1624/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1625impl std::ops::Drop for DebianGuestManagerLaunchResponder {
1626    fn drop(&mut self) {
1627        self.control_handle.shutdown();
1628        // Safety: drops once, never accessed again
1629        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1630    }
1631}
1632
1633impl fidl::endpoints::Responder for DebianGuestManagerLaunchResponder {
1634    type ControlHandle = DebianGuestManagerControlHandle;
1635
1636    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1637        &self.control_handle
1638    }
1639
1640    fn drop_without_shutdown(mut self) {
1641        // Safety: drops once, never accessed again due to mem::forget
1642        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1643        // Prevent Drop from running (which would shut down the channel)
1644        std::mem::forget(self);
1645    }
1646}
1647
1648impl DebianGuestManagerLaunchResponder {
1649    /// Sends a response to the FIDL transaction.
1650    ///
1651    /// Sets the channel to shutdown if an error occurs.
1652    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1653        let _result = self.send_raw(result);
1654        if _result.is_err() {
1655            self.control_handle.shutdown();
1656        }
1657        self.drop_without_shutdown();
1658        _result
1659    }
1660
1661    /// Similar to "send" but does not shutdown the channel if an error occurs.
1662    pub fn send_no_shutdown_on_err(
1663        self,
1664        mut result: Result<(), GuestManagerError>,
1665    ) -> Result<(), fidl::Error> {
1666        let _result = self.send_raw(result);
1667        self.drop_without_shutdown();
1668        _result
1669    }
1670
1671    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1672        self.control_handle.inner.send::<fidl::encoding::ResultType<
1673            fidl::encoding::EmptyStruct,
1674            GuestManagerError,
1675        >>(
1676            result,
1677            self.tx_id,
1678            0x394a2e29f750323e,
1679            fidl::encoding::DynamicFlags::empty(),
1680        )
1681    }
1682}
1683
1684#[must_use = "FIDL methods require a response to be sent"]
1685#[derive(Debug)]
1686pub struct DebianGuestManagerForceShutdownResponder {
1687    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1688    tx_id: u32,
1689}
1690
1691/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1692/// if the responder is dropped without sending a response, so that the client
1693/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1694impl std::ops::Drop for DebianGuestManagerForceShutdownResponder {
1695    fn drop(&mut self) {
1696        self.control_handle.shutdown();
1697        // Safety: drops once, never accessed again
1698        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1699    }
1700}
1701
1702impl fidl::endpoints::Responder for DebianGuestManagerForceShutdownResponder {
1703    type ControlHandle = DebianGuestManagerControlHandle;
1704
1705    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1706        &self.control_handle
1707    }
1708
1709    fn drop_without_shutdown(mut self) {
1710        // Safety: drops once, never accessed again due to mem::forget
1711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1712        // Prevent Drop from running (which would shut down the channel)
1713        std::mem::forget(self);
1714    }
1715}
1716
1717impl DebianGuestManagerForceShutdownResponder {
1718    /// Sends a response to the FIDL transaction.
1719    ///
1720    /// Sets the channel to shutdown if an error occurs.
1721    pub fn send(self) -> Result<(), fidl::Error> {
1722        let _result = self.send_raw();
1723        if _result.is_err() {
1724            self.control_handle.shutdown();
1725        }
1726        self.drop_without_shutdown();
1727        _result
1728    }
1729
1730    /// Similar to "send" but does not shutdown the channel if an error occurs.
1731    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1732        let _result = self.send_raw();
1733        self.drop_without_shutdown();
1734        _result
1735    }
1736
1737    fn send_raw(&self) -> Result<(), fidl::Error> {
1738        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1739            (),
1740            self.tx_id,
1741            0x3ad9a012982f872d,
1742            fidl::encoding::DynamicFlags::empty(),
1743        )
1744    }
1745}
1746
1747#[must_use = "FIDL methods require a response to be sent"]
1748#[derive(Debug)]
1749pub struct DebianGuestManagerConnectResponder {
1750    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1751    tx_id: u32,
1752}
1753
1754/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1755/// if the responder is dropped without sending a response, so that the client
1756/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1757impl std::ops::Drop for DebianGuestManagerConnectResponder {
1758    fn drop(&mut self) {
1759        self.control_handle.shutdown();
1760        // Safety: drops once, never accessed again
1761        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1762    }
1763}
1764
1765impl fidl::endpoints::Responder for DebianGuestManagerConnectResponder {
1766    type ControlHandle = DebianGuestManagerControlHandle;
1767
1768    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1769        &self.control_handle
1770    }
1771
1772    fn drop_without_shutdown(mut self) {
1773        // Safety: drops once, never accessed again due to mem::forget
1774        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1775        // Prevent Drop from running (which would shut down the channel)
1776        std::mem::forget(self);
1777    }
1778}
1779
1780impl DebianGuestManagerConnectResponder {
1781    /// Sends a response to the FIDL transaction.
1782    ///
1783    /// Sets the channel to shutdown if an error occurs.
1784    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1785        let _result = self.send_raw(result);
1786        if _result.is_err() {
1787            self.control_handle.shutdown();
1788        }
1789        self.drop_without_shutdown();
1790        _result
1791    }
1792
1793    /// Similar to "send" but does not shutdown the channel if an error occurs.
1794    pub fn send_no_shutdown_on_err(
1795        self,
1796        mut result: Result<(), GuestManagerError>,
1797    ) -> Result<(), fidl::Error> {
1798        let _result = self.send_raw(result);
1799        self.drop_without_shutdown();
1800        _result
1801    }
1802
1803    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
1804        self.control_handle.inner.send::<fidl::encoding::ResultType<
1805            fidl::encoding::EmptyStruct,
1806            GuestManagerError,
1807        >>(
1808            result,
1809            self.tx_id,
1810            0x4e489076e3bb15b4,
1811            fidl::encoding::DynamicFlags::empty(),
1812        )
1813    }
1814}
1815
1816#[must_use = "FIDL methods require a response to be sent"]
1817#[derive(Debug)]
1818pub struct DebianGuestManagerGetInfoResponder {
1819    control_handle: std::mem::ManuallyDrop<DebianGuestManagerControlHandle>,
1820    tx_id: u32,
1821}
1822
1823/// Set the the channel to be shutdown (see [`DebianGuestManagerControlHandle::shutdown`])
1824/// if the responder is dropped without sending a response, so that the client
1825/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1826impl std::ops::Drop for DebianGuestManagerGetInfoResponder {
1827    fn drop(&mut self) {
1828        self.control_handle.shutdown();
1829        // Safety: drops once, never accessed again
1830        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1831    }
1832}
1833
1834impl fidl::endpoints::Responder for DebianGuestManagerGetInfoResponder {
1835    type ControlHandle = DebianGuestManagerControlHandle;
1836
1837    fn control_handle(&self) -> &DebianGuestManagerControlHandle {
1838        &self.control_handle
1839    }
1840
1841    fn drop_without_shutdown(mut self) {
1842        // Safety: drops once, never accessed again due to mem::forget
1843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1844        // Prevent Drop from running (which would shut down the channel)
1845        std::mem::forget(self);
1846    }
1847}
1848
1849impl DebianGuestManagerGetInfoResponder {
1850    /// Sends a response to the FIDL transaction.
1851    ///
1852    /// Sets the channel to shutdown if an error occurs.
1853    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1854        let _result = self.send_raw(guest_info);
1855        if _result.is_err() {
1856            self.control_handle.shutdown();
1857        }
1858        self.drop_without_shutdown();
1859        _result
1860    }
1861
1862    /// Similar to "send" but does not shutdown the channel if an error occurs.
1863    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1864        let _result = self.send_raw(guest_info);
1865        self.drop_without_shutdown();
1866        _result
1867    }
1868
1869    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
1870        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
1871            (guest_info,),
1872            self.tx_id,
1873            0x76892614aea695dc,
1874            fidl::encoding::DynamicFlags::empty(),
1875        )
1876    }
1877}
1878
1879#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1880pub struct GuestMarker;
1881
1882impl fidl::endpoints::ProtocolMarker for GuestMarker {
1883    type Proxy = GuestProxy;
1884    type RequestStream = GuestRequestStream;
1885    #[cfg(target_os = "fuchsia")]
1886    type SynchronousProxy = GuestSynchronousProxy;
1887
1888    const DEBUG_NAME: &'static str = "fuchsia.virtualization.Guest";
1889}
1890impl fidl::endpoints::DiscoverableProtocolMarker for GuestMarker {}
1891pub type GuestGetConsoleResult = Result<fidl::Socket, GuestError>;
1892pub type GuestGetHostVsockEndpointResult = Result<(), GuestError>;
1893pub type GuestGetBalloonControllerResult = Result<(), GuestError>;
1894pub type GuestGetMemControllerResult = Result<(), GuestError>;
1895
1896pub trait GuestProxyInterface: Send + Sync {
1897    type GetConsoleResponseFut: std::future::Future<Output = Result<GuestGetConsoleResult, fidl::Error>>
1898        + Send;
1899    fn r#get_console(&self) -> Self::GetConsoleResponseFut;
1900    type GetSerialResponseFut: std::future::Future<Output = Result<fidl::Socket, fidl::Error>>
1901        + Send;
1902    fn r#get_serial(&self) -> Self::GetSerialResponseFut;
1903    type GetHostVsockEndpointResponseFut: std::future::Future<Output = Result<GuestGetHostVsockEndpointResult, fidl::Error>>
1904        + Send;
1905    fn r#get_host_vsock_endpoint(
1906        &self,
1907        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
1908    ) -> Self::GetHostVsockEndpointResponseFut;
1909    type GetBalloonControllerResponseFut: std::future::Future<Output = Result<GuestGetBalloonControllerResult, fidl::Error>>
1910        + Send;
1911    fn r#get_balloon_controller(
1912        &self,
1913        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
1914    ) -> Self::GetBalloonControllerResponseFut;
1915    type GetMemControllerResponseFut: std::future::Future<Output = Result<GuestGetMemControllerResult, fidl::Error>>
1916        + Send;
1917    fn r#get_mem_controller(
1918        &self,
1919        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
1920    ) -> Self::GetMemControllerResponseFut;
1921}
1922#[derive(Debug)]
1923#[cfg(target_os = "fuchsia")]
1924pub struct GuestSynchronousProxy {
1925    client: fidl::client::sync::Client,
1926}
1927
1928#[cfg(target_os = "fuchsia")]
1929impl fidl::endpoints::SynchronousProxy for GuestSynchronousProxy {
1930    type Proxy = GuestProxy;
1931    type Protocol = GuestMarker;
1932
1933    fn from_channel(inner: fidl::Channel) -> Self {
1934        Self::new(inner)
1935    }
1936
1937    fn into_channel(self) -> fidl::Channel {
1938        self.client.into_channel()
1939    }
1940
1941    fn as_channel(&self) -> &fidl::Channel {
1942        self.client.as_channel()
1943    }
1944}
1945
1946#[cfg(target_os = "fuchsia")]
1947impl GuestSynchronousProxy {
1948    pub fn new(channel: fidl::Channel) -> Self {
1949        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1950        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1951    }
1952
1953    pub fn into_channel(self) -> fidl::Channel {
1954        self.client.into_channel()
1955    }
1956
1957    /// Waits until an event arrives and returns it. It is safe for other
1958    /// threads to make concurrent requests while waiting for an event.
1959    pub fn wait_for_event(
1960        &self,
1961        deadline: zx::MonotonicInstant,
1962    ) -> Result<GuestEvent, fidl::Error> {
1963        GuestEvent::decode(self.client.wait_for_event(deadline)?)
1964    }
1965
1966    /// Get a guest console.
1967    ///
1968    /// The details regarding what output is produced and what input is accepted
1969    /// are determined by each guest, but will typically be a read/write socket
1970    /// with a shell.
1971    ///
1972    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
1973    pub fn r#get_console(
1974        &self,
1975        ___deadline: zx::MonotonicInstant,
1976    ) -> Result<GuestGetConsoleResult, fidl::Error> {
1977        let _response = self.client.send_query::<
1978            fidl::encoding::EmptyPayload,
1979            fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
1980        >(
1981            (),
1982            0x48cbcecb7793806e,
1983            fidl::encoding::DynamicFlags::empty(),
1984            ___deadline,
1985        )?;
1986        Ok(_response.map(|x| x.socket))
1987    }
1988
1989    /// Get the socket for low-level guest debug logs.
1990    ///
1991    /// The details regarding what output is produced and what input is accepted
1992    /// are determined by each guest, but will typically be a read-only socket
1993    /// with the guest kernel's serial logs.
1994    pub fn r#get_serial(
1995        &self,
1996        ___deadline: zx::MonotonicInstant,
1997    ) -> Result<fidl::Socket, fidl::Error> {
1998        let _response =
1999            self.client.send_query::<fidl::encoding::EmptyPayload, GuestGetSerialResponse>(
2000                (),
2001                0xcdd541a160d7044,
2002                fidl::encoding::DynamicFlags::empty(),
2003                ___deadline,
2004            )?;
2005        Ok(_response.socket)
2006    }
2007
2008    /// Get the vsock endpoint for the guest.
2009    ///
2010    /// This endpoint can be used to register listeners for guest initiated connections, and
2011    /// to initiate connections from a client. If listeners need to be registered before the guest
2012    /// starts so that they are immediately available, set them via the guest config instead of
2013    /// using this endpoint.
2014    ///
2015    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2016    pub fn r#get_host_vsock_endpoint(
2017        &self,
2018        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2019        ___deadline: zx::MonotonicInstant,
2020    ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2021        let _response = self.client.send_query::<
2022            GuestGetHostVsockEndpointRequest,
2023            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2024        >(
2025            (endpoint,),
2026            0x766e96aeb9c28ed1,
2027            fidl::encoding::DynamicFlags::empty(),
2028            ___deadline,
2029        )?;
2030        Ok(_response.map(|x| x))
2031    }
2032
2033    /// Get the balloon controller endpoint for the guest.
2034    ///
2035    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2036    pub fn r#get_balloon_controller(
2037        &self,
2038        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2039        ___deadline: zx::MonotonicInstant,
2040    ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2041        let _response = self.client.send_query::<
2042            GuestGetBalloonControllerRequest,
2043            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2044        >(
2045            (controller,),
2046            0x7b210bff219ac84e,
2047            fidl::encoding::DynamicFlags::empty(),
2048            ___deadline,
2049        )?;
2050        Ok(_response.map(|x| x))
2051    }
2052
2053    /// Get the mem controller endpoint for the guest.
2054    ///
2055    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2056    pub fn r#get_mem_controller(
2057        &self,
2058        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2059        ___deadline: zx::MonotonicInstant,
2060    ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2061        let _response = self.client.send_query::<
2062            GuestGetMemControllerRequest,
2063            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2064        >(
2065            (controller,),
2066            0x170b19f4b867a01c,
2067            fidl::encoding::DynamicFlags::empty(),
2068            ___deadline,
2069        )?;
2070        Ok(_response.map(|x| x))
2071    }
2072}
2073
2074#[cfg(target_os = "fuchsia")]
2075impl From<GuestSynchronousProxy> for zx::NullableHandle {
2076    fn from(value: GuestSynchronousProxy) -> Self {
2077        value.into_channel().into()
2078    }
2079}
2080
2081#[cfg(target_os = "fuchsia")]
2082impl From<fidl::Channel> for GuestSynchronousProxy {
2083    fn from(value: fidl::Channel) -> Self {
2084        Self::new(value)
2085    }
2086}
2087
2088#[cfg(target_os = "fuchsia")]
2089impl fidl::endpoints::FromClient for GuestSynchronousProxy {
2090    type Protocol = GuestMarker;
2091
2092    fn from_client(value: fidl::endpoints::ClientEnd<GuestMarker>) -> Self {
2093        Self::new(value.into_channel())
2094    }
2095}
2096
2097#[derive(Debug, Clone)]
2098pub struct GuestProxy {
2099    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2100}
2101
2102impl fidl::endpoints::Proxy for GuestProxy {
2103    type Protocol = GuestMarker;
2104
2105    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2106        Self::new(inner)
2107    }
2108
2109    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2110        self.client.into_channel().map_err(|client| Self { client })
2111    }
2112
2113    fn as_channel(&self) -> &::fidl::AsyncChannel {
2114        self.client.as_channel()
2115    }
2116}
2117
2118impl GuestProxy {
2119    /// Create a new Proxy for fuchsia.virtualization/Guest.
2120    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2121        let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2122        Self { client: fidl::client::Client::new(channel, protocol_name) }
2123    }
2124
2125    /// Get a Stream of events from the remote end of the protocol.
2126    ///
2127    /// # Panics
2128    ///
2129    /// Panics if the event stream was already taken.
2130    pub fn take_event_stream(&self) -> GuestEventStream {
2131        GuestEventStream { event_receiver: self.client.take_event_receiver() }
2132    }
2133
2134    /// Get a guest console.
2135    ///
2136    /// The details regarding what output is produced and what input is accepted
2137    /// are determined by each guest, but will typically be a read/write socket
2138    /// with a shell.
2139    ///
2140    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2141    pub fn r#get_console(
2142        &self,
2143    ) -> fidl::client::QueryResponseFut<
2144        GuestGetConsoleResult,
2145        fidl::encoding::DefaultFuchsiaResourceDialect,
2146    > {
2147        GuestProxyInterface::r#get_console(self)
2148    }
2149
2150    /// Get the socket for low-level guest debug logs.
2151    ///
2152    /// The details regarding what output is produced and what input is accepted
2153    /// are determined by each guest, but will typically be a read-only socket
2154    /// with the guest kernel's serial logs.
2155    pub fn r#get_serial(
2156        &self,
2157    ) -> fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>
2158    {
2159        GuestProxyInterface::r#get_serial(self)
2160    }
2161
2162    /// Get the vsock endpoint for the guest.
2163    ///
2164    /// This endpoint can be used to register listeners for guest initiated connections, and
2165    /// to initiate connections from a client. If listeners need to be registered before the guest
2166    /// starts so that they are immediately available, set them via the guest config instead of
2167    /// using this endpoint.
2168    ///
2169    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2170    pub fn r#get_host_vsock_endpoint(
2171        &self,
2172        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2173    ) -> fidl::client::QueryResponseFut<
2174        GuestGetHostVsockEndpointResult,
2175        fidl::encoding::DefaultFuchsiaResourceDialect,
2176    > {
2177        GuestProxyInterface::r#get_host_vsock_endpoint(self, endpoint)
2178    }
2179
2180    /// Get the balloon controller endpoint for the guest.
2181    ///
2182    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2183    pub fn r#get_balloon_controller(
2184        &self,
2185        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2186    ) -> fidl::client::QueryResponseFut<
2187        GuestGetBalloonControllerResult,
2188        fidl::encoding::DefaultFuchsiaResourceDialect,
2189    > {
2190        GuestProxyInterface::r#get_balloon_controller(self, controller)
2191    }
2192
2193    /// Get the mem controller endpoint for the guest.
2194    ///
2195    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2196    pub fn r#get_mem_controller(
2197        &self,
2198        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2199    ) -> fidl::client::QueryResponseFut<
2200        GuestGetMemControllerResult,
2201        fidl::encoding::DefaultFuchsiaResourceDialect,
2202    > {
2203        GuestProxyInterface::r#get_mem_controller(self, controller)
2204    }
2205}
2206
2207impl GuestProxyInterface for GuestProxy {
2208    type GetConsoleResponseFut = fidl::client::QueryResponseFut<
2209        GuestGetConsoleResult,
2210        fidl::encoding::DefaultFuchsiaResourceDialect,
2211    >;
2212    fn r#get_console(&self) -> Self::GetConsoleResponseFut {
2213        fn _decode(
2214            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2215        ) -> Result<GuestGetConsoleResult, fidl::Error> {
2216            let _response = fidl::client::decode_transaction_body::<
2217                fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>,
2218                fidl::encoding::DefaultFuchsiaResourceDialect,
2219                0x48cbcecb7793806e,
2220            >(_buf?)?;
2221            Ok(_response.map(|x| x.socket))
2222        }
2223        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestGetConsoleResult>(
2224            (),
2225            0x48cbcecb7793806e,
2226            fidl::encoding::DynamicFlags::empty(),
2227            _decode,
2228        )
2229    }
2230
2231    type GetSerialResponseFut =
2232        fidl::client::QueryResponseFut<fidl::Socket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2233    fn r#get_serial(&self) -> Self::GetSerialResponseFut {
2234        fn _decode(
2235            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2236        ) -> Result<fidl::Socket, fidl::Error> {
2237            let _response = fidl::client::decode_transaction_body::<
2238                GuestGetSerialResponse,
2239                fidl::encoding::DefaultFuchsiaResourceDialect,
2240                0xcdd541a160d7044,
2241            >(_buf?)?;
2242            Ok(_response.socket)
2243        }
2244        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Socket>(
2245            (),
2246            0xcdd541a160d7044,
2247            fidl::encoding::DynamicFlags::empty(),
2248            _decode,
2249        )
2250    }
2251
2252    type GetHostVsockEndpointResponseFut = fidl::client::QueryResponseFut<
2253        GuestGetHostVsockEndpointResult,
2254        fidl::encoding::DefaultFuchsiaResourceDialect,
2255    >;
2256    fn r#get_host_vsock_endpoint(
2257        &self,
2258        mut endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2259    ) -> Self::GetHostVsockEndpointResponseFut {
2260        fn _decode(
2261            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2262        ) -> Result<GuestGetHostVsockEndpointResult, fidl::Error> {
2263            let _response = fidl::client::decode_transaction_body::<
2264                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2265                fidl::encoding::DefaultFuchsiaResourceDialect,
2266                0x766e96aeb9c28ed1,
2267            >(_buf?)?;
2268            Ok(_response.map(|x| x))
2269        }
2270        self.client.send_query_and_decode::<
2271            GuestGetHostVsockEndpointRequest,
2272            GuestGetHostVsockEndpointResult,
2273        >(
2274            (endpoint,),
2275            0x766e96aeb9c28ed1,
2276            fidl::encoding::DynamicFlags::empty(),
2277            _decode,
2278        )
2279    }
2280
2281    type GetBalloonControllerResponseFut = fidl::client::QueryResponseFut<
2282        GuestGetBalloonControllerResult,
2283        fidl::encoding::DefaultFuchsiaResourceDialect,
2284    >;
2285    fn r#get_balloon_controller(
2286        &self,
2287        mut controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2288    ) -> Self::GetBalloonControllerResponseFut {
2289        fn _decode(
2290            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2291        ) -> Result<GuestGetBalloonControllerResult, fidl::Error> {
2292            let _response = fidl::client::decode_transaction_body::<
2293                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2294                fidl::encoding::DefaultFuchsiaResourceDialect,
2295                0x7b210bff219ac84e,
2296            >(_buf?)?;
2297            Ok(_response.map(|x| x))
2298        }
2299        self.client.send_query_and_decode::<
2300            GuestGetBalloonControllerRequest,
2301            GuestGetBalloonControllerResult,
2302        >(
2303            (controller,),
2304            0x7b210bff219ac84e,
2305            fidl::encoding::DynamicFlags::empty(),
2306            _decode,
2307        )
2308    }
2309
2310    type GetMemControllerResponseFut = fidl::client::QueryResponseFut<
2311        GuestGetMemControllerResult,
2312        fidl::encoding::DefaultFuchsiaResourceDialect,
2313    >;
2314    fn r#get_mem_controller(
2315        &self,
2316        mut controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2317    ) -> Self::GetMemControllerResponseFut {
2318        fn _decode(
2319            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2320        ) -> Result<GuestGetMemControllerResult, fidl::Error> {
2321            let _response = fidl::client::decode_transaction_body::<
2322                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
2323                fidl::encoding::DefaultFuchsiaResourceDialect,
2324                0x170b19f4b867a01c,
2325            >(_buf?)?;
2326            Ok(_response.map(|x| x))
2327        }
2328        self.client
2329            .send_query_and_decode::<GuestGetMemControllerRequest, GuestGetMemControllerResult>(
2330                (controller,),
2331                0x170b19f4b867a01c,
2332                fidl::encoding::DynamicFlags::empty(),
2333                _decode,
2334            )
2335    }
2336}
2337
2338pub struct GuestEventStream {
2339    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2340}
2341
2342impl std::marker::Unpin for GuestEventStream {}
2343
2344impl futures::stream::FusedStream for GuestEventStream {
2345    fn is_terminated(&self) -> bool {
2346        self.event_receiver.is_terminated()
2347    }
2348}
2349
2350impl futures::Stream for GuestEventStream {
2351    type Item = Result<GuestEvent, fidl::Error>;
2352
2353    fn poll_next(
2354        mut self: std::pin::Pin<&mut Self>,
2355        cx: &mut std::task::Context<'_>,
2356    ) -> std::task::Poll<Option<Self::Item>> {
2357        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2358            &mut self.event_receiver,
2359            cx
2360        )?) {
2361            Some(buf) => std::task::Poll::Ready(Some(GuestEvent::decode(buf))),
2362            None => std::task::Poll::Ready(None),
2363        }
2364    }
2365}
2366
2367#[derive(Debug)]
2368pub enum GuestEvent {}
2369
2370impl GuestEvent {
2371    /// Decodes a message buffer as a [`GuestEvent`].
2372    fn decode(
2373        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2374    ) -> Result<GuestEvent, fidl::Error> {
2375        let (bytes, _handles) = buf.split_mut();
2376        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2377        debug_assert_eq!(tx_header.tx_id, 0);
2378        match tx_header.ordinal {
2379            _ => Err(fidl::Error::UnknownOrdinal {
2380                ordinal: tx_header.ordinal,
2381                protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2382            }),
2383        }
2384    }
2385}
2386
2387/// A Stream of incoming requests for fuchsia.virtualization/Guest.
2388pub struct GuestRequestStream {
2389    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2390    is_terminated: bool,
2391}
2392
2393impl std::marker::Unpin for GuestRequestStream {}
2394
2395impl futures::stream::FusedStream for GuestRequestStream {
2396    fn is_terminated(&self) -> bool {
2397        self.is_terminated
2398    }
2399}
2400
2401impl fidl::endpoints::RequestStream for GuestRequestStream {
2402    type Protocol = GuestMarker;
2403    type ControlHandle = GuestControlHandle;
2404
2405    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2406        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2407    }
2408
2409    fn control_handle(&self) -> Self::ControlHandle {
2410        GuestControlHandle { inner: self.inner.clone() }
2411    }
2412
2413    fn into_inner(
2414        self,
2415    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2416    {
2417        (self.inner, self.is_terminated)
2418    }
2419
2420    fn from_inner(
2421        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2422        is_terminated: bool,
2423    ) -> Self {
2424        Self { inner, is_terminated }
2425    }
2426}
2427
2428impl futures::Stream for GuestRequestStream {
2429    type Item = Result<GuestRequest, fidl::Error>;
2430
2431    fn poll_next(
2432        mut self: std::pin::Pin<&mut Self>,
2433        cx: &mut std::task::Context<'_>,
2434    ) -> std::task::Poll<Option<Self::Item>> {
2435        let this = &mut *self;
2436        if this.inner.check_shutdown(cx) {
2437            this.is_terminated = true;
2438            return std::task::Poll::Ready(None);
2439        }
2440        if this.is_terminated {
2441            panic!("polled GuestRequestStream after completion");
2442        }
2443        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2444            |bytes, handles| {
2445                match this.inner.channel().read_etc(cx, bytes, handles) {
2446                    std::task::Poll::Ready(Ok(())) => {}
2447                    std::task::Poll::Pending => return std::task::Poll::Pending,
2448                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2449                        this.is_terminated = true;
2450                        return std::task::Poll::Ready(None);
2451                    }
2452                    std::task::Poll::Ready(Err(e)) => {
2453                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2454                            e.into(),
2455                        ))));
2456                    }
2457                }
2458
2459                // A message has been received from the channel
2460                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2461
2462                std::task::Poll::Ready(Some(match header.ordinal {
2463                    0x48cbcecb7793806e => {
2464                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2465                        let mut req = fidl::new_empty!(
2466                            fidl::encoding::EmptyPayload,
2467                            fidl::encoding::DefaultFuchsiaResourceDialect
2468                        );
2469                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2470                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2471                        Ok(GuestRequest::GetConsole {
2472                            responder: GuestGetConsoleResponder {
2473                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2474                                tx_id: header.tx_id,
2475                            },
2476                        })
2477                    }
2478                    0xcdd541a160d7044 => {
2479                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2480                        let mut req = fidl::new_empty!(
2481                            fidl::encoding::EmptyPayload,
2482                            fidl::encoding::DefaultFuchsiaResourceDialect
2483                        );
2484                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2485                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2486                        Ok(GuestRequest::GetSerial {
2487                            responder: GuestGetSerialResponder {
2488                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2489                                tx_id: header.tx_id,
2490                            },
2491                        })
2492                    }
2493                    0x766e96aeb9c28ed1 => {
2494                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2495                        let mut req = fidl::new_empty!(
2496                            GuestGetHostVsockEndpointRequest,
2497                            fidl::encoding::DefaultFuchsiaResourceDialect
2498                        );
2499                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetHostVsockEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
2500                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2501                        Ok(GuestRequest::GetHostVsockEndpoint {
2502                            endpoint: req.endpoint,
2503
2504                            responder: GuestGetHostVsockEndpointResponder {
2505                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2506                                tx_id: header.tx_id,
2507                            },
2508                        })
2509                    }
2510                    0x7b210bff219ac84e => {
2511                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2512                        let mut req = fidl::new_empty!(
2513                            GuestGetBalloonControllerRequest,
2514                            fidl::encoding::DefaultFuchsiaResourceDialect
2515                        );
2516                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetBalloonControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2517                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2518                        Ok(GuestRequest::GetBalloonController {
2519                            controller: req.controller,
2520
2521                            responder: GuestGetBalloonControllerResponder {
2522                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2523                                tx_id: header.tx_id,
2524                            },
2525                        })
2526                    }
2527                    0x170b19f4b867a01c => {
2528                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2529                        let mut req = fidl::new_empty!(
2530                            GuestGetMemControllerRequest,
2531                            fidl::encoding::DefaultFuchsiaResourceDialect
2532                        );
2533                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestGetMemControllerRequest>(&header, _body_bytes, handles, &mut req)?;
2534                        let control_handle = GuestControlHandle { inner: this.inner.clone() };
2535                        Ok(GuestRequest::GetMemController {
2536                            controller: req.controller,
2537
2538                            responder: GuestGetMemControllerResponder {
2539                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2540                                tx_id: header.tx_id,
2541                            },
2542                        })
2543                    }
2544                    _ => Err(fidl::Error::UnknownOrdinal {
2545                        ordinal: header.ordinal,
2546                        protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2547                    }),
2548                }))
2549            },
2550        )
2551    }
2552}
2553
2554/// The guest client API providing high level access to guest features. When the guest terminates,
2555/// this channel will contain a ZX_OK epitaph on a clean shutdown, a ZX_ERR_INTERNAL epitaph on
2556/// an unexpected shutdown, and no epitaph if the component crashed.
2557#[derive(Debug)]
2558pub enum GuestRequest {
2559    /// Get a guest console.
2560    ///
2561    /// The details regarding what output is produced and what input is accepted
2562    /// are determined by each guest, but will typically be a read/write socket
2563    /// with a shell.
2564    ///
2565    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a console device.
2566    GetConsole { responder: GuestGetConsoleResponder },
2567    /// Get the socket for low-level guest debug logs.
2568    ///
2569    /// The details regarding what output is produced and what input is accepted
2570    /// are determined by each guest, but will typically be a read-only socket
2571    /// with the guest kernel's serial logs.
2572    GetSerial { responder: GuestGetSerialResponder },
2573    /// Get the vsock endpoint for the guest.
2574    ///
2575    /// This endpoint can be used to register listeners for guest initiated connections, and
2576    /// to initiate connections from a client. If listeners need to be registered before the guest
2577    /// starts so that they are immediately available, set them via the guest config instead of
2578    /// using this endpoint.
2579    ///
2580    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a vsock device.
2581    GetHostVsockEndpoint {
2582        endpoint: fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2583        responder: GuestGetHostVsockEndpointResponder,
2584    },
2585    /// Get the balloon controller endpoint for the guest.
2586    ///
2587    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a balloon device.
2588    GetBalloonController {
2589        controller: fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2590        responder: GuestGetBalloonControllerResponder,
2591    },
2592    /// Get the mem controller endpoint for the guest.
2593    ///
2594    /// Returns error DEVICE_NOT_PRESENT if the guest was started without a mem device.
2595    GetMemController {
2596        controller: fidl::endpoints::ServerEnd<MemControllerMarker>,
2597        responder: GuestGetMemControllerResponder,
2598    },
2599}
2600
2601impl GuestRequest {
2602    #[allow(irrefutable_let_patterns)]
2603    pub fn into_get_console(self) -> Option<(GuestGetConsoleResponder)> {
2604        if let GuestRequest::GetConsole { responder } = self { Some((responder)) } else { None }
2605    }
2606
2607    #[allow(irrefutable_let_patterns)]
2608    pub fn into_get_serial(self) -> Option<(GuestGetSerialResponder)> {
2609        if let GuestRequest::GetSerial { responder } = self { Some((responder)) } else { None }
2610    }
2611
2612    #[allow(irrefutable_let_patterns)]
2613    pub fn into_get_host_vsock_endpoint(
2614        self,
2615    ) -> Option<(
2616        fidl::endpoints::ServerEnd<HostVsockEndpointMarker>,
2617        GuestGetHostVsockEndpointResponder,
2618    )> {
2619        if let GuestRequest::GetHostVsockEndpoint { endpoint, responder } = self {
2620            Some((endpoint, responder))
2621        } else {
2622            None
2623        }
2624    }
2625
2626    #[allow(irrefutable_let_patterns)]
2627    pub fn into_get_balloon_controller(
2628        self,
2629    ) -> Option<(
2630        fidl::endpoints::ServerEnd<BalloonControllerMarker>,
2631        GuestGetBalloonControllerResponder,
2632    )> {
2633        if let GuestRequest::GetBalloonController { controller, responder } = self {
2634            Some((controller, responder))
2635        } else {
2636            None
2637        }
2638    }
2639
2640    #[allow(irrefutable_let_patterns)]
2641    pub fn into_get_mem_controller(
2642        self,
2643    ) -> Option<(fidl::endpoints::ServerEnd<MemControllerMarker>, GuestGetMemControllerResponder)>
2644    {
2645        if let GuestRequest::GetMemController { controller, responder } = self {
2646            Some((controller, responder))
2647        } else {
2648            None
2649        }
2650    }
2651
2652    /// Name of the method defined in FIDL
2653    pub fn method_name(&self) -> &'static str {
2654        match *self {
2655            GuestRequest::GetConsole { .. } => "get_console",
2656            GuestRequest::GetSerial { .. } => "get_serial",
2657            GuestRequest::GetHostVsockEndpoint { .. } => "get_host_vsock_endpoint",
2658            GuestRequest::GetBalloonController { .. } => "get_balloon_controller",
2659            GuestRequest::GetMemController { .. } => "get_mem_controller",
2660        }
2661    }
2662}
2663
2664#[derive(Debug, Clone)]
2665pub struct GuestControlHandle {
2666    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2667}
2668
2669impl fidl::endpoints::ControlHandle for GuestControlHandle {
2670    fn shutdown(&self) {
2671        self.inner.shutdown()
2672    }
2673
2674    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2675        self.inner.shutdown_with_epitaph(status)
2676    }
2677
2678    fn is_closed(&self) -> bool {
2679        self.inner.channel().is_closed()
2680    }
2681    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2682        self.inner.channel().on_closed()
2683    }
2684
2685    #[cfg(target_os = "fuchsia")]
2686    fn signal_peer(
2687        &self,
2688        clear_mask: zx::Signals,
2689        set_mask: zx::Signals,
2690    ) -> Result<(), zx_status::Status> {
2691        use fidl::Peered;
2692        self.inner.channel().signal_peer(clear_mask, set_mask)
2693    }
2694}
2695
2696impl GuestControlHandle {}
2697
2698#[must_use = "FIDL methods require a response to be sent"]
2699#[derive(Debug)]
2700pub struct GuestGetConsoleResponder {
2701    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2702    tx_id: u32,
2703}
2704
2705/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2706/// if the responder is dropped without sending a response, so that the client
2707/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2708impl std::ops::Drop for GuestGetConsoleResponder {
2709    fn drop(&mut self) {
2710        self.control_handle.shutdown();
2711        // Safety: drops once, never accessed again
2712        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2713    }
2714}
2715
2716impl fidl::endpoints::Responder for GuestGetConsoleResponder {
2717    type ControlHandle = GuestControlHandle;
2718
2719    fn control_handle(&self) -> &GuestControlHandle {
2720        &self.control_handle
2721    }
2722
2723    fn drop_without_shutdown(mut self) {
2724        // Safety: drops once, never accessed again due to mem::forget
2725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2726        // Prevent Drop from running (which would shut down the channel)
2727        std::mem::forget(self);
2728    }
2729}
2730
2731impl GuestGetConsoleResponder {
2732    /// Sends a response to the FIDL transaction.
2733    ///
2734    /// Sets the channel to shutdown if an error occurs.
2735    pub fn send(self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2736        let _result = self.send_raw(result);
2737        if _result.is_err() {
2738            self.control_handle.shutdown();
2739        }
2740        self.drop_without_shutdown();
2741        _result
2742    }
2743
2744    /// Similar to "send" but does not shutdown the channel if an error occurs.
2745    pub fn send_no_shutdown_on_err(
2746        self,
2747        mut result: Result<fidl::Socket, GuestError>,
2748    ) -> Result<(), fidl::Error> {
2749        let _result = self.send_raw(result);
2750        self.drop_without_shutdown();
2751        _result
2752    }
2753
2754    fn send_raw(&self, mut result: Result<fidl::Socket, GuestError>) -> Result<(), fidl::Error> {
2755        self.control_handle
2756            .inner
2757            .send::<fidl::encoding::ResultType<GuestGetConsoleResponse, GuestError>>(
2758                result.map(|socket| (socket,)),
2759                self.tx_id,
2760                0x48cbcecb7793806e,
2761                fidl::encoding::DynamicFlags::empty(),
2762            )
2763    }
2764}
2765
2766#[must_use = "FIDL methods require a response to be sent"]
2767#[derive(Debug)]
2768pub struct GuestGetSerialResponder {
2769    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2770    tx_id: u32,
2771}
2772
2773/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2774/// if the responder is dropped without sending a response, so that the client
2775/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2776impl std::ops::Drop for GuestGetSerialResponder {
2777    fn drop(&mut self) {
2778        self.control_handle.shutdown();
2779        // Safety: drops once, never accessed again
2780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2781    }
2782}
2783
2784impl fidl::endpoints::Responder for GuestGetSerialResponder {
2785    type ControlHandle = GuestControlHandle;
2786
2787    fn control_handle(&self) -> &GuestControlHandle {
2788        &self.control_handle
2789    }
2790
2791    fn drop_without_shutdown(mut self) {
2792        // Safety: drops once, never accessed again due to mem::forget
2793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2794        // Prevent Drop from running (which would shut down the channel)
2795        std::mem::forget(self);
2796    }
2797}
2798
2799impl GuestGetSerialResponder {
2800    /// Sends a response to the FIDL transaction.
2801    ///
2802    /// Sets the channel to shutdown if an error occurs.
2803    pub fn send(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2804        let _result = self.send_raw(socket);
2805        if _result.is_err() {
2806            self.control_handle.shutdown();
2807        }
2808        self.drop_without_shutdown();
2809        _result
2810    }
2811
2812    /// Similar to "send" but does not shutdown the channel if an error occurs.
2813    pub fn send_no_shutdown_on_err(self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2814        let _result = self.send_raw(socket);
2815        self.drop_without_shutdown();
2816        _result
2817    }
2818
2819    fn send_raw(&self, mut socket: fidl::Socket) -> Result<(), fidl::Error> {
2820        self.control_handle.inner.send::<GuestGetSerialResponse>(
2821            (socket,),
2822            self.tx_id,
2823            0xcdd541a160d7044,
2824            fidl::encoding::DynamicFlags::empty(),
2825        )
2826    }
2827}
2828
2829#[must_use = "FIDL methods require a response to be sent"]
2830#[derive(Debug)]
2831pub struct GuestGetHostVsockEndpointResponder {
2832    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2833    tx_id: u32,
2834}
2835
2836/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2837/// if the responder is dropped without sending a response, so that the client
2838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2839impl std::ops::Drop for GuestGetHostVsockEndpointResponder {
2840    fn drop(&mut self) {
2841        self.control_handle.shutdown();
2842        // Safety: drops once, never accessed again
2843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2844    }
2845}
2846
2847impl fidl::endpoints::Responder for GuestGetHostVsockEndpointResponder {
2848    type ControlHandle = GuestControlHandle;
2849
2850    fn control_handle(&self) -> &GuestControlHandle {
2851        &self.control_handle
2852    }
2853
2854    fn drop_without_shutdown(mut self) {
2855        // Safety: drops once, never accessed again due to mem::forget
2856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2857        // Prevent Drop from running (which would shut down the channel)
2858        std::mem::forget(self);
2859    }
2860}
2861
2862impl GuestGetHostVsockEndpointResponder {
2863    /// Sends a response to the FIDL transaction.
2864    ///
2865    /// Sets the channel to shutdown if an error occurs.
2866    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2867        let _result = self.send_raw(result);
2868        if _result.is_err() {
2869            self.control_handle.shutdown();
2870        }
2871        self.drop_without_shutdown();
2872        _result
2873    }
2874
2875    /// Similar to "send" but does not shutdown the channel if an error occurs.
2876    pub fn send_no_shutdown_on_err(
2877        self,
2878        mut result: Result<(), GuestError>,
2879    ) -> Result<(), fidl::Error> {
2880        let _result = self.send_raw(result);
2881        self.drop_without_shutdown();
2882        _result
2883    }
2884
2885    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2886        self.control_handle
2887            .inner
2888            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2889                result,
2890                self.tx_id,
2891                0x766e96aeb9c28ed1,
2892                fidl::encoding::DynamicFlags::empty(),
2893            )
2894    }
2895}
2896
2897#[must_use = "FIDL methods require a response to be sent"]
2898#[derive(Debug)]
2899pub struct GuestGetBalloonControllerResponder {
2900    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2901    tx_id: u32,
2902}
2903
2904/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2905/// if the responder is dropped without sending a response, so that the client
2906/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2907impl std::ops::Drop for GuestGetBalloonControllerResponder {
2908    fn drop(&mut self) {
2909        self.control_handle.shutdown();
2910        // Safety: drops once, never accessed again
2911        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2912    }
2913}
2914
2915impl fidl::endpoints::Responder for GuestGetBalloonControllerResponder {
2916    type ControlHandle = GuestControlHandle;
2917
2918    fn control_handle(&self) -> &GuestControlHandle {
2919        &self.control_handle
2920    }
2921
2922    fn drop_without_shutdown(mut self) {
2923        // Safety: drops once, never accessed again due to mem::forget
2924        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2925        // Prevent Drop from running (which would shut down the channel)
2926        std::mem::forget(self);
2927    }
2928}
2929
2930impl GuestGetBalloonControllerResponder {
2931    /// Sends a response to the FIDL transaction.
2932    ///
2933    /// Sets the channel to shutdown if an error occurs.
2934    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2935        let _result = self.send_raw(result);
2936        if _result.is_err() {
2937            self.control_handle.shutdown();
2938        }
2939        self.drop_without_shutdown();
2940        _result
2941    }
2942
2943    /// Similar to "send" but does not shutdown the channel if an error occurs.
2944    pub fn send_no_shutdown_on_err(
2945        self,
2946        mut result: Result<(), GuestError>,
2947    ) -> Result<(), fidl::Error> {
2948        let _result = self.send_raw(result);
2949        self.drop_without_shutdown();
2950        _result
2951    }
2952
2953    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
2954        self.control_handle
2955            .inner
2956            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
2957                result,
2958                self.tx_id,
2959                0x7b210bff219ac84e,
2960                fidl::encoding::DynamicFlags::empty(),
2961            )
2962    }
2963}
2964
2965#[must_use = "FIDL methods require a response to be sent"]
2966#[derive(Debug)]
2967pub struct GuestGetMemControllerResponder {
2968    control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
2969    tx_id: u32,
2970}
2971
2972/// Set the the channel to be shutdown (see [`GuestControlHandle::shutdown`])
2973/// if the responder is dropped without sending a response, so that the client
2974/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2975impl std::ops::Drop for GuestGetMemControllerResponder {
2976    fn drop(&mut self) {
2977        self.control_handle.shutdown();
2978        // Safety: drops once, never accessed again
2979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2980    }
2981}
2982
2983impl fidl::endpoints::Responder for GuestGetMemControllerResponder {
2984    type ControlHandle = GuestControlHandle;
2985
2986    fn control_handle(&self) -> &GuestControlHandle {
2987        &self.control_handle
2988    }
2989
2990    fn drop_without_shutdown(mut self) {
2991        // Safety: drops once, never accessed again due to mem::forget
2992        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2993        // Prevent Drop from running (which would shut down the channel)
2994        std::mem::forget(self);
2995    }
2996}
2997
2998impl GuestGetMemControllerResponder {
2999    /// Sends a response to the FIDL transaction.
3000    ///
3001    /// Sets the channel to shutdown if an error occurs.
3002    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3003        let _result = self.send_raw(result);
3004        if _result.is_err() {
3005            self.control_handle.shutdown();
3006        }
3007        self.drop_without_shutdown();
3008        _result
3009    }
3010
3011    /// Similar to "send" but does not shutdown the channel if an error occurs.
3012    pub fn send_no_shutdown_on_err(
3013        self,
3014        mut result: Result<(), GuestError>,
3015    ) -> Result<(), fidl::Error> {
3016        let _result = self.send_raw(result);
3017        self.drop_without_shutdown();
3018        _result
3019    }
3020
3021    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3022        self.control_handle
3023            .inner
3024            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3025                result,
3026                self.tx_id,
3027                0x170b19f4b867a01c,
3028                fidl::encoding::DynamicFlags::empty(),
3029            )
3030    }
3031}
3032
3033#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3034pub struct GuestLifecycleMarker;
3035
3036impl fidl::endpoints::ProtocolMarker for GuestLifecycleMarker {
3037    type Proxy = GuestLifecycleProxy;
3038    type RequestStream = GuestLifecycleRequestStream;
3039    #[cfg(target_os = "fuchsia")]
3040    type SynchronousProxy = GuestLifecycleSynchronousProxy;
3041
3042    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestLifecycle";
3043}
3044impl fidl::endpoints::DiscoverableProtocolMarker for GuestLifecycleMarker {}
3045pub type GuestLifecycleCreateResult = Result<(), GuestError>;
3046pub type GuestLifecycleRunResult = Result<(), GuestError>;
3047
3048pub trait GuestLifecycleProxyInterface: Send + Sync {
3049    type CreateResponseFut: std::future::Future<Output = Result<GuestLifecycleCreateResult, fidl::Error>>
3050        + Send;
3051    fn r#create(&self, guest_config: GuestConfig) -> Self::CreateResponseFut;
3052    fn r#bind(&self, guest: fidl::endpoints::ServerEnd<GuestMarker>) -> Result<(), fidl::Error>;
3053    type RunResponseFut: std::future::Future<Output = Result<GuestLifecycleRunResult, fidl::Error>>
3054        + Send;
3055    fn r#run(&self) -> Self::RunResponseFut;
3056    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3057    fn r#stop(&self) -> Self::StopResponseFut;
3058}
3059#[derive(Debug)]
3060#[cfg(target_os = "fuchsia")]
3061pub struct GuestLifecycleSynchronousProxy {
3062    client: fidl::client::sync::Client,
3063}
3064
3065#[cfg(target_os = "fuchsia")]
3066impl fidl::endpoints::SynchronousProxy for GuestLifecycleSynchronousProxy {
3067    type Proxy = GuestLifecycleProxy;
3068    type Protocol = GuestLifecycleMarker;
3069
3070    fn from_channel(inner: fidl::Channel) -> Self {
3071        Self::new(inner)
3072    }
3073
3074    fn into_channel(self) -> fidl::Channel {
3075        self.client.into_channel()
3076    }
3077
3078    fn as_channel(&self) -> &fidl::Channel {
3079        self.client.as_channel()
3080    }
3081}
3082
3083#[cfg(target_os = "fuchsia")]
3084impl GuestLifecycleSynchronousProxy {
3085    pub fn new(channel: fidl::Channel) -> Self {
3086        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3087        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3088    }
3089
3090    pub fn into_channel(self) -> fidl::Channel {
3091        self.client.into_channel()
3092    }
3093
3094    /// Waits until an event arrives and returns it. It is safe for other
3095    /// threads to make concurrent requests while waiting for an event.
3096    pub fn wait_for_event(
3097        &self,
3098        deadline: zx::MonotonicInstant,
3099    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3100        GuestLifecycleEvent::decode(self.client.wait_for_event(deadline)?)
3101    }
3102
3103    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3104    /// the kernel without starting the VCPU or device dispatch loops.
3105    ///
3106    /// Possible errors:
3107    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3108    ///         recreated.
3109    ///
3110    /// All other errors are related to VMM initialization.
3111    pub fn r#create(
3112        &self,
3113        mut guest_config: GuestConfig,
3114        ___deadline: zx::MonotonicInstant,
3115    ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3116        let _response = self.client.send_query::<
3117            GuestLifecycleCreateRequest,
3118            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3119        >(
3120            (&mut guest_config,),
3121            0x152719eed416ed41,
3122            fidl::encoding::DynamicFlags::empty(),
3123            ___deadline,
3124        )?;
3125        Ok(_response.map(|x| x))
3126    }
3127
3128    /// Binds to the Guest protocol for an initialized guest.
3129    ///
3130    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3131    /// will be immediately closed.
3132    pub fn r#bind(
3133        &self,
3134        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3135    ) -> Result<(), fidl::Error> {
3136        self.client.send::<GuestLifecycleBindRequest>(
3137            (guest,),
3138            0x57dd3e245f9598ed,
3139            fidl::encoding::DynamicFlags::empty(),
3140        )
3141    }
3142
3143    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3144    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3145    ///
3146    /// Possible errors:
3147    ///     - ALREADY_RUNING: The VMM has already been started.
3148    ///     - NOT_CREATED: Run was called before the VMM was created.
3149    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3150    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3151    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3152    pub fn r#run(
3153        &self,
3154        ___deadline: zx::MonotonicInstant,
3155    ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3156        let _response = self.client.send_query::<
3157            fidl::encoding::EmptyPayload,
3158            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3159        >(
3160            (),
3161            0x2907fef2ac775657,
3162            fidl::encoding::DynamicFlags::empty(),
3163            ___deadline,
3164        )?;
3165        Ok(_response.map(|x| x))
3166    }
3167
3168    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3169    /// Create and then Run can be called again.
3170    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3171        let _response =
3172            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
3173                (),
3174                0x27eef9c535ac8eb4,
3175                fidl::encoding::DynamicFlags::empty(),
3176                ___deadline,
3177            )?;
3178        Ok(_response)
3179    }
3180}
3181
3182#[cfg(target_os = "fuchsia")]
3183impl From<GuestLifecycleSynchronousProxy> for zx::NullableHandle {
3184    fn from(value: GuestLifecycleSynchronousProxy) -> Self {
3185        value.into_channel().into()
3186    }
3187}
3188
3189#[cfg(target_os = "fuchsia")]
3190impl From<fidl::Channel> for GuestLifecycleSynchronousProxy {
3191    fn from(value: fidl::Channel) -> Self {
3192        Self::new(value)
3193    }
3194}
3195
3196#[cfg(target_os = "fuchsia")]
3197impl fidl::endpoints::FromClient for GuestLifecycleSynchronousProxy {
3198    type Protocol = GuestLifecycleMarker;
3199
3200    fn from_client(value: fidl::endpoints::ClientEnd<GuestLifecycleMarker>) -> Self {
3201        Self::new(value.into_channel())
3202    }
3203}
3204
3205#[derive(Debug, Clone)]
3206pub struct GuestLifecycleProxy {
3207    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3208}
3209
3210impl fidl::endpoints::Proxy for GuestLifecycleProxy {
3211    type Protocol = GuestLifecycleMarker;
3212
3213    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3214        Self::new(inner)
3215    }
3216
3217    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3218        self.client.into_channel().map_err(|client| Self { client })
3219    }
3220
3221    fn as_channel(&self) -> &::fidl::AsyncChannel {
3222        self.client.as_channel()
3223    }
3224}
3225
3226impl GuestLifecycleProxy {
3227    /// Create a new Proxy for fuchsia.virtualization/GuestLifecycle.
3228    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3229        let protocol_name = <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3230        Self { client: fidl::client::Client::new(channel, protocol_name) }
3231    }
3232
3233    /// Get a Stream of events from the remote end of the protocol.
3234    ///
3235    /// # Panics
3236    ///
3237    /// Panics if the event stream was already taken.
3238    pub fn take_event_stream(&self) -> GuestLifecycleEventStream {
3239        GuestLifecycleEventStream { event_receiver: self.client.take_event_receiver() }
3240    }
3241
3242    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3243    /// the kernel without starting the VCPU or device dispatch loops.
3244    ///
3245    /// Possible errors:
3246    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3247    ///         recreated.
3248    ///
3249    /// All other errors are related to VMM initialization.
3250    pub fn r#create(
3251        &self,
3252        mut guest_config: GuestConfig,
3253    ) -> fidl::client::QueryResponseFut<
3254        GuestLifecycleCreateResult,
3255        fidl::encoding::DefaultFuchsiaResourceDialect,
3256    > {
3257        GuestLifecycleProxyInterface::r#create(self, guest_config)
3258    }
3259
3260    /// Binds to the Guest protocol for an initialized guest.
3261    ///
3262    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3263    /// will be immediately closed.
3264    pub fn r#bind(
3265        &self,
3266        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3267    ) -> Result<(), fidl::Error> {
3268        GuestLifecycleProxyInterface::r#bind(self, guest)
3269    }
3270
3271    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3272    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3273    ///
3274    /// Possible errors:
3275    ///     - ALREADY_RUNING: The VMM has already been started.
3276    ///     - NOT_CREATED: Run was called before the VMM was created.
3277    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3278    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3279    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3280    pub fn r#run(
3281        &self,
3282    ) -> fidl::client::QueryResponseFut<
3283        GuestLifecycleRunResult,
3284        fidl::encoding::DefaultFuchsiaResourceDialect,
3285    > {
3286        GuestLifecycleProxyInterface::r#run(self)
3287    }
3288
3289    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3290    /// Create and then Run can be called again.
3291    pub fn r#stop(
3292        &self,
3293    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3294        GuestLifecycleProxyInterface::r#stop(self)
3295    }
3296}
3297
3298impl GuestLifecycleProxyInterface for GuestLifecycleProxy {
3299    type CreateResponseFut = fidl::client::QueryResponseFut<
3300        GuestLifecycleCreateResult,
3301        fidl::encoding::DefaultFuchsiaResourceDialect,
3302    >;
3303    fn r#create(&self, mut guest_config: GuestConfig) -> Self::CreateResponseFut {
3304        fn _decode(
3305            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3306        ) -> Result<GuestLifecycleCreateResult, fidl::Error> {
3307            let _response = fidl::client::decode_transaction_body::<
3308                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3309                fidl::encoding::DefaultFuchsiaResourceDialect,
3310                0x152719eed416ed41,
3311            >(_buf?)?;
3312            Ok(_response.map(|x| x))
3313        }
3314        self.client
3315            .send_query_and_decode::<GuestLifecycleCreateRequest, GuestLifecycleCreateResult>(
3316                (&mut guest_config,),
3317                0x152719eed416ed41,
3318                fidl::encoding::DynamicFlags::empty(),
3319                _decode,
3320            )
3321    }
3322
3323    fn r#bind(
3324        &self,
3325        mut guest: fidl::endpoints::ServerEnd<GuestMarker>,
3326    ) -> Result<(), fidl::Error> {
3327        self.client.send::<GuestLifecycleBindRequest>(
3328            (guest,),
3329            0x57dd3e245f9598ed,
3330            fidl::encoding::DynamicFlags::empty(),
3331        )
3332    }
3333
3334    type RunResponseFut = fidl::client::QueryResponseFut<
3335        GuestLifecycleRunResult,
3336        fidl::encoding::DefaultFuchsiaResourceDialect,
3337    >;
3338    fn r#run(&self) -> Self::RunResponseFut {
3339        fn _decode(
3340            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3341        ) -> Result<GuestLifecycleRunResult, fidl::Error> {
3342            let _response = fidl::client::decode_transaction_body::<
3343                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>,
3344                fidl::encoding::DefaultFuchsiaResourceDialect,
3345                0x2907fef2ac775657,
3346            >(_buf?)?;
3347            Ok(_response.map(|x| x))
3348        }
3349        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestLifecycleRunResult>(
3350            (),
3351            0x2907fef2ac775657,
3352            fidl::encoding::DynamicFlags::empty(),
3353            _decode,
3354        )
3355    }
3356
3357    type StopResponseFut =
3358        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3359    fn r#stop(&self) -> Self::StopResponseFut {
3360        fn _decode(
3361            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3362        ) -> Result<(), fidl::Error> {
3363            let _response = fidl::client::decode_transaction_body::<
3364                fidl::encoding::EmptyPayload,
3365                fidl::encoding::DefaultFuchsiaResourceDialect,
3366                0x27eef9c535ac8eb4,
3367            >(_buf?)?;
3368            Ok(_response)
3369        }
3370        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3371            (),
3372            0x27eef9c535ac8eb4,
3373            fidl::encoding::DynamicFlags::empty(),
3374            _decode,
3375        )
3376    }
3377}
3378
3379pub struct GuestLifecycleEventStream {
3380    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3381}
3382
3383impl std::marker::Unpin for GuestLifecycleEventStream {}
3384
3385impl futures::stream::FusedStream for GuestLifecycleEventStream {
3386    fn is_terminated(&self) -> bool {
3387        self.event_receiver.is_terminated()
3388    }
3389}
3390
3391impl futures::Stream for GuestLifecycleEventStream {
3392    type Item = Result<GuestLifecycleEvent, fidl::Error>;
3393
3394    fn poll_next(
3395        mut self: std::pin::Pin<&mut Self>,
3396        cx: &mut std::task::Context<'_>,
3397    ) -> std::task::Poll<Option<Self::Item>> {
3398        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3399            &mut self.event_receiver,
3400            cx
3401        )?) {
3402            Some(buf) => std::task::Poll::Ready(Some(GuestLifecycleEvent::decode(buf))),
3403            None => std::task::Poll::Ready(None),
3404        }
3405    }
3406}
3407
3408#[derive(Debug)]
3409pub enum GuestLifecycleEvent {}
3410
3411impl GuestLifecycleEvent {
3412    /// Decodes a message buffer as a [`GuestLifecycleEvent`].
3413    fn decode(
3414        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3415    ) -> Result<GuestLifecycleEvent, fidl::Error> {
3416        let (bytes, _handles) = buf.split_mut();
3417        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3418        debug_assert_eq!(tx_header.tx_id, 0);
3419        match tx_header.ordinal {
3420            _ => Err(fidl::Error::UnknownOrdinal {
3421                ordinal: tx_header.ordinal,
3422                protocol_name:
3423                    <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3424            }),
3425        }
3426    }
3427}
3428
3429/// A Stream of incoming requests for fuchsia.virtualization/GuestLifecycle.
3430pub struct GuestLifecycleRequestStream {
3431    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3432    is_terminated: bool,
3433}
3434
3435impl std::marker::Unpin for GuestLifecycleRequestStream {}
3436
3437impl futures::stream::FusedStream for GuestLifecycleRequestStream {
3438    fn is_terminated(&self) -> bool {
3439        self.is_terminated
3440    }
3441}
3442
3443impl fidl::endpoints::RequestStream for GuestLifecycleRequestStream {
3444    type Protocol = GuestLifecycleMarker;
3445    type ControlHandle = GuestLifecycleControlHandle;
3446
3447    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3448        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3449    }
3450
3451    fn control_handle(&self) -> Self::ControlHandle {
3452        GuestLifecycleControlHandle { inner: self.inner.clone() }
3453    }
3454
3455    fn into_inner(
3456        self,
3457    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3458    {
3459        (self.inner, self.is_terminated)
3460    }
3461
3462    fn from_inner(
3463        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3464        is_terminated: bool,
3465    ) -> Self {
3466        Self { inner, is_terminated }
3467    }
3468}
3469
3470impl futures::Stream for GuestLifecycleRequestStream {
3471    type Item = Result<GuestLifecycleRequest, fidl::Error>;
3472
3473    fn poll_next(
3474        mut self: std::pin::Pin<&mut Self>,
3475        cx: &mut std::task::Context<'_>,
3476    ) -> std::task::Poll<Option<Self::Item>> {
3477        let this = &mut *self;
3478        if this.inner.check_shutdown(cx) {
3479            this.is_terminated = true;
3480            return std::task::Poll::Ready(None);
3481        }
3482        if this.is_terminated {
3483            panic!("polled GuestLifecycleRequestStream after completion");
3484        }
3485        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3486            |bytes, handles| {
3487                match this.inner.channel().read_etc(cx, bytes, handles) {
3488                    std::task::Poll::Ready(Ok(())) => {}
3489                    std::task::Poll::Pending => return std::task::Poll::Pending,
3490                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3491                        this.is_terminated = true;
3492                        return std::task::Poll::Ready(None);
3493                    }
3494                    std::task::Poll::Ready(Err(e)) => {
3495                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3496                            e.into(),
3497                        ))));
3498                    }
3499                }
3500
3501                // A message has been received from the channel
3502                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3503
3504                std::task::Poll::Ready(Some(match header.ordinal {
3505                    0x152719eed416ed41 => {
3506                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3507                        let mut req = fidl::new_empty!(
3508                            GuestLifecycleCreateRequest,
3509                            fidl::encoding::DefaultFuchsiaResourceDialect
3510                        );
3511                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleCreateRequest>(&header, _body_bytes, handles, &mut req)?;
3512                        let control_handle =
3513                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3514                        Ok(GuestLifecycleRequest::Create {
3515                            guest_config: req.guest_config,
3516
3517                            responder: GuestLifecycleCreateResponder {
3518                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3519                                tx_id: header.tx_id,
3520                            },
3521                        })
3522                    }
3523                    0x57dd3e245f9598ed => {
3524                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3525                        let mut req = fidl::new_empty!(
3526                            GuestLifecycleBindRequest,
3527                            fidl::encoding::DefaultFuchsiaResourceDialect
3528                        );
3529                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestLifecycleBindRequest>(&header, _body_bytes, handles, &mut req)?;
3530                        let control_handle =
3531                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3532                        Ok(GuestLifecycleRequest::Bind { guest: req.guest, control_handle })
3533                    }
3534                    0x2907fef2ac775657 => {
3535                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3536                        let mut req = fidl::new_empty!(
3537                            fidl::encoding::EmptyPayload,
3538                            fidl::encoding::DefaultFuchsiaResourceDialect
3539                        );
3540                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3541                        let control_handle =
3542                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3543                        Ok(GuestLifecycleRequest::Run {
3544                            responder: GuestLifecycleRunResponder {
3545                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3546                                tx_id: header.tx_id,
3547                            },
3548                        })
3549                    }
3550                    0x27eef9c535ac8eb4 => {
3551                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3552                        let mut req = fidl::new_empty!(
3553                            fidl::encoding::EmptyPayload,
3554                            fidl::encoding::DefaultFuchsiaResourceDialect
3555                        );
3556                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3557                        let control_handle =
3558                            GuestLifecycleControlHandle { inner: this.inner.clone() };
3559                        Ok(GuestLifecycleRequest::Stop {
3560                            responder: GuestLifecycleStopResponder {
3561                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3562                                tx_id: header.tx_id,
3563                            },
3564                        })
3565                    }
3566                    _ => Err(fidl::Error::UnknownOrdinal {
3567                        ordinal: header.ordinal,
3568                        protocol_name:
3569                            <GuestLifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3570                    }),
3571                }))
3572            },
3573        )
3574    }
3575}
3576
3577/// The guest control plane allowing for creating, starting, and stopping the guest.
3578#[derive(Debug)]
3579pub enum GuestLifecycleRequest {
3580    /// Create a VMM configured with the provided config. This instantiates all devices and loads
3581    /// the kernel without starting the VCPU or device dispatch loops.
3582    ///
3583    /// Possible errors:
3584    ///     - ALREADY_RUNNING: A VMM instance is already running, and must be stopped before being
3585    ///         recreated.
3586    ///
3587    /// All other errors are related to VMM initialization.
3588    Create { guest_config: GuestConfig, responder: GuestLifecycleCreateResponder },
3589    /// Binds to the Guest protocol for an initialized guest.
3590    ///
3591    /// This operation must be called between `Create` and `Stop`, otherwise the provided channel
3592    /// will be immediately closed.
3593    Bind {
3594        guest: fidl::endpoints::ServerEnd<GuestMarker>,
3595        control_handle: GuestLifecycleControlHandle,
3596    },
3597    /// Start the primary VCPU and any dispatch loop. This will not return until the VMM stops
3598    /// running. On a clean shutdown (either guest or client initiated) this will return success.
3599    ///
3600    /// Possible errors:
3601    ///     - ALREADY_RUNING: The VMM has already been started.
3602    ///     - NOT_CREATED: Run was called before the VMM was created.
3603    ///     - CONTROLLER_FORCED_HALT: Stop was called on a running VMM.
3604    ///     - VCPU_START_FAILURE: Failed to start the primary VCPU.
3605    ///     - VCPU_RUNTIME_FAILURE: A VCPU encountered a fatal error while running the guest.
3606    Run { responder: GuestLifecycleRunResponder },
3607    /// Stop a running VMM. Returns once the dispatch loops have stopped. After Stop returns,
3608    /// Create and then Run can be called again.
3609    Stop { responder: GuestLifecycleStopResponder },
3610}
3611
3612impl GuestLifecycleRequest {
3613    #[allow(irrefutable_let_patterns)]
3614    pub fn into_create(self) -> Option<(GuestConfig, GuestLifecycleCreateResponder)> {
3615        if let GuestLifecycleRequest::Create { guest_config, responder } = self {
3616            Some((guest_config, responder))
3617        } else {
3618            None
3619        }
3620    }
3621
3622    #[allow(irrefutable_let_patterns)]
3623    pub fn into_bind(
3624        self,
3625    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestLifecycleControlHandle)> {
3626        if let GuestLifecycleRequest::Bind { guest, control_handle } = self {
3627            Some((guest, control_handle))
3628        } else {
3629            None
3630        }
3631    }
3632
3633    #[allow(irrefutable_let_patterns)]
3634    pub fn into_run(self) -> Option<(GuestLifecycleRunResponder)> {
3635        if let GuestLifecycleRequest::Run { responder } = self { Some((responder)) } else { None }
3636    }
3637
3638    #[allow(irrefutable_let_patterns)]
3639    pub fn into_stop(self) -> Option<(GuestLifecycleStopResponder)> {
3640        if let GuestLifecycleRequest::Stop { responder } = self { Some((responder)) } else { None }
3641    }
3642
3643    /// Name of the method defined in FIDL
3644    pub fn method_name(&self) -> &'static str {
3645        match *self {
3646            GuestLifecycleRequest::Create { .. } => "create",
3647            GuestLifecycleRequest::Bind { .. } => "bind",
3648            GuestLifecycleRequest::Run { .. } => "run",
3649            GuestLifecycleRequest::Stop { .. } => "stop",
3650        }
3651    }
3652}
3653
3654#[derive(Debug, Clone)]
3655pub struct GuestLifecycleControlHandle {
3656    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3657}
3658
3659impl fidl::endpoints::ControlHandle for GuestLifecycleControlHandle {
3660    fn shutdown(&self) {
3661        self.inner.shutdown()
3662    }
3663
3664    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3665        self.inner.shutdown_with_epitaph(status)
3666    }
3667
3668    fn is_closed(&self) -> bool {
3669        self.inner.channel().is_closed()
3670    }
3671    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3672        self.inner.channel().on_closed()
3673    }
3674
3675    #[cfg(target_os = "fuchsia")]
3676    fn signal_peer(
3677        &self,
3678        clear_mask: zx::Signals,
3679        set_mask: zx::Signals,
3680    ) -> Result<(), zx_status::Status> {
3681        use fidl::Peered;
3682        self.inner.channel().signal_peer(clear_mask, set_mask)
3683    }
3684}
3685
3686impl GuestLifecycleControlHandle {}
3687
3688#[must_use = "FIDL methods require a response to be sent"]
3689#[derive(Debug)]
3690pub struct GuestLifecycleCreateResponder {
3691    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3692    tx_id: u32,
3693}
3694
3695/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3696/// if the responder is dropped without sending a response, so that the client
3697/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3698impl std::ops::Drop for GuestLifecycleCreateResponder {
3699    fn drop(&mut self) {
3700        self.control_handle.shutdown();
3701        // Safety: drops once, never accessed again
3702        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3703    }
3704}
3705
3706impl fidl::endpoints::Responder for GuestLifecycleCreateResponder {
3707    type ControlHandle = GuestLifecycleControlHandle;
3708
3709    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3710        &self.control_handle
3711    }
3712
3713    fn drop_without_shutdown(mut self) {
3714        // Safety: drops once, never accessed again due to mem::forget
3715        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3716        // Prevent Drop from running (which would shut down the channel)
3717        std::mem::forget(self);
3718    }
3719}
3720
3721impl GuestLifecycleCreateResponder {
3722    /// Sends a response to the FIDL transaction.
3723    ///
3724    /// Sets the channel to shutdown if an error occurs.
3725    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3726        let _result = self.send_raw(result);
3727        if _result.is_err() {
3728            self.control_handle.shutdown();
3729        }
3730        self.drop_without_shutdown();
3731        _result
3732    }
3733
3734    /// Similar to "send" but does not shutdown the channel if an error occurs.
3735    pub fn send_no_shutdown_on_err(
3736        self,
3737        mut result: Result<(), GuestError>,
3738    ) -> Result<(), fidl::Error> {
3739        let _result = self.send_raw(result);
3740        self.drop_without_shutdown();
3741        _result
3742    }
3743
3744    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3745        self.control_handle
3746            .inner
3747            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3748                result,
3749                self.tx_id,
3750                0x152719eed416ed41,
3751                fidl::encoding::DynamicFlags::empty(),
3752            )
3753    }
3754}
3755
3756#[must_use = "FIDL methods require a response to be sent"]
3757#[derive(Debug)]
3758pub struct GuestLifecycleRunResponder {
3759    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3760    tx_id: u32,
3761}
3762
3763/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3764/// if the responder is dropped without sending a response, so that the client
3765/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3766impl std::ops::Drop for GuestLifecycleRunResponder {
3767    fn drop(&mut self) {
3768        self.control_handle.shutdown();
3769        // Safety: drops once, never accessed again
3770        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3771    }
3772}
3773
3774impl fidl::endpoints::Responder for GuestLifecycleRunResponder {
3775    type ControlHandle = GuestLifecycleControlHandle;
3776
3777    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3778        &self.control_handle
3779    }
3780
3781    fn drop_without_shutdown(mut self) {
3782        // Safety: drops once, never accessed again due to mem::forget
3783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3784        // Prevent Drop from running (which would shut down the channel)
3785        std::mem::forget(self);
3786    }
3787}
3788
3789impl GuestLifecycleRunResponder {
3790    /// Sends a response to the FIDL transaction.
3791    ///
3792    /// Sets the channel to shutdown if an error occurs.
3793    pub fn send(self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3794        let _result = self.send_raw(result);
3795        if _result.is_err() {
3796            self.control_handle.shutdown();
3797        }
3798        self.drop_without_shutdown();
3799        _result
3800    }
3801
3802    /// Similar to "send" but does not shutdown the channel if an error occurs.
3803    pub fn send_no_shutdown_on_err(
3804        self,
3805        mut result: Result<(), GuestError>,
3806    ) -> Result<(), fidl::Error> {
3807        let _result = self.send_raw(result);
3808        self.drop_without_shutdown();
3809        _result
3810    }
3811
3812    fn send_raw(&self, mut result: Result<(), GuestError>) -> Result<(), fidl::Error> {
3813        self.control_handle
3814            .inner
3815            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestError>>(
3816                result,
3817                self.tx_id,
3818                0x2907fef2ac775657,
3819                fidl::encoding::DynamicFlags::empty(),
3820            )
3821    }
3822}
3823
3824#[must_use = "FIDL methods require a response to be sent"]
3825#[derive(Debug)]
3826pub struct GuestLifecycleStopResponder {
3827    control_handle: std::mem::ManuallyDrop<GuestLifecycleControlHandle>,
3828    tx_id: u32,
3829}
3830
3831/// Set the the channel to be shutdown (see [`GuestLifecycleControlHandle::shutdown`])
3832/// if the responder is dropped without sending a response, so that the client
3833/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3834impl std::ops::Drop for GuestLifecycleStopResponder {
3835    fn drop(&mut self) {
3836        self.control_handle.shutdown();
3837        // Safety: drops once, never accessed again
3838        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3839    }
3840}
3841
3842impl fidl::endpoints::Responder for GuestLifecycleStopResponder {
3843    type ControlHandle = GuestLifecycleControlHandle;
3844
3845    fn control_handle(&self) -> &GuestLifecycleControlHandle {
3846        &self.control_handle
3847    }
3848
3849    fn drop_without_shutdown(mut self) {
3850        // Safety: drops once, never accessed again due to mem::forget
3851        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3852        // Prevent Drop from running (which would shut down the channel)
3853        std::mem::forget(self);
3854    }
3855}
3856
3857impl GuestLifecycleStopResponder {
3858    /// Sends a response to the FIDL transaction.
3859    ///
3860    /// Sets the channel to shutdown if an error occurs.
3861    pub fn send(self) -> Result<(), fidl::Error> {
3862        let _result = self.send_raw();
3863        if _result.is_err() {
3864            self.control_handle.shutdown();
3865        }
3866        self.drop_without_shutdown();
3867        _result
3868    }
3869
3870    /// Similar to "send" but does not shutdown the channel if an error occurs.
3871    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3872        let _result = self.send_raw();
3873        self.drop_without_shutdown();
3874        _result
3875    }
3876
3877    fn send_raw(&self) -> Result<(), fidl::Error> {
3878        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3879            (),
3880            self.tx_id,
3881            0x27eef9c535ac8eb4,
3882            fidl::encoding::DynamicFlags::empty(),
3883        )
3884    }
3885}
3886
3887#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3888pub struct GuestManagerMarker;
3889
3890impl fidl::endpoints::ProtocolMarker for GuestManagerMarker {
3891    type Proxy = GuestManagerProxy;
3892    type RequestStream = GuestManagerRequestStream;
3893    #[cfg(target_os = "fuchsia")]
3894    type SynchronousProxy = GuestManagerSynchronousProxy;
3895
3896    const DEBUG_NAME: &'static str = "fuchsia.virtualization.GuestManager";
3897}
3898impl fidl::endpoints::DiscoverableProtocolMarker for GuestManagerMarker {}
3899pub type GuestManagerLaunchResult = Result<(), GuestManagerError>;
3900pub type GuestManagerConnectResult = Result<(), GuestManagerError>;
3901
3902pub trait GuestManagerProxyInterface: Send + Sync {
3903    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
3904        + Send;
3905    fn r#launch(
3906        &self,
3907        guest_config: GuestConfig,
3908        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3909    ) -> Self::LaunchResponseFut;
3910    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3911    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
3912    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
3913        + Send;
3914    fn r#connect(
3915        &self,
3916        controller: fidl::endpoints::ServerEnd<GuestMarker>,
3917    ) -> Self::ConnectResponseFut;
3918    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
3919    fn r#get_info(&self) -> Self::GetInfoResponseFut;
3920}
3921#[derive(Debug)]
3922#[cfg(target_os = "fuchsia")]
3923pub struct GuestManagerSynchronousProxy {
3924    client: fidl::client::sync::Client,
3925}
3926
3927#[cfg(target_os = "fuchsia")]
3928impl fidl::endpoints::SynchronousProxy for GuestManagerSynchronousProxy {
3929    type Proxy = GuestManagerProxy;
3930    type Protocol = GuestManagerMarker;
3931
3932    fn from_channel(inner: fidl::Channel) -> Self {
3933        Self::new(inner)
3934    }
3935
3936    fn into_channel(self) -> fidl::Channel {
3937        self.client.into_channel()
3938    }
3939
3940    fn as_channel(&self) -> &fidl::Channel {
3941        self.client.as_channel()
3942    }
3943}
3944
3945#[cfg(target_os = "fuchsia")]
3946impl GuestManagerSynchronousProxy {
3947    pub fn new(channel: fidl::Channel) -> Self {
3948        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3949        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3950    }
3951
3952    pub fn into_channel(self) -> fidl::Channel {
3953        self.client.into_channel()
3954    }
3955
3956    /// Waits until an event arrives and returns it. It is safe for other
3957    /// threads to make concurrent requests while waiting for an event.
3958    pub fn wait_for_event(
3959        &self,
3960        deadline: zx::MonotonicInstant,
3961    ) -> Result<GuestManagerEvent, fidl::Error> {
3962        GuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
3963    }
3964
3965    /// Launch a new guest instance.
3966    ///
3967    /// Possible errors:
3968    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
3969    ///         problems detected by the guest manager.
3970    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
3971    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
3972    ///         component logs for a more specific failure.
3973    pub fn r#launch(
3974        &self,
3975        mut guest_config: GuestConfig,
3976        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
3977        ___deadline: zx::MonotonicInstant,
3978    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
3979        let _response =
3980            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
3981                fidl::encoding::EmptyStruct,
3982                GuestManagerError,
3983            >>(
3984                (&mut guest_config, controller),
3985                0x394a2e29f750323e,
3986                fidl::encoding::DynamicFlags::empty(),
3987                ___deadline,
3988            )?;
3989        Ok(_response.map(|x| x))
3990    }
3991
3992    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
3993    /// be used to launch another guest.
3994    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3995        let _response =
3996            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
3997                (),
3998                0x3ad9a012982f872d,
3999                fidl::encoding::DynamicFlags::empty(),
4000                ___deadline,
4001            )?;
4002        Ok(_response)
4003    }
4004
4005    /// Connect to a currently running guest.
4006    ///
4007    /// Possible errors:
4008    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4009    ///         has launched before attempting to reconnect.
4010    pub fn r#connect(
4011        &self,
4012        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4013        ___deadline: zx::MonotonicInstant,
4014    ) -> Result<GuestManagerConnectResult, fidl::Error> {
4015        let _response =
4016            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
4017                fidl::encoding::EmptyStruct,
4018                GuestManagerError,
4019            >>(
4020                (controller,),
4021                0x4e489076e3bb15b4,
4022                fidl::encoding::DynamicFlags::empty(),
4023                ___deadline,
4024            )?;
4025        Ok(_response.map(|x| x))
4026    }
4027
4028    /// Query guest info
4029    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
4030        let _response =
4031            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
4032                (),
4033                0x76892614aea695dc,
4034                fidl::encoding::DynamicFlags::empty(),
4035                ___deadline,
4036            )?;
4037        Ok(_response.guest_info)
4038    }
4039}
4040
4041#[cfg(target_os = "fuchsia")]
4042impl From<GuestManagerSynchronousProxy> for zx::NullableHandle {
4043    fn from(value: GuestManagerSynchronousProxy) -> Self {
4044        value.into_channel().into()
4045    }
4046}
4047
4048#[cfg(target_os = "fuchsia")]
4049impl From<fidl::Channel> for GuestManagerSynchronousProxy {
4050    fn from(value: fidl::Channel) -> Self {
4051        Self::new(value)
4052    }
4053}
4054
4055#[cfg(target_os = "fuchsia")]
4056impl fidl::endpoints::FromClient for GuestManagerSynchronousProxy {
4057    type Protocol = GuestManagerMarker;
4058
4059    fn from_client(value: fidl::endpoints::ClientEnd<GuestManagerMarker>) -> Self {
4060        Self::new(value.into_channel())
4061    }
4062}
4063
4064#[derive(Debug, Clone)]
4065pub struct GuestManagerProxy {
4066    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4067}
4068
4069impl fidl::endpoints::Proxy for GuestManagerProxy {
4070    type Protocol = GuestManagerMarker;
4071
4072    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4073        Self::new(inner)
4074    }
4075
4076    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4077        self.client.into_channel().map_err(|client| Self { client })
4078    }
4079
4080    fn as_channel(&self) -> &::fidl::AsyncChannel {
4081        self.client.as_channel()
4082    }
4083}
4084
4085impl GuestManagerProxy {
4086    /// Create a new Proxy for fuchsia.virtualization/GuestManager.
4087    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4088        let protocol_name = <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4089        Self { client: fidl::client::Client::new(channel, protocol_name) }
4090    }
4091
4092    /// Get a Stream of events from the remote end of the protocol.
4093    ///
4094    /// # Panics
4095    ///
4096    /// Panics if the event stream was already taken.
4097    pub fn take_event_stream(&self) -> GuestManagerEventStream {
4098        GuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
4099    }
4100
4101    /// Launch a new guest instance.
4102    ///
4103    /// Possible errors:
4104    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4105    ///         problems detected by the guest manager.
4106    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4107    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4108    ///         component logs for a more specific failure.
4109    pub fn r#launch(
4110        &self,
4111        mut guest_config: GuestConfig,
4112        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4113    ) -> fidl::client::QueryResponseFut<
4114        GuestManagerLaunchResult,
4115        fidl::encoding::DefaultFuchsiaResourceDialect,
4116    > {
4117        GuestManagerProxyInterface::r#launch(self, guest_config, controller)
4118    }
4119
4120    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4121    /// be used to launch another guest.
4122    pub fn r#force_shutdown(
4123        &self,
4124    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4125        GuestManagerProxyInterface::r#force_shutdown(self)
4126    }
4127
4128    /// Connect to a currently running guest.
4129    ///
4130    /// Possible errors:
4131    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4132    ///         has launched before attempting to reconnect.
4133    pub fn r#connect(
4134        &self,
4135        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4136    ) -> fidl::client::QueryResponseFut<
4137        GuestManagerConnectResult,
4138        fidl::encoding::DefaultFuchsiaResourceDialect,
4139    > {
4140        GuestManagerProxyInterface::r#connect(self, controller)
4141    }
4142
4143    /// Query guest info
4144    pub fn r#get_info(
4145        &self,
4146    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
4147    {
4148        GuestManagerProxyInterface::r#get_info(self)
4149    }
4150}
4151
4152impl GuestManagerProxyInterface for GuestManagerProxy {
4153    type LaunchResponseFut = fidl::client::QueryResponseFut<
4154        GuestManagerLaunchResult,
4155        fidl::encoding::DefaultFuchsiaResourceDialect,
4156    >;
4157    fn r#launch(
4158        &self,
4159        mut guest_config: GuestConfig,
4160        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4161    ) -> Self::LaunchResponseFut {
4162        fn _decode(
4163            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4164        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
4165            let _response = fidl::client::decode_transaction_body::<
4166                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4167                fidl::encoding::DefaultFuchsiaResourceDialect,
4168                0x394a2e29f750323e,
4169            >(_buf?)?;
4170            Ok(_response.map(|x| x))
4171        }
4172        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
4173            (&mut guest_config, controller),
4174            0x394a2e29f750323e,
4175            fidl::encoding::DynamicFlags::empty(),
4176            _decode,
4177        )
4178    }
4179
4180    type ForceShutdownResponseFut =
4181        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4182    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
4183        fn _decode(
4184            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4185        ) -> Result<(), fidl::Error> {
4186            let _response = fidl::client::decode_transaction_body::<
4187                fidl::encoding::EmptyPayload,
4188                fidl::encoding::DefaultFuchsiaResourceDialect,
4189                0x3ad9a012982f872d,
4190            >(_buf?)?;
4191            Ok(_response)
4192        }
4193        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
4194            (),
4195            0x3ad9a012982f872d,
4196            fidl::encoding::DynamicFlags::empty(),
4197            _decode,
4198        )
4199    }
4200
4201    type ConnectResponseFut = fidl::client::QueryResponseFut<
4202        GuestManagerConnectResult,
4203        fidl::encoding::DefaultFuchsiaResourceDialect,
4204    >;
4205    fn r#connect(
4206        &self,
4207        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
4208    ) -> Self::ConnectResponseFut {
4209        fn _decode(
4210            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4211        ) -> Result<GuestManagerConnectResult, fidl::Error> {
4212            let _response = fidl::client::decode_transaction_body::<
4213                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
4214                fidl::encoding::DefaultFuchsiaResourceDialect,
4215                0x4e489076e3bb15b4,
4216            >(_buf?)?;
4217            Ok(_response.map(|x| x))
4218        }
4219        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
4220            (controller,),
4221            0x4e489076e3bb15b4,
4222            fidl::encoding::DynamicFlags::empty(),
4223            _decode,
4224        )
4225    }
4226
4227    type GetInfoResponseFut =
4228        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
4229    fn r#get_info(&self) -> Self::GetInfoResponseFut {
4230        fn _decode(
4231            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4232        ) -> Result<GuestInfo, fidl::Error> {
4233            let _response = fidl::client::decode_transaction_body::<
4234                GuestManagerGetInfoResponse,
4235                fidl::encoding::DefaultFuchsiaResourceDialect,
4236                0x76892614aea695dc,
4237            >(_buf?)?;
4238            Ok(_response.guest_info)
4239        }
4240        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
4241            (),
4242            0x76892614aea695dc,
4243            fidl::encoding::DynamicFlags::empty(),
4244            _decode,
4245        )
4246    }
4247}
4248
4249pub struct GuestManagerEventStream {
4250    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4251}
4252
4253impl std::marker::Unpin for GuestManagerEventStream {}
4254
4255impl futures::stream::FusedStream for GuestManagerEventStream {
4256    fn is_terminated(&self) -> bool {
4257        self.event_receiver.is_terminated()
4258    }
4259}
4260
4261impl futures::Stream for GuestManagerEventStream {
4262    type Item = Result<GuestManagerEvent, fidl::Error>;
4263
4264    fn poll_next(
4265        mut self: std::pin::Pin<&mut Self>,
4266        cx: &mut std::task::Context<'_>,
4267    ) -> std::task::Poll<Option<Self::Item>> {
4268        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4269            &mut self.event_receiver,
4270            cx
4271        )?) {
4272            Some(buf) => std::task::Poll::Ready(Some(GuestManagerEvent::decode(buf))),
4273            None => std::task::Poll::Ready(None),
4274        }
4275    }
4276}
4277
4278#[derive(Debug)]
4279pub enum GuestManagerEvent {}
4280
4281impl GuestManagerEvent {
4282    /// Decodes a message buffer as a [`GuestManagerEvent`].
4283    fn decode(
4284        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4285    ) -> Result<GuestManagerEvent, fidl::Error> {
4286        let (bytes, _handles) = buf.split_mut();
4287        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4288        debug_assert_eq!(tx_header.tx_id, 0);
4289        match tx_header.ordinal {
4290            _ => Err(fidl::Error::UnknownOrdinal {
4291                ordinal: tx_header.ordinal,
4292                protocol_name: <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4293            }),
4294        }
4295    }
4296}
4297
4298/// A Stream of incoming requests for fuchsia.virtualization/GuestManager.
4299pub struct GuestManagerRequestStream {
4300    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4301    is_terminated: bool,
4302}
4303
4304impl std::marker::Unpin for GuestManagerRequestStream {}
4305
4306impl futures::stream::FusedStream for GuestManagerRequestStream {
4307    fn is_terminated(&self) -> bool {
4308        self.is_terminated
4309    }
4310}
4311
4312impl fidl::endpoints::RequestStream for GuestManagerRequestStream {
4313    type Protocol = GuestManagerMarker;
4314    type ControlHandle = GuestManagerControlHandle;
4315
4316    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4317        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4318    }
4319
4320    fn control_handle(&self) -> Self::ControlHandle {
4321        GuestManagerControlHandle { inner: self.inner.clone() }
4322    }
4323
4324    fn into_inner(
4325        self,
4326    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4327    {
4328        (self.inner, self.is_terminated)
4329    }
4330
4331    fn from_inner(
4332        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4333        is_terminated: bool,
4334    ) -> Self {
4335        Self { inner, is_terminated }
4336    }
4337}
4338
4339impl futures::Stream for GuestManagerRequestStream {
4340    type Item = Result<GuestManagerRequest, fidl::Error>;
4341
4342    fn poll_next(
4343        mut self: std::pin::Pin<&mut Self>,
4344        cx: &mut std::task::Context<'_>,
4345    ) -> std::task::Poll<Option<Self::Item>> {
4346        let this = &mut *self;
4347        if this.inner.check_shutdown(cx) {
4348            this.is_terminated = true;
4349            return std::task::Poll::Ready(None);
4350        }
4351        if this.is_terminated {
4352            panic!("polled GuestManagerRequestStream after completion");
4353        }
4354        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4355            |bytes, handles| {
4356                match this.inner.channel().read_etc(cx, bytes, handles) {
4357                    std::task::Poll::Ready(Ok(())) => {}
4358                    std::task::Poll::Pending => return std::task::Poll::Pending,
4359                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4360                        this.is_terminated = true;
4361                        return std::task::Poll::Ready(None);
4362                    }
4363                    std::task::Poll::Ready(Err(e)) => {
4364                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4365                            e.into(),
4366                        ))));
4367                    }
4368                }
4369
4370                // A message has been received from the channel
4371                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4372
4373                std::task::Poll::Ready(Some(match header.ordinal {
4374                    0x394a2e29f750323e => {
4375                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4376                        let mut req = fidl::new_empty!(
4377                            GuestManagerLaunchRequest,
4378                            fidl::encoding::DefaultFuchsiaResourceDialect
4379                        );
4380                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
4381                        let control_handle =
4382                            GuestManagerControlHandle { inner: this.inner.clone() };
4383                        Ok(GuestManagerRequest::Launch {
4384                            guest_config: req.guest_config,
4385                            controller: req.controller,
4386
4387                            responder: GuestManagerLaunchResponder {
4388                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4389                                tx_id: header.tx_id,
4390                            },
4391                        })
4392                    }
4393                    0x3ad9a012982f872d => {
4394                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4395                        let mut req = fidl::new_empty!(
4396                            fidl::encoding::EmptyPayload,
4397                            fidl::encoding::DefaultFuchsiaResourceDialect
4398                        );
4399                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4400                        let control_handle =
4401                            GuestManagerControlHandle { inner: this.inner.clone() };
4402                        Ok(GuestManagerRequest::ForceShutdown {
4403                            responder: GuestManagerForceShutdownResponder {
4404                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4405                                tx_id: header.tx_id,
4406                            },
4407                        })
4408                    }
4409                    0x4e489076e3bb15b4 => {
4410                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4411                        let mut req = fidl::new_empty!(
4412                            GuestManagerConnectRequest,
4413                            fidl::encoding::DefaultFuchsiaResourceDialect
4414                        );
4415                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
4416                        let control_handle =
4417                            GuestManagerControlHandle { inner: this.inner.clone() };
4418                        Ok(GuestManagerRequest::Connect {
4419                            controller: req.controller,
4420
4421                            responder: GuestManagerConnectResponder {
4422                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4423                                tx_id: header.tx_id,
4424                            },
4425                        })
4426                    }
4427                    0x76892614aea695dc => {
4428                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4429                        let mut req = fidl::new_empty!(
4430                            fidl::encoding::EmptyPayload,
4431                            fidl::encoding::DefaultFuchsiaResourceDialect
4432                        );
4433                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4434                        let control_handle =
4435                            GuestManagerControlHandle { inner: this.inner.clone() };
4436                        Ok(GuestManagerRequest::GetInfo {
4437                            responder: GuestManagerGetInfoResponder {
4438                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4439                                tx_id: header.tx_id,
4440                            },
4441                        })
4442                    }
4443                    _ => Err(fidl::Error::UnknownOrdinal {
4444                        ordinal: header.ordinal,
4445                        protocol_name:
4446                            <GuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4447                    }),
4448                }))
4449            },
4450        )
4451    }
4452}
4453
4454#[derive(Debug)]
4455pub enum GuestManagerRequest {
4456    /// Launch a new guest instance.
4457    ///
4458    /// Possible errors:
4459    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
4460    ///         problems detected by the guest manager.
4461    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
4462    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
4463    ///         component logs for a more specific failure.
4464    Launch {
4465        guest_config: GuestConfig,
4466        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4467        responder: GuestManagerLaunchResponder,
4468    },
4469    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
4470    /// be used to launch another guest.
4471    ForceShutdown { responder: GuestManagerForceShutdownResponder },
4472    /// Connect to a currently running guest.
4473    ///
4474    /// Possible errors:
4475    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
4476    ///         has launched before attempting to reconnect.
4477    Connect {
4478        controller: fidl::endpoints::ServerEnd<GuestMarker>,
4479        responder: GuestManagerConnectResponder,
4480    },
4481    /// Query guest info
4482    GetInfo { responder: GuestManagerGetInfoResponder },
4483}
4484
4485impl GuestManagerRequest {
4486    #[allow(irrefutable_let_patterns)]
4487    pub fn into_launch(
4488        self,
4489    ) -> Option<(GuestConfig, fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerLaunchResponder)>
4490    {
4491        if let GuestManagerRequest::Launch { guest_config, controller, responder } = self {
4492            Some((guest_config, controller, responder))
4493        } else {
4494            None
4495        }
4496    }
4497
4498    #[allow(irrefutable_let_patterns)]
4499    pub fn into_force_shutdown(self) -> Option<(GuestManagerForceShutdownResponder)> {
4500        if let GuestManagerRequest::ForceShutdown { responder } = self {
4501            Some((responder))
4502        } else {
4503            None
4504        }
4505    }
4506
4507    #[allow(irrefutable_let_patterns)]
4508    pub fn into_connect(
4509        self,
4510    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, GuestManagerConnectResponder)> {
4511        if let GuestManagerRequest::Connect { controller, responder } = self {
4512            Some((controller, responder))
4513        } else {
4514            None
4515        }
4516    }
4517
4518    #[allow(irrefutable_let_patterns)]
4519    pub fn into_get_info(self) -> Option<(GuestManagerGetInfoResponder)> {
4520        if let GuestManagerRequest::GetInfo { responder } = self { Some((responder)) } else { None }
4521    }
4522
4523    /// Name of the method defined in FIDL
4524    pub fn method_name(&self) -> &'static str {
4525        match *self {
4526            GuestManagerRequest::Launch { .. } => "launch",
4527            GuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
4528            GuestManagerRequest::Connect { .. } => "connect",
4529            GuestManagerRequest::GetInfo { .. } => "get_info",
4530        }
4531    }
4532}
4533
4534#[derive(Debug, Clone)]
4535pub struct GuestManagerControlHandle {
4536    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4537}
4538
4539impl fidl::endpoints::ControlHandle for GuestManagerControlHandle {
4540    fn shutdown(&self) {
4541        self.inner.shutdown()
4542    }
4543
4544    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4545        self.inner.shutdown_with_epitaph(status)
4546    }
4547
4548    fn is_closed(&self) -> bool {
4549        self.inner.channel().is_closed()
4550    }
4551    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4552        self.inner.channel().on_closed()
4553    }
4554
4555    #[cfg(target_os = "fuchsia")]
4556    fn signal_peer(
4557        &self,
4558        clear_mask: zx::Signals,
4559        set_mask: zx::Signals,
4560    ) -> Result<(), zx_status::Status> {
4561        use fidl::Peered;
4562        self.inner.channel().signal_peer(clear_mask, set_mask)
4563    }
4564}
4565
4566impl GuestManagerControlHandle {}
4567
4568#[must_use = "FIDL methods require a response to be sent"]
4569#[derive(Debug)]
4570pub struct GuestManagerLaunchResponder {
4571    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4572    tx_id: u32,
4573}
4574
4575/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4576/// if the responder is dropped without sending a response, so that the client
4577/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4578impl std::ops::Drop for GuestManagerLaunchResponder {
4579    fn drop(&mut self) {
4580        self.control_handle.shutdown();
4581        // Safety: drops once, never accessed again
4582        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4583    }
4584}
4585
4586impl fidl::endpoints::Responder for GuestManagerLaunchResponder {
4587    type ControlHandle = GuestManagerControlHandle;
4588
4589    fn control_handle(&self) -> &GuestManagerControlHandle {
4590        &self.control_handle
4591    }
4592
4593    fn drop_without_shutdown(mut self) {
4594        // Safety: drops once, never accessed again due to mem::forget
4595        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4596        // Prevent Drop from running (which would shut down the channel)
4597        std::mem::forget(self);
4598    }
4599}
4600
4601impl GuestManagerLaunchResponder {
4602    /// Sends a response to the FIDL transaction.
4603    ///
4604    /// Sets the channel to shutdown if an error occurs.
4605    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4606        let _result = self.send_raw(result);
4607        if _result.is_err() {
4608            self.control_handle.shutdown();
4609        }
4610        self.drop_without_shutdown();
4611        _result
4612    }
4613
4614    /// Similar to "send" but does not shutdown the channel if an error occurs.
4615    pub fn send_no_shutdown_on_err(
4616        self,
4617        mut result: Result<(), GuestManagerError>,
4618    ) -> Result<(), fidl::Error> {
4619        let _result = self.send_raw(result);
4620        self.drop_without_shutdown();
4621        _result
4622    }
4623
4624    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4625        self.control_handle.inner.send::<fidl::encoding::ResultType<
4626            fidl::encoding::EmptyStruct,
4627            GuestManagerError,
4628        >>(
4629            result,
4630            self.tx_id,
4631            0x394a2e29f750323e,
4632            fidl::encoding::DynamicFlags::empty(),
4633        )
4634    }
4635}
4636
4637#[must_use = "FIDL methods require a response to be sent"]
4638#[derive(Debug)]
4639pub struct GuestManagerForceShutdownResponder {
4640    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4641    tx_id: u32,
4642}
4643
4644/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4645/// if the responder is dropped without sending a response, so that the client
4646/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4647impl std::ops::Drop for GuestManagerForceShutdownResponder {
4648    fn drop(&mut self) {
4649        self.control_handle.shutdown();
4650        // Safety: drops once, never accessed again
4651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4652    }
4653}
4654
4655impl fidl::endpoints::Responder for GuestManagerForceShutdownResponder {
4656    type ControlHandle = GuestManagerControlHandle;
4657
4658    fn control_handle(&self) -> &GuestManagerControlHandle {
4659        &self.control_handle
4660    }
4661
4662    fn drop_without_shutdown(mut self) {
4663        // Safety: drops once, never accessed again due to mem::forget
4664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4665        // Prevent Drop from running (which would shut down the channel)
4666        std::mem::forget(self);
4667    }
4668}
4669
4670impl GuestManagerForceShutdownResponder {
4671    /// Sends a response to the FIDL transaction.
4672    ///
4673    /// Sets the channel to shutdown if an error occurs.
4674    pub fn send(self) -> Result<(), fidl::Error> {
4675        let _result = self.send_raw();
4676        if _result.is_err() {
4677            self.control_handle.shutdown();
4678        }
4679        self.drop_without_shutdown();
4680        _result
4681    }
4682
4683    /// Similar to "send" but does not shutdown the channel if an error occurs.
4684    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4685        let _result = self.send_raw();
4686        self.drop_without_shutdown();
4687        _result
4688    }
4689
4690    fn send_raw(&self) -> Result<(), fidl::Error> {
4691        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4692            (),
4693            self.tx_id,
4694            0x3ad9a012982f872d,
4695            fidl::encoding::DynamicFlags::empty(),
4696        )
4697    }
4698}
4699
4700#[must_use = "FIDL methods require a response to be sent"]
4701#[derive(Debug)]
4702pub struct GuestManagerConnectResponder {
4703    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4704    tx_id: u32,
4705}
4706
4707/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4708/// if the responder is dropped without sending a response, so that the client
4709/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4710impl std::ops::Drop for GuestManagerConnectResponder {
4711    fn drop(&mut self) {
4712        self.control_handle.shutdown();
4713        // Safety: drops once, never accessed again
4714        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4715    }
4716}
4717
4718impl fidl::endpoints::Responder for GuestManagerConnectResponder {
4719    type ControlHandle = GuestManagerControlHandle;
4720
4721    fn control_handle(&self) -> &GuestManagerControlHandle {
4722        &self.control_handle
4723    }
4724
4725    fn drop_without_shutdown(mut self) {
4726        // Safety: drops once, never accessed again due to mem::forget
4727        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4728        // Prevent Drop from running (which would shut down the channel)
4729        std::mem::forget(self);
4730    }
4731}
4732
4733impl GuestManagerConnectResponder {
4734    /// Sends a response to the FIDL transaction.
4735    ///
4736    /// Sets the channel to shutdown if an error occurs.
4737    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4738        let _result = self.send_raw(result);
4739        if _result.is_err() {
4740            self.control_handle.shutdown();
4741        }
4742        self.drop_without_shutdown();
4743        _result
4744    }
4745
4746    /// Similar to "send" but does not shutdown the channel if an error occurs.
4747    pub fn send_no_shutdown_on_err(
4748        self,
4749        mut result: Result<(), GuestManagerError>,
4750    ) -> Result<(), fidl::Error> {
4751        let _result = self.send_raw(result);
4752        self.drop_without_shutdown();
4753        _result
4754    }
4755
4756    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
4757        self.control_handle.inner.send::<fidl::encoding::ResultType<
4758            fidl::encoding::EmptyStruct,
4759            GuestManagerError,
4760        >>(
4761            result,
4762            self.tx_id,
4763            0x4e489076e3bb15b4,
4764            fidl::encoding::DynamicFlags::empty(),
4765        )
4766    }
4767}
4768
4769#[must_use = "FIDL methods require a response to be sent"]
4770#[derive(Debug)]
4771pub struct GuestManagerGetInfoResponder {
4772    control_handle: std::mem::ManuallyDrop<GuestManagerControlHandle>,
4773    tx_id: u32,
4774}
4775
4776/// Set the the channel to be shutdown (see [`GuestManagerControlHandle::shutdown`])
4777/// if the responder is dropped without sending a response, so that the client
4778/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4779impl std::ops::Drop for GuestManagerGetInfoResponder {
4780    fn drop(&mut self) {
4781        self.control_handle.shutdown();
4782        // Safety: drops once, never accessed again
4783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4784    }
4785}
4786
4787impl fidl::endpoints::Responder for GuestManagerGetInfoResponder {
4788    type ControlHandle = GuestManagerControlHandle;
4789
4790    fn control_handle(&self) -> &GuestManagerControlHandle {
4791        &self.control_handle
4792    }
4793
4794    fn drop_without_shutdown(mut self) {
4795        // Safety: drops once, never accessed again due to mem::forget
4796        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4797        // Prevent Drop from running (which would shut down the channel)
4798        std::mem::forget(self);
4799    }
4800}
4801
4802impl GuestManagerGetInfoResponder {
4803    /// Sends a response to the FIDL transaction.
4804    ///
4805    /// Sets the channel to shutdown if an error occurs.
4806    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4807        let _result = self.send_raw(guest_info);
4808        if _result.is_err() {
4809            self.control_handle.shutdown();
4810        }
4811        self.drop_without_shutdown();
4812        _result
4813    }
4814
4815    /// Similar to "send" but does not shutdown the channel if an error occurs.
4816    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4817        let _result = self.send_raw(guest_info);
4818        self.drop_without_shutdown();
4819        _result
4820    }
4821
4822    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
4823        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
4824            (guest_info,),
4825            self.tx_id,
4826            0x76892614aea695dc,
4827            fidl::encoding::DynamicFlags::empty(),
4828        )
4829    }
4830}
4831
4832#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4833pub struct HostVsockAcceptorMarker;
4834
4835impl fidl::endpoints::ProtocolMarker for HostVsockAcceptorMarker {
4836    type Proxy = HostVsockAcceptorProxy;
4837    type RequestStream = HostVsockAcceptorRequestStream;
4838    #[cfg(target_os = "fuchsia")]
4839    type SynchronousProxy = HostVsockAcceptorSynchronousProxy;
4840
4841    const DEBUG_NAME: &'static str = "(anonymous) HostVsockAcceptor";
4842}
4843pub type HostVsockAcceptorAcceptResult = Result<fidl::Socket, i32>;
4844
4845pub trait HostVsockAcceptorProxyInterface: Send + Sync {
4846    type AcceptResponseFut: std::future::Future<Output = Result<HostVsockAcceptorAcceptResult, fidl::Error>>
4847        + Send;
4848    fn r#accept(&self, src_cid: u32, src_port: u32, port: u32) -> Self::AcceptResponseFut;
4849}
4850#[derive(Debug)]
4851#[cfg(target_os = "fuchsia")]
4852pub struct HostVsockAcceptorSynchronousProxy {
4853    client: fidl::client::sync::Client,
4854}
4855
4856#[cfg(target_os = "fuchsia")]
4857impl fidl::endpoints::SynchronousProxy for HostVsockAcceptorSynchronousProxy {
4858    type Proxy = HostVsockAcceptorProxy;
4859    type Protocol = HostVsockAcceptorMarker;
4860
4861    fn from_channel(inner: fidl::Channel) -> Self {
4862        Self::new(inner)
4863    }
4864
4865    fn into_channel(self) -> fidl::Channel {
4866        self.client.into_channel()
4867    }
4868
4869    fn as_channel(&self) -> &fidl::Channel {
4870        self.client.as_channel()
4871    }
4872}
4873
4874#[cfg(target_os = "fuchsia")]
4875impl HostVsockAcceptorSynchronousProxy {
4876    pub fn new(channel: fidl::Channel) -> Self {
4877        let protocol_name =
4878            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4879        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4880    }
4881
4882    pub fn into_channel(self) -> fidl::Channel {
4883        self.client.into_channel()
4884    }
4885
4886    /// Waits until an event arrives and returns it. It is safe for other
4887    /// threads to make concurrent requests while waiting for an event.
4888    pub fn wait_for_event(
4889        &self,
4890        deadline: zx::MonotonicInstant,
4891    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
4892        HostVsockAcceptorEvent::decode(self.client.wait_for_event(deadline)?)
4893    }
4894
4895    pub fn r#accept(
4896        &self,
4897        mut src_cid: u32,
4898        mut src_port: u32,
4899        mut port: u32,
4900        ___deadline: zx::MonotonicInstant,
4901    ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
4902        let _response = self.client.send_query::<
4903            HostVsockAcceptorAcceptRequest,
4904            fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
4905        >(
4906            (src_cid, src_port, port,),
4907            0x6996ed935beaa2d7,
4908            fidl::encoding::DynamicFlags::empty(),
4909            ___deadline,
4910        )?;
4911        Ok(_response.map(|x| x.socket))
4912    }
4913}
4914
4915#[cfg(target_os = "fuchsia")]
4916impl From<HostVsockAcceptorSynchronousProxy> for zx::NullableHandle {
4917    fn from(value: HostVsockAcceptorSynchronousProxy) -> Self {
4918        value.into_channel().into()
4919    }
4920}
4921
4922#[cfg(target_os = "fuchsia")]
4923impl From<fidl::Channel> for HostVsockAcceptorSynchronousProxy {
4924    fn from(value: fidl::Channel) -> Self {
4925        Self::new(value)
4926    }
4927}
4928
4929#[cfg(target_os = "fuchsia")]
4930impl fidl::endpoints::FromClient for HostVsockAcceptorSynchronousProxy {
4931    type Protocol = HostVsockAcceptorMarker;
4932
4933    fn from_client(value: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>) -> Self {
4934        Self::new(value.into_channel())
4935    }
4936}
4937
4938#[derive(Debug, Clone)]
4939pub struct HostVsockAcceptorProxy {
4940    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4941}
4942
4943impl fidl::endpoints::Proxy for HostVsockAcceptorProxy {
4944    type Protocol = HostVsockAcceptorMarker;
4945
4946    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4947        Self::new(inner)
4948    }
4949
4950    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4951        self.client.into_channel().map_err(|client| Self { client })
4952    }
4953
4954    fn as_channel(&self) -> &::fidl::AsyncChannel {
4955        self.client.as_channel()
4956    }
4957}
4958
4959impl HostVsockAcceptorProxy {
4960    /// Create a new Proxy for fuchsia.virtualization/HostVsockAcceptor.
4961    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4962        let protocol_name =
4963            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4964        Self { client: fidl::client::Client::new(channel, protocol_name) }
4965    }
4966
4967    /// Get a Stream of events from the remote end of the protocol.
4968    ///
4969    /// # Panics
4970    ///
4971    /// Panics if the event stream was already taken.
4972    pub fn take_event_stream(&self) -> HostVsockAcceptorEventStream {
4973        HostVsockAcceptorEventStream { event_receiver: self.client.take_event_receiver() }
4974    }
4975
4976    pub fn r#accept(
4977        &self,
4978        mut src_cid: u32,
4979        mut src_port: u32,
4980        mut port: u32,
4981    ) -> fidl::client::QueryResponseFut<
4982        HostVsockAcceptorAcceptResult,
4983        fidl::encoding::DefaultFuchsiaResourceDialect,
4984    > {
4985        HostVsockAcceptorProxyInterface::r#accept(self, src_cid, src_port, port)
4986    }
4987}
4988
4989impl HostVsockAcceptorProxyInterface for HostVsockAcceptorProxy {
4990    type AcceptResponseFut = fidl::client::QueryResponseFut<
4991        HostVsockAcceptorAcceptResult,
4992        fidl::encoding::DefaultFuchsiaResourceDialect,
4993    >;
4994    fn r#accept(
4995        &self,
4996        mut src_cid: u32,
4997        mut src_port: u32,
4998        mut port: u32,
4999    ) -> Self::AcceptResponseFut {
5000        fn _decode(
5001            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5002        ) -> Result<HostVsockAcceptorAcceptResult, fidl::Error> {
5003            let _response = fidl::client::decode_transaction_body::<
5004                fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>,
5005                fidl::encoding::DefaultFuchsiaResourceDialect,
5006                0x6996ed935beaa2d7,
5007            >(_buf?)?;
5008            Ok(_response.map(|x| x.socket))
5009        }
5010        self.client
5011            .send_query_and_decode::<HostVsockAcceptorAcceptRequest, HostVsockAcceptorAcceptResult>(
5012                (src_cid, src_port, port),
5013                0x6996ed935beaa2d7,
5014                fidl::encoding::DynamicFlags::empty(),
5015                _decode,
5016            )
5017    }
5018}
5019
5020pub struct HostVsockAcceptorEventStream {
5021    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5022}
5023
5024impl std::marker::Unpin for HostVsockAcceptorEventStream {}
5025
5026impl futures::stream::FusedStream for HostVsockAcceptorEventStream {
5027    fn is_terminated(&self) -> bool {
5028        self.event_receiver.is_terminated()
5029    }
5030}
5031
5032impl futures::Stream for HostVsockAcceptorEventStream {
5033    type Item = Result<HostVsockAcceptorEvent, fidl::Error>;
5034
5035    fn poll_next(
5036        mut self: std::pin::Pin<&mut Self>,
5037        cx: &mut std::task::Context<'_>,
5038    ) -> std::task::Poll<Option<Self::Item>> {
5039        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5040            &mut self.event_receiver,
5041            cx
5042        )?) {
5043            Some(buf) => std::task::Poll::Ready(Some(HostVsockAcceptorEvent::decode(buf))),
5044            None => std::task::Poll::Ready(None),
5045        }
5046    }
5047}
5048
5049#[derive(Debug)]
5050pub enum HostVsockAcceptorEvent {}
5051
5052impl HostVsockAcceptorEvent {
5053    /// Decodes a message buffer as a [`HostVsockAcceptorEvent`].
5054    fn decode(
5055        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5056    ) -> Result<HostVsockAcceptorEvent, fidl::Error> {
5057        let (bytes, _handles) = buf.split_mut();
5058        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5059        debug_assert_eq!(tx_header.tx_id, 0);
5060        match tx_header.ordinal {
5061            _ => Err(fidl::Error::UnknownOrdinal {
5062                ordinal: tx_header.ordinal,
5063                protocol_name:
5064                    <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5065            }),
5066        }
5067    }
5068}
5069
5070/// A Stream of incoming requests for fuchsia.virtualization/HostVsockAcceptor.
5071pub struct HostVsockAcceptorRequestStream {
5072    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5073    is_terminated: bool,
5074}
5075
5076impl std::marker::Unpin for HostVsockAcceptorRequestStream {}
5077
5078impl futures::stream::FusedStream for HostVsockAcceptorRequestStream {
5079    fn is_terminated(&self) -> bool {
5080        self.is_terminated
5081    }
5082}
5083
5084impl fidl::endpoints::RequestStream for HostVsockAcceptorRequestStream {
5085    type Protocol = HostVsockAcceptorMarker;
5086    type ControlHandle = HostVsockAcceptorControlHandle;
5087
5088    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5089        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5090    }
5091
5092    fn control_handle(&self) -> Self::ControlHandle {
5093        HostVsockAcceptorControlHandle { inner: self.inner.clone() }
5094    }
5095
5096    fn into_inner(
5097        self,
5098    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5099    {
5100        (self.inner, self.is_terminated)
5101    }
5102
5103    fn from_inner(
5104        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5105        is_terminated: bool,
5106    ) -> Self {
5107        Self { inner, is_terminated }
5108    }
5109}
5110
5111impl futures::Stream for HostVsockAcceptorRequestStream {
5112    type Item = Result<HostVsockAcceptorRequest, fidl::Error>;
5113
5114    fn poll_next(
5115        mut self: std::pin::Pin<&mut Self>,
5116        cx: &mut std::task::Context<'_>,
5117    ) -> std::task::Poll<Option<Self::Item>> {
5118        let this = &mut *self;
5119        if this.inner.check_shutdown(cx) {
5120            this.is_terminated = true;
5121            return std::task::Poll::Ready(None);
5122        }
5123        if this.is_terminated {
5124            panic!("polled HostVsockAcceptorRequestStream after completion");
5125        }
5126        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5127            |bytes, handles| {
5128                match this.inner.channel().read_etc(cx, bytes, handles) {
5129                    std::task::Poll::Ready(Ok(())) => {}
5130                    std::task::Poll::Pending => return std::task::Poll::Pending,
5131                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5132                        this.is_terminated = true;
5133                        return std::task::Poll::Ready(None);
5134                    }
5135                    std::task::Poll::Ready(Err(e)) => {
5136                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5137                            e.into(),
5138                        ))));
5139                    }
5140                }
5141
5142                // A message has been received from the channel
5143                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5144
5145                std::task::Poll::Ready(Some(match header.ordinal {
5146                    0x6996ed935beaa2d7 => {
5147                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5148                        let mut req = fidl::new_empty!(
5149                            HostVsockAcceptorAcceptRequest,
5150                            fidl::encoding::DefaultFuchsiaResourceDialect
5151                        );
5152                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockAcceptorAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
5153                        let control_handle =
5154                            HostVsockAcceptorControlHandle { inner: this.inner.clone() };
5155                        Ok(HostVsockAcceptorRequest::Accept {
5156                            src_cid: req.src_cid,
5157                            src_port: req.src_port,
5158                            port: req.port,
5159
5160                            responder: HostVsockAcceptorAcceptResponder {
5161                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5162                                tx_id: header.tx_id,
5163                            },
5164                        })
5165                    }
5166                    _ => Err(fidl::Error::UnknownOrdinal {
5167                        ordinal: header.ordinal,
5168                        protocol_name:
5169                            <HostVsockAcceptorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5170                    }),
5171                }))
5172            },
5173        )
5174    }
5175}
5176
5177/// Exposed by a host capable of listening via vsocks. A variant of a
5178/// `GuestVsockAcceptor` that is responsible for creating the `socket` with which
5179/// to communicate.
5180#[derive(Debug)]
5181pub enum HostVsockAcceptorRequest {
5182    Accept { src_cid: u32, src_port: u32, port: u32, responder: HostVsockAcceptorAcceptResponder },
5183}
5184
5185impl HostVsockAcceptorRequest {
5186    #[allow(irrefutable_let_patterns)]
5187    pub fn into_accept(self) -> Option<(u32, u32, u32, HostVsockAcceptorAcceptResponder)> {
5188        if let HostVsockAcceptorRequest::Accept { src_cid, src_port, port, responder } = self {
5189            Some((src_cid, src_port, port, responder))
5190        } else {
5191            None
5192        }
5193    }
5194
5195    /// Name of the method defined in FIDL
5196    pub fn method_name(&self) -> &'static str {
5197        match *self {
5198            HostVsockAcceptorRequest::Accept { .. } => "accept",
5199        }
5200    }
5201}
5202
5203#[derive(Debug, Clone)]
5204pub struct HostVsockAcceptorControlHandle {
5205    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5206}
5207
5208impl fidl::endpoints::ControlHandle for HostVsockAcceptorControlHandle {
5209    fn shutdown(&self) {
5210        self.inner.shutdown()
5211    }
5212
5213    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5214        self.inner.shutdown_with_epitaph(status)
5215    }
5216
5217    fn is_closed(&self) -> bool {
5218        self.inner.channel().is_closed()
5219    }
5220    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5221        self.inner.channel().on_closed()
5222    }
5223
5224    #[cfg(target_os = "fuchsia")]
5225    fn signal_peer(
5226        &self,
5227        clear_mask: zx::Signals,
5228        set_mask: zx::Signals,
5229    ) -> Result<(), zx_status::Status> {
5230        use fidl::Peered;
5231        self.inner.channel().signal_peer(clear_mask, set_mask)
5232    }
5233}
5234
5235impl HostVsockAcceptorControlHandle {}
5236
5237#[must_use = "FIDL methods require a response to be sent"]
5238#[derive(Debug)]
5239pub struct HostVsockAcceptorAcceptResponder {
5240    control_handle: std::mem::ManuallyDrop<HostVsockAcceptorControlHandle>,
5241    tx_id: u32,
5242}
5243
5244/// Set the the channel to be shutdown (see [`HostVsockAcceptorControlHandle::shutdown`])
5245/// if the responder is dropped without sending a response, so that the client
5246/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5247impl std::ops::Drop for HostVsockAcceptorAcceptResponder {
5248    fn drop(&mut self) {
5249        self.control_handle.shutdown();
5250        // Safety: drops once, never accessed again
5251        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5252    }
5253}
5254
5255impl fidl::endpoints::Responder for HostVsockAcceptorAcceptResponder {
5256    type ControlHandle = HostVsockAcceptorControlHandle;
5257
5258    fn control_handle(&self) -> &HostVsockAcceptorControlHandle {
5259        &self.control_handle
5260    }
5261
5262    fn drop_without_shutdown(mut self) {
5263        // Safety: drops once, never accessed again due to mem::forget
5264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5265        // Prevent Drop from running (which would shut down the channel)
5266        std::mem::forget(self);
5267    }
5268}
5269
5270impl HostVsockAcceptorAcceptResponder {
5271    /// Sends a response to the FIDL transaction.
5272    ///
5273    /// Sets the channel to shutdown if an error occurs.
5274    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5275        let _result = self.send_raw(result);
5276        if _result.is_err() {
5277            self.control_handle.shutdown();
5278        }
5279        self.drop_without_shutdown();
5280        _result
5281    }
5282
5283    /// Similar to "send" but does not shutdown the channel if an error occurs.
5284    pub fn send_no_shutdown_on_err(
5285        self,
5286        mut result: Result<fidl::Socket, i32>,
5287    ) -> Result<(), fidl::Error> {
5288        let _result = self.send_raw(result);
5289        self.drop_without_shutdown();
5290        _result
5291    }
5292
5293    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5294        self.control_handle
5295            .inner
5296            .send::<fidl::encoding::ResultType<HostVsockAcceptorAcceptResponse, i32>>(
5297                result.map(|socket| (socket,)),
5298                self.tx_id,
5299                0x6996ed935beaa2d7,
5300                fidl::encoding::DynamicFlags::empty(),
5301            )
5302    }
5303}
5304
5305#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5306pub struct HostVsockEndpointMarker;
5307
5308impl fidl::endpoints::ProtocolMarker for HostVsockEndpointMarker {
5309    type Proxy = HostVsockEndpointProxy;
5310    type RequestStream = HostVsockEndpointRequestStream;
5311    #[cfg(target_os = "fuchsia")]
5312    type SynchronousProxy = HostVsockEndpointSynchronousProxy;
5313
5314    const DEBUG_NAME: &'static str = "fuchsia.virtualization.HostVsockEndpoint";
5315}
5316impl fidl::endpoints::DiscoverableProtocolMarker for HostVsockEndpointMarker {}
5317pub type HostVsockEndpointListenResult = Result<(), i32>;
5318pub type HostVsockEndpointConnectResult = Result<fidl::Socket, i32>;
5319
5320pub trait HostVsockEndpointProxyInterface: Send + Sync {
5321    type ListenResponseFut: std::future::Future<Output = Result<HostVsockEndpointListenResult, fidl::Error>>
5322        + Send;
5323    fn r#listen(
5324        &self,
5325        port: u32,
5326        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5327    ) -> Self::ListenResponseFut;
5328    type ConnectResponseFut: std::future::Future<Output = Result<HostVsockEndpointConnectResult, fidl::Error>>
5329        + Send;
5330    fn r#connect(&self, guest_port: u32) -> Self::ConnectResponseFut;
5331}
5332#[derive(Debug)]
5333#[cfg(target_os = "fuchsia")]
5334pub struct HostVsockEndpointSynchronousProxy {
5335    client: fidl::client::sync::Client,
5336}
5337
5338#[cfg(target_os = "fuchsia")]
5339impl fidl::endpoints::SynchronousProxy for HostVsockEndpointSynchronousProxy {
5340    type Proxy = HostVsockEndpointProxy;
5341    type Protocol = HostVsockEndpointMarker;
5342
5343    fn from_channel(inner: fidl::Channel) -> Self {
5344        Self::new(inner)
5345    }
5346
5347    fn into_channel(self) -> fidl::Channel {
5348        self.client.into_channel()
5349    }
5350
5351    fn as_channel(&self) -> &fidl::Channel {
5352        self.client.as_channel()
5353    }
5354}
5355
5356#[cfg(target_os = "fuchsia")]
5357impl HostVsockEndpointSynchronousProxy {
5358    pub fn new(channel: fidl::Channel) -> Self {
5359        let protocol_name =
5360            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5361        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5362    }
5363
5364    pub fn into_channel(self) -> fidl::Channel {
5365        self.client.into_channel()
5366    }
5367
5368    /// Waits until an event arrives and returns it. It is safe for other
5369    /// threads to make concurrent requests while waiting for an event.
5370    pub fn wait_for_event(
5371        &self,
5372        deadline: zx::MonotonicInstant,
5373    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5374        HostVsockEndpointEvent::decode(self.client.wait_for_event(deadline)?)
5375    }
5376
5377    /// Instructs the device to listen for guest initiated connections to a given port by
5378    /// using `acceptor` when the guest creates a connection.
5379    ///
5380    /// Possible errors:
5381    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5382    pub fn r#listen(
5383        &self,
5384        mut port: u32,
5385        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5386        ___deadline: zx::MonotonicInstant,
5387    ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5388        let _response = self
5389            .client
5390            .send_query::<Listener, fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5391                (port, acceptor),
5392                0xfd88f3b4767f2c7,
5393                fidl::encoding::DynamicFlags::empty(),
5394                ___deadline,
5395            )?;
5396        Ok(_response.map(|x| x))
5397    }
5398
5399    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5400    /// ephemeral host port.
5401    ///
5402    /// Possible errors:
5403    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5404    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5405    ///
5406    /// Other errors are related to socket creation, see
5407    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5408    pub fn r#connect(
5409        &self,
5410        mut guest_port: u32,
5411        ___deadline: zx::MonotonicInstant,
5412    ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5413        let _response = self.client.send_query::<
5414            HostVsockEndpointConnectRequest,
5415            fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5416        >(
5417            (guest_port,),
5418            0x4d12e10e946b43e4,
5419            fidl::encoding::DynamicFlags::empty(),
5420            ___deadline,
5421        )?;
5422        Ok(_response.map(|x| x.socket))
5423    }
5424}
5425
5426#[cfg(target_os = "fuchsia")]
5427impl From<HostVsockEndpointSynchronousProxy> for zx::NullableHandle {
5428    fn from(value: HostVsockEndpointSynchronousProxy) -> Self {
5429        value.into_channel().into()
5430    }
5431}
5432
5433#[cfg(target_os = "fuchsia")]
5434impl From<fidl::Channel> for HostVsockEndpointSynchronousProxy {
5435    fn from(value: fidl::Channel) -> Self {
5436        Self::new(value)
5437    }
5438}
5439
5440#[cfg(target_os = "fuchsia")]
5441impl fidl::endpoints::FromClient for HostVsockEndpointSynchronousProxy {
5442    type Protocol = HostVsockEndpointMarker;
5443
5444    fn from_client(value: fidl::endpoints::ClientEnd<HostVsockEndpointMarker>) -> Self {
5445        Self::new(value.into_channel())
5446    }
5447}
5448
5449#[derive(Debug, Clone)]
5450pub struct HostVsockEndpointProxy {
5451    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5452}
5453
5454impl fidl::endpoints::Proxy for HostVsockEndpointProxy {
5455    type Protocol = HostVsockEndpointMarker;
5456
5457    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5458        Self::new(inner)
5459    }
5460
5461    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5462        self.client.into_channel().map_err(|client| Self { client })
5463    }
5464
5465    fn as_channel(&self) -> &::fidl::AsyncChannel {
5466        self.client.as_channel()
5467    }
5468}
5469
5470impl HostVsockEndpointProxy {
5471    /// Create a new Proxy for fuchsia.virtualization/HostVsockEndpoint.
5472    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5473        let protocol_name =
5474            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5475        Self { client: fidl::client::Client::new(channel, protocol_name) }
5476    }
5477
5478    /// Get a Stream of events from the remote end of the protocol.
5479    ///
5480    /// # Panics
5481    ///
5482    /// Panics if the event stream was already taken.
5483    pub fn take_event_stream(&self) -> HostVsockEndpointEventStream {
5484        HostVsockEndpointEventStream { event_receiver: self.client.take_event_receiver() }
5485    }
5486
5487    /// Instructs the device to listen for guest initiated connections to a given port by
5488    /// using `acceptor` when the guest creates a connection.
5489    ///
5490    /// Possible errors:
5491    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5492    pub fn r#listen(
5493        &self,
5494        mut port: u32,
5495        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5496    ) -> fidl::client::QueryResponseFut<
5497        HostVsockEndpointListenResult,
5498        fidl::encoding::DefaultFuchsiaResourceDialect,
5499    > {
5500        HostVsockEndpointProxyInterface::r#listen(self, port, acceptor)
5501    }
5502
5503    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5504    /// ephemeral host port.
5505    ///
5506    /// Possible errors:
5507    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5508    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5509    ///
5510    /// Other errors are related to socket creation, see
5511    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5512    pub fn r#connect(
5513        &self,
5514        mut guest_port: u32,
5515    ) -> fidl::client::QueryResponseFut<
5516        HostVsockEndpointConnectResult,
5517        fidl::encoding::DefaultFuchsiaResourceDialect,
5518    > {
5519        HostVsockEndpointProxyInterface::r#connect(self, guest_port)
5520    }
5521}
5522
5523impl HostVsockEndpointProxyInterface for HostVsockEndpointProxy {
5524    type ListenResponseFut = fidl::client::QueryResponseFut<
5525        HostVsockEndpointListenResult,
5526        fidl::encoding::DefaultFuchsiaResourceDialect,
5527    >;
5528    fn r#listen(
5529        &self,
5530        mut port: u32,
5531        mut acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5532    ) -> Self::ListenResponseFut {
5533        fn _decode(
5534            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5535        ) -> Result<HostVsockEndpointListenResult, fidl::Error> {
5536            let _response = fidl::client::decode_transaction_body::<
5537                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5538                fidl::encoding::DefaultFuchsiaResourceDialect,
5539                0xfd88f3b4767f2c7,
5540            >(_buf?)?;
5541            Ok(_response.map(|x| x))
5542        }
5543        self.client.send_query_and_decode::<Listener, HostVsockEndpointListenResult>(
5544            (port, acceptor),
5545            0xfd88f3b4767f2c7,
5546            fidl::encoding::DynamicFlags::empty(),
5547            _decode,
5548        )
5549    }
5550
5551    type ConnectResponseFut = fidl::client::QueryResponseFut<
5552        HostVsockEndpointConnectResult,
5553        fidl::encoding::DefaultFuchsiaResourceDialect,
5554    >;
5555    fn r#connect(&self, mut guest_port: u32) -> Self::ConnectResponseFut {
5556        fn _decode(
5557            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5558        ) -> Result<HostVsockEndpointConnectResult, fidl::Error> {
5559            let _response = fidl::client::decode_transaction_body::<
5560                fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>,
5561                fidl::encoding::DefaultFuchsiaResourceDialect,
5562                0x4d12e10e946b43e4,
5563            >(_buf?)?;
5564            Ok(_response.map(|x| x.socket))
5565        }
5566        self.client.send_query_and_decode::<
5567            HostVsockEndpointConnectRequest,
5568            HostVsockEndpointConnectResult,
5569        >(
5570            (guest_port,),
5571            0x4d12e10e946b43e4,
5572            fidl::encoding::DynamicFlags::empty(),
5573            _decode,
5574        )
5575    }
5576}
5577
5578pub struct HostVsockEndpointEventStream {
5579    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5580}
5581
5582impl std::marker::Unpin for HostVsockEndpointEventStream {}
5583
5584impl futures::stream::FusedStream for HostVsockEndpointEventStream {
5585    fn is_terminated(&self) -> bool {
5586        self.event_receiver.is_terminated()
5587    }
5588}
5589
5590impl futures::Stream for HostVsockEndpointEventStream {
5591    type Item = Result<HostVsockEndpointEvent, fidl::Error>;
5592
5593    fn poll_next(
5594        mut self: std::pin::Pin<&mut Self>,
5595        cx: &mut std::task::Context<'_>,
5596    ) -> std::task::Poll<Option<Self::Item>> {
5597        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5598            &mut self.event_receiver,
5599            cx
5600        )?) {
5601            Some(buf) => std::task::Poll::Ready(Some(HostVsockEndpointEvent::decode(buf))),
5602            None => std::task::Poll::Ready(None),
5603        }
5604    }
5605}
5606
5607#[derive(Debug)]
5608pub enum HostVsockEndpointEvent {}
5609
5610impl HostVsockEndpointEvent {
5611    /// Decodes a message buffer as a [`HostVsockEndpointEvent`].
5612    fn decode(
5613        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5614    ) -> Result<HostVsockEndpointEvent, fidl::Error> {
5615        let (bytes, _handles) = buf.split_mut();
5616        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5617        debug_assert_eq!(tx_header.tx_id, 0);
5618        match tx_header.ordinal {
5619            _ => Err(fidl::Error::UnknownOrdinal {
5620                ordinal: tx_header.ordinal,
5621                protocol_name:
5622                    <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5623            }),
5624        }
5625    }
5626}
5627
5628/// A Stream of incoming requests for fuchsia.virtualization/HostVsockEndpoint.
5629pub struct HostVsockEndpointRequestStream {
5630    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5631    is_terminated: bool,
5632}
5633
5634impl std::marker::Unpin for HostVsockEndpointRequestStream {}
5635
5636impl futures::stream::FusedStream for HostVsockEndpointRequestStream {
5637    fn is_terminated(&self) -> bool {
5638        self.is_terminated
5639    }
5640}
5641
5642impl fidl::endpoints::RequestStream for HostVsockEndpointRequestStream {
5643    type Protocol = HostVsockEndpointMarker;
5644    type ControlHandle = HostVsockEndpointControlHandle;
5645
5646    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5647        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5648    }
5649
5650    fn control_handle(&self) -> Self::ControlHandle {
5651        HostVsockEndpointControlHandle { inner: self.inner.clone() }
5652    }
5653
5654    fn into_inner(
5655        self,
5656    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5657    {
5658        (self.inner, self.is_terminated)
5659    }
5660
5661    fn from_inner(
5662        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5663        is_terminated: bool,
5664    ) -> Self {
5665        Self { inner, is_terminated }
5666    }
5667}
5668
5669impl futures::Stream for HostVsockEndpointRequestStream {
5670    type Item = Result<HostVsockEndpointRequest, fidl::Error>;
5671
5672    fn poll_next(
5673        mut self: std::pin::Pin<&mut Self>,
5674        cx: &mut std::task::Context<'_>,
5675    ) -> std::task::Poll<Option<Self::Item>> {
5676        let this = &mut *self;
5677        if this.inner.check_shutdown(cx) {
5678            this.is_terminated = true;
5679            return std::task::Poll::Ready(None);
5680        }
5681        if this.is_terminated {
5682            panic!("polled HostVsockEndpointRequestStream after completion");
5683        }
5684        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5685            |bytes, handles| {
5686                match this.inner.channel().read_etc(cx, bytes, handles) {
5687                    std::task::Poll::Ready(Ok(())) => {}
5688                    std::task::Poll::Pending => return std::task::Poll::Pending,
5689                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5690                        this.is_terminated = true;
5691                        return std::task::Poll::Ready(None);
5692                    }
5693                    std::task::Poll::Ready(Err(e)) => {
5694                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5695                            e.into(),
5696                        ))));
5697                    }
5698                }
5699
5700                // A message has been received from the channel
5701                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5702
5703                std::task::Poll::Ready(Some(match header.ordinal {
5704                    0xfd88f3b4767f2c7 => {
5705                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5706                        let mut req = fidl::new_empty!(
5707                            Listener,
5708                            fidl::encoding::DefaultFuchsiaResourceDialect
5709                        );
5710                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Listener>(&header, _body_bytes, handles, &mut req)?;
5711                        let control_handle =
5712                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5713                        Ok(HostVsockEndpointRequest::Listen {
5714                            port: req.port,
5715                            acceptor: req.acceptor,
5716
5717                            responder: HostVsockEndpointListenResponder {
5718                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5719                                tx_id: header.tx_id,
5720                            },
5721                        })
5722                    }
5723                    0x4d12e10e946b43e4 => {
5724                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5725                        let mut req = fidl::new_empty!(
5726                            HostVsockEndpointConnectRequest,
5727                            fidl::encoding::DefaultFuchsiaResourceDialect
5728                        );
5729                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostVsockEndpointConnectRequest>(&header, _body_bytes, handles, &mut req)?;
5730                        let control_handle =
5731                            HostVsockEndpointControlHandle { inner: this.inner.clone() };
5732                        Ok(HostVsockEndpointRequest::Connect {
5733                            guest_port: req.guest_port,
5734
5735                            responder: HostVsockEndpointConnectResponder {
5736                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5737                                tx_id: header.tx_id,
5738                            },
5739                        })
5740                    }
5741                    _ => Err(fidl::Error::UnknownOrdinal {
5742                        ordinal: header.ordinal,
5743                        protocol_name:
5744                            <HostVsockEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5745                    }),
5746                }))
5747            },
5748        )
5749    }
5750}
5751
5752/// Exposed by a host to provide the ability for listeners to be multiplexed by
5753/// port and to manage dynamic port allocation for outbound connections.
5754#[derive(Debug)]
5755pub enum HostVsockEndpointRequest {
5756    /// Instructs the device to listen for guest initiated connections to a given port by
5757    /// using `acceptor` when the guest creates a connection.
5758    ///
5759    /// Possible errors:
5760    ///     - ZX_ERR_ALREADY_BOUND: A client is already listening on this port.
5761    Listen {
5762        port: u32,
5763        acceptor: fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5764        responder: HostVsockEndpointListenResponder,
5765    },
5766    /// Attempts to create a vsock connection to a guest on 'guest_port'. Uses a dynamically chosen
5767    /// ephemeral host port.
5768    ///
5769    /// Possible errors:
5770    ///     - ZX_ERR_NO_RESOURCES: The device couldn't allocate an unused host port.
5771    ///     - ZX_ERR_CONNECTION_REFUSED: The guest refused this connection.
5772    ///
5773    /// Other errors are related to socket creation, see
5774    /// [zx_socket_create](https://fuchsia.dev/fuchsia-src/reference/syscalls/socket_create.md)
5775    Connect { guest_port: u32, responder: HostVsockEndpointConnectResponder },
5776}
5777
5778impl HostVsockEndpointRequest {
5779    #[allow(irrefutable_let_patterns)]
5780    pub fn into_listen(
5781        self,
5782    ) -> Option<(
5783        u32,
5784        fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>,
5785        HostVsockEndpointListenResponder,
5786    )> {
5787        if let HostVsockEndpointRequest::Listen { port, acceptor, responder } = self {
5788            Some((port, acceptor, responder))
5789        } else {
5790            None
5791        }
5792    }
5793
5794    #[allow(irrefutable_let_patterns)]
5795    pub fn into_connect(self) -> Option<(u32, HostVsockEndpointConnectResponder)> {
5796        if let HostVsockEndpointRequest::Connect { guest_port, responder } = self {
5797            Some((guest_port, responder))
5798        } else {
5799            None
5800        }
5801    }
5802
5803    /// Name of the method defined in FIDL
5804    pub fn method_name(&self) -> &'static str {
5805        match *self {
5806            HostVsockEndpointRequest::Listen { .. } => "listen",
5807            HostVsockEndpointRequest::Connect { .. } => "connect",
5808        }
5809    }
5810}
5811
5812#[derive(Debug, Clone)]
5813pub struct HostVsockEndpointControlHandle {
5814    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5815}
5816
5817impl fidl::endpoints::ControlHandle for HostVsockEndpointControlHandle {
5818    fn shutdown(&self) {
5819        self.inner.shutdown()
5820    }
5821
5822    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5823        self.inner.shutdown_with_epitaph(status)
5824    }
5825
5826    fn is_closed(&self) -> bool {
5827        self.inner.channel().is_closed()
5828    }
5829    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5830        self.inner.channel().on_closed()
5831    }
5832
5833    #[cfg(target_os = "fuchsia")]
5834    fn signal_peer(
5835        &self,
5836        clear_mask: zx::Signals,
5837        set_mask: zx::Signals,
5838    ) -> Result<(), zx_status::Status> {
5839        use fidl::Peered;
5840        self.inner.channel().signal_peer(clear_mask, set_mask)
5841    }
5842}
5843
5844impl HostVsockEndpointControlHandle {}
5845
5846#[must_use = "FIDL methods require a response to be sent"]
5847#[derive(Debug)]
5848pub struct HostVsockEndpointListenResponder {
5849    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5850    tx_id: u32,
5851}
5852
5853/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5854/// if the responder is dropped without sending a response, so that the client
5855/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5856impl std::ops::Drop for HostVsockEndpointListenResponder {
5857    fn drop(&mut self) {
5858        self.control_handle.shutdown();
5859        // Safety: drops once, never accessed again
5860        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5861    }
5862}
5863
5864impl fidl::endpoints::Responder for HostVsockEndpointListenResponder {
5865    type ControlHandle = HostVsockEndpointControlHandle;
5866
5867    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5868        &self.control_handle
5869    }
5870
5871    fn drop_without_shutdown(mut self) {
5872        // Safety: drops once, never accessed again due to mem::forget
5873        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5874        // Prevent Drop from running (which would shut down the channel)
5875        std::mem::forget(self);
5876    }
5877}
5878
5879impl HostVsockEndpointListenResponder {
5880    /// Sends a response to the FIDL transaction.
5881    ///
5882    /// Sets the channel to shutdown if an error occurs.
5883    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5884        let _result = self.send_raw(result);
5885        if _result.is_err() {
5886            self.control_handle.shutdown();
5887        }
5888        self.drop_without_shutdown();
5889        _result
5890    }
5891
5892    /// Similar to "send" but does not shutdown the channel if an error occurs.
5893    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5894        let _result = self.send_raw(result);
5895        self.drop_without_shutdown();
5896        _result
5897    }
5898
5899    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5900        self.control_handle
5901            .inner
5902            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5903                result,
5904                self.tx_id,
5905                0xfd88f3b4767f2c7,
5906                fidl::encoding::DynamicFlags::empty(),
5907            )
5908    }
5909}
5910
5911#[must_use = "FIDL methods require a response to be sent"]
5912#[derive(Debug)]
5913pub struct HostVsockEndpointConnectResponder {
5914    control_handle: std::mem::ManuallyDrop<HostVsockEndpointControlHandle>,
5915    tx_id: u32,
5916}
5917
5918/// Set the the channel to be shutdown (see [`HostVsockEndpointControlHandle::shutdown`])
5919/// if the responder is dropped without sending a response, so that the client
5920/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5921impl std::ops::Drop for HostVsockEndpointConnectResponder {
5922    fn drop(&mut self) {
5923        self.control_handle.shutdown();
5924        // Safety: drops once, never accessed again
5925        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5926    }
5927}
5928
5929impl fidl::endpoints::Responder for HostVsockEndpointConnectResponder {
5930    type ControlHandle = HostVsockEndpointControlHandle;
5931
5932    fn control_handle(&self) -> &HostVsockEndpointControlHandle {
5933        &self.control_handle
5934    }
5935
5936    fn drop_without_shutdown(mut self) {
5937        // Safety: drops once, never accessed again due to mem::forget
5938        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5939        // Prevent Drop from running (which would shut down the channel)
5940        std::mem::forget(self);
5941    }
5942}
5943
5944impl HostVsockEndpointConnectResponder {
5945    /// Sends a response to the FIDL transaction.
5946    ///
5947    /// Sets the channel to shutdown if an error occurs.
5948    pub fn send(self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5949        let _result = self.send_raw(result);
5950        if _result.is_err() {
5951            self.control_handle.shutdown();
5952        }
5953        self.drop_without_shutdown();
5954        _result
5955    }
5956
5957    /// Similar to "send" but does not shutdown the channel if an error occurs.
5958    pub fn send_no_shutdown_on_err(
5959        self,
5960        mut result: Result<fidl::Socket, i32>,
5961    ) -> Result<(), fidl::Error> {
5962        let _result = self.send_raw(result);
5963        self.drop_without_shutdown();
5964        _result
5965    }
5966
5967    fn send_raw(&self, mut result: Result<fidl::Socket, i32>) -> Result<(), fidl::Error> {
5968        self.control_handle
5969            .inner
5970            .send::<fidl::encoding::ResultType<HostVsockEndpointConnectResponse, i32>>(
5971                result.map(|socket| (socket,)),
5972                self.tx_id,
5973                0x4d12e10e946b43e4,
5974                fidl::encoding::DynamicFlags::empty(),
5975            )
5976    }
5977}
5978
5979#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5980pub struct LinuxManagerMarker;
5981
5982impl fidl::endpoints::ProtocolMarker for LinuxManagerMarker {
5983    type Proxy = LinuxManagerProxy;
5984    type RequestStream = LinuxManagerRequestStream;
5985    #[cfg(target_os = "fuchsia")]
5986    type SynchronousProxy = LinuxManagerSynchronousProxy;
5987
5988    const DEBUG_NAME: &'static str = "fuchsia.virtualization.LinuxManager";
5989}
5990impl fidl::endpoints::DiscoverableProtocolMarker for LinuxManagerMarker {}
5991pub type LinuxManagerStartAndGetLinuxGuestInfoResult = Result<LinuxGuestInfo, i32>;
5992pub type LinuxManagerWipeDataResult = Result<(), i32>;
5993
5994pub trait LinuxManagerProxyInterface: Send + Sync {
5995    type StartAndGetLinuxGuestInfoResponseFut: std::future::Future<
5996            Output = Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error>,
5997        > + Send;
5998    fn r#start_and_get_linux_guest_info(
5999        &self,
6000        label: &str,
6001    ) -> Self::StartAndGetLinuxGuestInfoResponseFut;
6002    type WipeDataResponseFut: std::future::Future<Output = Result<LinuxManagerWipeDataResult, fidl::Error>>
6003        + Send;
6004    fn r#wipe_data(&self) -> Self::WipeDataResponseFut;
6005    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error>;
6006}
6007#[derive(Debug)]
6008#[cfg(target_os = "fuchsia")]
6009pub struct LinuxManagerSynchronousProxy {
6010    client: fidl::client::sync::Client,
6011}
6012
6013#[cfg(target_os = "fuchsia")]
6014impl fidl::endpoints::SynchronousProxy for LinuxManagerSynchronousProxy {
6015    type Proxy = LinuxManagerProxy;
6016    type Protocol = LinuxManagerMarker;
6017
6018    fn from_channel(inner: fidl::Channel) -> Self {
6019        Self::new(inner)
6020    }
6021
6022    fn into_channel(self) -> fidl::Channel {
6023        self.client.into_channel()
6024    }
6025
6026    fn as_channel(&self) -> &fidl::Channel {
6027        self.client.as_channel()
6028    }
6029}
6030
6031#[cfg(target_os = "fuchsia")]
6032impl LinuxManagerSynchronousProxy {
6033    pub fn new(channel: fidl::Channel) -> Self {
6034        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6035        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6036    }
6037
6038    pub fn into_channel(self) -> fidl::Channel {
6039        self.client.into_channel()
6040    }
6041
6042    /// Waits until an event arrives and returns it. It is safe for other
6043    /// threads to make concurrent requests while waiting for an event.
6044    pub fn wait_for_event(
6045        &self,
6046        deadline: zx::MonotonicInstant,
6047    ) -> Result<LinuxManagerEvent, fidl::Error> {
6048        LinuxManagerEvent::decode(self.client.wait_for_event(deadline)?)
6049    }
6050
6051    /// Get Linux guest environment info.
6052    ///
6053    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6054    pub fn r#start_and_get_linux_guest_info(
6055        &self,
6056        mut label: &str,
6057        ___deadline: zx::MonotonicInstant,
6058    ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6059        let _response = self.client.send_query::<
6060            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6061            fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6062        >(
6063            (label,),
6064            0x11809ced100a2bea,
6065            fidl::encoding::DynamicFlags::empty(),
6066            ___deadline,
6067        )?;
6068        Ok(_response.map(|x| x.info))
6069    }
6070
6071    /// Clears the stateful data. This includes any installed containers and any user data
6072    /// they may contain.
6073    ///
6074    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6075    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6076    /// operation.
6077    pub fn r#wipe_data(
6078        &self,
6079        ___deadline: zx::MonotonicInstant,
6080    ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6081        let _response = self.client.send_query::<
6082            fidl::encoding::EmptyPayload,
6083            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6084        >(
6085            (),
6086            0x732c69394548a76a,
6087            fidl::encoding::DynamicFlags::empty(),
6088            ___deadline,
6089        )?;
6090        Ok(_response.map(|x| x))
6091    }
6092
6093    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6094    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6095    /// the epitaph) before attempting to launch another guest.
6096    ///
6097    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6098    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6099    /// a component crash).
6100    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6101        self.client.send::<fidl::encoding::EmptyPayload>(
6102            (),
6103            0x5dab12b50bc9909d,
6104            fidl::encoding::DynamicFlags::empty(),
6105        )
6106    }
6107}
6108
6109#[cfg(target_os = "fuchsia")]
6110impl From<LinuxManagerSynchronousProxy> for zx::NullableHandle {
6111    fn from(value: LinuxManagerSynchronousProxy) -> Self {
6112        value.into_channel().into()
6113    }
6114}
6115
6116#[cfg(target_os = "fuchsia")]
6117impl From<fidl::Channel> for LinuxManagerSynchronousProxy {
6118    fn from(value: fidl::Channel) -> Self {
6119        Self::new(value)
6120    }
6121}
6122
6123#[cfg(target_os = "fuchsia")]
6124impl fidl::endpoints::FromClient for LinuxManagerSynchronousProxy {
6125    type Protocol = LinuxManagerMarker;
6126
6127    fn from_client(value: fidl::endpoints::ClientEnd<LinuxManagerMarker>) -> Self {
6128        Self::new(value.into_channel())
6129    }
6130}
6131
6132#[derive(Debug, Clone)]
6133pub struct LinuxManagerProxy {
6134    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6135}
6136
6137impl fidl::endpoints::Proxy for LinuxManagerProxy {
6138    type Protocol = LinuxManagerMarker;
6139
6140    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6141        Self::new(inner)
6142    }
6143
6144    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6145        self.client.into_channel().map_err(|client| Self { client })
6146    }
6147
6148    fn as_channel(&self) -> &::fidl::AsyncChannel {
6149        self.client.as_channel()
6150    }
6151}
6152
6153impl LinuxManagerProxy {
6154    /// Create a new Proxy for fuchsia.virtualization/LinuxManager.
6155    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6156        let protocol_name = <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6157        Self { client: fidl::client::Client::new(channel, protocol_name) }
6158    }
6159
6160    /// Get a Stream of events from the remote end of the protocol.
6161    ///
6162    /// # Panics
6163    ///
6164    /// Panics if the event stream was already taken.
6165    pub fn take_event_stream(&self) -> LinuxManagerEventStream {
6166        LinuxManagerEventStream { event_receiver: self.client.take_event_receiver() }
6167    }
6168
6169    /// Get Linux guest environment info.
6170    ///
6171    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6172    pub fn r#start_and_get_linux_guest_info(
6173        &self,
6174        mut label: &str,
6175    ) -> fidl::client::QueryResponseFut<
6176        LinuxManagerStartAndGetLinuxGuestInfoResult,
6177        fidl::encoding::DefaultFuchsiaResourceDialect,
6178    > {
6179        LinuxManagerProxyInterface::r#start_and_get_linux_guest_info(self, label)
6180    }
6181
6182    /// Clears the stateful data. This includes any installed containers and any user data
6183    /// they may contain.
6184    ///
6185    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6186    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6187    /// operation.
6188    pub fn r#wipe_data(
6189        &self,
6190    ) -> fidl::client::QueryResponseFut<
6191        LinuxManagerWipeDataResult,
6192        fidl::encoding::DefaultFuchsiaResourceDialect,
6193    > {
6194        LinuxManagerProxyInterface::r#wipe_data(self)
6195    }
6196
6197    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6198    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6199    /// the epitaph) before attempting to launch another guest.
6200    ///
6201    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6202    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6203    /// a component crash).
6204    pub fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6205        LinuxManagerProxyInterface::r#graceful_shutdown(self)
6206    }
6207}
6208
6209impl LinuxManagerProxyInterface for LinuxManagerProxy {
6210    type StartAndGetLinuxGuestInfoResponseFut = fidl::client::QueryResponseFut<
6211        LinuxManagerStartAndGetLinuxGuestInfoResult,
6212        fidl::encoding::DefaultFuchsiaResourceDialect,
6213    >;
6214    fn r#start_and_get_linux_guest_info(
6215        &self,
6216        mut label: &str,
6217    ) -> Self::StartAndGetLinuxGuestInfoResponseFut {
6218        fn _decode(
6219            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6220        ) -> Result<LinuxManagerStartAndGetLinuxGuestInfoResult, fidl::Error> {
6221            let _response = fidl::client::decode_transaction_body::<
6222                fidl::encoding::ResultType<LinuxManagerStartAndGetLinuxGuestInfoResponse, i32>,
6223                fidl::encoding::DefaultFuchsiaResourceDialect,
6224                0x11809ced100a2bea,
6225            >(_buf?)?;
6226            Ok(_response.map(|x| x.info))
6227        }
6228        self.client.send_query_and_decode::<
6229            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6230            LinuxManagerStartAndGetLinuxGuestInfoResult,
6231        >(
6232            (label,),
6233            0x11809ced100a2bea,
6234            fidl::encoding::DynamicFlags::empty(),
6235            _decode,
6236        )
6237    }
6238
6239    type WipeDataResponseFut = fidl::client::QueryResponseFut<
6240        LinuxManagerWipeDataResult,
6241        fidl::encoding::DefaultFuchsiaResourceDialect,
6242    >;
6243    fn r#wipe_data(&self) -> Self::WipeDataResponseFut {
6244        fn _decode(
6245            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6246        ) -> Result<LinuxManagerWipeDataResult, fidl::Error> {
6247            let _response = fidl::client::decode_transaction_body::<
6248                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6249                fidl::encoding::DefaultFuchsiaResourceDialect,
6250                0x732c69394548a76a,
6251            >(_buf?)?;
6252            Ok(_response.map(|x| x))
6253        }
6254        self.client
6255            .send_query_and_decode::<fidl::encoding::EmptyPayload, LinuxManagerWipeDataResult>(
6256                (),
6257                0x732c69394548a76a,
6258                fidl::encoding::DynamicFlags::empty(),
6259                _decode,
6260            )
6261    }
6262
6263    fn r#graceful_shutdown(&self) -> Result<(), fidl::Error> {
6264        self.client.send::<fidl::encoding::EmptyPayload>(
6265            (),
6266            0x5dab12b50bc9909d,
6267            fidl::encoding::DynamicFlags::empty(),
6268        )
6269    }
6270}
6271
6272pub struct LinuxManagerEventStream {
6273    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6274}
6275
6276impl std::marker::Unpin for LinuxManagerEventStream {}
6277
6278impl futures::stream::FusedStream for LinuxManagerEventStream {
6279    fn is_terminated(&self) -> bool {
6280        self.event_receiver.is_terminated()
6281    }
6282}
6283
6284impl futures::Stream for LinuxManagerEventStream {
6285    type Item = Result<LinuxManagerEvent, fidl::Error>;
6286
6287    fn poll_next(
6288        mut self: std::pin::Pin<&mut Self>,
6289        cx: &mut std::task::Context<'_>,
6290    ) -> std::task::Poll<Option<Self::Item>> {
6291        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6292            &mut self.event_receiver,
6293            cx
6294        )?) {
6295            Some(buf) => std::task::Poll::Ready(Some(LinuxManagerEvent::decode(buf))),
6296            None => std::task::Poll::Ready(None),
6297        }
6298    }
6299}
6300
6301#[derive(Debug)]
6302pub enum LinuxManagerEvent {
6303    OnGuestInfoChanged { label: String, info: LinuxGuestInfo },
6304}
6305
6306impl LinuxManagerEvent {
6307    #[allow(irrefutable_let_patterns)]
6308    pub fn into_on_guest_info_changed(self) -> Option<(String, LinuxGuestInfo)> {
6309        if let LinuxManagerEvent::OnGuestInfoChanged { label, info } = self {
6310            Some((label, info))
6311        } else {
6312            None
6313        }
6314    }
6315
6316    /// Decodes a message buffer as a [`LinuxManagerEvent`].
6317    fn decode(
6318        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6319    ) -> Result<LinuxManagerEvent, fidl::Error> {
6320        let (bytes, _handles) = buf.split_mut();
6321        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6322        debug_assert_eq!(tx_header.tx_id, 0);
6323        match tx_header.ordinal {
6324            0x30a9be4c43d6a2d6 => {
6325                let mut out = fidl::new_empty!(
6326                    LinuxManagerOnGuestInfoChangedRequest,
6327                    fidl::encoding::DefaultFuchsiaResourceDialect
6328                );
6329                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerOnGuestInfoChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6330                Ok((LinuxManagerEvent::OnGuestInfoChanged { label: out.label, info: out.info }))
6331            }
6332            _ => Err(fidl::Error::UnknownOrdinal {
6333                ordinal: tx_header.ordinal,
6334                protocol_name: <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6335            }),
6336        }
6337    }
6338}
6339
6340/// A Stream of incoming requests for fuchsia.virtualization/LinuxManager.
6341pub struct LinuxManagerRequestStream {
6342    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6343    is_terminated: bool,
6344}
6345
6346impl std::marker::Unpin for LinuxManagerRequestStream {}
6347
6348impl futures::stream::FusedStream for LinuxManagerRequestStream {
6349    fn is_terminated(&self) -> bool {
6350        self.is_terminated
6351    }
6352}
6353
6354impl fidl::endpoints::RequestStream for LinuxManagerRequestStream {
6355    type Protocol = LinuxManagerMarker;
6356    type ControlHandle = LinuxManagerControlHandle;
6357
6358    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6359        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6360    }
6361
6362    fn control_handle(&self) -> Self::ControlHandle {
6363        LinuxManagerControlHandle { inner: self.inner.clone() }
6364    }
6365
6366    fn into_inner(
6367        self,
6368    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6369    {
6370        (self.inner, self.is_terminated)
6371    }
6372
6373    fn from_inner(
6374        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6375        is_terminated: bool,
6376    ) -> Self {
6377        Self { inner, is_terminated }
6378    }
6379}
6380
6381impl futures::Stream for LinuxManagerRequestStream {
6382    type Item = Result<LinuxManagerRequest, fidl::Error>;
6383
6384    fn poll_next(
6385        mut self: std::pin::Pin<&mut Self>,
6386        cx: &mut std::task::Context<'_>,
6387    ) -> std::task::Poll<Option<Self::Item>> {
6388        let this = &mut *self;
6389        if this.inner.check_shutdown(cx) {
6390            this.is_terminated = true;
6391            return std::task::Poll::Ready(None);
6392        }
6393        if this.is_terminated {
6394            panic!("polled LinuxManagerRequestStream after completion");
6395        }
6396        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6397            |bytes, handles| {
6398                match this.inner.channel().read_etc(cx, bytes, handles) {
6399                    std::task::Poll::Ready(Ok(())) => {}
6400                    std::task::Poll::Pending => return std::task::Poll::Pending,
6401                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6402                        this.is_terminated = true;
6403                        return std::task::Poll::Ready(None);
6404                    }
6405                    std::task::Poll::Ready(Err(e)) => {
6406                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6407                            e.into(),
6408                        ))));
6409                    }
6410                }
6411
6412                // A message has been received from the channel
6413                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6414
6415                std::task::Poll::Ready(Some(match header.ordinal {
6416                    0x11809ced100a2bea => {
6417                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6418                        let mut req = fidl::new_empty!(
6419                            LinuxManagerStartAndGetLinuxGuestInfoRequest,
6420                            fidl::encoding::DefaultFuchsiaResourceDialect
6421                        );
6422                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LinuxManagerStartAndGetLinuxGuestInfoRequest>(&header, _body_bytes, handles, &mut req)?;
6423                        let control_handle =
6424                            LinuxManagerControlHandle { inner: this.inner.clone() };
6425                        Ok(LinuxManagerRequest::StartAndGetLinuxGuestInfo {
6426                            label: req.label,
6427
6428                            responder: LinuxManagerStartAndGetLinuxGuestInfoResponder {
6429                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6430                                tx_id: header.tx_id,
6431                            },
6432                        })
6433                    }
6434                    0x732c69394548a76a => {
6435                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6436                        let mut req = fidl::new_empty!(
6437                            fidl::encoding::EmptyPayload,
6438                            fidl::encoding::DefaultFuchsiaResourceDialect
6439                        );
6440                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6441                        let control_handle =
6442                            LinuxManagerControlHandle { inner: this.inner.clone() };
6443                        Ok(LinuxManagerRequest::WipeData {
6444                            responder: LinuxManagerWipeDataResponder {
6445                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6446                                tx_id: header.tx_id,
6447                            },
6448                        })
6449                    }
6450                    0x5dab12b50bc9909d => {
6451                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6452                        let mut req = fidl::new_empty!(
6453                            fidl::encoding::EmptyPayload,
6454                            fidl::encoding::DefaultFuchsiaResourceDialect
6455                        );
6456                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6457                        let control_handle =
6458                            LinuxManagerControlHandle { inner: this.inner.clone() };
6459                        Ok(LinuxManagerRequest::GracefulShutdown { control_handle })
6460                    }
6461                    _ => Err(fidl::Error::UnknownOrdinal {
6462                        ordinal: header.ordinal,
6463                        protocol_name:
6464                            <LinuxManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6465                    }),
6466                }))
6467            },
6468        )
6469    }
6470}
6471
6472/// A `LinuxManager` provides access to the status of Linux guest instances.
6473#[derive(Debug)]
6474pub enum LinuxManagerRequest {
6475    /// Get Linux guest environment info.
6476    ///
6477    /// Returns ZX_ERR_UNAVAILABLE if the Linux guest is not available.
6478    StartAndGetLinuxGuestInfo {
6479        label: String,
6480        responder: LinuxManagerStartAndGetLinuxGuestInfoResponder,
6481    },
6482    /// Clears the stateful data. This includes any installed containers and any user data
6483    /// they may contain.
6484    ///
6485    /// Returns ZX_ERR_BAD_STATE if this is called while the VM is running.
6486    /// Returns ZX_ERR_IO if there was an IO failure while performing the
6487    /// operation.
6488    WipeData { responder: LinuxManagerWipeDataResponder },
6489    /// Attempts to gracefully shut down a running guest. The caller must ensure that the guest
6490    /// has actually stopped (such as by waiting on a Guest client PEER_CLOSED signal and checking
6491    /// the epitaph) before attempting to launch another guest.
6492    ///
6493    /// On a clean shutdown the Guest client will contain a ZX_OK epitaph, and on an unexpected
6494    /// shutdown the client will contain a ZX_ERR_INTERNAL epitaph (or no epitaph if there was
6495    /// a component crash).
6496    GracefulShutdown { control_handle: LinuxManagerControlHandle },
6497}
6498
6499impl LinuxManagerRequest {
6500    #[allow(irrefutable_let_patterns)]
6501    pub fn into_start_and_get_linux_guest_info(
6502        self,
6503    ) -> Option<(String, LinuxManagerStartAndGetLinuxGuestInfoResponder)> {
6504        if let LinuxManagerRequest::StartAndGetLinuxGuestInfo { label, responder } = self {
6505            Some((label, responder))
6506        } else {
6507            None
6508        }
6509    }
6510
6511    #[allow(irrefutable_let_patterns)]
6512    pub fn into_wipe_data(self) -> Option<(LinuxManagerWipeDataResponder)> {
6513        if let LinuxManagerRequest::WipeData { responder } = self {
6514            Some((responder))
6515        } else {
6516            None
6517        }
6518    }
6519
6520    #[allow(irrefutable_let_patterns)]
6521    pub fn into_graceful_shutdown(self) -> Option<(LinuxManagerControlHandle)> {
6522        if let LinuxManagerRequest::GracefulShutdown { control_handle } = self {
6523            Some((control_handle))
6524        } else {
6525            None
6526        }
6527    }
6528
6529    /// Name of the method defined in FIDL
6530    pub fn method_name(&self) -> &'static str {
6531        match *self {
6532            LinuxManagerRequest::StartAndGetLinuxGuestInfo { .. } => {
6533                "start_and_get_linux_guest_info"
6534            }
6535            LinuxManagerRequest::WipeData { .. } => "wipe_data",
6536            LinuxManagerRequest::GracefulShutdown { .. } => "graceful_shutdown",
6537        }
6538    }
6539}
6540
6541#[derive(Debug, Clone)]
6542pub struct LinuxManagerControlHandle {
6543    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6544}
6545
6546impl fidl::endpoints::ControlHandle for LinuxManagerControlHandle {
6547    fn shutdown(&self) {
6548        self.inner.shutdown()
6549    }
6550
6551    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6552        self.inner.shutdown_with_epitaph(status)
6553    }
6554
6555    fn is_closed(&self) -> bool {
6556        self.inner.channel().is_closed()
6557    }
6558    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6559        self.inner.channel().on_closed()
6560    }
6561
6562    #[cfg(target_os = "fuchsia")]
6563    fn signal_peer(
6564        &self,
6565        clear_mask: zx::Signals,
6566        set_mask: zx::Signals,
6567    ) -> Result<(), zx_status::Status> {
6568        use fidl::Peered;
6569        self.inner.channel().signal_peer(clear_mask, set_mask)
6570    }
6571}
6572
6573impl LinuxManagerControlHandle {
6574    pub fn send_on_guest_info_changed(
6575        &self,
6576        mut label: &str,
6577        mut info: &LinuxGuestInfo,
6578    ) -> Result<(), fidl::Error> {
6579        self.inner.send::<LinuxManagerOnGuestInfoChangedRequest>(
6580            (label, info),
6581            0,
6582            0x30a9be4c43d6a2d6,
6583            fidl::encoding::DynamicFlags::empty(),
6584        )
6585    }
6586}
6587
6588#[must_use = "FIDL methods require a response to be sent"]
6589#[derive(Debug)]
6590pub struct LinuxManagerStartAndGetLinuxGuestInfoResponder {
6591    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6592    tx_id: u32,
6593}
6594
6595/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6596/// if the responder is dropped without sending a response, so that the client
6597/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6598impl std::ops::Drop for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6599    fn drop(&mut self) {
6600        self.control_handle.shutdown();
6601        // Safety: drops once, never accessed again
6602        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6603    }
6604}
6605
6606impl fidl::endpoints::Responder for LinuxManagerStartAndGetLinuxGuestInfoResponder {
6607    type ControlHandle = LinuxManagerControlHandle;
6608
6609    fn control_handle(&self) -> &LinuxManagerControlHandle {
6610        &self.control_handle
6611    }
6612
6613    fn drop_without_shutdown(mut self) {
6614        // Safety: drops once, never accessed again due to mem::forget
6615        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6616        // Prevent Drop from running (which would shut down the channel)
6617        std::mem::forget(self);
6618    }
6619}
6620
6621impl LinuxManagerStartAndGetLinuxGuestInfoResponder {
6622    /// Sends a response to the FIDL transaction.
6623    ///
6624    /// Sets the channel to shutdown if an error occurs.
6625    pub fn send(self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6626        let _result = self.send_raw(result);
6627        if _result.is_err() {
6628            self.control_handle.shutdown();
6629        }
6630        self.drop_without_shutdown();
6631        _result
6632    }
6633
6634    /// Similar to "send" but does not shutdown the channel if an error occurs.
6635    pub fn send_no_shutdown_on_err(
6636        self,
6637        mut result: Result<&LinuxGuestInfo, i32>,
6638    ) -> Result<(), fidl::Error> {
6639        let _result = self.send_raw(result);
6640        self.drop_without_shutdown();
6641        _result
6642    }
6643
6644    fn send_raw(&self, mut result: Result<&LinuxGuestInfo, i32>) -> Result<(), fidl::Error> {
6645        self.control_handle.inner.send::<fidl::encoding::ResultType<
6646            LinuxManagerStartAndGetLinuxGuestInfoResponse,
6647            i32,
6648        >>(
6649            result.map(|info| (info,)),
6650            self.tx_id,
6651            0x11809ced100a2bea,
6652            fidl::encoding::DynamicFlags::empty(),
6653        )
6654    }
6655}
6656
6657#[must_use = "FIDL methods require a response to be sent"]
6658#[derive(Debug)]
6659pub struct LinuxManagerWipeDataResponder {
6660    control_handle: std::mem::ManuallyDrop<LinuxManagerControlHandle>,
6661    tx_id: u32,
6662}
6663
6664/// Set the the channel to be shutdown (see [`LinuxManagerControlHandle::shutdown`])
6665/// if the responder is dropped without sending a response, so that the client
6666/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6667impl std::ops::Drop for LinuxManagerWipeDataResponder {
6668    fn drop(&mut self) {
6669        self.control_handle.shutdown();
6670        // Safety: drops once, never accessed again
6671        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6672    }
6673}
6674
6675impl fidl::endpoints::Responder for LinuxManagerWipeDataResponder {
6676    type ControlHandle = LinuxManagerControlHandle;
6677
6678    fn control_handle(&self) -> &LinuxManagerControlHandle {
6679        &self.control_handle
6680    }
6681
6682    fn drop_without_shutdown(mut self) {
6683        // Safety: drops once, never accessed again due to mem::forget
6684        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6685        // Prevent Drop from running (which would shut down the channel)
6686        std::mem::forget(self);
6687    }
6688}
6689
6690impl LinuxManagerWipeDataResponder {
6691    /// Sends a response to the FIDL transaction.
6692    ///
6693    /// Sets the channel to shutdown if an error occurs.
6694    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6695        let _result = self.send_raw(result);
6696        if _result.is_err() {
6697            self.control_handle.shutdown();
6698        }
6699        self.drop_without_shutdown();
6700        _result
6701    }
6702
6703    /// Similar to "send" but does not shutdown the channel if an error occurs.
6704    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6705        let _result = self.send_raw(result);
6706        self.drop_without_shutdown();
6707        _result
6708    }
6709
6710    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6711        self.control_handle
6712            .inner
6713            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6714                result,
6715                self.tx_id,
6716                0x732c69394548a76a,
6717                fidl::encoding::DynamicFlags::empty(),
6718            )
6719    }
6720}
6721
6722#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6723pub struct MemControllerMarker;
6724
6725impl fidl::endpoints::ProtocolMarker for MemControllerMarker {
6726    type Proxy = MemControllerProxy;
6727    type RequestStream = MemControllerRequestStream;
6728    #[cfg(target_os = "fuchsia")]
6729    type SynchronousProxy = MemControllerSynchronousProxy;
6730
6731    const DEBUG_NAME: &'static str = "fuchsia.virtualization.MemController";
6732}
6733impl fidl::endpoints::DiscoverableProtocolMarker for MemControllerMarker {}
6734
6735pub trait MemControllerProxyInterface: Send + Sync {
6736    type GetMemSizeResponseFut: std::future::Future<Output = Result<(u64, u64, u64, u64, u64), fidl::Error>>
6737        + Send;
6738    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut;
6739    fn r#request_size(&self, requested_size: u64) -> Result<(), fidl::Error>;
6740}
6741#[derive(Debug)]
6742#[cfg(target_os = "fuchsia")]
6743pub struct MemControllerSynchronousProxy {
6744    client: fidl::client::sync::Client,
6745}
6746
6747#[cfg(target_os = "fuchsia")]
6748impl fidl::endpoints::SynchronousProxy for MemControllerSynchronousProxy {
6749    type Proxy = MemControllerProxy;
6750    type Protocol = MemControllerMarker;
6751
6752    fn from_channel(inner: fidl::Channel) -> Self {
6753        Self::new(inner)
6754    }
6755
6756    fn into_channel(self) -> fidl::Channel {
6757        self.client.into_channel()
6758    }
6759
6760    fn as_channel(&self) -> &fidl::Channel {
6761        self.client.as_channel()
6762    }
6763}
6764
6765#[cfg(target_os = "fuchsia")]
6766impl MemControllerSynchronousProxy {
6767    pub fn new(channel: fidl::Channel) -> Self {
6768        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6769        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6770    }
6771
6772    pub fn into_channel(self) -> fidl::Channel {
6773        self.client.into_channel()
6774    }
6775
6776    /// Waits until an event arrives and returns it. It is safe for other
6777    /// threads to make concurrent requests while waiting for an event.
6778    pub fn wait_for_event(
6779        &self,
6780        deadline: zx::MonotonicInstant,
6781    ) -> Result<MemControllerEvent, fidl::Error> {
6782        MemControllerEvent::decode(self.client.wait_for_event(deadline)?)
6783    }
6784
6785    /// Get the configured region size, usable region size, plugged size and requestd size
6786    ///
6787    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6788    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6789    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6790    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6791    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6792    /// memory region.
6793    /// requested_size is the requested amount of plugged memory within the usable device-managed
6794    /// memory region.
6795    pub fn r#get_mem_size(
6796        &self,
6797        ___deadline: zx::MonotonicInstant,
6798    ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6799        let _response = self
6800            .client
6801            .send_query::<fidl::encoding::EmptyPayload, MemControllerGetMemSizeResponse>(
6802                (),
6803                0x6e9d496f9b66ea56,
6804                fidl::encoding::DynamicFlags::empty(),
6805                ___deadline,
6806            )?;
6807        Ok((
6808            _response.block_size,
6809            _response.region_size,
6810            _response.usable_region_size,
6811            _response.plugged_size,
6812            _response.requested_size,
6813        ))
6814    }
6815
6816    /// Update the requested size to plug or unplug memory
6817    ///
6818    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6819    /// configuration changed) by (un)plugging memory blocks.
6820    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6821        self.client.send::<MemControllerRequestSizeRequest>(
6822            (requested_size,),
6823            0x12f8e2cc21ee8102,
6824            fidl::encoding::DynamicFlags::empty(),
6825        )
6826    }
6827}
6828
6829#[cfg(target_os = "fuchsia")]
6830impl From<MemControllerSynchronousProxy> for zx::NullableHandle {
6831    fn from(value: MemControllerSynchronousProxy) -> Self {
6832        value.into_channel().into()
6833    }
6834}
6835
6836#[cfg(target_os = "fuchsia")]
6837impl From<fidl::Channel> for MemControllerSynchronousProxy {
6838    fn from(value: fidl::Channel) -> Self {
6839        Self::new(value)
6840    }
6841}
6842
6843#[cfg(target_os = "fuchsia")]
6844impl fidl::endpoints::FromClient for MemControllerSynchronousProxy {
6845    type Protocol = MemControllerMarker;
6846
6847    fn from_client(value: fidl::endpoints::ClientEnd<MemControllerMarker>) -> Self {
6848        Self::new(value.into_channel())
6849    }
6850}
6851
6852#[derive(Debug, Clone)]
6853pub struct MemControllerProxy {
6854    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6855}
6856
6857impl fidl::endpoints::Proxy for MemControllerProxy {
6858    type Protocol = MemControllerMarker;
6859
6860    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6861        Self::new(inner)
6862    }
6863
6864    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6865        self.client.into_channel().map_err(|client| Self { client })
6866    }
6867
6868    fn as_channel(&self) -> &::fidl::AsyncChannel {
6869        self.client.as_channel()
6870    }
6871}
6872
6873impl MemControllerProxy {
6874    /// Create a new Proxy for fuchsia.virtualization/MemController.
6875    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6876        let protocol_name = <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6877        Self { client: fidl::client::Client::new(channel, protocol_name) }
6878    }
6879
6880    /// Get a Stream of events from the remote end of the protocol.
6881    ///
6882    /// # Panics
6883    ///
6884    /// Panics if the event stream was already taken.
6885    pub fn take_event_stream(&self) -> MemControllerEventStream {
6886        MemControllerEventStream { event_receiver: self.client.take_event_receiver() }
6887    }
6888
6889    /// Get the configured region size, usable region size, plugged size and requestd size
6890    ///
6891    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
6892    /// region_size is the size of device-managed memory region in bytes. Cannot change.
6893    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
6894    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
6895    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
6896    /// memory region.
6897    /// requested_size is the requested amount of plugged memory within the usable device-managed
6898    /// memory region.
6899    pub fn r#get_mem_size(
6900        &self,
6901    ) -> fidl::client::QueryResponseFut<
6902        (u64, u64, u64, u64, u64),
6903        fidl::encoding::DefaultFuchsiaResourceDialect,
6904    > {
6905        MemControllerProxyInterface::r#get_mem_size(self)
6906    }
6907
6908    /// Update the requested size to plug or unplug memory
6909    ///
6910    /// The driver SHOULD react to resize requests from the device (requested_size in the device
6911    /// configuration changed) by (un)plugging memory blocks.
6912    pub fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6913        MemControllerProxyInterface::r#request_size(self, requested_size)
6914    }
6915}
6916
6917impl MemControllerProxyInterface for MemControllerProxy {
6918    type GetMemSizeResponseFut = fidl::client::QueryResponseFut<
6919        (u64, u64, u64, u64, u64),
6920        fidl::encoding::DefaultFuchsiaResourceDialect,
6921    >;
6922    fn r#get_mem_size(&self) -> Self::GetMemSizeResponseFut {
6923        fn _decode(
6924            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6925        ) -> Result<(u64, u64, u64, u64, u64), fidl::Error> {
6926            let _response = fidl::client::decode_transaction_body::<
6927                MemControllerGetMemSizeResponse,
6928                fidl::encoding::DefaultFuchsiaResourceDialect,
6929                0x6e9d496f9b66ea56,
6930            >(_buf?)?;
6931            Ok((
6932                _response.block_size,
6933                _response.region_size,
6934                _response.usable_region_size,
6935                _response.plugged_size,
6936                _response.requested_size,
6937            ))
6938        }
6939        self.client
6940            .send_query_and_decode::<fidl::encoding::EmptyPayload, (u64, u64, u64, u64, u64)>(
6941                (),
6942                0x6e9d496f9b66ea56,
6943                fidl::encoding::DynamicFlags::empty(),
6944                _decode,
6945            )
6946    }
6947
6948    fn r#request_size(&self, mut requested_size: u64) -> Result<(), fidl::Error> {
6949        self.client.send::<MemControllerRequestSizeRequest>(
6950            (requested_size,),
6951            0x12f8e2cc21ee8102,
6952            fidl::encoding::DynamicFlags::empty(),
6953        )
6954    }
6955}
6956
6957pub struct MemControllerEventStream {
6958    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6959}
6960
6961impl std::marker::Unpin for MemControllerEventStream {}
6962
6963impl futures::stream::FusedStream for MemControllerEventStream {
6964    fn is_terminated(&self) -> bool {
6965        self.event_receiver.is_terminated()
6966    }
6967}
6968
6969impl futures::Stream for MemControllerEventStream {
6970    type Item = Result<MemControllerEvent, fidl::Error>;
6971
6972    fn poll_next(
6973        mut self: std::pin::Pin<&mut Self>,
6974        cx: &mut std::task::Context<'_>,
6975    ) -> std::task::Poll<Option<Self::Item>> {
6976        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6977            &mut self.event_receiver,
6978            cx
6979        )?) {
6980            Some(buf) => std::task::Poll::Ready(Some(MemControllerEvent::decode(buf))),
6981            None => std::task::Poll::Ready(None),
6982        }
6983    }
6984}
6985
6986#[derive(Debug)]
6987pub enum MemControllerEvent {}
6988
6989impl MemControllerEvent {
6990    /// Decodes a message buffer as a [`MemControllerEvent`].
6991    fn decode(
6992        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6993    ) -> Result<MemControllerEvent, fidl::Error> {
6994        let (bytes, _handles) = buf.split_mut();
6995        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6996        debug_assert_eq!(tx_header.tx_id, 0);
6997        match tx_header.ordinal {
6998            _ => Err(fidl::Error::UnknownOrdinal {
6999                ordinal: tx_header.ordinal,
7000                protocol_name: <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7001            }),
7002        }
7003    }
7004}
7005
7006/// A Stream of incoming requests for fuchsia.virtualization/MemController.
7007pub struct MemControllerRequestStream {
7008    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7009    is_terminated: bool,
7010}
7011
7012impl std::marker::Unpin for MemControllerRequestStream {}
7013
7014impl futures::stream::FusedStream for MemControllerRequestStream {
7015    fn is_terminated(&self) -> bool {
7016        self.is_terminated
7017    }
7018}
7019
7020impl fidl::endpoints::RequestStream for MemControllerRequestStream {
7021    type Protocol = MemControllerMarker;
7022    type ControlHandle = MemControllerControlHandle;
7023
7024    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7025        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7026    }
7027
7028    fn control_handle(&self) -> Self::ControlHandle {
7029        MemControllerControlHandle { inner: self.inner.clone() }
7030    }
7031
7032    fn into_inner(
7033        self,
7034    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7035    {
7036        (self.inner, self.is_terminated)
7037    }
7038
7039    fn from_inner(
7040        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7041        is_terminated: bool,
7042    ) -> Self {
7043        Self { inner, is_terminated }
7044    }
7045}
7046
7047impl futures::Stream for MemControllerRequestStream {
7048    type Item = Result<MemControllerRequest, fidl::Error>;
7049
7050    fn poll_next(
7051        mut self: std::pin::Pin<&mut Self>,
7052        cx: &mut std::task::Context<'_>,
7053    ) -> std::task::Poll<Option<Self::Item>> {
7054        let this = &mut *self;
7055        if this.inner.check_shutdown(cx) {
7056            this.is_terminated = true;
7057            return std::task::Poll::Ready(None);
7058        }
7059        if this.is_terminated {
7060            panic!("polled MemControllerRequestStream after completion");
7061        }
7062        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7063            |bytes, handles| {
7064                match this.inner.channel().read_etc(cx, bytes, handles) {
7065                    std::task::Poll::Ready(Ok(())) => {}
7066                    std::task::Poll::Pending => return std::task::Poll::Pending,
7067                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7068                        this.is_terminated = true;
7069                        return std::task::Poll::Ready(None);
7070                    }
7071                    std::task::Poll::Ready(Err(e)) => {
7072                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7073                            e.into(),
7074                        ))));
7075                    }
7076                }
7077
7078                // A message has been received from the channel
7079                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7080
7081                std::task::Poll::Ready(Some(match header.ordinal {
7082                    0x6e9d496f9b66ea56 => {
7083                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7084                        let mut req = fidl::new_empty!(
7085                            fidl::encoding::EmptyPayload,
7086                            fidl::encoding::DefaultFuchsiaResourceDialect
7087                        );
7088                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7089                        let control_handle =
7090                            MemControllerControlHandle { inner: this.inner.clone() };
7091                        Ok(MemControllerRequest::GetMemSize {
7092                            responder: MemControllerGetMemSizeResponder {
7093                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7094                                tx_id: header.tx_id,
7095                            },
7096                        })
7097                    }
7098                    0x12f8e2cc21ee8102 => {
7099                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7100                        let mut req = fidl::new_empty!(
7101                            MemControllerRequestSizeRequest,
7102                            fidl::encoding::DefaultFuchsiaResourceDialect
7103                        );
7104                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MemControllerRequestSizeRequest>(&header, _body_bytes, handles, &mut req)?;
7105                        let control_handle =
7106                            MemControllerControlHandle { inner: this.inner.clone() };
7107                        Ok(MemControllerRequest::RequestSize {
7108                            requested_size: req.requested_size,
7109
7110                            control_handle,
7111                        })
7112                    }
7113                    _ => Err(fidl::Error::UnknownOrdinal {
7114                        ordinal: header.ordinal,
7115                        protocol_name:
7116                            <MemControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7117                    }),
7118                }))
7119            },
7120        )
7121    }
7122}
7123
7124/// A `MemController` controls a guest's virtio-mem
7125#[derive(Debug)]
7126pub enum MemControllerRequest {
7127    /// Get the configured region size, usable region size, plugged size and requestd size
7128    ///
7129    /// block_size is the size and the alignment in bytes of a memory block. Cannot change.
7130    /// region_size is the size of device-managed memory region in bytes. Cannot change.
7131    /// usable_region_size is the size of the usable device-managed memory region. Can grow up to
7132    /// the region_size. Can only shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL requests.
7133    /// plugged_size is the amount of plugged memory in bytes within the usable device-managed
7134    /// memory region.
7135    /// requested_size is the requested amount of plugged memory within the usable device-managed
7136    /// memory region.
7137    GetMemSize { responder: MemControllerGetMemSizeResponder },
7138    /// Update the requested size to plug or unplug memory
7139    ///
7140    /// The driver SHOULD react to resize requests from the device (requested_size in the device
7141    /// configuration changed) by (un)plugging memory blocks.
7142    RequestSize { requested_size: u64, control_handle: MemControllerControlHandle },
7143}
7144
7145impl MemControllerRequest {
7146    #[allow(irrefutable_let_patterns)]
7147    pub fn into_get_mem_size(self) -> Option<(MemControllerGetMemSizeResponder)> {
7148        if let MemControllerRequest::GetMemSize { responder } = self {
7149            Some((responder))
7150        } else {
7151            None
7152        }
7153    }
7154
7155    #[allow(irrefutable_let_patterns)]
7156    pub fn into_request_size(self) -> Option<(u64, MemControllerControlHandle)> {
7157        if let MemControllerRequest::RequestSize { requested_size, control_handle } = self {
7158            Some((requested_size, control_handle))
7159        } else {
7160            None
7161        }
7162    }
7163
7164    /// Name of the method defined in FIDL
7165    pub fn method_name(&self) -> &'static str {
7166        match *self {
7167            MemControllerRequest::GetMemSize { .. } => "get_mem_size",
7168            MemControllerRequest::RequestSize { .. } => "request_size",
7169        }
7170    }
7171}
7172
7173#[derive(Debug, Clone)]
7174pub struct MemControllerControlHandle {
7175    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7176}
7177
7178impl fidl::endpoints::ControlHandle for MemControllerControlHandle {
7179    fn shutdown(&self) {
7180        self.inner.shutdown()
7181    }
7182
7183    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7184        self.inner.shutdown_with_epitaph(status)
7185    }
7186
7187    fn is_closed(&self) -> bool {
7188        self.inner.channel().is_closed()
7189    }
7190    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7191        self.inner.channel().on_closed()
7192    }
7193
7194    #[cfg(target_os = "fuchsia")]
7195    fn signal_peer(
7196        &self,
7197        clear_mask: zx::Signals,
7198        set_mask: zx::Signals,
7199    ) -> Result<(), zx_status::Status> {
7200        use fidl::Peered;
7201        self.inner.channel().signal_peer(clear_mask, set_mask)
7202    }
7203}
7204
7205impl MemControllerControlHandle {}
7206
7207#[must_use = "FIDL methods require a response to be sent"]
7208#[derive(Debug)]
7209pub struct MemControllerGetMemSizeResponder {
7210    control_handle: std::mem::ManuallyDrop<MemControllerControlHandle>,
7211    tx_id: u32,
7212}
7213
7214/// Set the the channel to be shutdown (see [`MemControllerControlHandle::shutdown`])
7215/// if the responder is dropped without sending a response, so that the client
7216/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7217impl std::ops::Drop for MemControllerGetMemSizeResponder {
7218    fn drop(&mut self) {
7219        self.control_handle.shutdown();
7220        // Safety: drops once, never accessed again
7221        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7222    }
7223}
7224
7225impl fidl::endpoints::Responder for MemControllerGetMemSizeResponder {
7226    type ControlHandle = MemControllerControlHandle;
7227
7228    fn control_handle(&self) -> &MemControllerControlHandle {
7229        &self.control_handle
7230    }
7231
7232    fn drop_without_shutdown(mut self) {
7233        // Safety: drops once, never accessed again due to mem::forget
7234        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7235        // Prevent Drop from running (which would shut down the channel)
7236        std::mem::forget(self);
7237    }
7238}
7239
7240impl MemControllerGetMemSizeResponder {
7241    /// Sends a response to the FIDL transaction.
7242    ///
7243    /// Sets the channel to shutdown if an error occurs.
7244    pub fn send(
7245        self,
7246        mut block_size: u64,
7247        mut region_size: u64,
7248        mut usable_region_size: u64,
7249        mut plugged_size: u64,
7250        mut requested_size: u64,
7251    ) -> Result<(), fidl::Error> {
7252        let _result = self.send_raw(
7253            block_size,
7254            region_size,
7255            usable_region_size,
7256            plugged_size,
7257            requested_size,
7258        );
7259        if _result.is_err() {
7260            self.control_handle.shutdown();
7261        }
7262        self.drop_without_shutdown();
7263        _result
7264    }
7265
7266    /// Similar to "send" but does not shutdown the channel if an error occurs.
7267    pub fn send_no_shutdown_on_err(
7268        self,
7269        mut block_size: u64,
7270        mut region_size: u64,
7271        mut usable_region_size: u64,
7272        mut plugged_size: u64,
7273        mut requested_size: u64,
7274    ) -> Result<(), fidl::Error> {
7275        let _result = self.send_raw(
7276            block_size,
7277            region_size,
7278            usable_region_size,
7279            plugged_size,
7280            requested_size,
7281        );
7282        self.drop_without_shutdown();
7283        _result
7284    }
7285
7286    fn send_raw(
7287        &self,
7288        mut block_size: u64,
7289        mut region_size: u64,
7290        mut usable_region_size: u64,
7291        mut plugged_size: u64,
7292        mut requested_size: u64,
7293    ) -> Result<(), fidl::Error> {
7294        self.control_handle.inner.send::<MemControllerGetMemSizeResponse>(
7295            (block_size, region_size, usable_region_size, plugged_size, requested_size),
7296            self.tx_id,
7297            0x6e9d496f9b66ea56,
7298            fidl::encoding::DynamicFlags::empty(),
7299        )
7300    }
7301}
7302
7303#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7304pub struct TerminaGuestManagerMarker;
7305
7306impl fidl::endpoints::ProtocolMarker for TerminaGuestManagerMarker {
7307    type Proxy = TerminaGuestManagerProxy;
7308    type RequestStream = TerminaGuestManagerRequestStream;
7309    #[cfg(target_os = "fuchsia")]
7310    type SynchronousProxy = TerminaGuestManagerSynchronousProxy;
7311
7312    const DEBUG_NAME: &'static str = "fuchsia.virtualization.TerminaGuestManager";
7313}
7314impl fidl::endpoints::DiscoverableProtocolMarker for TerminaGuestManagerMarker {}
7315
7316pub trait TerminaGuestManagerProxyInterface: Send + Sync {
7317    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
7318        + Send;
7319    fn r#launch(
7320        &self,
7321        guest_config: GuestConfig,
7322        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7323    ) -> Self::LaunchResponseFut;
7324    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7325    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
7326    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
7327        + Send;
7328    fn r#connect(
7329        &self,
7330        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7331    ) -> Self::ConnectResponseFut;
7332    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
7333    fn r#get_info(&self) -> Self::GetInfoResponseFut;
7334}
7335#[derive(Debug)]
7336#[cfg(target_os = "fuchsia")]
7337pub struct TerminaGuestManagerSynchronousProxy {
7338    client: fidl::client::sync::Client,
7339}
7340
7341#[cfg(target_os = "fuchsia")]
7342impl fidl::endpoints::SynchronousProxy for TerminaGuestManagerSynchronousProxy {
7343    type Proxy = TerminaGuestManagerProxy;
7344    type Protocol = TerminaGuestManagerMarker;
7345
7346    fn from_channel(inner: fidl::Channel) -> Self {
7347        Self::new(inner)
7348    }
7349
7350    fn into_channel(self) -> fidl::Channel {
7351        self.client.into_channel()
7352    }
7353
7354    fn as_channel(&self) -> &fidl::Channel {
7355        self.client.as_channel()
7356    }
7357}
7358
7359#[cfg(target_os = "fuchsia")]
7360impl TerminaGuestManagerSynchronousProxy {
7361    pub fn new(channel: fidl::Channel) -> Self {
7362        let protocol_name =
7363            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7364        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7365    }
7366
7367    pub fn into_channel(self) -> fidl::Channel {
7368        self.client.into_channel()
7369    }
7370
7371    /// Waits until an event arrives and returns it. It is safe for other
7372    /// threads to make concurrent requests while waiting for an event.
7373    pub fn wait_for_event(
7374        &self,
7375        deadline: zx::MonotonicInstant,
7376    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7377        TerminaGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
7378    }
7379
7380    /// Launch a new guest instance.
7381    ///
7382    /// Possible errors:
7383    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7384    ///         problems detected by the guest manager.
7385    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7386    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7387    ///         component logs for a more specific failure.
7388    pub fn r#launch(
7389        &self,
7390        mut guest_config: GuestConfig,
7391        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7392        ___deadline: zx::MonotonicInstant,
7393    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7394        let _response =
7395            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
7396                fidl::encoding::EmptyStruct,
7397                GuestManagerError,
7398            >>(
7399                (&mut guest_config, controller),
7400                0x394a2e29f750323e,
7401                fidl::encoding::DynamicFlags::empty(),
7402                ___deadline,
7403            )?;
7404        Ok(_response.map(|x| x))
7405    }
7406
7407    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7408    /// be used to launch another guest.
7409    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
7410        let _response =
7411            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
7412                (),
7413                0x3ad9a012982f872d,
7414                fidl::encoding::DynamicFlags::empty(),
7415                ___deadline,
7416            )?;
7417        Ok(_response)
7418    }
7419
7420    /// Connect to a currently running guest.
7421    ///
7422    /// Possible errors:
7423    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7424    ///         has launched before attempting to reconnect.
7425    pub fn r#connect(
7426        &self,
7427        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7428        ___deadline: zx::MonotonicInstant,
7429    ) -> Result<GuestManagerConnectResult, fidl::Error> {
7430        let _response =
7431            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
7432                fidl::encoding::EmptyStruct,
7433                GuestManagerError,
7434            >>(
7435                (controller,),
7436                0x4e489076e3bb15b4,
7437                fidl::encoding::DynamicFlags::empty(),
7438                ___deadline,
7439            )?;
7440        Ok(_response.map(|x| x))
7441    }
7442
7443    /// Query guest info
7444    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
7445        let _response =
7446            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
7447                (),
7448                0x76892614aea695dc,
7449                fidl::encoding::DynamicFlags::empty(),
7450                ___deadline,
7451            )?;
7452        Ok(_response.guest_info)
7453    }
7454}
7455
7456#[cfg(target_os = "fuchsia")]
7457impl From<TerminaGuestManagerSynchronousProxy> for zx::NullableHandle {
7458    fn from(value: TerminaGuestManagerSynchronousProxy) -> Self {
7459        value.into_channel().into()
7460    }
7461}
7462
7463#[cfg(target_os = "fuchsia")]
7464impl From<fidl::Channel> for TerminaGuestManagerSynchronousProxy {
7465    fn from(value: fidl::Channel) -> Self {
7466        Self::new(value)
7467    }
7468}
7469
7470#[cfg(target_os = "fuchsia")]
7471impl fidl::endpoints::FromClient for TerminaGuestManagerSynchronousProxy {
7472    type Protocol = TerminaGuestManagerMarker;
7473
7474    fn from_client(value: fidl::endpoints::ClientEnd<TerminaGuestManagerMarker>) -> Self {
7475        Self::new(value.into_channel())
7476    }
7477}
7478
7479#[derive(Debug, Clone)]
7480pub struct TerminaGuestManagerProxy {
7481    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7482}
7483
7484impl fidl::endpoints::Proxy for TerminaGuestManagerProxy {
7485    type Protocol = TerminaGuestManagerMarker;
7486
7487    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7488        Self::new(inner)
7489    }
7490
7491    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7492        self.client.into_channel().map_err(|client| Self { client })
7493    }
7494
7495    fn as_channel(&self) -> &::fidl::AsyncChannel {
7496        self.client.as_channel()
7497    }
7498}
7499
7500impl TerminaGuestManagerProxy {
7501    /// Create a new Proxy for fuchsia.virtualization/TerminaGuestManager.
7502    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7503        let protocol_name =
7504            <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7505        Self { client: fidl::client::Client::new(channel, protocol_name) }
7506    }
7507
7508    /// Get a Stream of events from the remote end of the protocol.
7509    ///
7510    /// # Panics
7511    ///
7512    /// Panics if the event stream was already taken.
7513    pub fn take_event_stream(&self) -> TerminaGuestManagerEventStream {
7514        TerminaGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
7515    }
7516
7517    /// Launch a new guest instance.
7518    ///
7519    /// Possible errors:
7520    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7521    ///         problems detected by the guest manager.
7522    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7523    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7524    ///         component logs for a more specific failure.
7525    pub fn r#launch(
7526        &self,
7527        mut guest_config: GuestConfig,
7528        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7529    ) -> fidl::client::QueryResponseFut<
7530        GuestManagerLaunchResult,
7531        fidl::encoding::DefaultFuchsiaResourceDialect,
7532    > {
7533        TerminaGuestManagerProxyInterface::r#launch(self, guest_config, controller)
7534    }
7535
7536    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7537    /// be used to launch another guest.
7538    pub fn r#force_shutdown(
7539        &self,
7540    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7541        TerminaGuestManagerProxyInterface::r#force_shutdown(self)
7542    }
7543
7544    /// Connect to a currently running guest.
7545    ///
7546    /// Possible errors:
7547    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7548    ///         has launched before attempting to reconnect.
7549    pub fn r#connect(
7550        &self,
7551        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7552    ) -> fidl::client::QueryResponseFut<
7553        GuestManagerConnectResult,
7554        fidl::encoding::DefaultFuchsiaResourceDialect,
7555    > {
7556        TerminaGuestManagerProxyInterface::r#connect(self, controller)
7557    }
7558
7559    /// Query guest info
7560    pub fn r#get_info(
7561        &self,
7562    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
7563    {
7564        TerminaGuestManagerProxyInterface::r#get_info(self)
7565    }
7566}
7567
7568impl TerminaGuestManagerProxyInterface for TerminaGuestManagerProxy {
7569    type LaunchResponseFut = fidl::client::QueryResponseFut<
7570        GuestManagerLaunchResult,
7571        fidl::encoding::DefaultFuchsiaResourceDialect,
7572    >;
7573    fn r#launch(
7574        &self,
7575        mut guest_config: GuestConfig,
7576        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7577    ) -> Self::LaunchResponseFut {
7578        fn _decode(
7579            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7580        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
7581            let _response = fidl::client::decode_transaction_body::<
7582                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7583                fidl::encoding::DefaultFuchsiaResourceDialect,
7584                0x394a2e29f750323e,
7585            >(_buf?)?;
7586            Ok(_response.map(|x| x))
7587        }
7588        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
7589            (&mut guest_config, controller),
7590            0x394a2e29f750323e,
7591            fidl::encoding::DynamicFlags::empty(),
7592            _decode,
7593        )
7594    }
7595
7596    type ForceShutdownResponseFut =
7597        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7598    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
7599        fn _decode(
7600            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7601        ) -> Result<(), fidl::Error> {
7602            let _response = fidl::client::decode_transaction_body::<
7603                fidl::encoding::EmptyPayload,
7604                fidl::encoding::DefaultFuchsiaResourceDialect,
7605                0x3ad9a012982f872d,
7606            >(_buf?)?;
7607            Ok(_response)
7608        }
7609        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7610            (),
7611            0x3ad9a012982f872d,
7612            fidl::encoding::DynamicFlags::empty(),
7613            _decode,
7614        )
7615    }
7616
7617    type ConnectResponseFut = fidl::client::QueryResponseFut<
7618        GuestManagerConnectResult,
7619        fidl::encoding::DefaultFuchsiaResourceDialect,
7620    >;
7621    fn r#connect(
7622        &self,
7623        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
7624    ) -> Self::ConnectResponseFut {
7625        fn _decode(
7626            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7627        ) -> Result<GuestManagerConnectResult, fidl::Error> {
7628            let _response = fidl::client::decode_transaction_body::<
7629                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
7630                fidl::encoding::DefaultFuchsiaResourceDialect,
7631                0x4e489076e3bb15b4,
7632            >(_buf?)?;
7633            Ok(_response.map(|x| x))
7634        }
7635        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
7636            (controller,),
7637            0x4e489076e3bb15b4,
7638            fidl::encoding::DynamicFlags::empty(),
7639            _decode,
7640        )
7641    }
7642
7643    type GetInfoResponseFut =
7644        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
7645    fn r#get_info(&self) -> Self::GetInfoResponseFut {
7646        fn _decode(
7647            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7648        ) -> Result<GuestInfo, fidl::Error> {
7649            let _response = fidl::client::decode_transaction_body::<
7650                GuestManagerGetInfoResponse,
7651                fidl::encoding::DefaultFuchsiaResourceDialect,
7652                0x76892614aea695dc,
7653            >(_buf?)?;
7654            Ok(_response.guest_info)
7655        }
7656        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
7657            (),
7658            0x76892614aea695dc,
7659            fidl::encoding::DynamicFlags::empty(),
7660            _decode,
7661        )
7662    }
7663}
7664
7665pub struct TerminaGuestManagerEventStream {
7666    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7667}
7668
7669impl std::marker::Unpin for TerminaGuestManagerEventStream {}
7670
7671impl futures::stream::FusedStream for TerminaGuestManagerEventStream {
7672    fn is_terminated(&self) -> bool {
7673        self.event_receiver.is_terminated()
7674    }
7675}
7676
7677impl futures::Stream for TerminaGuestManagerEventStream {
7678    type Item = Result<TerminaGuestManagerEvent, fidl::Error>;
7679
7680    fn poll_next(
7681        mut self: std::pin::Pin<&mut Self>,
7682        cx: &mut std::task::Context<'_>,
7683    ) -> std::task::Poll<Option<Self::Item>> {
7684        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7685            &mut self.event_receiver,
7686            cx
7687        )?) {
7688            Some(buf) => std::task::Poll::Ready(Some(TerminaGuestManagerEvent::decode(buf))),
7689            None => std::task::Poll::Ready(None),
7690        }
7691    }
7692}
7693
7694#[derive(Debug)]
7695pub enum TerminaGuestManagerEvent {}
7696
7697impl TerminaGuestManagerEvent {
7698    /// Decodes a message buffer as a [`TerminaGuestManagerEvent`].
7699    fn decode(
7700        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7701    ) -> Result<TerminaGuestManagerEvent, fidl::Error> {
7702        let (bytes, _handles) = buf.split_mut();
7703        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7704        debug_assert_eq!(tx_header.tx_id, 0);
7705        match tx_header.ordinal {
7706            _ => Err(fidl::Error::UnknownOrdinal {
7707                ordinal: tx_header.ordinal,
7708                protocol_name:
7709                    <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7710            }),
7711        }
7712    }
7713}
7714
7715/// A Stream of incoming requests for fuchsia.virtualization/TerminaGuestManager.
7716pub struct TerminaGuestManagerRequestStream {
7717    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7718    is_terminated: bool,
7719}
7720
7721impl std::marker::Unpin for TerminaGuestManagerRequestStream {}
7722
7723impl futures::stream::FusedStream for TerminaGuestManagerRequestStream {
7724    fn is_terminated(&self) -> bool {
7725        self.is_terminated
7726    }
7727}
7728
7729impl fidl::endpoints::RequestStream for TerminaGuestManagerRequestStream {
7730    type Protocol = TerminaGuestManagerMarker;
7731    type ControlHandle = TerminaGuestManagerControlHandle;
7732
7733    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7734        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7735    }
7736
7737    fn control_handle(&self) -> Self::ControlHandle {
7738        TerminaGuestManagerControlHandle { inner: self.inner.clone() }
7739    }
7740
7741    fn into_inner(
7742        self,
7743    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7744    {
7745        (self.inner, self.is_terminated)
7746    }
7747
7748    fn from_inner(
7749        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7750        is_terminated: bool,
7751    ) -> Self {
7752        Self { inner, is_terminated }
7753    }
7754}
7755
7756impl futures::Stream for TerminaGuestManagerRequestStream {
7757    type Item = Result<TerminaGuestManagerRequest, fidl::Error>;
7758
7759    fn poll_next(
7760        mut self: std::pin::Pin<&mut Self>,
7761        cx: &mut std::task::Context<'_>,
7762    ) -> std::task::Poll<Option<Self::Item>> {
7763        let this = &mut *self;
7764        if this.inner.check_shutdown(cx) {
7765            this.is_terminated = true;
7766            return std::task::Poll::Ready(None);
7767        }
7768        if this.is_terminated {
7769            panic!("polled TerminaGuestManagerRequestStream after completion");
7770        }
7771        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7772            |bytes, handles| {
7773                match this.inner.channel().read_etc(cx, bytes, handles) {
7774                    std::task::Poll::Ready(Ok(())) => {}
7775                    std::task::Poll::Pending => return std::task::Poll::Pending,
7776                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7777                        this.is_terminated = true;
7778                        return std::task::Poll::Ready(None);
7779                    }
7780                    std::task::Poll::Ready(Err(e)) => {
7781                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7782                            e.into(),
7783                        ))));
7784                    }
7785                }
7786
7787                // A message has been received from the channel
7788                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7789
7790                std::task::Poll::Ready(Some(match header.ordinal {
7791                0x394a2e29f750323e => {
7792                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7793                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7794                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
7795                    let control_handle = TerminaGuestManagerControlHandle {
7796                        inner: this.inner.clone(),
7797                    };
7798                    Ok(TerminaGuestManagerRequest::Launch {guest_config: req.guest_config,
7799controller: req.controller,
7800
7801                        responder: TerminaGuestManagerLaunchResponder {
7802                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7803                            tx_id: header.tx_id,
7804                        },
7805                    })
7806                }
7807                0x3ad9a012982f872d => {
7808                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7809                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7810                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7811                    let control_handle = TerminaGuestManagerControlHandle {
7812                        inner: this.inner.clone(),
7813                    };
7814                    Ok(TerminaGuestManagerRequest::ForceShutdown {
7815                        responder: TerminaGuestManagerForceShutdownResponder {
7816                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7817                            tx_id: header.tx_id,
7818                        },
7819                    })
7820                }
7821                0x4e489076e3bb15b4 => {
7822                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7823                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7824                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
7825                    let control_handle = TerminaGuestManagerControlHandle {
7826                        inner: this.inner.clone(),
7827                    };
7828                    Ok(TerminaGuestManagerRequest::Connect {controller: req.controller,
7829
7830                        responder: TerminaGuestManagerConnectResponder {
7831                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7832                            tx_id: header.tx_id,
7833                        },
7834                    })
7835                }
7836                0x76892614aea695dc => {
7837                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7838                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7839                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7840                    let control_handle = TerminaGuestManagerControlHandle {
7841                        inner: this.inner.clone(),
7842                    };
7843                    Ok(TerminaGuestManagerRequest::GetInfo {
7844                        responder: TerminaGuestManagerGetInfoResponder {
7845                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7846                            tx_id: header.tx_id,
7847                        },
7848                    })
7849                }
7850                _ => Err(fidl::Error::UnknownOrdinal {
7851                    ordinal: header.ordinal,
7852                    protocol_name: <TerminaGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7853                }),
7854            }))
7855            },
7856        )
7857    }
7858}
7859
7860#[derive(Debug)]
7861pub enum TerminaGuestManagerRequest {
7862    /// Launch a new guest instance.
7863    ///
7864    /// Possible errors:
7865    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
7866    ///         problems detected by the guest manager.
7867    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
7868    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
7869    ///         component logs for a more specific failure.
7870    Launch {
7871        guest_config: GuestConfig,
7872        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7873        responder: TerminaGuestManagerLaunchResponder,
7874    },
7875    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
7876    /// be used to launch another guest.
7877    ForceShutdown { responder: TerminaGuestManagerForceShutdownResponder },
7878    /// Connect to a currently running guest.
7879    ///
7880    /// Possible errors:
7881    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
7882    ///         has launched before attempting to reconnect.
7883    Connect {
7884        controller: fidl::endpoints::ServerEnd<GuestMarker>,
7885        responder: TerminaGuestManagerConnectResponder,
7886    },
7887    /// Query guest info
7888    GetInfo { responder: TerminaGuestManagerGetInfoResponder },
7889}
7890
7891impl TerminaGuestManagerRequest {
7892    #[allow(irrefutable_let_patterns)]
7893    pub fn into_launch(
7894        self,
7895    ) -> Option<(
7896        GuestConfig,
7897        fidl::endpoints::ServerEnd<GuestMarker>,
7898        TerminaGuestManagerLaunchResponder,
7899    )> {
7900        if let TerminaGuestManagerRequest::Launch { guest_config, controller, responder } = self {
7901            Some((guest_config, controller, responder))
7902        } else {
7903            None
7904        }
7905    }
7906
7907    #[allow(irrefutable_let_patterns)]
7908    pub fn into_force_shutdown(self) -> Option<(TerminaGuestManagerForceShutdownResponder)> {
7909        if let TerminaGuestManagerRequest::ForceShutdown { responder } = self {
7910            Some((responder))
7911        } else {
7912            None
7913        }
7914    }
7915
7916    #[allow(irrefutable_let_patterns)]
7917    pub fn into_connect(
7918        self,
7919    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, TerminaGuestManagerConnectResponder)>
7920    {
7921        if let TerminaGuestManagerRequest::Connect { controller, responder } = self {
7922            Some((controller, responder))
7923        } else {
7924            None
7925        }
7926    }
7927
7928    #[allow(irrefutable_let_patterns)]
7929    pub fn into_get_info(self) -> Option<(TerminaGuestManagerGetInfoResponder)> {
7930        if let TerminaGuestManagerRequest::GetInfo { responder } = self {
7931            Some((responder))
7932        } else {
7933            None
7934        }
7935    }
7936
7937    /// Name of the method defined in FIDL
7938    pub fn method_name(&self) -> &'static str {
7939        match *self {
7940            TerminaGuestManagerRequest::Launch { .. } => "launch",
7941            TerminaGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
7942            TerminaGuestManagerRequest::Connect { .. } => "connect",
7943            TerminaGuestManagerRequest::GetInfo { .. } => "get_info",
7944        }
7945    }
7946}
7947
7948#[derive(Debug, Clone)]
7949pub struct TerminaGuestManagerControlHandle {
7950    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7951}
7952
7953impl fidl::endpoints::ControlHandle for TerminaGuestManagerControlHandle {
7954    fn shutdown(&self) {
7955        self.inner.shutdown()
7956    }
7957
7958    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7959        self.inner.shutdown_with_epitaph(status)
7960    }
7961
7962    fn is_closed(&self) -> bool {
7963        self.inner.channel().is_closed()
7964    }
7965    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7966        self.inner.channel().on_closed()
7967    }
7968
7969    #[cfg(target_os = "fuchsia")]
7970    fn signal_peer(
7971        &self,
7972        clear_mask: zx::Signals,
7973        set_mask: zx::Signals,
7974    ) -> Result<(), zx_status::Status> {
7975        use fidl::Peered;
7976        self.inner.channel().signal_peer(clear_mask, set_mask)
7977    }
7978}
7979
7980impl TerminaGuestManagerControlHandle {}
7981
7982#[must_use = "FIDL methods require a response to be sent"]
7983#[derive(Debug)]
7984pub struct TerminaGuestManagerLaunchResponder {
7985    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
7986    tx_id: u32,
7987}
7988
7989/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
7990/// if the responder is dropped without sending a response, so that the client
7991/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7992impl std::ops::Drop for TerminaGuestManagerLaunchResponder {
7993    fn drop(&mut self) {
7994        self.control_handle.shutdown();
7995        // Safety: drops once, never accessed again
7996        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7997    }
7998}
7999
8000impl fidl::endpoints::Responder for TerminaGuestManagerLaunchResponder {
8001    type ControlHandle = TerminaGuestManagerControlHandle;
8002
8003    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8004        &self.control_handle
8005    }
8006
8007    fn drop_without_shutdown(mut self) {
8008        // Safety: drops once, never accessed again due to mem::forget
8009        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8010        // Prevent Drop from running (which would shut down the channel)
8011        std::mem::forget(self);
8012    }
8013}
8014
8015impl TerminaGuestManagerLaunchResponder {
8016    /// Sends a response to the FIDL transaction.
8017    ///
8018    /// Sets the channel to shutdown if an error occurs.
8019    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8020        let _result = self.send_raw(result);
8021        if _result.is_err() {
8022            self.control_handle.shutdown();
8023        }
8024        self.drop_without_shutdown();
8025        _result
8026    }
8027
8028    /// Similar to "send" but does not shutdown the channel if an error occurs.
8029    pub fn send_no_shutdown_on_err(
8030        self,
8031        mut result: Result<(), GuestManagerError>,
8032    ) -> Result<(), fidl::Error> {
8033        let _result = self.send_raw(result);
8034        self.drop_without_shutdown();
8035        _result
8036    }
8037
8038    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8039        self.control_handle.inner.send::<fidl::encoding::ResultType<
8040            fidl::encoding::EmptyStruct,
8041            GuestManagerError,
8042        >>(
8043            result,
8044            self.tx_id,
8045            0x394a2e29f750323e,
8046            fidl::encoding::DynamicFlags::empty(),
8047        )
8048    }
8049}
8050
8051#[must_use = "FIDL methods require a response to be sent"]
8052#[derive(Debug)]
8053pub struct TerminaGuestManagerForceShutdownResponder {
8054    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8055    tx_id: u32,
8056}
8057
8058/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8059/// if the responder is dropped without sending a response, so that the client
8060/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8061impl std::ops::Drop for TerminaGuestManagerForceShutdownResponder {
8062    fn drop(&mut self) {
8063        self.control_handle.shutdown();
8064        // Safety: drops once, never accessed again
8065        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8066    }
8067}
8068
8069impl fidl::endpoints::Responder for TerminaGuestManagerForceShutdownResponder {
8070    type ControlHandle = TerminaGuestManagerControlHandle;
8071
8072    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8073        &self.control_handle
8074    }
8075
8076    fn drop_without_shutdown(mut self) {
8077        // Safety: drops once, never accessed again due to mem::forget
8078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8079        // Prevent Drop from running (which would shut down the channel)
8080        std::mem::forget(self);
8081    }
8082}
8083
8084impl TerminaGuestManagerForceShutdownResponder {
8085    /// Sends a response to the FIDL transaction.
8086    ///
8087    /// Sets the channel to shutdown if an error occurs.
8088    pub fn send(self) -> Result<(), fidl::Error> {
8089        let _result = self.send_raw();
8090        if _result.is_err() {
8091            self.control_handle.shutdown();
8092        }
8093        self.drop_without_shutdown();
8094        _result
8095    }
8096
8097    /// Similar to "send" but does not shutdown the channel if an error occurs.
8098    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8099        let _result = self.send_raw();
8100        self.drop_without_shutdown();
8101        _result
8102    }
8103
8104    fn send_raw(&self) -> Result<(), fidl::Error> {
8105        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8106            (),
8107            self.tx_id,
8108            0x3ad9a012982f872d,
8109            fidl::encoding::DynamicFlags::empty(),
8110        )
8111    }
8112}
8113
8114#[must_use = "FIDL methods require a response to be sent"]
8115#[derive(Debug)]
8116pub struct TerminaGuestManagerConnectResponder {
8117    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8118    tx_id: u32,
8119}
8120
8121/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8122/// if the responder is dropped without sending a response, so that the client
8123/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8124impl std::ops::Drop for TerminaGuestManagerConnectResponder {
8125    fn drop(&mut self) {
8126        self.control_handle.shutdown();
8127        // Safety: drops once, never accessed again
8128        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8129    }
8130}
8131
8132impl fidl::endpoints::Responder for TerminaGuestManagerConnectResponder {
8133    type ControlHandle = TerminaGuestManagerControlHandle;
8134
8135    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8136        &self.control_handle
8137    }
8138
8139    fn drop_without_shutdown(mut self) {
8140        // Safety: drops once, never accessed again due to mem::forget
8141        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8142        // Prevent Drop from running (which would shut down the channel)
8143        std::mem::forget(self);
8144    }
8145}
8146
8147impl TerminaGuestManagerConnectResponder {
8148    /// Sends a response to the FIDL transaction.
8149    ///
8150    /// Sets the channel to shutdown if an error occurs.
8151    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8152        let _result = self.send_raw(result);
8153        if _result.is_err() {
8154            self.control_handle.shutdown();
8155        }
8156        self.drop_without_shutdown();
8157        _result
8158    }
8159
8160    /// Similar to "send" but does not shutdown the channel if an error occurs.
8161    pub fn send_no_shutdown_on_err(
8162        self,
8163        mut result: Result<(), GuestManagerError>,
8164    ) -> Result<(), fidl::Error> {
8165        let _result = self.send_raw(result);
8166        self.drop_without_shutdown();
8167        _result
8168    }
8169
8170    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8171        self.control_handle.inner.send::<fidl::encoding::ResultType<
8172            fidl::encoding::EmptyStruct,
8173            GuestManagerError,
8174        >>(
8175            result,
8176            self.tx_id,
8177            0x4e489076e3bb15b4,
8178            fidl::encoding::DynamicFlags::empty(),
8179        )
8180    }
8181}
8182
8183#[must_use = "FIDL methods require a response to be sent"]
8184#[derive(Debug)]
8185pub struct TerminaGuestManagerGetInfoResponder {
8186    control_handle: std::mem::ManuallyDrop<TerminaGuestManagerControlHandle>,
8187    tx_id: u32,
8188}
8189
8190/// Set the the channel to be shutdown (see [`TerminaGuestManagerControlHandle::shutdown`])
8191/// if the responder is dropped without sending a response, so that the client
8192/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8193impl std::ops::Drop for TerminaGuestManagerGetInfoResponder {
8194    fn drop(&mut self) {
8195        self.control_handle.shutdown();
8196        // Safety: drops once, never accessed again
8197        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8198    }
8199}
8200
8201impl fidl::endpoints::Responder for TerminaGuestManagerGetInfoResponder {
8202    type ControlHandle = TerminaGuestManagerControlHandle;
8203
8204    fn control_handle(&self) -> &TerminaGuestManagerControlHandle {
8205        &self.control_handle
8206    }
8207
8208    fn drop_without_shutdown(mut self) {
8209        // Safety: drops once, never accessed again due to mem::forget
8210        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8211        // Prevent Drop from running (which would shut down the channel)
8212        std::mem::forget(self);
8213    }
8214}
8215
8216impl TerminaGuestManagerGetInfoResponder {
8217    /// Sends a response to the FIDL transaction.
8218    ///
8219    /// Sets the channel to shutdown if an error occurs.
8220    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8221        let _result = self.send_raw(guest_info);
8222        if _result.is_err() {
8223            self.control_handle.shutdown();
8224        }
8225        self.drop_without_shutdown();
8226        _result
8227    }
8228
8229    /// Similar to "send" but does not shutdown the channel if an error occurs.
8230    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8231        let _result = self.send_raw(guest_info);
8232        self.drop_without_shutdown();
8233        _result
8234    }
8235
8236    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
8237        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
8238            (guest_info,),
8239            self.tx_id,
8240            0x76892614aea695dc,
8241            fidl::encoding::DynamicFlags::empty(),
8242        )
8243    }
8244}
8245
8246#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8247pub struct ZirconGuestManagerMarker;
8248
8249impl fidl::endpoints::ProtocolMarker for ZirconGuestManagerMarker {
8250    type Proxy = ZirconGuestManagerProxy;
8251    type RequestStream = ZirconGuestManagerRequestStream;
8252    #[cfg(target_os = "fuchsia")]
8253    type SynchronousProxy = ZirconGuestManagerSynchronousProxy;
8254
8255    const DEBUG_NAME: &'static str = "fuchsia.virtualization.ZirconGuestManager";
8256}
8257impl fidl::endpoints::DiscoverableProtocolMarker for ZirconGuestManagerMarker {}
8258
8259pub trait ZirconGuestManagerProxyInterface: Send + Sync {
8260    type LaunchResponseFut: std::future::Future<Output = Result<GuestManagerLaunchResult, fidl::Error>>
8261        + Send;
8262    fn r#launch(
8263        &self,
8264        guest_config: GuestConfig,
8265        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8266    ) -> Self::LaunchResponseFut;
8267    type ForceShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8268    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut;
8269    type ConnectResponseFut: std::future::Future<Output = Result<GuestManagerConnectResult, fidl::Error>>
8270        + Send;
8271    fn r#connect(
8272        &self,
8273        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8274    ) -> Self::ConnectResponseFut;
8275    type GetInfoResponseFut: std::future::Future<Output = Result<GuestInfo, fidl::Error>> + Send;
8276    fn r#get_info(&self) -> Self::GetInfoResponseFut;
8277}
8278#[derive(Debug)]
8279#[cfg(target_os = "fuchsia")]
8280pub struct ZirconGuestManagerSynchronousProxy {
8281    client: fidl::client::sync::Client,
8282}
8283
8284#[cfg(target_os = "fuchsia")]
8285impl fidl::endpoints::SynchronousProxy for ZirconGuestManagerSynchronousProxy {
8286    type Proxy = ZirconGuestManagerProxy;
8287    type Protocol = ZirconGuestManagerMarker;
8288
8289    fn from_channel(inner: fidl::Channel) -> Self {
8290        Self::new(inner)
8291    }
8292
8293    fn into_channel(self) -> fidl::Channel {
8294        self.client.into_channel()
8295    }
8296
8297    fn as_channel(&self) -> &fidl::Channel {
8298        self.client.as_channel()
8299    }
8300}
8301
8302#[cfg(target_os = "fuchsia")]
8303impl ZirconGuestManagerSynchronousProxy {
8304    pub fn new(channel: fidl::Channel) -> Self {
8305        let protocol_name =
8306            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8307        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8308    }
8309
8310    pub fn into_channel(self) -> fidl::Channel {
8311        self.client.into_channel()
8312    }
8313
8314    /// Waits until an event arrives and returns it. It is safe for other
8315    /// threads to make concurrent requests while waiting for an event.
8316    pub fn wait_for_event(
8317        &self,
8318        deadline: zx::MonotonicInstant,
8319    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8320        ZirconGuestManagerEvent::decode(self.client.wait_for_event(deadline)?)
8321    }
8322
8323    /// Launch a new guest instance.
8324    ///
8325    /// Possible errors:
8326    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8327    ///         problems detected by the guest manager.
8328    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8329    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8330    ///         component logs for a more specific failure.
8331    pub fn r#launch(
8332        &self,
8333        mut guest_config: GuestConfig,
8334        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8335        ___deadline: zx::MonotonicInstant,
8336    ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8337        let _response =
8338            self.client.send_query::<GuestManagerLaunchRequest, fidl::encoding::ResultType<
8339                fidl::encoding::EmptyStruct,
8340                GuestManagerError,
8341            >>(
8342                (&mut guest_config, controller),
8343                0x394a2e29f750323e,
8344                fidl::encoding::DynamicFlags::empty(),
8345                ___deadline,
8346            )?;
8347        Ok(_response.map(|x| x))
8348    }
8349
8350    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8351    /// be used to launch another guest.
8352    pub fn r#force_shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
8353        let _response =
8354            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
8355                (),
8356                0x3ad9a012982f872d,
8357                fidl::encoding::DynamicFlags::empty(),
8358                ___deadline,
8359            )?;
8360        Ok(_response)
8361    }
8362
8363    /// Connect to a currently running guest.
8364    ///
8365    /// Possible errors:
8366    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8367    ///         has launched before attempting to reconnect.
8368    pub fn r#connect(
8369        &self,
8370        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8371        ___deadline: zx::MonotonicInstant,
8372    ) -> Result<GuestManagerConnectResult, fidl::Error> {
8373        let _response =
8374            self.client.send_query::<GuestManagerConnectRequest, fidl::encoding::ResultType<
8375                fidl::encoding::EmptyStruct,
8376                GuestManagerError,
8377            >>(
8378                (controller,),
8379                0x4e489076e3bb15b4,
8380                fidl::encoding::DynamicFlags::empty(),
8381                ___deadline,
8382            )?;
8383        Ok(_response.map(|x| x))
8384    }
8385
8386    /// Query guest info
8387    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<GuestInfo, fidl::Error> {
8388        let _response =
8389            self.client.send_query::<fidl::encoding::EmptyPayload, GuestManagerGetInfoResponse>(
8390                (),
8391                0x76892614aea695dc,
8392                fidl::encoding::DynamicFlags::empty(),
8393                ___deadline,
8394            )?;
8395        Ok(_response.guest_info)
8396    }
8397}
8398
8399#[cfg(target_os = "fuchsia")]
8400impl From<ZirconGuestManagerSynchronousProxy> for zx::NullableHandle {
8401    fn from(value: ZirconGuestManagerSynchronousProxy) -> Self {
8402        value.into_channel().into()
8403    }
8404}
8405
8406#[cfg(target_os = "fuchsia")]
8407impl From<fidl::Channel> for ZirconGuestManagerSynchronousProxy {
8408    fn from(value: fidl::Channel) -> Self {
8409        Self::new(value)
8410    }
8411}
8412
8413#[cfg(target_os = "fuchsia")]
8414impl fidl::endpoints::FromClient for ZirconGuestManagerSynchronousProxy {
8415    type Protocol = ZirconGuestManagerMarker;
8416
8417    fn from_client(value: fidl::endpoints::ClientEnd<ZirconGuestManagerMarker>) -> Self {
8418        Self::new(value.into_channel())
8419    }
8420}
8421
8422#[derive(Debug, Clone)]
8423pub struct ZirconGuestManagerProxy {
8424    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8425}
8426
8427impl fidl::endpoints::Proxy for ZirconGuestManagerProxy {
8428    type Protocol = ZirconGuestManagerMarker;
8429
8430    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8431        Self::new(inner)
8432    }
8433
8434    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8435        self.client.into_channel().map_err(|client| Self { client })
8436    }
8437
8438    fn as_channel(&self) -> &::fidl::AsyncChannel {
8439        self.client.as_channel()
8440    }
8441}
8442
8443impl ZirconGuestManagerProxy {
8444    /// Create a new Proxy for fuchsia.virtualization/ZirconGuestManager.
8445    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8446        let protocol_name =
8447            <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8448        Self { client: fidl::client::Client::new(channel, protocol_name) }
8449    }
8450
8451    /// Get a Stream of events from the remote end of the protocol.
8452    ///
8453    /// # Panics
8454    ///
8455    /// Panics if the event stream was already taken.
8456    pub fn take_event_stream(&self) -> ZirconGuestManagerEventStream {
8457        ZirconGuestManagerEventStream { event_receiver: self.client.take_event_receiver() }
8458    }
8459
8460    /// Launch a new guest instance.
8461    ///
8462    /// Possible errors:
8463    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8464    ///         problems detected by the guest manager.
8465    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8466    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8467    ///         component logs for a more specific failure.
8468    pub fn r#launch(
8469        &self,
8470        mut guest_config: GuestConfig,
8471        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8472    ) -> fidl::client::QueryResponseFut<
8473        GuestManagerLaunchResult,
8474        fidl::encoding::DefaultFuchsiaResourceDialect,
8475    > {
8476        ZirconGuestManagerProxyInterface::r#launch(self, guest_config, controller)
8477    }
8478
8479    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8480    /// be used to launch another guest.
8481    pub fn r#force_shutdown(
8482        &self,
8483    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8484        ZirconGuestManagerProxyInterface::r#force_shutdown(self)
8485    }
8486
8487    /// Connect to a currently running guest.
8488    ///
8489    /// Possible errors:
8490    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8491    ///         has launched before attempting to reconnect.
8492    pub fn r#connect(
8493        &self,
8494        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8495    ) -> fidl::client::QueryResponseFut<
8496        GuestManagerConnectResult,
8497        fidl::encoding::DefaultFuchsiaResourceDialect,
8498    > {
8499        ZirconGuestManagerProxyInterface::r#connect(self, controller)
8500    }
8501
8502    /// Query guest info
8503    pub fn r#get_info(
8504        &self,
8505    ) -> fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
8506    {
8507        ZirconGuestManagerProxyInterface::r#get_info(self)
8508    }
8509}
8510
8511impl ZirconGuestManagerProxyInterface for ZirconGuestManagerProxy {
8512    type LaunchResponseFut = fidl::client::QueryResponseFut<
8513        GuestManagerLaunchResult,
8514        fidl::encoding::DefaultFuchsiaResourceDialect,
8515    >;
8516    fn r#launch(
8517        &self,
8518        mut guest_config: GuestConfig,
8519        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8520    ) -> Self::LaunchResponseFut {
8521        fn _decode(
8522            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8523        ) -> Result<GuestManagerLaunchResult, fidl::Error> {
8524            let _response = fidl::client::decode_transaction_body::<
8525                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8526                fidl::encoding::DefaultFuchsiaResourceDialect,
8527                0x394a2e29f750323e,
8528            >(_buf?)?;
8529            Ok(_response.map(|x| x))
8530        }
8531        self.client.send_query_and_decode::<GuestManagerLaunchRequest, GuestManagerLaunchResult>(
8532            (&mut guest_config, controller),
8533            0x394a2e29f750323e,
8534            fidl::encoding::DynamicFlags::empty(),
8535            _decode,
8536        )
8537    }
8538
8539    type ForceShutdownResponseFut =
8540        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8541    fn r#force_shutdown(&self) -> Self::ForceShutdownResponseFut {
8542        fn _decode(
8543            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8544        ) -> Result<(), fidl::Error> {
8545            let _response = fidl::client::decode_transaction_body::<
8546                fidl::encoding::EmptyPayload,
8547                fidl::encoding::DefaultFuchsiaResourceDialect,
8548                0x3ad9a012982f872d,
8549            >(_buf?)?;
8550            Ok(_response)
8551        }
8552        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
8553            (),
8554            0x3ad9a012982f872d,
8555            fidl::encoding::DynamicFlags::empty(),
8556            _decode,
8557        )
8558    }
8559
8560    type ConnectResponseFut = fidl::client::QueryResponseFut<
8561        GuestManagerConnectResult,
8562        fidl::encoding::DefaultFuchsiaResourceDialect,
8563    >;
8564    fn r#connect(
8565        &self,
8566        mut controller: fidl::endpoints::ServerEnd<GuestMarker>,
8567    ) -> Self::ConnectResponseFut {
8568        fn _decode(
8569            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8570        ) -> Result<GuestManagerConnectResult, fidl::Error> {
8571            let _response = fidl::client::decode_transaction_body::<
8572                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GuestManagerError>,
8573                fidl::encoding::DefaultFuchsiaResourceDialect,
8574                0x4e489076e3bb15b4,
8575            >(_buf?)?;
8576            Ok(_response.map(|x| x))
8577        }
8578        self.client.send_query_and_decode::<GuestManagerConnectRequest, GuestManagerConnectResult>(
8579            (controller,),
8580            0x4e489076e3bb15b4,
8581            fidl::encoding::DynamicFlags::empty(),
8582            _decode,
8583        )
8584    }
8585
8586    type GetInfoResponseFut =
8587        fidl::client::QueryResponseFut<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
8588    fn r#get_info(&self) -> Self::GetInfoResponseFut {
8589        fn _decode(
8590            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8591        ) -> Result<GuestInfo, fidl::Error> {
8592            let _response = fidl::client::decode_transaction_body::<
8593                GuestManagerGetInfoResponse,
8594                fidl::encoding::DefaultFuchsiaResourceDialect,
8595                0x76892614aea695dc,
8596            >(_buf?)?;
8597            Ok(_response.guest_info)
8598        }
8599        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, GuestInfo>(
8600            (),
8601            0x76892614aea695dc,
8602            fidl::encoding::DynamicFlags::empty(),
8603            _decode,
8604        )
8605    }
8606}
8607
8608pub struct ZirconGuestManagerEventStream {
8609    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8610}
8611
8612impl std::marker::Unpin for ZirconGuestManagerEventStream {}
8613
8614impl futures::stream::FusedStream for ZirconGuestManagerEventStream {
8615    fn is_terminated(&self) -> bool {
8616        self.event_receiver.is_terminated()
8617    }
8618}
8619
8620impl futures::Stream for ZirconGuestManagerEventStream {
8621    type Item = Result<ZirconGuestManagerEvent, fidl::Error>;
8622
8623    fn poll_next(
8624        mut self: std::pin::Pin<&mut Self>,
8625        cx: &mut std::task::Context<'_>,
8626    ) -> std::task::Poll<Option<Self::Item>> {
8627        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8628            &mut self.event_receiver,
8629            cx
8630        )?) {
8631            Some(buf) => std::task::Poll::Ready(Some(ZirconGuestManagerEvent::decode(buf))),
8632            None => std::task::Poll::Ready(None),
8633        }
8634    }
8635}
8636
8637#[derive(Debug)]
8638pub enum ZirconGuestManagerEvent {}
8639
8640impl ZirconGuestManagerEvent {
8641    /// Decodes a message buffer as a [`ZirconGuestManagerEvent`].
8642    fn decode(
8643        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8644    ) -> Result<ZirconGuestManagerEvent, fidl::Error> {
8645        let (bytes, _handles) = buf.split_mut();
8646        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8647        debug_assert_eq!(tx_header.tx_id, 0);
8648        match tx_header.ordinal {
8649            _ => Err(fidl::Error::UnknownOrdinal {
8650                ordinal: tx_header.ordinal,
8651                protocol_name:
8652                    <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8653            }),
8654        }
8655    }
8656}
8657
8658/// A Stream of incoming requests for fuchsia.virtualization/ZirconGuestManager.
8659pub struct ZirconGuestManagerRequestStream {
8660    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8661    is_terminated: bool,
8662}
8663
8664impl std::marker::Unpin for ZirconGuestManagerRequestStream {}
8665
8666impl futures::stream::FusedStream for ZirconGuestManagerRequestStream {
8667    fn is_terminated(&self) -> bool {
8668        self.is_terminated
8669    }
8670}
8671
8672impl fidl::endpoints::RequestStream for ZirconGuestManagerRequestStream {
8673    type Protocol = ZirconGuestManagerMarker;
8674    type ControlHandle = ZirconGuestManagerControlHandle;
8675
8676    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8677        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8678    }
8679
8680    fn control_handle(&self) -> Self::ControlHandle {
8681        ZirconGuestManagerControlHandle { inner: self.inner.clone() }
8682    }
8683
8684    fn into_inner(
8685        self,
8686    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8687    {
8688        (self.inner, self.is_terminated)
8689    }
8690
8691    fn from_inner(
8692        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8693        is_terminated: bool,
8694    ) -> Self {
8695        Self { inner, is_terminated }
8696    }
8697}
8698
8699impl futures::Stream for ZirconGuestManagerRequestStream {
8700    type Item = Result<ZirconGuestManagerRequest, fidl::Error>;
8701
8702    fn poll_next(
8703        mut self: std::pin::Pin<&mut Self>,
8704        cx: &mut std::task::Context<'_>,
8705    ) -> std::task::Poll<Option<Self::Item>> {
8706        let this = &mut *self;
8707        if this.inner.check_shutdown(cx) {
8708            this.is_terminated = true;
8709            return std::task::Poll::Ready(None);
8710        }
8711        if this.is_terminated {
8712            panic!("polled ZirconGuestManagerRequestStream after completion");
8713        }
8714        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8715            |bytes, handles| {
8716                match this.inner.channel().read_etc(cx, bytes, handles) {
8717                    std::task::Poll::Ready(Ok(())) => {}
8718                    std::task::Poll::Pending => return std::task::Poll::Pending,
8719                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8720                        this.is_terminated = true;
8721                        return std::task::Poll::Ready(None);
8722                    }
8723                    std::task::Poll::Ready(Err(e)) => {
8724                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8725                            e.into(),
8726                        ))));
8727                    }
8728                }
8729
8730                // A message has been received from the channel
8731                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8732
8733                std::task::Poll::Ready(Some(match header.ordinal {
8734                0x394a2e29f750323e => {
8735                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8736                    let mut req = fidl::new_empty!(GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8737                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
8738                    let control_handle = ZirconGuestManagerControlHandle {
8739                        inner: this.inner.clone(),
8740                    };
8741                    Ok(ZirconGuestManagerRequest::Launch {guest_config: req.guest_config,
8742controller: req.controller,
8743
8744                        responder: ZirconGuestManagerLaunchResponder {
8745                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8746                            tx_id: header.tx_id,
8747                        },
8748                    })
8749                }
8750                0x3ad9a012982f872d => {
8751                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8752                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8753                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8754                    let control_handle = ZirconGuestManagerControlHandle {
8755                        inner: this.inner.clone(),
8756                    };
8757                    Ok(ZirconGuestManagerRequest::ForceShutdown {
8758                        responder: ZirconGuestManagerForceShutdownResponder {
8759                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8760                            tx_id: header.tx_id,
8761                        },
8762                    })
8763                }
8764                0x4e489076e3bb15b4 => {
8765                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8766                    let mut req = fidl::new_empty!(GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8767                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GuestManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
8768                    let control_handle = ZirconGuestManagerControlHandle {
8769                        inner: this.inner.clone(),
8770                    };
8771                    Ok(ZirconGuestManagerRequest::Connect {controller: req.controller,
8772
8773                        responder: ZirconGuestManagerConnectResponder {
8774                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8775                            tx_id: header.tx_id,
8776                        },
8777                    })
8778                }
8779                0x76892614aea695dc => {
8780                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8781                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8782                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8783                    let control_handle = ZirconGuestManagerControlHandle {
8784                        inner: this.inner.clone(),
8785                    };
8786                    Ok(ZirconGuestManagerRequest::GetInfo {
8787                        responder: ZirconGuestManagerGetInfoResponder {
8788                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8789                            tx_id: header.tx_id,
8790                        },
8791                    })
8792                }
8793                _ => Err(fidl::Error::UnknownOrdinal {
8794                    ordinal: header.ordinal,
8795                    protocol_name: <ZirconGuestManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8796                }),
8797            }))
8798            },
8799        )
8800    }
8801}
8802
8803#[derive(Debug)]
8804pub enum ZirconGuestManagerRequest {
8805    /// Launch a new guest instance.
8806    ///
8807    /// Possible errors:
8808    ///     - BAD_CONFIG: Failed to parse the config from the guest package, or other config
8809    ///         problems detected by the guest manager.
8810    ///     - ALREADY_RUNNING: The guest is already running. Stop the guest before launching again.
8811    ///     - START_FAILURE: Failed to initialize the VMM and devices, and start the guest. See
8812    ///         component logs for a more specific failure.
8813    Launch {
8814        guest_config: GuestConfig,
8815        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8816        responder: ZirconGuestManagerLaunchResponder,
8817    },
8818    /// Forcibly shuts down a running guest. Immediately after ForceShutdown returns, Launch can
8819    /// be used to launch another guest.
8820    ForceShutdown { responder: ZirconGuestManagerForceShutdownResponder },
8821    /// Connect to a currently running guest.
8822    ///
8823    /// Possible errors:
8824    ///     - NOT_RUNNING: Attempted to connect to a guest in a non-running state. Ensure the guest
8825    ///         has launched before attempting to reconnect.
8826    Connect {
8827        controller: fidl::endpoints::ServerEnd<GuestMarker>,
8828        responder: ZirconGuestManagerConnectResponder,
8829    },
8830    /// Query guest info
8831    GetInfo { responder: ZirconGuestManagerGetInfoResponder },
8832}
8833
8834impl ZirconGuestManagerRequest {
8835    #[allow(irrefutable_let_patterns)]
8836    pub fn into_launch(
8837        self,
8838    ) -> Option<(
8839        GuestConfig,
8840        fidl::endpoints::ServerEnd<GuestMarker>,
8841        ZirconGuestManagerLaunchResponder,
8842    )> {
8843        if let ZirconGuestManagerRequest::Launch { guest_config, controller, responder } = self {
8844            Some((guest_config, controller, responder))
8845        } else {
8846            None
8847        }
8848    }
8849
8850    #[allow(irrefutable_let_patterns)]
8851    pub fn into_force_shutdown(self) -> Option<(ZirconGuestManagerForceShutdownResponder)> {
8852        if let ZirconGuestManagerRequest::ForceShutdown { responder } = self {
8853            Some((responder))
8854        } else {
8855            None
8856        }
8857    }
8858
8859    #[allow(irrefutable_let_patterns)]
8860    pub fn into_connect(
8861        self,
8862    ) -> Option<(fidl::endpoints::ServerEnd<GuestMarker>, ZirconGuestManagerConnectResponder)> {
8863        if let ZirconGuestManagerRequest::Connect { controller, responder } = self {
8864            Some((controller, responder))
8865        } else {
8866            None
8867        }
8868    }
8869
8870    #[allow(irrefutable_let_patterns)]
8871    pub fn into_get_info(self) -> Option<(ZirconGuestManagerGetInfoResponder)> {
8872        if let ZirconGuestManagerRequest::GetInfo { responder } = self {
8873            Some((responder))
8874        } else {
8875            None
8876        }
8877    }
8878
8879    /// Name of the method defined in FIDL
8880    pub fn method_name(&self) -> &'static str {
8881        match *self {
8882            ZirconGuestManagerRequest::Launch { .. } => "launch",
8883            ZirconGuestManagerRequest::ForceShutdown { .. } => "force_shutdown",
8884            ZirconGuestManagerRequest::Connect { .. } => "connect",
8885            ZirconGuestManagerRequest::GetInfo { .. } => "get_info",
8886        }
8887    }
8888}
8889
8890#[derive(Debug, Clone)]
8891pub struct ZirconGuestManagerControlHandle {
8892    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8893}
8894
8895impl fidl::endpoints::ControlHandle for ZirconGuestManagerControlHandle {
8896    fn shutdown(&self) {
8897        self.inner.shutdown()
8898    }
8899
8900    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8901        self.inner.shutdown_with_epitaph(status)
8902    }
8903
8904    fn is_closed(&self) -> bool {
8905        self.inner.channel().is_closed()
8906    }
8907    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8908        self.inner.channel().on_closed()
8909    }
8910
8911    #[cfg(target_os = "fuchsia")]
8912    fn signal_peer(
8913        &self,
8914        clear_mask: zx::Signals,
8915        set_mask: zx::Signals,
8916    ) -> Result<(), zx_status::Status> {
8917        use fidl::Peered;
8918        self.inner.channel().signal_peer(clear_mask, set_mask)
8919    }
8920}
8921
8922impl ZirconGuestManagerControlHandle {}
8923
8924#[must_use = "FIDL methods require a response to be sent"]
8925#[derive(Debug)]
8926pub struct ZirconGuestManagerLaunchResponder {
8927    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8928    tx_id: u32,
8929}
8930
8931/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
8932/// if the responder is dropped without sending a response, so that the client
8933/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8934impl std::ops::Drop for ZirconGuestManagerLaunchResponder {
8935    fn drop(&mut self) {
8936        self.control_handle.shutdown();
8937        // Safety: drops once, never accessed again
8938        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8939    }
8940}
8941
8942impl fidl::endpoints::Responder for ZirconGuestManagerLaunchResponder {
8943    type ControlHandle = ZirconGuestManagerControlHandle;
8944
8945    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
8946        &self.control_handle
8947    }
8948
8949    fn drop_without_shutdown(mut self) {
8950        // Safety: drops once, never accessed again due to mem::forget
8951        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8952        // Prevent Drop from running (which would shut down the channel)
8953        std::mem::forget(self);
8954    }
8955}
8956
8957impl ZirconGuestManagerLaunchResponder {
8958    /// Sends a response to the FIDL transaction.
8959    ///
8960    /// Sets the channel to shutdown if an error occurs.
8961    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8962        let _result = self.send_raw(result);
8963        if _result.is_err() {
8964            self.control_handle.shutdown();
8965        }
8966        self.drop_without_shutdown();
8967        _result
8968    }
8969
8970    /// Similar to "send" but does not shutdown the channel if an error occurs.
8971    pub fn send_no_shutdown_on_err(
8972        self,
8973        mut result: Result<(), GuestManagerError>,
8974    ) -> Result<(), fidl::Error> {
8975        let _result = self.send_raw(result);
8976        self.drop_without_shutdown();
8977        _result
8978    }
8979
8980    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
8981        self.control_handle.inner.send::<fidl::encoding::ResultType<
8982            fidl::encoding::EmptyStruct,
8983            GuestManagerError,
8984        >>(
8985            result,
8986            self.tx_id,
8987            0x394a2e29f750323e,
8988            fidl::encoding::DynamicFlags::empty(),
8989        )
8990    }
8991}
8992
8993#[must_use = "FIDL methods require a response to be sent"]
8994#[derive(Debug)]
8995pub struct ZirconGuestManagerForceShutdownResponder {
8996    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
8997    tx_id: u32,
8998}
8999
9000/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9001/// if the responder is dropped without sending a response, so that the client
9002/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9003impl std::ops::Drop for ZirconGuestManagerForceShutdownResponder {
9004    fn drop(&mut self) {
9005        self.control_handle.shutdown();
9006        // Safety: drops once, never accessed again
9007        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9008    }
9009}
9010
9011impl fidl::endpoints::Responder for ZirconGuestManagerForceShutdownResponder {
9012    type ControlHandle = ZirconGuestManagerControlHandle;
9013
9014    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9015        &self.control_handle
9016    }
9017
9018    fn drop_without_shutdown(mut self) {
9019        // Safety: drops once, never accessed again due to mem::forget
9020        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9021        // Prevent Drop from running (which would shut down the channel)
9022        std::mem::forget(self);
9023    }
9024}
9025
9026impl ZirconGuestManagerForceShutdownResponder {
9027    /// Sends a response to the FIDL transaction.
9028    ///
9029    /// Sets the channel to shutdown if an error occurs.
9030    pub fn send(self) -> Result<(), fidl::Error> {
9031        let _result = self.send_raw();
9032        if _result.is_err() {
9033            self.control_handle.shutdown();
9034        }
9035        self.drop_without_shutdown();
9036        _result
9037    }
9038
9039    /// Similar to "send" but does not shutdown the channel if an error occurs.
9040    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9041        let _result = self.send_raw();
9042        self.drop_without_shutdown();
9043        _result
9044    }
9045
9046    fn send_raw(&self) -> Result<(), fidl::Error> {
9047        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9048            (),
9049            self.tx_id,
9050            0x3ad9a012982f872d,
9051            fidl::encoding::DynamicFlags::empty(),
9052        )
9053    }
9054}
9055
9056#[must_use = "FIDL methods require a response to be sent"]
9057#[derive(Debug)]
9058pub struct ZirconGuestManagerConnectResponder {
9059    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9060    tx_id: u32,
9061}
9062
9063/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9064/// if the responder is dropped without sending a response, so that the client
9065/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9066impl std::ops::Drop for ZirconGuestManagerConnectResponder {
9067    fn drop(&mut self) {
9068        self.control_handle.shutdown();
9069        // Safety: drops once, never accessed again
9070        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9071    }
9072}
9073
9074impl fidl::endpoints::Responder for ZirconGuestManagerConnectResponder {
9075    type ControlHandle = ZirconGuestManagerControlHandle;
9076
9077    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9078        &self.control_handle
9079    }
9080
9081    fn drop_without_shutdown(mut self) {
9082        // Safety: drops once, never accessed again due to mem::forget
9083        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9084        // Prevent Drop from running (which would shut down the channel)
9085        std::mem::forget(self);
9086    }
9087}
9088
9089impl ZirconGuestManagerConnectResponder {
9090    /// Sends a response to the FIDL transaction.
9091    ///
9092    /// Sets the channel to shutdown if an error occurs.
9093    pub fn send(self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9094        let _result = self.send_raw(result);
9095        if _result.is_err() {
9096            self.control_handle.shutdown();
9097        }
9098        self.drop_without_shutdown();
9099        _result
9100    }
9101
9102    /// Similar to "send" but does not shutdown the channel if an error occurs.
9103    pub fn send_no_shutdown_on_err(
9104        self,
9105        mut result: Result<(), GuestManagerError>,
9106    ) -> Result<(), fidl::Error> {
9107        let _result = self.send_raw(result);
9108        self.drop_without_shutdown();
9109        _result
9110    }
9111
9112    fn send_raw(&self, mut result: Result<(), GuestManagerError>) -> Result<(), fidl::Error> {
9113        self.control_handle.inner.send::<fidl::encoding::ResultType<
9114            fidl::encoding::EmptyStruct,
9115            GuestManagerError,
9116        >>(
9117            result,
9118            self.tx_id,
9119            0x4e489076e3bb15b4,
9120            fidl::encoding::DynamicFlags::empty(),
9121        )
9122    }
9123}
9124
9125#[must_use = "FIDL methods require a response to be sent"]
9126#[derive(Debug)]
9127pub struct ZirconGuestManagerGetInfoResponder {
9128    control_handle: std::mem::ManuallyDrop<ZirconGuestManagerControlHandle>,
9129    tx_id: u32,
9130}
9131
9132/// Set the the channel to be shutdown (see [`ZirconGuestManagerControlHandle::shutdown`])
9133/// if the responder is dropped without sending a response, so that the client
9134/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9135impl std::ops::Drop for ZirconGuestManagerGetInfoResponder {
9136    fn drop(&mut self) {
9137        self.control_handle.shutdown();
9138        // Safety: drops once, never accessed again
9139        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9140    }
9141}
9142
9143impl fidl::endpoints::Responder for ZirconGuestManagerGetInfoResponder {
9144    type ControlHandle = ZirconGuestManagerControlHandle;
9145
9146    fn control_handle(&self) -> &ZirconGuestManagerControlHandle {
9147        &self.control_handle
9148    }
9149
9150    fn drop_without_shutdown(mut self) {
9151        // Safety: drops once, never accessed again due to mem::forget
9152        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9153        // Prevent Drop from running (which would shut down the channel)
9154        std::mem::forget(self);
9155    }
9156}
9157
9158impl ZirconGuestManagerGetInfoResponder {
9159    /// Sends a response to the FIDL transaction.
9160    ///
9161    /// Sets the channel to shutdown if an error occurs.
9162    pub fn send(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9163        let _result = self.send_raw(guest_info);
9164        if _result.is_err() {
9165            self.control_handle.shutdown();
9166        }
9167        self.drop_without_shutdown();
9168        _result
9169    }
9170
9171    /// Similar to "send" but does not shutdown the channel if an error occurs.
9172    pub fn send_no_shutdown_on_err(self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9173        let _result = self.send_raw(guest_info);
9174        self.drop_without_shutdown();
9175        _result
9176    }
9177
9178    fn send_raw(&self, mut guest_info: &GuestInfo) -> Result<(), fidl::Error> {
9179        self.control_handle.inner.send::<GuestManagerGetInfoResponse>(
9180            (guest_info,),
9181            self.tx_id,
9182            0x76892614aea695dc,
9183            fidl::encoding::DynamicFlags::empty(),
9184        )
9185    }
9186}
9187
9188mod internal {
9189    use super::*;
9190
9191    impl fidl::encoding::ResourceTypeMarker for BlockSpec {
9192        type Borrowed<'a> = &'a mut Self;
9193        fn take_or_borrow<'a>(
9194            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9195        ) -> Self::Borrowed<'a> {
9196            value
9197        }
9198    }
9199
9200    unsafe impl fidl::encoding::TypeMarker for BlockSpec {
9201        type Owned = Self;
9202
9203        #[inline(always)]
9204        fn inline_align(_context: fidl::encoding::Context) -> usize {
9205            8
9206        }
9207
9208        #[inline(always)]
9209        fn inline_size(_context: fidl::encoding::Context) -> usize {
9210            40
9211        }
9212    }
9213
9214    unsafe impl fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9215        for &mut BlockSpec
9216    {
9217        #[inline]
9218        unsafe fn encode(
9219            self,
9220            encoder: &mut fidl::encoding::Encoder<
9221                '_,
9222                fidl::encoding::DefaultFuchsiaResourceDialect,
9223            >,
9224            offset: usize,
9225            _depth: fidl::encoding::Depth,
9226        ) -> fidl::Result<()> {
9227            encoder.debug_check_bounds::<BlockSpec>(offset);
9228            // Delegate to tuple encoding.
9229            fidl::encoding::Encode::<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9230                (
9231                    <fidl::encoding::BoundedString<20> as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
9232                    <BlockMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
9233                    <BlockFormat as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.format),
9234                ),
9235                encoder, offset, _depth
9236            )
9237        }
9238    }
9239    unsafe impl<
9240        T0: fidl::encoding::Encode<
9241                fidl::encoding::BoundedString<20>,
9242                fidl::encoding::DefaultFuchsiaResourceDialect,
9243            >,
9244        T1: fidl::encoding::Encode<BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect>,
9245        T2: fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>,
9246    > fidl::encoding::Encode<BlockSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
9247        for (T0, T1, T2)
9248    {
9249        #[inline]
9250        unsafe fn encode(
9251            self,
9252            encoder: &mut fidl::encoding::Encoder<
9253                '_,
9254                fidl::encoding::DefaultFuchsiaResourceDialect,
9255            >,
9256            offset: usize,
9257            depth: fidl::encoding::Depth,
9258        ) -> fidl::Result<()> {
9259            encoder.debug_check_bounds::<BlockSpec>(offset);
9260            // Zero out padding regions. There's no need to apply masks
9261            // because the unmasked parts will be overwritten by fields.
9262            unsafe {
9263                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9264                (ptr as *mut u64).write_unaligned(0);
9265            }
9266            // Write the fields.
9267            self.0.encode(encoder, offset + 0, depth)?;
9268            self.1.encode(encoder, offset + 16, depth)?;
9269            self.2.encode(encoder, offset + 24, depth)?;
9270            Ok(())
9271        }
9272    }
9273
9274    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockSpec {
9275        #[inline(always)]
9276        fn new_empty() -> Self {
9277            Self {
9278                id: fidl::new_empty!(
9279                    fidl::encoding::BoundedString<20>,
9280                    fidl::encoding::DefaultFuchsiaResourceDialect
9281                ),
9282                mode: fidl::new_empty!(BlockMode, fidl::encoding::DefaultFuchsiaResourceDialect),
9283                format: fidl::new_empty!(
9284                    BlockFormat,
9285                    fidl::encoding::DefaultFuchsiaResourceDialect
9286                ),
9287            }
9288        }
9289
9290        #[inline]
9291        unsafe fn decode(
9292            &mut self,
9293            decoder: &mut fidl::encoding::Decoder<
9294                '_,
9295                fidl::encoding::DefaultFuchsiaResourceDialect,
9296            >,
9297            offset: usize,
9298            _depth: fidl::encoding::Depth,
9299        ) -> fidl::Result<()> {
9300            decoder.debug_check_bounds::<Self>(offset);
9301            // Verify that padding bytes are zero.
9302            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9303            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9304            let mask = 0xffffffff00000000u64;
9305            let maskedval = padval & mask;
9306            if maskedval != 0 {
9307                return Err(fidl::Error::NonZeroPadding {
9308                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9309                });
9310            }
9311            fidl::decode!(
9312                fidl::encoding::BoundedString<20>,
9313                fidl::encoding::DefaultFuchsiaResourceDialect,
9314                &mut self.id,
9315                decoder,
9316                offset + 0,
9317                _depth
9318            )?;
9319            fidl::decode!(
9320                BlockMode,
9321                fidl::encoding::DefaultFuchsiaResourceDialect,
9322                &mut self.mode,
9323                decoder,
9324                offset + 16,
9325                _depth
9326            )?;
9327            fidl::decode!(
9328                BlockFormat,
9329                fidl::encoding::DefaultFuchsiaResourceDialect,
9330                &mut self.format,
9331                decoder,
9332                offset + 24,
9333                _depth
9334            )?;
9335            Ok(())
9336        }
9337    }
9338
9339    impl fidl::encoding::ResourceTypeMarker for GuestGetBalloonControllerRequest {
9340        type Borrowed<'a> = &'a mut Self;
9341        fn take_or_borrow<'a>(
9342            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9343        ) -> Self::Borrowed<'a> {
9344            value
9345        }
9346    }
9347
9348    unsafe impl fidl::encoding::TypeMarker for GuestGetBalloonControllerRequest {
9349        type Owned = Self;
9350
9351        #[inline(always)]
9352        fn inline_align(_context: fidl::encoding::Context) -> usize {
9353            4
9354        }
9355
9356        #[inline(always)]
9357        fn inline_size(_context: fidl::encoding::Context) -> usize {
9358            4
9359        }
9360    }
9361
9362    unsafe impl
9363        fidl::encoding::Encode<
9364            GuestGetBalloonControllerRequest,
9365            fidl::encoding::DefaultFuchsiaResourceDialect,
9366        > for &mut GuestGetBalloonControllerRequest
9367    {
9368        #[inline]
9369        unsafe fn encode(
9370            self,
9371            encoder: &mut fidl::encoding::Encoder<
9372                '_,
9373                fidl::encoding::DefaultFuchsiaResourceDialect,
9374            >,
9375            offset: usize,
9376            _depth: fidl::encoding::Depth,
9377        ) -> fidl::Result<()> {
9378            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9379            // Delegate to tuple encoding.
9380            fidl::encoding::Encode::<GuestGetBalloonControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9381                (
9382                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9383                ),
9384                encoder, offset, _depth
9385            )
9386        }
9387    }
9388    unsafe impl<
9389        T0: fidl::encoding::Encode<
9390                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9391                fidl::encoding::DefaultFuchsiaResourceDialect,
9392            >,
9393    >
9394        fidl::encoding::Encode<
9395            GuestGetBalloonControllerRequest,
9396            fidl::encoding::DefaultFuchsiaResourceDialect,
9397        > for (T0,)
9398    {
9399        #[inline]
9400        unsafe fn encode(
9401            self,
9402            encoder: &mut fidl::encoding::Encoder<
9403                '_,
9404                fidl::encoding::DefaultFuchsiaResourceDialect,
9405            >,
9406            offset: usize,
9407            depth: fidl::encoding::Depth,
9408        ) -> fidl::Result<()> {
9409            encoder.debug_check_bounds::<GuestGetBalloonControllerRequest>(offset);
9410            // Zero out padding regions. There's no need to apply masks
9411            // because the unmasked parts will be overwritten by fields.
9412            // Write the fields.
9413            self.0.encode(encoder, offset + 0, depth)?;
9414            Ok(())
9415        }
9416    }
9417
9418    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9419        for GuestGetBalloonControllerRequest
9420    {
9421        #[inline(always)]
9422        fn new_empty() -> Self {
9423            Self {
9424                controller: fidl::new_empty!(
9425                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9426                    fidl::encoding::DefaultFuchsiaResourceDialect
9427                ),
9428            }
9429        }
9430
9431        #[inline]
9432        unsafe fn decode(
9433            &mut self,
9434            decoder: &mut fidl::encoding::Decoder<
9435                '_,
9436                fidl::encoding::DefaultFuchsiaResourceDialect,
9437            >,
9438            offset: usize,
9439            _depth: fidl::encoding::Depth,
9440        ) -> fidl::Result<()> {
9441            decoder.debug_check_bounds::<Self>(offset);
9442            // Verify that padding bytes are zero.
9443            fidl::decode!(
9444                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BalloonControllerMarker>>,
9445                fidl::encoding::DefaultFuchsiaResourceDialect,
9446                &mut self.controller,
9447                decoder,
9448                offset + 0,
9449                _depth
9450            )?;
9451            Ok(())
9452        }
9453    }
9454
9455    impl fidl::encoding::ResourceTypeMarker for GuestGetHostVsockEndpointRequest {
9456        type Borrowed<'a> = &'a mut Self;
9457        fn take_or_borrow<'a>(
9458            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9459        ) -> Self::Borrowed<'a> {
9460            value
9461        }
9462    }
9463
9464    unsafe impl fidl::encoding::TypeMarker for GuestGetHostVsockEndpointRequest {
9465        type Owned = Self;
9466
9467        #[inline(always)]
9468        fn inline_align(_context: fidl::encoding::Context) -> usize {
9469            4
9470        }
9471
9472        #[inline(always)]
9473        fn inline_size(_context: fidl::encoding::Context) -> usize {
9474            4
9475        }
9476    }
9477
9478    unsafe impl
9479        fidl::encoding::Encode<
9480            GuestGetHostVsockEndpointRequest,
9481            fidl::encoding::DefaultFuchsiaResourceDialect,
9482        > for &mut GuestGetHostVsockEndpointRequest
9483    {
9484        #[inline]
9485        unsafe fn encode(
9486            self,
9487            encoder: &mut fidl::encoding::Encoder<
9488                '_,
9489                fidl::encoding::DefaultFuchsiaResourceDialect,
9490            >,
9491            offset: usize,
9492            _depth: fidl::encoding::Depth,
9493        ) -> fidl::Result<()> {
9494            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9495            // Delegate to tuple encoding.
9496            fidl::encoding::Encode::<GuestGetHostVsockEndpointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9497                (
9498                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoint),
9499                ),
9500                encoder, offset, _depth
9501            )
9502        }
9503    }
9504    unsafe impl<
9505        T0: fidl::encoding::Encode<
9506                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9507                fidl::encoding::DefaultFuchsiaResourceDialect,
9508            >,
9509    >
9510        fidl::encoding::Encode<
9511            GuestGetHostVsockEndpointRequest,
9512            fidl::encoding::DefaultFuchsiaResourceDialect,
9513        > for (T0,)
9514    {
9515        #[inline]
9516        unsafe fn encode(
9517            self,
9518            encoder: &mut fidl::encoding::Encoder<
9519                '_,
9520                fidl::encoding::DefaultFuchsiaResourceDialect,
9521            >,
9522            offset: usize,
9523            depth: fidl::encoding::Depth,
9524        ) -> fidl::Result<()> {
9525            encoder.debug_check_bounds::<GuestGetHostVsockEndpointRequest>(offset);
9526            // Zero out padding regions. There's no need to apply masks
9527            // because the unmasked parts will be overwritten by fields.
9528            // Write the fields.
9529            self.0.encode(encoder, offset + 0, depth)?;
9530            Ok(())
9531        }
9532    }
9533
9534    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9535        for GuestGetHostVsockEndpointRequest
9536    {
9537        #[inline(always)]
9538        fn new_empty() -> Self {
9539            Self {
9540                endpoint: fidl::new_empty!(
9541                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9542                    fidl::encoding::DefaultFuchsiaResourceDialect
9543                ),
9544            }
9545        }
9546
9547        #[inline]
9548        unsafe fn decode(
9549            &mut self,
9550            decoder: &mut fidl::encoding::Decoder<
9551                '_,
9552                fidl::encoding::DefaultFuchsiaResourceDialect,
9553            >,
9554            offset: usize,
9555            _depth: fidl::encoding::Depth,
9556        ) -> fidl::Result<()> {
9557            decoder.debug_check_bounds::<Self>(offset);
9558            // Verify that padding bytes are zero.
9559            fidl::decode!(
9560                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HostVsockEndpointMarker>>,
9561                fidl::encoding::DefaultFuchsiaResourceDialect,
9562                &mut self.endpoint,
9563                decoder,
9564                offset + 0,
9565                _depth
9566            )?;
9567            Ok(())
9568        }
9569    }
9570
9571    impl fidl::encoding::ResourceTypeMarker for GuestGetMemControllerRequest {
9572        type Borrowed<'a> = &'a mut Self;
9573        fn take_or_borrow<'a>(
9574            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9575        ) -> Self::Borrowed<'a> {
9576            value
9577        }
9578    }
9579
9580    unsafe impl fidl::encoding::TypeMarker for GuestGetMemControllerRequest {
9581        type Owned = Self;
9582
9583        #[inline(always)]
9584        fn inline_align(_context: fidl::encoding::Context) -> usize {
9585            4
9586        }
9587
9588        #[inline(always)]
9589        fn inline_size(_context: fidl::encoding::Context) -> usize {
9590            4
9591        }
9592    }
9593
9594    unsafe impl
9595        fidl::encoding::Encode<
9596            GuestGetMemControllerRequest,
9597            fidl::encoding::DefaultFuchsiaResourceDialect,
9598        > for &mut GuestGetMemControllerRequest
9599    {
9600        #[inline]
9601        unsafe fn encode(
9602            self,
9603            encoder: &mut fidl::encoding::Encoder<
9604                '_,
9605                fidl::encoding::DefaultFuchsiaResourceDialect,
9606            >,
9607            offset: usize,
9608            _depth: fidl::encoding::Depth,
9609        ) -> fidl::Result<()> {
9610            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9611            // Delegate to tuple encoding.
9612            fidl::encoding::Encode::<GuestGetMemControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9613                (
9614                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
9615                ),
9616                encoder, offset, _depth
9617            )
9618        }
9619    }
9620    unsafe impl<
9621        T0: fidl::encoding::Encode<
9622                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9623                fidl::encoding::DefaultFuchsiaResourceDialect,
9624            >,
9625    >
9626        fidl::encoding::Encode<
9627            GuestGetMemControllerRequest,
9628            fidl::encoding::DefaultFuchsiaResourceDialect,
9629        > for (T0,)
9630    {
9631        #[inline]
9632        unsafe fn encode(
9633            self,
9634            encoder: &mut fidl::encoding::Encoder<
9635                '_,
9636                fidl::encoding::DefaultFuchsiaResourceDialect,
9637            >,
9638            offset: usize,
9639            depth: fidl::encoding::Depth,
9640        ) -> fidl::Result<()> {
9641            encoder.debug_check_bounds::<GuestGetMemControllerRequest>(offset);
9642            // Zero out padding regions. There's no need to apply masks
9643            // because the unmasked parts will be overwritten by fields.
9644            // Write the fields.
9645            self.0.encode(encoder, offset + 0, depth)?;
9646            Ok(())
9647        }
9648    }
9649
9650    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9651        for GuestGetMemControllerRequest
9652    {
9653        #[inline(always)]
9654        fn new_empty() -> Self {
9655            Self {
9656                controller: fidl::new_empty!(
9657                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9658                    fidl::encoding::DefaultFuchsiaResourceDialect
9659                ),
9660            }
9661        }
9662
9663        #[inline]
9664        unsafe fn decode(
9665            &mut self,
9666            decoder: &mut fidl::encoding::Decoder<
9667                '_,
9668                fidl::encoding::DefaultFuchsiaResourceDialect,
9669            >,
9670            offset: usize,
9671            _depth: fidl::encoding::Depth,
9672        ) -> fidl::Result<()> {
9673            decoder.debug_check_bounds::<Self>(offset);
9674            // Verify that padding bytes are zero.
9675            fidl::decode!(
9676                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MemControllerMarker>>,
9677                fidl::encoding::DefaultFuchsiaResourceDialect,
9678                &mut self.controller,
9679                decoder,
9680                offset + 0,
9681                _depth
9682            )?;
9683            Ok(())
9684        }
9685    }
9686
9687    impl fidl::encoding::ResourceTypeMarker for GuestGetSerialResponse {
9688        type Borrowed<'a> = &'a mut Self;
9689        fn take_or_borrow<'a>(
9690            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9691        ) -> Self::Borrowed<'a> {
9692            value
9693        }
9694    }
9695
9696    unsafe impl fidl::encoding::TypeMarker for GuestGetSerialResponse {
9697        type Owned = Self;
9698
9699        #[inline(always)]
9700        fn inline_align(_context: fidl::encoding::Context) -> usize {
9701            4
9702        }
9703
9704        #[inline(always)]
9705        fn inline_size(_context: fidl::encoding::Context) -> usize {
9706            4
9707        }
9708    }
9709
9710    unsafe impl
9711        fidl::encoding::Encode<
9712            GuestGetSerialResponse,
9713            fidl::encoding::DefaultFuchsiaResourceDialect,
9714        > for &mut GuestGetSerialResponse
9715    {
9716        #[inline]
9717        unsafe fn encode(
9718            self,
9719            encoder: &mut fidl::encoding::Encoder<
9720                '_,
9721                fidl::encoding::DefaultFuchsiaResourceDialect,
9722            >,
9723            offset: usize,
9724            _depth: fidl::encoding::Depth,
9725        ) -> fidl::Result<()> {
9726            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9727            // Delegate to tuple encoding.
9728            fidl::encoding::Encode::<
9729                GuestGetSerialResponse,
9730                fidl::encoding::DefaultFuchsiaResourceDialect,
9731            >::encode(
9732                (<fidl::encoding::HandleType<
9733                    fidl::Socket,
9734                    { fidl::ObjectType::SOCKET.into_raw() },
9735                    2147483648,
9736                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9737                    &mut self.socket
9738                ),),
9739                encoder,
9740                offset,
9741                _depth,
9742            )
9743        }
9744    }
9745    unsafe impl<
9746        T0: fidl::encoding::Encode<
9747                fidl::encoding::HandleType<
9748                    fidl::Socket,
9749                    { fidl::ObjectType::SOCKET.into_raw() },
9750                    2147483648,
9751                >,
9752                fidl::encoding::DefaultFuchsiaResourceDialect,
9753            >,
9754    >
9755        fidl::encoding::Encode<
9756            GuestGetSerialResponse,
9757            fidl::encoding::DefaultFuchsiaResourceDialect,
9758        > for (T0,)
9759    {
9760        #[inline]
9761        unsafe fn encode(
9762            self,
9763            encoder: &mut fidl::encoding::Encoder<
9764                '_,
9765                fidl::encoding::DefaultFuchsiaResourceDialect,
9766            >,
9767            offset: usize,
9768            depth: fidl::encoding::Depth,
9769        ) -> fidl::Result<()> {
9770            encoder.debug_check_bounds::<GuestGetSerialResponse>(offset);
9771            // Zero out padding regions. There's no need to apply masks
9772            // because the unmasked parts will be overwritten by fields.
9773            // Write the fields.
9774            self.0.encode(encoder, offset + 0, depth)?;
9775            Ok(())
9776        }
9777    }
9778
9779    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9780        for GuestGetSerialResponse
9781    {
9782        #[inline(always)]
9783        fn new_empty() -> Self {
9784            Self {
9785                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9786            }
9787        }
9788
9789        #[inline]
9790        unsafe fn decode(
9791            &mut self,
9792            decoder: &mut fidl::encoding::Decoder<
9793                '_,
9794                fidl::encoding::DefaultFuchsiaResourceDialect,
9795            >,
9796            offset: usize,
9797            _depth: fidl::encoding::Depth,
9798        ) -> fidl::Result<()> {
9799            decoder.debug_check_bounds::<Self>(offset);
9800            // Verify that padding bytes are zero.
9801            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
9802            Ok(())
9803        }
9804    }
9805
9806    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleBindRequest {
9807        type Borrowed<'a> = &'a mut Self;
9808        fn take_or_borrow<'a>(
9809            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9810        ) -> Self::Borrowed<'a> {
9811            value
9812        }
9813    }
9814
9815    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleBindRequest {
9816        type Owned = Self;
9817
9818        #[inline(always)]
9819        fn inline_align(_context: fidl::encoding::Context) -> usize {
9820            4
9821        }
9822
9823        #[inline(always)]
9824        fn inline_size(_context: fidl::encoding::Context) -> usize {
9825            4
9826        }
9827    }
9828
9829    unsafe impl
9830        fidl::encoding::Encode<
9831            GuestLifecycleBindRequest,
9832            fidl::encoding::DefaultFuchsiaResourceDialect,
9833        > for &mut GuestLifecycleBindRequest
9834    {
9835        #[inline]
9836        unsafe fn encode(
9837            self,
9838            encoder: &mut fidl::encoding::Encoder<
9839                '_,
9840                fidl::encoding::DefaultFuchsiaResourceDialect,
9841            >,
9842            offset: usize,
9843            _depth: fidl::encoding::Depth,
9844        ) -> fidl::Result<()> {
9845            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9846            // Delegate to tuple encoding.
9847            fidl::encoding::Encode::<GuestLifecycleBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9848                (
9849                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest),
9850                ),
9851                encoder, offset, _depth
9852            )
9853        }
9854    }
9855    unsafe impl<
9856        T0: fidl::encoding::Encode<
9857                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9858                fidl::encoding::DefaultFuchsiaResourceDialect,
9859            >,
9860    >
9861        fidl::encoding::Encode<
9862            GuestLifecycleBindRequest,
9863            fidl::encoding::DefaultFuchsiaResourceDialect,
9864        > for (T0,)
9865    {
9866        #[inline]
9867        unsafe fn encode(
9868            self,
9869            encoder: &mut fidl::encoding::Encoder<
9870                '_,
9871                fidl::encoding::DefaultFuchsiaResourceDialect,
9872            >,
9873            offset: usize,
9874            depth: fidl::encoding::Depth,
9875        ) -> fidl::Result<()> {
9876            encoder.debug_check_bounds::<GuestLifecycleBindRequest>(offset);
9877            // Zero out padding regions. There's no need to apply masks
9878            // because the unmasked parts will be overwritten by fields.
9879            // Write the fields.
9880            self.0.encode(encoder, offset + 0, depth)?;
9881            Ok(())
9882        }
9883    }
9884
9885    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9886        for GuestLifecycleBindRequest
9887    {
9888        #[inline(always)]
9889        fn new_empty() -> Self {
9890            Self {
9891                guest: fidl::new_empty!(
9892                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9893                    fidl::encoding::DefaultFuchsiaResourceDialect
9894                ),
9895            }
9896        }
9897
9898        #[inline]
9899        unsafe fn decode(
9900            &mut self,
9901            decoder: &mut fidl::encoding::Decoder<
9902                '_,
9903                fidl::encoding::DefaultFuchsiaResourceDialect,
9904            >,
9905            offset: usize,
9906            _depth: fidl::encoding::Depth,
9907        ) -> fidl::Result<()> {
9908            decoder.debug_check_bounds::<Self>(offset);
9909            // Verify that padding bytes are zero.
9910            fidl::decode!(
9911                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
9912                fidl::encoding::DefaultFuchsiaResourceDialect,
9913                &mut self.guest,
9914                decoder,
9915                offset + 0,
9916                _depth
9917            )?;
9918            Ok(())
9919        }
9920    }
9921
9922    impl fidl::encoding::ResourceTypeMarker for GuestLifecycleCreateRequest {
9923        type Borrowed<'a> = &'a mut Self;
9924        fn take_or_borrow<'a>(
9925            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9926        ) -> Self::Borrowed<'a> {
9927            value
9928        }
9929    }
9930
9931    unsafe impl fidl::encoding::TypeMarker for GuestLifecycleCreateRequest {
9932        type Owned = Self;
9933
9934        #[inline(always)]
9935        fn inline_align(_context: fidl::encoding::Context) -> usize {
9936            8
9937        }
9938
9939        #[inline(always)]
9940        fn inline_size(_context: fidl::encoding::Context) -> usize {
9941            16
9942        }
9943    }
9944
9945    unsafe impl
9946        fidl::encoding::Encode<
9947            GuestLifecycleCreateRequest,
9948            fidl::encoding::DefaultFuchsiaResourceDialect,
9949        > for &mut GuestLifecycleCreateRequest
9950    {
9951        #[inline]
9952        unsafe fn encode(
9953            self,
9954            encoder: &mut fidl::encoding::Encoder<
9955                '_,
9956                fidl::encoding::DefaultFuchsiaResourceDialect,
9957            >,
9958            offset: usize,
9959            _depth: fidl::encoding::Depth,
9960        ) -> fidl::Result<()> {
9961            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
9962            // Delegate to tuple encoding.
9963            fidl::encoding::Encode::<
9964                GuestLifecycleCreateRequest,
9965                fidl::encoding::DefaultFuchsiaResourceDialect,
9966            >::encode(
9967                (<GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9968                    &mut self.guest_config,
9969                ),),
9970                encoder,
9971                offset,
9972                _depth,
9973            )
9974        }
9975    }
9976    unsafe impl<
9977        T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
9978    >
9979        fidl::encoding::Encode<
9980            GuestLifecycleCreateRequest,
9981            fidl::encoding::DefaultFuchsiaResourceDialect,
9982        > for (T0,)
9983    {
9984        #[inline]
9985        unsafe fn encode(
9986            self,
9987            encoder: &mut fidl::encoding::Encoder<
9988                '_,
9989                fidl::encoding::DefaultFuchsiaResourceDialect,
9990            >,
9991            offset: usize,
9992            depth: fidl::encoding::Depth,
9993        ) -> fidl::Result<()> {
9994            encoder.debug_check_bounds::<GuestLifecycleCreateRequest>(offset);
9995            // Zero out padding regions. There's no need to apply masks
9996            // because the unmasked parts will be overwritten by fields.
9997            // Write the fields.
9998            self.0.encode(encoder, offset + 0, depth)?;
9999            Ok(())
10000        }
10001    }
10002
10003    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10004        for GuestLifecycleCreateRequest
10005    {
10006        #[inline(always)]
10007        fn new_empty() -> Self {
10008            Self {
10009                guest_config: fidl::new_empty!(
10010                    GuestConfig,
10011                    fidl::encoding::DefaultFuchsiaResourceDialect
10012                ),
10013            }
10014        }
10015
10016        #[inline]
10017        unsafe fn decode(
10018            &mut self,
10019            decoder: &mut fidl::encoding::Decoder<
10020                '_,
10021                fidl::encoding::DefaultFuchsiaResourceDialect,
10022            >,
10023            offset: usize,
10024            _depth: fidl::encoding::Depth,
10025        ) -> fidl::Result<()> {
10026            decoder.debug_check_bounds::<Self>(offset);
10027            // Verify that padding bytes are zero.
10028            fidl::decode!(
10029                GuestConfig,
10030                fidl::encoding::DefaultFuchsiaResourceDialect,
10031                &mut self.guest_config,
10032                decoder,
10033                offset + 0,
10034                _depth
10035            )?;
10036            Ok(())
10037        }
10038    }
10039
10040    impl fidl::encoding::ResourceTypeMarker for GuestManagerConnectRequest {
10041        type Borrowed<'a> = &'a mut Self;
10042        fn take_or_borrow<'a>(
10043            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10044        ) -> Self::Borrowed<'a> {
10045            value
10046        }
10047    }
10048
10049    unsafe impl fidl::encoding::TypeMarker for GuestManagerConnectRequest {
10050        type Owned = Self;
10051
10052        #[inline(always)]
10053        fn inline_align(_context: fidl::encoding::Context) -> usize {
10054            4
10055        }
10056
10057        #[inline(always)]
10058        fn inline_size(_context: fidl::encoding::Context) -> usize {
10059            4
10060        }
10061    }
10062
10063    unsafe impl
10064        fidl::encoding::Encode<
10065            GuestManagerConnectRequest,
10066            fidl::encoding::DefaultFuchsiaResourceDialect,
10067        > for &mut GuestManagerConnectRequest
10068    {
10069        #[inline]
10070        unsafe fn encode(
10071            self,
10072            encoder: &mut fidl::encoding::Encoder<
10073                '_,
10074                fidl::encoding::DefaultFuchsiaResourceDialect,
10075            >,
10076            offset: usize,
10077            _depth: fidl::encoding::Depth,
10078        ) -> fidl::Result<()> {
10079            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
10080            // Delegate to tuple encoding.
10081            fidl::encoding::Encode::<GuestManagerConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10082                (
10083                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10084                ),
10085                encoder, offset, _depth
10086            )
10087        }
10088    }
10089    unsafe impl<
10090        T0: fidl::encoding::Encode<
10091                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10092                fidl::encoding::DefaultFuchsiaResourceDialect,
10093            >,
10094    >
10095        fidl::encoding::Encode<
10096            GuestManagerConnectRequest,
10097            fidl::encoding::DefaultFuchsiaResourceDialect,
10098        > for (T0,)
10099    {
10100        #[inline]
10101        unsafe fn encode(
10102            self,
10103            encoder: &mut fidl::encoding::Encoder<
10104                '_,
10105                fidl::encoding::DefaultFuchsiaResourceDialect,
10106            >,
10107            offset: usize,
10108            depth: fidl::encoding::Depth,
10109        ) -> fidl::Result<()> {
10110            encoder.debug_check_bounds::<GuestManagerConnectRequest>(offset);
10111            // Zero out padding regions. There's no need to apply masks
10112            // because the unmasked parts will be overwritten by fields.
10113            // Write the fields.
10114            self.0.encode(encoder, offset + 0, depth)?;
10115            Ok(())
10116        }
10117    }
10118
10119    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10120        for GuestManagerConnectRequest
10121    {
10122        #[inline(always)]
10123        fn new_empty() -> Self {
10124            Self {
10125                controller: fidl::new_empty!(
10126                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10127                    fidl::encoding::DefaultFuchsiaResourceDialect
10128                ),
10129            }
10130        }
10131
10132        #[inline]
10133        unsafe fn decode(
10134            &mut self,
10135            decoder: &mut fidl::encoding::Decoder<
10136                '_,
10137                fidl::encoding::DefaultFuchsiaResourceDialect,
10138            >,
10139            offset: usize,
10140            _depth: fidl::encoding::Depth,
10141        ) -> fidl::Result<()> {
10142            decoder.debug_check_bounds::<Self>(offset);
10143            // Verify that padding bytes are zero.
10144            fidl::decode!(
10145                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10146                fidl::encoding::DefaultFuchsiaResourceDialect,
10147                &mut self.controller,
10148                decoder,
10149                offset + 0,
10150                _depth
10151            )?;
10152            Ok(())
10153        }
10154    }
10155
10156    impl fidl::encoding::ResourceTypeMarker for GuestManagerGetInfoResponse {
10157        type Borrowed<'a> = &'a mut Self;
10158        fn take_or_borrow<'a>(
10159            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10160        ) -> Self::Borrowed<'a> {
10161            value
10162        }
10163    }
10164
10165    unsafe impl fidl::encoding::TypeMarker for GuestManagerGetInfoResponse {
10166        type Owned = Self;
10167
10168        #[inline(always)]
10169        fn inline_align(_context: fidl::encoding::Context) -> usize {
10170            8
10171        }
10172
10173        #[inline(always)]
10174        fn inline_size(_context: fidl::encoding::Context) -> usize {
10175            16
10176        }
10177    }
10178
10179    unsafe impl
10180        fidl::encoding::Encode<
10181            GuestManagerGetInfoResponse,
10182            fidl::encoding::DefaultFuchsiaResourceDialect,
10183        > for &mut GuestManagerGetInfoResponse
10184    {
10185        #[inline]
10186        unsafe fn encode(
10187            self,
10188            encoder: &mut fidl::encoding::Encoder<
10189                '_,
10190                fidl::encoding::DefaultFuchsiaResourceDialect,
10191            >,
10192            offset: usize,
10193            _depth: fidl::encoding::Depth,
10194        ) -> fidl::Result<()> {
10195            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10196            // Delegate to tuple encoding.
10197            fidl::encoding::Encode::<
10198                GuestManagerGetInfoResponse,
10199                fidl::encoding::DefaultFuchsiaResourceDialect,
10200            >::encode(
10201                (<GuestInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.guest_info),),
10202                encoder,
10203                offset,
10204                _depth,
10205            )
10206        }
10207    }
10208    unsafe impl<
10209        T0: fidl::encoding::Encode<GuestInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10210    >
10211        fidl::encoding::Encode<
10212            GuestManagerGetInfoResponse,
10213            fidl::encoding::DefaultFuchsiaResourceDialect,
10214        > for (T0,)
10215    {
10216        #[inline]
10217        unsafe fn encode(
10218            self,
10219            encoder: &mut fidl::encoding::Encoder<
10220                '_,
10221                fidl::encoding::DefaultFuchsiaResourceDialect,
10222            >,
10223            offset: usize,
10224            depth: fidl::encoding::Depth,
10225        ) -> fidl::Result<()> {
10226            encoder.debug_check_bounds::<GuestManagerGetInfoResponse>(offset);
10227            // Zero out padding regions. There's no need to apply masks
10228            // because the unmasked parts will be overwritten by fields.
10229            // Write the fields.
10230            self.0.encode(encoder, offset + 0, depth)?;
10231            Ok(())
10232        }
10233    }
10234
10235    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10236        for GuestManagerGetInfoResponse
10237    {
10238        #[inline(always)]
10239        fn new_empty() -> Self {
10240            Self {
10241                guest_info: fidl::new_empty!(
10242                    GuestInfo,
10243                    fidl::encoding::DefaultFuchsiaResourceDialect
10244                ),
10245            }
10246        }
10247
10248        #[inline]
10249        unsafe fn decode(
10250            &mut self,
10251            decoder: &mut fidl::encoding::Decoder<
10252                '_,
10253                fidl::encoding::DefaultFuchsiaResourceDialect,
10254            >,
10255            offset: usize,
10256            _depth: fidl::encoding::Depth,
10257        ) -> fidl::Result<()> {
10258            decoder.debug_check_bounds::<Self>(offset);
10259            // Verify that padding bytes are zero.
10260            fidl::decode!(
10261                GuestInfo,
10262                fidl::encoding::DefaultFuchsiaResourceDialect,
10263                &mut self.guest_info,
10264                decoder,
10265                offset + 0,
10266                _depth
10267            )?;
10268            Ok(())
10269        }
10270    }
10271
10272    impl fidl::encoding::ResourceTypeMarker for GuestManagerLaunchRequest {
10273        type Borrowed<'a> = &'a mut Self;
10274        fn take_or_borrow<'a>(
10275            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10276        ) -> Self::Borrowed<'a> {
10277            value
10278        }
10279    }
10280
10281    unsafe impl fidl::encoding::TypeMarker for GuestManagerLaunchRequest {
10282        type Owned = Self;
10283
10284        #[inline(always)]
10285        fn inline_align(_context: fidl::encoding::Context) -> usize {
10286            8
10287        }
10288
10289        #[inline(always)]
10290        fn inline_size(_context: fidl::encoding::Context) -> usize {
10291            24
10292        }
10293    }
10294
10295    unsafe impl
10296        fidl::encoding::Encode<
10297            GuestManagerLaunchRequest,
10298            fidl::encoding::DefaultFuchsiaResourceDialect,
10299        > for &mut GuestManagerLaunchRequest
10300    {
10301        #[inline]
10302        unsafe fn encode(
10303            self,
10304            encoder: &mut fidl::encoding::Encoder<
10305                '_,
10306                fidl::encoding::DefaultFuchsiaResourceDialect,
10307            >,
10308            offset: usize,
10309            _depth: fidl::encoding::Depth,
10310        ) -> fidl::Result<()> {
10311            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10312            // Delegate to tuple encoding.
10313            fidl::encoding::Encode::<GuestManagerLaunchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10314                (
10315                    <GuestConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest_config),
10316                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
10317                ),
10318                encoder, offset, _depth
10319            )
10320        }
10321    }
10322    unsafe impl<
10323        T0: fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
10324        T1: fidl::encoding::Encode<
10325                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10326                fidl::encoding::DefaultFuchsiaResourceDialect,
10327            >,
10328    >
10329        fidl::encoding::Encode<
10330            GuestManagerLaunchRequest,
10331            fidl::encoding::DefaultFuchsiaResourceDialect,
10332        > for (T0, T1)
10333    {
10334        #[inline]
10335        unsafe fn encode(
10336            self,
10337            encoder: &mut fidl::encoding::Encoder<
10338                '_,
10339                fidl::encoding::DefaultFuchsiaResourceDialect,
10340            >,
10341            offset: usize,
10342            depth: fidl::encoding::Depth,
10343        ) -> fidl::Result<()> {
10344            encoder.debug_check_bounds::<GuestManagerLaunchRequest>(offset);
10345            // Zero out padding regions. There's no need to apply masks
10346            // because the unmasked parts will be overwritten by fields.
10347            unsafe {
10348                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10349                (ptr as *mut u64).write_unaligned(0);
10350            }
10351            // Write the fields.
10352            self.0.encode(encoder, offset + 0, depth)?;
10353            self.1.encode(encoder, offset + 16, depth)?;
10354            Ok(())
10355        }
10356    }
10357
10358    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10359        for GuestManagerLaunchRequest
10360    {
10361        #[inline(always)]
10362        fn new_empty() -> Self {
10363            Self {
10364                guest_config: fidl::new_empty!(
10365                    GuestConfig,
10366                    fidl::encoding::DefaultFuchsiaResourceDialect
10367                ),
10368                controller: fidl::new_empty!(
10369                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10370                    fidl::encoding::DefaultFuchsiaResourceDialect
10371                ),
10372            }
10373        }
10374
10375        #[inline]
10376        unsafe fn decode(
10377            &mut self,
10378            decoder: &mut fidl::encoding::Decoder<
10379                '_,
10380                fidl::encoding::DefaultFuchsiaResourceDialect,
10381            >,
10382            offset: usize,
10383            _depth: fidl::encoding::Depth,
10384        ) -> fidl::Result<()> {
10385            decoder.debug_check_bounds::<Self>(offset);
10386            // Verify that padding bytes are zero.
10387            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10388            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10389            let mask = 0xffffffff00000000u64;
10390            let maskedval = padval & mask;
10391            if maskedval != 0 {
10392                return Err(fidl::Error::NonZeroPadding {
10393                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10394                });
10395            }
10396            fidl::decode!(
10397                GuestConfig,
10398                fidl::encoding::DefaultFuchsiaResourceDialect,
10399                &mut self.guest_config,
10400                decoder,
10401                offset + 0,
10402                _depth
10403            )?;
10404            fidl::decode!(
10405                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<GuestMarker>>,
10406                fidl::encoding::DefaultFuchsiaResourceDialect,
10407                &mut self.controller,
10408                decoder,
10409                offset + 16,
10410                _depth
10411            )?;
10412            Ok(())
10413        }
10414    }
10415
10416    impl fidl::encoding::ResourceTypeMarker for GuestGetConsoleResponse {
10417        type Borrowed<'a> = &'a mut Self;
10418        fn take_or_borrow<'a>(
10419            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10420        ) -> Self::Borrowed<'a> {
10421            value
10422        }
10423    }
10424
10425    unsafe impl fidl::encoding::TypeMarker for GuestGetConsoleResponse {
10426        type Owned = Self;
10427
10428        #[inline(always)]
10429        fn inline_align(_context: fidl::encoding::Context) -> usize {
10430            4
10431        }
10432
10433        #[inline(always)]
10434        fn inline_size(_context: fidl::encoding::Context) -> usize {
10435            4
10436        }
10437    }
10438
10439    unsafe impl
10440        fidl::encoding::Encode<
10441            GuestGetConsoleResponse,
10442            fidl::encoding::DefaultFuchsiaResourceDialect,
10443        > for &mut GuestGetConsoleResponse
10444    {
10445        #[inline]
10446        unsafe fn encode(
10447            self,
10448            encoder: &mut fidl::encoding::Encoder<
10449                '_,
10450                fidl::encoding::DefaultFuchsiaResourceDialect,
10451            >,
10452            offset: usize,
10453            _depth: fidl::encoding::Depth,
10454        ) -> fidl::Result<()> {
10455            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10456            // Delegate to tuple encoding.
10457            fidl::encoding::Encode::<
10458                GuestGetConsoleResponse,
10459                fidl::encoding::DefaultFuchsiaResourceDialect,
10460            >::encode(
10461                (<fidl::encoding::HandleType<
10462                    fidl::Socket,
10463                    { fidl::ObjectType::SOCKET.into_raw() },
10464                    2147483648,
10465                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10466                    &mut self.socket
10467                ),),
10468                encoder,
10469                offset,
10470                _depth,
10471            )
10472        }
10473    }
10474    unsafe impl<
10475        T0: fidl::encoding::Encode<
10476                fidl::encoding::HandleType<
10477                    fidl::Socket,
10478                    { fidl::ObjectType::SOCKET.into_raw() },
10479                    2147483648,
10480                >,
10481                fidl::encoding::DefaultFuchsiaResourceDialect,
10482            >,
10483    >
10484        fidl::encoding::Encode<
10485            GuestGetConsoleResponse,
10486            fidl::encoding::DefaultFuchsiaResourceDialect,
10487        > for (T0,)
10488    {
10489        #[inline]
10490        unsafe fn encode(
10491            self,
10492            encoder: &mut fidl::encoding::Encoder<
10493                '_,
10494                fidl::encoding::DefaultFuchsiaResourceDialect,
10495            >,
10496            offset: usize,
10497            depth: fidl::encoding::Depth,
10498        ) -> fidl::Result<()> {
10499            encoder.debug_check_bounds::<GuestGetConsoleResponse>(offset);
10500            // Zero out padding regions. There's no need to apply masks
10501            // because the unmasked parts will be overwritten by fields.
10502            // Write the fields.
10503            self.0.encode(encoder, offset + 0, depth)?;
10504            Ok(())
10505        }
10506    }
10507
10508    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10509        for GuestGetConsoleResponse
10510    {
10511        #[inline(always)]
10512        fn new_empty() -> Self {
10513            Self {
10514                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10515            }
10516        }
10517
10518        #[inline]
10519        unsafe fn decode(
10520            &mut self,
10521            decoder: &mut fidl::encoding::Decoder<
10522                '_,
10523                fidl::encoding::DefaultFuchsiaResourceDialect,
10524            >,
10525            offset: usize,
10526            _depth: fidl::encoding::Depth,
10527        ) -> fidl::Result<()> {
10528            decoder.debug_check_bounds::<Self>(offset);
10529            // Verify that padding bytes are zero.
10530            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10531            Ok(())
10532        }
10533    }
10534
10535    impl fidl::encoding::ResourceTypeMarker for HostVsockAcceptorAcceptResponse {
10536        type Borrowed<'a> = &'a mut Self;
10537        fn take_or_borrow<'a>(
10538            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10539        ) -> Self::Borrowed<'a> {
10540            value
10541        }
10542    }
10543
10544    unsafe impl fidl::encoding::TypeMarker for HostVsockAcceptorAcceptResponse {
10545        type Owned = Self;
10546
10547        #[inline(always)]
10548        fn inline_align(_context: fidl::encoding::Context) -> usize {
10549            4
10550        }
10551
10552        #[inline(always)]
10553        fn inline_size(_context: fidl::encoding::Context) -> usize {
10554            4
10555        }
10556    }
10557
10558    unsafe impl
10559        fidl::encoding::Encode<
10560            HostVsockAcceptorAcceptResponse,
10561            fidl::encoding::DefaultFuchsiaResourceDialect,
10562        > for &mut HostVsockAcceptorAcceptResponse
10563    {
10564        #[inline]
10565        unsafe fn encode(
10566            self,
10567            encoder: &mut fidl::encoding::Encoder<
10568                '_,
10569                fidl::encoding::DefaultFuchsiaResourceDialect,
10570            >,
10571            offset: usize,
10572            _depth: fidl::encoding::Depth,
10573        ) -> fidl::Result<()> {
10574            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10575            // Delegate to tuple encoding.
10576            fidl::encoding::Encode::<
10577                HostVsockAcceptorAcceptResponse,
10578                fidl::encoding::DefaultFuchsiaResourceDialect,
10579            >::encode(
10580                (<fidl::encoding::HandleType<
10581                    fidl::Socket,
10582                    { fidl::ObjectType::SOCKET.into_raw() },
10583                    2147483648,
10584                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10585                    &mut self.socket
10586                ),),
10587                encoder,
10588                offset,
10589                _depth,
10590            )
10591        }
10592    }
10593    unsafe impl<
10594        T0: fidl::encoding::Encode<
10595                fidl::encoding::HandleType<
10596                    fidl::Socket,
10597                    { fidl::ObjectType::SOCKET.into_raw() },
10598                    2147483648,
10599                >,
10600                fidl::encoding::DefaultFuchsiaResourceDialect,
10601            >,
10602    >
10603        fidl::encoding::Encode<
10604            HostVsockAcceptorAcceptResponse,
10605            fidl::encoding::DefaultFuchsiaResourceDialect,
10606        > for (T0,)
10607    {
10608        #[inline]
10609        unsafe fn encode(
10610            self,
10611            encoder: &mut fidl::encoding::Encoder<
10612                '_,
10613                fidl::encoding::DefaultFuchsiaResourceDialect,
10614            >,
10615            offset: usize,
10616            depth: fidl::encoding::Depth,
10617        ) -> fidl::Result<()> {
10618            encoder.debug_check_bounds::<HostVsockAcceptorAcceptResponse>(offset);
10619            // Zero out padding regions. There's no need to apply masks
10620            // because the unmasked parts will be overwritten by fields.
10621            // Write the fields.
10622            self.0.encode(encoder, offset + 0, depth)?;
10623            Ok(())
10624        }
10625    }
10626
10627    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10628        for HostVsockAcceptorAcceptResponse
10629    {
10630        #[inline(always)]
10631        fn new_empty() -> Self {
10632            Self {
10633                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10634            }
10635        }
10636
10637        #[inline]
10638        unsafe fn decode(
10639            &mut self,
10640            decoder: &mut fidl::encoding::Decoder<
10641                '_,
10642                fidl::encoding::DefaultFuchsiaResourceDialect,
10643            >,
10644            offset: usize,
10645            _depth: fidl::encoding::Depth,
10646        ) -> fidl::Result<()> {
10647            decoder.debug_check_bounds::<Self>(offset);
10648            // Verify that padding bytes are zero.
10649            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10650            Ok(())
10651        }
10652    }
10653
10654    impl fidl::encoding::ResourceTypeMarker for HostVsockEndpointConnectResponse {
10655        type Borrowed<'a> = &'a mut Self;
10656        fn take_or_borrow<'a>(
10657            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10658        ) -> Self::Borrowed<'a> {
10659            value
10660        }
10661    }
10662
10663    unsafe impl fidl::encoding::TypeMarker for HostVsockEndpointConnectResponse {
10664        type Owned = Self;
10665
10666        #[inline(always)]
10667        fn inline_align(_context: fidl::encoding::Context) -> usize {
10668            4
10669        }
10670
10671        #[inline(always)]
10672        fn inline_size(_context: fidl::encoding::Context) -> usize {
10673            4
10674        }
10675    }
10676
10677    unsafe impl
10678        fidl::encoding::Encode<
10679            HostVsockEndpointConnectResponse,
10680            fidl::encoding::DefaultFuchsiaResourceDialect,
10681        > for &mut HostVsockEndpointConnectResponse
10682    {
10683        #[inline]
10684        unsafe fn encode(
10685            self,
10686            encoder: &mut fidl::encoding::Encoder<
10687                '_,
10688                fidl::encoding::DefaultFuchsiaResourceDialect,
10689            >,
10690            offset: usize,
10691            _depth: fidl::encoding::Depth,
10692        ) -> fidl::Result<()> {
10693            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10694            // Delegate to tuple encoding.
10695            fidl::encoding::Encode::<
10696                HostVsockEndpointConnectResponse,
10697                fidl::encoding::DefaultFuchsiaResourceDialect,
10698            >::encode(
10699                (<fidl::encoding::HandleType<
10700                    fidl::Socket,
10701                    { fidl::ObjectType::SOCKET.into_raw() },
10702                    2147483648,
10703                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10704                    &mut self.socket
10705                ),),
10706                encoder,
10707                offset,
10708                _depth,
10709            )
10710        }
10711    }
10712    unsafe impl<
10713        T0: fidl::encoding::Encode<
10714                fidl::encoding::HandleType<
10715                    fidl::Socket,
10716                    { fidl::ObjectType::SOCKET.into_raw() },
10717                    2147483648,
10718                >,
10719                fidl::encoding::DefaultFuchsiaResourceDialect,
10720            >,
10721    >
10722        fidl::encoding::Encode<
10723            HostVsockEndpointConnectResponse,
10724            fidl::encoding::DefaultFuchsiaResourceDialect,
10725        > for (T0,)
10726    {
10727        #[inline]
10728        unsafe fn encode(
10729            self,
10730            encoder: &mut fidl::encoding::Encoder<
10731                '_,
10732                fidl::encoding::DefaultFuchsiaResourceDialect,
10733            >,
10734            offset: usize,
10735            depth: fidl::encoding::Depth,
10736        ) -> fidl::Result<()> {
10737            encoder.debug_check_bounds::<HostVsockEndpointConnectResponse>(offset);
10738            // Zero out padding regions. There's no need to apply masks
10739            // because the unmasked parts will be overwritten by fields.
10740            // Write the fields.
10741            self.0.encode(encoder, offset + 0, depth)?;
10742            Ok(())
10743        }
10744    }
10745
10746    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10747        for HostVsockEndpointConnectResponse
10748    {
10749        #[inline(always)]
10750        fn new_empty() -> Self {
10751            Self {
10752                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10753            }
10754        }
10755
10756        #[inline]
10757        unsafe fn decode(
10758            &mut self,
10759            decoder: &mut fidl::encoding::Decoder<
10760                '_,
10761                fidl::encoding::DefaultFuchsiaResourceDialect,
10762            >,
10763            offset: usize,
10764            _depth: fidl::encoding::Depth,
10765        ) -> fidl::Result<()> {
10766            decoder.debug_check_bounds::<Self>(offset);
10767            // Verify that padding bytes are zero.
10768            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
10769            Ok(())
10770        }
10771    }
10772
10773    impl fidl::encoding::ResourceTypeMarker for Listener {
10774        type Borrowed<'a> = &'a mut Self;
10775        fn take_or_borrow<'a>(
10776            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10777        ) -> Self::Borrowed<'a> {
10778            value
10779        }
10780    }
10781
10782    unsafe impl fidl::encoding::TypeMarker for Listener {
10783        type Owned = Self;
10784
10785        #[inline(always)]
10786        fn inline_align(_context: fidl::encoding::Context) -> usize {
10787            4
10788        }
10789
10790        #[inline(always)]
10791        fn inline_size(_context: fidl::encoding::Context) -> usize {
10792            8
10793        }
10794    }
10795
10796    unsafe impl fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>
10797        for &mut Listener
10798    {
10799        #[inline]
10800        unsafe fn encode(
10801            self,
10802            encoder: &mut fidl::encoding::Encoder<
10803                '_,
10804                fidl::encoding::DefaultFuchsiaResourceDialect,
10805            >,
10806            offset: usize,
10807            _depth: fidl::encoding::Depth,
10808        ) -> fidl::Result<()> {
10809            encoder.debug_check_bounds::<Listener>(offset);
10810            // Delegate to tuple encoding.
10811            fidl::encoding::Encode::<Listener, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10812                (
10813                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.port),
10814                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.acceptor),
10815                ),
10816                encoder, offset, _depth
10817            )
10818        }
10819    }
10820    unsafe impl<
10821        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
10822        T1: fidl::encoding::Encode<
10823                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10824                fidl::encoding::DefaultFuchsiaResourceDialect,
10825            >,
10826    > fidl::encoding::Encode<Listener, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0, T1)
10827    {
10828        #[inline]
10829        unsafe fn encode(
10830            self,
10831            encoder: &mut fidl::encoding::Encoder<
10832                '_,
10833                fidl::encoding::DefaultFuchsiaResourceDialect,
10834            >,
10835            offset: usize,
10836            depth: fidl::encoding::Depth,
10837        ) -> fidl::Result<()> {
10838            encoder.debug_check_bounds::<Listener>(offset);
10839            // Zero out padding regions. There's no need to apply masks
10840            // because the unmasked parts will be overwritten by fields.
10841            // Write the fields.
10842            self.0.encode(encoder, offset + 0, depth)?;
10843            self.1.encode(encoder, offset + 4, depth)?;
10844            Ok(())
10845        }
10846    }
10847
10848    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Listener {
10849        #[inline(always)]
10850        fn new_empty() -> Self {
10851            Self {
10852                port: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
10853                acceptor: fidl::new_empty!(
10854                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10855                    fidl::encoding::DefaultFuchsiaResourceDialect
10856                ),
10857            }
10858        }
10859
10860        #[inline]
10861        unsafe fn decode(
10862            &mut self,
10863            decoder: &mut fidl::encoding::Decoder<
10864                '_,
10865                fidl::encoding::DefaultFuchsiaResourceDialect,
10866            >,
10867            offset: usize,
10868            _depth: fidl::encoding::Depth,
10869        ) -> fidl::Result<()> {
10870            decoder.debug_check_bounds::<Self>(offset);
10871            // Verify that padding bytes are zero.
10872            fidl::decode!(
10873                u32,
10874                fidl::encoding::DefaultFuchsiaResourceDialect,
10875                &mut self.port,
10876                decoder,
10877                offset + 0,
10878                _depth
10879            )?;
10880            fidl::decode!(
10881                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostVsockAcceptorMarker>>,
10882                fidl::encoding::DefaultFuchsiaResourceDialect,
10883                &mut self.acceptor,
10884                decoder,
10885                offset + 4,
10886                _depth
10887            )?;
10888            Ok(())
10889        }
10890    }
10891
10892    impl GuestConfig {
10893        #[inline(always)]
10894        fn max_ordinal_present(&self) -> u64 {
10895            if let Some(_) = self.virtio_mem_region_alignment {
10896                return 25;
10897            }
10898            if let Some(_) = self.virtio_mem_region_size {
10899                return 24;
10900            }
10901            if let Some(_) = self.virtio_mem_block_size {
10902                return 23;
10903            }
10904            if let Some(_) = self.virtio_mem {
10905                return 22;
10906            }
10907            if let Some(_) = self.vsock_listeners {
10908                return 21;
10909            }
10910            if let Some(_) = self.virtio_sound_input {
10911                return 20;
10912            }
10913            if let Some(_) = self.virtio_sound {
10914                return 19;
10915            }
10916            if let Some(_) = self.virtio_vsock {
10917                return 18;
10918            }
10919            if let Some(_) = self.virtio_rng {
10920                return 17;
10921            }
10922            if let Some(_) = self.virtio_gpu {
10923                return 16;
10924            }
10925            if let Some(_) = self.virtio_console {
10926                return 15;
10927            }
10928            if let Some(_) = self.virtio_balloon {
10929                return 14;
10930            }
10931            if let Some(_) = self.default_net {
10932                return 13;
10933            }
10934            if let Some(_) = self.net_devices {
10935                return 10;
10936            }
10937            if let Some(_) = self.block_devices {
10938                return 9;
10939            }
10940            if let Some(_) = self.guest_memory {
10941                return 8;
10942            }
10943            if let Some(_) = self.cpus {
10944                return 7;
10945            }
10946            if let Some(_) = self.cmdline_add {
10947                return 6;
10948            }
10949            if let Some(_) = self.cmdline {
10950                return 5;
10951            }
10952            if let Some(_) = self.dtb_overlay {
10953                return 4;
10954            }
10955            if let Some(_) = self.ramdisk {
10956                return 3;
10957            }
10958            if let Some(_) = self.kernel {
10959                return 2;
10960            }
10961            if let Some(_) = self.kernel_type {
10962                return 1;
10963            }
10964            0
10965        }
10966    }
10967
10968    impl fidl::encoding::ResourceTypeMarker for GuestConfig {
10969        type Borrowed<'a> = &'a mut Self;
10970        fn take_or_borrow<'a>(
10971            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10972        ) -> Self::Borrowed<'a> {
10973            value
10974        }
10975    }
10976
10977    unsafe impl fidl::encoding::TypeMarker for GuestConfig {
10978        type Owned = Self;
10979
10980        #[inline(always)]
10981        fn inline_align(_context: fidl::encoding::Context) -> usize {
10982            8
10983        }
10984
10985        #[inline(always)]
10986        fn inline_size(_context: fidl::encoding::Context) -> usize {
10987            16
10988        }
10989    }
10990
10991    unsafe impl fidl::encoding::Encode<GuestConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
10992        for &mut GuestConfig
10993    {
10994        unsafe fn encode(
10995            self,
10996            encoder: &mut fidl::encoding::Encoder<
10997                '_,
10998                fidl::encoding::DefaultFuchsiaResourceDialect,
10999            >,
11000            offset: usize,
11001            mut depth: fidl::encoding::Depth,
11002        ) -> fidl::Result<()> {
11003            encoder.debug_check_bounds::<GuestConfig>(offset);
11004            // Vector header
11005            let max_ordinal: u64 = self.max_ordinal_present();
11006            encoder.write_num(max_ordinal, offset);
11007            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11008            // Calling encoder.out_of_line_offset(0) is not allowed.
11009            if max_ordinal == 0 {
11010                return Ok(());
11011            }
11012            depth.increment()?;
11013            let envelope_size = 8;
11014            let bytes_len = max_ordinal as usize * envelope_size;
11015            #[allow(unused_variables)]
11016            let offset = encoder.out_of_line_offset(bytes_len);
11017            let mut _prev_end_offset: usize = 0;
11018            if 1 > max_ordinal {
11019                return Ok(());
11020            }
11021
11022            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11023            // are envelope_size bytes.
11024            let cur_offset: usize = (1 - 1) * envelope_size;
11025
11026            // Zero reserved fields.
11027            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11028
11029            // Safety:
11030            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11031            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11032            //   envelope_size bytes, there is always sufficient room.
11033            fidl::encoding::encode_in_envelope_optional::<
11034                KernelType,
11035                fidl::encoding::DefaultFuchsiaResourceDialect,
11036            >(
11037                self.kernel_type
11038                    .as_ref()
11039                    .map(<KernelType as fidl::encoding::ValueTypeMarker>::borrow),
11040                encoder,
11041                offset + cur_offset,
11042                depth,
11043            )?;
11044
11045            _prev_end_offset = cur_offset + envelope_size;
11046            if 2 > max_ordinal {
11047                return Ok(());
11048            }
11049
11050            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11051            // are envelope_size bytes.
11052            let cur_offset: usize = (2 - 1) * envelope_size;
11053
11054            // Zero reserved fields.
11055            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11056
11057            // Safety:
11058            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11059            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11060            //   envelope_size bytes, there is always sufficient room.
11061            fidl::encoding::encode_in_envelope_optional::<
11062                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11063                fidl::encoding::DefaultFuchsiaResourceDialect,
11064            >(
11065                self.kernel.as_mut().map(
11066                    <fidl::encoding::Endpoint<
11067                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11068                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11069                ),
11070                encoder,
11071                offset + cur_offset,
11072                depth,
11073            )?;
11074
11075            _prev_end_offset = cur_offset + envelope_size;
11076            if 3 > max_ordinal {
11077                return Ok(());
11078            }
11079
11080            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11081            // are envelope_size bytes.
11082            let cur_offset: usize = (3 - 1) * envelope_size;
11083
11084            // Zero reserved fields.
11085            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11086
11087            // Safety:
11088            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11089            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11090            //   envelope_size bytes, there is always sufficient room.
11091            fidl::encoding::encode_in_envelope_optional::<
11092                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11093                fidl::encoding::DefaultFuchsiaResourceDialect,
11094            >(
11095                self.ramdisk.as_mut().map(
11096                    <fidl::encoding::Endpoint<
11097                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11098                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11099                ),
11100                encoder,
11101                offset + cur_offset,
11102                depth,
11103            )?;
11104
11105            _prev_end_offset = cur_offset + envelope_size;
11106            if 4 > max_ordinal {
11107                return Ok(());
11108            }
11109
11110            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11111            // are envelope_size bytes.
11112            let cur_offset: usize = (4 - 1) * envelope_size;
11113
11114            // Zero reserved fields.
11115            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11116
11117            // Safety:
11118            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11119            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11120            //   envelope_size bytes, there is always sufficient room.
11121            fidl::encoding::encode_in_envelope_optional::<
11122                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
11123                fidl::encoding::DefaultFuchsiaResourceDialect,
11124            >(
11125                self.dtb_overlay.as_mut().map(
11126                    <fidl::encoding::Endpoint<
11127                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11128                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11129                ),
11130                encoder,
11131                offset + cur_offset,
11132                depth,
11133            )?;
11134
11135            _prev_end_offset = cur_offset + envelope_size;
11136            if 5 > max_ordinal {
11137                return Ok(());
11138            }
11139
11140            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11141            // are envelope_size bytes.
11142            let cur_offset: usize = (5 - 1) * envelope_size;
11143
11144            // Zero reserved fields.
11145            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11146
11147            // Safety:
11148            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11149            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11150            //   envelope_size bytes, there is always sufficient room.
11151            fidl::encoding::encode_in_envelope_optional::<
11152                fidl::encoding::UnboundedString,
11153                fidl::encoding::DefaultFuchsiaResourceDialect,
11154            >(
11155                self.cmdline.as_ref().map(
11156                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
11157                ),
11158                encoder,
11159                offset + cur_offset,
11160                depth,
11161            )?;
11162
11163            _prev_end_offset = cur_offset + envelope_size;
11164            if 6 > max_ordinal {
11165                return Ok(());
11166            }
11167
11168            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11169            // are envelope_size bytes.
11170            let cur_offset: usize = (6 - 1) * envelope_size;
11171
11172            // Zero reserved fields.
11173            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11174
11175            // Safety:
11176            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11177            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11178            //   envelope_size bytes, there is always sufficient room.
11179            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11180            self.cmdline_add.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow),
11181            encoder, offset + cur_offset, depth
11182        )?;
11183
11184            _prev_end_offset = cur_offset + envelope_size;
11185            if 7 > max_ordinal {
11186                return Ok(());
11187            }
11188
11189            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11190            // are envelope_size bytes.
11191            let cur_offset: usize = (7 - 1) * envelope_size;
11192
11193            // Zero reserved fields.
11194            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11195
11196            // Safety:
11197            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11198            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11199            //   envelope_size bytes, there is always sufficient room.
11200            fidl::encoding::encode_in_envelope_optional::<
11201                u8,
11202                fidl::encoding::DefaultFuchsiaResourceDialect,
11203            >(
11204                self.cpus.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
11205                encoder,
11206                offset + cur_offset,
11207                depth,
11208            )?;
11209
11210            _prev_end_offset = cur_offset + envelope_size;
11211            if 8 > max_ordinal {
11212                return Ok(());
11213            }
11214
11215            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11216            // are envelope_size bytes.
11217            let cur_offset: usize = (8 - 1) * envelope_size;
11218
11219            // Zero reserved fields.
11220            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11221
11222            // Safety:
11223            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11224            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11225            //   envelope_size bytes, there is always sufficient room.
11226            fidl::encoding::encode_in_envelope_optional::<
11227                u64,
11228                fidl::encoding::DefaultFuchsiaResourceDialect,
11229            >(
11230                self.guest_memory.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11231                encoder,
11232                offset + cur_offset,
11233                depth,
11234            )?;
11235
11236            _prev_end_offset = cur_offset + envelope_size;
11237            if 9 > max_ordinal {
11238                return Ok(());
11239            }
11240
11241            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11242            // are envelope_size bytes.
11243            let cur_offset: usize = (9 - 1) * envelope_size;
11244
11245            // Zero reserved fields.
11246            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11247
11248            // Safety:
11249            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11250            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11251            //   envelope_size bytes, there is always sufficient room.
11252            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11253            self.block_devices.as_mut().map(<fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11254            encoder, offset + cur_offset, depth
11255        )?;
11256
11257            _prev_end_offset = cur_offset + envelope_size;
11258            if 10 > max_ordinal {
11259                return Ok(());
11260            }
11261
11262            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11263            // are envelope_size bytes.
11264            let cur_offset: usize = (10 - 1) * envelope_size;
11265
11266            // Zero reserved fields.
11267            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11268
11269            // Safety:
11270            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11271            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11272            //   envelope_size bytes, there is always sufficient room.
11273            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11274            self.net_devices.as_ref().map(<fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11275            encoder, offset + cur_offset, depth
11276        )?;
11277
11278            _prev_end_offset = cur_offset + envelope_size;
11279            if 13 > max_ordinal {
11280                return Ok(());
11281            }
11282
11283            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11284            // are envelope_size bytes.
11285            let cur_offset: usize = (13 - 1) * envelope_size;
11286
11287            // Zero reserved fields.
11288            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11289
11290            // Safety:
11291            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11292            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11293            //   envelope_size bytes, there is always sufficient room.
11294            fidl::encoding::encode_in_envelope_optional::<
11295                bool,
11296                fidl::encoding::DefaultFuchsiaResourceDialect,
11297            >(
11298                self.default_net.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11299                encoder,
11300                offset + cur_offset,
11301                depth,
11302            )?;
11303
11304            _prev_end_offset = cur_offset + envelope_size;
11305            if 14 > max_ordinal {
11306                return Ok(());
11307            }
11308
11309            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11310            // are envelope_size bytes.
11311            let cur_offset: usize = (14 - 1) * envelope_size;
11312
11313            // Zero reserved fields.
11314            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11315
11316            // Safety:
11317            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11318            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11319            //   envelope_size bytes, there is always sufficient room.
11320            fidl::encoding::encode_in_envelope_optional::<
11321                bool,
11322                fidl::encoding::DefaultFuchsiaResourceDialect,
11323            >(
11324                self.virtio_balloon.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11325                encoder,
11326                offset + cur_offset,
11327                depth,
11328            )?;
11329
11330            _prev_end_offset = cur_offset + envelope_size;
11331            if 15 > max_ordinal {
11332                return Ok(());
11333            }
11334
11335            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11336            // are envelope_size bytes.
11337            let cur_offset: usize = (15 - 1) * envelope_size;
11338
11339            // Zero reserved fields.
11340            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11341
11342            // Safety:
11343            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11344            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11345            //   envelope_size bytes, there is always sufficient room.
11346            fidl::encoding::encode_in_envelope_optional::<
11347                bool,
11348                fidl::encoding::DefaultFuchsiaResourceDialect,
11349            >(
11350                self.virtio_console.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11351                encoder,
11352                offset + cur_offset,
11353                depth,
11354            )?;
11355
11356            _prev_end_offset = cur_offset + envelope_size;
11357            if 16 > max_ordinal {
11358                return Ok(());
11359            }
11360
11361            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11362            // are envelope_size bytes.
11363            let cur_offset: usize = (16 - 1) * envelope_size;
11364
11365            // Zero reserved fields.
11366            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11367
11368            // Safety:
11369            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11370            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11371            //   envelope_size bytes, there is always sufficient room.
11372            fidl::encoding::encode_in_envelope_optional::<
11373                bool,
11374                fidl::encoding::DefaultFuchsiaResourceDialect,
11375            >(
11376                self.virtio_gpu.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11377                encoder,
11378                offset + cur_offset,
11379                depth,
11380            )?;
11381
11382            _prev_end_offset = cur_offset + envelope_size;
11383            if 17 > max_ordinal {
11384                return Ok(());
11385            }
11386
11387            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11388            // are envelope_size bytes.
11389            let cur_offset: usize = (17 - 1) * envelope_size;
11390
11391            // Zero reserved fields.
11392            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11393
11394            // Safety:
11395            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11396            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11397            //   envelope_size bytes, there is always sufficient room.
11398            fidl::encoding::encode_in_envelope_optional::<
11399                bool,
11400                fidl::encoding::DefaultFuchsiaResourceDialect,
11401            >(
11402                self.virtio_rng.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11403                encoder,
11404                offset + cur_offset,
11405                depth,
11406            )?;
11407
11408            _prev_end_offset = cur_offset + envelope_size;
11409            if 18 > max_ordinal {
11410                return Ok(());
11411            }
11412
11413            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11414            // are envelope_size bytes.
11415            let cur_offset: usize = (18 - 1) * envelope_size;
11416
11417            // Zero reserved fields.
11418            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11419
11420            // Safety:
11421            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11422            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11423            //   envelope_size bytes, there is always sufficient room.
11424            fidl::encoding::encode_in_envelope_optional::<
11425                bool,
11426                fidl::encoding::DefaultFuchsiaResourceDialect,
11427            >(
11428                self.virtio_vsock.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11429                encoder,
11430                offset + cur_offset,
11431                depth,
11432            )?;
11433
11434            _prev_end_offset = cur_offset + envelope_size;
11435            if 19 > max_ordinal {
11436                return Ok(());
11437            }
11438
11439            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11440            // are envelope_size bytes.
11441            let cur_offset: usize = (19 - 1) * envelope_size;
11442
11443            // Zero reserved fields.
11444            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11445
11446            // Safety:
11447            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11448            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11449            //   envelope_size bytes, there is always sufficient room.
11450            fidl::encoding::encode_in_envelope_optional::<
11451                bool,
11452                fidl::encoding::DefaultFuchsiaResourceDialect,
11453            >(
11454                self.virtio_sound.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11455                encoder,
11456                offset + cur_offset,
11457                depth,
11458            )?;
11459
11460            _prev_end_offset = cur_offset + envelope_size;
11461            if 20 > max_ordinal {
11462                return Ok(());
11463            }
11464
11465            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11466            // are envelope_size bytes.
11467            let cur_offset: usize = (20 - 1) * envelope_size;
11468
11469            // Zero reserved fields.
11470            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11471
11472            // Safety:
11473            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11474            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11475            //   envelope_size bytes, there is always sufficient room.
11476            fidl::encoding::encode_in_envelope_optional::<
11477                bool,
11478                fidl::encoding::DefaultFuchsiaResourceDialect,
11479            >(
11480                self.virtio_sound_input
11481                    .as_ref()
11482                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11483                encoder,
11484                offset + cur_offset,
11485                depth,
11486            )?;
11487
11488            _prev_end_offset = cur_offset + envelope_size;
11489            if 21 > max_ordinal {
11490                return Ok(());
11491            }
11492
11493            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11494            // are envelope_size bytes.
11495            let cur_offset: usize = (21 - 1) * envelope_size;
11496
11497            // Zero reserved fields.
11498            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11499
11500            // Safety:
11501            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11502            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11503            //   envelope_size bytes, there is always sufficient room.
11504            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Listener>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11505            self.vsock_listeners.as_mut().map(<fidl::encoding::UnboundedVector<Listener> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11506            encoder, offset + cur_offset, depth
11507        )?;
11508
11509            _prev_end_offset = cur_offset + envelope_size;
11510            if 22 > max_ordinal {
11511                return Ok(());
11512            }
11513
11514            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11515            // are envelope_size bytes.
11516            let cur_offset: usize = (22 - 1) * envelope_size;
11517
11518            // Zero reserved fields.
11519            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11520
11521            // Safety:
11522            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11523            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11524            //   envelope_size bytes, there is always sufficient room.
11525            fidl::encoding::encode_in_envelope_optional::<
11526                bool,
11527                fidl::encoding::DefaultFuchsiaResourceDialect,
11528            >(
11529                self.virtio_mem.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11530                encoder,
11531                offset + cur_offset,
11532                depth,
11533            )?;
11534
11535            _prev_end_offset = cur_offset + envelope_size;
11536            if 23 > max_ordinal {
11537                return Ok(());
11538            }
11539
11540            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11541            // are envelope_size bytes.
11542            let cur_offset: usize = (23 - 1) * envelope_size;
11543
11544            // Zero reserved fields.
11545            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11546
11547            // Safety:
11548            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11549            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11550            //   envelope_size bytes, there is always sufficient room.
11551            fidl::encoding::encode_in_envelope_optional::<
11552                u64,
11553                fidl::encoding::DefaultFuchsiaResourceDialect,
11554            >(
11555                self.virtio_mem_block_size
11556                    .as_ref()
11557                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11558                encoder,
11559                offset + cur_offset,
11560                depth,
11561            )?;
11562
11563            _prev_end_offset = cur_offset + envelope_size;
11564            if 24 > max_ordinal {
11565                return Ok(());
11566            }
11567
11568            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11569            // are envelope_size bytes.
11570            let cur_offset: usize = (24 - 1) * envelope_size;
11571
11572            // Zero reserved fields.
11573            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11574
11575            // Safety:
11576            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11577            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11578            //   envelope_size bytes, there is always sufficient room.
11579            fidl::encoding::encode_in_envelope_optional::<
11580                u64,
11581                fidl::encoding::DefaultFuchsiaResourceDialect,
11582            >(
11583                self.virtio_mem_region_size
11584                    .as_ref()
11585                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11586                encoder,
11587                offset + cur_offset,
11588                depth,
11589            )?;
11590
11591            _prev_end_offset = cur_offset + envelope_size;
11592            if 25 > max_ordinal {
11593                return Ok(());
11594            }
11595
11596            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11597            // are envelope_size bytes.
11598            let cur_offset: usize = (25 - 1) * envelope_size;
11599
11600            // Zero reserved fields.
11601            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11602
11603            // Safety:
11604            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11605            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11606            //   envelope_size bytes, there is always sufficient room.
11607            fidl::encoding::encode_in_envelope_optional::<
11608                u64,
11609                fidl::encoding::DefaultFuchsiaResourceDialect,
11610            >(
11611                self.virtio_mem_region_alignment
11612                    .as_ref()
11613                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11614                encoder,
11615                offset + cur_offset,
11616                depth,
11617            )?;
11618
11619            _prev_end_offset = cur_offset + envelope_size;
11620
11621            Ok(())
11622        }
11623    }
11624
11625    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for GuestConfig {
11626        #[inline(always)]
11627        fn new_empty() -> Self {
11628            Self::default()
11629        }
11630
11631        unsafe fn decode(
11632            &mut self,
11633            decoder: &mut fidl::encoding::Decoder<
11634                '_,
11635                fidl::encoding::DefaultFuchsiaResourceDialect,
11636            >,
11637            offset: usize,
11638            mut depth: fidl::encoding::Depth,
11639        ) -> fidl::Result<()> {
11640            decoder.debug_check_bounds::<Self>(offset);
11641            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11642                None => return Err(fidl::Error::NotNullable),
11643                Some(len) => len,
11644            };
11645            // Calling decoder.out_of_line_offset(0) is not allowed.
11646            if len == 0 {
11647                return Ok(());
11648            };
11649            depth.increment()?;
11650            let envelope_size = 8;
11651            let bytes_len = len * envelope_size;
11652            let offset = decoder.out_of_line_offset(bytes_len)?;
11653            // Decode the envelope for each type.
11654            let mut _next_ordinal_to_read = 0;
11655            let mut next_offset = offset;
11656            let end_offset = offset + bytes_len;
11657            _next_ordinal_to_read += 1;
11658            if next_offset >= end_offset {
11659                return Ok(());
11660            }
11661
11662            // Decode unknown envelopes for gaps in ordinals.
11663            while _next_ordinal_to_read < 1 {
11664                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11665                _next_ordinal_to_read += 1;
11666                next_offset += envelope_size;
11667            }
11668
11669            let next_out_of_line = decoder.next_out_of_line();
11670            let handles_before = decoder.remaining_handles();
11671            if let Some((inlined, num_bytes, num_handles)) =
11672                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11673            {
11674                let member_inline_size =
11675                    <KernelType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11676                if inlined != (member_inline_size <= 4) {
11677                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11678                }
11679                let inner_offset;
11680                let mut inner_depth = depth.clone();
11681                if inlined {
11682                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11683                    inner_offset = next_offset;
11684                } else {
11685                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11686                    inner_depth.increment()?;
11687                }
11688                let val_ref = self.kernel_type.get_or_insert_with(|| {
11689                    fidl::new_empty!(KernelType, fidl::encoding::DefaultFuchsiaResourceDialect)
11690                });
11691                fidl::decode!(
11692                    KernelType,
11693                    fidl::encoding::DefaultFuchsiaResourceDialect,
11694                    val_ref,
11695                    decoder,
11696                    inner_offset,
11697                    inner_depth
11698                )?;
11699                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11700                {
11701                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11702                }
11703                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11704                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11705                }
11706            }
11707
11708            next_offset += envelope_size;
11709            _next_ordinal_to_read += 1;
11710            if next_offset >= end_offset {
11711                return Ok(());
11712            }
11713
11714            // Decode unknown envelopes for gaps in ordinals.
11715            while _next_ordinal_to_read < 2 {
11716                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11717                _next_ordinal_to_read += 1;
11718                next_offset += envelope_size;
11719            }
11720
11721            let next_out_of_line = decoder.next_out_of_line();
11722            let handles_before = decoder.remaining_handles();
11723            if let Some((inlined, num_bytes, num_handles)) =
11724                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11725            {
11726                let member_inline_size = <fidl::encoding::Endpoint<
11727                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11728                > as fidl::encoding::TypeMarker>::inline_size(
11729                    decoder.context
11730                );
11731                if inlined != (member_inline_size <= 4) {
11732                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11733                }
11734                let inner_offset;
11735                let mut inner_depth = depth.clone();
11736                if inlined {
11737                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11738                    inner_offset = next_offset;
11739                } else {
11740                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11741                    inner_depth.increment()?;
11742                }
11743                let val_ref = self.kernel.get_or_insert_with(|| {
11744                    fidl::new_empty!(
11745                        fidl::encoding::Endpoint<
11746                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11747                        >,
11748                        fidl::encoding::DefaultFuchsiaResourceDialect
11749                    )
11750                });
11751                fidl::decode!(
11752                    fidl::encoding::Endpoint<
11753                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11754                    >,
11755                    fidl::encoding::DefaultFuchsiaResourceDialect,
11756                    val_ref,
11757                    decoder,
11758                    inner_offset,
11759                    inner_depth
11760                )?;
11761                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11762                {
11763                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11764                }
11765                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11766                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11767                }
11768            }
11769
11770            next_offset += envelope_size;
11771            _next_ordinal_to_read += 1;
11772            if next_offset >= end_offset {
11773                return Ok(());
11774            }
11775
11776            // Decode unknown envelopes for gaps in ordinals.
11777            while _next_ordinal_to_read < 3 {
11778                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11779                _next_ordinal_to_read += 1;
11780                next_offset += envelope_size;
11781            }
11782
11783            let next_out_of_line = decoder.next_out_of_line();
11784            let handles_before = decoder.remaining_handles();
11785            if let Some((inlined, num_bytes, num_handles)) =
11786                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11787            {
11788                let member_inline_size = <fidl::encoding::Endpoint<
11789                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11790                > as fidl::encoding::TypeMarker>::inline_size(
11791                    decoder.context
11792                );
11793                if inlined != (member_inline_size <= 4) {
11794                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11795                }
11796                let inner_offset;
11797                let mut inner_depth = depth.clone();
11798                if inlined {
11799                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11800                    inner_offset = next_offset;
11801                } else {
11802                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11803                    inner_depth.increment()?;
11804                }
11805                let val_ref = self.ramdisk.get_or_insert_with(|| {
11806                    fidl::new_empty!(
11807                        fidl::encoding::Endpoint<
11808                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11809                        >,
11810                        fidl::encoding::DefaultFuchsiaResourceDialect
11811                    )
11812                });
11813                fidl::decode!(
11814                    fidl::encoding::Endpoint<
11815                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11816                    >,
11817                    fidl::encoding::DefaultFuchsiaResourceDialect,
11818                    val_ref,
11819                    decoder,
11820                    inner_offset,
11821                    inner_depth
11822                )?;
11823                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11824                {
11825                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11826                }
11827                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11828                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11829                }
11830            }
11831
11832            next_offset += envelope_size;
11833            _next_ordinal_to_read += 1;
11834            if next_offset >= end_offset {
11835                return Ok(());
11836            }
11837
11838            // Decode unknown envelopes for gaps in ordinals.
11839            while _next_ordinal_to_read < 4 {
11840                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11841                _next_ordinal_to_read += 1;
11842                next_offset += envelope_size;
11843            }
11844
11845            let next_out_of_line = decoder.next_out_of_line();
11846            let handles_before = decoder.remaining_handles();
11847            if let Some((inlined, num_bytes, num_handles)) =
11848                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11849            {
11850                let member_inline_size = <fidl::encoding::Endpoint<
11851                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11852                > as fidl::encoding::TypeMarker>::inline_size(
11853                    decoder.context
11854                );
11855                if inlined != (member_inline_size <= 4) {
11856                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11857                }
11858                let inner_offset;
11859                let mut inner_depth = depth.clone();
11860                if inlined {
11861                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11862                    inner_offset = next_offset;
11863                } else {
11864                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11865                    inner_depth.increment()?;
11866                }
11867                let val_ref = self.dtb_overlay.get_or_insert_with(|| {
11868                    fidl::new_empty!(
11869                        fidl::encoding::Endpoint<
11870                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11871                        >,
11872                        fidl::encoding::DefaultFuchsiaResourceDialect
11873                    )
11874                });
11875                fidl::decode!(
11876                    fidl::encoding::Endpoint<
11877                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
11878                    >,
11879                    fidl::encoding::DefaultFuchsiaResourceDialect,
11880                    val_ref,
11881                    decoder,
11882                    inner_offset,
11883                    inner_depth
11884                )?;
11885                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11886                {
11887                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11888                }
11889                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11890                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11891                }
11892            }
11893
11894            next_offset += envelope_size;
11895            _next_ordinal_to_read += 1;
11896            if next_offset >= end_offset {
11897                return Ok(());
11898            }
11899
11900            // Decode unknown envelopes for gaps in ordinals.
11901            while _next_ordinal_to_read < 5 {
11902                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11903                _next_ordinal_to_read += 1;
11904                next_offset += envelope_size;
11905            }
11906
11907            let next_out_of_line = decoder.next_out_of_line();
11908            let handles_before = decoder.remaining_handles();
11909            if let Some((inlined, num_bytes, num_handles)) =
11910                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11911            {
11912                let member_inline_size =
11913                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
11914                        decoder.context,
11915                    );
11916                if inlined != (member_inline_size <= 4) {
11917                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11918                }
11919                let inner_offset;
11920                let mut inner_depth = depth.clone();
11921                if inlined {
11922                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11923                    inner_offset = next_offset;
11924                } else {
11925                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11926                    inner_depth.increment()?;
11927                }
11928                let val_ref = self.cmdline.get_or_insert_with(|| {
11929                    fidl::new_empty!(
11930                        fidl::encoding::UnboundedString,
11931                        fidl::encoding::DefaultFuchsiaResourceDialect
11932                    )
11933                });
11934                fidl::decode!(
11935                    fidl::encoding::UnboundedString,
11936                    fidl::encoding::DefaultFuchsiaResourceDialect,
11937                    val_ref,
11938                    decoder,
11939                    inner_offset,
11940                    inner_depth
11941                )?;
11942                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11943                {
11944                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11945                }
11946                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11947                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11948                }
11949            }
11950
11951            next_offset += envelope_size;
11952            _next_ordinal_to_read += 1;
11953            if next_offset >= end_offset {
11954                return Ok(());
11955            }
11956
11957            // Decode unknown envelopes for gaps in ordinals.
11958            while _next_ordinal_to_read < 6 {
11959                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11960                _next_ordinal_to_read += 1;
11961                next_offset += envelope_size;
11962            }
11963
11964            let next_out_of_line = decoder.next_out_of_line();
11965            let handles_before = decoder.remaining_handles();
11966            if let Some((inlined, num_bytes, num_handles)) =
11967                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11968            {
11969                let member_inline_size = <fidl::encoding::UnboundedVector<
11970                    fidl::encoding::UnboundedString,
11971                > as fidl::encoding::TypeMarker>::inline_size(
11972                    decoder.context
11973                );
11974                if inlined != (member_inline_size <= 4) {
11975                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11976                }
11977                let inner_offset;
11978                let mut inner_depth = depth.clone();
11979                if inlined {
11980                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11981                    inner_offset = next_offset;
11982                } else {
11983                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11984                    inner_depth.increment()?;
11985                }
11986                let val_ref = self.cmdline_add.get_or_insert_with(|| {
11987                    fidl::new_empty!(
11988                        fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
11989                        fidl::encoding::DefaultFuchsiaResourceDialect
11990                    )
11991                });
11992                fidl::decode!(
11993                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
11994                    fidl::encoding::DefaultFuchsiaResourceDialect,
11995                    val_ref,
11996                    decoder,
11997                    inner_offset,
11998                    inner_depth
11999                )?;
12000                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12001                {
12002                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12003                }
12004                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12005                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12006                }
12007            }
12008
12009            next_offset += envelope_size;
12010            _next_ordinal_to_read += 1;
12011            if next_offset >= end_offset {
12012                return Ok(());
12013            }
12014
12015            // Decode unknown envelopes for gaps in ordinals.
12016            while _next_ordinal_to_read < 7 {
12017                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12018                _next_ordinal_to_read += 1;
12019                next_offset += envelope_size;
12020            }
12021
12022            let next_out_of_line = decoder.next_out_of_line();
12023            let handles_before = decoder.remaining_handles();
12024            if let Some((inlined, num_bytes, num_handles)) =
12025                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12026            {
12027                let member_inline_size =
12028                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12029                if inlined != (member_inline_size <= 4) {
12030                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12031                }
12032                let inner_offset;
12033                let mut inner_depth = depth.clone();
12034                if inlined {
12035                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12036                    inner_offset = next_offset;
12037                } else {
12038                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12039                    inner_depth.increment()?;
12040                }
12041                let val_ref = self.cpus.get_or_insert_with(|| {
12042                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12043                });
12044                fidl::decode!(
12045                    u8,
12046                    fidl::encoding::DefaultFuchsiaResourceDialect,
12047                    val_ref,
12048                    decoder,
12049                    inner_offset,
12050                    inner_depth
12051                )?;
12052                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12053                {
12054                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12055                }
12056                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12057                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12058                }
12059            }
12060
12061            next_offset += envelope_size;
12062            _next_ordinal_to_read += 1;
12063            if next_offset >= end_offset {
12064                return Ok(());
12065            }
12066
12067            // Decode unknown envelopes for gaps in ordinals.
12068            while _next_ordinal_to_read < 8 {
12069                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12070                _next_ordinal_to_read += 1;
12071                next_offset += envelope_size;
12072            }
12073
12074            let next_out_of_line = decoder.next_out_of_line();
12075            let handles_before = decoder.remaining_handles();
12076            if let Some((inlined, num_bytes, num_handles)) =
12077                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12078            {
12079                let member_inline_size =
12080                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12081                if inlined != (member_inline_size <= 4) {
12082                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12083                }
12084                let inner_offset;
12085                let mut inner_depth = depth.clone();
12086                if inlined {
12087                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12088                    inner_offset = next_offset;
12089                } else {
12090                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12091                    inner_depth.increment()?;
12092                }
12093                let val_ref = self.guest_memory.get_or_insert_with(|| {
12094                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12095                });
12096                fidl::decode!(
12097                    u64,
12098                    fidl::encoding::DefaultFuchsiaResourceDialect,
12099                    val_ref,
12100                    decoder,
12101                    inner_offset,
12102                    inner_depth
12103                )?;
12104                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12105                {
12106                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12107                }
12108                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12109                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12110                }
12111            }
12112
12113            next_offset += envelope_size;
12114            _next_ordinal_to_read += 1;
12115            if next_offset >= end_offset {
12116                return Ok(());
12117            }
12118
12119            // Decode unknown envelopes for gaps in ordinals.
12120            while _next_ordinal_to_read < 9 {
12121                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12122                _next_ordinal_to_read += 1;
12123                next_offset += envelope_size;
12124            }
12125
12126            let next_out_of_line = decoder.next_out_of_line();
12127            let handles_before = decoder.remaining_handles();
12128            if let Some((inlined, num_bytes, num_handles)) =
12129                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12130            {
12131                let member_inline_size = <fidl::encoding::Vector<BlockSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12132                if inlined != (member_inline_size <= 4) {
12133                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12134                }
12135                let inner_offset;
12136                let mut inner_depth = depth.clone();
12137                if inlined {
12138                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12139                    inner_offset = next_offset;
12140                } else {
12141                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12142                    inner_depth.increment()?;
12143                }
12144                let val_ref =
12145                self.block_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12146                fidl::decode!(fidl::encoding::Vector<BlockSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12147                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12148                {
12149                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12150                }
12151                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12152                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12153                }
12154            }
12155
12156            next_offset += envelope_size;
12157            _next_ordinal_to_read += 1;
12158            if next_offset >= end_offset {
12159                return Ok(());
12160            }
12161
12162            // Decode unknown envelopes for gaps in ordinals.
12163            while _next_ordinal_to_read < 10 {
12164                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12165                _next_ordinal_to_read += 1;
12166                next_offset += envelope_size;
12167            }
12168
12169            let next_out_of_line = decoder.next_out_of_line();
12170            let handles_before = decoder.remaining_handles();
12171            if let Some((inlined, num_bytes, num_handles)) =
12172                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12173            {
12174                let member_inline_size = <fidl::encoding::Vector<NetSpec, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12175                if inlined != (member_inline_size <= 4) {
12176                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12177                }
12178                let inner_offset;
12179                let mut inner_depth = depth.clone();
12180                if inlined {
12181                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12182                    inner_offset = next_offset;
12183                } else {
12184                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12185                    inner_depth.increment()?;
12186                }
12187                let val_ref =
12188                self.net_devices.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
12189                fidl::decode!(fidl::encoding::Vector<NetSpec, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12190                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12191                {
12192                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12193                }
12194                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12195                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12196                }
12197            }
12198
12199            next_offset += envelope_size;
12200            _next_ordinal_to_read += 1;
12201            if next_offset >= end_offset {
12202                return Ok(());
12203            }
12204
12205            // Decode unknown envelopes for gaps in ordinals.
12206            while _next_ordinal_to_read < 13 {
12207                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12208                _next_ordinal_to_read += 1;
12209                next_offset += envelope_size;
12210            }
12211
12212            let next_out_of_line = decoder.next_out_of_line();
12213            let handles_before = decoder.remaining_handles();
12214            if let Some((inlined, num_bytes, num_handles)) =
12215                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12216            {
12217                let member_inline_size =
12218                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12219                if inlined != (member_inline_size <= 4) {
12220                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12221                }
12222                let inner_offset;
12223                let mut inner_depth = depth.clone();
12224                if inlined {
12225                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12226                    inner_offset = next_offset;
12227                } else {
12228                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12229                    inner_depth.increment()?;
12230                }
12231                let val_ref = self.default_net.get_or_insert_with(|| {
12232                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12233                });
12234                fidl::decode!(
12235                    bool,
12236                    fidl::encoding::DefaultFuchsiaResourceDialect,
12237                    val_ref,
12238                    decoder,
12239                    inner_offset,
12240                    inner_depth
12241                )?;
12242                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12243                {
12244                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12245                }
12246                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12247                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12248                }
12249            }
12250
12251            next_offset += envelope_size;
12252            _next_ordinal_to_read += 1;
12253            if next_offset >= end_offset {
12254                return Ok(());
12255            }
12256
12257            // Decode unknown envelopes for gaps in ordinals.
12258            while _next_ordinal_to_read < 14 {
12259                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12260                _next_ordinal_to_read += 1;
12261                next_offset += envelope_size;
12262            }
12263
12264            let next_out_of_line = decoder.next_out_of_line();
12265            let handles_before = decoder.remaining_handles();
12266            if let Some((inlined, num_bytes, num_handles)) =
12267                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12268            {
12269                let member_inline_size =
12270                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12271                if inlined != (member_inline_size <= 4) {
12272                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12273                }
12274                let inner_offset;
12275                let mut inner_depth = depth.clone();
12276                if inlined {
12277                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12278                    inner_offset = next_offset;
12279                } else {
12280                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12281                    inner_depth.increment()?;
12282                }
12283                let val_ref = self.virtio_balloon.get_or_insert_with(|| {
12284                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12285                });
12286                fidl::decode!(
12287                    bool,
12288                    fidl::encoding::DefaultFuchsiaResourceDialect,
12289                    val_ref,
12290                    decoder,
12291                    inner_offset,
12292                    inner_depth
12293                )?;
12294                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12295                {
12296                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12297                }
12298                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12299                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12300                }
12301            }
12302
12303            next_offset += envelope_size;
12304            _next_ordinal_to_read += 1;
12305            if next_offset >= end_offset {
12306                return Ok(());
12307            }
12308
12309            // Decode unknown envelopes for gaps in ordinals.
12310            while _next_ordinal_to_read < 15 {
12311                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12312                _next_ordinal_to_read += 1;
12313                next_offset += envelope_size;
12314            }
12315
12316            let next_out_of_line = decoder.next_out_of_line();
12317            let handles_before = decoder.remaining_handles();
12318            if let Some((inlined, num_bytes, num_handles)) =
12319                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12320            {
12321                let member_inline_size =
12322                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12323                if inlined != (member_inline_size <= 4) {
12324                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12325                }
12326                let inner_offset;
12327                let mut inner_depth = depth.clone();
12328                if inlined {
12329                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12330                    inner_offset = next_offset;
12331                } else {
12332                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12333                    inner_depth.increment()?;
12334                }
12335                let val_ref = self.virtio_console.get_or_insert_with(|| {
12336                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12337                });
12338                fidl::decode!(
12339                    bool,
12340                    fidl::encoding::DefaultFuchsiaResourceDialect,
12341                    val_ref,
12342                    decoder,
12343                    inner_offset,
12344                    inner_depth
12345                )?;
12346                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12347                {
12348                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12349                }
12350                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12351                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12352                }
12353            }
12354
12355            next_offset += envelope_size;
12356            _next_ordinal_to_read += 1;
12357            if next_offset >= end_offset {
12358                return Ok(());
12359            }
12360
12361            // Decode unknown envelopes for gaps in ordinals.
12362            while _next_ordinal_to_read < 16 {
12363                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12364                _next_ordinal_to_read += 1;
12365                next_offset += envelope_size;
12366            }
12367
12368            let next_out_of_line = decoder.next_out_of_line();
12369            let handles_before = decoder.remaining_handles();
12370            if let Some((inlined, num_bytes, num_handles)) =
12371                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12372            {
12373                let member_inline_size =
12374                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12375                if inlined != (member_inline_size <= 4) {
12376                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12377                }
12378                let inner_offset;
12379                let mut inner_depth = depth.clone();
12380                if inlined {
12381                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12382                    inner_offset = next_offset;
12383                } else {
12384                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12385                    inner_depth.increment()?;
12386                }
12387                let val_ref = self.virtio_gpu.get_or_insert_with(|| {
12388                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12389                });
12390                fidl::decode!(
12391                    bool,
12392                    fidl::encoding::DefaultFuchsiaResourceDialect,
12393                    val_ref,
12394                    decoder,
12395                    inner_offset,
12396                    inner_depth
12397                )?;
12398                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12399                {
12400                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12401                }
12402                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12403                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12404                }
12405            }
12406
12407            next_offset += envelope_size;
12408            _next_ordinal_to_read += 1;
12409            if next_offset >= end_offset {
12410                return Ok(());
12411            }
12412
12413            // Decode unknown envelopes for gaps in ordinals.
12414            while _next_ordinal_to_read < 17 {
12415                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12416                _next_ordinal_to_read += 1;
12417                next_offset += envelope_size;
12418            }
12419
12420            let next_out_of_line = decoder.next_out_of_line();
12421            let handles_before = decoder.remaining_handles();
12422            if let Some((inlined, num_bytes, num_handles)) =
12423                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12424            {
12425                let member_inline_size =
12426                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12427                if inlined != (member_inline_size <= 4) {
12428                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12429                }
12430                let inner_offset;
12431                let mut inner_depth = depth.clone();
12432                if inlined {
12433                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12434                    inner_offset = next_offset;
12435                } else {
12436                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12437                    inner_depth.increment()?;
12438                }
12439                let val_ref = self.virtio_rng.get_or_insert_with(|| {
12440                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12441                });
12442                fidl::decode!(
12443                    bool,
12444                    fidl::encoding::DefaultFuchsiaResourceDialect,
12445                    val_ref,
12446                    decoder,
12447                    inner_offset,
12448                    inner_depth
12449                )?;
12450                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12451                {
12452                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12453                }
12454                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12455                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12456                }
12457            }
12458
12459            next_offset += envelope_size;
12460            _next_ordinal_to_read += 1;
12461            if next_offset >= end_offset {
12462                return Ok(());
12463            }
12464
12465            // Decode unknown envelopes for gaps in ordinals.
12466            while _next_ordinal_to_read < 18 {
12467                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12468                _next_ordinal_to_read += 1;
12469                next_offset += envelope_size;
12470            }
12471
12472            let next_out_of_line = decoder.next_out_of_line();
12473            let handles_before = decoder.remaining_handles();
12474            if let Some((inlined, num_bytes, num_handles)) =
12475                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12476            {
12477                let member_inline_size =
12478                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12479                if inlined != (member_inline_size <= 4) {
12480                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12481                }
12482                let inner_offset;
12483                let mut inner_depth = depth.clone();
12484                if inlined {
12485                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12486                    inner_offset = next_offset;
12487                } else {
12488                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12489                    inner_depth.increment()?;
12490                }
12491                let val_ref = self.virtio_vsock.get_or_insert_with(|| {
12492                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12493                });
12494                fidl::decode!(
12495                    bool,
12496                    fidl::encoding::DefaultFuchsiaResourceDialect,
12497                    val_ref,
12498                    decoder,
12499                    inner_offset,
12500                    inner_depth
12501                )?;
12502                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12503                {
12504                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12505                }
12506                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12507                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12508                }
12509            }
12510
12511            next_offset += envelope_size;
12512            _next_ordinal_to_read += 1;
12513            if next_offset >= end_offset {
12514                return Ok(());
12515            }
12516
12517            // Decode unknown envelopes for gaps in ordinals.
12518            while _next_ordinal_to_read < 19 {
12519                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12520                _next_ordinal_to_read += 1;
12521                next_offset += envelope_size;
12522            }
12523
12524            let next_out_of_line = decoder.next_out_of_line();
12525            let handles_before = decoder.remaining_handles();
12526            if let Some((inlined, num_bytes, num_handles)) =
12527                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12528            {
12529                let member_inline_size =
12530                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12531                if inlined != (member_inline_size <= 4) {
12532                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12533                }
12534                let inner_offset;
12535                let mut inner_depth = depth.clone();
12536                if inlined {
12537                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12538                    inner_offset = next_offset;
12539                } else {
12540                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12541                    inner_depth.increment()?;
12542                }
12543                let val_ref = self.virtio_sound.get_or_insert_with(|| {
12544                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12545                });
12546                fidl::decode!(
12547                    bool,
12548                    fidl::encoding::DefaultFuchsiaResourceDialect,
12549                    val_ref,
12550                    decoder,
12551                    inner_offset,
12552                    inner_depth
12553                )?;
12554                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12555                {
12556                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12557                }
12558                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12559                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12560                }
12561            }
12562
12563            next_offset += envelope_size;
12564            _next_ordinal_to_read += 1;
12565            if next_offset >= end_offset {
12566                return Ok(());
12567            }
12568
12569            // Decode unknown envelopes for gaps in ordinals.
12570            while _next_ordinal_to_read < 20 {
12571                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12572                _next_ordinal_to_read += 1;
12573                next_offset += envelope_size;
12574            }
12575
12576            let next_out_of_line = decoder.next_out_of_line();
12577            let handles_before = decoder.remaining_handles();
12578            if let Some((inlined, num_bytes, num_handles)) =
12579                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12580            {
12581                let member_inline_size =
12582                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12583                if inlined != (member_inline_size <= 4) {
12584                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12585                }
12586                let inner_offset;
12587                let mut inner_depth = depth.clone();
12588                if inlined {
12589                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12590                    inner_offset = next_offset;
12591                } else {
12592                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12593                    inner_depth.increment()?;
12594                }
12595                let val_ref = self.virtio_sound_input.get_or_insert_with(|| {
12596                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12597                });
12598                fidl::decode!(
12599                    bool,
12600                    fidl::encoding::DefaultFuchsiaResourceDialect,
12601                    val_ref,
12602                    decoder,
12603                    inner_offset,
12604                    inner_depth
12605                )?;
12606                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12607                {
12608                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12609                }
12610                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12611                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12612                }
12613            }
12614
12615            next_offset += envelope_size;
12616            _next_ordinal_to_read += 1;
12617            if next_offset >= end_offset {
12618                return Ok(());
12619            }
12620
12621            // Decode unknown envelopes for gaps in ordinals.
12622            while _next_ordinal_to_read < 21 {
12623                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12624                _next_ordinal_to_read += 1;
12625                next_offset += envelope_size;
12626            }
12627
12628            let next_out_of_line = decoder.next_out_of_line();
12629            let handles_before = decoder.remaining_handles();
12630            if let Some((inlined, num_bytes, num_handles)) =
12631                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12632            {
12633                let member_inline_size = <fidl::encoding::UnboundedVector<Listener> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12634                if inlined != (member_inline_size <= 4) {
12635                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12636                }
12637                let inner_offset;
12638                let mut inner_depth = depth.clone();
12639                if inlined {
12640                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12641                    inner_offset = next_offset;
12642                } else {
12643                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12644                    inner_depth.increment()?;
12645                }
12646                let val_ref = self.vsock_listeners.get_or_insert_with(|| {
12647                    fidl::new_empty!(
12648                        fidl::encoding::UnboundedVector<Listener>,
12649                        fidl::encoding::DefaultFuchsiaResourceDialect
12650                    )
12651                });
12652                fidl::decode!(
12653                    fidl::encoding::UnboundedVector<Listener>,
12654                    fidl::encoding::DefaultFuchsiaResourceDialect,
12655                    val_ref,
12656                    decoder,
12657                    inner_offset,
12658                    inner_depth
12659                )?;
12660                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12661                {
12662                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12663                }
12664                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12665                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12666                }
12667            }
12668
12669            next_offset += envelope_size;
12670            _next_ordinal_to_read += 1;
12671            if next_offset >= end_offset {
12672                return Ok(());
12673            }
12674
12675            // Decode unknown envelopes for gaps in ordinals.
12676            while _next_ordinal_to_read < 22 {
12677                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12678                _next_ordinal_to_read += 1;
12679                next_offset += envelope_size;
12680            }
12681
12682            let next_out_of_line = decoder.next_out_of_line();
12683            let handles_before = decoder.remaining_handles();
12684            if let Some((inlined, num_bytes, num_handles)) =
12685                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12686            {
12687                let member_inline_size =
12688                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12689                if inlined != (member_inline_size <= 4) {
12690                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12691                }
12692                let inner_offset;
12693                let mut inner_depth = depth.clone();
12694                if inlined {
12695                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12696                    inner_offset = next_offset;
12697                } else {
12698                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12699                    inner_depth.increment()?;
12700                }
12701                let val_ref = self.virtio_mem.get_or_insert_with(|| {
12702                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
12703                });
12704                fidl::decode!(
12705                    bool,
12706                    fidl::encoding::DefaultFuchsiaResourceDialect,
12707                    val_ref,
12708                    decoder,
12709                    inner_offset,
12710                    inner_depth
12711                )?;
12712                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12713                {
12714                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12715                }
12716                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12717                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12718                }
12719            }
12720
12721            next_offset += envelope_size;
12722            _next_ordinal_to_read += 1;
12723            if next_offset >= end_offset {
12724                return Ok(());
12725            }
12726
12727            // Decode unknown envelopes for gaps in ordinals.
12728            while _next_ordinal_to_read < 23 {
12729                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12730                _next_ordinal_to_read += 1;
12731                next_offset += envelope_size;
12732            }
12733
12734            let next_out_of_line = decoder.next_out_of_line();
12735            let handles_before = decoder.remaining_handles();
12736            if let Some((inlined, num_bytes, num_handles)) =
12737                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12738            {
12739                let member_inline_size =
12740                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12741                if inlined != (member_inline_size <= 4) {
12742                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12743                }
12744                let inner_offset;
12745                let mut inner_depth = depth.clone();
12746                if inlined {
12747                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12748                    inner_offset = next_offset;
12749                } else {
12750                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12751                    inner_depth.increment()?;
12752                }
12753                let val_ref = self.virtio_mem_block_size.get_or_insert_with(|| {
12754                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12755                });
12756                fidl::decode!(
12757                    u64,
12758                    fidl::encoding::DefaultFuchsiaResourceDialect,
12759                    val_ref,
12760                    decoder,
12761                    inner_offset,
12762                    inner_depth
12763                )?;
12764                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12765                {
12766                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12767                }
12768                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12769                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12770                }
12771            }
12772
12773            next_offset += envelope_size;
12774            _next_ordinal_to_read += 1;
12775            if next_offset >= end_offset {
12776                return Ok(());
12777            }
12778
12779            // Decode unknown envelopes for gaps in ordinals.
12780            while _next_ordinal_to_read < 24 {
12781                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12782                _next_ordinal_to_read += 1;
12783                next_offset += envelope_size;
12784            }
12785
12786            let next_out_of_line = decoder.next_out_of_line();
12787            let handles_before = decoder.remaining_handles();
12788            if let Some((inlined, num_bytes, num_handles)) =
12789                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12790            {
12791                let member_inline_size =
12792                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12793                if inlined != (member_inline_size <= 4) {
12794                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12795                }
12796                let inner_offset;
12797                let mut inner_depth = depth.clone();
12798                if inlined {
12799                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12800                    inner_offset = next_offset;
12801                } else {
12802                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12803                    inner_depth.increment()?;
12804                }
12805                let val_ref = self.virtio_mem_region_size.get_or_insert_with(|| {
12806                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12807                });
12808                fidl::decode!(
12809                    u64,
12810                    fidl::encoding::DefaultFuchsiaResourceDialect,
12811                    val_ref,
12812                    decoder,
12813                    inner_offset,
12814                    inner_depth
12815                )?;
12816                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12817                {
12818                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12819                }
12820                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12821                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12822                }
12823            }
12824
12825            next_offset += envelope_size;
12826            _next_ordinal_to_read += 1;
12827            if next_offset >= end_offset {
12828                return Ok(());
12829            }
12830
12831            // Decode unknown envelopes for gaps in ordinals.
12832            while _next_ordinal_to_read < 25 {
12833                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12834                _next_ordinal_to_read += 1;
12835                next_offset += envelope_size;
12836            }
12837
12838            let next_out_of_line = decoder.next_out_of_line();
12839            let handles_before = decoder.remaining_handles();
12840            if let Some((inlined, num_bytes, num_handles)) =
12841                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12842            {
12843                let member_inline_size =
12844                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12845                if inlined != (member_inline_size <= 4) {
12846                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12847                }
12848                let inner_offset;
12849                let mut inner_depth = depth.clone();
12850                if inlined {
12851                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12852                    inner_offset = next_offset;
12853                } else {
12854                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12855                    inner_depth.increment()?;
12856                }
12857                let val_ref = self.virtio_mem_region_alignment.get_or_insert_with(|| {
12858                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12859                });
12860                fidl::decode!(
12861                    u64,
12862                    fidl::encoding::DefaultFuchsiaResourceDialect,
12863                    val_ref,
12864                    decoder,
12865                    inner_offset,
12866                    inner_depth
12867                )?;
12868                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12869                {
12870                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12871                }
12872                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12873                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12874                }
12875            }
12876
12877            next_offset += envelope_size;
12878
12879            // Decode the remaining unknown envelopes.
12880            while next_offset < end_offset {
12881                _next_ordinal_to_read += 1;
12882                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12883                next_offset += envelope_size;
12884            }
12885
12886            Ok(())
12887        }
12888    }
12889
12890    impl fidl::encoding::ResourceTypeMarker for BlockFormat {
12891        type Borrowed<'a> = &'a mut Self;
12892        fn take_or_borrow<'a>(
12893            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12894        ) -> Self::Borrowed<'a> {
12895            value
12896        }
12897    }
12898
12899    unsafe impl fidl::encoding::TypeMarker for BlockFormat {
12900        type Owned = Self;
12901
12902        #[inline(always)]
12903        fn inline_align(_context: fidl::encoding::Context) -> usize {
12904            8
12905        }
12906
12907        #[inline(always)]
12908        fn inline_size(_context: fidl::encoding::Context) -> usize {
12909            16
12910        }
12911    }
12912
12913    unsafe impl fidl::encoding::Encode<BlockFormat, fidl::encoding::DefaultFuchsiaResourceDialect>
12914        for &mut BlockFormat
12915    {
12916        #[inline]
12917        unsafe fn encode(
12918            self,
12919            encoder: &mut fidl::encoding::Encoder<
12920                '_,
12921                fidl::encoding::DefaultFuchsiaResourceDialect,
12922            >,
12923            offset: usize,
12924            _depth: fidl::encoding::Depth,
12925        ) -> fidl::Result<()> {
12926            encoder.debug_check_bounds::<BlockFormat>(offset);
12927            encoder.write_num::<u64>(self.ordinal(), offset);
12928            match self {
12929                BlockFormat::File(ref mut val) => fidl::encoding::encode_in_envelope::<
12930                    fidl::encoding::Endpoint<
12931                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12932                    >,
12933                    fidl::encoding::DefaultFuchsiaResourceDialect,
12934                >(
12935                    <fidl::encoding::Endpoint<
12936                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12937                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12938                        val
12939                    ),
12940                    encoder,
12941                    offset + 8,
12942                    _depth,
12943                ),
12944                BlockFormat::Qcow(ref mut val) => fidl::encoding::encode_in_envelope::<
12945                    fidl::encoding::HandleType<
12946                        fidl::Channel,
12947                        { fidl::ObjectType::CHANNEL.into_raw() },
12948                        2147483648,
12949                    >,
12950                    fidl::encoding::DefaultFuchsiaResourceDialect,
12951                >(
12952                    <fidl::encoding::HandleType<
12953                        fidl::Channel,
12954                        { fidl::ObjectType::CHANNEL.into_raw() },
12955                        2147483648,
12956                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12957                        val
12958                    ),
12959                    encoder,
12960                    offset + 8,
12961                    _depth,
12962                ),
12963                BlockFormat::Block(ref mut val) => fidl::encoding::encode_in_envelope::<
12964                    fidl::encoding::Endpoint<
12965                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
12966                    >,
12967                    fidl::encoding::DefaultFuchsiaResourceDialect,
12968                >(
12969                    <fidl::encoding::Endpoint<
12970                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
12971                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12972                        val
12973                    ),
12974                    encoder,
12975                    offset + 8,
12976                    _depth,
12977                ),
12978            }
12979        }
12980    }
12981
12982    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockFormat {
12983        #[inline(always)]
12984        fn new_empty() -> Self {
12985            Self::File(fidl::new_empty!(
12986                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
12987                fidl::encoding::DefaultFuchsiaResourceDialect
12988            ))
12989        }
12990
12991        #[inline]
12992        unsafe fn decode(
12993            &mut self,
12994            decoder: &mut fidl::encoding::Decoder<
12995                '_,
12996                fidl::encoding::DefaultFuchsiaResourceDialect,
12997            >,
12998            offset: usize,
12999            mut depth: fidl::encoding::Depth,
13000        ) -> fidl::Result<()> {
13001            decoder.debug_check_bounds::<Self>(offset);
13002            #[allow(unused_variables)]
13003            let next_out_of_line = decoder.next_out_of_line();
13004            let handles_before = decoder.remaining_handles();
13005            let (ordinal, inlined, num_bytes, num_handles) =
13006                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
13007
13008            let member_inline_size = match ordinal {
13009                1 => <fidl::encoding::Endpoint<
13010                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13011                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13012                2 => <fidl::encoding::HandleType<
13013                    fidl::Channel,
13014                    { fidl::ObjectType::CHANNEL.into_raw() },
13015                    2147483648,
13016                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13017                3 => <fidl::encoding::Endpoint<
13018                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::BlockMarker>,
13019                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
13020                _ => return Err(fidl::Error::UnknownUnionTag),
13021            };
13022
13023            if inlined != (member_inline_size <= 4) {
13024                return Err(fidl::Error::InvalidInlineBitInEnvelope);
13025            }
13026            let _inner_offset;
13027            if inlined {
13028                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
13029                _inner_offset = offset + 8;
13030            } else {
13031                depth.increment()?;
13032                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13033            }
13034            match ordinal {
13035                1 => {
13036                    #[allow(irrefutable_let_patterns)]
13037                    if let BlockFormat::File(_) = self {
13038                        // Do nothing, read the value into the object
13039                    } else {
13040                        // Initialize `self` to the right variant
13041                        *self = BlockFormat::File(fidl::new_empty!(
13042                            fidl::encoding::Endpoint<
13043                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13044                            >,
13045                            fidl::encoding::DefaultFuchsiaResourceDialect
13046                        ));
13047                    }
13048                    #[allow(irrefutable_let_patterns)]
13049                    if let BlockFormat::File(ref mut val) = self {
13050                        fidl::decode!(
13051                            fidl::encoding::Endpoint<
13052                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13053                            >,
13054                            fidl::encoding::DefaultFuchsiaResourceDialect,
13055                            val,
13056                            decoder,
13057                            _inner_offset,
13058                            depth
13059                        )?;
13060                    } else {
13061                        unreachable!()
13062                    }
13063                }
13064                2 => {
13065                    #[allow(irrefutable_let_patterns)]
13066                    if let BlockFormat::Qcow(_) = self {
13067                        // Do nothing, read the value into the object
13068                    } else {
13069                        // Initialize `self` to the right variant
13070                        *self = BlockFormat::Qcow(
13071                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
13072                        );
13073                    }
13074                    #[allow(irrefutable_let_patterns)]
13075                    if let BlockFormat::Qcow(ref mut val) = self {
13076                        fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
13077                    } else {
13078                        unreachable!()
13079                    }
13080                }
13081                3 => {
13082                    #[allow(irrefutable_let_patterns)]
13083                    if let BlockFormat::Block(_) = self {
13084                        // Do nothing, read the value into the object
13085                    } else {
13086                        // Initialize `self` to the right variant
13087                        *self = BlockFormat::Block(fidl::new_empty!(
13088                            fidl::encoding::Endpoint<
13089                                fidl::endpoints::ClientEnd<
13090                                    fidl_fuchsia_hardware_block::BlockMarker,
13091                                >,
13092                            >,
13093                            fidl::encoding::DefaultFuchsiaResourceDialect
13094                        ));
13095                    }
13096                    #[allow(irrefutable_let_patterns)]
13097                    if let BlockFormat::Block(ref mut val) = self {
13098                        fidl::decode!(
13099                            fidl::encoding::Endpoint<
13100                                fidl::endpoints::ClientEnd<
13101                                    fidl_fuchsia_hardware_block::BlockMarker,
13102                                >,
13103                            >,
13104                            fidl::encoding::DefaultFuchsiaResourceDialect,
13105                            val,
13106                            decoder,
13107                            _inner_offset,
13108                            depth
13109                        )?;
13110                    } else {
13111                        unreachable!()
13112                    }
13113                }
13114                ordinal => panic!("unexpected ordinal {:?}", ordinal),
13115            }
13116            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
13117                return Err(fidl::Error::InvalidNumBytesInEnvelope);
13118            }
13119            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13120                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13121            }
13122            Ok(())
13123        }
13124    }
13125}