fidl_fuchsia_virtualization_hardware/
fidl_fuchsia_virtualization_hardware.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_hardware__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14/// Contains the basic information required to start execution of a device.
15#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
16pub struct StartInfo {
17    /// The trap associated with a device. It is up to the device to set this
18    /// trap during device setup.
19    pub trap: Trap,
20    /// The guest associated with a device. This handle should be used to setup
21    /// device traps, and then be released before device operation begins.
22    pub guest: Option<fidl::Guest>,
23    /// The event associated with a device interrupt. This is how the device will
24    /// notify the guest of events it should process.
25    ///
26    /// The meaning of the different signals that can be raised on the event are
27    /// documented by the EVENT_* constants above.
28    pub event: fidl::Event,
29    /// The VMO used to represent guest physical memory.
30    pub vmo: fidl::Vmo,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for StartInfo {}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36pub struct VirtioBalloonStartRequest {
37    pub start_info: StartInfo,
38}
39
40impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioBalloonStartRequest {}
41
42#[derive(Debug, PartialEq)]
43pub struct VirtioBlockStartRequest {
44    pub start_info: StartInfo,
45    pub spec: fidl_fuchsia_virtualization::BlockSpec,
46}
47
48impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioBlockStartRequest {}
49
50#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
51pub struct VirtioConsoleStartRequest {
52    pub start_info: StartInfo,
53    pub socket: fidl::Socket,
54}
55
56impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioConsoleStartRequest {}
57
58#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
59pub struct VirtioGpuStartRequest {
60    pub start_info: StartInfo,
61    pub keyboard_listener:
62        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
63    pub mouse_source:
64        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
65}
66
67impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioGpuStartRequest {}
68
69/// VirtioImages are shared with VirtioMagma, enabling guest clients to allocate
70/// GBM and Vulkan compatible images and share them with Sommelier as dma-bufs.
71/// An image corresponds to a single buffer collection, and also contains some
72/// opaque image info needed by VirtioMagma.
73#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
74pub struct VirtioImage {
75    pub vmo: fidl::Vmo,
76    pub token: Option<fidl::EventPair>,
77    pub info: Vec<u8>,
78}
79
80impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioImage {}
81
82#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
83pub struct VirtioInputStartRequest {
84    pub start_info: StartInfo,
85    pub input_type: InputType,
86}
87
88impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioInputStartRequest {}
89
90#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
91pub struct VirtioMagmaStartRequest {
92    pub start_info: StartInfo,
93    pub vmar: fidl::Vmar,
94    pub wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
95}
96
97impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioMagmaStartRequest {}
98
99#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
100pub struct VirtioMemStartRequest {
101    pub start_info: StartInfo,
102    pub region_addr: u64,
103    pub plugged_block_size: u64,
104    pub region_size: u64,
105}
106
107impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioMemStartRequest {}
108
109#[derive(Debug, PartialEq)]
110pub struct VirtioNetStartRequest {
111    pub start_info: StartInfo,
112    pub mac_address: fidl_fuchsia_net::MacAddress,
113    pub enable_bridge: bool,
114}
115
116impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioNetStartRequest {}
117
118#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
119pub struct VirtioRngStartRequest {
120    pub start_info: StartInfo,
121}
122
123impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioRngStartRequest {}
124
125#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
126pub struct VirtioSoundStartRequest {
127    pub start_info: StartInfo,
128    pub enable_input: bool,
129    pub enable_verbose_logging: bool,
130}
131
132impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioSoundStartRequest {}
133
134#[derive(Debug, PartialEq)]
135pub struct VirtioVsockStartRequest {
136    pub start_info: StartInfo,
137    pub guest_cid: u32,
138    pub listeners: Vec<fidl_fuchsia_virtualization::Listener>,
139}
140
141impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioVsockStartRequest {}
142
143#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
144pub struct VirtioWaylandGetImporterRequest {
145    pub importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
146}
147
148impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
149    for VirtioWaylandGetImporterRequest
150{
151}
152
153#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
154pub struct VirtioWaylandImporterExportImageResponse {
155    pub status: i32,
156    pub image: Option<Box<VirtioImage>>,
157}
158
159impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
160    for VirtioWaylandImporterExportImageResponse
161{
162}
163
164#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
165pub struct VirtioWaylandImporterImportImageRequest {
166    pub image: VirtioImage,
167}
168
169impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
170    for VirtioWaylandImporterImportImageRequest
171{
172}
173
174#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
175pub struct VirtioWaylandStartRequest {
176    pub start_info: StartInfo,
177    pub vmar: fidl::Vmar,
178    pub sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
179    pub scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
180}
181
182impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioWaylandStartRequest {}
183
184#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
185pub struct VirtioWaylandStartWithWaylandServerRequest {
186    pub start_info: StartInfo,
187    pub vmar: fidl::Vmar,
188    pub wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
189    pub sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
190    pub scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
191}
192
193impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
194    for VirtioWaylandStartWithWaylandServerRequest
195{
196}
197
198#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
199pub enum InputType {
200    Keyboard(fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>),
201    Mouse(fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>),
202}
203
204impl InputType {
205    #[inline]
206    pub fn ordinal(&self) -> u64 {
207        match *self {
208            Self::Keyboard(_) => 1,
209            Self::Mouse(_) => 2,
210        }
211    }
212}
213
214impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for InputType {}
215
216#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
217pub struct VirtioBalloonMarker;
218
219impl fidl::endpoints::ProtocolMarker for VirtioBalloonMarker {
220    type Proxy = VirtioBalloonProxy;
221    type RequestStream = VirtioBalloonRequestStream;
222    #[cfg(target_os = "fuchsia")]
223    type SynchronousProxy = VirtioBalloonSynchronousProxy;
224
225    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioBalloon";
226}
227impl fidl::endpoints::DiscoverableProtocolMarker for VirtioBalloonMarker {}
228
229pub trait VirtioBalloonProxyInterface: Send + Sync {
230    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
231    fn r#configure_queue(
232        &self,
233        queue: u16,
234        size: u16,
235        desc: u64,
236        avail: u64,
237        used: u64,
238    ) -> Self::ConfigureQueueResponseFut;
239    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
240    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
241    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
242    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
243    fn r#start(&self, start_info: StartInfo) -> Self::StartResponseFut;
244    type GetMemStatsResponseFut: std::future::Future<
245            Output = Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error>,
246        > + Send;
247    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut;
248}
249#[derive(Debug)]
250#[cfg(target_os = "fuchsia")]
251pub struct VirtioBalloonSynchronousProxy {
252    client: fidl::client::sync::Client,
253}
254
255#[cfg(target_os = "fuchsia")]
256impl fidl::endpoints::SynchronousProxy for VirtioBalloonSynchronousProxy {
257    type Proxy = VirtioBalloonProxy;
258    type Protocol = VirtioBalloonMarker;
259
260    fn from_channel(inner: fidl::Channel) -> Self {
261        Self::new(inner)
262    }
263
264    fn into_channel(self) -> fidl::Channel {
265        self.client.into_channel()
266    }
267
268    fn as_channel(&self) -> &fidl::Channel {
269        self.client.as_channel()
270    }
271}
272
273#[cfg(target_os = "fuchsia")]
274impl VirtioBalloonSynchronousProxy {
275    pub fn new(channel: fidl::Channel) -> Self {
276        let protocol_name = <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
277        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
278    }
279
280    pub fn into_channel(self) -> fidl::Channel {
281        self.client.into_channel()
282    }
283
284    /// Waits until an event arrives and returns it. It is safe for other
285    /// threads to make concurrent requests while waiting for an event.
286    pub fn wait_for_event(
287        &self,
288        deadline: zx::MonotonicInstant,
289    ) -> Result<VirtioBalloonEvent, fidl::Error> {
290        VirtioBalloonEvent::decode(self.client.wait_for_event(deadline)?)
291    }
292
293    /// Configure a `queue` for the device. This specifies the `size` and the
294    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
295    pub fn r#configure_queue(
296        &self,
297        mut queue: u16,
298        mut size: u16,
299        mut desc: u64,
300        mut avail: u64,
301        mut used: u64,
302        ___deadline: zx::MonotonicInstant,
303    ) -> Result<(), fidl::Error> {
304        let _response = self
305            .client
306            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
307                (queue, size, desc, avail, used),
308                0x72b44fb963480b11,
309                fidl::encoding::DynamicFlags::empty(),
310                ___deadline,
311            )?;
312        Ok(_response)
313    }
314
315    /// Notify a `queue` for the device. Primarily used for black-box testing.
316    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
317        self.client.send::<VirtioDeviceNotifyQueueRequest>(
318            (queue,),
319            0x6e3a61d652499244,
320            fidl::encoding::DynamicFlags::empty(),
321        )
322    }
323
324    /// Ready a device. This provides the set of `negotiated_features` that the
325    /// driver and device have agreed upon.
326    pub fn r#ready(
327        &self,
328        mut negotiated_features: u32,
329        ___deadline: zx::MonotonicInstant,
330    ) -> Result<(), fidl::Error> {
331        let _response =
332            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
333                (negotiated_features,),
334                0x45707654f5d23c3f,
335                fidl::encoding::DynamicFlags::empty(),
336                ___deadline,
337            )?;
338        Ok(_response)
339    }
340
341    /// Start the balloon device.
342    pub fn r#start(
343        &self,
344        mut start_info: StartInfo,
345        ___deadline: zx::MonotonicInstant,
346    ) -> Result<(), fidl::Error> {
347        let _response =
348            self.client.send_query::<VirtioBalloonStartRequest, fidl::encoding::EmptyPayload>(
349                (&mut start_info,),
350                0x26645282fddf6f46,
351                fidl::encoding::DynamicFlags::empty(),
352                ___deadline,
353            )?;
354        Ok(_response)
355    }
356
357    /// Get memory statistics from the balloon device.
358    pub fn r#get_mem_stats(
359        &self,
360        ___deadline: zx::MonotonicInstant,
361    ) -> Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error> {
362        let _response = self
363            .client
364            .send_query::<fidl::encoding::EmptyPayload, VirtioBalloonGetMemStatsResponse>(
365                (),
366                0x6641f4c296607e24,
367                fidl::encoding::DynamicFlags::empty(),
368                ___deadline,
369            )?;
370        Ok((_response.status, _response.mem_stats))
371    }
372}
373
374#[cfg(target_os = "fuchsia")]
375impl From<VirtioBalloonSynchronousProxy> for zx::Handle {
376    fn from(value: VirtioBalloonSynchronousProxy) -> Self {
377        value.into_channel().into()
378    }
379}
380
381#[cfg(target_os = "fuchsia")]
382impl From<fidl::Channel> for VirtioBalloonSynchronousProxy {
383    fn from(value: fidl::Channel) -> Self {
384        Self::new(value)
385    }
386}
387
388#[cfg(target_os = "fuchsia")]
389impl fidl::endpoints::FromClient for VirtioBalloonSynchronousProxy {
390    type Protocol = VirtioBalloonMarker;
391
392    fn from_client(value: fidl::endpoints::ClientEnd<VirtioBalloonMarker>) -> Self {
393        Self::new(value.into_channel())
394    }
395}
396
397#[derive(Debug, Clone)]
398pub struct VirtioBalloonProxy {
399    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
400}
401
402impl fidl::endpoints::Proxy for VirtioBalloonProxy {
403    type Protocol = VirtioBalloonMarker;
404
405    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
406        Self::new(inner)
407    }
408
409    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
410        self.client.into_channel().map_err(|client| Self { client })
411    }
412
413    fn as_channel(&self) -> &::fidl::AsyncChannel {
414        self.client.as_channel()
415    }
416}
417
418impl VirtioBalloonProxy {
419    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioBalloon.
420    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
421        let protocol_name = <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
422        Self { client: fidl::client::Client::new(channel, protocol_name) }
423    }
424
425    /// Get a Stream of events from the remote end of the protocol.
426    ///
427    /// # Panics
428    ///
429    /// Panics if the event stream was already taken.
430    pub fn take_event_stream(&self) -> VirtioBalloonEventStream {
431        VirtioBalloonEventStream { event_receiver: self.client.take_event_receiver() }
432    }
433
434    /// Configure a `queue` for the device. This specifies the `size` and the
435    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
436    pub fn r#configure_queue(
437        &self,
438        mut queue: u16,
439        mut size: u16,
440        mut desc: u64,
441        mut avail: u64,
442        mut used: u64,
443    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
444        VirtioBalloonProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
445    }
446
447    /// Notify a `queue` for the device. Primarily used for black-box testing.
448    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
449        VirtioBalloonProxyInterface::r#notify_queue(self, queue)
450    }
451
452    /// Ready a device. This provides the set of `negotiated_features` that the
453    /// driver and device have agreed upon.
454    pub fn r#ready(
455        &self,
456        mut negotiated_features: u32,
457    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
458        VirtioBalloonProxyInterface::r#ready(self, negotiated_features)
459    }
460
461    /// Start the balloon device.
462    pub fn r#start(
463        &self,
464        mut start_info: StartInfo,
465    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
466        VirtioBalloonProxyInterface::r#start(self, start_info)
467    }
468
469    /// Get memory statistics from the balloon device.
470    pub fn r#get_mem_stats(
471        &self,
472    ) -> fidl::client::QueryResponseFut<
473        (i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
474        fidl::encoding::DefaultFuchsiaResourceDialect,
475    > {
476        VirtioBalloonProxyInterface::r#get_mem_stats(self)
477    }
478}
479
480impl VirtioBalloonProxyInterface for VirtioBalloonProxy {
481    type ConfigureQueueResponseFut =
482        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
483    fn r#configure_queue(
484        &self,
485        mut queue: u16,
486        mut size: u16,
487        mut desc: u64,
488        mut avail: u64,
489        mut used: u64,
490    ) -> Self::ConfigureQueueResponseFut {
491        fn _decode(
492            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
493        ) -> Result<(), fidl::Error> {
494            let _response = fidl::client::decode_transaction_body::<
495                fidl::encoding::EmptyPayload,
496                fidl::encoding::DefaultFuchsiaResourceDialect,
497                0x72b44fb963480b11,
498            >(_buf?)?;
499            Ok(_response)
500        }
501        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
502            (queue, size, desc, avail, used),
503            0x72b44fb963480b11,
504            fidl::encoding::DynamicFlags::empty(),
505            _decode,
506        )
507    }
508
509    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
510        self.client.send::<VirtioDeviceNotifyQueueRequest>(
511            (queue,),
512            0x6e3a61d652499244,
513            fidl::encoding::DynamicFlags::empty(),
514        )
515    }
516
517    type ReadyResponseFut =
518        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
519    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
520        fn _decode(
521            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
522        ) -> Result<(), fidl::Error> {
523            let _response = fidl::client::decode_transaction_body::<
524                fidl::encoding::EmptyPayload,
525                fidl::encoding::DefaultFuchsiaResourceDialect,
526                0x45707654f5d23c3f,
527            >(_buf?)?;
528            Ok(_response)
529        }
530        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
531            (negotiated_features,),
532            0x45707654f5d23c3f,
533            fidl::encoding::DynamicFlags::empty(),
534            _decode,
535        )
536    }
537
538    type StartResponseFut =
539        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
540    fn r#start(&self, mut start_info: StartInfo) -> Self::StartResponseFut {
541        fn _decode(
542            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
543        ) -> Result<(), fidl::Error> {
544            let _response = fidl::client::decode_transaction_body::<
545                fidl::encoding::EmptyPayload,
546                fidl::encoding::DefaultFuchsiaResourceDialect,
547                0x26645282fddf6f46,
548            >(_buf?)?;
549            Ok(_response)
550        }
551        self.client.send_query_and_decode::<VirtioBalloonStartRequest, ()>(
552            (&mut start_info,),
553            0x26645282fddf6f46,
554            fidl::encoding::DynamicFlags::empty(),
555            _decode,
556        )
557    }
558
559    type GetMemStatsResponseFut = fidl::client::QueryResponseFut<
560        (i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
561        fidl::encoding::DefaultFuchsiaResourceDialect,
562    >;
563    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut {
564        fn _decode(
565            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
566        ) -> Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error> {
567            let _response = fidl::client::decode_transaction_body::<
568                VirtioBalloonGetMemStatsResponse,
569                fidl::encoding::DefaultFuchsiaResourceDialect,
570                0x6641f4c296607e24,
571            >(_buf?)?;
572            Ok((_response.status, _response.mem_stats))
573        }
574        self.client.send_query_and_decode::<
575            fidl::encoding::EmptyPayload,
576            (i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
577        >(
578            (),
579            0x6641f4c296607e24,
580            fidl::encoding::DynamicFlags::empty(),
581            _decode,
582        )
583    }
584}
585
586pub struct VirtioBalloonEventStream {
587    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
588}
589
590impl std::marker::Unpin for VirtioBalloonEventStream {}
591
592impl futures::stream::FusedStream for VirtioBalloonEventStream {
593    fn is_terminated(&self) -> bool {
594        self.event_receiver.is_terminated()
595    }
596}
597
598impl futures::Stream for VirtioBalloonEventStream {
599    type Item = Result<VirtioBalloonEvent, 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        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
606            &mut self.event_receiver,
607            cx
608        )?) {
609            Some(buf) => std::task::Poll::Ready(Some(VirtioBalloonEvent::decode(buf))),
610            None => std::task::Poll::Ready(None),
611        }
612    }
613}
614
615#[derive(Debug)]
616pub enum VirtioBalloonEvent {}
617
618impl VirtioBalloonEvent {
619    /// Decodes a message buffer as a [`VirtioBalloonEvent`].
620    fn decode(
621        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
622    ) -> Result<VirtioBalloonEvent, fidl::Error> {
623        let (bytes, _handles) = buf.split_mut();
624        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
625        debug_assert_eq!(tx_header.tx_id, 0);
626        match tx_header.ordinal {
627            _ => Err(fidl::Error::UnknownOrdinal {
628                ordinal: tx_header.ordinal,
629                protocol_name: <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
630            }),
631        }
632    }
633}
634
635/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioBalloon.
636pub struct VirtioBalloonRequestStream {
637    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
638    is_terminated: bool,
639}
640
641impl std::marker::Unpin for VirtioBalloonRequestStream {}
642
643impl futures::stream::FusedStream for VirtioBalloonRequestStream {
644    fn is_terminated(&self) -> bool {
645        self.is_terminated
646    }
647}
648
649impl fidl::endpoints::RequestStream for VirtioBalloonRequestStream {
650    type Protocol = VirtioBalloonMarker;
651    type ControlHandle = VirtioBalloonControlHandle;
652
653    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
654        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
655    }
656
657    fn control_handle(&self) -> Self::ControlHandle {
658        VirtioBalloonControlHandle { inner: self.inner.clone() }
659    }
660
661    fn into_inner(
662        self,
663    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
664    {
665        (self.inner, self.is_terminated)
666    }
667
668    fn from_inner(
669        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
670        is_terminated: bool,
671    ) -> Self {
672        Self { inner, is_terminated }
673    }
674}
675
676impl futures::Stream for VirtioBalloonRequestStream {
677    type Item = Result<VirtioBalloonRequest, fidl::Error>;
678
679    fn poll_next(
680        mut self: std::pin::Pin<&mut Self>,
681        cx: &mut std::task::Context<'_>,
682    ) -> std::task::Poll<Option<Self::Item>> {
683        let this = &mut *self;
684        if this.inner.check_shutdown(cx) {
685            this.is_terminated = true;
686            return std::task::Poll::Ready(None);
687        }
688        if this.is_terminated {
689            panic!("polled VirtioBalloonRequestStream after completion");
690        }
691        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
692            |bytes, handles| {
693                match this.inner.channel().read_etc(cx, bytes, handles) {
694                    std::task::Poll::Ready(Ok(())) => {}
695                    std::task::Poll::Pending => return std::task::Poll::Pending,
696                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
697                        this.is_terminated = true;
698                        return std::task::Poll::Ready(None);
699                    }
700                    std::task::Poll::Ready(Err(e)) => {
701                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
702                            e.into(),
703                        ))))
704                    }
705                }
706
707                // A message has been received from the channel
708                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
709
710                std::task::Poll::Ready(Some(match header.ordinal {
711                    0x72b44fb963480b11 => {
712                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
713                        let mut req = fidl::new_empty!(
714                            VirtioDeviceConfigureQueueRequest,
715                            fidl::encoding::DefaultFuchsiaResourceDialect
716                        );
717                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
718                        let control_handle =
719                            VirtioBalloonControlHandle { inner: this.inner.clone() };
720                        Ok(VirtioBalloonRequest::ConfigureQueue {
721                            queue: req.queue,
722                            size: req.size,
723                            desc: req.desc,
724                            avail: req.avail,
725                            used: req.used,
726
727                            responder: VirtioBalloonConfigureQueueResponder {
728                                control_handle: std::mem::ManuallyDrop::new(control_handle),
729                                tx_id: header.tx_id,
730                            },
731                        })
732                    }
733                    0x6e3a61d652499244 => {
734                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
735                        let mut req = fidl::new_empty!(
736                            VirtioDeviceNotifyQueueRequest,
737                            fidl::encoding::DefaultFuchsiaResourceDialect
738                        );
739                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
740                        let control_handle =
741                            VirtioBalloonControlHandle { inner: this.inner.clone() };
742                        Ok(VirtioBalloonRequest::NotifyQueue { queue: req.queue, control_handle })
743                    }
744                    0x45707654f5d23c3f => {
745                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
746                        let mut req = fidl::new_empty!(
747                            VirtioDeviceReadyRequest,
748                            fidl::encoding::DefaultFuchsiaResourceDialect
749                        );
750                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
751                        let control_handle =
752                            VirtioBalloonControlHandle { inner: this.inner.clone() };
753                        Ok(VirtioBalloonRequest::Ready {
754                            negotiated_features: req.negotiated_features,
755
756                            responder: VirtioBalloonReadyResponder {
757                                control_handle: std::mem::ManuallyDrop::new(control_handle),
758                                tx_id: header.tx_id,
759                            },
760                        })
761                    }
762                    0x26645282fddf6f46 => {
763                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
764                        let mut req = fidl::new_empty!(
765                            VirtioBalloonStartRequest,
766                            fidl::encoding::DefaultFuchsiaResourceDialect
767                        );
768                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioBalloonStartRequest>(&header, _body_bytes, handles, &mut req)?;
769                        let control_handle =
770                            VirtioBalloonControlHandle { inner: this.inner.clone() };
771                        Ok(VirtioBalloonRequest::Start {
772                            start_info: req.start_info,
773
774                            responder: VirtioBalloonStartResponder {
775                                control_handle: std::mem::ManuallyDrop::new(control_handle),
776                                tx_id: header.tx_id,
777                            },
778                        })
779                    }
780                    0x6641f4c296607e24 => {
781                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
782                        let mut req = fidl::new_empty!(
783                            fidl::encoding::EmptyPayload,
784                            fidl::encoding::DefaultFuchsiaResourceDialect
785                        );
786                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
787                        let control_handle =
788                            VirtioBalloonControlHandle { inner: this.inner.clone() };
789                        Ok(VirtioBalloonRequest::GetMemStats {
790                            responder: VirtioBalloonGetMemStatsResponder {
791                                control_handle: std::mem::ManuallyDrop::new(control_handle),
792                                tx_id: header.tx_id,
793                            },
794                        })
795                    }
796                    _ => Err(fidl::Error::UnknownOrdinal {
797                        ordinal: header.ordinal,
798                        protocol_name:
799                            <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
800                    }),
801                }))
802            },
803        )
804    }
805}
806
807#[derive(Debug)]
808pub enum VirtioBalloonRequest {
809    /// Configure a `queue` for the device. This specifies the `size` and the
810    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
811    ConfigureQueue {
812        queue: u16,
813        size: u16,
814        desc: u64,
815        avail: u64,
816        used: u64,
817        responder: VirtioBalloonConfigureQueueResponder,
818    },
819    /// Notify a `queue` for the device. Primarily used for black-box testing.
820    NotifyQueue { queue: u16, control_handle: VirtioBalloonControlHandle },
821    /// Ready a device. This provides the set of `negotiated_features` that the
822    /// driver and device have agreed upon.
823    Ready { negotiated_features: u32, responder: VirtioBalloonReadyResponder },
824    /// Start the balloon device.
825    Start { start_info: StartInfo, responder: VirtioBalloonStartResponder },
826    /// Get memory statistics from the balloon device.
827    GetMemStats { responder: VirtioBalloonGetMemStatsResponder },
828}
829
830impl VirtioBalloonRequest {
831    #[allow(irrefutable_let_patterns)]
832    pub fn into_configure_queue(
833        self,
834    ) -> Option<(u16, u16, u64, u64, u64, VirtioBalloonConfigureQueueResponder)> {
835        if let VirtioBalloonRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
836            self
837        {
838            Some((queue, size, desc, avail, used, responder))
839        } else {
840            None
841        }
842    }
843
844    #[allow(irrefutable_let_patterns)]
845    pub fn into_notify_queue(self) -> Option<(u16, VirtioBalloonControlHandle)> {
846        if let VirtioBalloonRequest::NotifyQueue { queue, control_handle } = self {
847            Some((queue, control_handle))
848        } else {
849            None
850        }
851    }
852
853    #[allow(irrefutable_let_patterns)]
854    pub fn into_ready(self) -> Option<(u32, VirtioBalloonReadyResponder)> {
855        if let VirtioBalloonRequest::Ready { negotiated_features, responder } = self {
856            Some((negotiated_features, responder))
857        } else {
858            None
859        }
860    }
861
862    #[allow(irrefutable_let_patterns)]
863    pub fn into_start(self) -> Option<(StartInfo, VirtioBalloonStartResponder)> {
864        if let VirtioBalloonRequest::Start { start_info, responder } = self {
865            Some((start_info, responder))
866        } else {
867            None
868        }
869    }
870
871    #[allow(irrefutable_let_patterns)]
872    pub fn into_get_mem_stats(self) -> Option<(VirtioBalloonGetMemStatsResponder)> {
873        if let VirtioBalloonRequest::GetMemStats { responder } = self {
874            Some((responder))
875        } else {
876            None
877        }
878    }
879
880    /// Name of the method defined in FIDL
881    pub fn method_name(&self) -> &'static str {
882        match *self {
883            VirtioBalloonRequest::ConfigureQueue { .. } => "configure_queue",
884            VirtioBalloonRequest::NotifyQueue { .. } => "notify_queue",
885            VirtioBalloonRequest::Ready { .. } => "ready",
886            VirtioBalloonRequest::Start { .. } => "start",
887            VirtioBalloonRequest::GetMemStats { .. } => "get_mem_stats",
888        }
889    }
890}
891
892#[derive(Debug, Clone)]
893pub struct VirtioBalloonControlHandle {
894    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
895}
896
897impl fidl::endpoints::ControlHandle for VirtioBalloonControlHandle {
898    fn shutdown(&self) {
899        self.inner.shutdown()
900    }
901    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
902        self.inner.shutdown_with_epitaph(status)
903    }
904
905    fn is_closed(&self) -> bool {
906        self.inner.channel().is_closed()
907    }
908    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
909        self.inner.channel().on_closed()
910    }
911
912    #[cfg(target_os = "fuchsia")]
913    fn signal_peer(
914        &self,
915        clear_mask: zx::Signals,
916        set_mask: zx::Signals,
917    ) -> Result<(), zx_status::Status> {
918        use fidl::Peered;
919        self.inner.channel().signal_peer(clear_mask, set_mask)
920    }
921}
922
923impl VirtioBalloonControlHandle {}
924
925#[must_use = "FIDL methods require a response to be sent"]
926#[derive(Debug)]
927pub struct VirtioBalloonConfigureQueueResponder {
928    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
929    tx_id: u32,
930}
931
932/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
933/// if the responder is dropped without sending a response, so that the client
934/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
935impl std::ops::Drop for VirtioBalloonConfigureQueueResponder {
936    fn drop(&mut self) {
937        self.control_handle.shutdown();
938        // Safety: drops once, never accessed again
939        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
940    }
941}
942
943impl fidl::endpoints::Responder for VirtioBalloonConfigureQueueResponder {
944    type ControlHandle = VirtioBalloonControlHandle;
945
946    fn control_handle(&self) -> &VirtioBalloonControlHandle {
947        &self.control_handle
948    }
949
950    fn drop_without_shutdown(mut self) {
951        // Safety: drops once, never accessed again due to mem::forget
952        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
953        // Prevent Drop from running (which would shut down the channel)
954        std::mem::forget(self);
955    }
956}
957
958impl VirtioBalloonConfigureQueueResponder {
959    /// Sends a response to the FIDL transaction.
960    ///
961    /// Sets the channel to shutdown if an error occurs.
962    pub fn send(self) -> Result<(), fidl::Error> {
963        let _result = self.send_raw();
964        if _result.is_err() {
965            self.control_handle.shutdown();
966        }
967        self.drop_without_shutdown();
968        _result
969    }
970
971    /// Similar to "send" but does not shutdown the channel if an error occurs.
972    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
973        let _result = self.send_raw();
974        self.drop_without_shutdown();
975        _result
976    }
977
978    fn send_raw(&self) -> Result<(), fidl::Error> {
979        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
980            (),
981            self.tx_id,
982            0x72b44fb963480b11,
983            fidl::encoding::DynamicFlags::empty(),
984        )
985    }
986}
987
988#[must_use = "FIDL methods require a response to be sent"]
989#[derive(Debug)]
990pub struct VirtioBalloonReadyResponder {
991    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
992    tx_id: u32,
993}
994
995/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
996/// if the responder is dropped without sending a response, so that the client
997/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
998impl std::ops::Drop for VirtioBalloonReadyResponder {
999    fn drop(&mut self) {
1000        self.control_handle.shutdown();
1001        // Safety: drops once, never accessed again
1002        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1003    }
1004}
1005
1006impl fidl::endpoints::Responder for VirtioBalloonReadyResponder {
1007    type ControlHandle = VirtioBalloonControlHandle;
1008
1009    fn control_handle(&self) -> &VirtioBalloonControlHandle {
1010        &self.control_handle
1011    }
1012
1013    fn drop_without_shutdown(mut self) {
1014        // Safety: drops once, never accessed again due to mem::forget
1015        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1016        // Prevent Drop from running (which would shut down the channel)
1017        std::mem::forget(self);
1018    }
1019}
1020
1021impl VirtioBalloonReadyResponder {
1022    /// Sends a response to the FIDL transaction.
1023    ///
1024    /// Sets the channel to shutdown if an error occurs.
1025    pub fn send(self) -> Result<(), fidl::Error> {
1026        let _result = self.send_raw();
1027        if _result.is_err() {
1028            self.control_handle.shutdown();
1029        }
1030        self.drop_without_shutdown();
1031        _result
1032    }
1033
1034    /// Similar to "send" but does not shutdown the channel if an error occurs.
1035    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1036        let _result = self.send_raw();
1037        self.drop_without_shutdown();
1038        _result
1039    }
1040
1041    fn send_raw(&self) -> Result<(), fidl::Error> {
1042        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1043            (),
1044            self.tx_id,
1045            0x45707654f5d23c3f,
1046            fidl::encoding::DynamicFlags::empty(),
1047        )
1048    }
1049}
1050
1051#[must_use = "FIDL methods require a response to be sent"]
1052#[derive(Debug)]
1053pub struct VirtioBalloonStartResponder {
1054    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
1055    tx_id: u32,
1056}
1057
1058/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
1059/// if the responder is dropped without sending a response, so that the client
1060/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1061impl std::ops::Drop for VirtioBalloonStartResponder {
1062    fn drop(&mut self) {
1063        self.control_handle.shutdown();
1064        // Safety: drops once, never accessed again
1065        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1066    }
1067}
1068
1069impl fidl::endpoints::Responder for VirtioBalloonStartResponder {
1070    type ControlHandle = VirtioBalloonControlHandle;
1071
1072    fn control_handle(&self) -> &VirtioBalloonControlHandle {
1073        &self.control_handle
1074    }
1075
1076    fn drop_without_shutdown(mut self) {
1077        // Safety: drops once, never accessed again due to mem::forget
1078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1079        // Prevent Drop from running (which would shut down the channel)
1080        std::mem::forget(self);
1081    }
1082}
1083
1084impl VirtioBalloonStartResponder {
1085    /// Sends a response to the FIDL transaction.
1086    ///
1087    /// Sets the channel to shutdown if an error occurs.
1088    pub fn send(self) -> Result<(), fidl::Error> {
1089        let _result = self.send_raw();
1090        if _result.is_err() {
1091            self.control_handle.shutdown();
1092        }
1093        self.drop_without_shutdown();
1094        _result
1095    }
1096
1097    /// Similar to "send" but does not shutdown the channel if an error occurs.
1098    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1099        let _result = self.send_raw();
1100        self.drop_without_shutdown();
1101        _result
1102    }
1103
1104    fn send_raw(&self) -> Result<(), fidl::Error> {
1105        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1106            (),
1107            self.tx_id,
1108            0x26645282fddf6f46,
1109            fidl::encoding::DynamicFlags::empty(),
1110        )
1111    }
1112}
1113
1114#[must_use = "FIDL methods require a response to be sent"]
1115#[derive(Debug)]
1116pub struct VirtioBalloonGetMemStatsResponder {
1117    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
1118    tx_id: u32,
1119}
1120
1121/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
1122/// if the responder is dropped without sending a response, so that the client
1123/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1124impl std::ops::Drop for VirtioBalloonGetMemStatsResponder {
1125    fn drop(&mut self) {
1126        self.control_handle.shutdown();
1127        // Safety: drops once, never accessed again
1128        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1129    }
1130}
1131
1132impl fidl::endpoints::Responder for VirtioBalloonGetMemStatsResponder {
1133    type ControlHandle = VirtioBalloonControlHandle;
1134
1135    fn control_handle(&self) -> &VirtioBalloonControlHandle {
1136        &self.control_handle
1137    }
1138
1139    fn drop_without_shutdown(mut self) {
1140        // Safety: drops once, never accessed again due to mem::forget
1141        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1142        // Prevent Drop from running (which would shut down the channel)
1143        std::mem::forget(self);
1144    }
1145}
1146
1147impl VirtioBalloonGetMemStatsResponder {
1148    /// Sends a response to the FIDL transaction.
1149    ///
1150    /// Sets the channel to shutdown if an error occurs.
1151    pub fn send(
1152        self,
1153        mut status: i32,
1154        mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
1155    ) -> Result<(), fidl::Error> {
1156        let _result = self.send_raw(status, mem_stats);
1157        if _result.is_err() {
1158            self.control_handle.shutdown();
1159        }
1160        self.drop_without_shutdown();
1161        _result
1162    }
1163
1164    /// Similar to "send" but does not shutdown the channel if an error occurs.
1165    pub fn send_no_shutdown_on_err(
1166        self,
1167        mut status: i32,
1168        mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
1169    ) -> Result<(), fidl::Error> {
1170        let _result = self.send_raw(status, mem_stats);
1171        self.drop_without_shutdown();
1172        _result
1173    }
1174
1175    fn send_raw(
1176        &self,
1177        mut status: i32,
1178        mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
1179    ) -> Result<(), fidl::Error> {
1180        self.control_handle.inner.send::<VirtioBalloonGetMemStatsResponse>(
1181            (status, mem_stats),
1182            self.tx_id,
1183            0x6641f4c296607e24,
1184            fidl::encoding::DynamicFlags::empty(),
1185        )
1186    }
1187}
1188
1189#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1190pub struct VirtioBlockMarker;
1191
1192impl fidl::endpoints::ProtocolMarker for VirtioBlockMarker {
1193    type Proxy = VirtioBlockProxy;
1194    type RequestStream = VirtioBlockRequestStream;
1195    #[cfg(target_os = "fuchsia")]
1196    type SynchronousProxy = VirtioBlockSynchronousProxy;
1197
1198    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioBlock";
1199}
1200impl fidl::endpoints::DiscoverableProtocolMarker for VirtioBlockMarker {}
1201
1202pub trait VirtioBlockProxyInterface: Send + Sync {
1203    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1204    fn r#configure_queue(
1205        &self,
1206        queue: u16,
1207        size: u16,
1208        desc: u64,
1209        avail: u64,
1210        used: u64,
1211    ) -> Self::ConfigureQueueResponseFut;
1212    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
1213    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1214    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
1215    type StartResponseFut: std::future::Future<Output = Result<(u64, u32), fidl::Error>> + Send;
1216    fn r#start(
1217        &self,
1218        start_info: StartInfo,
1219        spec: fidl_fuchsia_virtualization::BlockSpec,
1220    ) -> Self::StartResponseFut;
1221}
1222#[derive(Debug)]
1223#[cfg(target_os = "fuchsia")]
1224pub struct VirtioBlockSynchronousProxy {
1225    client: fidl::client::sync::Client,
1226}
1227
1228#[cfg(target_os = "fuchsia")]
1229impl fidl::endpoints::SynchronousProxy for VirtioBlockSynchronousProxy {
1230    type Proxy = VirtioBlockProxy;
1231    type Protocol = VirtioBlockMarker;
1232
1233    fn from_channel(inner: fidl::Channel) -> Self {
1234        Self::new(inner)
1235    }
1236
1237    fn into_channel(self) -> fidl::Channel {
1238        self.client.into_channel()
1239    }
1240
1241    fn as_channel(&self) -> &fidl::Channel {
1242        self.client.as_channel()
1243    }
1244}
1245
1246#[cfg(target_os = "fuchsia")]
1247impl VirtioBlockSynchronousProxy {
1248    pub fn new(channel: fidl::Channel) -> Self {
1249        let protocol_name = <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1250        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1251    }
1252
1253    pub fn into_channel(self) -> fidl::Channel {
1254        self.client.into_channel()
1255    }
1256
1257    /// Waits until an event arrives and returns it. It is safe for other
1258    /// threads to make concurrent requests while waiting for an event.
1259    pub fn wait_for_event(
1260        &self,
1261        deadline: zx::MonotonicInstant,
1262    ) -> Result<VirtioBlockEvent, fidl::Error> {
1263        VirtioBlockEvent::decode(self.client.wait_for_event(deadline)?)
1264    }
1265
1266    /// Configure a `queue` for the device. This specifies the `size` and the
1267    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
1268    pub fn r#configure_queue(
1269        &self,
1270        mut queue: u16,
1271        mut size: u16,
1272        mut desc: u64,
1273        mut avail: u64,
1274        mut used: u64,
1275        ___deadline: zx::MonotonicInstant,
1276    ) -> Result<(), fidl::Error> {
1277        let _response = self
1278            .client
1279            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
1280                (queue, size, desc, avail, used),
1281                0x72b44fb963480b11,
1282                fidl::encoding::DynamicFlags::empty(),
1283                ___deadline,
1284            )?;
1285        Ok(_response)
1286    }
1287
1288    /// Notify a `queue` for the device. Primarily used for black-box testing.
1289    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
1290        self.client.send::<VirtioDeviceNotifyQueueRequest>(
1291            (queue,),
1292            0x6e3a61d652499244,
1293            fidl::encoding::DynamicFlags::empty(),
1294        )
1295    }
1296
1297    /// Ready a device. This provides the set of `negotiated_features` that the
1298    /// driver and device have agreed upon.
1299    pub fn r#ready(
1300        &self,
1301        mut negotiated_features: u32,
1302        ___deadline: zx::MonotonicInstant,
1303    ) -> Result<(), fidl::Error> {
1304        let _response =
1305            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
1306                (negotiated_features,),
1307                0x45707654f5d23c3f,
1308                fidl::encoding::DynamicFlags::empty(),
1309                ___deadline,
1310            )?;
1311        Ok(_response)
1312    }
1313
1314    /// Start the block device.
1315    pub fn r#start(
1316        &self,
1317        mut start_info: StartInfo,
1318        mut spec: fidl_fuchsia_virtualization::BlockSpec,
1319        ___deadline: zx::MonotonicInstant,
1320    ) -> Result<(u64, u32), fidl::Error> {
1321        let _response =
1322            self.client.send_query::<VirtioBlockStartRequest, VirtioBlockStartResponse>(
1323                (&mut start_info, &mut spec),
1324                0x5ef6a4b9ce9adcb2,
1325                fidl::encoding::DynamicFlags::empty(),
1326                ___deadline,
1327            )?;
1328        Ok((_response.capacity, _response.block_size))
1329    }
1330}
1331
1332#[cfg(target_os = "fuchsia")]
1333impl From<VirtioBlockSynchronousProxy> for zx::Handle {
1334    fn from(value: VirtioBlockSynchronousProxy) -> Self {
1335        value.into_channel().into()
1336    }
1337}
1338
1339#[cfg(target_os = "fuchsia")]
1340impl From<fidl::Channel> for VirtioBlockSynchronousProxy {
1341    fn from(value: fidl::Channel) -> Self {
1342        Self::new(value)
1343    }
1344}
1345
1346#[cfg(target_os = "fuchsia")]
1347impl fidl::endpoints::FromClient for VirtioBlockSynchronousProxy {
1348    type Protocol = VirtioBlockMarker;
1349
1350    fn from_client(value: fidl::endpoints::ClientEnd<VirtioBlockMarker>) -> Self {
1351        Self::new(value.into_channel())
1352    }
1353}
1354
1355#[derive(Debug, Clone)]
1356pub struct VirtioBlockProxy {
1357    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1358}
1359
1360impl fidl::endpoints::Proxy for VirtioBlockProxy {
1361    type Protocol = VirtioBlockMarker;
1362
1363    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1364        Self::new(inner)
1365    }
1366
1367    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1368        self.client.into_channel().map_err(|client| Self { client })
1369    }
1370
1371    fn as_channel(&self) -> &::fidl::AsyncChannel {
1372        self.client.as_channel()
1373    }
1374}
1375
1376impl VirtioBlockProxy {
1377    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioBlock.
1378    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1379        let protocol_name = <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1380        Self { client: fidl::client::Client::new(channel, protocol_name) }
1381    }
1382
1383    /// Get a Stream of events from the remote end of the protocol.
1384    ///
1385    /// # Panics
1386    ///
1387    /// Panics if the event stream was already taken.
1388    pub fn take_event_stream(&self) -> VirtioBlockEventStream {
1389        VirtioBlockEventStream { event_receiver: self.client.take_event_receiver() }
1390    }
1391
1392    /// Configure a `queue` for the device. This specifies the `size` and the
1393    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
1394    pub fn r#configure_queue(
1395        &self,
1396        mut queue: u16,
1397        mut size: u16,
1398        mut desc: u64,
1399        mut avail: u64,
1400        mut used: u64,
1401    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1402        VirtioBlockProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
1403    }
1404
1405    /// Notify a `queue` for the device. Primarily used for black-box testing.
1406    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
1407        VirtioBlockProxyInterface::r#notify_queue(self, queue)
1408    }
1409
1410    /// Ready a device. This provides the set of `negotiated_features` that the
1411    /// driver and device have agreed upon.
1412    pub fn r#ready(
1413        &self,
1414        mut negotiated_features: u32,
1415    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1416        VirtioBlockProxyInterface::r#ready(self, negotiated_features)
1417    }
1418
1419    /// Start the block device.
1420    pub fn r#start(
1421        &self,
1422        mut start_info: StartInfo,
1423        mut spec: fidl_fuchsia_virtualization::BlockSpec,
1424    ) -> fidl::client::QueryResponseFut<(u64, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
1425    {
1426        VirtioBlockProxyInterface::r#start(self, start_info, spec)
1427    }
1428}
1429
1430impl VirtioBlockProxyInterface for VirtioBlockProxy {
1431    type ConfigureQueueResponseFut =
1432        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1433    fn r#configure_queue(
1434        &self,
1435        mut queue: u16,
1436        mut size: u16,
1437        mut desc: u64,
1438        mut avail: u64,
1439        mut used: u64,
1440    ) -> Self::ConfigureQueueResponseFut {
1441        fn _decode(
1442            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1443        ) -> Result<(), fidl::Error> {
1444            let _response = fidl::client::decode_transaction_body::<
1445                fidl::encoding::EmptyPayload,
1446                fidl::encoding::DefaultFuchsiaResourceDialect,
1447                0x72b44fb963480b11,
1448            >(_buf?)?;
1449            Ok(_response)
1450        }
1451        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
1452            (queue, size, desc, avail, used),
1453            0x72b44fb963480b11,
1454            fidl::encoding::DynamicFlags::empty(),
1455            _decode,
1456        )
1457    }
1458
1459    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
1460        self.client.send::<VirtioDeviceNotifyQueueRequest>(
1461            (queue,),
1462            0x6e3a61d652499244,
1463            fidl::encoding::DynamicFlags::empty(),
1464        )
1465    }
1466
1467    type ReadyResponseFut =
1468        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1469    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
1470        fn _decode(
1471            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1472        ) -> Result<(), fidl::Error> {
1473            let _response = fidl::client::decode_transaction_body::<
1474                fidl::encoding::EmptyPayload,
1475                fidl::encoding::DefaultFuchsiaResourceDialect,
1476                0x45707654f5d23c3f,
1477            >(_buf?)?;
1478            Ok(_response)
1479        }
1480        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
1481            (negotiated_features,),
1482            0x45707654f5d23c3f,
1483            fidl::encoding::DynamicFlags::empty(),
1484            _decode,
1485        )
1486    }
1487
1488    type StartResponseFut =
1489        fidl::client::QueryResponseFut<(u64, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
1490    fn r#start(
1491        &self,
1492        mut start_info: StartInfo,
1493        mut spec: fidl_fuchsia_virtualization::BlockSpec,
1494    ) -> Self::StartResponseFut {
1495        fn _decode(
1496            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1497        ) -> Result<(u64, u32), fidl::Error> {
1498            let _response = fidl::client::decode_transaction_body::<
1499                VirtioBlockStartResponse,
1500                fidl::encoding::DefaultFuchsiaResourceDialect,
1501                0x5ef6a4b9ce9adcb2,
1502            >(_buf?)?;
1503            Ok((_response.capacity, _response.block_size))
1504        }
1505        self.client.send_query_and_decode::<VirtioBlockStartRequest, (u64, u32)>(
1506            (&mut start_info, &mut spec),
1507            0x5ef6a4b9ce9adcb2,
1508            fidl::encoding::DynamicFlags::empty(),
1509            _decode,
1510        )
1511    }
1512}
1513
1514pub struct VirtioBlockEventStream {
1515    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1516}
1517
1518impl std::marker::Unpin for VirtioBlockEventStream {}
1519
1520impl futures::stream::FusedStream for VirtioBlockEventStream {
1521    fn is_terminated(&self) -> bool {
1522        self.event_receiver.is_terminated()
1523    }
1524}
1525
1526impl futures::Stream for VirtioBlockEventStream {
1527    type Item = Result<VirtioBlockEvent, fidl::Error>;
1528
1529    fn poll_next(
1530        mut self: std::pin::Pin<&mut Self>,
1531        cx: &mut std::task::Context<'_>,
1532    ) -> std::task::Poll<Option<Self::Item>> {
1533        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1534            &mut self.event_receiver,
1535            cx
1536        )?) {
1537            Some(buf) => std::task::Poll::Ready(Some(VirtioBlockEvent::decode(buf))),
1538            None => std::task::Poll::Ready(None),
1539        }
1540    }
1541}
1542
1543#[derive(Debug)]
1544pub enum VirtioBlockEvent {}
1545
1546impl VirtioBlockEvent {
1547    /// Decodes a message buffer as a [`VirtioBlockEvent`].
1548    fn decode(
1549        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1550    ) -> Result<VirtioBlockEvent, fidl::Error> {
1551        let (bytes, _handles) = buf.split_mut();
1552        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1553        debug_assert_eq!(tx_header.tx_id, 0);
1554        match tx_header.ordinal {
1555            _ => Err(fidl::Error::UnknownOrdinal {
1556                ordinal: tx_header.ordinal,
1557                protocol_name: <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1558            }),
1559        }
1560    }
1561}
1562
1563/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioBlock.
1564pub struct VirtioBlockRequestStream {
1565    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1566    is_terminated: bool,
1567}
1568
1569impl std::marker::Unpin for VirtioBlockRequestStream {}
1570
1571impl futures::stream::FusedStream for VirtioBlockRequestStream {
1572    fn is_terminated(&self) -> bool {
1573        self.is_terminated
1574    }
1575}
1576
1577impl fidl::endpoints::RequestStream for VirtioBlockRequestStream {
1578    type Protocol = VirtioBlockMarker;
1579    type ControlHandle = VirtioBlockControlHandle;
1580
1581    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1582        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1583    }
1584
1585    fn control_handle(&self) -> Self::ControlHandle {
1586        VirtioBlockControlHandle { inner: self.inner.clone() }
1587    }
1588
1589    fn into_inner(
1590        self,
1591    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1592    {
1593        (self.inner, self.is_terminated)
1594    }
1595
1596    fn from_inner(
1597        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1598        is_terminated: bool,
1599    ) -> Self {
1600        Self { inner, is_terminated }
1601    }
1602}
1603
1604impl futures::Stream for VirtioBlockRequestStream {
1605    type Item = Result<VirtioBlockRequest, fidl::Error>;
1606
1607    fn poll_next(
1608        mut self: std::pin::Pin<&mut Self>,
1609        cx: &mut std::task::Context<'_>,
1610    ) -> std::task::Poll<Option<Self::Item>> {
1611        let this = &mut *self;
1612        if this.inner.check_shutdown(cx) {
1613            this.is_terminated = true;
1614            return std::task::Poll::Ready(None);
1615        }
1616        if this.is_terminated {
1617            panic!("polled VirtioBlockRequestStream after completion");
1618        }
1619        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1620            |bytes, handles| {
1621                match this.inner.channel().read_etc(cx, bytes, handles) {
1622                    std::task::Poll::Ready(Ok(())) => {}
1623                    std::task::Poll::Pending => return std::task::Poll::Pending,
1624                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1625                        this.is_terminated = true;
1626                        return std::task::Poll::Ready(None);
1627                    }
1628                    std::task::Poll::Ready(Err(e)) => {
1629                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1630                            e.into(),
1631                        ))))
1632                    }
1633                }
1634
1635                // A message has been received from the channel
1636                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1637
1638                std::task::Poll::Ready(Some(match header.ordinal {
1639                    0x72b44fb963480b11 => {
1640                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1641                        let mut req = fidl::new_empty!(
1642                            VirtioDeviceConfigureQueueRequest,
1643                            fidl::encoding::DefaultFuchsiaResourceDialect
1644                        );
1645                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
1646                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1647                        Ok(VirtioBlockRequest::ConfigureQueue {
1648                            queue: req.queue,
1649                            size: req.size,
1650                            desc: req.desc,
1651                            avail: req.avail,
1652                            used: req.used,
1653
1654                            responder: VirtioBlockConfigureQueueResponder {
1655                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1656                                tx_id: header.tx_id,
1657                            },
1658                        })
1659                    }
1660                    0x6e3a61d652499244 => {
1661                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1662                        let mut req = fidl::new_empty!(
1663                            VirtioDeviceNotifyQueueRequest,
1664                            fidl::encoding::DefaultFuchsiaResourceDialect
1665                        );
1666                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
1667                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1668                        Ok(VirtioBlockRequest::NotifyQueue { queue: req.queue, control_handle })
1669                    }
1670                    0x45707654f5d23c3f => {
1671                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1672                        let mut req = fidl::new_empty!(
1673                            VirtioDeviceReadyRequest,
1674                            fidl::encoding::DefaultFuchsiaResourceDialect
1675                        );
1676                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
1677                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1678                        Ok(VirtioBlockRequest::Ready {
1679                            negotiated_features: req.negotiated_features,
1680
1681                            responder: VirtioBlockReadyResponder {
1682                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1683                                tx_id: header.tx_id,
1684                            },
1685                        })
1686                    }
1687                    0x5ef6a4b9ce9adcb2 => {
1688                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1689                        let mut req = fidl::new_empty!(
1690                            VirtioBlockStartRequest,
1691                            fidl::encoding::DefaultFuchsiaResourceDialect
1692                        );
1693                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioBlockStartRequest>(&header, _body_bytes, handles, &mut req)?;
1694                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1695                        Ok(VirtioBlockRequest::Start {
1696                            start_info: req.start_info,
1697                            spec: req.spec,
1698
1699                            responder: VirtioBlockStartResponder {
1700                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1701                                tx_id: header.tx_id,
1702                            },
1703                        })
1704                    }
1705                    _ => Err(fidl::Error::UnknownOrdinal {
1706                        ordinal: header.ordinal,
1707                        protocol_name:
1708                            <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1709                    }),
1710                }))
1711            },
1712        )
1713    }
1714}
1715
1716#[derive(Debug)]
1717pub enum VirtioBlockRequest {
1718    /// Configure a `queue` for the device. This specifies the `size` and the
1719    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
1720    ConfigureQueue {
1721        queue: u16,
1722        size: u16,
1723        desc: u64,
1724        avail: u64,
1725        used: u64,
1726        responder: VirtioBlockConfigureQueueResponder,
1727    },
1728    /// Notify a `queue` for the device. Primarily used for black-box testing.
1729    NotifyQueue { queue: u16, control_handle: VirtioBlockControlHandle },
1730    /// Ready a device. This provides the set of `negotiated_features` that the
1731    /// driver and device have agreed upon.
1732    Ready { negotiated_features: u32, responder: VirtioBlockReadyResponder },
1733    /// Start the block device.
1734    Start {
1735        start_info: StartInfo,
1736        spec: fidl_fuchsia_virtualization::BlockSpec,
1737        responder: VirtioBlockStartResponder,
1738    },
1739}
1740
1741impl VirtioBlockRequest {
1742    #[allow(irrefutable_let_patterns)]
1743    pub fn into_configure_queue(
1744        self,
1745    ) -> Option<(u16, u16, u64, u64, u64, VirtioBlockConfigureQueueResponder)> {
1746        if let VirtioBlockRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
1747            self
1748        {
1749            Some((queue, size, desc, avail, used, responder))
1750        } else {
1751            None
1752        }
1753    }
1754
1755    #[allow(irrefutable_let_patterns)]
1756    pub fn into_notify_queue(self) -> Option<(u16, VirtioBlockControlHandle)> {
1757        if let VirtioBlockRequest::NotifyQueue { queue, control_handle } = self {
1758            Some((queue, control_handle))
1759        } else {
1760            None
1761        }
1762    }
1763
1764    #[allow(irrefutable_let_patterns)]
1765    pub fn into_ready(self) -> Option<(u32, VirtioBlockReadyResponder)> {
1766        if let VirtioBlockRequest::Ready { negotiated_features, responder } = self {
1767            Some((negotiated_features, responder))
1768        } else {
1769            None
1770        }
1771    }
1772
1773    #[allow(irrefutable_let_patterns)]
1774    pub fn into_start(
1775        self,
1776    ) -> Option<(StartInfo, fidl_fuchsia_virtualization::BlockSpec, VirtioBlockStartResponder)>
1777    {
1778        if let VirtioBlockRequest::Start { start_info, spec, responder } = self {
1779            Some((start_info, spec, responder))
1780        } else {
1781            None
1782        }
1783    }
1784
1785    /// Name of the method defined in FIDL
1786    pub fn method_name(&self) -> &'static str {
1787        match *self {
1788            VirtioBlockRequest::ConfigureQueue { .. } => "configure_queue",
1789            VirtioBlockRequest::NotifyQueue { .. } => "notify_queue",
1790            VirtioBlockRequest::Ready { .. } => "ready",
1791            VirtioBlockRequest::Start { .. } => "start",
1792        }
1793    }
1794}
1795
1796#[derive(Debug, Clone)]
1797pub struct VirtioBlockControlHandle {
1798    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1799}
1800
1801impl fidl::endpoints::ControlHandle for VirtioBlockControlHandle {
1802    fn shutdown(&self) {
1803        self.inner.shutdown()
1804    }
1805    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1806        self.inner.shutdown_with_epitaph(status)
1807    }
1808
1809    fn is_closed(&self) -> bool {
1810        self.inner.channel().is_closed()
1811    }
1812    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1813        self.inner.channel().on_closed()
1814    }
1815
1816    #[cfg(target_os = "fuchsia")]
1817    fn signal_peer(
1818        &self,
1819        clear_mask: zx::Signals,
1820        set_mask: zx::Signals,
1821    ) -> Result<(), zx_status::Status> {
1822        use fidl::Peered;
1823        self.inner.channel().signal_peer(clear_mask, set_mask)
1824    }
1825}
1826
1827impl VirtioBlockControlHandle {}
1828
1829#[must_use = "FIDL methods require a response to be sent"]
1830#[derive(Debug)]
1831pub struct VirtioBlockConfigureQueueResponder {
1832    control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
1833    tx_id: u32,
1834}
1835
1836/// Set the the channel to be shutdown (see [`VirtioBlockControlHandle::shutdown`])
1837/// if the responder is dropped without sending a response, so that the client
1838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1839impl std::ops::Drop for VirtioBlockConfigureQueueResponder {
1840    fn drop(&mut self) {
1841        self.control_handle.shutdown();
1842        // Safety: drops once, never accessed again
1843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1844    }
1845}
1846
1847impl fidl::endpoints::Responder for VirtioBlockConfigureQueueResponder {
1848    type ControlHandle = VirtioBlockControlHandle;
1849
1850    fn control_handle(&self) -> &VirtioBlockControlHandle {
1851        &self.control_handle
1852    }
1853
1854    fn drop_without_shutdown(mut self) {
1855        // Safety: drops once, never accessed again due to mem::forget
1856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1857        // Prevent Drop from running (which would shut down the channel)
1858        std::mem::forget(self);
1859    }
1860}
1861
1862impl VirtioBlockConfigureQueueResponder {
1863    /// Sends a response to the FIDL transaction.
1864    ///
1865    /// Sets the channel to shutdown if an error occurs.
1866    pub fn send(self) -> Result<(), fidl::Error> {
1867        let _result = self.send_raw();
1868        if _result.is_err() {
1869            self.control_handle.shutdown();
1870        }
1871        self.drop_without_shutdown();
1872        _result
1873    }
1874
1875    /// Similar to "send" but does not shutdown the channel if an error occurs.
1876    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1877        let _result = self.send_raw();
1878        self.drop_without_shutdown();
1879        _result
1880    }
1881
1882    fn send_raw(&self) -> Result<(), fidl::Error> {
1883        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1884            (),
1885            self.tx_id,
1886            0x72b44fb963480b11,
1887            fidl::encoding::DynamicFlags::empty(),
1888        )
1889    }
1890}
1891
1892#[must_use = "FIDL methods require a response to be sent"]
1893#[derive(Debug)]
1894pub struct VirtioBlockReadyResponder {
1895    control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
1896    tx_id: u32,
1897}
1898
1899/// Set the the channel to be shutdown (see [`VirtioBlockControlHandle::shutdown`])
1900/// if the responder is dropped without sending a response, so that the client
1901/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1902impl std::ops::Drop for VirtioBlockReadyResponder {
1903    fn drop(&mut self) {
1904        self.control_handle.shutdown();
1905        // Safety: drops once, never accessed again
1906        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1907    }
1908}
1909
1910impl fidl::endpoints::Responder for VirtioBlockReadyResponder {
1911    type ControlHandle = VirtioBlockControlHandle;
1912
1913    fn control_handle(&self) -> &VirtioBlockControlHandle {
1914        &self.control_handle
1915    }
1916
1917    fn drop_without_shutdown(mut self) {
1918        // Safety: drops once, never accessed again due to mem::forget
1919        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1920        // Prevent Drop from running (which would shut down the channel)
1921        std::mem::forget(self);
1922    }
1923}
1924
1925impl VirtioBlockReadyResponder {
1926    /// Sends a response to the FIDL transaction.
1927    ///
1928    /// Sets the channel to shutdown if an error occurs.
1929    pub fn send(self) -> Result<(), fidl::Error> {
1930        let _result = self.send_raw();
1931        if _result.is_err() {
1932            self.control_handle.shutdown();
1933        }
1934        self.drop_without_shutdown();
1935        _result
1936    }
1937
1938    /// Similar to "send" but does not shutdown the channel if an error occurs.
1939    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1940        let _result = self.send_raw();
1941        self.drop_without_shutdown();
1942        _result
1943    }
1944
1945    fn send_raw(&self) -> Result<(), fidl::Error> {
1946        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1947            (),
1948            self.tx_id,
1949            0x45707654f5d23c3f,
1950            fidl::encoding::DynamicFlags::empty(),
1951        )
1952    }
1953}
1954
1955#[must_use = "FIDL methods require a response to be sent"]
1956#[derive(Debug)]
1957pub struct VirtioBlockStartResponder {
1958    control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
1959    tx_id: u32,
1960}
1961
1962/// Set the the channel to be shutdown (see [`VirtioBlockControlHandle::shutdown`])
1963/// if the responder is dropped without sending a response, so that the client
1964/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1965impl std::ops::Drop for VirtioBlockStartResponder {
1966    fn drop(&mut self) {
1967        self.control_handle.shutdown();
1968        // Safety: drops once, never accessed again
1969        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1970    }
1971}
1972
1973impl fidl::endpoints::Responder for VirtioBlockStartResponder {
1974    type ControlHandle = VirtioBlockControlHandle;
1975
1976    fn control_handle(&self) -> &VirtioBlockControlHandle {
1977        &self.control_handle
1978    }
1979
1980    fn drop_without_shutdown(mut self) {
1981        // Safety: drops once, never accessed again due to mem::forget
1982        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1983        // Prevent Drop from running (which would shut down the channel)
1984        std::mem::forget(self);
1985    }
1986}
1987
1988impl VirtioBlockStartResponder {
1989    /// Sends a response to the FIDL transaction.
1990    ///
1991    /// Sets the channel to shutdown if an error occurs.
1992    pub fn send(self, mut capacity: u64, mut block_size: u32) -> Result<(), fidl::Error> {
1993        let _result = self.send_raw(capacity, block_size);
1994        if _result.is_err() {
1995            self.control_handle.shutdown();
1996        }
1997        self.drop_without_shutdown();
1998        _result
1999    }
2000
2001    /// Similar to "send" but does not shutdown the channel if an error occurs.
2002    pub fn send_no_shutdown_on_err(
2003        self,
2004        mut capacity: u64,
2005        mut block_size: u32,
2006    ) -> Result<(), fidl::Error> {
2007        let _result = self.send_raw(capacity, block_size);
2008        self.drop_without_shutdown();
2009        _result
2010    }
2011
2012    fn send_raw(&self, mut capacity: u64, mut block_size: u32) -> Result<(), fidl::Error> {
2013        self.control_handle.inner.send::<VirtioBlockStartResponse>(
2014            (capacity, block_size),
2015            self.tx_id,
2016            0x5ef6a4b9ce9adcb2,
2017            fidl::encoding::DynamicFlags::empty(),
2018        )
2019    }
2020}
2021
2022#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2023pub struct VirtioConsoleMarker;
2024
2025impl fidl::endpoints::ProtocolMarker for VirtioConsoleMarker {
2026    type Proxy = VirtioConsoleProxy;
2027    type RequestStream = VirtioConsoleRequestStream;
2028    #[cfg(target_os = "fuchsia")]
2029    type SynchronousProxy = VirtioConsoleSynchronousProxy;
2030
2031    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioConsole";
2032}
2033impl fidl::endpoints::DiscoverableProtocolMarker for VirtioConsoleMarker {}
2034
2035pub trait VirtioConsoleProxyInterface: Send + Sync {
2036    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2037    fn r#configure_queue(
2038        &self,
2039        queue: u16,
2040        size: u16,
2041        desc: u64,
2042        avail: u64,
2043        used: u64,
2044    ) -> Self::ConfigureQueueResponseFut;
2045    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
2046    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2047    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
2048    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2049    fn r#start(&self, start_info: StartInfo, socket: fidl::Socket) -> Self::StartResponseFut;
2050}
2051#[derive(Debug)]
2052#[cfg(target_os = "fuchsia")]
2053pub struct VirtioConsoleSynchronousProxy {
2054    client: fidl::client::sync::Client,
2055}
2056
2057#[cfg(target_os = "fuchsia")]
2058impl fidl::endpoints::SynchronousProxy for VirtioConsoleSynchronousProxy {
2059    type Proxy = VirtioConsoleProxy;
2060    type Protocol = VirtioConsoleMarker;
2061
2062    fn from_channel(inner: fidl::Channel) -> Self {
2063        Self::new(inner)
2064    }
2065
2066    fn into_channel(self) -> fidl::Channel {
2067        self.client.into_channel()
2068    }
2069
2070    fn as_channel(&self) -> &fidl::Channel {
2071        self.client.as_channel()
2072    }
2073}
2074
2075#[cfg(target_os = "fuchsia")]
2076impl VirtioConsoleSynchronousProxy {
2077    pub fn new(channel: fidl::Channel) -> Self {
2078        let protocol_name = <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2079        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2080    }
2081
2082    pub fn into_channel(self) -> fidl::Channel {
2083        self.client.into_channel()
2084    }
2085
2086    /// Waits until an event arrives and returns it. It is safe for other
2087    /// threads to make concurrent requests while waiting for an event.
2088    pub fn wait_for_event(
2089        &self,
2090        deadline: zx::MonotonicInstant,
2091    ) -> Result<VirtioConsoleEvent, fidl::Error> {
2092        VirtioConsoleEvent::decode(self.client.wait_for_event(deadline)?)
2093    }
2094
2095    /// Configure a `queue` for the device. This specifies the `size` and the
2096    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2097    pub fn r#configure_queue(
2098        &self,
2099        mut queue: u16,
2100        mut size: u16,
2101        mut desc: u64,
2102        mut avail: u64,
2103        mut used: u64,
2104        ___deadline: zx::MonotonicInstant,
2105    ) -> Result<(), fidl::Error> {
2106        let _response = self
2107            .client
2108            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
2109                (queue, size, desc, avail, used),
2110                0x72b44fb963480b11,
2111                fidl::encoding::DynamicFlags::empty(),
2112                ___deadline,
2113            )?;
2114        Ok(_response)
2115    }
2116
2117    /// Notify a `queue` for the device. Primarily used for black-box testing.
2118    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2119        self.client.send::<VirtioDeviceNotifyQueueRequest>(
2120            (queue,),
2121            0x6e3a61d652499244,
2122            fidl::encoding::DynamicFlags::empty(),
2123        )
2124    }
2125
2126    /// Ready a device. This provides the set of `negotiated_features` that the
2127    /// driver and device have agreed upon.
2128    pub fn r#ready(
2129        &self,
2130        mut negotiated_features: u32,
2131        ___deadline: zx::MonotonicInstant,
2132    ) -> Result<(), fidl::Error> {
2133        let _response =
2134            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
2135                (negotiated_features,),
2136                0x45707654f5d23c3f,
2137                fidl::encoding::DynamicFlags::empty(),
2138                ___deadline,
2139            )?;
2140        Ok(_response)
2141    }
2142
2143    /// Start the console device. This uses `socket` to handle input and output.
2144    pub fn r#start(
2145        &self,
2146        mut start_info: StartInfo,
2147        mut socket: fidl::Socket,
2148        ___deadline: zx::MonotonicInstant,
2149    ) -> Result<(), fidl::Error> {
2150        let _response =
2151            self.client.send_query::<VirtioConsoleStartRequest, fidl::encoding::EmptyPayload>(
2152                (&mut start_info, socket),
2153                0x10a6267f2ab7e24c,
2154                fidl::encoding::DynamicFlags::empty(),
2155                ___deadline,
2156            )?;
2157        Ok(_response)
2158    }
2159}
2160
2161#[cfg(target_os = "fuchsia")]
2162impl From<VirtioConsoleSynchronousProxy> for zx::Handle {
2163    fn from(value: VirtioConsoleSynchronousProxy) -> Self {
2164        value.into_channel().into()
2165    }
2166}
2167
2168#[cfg(target_os = "fuchsia")]
2169impl From<fidl::Channel> for VirtioConsoleSynchronousProxy {
2170    fn from(value: fidl::Channel) -> Self {
2171        Self::new(value)
2172    }
2173}
2174
2175#[cfg(target_os = "fuchsia")]
2176impl fidl::endpoints::FromClient for VirtioConsoleSynchronousProxy {
2177    type Protocol = VirtioConsoleMarker;
2178
2179    fn from_client(value: fidl::endpoints::ClientEnd<VirtioConsoleMarker>) -> Self {
2180        Self::new(value.into_channel())
2181    }
2182}
2183
2184#[derive(Debug, Clone)]
2185pub struct VirtioConsoleProxy {
2186    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2187}
2188
2189impl fidl::endpoints::Proxy for VirtioConsoleProxy {
2190    type Protocol = VirtioConsoleMarker;
2191
2192    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2193        Self::new(inner)
2194    }
2195
2196    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2197        self.client.into_channel().map_err(|client| Self { client })
2198    }
2199
2200    fn as_channel(&self) -> &::fidl::AsyncChannel {
2201        self.client.as_channel()
2202    }
2203}
2204
2205impl VirtioConsoleProxy {
2206    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioConsole.
2207    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2208        let protocol_name = <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2209        Self { client: fidl::client::Client::new(channel, protocol_name) }
2210    }
2211
2212    /// Get a Stream of events from the remote end of the protocol.
2213    ///
2214    /// # Panics
2215    ///
2216    /// Panics if the event stream was already taken.
2217    pub fn take_event_stream(&self) -> VirtioConsoleEventStream {
2218        VirtioConsoleEventStream { event_receiver: self.client.take_event_receiver() }
2219    }
2220
2221    /// Configure a `queue` for the device. This specifies the `size` and the
2222    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2223    pub fn r#configure_queue(
2224        &self,
2225        mut queue: u16,
2226        mut size: u16,
2227        mut desc: u64,
2228        mut avail: u64,
2229        mut used: u64,
2230    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2231        VirtioConsoleProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
2232    }
2233
2234    /// Notify a `queue` for the device. Primarily used for black-box testing.
2235    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2236        VirtioConsoleProxyInterface::r#notify_queue(self, queue)
2237    }
2238
2239    /// Ready a device. This provides the set of `negotiated_features` that the
2240    /// driver and device have agreed upon.
2241    pub fn r#ready(
2242        &self,
2243        mut negotiated_features: u32,
2244    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2245        VirtioConsoleProxyInterface::r#ready(self, negotiated_features)
2246    }
2247
2248    /// Start the console device. This uses `socket` to handle input and output.
2249    pub fn r#start(
2250        &self,
2251        mut start_info: StartInfo,
2252        mut socket: fidl::Socket,
2253    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2254        VirtioConsoleProxyInterface::r#start(self, start_info, socket)
2255    }
2256}
2257
2258impl VirtioConsoleProxyInterface for VirtioConsoleProxy {
2259    type ConfigureQueueResponseFut =
2260        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2261    fn r#configure_queue(
2262        &self,
2263        mut queue: u16,
2264        mut size: u16,
2265        mut desc: u64,
2266        mut avail: u64,
2267        mut used: u64,
2268    ) -> Self::ConfigureQueueResponseFut {
2269        fn _decode(
2270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2271        ) -> Result<(), fidl::Error> {
2272            let _response = fidl::client::decode_transaction_body::<
2273                fidl::encoding::EmptyPayload,
2274                fidl::encoding::DefaultFuchsiaResourceDialect,
2275                0x72b44fb963480b11,
2276            >(_buf?)?;
2277            Ok(_response)
2278        }
2279        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
2280            (queue, size, desc, avail, used),
2281            0x72b44fb963480b11,
2282            fidl::encoding::DynamicFlags::empty(),
2283            _decode,
2284        )
2285    }
2286
2287    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2288        self.client.send::<VirtioDeviceNotifyQueueRequest>(
2289            (queue,),
2290            0x6e3a61d652499244,
2291            fidl::encoding::DynamicFlags::empty(),
2292        )
2293    }
2294
2295    type ReadyResponseFut =
2296        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2297    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
2298        fn _decode(
2299            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2300        ) -> Result<(), fidl::Error> {
2301            let _response = fidl::client::decode_transaction_body::<
2302                fidl::encoding::EmptyPayload,
2303                fidl::encoding::DefaultFuchsiaResourceDialect,
2304                0x45707654f5d23c3f,
2305            >(_buf?)?;
2306            Ok(_response)
2307        }
2308        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
2309            (negotiated_features,),
2310            0x45707654f5d23c3f,
2311            fidl::encoding::DynamicFlags::empty(),
2312            _decode,
2313        )
2314    }
2315
2316    type StartResponseFut =
2317        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2318    fn r#start(
2319        &self,
2320        mut start_info: StartInfo,
2321        mut socket: fidl::Socket,
2322    ) -> Self::StartResponseFut {
2323        fn _decode(
2324            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2325        ) -> Result<(), fidl::Error> {
2326            let _response = fidl::client::decode_transaction_body::<
2327                fidl::encoding::EmptyPayload,
2328                fidl::encoding::DefaultFuchsiaResourceDialect,
2329                0x10a6267f2ab7e24c,
2330            >(_buf?)?;
2331            Ok(_response)
2332        }
2333        self.client.send_query_and_decode::<VirtioConsoleStartRequest, ()>(
2334            (&mut start_info, socket),
2335            0x10a6267f2ab7e24c,
2336            fidl::encoding::DynamicFlags::empty(),
2337            _decode,
2338        )
2339    }
2340}
2341
2342pub struct VirtioConsoleEventStream {
2343    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2344}
2345
2346impl std::marker::Unpin for VirtioConsoleEventStream {}
2347
2348impl futures::stream::FusedStream for VirtioConsoleEventStream {
2349    fn is_terminated(&self) -> bool {
2350        self.event_receiver.is_terminated()
2351    }
2352}
2353
2354impl futures::Stream for VirtioConsoleEventStream {
2355    type Item = Result<VirtioConsoleEvent, fidl::Error>;
2356
2357    fn poll_next(
2358        mut self: std::pin::Pin<&mut Self>,
2359        cx: &mut std::task::Context<'_>,
2360    ) -> std::task::Poll<Option<Self::Item>> {
2361        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2362            &mut self.event_receiver,
2363            cx
2364        )?) {
2365            Some(buf) => std::task::Poll::Ready(Some(VirtioConsoleEvent::decode(buf))),
2366            None => std::task::Poll::Ready(None),
2367        }
2368    }
2369}
2370
2371#[derive(Debug)]
2372pub enum VirtioConsoleEvent {}
2373
2374impl VirtioConsoleEvent {
2375    /// Decodes a message buffer as a [`VirtioConsoleEvent`].
2376    fn decode(
2377        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2378    ) -> Result<VirtioConsoleEvent, fidl::Error> {
2379        let (bytes, _handles) = buf.split_mut();
2380        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2381        debug_assert_eq!(tx_header.tx_id, 0);
2382        match tx_header.ordinal {
2383            _ => Err(fidl::Error::UnknownOrdinal {
2384                ordinal: tx_header.ordinal,
2385                protocol_name: <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2386            }),
2387        }
2388    }
2389}
2390
2391/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioConsole.
2392pub struct VirtioConsoleRequestStream {
2393    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2394    is_terminated: bool,
2395}
2396
2397impl std::marker::Unpin for VirtioConsoleRequestStream {}
2398
2399impl futures::stream::FusedStream for VirtioConsoleRequestStream {
2400    fn is_terminated(&self) -> bool {
2401        self.is_terminated
2402    }
2403}
2404
2405impl fidl::endpoints::RequestStream for VirtioConsoleRequestStream {
2406    type Protocol = VirtioConsoleMarker;
2407    type ControlHandle = VirtioConsoleControlHandle;
2408
2409    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2410        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2411    }
2412
2413    fn control_handle(&self) -> Self::ControlHandle {
2414        VirtioConsoleControlHandle { inner: self.inner.clone() }
2415    }
2416
2417    fn into_inner(
2418        self,
2419    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2420    {
2421        (self.inner, self.is_terminated)
2422    }
2423
2424    fn from_inner(
2425        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2426        is_terminated: bool,
2427    ) -> Self {
2428        Self { inner, is_terminated }
2429    }
2430}
2431
2432impl futures::Stream for VirtioConsoleRequestStream {
2433    type Item = Result<VirtioConsoleRequest, fidl::Error>;
2434
2435    fn poll_next(
2436        mut self: std::pin::Pin<&mut Self>,
2437        cx: &mut std::task::Context<'_>,
2438    ) -> std::task::Poll<Option<Self::Item>> {
2439        let this = &mut *self;
2440        if this.inner.check_shutdown(cx) {
2441            this.is_terminated = true;
2442            return std::task::Poll::Ready(None);
2443        }
2444        if this.is_terminated {
2445            panic!("polled VirtioConsoleRequestStream after completion");
2446        }
2447        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2448            |bytes, handles| {
2449                match this.inner.channel().read_etc(cx, bytes, handles) {
2450                    std::task::Poll::Ready(Ok(())) => {}
2451                    std::task::Poll::Pending => return std::task::Poll::Pending,
2452                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2453                        this.is_terminated = true;
2454                        return std::task::Poll::Ready(None);
2455                    }
2456                    std::task::Poll::Ready(Err(e)) => {
2457                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2458                            e.into(),
2459                        ))))
2460                    }
2461                }
2462
2463                // A message has been received from the channel
2464                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2465
2466                std::task::Poll::Ready(Some(match header.ordinal {
2467                    0x72b44fb963480b11 => {
2468                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2469                        let mut req = fidl::new_empty!(
2470                            VirtioDeviceConfigureQueueRequest,
2471                            fidl::encoding::DefaultFuchsiaResourceDialect
2472                        );
2473                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
2474                        let control_handle =
2475                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2476                        Ok(VirtioConsoleRequest::ConfigureQueue {
2477                            queue: req.queue,
2478                            size: req.size,
2479                            desc: req.desc,
2480                            avail: req.avail,
2481                            used: req.used,
2482
2483                            responder: VirtioConsoleConfigureQueueResponder {
2484                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2485                                tx_id: header.tx_id,
2486                            },
2487                        })
2488                    }
2489                    0x6e3a61d652499244 => {
2490                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2491                        let mut req = fidl::new_empty!(
2492                            VirtioDeviceNotifyQueueRequest,
2493                            fidl::encoding::DefaultFuchsiaResourceDialect
2494                        );
2495                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
2496                        let control_handle =
2497                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2498                        Ok(VirtioConsoleRequest::NotifyQueue { queue: req.queue, control_handle })
2499                    }
2500                    0x45707654f5d23c3f => {
2501                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2502                        let mut req = fidl::new_empty!(
2503                            VirtioDeviceReadyRequest,
2504                            fidl::encoding::DefaultFuchsiaResourceDialect
2505                        );
2506                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
2507                        let control_handle =
2508                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2509                        Ok(VirtioConsoleRequest::Ready {
2510                            negotiated_features: req.negotiated_features,
2511
2512                            responder: VirtioConsoleReadyResponder {
2513                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2514                                tx_id: header.tx_id,
2515                            },
2516                        })
2517                    }
2518                    0x10a6267f2ab7e24c => {
2519                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2520                        let mut req = fidl::new_empty!(
2521                            VirtioConsoleStartRequest,
2522                            fidl::encoding::DefaultFuchsiaResourceDialect
2523                        );
2524                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioConsoleStartRequest>(&header, _body_bytes, handles, &mut req)?;
2525                        let control_handle =
2526                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2527                        Ok(VirtioConsoleRequest::Start {
2528                            start_info: req.start_info,
2529                            socket: req.socket,
2530
2531                            responder: VirtioConsoleStartResponder {
2532                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2533                                tx_id: header.tx_id,
2534                            },
2535                        })
2536                    }
2537                    _ => Err(fidl::Error::UnknownOrdinal {
2538                        ordinal: header.ordinal,
2539                        protocol_name:
2540                            <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2541                    }),
2542                }))
2543            },
2544        )
2545    }
2546}
2547
2548#[derive(Debug)]
2549pub enum VirtioConsoleRequest {
2550    /// Configure a `queue` for the device. This specifies the `size` and the
2551    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2552    ConfigureQueue {
2553        queue: u16,
2554        size: u16,
2555        desc: u64,
2556        avail: u64,
2557        used: u64,
2558        responder: VirtioConsoleConfigureQueueResponder,
2559    },
2560    /// Notify a `queue` for the device. Primarily used for black-box testing.
2561    NotifyQueue { queue: u16, control_handle: VirtioConsoleControlHandle },
2562    /// Ready a device. This provides the set of `negotiated_features` that the
2563    /// driver and device have agreed upon.
2564    Ready { negotiated_features: u32, responder: VirtioConsoleReadyResponder },
2565    /// Start the console device. This uses `socket` to handle input and output.
2566    Start { start_info: StartInfo, socket: fidl::Socket, responder: VirtioConsoleStartResponder },
2567}
2568
2569impl VirtioConsoleRequest {
2570    #[allow(irrefutable_let_patterns)]
2571    pub fn into_configure_queue(
2572        self,
2573    ) -> Option<(u16, u16, u64, u64, u64, VirtioConsoleConfigureQueueResponder)> {
2574        if let VirtioConsoleRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
2575            self
2576        {
2577            Some((queue, size, desc, avail, used, responder))
2578        } else {
2579            None
2580        }
2581    }
2582
2583    #[allow(irrefutable_let_patterns)]
2584    pub fn into_notify_queue(self) -> Option<(u16, VirtioConsoleControlHandle)> {
2585        if let VirtioConsoleRequest::NotifyQueue { queue, control_handle } = self {
2586            Some((queue, control_handle))
2587        } else {
2588            None
2589        }
2590    }
2591
2592    #[allow(irrefutable_let_patterns)]
2593    pub fn into_ready(self) -> Option<(u32, VirtioConsoleReadyResponder)> {
2594        if let VirtioConsoleRequest::Ready { negotiated_features, responder } = self {
2595            Some((negotiated_features, responder))
2596        } else {
2597            None
2598        }
2599    }
2600
2601    #[allow(irrefutable_let_patterns)]
2602    pub fn into_start(self) -> Option<(StartInfo, fidl::Socket, VirtioConsoleStartResponder)> {
2603        if let VirtioConsoleRequest::Start { start_info, socket, responder } = self {
2604            Some((start_info, socket, responder))
2605        } else {
2606            None
2607        }
2608    }
2609
2610    /// Name of the method defined in FIDL
2611    pub fn method_name(&self) -> &'static str {
2612        match *self {
2613            VirtioConsoleRequest::ConfigureQueue { .. } => "configure_queue",
2614            VirtioConsoleRequest::NotifyQueue { .. } => "notify_queue",
2615            VirtioConsoleRequest::Ready { .. } => "ready",
2616            VirtioConsoleRequest::Start { .. } => "start",
2617        }
2618    }
2619}
2620
2621#[derive(Debug, Clone)]
2622pub struct VirtioConsoleControlHandle {
2623    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2624}
2625
2626impl fidl::endpoints::ControlHandle for VirtioConsoleControlHandle {
2627    fn shutdown(&self) {
2628        self.inner.shutdown()
2629    }
2630    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2631        self.inner.shutdown_with_epitaph(status)
2632    }
2633
2634    fn is_closed(&self) -> bool {
2635        self.inner.channel().is_closed()
2636    }
2637    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2638        self.inner.channel().on_closed()
2639    }
2640
2641    #[cfg(target_os = "fuchsia")]
2642    fn signal_peer(
2643        &self,
2644        clear_mask: zx::Signals,
2645        set_mask: zx::Signals,
2646    ) -> Result<(), zx_status::Status> {
2647        use fidl::Peered;
2648        self.inner.channel().signal_peer(clear_mask, set_mask)
2649    }
2650}
2651
2652impl VirtioConsoleControlHandle {}
2653
2654#[must_use = "FIDL methods require a response to be sent"]
2655#[derive(Debug)]
2656pub struct VirtioConsoleConfigureQueueResponder {
2657    control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
2658    tx_id: u32,
2659}
2660
2661/// Set the the channel to be shutdown (see [`VirtioConsoleControlHandle::shutdown`])
2662/// if the responder is dropped without sending a response, so that the client
2663/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2664impl std::ops::Drop for VirtioConsoleConfigureQueueResponder {
2665    fn drop(&mut self) {
2666        self.control_handle.shutdown();
2667        // Safety: drops once, never accessed again
2668        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2669    }
2670}
2671
2672impl fidl::endpoints::Responder for VirtioConsoleConfigureQueueResponder {
2673    type ControlHandle = VirtioConsoleControlHandle;
2674
2675    fn control_handle(&self) -> &VirtioConsoleControlHandle {
2676        &self.control_handle
2677    }
2678
2679    fn drop_without_shutdown(mut self) {
2680        // Safety: drops once, never accessed again due to mem::forget
2681        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2682        // Prevent Drop from running (which would shut down the channel)
2683        std::mem::forget(self);
2684    }
2685}
2686
2687impl VirtioConsoleConfigureQueueResponder {
2688    /// Sends a response to the FIDL transaction.
2689    ///
2690    /// Sets the channel to shutdown if an error occurs.
2691    pub fn send(self) -> Result<(), fidl::Error> {
2692        let _result = self.send_raw();
2693        if _result.is_err() {
2694            self.control_handle.shutdown();
2695        }
2696        self.drop_without_shutdown();
2697        _result
2698    }
2699
2700    /// Similar to "send" but does not shutdown the channel if an error occurs.
2701    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2702        let _result = self.send_raw();
2703        self.drop_without_shutdown();
2704        _result
2705    }
2706
2707    fn send_raw(&self) -> Result<(), fidl::Error> {
2708        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2709            (),
2710            self.tx_id,
2711            0x72b44fb963480b11,
2712            fidl::encoding::DynamicFlags::empty(),
2713        )
2714    }
2715}
2716
2717#[must_use = "FIDL methods require a response to be sent"]
2718#[derive(Debug)]
2719pub struct VirtioConsoleReadyResponder {
2720    control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
2721    tx_id: u32,
2722}
2723
2724/// Set the the channel to be shutdown (see [`VirtioConsoleControlHandle::shutdown`])
2725/// if the responder is dropped without sending a response, so that the client
2726/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2727impl std::ops::Drop for VirtioConsoleReadyResponder {
2728    fn drop(&mut self) {
2729        self.control_handle.shutdown();
2730        // Safety: drops once, never accessed again
2731        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2732    }
2733}
2734
2735impl fidl::endpoints::Responder for VirtioConsoleReadyResponder {
2736    type ControlHandle = VirtioConsoleControlHandle;
2737
2738    fn control_handle(&self) -> &VirtioConsoleControlHandle {
2739        &self.control_handle
2740    }
2741
2742    fn drop_without_shutdown(mut self) {
2743        // Safety: drops once, never accessed again due to mem::forget
2744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2745        // Prevent Drop from running (which would shut down the channel)
2746        std::mem::forget(self);
2747    }
2748}
2749
2750impl VirtioConsoleReadyResponder {
2751    /// Sends a response to the FIDL transaction.
2752    ///
2753    /// Sets the channel to shutdown if an error occurs.
2754    pub fn send(self) -> Result<(), fidl::Error> {
2755        let _result = self.send_raw();
2756        if _result.is_err() {
2757            self.control_handle.shutdown();
2758        }
2759        self.drop_without_shutdown();
2760        _result
2761    }
2762
2763    /// Similar to "send" but does not shutdown the channel if an error occurs.
2764    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2765        let _result = self.send_raw();
2766        self.drop_without_shutdown();
2767        _result
2768    }
2769
2770    fn send_raw(&self) -> Result<(), fidl::Error> {
2771        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2772            (),
2773            self.tx_id,
2774            0x45707654f5d23c3f,
2775            fidl::encoding::DynamicFlags::empty(),
2776        )
2777    }
2778}
2779
2780#[must_use = "FIDL methods require a response to be sent"]
2781#[derive(Debug)]
2782pub struct VirtioConsoleStartResponder {
2783    control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
2784    tx_id: u32,
2785}
2786
2787/// Set the the channel to be shutdown (see [`VirtioConsoleControlHandle::shutdown`])
2788/// if the responder is dropped without sending a response, so that the client
2789/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2790impl std::ops::Drop for VirtioConsoleStartResponder {
2791    fn drop(&mut self) {
2792        self.control_handle.shutdown();
2793        // Safety: drops once, never accessed again
2794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2795    }
2796}
2797
2798impl fidl::endpoints::Responder for VirtioConsoleStartResponder {
2799    type ControlHandle = VirtioConsoleControlHandle;
2800
2801    fn control_handle(&self) -> &VirtioConsoleControlHandle {
2802        &self.control_handle
2803    }
2804
2805    fn drop_without_shutdown(mut self) {
2806        // Safety: drops once, never accessed again due to mem::forget
2807        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2808        // Prevent Drop from running (which would shut down the channel)
2809        std::mem::forget(self);
2810    }
2811}
2812
2813impl VirtioConsoleStartResponder {
2814    /// Sends a response to the FIDL transaction.
2815    ///
2816    /// Sets the channel to shutdown if an error occurs.
2817    pub fn send(self) -> Result<(), fidl::Error> {
2818        let _result = self.send_raw();
2819        if _result.is_err() {
2820            self.control_handle.shutdown();
2821        }
2822        self.drop_without_shutdown();
2823        _result
2824    }
2825
2826    /// Similar to "send" but does not shutdown the channel if an error occurs.
2827    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2828        let _result = self.send_raw();
2829        self.drop_without_shutdown();
2830        _result
2831    }
2832
2833    fn send_raw(&self) -> Result<(), fidl::Error> {
2834        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2835            (),
2836            self.tx_id,
2837            0x10a6267f2ab7e24c,
2838            fidl::encoding::DynamicFlags::empty(),
2839        )
2840    }
2841}
2842
2843#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2844pub struct VirtioDeviceMarker;
2845
2846impl fidl::endpoints::ProtocolMarker for VirtioDeviceMarker {
2847    type Proxy = VirtioDeviceProxy;
2848    type RequestStream = VirtioDeviceRequestStream;
2849    #[cfg(target_os = "fuchsia")]
2850    type SynchronousProxy = VirtioDeviceSynchronousProxy;
2851
2852    const DEBUG_NAME: &'static str = "(anonymous) VirtioDevice";
2853}
2854
2855pub trait VirtioDeviceProxyInterface: Send + Sync {
2856    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2857    fn r#configure_queue(
2858        &self,
2859        queue: u16,
2860        size: u16,
2861        desc: u64,
2862        avail: u64,
2863        used: u64,
2864    ) -> Self::ConfigureQueueResponseFut;
2865    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
2866    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2867    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
2868}
2869#[derive(Debug)]
2870#[cfg(target_os = "fuchsia")]
2871pub struct VirtioDeviceSynchronousProxy {
2872    client: fidl::client::sync::Client,
2873}
2874
2875#[cfg(target_os = "fuchsia")]
2876impl fidl::endpoints::SynchronousProxy for VirtioDeviceSynchronousProxy {
2877    type Proxy = VirtioDeviceProxy;
2878    type Protocol = VirtioDeviceMarker;
2879
2880    fn from_channel(inner: fidl::Channel) -> Self {
2881        Self::new(inner)
2882    }
2883
2884    fn into_channel(self) -> fidl::Channel {
2885        self.client.into_channel()
2886    }
2887
2888    fn as_channel(&self) -> &fidl::Channel {
2889        self.client.as_channel()
2890    }
2891}
2892
2893#[cfg(target_os = "fuchsia")]
2894impl VirtioDeviceSynchronousProxy {
2895    pub fn new(channel: fidl::Channel) -> Self {
2896        let protocol_name = <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2897        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2898    }
2899
2900    pub fn into_channel(self) -> fidl::Channel {
2901        self.client.into_channel()
2902    }
2903
2904    /// Waits until an event arrives and returns it. It is safe for other
2905    /// threads to make concurrent requests while waiting for an event.
2906    pub fn wait_for_event(
2907        &self,
2908        deadline: zx::MonotonicInstant,
2909    ) -> Result<VirtioDeviceEvent, fidl::Error> {
2910        VirtioDeviceEvent::decode(self.client.wait_for_event(deadline)?)
2911    }
2912
2913    /// Configure a `queue` for the device. This specifies the `size` and the
2914    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2915    pub fn r#configure_queue(
2916        &self,
2917        mut queue: u16,
2918        mut size: u16,
2919        mut desc: u64,
2920        mut avail: u64,
2921        mut used: u64,
2922        ___deadline: zx::MonotonicInstant,
2923    ) -> Result<(), fidl::Error> {
2924        let _response = self
2925            .client
2926            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
2927                (queue, size, desc, avail, used),
2928                0x72b44fb963480b11,
2929                fidl::encoding::DynamicFlags::empty(),
2930                ___deadline,
2931            )?;
2932        Ok(_response)
2933    }
2934
2935    /// Notify a `queue` for the device. Primarily used for black-box testing.
2936    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2937        self.client.send::<VirtioDeviceNotifyQueueRequest>(
2938            (queue,),
2939            0x6e3a61d652499244,
2940            fidl::encoding::DynamicFlags::empty(),
2941        )
2942    }
2943
2944    /// Ready a device. This provides the set of `negotiated_features` that the
2945    /// driver and device have agreed upon.
2946    pub fn r#ready(
2947        &self,
2948        mut negotiated_features: u32,
2949        ___deadline: zx::MonotonicInstant,
2950    ) -> Result<(), fidl::Error> {
2951        let _response =
2952            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
2953                (negotiated_features,),
2954                0x45707654f5d23c3f,
2955                fidl::encoding::DynamicFlags::empty(),
2956                ___deadline,
2957            )?;
2958        Ok(_response)
2959    }
2960}
2961
2962#[cfg(target_os = "fuchsia")]
2963impl From<VirtioDeviceSynchronousProxy> for zx::Handle {
2964    fn from(value: VirtioDeviceSynchronousProxy) -> Self {
2965        value.into_channel().into()
2966    }
2967}
2968
2969#[cfg(target_os = "fuchsia")]
2970impl From<fidl::Channel> for VirtioDeviceSynchronousProxy {
2971    fn from(value: fidl::Channel) -> Self {
2972        Self::new(value)
2973    }
2974}
2975
2976#[cfg(target_os = "fuchsia")]
2977impl fidl::endpoints::FromClient for VirtioDeviceSynchronousProxy {
2978    type Protocol = VirtioDeviceMarker;
2979
2980    fn from_client(value: fidl::endpoints::ClientEnd<VirtioDeviceMarker>) -> Self {
2981        Self::new(value.into_channel())
2982    }
2983}
2984
2985#[derive(Debug, Clone)]
2986pub struct VirtioDeviceProxy {
2987    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2988}
2989
2990impl fidl::endpoints::Proxy for VirtioDeviceProxy {
2991    type Protocol = VirtioDeviceMarker;
2992
2993    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2994        Self::new(inner)
2995    }
2996
2997    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2998        self.client.into_channel().map_err(|client| Self { client })
2999    }
3000
3001    fn as_channel(&self) -> &::fidl::AsyncChannel {
3002        self.client.as_channel()
3003    }
3004}
3005
3006impl VirtioDeviceProxy {
3007    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioDevice.
3008    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3009        let protocol_name = <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3010        Self { client: fidl::client::Client::new(channel, protocol_name) }
3011    }
3012
3013    /// Get a Stream of events from the remote end of the protocol.
3014    ///
3015    /// # Panics
3016    ///
3017    /// Panics if the event stream was already taken.
3018    pub fn take_event_stream(&self) -> VirtioDeviceEventStream {
3019        VirtioDeviceEventStream { event_receiver: self.client.take_event_receiver() }
3020    }
3021
3022    /// Configure a `queue` for the device. This specifies the `size` and the
3023    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3024    pub fn r#configure_queue(
3025        &self,
3026        mut queue: u16,
3027        mut size: u16,
3028        mut desc: u64,
3029        mut avail: u64,
3030        mut used: u64,
3031    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3032        VirtioDeviceProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
3033    }
3034
3035    /// Notify a `queue` for the device. Primarily used for black-box testing.
3036    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3037        VirtioDeviceProxyInterface::r#notify_queue(self, queue)
3038    }
3039
3040    /// Ready a device. This provides the set of `negotiated_features` that the
3041    /// driver and device have agreed upon.
3042    pub fn r#ready(
3043        &self,
3044        mut negotiated_features: u32,
3045    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3046        VirtioDeviceProxyInterface::r#ready(self, negotiated_features)
3047    }
3048}
3049
3050impl VirtioDeviceProxyInterface for VirtioDeviceProxy {
3051    type ConfigureQueueResponseFut =
3052        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3053    fn r#configure_queue(
3054        &self,
3055        mut queue: u16,
3056        mut size: u16,
3057        mut desc: u64,
3058        mut avail: u64,
3059        mut used: u64,
3060    ) -> Self::ConfigureQueueResponseFut {
3061        fn _decode(
3062            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3063        ) -> Result<(), fidl::Error> {
3064            let _response = fidl::client::decode_transaction_body::<
3065                fidl::encoding::EmptyPayload,
3066                fidl::encoding::DefaultFuchsiaResourceDialect,
3067                0x72b44fb963480b11,
3068            >(_buf?)?;
3069            Ok(_response)
3070        }
3071        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
3072            (queue, size, desc, avail, used),
3073            0x72b44fb963480b11,
3074            fidl::encoding::DynamicFlags::empty(),
3075            _decode,
3076        )
3077    }
3078
3079    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3080        self.client.send::<VirtioDeviceNotifyQueueRequest>(
3081            (queue,),
3082            0x6e3a61d652499244,
3083            fidl::encoding::DynamicFlags::empty(),
3084        )
3085    }
3086
3087    type ReadyResponseFut =
3088        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3089    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
3090        fn _decode(
3091            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3092        ) -> Result<(), fidl::Error> {
3093            let _response = fidl::client::decode_transaction_body::<
3094                fidl::encoding::EmptyPayload,
3095                fidl::encoding::DefaultFuchsiaResourceDialect,
3096                0x45707654f5d23c3f,
3097            >(_buf?)?;
3098            Ok(_response)
3099        }
3100        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
3101            (negotiated_features,),
3102            0x45707654f5d23c3f,
3103            fidl::encoding::DynamicFlags::empty(),
3104            _decode,
3105        )
3106    }
3107}
3108
3109pub struct VirtioDeviceEventStream {
3110    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3111}
3112
3113impl std::marker::Unpin for VirtioDeviceEventStream {}
3114
3115impl futures::stream::FusedStream for VirtioDeviceEventStream {
3116    fn is_terminated(&self) -> bool {
3117        self.event_receiver.is_terminated()
3118    }
3119}
3120
3121impl futures::Stream for VirtioDeviceEventStream {
3122    type Item = Result<VirtioDeviceEvent, fidl::Error>;
3123
3124    fn poll_next(
3125        mut self: std::pin::Pin<&mut Self>,
3126        cx: &mut std::task::Context<'_>,
3127    ) -> std::task::Poll<Option<Self::Item>> {
3128        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3129            &mut self.event_receiver,
3130            cx
3131        )?) {
3132            Some(buf) => std::task::Poll::Ready(Some(VirtioDeviceEvent::decode(buf))),
3133            None => std::task::Poll::Ready(None),
3134        }
3135    }
3136}
3137
3138#[derive(Debug)]
3139pub enum VirtioDeviceEvent {}
3140
3141impl VirtioDeviceEvent {
3142    /// Decodes a message buffer as a [`VirtioDeviceEvent`].
3143    fn decode(
3144        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3145    ) -> Result<VirtioDeviceEvent, fidl::Error> {
3146        let (bytes, _handles) = buf.split_mut();
3147        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3148        debug_assert_eq!(tx_header.tx_id, 0);
3149        match tx_header.ordinal {
3150            _ => Err(fidl::Error::UnknownOrdinal {
3151                ordinal: tx_header.ordinal,
3152                protocol_name: <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3153            }),
3154        }
3155    }
3156}
3157
3158/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioDevice.
3159pub struct VirtioDeviceRequestStream {
3160    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3161    is_terminated: bool,
3162}
3163
3164impl std::marker::Unpin for VirtioDeviceRequestStream {}
3165
3166impl futures::stream::FusedStream for VirtioDeviceRequestStream {
3167    fn is_terminated(&self) -> bool {
3168        self.is_terminated
3169    }
3170}
3171
3172impl fidl::endpoints::RequestStream for VirtioDeviceRequestStream {
3173    type Protocol = VirtioDeviceMarker;
3174    type ControlHandle = VirtioDeviceControlHandle;
3175
3176    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3177        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3178    }
3179
3180    fn control_handle(&self) -> Self::ControlHandle {
3181        VirtioDeviceControlHandle { inner: self.inner.clone() }
3182    }
3183
3184    fn into_inner(
3185        self,
3186    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3187    {
3188        (self.inner, self.is_terminated)
3189    }
3190
3191    fn from_inner(
3192        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3193        is_terminated: bool,
3194    ) -> Self {
3195        Self { inner, is_terminated }
3196    }
3197}
3198
3199impl futures::Stream for VirtioDeviceRequestStream {
3200    type Item = Result<VirtioDeviceRequest, fidl::Error>;
3201
3202    fn poll_next(
3203        mut self: std::pin::Pin<&mut Self>,
3204        cx: &mut std::task::Context<'_>,
3205    ) -> std::task::Poll<Option<Self::Item>> {
3206        let this = &mut *self;
3207        if this.inner.check_shutdown(cx) {
3208            this.is_terminated = true;
3209            return std::task::Poll::Ready(None);
3210        }
3211        if this.is_terminated {
3212            panic!("polled VirtioDeviceRequestStream after completion");
3213        }
3214        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3215            |bytes, handles| {
3216                match this.inner.channel().read_etc(cx, bytes, handles) {
3217                    std::task::Poll::Ready(Ok(())) => {}
3218                    std::task::Poll::Pending => return std::task::Poll::Pending,
3219                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3220                        this.is_terminated = true;
3221                        return std::task::Poll::Ready(None);
3222                    }
3223                    std::task::Poll::Ready(Err(e)) => {
3224                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3225                            e.into(),
3226                        ))))
3227                    }
3228                }
3229
3230                // A message has been received from the channel
3231                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3232
3233                std::task::Poll::Ready(Some(match header.ordinal {
3234                    0x72b44fb963480b11 => {
3235                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3236                        let mut req = fidl::new_empty!(
3237                            VirtioDeviceConfigureQueueRequest,
3238                            fidl::encoding::DefaultFuchsiaResourceDialect
3239                        );
3240                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3241                        let control_handle =
3242                            VirtioDeviceControlHandle { inner: this.inner.clone() };
3243                        Ok(VirtioDeviceRequest::ConfigureQueue {
3244                            queue: req.queue,
3245                            size: req.size,
3246                            desc: req.desc,
3247                            avail: req.avail,
3248                            used: req.used,
3249
3250                            responder: VirtioDeviceConfigureQueueResponder {
3251                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3252                                tx_id: header.tx_id,
3253                            },
3254                        })
3255                    }
3256                    0x6e3a61d652499244 => {
3257                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3258                        let mut req = fidl::new_empty!(
3259                            VirtioDeviceNotifyQueueRequest,
3260                            fidl::encoding::DefaultFuchsiaResourceDialect
3261                        );
3262                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3263                        let control_handle =
3264                            VirtioDeviceControlHandle { inner: this.inner.clone() };
3265                        Ok(VirtioDeviceRequest::NotifyQueue { queue: req.queue, control_handle })
3266                    }
3267                    0x45707654f5d23c3f => {
3268                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3269                        let mut req = fidl::new_empty!(
3270                            VirtioDeviceReadyRequest,
3271                            fidl::encoding::DefaultFuchsiaResourceDialect
3272                        );
3273                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
3274                        let control_handle =
3275                            VirtioDeviceControlHandle { inner: this.inner.clone() };
3276                        Ok(VirtioDeviceRequest::Ready {
3277                            negotiated_features: req.negotiated_features,
3278
3279                            responder: VirtioDeviceReadyResponder {
3280                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3281                                tx_id: header.tx_id,
3282                            },
3283                        })
3284                    }
3285                    _ => Err(fidl::Error::UnknownOrdinal {
3286                        ordinal: header.ordinal,
3287                        protocol_name:
3288                            <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3289                    }),
3290                }))
3291            },
3292        )
3293    }
3294}
3295
3296#[derive(Debug)]
3297pub enum VirtioDeviceRequest {
3298    /// Configure a `queue` for the device. This specifies the `size` and the
3299    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3300    ConfigureQueue {
3301        queue: u16,
3302        size: u16,
3303        desc: u64,
3304        avail: u64,
3305        used: u64,
3306        responder: VirtioDeviceConfigureQueueResponder,
3307    },
3308    /// Notify a `queue` for the device. Primarily used for black-box testing.
3309    NotifyQueue { queue: u16, control_handle: VirtioDeviceControlHandle },
3310    /// Ready a device. This provides the set of `negotiated_features` that the
3311    /// driver and device have agreed upon.
3312    Ready { negotiated_features: u32, responder: VirtioDeviceReadyResponder },
3313}
3314
3315impl VirtioDeviceRequest {
3316    #[allow(irrefutable_let_patterns)]
3317    pub fn into_configure_queue(
3318        self,
3319    ) -> Option<(u16, u16, u64, u64, u64, VirtioDeviceConfigureQueueResponder)> {
3320        if let VirtioDeviceRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
3321            self
3322        {
3323            Some((queue, size, desc, avail, used, responder))
3324        } else {
3325            None
3326        }
3327    }
3328
3329    #[allow(irrefutable_let_patterns)]
3330    pub fn into_notify_queue(self) -> Option<(u16, VirtioDeviceControlHandle)> {
3331        if let VirtioDeviceRequest::NotifyQueue { queue, control_handle } = self {
3332            Some((queue, control_handle))
3333        } else {
3334            None
3335        }
3336    }
3337
3338    #[allow(irrefutable_let_patterns)]
3339    pub fn into_ready(self) -> Option<(u32, VirtioDeviceReadyResponder)> {
3340        if let VirtioDeviceRequest::Ready { negotiated_features, responder } = self {
3341            Some((negotiated_features, responder))
3342        } else {
3343            None
3344        }
3345    }
3346
3347    /// Name of the method defined in FIDL
3348    pub fn method_name(&self) -> &'static str {
3349        match *self {
3350            VirtioDeviceRequest::ConfigureQueue { .. } => "configure_queue",
3351            VirtioDeviceRequest::NotifyQueue { .. } => "notify_queue",
3352            VirtioDeviceRequest::Ready { .. } => "ready",
3353        }
3354    }
3355}
3356
3357#[derive(Debug, Clone)]
3358pub struct VirtioDeviceControlHandle {
3359    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3360}
3361
3362impl fidl::endpoints::ControlHandle for VirtioDeviceControlHandle {
3363    fn shutdown(&self) {
3364        self.inner.shutdown()
3365    }
3366    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3367        self.inner.shutdown_with_epitaph(status)
3368    }
3369
3370    fn is_closed(&self) -> bool {
3371        self.inner.channel().is_closed()
3372    }
3373    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3374        self.inner.channel().on_closed()
3375    }
3376
3377    #[cfg(target_os = "fuchsia")]
3378    fn signal_peer(
3379        &self,
3380        clear_mask: zx::Signals,
3381        set_mask: zx::Signals,
3382    ) -> Result<(), zx_status::Status> {
3383        use fidl::Peered;
3384        self.inner.channel().signal_peer(clear_mask, set_mask)
3385    }
3386}
3387
3388impl VirtioDeviceControlHandle {}
3389
3390#[must_use = "FIDL methods require a response to be sent"]
3391#[derive(Debug)]
3392pub struct VirtioDeviceConfigureQueueResponder {
3393    control_handle: std::mem::ManuallyDrop<VirtioDeviceControlHandle>,
3394    tx_id: u32,
3395}
3396
3397/// Set the the channel to be shutdown (see [`VirtioDeviceControlHandle::shutdown`])
3398/// if the responder is dropped without sending a response, so that the client
3399/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3400impl std::ops::Drop for VirtioDeviceConfigureQueueResponder {
3401    fn drop(&mut self) {
3402        self.control_handle.shutdown();
3403        // Safety: drops once, never accessed again
3404        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3405    }
3406}
3407
3408impl fidl::endpoints::Responder for VirtioDeviceConfigureQueueResponder {
3409    type ControlHandle = VirtioDeviceControlHandle;
3410
3411    fn control_handle(&self) -> &VirtioDeviceControlHandle {
3412        &self.control_handle
3413    }
3414
3415    fn drop_without_shutdown(mut self) {
3416        // Safety: drops once, never accessed again due to mem::forget
3417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3418        // Prevent Drop from running (which would shut down the channel)
3419        std::mem::forget(self);
3420    }
3421}
3422
3423impl VirtioDeviceConfigureQueueResponder {
3424    /// Sends a response to the FIDL transaction.
3425    ///
3426    /// Sets the channel to shutdown if an error occurs.
3427    pub fn send(self) -> Result<(), fidl::Error> {
3428        let _result = self.send_raw();
3429        if _result.is_err() {
3430            self.control_handle.shutdown();
3431        }
3432        self.drop_without_shutdown();
3433        _result
3434    }
3435
3436    /// Similar to "send" but does not shutdown the channel if an error occurs.
3437    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3438        let _result = self.send_raw();
3439        self.drop_without_shutdown();
3440        _result
3441    }
3442
3443    fn send_raw(&self) -> Result<(), fidl::Error> {
3444        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3445            (),
3446            self.tx_id,
3447            0x72b44fb963480b11,
3448            fidl::encoding::DynamicFlags::empty(),
3449        )
3450    }
3451}
3452
3453#[must_use = "FIDL methods require a response to be sent"]
3454#[derive(Debug)]
3455pub struct VirtioDeviceReadyResponder {
3456    control_handle: std::mem::ManuallyDrop<VirtioDeviceControlHandle>,
3457    tx_id: u32,
3458}
3459
3460/// Set the the channel to be shutdown (see [`VirtioDeviceControlHandle::shutdown`])
3461/// if the responder is dropped without sending a response, so that the client
3462/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3463impl std::ops::Drop for VirtioDeviceReadyResponder {
3464    fn drop(&mut self) {
3465        self.control_handle.shutdown();
3466        // Safety: drops once, never accessed again
3467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3468    }
3469}
3470
3471impl fidl::endpoints::Responder for VirtioDeviceReadyResponder {
3472    type ControlHandle = VirtioDeviceControlHandle;
3473
3474    fn control_handle(&self) -> &VirtioDeviceControlHandle {
3475        &self.control_handle
3476    }
3477
3478    fn drop_without_shutdown(mut self) {
3479        // Safety: drops once, never accessed again due to mem::forget
3480        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3481        // Prevent Drop from running (which would shut down the channel)
3482        std::mem::forget(self);
3483    }
3484}
3485
3486impl VirtioDeviceReadyResponder {
3487    /// Sends a response to the FIDL transaction.
3488    ///
3489    /// Sets the channel to shutdown if an error occurs.
3490    pub fn send(self) -> Result<(), fidl::Error> {
3491        let _result = self.send_raw();
3492        if _result.is_err() {
3493            self.control_handle.shutdown();
3494        }
3495        self.drop_without_shutdown();
3496        _result
3497    }
3498
3499    /// Similar to "send" but does not shutdown the channel if an error occurs.
3500    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3501        let _result = self.send_raw();
3502        self.drop_without_shutdown();
3503        _result
3504    }
3505
3506    fn send_raw(&self) -> Result<(), fidl::Error> {
3507        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3508            (),
3509            self.tx_id,
3510            0x45707654f5d23c3f,
3511            fidl::encoding::DynamicFlags::empty(),
3512        )
3513    }
3514}
3515
3516#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3517pub struct VirtioGpuMarker;
3518
3519impl fidl::endpoints::ProtocolMarker for VirtioGpuMarker {
3520    type Proxy = VirtioGpuProxy;
3521    type RequestStream = VirtioGpuRequestStream;
3522    #[cfg(target_os = "fuchsia")]
3523    type SynchronousProxy = VirtioGpuSynchronousProxy;
3524
3525    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioGpu";
3526}
3527impl fidl::endpoints::DiscoverableProtocolMarker for VirtioGpuMarker {}
3528
3529pub trait VirtioGpuProxyInterface: Send + Sync {
3530    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3531    fn r#configure_queue(
3532        &self,
3533        queue: u16,
3534        size: u16,
3535        desc: u64,
3536        avail: u64,
3537        used: u64,
3538    ) -> Self::ConfigureQueueResponseFut;
3539    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
3540    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3541    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
3542    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3543    fn r#start(
3544        &self,
3545        start_info: StartInfo,
3546        keyboard_listener: Option<
3547            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3548        >,
3549        mouse_source: Option<
3550            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3551        >,
3552    ) -> Self::StartResponseFut;
3553}
3554#[derive(Debug)]
3555#[cfg(target_os = "fuchsia")]
3556pub struct VirtioGpuSynchronousProxy {
3557    client: fidl::client::sync::Client,
3558}
3559
3560#[cfg(target_os = "fuchsia")]
3561impl fidl::endpoints::SynchronousProxy for VirtioGpuSynchronousProxy {
3562    type Proxy = VirtioGpuProxy;
3563    type Protocol = VirtioGpuMarker;
3564
3565    fn from_channel(inner: fidl::Channel) -> Self {
3566        Self::new(inner)
3567    }
3568
3569    fn into_channel(self) -> fidl::Channel {
3570        self.client.into_channel()
3571    }
3572
3573    fn as_channel(&self) -> &fidl::Channel {
3574        self.client.as_channel()
3575    }
3576}
3577
3578#[cfg(target_os = "fuchsia")]
3579impl VirtioGpuSynchronousProxy {
3580    pub fn new(channel: fidl::Channel) -> Self {
3581        let protocol_name = <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3582        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3583    }
3584
3585    pub fn into_channel(self) -> fidl::Channel {
3586        self.client.into_channel()
3587    }
3588
3589    /// Waits until an event arrives and returns it. It is safe for other
3590    /// threads to make concurrent requests while waiting for an event.
3591    pub fn wait_for_event(
3592        &self,
3593        deadline: zx::MonotonicInstant,
3594    ) -> Result<VirtioGpuEvent, fidl::Error> {
3595        VirtioGpuEvent::decode(self.client.wait_for_event(deadline)?)
3596    }
3597
3598    /// Configure a `queue` for the device. This specifies the `size` and the
3599    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3600    pub fn r#configure_queue(
3601        &self,
3602        mut queue: u16,
3603        mut size: u16,
3604        mut desc: u64,
3605        mut avail: u64,
3606        mut used: u64,
3607        ___deadline: zx::MonotonicInstant,
3608    ) -> Result<(), fidl::Error> {
3609        let _response = self
3610            .client
3611            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
3612                (queue, size, desc, avail, used),
3613                0x72b44fb963480b11,
3614                fidl::encoding::DynamicFlags::empty(),
3615                ___deadline,
3616            )?;
3617        Ok(_response)
3618    }
3619
3620    /// Notify a `queue` for the device. Primarily used for black-box testing.
3621    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3622        self.client.send::<VirtioDeviceNotifyQueueRequest>(
3623            (queue,),
3624            0x6e3a61d652499244,
3625            fidl::encoding::DynamicFlags::empty(),
3626        )
3627    }
3628
3629    /// Ready a device. This provides the set of `negotiated_features` that the
3630    /// driver and device have agreed upon.
3631    pub fn r#ready(
3632        &self,
3633        mut negotiated_features: u32,
3634        ___deadline: zx::MonotonicInstant,
3635    ) -> Result<(), fidl::Error> {
3636        let _response =
3637            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
3638                (negotiated_features,),
3639                0x45707654f5d23c3f,
3640                fidl::encoding::DynamicFlags::empty(),
3641                ___deadline,
3642            )?;
3643        Ok(_response)
3644    }
3645
3646    /// Start the GPU device.
3647    pub fn r#start(
3648        &self,
3649        mut start_info: StartInfo,
3650        mut keyboard_listener: Option<
3651            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3652        >,
3653        mut mouse_source: Option<
3654            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3655        >,
3656        ___deadline: zx::MonotonicInstant,
3657    ) -> Result<(), fidl::Error> {
3658        let _response =
3659            self.client.send_query::<VirtioGpuStartRequest, fidl::encoding::EmptyPayload>(
3660                (&mut start_info, keyboard_listener, mouse_source),
3661                0x7e81ed410f770c14,
3662                fidl::encoding::DynamicFlags::empty(),
3663                ___deadline,
3664            )?;
3665        Ok(_response)
3666    }
3667}
3668
3669#[cfg(target_os = "fuchsia")]
3670impl From<VirtioGpuSynchronousProxy> for zx::Handle {
3671    fn from(value: VirtioGpuSynchronousProxy) -> Self {
3672        value.into_channel().into()
3673    }
3674}
3675
3676#[cfg(target_os = "fuchsia")]
3677impl From<fidl::Channel> for VirtioGpuSynchronousProxy {
3678    fn from(value: fidl::Channel) -> Self {
3679        Self::new(value)
3680    }
3681}
3682
3683#[cfg(target_os = "fuchsia")]
3684impl fidl::endpoints::FromClient for VirtioGpuSynchronousProxy {
3685    type Protocol = VirtioGpuMarker;
3686
3687    fn from_client(value: fidl::endpoints::ClientEnd<VirtioGpuMarker>) -> Self {
3688        Self::new(value.into_channel())
3689    }
3690}
3691
3692#[derive(Debug, Clone)]
3693pub struct VirtioGpuProxy {
3694    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3695}
3696
3697impl fidl::endpoints::Proxy for VirtioGpuProxy {
3698    type Protocol = VirtioGpuMarker;
3699
3700    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3701        Self::new(inner)
3702    }
3703
3704    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3705        self.client.into_channel().map_err(|client| Self { client })
3706    }
3707
3708    fn as_channel(&self) -> &::fidl::AsyncChannel {
3709        self.client.as_channel()
3710    }
3711}
3712
3713impl VirtioGpuProxy {
3714    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioGpu.
3715    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3716        let protocol_name = <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3717        Self { client: fidl::client::Client::new(channel, protocol_name) }
3718    }
3719
3720    /// Get a Stream of events from the remote end of the protocol.
3721    ///
3722    /// # Panics
3723    ///
3724    /// Panics if the event stream was already taken.
3725    pub fn take_event_stream(&self) -> VirtioGpuEventStream {
3726        VirtioGpuEventStream { event_receiver: self.client.take_event_receiver() }
3727    }
3728
3729    /// Configure a `queue` for the device. This specifies the `size` and the
3730    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3731    pub fn r#configure_queue(
3732        &self,
3733        mut queue: u16,
3734        mut size: u16,
3735        mut desc: u64,
3736        mut avail: u64,
3737        mut used: u64,
3738    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3739        VirtioGpuProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
3740    }
3741
3742    /// Notify a `queue` for the device. Primarily used for black-box testing.
3743    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3744        VirtioGpuProxyInterface::r#notify_queue(self, queue)
3745    }
3746
3747    /// Ready a device. This provides the set of `negotiated_features` that the
3748    /// driver and device have agreed upon.
3749    pub fn r#ready(
3750        &self,
3751        mut negotiated_features: u32,
3752    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3753        VirtioGpuProxyInterface::r#ready(self, negotiated_features)
3754    }
3755
3756    /// Start the GPU device.
3757    pub fn r#start(
3758        &self,
3759        mut start_info: StartInfo,
3760        mut keyboard_listener: Option<
3761            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3762        >,
3763        mut mouse_source: Option<
3764            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3765        >,
3766    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3767        VirtioGpuProxyInterface::r#start(self, start_info, keyboard_listener, mouse_source)
3768    }
3769}
3770
3771impl VirtioGpuProxyInterface for VirtioGpuProxy {
3772    type ConfigureQueueResponseFut =
3773        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3774    fn r#configure_queue(
3775        &self,
3776        mut queue: u16,
3777        mut size: u16,
3778        mut desc: u64,
3779        mut avail: u64,
3780        mut used: u64,
3781    ) -> Self::ConfigureQueueResponseFut {
3782        fn _decode(
3783            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3784        ) -> Result<(), fidl::Error> {
3785            let _response = fidl::client::decode_transaction_body::<
3786                fidl::encoding::EmptyPayload,
3787                fidl::encoding::DefaultFuchsiaResourceDialect,
3788                0x72b44fb963480b11,
3789            >(_buf?)?;
3790            Ok(_response)
3791        }
3792        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
3793            (queue, size, desc, avail, used),
3794            0x72b44fb963480b11,
3795            fidl::encoding::DynamicFlags::empty(),
3796            _decode,
3797        )
3798    }
3799
3800    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3801        self.client.send::<VirtioDeviceNotifyQueueRequest>(
3802            (queue,),
3803            0x6e3a61d652499244,
3804            fidl::encoding::DynamicFlags::empty(),
3805        )
3806    }
3807
3808    type ReadyResponseFut =
3809        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3810    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
3811        fn _decode(
3812            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3813        ) -> Result<(), fidl::Error> {
3814            let _response = fidl::client::decode_transaction_body::<
3815                fidl::encoding::EmptyPayload,
3816                fidl::encoding::DefaultFuchsiaResourceDialect,
3817                0x45707654f5d23c3f,
3818            >(_buf?)?;
3819            Ok(_response)
3820        }
3821        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
3822            (negotiated_features,),
3823            0x45707654f5d23c3f,
3824            fidl::encoding::DynamicFlags::empty(),
3825            _decode,
3826        )
3827    }
3828
3829    type StartResponseFut =
3830        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3831    fn r#start(
3832        &self,
3833        mut start_info: StartInfo,
3834        mut keyboard_listener: Option<
3835            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3836        >,
3837        mut mouse_source: Option<
3838            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3839        >,
3840    ) -> Self::StartResponseFut {
3841        fn _decode(
3842            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3843        ) -> Result<(), fidl::Error> {
3844            let _response = fidl::client::decode_transaction_body::<
3845                fidl::encoding::EmptyPayload,
3846                fidl::encoding::DefaultFuchsiaResourceDialect,
3847                0x7e81ed410f770c14,
3848            >(_buf?)?;
3849            Ok(_response)
3850        }
3851        self.client.send_query_and_decode::<VirtioGpuStartRequest, ()>(
3852            (&mut start_info, keyboard_listener, mouse_source),
3853            0x7e81ed410f770c14,
3854            fidl::encoding::DynamicFlags::empty(),
3855            _decode,
3856        )
3857    }
3858}
3859
3860pub struct VirtioGpuEventStream {
3861    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3862}
3863
3864impl std::marker::Unpin for VirtioGpuEventStream {}
3865
3866impl futures::stream::FusedStream for VirtioGpuEventStream {
3867    fn is_terminated(&self) -> bool {
3868        self.event_receiver.is_terminated()
3869    }
3870}
3871
3872impl futures::Stream for VirtioGpuEventStream {
3873    type Item = Result<VirtioGpuEvent, fidl::Error>;
3874
3875    fn poll_next(
3876        mut self: std::pin::Pin<&mut Self>,
3877        cx: &mut std::task::Context<'_>,
3878    ) -> std::task::Poll<Option<Self::Item>> {
3879        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3880            &mut self.event_receiver,
3881            cx
3882        )?) {
3883            Some(buf) => std::task::Poll::Ready(Some(VirtioGpuEvent::decode(buf))),
3884            None => std::task::Poll::Ready(None),
3885        }
3886    }
3887}
3888
3889#[derive(Debug)]
3890pub enum VirtioGpuEvent {
3891    OnConfigChanged {},
3892}
3893
3894impl VirtioGpuEvent {
3895    #[allow(irrefutable_let_patterns)]
3896    pub fn into_on_config_changed(self) -> Option<()> {
3897        if let VirtioGpuEvent::OnConfigChanged {} = self {
3898            Some(())
3899        } else {
3900            None
3901        }
3902    }
3903
3904    /// Decodes a message buffer as a [`VirtioGpuEvent`].
3905    fn decode(
3906        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3907    ) -> Result<VirtioGpuEvent, fidl::Error> {
3908        let (bytes, _handles) = buf.split_mut();
3909        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3910        debug_assert_eq!(tx_header.tx_id, 0);
3911        match tx_header.ordinal {
3912            0x1555f5b7c8444aa0 => {
3913                let mut out = fidl::new_empty!(
3914                    fidl::encoding::EmptyPayload,
3915                    fidl::encoding::DefaultFuchsiaResourceDialect
3916                );
3917                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3918                Ok((VirtioGpuEvent::OnConfigChanged {}))
3919            }
3920            _ => Err(fidl::Error::UnknownOrdinal {
3921                ordinal: tx_header.ordinal,
3922                protocol_name: <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3923            }),
3924        }
3925    }
3926}
3927
3928/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioGpu.
3929pub struct VirtioGpuRequestStream {
3930    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3931    is_terminated: bool,
3932}
3933
3934impl std::marker::Unpin for VirtioGpuRequestStream {}
3935
3936impl futures::stream::FusedStream for VirtioGpuRequestStream {
3937    fn is_terminated(&self) -> bool {
3938        self.is_terminated
3939    }
3940}
3941
3942impl fidl::endpoints::RequestStream for VirtioGpuRequestStream {
3943    type Protocol = VirtioGpuMarker;
3944    type ControlHandle = VirtioGpuControlHandle;
3945
3946    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3947        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3948    }
3949
3950    fn control_handle(&self) -> Self::ControlHandle {
3951        VirtioGpuControlHandle { inner: self.inner.clone() }
3952    }
3953
3954    fn into_inner(
3955        self,
3956    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3957    {
3958        (self.inner, self.is_terminated)
3959    }
3960
3961    fn from_inner(
3962        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3963        is_terminated: bool,
3964    ) -> Self {
3965        Self { inner, is_terminated }
3966    }
3967}
3968
3969impl futures::Stream for VirtioGpuRequestStream {
3970    type Item = Result<VirtioGpuRequest, fidl::Error>;
3971
3972    fn poll_next(
3973        mut self: std::pin::Pin<&mut Self>,
3974        cx: &mut std::task::Context<'_>,
3975    ) -> std::task::Poll<Option<Self::Item>> {
3976        let this = &mut *self;
3977        if this.inner.check_shutdown(cx) {
3978            this.is_terminated = true;
3979            return std::task::Poll::Ready(None);
3980        }
3981        if this.is_terminated {
3982            panic!("polled VirtioGpuRequestStream after completion");
3983        }
3984        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3985            |bytes, handles| {
3986                match this.inner.channel().read_etc(cx, bytes, handles) {
3987                    std::task::Poll::Ready(Ok(())) => {}
3988                    std::task::Poll::Pending => return std::task::Poll::Pending,
3989                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3990                        this.is_terminated = true;
3991                        return std::task::Poll::Ready(None);
3992                    }
3993                    std::task::Poll::Ready(Err(e)) => {
3994                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3995                            e.into(),
3996                        ))))
3997                    }
3998                }
3999
4000                // A message has been received from the channel
4001                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4002
4003                std::task::Poll::Ready(Some(match header.ordinal {
4004                    0x72b44fb963480b11 => {
4005                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4006                        let mut req = fidl::new_empty!(
4007                            VirtioDeviceConfigureQueueRequest,
4008                            fidl::encoding::DefaultFuchsiaResourceDialect
4009                        );
4010                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
4011                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
4012                        Ok(VirtioGpuRequest::ConfigureQueue {
4013                            queue: req.queue,
4014                            size: req.size,
4015                            desc: req.desc,
4016                            avail: req.avail,
4017                            used: req.used,
4018
4019                            responder: VirtioGpuConfigureQueueResponder {
4020                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4021                                tx_id: header.tx_id,
4022                            },
4023                        })
4024                    }
4025                    0x6e3a61d652499244 => {
4026                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4027                        let mut req = fidl::new_empty!(
4028                            VirtioDeviceNotifyQueueRequest,
4029                            fidl::encoding::DefaultFuchsiaResourceDialect
4030                        );
4031                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
4032                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
4033                        Ok(VirtioGpuRequest::NotifyQueue { queue: req.queue, control_handle })
4034                    }
4035                    0x45707654f5d23c3f => {
4036                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4037                        let mut req = fidl::new_empty!(
4038                            VirtioDeviceReadyRequest,
4039                            fidl::encoding::DefaultFuchsiaResourceDialect
4040                        );
4041                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
4042                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
4043                        Ok(VirtioGpuRequest::Ready {
4044                            negotiated_features: req.negotiated_features,
4045
4046                            responder: VirtioGpuReadyResponder {
4047                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4048                                tx_id: header.tx_id,
4049                            },
4050                        })
4051                    }
4052                    0x7e81ed410f770c14 => {
4053                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4054                        let mut req = fidl::new_empty!(
4055                            VirtioGpuStartRequest,
4056                            fidl::encoding::DefaultFuchsiaResourceDialect
4057                        );
4058                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioGpuStartRequest>(&header, _body_bytes, handles, &mut req)?;
4059                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
4060                        Ok(VirtioGpuRequest::Start {
4061                            start_info: req.start_info,
4062                            keyboard_listener: req.keyboard_listener,
4063                            mouse_source: req.mouse_source,
4064
4065                            responder: VirtioGpuStartResponder {
4066                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4067                                tx_id: header.tx_id,
4068                            },
4069                        })
4070                    }
4071                    _ => Err(fidl::Error::UnknownOrdinal {
4072                        ordinal: header.ordinal,
4073                        protocol_name:
4074                            <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4075                    }),
4076                }))
4077            },
4078        )
4079    }
4080}
4081
4082#[derive(Debug)]
4083pub enum VirtioGpuRequest {
4084    /// Configure a `queue` for the device. This specifies the `size` and the
4085    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4086    ConfigureQueue {
4087        queue: u16,
4088        size: u16,
4089        desc: u64,
4090        avail: u64,
4091        used: u64,
4092        responder: VirtioGpuConfigureQueueResponder,
4093    },
4094    /// Notify a `queue` for the device. Primarily used for black-box testing.
4095    NotifyQueue { queue: u16, control_handle: VirtioGpuControlHandle },
4096    /// Ready a device. This provides the set of `negotiated_features` that the
4097    /// driver and device have agreed upon.
4098    Ready { negotiated_features: u32, responder: VirtioGpuReadyResponder },
4099    /// Start the GPU device.
4100    Start {
4101        start_info: StartInfo,
4102        keyboard_listener:
4103            Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
4104        mouse_source:
4105            Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
4106        responder: VirtioGpuStartResponder,
4107    },
4108}
4109
4110impl VirtioGpuRequest {
4111    #[allow(irrefutable_let_patterns)]
4112    pub fn into_configure_queue(
4113        self,
4114    ) -> Option<(u16, u16, u64, u64, u64, VirtioGpuConfigureQueueResponder)> {
4115        if let VirtioGpuRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
4116        {
4117            Some((queue, size, desc, avail, used, responder))
4118        } else {
4119            None
4120        }
4121    }
4122
4123    #[allow(irrefutable_let_patterns)]
4124    pub fn into_notify_queue(self) -> Option<(u16, VirtioGpuControlHandle)> {
4125        if let VirtioGpuRequest::NotifyQueue { queue, control_handle } = self {
4126            Some((queue, control_handle))
4127        } else {
4128            None
4129        }
4130    }
4131
4132    #[allow(irrefutable_let_patterns)]
4133    pub fn into_ready(self) -> Option<(u32, VirtioGpuReadyResponder)> {
4134        if let VirtioGpuRequest::Ready { negotiated_features, responder } = self {
4135            Some((negotiated_features, responder))
4136        } else {
4137            None
4138        }
4139    }
4140
4141    #[allow(irrefutable_let_patterns)]
4142    pub fn into_start(
4143        self,
4144    ) -> Option<(
4145        StartInfo,
4146        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
4147        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
4148        VirtioGpuStartResponder,
4149    )> {
4150        if let VirtioGpuRequest::Start { start_info, keyboard_listener, mouse_source, responder } =
4151            self
4152        {
4153            Some((start_info, keyboard_listener, mouse_source, responder))
4154        } else {
4155            None
4156        }
4157    }
4158
4159    /// Name of the method defined in FIDL
4160    pub fn method_name(&self) -> &'static str {
4161        match *self {
4162            VirtioGpuRequest::ConfigureQueue { .. } => "configure_queue",
4163            VirtioGpuRequest::NotifyQueue { .. } => "notify_queue",
4164            VirtioGpuRequest::Ready { .. } => "ready",
4165            VirtioGpuRequest::Start { .. } => "start",
4166        }
4167    }
4168}
4169
4170#[derive(Debug, Clone)]
4171pub struct VirtioGpuControlHandle {
4172    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4173}
4174
4175impl fidl::endpoints::ControlHandle for VirtioGpuControlHandle {
4176    fn shutdown(&self) {
4177        self.inner.shutdown()
4178    }
4179    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4180        self.inner.shutdown_with_epitaph(status)
4181    }
4182
4183    fn is_closed(&self) -> bool {
4184        self.inner.channel().is_closed()
4185    }
4186    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4187        self.inner.channel().on_closed()
4188    }
4189
4190    #[cfg(target_os = "fuchsia")]
4191    fn signal_peer(
4192        &self,
4193        clear_mask: zx::Signals,
4194        set_mask: zx::Signals,
4195    ) -> Result<(), zx_status::Status> {
4196        use fidl::Peered;
4197        self.inner.channel().signal_peer(clear_mask, set_mask)
4198    }
4199}
4200
4201impl VirtioGpuControlHandle {
4202    pub fn send_on_config_changed(&self) -> Result<(), fidl::Error> {
4203        self.inner.send::<fidl::encoding::EmptyPayload>(
4204            (),
4205            0,
4206            0x1555f5b7c8444aa0,
4207            fidl::encoding::DynamicFlags::empty(),
4208        )
4209    }
4210}
4211
4212#[must_use = "FIDL methods require a response to be sent"]
4213#[derive(Debug)]
4214pub struct VirtioGpuConfigureQueueResponder {
4215    control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
4216    tx_id: u32,
4217}
4218
4219/// Set the the channel to be shutdown (see [`VirtioGpuControlHandle::shutdown`])
4220/// if the responder is dropped without sending a response, so that the client
4221/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4222impl std::ops::Drop for VirtioGpuConfigureQueueResponder {
4223    fn drop(&mut self) {
4224        self.control_handle.shutdown();
4225        // Safety: drops once, never accessed again
4226        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4227    }
4228}
4229
4230impl fidl::endpoints::Responder for VirtioGpuConfigureQueueResponder {
4231    type ControlHandle = VirtioGpuControlHandle;
4232
4233    fn control_handle(&self) -> &VirtioGpuControlHandle {
4234        &self.control_handle
4235    }
4236
4237    fn drop_without_shutdown(mut self) {
4238        // Safety: drops once, never accessed again due to mem::forget
4239        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4240        // Prevent Drop from running (which would shut down the channel)
4241        std::mem::forget(self);
4242    }
4243}
4244
4245impl VirtioGpuConfigureQueueResponder {
4246    /// Sends a response to the FIDL transaction.
4247    ///
4248    /// Sets the channel to shutdown if an error occurs.
4249    pub fn send(self) -> Result<(), fidl::Error> {
4250        let _result = self.send_raw();
4251        if _result.is_err() {
4252            self.control_handle.shutdown();
4253        }
4254        self.drop_without_shutdown();
4255        _result
4256    }
4257
4258    /// Similar to "send" but does not shutdown the channel if an error occurs.
4259    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4260        let _result = self.send_raw();
4261        self.drop_without_shutdown();
4262        _result
4263    }
4264
4265    fn send_raw(&self) -> Result<(), fidl::Error> {
4266        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4267            (),
4268            self.tx_id,
4269            0x72b44fb963480b11,
4270            fidl::encoding::DynamicFlags::empty(),
4271        )
4272    }
4273}
4274
4275#[must_use = "FIDL methods require a response to be sent"]
4276#[derive(Debug)]
4277pub struct VirtioGpuReadyResponder {
4278    control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
4279    tx_id: u32,
4280}
4281
4282/// Set the the channel to be shutdown (see [`VirtioGpuControlHandle::shutdown`])
4283/// if the responder is dropped without sending a response, so that the client
4284/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4285impl std::ops::Drop for VirtioGpuReadyResponder {
4286    fn drop(&mut self) {
4287        self.control_handle.shutdown();
4288        // Safety: drops once, never accessed again
4289        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4290    }
4291}
4292
4293impl fidl::endpoints::Responder for VirtioGpuReadyResponder {
4294    type ControlHandle = VirtioGpuControlHandle;
4295
4296    fn control_handle(&self) -> &VirtioGpuControlHandle {
4297        &self.control_handle
4298    }
4299
4300    fn drop_without_shutdown(mut self) {
4301        // Safety: drops once, never accessed again due to mem::forget
4302        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4303        // Prevent Drop from running (which would shut down the channel)
4304        std::mem::forget(self);
4305    }
4306}
4307
4308impl VirtioGpuReadyResponder {
4309    /// Sends a response to the FIDL transaction.
4310    ///
4311    /// Sets the channel to shutdown if an error occurs.
4312    pub fn send(self) -> Result<(), fidl::Error> {
4313        let _result = self.send_raw();
4314        if _result.is_err() {
4315            self.control_handle.shutdown();
4316        }
4317        self.drop_without_shutdown();
4318        _result
4319    }
4320
4321    /// Similar to "send" but does not shutdown the channel if an error occurs.
4322    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4323        let _result = self.send_raw();
4324        self.drop_without_shutdown();
4325        _result
4326    }
4327
4328    fn send_raw(&self) -> Result<(), fidl::Error> {
4329        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4330            (),
4331            self.tx_id,
4332            0x45707654f5d23c3f,
4333            fidl::encoding::DynamicFlags::empty(),
4334        )
4335    }
4336}
4337
4338#[must_use = "FIDL methods require a response to be sent"]
4339#[derive(Debug)]
4340pub struct VirtioGpuStartResponder {
4341    control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
4342    tx_id: u32,
4343}
4344
4345/// Set the the channel to be shutdown (see [`VirtioGpuControlHandle::shutdown`])
4346/// if the responder is dropped without sending a response, so that the client
4347/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4348impl std::ops::Drop for VirtioGpuStartResponder {
4349    fn drop(&mut self) {
4350        self.control_handle.shutdown();
4351        // Safety: drops once, never accessed again
4352        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4353    }
4354}
4355
4356impl fidl::endpoints::Responder for VirtioGpuStartResponder {
4357    type ControlHandle = VirtioGpuControlHandle;
4358
4359    fn control_handle(&self) -> &VirtioGpuControlHandle {
4360        &self.control_handle
4361    }
4362
4363    fn drop_without_shutdown(mut self) {
4364        // Safety: drops once, never accessed again due to mem::forget
4365        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4366        // Prevent Drop from running (which would shut down the channel)
4367        std::mem::forget(self);
4368    }
4369}
4370
4371impl VirtioGpuStartResponder {
4372    /// Sends a response to the FIDL transaction.
4373    ///
4374    /// Sets the channel to shutdown if an error occurs.
4375    pub fn send(self) -> Result<(), fidl::Error> {
4376        let _result = self.send_raw();
4377        if _result.is_err() {
4378            self.control_handle.shutdown();
4379        }
4380        self.drop_without_shutdown();
4381        _result
4382    }
4383
4384    /// Similar to "send" but does not shutdown the channel if an error occurs.
4385    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4386        let _result = self.send_raw();
4387        self.drop_without_shutdown();
4388        _result
4389    }
4390
4391    fn send_raw(&self) -> Result<(), fidl::Error> {
4392        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4393            (),
4394            self.tx_id,
4395            0x7e81ed410f770c14,
4396            fidl::encoding::DynamicFlags::empty(),
4397        )
4398    }
4399}
4400
4401#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4402pub struct VirtioInputMarker;
4403
4404impl fidl::endpoints::ProtocolMarker for VirtioInputMarker {
4405    type Proxy = VirtioInputProxy;
4406    type RequestStream = VirtioInputRequestStream;
4407    #[cfg(target_os = "fuchsia")]
4408    type SynchronousProxy = VirtioInputSynchronousProxy;
4409
4410    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioInput";
4411}
4412impl fidl::endpoints::DiscoverableProtocolMarker for VirtioInputMarker {}
4413
4414pub trait VirtioInputProxyInterface: Send + Sync {
4415    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4416    fn r#configure_queue(
4417        &self,
4418        queue: u16,
4419        size: u16,
4420        desc: u64,
4421        avail: u64,
4422        used: u64,
4423    ) -> Self::ConfigureQueueResponseFut;
4424    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
4425    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4426    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
4427    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4428    fn r#start(&self, start_info: StartInfo, input_type: InputType) -> Self::StartResponseFut;
4429}
4430#[derive(Debug)]
4431#[cfg(target_os = "fuchsia")]
4432pub struct VirtioInputSynchronousProxy {
4433    client: fidl::client::sync::Client,
4434}
4435
4436#[cfg(target_os = "fuchsia")]
4437impl fidl::endpoints::SynchronousProxy for VirtioInputSynchronousProxy {
4438    type Proxy = VirtioInputProxy;
4439    type Protocol = VirtioInputMarker;
4440
4441    fn from_channel(inner: fidl::Channel) -> Self {
4442        Self::new(inner)
4443    }
4444
4445    fn into_channel(self) -> fidl::Channel {
4446        self.client.into_channel()
4447    }
4448
4449    fn as_channel(&self) -> &fidl::Channel {
4450        self.client.as_channel()
4451    }
4452}
4453
4454#[cfg(target_os = "fuchsia")]
4455impl VirtioInputSynchronousProxy {
4456    pub fn new(channel: fidl::Channel) -> Self {
4457        let protocol_name = <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4458        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4459    }
4460
4461    pub fn into_channel(self) -> fidl::Channel {
4462        self.client.into_channel()
4463    }
4464
4465    /// Waits until an event arrives and returns it. It is safe for other
4466    /// threads to make concurrent requests while waiting for an event.
4467    pub fn wait_for_event(
4468        &self,
4469        deadline: zx::MonotonicInstant,
4470    ) -> Result<VirtioInputEvent, fidl::Error> {
4471        VirtioInputEvent::decode(self.client.wait_for_event(deadline)?)
4472    }
4473
4474    /// Configure a `queue` for the device. This specifies the `size` and the
4475    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4476    pub fn r#configure_queue(
4477        &self,
4478        mut queue: u16,
4479        mut size: u16,
4480        mut desc: u64,
4481        mut avail: u64,
4482        mut used: u64,
4483        ___deadline: zx::MonotonicInstant,
4484    ) -> Result<(), fidl::Error> {
4485        let _response = self
4486            .client
4487            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
4488                (queue, size, desc, avail, used),
4489                0x72b44fb963480b11,
4490                fidl::encoding::DynamicFlags::empty(),
4491                ___deadline,
4492            )?;
4493        Ok(_response)
4494    }
4495
4496    /// Notify a `queue` for the device. Primarily used for black-box testing.
4497    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
4498        self.client.send::<VirtioDeviceNotifyQueueRequest>(
4499            (queue,),
4500            0x6e3a61d652499244,
4501            fidl::encoding::DynamicFlags::empty(),
4502        )
4503    }
4504
4505    /// Ready a device. This provides the set of `negotiated_features` that the
4506    /// driver and device have agreed upon.
4507    pub fn r#ready(
4508        &self,
4509        mut negotiated_features: u32,
4510        ___deadline: zx::MonotonicInstant,
4511    ) -> Result<(), fidl::Error> {
4512        let _response =
4513            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
4514                (negotiated_features,),
4515                0x45707654f5d23c3f,
4516                fidl::encoding::DynamicFlags::empty(),
4517                ___deadline,
4518            )?;
4519        Ok(_response)
4520    }
4521
4522    /// Start the input device.
4523    pub fn r#start(
4524        &self,
4525        mut start_info: StartInfo,
4526        mut input_type: InputType,
4527        ___deadline: zx::MonotonicInstant,
4528    ) -> Result<(), fidl::Error> {
4529        let _response =
4530            self.client.send_query::<VirtioInputStartRequest, fidl::encoding::EmptyPayload>(
4531                (&mut start_info, &mut input_type),
4532                0x612743931f7f9249,
4533                fidl::encoding::DynamicFlags::empty(),
4534                ___deadline,
4535            )?;
4536        Ok(_response)
4537    }
4538}
4539
4540#[cfg(target_os = "fuchsia")]
4541impl From<VirtioInputSynchronousProxy> for zx::Handle {
4542    fn from(value: VirtioInputSynchronousProxy) -> Self {
4543        value.into_channel().into()
4544    }
4545}
4546
4547#[cfg(target_os = "fuchsia")]
4548impl From<fidl::Channel> for VirtioInputSynchronousProxy {
4549    fn from(value: fidl::Channel) -> Self {
4550        Self::new(value)
4551    }
4552}
4553
4554#[cfg(target_os = "fuchsia")]
4555impl fidl::endpoints::FromClient for VirtioInputSynchronousProxy {
4556    type Protocol = VirtioInputMarker;
4557
4558    fn from_client(value: fidl::endpoints::ClientEnd<VirtioInputMarker>) -> Self {
4559        Self::new(value.into_channel())
4560    }
4561}
4562
4563#[derive(Debug, Clone)]
4564pub struct VirtioInputProxy {
4565    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4566}
4567
4568impl fidl::endpoints::Proxy for VirtioInputProxy {
4569    type Protocol = VirtioInputMarker;
4570
4571    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4572        Self::new(inner)
4573    }
4574
4575    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4576        self.client.into_channel().map_err(|client| Self { client })
4577    }
4578
4579    fn as_channel(&self) -> &::fidl::AsyncChannel {
4580        self.client.as_channel()
4581    }
4582}
4583
4584impl VirtioInputProxy {
4585    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioInput.
4586    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4587        let protocol_name = <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4588        Self { client: fidl::client::Client::new(channel, protocol_name) }
4589    }
4590
4591    /// Get a Stream of events from the remote end of the protocol.
4592    ///
4593    /// # Panics
4594    ///
4595    /// Panics if the event stream was already taken.
4596    pub fn take_event_stream(&self) -> VirtioInputEventStream {
4597        VirtioInputEventStream { event_receiver: self.client.take_event_receiver() }
4598    }
4599
4600    /// Configure a `queue` for the device. This specifies the `size` and the
4601    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4602    pub fn r#configure_queue(
4603        &self,
4604        mut queue: u16,
4605        mut size: u16,
4606        mut desc: u64,
4607        mut avail: u64,
4608        mut used: u64,
4609    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4610        VirtioInputProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
4611    }
4612
4613    /// Notify a `queue` for the device. Primarily used for black-box testing.
4614    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
4615        VirtioInputProxyInterface::r#notify_queue(self, queue)
4616    }
4617
4618    /// Ready a device. This provides the set of `negotiated_features` that the
4619    /// driver and device have agreed upon.
4620    pub fn r#ready(
4621        &self,
4622        mut negotiated_features: u32,
4623    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4624        VirtioInputProxyInterface::r#ready(self, negotiated_features)
4625    }
4626
4627    /// Start the input device.
4628    pub fn r#start(
4629        &self,
4630        mut start_info: StartInfo,
4631        mut input_type: InputType,
4632    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4633        VirtioInputProxyInterface::r#start(self, start_info, input_type)
4634    }
4635}
4636
4637impl VirtioInputProxyInterface for VirtioInputProxy {
4638    type ConfigureQueueResponseFut =
4639        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4640    fn r#configure_queue(
4641        &self,
4642        mut queue: u16,
4643        mut size: u16,
4644        mut desc: u64,
4645        mut avail: u64,
4646        mut used: u64,
4647    ) -> Self::ConfigureQueueResponseFut {
4648        fn _decode(
4649            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4650        ) -> Result<(), fidl::Error> {
4651            let _response = fidl::client::decode_transaction_body::<
4652                fidl::encoding::EmptyPayload,
4653                fidl::encoding::DefaultFuchsiaResourceDialect,
4654                0x72b44fb963480b11,
4655            >(_buf?)?;
4656            Ok(_response)
4657        }
4658        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
4659            (queue, size, desc, avail, used),
4660            0x72b44fb963480b11,
4661            fidl::encoding::DynamicFlags::empty(),
4662            _decode,
4663        )
4664    }
4665
4666    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
4667        self.client.send::<VirtioDeviceNotifyQueueRequest>(
4668            (queue,),
4669            0x6e3a61d652499244,
4670            fidl::encoding::DynamicFlags::empty(),
4671        )
4672    }
4673
4674    type ReadyResponseFut =
4675        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4676    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
4677        fn _decode(
4678            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4679        ) -> Result<(), fidl::Error> {
4680            let _response = fidl::client::decode_transaction_body::<
4681                fidl::encoding::EmptyPayload,
4682                fidl::encoding::DefaultFuchsiaResourceDialect,
4683                0x45707654f5d23c3f,
4684            >(_buf?)?;
4685            Ok(_response)
4686        }
4687        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
4688            (negotiated_features,),
4689            0x45707654f5d23c3f,
4690            fidl::encoding::DynamicFlags::empty(),
4691            _decode,
4692        )
4693    }
4694
4695    type StartResponseFut =
4696        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4697    fn r#start(
4698        &self,
4699        mut start_info: StartInfo,
4700        mut input_type: InputType,
4701    ) -> Self::StartResponseFut {
4702        fn _decode(
4703            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4704        ) -> Result<(), fidl::Error> {
4705            let _response = fidl::client::decode_transaction_body::<
4706                fidl::encoding::EmptyPayload,
4707                fidl::encoding::DefaultFuchsiaResourceDialect,
4708                0x612743931f7f9249,
4709            >(_buf?)?;
4710            Ok(_response)
4711        }
4712        self.client.send_query_and_decode::<VirtioInputStartRequest, ()>(
4713            (&mut start_info, &mut input_type),
4714            0x612743931f7f9249,
4715            fidl::encoding::DynamicFlags::empty(),
4716            _decode,
4717        )
4718    }
4719}
4720
4721pub struct VirtioInputEventStream {
4722    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4723}
4724
4725impl std::marker::Unpin for VirtioInputEventStream {}
4726
4727impl futures::stream::FusedStream for VirtioInputEventStream {
4728    fn is_terminated(&self) -> bool {
4729        self.event_receiver.is_terminated()
4730    }
4731}
4732
4733impl futures::Stream for VirtioInputEventStream {
4734    type Item = Result<VirtioInputEvent, fidl::Error>;
4735
4736    fn poll_next(
4737        mut self: std::pin::Pin<&mut Self>,
4738        cx: &mut std::task::Context<'_>,
4739    ) -> std::task::Poll<Option<Self::Item>> {
4740        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4741            &mut self.event_receiver,
4742            cx
4743        )?) {
4744            Some(buf) => std::task::Poll::Ready(Some(VirtioInputEvent::decode(buf))),
4745            None => std::task::Poll::Ready(None),
4746        }
4747    }
4748}
4749
4750#[derive(Debug)]
4751pub enum VirtioInputEvent {}
4752
4753impl VirtioInputEvent {
4754    /// Decodes a message buffer as a [`VirtioInputEvent`].
4755    fn decode(
4756        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4757    ) -> Result<VirtioInputEvent, fidl::Error> {
4758        let (bytes, _handles) = buf.split_mut();
4759        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4760        debug_assert_eq!(tx_header.tx_id, 0);
4761        match tx_header.ordinal {
4762            _ => Err(fidl::Error::UnknownOrdinal {
4763                ordinal: tx_header.ordinal,
4764                protocol_name: <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4765            }),
4766        }
4767    }
4768}
4769
4770/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioInput.
4771pub struct VirtioInputRequestStream {
4772    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4773    is_terminated: bool,
4774}
4775
4776impl std::marker::Unpin for VirtioInputRequestStream {}
4777
4778impl futures::stream::FusedStream for VirtioInputRequestStream {
4779    fn is_terminated(&self) -> bool {
4780        self.is_terminated
4781    }
4782}
4783
4784impl fidl::endpoints::RequestStream for VirtioInputRequestStream {
4785    type Protocol = VirtioInputMarker;
4786    type ControlHandle = VirtioInputControlHandle;
4787
4788    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4789        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4790    }
4791
4792    fn control_handle(&self) -> Self::ControlHandle {
4793        VirtioInputControlHandle { inner: self.inner.clone() }
4794    }
4795
4796    fn into_inner(
4797        self,
4798    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4799    {
4800        (self.inner, self.is_terminated)
4801    }
4802
4803    fn from_inner(
4804        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4805        is_terminated: bool,
4806    ) -> Self {
4807        Self { inner, is_terminated }
4808    }
4809}
4810
4811impl futures::Stream for VirtioInputRequestStream {
4812    type Item = Result<VirtioInputRequest, fidl::Error>;
4813
4814    fn poll_next(
4815        mut self: std::pin::Pin<&mut Self>,
4816        cx: &mut std::task::Context<'_>,
4817    ) -> std::task::Poll<Option<Self::Item>> {
4818        let this = &mut *self;
4819        if this.inner.check_shutdown(cx) {
4820            this.is_terminated = true;
4821            return std::task::Poll::Ready(None);
4822        }
4823        if this.is_terminated {
4824            panic!("polled VirtioInputRequestStream after completion");
4825        }
4826        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4827            |bytes, handles| {
4828                match this.inner.channel().read_etc(cx, bytes, handles) {
4829                    std::task::Poll::Ready(Ok(())) => {}
4830                    std::task::Poll::Pending => return std::task::Poll::Pending,
4831                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4832                        this.is_terminated = true;
4833                        return std::task::Poll::Ready(None);
4834                    }
4835                    std::task::Poll::Ready(Err(e)) => {
4836                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4837                            e.into(),
4838                        ))))
4839                    }
4840                }
4841
4842                // A message has been received from the channel
4843                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4844
4845                std::task::Poll::Ready(Some(match header.ordinal {
4846                    0x72b44fb963480b11 => {
4847                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4848                        let mut req = fidl::new_empty!(
4849                            VirtioDeviceConfigureQueueRequest,
4850                            fidl::encoding::DefaultFuchsiaResourceDialect
4851                        );
4852                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
4853                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4854                        Ok(VirtioInputRequest::ConfigureQueue {
4855                            queue: req.queue,
4856                            size: req.size,
4857                            desc: req.desc,
4858                            avail: req.avail,
4859                            used: req.used,
4860
4861                            responder: VirtioInputConfigureQueueResponder {
4862                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4863                                tx_id: header.tx_id,
4864                            },
4865                        })
4866                    }
4867                    0x6e3a61d652499244 => {
4868                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4869                        let mut req = fidl::new_empty!(
4870                            VirtioDeviceNotifyQueueRequest,
4871                            fidl::encoding::DefaultFuchsiaResourceDialect
4872                        );
4873                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
4874                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4875                        Ok(VirtioInputRequest::NotifyQueue { queue: req.queue, control_handle })
4876                    }
4877                    0x45707654f5d23c3f => {
4878                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4879                        let mut req = fidl::new_empty!(
4880                            VirtioDeviceReadyRequest,
4881                            fidl::encoding::DefaultFuchsiaResourceDialect
4882                        );
4883                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
4884                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4885                        Ok(VirtioInputRequest::Ready {
4886                            negotiated_features: req.negotiated_features,
4887
4888                            responder: VirtioInputReadyResponder {
4889                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4890                                tx_id: header.tx_id,
4891                            },
4892                        })
4893                    }
4894                    0x612743931f7f9249 => {
4895                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4896                        let mut req = fidl::new_empty!(
4897                            VirtioInputStartRequest,
4898                            fidl::encoding::DefaultFuchsiaResourceDialect
4899                        );
4900                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioInputStartRequest>(&header, _body_bytes, handles, &mut req)?;
4901                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4902                        Ok(VirtioInputRequest::Start {
4903                            start_info: req.start_info,
4904                            input_type: req.input_type,
4905
4906                            responder: VirtioInputStartResponder {
4907                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4908                                tx_id: header.tx_id,
4909                            },
4910                        })
4911                    }
4912                    _ => Err(fidl::Error::UnknownOrdinal {
4913                        ordinal: header.ordinal,
4914                        protocol_name:
4915                            <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4916                    }),
4917                }))
4918            },
4919        )
4920    }
4921}
4922
4923#[derive(Debug)]
4924pub enum VirtioInputRequest {
4925    /// Configure a `queue` for the device. This specifies the `size` and the
4926    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4927    ConfigureQueue {
4928        queue: u16,
4929        size: u16,
4930        desc: u64,
4931        avail: u64,
4932        used: u64,
4933        responder: VirtioInputConfigureQueueResponder,
4934    },
4935    /// Notify a `queue` for the device. Primarily used for black-box testing.
4936    NotifyQueue { queue: u16, control_handle: VirtioInputControlHandle },
4937    /// Ready a device. This provides the set of `negotiated_features` that the
4938    /// driver and device have agreed upon.
4939    Ready { negotiated_features: u32, responder: VirtioInputReadyResponder },
4940    /// Start the input device.
4941    Start { start_info: StartInfo, input_type: InputType, responder: VirtioInputStartResponder },
4942}
4943
4944impl VirtioInputRequest {
4945    #[allow(irrefutable_let_patterns)]
4946    pub fn into_configure_queue(
4947        self,
4948    ) -> Option<(u16, u16, u64, u64, u64, VirtioInputConfigureQueueResponder)> {
4949        if let VirtioInputRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
4950            self
4951        {
4952            Some((queue, size, desc, avail, used, responder))
4953        } else {
4954            None
4955        }
4956    }
4957
4958    #[allow(irrefutable_let_patterns)]
4959    pub fn into_notify_queue(self) -> Option<(u16, VirtioInputControlHandle)> {
4960        if let VirtioInputRequest::NotifyQueue { queue, control_handle } = self {
4961            Some((queue, control_handle))
4962        } else {
4963            None
4964        }
4965    }
4966
4967    #[allow(irrefutable_let_patterns)]
4968    pub fn into_ready(self) -> Option<(u32, VirtioInputReadyResponder)> {
4969        if let VirtioInputRequest::Ready { negotiated_features, responder } = self {
4970            Some((negotiated_features, responder))
4971        } else {
4972            None
4973        }
4974    }
4975
4976    #[allow(irrefutable_let_patterns)]
4977    pub fn into_start(self) -> Option<(StartInfo, InputType, VirtioInputStartResponder)> {
4978        if let VirtioInputRequest::Start { start_info, input_type, responder } = self {
4979            Some((start_info, input_type, responder))
4980        } else {
4981            None
4982        }
4983    }
4984
4985    /// Name of the method defined in FIDL
4986    pub fn method_name(&self) -> &'static str {
4987        match *self {
4988            VirtioInputRequest::ConfigureQueue { .. } => "configure_queue",
4989            VirtioInputRequest::NotifyQueue { .. } => "notify_queue",
4990            VirtioInputRequest::Ready { .. } => "ready",
4991            VirtioInputRequest::Start { .. } => "start",
4992        }
4993    }
4994}
4995
4996#[derive(Debug, Clone)]
4997pub struct VirtioInputControlHandle {
4998    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4999}
5000
5001impl fidl::endpoints::ControlHandle for VirtioInputControlHandle {
5002    fn shutdown(&self) {
5003        self.inner.shutdown()
5004    }
5005    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5006        self.inner.shutdown_with_epitaph(status)
5007    }
5008
5009    fn is_closed(&self) -> bool {
5010        self.inner.channel().is_closed()
5011    }
5012    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5013        self.inner.channel().on_closed()
5014    }
5015
5016    #[cfg(target_os = "fuchsia")]
5017    fn signal_peer(
5018        &self,
5019        clear_mask: zx::Signals,
5020        set_mask: zx::Signals,
5021    ) -> Result<(), zx_status::Status> {
5022        use fidl::Peered;
5023        self.inner.channel().signal_peer(clear_mask, set_mask)
5024    }
5025}
5026
5027impl VirtioInputControlHandle {}
5028
5029#[must_use = "FIDL methods require a response to be sent"]
5030#[derive(Debug)]
5031pub struct VirtioInputConfigureQueueResponder {
5032    control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
5033    tx_id: u32,
5034}
5035
5036/// Set the the channel to be shutdown (see [`VirtioInputControlHandle::shutdown`])
5037/// if the responder is dropped without sending a response, so that the client
5038/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5039impl std::ops::Drop for VirtioInputConfigureQueueResponder {
5040    fn drop(&mut self) {
5041        self.control_handle.shutdown();
5042        // Safety: drops once, never accessed again
5043        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5044    }
5045}
5046
5047impl fidl::endpoints::Responder for VirtioInputConfigureQueueResponder {
5048    type ControlHandle = VirtioInputControlHandle;
5049
5050    fn control_handle(&self) -> &VirtioInputControlHandle {
5051        &self.control_handle
5052    }
5053
5054    fn drop_without_shutdown(mut self) {
5055        // Safety: drops once, never accessed again due to mem::forget
5056        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5057        // Prevent Drop from running (which would shut down the channel)
5058        std::mem::forget(self);
5059    }
5060}
5061
5062impl VirtioInputConfigureQueueResponder {
5063    /// Sends a response to the FIDL transaction.
5064    ///
5065    /// Sets the channel to shutdown if an error occurs.
5066    pub fn send(self) -> Result<(), fidl::Error> {
5067        let _result = self.send_raw();
5068        if _result.is_err() {
5069            self.control_handle.shutdown();
5070        }
5071        self.drop_without_shutdown();
5072        _result
5073    }
5074
5075    /// Similar to "send" but does not shutdown the channel if an error occurs.
5076    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5077        let _result = self.send_raw();
5078        self.drop_without_shutdown();
5079        _result
5080    }
5081
5082    fn send_raw(&self) -> Result<(), fidl::Error> {
5083        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5084            (),
5085            self.tx_id,
5086            0x72b44fb963480b11,
5087            fidl::encoding::DynamicFlags::empty(),
5088        )
5089    }
5090}
5091
5092#[must_use = "FIDL methods require a response to be sent"]
5093#[derive(Debug)]
5094pub struct VirtioInputReadyResponder {
5095    control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
5096    tx_id: u32,
5097}
5098
5099/// Set the the channel to be shutdown (see [`VirtioInputControlHandle::shutdown`])
5100/// if the responder is dropped without sending a response, so that the client
5101/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5102impl std::ops::Drop for VirtioInputReadyResponder {
5103    fn drop(&mut self) {
5104        self.control_handle.shutdown();
5105        // Safety: drops once, never accessed again
5106        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5107    }
5108}
5109
5110impl fidl::endpoints::Responder for VirtioInputReadyResponder {
5111    type ControlHandle = VirtioInputControlHandle;
5112
5113    fn control_handle(&self) -> &VirtioInputControlHandle {
5114        &self.control_handle
5115    }
5116
5117    fn drop_without_shutdown(mut self) {
5118        // Safety: drops once, never accessed again due to mem::forget
5119        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5120        // Prevent Drop from running (which would shut down the channel)
5121        std::mem::forget(self);
5122    }
5123}
5124
5125impl VirtioInputReadyResponder {
5126    /// Sends a response to the FIDL transaction.
5127    ///
5128    /// Sets the channel to shutdown if an error occurs.
5129    pub fn send(self) -> Result<(), fidl::Error> {
5130        let _result = self.send_raw();
5131        if _result.is_err() {
5132            self.control_handle.shutdown();
5133        }
5134        self.drop_without_shutdown();
5135        _result
5136    }
5137
5138    /// Similar to "send" but does not shutdown the channel if an error occurs.
5139    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5140        let _result = self.send_raw();
5141        self.drop_without_shutdown();
5142        _result
5143    }
5144
5145    fn send_raw(&self) -> Result<(), fidl::Error> {
5146        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5147            (),
5148            self.tx_id,
5149            0x45707654f5d23c3f,
5150            fidl::encoding::DynamicFlags::empty(),
5151        )
5152    }
5153}
5154
5155#[must_use = "FIDL methods require a response to be sent"]
5156#[derive(Debug)]
5157pub struct VirtioInputStartResponder {
5158    control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
5159    tx_id: u32,
5160}
5161
5162/// Set the the channel to be shutdown (see [`VirtioInputControlHandle::shutdown`])
5163/// if the responder is dropped without sending a response, so that the client
5164/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5165impl std::ops::Drop for VirtioInputStartResponder {
5166    fn drop(&mut self) {
5167        self.control_handle.shutdown();
5168        // Safety: drops once, never accessed again
5169        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5170    }
5171}
5172
5173impl fidl::endpoints::Responder for VirtioInputStartResponder {
5174    type ControlHandle = VirtioInputControlHandle;
5175
5176    fn control_handle(&self) -> &VirtioInputControlHandle {
5177        &self.control_handle
5178    }
5179
5180    fn drop_without_shutdown(mut self) {
5181        // Safety: drops once, never accessed again due to mem::forget
5182        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5183        // Prevent Drop from running (which would shut down the channel)
5184        std::mem::forget(self);
5185    }
5186}
5187
5188impl VirtioInputStartResponder {
5189    /// Sends a response to the FIDL transaction.
5190    ///
5191    /// Sets the channel to shutdown if an error occurs.
5192    pub fn send(self) -> Result<(), fidl::Error> {
5193        let _result = self.send_raw();
5194        if _result.is_err() {
5195            self.control_handle.shutdown();
5196        }
5197        self.drop_without_shutdown();
5198        _result
5199    }
5200
5201    /// Similar to "send" but does not shutdown the channel if an error occurs.
5202    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5203        let _result = self.send_raw();
5204        self.drop_without_shutdown();
5205        _result
5206    }
5207
5208    fn send_raw(&self) -> Result<(), fidl::Error> {
5209        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5210            (),
5211            self.tx_id,
5212            0x612743931f7f9249,
5213            fidl::encoding::DynamicFlags::empty(),
5214        )
5215    }
5216}
5217
5218#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5219pub struct VirtioMagmaMarker;
5220
5221impl fidl::endpoints::ProtocolMarker for VirtioMagmaMarker {
5222    type Proxy = VirtioMagmaProxy;
5223    type RequestStream = VirtioMagmaRequestStream;
5224    #[cfg(target_os = "fuchsia")]
5225    type SynchronousProxy = VirtioMagmaSynchronousProxy;
5226
5227    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioMagma";
5228}
5229impl fidl::endpoints::DiscoverableProtocolMarker for VirtioMagmaMarker {}
5230
5231pub trait VirtioMagmaProxyInterface: Send + Sync {
5232    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5233    fn r#configure_queue(
5234        &self,
5235        queue: u16,
5236        size: u16,
5237        desc: u64,
5238        avail: u64,
5239        used: u64,
5240    ) -> Self::ConfigureQueueResponseFut;
5241    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
5242    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5243    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
5244    type StartResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
5245    fn r#start(
5246        &self,
5247        start_info: StartInfo,
5248        vmar: fidl::Vmar,
5249        wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5250    ) -> Self::StartResponseFut;
5251}
5252#[derive(Debug)]
5253#[cfg(target_os = "fuchsia")]
5254pub struct VirtioMagmaSynchronousProxy {
5255    client: fidl::client::sync::Client,
5256}
5257
5258#[cfg(target_os = "fuchsia")]
5259impl fidl::endpoints::SynchronousProxy for VirtioMagmaSynchronousProxy {
5260    type Proxy = VirtioMagmaProxy;
5261    type Protocol = VirtioMagmaMarker;
5262
5263    fn from_channel(inner: fidl::Channel) -> Self {
5264        Self::new(inner)
5265    }
5266
5267    fn into_channel(self) -> fidl::Channel {
5268        self.client.into_channel()
5269    }
5270
5271    fn as_channel(&self) -> &fidl::Channel {
5272        self.client.as_channel()
5273    }
5274}
5275
5276#[cfg(target_os = "fuchsia")]
5277impl VirtioMagmaSynchronousProxy {
5278    pub fn new(channel: fidl::Channel) -> Self {
5279        let protocol_name = <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5280        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5281    }
5282
5283    pub fn into_channel(self) -> fidl::Channel {
5284        self.client.into_channel()
5285    }
5286
5287    /// Waits until an event arrives and returns it. It is safe for other
5288    /// threads to make concurrent requests while waiting for an event.
5289    pub fn wait_for_event(
5290        &self,
5291        deadline: zx::MonotonicInstant,
5292    ) -> Result<VirtioMagmaEvent, fidl::Error> {
5293        VirtioMagmaEvent::decode(self.client.wait_for_event(deadline)?)
5294    }
5295
5296    /// Configure a `queue` for the device. This specifies the `size` and the
5297    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
5298    pub fn r#configure_queue(
5299        &self,
5300        mut queue: u16,
5301        mut size: u16,
5302        mut desc: u64,
5303        mut avail: u64,
5304        mut used: u64,
5305        ___deadline: zx::MonotonicInstant,
5306    ) -> Result<(), fidl::Error> {
5307        let _response = self
5308            .client
5309            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
5310                (queue, size, desc, avail, used),
5311                0x72b44fb963480b11,
5312                fidl::encoding::DynamicFlags::empty(),
5313                ___deadline,
5314            )?;
5315        Ok(_response)
5316    }
5317
5318    /// Notify a `queue` for the device. Primarily used for black-box testing.
5319    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
5320        self.client.send::<VirtioDeviceNotifyQueueRequest>(
5321            (queue,),
5322            0x6e3a61d652499244,
5323            fidl::encoding::DynamicFlags::empty(),
5324        )
5325    }
5326
5327    /// Ready a device. This provides the set of `negotiated_features` that the
5328    /// driver and device have agreed upon.
5329    pub fn r#ready(
5330        &self,
5331        mut negotiated_features: u32,
5332        ___deadline: zx::MonotonicInstant,
5333    ) -> Result<(), fidl::Error> {
5334        let _response =
5335            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
5336                (negotiated_features,),
5337                0x45707654f5d23c3f,
5338                fidl::encoding::DynamicFlags::empty(),
5339                ___deadline,
5340            )?;
5341        Ok(_response)
5342    }
5343
5344    /// Start the magma device.
5345    pub fn r#start(
5346        &self,
5347        mut start_info: StartInfo,
5348        mut vmar: fidl::Vmar,
5349        mut wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5350        ___deadline: zx::MonotonicInstant,
5351    ) -> Result<i32, fidl::Error> {
5352        let _response =
5353            self.client.send_query::<VirtioMagmaStartRequest, VirtioMagmaStartResponse>(
5354                (&mut start_info, vmar, wayland_importer),
5355                0x6b94e28f73d201e2,
5356                fidl::encoding::DynamicFlags::empty(),
5357                ___deadline,
5358            )?;
5359        Ok(_response.status)
5360    }
5361}
5362
5363#[cfg(target_os = "fuchsia")]
5364impl From<VirtioMagmaSynchronousProxy> for zx::Handle {
5365    fn from(value: VirtioMagmaSynchronousProxy) -> Self {
5366        value.into_channel().into()
5367    }
5368}
5369
5370#[cfg(target_os = "fuchsia")]
5371impl From<fidl::Channel> for VirtioMagmaSynchronousProxy {
5372    fn from(value: fidl::Channel) -> Self {
5373        Self::new(value)
5374    }
5375}
5376
5377#[cfg(target_os = "fuchsia")]
5378impl fidl::endpoints::FromClient for VirtioMagmaSynchronousProxy {
5379    type Protocol = VirtioMagmaMarker;
5380
5381    fn from_client(value: fidl::endpoints::ClientEnd<VirtioMagmaMarker>) -> Self {
5382        Self::new(value.into_channel())
5383    }
5384}
5385
5386#[derive(Debug, Clone)]
5387pub struct VirtioMagmaProxy {
5388    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5389}
5390
5391impl fidl::endpoints::Proxy for VirtioMagmaProxy {
5392    type Protocol = VirtioMagmaMarker;
5393
5394    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5395        Self::new(inner)
5396    }
5397
5398    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5399        self.client.into_channel().map_err(|client| Self { client })
5400    }
5401
5402    fn as_channel(&self) -> &::fidl::AsyncChannel {
5403        self.client.as_channel()
5404    }
5405}
5406
5407impl VirtioMagmaProxy {
5408    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioMagma.
5409    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5410        let protocol_name = <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5411        Self { client: fidl::client::Client::new(channel, protocol_name) }
5412    }
5413
5414    /// Get a Stream of events from the remote end of the protocol.
5415    ///
5416    /// # Panics
5417    ///
5418    /// Panics if the event stream was already taken.
5419    pub fn take_event_stream(&self) -> VirtioMagmaEventStream {
5420        VirtioMagmaEventStream { event_receiver: self.client.take_event_receiver() }
5421    }
5422
5423    /// Configure a `queue` for the device. This specifies the `size` and the
5424    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
5425    pub fn r#configure_queue(
5426        &self,
5427        mut queue: u16,
5428        mut size: u16,
5429        mut desc: u64,
5430        mut avail: u64,
5431        mut used: u64,
5432    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5433        VirtioMagmaProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
5434    }
5435
5436    /// Notify a `queue` for the device. Primarily used for black-box testing.
5437    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
5438        VirtioMagmaProxyInterface::r#notify_queue(self, queue)
5439    }
5440
5441    /// Ready a device. This provides the set of `negotiated_features` that the
5442    /// driver and device have agreed upon.
5443    pub fn r#ready(
5444        &self,
5445        mut negotiated_features: u32,
5446    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5447        VirtioMagmaProxyInterface::r#ready(self, negotiated_features)
5448    }
5449
5450    /// Start the magma device.
5451    pub fn r#start(
5452        &self,
5453        mut start_info: StartInfo,
5454        mut vmar: fidl::Vmar,
5455        mut wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5456    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5457        VirtioMagmaProxyInterface::r#start(self, start_info, vmar, wayland_importer)
5458    }
5459}
5460
5461impl VirtioMagmaProxyInterface for VirtioMagmaProxy {
5462    type ConfigureQueueResponseFut =
5463        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5464    fn r#configure_queue(
5465        &self,
5466        mut queue: u16,
5467        mut size: u16,
5468        mut desc: u64,
5469        mut avail: u64,
5470        mut used: u64,
5471    ) -> Self::ConfigureQueueResponseFut {
5472        fn _decode(
5473            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5474        ) -> Result<(), fidl::Error> {
5475            let _response = fidl::client::decode_transaction_body::<
5476                fidl::encoding::EmptyPayload,
5477                fidl::encoding::DefaultFuchsiaResourceDialect,
5478                0x72b44fb963480b11,
5479            >(_buf?)?;
5480            Ok(_response)
5481        }
5482        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
5483            (queue, size, desc, avail, used),
5484            0x72b44fb963480b11,
5485            fidl::encoding::DynamicFlags::empty(),
5486            _decode,
5487        )
5488    }
5489
5490    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
5491        self.client.send::<VirtioDeviceNotifyQueueRequest>(
5492            (queue,),
5493            0x6e3a61d652499244,
5494            fidl::encoding::DynamicFlags::empty(),
5495        )
5496    }
5497
5498    type ReadyResponseFut =
5499        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5500    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
5501        fn _decode(
5502            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5503        ) -> Result<(), fidl::Error> {
5504            let _response = fidl::client::decode_transaction_body::<
5505                fidl::encoding::EmptyPayload,
5506                fidl::encoding::DefaultFuchsiaResourceDialect,
5507                0x45707654f5d23c3f,
5508            >(_buf?)?;
5509            Ok(_response)
5510        }
5511        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
5512            (negotiated_features,),
5513            0x45707654f5d23c3f,
5514            fidl::encoding::DynamicFlags::empty(),
5515            _decode,
5516        )
5517    }
5518
5519    type StartResponseFut =
5520        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5521    fn r#start(
5522        &self,
5523        mut start_info: StartInfo,
5524        mut vmar: fidl::Vmar,
5525        mut wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5526    ) -> Self::StartResponseFut {
5527        fn _decode(
5528            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5529        ) -> Result<i32, fidl::Error> {
5530            let _response = fidl::client::decode_transaction_body::<
5531                VirtioMagmaStartResponse,
5532                fidl::encoding::DefaultFuchsiaResourceDialect,
5533                0x6b94e28f73d201e2,
5534            >(_buf?)?;
5535            Ok(_response.status)
5536        }
5537        self.client.send_query_and_decode::<VirtioMagmaStartRequest, i32>(
5538            (&mut start_info, vmar, wayland_importer),
5539            0x6b94e28f73d201e2,
5540            fidl::encoding::DynamicFlags::empty(),
5541            _decode,
5542        )
5543    }
5544}
5545
5546pub struct VirtioMagmaEventStream {
5547    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5548}
5549
5550impl std::marker::Unpin for VirtioMagmaEventStream {}
5551
5552impl futures::stream::FusedStream for VirtioMagmaEventStream {
5553    fn is_terminated(&self) -> bool {
5554        self.event_receiver.is_terminated()
5555    }
5556}
5557
5558impl futures::Stream for VirtioMagmaEventStream {
5559    type Item = Result<VirtioMagmaEvent, fidl::Error>;
5560
5561    fn poll_next(
5562        mut self: std::pin::Pin<&mut Self>,
5563        cx: &mut std::task::Context<'_>,
5564    ) -> std::task::Poll<Option<Self::Item>> {
5565        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5566            &mut self.event_receiver,
5567            cx
5568        )?) {
5569            Some(buf) => std::task::Poll::Ready(Some(VirtioMagmaEvent::decode(buf))),
5570            None => std::task::Poll::Ready(None),
5571        }
5572    }
5573}
5574
5575#[derive(Debug)]
5576pub enum VirtioMagmaEvent {}
5577
5578impl VirtioMagmaEvent {
5579    /// Decodes a message buffer as a [`VirtioMagmaEvent`].
5580    fn decode(
5581        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5582    ) -> Result<VirtioMagmaEvent, fidl::Error> {
5583        let (bytes, _handles) = buf.split_mut();
5584        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5585        debug_assert_eq!(tx_header.tx_id, 0);
5586        match tx_header.ordinal {
5587            _ => Err(fidl::Error::UnknownOrdinal {
5588                ordinal: tx_header.ordinal,
5589                protocol_name: <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5590            }),
5591        }
5592    }
5593}
5594
5595/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioMagma.
5596pub struct VirtioMagmaRequestStream {
5597    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5598    is_terminated: bool,
5599}
5600
5601impl std::marker::Unpin for VirtioMagmaRequestStream {}
5602
5603impl futures::stream::FusedStream for VirtioMagmaRequestStream {
5604    fn is_terminated(&self) -> bool {
5605        self.is_terminated
5606    }
5607}
5608
5609impl fidl::endpoints::RequestStream for VirtioMagmaRequestStream {
5610    type Protocol = VirtioMagmaMarker;
5611    type ControlHandle = VirtioMagmaControlHandle;
5612
5613    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5614        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5615    }
5616
5617    fn control_handle(&self) -> Self::ControlHandle {
5618        VirtioMagmaControlHandle { inner: self.inner.clone() }
5619    }
5620
5621    fn into_inner(
5622        self,
5623    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5624    {
5625        (self.inner, self.is_terminated)
5626    }
5627
5628    fn from_inner(
5629        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5630        is_terminated: bool,
5631    ) -> Self {
5632        Self { inner, is_terminated }
5633    }
5634}
5635
5636impl futures::Stream for VirtioMagmaRequestStream {
5637    type Item = Result<VirtioMagmaRequest, fidl::Error>;
5638
5639    fn poll_next(
5640        mut self: std::pin::Pin<&mut Self>,
5641        cx: &mut std::task::Context<'_>,
5642    ) -> std::task::Poll<Option<Self::Item>> {
5643        let this = &mut *self;
5644        if this.inner.check_shutdown(cx) {
5645            this.is_terminated = true;
5646            return std::task::Poll::Ready(None);
5647        }
5648        if this.is_terminated {
5649            panic!("polled VirtioMagmaRequestStream after completion");
5650        }
5651        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5652            |bytes, handles| {
5653                match this.inner.channel().read_etc(cx, bytes, handles) {
5654                    std::task::Poll::Ready(Ok(())) => {}
5655                    std::task::Poll::Pending => return std::task::Poll::Pending,
5656                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5657                        this.is_terminated = true;
5658                        return std::task::Poll::Ready(None);
5659                    }
5660                    std::task::Poll::Ready(Err(e)) => {
5661                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5662                            e.into(),
5663                        ))))
5664                    }
5665                }
5666
5667                // A message has been received from the channel
5668                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5669
5670                std::task::Poll::Ready(Some(match header.ordinal {
5671                    0x72b44fb963480b11 => {
5672                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5673                        let mut req = fidl::new_empty!(
5674                            VirtioDeviceConfigureQueueRequest,
5675                            fidl::encoding::DefaultFuchsiaResourceDialect
5676                        );
5677                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
5678                        let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
5679                        Ok(VirtioMagmaRequest::ConfigureQueue {
5680                            queue: req.queue,
5681                            size: req.size,
5682                            desc: req.desc,
5683                            avail: req.avail,
5684                            used: req.used,
5685
5686                            responder: VirtioMagmaConfigureQueueResponder {
5687                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5688                                tx_id: header.tx_id,
5689                            },
5690                        })
5691                    }
5692                    0x6e3a61d652499244 => {
5693                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5694                        let mut req = fidl::new_empty!(
5695                            VirtioDeviceNotifyQueueRequest,
5696                            fidl::encoding::DefaultFuchsiaResourceDialect
5697                        );
5698                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
5699                        let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
5700                        Ok(VirtioMagmaRequest::NotifyQueue { queue: req.queue, control_handle })
5701                    }
5702                    0x45707654f5d23c3f => {
5703                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5704                        let mut req = fidl::new_empty!(
5705                            VirtioDeviceReadyRequest,
5706                            fidl::encoding::DefaultFuchsiaResourceDialect
5707                        );
5708                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
5709                        let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
5710                        Ok(VirtioMagmaRequest::Ready {
5711                            negotiated_features: req.negotiated_features,
5712
5713                            responder: VirtioMagmaReadyResponder {
5714                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5715                                tx_id: header.tx_id,
5716                            },
5717                        })
5718                    }
5719                    0x6b94e28f73d201e2 => {
5720                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5721                        let mut req = fidl::new_empty!(
5722                            VirtioMagmaStartRequest,
5723                            fidl::encoding::DefaultFuchsiaResourceDialect
5724                        );
5725                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMagmaStartRequest>(&header, _body_bytes, handles, &mut req)?;
5726                        let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
5727                        Ok(VirtioMagmaRequest::Start {
5728                            start_info: req.start_info,
5729                            vmar: req.vmar,
5730                            wayland_importer: req.wayland_importer,
5731
5732                            responder: VirtioMagmaStartResponder {
5733                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5734                                tx_id: header.tx_id,
5735                            },
5736                        })
5737                    }
5738                    _ => Err(fidl::Error::UnknownOrdinal {
5739                        ordinal: header.ordinal,
5740                        protocol_name:
5741                            <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5742                    }),
5743                }))
5744            },
5745        )
5746    }
5747}
5748
5749#[derive(Debug)]
5750pub enum VirtioMagmaRequest {
5751    /// Configure a `queue` for the device. This specifies the `size` and the
5752    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
5753    ConfigureQueue {
5754        queue: u16,
5755        size: u16,
5756        desc: u64,
5757        avail: u64,
5758        used: u64,
5759        responder: VirtioMagmaConfigureQueueResponder,
5760    },
5761    /// Notify a `queue` for the device. Primarily used for black-box testing.
5762    NotifyQueue { queue: u16, control_handle: VirtioMagmaControlHandle },
5763    /// Ready a device. This provides the set of `negotiated_features` that the
5764    /// driver and device have agreed upon.
5765    Ready { negotiated_features: u32, responder: VirtioMagmaReadyResponder },
5766    /// Start the magma device.
5767    Start {
5768        start_info: StartInfo,
5769        vmar: fidl::Vmar,
5770        wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5771        responder: VirtioMagmaStartResponder,
5772    },
5773}
5774
5775impl VirtioMagmaRequest {
5776    #[allow(irrefutable_let_patterns)]
5777    pub fn into_configure_queue(
5778        self,
5779    ) -> Option<(u16, u16, u64, u64, u64, VirtioMagmaConfigureQueueResponder)> {
5780        if let VirtioMagmaRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
5781            self
5782        {
5783            Some((queue, size, desc, avail, used, responder))
5784        } else {
5785            None
5786        }
5787    }
5788
5789    #[allow(irrefutable_let_patterns)]
5790    pub fn into_notify_queue(self) -> Option<(u16, VirtioMagmaControlHandle)> {
5791        if let VirtioMagmaRequest::NotifyQueue { queue, control_handle } = self {
5792            Some((queue, control_handle))
5793        } else {
5794            None
5795        }
5796    }
5797
5798    #[allow(irrefutable_let_patterns)]
5799    pub fn into_ready(self) -> Option<(u32, VirtioMagmaReadyResponder)> {
5800        if let VirtioMagmaRequest::Ready { negotiated_features, responder } = self {
5801            Some((negotiated_features, responder))
5802        } else {
5803            None
5804        }
5805    }
5806
5807    #[allow(irrefutable_let_patterns)]
5808    pub fn into_start(
5809        self,
5810    ) -> Option<(
5811        StartInfo,
5812        fidl::Vmar,
5813        Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5814        VirtioMagmaStartResponder,
5815    )> {
5816        if let VirtioMagmaRequest::Start { start_info, vmar, wayland_importer, responder } = self {
5817            Some((start_info, vmar, wayland_importer, responder))
5818        } else {
5819            None
5820        }
5821    }
5822
5823    /// Name of the method defined in FIDL
5824    pub fn method_name(&self) -> &'static str {
5825        match *self {
5826            VirtioMagmaRequest::ConfigureQueue { .. } => "configure_queue",
5827            VirtioMagmaRequest::NotifyQueue { .. } => "notify_queue",
5828            VirtioMagmaRequest::Ready { .. } => "ready",
5829            VirtioMagmaRequest::Start { .. } => "start",
5830        }
5831    }
5832}
5833
5834#[derive(Debug, Clone)]
5835pub struct VirtioMagmaControlHandle {
5836    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5837}
5838
5839impl fidl::endpoints::ControlHandle for VirtioMagmaControlHandle {
5840    fn shutdown(&self) {
5841        self.inner.shutdown()
5842    }
5843    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5844        self.inner.shutdown_with_epitaph(status)
5845    }
5846
5847    fn is_closed(&self) -> bool {
5848        self.inner.channel().is_closed()
5849    }
5850    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5851        self.inner.channel().on_closed()
5852    }
5853
5854    #[cfg(target_os = "fuchsia")]
5855    fn signal_peer(
5856        &self,
5857        clear_mask: zx::Signals,
5858        set_mask: zx::Signals,
5859    ) -> Result<(), zx_status::Status> {
5860        use fidl::Peered;
5861        self.inner.channel().signal_peer(clear_mask, set_mask)
5862    }
5863}
5864
5865impl VirtioMagmaControlHandle {}
5866
5867#[must_use = "FIDL methods require a response to be sent"]
5868#[derive(Debug)]
5869pub struct VirtioMagmaConfigureQueueResponder {
5870    control_handle: std::mem::ManuallyDrop<VirtioMagmaControlHandle>,
5871    tx_id: u32,
5872}
5873
5874/// Set the the channel to be shutdown (see [`VirtioMagmaControlHandle::shutdown`])
5875/// if the responder is dropped without sending a response, so that the client
5876/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5877impl std::ops::Drop for VirtioMagmaConfigureQueueResponder {
5878    fn drop(&mut self) {
5879        self.control_handle.shutdown();
5880        // Safety: drops once, never accessed again
5881        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5882    }
5883}
5884
5885impl fidl::endpoints::Responder for VirtioMagmaConfigureQueueResponder {
5886    type ControlHandle = VirtioMagmaControlHandle;
5887
5888    fn control_handle(&self) -> &VirtioMagmaControlHandle {
5889        &self.control_handle
5890    }
5891
5892    fn drop_without_shutdown(mut self) {
5893        // Safety: drops once, never accessed again due to mem::forget
5894        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5895        // Prevent Drop from running (which would shut down the channel)
5896        std::mem::forget(self);
5897    }
5898}
5899
5900impl VirtioMagmaConfigureQueueResponder {
5901    /// Sends a response to the FIDL transaction.
5902    ///
5903    /// Sets the channel to shutdown if an error occurs.
5904    pub fn send(self) -> Result<(), fidl::Error> {
5905        let _result = self.send_raw();
5906        if _result.is_err() {
5907            self.control_handle.shutdown();
5908        }
5909        self.drop_without_shutdown();
5910        _result
5911    }
5912
5913    /// Similar to "send" but does not shutdown the channel if an error occurs.
5914    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5915        let _result = self.send_raw();
5916        self.drop_without_shutdown();
5917        _result
5918    }
5919
5920    fn send_raw(&self) -> Result<(), fidl::Error> {
5921        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5922            (),
5923            self.tx_id,
5924            0x72b44fb963480b11,
5925            fidl::encoding::DynamicFlags::empty(),
5926        )
5927    }
5928}
5929
5930#[must_use = "FIDL methods require a response to be sent"]
5931#[derive(Debug)]
5932pub struct VirtioMagmaReadyResponder {
5933    control_handle: std::mem::ManuallyDrop<VirtioMagmaControlHandle>,
5934    tx_id: u32,
5935}
5936
5937/// Set the the channel to be shutdown (see [`VirtioMagmaControlHandle::shutdown`])
5938/// if the responder is dropped without sending a response, so that the client
5939/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5940impl std::ops::Drop for VirtioMagmaReadyResponder {
5941    fn drop(&mut self) {
5942        self.control_handle.shutdown();
5943        // Safety: drops once, never accessed again
5944        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5945    }
5946}
5947
5948impl fidl::endpoints::Responder for VirtioMagmaReadyResponder {
5949    type ControlHandle = VirtioMagmaControlHandle;
5950
5951    fn control_handle(&self) -> &VirtioMagmaControlHandle {
5952        &self.control_handle
5953    }
5954
5955    fn drop_without_shutdown(mut self) {
5956        // Safety: drops once, never accessed again due to mem::forget
5957        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5958        // Prevent Drop from running (which would shut down the channel)
5959        std::mem::forget(self);
5960    }
5961}
5962
5963impl VirtioMagmaReadyResponder {
5964    /// Sends a response to the FIDL transaction.
5965    ///
5966    /// Sets the channel to shutdown if an error occurs.
5967    pub fn send(self) -> Result<(), fidl::Error> {
5968        let _result = self.send_raw();
5969        if _result.is_err() {
5970            self.control_handle.shutdown();
5971        }
5972        self.drop_without_shutdown();
5973        _result
5974    }
5975
5976    /// Similar to "send" but does not shutdown the channel if an error occurs.
5977    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5978        let _result = self.send_raw();
5979        self.drop_without_shutdown();
5980        _result
5981    }
5982
5983    fn send_raw(&self) -> Result<(), fidl::Error> {
5984        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5985            (),
5986            self.tx_id,
5987            0x45707654f5d23c3f,
5988            fidl::encoding::DynamicFlags::empty(),
5989        )
5990    }
5991}
5992
5993#[must_use = "FIDL methods require a response to be sent"]
5994#[derive(Debug)]
5995pub struct VirtioMagmaStartResponder {
5996    control_handle: std::mem::ManuallyDrop<VirtioMagmaControlHandle>,
5997    tx_id: u32,
5998}
5999
6000/// Set the the channel to be shutdown (see [`VirtioMagmaControlHandle::shutdown`])
6001/// if the responder is dropped without sending a response, so that the client
6002/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6003impl std::ops::Drop for VirtioMagmaStartResponder {
6004    fn drop(&mut self) {
6005        self.control_handle.shutdown();
6006        // Safety: drops once, never accessed again
6007        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6008    }
6009}
6010
6011impl fidl::endpoints::Responder for VirtioMagmaStartResponder {
6012    type ControlHandle = VirtioMagmaControlHandle;
6013
6014    fn control_handle(&self) -> &VirtioMagmaControlHandle {
6015        &self.control_handle
6016    }
6017
6018    fn drop_without_shutdown(mut self) {
6019        // Safety: drops once, never accessed again due to mem::forget
6020        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6021        // Prevent Drop from running (which would shut down the channel)
6022        std::mem::forget(self);
6023    }
6024}
6025
6026impl VirtioMagmaStartResponder {
6027    /// Sends a response to the FIDL transaction.
6028    ///
6029    /// Sets the channel to shutdown if an error occurs.
6030    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
6031        let _result = self.send_raw(status);
6032        if _result.is_err() {
6033            self.control_handle.shutdown();
6034        }
6035        self.drop_without_shutdown();
6036        _result
6037    }
6038
6039    /// Similar to "send" but does not shutdown the channel if an error occurs.
6040    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
6041        let _result = self.send_raw(status);
6042        self.drop_without_shutdown();
6043        _result
6044    }
6045
6046    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
6047        self.control_handle.inner.send::<VirtioMagmaStartResponse>(
6048            (status,),
6049            self.tx_id,
6050            0x6b94e28f73d201e2,
6051            fidl::encoding::DynamicFlags::empty(),
6052        )
6053    }
6054}
6055
6056#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6057pub struct VirtioMemMarker;
6058
6059impl fidl::endpoints::ProtocolMarker for VirtioMemMarker {
6060    type Proxy = VirtioMemProxy;
6061    type RequestStream = VirtioMemRequestStream;
6062    #[cfg(target_os = "fuchsia")]
6063    type SynchronousProxy = VirtioMemSynchronousProxy;
6064
6065    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioMem";
6066}
6067impl fidl::endpoints::DiscoverableProtocolMarker for VirtioMemMarker {}
6068
6069pub trait VirtioMemProxyInterface: Send + Sync {
6070    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6071    fn r#configure_queue(
6072        &self,
6073        queue: u16,
6074        size: u16,
6075        desc: u64,
6076        avail: u64,
6077        used: u64,
6078    ) -> Self::ConfigureQueueResponseFut;
6079    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
6080    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6081    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
6082    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6083    fn r#start(
6084        &self,
6085        start_info: StartInfo,
6086        region_addr: u64,
6087        plugged_block_size: u64,
6088        region_size: u64,
6089    ) -> Self::StartResponseFut;
6090}
6091#[derive(Debug)]
6092#[cfg(target_os = "fuchsia")]
6093pub struct VirtioMemSynchronousProxy {
6094    client: fidl::client::sync::Client,
6095}
6096
6097#[cfg(target_os = "fuchsia")]
6098impl fidl::endpoints::SynchronousProxy for VirtioMemSynchronousProxy {
6099    type Proxy = VirtioMemProxy;
6100    type Protocol = VirtioMemMarker;
6101
6102    fn from_channel(inner: fidl::Channel) -> Self {
6103        Self::new(inner)
6104    }
6105
6106    fn into_channel(self) -> fidl::Channel {
6107        self.client.into_channel()
6108    }
6109
6110    fn as_channel(&self) -> &fidl::Channel {
6111        self.client.as_channel()
6112    }
6113}
6114
6115#[cfg(target_os = "fuchsia")]
6116impl VirtioMemSynchronousProxy {
6117    pub fn new(channel: fidl::Channel) -> Self {
6118        let protocol_name = <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6119        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6120    }
6121
6122    pub fn into_channel(self) -> fidl::Channel {
6123        self.client.into_channel()
6124    }
6125
6126    /// Waits until an event arrives and returns it. It is safe for other
6127    /// threads to make concurrent requests while waiting for an event.
6128    pub fn wait_for_event(
6129        &self,
6130        deadline: zx::MonotonicInstant,
6131    ) -> Result<VirtioMemEvent, fidl::Error> {
6132        VirtioMemEvent::decode(self.client.wait_for_event(deadline)?)
6133    }
6134
6135    /// Configure a `queue` for the device. This specifies the `size` and the
6136    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6137    pub fn r#configure_queue(
6138        &self,
6139        mut queue: u16,
6140        mut size: u16,
6141        mut desc: u64,
6142        mut avail: u64,
6143        mut used: u64,
6144        ___deadline: zx::MonotonicInstant,
6145    ) -> Result<(), fidl::Error> {
6146        let _response = self
6147            .client
6148            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
6149                (queue, size, desc, avail, used),
6150                0x72b44fb963480b11,
6151                fidl::encoding::DynamicFlags::empty(),
6152                ___deadline,
6153            )?;
6154        Ok(_response)
6155    }
6156
6157    /// Notify a `queue` for the device. Primarily used for black-box testing.
6158    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6159        self.client.send::<VirtioDeviceNotifyQueueRequest>(
6160            (queue,),
6161            0x6e3a61d652499244,
6162            fidl::encoding::DynamicFlags::empty(),
6163        )
6164    }
6165
6166    /// Ready a device. This provides the set of `negotiated_features` that the
6167    /// driver and device have agreed upon.
6168    pub fn r#ready(
6169        &self,
6170        mut negotiated_features: u32,
6171        ___deadline: zx::MonotonicInstant,
6172    ) -> Result<(), fidl::Error> {
6173        let _response =
6174            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
6175                (negotiated_features,),
6176                0x45707654f5d23c3f,
6177                fidl::encoding::DynamicFlags::empty(),
6178                ___deadline,
6179            )?;
6180        Ok(_response)
6181    }
6182
6183    /// Start the mem device.
6184    pub fn r#start(
6185        &self,
6186        mut start_info: StartInfo,
6187        mut region_addr: u64,
6188        mut plugged_block_size: u64,
6189        mut region_size: u64,
6190        ___deadline: zx::MonotonicInstant,
6191    ) -> Result<(), fidl::Error> {
6192        let _response =
6193            self.client.send_query::<VirtioMemStartRequest, fidl::encoding::EmptyPayload>(
6194                (&mut start_info, region_addr, plugged_block_size, region_size),
6195                0x66dd64f17fb5223c,
6196                fidl::encoding::DynamicFlags::empty(),
6197                ___deadline,
6198            )?;
6199        Ok(_response)
6200    }
6201}
6202
6203#[cfg(target_os = "fuchsia")]
6204impl From<VirtioMemSynchronousProxy> for zx::Handle {
6205    fn from(value: VirtioMemSynchronousProxy) -> Self {
6206        value.into_channel().into()
6207    }
6208}
6209
6210#[cfg(target_os = "fuchsia")]
6211impl From<fidl::Channel> for VirtioMemSynchronousProxy {
6212    fn from(value: fidl::Channel) -> Self {
6213        Self::new(value)
6214    }
6215}
6216
6217#[cfg(target_os = "fuchsia")]
6218impl fidl::endpoints::FromClient for VirtioMemSynchronousProxy {
6219    type Protocol = VirtioMemMarker;
6220
6221    fn from_client(value: fidl::endpoints::ClientEnd<VirtioMemMarker>) -> Self {
6222        Self::new(value.into_channel())
6223    }
6224}
6225
6226#[derive(Debug, Clone)]
6227pub struct VirtioMemProxy {
6228    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6229}
6230
6231impl fidl::endpoints::Proxy for VirtioMemProxy {
6232    type Protocol = VirtioMemMarker;
6233
6234    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6235        Self::new(inner)
6236    }
6237
6238    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6239        self.client.into_channel().map_err(|client| Self { client })
6240    }
6241
6242    fn as_channel(&self) -> &::fidl::AsyncChannel {
6243        self.client.as_channel()
6244    }
6245}
6246
6247impl VirtioMemProxy {
6248    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioMem.
6249    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6250        let protocol_name = <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6251        Self { client: fidl::client::Client::new(channel, protocol_name) }
6252    }
6253
6254    /// Get a Stream of events from the remote end of the protocol.
6255    ///
6256    /// # Panics
6257    ///
6258    /// Panics if the event stream was already taken.
6259    pub fn take_event_stream(&self) -> VirtioMemEventStream {
6260        VirtioMemEventStream { event_receiver: self.client.take_event_receiver() }
6261    }
6262
6263    /// Configure a `queue` for the device. This specifies the `size` and the
6264    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6265    pub fn r#configure_queue(
6266        &self,
6267        mut queue: u16,
6268        mut size: u16,
6269        mut desc: u64,
6270        mut avail: u64,
6271        mut used: u64,
6272    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
6273        VirtioMemProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
6274    }
6275
6276    /// Notify a `queue` for the device. Primarily used for black-box testing.
6277    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6278        VirtioMemProxyInterface::r#notify_queue(self, queue)
6279    }
6280
6281    /// Ready a device. This provides the set of `negotiated_features` that the
6282    /// driver and device have agreed upon.
6283    pub fn r#ready(
6284        &self,
6285        mut negotiated_features: u32,
6286    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
6287        VirtioMemProxyInterface::r#ready(self, negotiated_features)
6288    }
6289
6290    /// Start the mem device.
6291    pub fn r#start(
6292        &self,
6293        mut start_info: StartInfo,
6294        mut region_addr: u64,
6295        mut plugged_block_size: u64,
6296        mut region_size: u64,
6297    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
6298        VirtioMemProxyInterface::r#start(
6299            self,
6300            start_info,
6301            region_addr,
6302            plugged_block_size,
6303            region_size,
6304        )
6305    }
6306}
6307
6308impl VirtioMemProxyInterface for VirtioMemProxy {
6309    type ConfigureQueueResponseFut =
6310        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
6311    fn r#configure_queue(
6312        &self,
6313        mut queue: u16,
6314        mut size: u16,
6315        mut desc: u64,
6316        mut avail: u64,
6317        mut used: u64,
6318    ) -> Self::ConfigureQueueResponseFut {
6319        fn _decode(
6320            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6321        ) -> Result<(), fidl::Error> {
6322            let _response = fidl::client::decode_transaction_body::<
6323                fidl::encoding::EmptyPayload,
6324                fidl::encoding::DefaultFuchsiaResourceDialect,
6325                0x72b44fb963480b11,
6326            >(_buf?)?;
6327            Ok(_response)
6328        }
6329        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
6330            (queue, size, desc, avail, used),
6331            0x72b44fb963480b11,
6332            fidl::encoding::DynamicFlags::empty(),
6333            _decode,
6334        )
6335    }
6336
6337    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6338        self.client.send::<VirtioDeviceNotifyQueueRequest>(
6339            (queue,),
6340            0x6e3a61d652499244,
6341            fidl::encoding::DynamicFlags::empty(),
6342        )
6343    }
6344
6345    type ReadyResponseFut =
6346        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
6347    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
6348        fn _decode(
6349            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6350        ) -> Result<(), fidl::Error> {
6351            let _response = fidl::client::decode_transaction_body::<
6352                fidl::encoding::EmptyPayload,
6353                fidl::encoding::DefaultFuchsiaResourceDialect,
6354                0x45707654f5d23c3f,
6355            >(_buf?)?;
6356            Ok(_response)
6357        }
6358        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
6359            (negotiated_features,),
6360            0x45707654f5d23c3f,
6361            fidl::encoding::DynamicFlags::empty(),
6362            _decode,
6363        )
6364    }
6365
6366    type StartResponseFut =
6367        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
6368    fn r#start(
6369        &self,
6370        mut start_info: StartInfo,
6371        mut region_addr: u64,
6372        mut plugged_block_size: u64,
6373        mut region_size: u64,
6374    ) -> Self::StartResponseFut {
6375        fn _decode(
6376            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6377        ) -> Result<(), fidl::Error> {
6378            let _response = fidl::client::decode_transaction_body::<
6379                fidl::encoding::EmptyPayload,
6380                fidl::encoding::DefaultFuchsiaResourceDialect,
6381                0x66dd64f17fb5223c,
6382            >(_buf?)?;
6383            Ok(_response)
6384        }
6385        self.client.send_query_and_decode::<VirtioMemStartRequest, ()>(
6386            (&mut start_info, region_addr, plugged_block_size, region_size),
6387            0x66dd64f17fb5223c,
6388            fidl::encoding::DynamicFlags::empty(),
6389            _decode,
6390        )
6391    }
6392}
6393
6394pub struct VirtioMemEventStream {
6395    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6396}
6397
6398impl std::marker::Unpin for VirtioMemEventStream {}
6399
6400impl futures::stream::FusedStream for VirtioMemEventStream {
6401    fn is_terminated(&self) -> bool {
6402        self.event_receiver.is_terminated()
6403    }
6404}
6405
6406impl futures::Stream for VirtioMemEventStream {
6407    type Item = Result<VirtioMemEvent, fidl::Error>;
6408
6409    fn poll_next(
6410        mut self: std::pin::Pin<&mut Self>,
6411        cx: &mut std::task::Context<'_>,
6412    ) -> std::task::Poll<Option<Self::Item>> {
6413        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6414            &mut self.event_receiver,
6415            cx
6416        )?) {
6417            Some(buf) => std::task::Poll::Ready(Some(VirtioMemEvent::decode(buf))),
6418            None => std::task::Poll::Ready(None),
6419        }
6420    }
6421}
6422
6423#[derive(Debug)]
6424pub enum VirtioMemEvent {
6425    OnConfigChanged { plugged_size: u64 },
6426}
6427
6428impl VirtioMemEvent {
6429    #[allow(irrefutable_let_patterns)]
6430    pub fn into_on_config_changed(self) -> Option<u64> {
6431        if let VirtioMemEvent::OnConfigChanged { plugged_size } = self {
6432            Some((plugged_size))
6433        } else {
6434            None
6435        }
6436    }
6437
6438    /// Decodes a message buffer as a [`VirtioMemEvent`].
6439    fn decode(
6440        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6441    ) -> Result<VirtioMemEvent, fidl::Error> {
6442        let (bytes, _handles) = buf.split_mut();
6443        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6444        debug_assert_eq!(tx_header.tx_id, 0);
6445        match tx_header.ordinal {
6446            0x73b86d7cc80020b9 => {
6447                let mut out = fidl::new_empty!(
6448                    VirtioMemOnConfigChangedRequest,
6449                    fidl::encoding::DefaultFuchsiaResourceDialect
6450                );
6451                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMemOnConfigChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6452                Ok((VirtioMemEvent::OnConfigChanged { plugged_size: out.plugged_size }))
6453            }
6454            _ => Err(fidl::Error::UnknownOrdinal {
6455                ordinal: tx_header.ordinal,
6456                protocol_name: <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6457            }),
6458        }
6459    }
6460}
6461
6462/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioMem.
6463pub struct VirtioMemRequestStream {
6464    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6465    is_terminated: bool,
6466}
6467
6468impl std::marker::Unpin for VirtioMemRequestStream {}
6469
6470impl futures::stream::FusedStream for VirtioMemRequestStream {
6471    fn is_terminated(&self) -> bool {
6472        self.is_terminated
6473    }
6474}
6475
6476impl fidl::endpoints::RequestStream for VirtioMemRequestStream {
6477    type Protocol = VirtioMemMarker;
6478    type ControlHandle = VirtioMemControlHandle;
6479
6480    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6481        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6482    }
6483
6484    fn control_handle(&self) -> Self::ControlHandle {
6485        VirtioMemControlHandle { inner: self.inner.clone() }
6486    }
6487
6488    fn into_inner(
6489        self,
6490    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6491    {
6492        (self.inner, self.is_terminated)
6493    }
6494
6495    fn from_inner(
6496        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6497        is_terminated: bool,
6498    ) -> Self {
6499        Self { inner, is_terminated }
6500    }
6501}
6502
6503impl futures::Stream for VirtioMemRequestStream {
6504    type Item = Result<VirtioMemRequest, fidl::Error>;
6505
6506    fn poll_next(
6507        mut self: std::pin::Pin<&mut Self>,
6508        cx: &mut std::task::Context<'_>,
6509    ) -> std::task::Poll<Option<Self::Item>> {
6510        let this = &mut *self;
6511        if this.inner.check_shutdown(cx) {
6512            this.is_terminated = true;
6513            return std::task::Poll::Ready(None);
6514        }
6515        if this.is_terminated {
6516            panic!("polled VirtioMemRequestStream after completion");
6517        }
6518        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6519            |bytes, handles| {
6520                match this.inner.channel().read_etc(cx, bytes, handles) {
6521                    std::task::Poll::Ready(Ok(())) => {}
6522                    std::task::Poll::Pending => return std::task::Poll::Pending,
6523                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6524                        this.is_terminated = true;
6525                        return std::task::Poll::Ready(None);
6526                    }
6527                    std::task::Poll::Ready(Err(e)) => {
6528                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6529                            e.into(),
6530                        ))))
6531                    }
6532                }
6533
6534                // A message has been received from the channel
6535                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6536
6537                std::task::Poll::Ready(Some(match header.ordinal {
6538                    0x72b44fb963480b11 => {
6539                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6540                        let mut req = fidl::new_empty!(
6541                            VirtioDeviceConfigureQueueRequest,
6542                            fidl::encoding::DefaultFuchsiaResourceDialect
6543                        );
6544                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
6545                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
6546                        Ok(VirtioMemRequest::ConfigureQueue {
6547                            queue: req.queue,
6548                            size: req.size,
6549                            desc: req.desc,
6550                            avail: req.avail,
6551                            used: req.used,
6552
6553                            responder: VirtioMemConfigureQueueResponder {
6554                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6555                                tx_id: header.tx_id,
6556                            },
6557                        })
6558                    }
6559                    0x6e3a61d652499244 => {
6560                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6561                        let mut req = fidl::new_empty!(
6562                            VirtioDeviceNotifyQueueRequest,
6563                            fidl::encoding::DefaultFuchsiaResourceDialect
6564                        );
6565                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
6566                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
6567                        Ok(VirtioMemRequest::NotifyQueue { queue: req.queue, control_handle })
6568                    }
6569                    0x45707654f5d23c3f => {
6570                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6571                        let mut req = fidl::new_empty!(
6572                            VirtioDeviceReadyRequest,
6573                            fidl::encoding::DefaultFuchsiaResourceDialect
6574                        );
6575                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
6576                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
6577                        Ok(VirtioMemRequest::Ready {
6578                            negotiated_features: req.negotiated_features,
6579
6580                            responder: VirtioMemReadyResponder {
6581                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6582                                tx_id: header.tx_id,
6583                            },
6584                        })
6585                    }
6586                    0x66dd64f17fb5223c => {
6587                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6588                        let mut req = fidl::new_empty!(
6589                            VirtioMemStartRequest,
6590                            fidl::encoding::DefaultFuchsiaResourceDialect
6591                        );
6592                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMemStartRequest>(&header, _body_bytes, handles, &mut req)?;
6593                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
6594                        Ok(VirtioMemRequest::Start {
6595                            start_info: req.start_info,
6596                            region_addr: req.region_addr,
6597                            plugged_block_size: req.plugged_block_size,
6598                            region_size: req.region_size,
6599
6600                            responder: VirtioMemStartResponder {
6601                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6602                                tx_id: header.tx_id,
6603                            },
6604                        })
6605                    }
6606                    _ => Err(fidl::Error::UnknownOrdinal {
6607                        ordinal: header.ordinal,
6608                        protocol_name:
6609                            <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6610                    }),
6611                }))
6612            },
6613        )
6614    }
6615}
6616
6617#[derive(Debug)]
6618pub enum VirtioMemRequest {
6619    /// Configure a `queue` for the device. This specifies the `size` and the
6620    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6621    ConfigureQueue {
6622        queue: u16,
6623        size: u16,
6624        desc: u64,
6625        avail: u64,
6626        used: u64,
6627        responder: VirtioMemConfigureQueueResponder,
6628    },
6629    /// Notify a `queue` for the device. Primarily used for black-box testing.
6630    NotifyQueue { queue: u16, control_handle: VirtioMemControlHandle },
6631    /// Ready a device. This provides the set of `negotiated_features` that the
6632    /// driver and device have agreed upon.
6633    Ready { negotiated_features: u32, responder: VirtioMemReadyResponder },
6634    /// Start the mem device.
6635    Start {
6636        start_info: StartInfo,
6637        region_addr: u64,
6638        plugged_block_size: u64,
6639        region_size: u64,
6640        responder: VirtioMemStartResponder,
6641    },
6642}
6643
6644impl VirtioMemRequest {
6645    #[allow(irrefutable_let_patterns)]
6646    pub fn into_configure_queue(
6647        self,
6648    ) -> Option<(u16, u16, u64, u64, u64, VirtioMemConfigureQueueResponder)> {
6649        if let VirtioMemRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
6650        {
6651            Some((queue, size, desc, avail, used, responder))
6652        } else {
6653            None
6654        }
6655    }
6656
6657    #[allow(irrefutable_let_patterns)]
6658    pub fn into_notify_queue(self) -> Option<(u16, VirtioMemControlHandle)> {
6659        if let VirtioMemRequest::NotifyQueue { queue, control_handle } = self {
6660            Some((queue, control_handle))
6661        } else {
6662            None
6663        }
6664    }
6665
6666    #[allow(irrefutable_let_patterns)]
6667    pub fn into_ready(self) -> Option<(u32, VirtioMemReadyResponder)> {
6668        if let VirtioMemRequest::Ready { negotiated_features, responder } = self {
6669            Some((negotiated_features, responder))
6670        } else {
6671            None
6672        }
6673    }
6674
6675    #[allow(irrefutable_let_patterns)]
6676    pub fn into_start(self) -> Option<(StartInfo, u64, u64, u64, VirtioMemStartResponder)> {
6677        if let VirtioMemRequest::Start {
6678            start_info,
6679            region_addr,
6680            plugged_block_size,
6681            region_size,
6682            responder,
6683        } = self
6684        {
6685            Some((start_info, region_addr, plugged_block_size, region_size, responder))
6686        } else {
6687            None
6688        }
6689    }
6690
6691    /// Name of the method defined in FIDL
6692    pub fn method_name(&self) -> &'static str {
6693        match *self {
6694            VirtioMemRequest::ConfigureQueue { .. } => "configure_queue",
6695            VirtioMemRequest::NotifyQueue { .. } => "notify_queue",
6696            VirtioMemRequest::Ready { .. } => "ready",
6697            VirtioMemRequest::Start { .. } => "start",
6698        }
6699    }
6700}
6701
6702#[derive(Debug, Clone)]
6703pub struct VirtioMemControlHandle {
6704    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6705}
6706
6707impl fidl::endpoints::ControlHandle for VirtioMemControlHandle {
6708    fn shutdown(&self) {
6709        self.inner.shutdown()
6710    }
6711    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6712        self.inner.shutdown_with_epitaph(status)
6713    }
6714
6715    fn is_closed(&self) -> bool {
6716        self.inner.channel().is_closed()
6717    }
6718    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6719        self.inner.channel().on_closed()
6720    }
6721
6722    #[cfg(target_os = "fuchsia")]
6723    fn signal_peer(
6724        &self,
6725        clear_mask: zx::Signals,
6726        set_mask: zx::Signals,
6727    ) -> Result<(), zx_status::Status> {
6728        use fidl::Peered;
6729        self.inner.channel().signal_peer(clear_mask, set_mask)
6730    }
6731}
6732
6733impl VirtioMemControlHandle {
6734    pub fn send_on_config_changed(&self, mut plugged_size: u64) -> Result<(), fidl::Error> {
6735        self.inner.send::<VirtioMemOnConfigChangedRequest>(
6736            (plugged_size,),
6737            0,
6738            0x73b86d7cc80020b9,
6739            fidl::encoding::DynamicFlags::empty(),
6740        )
6741    }
6742}
6743
6744#[must_use = "FIDL methods require a response to be sent"]
6745#[derive(Debug)]
6746pub struct VirtioMemConfigureQueueResponder {
6747    control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
6748    tx_id: u32,
6749}
6750
6751/// Set the the channel to be shutdown (see [`VirtioMemControlHandle::shutdown`])
6752/// if the responder is dropped without sending a response, so that the client
6753/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6754impl std::ops::Drop for VirtioMemConfigureQueueResponder {
6755    fn drop(&mut self) {
6756        self.control_handle.shutdown();
6757        // Safety: drops once, never accessed again
6758        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6759    }
6760}
6761
6762impl fidl::endpoints::Responder for VirtioMemConfigureQueueResponder {
6763    type ControlHandle = VirtioMemControlHandle;
6764
6765    fn control_handle(&self) -> &VirtioMemControlHandle {
6766        &self.control_handle
6767    }
6768
6769    fn drop_without_shutdown(mut self) {
6770        // Safety: drops once, never accessed again due to mem::forget
6771        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6772        // Prevent Drop from running (which would shut down the channel)
6773        std::mem::forget(self);
6774    }
6775}
6776
6777impl VirtioMemConfigureQueueResponder {
6778    /// Sends a response to the FIDL transaction.
6779    ///
6780    /// Sets the channel to shutdown if an error occurs.
6781    pub fn send(self) -> Result<(), fidl::Error> {
6782        let _result = self.send_raw();
6783        if _result.is_err() {
6784            self.control_handle.shutdown();
6785        }
6786        self.drop_without_shutdown();
6787        _result
6788    }
6789
6790    /// Similar to "send" but does not shutdown the channel if an error occurs.
6791    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6792        let _result = self.send_raw();
6793        self.drop_without_shutdown();
6794        _result
6795    }
6796
6797    fn send_raw(&self) -> Result<(), fidl::Error> {
6798        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6799            (),
6800            self.tx_id,
6801            0x72b44fb963480b11,
6802            fidl::encoding::DynamicFlags::empty(),
6803        )
6804    }
6805}
6806
6807#[must_use = "FIDL methods require a response to be sent"]
6808#[derive(Debug)]
6809pub struct VirtioMemReadyResponder {
6810    control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
6811    tx_id: u32,
6812}
6813
6814/// Set the the channel to be shutdown (see [`VirtioMemControlHandle::shutdown`])
6815/// if the responder is dropped without sending a response, so that the client
6816/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6817impl std::ops::Drop for VirtioMemReadyResponder {
6818    fn drop(&mut self) {
6819        self.control_handle.shutdown();
6820        // Safety: drops once, never accessed again
6821        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6822    }
6823}
6824
6825impl fidl::endpoints::Responder for VirtioMemReadyResponder {
6826    type ControlHandle = VirtioMemControlHandle;
6827
6828    fn control_handle(&self) -> &VirtioMemControlHandle {
6829        &self.control_handle
6830    }
6831
6832    fn drop_without_shutdown(mut self) {
6833        // Safety: drops once, never accessed again due to mem::forget
6834        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6835        // Prevent Drop from running (which would shut down the channel)
6836        std::mem::forget(self);
6837    }
6838}
6839
6840impl VirtioMemReadyResponder {
6841    /// Sends a response to the FIDL transaction.
6842    ///
6843    /// Sets the channel to shutdown if an error occurs.
6844    pub fn send(self) -> Result<(), fidl::Error> {
6845        let _result = self.send_raw();
6846        if _result.is_err() {
6847            self.control_handle.shutdown();
6848        }
6849        self.drop_without_shutdown();
6850        _result
6851    }
6852
6853    /// Similar to "send" but does not shutdown the channel if an error occurs.
6854    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6855        let _result = self.send_raw();
6856        self.drop_without_shutdown();
6857        _result
6858    }
6859
6860    fn send_raw(&self) -> Result<(), fidl::Error> {
6861        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6862            (),
6863            self.tx_id,
6864            0x45707654f5d23c3f,
6865            fidl::encoding::DynamicFlags::empty(),
6866        )
6867    }
6868}
6869
6870#[must_use = "FIDL methods require a response to be sent"]
6871#[derive(Debug)]
6872pub struct VirtioMemStartResponder {
6873    control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
6874    tx_id: u32,
6875}
6876
6877/// Set the the channel to be shutdown (see [`VirtioMemControlHandle::shutdown`])
6878/// if the responder is dropped without sending a response, so that the client
6879/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6880impl std::ops::Drop for VirtioMemStartResponder {
6881    fn drop(&mut self) {
6882        self.control_handle.shutdown();
6883        // Safety: drops once, never accessed again
6884        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6885    }
6886}
6887
6888impl fidl::endpoints::Responder for VirtioMemStartResponder {
6889    type ControlHandle = VirtioMemControlHandle;
6890
6891    fn control_handle(&self) -> &VirtioMemControlHandle {
6892        &self.control_handle
6893    }
6894
6895    fn drop_without_shutdown(mut self) {
6896        // Safety: drops once, never accessed again due to mem::forget
6897        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6898        // Prevent Drop from running (which would shut down the channel)
6899        std::mem::forget(self);
6900    }
6901}
6902
6903impl VirtioMemStartResponder {
6904    /// Sends a response to the FIDL transaction.
6905    ///
6906    /// Sets the channel to shutdown if an error occurs.
6907    pub fn send(self) -> Result<(), fidl::Error> {
6908        let _result = self.send_raw();
6909        if _result.is_err() {
6910            self.control_handle.shutdown();
6911        }
6912        self.drop_without_shutdown();
6913        _result
6914    }
6915
6916    /// Similar to "send" but does not shutdown the channel if an error occurs.
6917    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6918        let _result = self.send_raw();
6919        self.drop_without_shutdown();
6920        _result
6921    }
6922
6923    fn send_raw(&self) -> Result<(), fidl::Error> {
6924        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6925            (),
6926            self.tx_id,
6927            0x66dd64f17fb5223c,
6928            fidl::encoding::DynamicFlags::empty(),
6929        )
6930    }
6931}
6932
6933#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6934pub struct VirtioNetMarker;
6935
6936impl fidl::endpoints::ProtocolMarker for VirtioNetMarker {
6937    type Proxy = VirtioNetProxy;
6938    type RequestStream = VirtioNetRequestStream;
6939    #[cfg(target_os = "fuchsia")]
6940    type SynchronousProxy = VirtioNetSynchronousProxy;
6941
6942    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioNet";
6943}
6944impl fidl::endpoints::DiscoverableProtocolMarker for VirtioNetMarker {}
6945pub type VirtioNetStartResult = Result<(), i32>;
6946
6947pub trait VirtioNetProxyInterface: Send + Sync {
6948    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6949    fn r#configure_queue(
6950        &self,
6951        queue: u16,
6952        size: u16,
6953        desc: u64,
6954        avail: u64,
6955        used: u64,
6956    ) -> Self::ConfigureQueueResponseFut;
6957    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
6958    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6959    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
6960    type StartResponseFut: std::future::Future<Output = Result<VirtioNetStartResult, fidl::Error>>
6961        + Send;
6962    fn r#start(
6963        &self,
6964        start_info: StartInfo,
6965        mac_address: &fidl_fuchsia_net::MacAddress,
6966        enable_bridge: bool,
6967    ) -> Self::StartResponseFut;
6968}
6969#[derive(Debug)]
6970#[cfg(target_os = "fuchsia")]
6971pub struct VirtioNetSynchronousProxy {
6972    client: fidl::client::sync::Client,
6973}
6974
6975#[cfg(target_os = "fuchsia")]
6976impl fidl::endpoints::SynchronousProxy for VirtioNetSynchronousProxy {
6977    type Proxy = VirtioNetProxy;
6978    type Protocol = VirtioNetMarker;
6979
6980    fn from_channel(inner: fidl::Channel) -> Self {
6981        Self::new(inner)
6982    }
6983
6984    fn into_channel(self) -> fidl::Channel {
6985        self.client.into_channel()
6986    }
6987
6988    fn as_channel(&self) -> &fidl::Channel {
6989        self.client.as_channel()
6990    }
6991}
6992
6993#[cfg(target_os = "fuchsia")]
6994impl VirtioNetSynchronousProxy {
6995    pub fn new(channel: fidl::Channel) -> Self {
6996        let protocol_name = <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6997        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6998    }
6999
7000    pub fn into_channel(self) -> fidl::Channel {
7001        self.client.into_channel()
7002    }
7003
7004    /// Waits until an event arrives and returns it. It is safe for other
7005    /// threads to make concurrent requests while waiting for an event.
7006    pub fn wait_for_event(
7007        &self,
7008        deadline: zx::MonotonicInstant,
7009    ) -> Result<VirtioNetEvent, fidl::Error> {
7010        VirtioNetEvent::decode(self.client.wait_for_event(deadline)?)
7011    }
7012
7013    /// Configure a `queue` for the device. This specifies the `size` and the
7014    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7015    pub fn r#configure_queue(
7016        &self,
7017        mut queue: u16,
7018        mut size: u16,
7019        mut desc: u64,
7020        mut avail: u64,
7021        mut used: u64,
7022        ___deadline: zx::MonotonicInstant,
7023    ) -> Result<(), fidl::Error> {
7024        let _response = self
7025            .client
7026            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
7027                (queue, size, desc, avail, used),
7028                0x72b44fb963480b11,
7029                fidl::encoding::DynamicFlags::empty(),
7030                ___deadline,
7031            )?;
7032        Ok(_response)
7033    }
7034
7035    /// Notify a `queue` for the device. Primarily used for black-box testing.
7036    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7037        self.client.send::<VirtioDeviceNotifyQueueRequest>(
7038            (queue,),
7039            0x6e3a61d652499244,
7040            fidl::encoding::DynamicFlags::empty(),
7041        )
7042    }
7043
7044    /// Ready a device. This provides the set of `negotiated_features` that the
7045    /// driver and device have agreed upon.
7046    pub fn r#ready(
7047        &self,
7048        mut negotiated_features: u32,
7049        ___deadline: zx::MonotonicInstant,
7050    ) -> Result<(), fidl::Error> {
7051        let _response =
7052            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
7053                (negotiated_features,),
7054                0x45707654f5d23c3f,
7055                fidl::encoding::DynamicFlags::empty(),
7056                ___deadline,
7057            )?;
7058        Ok(_response)
7059    }
7060
7061    /// Start the net device.
7062    pub fn r#start(
7063        &self,
7064        mut start_info: StartInfo,
7065        mut mac_address: &fidl_fuchsia_net::MacAddress,
7066        mut enable_bridge: bool,
7067        ___deadline: zx::MonotonicInstant,
7068    ) -> Result<VirtioNetStartResult, fidl::Error> {
7069        let _response = self.client.send_query::<
7070            VirtioNetStartRequest,
7071            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
7072        >(
7073            (&mut start_info, mac_address, enable_bridge,),
7074            0x795c0b3a8461b3ed,
7075            fidl::encoding::DynamicFlags::empty(),
7076            ___deadline,
7077        )?;
7078        Ok(_response.map(|x| x))
7079    }
7080}
7081
7082#[cfg(target_os = "fuchsia")]
7083impl From<VirtioNetSynchronousProxy> for zx::Handle {
7084    fn from(value: VirtioNetSynchronousProxy) -> Self {
7085        value.into_channel().into()
7086    }
7087}
7088
7089#[cfg(target_os = "fuchsia")]
7090impl From<fidl::Channel> for VirtioNetSynchronousProxy {
7091    fn from(value: fidl::Channel) -> Self {
7092        Self::new(value)
7093    }
7094}
7095
7096#[cfg(target_os = "fuchsia")]
7097impl fidl::endpoints::FromClient for VirtioNetSynchronousProxy {
7098    type Protocol = VirtioNetMarker;
7099
7100    fn from_client(value: fidl::endpoints::ClientEnd<VirtioNetMarker>) -> Self {
7101        Self::new(value.into_channel())
7102    }
7103}
7104
7105#[derive(Debug, Clone)]
7106pub struct VirtioNetProxy {
7107    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7108}
7109
7110impl fidl::endpoints::Proxy for VirtioNetProxy {
7111    type Protocol = VirtioNetMarker;
7112
7113    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7114        Self::new(inner)
7115    }
7116
7117    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7118        self.client.into_channel().map_err(|client| Self { client })
7119    }
7120
7121    fn as_channel(&self) -> &::fidl::AsyncChannel {
7122        self.client.as_channel()
7123    }
7124}
7125
7126impl VirtioNetProxy {
7127    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioNet.
7128    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7129        let protocol_name = <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7130        Self { client: fidl::client::Client::new(channel, protocol_name) }
7131    }
7132
7133    /// Get a Stream of events from the remote end of the protocol.
7134    ///
7135    /// # Panics
7136    ///
7137    /// Panics if the event stream was already taken.
7138    pub fn take_event_stream(&self) -> VirtioNetEventStream {
7139        VirtioNetEventStream { event_receiver: self.client.take_event_receiver() }
7140    }
7141
7142    /// Configure a `queue` for the device. This specifies the `size` and the
7143    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7144    pub fn r#configure_queue(
7145        &self,
7146        mut queue: u16,
7147        mut size: u16,
7148        mut desc: u64,
7149        mut avail: u64,
7150        mut used: u64,
7151    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7152        VirtioNetProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
7153    }
7154
7155    /// Notify a `queue` for the device. Primarily used for black-box testing.
7156    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7157        VirtioNetProxyInterface::r#notify_queue(self, queue)
7158    }
7159
7160    /// Ready a device. This provides the set of `negotiated_features` that the
7161    /// driver and device have agreed upon.
7162    pub fn r#ready(
7163        &self,
7164        mut negotiated_features: u32,
7165    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7166        VirtioNetProxyInterface::r#ready(self, negotiated_features)
7167    }
7168
7169    /// Start the net device.
7170    pub fn r#start(
7171        &self,
7172        mut start_info: StartInfo,
7173        mut mac_address: &fidl_fuchsia_net::MacAddress,
7174        mut enable_bridge: bool,
7175    ) -> fidl::client::QueryResponseFut<
7176        VirtioNetStartResult,
7177        fidl::encoding::DefaultFuchsiaResourceDialect,
7178    > {
7179        VirtioNetProxyInterface::r#start(self, start_info, mac_address, enable_bridge)
7180    }
7181}
7182
7183impl VirtioNetProxyInterface for VirtioNetProxy {
7184    type ConfigureQueueResponseFut =
7185        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7186    fn r#configure_queue(
7187        &self,
7188        mut queue: u16,
7189        mut size: u16,
7190        mut desc: u64,
7191        mut avail: u64,
7192        mut used: u64,
7193    ) -> Self::ConfigureQueueResponseFut {
7194        fn _decode(
7195            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7196        ) -> Result<(), fidl::Error> {
7197            let _response = fidl::client::decode_transaction_body::<
7198                fidl::encoding::EmptyPayload,
7199                fidl::encoding::DefaultFuchsiaResourceDialect,
7200                0x72b44fb963480b11,
7201            >(_buf?)?;
7202            Ok(_response)
7203        }
7204        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
7205            (queue, size, desc, avail, used),
7206            0x72b44fb963480b11,
7207            fidl::encoding::DynamicFlags::empty(),
7208            _decode,
7209        )
7210    }
7211
7212    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7213        self.client.send::<VirtioDeviceNotifyQueueRequest>(
7214            (queue,),
7215            0x6e3a61d652499244,
7216            fidl::encoding::DynamicFlags::empty(),
7217        )
7218    }
7219
7220    type ReadyResponseFut =
7221        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7222    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
7223        fn _decode(
7224            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7225        ) -> Result<(), fidl::Error> {
7226            let _response = fidl::client::decode_transaction_body::<
7227                fidl::encoding::EmptyPayload,
7228                fidl::encoding::DefaultFuchsiaResourceDialect,
7229                0x45707654f5d23c3f,
7230            >(_buf?)?;
7231            Ok(_response)
7232        }
7233        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
7234            (negotiated_features,),
7235            0x45707654f5d23c3f,
7236            fidl::encoding::DynamicFlags::empty(),
7237            _decode,
7238        )
7239    }
7240
7241    type StartResponseFut = fidl::client::QueryResponseFut<
7242        VirtioNetStartResult,
7243        fidl::encoding::DefaultFuchsiaResourceDialect,
7244    >;
7245    fn r#start(
7246        &self,
7247        mut start_info: StartInfo,
7248        mut mac_address: &fidl_fuchsia_net::MacAddress,
7249        mut enable_bridge: bool,
7250    ) -> Self::StartResponseFut {
7251        fn _decode(
7252            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7253        ) -> Result<VirtioNetStartResult, fidl::Error> {
7254            let _response = fidl::client::decode_transaction_body::<
7255                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
7256                fidl::encoding::DefaultFuchsiaResourceDialect,
7257                0x795c0b3a8461b3ed,
7258            >(_buf?)?;
7259            Ok(_response.map(|x| x))
7260        }
7261        self.client.send_query_and_decode::<VirtioNetStartRequest, VirtioNetStartResult>(
7262            (&mut start_info, mac_address, enable_bridge),
7263            0x795c0b3a8461b3ed,
7264            fidl::encoding::DynamicFlags::empty(),
7265            _decode,
7266        )
7267    }
7268}
7269
7270pub struct VirtioNetEventStream {
7271    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7272}
7273
7274impl std::marker::Unpin for VirtioNetEventStream {}
7275
7276impl futures::stream::FusedStream for VirtioNetEventStream {
7277    fn is_terminated(&self) -> bool {
7278        self.event_receiver.is_terminated()
7279    }
7280}
7281
7282impl futures::Stream for VirtioNetEventStream {
7283    type Item = Result<VirtioNetEvent, fidl::Error>;
7284
7285    fn poll_next(
7286        mut self: std::pin::Pin<&mut Self>,
7287        cx: &mut std::task::Context<'_>,
7288    ) -> std::task::Poll<Option<Self::Item>> {
7289        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7290            &mut self.event_receiver,
7291            cx
7292        )?) {
7293            Some(buf) => std::task::Poll::Ready(Some(VirtioNetEvent::decode(buf))),
7294            None => std::task::Poll::Ready(None),
7295        }
7296    }
7297}
7298
7299#[derive(Debug)]
7300pub enum VirtioNetEvent {}
7301
7302impl VirtioNetEvent {
7303    /// Decodes a message buffer as a [`VirtioNetEvent`].
7304    fn decode(
7305        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7306    ) -> Result<VirtioNetEvent, fidl::Error> {
7307        let (bytes, _handles) = buf.split_mut();
7308        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7309        debug_assert_eq!(tx_header.tx_id, 0);
7310        match tx_header.ordinal {
7311            _ => Err(fidl::Error::UnknownOrdinal {
7312                ordinal: tx_header.ordinal,
7313                protocol_name: <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7314            }),
7315        }
7316    }
7317}
7318
7319/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioNet.
7320pub struct VirtioNetRequestStream {
7321    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7322    is_terminated: bool,
7323}
7324
7325impl std::marker::Unpin for VirtioNetRequestStream {}
7326
7327impl futures::stream::FusedStream for VirtioNetRequestStream {
7328    fn is_terminated(&self) -> bool {
7329        self.is_terminated
7330    }
7331}
7332
7333impl fidl::endpoints::RequestStream for VirtioNetRequestStream {
7334    type Protocol = VirtioNetMarker;
7335    type ControlHandle = VirtioNetControlHandle;
7336
7337    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7338        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7339    }
7340
7341    fn control_handle(&self) -> Self::ControlHandle {
7342        VirtioNetControlHandle { inner: self.inner.clone() }
7343    }
7344
7345    fn into_inner(
7346        self,
7347    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7348    {
7349        (self.inner, self.is_terminated)
7350    }
7351
7352    fn from_inner(
7353        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7354        is_terminated: bool,
7355    ) -> Self {
7356        Self { inner, is_terminated }
7357    }
7358}
7359
7360impl futures::Stream for VirtioNetRequestStream {
7361    type Item = Result<VirtioNetRequest, fidl::Error>;
7362
7363    fn poll_next(
7364        mut self: std::pin::Pin<&mut Self>,
7365        cx: &mut std::task::Context<'_>,
7366    ) -> std::task::Poll<Option<Self::Item>> {
7367        let this = &mut *self;
7368        if this.inner.check_shutdown(cx) {
7369            this.is_terminated = true;
7370            return std::task::Poll::Ready(None);
7371        }
7372        if this.is_terminated {
7373            panic!("polled VirtioNetRequestStream after completion");
7374        }
7375        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7376            |bytes, handles| {
7377                match this.inner.channel().read_etc(cx, bytes, handles) {
7378                    std::task::Poll::Ready(Ok(())) => {}
7379                    std::task::Poll::Pending => return std::task::Poll::Pending,
7380                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7381                        this.is_terminated = true;
7382                        return std::task::Poll::Ready(None);
7383                    }
7384                    std::task::Poll::Ready(Err(e)) => {
7385                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7386                            e.into(),
7387                        ))))
7388                    }
7389                }
7390
7391                // A message has been received from the channel
7392                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7393
7394                std::task::Poll::Ready(Some(match header.ordinal {
7395                    0x72b44fb963480b11 => {
7396                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7397                        let mut req = fidl::new_empty!(
7398                            VirtioDeviceConfigureQueueRequest,
7399                            fidl::encoding::DefaultFuchsiaResourceDialect
7400                        );
7401                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
7402                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
7403                        Ok(VirtioNetRequest::ConfigureQueue {
7404                            queue: req.queue,
7405                            size: req.size,
7406                            desc: req.desc,
7407                            avail: req.avail,
7408                            used: req.used,
7409
7410                            responder: VirtioNetConfigureQueueResponder {
7411                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7412                                tx_id: header.tx_id,
7413                            },
7414                        })
7415                    }
7416                    0x6e3a61d652499244 => {
7417                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7418                        let mut req = fidl::new_empty!(
7419                            VirtioDeviceNotifyQueueRequest,
7420                            fidl::encoding::DefaultFuchsiaResourceDialect
7421                        );
7422                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
7423                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
7424                        Ok(VirtioNetRequest::NotifyQueue { queue: req.queue, control_handle })
7425                    }
7426                    0x45707654f5d23c3f => {
7427                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7428                        let mut req = fidl::new_empty!(
7429                            VirtioDeviceReadyRequest,
7430                            fidl::encoding::DefaultFuchsiaResourceDialect
7431                        );
7432                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
7433                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
7434                        Ok(VirtioNetRequest::Ready {
7435                            negotiated_features: req.negotiated_features,
7436
7437                            responder: VirtioNetReadyResponder {
7438                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7439                                tx_id: header.tx_id,
7440                            },
7441                        })
7442                    }
7443                    0x795c0b3a8461b3ed => {
7444                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7445                        let mut req = fidl::new_empty!(
7446                            VirtioNetStartRequest,
7447                            fidl::encoding::DefaultFuchsiaResourceDialect
7448                        );
7449                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioNetStartRequest>(&header, _body_bytes, handles, &mut req)?;
7450                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
7451                        Ok(VirtioNetRequest::Start {
7452                            start_info: req.start_info,
7453                            mac_address: req.mac_address,
7454                            enable_bridge: req.enable_bridge,
7455
7456                            responder: VirtioNetStartResponder {
7457                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7458                                tx_id: header.tx_id,
7459                            },
7460                        })
7461                    }
7462                    _ => Err(fidl::Error::UnknownOrdinal {
7463                        ordinal: header.ordinal,
7464                        protocol_name:
7465                            <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7466                    }),
7467                }))
7468            },
7469        )
7470    }
7471}
7472
7473#[derive(Debug)]
7474pub enum VirtioNetRequest {
7475    /// Configure a `queue` for the device. This specifies the `size` and the
7476    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7477    ConfigureQueue {
7478        queue: u16,
7479        size: u16,
7480        desc: u64,
7481        avail: u64,
7482        used: u64,
7483        responder: VirtioNetConfigureQueueResponder,
7484    },
7485    /// Notify a `queue` for the device. Primarily used for black-box testing.
7486    NotifyQueue { queue: u16, control_handle: VirtioNetControlHandle },
7487    /// Ready a device. This provides the set of `negotiated_features` that the
7488    /// driver and device have agreed upon.
7489    Ready { negotiated_features: u32, responder: VirtioNetReadyResponder },
7490    /// Start the net device.
7491    Start {
7492        start_info: StartInfo,
7493        mac_address: fidl_fuchsia_net::MacAddress,
7494        enable_bridge: bool,
7495        responder: VirtioNetStartResponder,
7496    },
7497}
7498
7499impl VirtioNetRequest {
7500    #[allow(irrefutable_let_patterns)]
7501    pub fn into_configure_queue(
7502        self,
7503    ) -> Option<(u16, u16, u64, u64, u64, VirtioNetConfigureQueueResponder)> {
7504        if let VirtioNetRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
7505        {
7506            Some((queue, size, desc, avail, used, responder))
7507        } else {
7508            None
7509        }
7510    }
7511
7512    #[allow(irrefutable_let_patterns)]
7513    pub fn into_notify_queue(self) -> Option<(u16, VirtioNetControlHandle)> {
7514        if let VirtioNetRequest::NotifyQueue { queue, control_handle } = self {
7515            Some((queue, control_handle))
7516        } else {
7517            None
7518        }
7519    }
7520
7521    #[allow(irrefutable_let_patterns)]
7522    pub fn into_ready(self) -> Option<(u32, VirtioNetReadyResponder)> {
7523        if let VirtioNetRequest::Ready { negotiated_features, responder } = self {
7524            Some((negotiated_features, responder))
7525        } else {
7526            None
7527        }
7528    }
7529
7530    #[allow(irrefutable_let_patterns)]
7531    pub fn into_start(
7532        self,
7533    ) -> Option<(StartInfo, fidl_fuchsia_net::MacAddress, bool, VirtioNetStartResponder)> {
7534        if let VirtioNetRequest::Start { start_info, mac_address, enable_bridge, responder } = self
7535        {
7536            Some((start_info, mac_address, enable_bridge, responder))
7537        } else {
7538            None
7539        }
7540    }
7541
7542    /// Name of the method defined in FIDL
7543    pub fn method_name(&self) -> &'static str {
7544        match *self {
7545            VirtioNetRequest::ConfigureQueue { .. } => "configure_queue",
7546            VirtioNetRequest::NotifyQueue { .. } => "notify_queue",
7547            VirtioNetRequest::Ready { .. } => "ready",
7548            VirtioNetRequest::Start { .. } => "start",
7549        }
7550    }
7551}
7552
7553#[derive(Debug, Clone)]
7554pub struct VirtioNetControlHandle {
7555    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7556}
7557
7558impl fidl::endpoints::ControlHandle for VirtioNetControlHandle {
7559    fn shutdown(&self) {
7560        self.inner.shutdown()
7561    }
7562    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7563        self.inner.shutdown_with_epitaph(status)
7564    }
7565
7566    fn is_closed(&self) -> bool {
7567        self.inner.channel().is_closed()
7568    }
7569    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7570        self.inner.channel().on_closed()
7571    }
7572
7573    #[cfg(target_os = "fuchsia")]
7574    fn signal_peer(
7575        &self,
7576        clear_mask: zx::Signals,
7577        set_mask: zx::Signals,
7578    ) -> Result<(), zx_status::Status> {
7579        use fidl::Peered;
7580        self.inner.channel().signal_peer(clear_mask, set_mask)
7581    }
7582}
7583
7584impl VirtioNetControlHandle {}
7585
7586#[must_use = "FIDL methods require a response to be sent"]
7587#[derive(Debug)]
7588pub struct VirtioNetConfigureQueueResponder {
7589    control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
7590    tx_id: u32,
7591}
7592
7593/// Set the the channel to be shutdown (see [`VirtioNetControlHandle::shutdown`])
7594/// if the responder is dropped without sending a response, so that the client
7595/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7596impl std::ops::Drop for VirtioNetConfigureQueueResponder {
7597    fn drop(&mut self) {
7598        self.control_handle.shutdown();
7599        // Safety: drops once, never accessed again
7600        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7601    }
7602}
7603
7604impl fidl::endpoints::Responder for VirtioNetConfigureQueueResponder {
7605    type ControlHandle = VirtioNetControlHandle;
7606
7607    fn control_handle(&self) -> &VirtioNetControlHandle {
7608        &self.control_handle
7609    }
7610
7611    fn drop_without_shutdown(mut self) {
7612        // Safety: drops once, never accessed again due to mem::forget
7613        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7614        // Prevent Drop from running (which would shut down the channel)
7615        std::mem::forget(self);
7616    }
7617}
7618
7619impl VirtioNetConfigureQueueResponder {
7620    /// Sends a response to the FIDL transaction.
7621    ///
7622    /// Sets the channel to shutdown if an error occurs.
7623    pub fn send(self) -> Result<(), fidl::Error> {
7624        let _result = self.send_raw();
7625        if _result.is_err() {
7626            self.control_handle.shutdown();
7627        }
7628        self.drop_without_shutdown();
7629        _result
7630    }
7631
7632    /// Similar to "send" but does not shutdown the channel if an error occurs.
7633    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7634        let _result = self.send_raw();
7635        self.drop_without_shutdown();
7636        _result
7637    }
7638
7639    fn send_raw(&self) -> Result<(), fidl::Error> {
7640        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7641            (),
7642            self.tx_id,
7643            0x72b44fb963480b11,
7644            fidl::encoding::DynamicFlags::empty(),
7645        )
7646    }
7647}
7648
7649#[must_use = "FIDL methods require a response to be sent"]
7650#[derive(Debug)]
7651pub struct VirtioNetReadyResponder {
7652    control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
7653    tx_id: u32,
7654}
7655
7656/// Set the the channel to be shutdown (see [`VirtioNetControlHandle::shutdown`])
7657/// if the responder is dropped without sending a response, so that the client
7658/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7659impl std::ops::Drop for VirtioNetReadyResponder {
7660    fn drop(&mut self) {
7661        self.control_handle.shutdown();
7662        // Safety: drops once, never accessed again
7663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7664    }
7665}
7666
7667impl fidl::endpoints::Responder for VirtioNetReadyResponder {
7668    type ControlHandle = VirtioNetControlHandle;
7669
7670    fn control_handle(&self) -> &VirtioNetControlHandle {
7671        &self.control_handle
7672    }
7673
7674    fn drop_without_shutdown(mut self) {
7675        // Safety: drops once, never accessed again due to mem::forget
7676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7677        // Prevent Drop from running (which would shut down the channel)
7678        std::mem::forget(self);
7679    }
7680}
7681
7682impl VirtioNetReadyResponder {
7683    /// Sends a response to the FIDL transaction.
7684    ///
7685    /// Sets the channel to shutdown if an error occurs.
7686    pub fn send(self) -> Result<(), fidl::Error> {
7687        let _result = self.send_raw();
7688        if _result.is_err() {
7689            self.control_handle.shutdown();
7690        }
7691        self.drop_without_shutdown();
7692        _result
7693    }
7694
7695    /// Similar to "send" but does not shutdown the channel if an error occurs.
7696    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7697        let _result = self.send_raw();
7698        self.drop_without_shutdown();
7699        _result
7700    }
7701
7702    fn send_raw(&self) -> Result<(), fidl::Error> {
7703        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7704            (),
7705            self.tx_id,
7706            0x45707654f5d23c3f,
7707            fidl::encoding::DynamicFlags::empty(),
7708        )
7709    }
7710}
7711
7712#[must_use = "FIDL methods require a response to be sent"]
7713#[derive(Debug)]
7714pub struct VirtioNetStartResponder {
7715    control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
7716    tx_id: u32,
7717}
7718
7719/// Set the the channel to be shutdown (see [`VirtioNetControlHandle::shutdown`])
7720/// if the responder is dropped without sending a response, so that the client
7721/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7722impl std::ops::Drop for VirtioNetStartResponder {
7723    fn drop(&mut self) {
7724        self.control_handle.shutdown();
7725        // Safety: drops once, never accessed again
7726        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7727    }
7728}
7729
7730impl fidl::endpoints::Responder for VirtioNetStartResponder {
7731    type ControlHandle = VirtioNetControlHandle;
7732
7733    fn control_handle(&self) -> &VirtioNetControlHandle {
7734        &self.control_handle
7735    }
7736
7737    fn drop_without_shutdown(mut self) {
7738        // Safety: drops once, never accessed again due to mem::forget
7739        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7740        // Prevent Drop from running (which would shut down the channel)
7741        std::mem::forget(self);
7742    }
7743}
7744
7745impl VirtioNetStartResponder {
7746    /// Sends a response to the FIDL transaction.
7747    ///
7748    /// Sets the channel to shutdown if an error occurs.
7749    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7750        let _result = self.send_raw(result);
7751        if _result.is_err() {
7752            self.control_handle.shutdown();
7753        }
7754        self.drop_without_shutdown();
7755        _result
7756    }
7757
7758    /// Similar to "send" but does not shutdown the channel if an error occurs.
7759    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7760        let _result = self.send_raw(result);
7761        self.drop_without_shutdown();
7762        _result
7763    }
7764
7765    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7766        self.control_handle
7767            .inner
7768            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
7769                result,
7770                self.tx_id,
7771                0x795c0b3a8461b3ed,
7772                fidl::encoding::DynamicFlags::empty(),
7773            )
7774    }
7775}
7776
7777#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7778pub struct VirtioRngMarker;
7779
7780impl fidl::endpoints::ProtocolMarker for VirtioRngMarker {
7781    type Proxy = VirtioRngProxy;
7782    type RequestStream = VirtioRngRequestStream;
7783    #[cfg(target_os = "fuchsia")]
7784    type SynchronousProxy = VirtioRngSynchronousProxy;
7785
7786    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioRng";
7787}
7788impl fidl::endpoints::DiscoverableProtocolMarker for VirtioRngMarker {}
7789
7790pub trait VirtioRngProxyInterface: Send + Sync {
7791    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7792    fn r#configure_queue(
7793        &self,
7794        queue: u16,
7795        size: u16,
7796        desc: u64,
7797        avail: u64,
7798        used: u64,
7799    ) -> Self::ConfigureQueueResponseFut;
7800    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
7801    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7802    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
7803    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7804    fn r#start(&self, start_info: StartInfo) -> Self::StartResponseFut;
7805}
7806#[derive(Debug)]
7807#[cfg(target_os = "fuchsia")]
7808pub struct VirtioRngSynchronousProxy {
7809    client: fidl::client::sync::Client,
7810}
7811
7812#[cfg(target_os = "fuchsia")]
7813impl fidl::endpoints::SynchronousProxy for VirtioRngSynchronousProxy {
7814    type Proxy = VirtioRngProxy;
7815    type Protocol = VirtioRngMarker;
7816
7817    fn from_channel(inner: fidl::Channel) -> Self {
7818        Self::new(inner)
7819    }
7820
7821    fn into_channel(self) -> fidl::Channel {
7822        self.client.into_channel()
7823    }
7824
7825    fn as_channel(&self) -> &fidl::Channel {
7826        self.client.as_channel()
7827    }
7828}
7829
7830#[cfg(target_os = "fuchsia")]
7831impl VirtioRngSynchronousProxy {
7832    pub fn new(channel: fidl::Channel) -> Self {
7833        let protocol_name = <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7834        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7835    }
7836
7837    pub fn into_channel(self) -> fidl::Channel {
7838        self.client.into_channel()
7839    }
7840
7841    /// Waits until an event arrives and returns it. It is safe for other
7842    /// threads to make concurrent requests while waiting for an event.
7843    pub fn wait_for_event(
7844        &self,
7845        deadline: zx::MonotonicInstant,
7846    ) -> Result<VirtioRngEvent, fidl::Error> {
7847        VirtioRngEvent::decode(self.client.wait_for_event(deadline)?)
7848    }
7849
7850    /// Configure a `queue` for the device. This specifies the `size` and the
7851    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7852    pub fn r#configure_queue(
7853        &self,
7854        mut queue: u16,
7855        mut size: u16,
7856        mut desc: u64,
7857        mut avail: u64,
7858        mut used: u64,
7859        ___deadline: zx::MonotonicInstant,
7860    ) -> Result<(), fidl::Error> {
7861        let _response = self
7862            .client
7863            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
7864                (queue, size, desc, avail, used),
7865                0x72b44fb963480b11,
7866                fidl::encoding::DynamicFlags::empty(),
7867                ___deadline,
7868            )?;
7869        Ok(_response)
7870    }
7871
7872    /// Notify a `queue` for the device. Primarily used for black-box testing.
7873    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7874        self.client.send::<VirtioDeviceNotifyQueueRequest>(
7875            (queue,),
7876            0x6e3a61d652499244,
7877            fidl::encoding::DynamicFlags::empty(),
7878        )
7879    }
7880
7881    /// Ready a device. This provides the set of `negotiated_features` that the
7882    /// driver and device have agreed upon.
7883    pub fn r#ready(
7884        &self,
7885        mut negotiated_features: u32,
7886        ___deadline: zx::MonotonicInstant,
7887    ) -> Result<(), fidl::Error> {
7888        let _response =
7889            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
7890                (negotiated_features,),
7891                0x45707654f5d23c3f,
7892                fidl::encoding::DynamicFlags::empty(),
7893                ___deadline,
7894            )?;
7895        Ok(_response)
7896    }
7897
7898    /// Start the RNG device.
7899    pub fn r#start(
7900        &self,
7901        mut start_info: StartInfo,
7902        ___deadline: zx::MonotonicInstant,
7903    ) -> Result<(), fidl::Error> {
7904        let _response =
7905            self.client.send_query::<VirtioRngStartRequest, fidl::encoding::EmptyPayload>(
7906                (&mut start_info,),
7907                0x620b3ed254febc0f,
7908                fidl::encoding::DynamicFlags::empty(),
7909                ___deadline,
7910            )?;
7911        Ok(_response)
7912    }
7913}
7914
7915#[cfg(target_os = "fuchsia")]
7916impl From<VirtioRngSynchronousProxy> for zx::Handle {
7917    fn from(value: VirtioRngSynchronousProxy) -> Self {
7918        value.into_channel().into()
7919    }
7920}
7921
7922#[cfg(target_os = "fuchsia")]
7923impl From<fidl::Channel> for VirtioRngSynchronousProxy {
7924    fn from(value: fidl::Channel) -> Self {
7925        Self::new(value)
7926    }
7927}
7928
7929#[cfg(target_os = "fuchsia")]
7930impl fidl::endpoints::FromClient for VirtioRngSynchronousProxy {
7931    type Protocol = VirtioRngMarker;
7932
7933    fn from_client(value: fidl::endpoints::ClientEnd<VirtioRngMarker>) -> Self {
7934        Self::new(value.into_channel())
7935    }
7936}
7937
7938#[derive(Debug, Clone)]
7939pub struct VirtioRngProxy {
7940    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7941}
7942
7943impl fidl::endpoints::Proxy for VirtioRngProxy {
7944    type Protocol = VirtioRngMarker;
7945
7946    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7947        Self::new(inner)
7948    }
7949
7950    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7951        self.client.into_channel().map_err(|client| Self { client })
7952    }
7953
7954    fn as_channel(&self) -> &::fidl::AsyncChannel {
7955        self.client.as_channel()
7956    }
7957}
7958
7959impl VirtioRngProxy {
7960    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioRng.
7961    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7962        let protocol_name = <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7963        Self { client: fidl::client::Client::new(channel, protocol_name) }
7964    }
7965
7966    /// Get a Stream of events from the remote end of the protocol.
7967    ///
7968    /// # Panics
7969    ///
7970    /// Panics if the event stream was already taken.
7971    pub fn take_event_stream(&self) -> VirtioRngEventStream {
7972        VirtioRngEventStream { event_receiver: self.client.take_event_receiver() }
7973    }
7974
7975    /// Configure a `queue` for the device. This specifies the `size` and the
7976    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7977    pub fn r#configure_queue(
7978        &self,
7979        mut queue: u16,
7980        mut size: u16,
7981        mut desc: u64,
7982        mut avail: u64,
7983        mut used: u64,
7984    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7985        VirtioRngProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
7986    }
7987
7988    /// Notify a `queue` for the device. Primarily used for black-box testing.
7989    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7990        VirtioRngProxyInterface::r#notify_queue(self, queue)
7991    }
7992
7993    /// Ready a device. This provides the set of `negotiated_features` that the
7994    /// driver and device have agreed upon.
7995    pub fn r#ready(
7996        &self,
7997        mut negotiated_features: u32,
7998    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7999        VirtioRngProxyInterface::r#ready(self, negotiated_features)
8000    }
8001
8002    /// Start the RNG device.
8003    pub fn r#start(
8004        &self,
8005        mut start_info: StartInfo,
8006    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8007        VirtioRngProxyInterface::r#start(self, start_info)
8008    }
8009}
8010
8011impl VirtioRngProxyInterface for VirtioRngProxy {
8012    type ConfigureQueueResponseFut =
8013        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8014    fn r#configure_queue(
8015        &self,
8016        mut queue: u16,
8017        mut size: u16,
8018        mut desc: u64,
8019        mut avail: u64,
8020        mut used: u64,
8021    ) -> Self::ConfigureQueueResponseFut {
8022        fn _decode(
8023            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8024        ) -> Result<(), fidl::Error> {
8025            let _response = fidl::client::decode_transaction_body::<
8026                fidl::encoding::EmptyPayload,
8027                fidl::encoding::DefaultFuchsiaResourceDialect,
8028                0x72b44fb963480b11,
8029            >(_buf?)?;
8030            Ok(_response)
8031        }
8032        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
8033            (queue, size, desc, avail, used),
8034            0x72b44fb963480b11,
8035            fidl::encoding::DynamicFlags::empty(),
8036            _decode,
8037        )
8038    }
8039
8040    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8041        self.client.send::<VirtioDeviceNotifyQueueRequest>(
8042            (queue,),
8043            0x6e3a61d652499244,
8044            fidl::encoding::DynamicFlags::empty(),
8045        )
8046    }
8047
8048    type ReadyResponseFut =
8049        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8050    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
8051        fn _decode(
8052            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8053        ) -> Result<(), fidl::Error> {
8054            let _response = fidl::client::decode_transaction_body::<
8055                fidl::encoding::EmptyPayload,
8056                fidl::encoding::DefaultFuchsiaResourceDialect,
8057                0x45707654f5d23c3f,
8058            >(_buf?)?;
8059            Ok(_response)
8060        }
8061        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
8062            (negotiated_features,),
8063            0x45707654f5d23c3f,
8064            fidl::encoding::DynamicFlags::empty(),
8065            _decode,
8066        )
8067    }
8068
8069    type StartResponseFut =
8070        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8071    fn r#start(&self, mut start_info: StartInfo) -> Self::StartResponseFut {
8072        fn _decode(
8073            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8074        ) -> Result<(), fidl::Error> {
8075            let _response = fidl::client::decode_transaction_body::<
8076                fidl::encoding::EmptyPayload,
8077                fidl::encoding::DefaultFuchsiaResourceDialect,
8078                0x620b3ed254febc0f,
8079            >(_buf?)?;
8080            Ok(_response)
8081        }
8082        self.client.send_query_and_decode::<VirtioRngStartRequest, ()>(
8083            (&mut start_info,),
8084            0x620b3ed254febc0f,
8085            fidl::encoding::DynamicFlags::empty(),
8086            _decode,
8087        )
8088    }
8089}
8090
8091pub struct VirtioRngEventStream {
8092    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8093}
8094
8095impl std::marker::Unpin for VirtioRngEventStream {}
8096
8097impl futures::stream::FusedStream for VirtioRngEventStream {
8098    fn is_terminated(&self) -> bool {
8099        self.event_receiver.is_terminated()
8100    }
8101}
8102
8103impl futures::Stream for VirtioRngEventStream {
8104    type Item = Result<VirtioRngEvent, fidl::Error>;
8105
8106    fn poll_next(
8107        mut self: std::pin::Pin<&mut Self>,
8108        cx: &mut std::task::Context<'_>,
8109    ) -> std::task::Poll<Option<Self::Item>> {
8110        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8111            &mut self.event_receiver,
8112            cx
8113        )?) {
8114            Some(buf) => std::task::Poll::Ready(Some(VirtioRngEvent::decode(buf))),
8115            None => std::task::Poll::Ready(None),
8116        }
8117    }
8118}
8119
8120#[derive(Debug)]
8121pub enum VirtioRngEvent {}
8122
8123impl VirtioRngEvent {
8124    /// Decodes a message buffer as a [`VirtioRngEvent`].
8125    fn decode(
8126        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8127    ) -> Result<VirtioRngEvent, fidl::Error> {
8128        let (bytes, _handles) = buf.split_mut();
8129        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8130        debug_assert_eq!(tx_header.tx_id, 0);
8131        match tx_header.ordinal {
8132            _ => Err(fidl::Error::UnknownOrdinal {
8133                ordinal: tx_header.ordinal,
8134                protocol_name: <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8135            }),
8136        }
8137    }
8138}
8139
8140/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioRng.
8141pub struct VirtioRngRequestStream {
8142    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8143    is_terminated: bool,
8144}
8145
8146impl std::marker::Unpin for VirtioRngRequestStream {}
8147
8148impl futures::stream::FusedStream for VirtioRngRequestStream {
8149    fn is_terminated(&self) -> bool {
8150        self.is_terminated
8151    }
8152}
8153
8154impl fidl::endpoints::RequestStream for VirtioRngRequestStream {
8155    type Protocol = VirtioRngMarker;
8156    type ControlHandle = VirtioRngControlHandle;
8157
8158    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8159        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8160    }
8161
8162    fn control_handle(&self) -> Self::ControlHandle {
8163        VirtioRngControlHandle { inner: self.inner.clone() }
8164    }
8165
8166    fn into_inner(
8167        self,
8168    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8169    {
8170        (self.inner, self.is_terminated)
8171    }
8172
8173    fn from_inner(
8174        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8175        is_terminated: bool,
8176    ) -> Self {
8177        Self { inner, is_terminated }
8178    }
8179}
8180
8181impl futures::Stream for VirtioRngRequestStream {
8182    type Item = Result<VirtioRngRequest, fidl::Error>;
8183
8184    fn poll_next(
8185        mut self: std::pin::Pin<&mut Self>,
8186        cx: &mut std::task::Context<'_>,
8187    ) -> std::task::Poll<Option<Self::Item>> {
8188        let this = &mut *self;
8189        if this.inner.check_shutdown(cx) {
8190            this.is_terminated = true;
8191            return std::task::Poll::Ready(None);
8192        }
8193        if this.is_terminated {
8194            panic!("polled VirtioRngRequestStream after completion");
8195        }
8196        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8197            |bytes, handles| {
8198                match this.inner.channel().read_etc(cx, bytes, handles) {
8199                    std::task::Poll::Ready(Ok(())) => {}
8200                    std::task::Poll::Pending => return std::task::Poll::Pending,
8201                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8202                        this.is_terminated = true;
8203                        return std::task::Poll::Ready(None);
8204                    }
8205                    std::task::Poll::Ready(Err(e)) => {
8206                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8207                            e.into(),
8208                        ))))
8209                    }
8210                }
8211
8212                // A message has been received from the channel
8213                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8214
8215                std::task::Poll::Ready(Some(match header.ordinal {
8216                    0x72b44fb963480b11 => {
8217                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8218                        let mut req = fidl::new_empty!(
8219                            VirtioDeviceConfigureQueueRequest,
8220                            fidl::encoding::DefaultFuchsiaResourceDialect
8221                        );
8222                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
8223                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
8224                        Ok(VirtioRngRequest::ConfigureQueue {
8225                            queue: req.queue,
8226                            size: req.size,
8227                            desc: req.desc,
8228                            avail: req.avail,
8229                            used: req.used,
8230
8231                            responder: VirtioRngConfigureQueueResponder {
8232                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8233                                tx_id: header.tx_id,
8234                            },
8235                        })
8236                    }
8237                    0x6e3a61d652499244 => {
8238                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8239                        let mut req = fidl::new_empty!(
8240                            VirtioDeviceNotifyQueueRequest,
8241                            fidl::encoding::DefaultFuchsiaResourceDialect
8242                        );
8243                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
8244                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
8245                        Ok(VirtioRngRequest::NotifyQueue { queue: req.queue, control_handle })
8246                    }
8247                    0x45707654f5d23c3f => {
8248                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8249                        let mut req = fidl::new_empty!(
8250                            VirtioDeviceReadyRequest,
8251                            fidl::encoding::DefaultFuchsiaResourceDialect
8252                        );
8253                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
8254                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
8255                        Ok(VirtioRngRequest::Ready {
8256                            negotiated_features: req.negotiated_features,
8257
8258                            responder: VirtioRngReadyResponder {
8259                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8260                                tx_id: header.tx_id,
8261                            },
8262                        })
8263                    }
8264                    0x620b3ed254febc0f => {
8265                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8266                        let mut req = fidl::new_empty!(
8267                            VirtioRngStartRequest,
8268                            fidl::encoding::DefaultFuchsiaResourceDialect
8269                        );
8270                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioRngStartRequest>(&header, _body_bytes, handles, &mut req)?;
8271                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
8272                        Ok(VirtioRngRequest::Start {
8273                            start_info: req.start_info,
8274
8275                            responder: VirtioRngStartResponder {
8276                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8277                                tx_id: header.tx_id,
8278                            },
8279                        })
8280                    }
8281                    _ => Err(fidl::Error::UnknownOrdinal {
8282                        ordinal: header.ordinal,
8283                        protocol_name:
8284                            <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8285                    }),
8286                }))
8287            },
8288        )
8289    }
8290}
8291
8292#[derive(Debug)]
8293pub enum VirtioRngRequest {
8294    /// Configure a `queue` for the device. This specifies the `size` and the
8295    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
8296    ConfigureQueue {
8297        queue: u16,
8298        size: u16,
8299        desc: u64,
8300        avail: u64,
8301        used: u64,
8302        responder: VirtioRngConfigureQueueResponder,
8303    },
8304    /// Notify a `queue` for the device. Primarily used for black-box testing.
8305    NotifyQueue { queue: u16, control_handle: VirtioRngControlHandle },
8306    /// Ready a device. This provides the set of `negotiated_features` that the
8307    /// driver and device have agreed upon.
8308    Ready { negotiated_features: u32, responder: VirtioRngReadyResponder },
8309    /// Start the RNG device.
8310    Start { start_info: StartInfo, responder: VirtioRngStartResponder },
8311}
8312
8313impl VirtioRngRequest {
8314    #[allow(irrefutable_let_patterns)]
8315    pub fn into_configure_queue(
8316        self,
8317    ) -> Option<(u16, u16, u64, u64, u64, VirtioRngConfigureQueueResponder)> {
8318        if let VirtioRngRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
8319        {
8320            Some((queue, size, desc, avail, used, responder))
8321        } else {
8322            None
8323        }
8324    }
8325
8326    #[allow(irrefutable_let_patterns)]
8327    pub fn into_notify_queue(self) -> Option<(u16, VirtioRngControlHandle)> {
8328        if let VirtioRngRequest::NotifyQueue { queue, control_handle } = self {
8329            Some((queue, control_handle))
8330        } else {
8331            None
8332        }
8333    }
8334
8335    #[allow(irrefutable_let_patterns)]
8336    pub fn into_ready(self) -> Option<(u32, VirtioRngReadyResponder)> {
8337        if let VirtioRngRequest::Ready { negotiated_features, responder } = self {
8338            Some((negotiated_features, responder))
8339        } else {
8340            None
8341        }
8342    }
8343
8344    #[allow(irrefutable_let_patterns)]
8345    pub fn into_start(self) -> Option<(StartInfo, VirtioRngStartResponder)> {
8346        if let VirtioRngRequest::Start { start_info, responder } = self {
8347            Some((start_info, responder))
8348        } else {
8349            None
8350        }
8351    }
8352
8353    /// Name of the method defined in FIDL
8354    pub fn method_name(&self) -> &'static str {
8355        match *self {
8356            VirtioRngRequest::ConfigureQueue { .. } => "configure_queue",
8357            VirtioRngRequest::NotifyQueue { .. } => "notify_queue",
8358            VirtioRngRequest::Ready { .. } => "ready",
8359            VirtioRngRequest::Start { .. } => "start",
8360        }
8361    }
8362}
8363
8364#[derive(Debug, Clone)]
8365pub struct VirtioRngControlHandle {
8366    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8367}
8368
8369impl fidl::endpoints::ControlHandle for VirtioRngControlHandle {
8370    fn shutdown(&self) {
8371        self.inner.shutdown()
8372    }
8373    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8374        self.inner.shutdown_with_epitaph(status)
8375    }
8376
8377    fn is_closed(&self) -> bool {
8378        self.inner.channel().is_closed()
8379    }
8380    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8381        self.inner.channel().on_closed()
8382    }
8383
8384    #[cfg(target_os = "fuchsia")]
8385    fn signal_peer(
8386        &self,
8387        clear_mask: zx::Signals,
8388        set_mask: zx::Signals,
8389    ) -> Result<(), zx_status::Status> {
8390        use fidl::Peered;
8391        self.inner.channel().signal_peer(clear_mask, set_mask)
8392    }
8393}
8394
8395impl VirtioRngControlHandle {}
8396
8397#[must_use = "FIDL methods require a response to be sent"]
8398#[derive(Debug)]
8399pub struct VirtioRngConfigureQueueResponder {
8400    control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
8401    tx_id: u32,
8402}
8403
8404/// Set the the channel to be shutdown (see [`VirtioRngControlHandle::shutdown`])
8405/// if the responder is dropped without sending a response, so that the client
8406/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8407impl std::ops::Drop for VirtioRngConfigureQueueResponder {
8408    fn drop(&mut self) {
8409        self.control_handle.shutdown();
8410        // Safety: drops once, never accessed again
8411        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8412    }
8413}
8414
8415impl fidl::endpoints::Responder for VirtioRngConfigureQueueResponder {
8416    type ControlHandle = VirtioRngControlHandle;
8417
8418    fn control_handle(&self) -> &VirtioRngControlHandle {
8419        &self.control_handle
8420    }
8421
8422    fn drop_without_shutdown(mut self) {
8423        // Safety: drops once, never accessed again due to mem::forget
8424        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8425        // Prevent Drop from running (which would shut down the channel)
8426        std::mem::forget(self);
8427    }
8428}
8429
8430impl VirtioRngConfigureQueueResponder {
8431    /// Sends a response to the FIDL transaction.
8432    ///
8433    /// Sets the channel to shutdown if an error occurs.
8434    pub fn send(self) -> Result<(), fidl::Error> {
8435        let _result = self.send_raw();
8436        if _result.is_err() {
8437            self.control_handle.shutdown();
8438        }
8439        self.drop_without_shutdown();
8440        _result
8441    }
8442
8443    /// Similar to "send" but does not shutdown the channel if an error occurs.
8444    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8445        let _result = self.send_raw();
8446        self.drop_without_shutdown();
8447        _result
8448    }
8449
8450    fn send_raw(&self) -> Result<(), fidl::Error> {
8451        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8452            (),
8453            self.tx_id,
8454            0x72b44fb963480b11,
8455            fidl::encoding::DynamicFlags::empty(),
8456        )
8457    }
8458}
8459
8460#[must_use = "FIDL methods require a response to be sent"]
8461#[derive(Debug)]
8462pub struct VirtioRngReadyResponder {
8463    control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
8464    tx_id: u32,
8465}
8466
8467/// Set the the channel to be shutdown (see [`VirtioRngControlHandle::shutdown`])
8468/// if the responder is dropped without sending a response, so that the client
8469/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8470impl std::ops::Drop for VirtioRngReadyResponder {
8471    fn drop(&mut self) {
8472        self.control_handle.shutdown();
8473        // Safety: drops once, never accessed again
8474        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8475    }
8476}
8477
8478impl fidl::endpoints::Responder for VirtioRngReadyResponder {
8479    type ControlHandle = VirtioRngControlHandle;
8480
8481    fn control_handle(&self) -> &VirtioRngControlHandle {
8482        &self.control_handle
8483    }
8484
8485    fn drop_without_shutdown(mut self) {
8486        // Safety: drops once, never accessed again due to mem::forget
8487        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8488        // Prevent Drop from running (which would shut down the channel)
8489        std::mem::forget(self);
8490    }
8491}
8492
8493impl VirtioRngReadyResponder {
8494    /// Sends a response to the FIDL transaction.
8495    ///
8496    /// Sets the channel to shutdown if an error occurs.
8497    pub fn send(self) -> Result<(), fidl::Error> {
8498        let _result = self.send_raw();
8499        if _result.is_err() {
8500            self.control_handle.shutdown();
8501        }
8502        self.drop_without_shutdown();
8503        _result
8504    }
8505
8506    /// Similar to "send" but does not shutdown the channel if an error occurs.
8507    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8508        let _result = self.send_raw();
8509        self.drop_without_shutdown();
8510        _result
8511    }
8512
8513    fn send_raw(&self) -> Result<(), fidl::Error> {
8514        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8515            (),
8516            self.tx_id,
8517            0x45707654f5d23c3f,
8518            fidl::encoding::DynamicFlags::empty(),
8519        )
8520    }
8521}
8522
8523#[must_use = "FIDL methods require a response to be sent"]
8524#[derive(Debug)]
8525pub struct VirtioRngStartResponder {
8526    control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
8527    tx_id: u32,
8528}
8529
8530/// Set the the channel to be shutdown (see [`VirtioRngControlHandle::shutdown`])
8531/// if the responder is dropped without sending a response, so that the client
8532/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8533impl std::ops::Drop for VirtioRngStartResponder {
8534    fn drop(&mut self) {
8535        self.control_handle.shutdown();
8536        // Safety: drops once, never accessed again
8537        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8538    }
8539}
8540
8541impl fidl::endpoints::Responder for VirtioRngStartResponder {
8542    type ControlHandle = VirtioRngControlHandle;
8543
8544    fn control_handle(&self) -> &VirtioRngControlHandle {
8545        &self.control_handle
8546    }
8547
8548    fn drop_without_shutdown(mut self) {
8549        // Safety: drops once, never accessed again due to mem::forget
8550        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8551        // Prevent Drop from running (which would shut down the channel)
8552        std::mem::forget(self);
8553    }
8554}
8555
8556impl VirtioRngStartResponder {
8557    /// Sends a response to the FIDL transaction.
8558    ///
8559    /// Sets the channel to shutdown if an error occurs.
8560    pub fn send(self) -> Result<(), fidl::Error> {
8561        let _result = self.send_raw();
8562        if _result.is_err() {
8563            self.control_handle.shutdown();
8564        }
8565        self.drop_without_shutdown();
8566        _result
8567    }
8568
8569    /// Similar to "send" but does not shutdown the channel if an error occurs.
8570    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8571        let _result = self.send_raw();
8572        self.drop_without_shutdown();
8573        _result
8574    }
8575
8576    fn send_raw(&self) -> Result<(), fidl::Error> {
8577        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8578            (),
8579            self.tx_id,
8580            0x620b3ed254febc0f,
8581            fidl::encoding::DynamicFlags::empty(),
8582        )
8583    }
8584}
8585
8586#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8587pub struct VirtioSoundMarker;
8588
8589impl fidl::endpoints::ProtocolMarker for VirtioSoundMarker {
8590    type Proxy = VirtioSoundProxy;
8591    type RequestStream = VirtioSoundRequestStream;
8592    #[cfg(target_os = "fuchsia")]
8593    type SynchronousProxy = VirtioSoundSynchronousProxy;
8594
8595    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioSound";
8596}
8597impl fidl::endpoints::DiscoverableProtocolMarker for VirtioSoundMarker {}
8598
8599pub trait VirtioSoundProxyInterface: Send + Sync {
8600    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8601    fn r#configure_queue(
8602        &self,
8603        queue: u16,
8604        size: u16,
8605        desc: u64,
8606        avail: u64,
8607        used: u64,
8608    ) -> Self::ConfigureQueueResponseFut;
8609    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
8610    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8611    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
8612    type StartResponseFut: std::future::Future<Output = Result<(u32, u32, u32, u32), fidl::Error>>
8613        + Send;
8614    fn r#start(
8615        &self,
8616        start_info: StartInfo,
8617        enable_input: bool,
8618        enable_verbose_logging: bool,
8619    ) -> Self::StartResponseFut;
8620}
8621#[derive(Debug)]
8622#[cfg(target_os = "fuchsia")]
8623pub struct VirtioSoundSynchronousProxy {
8624    client: fidl::client::sync::Client,
8625}
8626
8627#[cfg(target_os = "fuchsia")]
8628impl fidl::endpoints::SynchronousProxy for VirtioSoundSynchronousProxy {
8629    type Proxy = VirtioSoundProxy;
8630    type Protocol = VirtioSoundMarker;
8631
8632    fn from_channel(inner: fidl::Channel) -> Self {
8633        Self::new(inner)
8634    }
8635
8636    fn into_channel(self) -> fidl::Channel {
8637        self.client.into_channel()
8638    }
8639
8640    fn as_channel(&self) -> &fidl::Channel {
8641        self.client.as_channel()
8642    }
8643}
8644
8645#[cfg(target_os = "fuchsia")]
8646impl VirtioSoundSynchronousProxy {
8647    pub fn new(channel: fidl::Channel) -> Self {
8648        let protocol_name = <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8649        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8650    }
8651
8652    pub fn into_channel(self) -> fidl::Channel {
8653        self.client.into_channel()
8654    }
8655
8656    /// Waits until an event arrives and returns it. It is safe for other
8657    /// threads to make concurrent requests while waiting for an event.
8658    pub fn wait_for_event(
8659        &self,
8660        deadline: zx::MonotonicInstant,
8661    ) -> Result<VirtioSoundEvent, fidl::Error> {
8662        VirtioSoundEvent::decode(self.client.wait_for_event(deadline)?)
8663    }
8664
8665    /// Configure a `queue` for the device. This specifies the `size` and the
8666    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
8667    pub fn r#configure_queue(
8668        &self,
8669        mut queue: u16,
8670        mut size: u16,
8671        mut desc: u64,
8672        mut avail: u64,
8673        mut used: u64,
8674        ___deadline: zx::MonotonicInstant,
8675    ) -> Result<(), fidl::Error> {
8676        let _response = self
8677            .client
8678            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
8679                (queue, size, desc, avail, used),
8680                0x72b44fb963480b11,
8681                fidl::encoding::DynamicFlags::empty(),
8682                ___deadline,
8683            )?;
8684        Ok(_response)
8685    }
8686
8687    /// Notify a `queue` for the device. Primarily used for black-box testing.
8688    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8689        self.client.send::<VirtioDeviceNotifyQueueRequest>(
8690            (queue,),
8691            0x6e3a61d652499244,
8692            fidl::encoding::DynamicFlags::empty(),
8693        )
8694    }
8695
8696    /// Ready a device. This provides the set of `negotiated_features` that the
8697    /// driver and device have agreed upon.
8698    pub fn r#ready(
8699        &self,
8700        mut negotiated_features: u32,
8701        ___deadline: zx::MonotonicInstant,
8702    ) -> Result<(), fidl::Error> {
8703        let _response =
8704            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
8705                (negotiated_features,),
8706                0x45707654f5d23c3f,
8707                fidl::encoding::DynamicFlags::empty(),
8708                ___deadline,
8709            )?;
8710        Ok(_response)
8711    }
8712
8713    /// Start the sound device.
8714    /// The response contains the device's expected static configuration.
8715    ///
8716    /// + request `start_info` basic info to start the device
8717    /// + request `enable_input` whether audio input (capture) should be enabled
8718    /// + request `enable_verbose_logging` whether verbose logging should be enabled
8719    /// - response `features` supported features
8720    /// - response `jacks` the virtio_snd_config.jacks value to advertise
8721    /// - response `streams` the virtio_snd_config.streams value to advertise
8722    /// - response `chmaps` the virtio_snd_config.chaps value to advertise
8723    pub fn r#start(
8724        &self,
8725        mut start_info: StartInfo,
8726        mut enable_input: bool,
8727        mut enable_verbose_logging: bool,
8728        ___deadline: zx::MonotonicInstant,
8729    ) -> Result<(u32, u32, u32, u32), fidl::Error> {
8730        let _response =
8731            self.client.send_query::<VirtioSoundStartRequest, VirtioSoundStartResponse>(
8732                (&mut start_info, enable_input, enable_verbose_logging),
8733                0x2c3a5528c0b92e2d,
8734                fidl::encoding::DynamicFlags::empty(),
8735                ___deadline,
8736            )?;
8737        Ok((_response.features, _response.jacks, _response.streams, _response.chmaps))
8738    }
8739}
8740
8741#[cfg(target_os = "fuchsia")]
8742impl From<VirtioSoundSynchronousProxy> for zx::Handle {
8743    fn from(value: VirtioSoundSynchronousProxy) -> Self {
8744        value.into_channel().into()
8745    }
8746}
8747
8748#[cfg(target_os = "fuchsia")]
8749impl From<fidl::Channel> for VirtioSoundSynchronousProxy {
8750    fn from(value: fidl::Channel) -> Self {
8751        Self::new(value)
8752    }
8753}
8754
8755#[cfg(target_os = "fuchsia")]
8756impl fidl::endpoints::FromClient for VirtioSoundSynchronousProxy {
8757    type Protocol = VirtioSoundMarker;
8758
8759    fn from_client(value: fidl::endpoints::ClientEnd<VirtioSoundMarker>) -> Self {
8760        Self::new(value.into_channel())
8761    }
8762}
8763
8764#[derive(Debug, Clone)]
8765pub struct VirtioSoundProxy {
8766    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8767}
8768
8769impl fidl::endpoints::Proxy for VirtioSoundProxy {
8770    type Protocol = VirtioSoundMarker;
8771
8772    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8773        Self::new(inner)
8774    }
8775
8776    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8777        self.client.into_channel().map_err(|client| Self { client })
8778    }
8779
8780    fn as_channel(&self) -> &::fidl::AsyncChannel {
8781        self.client.as_channel()
8782    }
8783}
8784
8785impl VirtioSoundProxy {
8786    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioSound.
8787    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8788        let protocol_name = <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8789        Self { client: fidl::client::Client::new(channel, protocol_name) }
8790    }
8791
8792    /// Get a Stream of events from the remote end of the protocol.
8793    ///
8794    /// # Panics
8795    ///
8796    /// Panics if the event stream was already taken.
8797    pub fn take_event_stream(&self) -> VirtioSoundEventStream {
8798        VirtioSoundEventStream { event_receiver: self.client.take_event_receiver() }
8799    }
8800
8801    /// Configure a `queue` for the device. This specifies the `size` and the
8802    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
8803    pub fn r#configure_queue(
8804        &self,
8805        mut queue: u16,
8806        mut size: u16,
8807        mut desc: u64,
8808        mut avail: u64,
8809        mut used: u64,
8810    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8811        VirtioSoundProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
8812    }
8813
8814    /// Notify a `queue` for the device. Primarily used for black-box testing.
8815    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8816        VirtioSoundProxyInterface::r#notify_queue(self, queue)
8817    }
8818
8819    /// Ready a device. This provides the set of `negotiated_features` that the
8820    /// driver and device have agreed upon.
8821    pub fn r#ready(
8822        &self,
8823        mut negotiated_features: u32,
8824    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8825        VirtioSoundProxyInterface::r#ready(self, negotiated_features)
8826    }
8827
8828    /// Start the sound device.
8829    /// The response contains the device's expected static configuration.
8830    ///
8831    /// + request `start_info` basic info to start the device
8832    /// + request `enable_input` whether audio input (capture) should be enabled
8833    /// + request `enable_verbose_logging` whether verbose logging should be enabled
8834    /// - response `features` supported features
8835    /// - response `jacks` the virtio_snd_config.jacks value to advertise
8836    /// - response `streams` the virtio_snd_config.streams value to advertise
8837    /// - response `chmaps` the virtio_snd_config.chaps value to advertise
8838    pub fn r#start(
8839        &self,
8840        mut start_info: StartInfo,
8841        mut enable_input: bool,
8842        mut enable_verbose_logging: bool,
8843    ) -> fidl::client::QueryResponseFut<
8844        (u32, u32, u32, u32),
8845        fidl::encoding::DefaultFuchsiaResourceDialect,
8846    > {
8847        VirtioSoundProxyInterface::r#start(self, start_info, enable_input, enable_verbose_logging)
8848    }
8849}
8850
8851impl VirtioSoundProxyInterface for VirtioSoundProxy {
8852    type ConfigureQueueResponseFut =
8853        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8854    fn r#configure_queue(
8855        &self,
8856        mut queue: u16,
8857        mut size: u16,
8858        mut desc: u64,
8859        mut avail: u64,
8860        mut used: u64,
8861    ) -> Self::ConfigureQueueResponseFut {
8862        fn _decode(
8863            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8864        ) -> Result<(), fidl::Error> {
8865            let _response = fidl::client::decode_transaction_body::<
8866                fidl::encoding::EmptyPayload,
8867                fidl::encoding::DefaultFuchsiaResourceDialect,
8868                0x72b44fb963480b11,
8869            >(_buf?)?;
8870            Ok(_response)
8871        }
8872        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
8873            (queue, size, desc, avail, used),
8874            0x72b44fb963480b11,
8875            fidl::encoding::DynamicFlags::empty(),
8876            _decode,
8877        )
8878    }
8879
8880    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8881        self.client.send::<VirtioDeviceNotifyQueueRequest>(
8882            (queue,),
8883            0x6e3a61d652499244,
8884            fidl::encoding::DynamicFlags::empty(),
8885        )
8886    }
8887
8888    type ReadyResponseFut =
8889        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8890    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
8891        fn _decode(
8892            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8893        ) -> Result<(), fidl::Error> {
8894            let _response = fidl::client::decode_transaction_body::<
8895                fidl::encoding::EmptyPayload,
8896                fidl::encoding::DefaultFuchsiaResourceDialect,
8897                0x45707654f5d23c3f,
8898            >(_buf?)?;
8899            Ok(_response)
8900        }
8901        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
8902            (negotiated_features,),
8903            0x45707654f5d23c3f,
8904            fidl::encoding::DynamicFlags::empty(),
8905            _decode,
8906        )
8907    }
8908
8909    type StartResponseFut = fidl::client::QueryResponseFut<
8910        (u32, u32, u32, u32),
8911        fidl::encoding::DefaultFuchsiaResourceDialect,
8912    >;
8913    fn r#start(
8914        &self,
8915        mut start_info: StartInfo,
8916        mut enable_input: bool,
8917        mut enable_verbose_logging: bool,
8918    ) -> Self::StartResponseFut {
8919        fn _decode(
8920            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8921        ) -> Result<(u32, u32, u32, u32), fidl::Error> {
8922            let _response = fidl::client::decode_transaction_body::<
8923                VirtioSoundStartResponse,
8924                fidl::encoding::DefaultFuchsiaResourceDialect,
8925                0x2c3a5528c0b92e2d,
8926            >(_buf?)?;
8927            Ok((_response.features, _response.jacks, _response.streams, _response.chmaps))
8928        }
8929        self.client.send_query_and_decode::<VirtioSoundStartRequest, (u32, u32, u32, u32)>(
8930            (&mut start_info, enable_input, enable_verbose_logging),
8931            0x2c3a5528c0b92e2d,
8932            fidl::encoding::DynamicFlags::empty(),
8933            _decode,
8934        )
8935    }
8936}
8937
8938pub struct VirtioSoundEventStream {
8939    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8940}
8941
8942impl std::marker::Unpin for VirtioSoundEventStream {}
8943
8944impl futures::stream::FusedStream for VirtioSoundEventStream {
8945    fn is_terminated(&self) -> bool {
8946        self.event_receiver.is_terminated()
8947    }
8948}
8949
8950impl futures::Stream for VirtioSoundEventStream {
8951    type Item = Result<VirtioSoundEvent, fidl::Error>;
8952
8953    fn poll_next(
8954        mut self: std::pin::Pin<&mut Self>,
8955        cx: &mut std::task::Context<'_>,
8956    ) -> std::task::Poll<Option<Self::Item>> {
8957        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8958            &mut self.event_receiver,
8959            cx
8960        )?) {
8961            Some(buf) => std::task::Poll::Ready(Some(VirtioSoundEvent::decode(buf))),
8962            None => std::task::Poll::Ready(None),
8963        }
8964    }
8965}
8966
8967#[derive(Debug)]
8968pub enum VirtioSoundEvent {}
8969
8970impl VirtioSoundEvent {
8971    /// Decodes a message buffer as a [`VirtioSoundEvent`].
8972    fn decode(
8973        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8974    ) -> Result<VirtioSoundEvent, fidl::Error> {
8975        let (bytes, _handles) = buf.split_mut();
8976        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8977        debug_assert_eq!(tx_header.tx_id, 0);
8978        match tx_header.ordinal {
8979            _ => Err(fidl::Error::UnknownOrdinal {
8980                ordinal: tx_header.ordinal,
8981                protocol_name: <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8982            }),
8983        }
8984    }
8985}
8986
8987/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioSound.
8988pub struct VirtioSoundRequestStream {
8989    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8990    is_terminated: bool,
8991}
8992
8993impl std::marker::Unpin for VirtioSoundRequestStream {}
8994
8995impl futures::stream::FusedStream for VirtioSoundRequestStream {
8996    fn is_terminated(&self) -> bool {
8997        self.is_terminated
8998    }
8999}
9000
9001impl fidl::endpoints::RequestStream for VirtioSoundRequestStream {
9002    type Protocol = VirtioSoundMarker;
9003    type ControlHandle = VirtioSoundControlHandle;
9004
9005    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9006        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9007    }
9008
9009    fn control_handle(&self) -> Self::ControlHandle {
9010        VirtioSoundControlHandle { inner: self.inner.clone() }
9011    }
9012
9013    fn into_inner(
9014        self,
9015    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9016    {
9017        (self.inner, self.is_terminated)
9018    }
9019
9020    fn from_inner(
9021        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9022        is_terminated: bool,
9023    ) -> Self {
9024        Self { inner, is_terminated }
9025    }
9026}
9027
9028impl futures::Stream for VirtioSoundRequestStream {
9029    type Item = Result<VirtioSoundRequest, fidl::Error>;
9030
9031    fn poll_next(
9032        mut self: std::pin::Pin<&mut Self>,
9033        cx: &mut std::task::Context<'_>,
9034    ) -> std::task::Poll<Option<Self::Item>> {
9035        let this = &mut *self;
9036        if this.inner.check_shutdown(cx) {
9037            this.is_terminated = true;
9038            return std::task::Poll::Ready(None);
9039        }
9040        if this.is_terminated {
9041            panic!("polled VirtioSoundRequestStream after completion");
9042        }
9043        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9044            |bytes, handles| {
9045                match this.inner.channel().read_etc(cx, bytes, handles) {
9046                    std::task::Poll::Ready(Ok(())) => {}
9047                    std::task::Poll::Pending => return std::task::Poll::Pending,
9048                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9049                        this.is_terminated = true;
9050                        return std::task::Poll::Ready(None);
9051                    }
9052                    std::task::Poll::Ready(Err(e)) => {
9053                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9054                            e.into(),
9055                        ))))
9056                    }
9057                }
9058
9059                // A message has been received from the channel
9060                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9061
9062                std::task::Poll::Ready(Some(match header.ordinal {
9063                    0x72b44fb963480b11 => {
9064                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9065                        let mut req = fidl::new_empty!(
9066                            VirtioDeviceConfigureQueueRequest,
9067                            fidl::encoding::DefaultFuchsiaResourceDialect
9068                        );
9069                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
9070                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
9071                        Ok(VirtioSoundRequest::ConfigureQueue {
9072                            queue: req.queue,
9073                            size: req.size,
9074                            desc: req.desc,
9075                            avail: req.avail,
9076                            used: req.used,
9077
9078                            responder: VirtioSoundConfigureQueueResponder {
9079                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9080                                tx_id: header.tx_id,
9081                            },
9082                        })
9083                    }
9084                    0x6e3a61d652499244 => {
9085                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9086                        let mut req = fidl::new_empty!(
9087                            VirtioDeviceNotifyQueueRequest,
9088                            fidl::encoding::DefaultFuchsiaResourceDialect
9089                        );
9090                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
9091                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
9092                        Ok(VirtioSoundRequest::NotifyQueue { queue: req.queue, control_handle })
9093                    }
9094                    0x45707654f5d23c3f => {
9095                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9096                        let mut req = fidl::new_empty!(
9097                            VirtioDeviceReadyRequest,
9098                            fidl::encoding::DefaultFuchsiaResourceDialect
9099                        );
9100                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
9101                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
9102                        Ok(VirtioSoundRequest::Ready {
9103                            negotiated_features: req.negotiated_features,
9104
9105                            responder: VirtioSoundReadyResponder {
9106                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9107                                tx_id: header.tx_id,
9108                            },
9109                        })
9110                    }
9111                    0x2c3a5528c0b92e2d => {
9112                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9113                        let mut req = fidl::new_empty!(
9114                            VirtioSoundStartRequest,
9115                            fidl::encoding::DefaultFuchsiaResourceDialect
9116                        );
9117                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioSoundStartRequest>(&header, _body_bytes, handles, &mut req)?;
9118                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
9119                        Ok(VirtioSoundRequest::Start {
9120                            start_info: req.start_info,
9121                            enable_input: req.enable_input,
9122                            enable_verbose_logging: req.enable_verbose_logging,
9123
9124                            responder: VirtioSoundStartResponder {
9125                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9126                                tx_id: header.tx_id,
9127                            },
9128                        })
9129                    }
9130                    _ => Err(fidl::Error::UnknownOrdinal {
9131                        ordinal: header.ordinal,
9132                        protocol_name:
9133                            <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9134                    }),
9135                }))
9136            },
9137        )
9138    }
9139}
9140
9141#[derive(Debug)]
9142pub enum VirtioSoundRequest {
9143    /// Configure a `queue` for the device. This specifies the `size` and the
9144    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
9145    ConfigureQueue {
9146        queue: u16,
9147        size: u16,
9148        desc: u64,
9149        avail: u64,
9150        used: u64,
9151        responder: VirtioSoundConfigureQueueResponder,
9152    },
9153    /// Notify a `queue` for the device. Primarily used for black-box testing.
9154    NotifyQueue { queue: u16, control_handle: VirtioSoundControlHandle },
9155    /// Ready a device. This provides the set of `negotiated_features` that the
9156    /// driver and device have agreed upon.
9157    Ready { negotiated_features: u32, responder: VirtioSoundReadyResponder },
9158    /// Start the sound device.
9159    /// The response contains the device's expected static configuration.
9160    ///
9161    /// + request `start_info` basic info to start the device
9162    /// + request `enable_input` whether audio input (capture) should be enabled
9163    /// + request `enable_verbose_logging` whether verbose logging should be enabled
9164    /// - response `features` supported features
9165    /// - response `jacks` the virtio_snd_config.jacks value to advertise
9166    /// - response `streams` the virtio_snd_config.streams value to advertise
9167    /// - response `chmaps` the virtio_snd_config.chaps value to advertise
9168    Start {
9169        start_info: StartInfo,
9170        enable_input: bool,
9171        enable_verbose_logging: bool,
9172        responder: VirtioSoundStartResponder,
9173    },
9174}
9175
9176impl VirtioSoundRequest {
9177    #[allow(irrefutable_let_patterns)]
9178    pub fn into_configure_queue(
9179        self,
9180    ) -> Option<(u16, u16, u64, u64, u64, VirtioSoundConfigureQueueResponder)> {
9181        if let VirtioSoundRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
9182            self
9183        {
9184            Some((queue, size, desc, avail, used, responder))
9185        } else {
9186            None
9187        }
9188    }
9189
9190    #[allow(irrefutable_let_patterns)]
9191    pub fn into_notify_queue(self) -> Option<(u16, VirtioSoundControlHandle)> {
9192        if let VirtioSoundRequest::NotifyQueue { queue, control_handle } = self {
9193            Some((queue, control_handle))
9194        } else {
9195            None
9196        }
9197    }
9198
9199    #[allow(irrefutable_let_patterns)]
9200    pub fn into_ready(self) -> Option<(u32, VirtioSoundReadyResponder)> {
9201        if let VirtioSoundRequest::Ready { negotiated_features, responder } = self {
9202            Some((negotiated_features, responder))
9203        } else {
9204            None
9205        }
9206    }
9207
9208    #[allow(irrefutable_let_patterns)]
9209    pub fn into_start(self) -> Option<(StartInfo, bool, bool, VirtioSoundStartResponder)> {
9210        if let VirtioSoundRequest::Start {
9211            start_info,
9212            enable_input,
9213            enable_verbose_logging,
9214            responder,
9215        } = self
9216        {
9217            Some((start_info, enable_input, enable_verbose_logging, responder))
9218        } else {
9219            None
9220        }
9221    }
9222
9223    /// Name of the method defined in FIDL
9224    pub fn method_name(&self) -> &'static str {
9225        match *self {
9226            VirtioSoundRequest::ConfigureQueue { .. } => "configure_queue",
9227            VirtioSoundRequest::NotifyQueue { .. } => "notify_queue",
9228            VirtioSoundRequest::Ready { .. } => "ready",
9229            VirtioSoundRequest::Start { .. } => "start",
9230        }
9231    }
9232}
9233
9234#[derive(Debug, Clone)]
9235pub struct VirtioSoundControlHandle {
9236    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9237}
9238
9239impl fidl::endpoints::ControlHandle for VirtioSoundControlHandle {
9240    fn shutdown(&self) {
9241        self.inner.shutdown()
9242    }
9243    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9244        self.inner.shutdown_with_epitaph(status)
9245    }
9246
9247    fn is_closed(&self) -> bool {
9248        self.inner.channel().is_closed()
9249    }
9250    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9251        self.inner.channel().on_closed()
9252    }
9253
9254    #[cfg(target_os = "fuchsia")]
9255    fn signal_peer(
9256        &self,
9257        clear_mask: zx::Signals,
9258        set_mask: zx::Signals,
9259    ) -> Result<(), zx_status::Status> {
9260        use fidl::Peered;
9261        self.inner.channel().signal_peer(clear_mask, set_mask)
9262    }
9263}
9264
9265impl VirtioSoundControlHandle {}
9266
9267#[must_use = "FIDL methods require a response to be sent"]
9268#[derive(Debug)]
9269pub struct VirtioSoundConfigureQueueResponder {
9270    control_handle: std::mem::ManuallyDrop<VirtioSoundControlHandle>,
9271    tx_id: u32,
9272}
9273
9274/// Set the the channel to be shutdown (see [`VirtioSoundControlHandle::shutdown`])
9275/// if the responder is dropped without sending a response, so that the client
9276/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9277impl std::ops::Drop for VirtioSoundConfigureQueueResponder {
9278    fn drop(&mut self) {
9279        self.control_handle.shutdown();
9280        // Safety: drops once, never accessed again
9281        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9282    }
9283}
9284
9285impl fidl::endpoints::Responder for VirtioSoundConfigureQueueResponder {
9286    type ControlHandle = VirtioSoundControlHandle;
9287
9288    fn control_handle(&self) -> &VirtioSoundControlHandle {
9289        &self.control_handle
9290    }
9291
9292    fn drop_without_shutdown(mut self) {
9293        // Safety: drops once, never accessed again due to mem::forget
9294        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9295        // Prevent Drop from running (which would shut down the channel)
9296        std::mem::forget(self);
9297    }
9298}
9299
9300impl VirtioSoundConfigureQueueResponder {
9301    /// Sends a response to the FIDL transaction.
9302    ///
9303    /// Sets the channel to shutdown if an error occurs.
9304    pub fn send(self) -> Result<(), fidl::Error> {
9305        let _result = self.send_raw();
9306        if _result.is_err() {
9307            self.control_handle.shutdown();
9308        }
9309        self.drop_without_shutdown();
9310        _result
9311    }
9312
9313    /// Similar to "send" but does not shutdown the channel if an error occurs.
9314    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9315        let _result = self.send_raw();
9316        self.drop_without_shutdown();
9317        _result
9318    }
9319
9320    fn send_raw(&self) -> Result<(), fidl::Error> {
9321        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9322            (),
9323            self.tx_id,
9324            0x72b44fb963480b11,
9325            fidl::encoding::DynamicFlags::empty(),
9326        )
9327    }
9328}
9329
9330#[must_use = "FIDL methods require a response to be sent"]
9331#[derive(Debug)]
9332pub struct VirtioSoundReadyResponder {
9333    control_handle: std::mem::ManuallyDrop<VirtioSoundControlHandle>,
9334    tx_id: u32,
9335}
9336
9337/// Set the the channel to be shutdown (see [`VirtioSoundControlHandle::shutdown`])
9338/// if the responder is dropped without sending a response, so that the client
9339/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9340impl std::ops::Drop for VirtioSoundReadyResponder {
9341    fn drop(&mut self) {
9342        self.control_handle.shutdown();
9343        // Safety: drops once, never accessed again
9344        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9345    }
9346}
9347
9348impl fidl::endpoints::Responder for VirtioSoundReadyResponder {
9349    type ControlHandle = VirtioSoundControlHandle;
9350
9351    fn control_handle(&self) -> &VirtioSoundControlHandle {
9352        &self.control_handle
9353    }
9354
9355    fn drop_without_shutdown(mut self) {
9356        // Safety: drops once, never accessed again due to mem::forget
9357        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9358        // Prevent Drop from running (which would shut down the channel)
9359        std::mem::forget(self);
9360    }
9361}
9362
9363impl VirtioSoundReadyResponder {
9364    /// Sends a response to the FIDL transaction.
9365    ///
9366    /// Sets the channel to shutdown if an error occurs.
9367    pub fn send(self) -> Result<(), fidl::Error> {
9368        let _result = self.send_raw();
9369        if _result.is_err() {
9370            self.control_handle.shutdown();
9371        }
9372        self.drop_without_shutdown();
9373        _result
9374    }
9375
9376    /// Similar to "send" but does not shutdown the channel if an error occurs.
9377    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9378        let _result = self.send_raw();
9379        self.drop_without_shutdown();
9380        _result
9381    }
9382
9383    fn send_raw(&self) -> Result<(), fidl::Error> {
9384        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9385            (),
9386            self.tx_id,
9387            0x45707654f5d23c3f,
9388            fidl::encoding::DynamicFlags::empty(),
9389        )
9390    }
9391}
9392
9393#[must_use = "FIDL methods require a response to be sent"]
9394#[derive(Debug)]
9395pub struct VirtioSoundStartResponder {
9396    control_handle: std::mem::ManuallyDrop<VirtioSoundControlHandle>,
9397    tx_id: u32,
9398}
9399
9400/// Set the the channel to be shutdown (see [`VirtioSoundControlHandle::shutdown`])
9401/// if the responder is dropped without sending a response, so that the client
9402/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9403impl std::ops::Drop for VirtioSoundStartResponder {
9404    fn drop(&mut self) {
9405        self.control_handle.shutdown();
9406        // Safety: drops once, never accessed again
9407        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9408    }
9409}
9410
9411impl fidl::endpoints::Responder for VirtioSoundStartResponder {
9412    type ControlHandle = VirtioSoundControlHandle;
9413
9414    fn control_handle(&self) -> &VirtioSoundControlHandle {
9415        &self.control_handle
9416    }
9417
9418    fn drop_without_shutdown(mut self) {
9419        // Safety: drops once, never accessed again due to mem::forget
9420        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9421        // Prevent Drop from running (which would shut down the channel)
9422        std::mem::forget(self);
9423    }
9424}
9425
9426impl VirtioSoundStartResponder {
9427    /// Sends a response to the FIDL transaction.
9428    ///
9429    /// Sets the channel to shutdown if an error occurs.
9430    pub fn send(
9431        self,
9432        mut features: u32,
9433        mut jacks: u32,
9434        mut streams: u32,
9435        mut chmaps: u32,
9436    ) -> Result<(), fidl::Error> {
9437        let _result = self.send_raw(features, jacks, streams, chmaps);
9438        if _result.is_err() {
9439            self.control_handle.shutdown();
9440        }
9441        self.drop_without_shutdown();
9442        _result
9443    }
9444
9445    /// Similar to "send" but does not shutdown the channel if an error occurs.
9446    pub fn send_no_shutdown_on_err(
9447        self,
9448        mut features: u32,
9449        mut jacks: u32,
9450        mut streams: u32,
9451        mut chmaps: u32,
9452    ) -> Result<(), fidl::Error> {
9453        let _result = self.send_raw(features, jacks, streams, chmaps);
9454        self.drop_without_shutdown();
9455        _result
9456    }
9457
9458    fn send_raw(
9459        &self,
9460        mut features: u32,
9461        mut jacks: u32,
9462        mut streams: u32,
9463        mut chmaps: u32,
9464    ) -> Result<(), fidl::Error> {
9465        self.control_handle.inner.send::<VirtioSoundStartResponse>(
9466            (features, jacks, streams, chmaps),
9467            self.tx_id,
9468            0x2c3a5528c0b92e2d,
9469            fidl::encoding::DynamicFlags::empty(),
9470        )
9471    }
9472}
9473
9474#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9475pub struct VirtioVsockMarker;
9476
9477impl fidl::endpoints::ProtocolMarker for VirtioVsockMarker {
9478    type Proxy = VirtioVsockProxy;
9479    type RequestStream = VirtioVsockRequestStream;
9480    #[cfg(target_os = "fuchsia")]
9481    type SynchronousProxy = VirtioVsockSynchronousProxy;
9482
9483    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioVsock";
9484}
9485impl fidl::endpoints::DiscoverableProtocolMarker for VirtioVsockMarker {}
9486pub type VirtioVsockStartResult = Result<(), i32>;
9487
9488pub trait VirtioVsockProxyInterface: Send + Sync {
9489    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9490    fn r#configure_queue(
9491        &self,
9492        queue: u16,
9493        size: u16,
9494        desc: u64,
9495        avail: u64,
9496        used: u64,
9497    ) -> Self::ConfigureQueueResponseFut;
9498    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
9499    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9500    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
9501    type StartResponseFut: std::future::Future<Output = Result<VirtioVsockStartResult, fidl::Error>>
9502        + Send;
9503    fn r#start(
9504        &self,
9505        start_info: StartInfo,
9506        guest_cid: u32,
9507        listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9508    ) -> Self::StartResponseFut;
9509}
9510#[derive(Debug)]
9511#[cfg(target_os = "fuchsia")]
9512pub struct VirtioVsockSynchronousProxy {
9513    client: fidl::client::sync::Client,
9514}
9515
9516#[cfg(target_os = "fuchsia")]
9517impl fidl::endpoints::SynchronousProxy for VirtioVsockSynchronousProxy {
9518    type Proxy = VirtioVsockProxy;
9519    type Protocol = VirtioVsockMarker;
9520
9521    fn from_channel(inner: fidl::Channel) -> Self {
9522        Self::new(inner)
9523    }
9524
9525    fn into_channel(self) -> fidl::Channel {
9526        self.client.into_channel()
9527    }
9528
9529    fn as_channel(&self) -> &fidl::Channel {
9530        self.client.as_channel()
9531    }
9532}
9533
9534#[cfg(target_os = "fuchsia")]
9535impl VirtioVsockSynchronousProxy {
9536    pub fn new(channel: fidl::Channel) -> Self {
9537        let protocol_name = <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9538        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
9539    }
9540
9541    pub fn into_channel(self) -> fidl::Channel {
9542        self.client.into_channel()
9543    }
9544
9545    /// Waits until an event arrives and returns it. It is safe for other
9546    /// threads to make concurrent requests while waiting for an event.
9547    pub fn wait_for_event(
9548        &self,
9549        deadline: zx::MonotonicInstant,
9550    ) -> Result<VirtioVsockEvent, fidl::Error> {
9551        VirtioVsockEvent::decode(self.client.wait_for_event(deadline)?)
9552    }
9553
9554    /// Configure a `queue` for the device. This specifies the `size` and the
9555    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
9556    pub fn r#configure_queue(
9557        &self,
9558        mut queue: u16,
9559        mut size: u16,
9560        mut desc: u64,
9561        mut avail: u64,
9562        mut used: u64,
9563        ___deadline: zx::MonotonicInstant,
9564    ) -> Result<(), fidl::Error> {
9565        let _response = self
9566            .client
9567            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
9568                (queue, size, desc, avail, used),
9569                0x72b44fb963480b11,
9570                fidl::encoding::DynamicFlags::empty(),
9571                ___deadline,
9572            )?;
9573        Ok(_response)
9574    }
9575
9576    /// Notify a `queue` for the device. Primarily used for black-box testing.
9577    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
9578        self.client.send::<VirtioDeviceNotifyQueueRequest>(
9579            (queue,),
9580            0x6e3a61d652499244,
9581            fidl::encoding::DynamicFlags::empty(),
9582        )
9583    }
9584
9585    /// Ready a device. This provides the set of `negotiated_features` that the
9586    /// driver and device have agreed upon.
9587    pub fn r#ready(
9588        &self,
9589        mut negotiated_features: u32,
9590        ___deadline: zx::MonotonicInstant,
9591    ) -> Result<(), fidl::Error> {
9592        let _response =
9593            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
9594                (negotiated_features,),
9595                0x45707654f5d23c3f,
9596                fidl::encoding::DynamicFlags::empty(),
9597                ___deadline,
9598            )?;
9599        Ok(_response)
9600    }
9601
9602    /// Start the vsock device, setting the guest_cid to the provided value.
9603    ///
9604    /// Returns:
9605    ///   - ZX_OK if device startup succeeded
9606    ///   - ZX_ERR_INVALID_ARGS if guest_cid is a reserved value
9607    ///   - Any errors returned from fuchsia.virtualization.HostVsockEndpoint::Listen
9608    pub fn r#start(
9609        &self,
9610        mut start_info: StartInfo,
9611        mut guest_cid: u32,
9612        mut listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9613        ___deadline: zx::MonotonicInstant,
9614    ) -> Result<VirtioVsockStartResult, fidl::Error> {
9615        let _response = self.client.send_query::<
9616            VirtioVsockStartRequest,
9617            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
9618        >(
9619            (&mut start_info, guest_cid, listeners.as_mut(),),
9620            0x56433562cf67ae0f,
9621            fidl::encoding::DynamicFlags::empty(),
9622            ___deadline,
9623        )?;
9624        Ok(_response.map(|x| x))
9625    }
9626}
9627
9628#[cfg(target_os = "fuchsia")]
9629impl From<VirtioVsockSynchronousProxy> for zx::Handle {
9630    fn from(value: VirtioVsockSynchronousProxy) -> Self {
9631        value.into_channel().into()
9632    }
9633}
9634
9635#[cfg(target_os = "fuchsia")]
9636impl From<fidl::Channel> for VirtioVsockSynchronousProxy {
9637    fn from(value: fidl::Channel) -> Self {
9638        Self::new(value)
9639    }
9640}
9641
9642#[cfg(target_os = "fuchsia")]
9643impl fidl::endpoints::FromClient for VirtioVsockSynchronousProxy {
9644    type Protocol = VirtioVsockMarker;
9645
9646    fn from_client(value: fidl::endpoints::ClientEnd<VirtioVsockMarker>) -> Self {
9647        Self::new(value.into_channel())
9648    }
9649}
9650
9651#[derive(Debug, Clone)]
9652pub struct VirtioVsockProxy {
9653    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
9654}
9655
9656impl fidl::endpoints::Proxy for VirtioVsockProxy {
9657    type Protocol = VirtioVsockMarker;
9658
9659    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
9660        Self::new(inner)
9661    }
9662
9663    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
9664        self.client.into_channel().map_err(|client| Self { client })
9665    }
9666
9667    fn as_channel(&self) -> &::fidl::AsyncChannel {
9668        self.client.as_channel()
9669    }
9670}
9671
9672impl VirtioVsockProxy {
9673    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioVsock.
9674    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
9675        let protocol_name = <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9676        Self { client: fidl::client::Client::new(channel, protocol_name) }
9677    }
9678
9679    /// Get a Stream of events from the remote end of the protocol.
9680    ///
9681    /// # Panics
9682    ///
9683    /// Panics if the event stream was already taken.
9684    pub fn take_event_stream(&self) -> VirtioVsockEventStream {
9685        VirtioVsockEventStream { event_receiver: self.client.take_event_receiver() }
9686    }
9687
9688    /// Configure a `queue` for the device. This specifies the `size` and the
9689    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
9690    pub fn r#configure_queue(
9691        &self,
9692        mut queue: u16,
9693        mut size: u16,
9694        mut desc: u64,
9695        mut avail: u64,
9696        mut used: u64,
9697    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
9698        VirtioVsockProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
9699    }
9700
9701    /// Notify a `queue` for the device. Primarily used for black-box testing.
9702    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
9703        VirtioVsockProxyInterface::r#notify_queue(self, queue)
9704    }
9705
9706    /// Ready a device. This provides the set of `negotiated_features` that the
9707    /// driver and device have agreed upon.
9708    pub fn r#ready(
9709        &self,
9710        mut negotiated_features: u32,
9711    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
9712        VirtioVsockProxyInterface::r#ready(self, negotiated_features)
9713    }
9714
9715    /// Start the vsock device, setting the guest_cid to the provided value.
9716    ///
9717    /// Returns:
9718    ///   - ZX_OK if device startup succeeded
9719    ///   - ZX_ERR_INVALID_ARGS if guest_cid is a reserved value
9720    ///   - Any errors returned from fuchsia.virtualization.HostVsockEndpoint::Listen
9721    pub fn r#start(
9722        &self,
9723        mut start_info: StartInfo,
9724        mut guest_cid: u32,
9725        mut listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9726    ) -> fidl::client::QueryResponseFut<
9727        VirtioVsockStartResult,
9728        fidl::encoding::DefaultFuchsiaResourceDialect,
9729    > {
9730        VirtioVsockProxyInterface::r#start(self, start_info, guest_cid, listeners)
9731    }
9732}
9733
9734impl VirtioVsockProxyInterface for VirtioVsockProxy {
9735    type ConfigureQueueResponseFut =
9736        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9737    fn r#configure_queue(
9738        &self,
9739        mut queue: u16,
9740        mut size: u16,
9741        mut desc: u64,
9742        mut avail: u64,
9743        mut used: u64,
9744    ) -> Self::ConfigureQueueResponseFut {
9745        fn _decode(
9746            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9747        ) -> Result<(), fidl::Error> {
9748            let _response = fidl::client::decode_transaction_body::<
9749                fidl::encoding::EmptyPayload,
9750                fidl::encoding::DefaultFuchsiaResourceDialect,
9751                0x72b44fb963480b11,
9752            >(_buf?)?;
9753            Ok(_response)
9754        }
9755        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
9756            (queue, size, desc, avail, used),
9757            0x72b44fb963480b11,
9758            fidl::encoding::DynamicFlags::empty(),
9759            _decode,
9760        )
9761    }
9762
9763    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
9764        self.client.send::<VirtioDeviceNotifyQueueRequest>(
9765            (queue,),
9766            0x6e3a61d652499244,
9767            fidl::encoding::DynamicFlags::empty(),
9768        )
9769    }
9770
9771    type ReadyResponseFut =
9772        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9773    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
9774        fn _decode(
9775            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9776        ) -> Result<(), fidl::Error> {
9777            let _response = fidl::client::decode_transaction_body::<
9778                fidl::encoding::EmptyPayload,
9779                fidl::encoding::DefaultFuchsiaResourceDialect,
9780                0x45707654f5d23c3f,
9781            >(_buf?)?;
9782            Ok(_response)
9783        }
9784        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
9785            (negotiated_features,),
9786            0x45707654f5d23c3f,
9787            fidl::encoding::DynamicFlags::empty(),
9788            _decode,
9789        )
9790    }
9791
9792    type StartResponseFut = fidl::client::QueryResponseFut<
9793        VirtioVsockStartResult,
9794        fidl::encoding::DefaultFuchsiaResourceDialect,
9795    >;
9796    fn r#start(
9797        &self,
9798        mut start_info: StartInfo,
9799        mut guest_cid: u32,
9800        mut listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9801    ) -> Self::StartResponseFut {
9802        fn _decode(
9803            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9804        ) -> Result<VirtioVsockStartResult, fidl::Error> {
9805            let _response = fidl::client::decode_transaction_body::<
9806                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
9807                fidl::encoding::DefaultFuchsiaResourceDialect,
9808                0x56433562cf67ae0f,
9809            >(_buf?)?;
9810            Ok(_response.map(|x| x))
9811        }
9812        self.client.send_query_and_decode::<VirtioVsockStartRequest, VirtioVsockStartResult>(
9813            (&mut start_info, guest_cid, listeners.as_mut()),
9814            0x56433562cf67ae0f,
9815            fidl::encoding::DynamicFlags::empty(),
9816            _decode,
9817        )
9818    }
9819}
9820
9821pub struct VirtioVsockEventStream {
9822    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9823}
9824
9825impl std::marker::Unpin for VirtioVsockEventStream {}
9826
9827impl futures::stream::FusedStream for VirtioVsockEventStream {
9828    fn is_terminated(&self) -> bool {
9829        self.event_receiver.is_terminated()
9830    }
9831}
9832
9833impl futures::Stream for VirtioVsockEventStream {
9834    type Item = Result<VirtioVsockEvent, fidl::Error>;
9835
9836    fn poll_next(
9837        mut self: std::pin::Pin<&mut Self>,
9838        cx: &mut std::task::Context<'_>,
9839    ) -> std::task::Poll<Option<Self::Item>> {
9840        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9841            &mut self.event_receiver,
9842            cx
9843        )?) {
9844            Some(buf) => std::task::Poll::Ready(Some(VirtioVsockEvent::decode(buf))),
9845            None => std::task::Poll::Ready(None),
9846        }
9847    }
9848}
9849
9850#[derive(Debug)]
9851pub enum VirtioVsockEvent {}
9852
9853impl VirtioVsockEvent {
9854    /// Decodes a message buffer as a [`VirtioVsockEvent`].
9855    fn decode(
9856        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9857    ) -> Result<VirtioVsockEvent, fidl::Error> {
9858        let (bytes, _handles) = buf.split_mut();
9859        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9860        debug_assert_eq!(tx_header.tx_id, 0);
9861        match tx_header.ordinal {
9862            _ => Err(fidl::Error::UnknownOrdinal {
9863                ordinal: tx_header.ordinal,
9864                protocol_name: <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9865            }),
9866        }
9867    }
9868}
9869
9870/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioVsock.
9871pub struct VirtioVsockRequestStream {
9872    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9873    is_terminated: bool,
9874}
9875
9876impl std::marker::Unpin for VirtioVsockRequestStream {}
9877
9878impl futures::stream::FusedStream for VirtioVsockRequestStream {
9879    fn is_terminated(&self) -> bool {
9880        self.is_terminated
9881    }
9882}
9883
9884impl fidl::endpoints::RequestStream for VirtioVsockRequestStream {
9885    type Protocol = VirtioVsockMarker;
9886    type ControlHandle = VirtioVsockControlHandle;
9887
9888    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9889        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9890    }
9891
9892    fn control_handle(&self) -> Self::ControlHandle {
9893        VirtioVsockControlHandle { inner: self.inner.clone() }
9894    }
9895
9896    fn into_inner(
9897        self,
9898    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9899    {
9900        (self.inner, self.is_terminated)
9901    }
9902
9903    fn from_inner(
9904        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9905        is_terminated: bool,
9906    ) -> Self {
9907        Self { inner, is_terminated }
9908    }
9909}
9910
9911impl futures::Stream for VirtioVsockRequestStream {
9912    type Item = Result<VirtioVsockRequest, fidl::Error>;
9913
9914    fn poll_next(
9915        mut self: std::pin::Pin<&mut Self>,
9916        cx: &mut std::task::Context<'_>,
9917    ) -> std::task::Poll<Option<Self::Item>> {
9918        let this = &mut *self;
9919        if this.inner.check_shutdown(cx) {
9920            this.is_terminated = true;
9921            return std::task::Poll::Ready(None);
9922        }
9923        if this.is_terminated {
9924            panic!("polled VirtioVsockRequestStream after completion");
9925        }
9926        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9927            |bytes, handles| {
9928                match this.inner.channel().read_etc(cx, bytes, handles) {
9929                    std::task::Poll::Ready(Ok(())) => {}
9930                    std::task::Poll::Pending => return std::task::Poll::Pending,
9931                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9932                        this.is_terminated = true;
9933                        return std::task::Poll::Ready(None);
9934                    }
9935                    std::task::Poll::Ready(Err(e)) => {
9936                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9937                            e.into(),
9938                        ))))
9939                    }
9940                }
9941
9942                // A message has been received from the channel
9943                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9944
9945                std::task::Poll::Ready(Some(match header.ordinal {
9946                    0x72b44fb963480b11 => {
9947                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9948                        let mut req = fidl::new_empty!(
9949                            VirtioDeviceConfigureQueueRequest,
9950                            fidl::encoding::DefaultFuchsiaResourceDialect
9951                        );
9952                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
9953                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9954                        Ok(VirtioVsockRequest::ConfigureQueue {
9955                            queue: req.queue,
9956                            size: req.size,
9957                            desc: req.desc,
9958                            avail: req.avail,
9959                            used: req.used,
9960
9961                            responder: VirtioVsockConfigureQueueResponder {
9962                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9963                                tx_id: header.tx_id,
9964                            },
9965                        })
9966                    }
9967                    0x6e3a61d652499244 => {
9968                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9969                        let mut req = fidl::new_empty!(
9970                            VirtioDeviceNotifyQueueRequest,
9971                            fidl::encoding::DefaultFuchsiaResourceDialect
9972                        );
9973                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
9974                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9975                        Ok(VirtioVsockRequest::NotifyQueue { queue: req.queue, control_handle })
9976                    }
9977                    0x45707654f5d23c3f => {
9978                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9979                        let mut req = fidl::new_empty!(
9980                            VirtioDeviceReadyRequest,
9981                            fidl::encoding::DefaultFuchsiaResourceDialect
9982                        );
9983                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
9984                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9985                        Ok(VirtioVsockRequest::Ready {
9986                            negotiated_features: req.negotiated_features,
9987
9988                            responder: VirtioVsockReadyResponder {
9989                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9990                                tx_id: header.tx_id,
9991                            },
9992                        })
9993                    }
9994                    0x56433562cf67ae0f => {
9995                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9996                        let mut req = fidl::new_empty!(
9997                            VirtioVsockStartRequest,
9998                            fidl::encoding::DefaultFuchsiaResourceDialect
9999                        );
10000                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioVsockStartRequest>(&header, _body_bytes, handles, &mut req)?;
10001                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
10002                        Ok(VirtioVsockRequest::Start {
10003                            start_info: req.start_info,
10004                            guest_cid: req.guest_cid,
10005                            listeners: req.listeners,
10006
10007                            responder: VirtioVsockStartResponder {
10008                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10009                                tx_id: header.tx_id,
10010                            },
10011                        })
10012                    }
10013                    _ => Err(fidl::Error::UnknownOrdinal {
10014                        ordinal: header.ordinal,
10015                        protocol_name:
10016                            <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
10017                    }),
10018                }))
10019            },
10020        )
10021    }
10022}
10023
10024#[derive(Debug)]
10025pub enum VirtioVsockRequest {
10026    /// Configure a `queue` for the device. This specifies the `size` and the
10027    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
10028    ConfigureQueue {
10029        queue: u16,
10030        size: u16,
10031        desc: u64,
10032        avail: u64,
10033        used: u64,
10034        responder: VirtioVsockConfigureQueueResponder,
10035    },
10036    /// Notify a `queue` for the device. Primarily used for black-box testing.
10037    NotifyQueue { queue: u16, control_handle: VirtioVsockControlHandle },
10038    /// Ready a device. This provides the set of `negotiated_features` that the
10039    /// driver and device have agreed upon.
10040    Ready { negotiated_features: u32, responder: VirtioVsockReadyResponder },
10041    /// Start the vsock device, setting the guest_cid to the provided value.
10042    ///
10043    /// Returns:
10044    ///   - ZX_OK if device startup succeeded
10045    ///   - ZX_ERR_INVALID_ARGS if guest_cid is a reserved value
10046    ///   - Any errors returned from fuchsia.virtualization.HostVsockEndpoint::Listen
10047    Start {
10048        start_info: StartInfo,
10049        guest_cid: u32,
10050        listeners: Vec<fidl_fuchsia_virtualization::Listener>,
10051        responder: VirtioVsockStartResponder,
10052    },
10053}
10054
10055impl VirtioVsockRequest {
10056    #[allow(irrefutable_let_patterns)]
10057    pub fn into_configure_queue(
10058        self,
10059    ) -> Option<(u16, u16, u64, u64, u64, VirtioVsockConfigureQueueResponder)> {
10060        if let VirtioVsockRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
10061            self
10062        {
10063            Some((queue, size, desc, avail, used, responder))
10064        } else {
10065            None
10066        }
10067    }
10068
10069    #[allow(irrefutable_let_patterns)]
10070    pub fn into_notify_queue(self) -> Option<(u16, VirtioVsockControlHandle)> {
10071        if let VirtioVsockRequest::NotifyQueue { queue, control_handle } = self {
10072            Some((queue, control_handle))
10073        } else {
10074            None
10075        }
10076    }
10077
10078    #[allow(irrefutable_let_patterns)]
10079    pub fn into_ready(self) -> Option<(u32, VirtioVsockReadyResponder)> {
10080        if let VirtioVsockRequest::Ready { negotiated_features, responder } = self {
10081            Some((negotiated_features, responder))
10082        } else {
10083            None
10084        }
10085    }
10086
10087    #[allow(irrefutable_let_patterns)]
10088    pub fn into_start(
10089        self,
10090    ) -> Option<(
10091        StartInfo,
10092        u32,
10093        Vec<fidl_fuchsia_virtualization::Listener>,
10094        VirtioVsockStartResponder,
10095    )> {
10096        if let VirtioVsockRequest::Start { start_info, guest_cid, listeners, responder } = self {
10097            Some((start_info, guest_cid, listeners, responder))
10098        } else {
10099            None
10100        }
10101    }
10102
10103    /// Name of the method defined in FIDL
10104    pub fn method_name(&self) -> &'static str {
10105        match *self {
10106            VirtioVsockRequest::ConfigureQueue { .. } => "configure_queue",
10107            VirtioVsockRequest::NotifyQueue { .. } => "notify_queue",
10108            VirtioVsockRequest::Ready { .. } => "ready",
10109            VirtioVsockRequest::Start { .. } => "start",
10110        }
10111    }
10112}
10113
10114#[derive(Debug, Clone)]
10115pub struct VirtioVsockControlHandle {
10116    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10117}
10118
10119impl fidl::endpoints::ControlHandle for VirtioVsockControlHandle {
10120    fn shutdown(&self) {
10121        self.inner.shutdown()
10122    }
10123    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10124        self.inner.shutdown_with_epitaph(status)
10125    }
10126
10127    fn is_closed(&self) -> bool {
10128        self.inner.channel().is_closed()
10129    }
10130    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10131        self.inner.channel().on_closed()
10132    }
10133
10134    #[cfg(target_os = "fuchsia")]
10135    fn signal_peer(
10136        &self,
10137        clear_mask: zx::Signals,
10138        set_mask: zx::Signals,
10139    ) -> Result<(), zx_status::Status> {
10140        use fidl::Peered;
10141        self.inner.channel().signal_peer(clear_mask, set_mask)
10142    }
10143}
10144
10145impl VirtioVsockControlHandle {}
10146
10147#[must_use = "FIDL methods require a response to be sent"]
10148#[derive(Debug)]
10149pub struct VirtioVsockConfigureQueueResponder {
10150    control_handle: std::mem::ManuallyDrop<VirtioVsockControlHandle>,
10151    tx_id: u32,
10152}
10153
10154/// Set the the channel to be shutdown (see [`VirtioVsockControlHandle::shutdown`])
10155/// if the responder is dropped without sending a response, so that the client
10156/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10157impl std::ops::Drop for VirtioVsockConfigureQueueResponder {
10158    fn drop(&mut self) {
10159        self.control_handle.shutdown();
10160        // Safety: drops once, never accessed again
10161        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10162    }
10163}
10164
10165impl fidl::endpoints::Responder for VirtioVsockConfigureQueueResponder {
10166    type ControlHandle = VirtioVsockControlHandle;
10167
10168    fn control_handle(&self) -> &VirtioVsockControlHandle {
10169        &self.control_handle
10170    }
10171
10172    fn drop_without_shutdown(mut self) {
10173        // Safety: drops once, never accessed again due to mem::forget
10174        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10175        // Prevent Drop from running (which would shut down the channel)
10176        std::mem::forget(self);
10177    }
10178}
10179
10180impl VirtioVsockConfigureQueueResponder {
10181    /// Sends a response to the FIDL transaction.
10182    ///
10183    /// Sets the channel to shutdown if an error occurs.
10184    pub fn send(self) -> Result<(), fidl::Error> {
10185        let _result = self.send_raw();
10186        if _result.is_err() {
10187            self.control_handle.shutdown();
10188        }
10189        self.drop_without_shutdown();
10190        _result
10191    }
10192
10193    /// Similar to "send" but does not shutdown the channel if an error occurs.
10194    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10195        let _result = self.send_raw();
10196        self.drop_without_shutdown();
10197        _result
10198    }
10199
10200    fn send_raw(&self) -> Result<(), fidl::Error> {
10201        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10202            (),
10203            self.tx_id,
10204            0x72b44fb963480b11,
10205            fidl::encoding::DynamicFlags::empty(),
10206        )
10207    }
10208}
10209
10210#[must_use = "FIDL methods require a response to be sent"]
10211#[derive(Debug)]
10212pub struct VirtioVsockReadyResponder {
10213    control_handle: std::mem::ManuallyDrop<VirtioVsockControlHandle>,
10214    tx_id: u32,
10215}
10216
10217/// Set the the channel to be shutdown (see [`VirtioVsockControlHandle::shutdown`])
10218/// if the responder is dropped without sending a response, so that the client
10219/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10220impl std::ops::Drop for VirtioVsockReadyResponder {
10221    fn drop(&mut self) {
10222        self.control_handle.shutdown();
10223        // Safety: drops once, never accessed again
10224        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10225    }
10226}
10227
10228impl fidl::endpoints::Responder for VirtioVsockReadyResponder {
10229    type ControlHandle = VirtioVsockControlHandle;
10230
10231    fn control_handle(&self) -> &VirtioVsockControlHandle {
10232        &self.control_handle
10233    }
10234
10235    fn drop_without_shutdown(mut self) {
10236        // Safety: drops once, never accessed again due to mem::forget
10237        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10238        // Prevent Drop from running (which would shut down the channel)
10239        std::mem::forget(self);
10240    }
10241}
10242
10243impl VirtioVsockReadyResponder {
10244    /// Sends a response to the FIDL transaction.
10245    ///
10246    /// Sets the channel to shutdown if an error occurs.
10247    pub fn send(self) -> Result<(), fidl::Error> {
10248        let _result = self.send_raw();
10249        if _result.is_err() {
10250            self.control_handle.shutdown();
10251        }
10252        self.drop_without_shutdown();
10253        _result
10254    }
10255
10256    /// Similar to "send" but does not shutdown the channel if an error occurs.
10257    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10258        let _result = self.send_raw();
10259        self.drop_without_shutdown();
10260        _result
10261    }
10262
10263    fn send_raw(&self) -> Result<(), fidl::Error> {
10264        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10265            (),
10266            self.tx_id,
10267            0x45707654f5d23c3f,
10268            fidl::encoding::DynamicFlags::empty(),
10269        )
10270    }
10271}
10272
10273#[must_use = "FIDL methods require a response to be sent"]
10274#[derive(Debug)]
10275pub struct VirtioVsockStartResponder {
10276    control_handle: std::mem::ManuallyDrop<VirtioVsockControlHandle>,
10277    tx_id: u32,
10278}
10279
10280/// Set the the channel to be shutdown (see [`VirtioVsockControlHandle::shutdown`])
10281/// if the responder is dropped without sending a response, so that the client
10282/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10283impl std::ops::Drop for VirtioVsockStartResponder {
10284    fn drop(&mut self) {
10285        self.control_handle.shutdown();
10286        // Safety: drops once, never accessed again
10287        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10288    }
10289}
10290
10291impl fidl::endpoints::Responder for VirtioVsockStartResponder {
10292    type ControlHandle = VirtioVsockControlHandle;
10293
10294    fn control_handle(&self) -> &VirtioVsockControlHandle {
10295        &self.control_handle
10296    }
10297
10298    fn drop_without_shutdown(mut self) {
10299        // Safety: drops once, never accessed again due to mem::forget
10300        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10301        // Prevent Drop from running (which would shut down the channel)
10302        std::mem::forget(self);
10303    }
10304}
10305
10306impl VirtioVsockStartResponder {
10307    /// Sends a response to the FIDL transaction.
10308    ///
10309    /// Sets the channel to shutdown if an error occurs.
10310    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
10311        let _result = self.send_raw(result);
10312        if _result.is_err() {
10313            self.control_handle.shutdown();
10314        }
10315        self.drop_without_shutdown();
10316        _result
10317    }
10318
10319    /// Similar to "send" but does not shutdown the channel if an error occurs.
10320    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
10321        let _result = self.send_raw(result);
10322        self.drop_without_shutdown();
10323        _result
10324    }
10325
10326    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
10327        self.control_handle
10328            .inner
10329            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
10330                result,
10331                self.tx_id,
10332                0x56433562cf67ae0f,
10333                fidl::encoding::DynamicFlags::empty(),
10334            )
10335    }
10336}
10337
10338#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10339pub struct VirtioWaylandMarker;
10340
10341impl fidl::endpoints::ProtocolMarker for VirtioWaylandMarker {
10342    type Proxy = VirtioWaylandProxy;
10343    type RequestStream = VirtioWaylandRequestStream;
10344    #[cfg(target_os = "fuchsia")]
10345    type SynchronousProxy = VirtioWaylandSynchronousProxy;
10346
10347    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioWayland";
10348}
10349impl fidl::endpoints::DiscoverableProtocolMarker for VirtioWaylandMarker {}
10350
10351pub trait VirtioWaylandProxyInterface: Send + Sync {
10352    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10353    fn r#configure_queue(
10354        &self,
10355        queue: u16,
10356        size: u16,
10357        desc: u64,
10358        avail: u64,
10359        used: u64,
10360    ) -> Self::ConfigureQueueResponseFut;
10361    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
10362    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10363    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
10364    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10365    fn r#start(
10366        &self,
10367        start_info: StartInfo,
10368        vmar: fidl::Vmar,
10369        sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10370        scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
10371    ) -> Self::StartResponseFut;
10372    type StartWithWaylandServer_ResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10373        + Send;
10374    fn r#start_with_wayland_server_(
10375        &self,
10376        start_info: StartInfo,
10377        vmar: fidl::Vmar,
10378        wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
10379        sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10380        scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
10381    ) -> Self::StartWithWaylandServer_ResponseFut;
10382    fn r#get_importer(
10383        &self,
10384        importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
10385    ) -> Result<(), fidl::Error>;
10386}
10387#[derive(Debug)]
10388#[cfg(target_os = "fuchsia")]
10389pub struct VirtioWaylandSynchronousProxy {
10390    client: fidl::client::sync::Client,
10391}
10392
10393#[cfg(target_os = "fuchsia")]
10394impl fidl::endpoints::SynchronousProxy for VirtioWaylandSynchronousProxy {
10395    type Proxy = VirtioWaylandProxy;
10396    type Protocol = VirtioWaylandMarker;
10397
10398    fn from_channel(inner: fidl::Channel) -> Self {
10399        Self::new(inner)
10400    }
10401
10402    fn into_channel(self) -> fidl::Channel {
10403        self.client.into_channel()
10404    }
10405
10406    fn as_channel(&self) -> &fidl::Channel {
10407        self.client.as_channel()
10408    }
10409}
10410
10411#[cfg(target_os = "fuchsia")]
10412impl VirtioWaylandSynchronousProxy {
10413    pub fn new(channel: fidl::Channel) -> Self {
10414        let protocol_name = <VirtioWaylandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10415        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
10416    }
10417
10418    pub fn into_channel(self) -> fidl::Channel {
10419        self.client.into_channel()
10420    }
10421
10422    /// Waits until an event arrives and returns it. It is safe for other
10423    /// threads to make concurrent requests while waiting for an event.
10424    pub fn wait_for_event(
10425        &self,
10426        deadline: zx::MonotonicInstant,
10427    ) -> Result<VirtioWaylandEvent, fidl::Error> {
10428        VirtioWaylandEvent::decode(self.client.wait_for_event(deadline)?)
10429    }
10430
10431    /// Configure a `queue` for the device. This specifies the `size` and the
10432    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
10433    pub fn r#configure_queue(
10434        &self,
10435        mut queue: u16,
10436        mut size: u16,
10437        mut desc: u64,
10438        mut avail: u64,
10439        mut used: u64,
10440        ___deadline: zx::MonotonicInstant,
10441    ) -> Result<(), fidl::Error> {
10442        let _response = self
10443            .client
10444            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
10445                (queue, size, desc, avail, used),
10446                0x72b44fb963480b11,
10447                fidl::encoding::DynamicFlags::empty(),
10448                ___deadline,
10449            )?;
10450        Ok(_response)
10451    }
10452
10453    /// Notify a `queue` for the device. Primarily used for black-box testing.
10454    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
10455        self.client.send::<VirtioDeviceNotifyQueueRequest>(
10456            (queue,),
10457            0x6e3a61d652499244,
10458            fidl::encoding::DynamicFlags::empty(),
10459        )
10460    }
10461
10462    /// Ready a device. This provides the set of `negotiated_features` that the
10463    /// driver and device have agreed upon.
10464    pub fn r#ready(
10465        &self,
10466        mut negotiated_features: u32,
10467        ___deadline: zx::MonotonicInstant,
10468    ) -> Result<(), fidl::Error> {
10469        let _response =
10470            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
10471                (negotiated_features,),
10472                0x45707654f5d23c3f,
10473                fidl::encoding::DynamicFlags::empty(),
10474                ___deadline,
10475            )?;
10476        Ok(_response)
10477    }
10478
10479    /// Start the wayland device using the built-in wayland server.
10480    pub fn r#start(
10481        &self,
10482        mut start_info: StartInfo,
10483        mut vmar: fidl::Vmar,
10484        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10485        mut scenic_allocator: fidl::endpoints::ClientEnd<
10486            fidl_fuchsia_ui_composition::AllocatorMarker,
10487        >,
10488        ___deadline: zx::MonotonicInstant,
10489    ) -> Result<(), fidl::Error> {
10490        let _response =
10491            self.client.send_query::<VirtioWaylandStartRequest, fidl::encoding::EmptyPayload>(
10492                (&mut start_info, vmar, sysmem_allocator, scenic_allocator),
10493                0x1f60e084e30deee6,
10494                fidl::encoding::DynamicFlags::empty(),
10495                ___deadline,
10496            )?;
10497        Ok(_response)
10498    }
10499
10500    /// Start the wayland device using the provided wayland server.
10501    pub fn r#start_with_wayland_server_(
10502        &self,
10503        mut start_info: StartInfo,
10504        mut vmar: fidl::Vmar,
10505        mut wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
10506        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10507        mut scenic_allocator: fidl::endpoints::ClientEnd<
10508            fidl_fuchsia_ui_composition::AllocatorMarker,
10509        >,
10510        ___deadline: zx::MonotonicInstant,
10511    ) -> Result<(), fidl::Error> {
10512        let _response = self
10513            .client
10514            .send_query::<VirtioWaylandStartWithWaylandServerRequest, fidl::encoding::EmptyPayload>(
10515                (&mut start_info, vmar, wayland_server, sysmem_allocator, scenic_allocator),
10516                0x3f2e38dfb60077e9,
10517                fidl::encoding::DynamicFlags::empty(),
10518                ___deadline,
10519            )?;
10520        Ok(_response)
10521    }
10522
10523    pub fn r#get_importer(
10524        &self,
10525        mut importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
10526    ) -> Result<(), fidl::Error> {
10527        self.client.send::<VirtioWaylandGetImporterRequest>(
10528            (importer,),
10529            0x49d1b3c94767a541,
10530            fidl::encoding::DynamicFlags::empty(),
10531        )
10532    }
10533}
10534
10535#[cfg(target_os = "fuchsia")]
10536impl From<VirtioWaylandSynchronousProxy> for zx::Handle {
10537    fn from(value: VirtioWaylandSynchronousProxy) -> Self {
10538        value.into_channel().into()
10539    }
10540}
10541
10542#[cfg(target_os = "fuchsia")]
10543impl From<fidl::Channel> for VirtioWaylandSynchronousProxy {
10544    fn from(value: fidl::Channel) -> Self {
10545        Self::new(value)
10546    }
10547}
10548
10549#[cfg(target_os = "fuchsia")]
10550impl fidl::endpoints::FromClient for VirtioWaylandSynchronousProxy {
10551    type Protocol = VirtioWaylandMarker;
10552
10553    fn from_client(value: fidl::endpoints::ClientEnd<VirtioWaylandMarker>) -> Self {
10554        Self::new(value.into_channel())
10555    }
10556}
10557
10558#[derive(Debug, Clone)]
10559pub struct VirtioWaylandProxy {
10560    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10561}
10562
10563impl fidl::endpoints::Proxy for VirtioWaylandProxy {
10564    type Protocol = VirtioWaylandMarker;
10565
10566    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10567        Self::new(inner)
10568    }
10569
10570    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10571        self.client.into_channel().map_err(|client| Self { client })
10572    }
10573
10574    fn as_channel(&self) -> &::fidl::AsyncChannel {
10575        self.client.as_channel()
10576    }
10577}
10578
10579impl VirtioWaylandProxy {
10580    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioWayland.
10581    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10582        let protocol_name = <VirtioWaylandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10583        Self { client: fidl::client::Client::new(channel, protocol_name) }
10584    }
10585
10586    /// Get a Stream of events from the remote end of the protocol.
10587    ///
10588    /// # Panics
10589    ///
10590    /// Panics if the event stream was already taken.
10591    pub fn take_event_stream(&self) -> VirtioWaylandEventStream {
10592        VirtioWaylandEventStream { event_receiver: self.client.take_event_receiver() }
10593    }
10594
10595    /// Configure a `queue` for the device. This specifies the `size` and the
10596    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
10597    pub fn r#configure_queue(
10598        &self,
10599        mut queue: u16,
10600        mut size: u16,
10601        mut desc: u64,
10602        mut avail: u64,
10603        mut used: u64,
10604    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10605        VirtioWaylandProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
10606    }
10607
10608    /// Notify a `queue` for the device. Primarily used for black-box testing.
10609    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
10610        VirtioWaylandProxyInterface::r#notify_queue(self, queue)
10611    }
10612
10613    /// Ready a device. This provides the set of `negotiated_features` that the
10614    /// driver and device have agreed upon.
10615    pub fn r#ready(
10616        &self,
10617        mut negotiated_features: u32,
10618    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10619        VirtioWaylandProxyInterface::r#ready(self, negotiated_features)
10620    }
10621
10622    /// Start the wayland device using the built-in wayland server.
10623    pub fn r#start(
10624        &self,
10625        mut start_info: StartInfo,
10626        mut vmar: fidl::Vmar,
10627        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10628        mut scenic_allocator: fidl::endpoints::ClientEnd<
10629            fidl_fuchsia_ui_composition::AllocatorMarker,
10630        >,
10631    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10632        VirtioWaylandProxyInterface::r#start(
10633            self,
10634            start_info,
10635            vmar,
10636            sysmem_allocator,
10637            scenic_allocator,
10638        )
10639    }
10640
10641    /// Start the wayland device using the provided wayland server.
10642    pub fn r#start_with_wayland_server_(
10643        &self,
10644        mut start_info: StartInfo,
10645        mut vmar: fidl::Vmar,
10646        mut wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
10647        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10648        mut scenic_allocator: fidl::endpoints::ClientEnd<
10649            fidl_fuchsia_ui_composition::AllocatorMarker,
10650        >,
10651    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10652        VirtioWaylandProxyInterface::r#start_with_wayland_server_(
10653            self,
10654            start_info,
10655            vmar,
10656            wayland_server,
10657            sysmem_allocator,
10658            scenic_allocator,
10659        )
10660    }
10661
10662    pub fn r#get_importer(
10663        &self,
10664        mut importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
10665    ) -> Result<(), fidl::Error> {
10666        VirtioWaylandProxyInterface::r#get_importer(self, importer)
10667    }
10668}
10669
10670impl VirtioWaylandProxyInterface for VirtioWaylandProxy {
10671    type ConfigureQueueResponseFut =
10672        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10673    fn r#configure_queue(
10674        &self,
10675        mut queue: u16,
10676        mut size: u16,
10677        mut desc: u64,
10678        mut avail: u64,
10679        mut used: u64,
10680    ) -> Self::ConfigureQueueResponseFut {
10681        fn _decode(
10682            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10683        ) -> Result<(), fidl::Error> {
10684            let _response = fidl::client::decode_transaction_body::<
10685                fidl::encoding::EmptyPayload,
10686                fidl::encoding::DefaultFuchsiaResourceDialect,
10687                0x72b44fb963480b11,
10688            >(_buf?)?;
10689            Ok(_response)
10690        }
10691        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
10692            (queue, size, desc, avail, used),
10693            0x72b44fb963480b11,
10694            fidl::encoding::DynamicFlags::empty(),
10695            _decode,
10696        )
10697    }
10698
10699    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
10700        self.client.send::<VirtioDeviceNotifyQueueRequest>(
10701            (queue,),
10702            0x6e3a61d652499244,
10703            fidl::encoding::DynamicFlags::empty(),
10704        )
10705    }
10706
10707    type ReadyResponseFut =
10708        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10709    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
10710        fn _decode(
10711            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10712        ) -> Result<(), fidl::Error> {
10713            let _response = fidl::client::decode_transaction_body::<
10714                fidl::encoding::EmptyPayload,
10715                fidl::encoding::DefaultFuchsiaResourceDialect,
10716                0x45707654f5d23c3f,
10717            >(_buf?)?;
10718            Ok(_response)
10719        }
10720        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
10721            (negotiated_features,),
10722            0x45707654f5d23c3f,
10723            fidl::encoding::DynamicFlags::empty(),
10724            _decode,
10725        )
10726    }
10727
10728    type StartResponseFut =
10729        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10730    fn r#start(
10731        &self,
10732        mut start_info: StartInfo,
10733        mut vmar: fidl::Vmar,
10734        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10735        mut scenic_allocator: fidl::endpoints::ClientEnd<
10736            fidl_fuchsia_ui_composition::AllocatorMarker,
10737        >,
10738    ) -> Self::StartResponseFut {
10739        fn _decode(
10740            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10741        ) -> Result<(), fidl::Error> {
10742            let _response = fidl::client::decode_transaction_body::<
10743                fidl::encoding::EmptyPayload,
10744                fidl::encoding::DefaultFuchsiaResourceDialect,
10745                0x1f60e084e30deee6,
10746            >(_buf?)?;
10747            Ok(_response)
10748        }
10749        self.client.send_query_and_decode::<VirtioWaylandStartRequest, ()>(
10750            (&mut start_info, vmar, sysmem_allocator, scenic_allocator),
10751            0x1f60e084e30deee6,
10752            fidl::encoding::DynamicFlags::empty(),
10753            _decode,
10754        )
10755    }
10756
10757    type StartWithWaylandServer_ResponseFut =
10758        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10759    fn r#start_with_wayland_server_(
10760        &self,
10761        mut start_info: StartInfo,
10762        mut vmar: fidl::Vmar,
10763        mut wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
10764        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10765        mut scenic_allocator: fidl::endpoints::ClientEnd<
10766            fidl_fuchsia_ui_composition::AllocatorMarker,
10767        >,
10768    ) -> Self::StartWithWaylandServer_ResponseFut {
10769        fn _decode(
10770            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10771        ) -> Result<(), fidl::Error> {
10772            let _response = fidl::client::decode_transaction_body::<
10773                fidl::encoding::EmptyPayload,
10774                fidl::encoding::DefaultFuchsiaResourceDialect,
10775                0x3f2e38dfb60077e9,
10776            >(_buf?)?;
10777            Ok(_response)
10778        }
10779        self.client.send_query_and_decode::<VirtioWaylandStartWithWaylandServerRequest, ()>(
10780            (&mut start_info, vmar, wayland_server, sysmem_allocator, scenic_allocator),
10781            0x3f2e38dfb60077e9,
10782            fidl::encoding::DynamicFlags::empty(),
10783            _decode,
10784        )
10785    }
10786
10787    fn r#get_importer(
10788        &self,
10789        mut importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
10790    ) -> Result<(), fidl::Error> {
10791        self.client.send::<VirtioWaylandGetImporterRequest>(
10792            (importer,),
10793            0x49d1b3c94767a541,
10794            fidl::encoding::DynamicFlags::empty(),
10795        )
10796    }
10797}
10798
10799pub struct VirtioWaylandEventStream {
10800    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
10801}
10802
10803impl std::marker::Unpin for VirtioWaylandEventStream {}
10804
10805impl futures::stream::FusedStream for VirtioWaylandEventStream {
10806    fn is_terminated(&self) -> bool {
10807        self.event_receiver.is_terminated()
10808    }
10809}
10810
10811impl futures::Stream for VirtioWaylandEventStream {
10812    type Item = Result<VirtioWaylandEvent, fidl::Error>;
10813
10814    fn poll_next(
10815        mut self: std::pin::Pin<&mut Self>,
10816        cx: &mut std::task::Context<'_>,
10817    ) -> std::task::Poll<Option<Self::Item>> {
10818        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10819            &mut self.event_receiver,
10820            cx
10821        )?) {
10822            Some(buf) => std::task::Poll::Ready(Some(VirtioWaylandEvent::decode(buf))),
10823            None => std::task::Poll::Ready(None),
10824        }
10825    }
10826}
10827
10828#[derive(Debug)]
10829pub enum VirtioWaylandEvent {}
10830
10831impl VirtioWaylandEvent {
10832    /// Decodes a message buffer as a [`VirtioWaylandEvent`].
10833    fn decode(
10834        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10835    ) -> Result<VirtioWaylandEvent, fidl::Error> {
10836        let (bytes, _handles) = buf.split_mut();
10837        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10838        debug_assert_eq!(tx_header.tx_id, 0);
10839        match tx_header.ordinal {
10840            _ => Err(fidl::Error::UnknownOrdinal {
10841                ordinal: tx_header.ordinal,
10842                protocol_name: <VirtioWaylandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
10843            }),
10844        }
10845    }
10846}
10847
10848/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioWayland.
10849pub struct VirtioWaylandRequestStream {
10850    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10851    is_terminated: bool,
10852}
10853
10854impl std::marker::Unpin for VirtioWaylandRequestStream {}
10855
10856impl futures::stream::FusedStream for VirtioWaylandRequestStream {
10857    fn is_terminated(&self) -> bool {
10858        self.is_terminated
10859    }
10860}
10861
10862impl fidl::endpoints::RequestStream for VirtioWaylandRequestStream {
10863    type Protocol = VirtioWaylandMarker;
10864    type ControlHandle = VirtioWaylandControlHandle;
10865
10866    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
10867        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10868    }
10869
10870    fn control_handle(&self) -> Self::ControlHandle {
10871        VirtioWaylandControlHandle { inner: self.inner.clone() }
10872    }
10873
10874    fn into_inner(
10875        self,
10876    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
10877    {
10878        (self.inner, self.is_terminated)
10879    }
10880
10881    fn from_inner(
10882        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10883        is_terminated: bool,
10884    ) -> Self {
10885        Self { inner, is_terminated }
10886    }
10887}
10888
10889impl futures::Stream for VirtioWaylandRequestStream {
10890    type Item = Result<VirtioWaylandRequest, fidl::Error>;
10891
10892    fn poll_next(
10893        mut self: std::pin::Pin<&mut Self>,
10894        cx: &mut std::task::Context<'_>,
10895    ) -> std::task::Poll<Option<Self::Item>> {
10896        let this = &mut *self;
10897        if this.inner.check_shutdown(cx) {
10898            this.is_terminated = true;
10899            return std::task::Poll::Ready(None);
10900        }
10901        if this.is_terminated {
10902            panic!("polled VirtioWaylandRequestStream after completion");
10903        }
10904        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
10905            |bytes, handles| {
10906                match this.inner.channel().read_etc(cx, bytes, handles) {
10907                    std::task::Poll::Ready(Ok(())) => {}
10908                    std::task::Poll::Pending => return std::task::Poll::Pending,
10909                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
10910                        this.is_terminated = true;
10911                        return std::task::Poll::Ready(None);
10912                    }
10913                    std::task::Poll::Ready(Err(e)) => {
10914                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10915                            e.into(),
10916                        ))))
10917                    }
10918                }
10919
10920                // A message has been received from the channel
10921                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10922
10923                std::task::Poll::Ready(Some(match header.ordinal {
10924                    0x72b44fb963480b11 => {
10925                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10926                        let mut req = fidl::new_empty!(
10927                            VirtioDeviceConfigureQueueRequest,
10928                            fidl::encoding::DefaultFuchsiaResourceDialect
10929                        );
10930                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
10931                        let control_handle =
10932                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10933                        Ok(VirtioWaylandRequest::ConfigureQueue {
10934                            queue: req.queue,
10935                            size: req.size,
10936                            desc: req.desc,
10937                            avail: req.avail,
10938                            used: req.used,
10939
10940                            responder: VirtioWaylandConfigureQueueResponder {
10941                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10942                                tx_id: header.tx_id,
10943                            },
10944                        })
10945                    }
10946                    0x6e3a61d652499244 => {
10947                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10948                        let mut req = fidl::new_empty!(
10949                            VirtioDeviceNotifyQueueRequest,
10950                            fidl::encoding::DefaultFuchsiaResourceDialect
10951                        );
10952                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
10953                        let control_handle =
10954                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10955                        Ok(VirtioWaylandRequest::NotifyQueue { queue: req.queue, control_handle })
10956                    }
10957                    0x45707654f5d23c3f => {
10958                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10959                        let mut req = fidl::new_empty!(
10960                            VirtioDeviceReadyRequest,
10961                            fidl::encoding::DefaultFuchsiaResourceDialect
10962                        );
10963                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
10964                        let control_handle =
10965                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10966                        Ok(VirtioWaylandRequest::Ready {
10967                            negotiated_features: req.negotiated_features,
10968
10969                            responder: VirtioWaylandReadyResponder {
10970                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10971                                tx_id: header.tx_id,
10972                            },
10973                        })
10974                    }
10975                    0x1f60e084e30deee6 => {
10976                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10977                        let mut req = fidl::new_empty!(
10978                            VirtioWaylandStartRequest,
10979                            fidl::encoding::DefaultFuchsiaResourceDialect
10980                        );
10981                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandStartRequest>(&header, _body_bytes, handles, &mut req)?;
10982                        let control_handle =
10983                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10984                        Ok(VirtioWaylandRequest::Start {
10985                            start_info: req.start_info,
10986                            vmar: req.vmar,
10987                            sysmem_allocator: req.sysmem_allocator,
10988                            scenic_allocator: req.scenic_allocator,
10989
10990                            responder: VirtioWaylandStartResponder {
10991                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10992                                tx_id: header.tx_id,
10993                            },
10994                        })
10995                    }
10996                    0x3f2e38dfb60077e9 => {
10997                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10998                        let mut req = fidl::new_empty!(
10999                            VirtioWaylandStartWithWaylandServerRequest,
11000                            fidl::encoding::DefaultFuchsiaResourceDialect
11001                        );
11002                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandStartWithWaylandServerRequest>(&header, _body_bytes, handles, &mut req)?;
11003                        let control_handle =
11004                            VirtioWaylandControlHandle { inner: this.inner.clone() };
11005                        Ok(VirtioWaylandRequest::StartWithWaylandServer_ {
11006                            start_info: req.start_info,
11007                            vmar: req.vmar,
11008                            wayland_server: req.wayland_server,
11009                            sysmem_allocator: req.sysmem_allocator,
11010                            scenic_allocator: req.scenic_allocator,
11011
11012                            responder: VirtioWaylandStartWithWaylandServer_Responder {
11013                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11014                                tx_id: header.tx_id,
11015                            },
11016                        })
11017                    }
11018                    0x49d1b3c94767a541 => {
11019                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11020                        let mut req = fidl::new_empty!(
11021                            VirtioWaylandGetImporterRequest,
11022                            fidl::encoding::DefaultFuchsiaResourceDialect
11023                        );
11024                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandGetImporterRequest>(&header, _body_bytes, handles, &mut req)?;
11025                        let control_handle =
11026                            VirtioWaylandControlHandle { inner: this.inner.clone() };
11027                        Ok(VirtioWaylandRequest::GetImporter {
11028                            importer: req.importer,
11029
11030                            control_handle,
11031                        })
11032                    }
11033                    _ => Err(fidl::Error::UnknownOrdinal {
11034                        ordinal: header.ordinal,
11035                        protocol_name:
11036                            <VirtioWaylandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11037                    }),
11038                }))
11039            },
11040        )
11041    }
11042}
11043
11044#[derive(Debug)]
11045pub enum VirtioWaylandRequest {
11046    /// Configure a `queue` for the device. This specifies the `size` and the
11047    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
11048    ConfigureQueue {
11049        queue: u16,
11050        size: u16,
11051        desc: u64,
11052        avail: u64,
11053        used: u64,
11054        responder: VirtioWaylandConfigureQueueResponder,
11055    },
11056    /// Notify a `queue` for the device. Primarily used for black-box testing.
11057    NotifyQueue { queue: u16, control_handle: VirtioWaylandControlHandle },
11058    /// Ready a device. This provides the set of `negotiated_features` that the
11059    /// driver and device have agreed upon.
11060    Ready { negotiated_features: u32, responder: VirtioWaylandReadyResponder },
11061    /// Start the wayland device using the built-in wayland server.
11062    Start {
11063        start_info: StartInfo,
11064        vmar: fidl::Vmar,
11065        sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
11066        scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
11067        responder: VirtioWaylandStartResponder,
11068    },
11069    /// Start the wayland device using the provided wayland server.
11070    StartWithWaylandServer_ {
11071        start_info: StartInfo,
11072        vmar: fidl::Vmar,
11073        wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
11074        sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
11075        scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
11076        responder: VirtioWaylandStartWithWaylandServer_Responder,
11077    },
11078    GetImporter {
11079        importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
11080        control_handle: VirtioWaylandControlHandle,
11081    },
11082}
11083
11084impl VirtioWaylandRequest {
11085    #[allow(irrefutable_let_patterns)]
11086    pub fn into_configure_queue(
11087        self,
11088    ) -> Option<(u16, u16, u64, u64, u64, VirtioWaylandConfigureQueueResponder)> {
11089        if let VirtioWaylandRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
11090            self
11091        {
11092            Some((queue, size, desc, avail, used, responder))
11093        } else {
11094            None
11095        }
11096    }
11097
11098    #[allow(irrefutable_let_patterns)]
11099    pub fn into_notify_queue(self) -> Option<(u16, VirtioWaylandControlHandle)> {
11100        if let VirtioWaylandRequest::NotifyQueue { queue, control_handle } = self {
11101            Some((queue, control_handle))
11102        } else {
11103            None
11104        }
11105    }
11106
11107    #[allow(irrefutable_let_patterns)]
11108    pub fn into_ready(self) -> Option<(u32, VirtioWaylandReadyResponder)> {
11109        if let VirtioWaylandRequest::Ready { negotiated_features, responder } = self {
11110            Some((negotiated_features, responder))
11111        } else {
11112            None
11113        }
11114    }
11115
11116    #[allow(irrefutable_let_patterns)]
11117    pub fn into_start(
11118        self,
11119    ) -> Option<(
11120        StartInfo,
11121        fidl::Vmar,
11122        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
11123        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
11124        VirtioWaylandStartResponder,
11125    )> {
11126        if let VirtioWaylandRequest::Start {
11127            start_info,
11128            vmar,
11129            sysmem_allocator,
11130            scenic_allocator,
11131            responder,
11132        } = self
11133        {
11134            Some((start_info, vmar, sysmem_allocator, scenic_allocator, responder))
11135        } else {
11136            None
11137        }
11138    }
11139
11140    #[allow(irrefutable_let_patterns)]
11141    pub fn into_start_with_wayland_server_(
11142        self,
11143    ) -> Option<(
11144        StartInfo,
11145        fidl::Vmar,
11146        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
11147        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
11148        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
11149        VirtioWaylandStartWithWaylandServer_Responder,
11150    )> {
11151        if let VirtioWaylandRequest::StartWithWaylandServer_ {
11152            start_info,
11153            vmar,
11154            wayland_server,
11155            sysmem_allocator,
11156            scenic_allocator,
11157            responder,
11158        } = self
11159        {
11160            Some((start_info, vmar, wayland_server, sysmem_allocator, scenic_allocator, responder))
11161        } else {
11162            None
11163        }
11164    }
11165
11166    #[allow(irrefutable_let_patterns)]
11167    pub fn into_get_importer(
11168        self,
11169    ) -> Option<(fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>, VirtioWaylandControlHandle)>
11170    {
11171        if let VirtioWaylandRequest::GetImporter { importer, control_handle } = self {
11172            Some((importer, control_handle))
11173        } else {
11174            None
11175        }
11176    }
11177
11178    /// Name of the method defined in FIDL
11179    pub fn method_name(&self) -> &'static str {
11180        match *self {
11181            VirtioWaylandRequest::ConfigureQueue { .. } => "configure_queue",
11182            VirtioWaylandRequest::NotifyQueue { .. } => "notify_queue",
11183            VirtioWaylandRequest::Ready { .. } => "ready",
11184            VirtioWaylandRequest::Start { .. } => "start",
11185            VirtioWaylandRequest::StartWithWaylandServer_ { .. } => "start_with_wayland_server_",
11186            VirtioWaylandRequest::GetImporter { .. } => "get_importer",
11187        }
11188    }
11189}
11190
11191#[derive(Debug, Clone)]
11192pub struct VirtioWaylandControlHandle {
11193    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11194}
11195
11196impl fidl::endpoints::ControlHandle for VirtioWaylandControlHandle {
11197    fn shutdown(&self) {
11198        self.inner.shutdown()
11199    }
11200    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11201        self.inner.shutdown_with_epitaph(status)
11202    }
11203
11204    fn is_closed(&self) -> bool {
11205        self.inner.channel().is_closed()
11206    }
11207    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11208        self.inner.channel().on_closed()
11209    }
11210
11211    #[cfg(target_os = "fuchsia")]
11212    fn signal_peer(
11213        &self,
11214        clear_mask: zx::Signals,
11215        set_mask: zx::Signals,
11216    ) -> Result<(), zx_status::Status> {
11217        use fidl::Peered;
11218        self.inner.channel().signal_peer(clear_mask, set_mask)
11219    }
11220}
11221
11222impl VirtioWaylandControlHandle {}
11223
11224#[must_use = "FIDL methods require a response to be sent"]
11225#[derive(Debug)]
11226pub struct VirtioWaylandConfigureQueueResponder {
11227    control_handle: std::mem::ManuallyDrop<VirtioWaylandControlHandle>,
11228    tx_id: u32,
11229}
11230
11231/// Set the the channel to be shutdown (see [`VirtioWaylandControlHandle::shutdown`])
11232/// if the responder is dropped without sending a response, so that the client
11233/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11234impl std::ops::Drop for VirtioWaylandConfigureQueueResponder {
11235    fn drop(&mut self) {
11236        self.control_handle.shutdown();
11237        // Safety: drops once, never accessed again
11238        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11239    }
11240}
11241
11242impl fidl::endpoints::Responder for VirtioWaylandConfigureQueueResponder {
11243    type ControlHandle = VirtioWaylandControlHandle;
11244
11245    fn control_handle(&self) -> &VirtioWaylandControlHandle {
11246        &self.control_handle
11247    }
11248
11249    fn drop_without_shutdown(mut self) {
11250        // Safety: drops once, never accessed again due to mem::forget
11251        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11252        // Prevent Drop from running (which would shut down the channel)
11253        std::mem::forget(self);
11254    }
11255}
11256
11257impl VirtioWaylandConfigureQueueResponder {
11258    /// Sends a response to the FIDL transaction.
11259    ///
11260    /// Sets the channel to shutdown if an error occurs.
11261    pub fn send(self) -> Result<(), fidl::Error> {
11262        let _result = self.send_raw();
11263        if _result.is_err() {
11264            self.control_handle.shutdown();
11265        }
11266        self.drop_without_shutdown();
11267        _result
11268    }
11269
11270    /// Similar to "send" but does not shutdown the channel if an error occurs.
11271    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11272        let _result = self.send_raw();
11273        self.drop_without_shutdown();
11274        _result
11275    }
11276
11277    fn send_raw(&self) -> Result<(), fidl::Error> {
11278        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11279            (),
11280            self.tx_id,
11281            0x72b44fb963480b11,
11282            fidl::encoding::DynamicFlags::empty(),
11283        )
11284    }
11285}
11286
11287#[must_use = "FIDL methods require a response to be sent"]
11288#[derive(Debug)]
11289pub struct VirtioWaylandReadyResponder {
11290    control_handle: std::mem::ManuallyDrop<VirtioWaylandControlHandle>,
11291    tx_id: u32,
11292}
11293
11294/// Set the the channel to be shutdown (see [`VirtioWaylandControlHandle::shutdown`])
11295/// if the responder is dropped without sending a response, so that the client
11296/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11297impl std::ops::Drop for VirtioWaylandReadyResponder {
11298    fn drop(&mut self) {
11299        self.control_handle.shutdown();
11300        // Safety: drops once, never accessed again
11301        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11302    }
11303}
11304
11305impl fidl::endpoints::Responder for VirtioWaylandReadyResponder {
11306    type ControlHandle = VirtioWaylandControlHandle;
11307
11308    fn control_handle(&self) -> &VirtioWaylandControlHandle {
11309        &self.control_handle
11310    }
11311
11312    fn drop_without_shutdown(mut self) {
11313        // Safety: drops once, never accessed again due to mem::forget
11314        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11315        // Prevent Drop from running (which would shut down the channel)
11316        std::mem::forget(self);
11317    }
11318}
11319
11320impl VirtioWaylandReadyResponder {
11321    /// Sends a response to the FIDL transaction.
11322    ///
11323    /// Sets the channel to shutdown if an error occurs.
11324    pub fn send(self) -> Result<(), fidl::Error> {
11325        let _result = self.send_raw();
11326        if _result.is_err() {
11327            self.control_handle.shutdown();
11328        }
11329        self.drop_without_shutdown();
11330        _result
11331    }
11332
11333    /// Similar to "send" but does not shutdown the channel if an error occurs.
11334    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11335        let _result = self.send_raw();
11336        self.drop_without_shutdown();
11337        _result
11338    }
11339
11340    fn send_raw(&self) -> Result<(), fidl::Error> {
11341        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11342            (),
11343            self.tx_id,
11344            0x45707654f5d23c3f,
11345            fidl::encoding::DynamicFlags::empty(),
11346        )
11347    }
11348}
11349
11350#[must_use = "FIDL methods require a response to be sent"]
11351#[derive(Debug)]
11352pub struct VirtioWaylandStartResponder {
11353    control_handle: std::mem::ManuallyDrop<VirtioWaylandControlHandle>,
11354    tx_id: u32,
11355}
11356
11357/// Set the the channel to be shutdown (see [`VirtioWaylandControlHandle::shutdown`])
11358/// if the responder is dropped without sending a response, so that the client
11359/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11360impl std::ops::Drop for VirtioWaylandStartResponder {
11361    fn drop(&mut self) {
11362        self.control_handle.shutdown();
11363        // Safety: drops once, never accessed again
11364        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11365    }
11366}
11367
11368impl fidl::endpoints::Responder for VirtioWaylandStartResponder {
11369    type ControlHandle = VirtioWaylandControlHandle;
11370
11371    fn control_handle(&self) -> &VirtioWaylandControlHandle {
11372        &self.control_handle
11373    }
11374
11375    fn drop_without_shutdown(mut self) {
11376        // Safety: drops once, never accessed again due to mem::forget
11377        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11378        // Prevent Drop from running (which would shut down the channel)
11379        std::mem::forget(self);
11380    }
11381}
11382
11383impl VirtioWaylandStartResponder {
11384    /// Sends a response to the FIDL transaction.
11385    ///
11386    /// Sets the channel to shutdown if an error occurs.
11387    pub fn send(self) -> Result<(), fidl::Error> {
11388        let _result = self.send_raw();
11389        if _result.is_err() {
11390            self.control_handle.shutdown();
11391        }
11392        self.drop_without_shutdown();
11393        _result
11394    }
11395
11396    /// Similar to "send" but does not shutdown the channel if an error occurs.
11397    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11398        let _result = self.send_raw();
11399        self.drop_without_shutdown();
11400        _result
11401    }
11402
11403    fn send_raw(&self) -> Result<(), fidl::Error> {
11404        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11405            (),
11406            self.tx_id,
11407            0x1f60e084e30deee6,
11408            fidl::encoding::DynamicFlags::empty(),
11409        )
11410    }
11411}
11412
11413#[must_use = "FIDL methods require a response to be sent"]
11414#[derive(Debug)]
11415pub struct VirtioWaylandStartWithWaylandServer_Responder {
11416    control_handle: std::mem::ManuallyDrop<VirtioWaylandControlHandle>,
11417    tx_id: u32,
11418}
11419
11420/// Set the the channel to be shutdown (see [`VirtioWaylandControlHandle::shutdown`])
11421/// if the responder is dropped without sending a response, so that the client
11422/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11423impl std::ops::Drop for VirtioWaylandStartWithWaylandServer_Responder {
11424    fn drop(&mut self) {
11425        self.control_handle.shutdown();
11426        // Safety: drops once, never accessed again
11427        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11428    }
11429}
11430
11431impl fidl::endpoints::Responder for VirtioWaylandStartWithWaylandServer_Responder {
11432    type ControlHandle = VirtioWaylandControlHandle;
11433
11434    fn control_handle(&self) -> &VirtioWaylandControlHandle {
11435        &self.control_handle
11436    }
11437
11438    fn drop_without_shutdown(mut self) {
11439        // Safety: drops once, never accessed again due to mem::forget
11440        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11441        // Prevent Drop from running (which would shut down the channel)
11442        std::mem::forget(self);
11443    }
11444}
11445
11446impl VirtioWaylandStartWithWaylandServer_Responder {
11447    /// Sends a response to the FIDL transaction.
11448    ///
11449    /// Sets the channel to shutdown if an error occurs.
11450    pub fn send(self) -> Result<(), fidl::Error> {
11451        let _result = self.send_raw();
11452        if _result.is_err() {
11453            self.control_handle.shutdown();
11454        }
11455        self.drop_without_shutdown();
11456        _result
11457    }
11458
11459    /// Similar to "send" but does not shutdown the channel if an error occurs.
11460    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11461        let _result = self.send_raw();
11462        self.drop_without_shutdown();
11463        _result
11464    }
11465
11466    fn send_raw(&self) -> Result<(), fidl::Error> {
11467        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11468            (),
11469            self.tx_id,
11470            0x3f2e38dfb60077e9,
11471            fidl::encoding::DynamicFlags::empty(),
11472        )
11473    }
11474}
11475
11476#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11477pub struct VirtioWaylandImporterMarker;
11478
11479impl fidl::endpoints::ProtocolMarker for VirtioWaylandImporterMarker {
11480    type Proxy = VirtioWaylandImporterProxy;
11481    type RequestStream = VirtioWaylandImporterRequestStream;
11482    #[cfg(target_os = "fuchsia")]
11483    type SynchronousProxy = VirtioWaylandImporterSynchronousProxy;
11484
11485    const DEBUG_NAME: &'static str = "(anonymous) VirtioWaylandImporter";
11486}
11487
11488pub trait VirtioWaylandImporterProxyInterface: Send + Sync {
11489    type ImportImageResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
11490    fn r#import_image(&self, image: VirtioImage) -> Self::ImportImageResponseFut;
11491    type ExportImageResponseFut: std::future::Future<Output = Result<(i32, Option<Box<VirtioImage>>), fidl::Error>>
11492        + Send;
11493    fn r#export_image(&self, vfd_id: u32) -> Self::ExportImageResponseFut;
11494}
11495#[derive(Debug)]
11496#[cfg(target_os = "fuchsia")]
11497pub struct VirtioWaylandImporterSynchronousProxy {
11498    client: fidl::client::sync::Client,
11499}
11500
11501#[cfg(target_os = "fuchsia")]
11502impl fidl::endpoints::SynchronousProxy for VirtioWaylandImporterSynchronousProxy {
11503    type Proxy = VirtioWaylandImporterProxy;
11504    type Protocol = VirtioWaylandImporterMarker;
11505
11506    fn from_channel(inner: fidl::Channel) -> Self {
11507        Self::new(inner)
11508    }
11509
11510    fn into_channel(self) -> fidl::Channel {
11511        self.client.into_channel()
11512    }
11513
11514    fn as_channel(&self) -> &fidl::Channel {
11515        self.client.as_channel()
11516    }
11517}
11518
11519#[cfg(target_os = "fuchsia")]
11520impl VirtioWaylandImporterSynchronousProxy {
11521    pub fn new(channel: fidl::Channel) -> Self {
11522        let protocol_name =
11523            <VirtioWaylandImporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11524        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
11525    }
11526
11527    pub fn into_channel(self) -> fidl::Channel {
11528        self.client.into_channel()
11529    }
11530
11531    /// Waits until an event arrives and returns it. It is safe for other
11532    /// threads to make concurrent requests while waiting for an event.
11533    pub fn wait_for_event(
11534        &self,
11535        deadline: zx::MonotonicInstant,
11536    ) -> Result<VirtioWaylandImporterEvent, fidl::Error> {
11537        VirtioWaylandImporterEvent::decode(self.client.wait_for_event(deadline)?)
11538    }
11539
11540    pub fn r#import_image(
11541        &self,
11542        mut image: VirtioImage,
11543        ___deadline: zx::MonotonicInstant,
11544    ) -> Result<u32, fidl::Error> {
11545        let _response = self.client.send_query::<
11546            VirtioWaylandImporterImportImageRequest,
11547            VirtioWaylandImporterImportImageResponse,
11548        >(
11549            (&mut image,),
11550            0x3f8f3f75c34de5c,
11551            fidl::encoding::DynamicFlags::empty(),
11552            ___deadline,
11553        )?;
11554        Ok(_response.vfd_id)
11555    }
11556
11557    pub fn r#export_image(
11558        &self,
11559        mut vfd_id: u32,
11560        ___deadline: zx::MonotonicInstant,
11561    ) -> Result<(i32, Option<Box<VirtioImage>>), fidl::Error> {
11562        let _response = self.client.send_query::<
11563            VirtioWaylandImporterExportImageRequest,
11564            VirtioWaylandImporterExportImageResponse,
11565        >(
11566            (vfd_id,),
11567            0x25a33daa7c0307c4,
11568            fidl::encoding::DynamicFlags::empty(),
11569            ___deadline,
11570        )?;
11571        Ok((_response.status, _response.image))
11572    }
11573}
11574
11575#[cfg(target_os = "fuchsia")]
11576impl From<VirtioWaylandImporterSynchronousProxy> for zx::Handle {
11577    fn from(value: VirtioWaylandImporterSynchronousProxy) -> Self {
11578        value.into_channel().into()
11579    }
11580}
11581
11582#[cfg(target_os = "fuchsia")]
11583impl From<fidl::Channel> for VirtioWaylandImporterSynchronousProxy {
11584    fn from(value: fidl::Channel) -> Self {
11585        Self::new(value)
11586    }
11587}
11588
11589#[cfg(target_os = "fuchsia")]
11590impl fidl::endpoints::FromClient for VirtioWaylandImporterSynchronousProxy {
11591    type Protocol = VirtioWaylandImporterMarker;
11592
11593    fn from_client(value: fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>) -> Self {
11594        Self::new(value.into_channel())
11595    }
11596}
11597
11598#[derive(Debug, Clone)]
11599pub struct VirtioWaylandImporterProxy {
11600    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
11601}
11602
11603impl fidl::endpoints::Proxy for VirtioWaylandImporterProxy {
11604    type Protocol = VirtioWaylandImporterMarker;
11605
11606    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
11607        Self::new(inner)
11608    }
11609
11610    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
11611        self.client.into_channel().map_err(|client| Self { client })
11612    }
11613
11614    fn as_channel(&self) -> &::fidl::AsyncChannel {
11615        self.client.as_channel()
11616    }
11617}
11618
11619impl VirtioWaylandImporterProxy {
11620    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioWaylandImporter.
11621    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
11622        let protocol_name =
11623            <VirtioWaylandImporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11624        Self { client: fidl::client::Client::new(channel, protocol_name) }
11625    }
11626
11627    /// Get a Stream of events from the remote end of the protocol.
11628    ///
11629    /// # Panics
11630    ///
11631    /// Panics if the event stream was already taken.
11632    pub fn take_event_stream(&self) -> VirtioWaylandImporterEventStream {
11633        VirtioWaylandImporterEventStream { event_receiver: self.client.take_event_receiver() }
11634    }
11635
11636    pub fn r#import_image(
11637        &self,
11638        mut image: VirtioImage,
11639    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
11640        VirtioWaylandImporterProxyInterface::r#import_image(self, image)
11641    }
11642
11643    pub fn r#export_image(
11644        &self,
11645        mut vfd_id: u32,
11646    ) -> fidl::client::QueryResponseFut<
11647        (i32, Option<Box<VirtioImage>>),
11648        fidl::encoding::DefaultFuchsiaResourceDialect,
11649    > {
11650        VirtioWaylandImporterProxyInterface::r#export_image(self, vfd_id)
11651    }
11652}
11653
11654impl VirtioWaylandImporterProxyInterface for VirtioWaylandImporterProxy {
11655    type ImportImageResponseFut =
11656        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
11657    fn r#import_image(&self, mut image: VirtioImage) -> Self::ImportImageResponseFut {
11658        fn _decode(
11659            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11660        ) -> Result<u32, fidl::Error> {
11661            let _response = fidl::client::decode_transaction_body::<
11662                VirtioWaylandImporterImportImageResponse,
11663                fidl::encoding::DefaultFuchsiaResourceDialect,
11664                0x3f8f3f75c34de5c,
11665            >(_buf?)?;
11666            Ok(_response.vfd_id)
11667        }
11668        self.client.send_query_and_decode::<VirtioWaylandImporterImportImageRequest, u32>(
11669            (&mut image,),
11670            0x3f8f3f75c34de5c,
11671            fidl::encoding::DynamicFlags::empty(),
11672            _decode,
11673        )
11674    }
11675
11676    type ExportImageResponseFut = fidl::client::QueryResponseFut<
11677        (i32, Option<Box<VirtioImage>>),
11678        fidl::encoding::DefaultFuchsiaResourceDialect,
11679    >;
11680    fn r#export_image(&self, mut vfd_id: u32) -> Self::ExportImageResponseFut {
11681        fn _decode(
11682            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11683        ) -> Result<(i32, Option<Box<VirtioImage>>), fidl::Error> {
11684            let _response = fidl::client::decode_transaction_body::<
11685                VirtioWaylandImporterExportImageResponse,
11686                fidl::encoding::DefaultFuchsiaResourceDialect,
11687                0x25a33daa7c0307c4,
11688            >(_buf?)?;
11689            Ok((_response.status, _response.image))
11690        }
11691        self.client.send_query_and_decode::<
11692            VirtioWaylandImporterExportImageRequest,
11693            (i32, Option<Box<VirtioImage>>),
11694        >(
11695            (vfd_id,),
11696            0x25a33daa7c0307c4,
11697            fidl::encoding::DynamicFlags::empty(),
11698            _decode,
11699        )
11700    }
11701}
11702
11703pub struct VirtioWaylandImporterEventStream {
11704    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11705}
11706
11707impl std::marker::Unpin for VirtioWaylandImporterEventStream {}
11708
11709impl futures::stream::FusedStream for VirtioWaylandImporterEventStream {
11710    fn is_terminated(&self) -> bool {
11711        self.event_receiver.is_terminated()
11712    }
11713}
11714
11715impl futures::Stream for VirtioWaylandImporterEventStream {
11716    type Item = Result<VirtioWaylandImporterEvent, fidl::Error>;
11717
11718    fn poll_next(
11719        mut self: std::pin::Pin<&mut Self>,
11720        cx: &mut std::task::Context<'_>,
11721    ) -> std::task::Poll<Option<Self::Item>> {
11722        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11723            &mut self.event_receiver,
11724            cx
11725        )?) {
11726            Some(buf) => std::task::Poll::Ready(Some(VirtioWaylandImporterEvent::decode(buf))),
11727            None => std::task::Poll::Ready(None),
11728        }
11729    }
11730}
11731
11732#[derive(Debug)]
11733pub enum VirtioWaylandImporterEvent {}
11734
11735impl VirtioWaylandImporterEvent {
11736    /// Decodes a message buffer as a [`VirtioWaylandImporterEvent`].
11737    fn decode(
11738        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11739    ) -> Result<VirtioWaylandImporterEvent, fidl::Error> {
11740        let (bytes, _handles) = buf.split_mut();
11741        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11742        debug_assert_eq!(tx_header.tx_id, 0);
11743        match tx_header.ordinal {
11744            _ => Err(fidl::Error::UnknownOrdinal {
11745                ordinal: tx_header.ordinal,
11746                protocol_name:
11747                    <VirtioWaylandImporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11748            }),
11749        }
11750    }
11751}
11752
11753/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioWaylandImporter.
11754pub struct VirtioWaylandImporterRequestStream {
11755    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11756    is_terminated: bool,
11757}
11758
11759impl std::marker::Unpin for VirtioWaylandImporterRequestStream {}
11760
11761impl futures::stream::FusedStream for VirtioWaylandImporterRequestStream {
11762    fn is_terminated(&self) -> bool {
11763        self.is_terminated
11764    }
11765}
11766
11767impl fidl::endpoints::RequestStream for VirtioWaylandImporterRequestStream {
11768    type Protocol = VirtioWaylandImporterMarker;
11769    type ControlHandle = VirtioWaylandImporterControlHandle;
11770
11771    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11772        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11773    }
11774
11775    fn control_handle(&self) -> Self::ControlHandle {
11776        VirtioWaylandImporterControlHandle { inner: self.inner.clone() }
11777    }
11778
11779    fn into_inner(
11780        self,
11781    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11782    {
11783        (self.inner, self.is_terminated)
11784    }
11785
11786    fn from_inner(
11787        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11788        is_terminated: bool,
11789    ) -> Self {
11790        Self { inner, is_terminated }
11791    }
11792}
11793
11794impl futures::Stream for VirtioWaylandImporterRequestStream {
11795    type Item = Result<VirtioWaylandImporterRequest, fidl::Error>;
11796
11797    fn poll_next(
11798        mut self: std::pin::Pin<&mut Self>,
11799        cx: &mut std::task::Context<'_>,
11800    ) -> std::task::Poll<Option<Self::Item>> {
11801        let this = &mut *self;
11802        if this.inner.check_shutdown(cx) {
11803            this.is_terminated = true;
11804            return std::task::Poll::Ready(None);
11805        }
11806        if this.is_terminated {
11807            panic!("polled VirtioWaylandImporterRequestStream after completion");
11808        }
11809        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11810            |bytes, handles| {
11811                match this.inner.channel().read_etc(cx, bytes, handles) {
11812                    std::task::Poll::Ready(Ok(())) => {}
11813                    std::task::Poll::Pending => return std::task::Poll::Pending,
11814                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11815                        this.is_terminated = true;
11816                        return std::task::Poll::Ready(None);
11817                    }
11818                    std::task::Poll::Ready(Err(e)) => {
11819                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11820                            e.into(),
11821                        ))))
11822                    }
11823                }
11824
11825                // A message has been received from the channel
11826                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11827
11828                std::task::Poll::Ready(Some(match header.ordinal {
11829                0x3f8f3f75c34de5c => {
11830                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11831                    let mut req = fidl::new_empty!(VirtioWaylandImporterImportImageRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
11832                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandImporterImportImageRequest>(&header, _body_bytes, handles, &mut req)?;
11833                    let control_handle = VirtioWaylandImporterControlHandle {
11834                        inner: this.inner.clone(),
11835                    };
11836                    Ok(VirtioWaylandImporterRequest::ImportImage {image: req.image,
11837
11838                        responder: VirtioWaylandImporterImportImageResponder {
11839                            control_handle: std::mem::ManuallyDrop::new(control_handle),
11840                            tx_id: header.tx_id,
11841                        },
11842                    })
11843                }
11844                0x25a33daa7c0307c4 => {
11845                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11846                    let mut req = fidl::new_empty!(VirtioWaylandImporterExportImageRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
11847                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandImporterExportImageRequest>(&header, _body_bytes, handles, &mut req)?;
11848                    let control_handle = VirtioWaylandImporterControlHandle {
11849                        inner: this.inner.clone(),
11850                    };
11851                    Ok(VirtioWaylandImporterRequest::ExportImage {vfd_id: req.vfd_id,
11852
11853                        responder: VirtioWaylandImporterExportImageResponder {
11854                            control_handle: std::mem::ManuallyDrop::new(control_handle),
11855                            tx_id: header.tx_id,
11856                        },
11857                    })
11858                }
11859                _ => Err(fidl::Error::UnknownOrdinal {
11860                    ordinal: header.ordinal,
11861                    protocol_name: <VirtioWaylandImporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11862                }),
11863            }))
11864            },
11865        )
11866    }
11867}
11868
11869#[derive(Debug)]
11870pub enum VirtioWaylandImporterRequest {
11871    ImportImage { image: VirtioImage, responder: VirtioWaylandImporterImportImageResponder },
11872    ExportImage { vfd_id: u32, responder: VirtioWaylandImporterExportImageResponder },
11873}
11874
11875impl VirtioWaylandImporterRequest {
11876    #[allow(irrefutable_let_patterns)]
11877    pub fn into_import_image(
11878        self,
11879    ) -> Option<(VirtioImage, VirtioWaylandImporterImportImageResponder)> {
11880        if let VirtioWaylandImporterRequest::ImportImage { image, responder } = self {
11881            Some((image, responder))
11882        } else {
11883            None
11884        }
11885    }
11886
11887    #[allow(irrefutable_let_patterns)]
11888    pub fn into_export_image(self) -> Option<(u32, VirtioWaylandImporterExportImageResponder)> {
11889        if let VirtioWaylandImporterRequest::ExportImage { vfd_id, responder } = self {
11890            Some((vfd_id, responder))
11891        } else {
11892            None
11893        }
11894    }
11895
11896    /// Name of the method defined in FIDL
11897    pub fn method_name(&self) -> &'static str {
11898        match *self {
11899            VirtioWaylandImporterRequest::ImportImage { .. } => "import_image",
11900            VirtioWaylandImporterRequest::ExportImage { .. } => "export_image",
11901        }
11902    }
11903}
11904
11905#[derive(Debug, Clone)]
11906pub struct VirtioWaylandImporterControlHandle {
11907    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11908}
11909
11910impl fidl::endpoints::ControlHandle for VirtioWaylandImporterControlHandle {
11911    fn shutdown(&self) {
11912        self.inner.shutdown()
11913    }
11914    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11915        self.inner.shutdown_with_epitaph(status)
11916    }
11917
11918    fn is_closed(&self) -> bool {
11919        self.inner.channel().is_closed()
11920    }
11921    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11922        self.inner.channel().on_closed()
11923    }
11924
11925    #[cfg(target_os = "fuchsia")]
11926    fn signal_peer(
11927        &self,
11928        clear_mask: zx::Signals,
11929        set_mask: zx::Signals,
11930    ) -> Result<(), zx_status::Status> {
11931        use fidl::Peered;
11932        self.inner.channel().signal_peer(clear_mask, set_mask)
11933    }
11934}
11935
11936impl VirtioWaylandImporterControlHandle {}
11937
11938#[must_use = "FIDL methods require a response to be sent"]
11939#[derive(Debug)]
11940pub struct VirtioWaylandImporterImportImageResponder {
11941    control_handle: std::mem::ManuallyDrop<VirtioWaylandImporterControlHandle>,
11942    tx_id: u32,
11943}
11944
11945/// Set the the channel to be shutdown (see [`VirtioWaylandImporterControlHandle::shutdown`])
11946/// if the responder is dropped without sending a response, so that the client
11947/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11948impl std::ops::Drop for VirtioWaylandImporterImportImageResponder {
11949    fn drop(&mut self) {
11950        self.control_handle.shutdown();
11951        // Safety: drops once, never accessed again
11952        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11953    }
11954}
11955
11956impl fidl::endpoints::Responder for VirtioWaylandImporterImportImageResponder {
11957    type ControlHandle = VirtioWaylandImporterControlHandle;
11958
11959    fn control_handle(&self) -> &VirtioWaylandImporterControlHandle {
11960        &self.control_handle
11961    }
11962
11963    fn drop_without_shutdown(mut self) {
11964        // Safety: drops once, never accessed again due to mem::forget
11965        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11966        // Prevent Drop from running (which would shut down the channel)
11967        std::mem::forget(self);
11968    }
11969}
11970
11971impl VirtioWaylandImporterImportImageResponder {
11972    /// Sends a response to the FIDL transaction.
11973    ///
11974    /// Sets the channel to shutdown if an error occurs.
11975    pub fn send(self, mut vfd_id: u32) -> Result<(), fidl::Error> {
11976        let _result = self.send_raw(vfd_id);
11977        if _result.is_err() {
11978            self.control_handle.shutdown();
11979        }
11980        self.drop_without_shutdown();
11981        _result
11982    }
11983
11984    /// Similar to "send" but does not shutdown the channel if an error occurs.
11985    pub fn send_no_shutdown_on_err(self, mut vfd_id: u32) -> Result<(), fidl::Error> {
11986        let _result = self.send_raw(vfd_id);
11987        self.drop_without_shutdown();
11988        _result
11989    }
11990
11991    fn send_raw(&self, mut vfd_id: u32) -> Result<(), fidl::Error> {
11992        self.control_handle.inner.send::<VirtioWaylandImporterImportImageResponse>(
11993            (vfd_id,),
11994            self.tx_id,
11995            0x3f8f3f75c34de5c,
11996            fidl::encoding::DynamicFlags::empty(),
11997        )
11998    }
11999}
12000
12001#[must_use = "FIDL methods require a response to be sent"]
12002#[derive(Debug)]
12003pub struct VirtioWaylandImporterExportImageResponder {
12004    control_handle: std::mem::ManuallyDrop<VirtioWaylandImporterControlHandle>,
12005    tx_id: u32,
12006}
12007
12008/// Set the the channel to be shutdown (see [`VirtioWaylandImporterControlHandle::shutdown`])
12009/// if the responder is dropped without sending a response, so that the client
12010/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12011impl std::ops::Drop for VirtioWaylandImporterExportImageResponder {
12012    fn drop(&mut self) {
12013        self.control_handle.shutdown();
12014        // Safety: drops once, never accessed again
12015        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12016    }
12017}
12018
12019impl fidl::endpoints::Responder for VirtioWaylandImporterExportImageResponder {
12020    type ControlHandle = VirtioWaylandImporterControlHandle;
12021
12022    fn control_handle(&self) -> &VirtioWaylandImporterControlHandle {
12023        &self.control_handle
12024    }
12025
12026    fn drop_without_shutdown(mut self) {
12027        // Safety: drops once, never accessed again due to mem::forget
12028        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12029        // Prevent Drop from running (which would shut down the channel)
12030        std::mem::forget(self);
12031    }
12032}
12033
12034impl VirtioWaylandImporterExportImageResponder {
12035    /// Sends a response to the FIDL transaction.
12036    ///
12037    /// Sets the channel to shutdown if an error occurs.
12038    pub fn send(self, mut status: i32, mut image: Option<VirtioImage>) -> Result<(), fidl::Error> {
12039        let _result = self.send_raw(status, image);
12040        if _result.is_err() {
12041            self.control_handle.shutdown();
12042        }
12043        self.drop_without_shutdown();
12044        _result
12045    }
12046
12047    /// Similar to "send" but does not shutdown the channel if an error occurs.
12048    pub fn send_no_shutdown_on_err(
12049        self,
12050        mut status: i32,
12051        mut image: Option<VirtioImage>,
12052    ) -> Result<(), fidl::Error> {
12053        let _result = self.send_raw(status, image);
12054        self.drop_without_shutdown();
12055        _result
12056    }
12057
12058    fn send_raw(&self, mut status: i32, mut image: Option<VirtioImage>) -> Result<(), fidl::Error> {
12059        self.control_handle.inner.send::<VirtioWaylandImporterExportImageResponse>(
12060            (status, image.as_mut()),
12061            self.tx_id,
12062            0x25a33daa7c0307c4,
12063            fidl::encoding::DynamicFlags::empty(),
12064        )
12065    }
12066}
12067
12068mod internal {
12069    use super::*;
12070
12071    impl fidl::encoding::ResourceTypeMarker for StartInfo {
12072        type Borrowed<'a> = &'a mut Self;
12073        fn take_or_borrow<'a>(
12074            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12075        ) -> Self::Borrowed<'a> {
12076            value
12077        }
12078    }
12079
12080    unsafe impl fidl::encoding::TypeMarker for StartInfo {
12081        type Owned = Self;
12082
12083        #[inline(always)]
12084        fn inline_align(_context: fidl::encoding::Context) -> usize {
12085            8
12086        }
12087
12088        #[inline(always)]
12089        fn inline_size(_context: fidl::encoding::Context) -> usize {
12090            32
12091        }
12092    }
12093
12094    unsafe impl fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
12095        for &mut StartInfo
12096    {
12097        #[inline]
12098        unsafe fn encode(
12099            self,
12100            encoder: &mut fidl::encoding::Encoder<
12101                '_,
12102                fidl::encoding::DefaultFuchsiaResourceDialect,
12103            >,
12104            offset: usize,
12105            _depth: fidl::encoding::Depth,
12106        ) -> fidl::Result<()> {
12107            encoder.debug_check_bounds::<StartInfo>(offset);
12108            // Delegate to tuple encoding.
12109            fidl::encoding::Encode::<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12110                (
12111                    <Trap as fidl::encoding::ValueTypeMarker>::borrow(&self.trap),
12112                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Guest, { fidl::ObjectType::GUEST.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest),
12113                    <fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.event),
12114                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
12115                ),
12116                encoder, offset, _depth
12117            )
12118        }
12119    }
12120    unsafe impl<
12121            T0: fidl::encoding::Encode<Trap, fidl::encoding::DefaultFuchsiaResourceDialect>,
12122            T1: fidl::encoding::Encode<
12123                fidl::encoding::Optional<
12124                    fidl::encoding::HandleType<
12125                        fidl::Guest,
12126                        { fidl::ObjectType::GUEST.into_raw() },
12127                        2147483648,
12128                    >,
12129                >,
12130                fidl::encoding::DefaultFuchsiaResourceDialect,
12131            >,
12132            T2: fidl::encoding::Encode<
12133                fidl::encoding::HandleType<
12134                    fidl::Event,
12135                    { fidl::ObjectType::EVENT.into_raw() },
12136                    2147483648,
12137                >,
12138                fidl::encoding::DefaultFuchsiaResourceDialect,
12139            >,
12140            T3: fidl::encoding::Encode<
12141                fidl::encoding::HandleType<
12142                    fidl::Vmo,
12143                    { fidl::ObjectType::VMO.into_raw() },
12144                    2147483648,
12145                >,
12146                fidl::encoding::DefaultFuchsiaResourceDialect,
12147            >,
12148        > fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
12149        for (T0, T1, T2, T3)
12150    {
12151        #[inline]
12152        unsafe fn encode(
12153            self,
12154            encoder: &mut fidl::encoding::Encoder<
12155                '_,
12156                fidl::encoding::DefaultFuchsiaResourceDialect,
12157            >,
12158            offset: usize,
12159            depth: fidl::encoding::Depth,
12160        ) -> fidl::Result<()> {
12161            encoder.debug_check_bounds::<StartInfo>(offset);
12162            // Zero out padding regions. There's no need to apply masks
12163            // because the unmasked parts will be overwritten by fields.
12164            unsafe {
12165                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
12166                (ptr as *mut u64).write_unaligned(0);
12167            }
12168            // Write the fields.
12169            self.0.encode(encoder, offset + 0, depth)?;
12170            self.1.encode(encoder, offset + 16, depth)?;
12171            self.2.encode(encoder, offset + 20, depth)?;
12172            self.3.encode(encoder, offset + 24, depth)?;
12173            Ok(())
12174        }
12175    }
12176
12177    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for StartInfo {
12178        #[inline(always)]
12179        fn new_empty() -> Self {
12180            Self {
12181                trap: fidl::new_empty!(Trap, fidl::encoding::DefaultFuchsiaResourceDialect),
12182                guest: fidl::new_empty!(
12183                    fidl::encoding::Optional<
12184                        fidl::encoding::HandleType<
12185                            fidl::Guest,
12186                            { fidl::ObjectType::GUEST.into_raw() },
12187                            2147483648,
12188                        >,
12189                    >,
12190                    fidl::encoding::DefaultFuchsiaResourceDialect
12191                ),
12192                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12193                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12194            }
12195        }
12196
12197        #[inline]
12198        unsafe fn decode(
12199            &mut self,
12200            decoder: &mut fidl::encoding::Decoder<
12201                '_,
12202                fidl::encoding::DefaultFuchsiaResourceDialect,
12203            >,
12204            offset: usize,
12205            _depth: fidl::encoding::Depth,
12206        ) -> fidl::Result<()> {
12207            decoder.debug_check_bounds::<Self>(offset);
12208            // Verify that padding bytes are zero.
12209            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
12210            let padval = unsafe { (ptr as *const u64).read_unaligned() };
12211            let mask = 0xffffffff00000000u64;
12212            let maskedval = padval & mask;
12213            if maskedval != 0 {
12214                return Err(fidl::Error::NonZeroPadding {
12215                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
12216                });
12217            }
12218            fidl::decode!(
12219                Trap,
12220                fidl::encoding::DefaultFuchsiaResourceDialect,
12221                &mut self.trap,
12222                decoder,
12223                offset + 0,
12224                _depth
12225            )?;
12226            fidl::decode!(
12227                fidl::encoding::Optional<
12228                    fidl::encoding::HandleType<
12229                        fidl::Guest,
12230                        { fidl::ObjectType::GUEST.into_raw() },
12231                        2147483648,
12232                    >,
12233                >,
12234                fidl::encoding::DefaultFuchsiaResourceDialect,
12235                &mut self.guest,
12236                decoder,
12237                offset + 16,
12238                _depth
12239            )?;
12240            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 20, _depth)?;
12241            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 24, _depth)?;
12242            Ok(())
12243        }
12244    }
12245
12246    impl fidl::encoding::ResourceTypeMarker for VirtioBalloonStartRequest {
12247        type Borrowed<'a> = &'a mut Self;
12248        fn take_or_borrow<'a>(
12249            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12250        ) -> Self::Borrowed<'a> {
12251            value
12252        }
12253    }
12254
12255    unsafe impl fidl::encoding::TypeMarker for VirtioBalloonStartRequest {
12256        type Owned = Self;
12257
12258        #[inline(always)]
12259        fn inline_align(_context: fidl::encoding::Context) -> usize {
12260            8
12261        }
12262
12263        #[inline(always)]
12264        fn inline_size(_context: fidl::encoding::Context) -> usize {
12265            32
12266        }
12267    }
12268
12269    unsafe impl
12270        fidl::encoding::Encode<
12271            VirtioBalloonStartRequest,
12272            fidl::encoding::DefaultFuchsiaResourceDialect,
12273        > for &mut VirtioBalloonStartRequest
12274    {
12275        #[inline]
12276        unsafe fn encode(
12277            self,
12278            encoder: &mut fidl::encoding::Encoder<
12279                '_,
12280                fidl::encoding::DefaultFuchsiaResourceDialect,
12281            >,
12282            offset: usize,
12283            _depth: fidl::encoding::Depth,
12284        ) -> fidl::Result<()> {
12285            encoder.debug_check_bounds::<VirtioBalloonStartRequest>(offset);
12286            // Delegate to tuple encoding.
12287            fidl::encoding::Encode::<
12288                VirtioBalloonStartRequest,
12289                fidl::encoding::DefaultFuchsiaResourceDialect,
12290            >::encode(
12291                (<StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12292                    &mut self.start_info,
12293                ),),
12294                encoder,
12295                offset,
12296                _depth,
12297            )
12298        }
12299    }
12300    unsafe impl<T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>>
12301        fidl::encoding::Encode<
12302            VirtioBalloonStartRequest,
12303            fidl::encoding::DefaultFuchsiaResourceDialect,
12304        > for (T0,)
12305    {
12306        #[inline]
12307        unsafe fn encode(
12308            self,
12309            encoder: &mut fidl::encoding::Encoder<
12310                '_,
12311                fidl::encoding::DefaultFuchsiaResourceDialect,
12312            >,
12313            offset: usize,
12314            depth: fidl::encoding::Depth,
12315        ) -> fidl::Result<()> {
12316            encoder.debug_check_bounds::<VirtioBalloonStartRequest>(offset);
12317            // Zero out padding regions. There's no need to apply masks
12318            // because the unmasked parts will be overwritten by fields.
12319            // Write the fields.
12320            self.0.encode(encoder, offset + 0, depth)?;
12321            Ok(())
12322        }
12323    }
12324
12325    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12326        for VirtioBalloonStartRequest
12327    {
12328        #[inline(always)]
12329        fn new_empty() -> Self {
12330            Self {
12331                start_info: fidl::new_empty!(
12332                    StartInfo,
12333                    fidl::encoding::DefaultFuchsiaResourceDialect
12334                ),
12335            }
12336        }
12337
12338        #[inline]
12339        unsafe fn decode(
12340            &mut self,
12341            decoder: &mut fidl::encoding::Decoder<
12342                '_,
12343                fidl::encoding::DefaultFuchsiaResourceDialect,
12344            >,
12345            offset: usize,
12346            _depth: fidl::encoding::Depth,
12347        ) -> fidl::Result<()> {
12348            decoder.debug_check_bounds::<Self>(offset);
12349            // Verify that padding bytes are zero.
12350            fidl::decode!(
12351                StartInfo,
12352                fidl::encoding::DefaultFuchsiaResourceDialect,
12353                &mut self.start_info,
12354                decoder,
12355                offset + 0,
12356                _depth
12357            )?;
12358            Ok(())
12359        }
12360    }
12361
12362    impl fidl::encoding::ResourceTypeMarker for VirtioBlockStartRequest {
12363        type Borrowed<'a> = &'a mut Self;
12364        fn take_or_borrow<'a>(
12365            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12366        ) -> Self::Borrowed<'a> {
12367            value
12368        }
12369    }
12370
12371    unsafe impl fidl::encoding::TypeMarker for VirtioBlockStartRequest {
12372        type Owned = Self;
12373
12374        #[inline(always)]
12375        fn inline_align(_context: fidl::encoding::Context) -> usize {
12376            8
12377        }
12378
12379        #[inline(always)]
12380        fn inline_size(_context: fidl::encoding::Context) -> usize {
12381            72
12382        }
12383    }
12384
12385    unsafe impl
12386        fidl::encoding::Encode<
12387            VirtioBlockStartRequest,
12388            fidl::encoding::DefaultFuchsiaResourceDialect,
12389        > for &mut VirtioBlockStartRequest
12390    {
12391        #[inline]
12392        unsafe fn encode(
12393            self,
12394            encoder: &mut fidl::encoding::Encoder<
12395                '_,
12396                fidl::encoding::DefaultFuchsiaResourceDialect,
12397            >,
12398            offset: usize,
12399            _depth: fidl::encoding::Depth,
12400        ) -> fidl::Result<()> {
12401            encoder.debug_check_bounds::<VirtioBlockStartRequest>(offset);
12402            // Delegate to tuple encoding.
12403            fidl::encoding::Encode::<VirtioBlockStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12404                (
12405                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.start_info),
12406                    <fidl_fuchsia_virtualization::BlockSpec as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.spec),
12407                ),
12408                encoder, offset, _depth
12409            )
12410        }
12411    }
12412    unsafe impl<
12413            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
12414            T1: fidl::encoding::Encode<
12415                fidl_fuchsia_virtualization::BlockSpec,
12416                fidl::encoding::DefaultFuchsiaResourceDialect,
12417            >,
12418        >
12419        fidl::encoding::Encode<
12420            VirtioBlockStartRequest,
12421            fidl::encoding::DefaultFuchsiaResourceDialect,
12422        > for (T0, T1)
12423    {
12424        #[inline]
12425        unsafe fn encode(
12426            self,
12427            encoder: &mut fidl::encoding::Encoder<
12428                '_,
12429                fidl::encoding::DefaultFuchsiaResourceDialect,
12430            >,
12431            offset: usize,
12432            depth: fidl::encoding::Depth,
12433        ) -> fidl::Result<()> {
12434            encoder.debug_check_bounds::<VirtioBlockStartRequest>(offset);
12435            // Zero out padding regions. There's no need to apply masks
12436            // because the unmasked parts will be overwritten by fields.
12437            // Write the fields.
12438            self.0.encode(encoder, offset + 0, depth)?;
12439            self.1.encode(encoder, offset + 32, depth)?;
12440            Ok(())
12441        }
12442    }
12443
12444    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12445        for VirtioBlockStartRequest
12446    {
12447        #[inline(always)]
12448        fn new_empty() -> Self {
12449            Self {
12450                start_info: fidl::new_empty!(
12451                    StartInfo,
12452                    fidl::encoding::DefaultFuchsiaResourceDialect
12453                ),
12454                spec: fidl::new_empty!(
12455                    fidl_fuchsia_virtualization::BlockSpec,
12456                    fidl::encoding::DefaultFuchsiaResourceDialect
12457                ),
12458            }
12459        }
12460
12461        #[inline]
12462        unsafe fn decode(
12463            &mut self,
12464            decoder: &mut fidl::encoding::Decoder<
12465                '_,
12466                fidl::encoding::DefaultFuchsiaResourceDialect,
12467            >,
12468            offset: usize,
12469            _depth: fidl::encoding::Depth,
12470        ) -> fidl::Result<()> {
12471            decoder.debug_check_bounds::<Self>(offset);
12472            // Verify that padding bytes are zero.
12473            fidl::decode!(
12474                StartInfo,
12475                fidl::encoding::DefaultFuchsiaResourceDialect,
12476                &mut self.start_info,
12477                decoder,
12478                offset + 0,
12479                _depth
12480            )?;
12481            fidl::decode!(
12482                fidl_fuchsia_virtualization::BlockSpec,
12483                fidl::encoding::DefaultFuchsiaResourceDialect,
12484                &mut self.spec,
12485                decoder,
12486                offset + 32,
12487                _depth
12488            )?;
12489            Ok(())
12490        }
12491    }
12492
12493    impl fidl::encoding::ResourceTypeMarker for VirtioConsoleStartRequest {
12494        type Borrowed<'a> = &'a mut Self;
12495        fn take_or_borrow<'a>(
12496            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12497        ) -> Self::Borrowed<'a> {
12498            value
12499        }
12500    }
12501
12502    unsafe impl fidl::encoding::TypeMarker for VirtioConsoleStartRequest {
12503        type Owned = Self;
12504
12505        #[inline(always)]
12506        fn inline_align(_context: fidl::encoding::Context) -> usize {
12507            8
12508        }
12509
12510        #[inline(always)]
12511        fn inline_size(_context: fidl::encoding::Context) -> usize {
12512            40
12513        }
12514    }
12515
12516    unsafe impl
12517        fidl::encoding::Encode<
12518            VirtioConsoleStartRequest,
12519            fidl::encoding::DefaultFuchsiaResourceDialect,
12520        > for &mut VirtioConsoleStartRequest
12521    {
12522        #[inline]
12523        unsafe fn encode(
12524            self,
12525            encoder: &mut fidl::encoding::Encoder<
12526                '_,
12527                fidl::encoding::DefaultFuchsiaResourceDialect,
12528            >,
12529            offset: usize,
12530            _depth: fidl::encoding::Depth,
12531        ) -> fidl::Result<()> {
12532            encoder.debug_check_bounds::<VirtioConsoleStartRequest>(offset);
12533            // Delegate to tuple encoding.
12534            fidl::encoding::Encode::<
12535                VirtioConsoleStartRequest,
12536                fidl::encoding::DefaultFuchsiaResourceDialect,
12537            >::encode(
12538                (
12539                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12540                        &mut self.start_info,
12541                    ),
12542                    <fidl::encoding::HandleType<
12543                        fidl::Socket,
12544                        { fidl::ObjectType::SOCKET.into_raw() },
12545                        2147483648,
12546                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12547                        &mut self.socket
12548                    ),
12549                ),
12550                encoder,
12551                offset,
12552                _depth,
12553            )
12554        }
12555    }
12556    unsafe impl<
12557            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
12558            T1: fidl::encoding::Encode<
12559                fidl::encoding::HandleType<
12560                    fidl::Socket,
12561                    { fidl::ObjectType::SOCKET.into_raw() },
12562                    2147483648,
12563                >,
12564                fidl::encoding::DefaultFuchsiaResourceDialect,
12565            >,
12566        >
12567        fidl::encoding::Encode<
12568            VirtioConsoleStartRequest,
12569            fidl::encoding::DefaultFuchsiaResourceDialect,
12570        > for (T0, T1)
12571    {
12572        #[inline]
12573        unsafe fn encode(
12574            self,
12575            encoder: &mut fidl::encoding::Encoder<
12576                '_,
12577                fidl::encoding::DefaultFuchsiaResourceDialect,
12578            >,
12579            offset: usize,
12580            depth: fidl::encoding::Depth,
12581        ) -> fidl::Result<()> {
12582            encoder.debug_check_bounds::<VirtioConsoleStartRequest>(offset);
12583            // Zero out padding regions. There's no need to apply masks
12584            // because the unmasked parts will be overwritten by fields.
12585            unsafe {
12586                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
12587                (ptr as *mut u64).write_unaligned(0);
12588            }
12589            // Write the fields.
12590            self.0.encode(encoder, offset + 0, depth)?;
12591            self.1.encode(encoder, offset + 32, depth)?;
12592            Ok(())
12593        }
12594    }
12595
12596    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12597        for VirtioConsoleStartRequest
12598    {
12599        #[inline(always)]
12600        fn new_empty() -> Self {
12601            Self {
12602                start_info: fidl::new_empty!(
12603                    StartInfo,
12604                    fidl::encoding::DefaultFuchsiaResourceDialect
12605                ),
12606                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12607            }
12608        }
12609
12610        #[inline]
12611        unsafe fn decode(
12612            &mut self,
12613            decoder: &mut fidl::encoding::Decoder<
12614                '_,
12615                fidl::encoding::DefaultFuchsiaResourceDialect,
12616            >,
12617            offset: usize,
12618            _depth: fidl::encoding::Depth,
12619        ) -> fidl::Result<()> {
12620            decoder.debug_check_bounds::<Self>(offset);
12621            // Verify that padding bytes are zero.
12622            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
12623            let padval = unsafe { (ptr as *const u64).read_unaligned() };
12624            let mask = 0xffffffff00000000u64;
12625            let maskedval = padval & mask;
12626            if maskedval != 0 {
12627                return Err(fidl::Error::NonZeroPadding {
12628                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
12629                });
12630            }
12631            fidl::decode!(
12632                StartInfo,
12633                fidl::encoding::DefaultFuchsiaResourceDialect,
12634                &mut self.start_info,
12635                decoder,
12636                offset + 0,
12637                _depth
12638            )?;
12639            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 32, _depth)?;
12640            Ok(())
12641        }
12642    }
12643
12644    impl fidl::encoding::ResourceTypeMarker for VirtioGpuStartRequest {
12645        type Borrowed<'a> = &'a mut Self;
12646        fn take_or_borrow<'a>(
12647            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12648        ) -> Self::Borrowed<'a> {
12649            value
12650        }
12651    }
12652
12653    unsafe impl fidl::encoding::TypeMarker for VirtioGpuStartRequest {
12654        type Owned = Self;
12655
12656        #[inline(always)]
12657        fn inline_align(_context: fidl::encoding::Context) -> usize {
12658            8
12659        }
12660
12661        #[inline(always)]
12662        fn inline_size(_context: fidl::encoding::Context) -> usize {
12663            40
12664        }
12665    }
12666
12667    unsafe impl
12668        fidl::encoding::Encode<VirtioGpuStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
12669        for &mut VirtioGpuStartRequest
12670    {
12671        #[inline]
12672        unsafe fn encode(
12673            self,
12674            encoder: &mut fidl::encoding::Encoder<
12675                '_,
12676                fidl::encoding::DefaultFuchsiaResourceDialect,
12677            >,
12678            offset: usize,
12679            _depth: fidl::encoding::Depth,
12680        ) -> fidl::Result<()> {
12681            encoder.debug_check_bounds::<VirtioGpuStartRequest>(offset);
12682            // Delegate to tuple encoding.
12683            fidl::encoding::Encode::<
12684                VirtioGpuStartRequest,
12685                fidl::encoding::DefaultFuchsiaResourceDialect,
12686            >::encode(
12687                (
12688                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12689                        &mut self.start_info,
12690                    ),
12691                    <fidl::encoding::Optional<
12692                        fidl::encoding::Endpoint<
12693                            fidl::endpoints::ClientEnd<
12694                                fidl_fuchsia_ui_input3::KeyboardListenerMarker,
12695                            >,
12696                        >,
12697                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12698                        &mut self.keyboard_listener,
12699                    ),
12700                    <fidl::encoding::Optional<
12701                        fidl::encoding::Endpoint<
12702                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
12703                        >,
12704                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12705                        &mut self.mouse_source,
12706                    ),
12707                ),
12708                encoder,
12709                offset,
12710                _depth,
12711            )
12712        }
12713    }
12714    unsafe impl<
12715            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
12716            T1: fidl::encoding::Encode<
12717                fidl::encoding::Optional<
12718                    fidl::encoding::Endpoint<
12719                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
12720                    >,
12721                >,
12722                fidl::encoding::DefaultFuchsiaResourceDialect,
12723            >,
12724            T2: fidl::encoding::Encode<
12725                fidl::encoding::Optional<
12726                    fidl::encoding::Endpoint<
12727                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
12728                    >,
12729                >,
12730                fidl::encoding::DefaultFuchsiaResourceDialect,
12731            >,
12732        >
12733        fidl::encoding::Encode<VirtioGpuStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
12734        for (T0, T1, T2)
12735    {
12736        #[inline]
12737        unsafe fn encode(
12738            self,
12739            encoder: &mut fidl::encoding::Encoder<
12740                '_,
12741                fidl::encoding::DefaultFuchsiaResourceDialect,
12742            >,
12743            offset: usize,
12744            depth: fidl::encoding::Depth,
12745        ) -> fidl::Result<()> {
12746            encoder.debug_check_bounds::<VirtioGpuStartRequest>(offset);
12747            // Zero out padding regions. There's no need to apply masks
12748            // because the unmasked parts will be overwritten by fields.
12749            // Write the fields.
12750            self.0.encode(encoder, offset + 0, depth)?;
12751            self.1.encode(encoder, offset + 32, depth)?;
12752            self.2.encode(encoder, offset + 36, depth)?;
12753            Ok(())
12754        }
12755    }
12756
12757    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12758        for VirtioGpuStartRequest
12759    {
12760        #[inline(always)]
12761        fn new_empty() -> Self {
12762            Self {
12763                start_info: fidl::new_empty!(
12764                    StartInfo,
12765                    fidl::encoding::DefaultFuchsiaResourceDialect
12766                ),
12767                keyboard_listener: fidl::new_empty!(
12768                    fidl::encoding::Optional<
12769                        fidl::encoding::Endpoint<
12770                            fidl::endpoints::ClientEnd<
12771                                fidl_fuchsia_ui_input3::KeyboardListenerMarker,
12772                            >,
12773                        >,
12774                    >,
12775                    fidl::encoding::DefaultFuchsiaResourceDialect
12776                ),
12777                mouse_source: fidl::new_empty!(
12778                    fidl::encoding::Optional<
12779                        fidl::encoding::Endpoint<
12780                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
12781                        >,
12782                    >,
12783                    fidl::encoding::DefaultFuchsiaResourceDialect
12784                ),
12785            }
12786        }
12787
12788        #[inline]
12789        unsafe fn decode(
12790            &mut self,
12791            decoder: &mut fidl::encoding::Decoder<
12792                '_,
12793                fidl::encoding::DefaultFuchsiaResourceDialect,
12794            >,
12795            offset: usize,
12796            _depth: fidl::encoding::Depth,
12797        ) -> fidl::Result<()> {
12798            decoder.debug_check_bounds::<Self>(offset);
12799            // Verify that padding bytes are zero.
12800            fidl::decode!(
12801                StartInfo,
12802                fidl::encoding::DefaultFuchsiaResourceDialect,
12803                &mut self.start_info,
12804                decoder,
12805                offset + 0,
12806                _depth
12807            )?;
12808            fidl::decode!(
12809                fidl::encoding::Optional<
12810                    fidl::encoding::Endpoint<
12811                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
12812                    >,
12813                >,
12814                fidl::encoding::DefaultFuchsiaResourceDialect,
12815                &mut self.keyboard_listener,
12816                decoder,
12817                offset + 32,
12818                _depth
12819            )?;
12820            fidl::decode!(
12821                fidl::encoding::Optional<
12822                    fidl::encoding::Endpoint<
12823                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
12824                    >,
12825                >,
12826                fidl::encoding::DefaultFuchsiaResourceDialect,
12827                &mut self.mouse_source,
12828                decoder,
12829                offset + 36,
12830                _depth
12831            )?;
12832            Ok(())
12833        }
12834    }
12835
12836    impl fidl::encoding::ResourceTypeMarker for VirtioImage {
12837        type Borrowed<'a> = &'a mut Self;
12838        fn take_or_borrow<'a>(
12839            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12840        ) -> Self::Borrowed<'a> {
12841            value
12842        }
12843    }
12844
12845    unsafe impl fidl::encoding::TypeMarker for VirtioImage {
12846        type Owned = Self;
12847
12848        #[inline(always)]
12849        fn inline_align(_context: fidl::encoding::Context) -> usize {
12850            8
12851        }
12852
12853        #[inline(always)]
12854        fn inline_size(_context: fidl::encoding::Context) -> usize {
12855            24
12856        }
12857    }
12858
12859    unsafe impl fidl::encoding::Encode<VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect>
12860        for &mut VirtioImage
12861    {
12862        #[inline]
12863        unsafe fn encode(
12864            self,
12865            encoder: &mut fidl::encoding::Encoder<
12866                '_,
12867                fidl::encoding::DefaultFuchsiaResourceDialect,
12868            >,
12869            offset: usize,
12870            _depth: fidl::encoding::Depth,
12871        ) -> fidl::Result<()> {
12872            encoder.debug_check_bounds::<VirtioImage>(offset);
12873            // Delegate to tuple encoding.
12874            fidl::encoding::Encode::<VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12875                (
12876                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
12877                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
12878                    <fidl::encoding::Vector<u8, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.info),
12879                ),
12880                encoder, offset, _depth
12881            )
12882        }
12883    }
12884    unsafe impl<
12885            T0: fidl::encoding::Encode<
12886                fidl::encoding::HandleType<
12887                    fidl::Vmo,
12888                    { fidl::ObjectType::VMO.into_raw() },
12889                    2147483648,
12890                >,
12891                fidl::encoding::DefaultFuchsiaResourceDialect,
12892            >,
12893            T1: fidl::encoding::Encode<
12894                fidl::encoding::Optional<
12895                    fidl::encoding::HandleType<
12896                        fidl::EventPair,
12897                        { fidl::ObjectType::EVENTPAIR.into_raw() },
12898                        2147483648,
12899                    >,
12900                >,
12901                fidl::encoding::DefaultFuchsiaResourceDialect,
12902            >,
12903            T2: fidl::encoding::Encode<
12904                fidl::encoding::Vector<u8, 128>,
12905                fidl::encoding::DefaultFuchsiaResourceDialect,
12906            >,
12907        > fidl::encoding::Encode<VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect>
12908        for (T0, T1, T2)
12909    {
12910        #[inline]
12911        unsafe fn encode(
12912            self,
12913            encoder: &mut fidl::encoding::Encoder<
12914                '_,
12915                fidl::encoding::DefaultFuchsiaResourceDialect,
12916            >,
12917            offset: usize,
12918            depth: fidl::encoding::Depth,
12919        ) -> fidl::Result<()> {
12920            encoder.debug_check_bounds::<VirtioImage>(offset);
12921            // Zero out padding regions. There's no need to apply masks
12922            // because the unmasked parts will be overwritten by fields.
12923            // Write the fields.
12924            self.0.encode(encoder, offset + 0, depth)?;
12925            self.1.encode(encoder, offset + 4, depth)?;
12926            self.2.encode(encoder, offset + 8, depth)?;
12927            Ok(())
12928        }
12929    }
12930
12931    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioImage {
12932        #[inline(always)]
12933        fn new_empty() -> Self {
12934            Self {
12935                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12936                token: fidl::new_empty!(
12937                    fidl::encoding::Optional<
12938                        fidl::encoding::HandleType<
12939                            fidl::EventPair,
12940                            { fidl::ObjectType::EVENTPAIR.into_raw() },
12941                            2147483648,
12942                        >,
12943                    >,
12944                    fidl::encoding::DefaultFuchsiaResourceDialect
12945                ),
12946                info: fidl::new_empty!(fidl::encoding::Vector<u8, 128>, fidl::encoding::DefaultFuchsiaResourceDialect),
12947            }
12948        }
12949
12950        #[inline]
12951        unsafe fn decode(
12952            &mut self,
12953            decoder: &mut fidl::encoding::Decoder<
12954                '_,
12955                fidl::encoding::DefaultFuchsiaResourceDialect,
12956            >,
12957            offset: usize,
12958            _depth: fidl::encoding::Depth,
12959        ) -> fidl::Result<()> {
12960            decoder.debug_check_bounds::<Self>(offset);
12961            // Verify that padding bytes are zero.
12962            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
12963            fidl::decode!(
12964                fidl::encoding::Optional<
12965                    fidl::encoding::HandleType<
12966                        fidl::EventPair,
12967                        { fidl::ObjectType::EVENTPAIR.into_raw() },
12968                        2147483648,
12969                    >,
12970                >,
12971                fidl::encoding::DefaultFuchsiaResourceDialect,
12972                &mut self.token,
12973                decoder,
12974                offset + 4,
12975                _depth
12976            )?;
12977            fidl::decode!(fidl::encoding::Vector<u8, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.info, decoder, offset + 8, _depth)?;
12978            Ok(())
12979        }
12980    }
12981
12982    impl fidl::encoding::ResourceTypeMarker for VirtioInputStartRequest {
12983        type Borrowed<'a> = &'a mut Self;
12984        fn take_or_borrow<'a>(
12985            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12986        ) -> Self::Borrowed<'a> {
12987            value
12988        }
12989    }
12990
12991    unsafe impl fidl::encoding::TypeMarker for VirtioInputStartRequest {
12992        type Owned = Self;
12993
12994        #[inline(always)]
12995        fn inline_align(_context: fidl::encoding::Context) -> usize {
12996            8
12997        }
12998
12999        #[inline(always)]
13000        fn inline_size(_context: fidl::encoding::Context) -> usize {
13001            48
13002        }
13003    }
13004
13005    unsafe impl
13006        fidl::encoding::Encode<
13007            VirtioInputStartRequest,
13008            fidl::encoding::DefaultFuchsiaResourceDialect,
13009        > for &mut VirtioInputStartRequest
13010    {
13011        #[inline]
13012        unsafe fn encode(
13013            self,
13014            encoder: &mut fidl::encoding::Encoder<
13015                '_,
13016                fidl::encoding::DefaultFuchsiaResourceDialect,
13017            >,
13018            offset: usize,
13019            _depth: fidl::encoding::Depth,
13020        ) -> fidl::Result<()> {
13021            encoder.debug_check_bounds::<VirtioInputStartRequest>(offset);
13022            // Delegate to tuple encoding.
13023            fidl::encoding::Encode::<
13024                VirtioInputStartRequest,
13025                fidl::encoding::DefaultFuchsiaResourceDialect,
13026            >::encode(
13027                (
13028                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13029                        &mut self.start_info,
13030                    ),
13031                    <InputType as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13032                        &mut self.input_type,
13033                    ),
13034                ),
13035                encoder,
13036                offset,
13037                _depth,
13038            )
13039        }
13040    }
13041    unsafe impl<
13042            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13043            T1: fidl::encoding::Encode<InputType, fidl::encoding::DefaultFuchsiaResourceDialect>,
13044        >
13045        fidl::encoding::Encode<
13046            VirtioInputStartRequest,
13047            fidl::encoding::DefaultFuchsiaResourceDialect,
13048        > for (T0, T1)
13049    {
13050        #[inline]
13051        unsafe fn encode(
13052            self,
13053            encoder: &mut fidl::encoding::Encoder<
13054                '_,
13055                fidl::encoding::DefaultFuchsiaResourceDialect,
13056            >,
13057            offset: usize,
13058            depth: fidl::encoding::Depth,
13059        ) -> fidl::Result<()> {
13060            encoder.debug_check_bounds::<VirtioInputStartRequest>(offset);
13061            // Zero out padding regions. There's no need to apply masks
13062            // because the unmasked parts will be overwritten by fields.
13063            // Write the fields.
13064            self.0.encode(encoder, offset + 0, depth)?;
13065            self.1.encode(encoder, offset + 32, depth)?;
13066            Ok(())
13067        }
13068    }
13069
13070    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13071        for VirtioInputStartRequest
13072    {
13073        #[inline(always)]
13074        fn new_empty() -> Self {
13075            Self {
13076                start_info: fidl::new_empty!(
13077                    StartInfo,
13078                    fidl::encoding::DefaultFuchsiaResourceDialect
13079                ),
13080                input_type: fidl::new_empty!(
13081                    InputType,
13082                    fidl::encoding::DefaultFuchsiaResourceDialect
13083                ),
13084            }
13085        }
13086
13087        #[inline]
13088        unsafe fn decode(
13089            &mut self,
13090            decoder: &mut fidl::encoding::Decoder<
13091                '_,
13092                fidl::encoding::DefaultFuchsiaResourceDialect,
13093            >,
13094            offset: usize,
13095            _depth: fidl::encoding::Depth,
13096        ) -> fidl::Result<()> {
13097            decoder.debug_check_bounds::<Self>(offset);
13098            // Verify that padding bytes are zero.
13099            fidl::decode!(
13100                StartInfo,
13101                fidl::encoding::DefaultFuchsiaResourceDialect,
13102                &mut self.start_info,
13103                decoder,
13104                offset + 0,
13105                _depth
13106            )?;
13107            fidl::decode!(
13108                InputType,
13109                fidl::encoding::DefaultFuchsiaResourceDialect,
13110                &mut self.input_type,
13111                decoder,
13112                offset + 32,
13113                _depth
13114            )?;
13115            Ok(())
13116        }
13117    }
13118
13119    impl fidl::encoding::ResourceTypeMarker for VirtioMagmaStartRequest {
13120        type Borrowed<'a> = &'a mut Self;
13121        fn take_or_borrow<'a>(
13122            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13123        ) -> Self::Borrowed<'a> {
13124            value
13125        }
13126    }
13127
13128    unsafe impl fidl::encoding::TypeMarker for VirtioMagmaStartRequest {
13129        type Owned = Self;
13130
13131        #[inline(always)]
13132        fn inline_align(_context: fidl::encoding::Context) -> usize {
13133            8
13134        }
13135
13136        #[inline(always)]
13137        fn inline_size(_context: fidl::encoding::Context) -> usize {
13138            40
13139        }
13140    }
13141
13142    unsafe impl
13143        fidl::encoding::Encode<
13144            VirtioMagmaStartRequest,
13145            fidl::encoding::DefaultFuchsiaResourceDialect,
13146        > for &mut VirtioMagmaStartRequest
13147    {
13148        #[inline]
13149        unsafe fn encode(
13150            self,
13151            encoder: &mut fidl::encoding::Encoder<
13152                '_,
13153                fidl::encoding::DefaultFuchsiaResourceDialect,
13154            >,
13155            offset: usize,
13156            _depth: fidl::encoding::Depth,
13157        ) -> fidl::Result<()> {
13158            encoder.debug_check_bounds::<VirtioMagmaStartRequest>(offset);
13159            // Delegate to tuple encoding.
13160            fidl::encoding::Encode::<
13161                VirtioMagmaStartRequest,
13162                fidl::encoding::DefaultFuchsiaResourceDialect,
13163            >::encode(
13164                (
13165                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13166                        &mut self.start_info,
13167                    ),
13168                    <fidl::encoding::HandleType<
13169                        fidl::Vmar,
13170                        { fidl::ObjectType::VMAR.into_raw() },
13171                        2147483648,
13172                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13173                        &mut self.vmar
13174                    ),
13175                    <fidl::encoding::Optional<
13176                        fidl::encoding::Endpoint<
13177                            fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>,
13178                        >,
13179                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13180                        &mut self.wayland_importer,
13181                    ),
13182                ),
13183                encoder,
13184                offset,
13185                _depth,
13186            )
13187        }
13188    }
13189    unsafe impl<
13190            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13191            T1: fidl::encoding::Encode<
13192                fidl::encoding::HandleType<
13193                    fidl::Vmar,
13194                    { fidl::ObjectType::VMAR.into_raw() },
13195                    2147483648,
13196                >,
13197                fidl::encoding::DefaultFuchsiaResourceDialect,
13198            >,
13199            T2: fidl::encoding::Encode<
13200                fidl::encoding::Optional<
13201                    fidl::encoding::Endpoint<
13202                        fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>,
13203                    >,
13204                >,
13205                fidl::encoding::DefaultFuchsiaResourceDialect,
13206            >,
13207        >
13208        fidl::encoding::Encode<
13209            VirtioMagmaStartRequest,
13210            fidl::encoding::DefaultFuchsiaResourceDialect,
13211        > for (T0, T1, T2)
13212    {
13213        #[inline]
13214        unsafe fn encode(
13215            self,
13216            encoder: &mut fidl::encoding::Encoder<
13217                '_,
13218                fidl::encoding::DefaultFuchsiaResourceDialect,
13219            >,
13220            offset: usize,
13221            depth: fidl::encoding::Depth,
13222        ) -> fidl::Result<()> {
13223            encoder.debug_check_bounds::<VirtioMagmaStartRequest>(offset);
13224            // Zero out padding regions. There's no need to apply masks
13225            // because the unmasked parts will be overwritten by fields.
13226            // Write the fields.
13227            self.0.encode(encoder, offset + 0, depth)?;
13228            self.1.encode(encoder, offset + 32, depth)?;
13229            self.2.encode(encoder, offset + 36, depth)?;
13230            Ok(())
13231        }
13232    }
13233
13234    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13235        for VirtioMagmaStartRequest
13236    {
13237        #[inline(always)]
13238        fn new_empty() -> Self {
13239            Self {
13240                start_info: fidl::new_empty!(
13241                    StartInfo,
13242                    fidl::encoding::DefaultFuchsiaResourceDialect
13243                ),
13244                vmar: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
13245                wayland_importer: fidl::new_empty!(
13246                    fidl::encoding::Optional<
13247                        fidl::encoding::Endpoint<
13248                            fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>,
13249                        >,
13250                    >,
13251                    fidl::encoding::DefaultFuchsiaResourceDialect
13252                ),
13253            }
13254        }
13255
13256        #[inline]
13257        unsafe fn decode(
13258            &mut self,
13259            decoder: &mut fidl::encoding::Decoder<
13260                '_,
13261                fidl::encoding::DefaultFuchsiaResourceDialect,
13262            >,
13263            offset: usize,
13264            _depth: fidl::encoding::Depth,
13265        ) -> fidl::Result<()> {
13266            decoder.debug_check_bounds::<Self>(offset);
13267            // Verify that padding bytes are zero.
13268            fidl::decode!(
13269                StartInfo,
13270                fidl::encoding::DefaultFuchsiaResourceDialect,
13271                &mut self.start_info,
13272                decoder,
13273                offset + 0,
13274                _depth
13275            )?;
13276            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar, decoder, offset + 32, _depth)?;
13277            fidl::decode!(
13278                fidl::encoding::Optional<
13279                    fidl::encoding::Endpoint<
13280                        fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>,
13281                    >,
13282                >,
13283                fidl::encoding::DefaultFuchsiaResourceDialect,
13284                &mut self.wayland_importer,
13285                decoder,
13286                offset + 36,
13287                _depth
13288            )?;
13289            Ok(())
13290        }
13291    }
13292
13293    impl fidl::encoding::ResourceTypeMarker for VirtioMemStartRequest {
13294        type Borrowed<'a> = &'a mut Self;
13295        fn take_or_borrow<'a>(
13296            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13297        ) -> Self::Borrowed<'a> {
13298            value
13299        }
13300    }
13301
13302    unsafe impl fidl::encoding::TypeMarker for VirtioMemStartRequest {
13303        type Owned = Self;
13304
13305        #[inline(always)]
13306        fn inline_align(_context: fidl::encoding::Context) -> usize {
13307            8
13308        }
13309
13310        #[inline(always)]
13311        fn inline_size(_context: fidl::encoding::Context) -> usize {
13312            56
13313        }
13314    }
13315
13316    unsafe impl
13317        fidl::encoding::Encode<VirtioMemStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13318        for &mut VirtioMemStartRequest
13319    {
13320        #[inline]
13321        unsafe fn encode(
13322            self,
13323            encoder: &mut fidl::encoding::Encoder<
13324                '_,
13325                fidl::encoding::DefaultFuchsiaResourceDialect,
13326            >,
13327            offset: usize,
13328            _depth: fidl::encoding::Depth,
13329        ) -> fidl::Result<()> {
13330            encoder.debug_check_bounds::<VirtioMemStartRequest>(offset);
13331            // Delegate to tuple encoding.
13332            fidl::encoding::Encode::<
13333                VirtioMemStartRequest,
13334                fidl::encoding::DefaultFuchsiaResourceDialect,
13335            >::encode(
13336                (
13337                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13338                        &mut self.start_info,
13339                    ),
13340                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.region_addr),
13341                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.plugged_block_size),
13342                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.region_size),
13343                ),
13344                encoder,
13345                offset,
13346                _depth,
13347            )
13348        }
13349    }
13350    unsafe impl<
13351            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13352            T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
13353            T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
13354            T3: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
13355        >
13356        fidl::encoding::Encode<VirtioMemStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13357        for (T0, T1, T2, T3)
13358    {
13359        #[inline]
13360        unsafe fn encode(
13361            self,
13362            encoder: &mut fidl::encoding::Encoder<
13363                '_,
13364                fidl::encoding::DefaultFuchsiaResourceDialect,
13365            >,
13366            offset: usize,
13367            depth: fidl::encoding::Depth,
13368        ) -> fidl::Result<()> {
13369            encoder.debug_check_bounds::<VirtioMemStartRequest>(offset);
13370            // Zero out padding regions. There's no need to apply masks
13371            // because the unmasked parts will be overwritten by fields.
13372            // Write the fields.
13373            self.0.encode(encoder, offset + 0, depth)?;
13374            self.1.encode(encoder, offset + 32, depth)?;
13375            self.2.encode(encoder, offset + 40, depth)?;
13376            self.3.encode(encoder, offset + 48, depth)?;
13377            Ok(())
13378        }
13379    }
13380
13381    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13382        for VirtioMemStartRequest
13383    {
13384        #[inline(always)]
13385        fn new_empty() -> Self {
13386            Self {
13387                start_info: fidl::new_empty!(
13388                    StartInfo,
13389                    fidl::encoding::DefaultFuchsiaResourceDialect
13390                ),
13391                region_addr: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
13392                plugged_block_size: fidl::new_empty!(
13393                    u64,
13394                    fidl::encoding::DefaultFuchsiaResourceDialect
13395                ),
13396                region_size: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
13397            }
13398        }
13399
13400        #[inline]
13401        unsafe fn decode(
13402            &mut self,
13403            decoder: &mut fidl::encoding::Decoder<
13404                '_,
13405                fidl::encoding::DefaultFuchsiaResourceDialect,
13406            >,
13407            offset: usize,
13408            _depth: fidl::encoding::Depth,
13409        ) -> fidl::Result<()> {
13410            decoder.debug_check_bounds::<Self>(offset);
13411            // Verify that padding bytes are zero.
13412            fidl::decode!(
13413                StartInfo,
13414                fidl::encoding::DefaultFuchsiaResourceDialect,
13415                &mut self.start_info,
13416                decoder,
13417                offset + 0,
13418                _depth
13419            )?;
13420            fidl::decode!(
13421                u64,
13422                fidl::encoding::DefaultFuchsiaResourceDialect,
13423                &mut self.region_addr,
13424                decoder,
13425                offset + 32,
13426                _depth
13427            )?;
13428            fidl::decode!(
13429                u64,
13430                fidl::encoding::DefaultFuchsiaResourceDialect,
13431                &mut self.plugged_block_size,
13432                decoder,
13433                offset + 40,
13434                _depth
13435            )?;
13436            fidl::decode!(
13437                u64,
13438                fidl::encoding::DefaultFuchsiaResourceDialect,
13439                &mut self.region_size,
13440                decoder,
13441                offset + 48,
13442                _depth
13443            )?;
13444            Ok(())
13445        }
13446    }
13447
13448    impl fidl::encoding::ResourceTypeMarker for VirtioNetStartRequest {
13449        type Borrowed<'a> = &'a mut Self;
13450        fn take_or_borrow<'a>(
13451            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13452        ) -> Self::Borrowed<'a> {
13453            value
13454        }
13455    }
13456
13457    unsafe impl fidl::encoding::TypeMarker for VirtioNetStartRequest {
13458        type Owned = Self;
13459
13460        #[inline(always)]
13461        fn inline_align(_context: fidl::encoding::Context) -> usize {
13462            8
13463        }
13464
13465        #[inline(always)]
13466        fn inline_size(_context: fidl::encoding::Context) -> usize {
13467            40
13468        }
13469    }
13470
13471    unsafe impl
13472        fidl::encoding::Encode<VirtioNetStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13473        for &mut VirtioNetStartRequest
13474    {
13475        #[inline]
13476        unsafe fn encode(
13477            self,
13478            encoder: &mut fidl::encoding::Encoder<
13479                '_,
13480                fidl::encoding::DefaultFuchsiaResourceDialect,
13481            >,
13482            offset: usize,
13483            _depth: fidl::encoding::Depth,
13484        ) -> fidl::Result<()> {
13485            encoder.debug_check_bounds::<VirtioNetStartRequest>(offset);
13486            // Delegate to tuple encoding.
13487            fidl::encoding::Encode::<
13488                VirtioNetStartRequest,
13489                fidl::encoding::DefaultFuchsiaResourceDialect,
13490            >::encode(
13491                (
13492                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13493                        &mut self.start_info,
13494                    ),
13495                    <fidl_fuchsia_net::MacAddress as fidl::encoding::ValueTypeMarker>::borrow(
13496                        &self.mac_address,
13497                    ),
13498                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_bridge),
13499                ),
13500                encoder,
13501                offset,
13502                _depth,
13503            )
13504        }
13505    }
13506    unsafe impl<
13507            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13508            T1: fidl::encoding::Encode<
13509                fidl_fuchsia_net::MacAddress,
13510                fidl::encoding::DefaultFuchsiaResourceDialect,
13511            >,
13512            T2: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
13513        >
13514        fidl::encoding::Encode<VirtioNetStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13515        for (T0, T1, T2)
13516    {
13517        #[inline]
13518        unsafe fn encode(
13519            self,
13520            encoder: &mut fidl::encoding::Encoder<
13521                '_,
13522                fidl::encoding::DefaultFuchsiaResourceDialect,
13523            >,
13524            offset: usize,
13525            depth: fidl::encoding::Depth,
13526        ) -> fidl::Result<()> {
13527            encoder.debug_check_bounds::<VirtioNetStartRequest>(offset);
13528            // Zero out padding regions. There's no need to apply masks
13529            // because the unmasked parts will be overwritten by fields.
13530            unsafe {
13531                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
13532                (ptr as *mut u64).write_unaligned(0);
13533            }
13534            // Write the fields.
13535            self.0.encode(encoder, offset + 0, depth)?;
13536            self.1.encode(encoder, offset + 32, depth)?;
13537            self.2.encode(encoder, offset + 38, depth)?;
13538            Ok(())
13539        }
13540    }
13541
13542    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13543        for VirtioNetStartRequest
13544    {
13545        #[inline(always)]
13546        fn new_empty() -> Self {
13547            Self {
13548                start_info: fidl::new_empty!(
13549                    StartInfo,
13550                    fidl::encoding::DefaultFuchsiaResourceDialect
13551                ),
13552                mac_address: fidl::new_empty!(
13553                    fidl_fuchsia_net::MacAddress,
13554                    fidl::encoding::DefaultFuchsiaResourceDialect
13555                ),
13556                enable_bridge: fidl::new_empty!(
13557                    bool,
13558                    fidl::encoding::DefaultFuchsiaResourceDialect
13559                ),
13560            }
13561        }
13562
13563        #[inline]
13564        unsafe fn decode(
13565            &mut self,
13566            decoder: &mut fidl::encoding::Decoder<
13567                '_,
13568                fidl::encoding::DefaultFuchsiaResourceDialect,
13569            >,
13570            offset: usize,
13571            _depth: fidl::encoding::Depth,
13572        ) -> fidl::Result<()> {
13573            decoder.debug_check_bounds::<Self>(offset);
13574            // Verify that padding bytes are zero.
13575            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
13576            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13577            let mask = 0xff00000000000000u64;
13578            let maskedval = padval & mask;
13579            if maskedval != 0 {
13580                return Err(fidl::Error::NonZeroPadding {
13581                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
13582                });
13583            }
13584            fidl::decode!(
13585                StartInfo,
13586                fidl::encoding::DefaultFuchsiaResourceDialect,
13587                &mut self.start_info,
13588                decoder,
13589                offset + 0,
13590                _depth
13591            )?;
13592            fidl::decode!(
13593                fidl_fuchsia_net::MacAddress,
13594                fidl::encoding::DefaultFuchsiaResourceDialect,
13595                &mut self.mac_address,
13596                decoder,
13597                offset + 32,
13598                _depth
13599            )?;
13600            fidl::decode!(
13601                bool,
13602                fidl::encoding::DefaultFuchsiaResourceDialect,
13603                &mut self.enable_bridge,
13604                decoder,
13605                offset + 38,
13606                _depth
13607            )?;
13608            Ok(())
13609        }
13610    }
13611
13612    impl fidl::encoding::ResourceTypeMarker for VirtioRngStartRequest {
13613        type Borrowed<'a> = &'a mut Self;
13614        fn take_or_borrow<'a>(
13615            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13616        ) -> Self::Borrowed<'a> {
13617            value
13618        }
13619    }
13620
13621    unsafe impl fidl::encoding::TypeMarker for VirtioRngStartRequest {
13622        type Owned = Self;
13623
13624        #[inline(always)]
13625        fn inline_align(_context: fidl::encoding::Context) -> usize {
13626            8
13627        }
13628
13629        #[inline(always)]
13630        fn inline_size(_context: fidl::encoding::Context) -> usize {
13631            32
13632        }
13633    }
13634
13635    unsafe impl
13636        fidl::encoding::Encode<VirtioRngStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13637        for &mut VirtioRngStartRequest
13638    {
13639        #[inline]
13640        unsafe fn encode(
13641            self,
13642            encoder: &mut fidl::encoding::Encoder<
13643                '_,
13644                fidl::encoding::DefaultFuchsiaResourceDialect,
13645            >,
13646            offset: usize,
13647            _depth: fidl::encoding::Depth,
13648        ) -> fidl::Result<()> {
13649            encoder.debug_check_bounds::<VirtioRngStartRequest>(offset);
13650            // Delegate to tuple encoding.
13651            fidl::encoding::Encode::<
13652                VirtioRngStartRequest,
13653                fidl::encoding::DefaultFuchsiaResourceDialect,
13654            >::encode(
13655                (<StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13656                    &mut self.start_info,
13657                ),),
13658                encoder,
13659                offset,
13660                _depth,
13661            )
13662        }
13663    }
13664    unsafe impl<T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>>
13665        fidl::encoding::Encode<VirtioRngStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13666        for (T0,)
13667    {
13668        #[inline]
13669        unsafe fn encode(
13670            self,
13671            encoder: &mut fidl::encoding::Encoder<
13672                '_,
13673                fidl::encoding::DefaultFuchsiaResourceDialect,
13674            >,
13675            offset: usize,
13676            depth: fidl::encoding::Depth,
13677        ) -> fidl::Result<()> {
13678            encoder.debug_check_bounds::<VirtioRngStartRequest>(offset);
13679            // Zero out padding regions. There's no need to apply masks
13680            // because the unmasked parts will be overwritten by fields.
13681            // Write the fields.
13682            self.0.encode(encoder, offset + 0, depth)?;
13683            Ok(())
13684        }
13685    }
13686
13687    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13688        for VirtioRngStartRequest
13689    {
13690        #[inline(always)]
13691        fn new_empty() -> Self {
13692            Self {
13693                start_info: fidl::new_empty!(
13694                    StartInfo,
13695                    fidl::encoding::DefaultFuchsiaResourceDialect
13696                ),
13697            }
13698        }
13699
13700        #[inline]
13701        unsafe fn decode(
13702            &mut self,
13703            decoder: &mut fidl::encoding::Decoder<
13704                '_,
13705                fidl::encoding::DefaultFuchsiaResourceDialect,
13706            >,
13707            offset: usize,
13708            _depth: fidl::encoding::Depth,
13709        ) -> fidl::Result<()> {
13710            decoder.debug_check_bounds::<Self>(offset);
13711            // Verify that padding bytes are zero.
13712            fidl::decode!(
13713                StartInfo,
13714                fidl::encoding::DefaultFuchsiaResourceDialect,
13715                &mut self.start_info,
13716                decoder,
13717                offset + 0,
13718                _depth
13719            )?;
13720            Ok(())
13721        }
13722    }
13723
13724    impl fidl::encoding::ResourceTypeMarker for VirtioSoundStartRequest {
13725        type Borrowed<'a> = &'a mut Self;
13726        fn take_or_borrow<'a>(
13727            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13728        ) -> Self::Borrowed<'a> {
13729            value
13730        }
13731    }
13732
13733    unsafe impl fidl::encoding::TypeMarker for VirtioSoundStartRequest {
13734        type Owned = Self;
13735
13736        #[inline(always)]
13737        fn inline_align(_context: fidl::encoding::Context) -> usize {
13738            8
13739        }
13740
13741        #[inline(always)]
13742        fn inline_size(_context: fidl::encoding::Context) -> usize {
13743            40
13744        }
13745    }
13746
13747    unsafe impl
13748        fidl::encoding::Encode<
13749            VirtioSoundStartRequest,
13750            fidl::encoding::DefaultFuchsiaResourceDialect,
13751        > for &mut VirtioSoundStartRequest
13752    {
13753        #[inline]
13754        unsafe fn encode(
13755            self,
13756            encoder: &mut fidl::encoding::Encoder<
13757                '_,
13758                fidl::encoding::DefaultFuchsiaResourceDialect,
13759            >,
13760            offset: usize,
13761            _depth: fidl::encoding::Depth,
13762        ) -> fidl::Result<()> {
13763            encoder.debug_check_bounds::<VirtioSoundStartRequest>(offset);
13764            // Delegate to tuple encoding.
13765            fidl::encoding::Encode::<
13766                VirtioSoundStartRequest,
13767                fidl::encoding::DefaultFuchsiaResourceDialect,
13768            >::encode(
13769                (
13770                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13771                        &mut self.start_info,
13772                    ),
13773                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_input),
13774                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_verbose_logging),
13775                ),
13776                encoder,
13777                offset,
13778                _depth,
13779            )
13780        }
13781    }
13782    unsafe impl<
13783            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13784            T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
13785            T2: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
13786        >
13787        fidl::encoding::Encode<
13788            VirtioSoundStartRequest,
13789            fidl::encoding::DefaultFuchsiaResourceDialect,
13790        > for (T0, T1, T2)
13791    {
13792        #[inline]
13793        unsafe fn encode(
13794            self,
13795            encoder: &mut fidl::encoding::Encoder<
13796                '_,
13797                fidl::encoding::DefaultFuchsiaResourceDialect,
13798            >,
13799            offset: usize,
13800            depth: fidl::encoding::Depth,
13801        ) -> fidl::Result<()> {
13802            encoder.debug_check_bounds::<VirtioSoundStartRequest>(offset);
13803            // Zero out padding regions. There's no need to apply masks
13804            // because the unmasked parts will be overwritten by fields.
13805            unsafe {
13806                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
13807                (ptr as *mut u64).write_unaligned(0);
13808            }
13809            // Write the fields.
13810            self.0.encode(encoder, offset + 0, depth)?;
13811            self.1.encode(encoder, offset + 32, depth)?;
13812            self.2.encode(encoder, offset + 33, depth)?;
13813            Ok(())
13814        }
13815    }
13816
13817    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13818        for VirtioSoundStartRequest
13819    {
13820        #[inline(always)]
13821        fn new_empty() -> Self {
13822            Self {
13823                start_info: fidl::new_empty!(
13824                    StartInfo,
13825                    fidl::encoding::DefaultFuchsiaResourceDialect
13826                ),
13827                enable_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
13828                enable_verbose_logging: fidl::new_empty!(
13829                    bool,
13830                    fidl::encoding::DefaultFuchsiaResourceDialect
13831                ),
13832            }
13833        }
13834
13835        #[inline]
13836        unsafe fn decode(
13837            &mut self,
13838            decoder: &mut fidl::encoding::Decoder<
13839                '_,
13840                fidl::encoding::DefaultFuchsiaResourceDialect,
13841            >,
13842            offset: usize,
13843            _depth: fidl::encoding::Depth,
13844        ) -> fidl::Result<()> {
13845            decoder.debug_check_bounds::<Self>(offset);
13846            // Verify that padding bytes are zero.
13847            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
13848            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13849            let mask = 0xffffffffffff0000u64;
13850            let maskedval = padval & mask;
13851            if maskedval != 0 {
13852                return Err(fidl::Error::NonZeroPadding {
13853                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
13854                });
13855            }
13856            fidl::decode!(
13857                StartInfo,
13858                fidl::encoding::DefaultFuchsiaResourceDialect,
13859                &mut self.start_info,
13860                decoder,
13861                offset + 0,
13862                _depth
13863            )?;
13864            fidl::decode!(
13865                bool,
13866                fidl::encoding::DefaultFuchsiaResourceDialect,
13867                &mut self.enable_input,
13868                decoder,
13869                offset + 32,
13870                _depth
13871            )?;
13872            fidl::decode!(
13873                bool,
13874                fidl::encoding::DefaultFuchsiaResourceDialect,
13875                &mut self.enable_verbose_logging,
13876                decoder,
13877                offset + 33,
13878                _depth
13879            )?;
13880            Ok(())
13881        }
13882    }
13883
13884    impl fidl::encoding::ResourceTypeMarker for VirtioVsockStartRequest {
13885        type Borrowed<'a> = &'a mut Self;
13886        fn take_or_borrow<'a>(
13887            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13888        ) -> Self::Borrowed<'a> {
13889            value
13890        }
13891    }
13892
13893    unsafe impl fidl::encoding::TypeMarker for VirtioVsockStartRequest {
13894        type Owned = Self;
13895
13896        #[inline(always)]
13897        fn inline_align(_context: fidl::encoding::Context) -> usize {
13898            8
13899        }
13900
13901        #[inline(always)]
13902        fn inline_size(_context: fidl::encoding::Context) -> usize {
13903            56
13904        }
13905    }
13906
13907    unsafe impl
13908        fidl::encoding::Encode<
13909            VirtioVsockStartRequest,
13910            fidl::encoding::DefaultFuchsiaResourceDialect,
13911        > for &mut VirtioVsockStartRequest
13912    {
13913        #[inline]
13914        unsafe fn encode(
13915            self,
13916            encoder: &mut fidl::encoding::Encoder<
13917                '_,
13918                fidl::encoding::DefaultFuchsiaResourceDialect,
13919            >,
13920            offset: usize,
13921            _depth: fidl::encoding::Depth,
13922        ) -> fidl::Result<()> {
13923            encoder.debug_check_bounds::<VirtioVsockStartRequest>(offset);
13924            // Delegate to tuple encoding.
13925            fidl::encoding::Encode::<VirtioVsockStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
13926                (
13927                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.start_info),
13928                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.guest_cid),
13929                    <fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listeners),
13930                ),
13931                encoder, offset, _depth
13932            )
13933        }
13934    }
13935    unsafe impl<
13936            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13937            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13938            T2: fidl::encoding::Encode<
13939                fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener>,
13940                fidl::encoding::DefaultFuchsiaResourceDialect,
13941            >,
13942        >
13943        fidl::encoding::Encode<
13944            VirtioVsockStartRequest,
13945            fidl::encoding::DefaultFuchsiaResourceDialect,
13946        > for (T0, T1, T2)
13947    {
13948        #[inline]
13949        unsafe fn encode(
13950            self,
13951            encoder: &mut fidl::encoding::Encoder<
13952                '_,
13953                fidl::encoding::DefaultFuchsiaResourceDialect,
13954            >,
13955            offset: usize,
13956            depth: fidl::encoding::Depth,
13957        ) -> fidl::Result<()> {
13958            encoder.debug_check_bounds::<VirtioVsockStartRequest>(offset);
13959            // Zero out padding regions. There's no need to apply masks
13960            // because the unmasked parts will be overwritten by fields.
13961            unsafe {
13962                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
13963                (ptr as *mut u64).write_unaligned(0);
13964            }
13965            // Write the fields.
13966            self.0.encode(encoder, offset + 0, depth)?;
13967            self.1.encode(encoder, offset + 32, depth)?;
13968            self.2.encode(encoder, offset + 40, depth)?;
13969            Ok(())
13970        }
13971    }
13972
13973    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13974        for VirtioVsockStartRequest
13975    {
13976        #[inline(always)]
13977        fn new_empty() -> Self {
13978            Self {
13979                start_info: fidl::new_empty!(
13980                    StartInfo,
13981                    fidl::encoding::DefaultFuchsiaResourceDialect
13982                ),
13983                guest_cid: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
13984                listeners: fidl::new_empty!(
13985                    fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener>,
13986                    fidl::encoding::DefaultFuchsiaResourceDialect
13987                ),
13988            }
13989        }
13990
13991        #[inline]
13992        unsafe fn decode(
13993            &mut self,
13994            decoder: &mut fidl::encoding::Decoder<
13995                '_,
13996                fidl::encoding::DefaultFuchsiaResourceDialect,
13997            >,
13998            offset: usize,
13999            _depth: fidl::encoding::Depth,
14000        ) -> fidl::Result<()> {
14001            decoder.debug_check_bounds::<Self>(offset);
14002            // Verify that padding bytes are zero.
14003            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
14004            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14005            let mask = 0xffffffff00000000u64;
14006            let maskedval = padval & mask;
14007            if maskedval != 0 {
14008                return Err(fidl::Error::NonZeroPadding {
14009                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
14010                });
14011            }
14012            fidl::decode!(
14013                StartInfo,
14014                fidl::encoding::DefaultFuchsiaResourceDialect,
14015                &mut self.start_info,
14016                decoder,
14017                offset + 0,
14018                _depth
14019            )?;
14020            fidl::decode!(
14021                u32,
14022                fidl::encoding::DefaultFuchsiaResourceDialect,
14023                &mut self.guest_cid,
14024                decoder,
14025                offset + 32,
14026                _depth
14027            )?;
14028            fidl::decode!(
14029                fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener>,
14030                fidl::encoding::DefaultFuchsiaResourceDialect,
14031                &mut self.listeners,
14032                decoder,
14033                offset + 40,
14034                _depth
14035            )?;
14036            Ok(())
14037        }
14038    }
14039
14040    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandGetImporterRequest {
14041        type Borrowed<'a> = &'a mut Self;
14042        fn take_or_borrow<'a>(
14043            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14044        ) -> Self::Borrowed<'a> {
14045            value
14046        }
14047    }
14048
14049    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandGetImporterRequest {
14050        type Owned = Self;
14051
14052        #[inline(always)]
14053        fn inline_align(_context: fidl::encoding::Context) -> usize {
14054            4
14055        }
14056
14057        #[inline(always)]
14058        fn inline_size(_context: fidl::encoding::Context) -> usize {
14059            4
14060        }
14061    }
14062
14063    unsafe impl
14064        fidl::encoding::Encode<
14065            VirtioWaylandGetImporterRequest,
14066            fidl::encoding::DefaultFuchsiaResourceDialect,
14067        > for &mut VirtioWaylandGetImporterRequest
14068    {
14069        #[inline]
14070        unsafe fn encode(
14071            self,
14072            encoder: &mut fidl::encoding::Encoder<
14073                '_,
14074                fidl::encoding::DefaultFuchsiaResourceDialect,
14075            >,
14076            offset: usize,
14077            _depth: fidl::encoding::Depth,
14078        ) -> fidl::Result<()> {
14079            encoder.debug_check_bounds::<VirtioWaylandGetImporterRequest>(offset);
14080            // Delegate to tuple encoding.
14081            fidl::encoding::Encode::<
14082                VirtioWaylandGetImporterRequest,
14083                fidl::encoding::DefaultFuchsiaResourceDialect,
14084            >::encode(
14085                (
14086                    <fidl::encoding::Endpoint<
14087                        fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
14088                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14089                        &mut self.importer
14090                    ),
14091                ),
14092                encoder,
14093                offset,
14094                _depth,
14095            )
14096        }
14097    }
14098    unsafe impl<
14099            T0: fidl::encoding::Encode<
14100                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>>,
14101                fidl::encoding::DefaultFuchsiaResourceDialect,
14102            >,
14103        >
14104        fidl::encoding::Encode<
14105            VirtioWaylandGetImporterRequest,
14106            fidl::encoding::DefaultFuchsiaResourceDialect,
14107        > for (T0,)
14108    {
14109        #[inline]
14110        unsafe fn encode(
14111            self,
14112            encoder: &mut fidl::encoding::Encoder<
14113                '_,
14114                fidl::encoding::DefaultFuchsiaResourceDialect,
14115            >,
14116            offset: usize,
14117            depth: fidl::encoding::Depth,
14118        ) -> fidl::Result<()> {
14119            encoder.debug_check_bounds::<VirtioWaylandGetImporterRequest>(offset);
14120            // Zero out padding regions. There's no need to apply masks
14121            // because the unmasked parts will be overwritten by fields.
14122            // Write the fields.
14123            self.0.encode(encoder, offset + 0, depth)?;
14124            Ok(())
14125        }
14126    }
14127
14128    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14129        for VirtioWaylandGetImporterRequest
14130    {
14131        #[inline(always)]
14132        fn new_empty() -> Self {
14133            Self {
14134                importer: fidl::new_empty!(
14135                    fidl::encoding::Endpoint<
14136                        fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
14137                    >,
14138                    fidl::encoding::DefaultFuchsiaResourceDialect
14139                ),
14140            }
14141        }
14142
14143        #[inline]
14144        unsafe fn decode(
14145            &mut self,
14146            decoder: &mut fidl::encoding::Decoder<
14147                '_,
14148                fidl::encoding::DefaultFuchsiaResourceDialect,
14149            >,
14150            offset: usize,
14151            _depth: fidl::encoding::Depth,
14152        ) -> fidl::Result<()> {
14153            decoder.debug_check_bounds::<Self>(offset);
14154            // Verify that padding bytes are zero.
14155            fidl::decode!(
14156                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>>,
14157                fidl::encoding::DefaultFuchsiaResourceDialect,
14158                &mut self.importer,
14159                decoder,
14160                offset + 0,
14161                _depth
14162            )?;
14163            Ok(())
14164        }
14165    }
14166
14167    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandImporterExportImageResponse {
14168        type Borrowed<'a> = &'a mut Self;
14169        fn take_or_borrow<'a>(
14170            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14171        ) -> Self::Borrowed<'a> {
14172            value
14173        }
14174    }
14175
14176    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandImporterExportImageResponse {
14177        type Owned = Self;
14178
14179        #[inline(always)]
14180        fn inline_align(_context: fidl::encoding::Context) -> usize {
14181            8
14182        }
14183
14184        #[inline(always)]
14185        fn inline_size(_context: fidl::encoding::Context) -> usize {
14186            16
14187        }
14188    }
14189
14190    unsafe impl
14191        fidl::encoding::Encode<
14192            VirtioWaylandImporterExportImageResponse,
14193            fidl::encoding::DefaultFuchsiaResourceDialect,
14194        > for &mut VirtioWaylandImporterExportImageResponse
14195    {
14196        #[inline]
14197        unsafe fn encode(
14198            self,
14199            encoder: &mut fidl::encoding::Encoder<
14200                '_,
14201                fidl::encoding::DefaultFuchsiaResourceDialect,
14202            >,
14203            offset: usize,
14204            _depth: fidl::encoding::Depth,
14205        ) -> fidl::Result<()> {
14206            encoder.debug_check_bounds::<VirtioWaylandImporterExportImageResponse>(offset);
14207            // Delegate to tuple encoding.
14208            fidl::encoding::Encode::<VirtioWaylandImporterExportImageResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14209                (
14210                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
14211                    <fidl::encoding::Boxed<VirtioImage> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.image),
14212                ),
14213                encoder, offset, _depth
14214            )
14215        }
14216    }
14217    unsafe impl<
14218            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
14219            T1: fidl::encoding::Encode<
14220                fidl::encoding::Boxed<VirtioImage>,
14221                fidl::encoding::DefaultFuchsiaResourceDialect,
14222            >,
14223        >
14224        fidl::encoding::Encode<
14225            VirtioWaylandImporterExportImageResponse,
14226            fidl::encoding::DefaultFuchsiaResourceDialect,
14227        > for (T0, T1)
14228    {
14229        #[inline]
14230        unsafe fn encode(
14231            self,
14232            encoder: &mut fidl::encoding::Encoder<
14233                '_,
14234                fidl::encoding::DefaultFuchsiaResourceDialect,
14235            >,
14236            offset: usize,
14237            depth: fidl::encoding::Depth,
14238        ) -> fidl::Result<()> {
14239            encoder.debug_check_bounds::<VirtioWaylandImporterExportImageResponse>(offset);
14240            // Zero out padding regions. There's no need to apply masks
14241            // because the unmasked parts will be overwritten by fields.
14242            unsafe {
14243                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
14244                (ptr as *mut u64).write_unaligned(0);
14245            }
14246            // Write the fields.
14247            self.0.encode(encoder, offset + 0, depth)?;
14248            self.1.encode(encoder, offset + 8, depth)?;
14249            Ok(())
14250        }
14251    }
14252
14253    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14254        for VirtioWaylandImporterExportImageResponse
14255    {
14256        #[inline(always)]
14257        fn new_empty() -> Self {
14258            Self {
14259                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
14260                image: fidl::new_empty!(
14261                    fidl::encoding::Boxed<VirtioImage>,
14262                    fidl::encoding::DefaultFuchsiaResourceDialect
14263                ),
14264            }
14265        }
14266
14267        #[inline]
14268        unsafe fn decode(
14269            &mut self,
14270            decoder: &mut fidl::encoding::Decoder<
14271                '_,
14272                fidl::encoding::DefaultFuchsiaResourceDialect,
14273            >,
14274            offset: usize,
14275            _depth: fidl::encoding::Depth,
14276        ) -> fidl::Result<()> {
14277            decoder.debug_check_bounds::<Self>(offset);
14278            // Verify that padding bytes are zero.
14279            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
14280            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14281            let mask = 0xffffffff00000000u64;
14282            let maskedval = padval & mask;
14283            if maskedval != 0 {
14284                return Err(fidl::Error::NonZeroPadding {
14285                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
14286                });
14287            }
14288            fidl::decode!(
14289                i32,
14290                fidl::encoding::DefaultFuchsiaResourceDialect,
14291                &mut self.status,
14292                decoder,
14293                offset + 0,
14294                _depth
14295            )?;
14296            fidl::decode!(
14297                fidl::encoding::Boxed<VirtioImage>,
14298                fidl::encoding::DefaultFuchsiaResourceDialect,
14299                &mut self.image,
14300                decoder,
14301                offset + 8,
14302                _depth
14303            )?;
14304            Ok(())
14305        }
14306    }
14307
14308    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandImporterImportImageRequest {
14309        type Borrowed<'a> = &'a mut Self;
14310        fn take_or_borrow<'a>(
14311            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14312        ) -> Self::Borrowed<'a> {
14313            value
14314        }
14315    }
14316
14317    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandImporterImportImageRequest {
14318        type Owned = Self;
14319
14320        #[inline(always)]
14321        fn inline_align(_context: fidl::encoding::Context) -> usize {
14322            8
14323        }
14324
14325        #[inline(always)]
14326        fn inline_size(_context: fidl::encoding::Context) -> usize {
14327            24
14328        }
14329    }
14330
14331    unsafe impl
14332        fidl::encoding::Encode<
14333            VirtioWaylandImporterImportImageRequest,
14334            fidl::encoding::DefaultFuchsiaResourceDialect,
14335        > for &mut VirtioWaylandImporterImportImageRequest
14336    {
14337        #[inline]
14338        unsafe fn encode(
14339            self,
14340            encoder: &mut fidl::encoding::Encoder<
14341                '_,
14342                fidl::encoding::DefaultFuchsiaResourceDialect,
14343            >,
14344            offset: usize,
14345            _depth: fidl::encoding::Depth,
14346        ) -> fidl::Result<()> {
14347            encoder.debug_check_bounds::<VirtioWaylandImporterImportImageRequest>(offset);
14348            // Delegate to tuple encoding.
14349            fidl::encoding::Encode::<
14350                VirtioWaylandImporterImportImageRequest,
14351                fidl::encoding::DefaultFuchsiaResourceDialect,
14352            >::encode(
14353                (<VirtioImage as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14354                    &mut self.image,
14355                ),),
14356                encoder,
14357                offset,
14358                _depth,
14359            )
14360        }
14361    }
14362    unsafe impl<
14363            T0: fidl::encoding::Encode<VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect>,
14364        >
14365        fidl::encoding::Encode<
14366            VirtioWaylandImporterImportImageRequest,
14367            fidl::encoding::DefaultFuchsiaResourceDialect,
14368        > for (T0,)
14369    {
14370        #[inline]
14371        unsafe fn encode(
14372            self,
14373            encoder: &mut fidl::encoding::Encoder<
14374                '_,
14375                fidl::encoding::DefaultFuchsiaResourceDialect,
14376            >,
14377            offset: usize,
14378            depth: fidl::encoding::Depth,
14379        ) -> fidl::Result<()> {
14380            encoder.debug_check_bounds::<VirtioWaylandImporterImportImageRequest>(offset);
14381            // Zero out padding regions. There's no need to apply masks
14382            // because the unmasked parts will be overwritten by fields.
14383            // Write the fields.
14384            self.0.encode(encoder, offset + 0, depth)?;
14385            Ok(())
14386        }
14387    }
14388
14389    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14390        for VirtioWaylandImporterImportImageRequest
14391    {
14392        #[inline(always)]
14393        fn new_empty() -> Self {
14394            Self {
14395                image: fidl::new_empty!(VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect),
14396            }
14397        }
14398
14399        #[inline]
14400        unsafe fn decode(
14401            &mut self,
14402            decoder: &mut fidl::encoding::Decoder<
14403                '_,
14404                fidl::encoding::DefaultFuchsiaResourceDialect,
14405            >,
14406            offset: usize,
14407            _depth: fidl::encoding::Depth,
14408        ) -> fidl::Result<()> {
14409            decoder.debug_check_bounds::<Self>(offset);
14410            // Verify that padding bytes are zero.
14411            fidl::decode!(
14412                VirtioImage,
14413                fidl::encoding::DefaultFuchsiaResourceDialect,
14414                &mut self.image,
14415                decoder,
14416                offset + 0,
14417                _depth
14418            )?;
14419            Ok(())
14420        }
14421    }
14422
14423    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandStartRequest {
14424        type Borrowed<'a> = &'a mut Self;
14425        fn take_or_borrow<'a>(
14426            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14427        ) -> Self::Borrowed<'a> {
14428            value
14429        }
14430    }
14431
14432    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandStartRequest {
14433        type Owned = Self;
14434
14435        #[inline(always)]
14436        fn inline_align(_context: fidl::encoding::Context) -> usize {
14437            8
14438        }
14439
14440        #[inline(always)]
14441        fn inline_size(_context: fidl::encoding::Context) -> usize {
14442            48
14443        }
14444    }
14445
14446    unsafe impl
14447        fidl::encoding::Encode<
14448            VirtioWaylandStartRequest,
14449            fidl::encoding::DefaultFuchsiaResourceDialect,
14450        > for &mut VirtioWaylandStartRequest
14451    {
14452        #[inline]
14453        unsafe fn encode(
14454            self,
14455            encoder: &mut fidl::encoding::Encoder<
14456                '_,
14457                fidl::encoding::DefaultFuchsiaResourceDialect,
14458            >,
14459            offset: usize,
14460            _depth: fidl::encoding::Depth,
14461        ) -> fidl::Result<()> {
14462            encoder.debug_check_bounds::<VirtioWaylandStartRequest>(offset);
14463            // Delegate to tuple encoding.
14464            fidl::encoding::Encode::<
14465                VirtioWaylandStartRequest,
14466                fidl::encoding::DefaultFuchsiaResourceDialect,
14467            >::encode(
14468                (
14469                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14470                        &mut self.start_info,
14471                    ),
14472                    <fidl::encoding::HandleType<
14473                        fidl::Vmar,
14474                        { fidl::ObjectType::VMAR.into_raw() },
14475                        2147483648,
14476                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14477                        &mut self.vmar
14478                    ),
14479                    <fidl::encoding::Endpoint<
14480                        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14481                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14482                        &mut self.sysmem_allocator,
14483                    ),
14484                    <fidl::encoding::Endpoint<
14485                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14486                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14487                        &mut self.scenic_allocator,
14488                    ),
14489                ),
14490                encoder,
14491                offset,
14492                _depth,
14493            )
14494        }
14495    }
14496    unsafe impl<
14497            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
14498            T1: fidl::encoding::Encode<
14499                fidl::encoding::HandleType<
14500                    fidl::Vmar,
14501                    { fidl::ObjectType::VMAR.into_raw() },
14502                    2147483648,
14503                >,
14504                fidl::encoding::DefaultFuchsiaResourceDialect,
14505            >,
14506            T2: fidl::encoding::Encode<
14507                fidl::encoding::Endpoint<
14508                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14509                >,
14510                fidl::encoding::DefaultFuchsiaResourceDialect,
14511            >,
14512            T3: fidl::encoding::Encode<
14513                fidl::encoding::Endpoint<
14514                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14515                >,
14516                fidl::encoding::DefaultFuchsiaResourceDialect,
14517            >,
14518        >
14519        fidl::encoding::Encode<
14520            VirtioWaylandStartRequest,
14521            fidl::encoding::DefaultFuchsiaResourceDialect,
14522        > for (T0, T1, T2, T3)
14523    {
14524        #[inline]
14525        unsafe fn encode(
14526            self,
14527            encoder: &mut fidl::encoding::Encoder<
14528                '_,
14529                fidl::encoding::DefaultFuchsiaResourceDialect,
14530            >,
14531            offset: usize,
14532            depth: fidl::encoding::Depth,
14533        ) -> fidl::Result<()> {
14534            encoder.debug_check_bounds::<VirtioWaylandStartRequest>(offset);
14535            // Zero out padding regions. There's no need to apply masks
14536            // because the unmasked parts will be overwritten by fields.
14537            unsafe {
14538                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
14539                (ptr as *mut u64).write_unaligned(0);
14540            }
14541            // Write the fields.
14542            self.0.encode(encoder, offset + 0, depth)?;
14543            self.1.encode(encoder, offset + 32, depth)?;
14544            self.2.encode(encoder, offset + 36, depth)?;
14545            self.3.encode(encoder, offset + 40, depth)?;
14546            Ok(())
14547        }
14548    }
14549
14550    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14551        for VirtioWaylandStartRequest
14552    {
14553        #[inline(always)]
14554        fn new_empty() -> Self {
14555            Self {
14556                start_info: fidl::new_empty!(
14557                    StartInfo,
14558                    fidl::encoding::DefaultFuchsiaResourceDialect
14559                ),
14560                vmar: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
14561                sysmem_allocator: fidl::new_empty!(
14562                    fidl::encoding::Endpoint<
14563                        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14564                    >,
14565                    fidl::encoding::DefaultFuchsiaResourceDialect
14566                ),
14567                scenic_allocator: fidl::new_empty!(
14568                    fidl::encoding::Endpoint<
14569                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14570                    >,
14571                    fidl::encoding::DefaultFuchsiaResourceDialect
14572                ),
14573            }
14574        }
14575
14576        #[inline]
14577        unsafe fn decode(
14578            &mut self,
14579            decoder: &mut fidl::encoding::Decoder<
14580                '_,
14581                fidl::encoding::DefaultFuchsiaResourceDialect,
14582            >,
14583            offset: usize,
14584            _depth: fidl::encoding::Depth,
14585        ) -> fidl::Result<()> {
14586            decoder.debug_check_bounds::<Self>(offset);
14587            // Verify that padding bytes are zero.
14588            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
14589            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14590            let mask = 0xffffffff00000000u64;
14591            let maskedval = padval & mask;
14592            if maskedval != 0 {
14593                return Err(fidl::Error::NonZeroPadding {
14594                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
14595                });
14596            }
14597            fidl::decode!(
14598                StartInfo,
14599                fidl::encoding::DefaultFuchsiaResourceDialect,
14600                &mut self.start_info,
14601                decoder,
14602                offset + 0,
14603                _depth
14604            )?;
14605            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar, decoder, offset + 32, _depth)?;
14606            fidl::decode!(
14607                fidl::encoding::Endpoint<
14608                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14609                >,
14610                fidl::encoding::DefaultFuchsiaResourceDialect,
14611                &mut self.sysmem_allocator,
14612                decoder,
14613                offset + 36,
14614                _depth
14615            )?;
14616            fidl::decode!(
14617                fidl::encoding::Endpoint<
14618                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14619                >,
14620                fidl::encoding::DefaultFuchsiaResourceDialect,
14621                &mut self.scenic_allocator,
14622                decoder,
14623                offset + 40,
14624                _depth
14625            )?;
14626            Ok(())
14627        }
14628    }
14629
14630    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandStartWithWaylandServerRequest {
14631        type Borrowed<'a> = &'a mut Self;
14632        fn take_or_borrow<'a>(
14633            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14634        ) -> Self::Borrowed<'a> {
14635            value
14636        }
14637    }
14638
14639    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandStartWithWaylandServerRequest {
14640        type Owned = Self;
14641
14642        #[inline(always)]
14643        fn inline_align(_context: fidl::encoding::Context) -> usize {
14644            8
14645        }
14646
14647        #[inline(always)]
14648        fn inline_size(_context: fidl::encoding::Context) -> usize {
14649            48
14650        }
14651    }
14652
14653    unsafe impl
14654        fidl::encoding::Encode<
14655            VirtioWaylandStartWithWaylandServerRequest,
14656            fidl::encoding::DefaultFuchsiaResourceDialect,
14657        > for &mut VirtioWaylandStartWithWaylandServerRequest
14658    {
14659        #[inline]
14660        unsafe fn encode(
14661            self,
14662            encoder: &mut fidl::encoding::Encoder<
14663                '_,
14664                fidl::encoding::DefaultFuchsiaResourceDialect,
14665            >,
14666            offset: usize,
14667            _depth: fidl::encoding::Depth,
14668        ) -> fidl::Result<()> {
14669            encoder.debug_check_bounds::<VirtioWaylandStartWithWaylandServerRequest>(offset);
14670            // Delegate to tuple encoding.
14671            fidl::encoding::Encode::<
14672                VirtioWaylandStartWithWaylandServerRequest,
14673                fidl::encoding::DefaultFuchsiaResourceDialect,
14674            >::encode(
14675                (
14676                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14677                        &mut self.start_info,
14678                    ),
14679                    <fidl::encoding::HandleType<
14680                        fidl::Vmar,
14681                        { fidl::ObjectType::VMAR.into_raw() },
14682                        2147483648,
14683                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14684                        &mut self.vmar
14685                    ),
14686                    <fidl::encoding::Optional<
14687                        fidl::encoding::Endpoint<
14688                            fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
14689                        >,
14690                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14691                        &mut self.wayland_server,
14692                    ),
14693                    <fidl::encoding::Endpoint<
14694                        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14695                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14696                        &mut self.sysmem_allocator,
14697                    ),
14698                    <fidl::encoding::Endpoint<
14699                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14700                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14701                        &mut self.scenic_allocator,
14702                    ),
14703                ),
14704                encoder,
14705                offset,
14706                _depth,
14707            )
14708        }
14709    }
14710    unsafe impl<
14711            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
14712            T1: fidl::encoding::Encode<
14713                fidl::encoding::HandleType<
14714                    fidl::Vmar,
14715                    { fidl::ObjectType::VMAR.into_raw() },
14716                    2147483648,
14717                >,
14718                fidl::encoding::DefaultFuchsiaResourceDialect,
14719            >,
14720            T2: fidl::encoding::Encode<
14721                fidl::encoding::Optional<
14722                    fidl::encoding::Endpoint<
14723                        fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
14724                    >,
14725                >,
14726                fidl::encoding::DefaultFuchsiaResourceDialect,
14727            >,
14728            T3: fidl::encoding::Encode<
14729                fidl::encoding::Endpoint<
14730                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14731                >,
14732                fidl::encoding::DefaultFuchsiaResourceDialect,
14733            >,
14734            T4: fidl::encoding::Encode<
14735                fidl::encoding::Endpoint<
14736                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14737                >,
14738                fidl::encoding::DefaultFuchsiaResourceDialect,
14739            >,
14740        >
14741        fidl::encoding::Encode<
14742            VirtioWaylandStartWithWaylandServerRequest,
14743            fidl::encoding::DefaultFuchsiaResourceDialect,
14744        > for (T0, T1, T2, T3, T4)
14745    {
14746        #[inline]
14747        unsafe fn encode(
14748            self,
14749            encoder: &mut fidl::encoding::Encoder<
14750                '_,
14751                fidl::encoding::DefaultFuchsiaResourceDialect,
14752            >,
14753            offset: usize,
14754            depth: fidl::encoding::Depth,
14755        ) -> fidl::Result<()> {
14756            encoder.debug_check_bounds::<VirtioWaylandStartWithWaylandServerRequest>(offset);
14757            // Zero out padding regions. There's no need to apply masks
14758            // because the unmasked parts will be overwritten by fields.
14759            // Write the fields.
14760            self.0.encode(encoder, offset + 0, depth)?;
14761            self.1.encode(encoder, offset + 32, depth)?;
14762            self.2.encode(encoder, offset + 36, depth)?;
14763            self.3.encode(encoder, offset + 40, depth)?;
14764            self.4.encode(encoder, offset + 44, depth)?;
14765            Ok(())
14766        }
14767    }
14768
14769    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14770        for VirtioWaylandStartWithWaylandServerRequest
14771    {
14772        #[inline(always)]
14773        fn new_empty() -> Self {
14774            Self {
14775                start_info: fidl::new_empty!(
14776                    StartInfo,
14777                    fidl::encoding::DefaultFuchsiaResourceDialect
14778                ),
14779                vmar: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
14780                wayland_server: fidl::new_empty!(
14781                    fidl::encoding::Optional<
14782                        fidl::encoding::Endpoint<
14783                            fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
14784                        >,
14785                    >,
14786                    fidl::encoding::DefaultFuchsiaResourceDialect
14787                ),
14788                sysmem_allocator: fidl::new_empty!(
14789                    fidl::encoding::Endpoint<
14790                        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14791                    >,
14792                    fidl::encoding::DefaultFuchsiaResourceDialect
14793                ),
14794                scenic_allocator: fidl::new_empty!(
14795                    fidl::encoding::Endpoint<
14796                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14797                    >,
14798                    fidl::encoding::DefaultFuchsiaResourceDialect
14799                ),
14800            }
14801        }
14802
14803        #[inline]
14804        unsafe fn decode(
14805            &mut self,
14806            decoder: &mut fidl::encoding::Decoder<
14807                '_,
14808                fidl::encoding::DefaultFuchsiaResourceDialect,
14809            >,
14810            offset: usize,
14811            _depth: fidl::encoding::Depth,
14812        ) -> fidl::Result<()> {
14813            decoder.debug_check_bounds::<Self>(offset);
14814            // Verify that padding bytes are zero.
14815            fidl::decode!(
14816                StartInfo,
14817                fidl::encoding::DefaultFuchsiaResourceDialect,
14818                &mut self.start_info,
14819                decoder,
14820                offset + 0,
14821                _depth
14822            )?;
14823            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar, decoder, offset + 32, _depth)?;
14824            fidl::decode!(
14825                fidl::encoding::Optional<
14826                    fidl::encoding::Endpoint<
14827                        fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
14828                    >,
14829                >,
14830                fidl::encoding::DefaultFuchsiaResourceDialect,
14831                &mut self.wayland_server,
14832                decoder,
14833                offset + 36,
14834                _depth
14835            )?;
14836            fidl::decode!(
14837                fidl::encoding::Endpoint<
14838                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14839                >,
14840                fidl::encoding::DefaultFuchsiaResourceDialect,
14841                &mut self.sysmem_allocator,
14842                decoder,
14843                offset + 40,
14844                _depth
14845            )?;
14846            fidl::decode!(
14847                fidl::encoding::Endpoint<
14848                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14849                >,
14850                fidl::encoding::DefaultFuchsiaResourceDialect,
14851                &mut self.scenic_allocator,
14852                decoder,
14853                offset + 44,
14854                _depth
14855            )?;
14856            Ok(())
14857        }
14858    }
14859
14860    impl fidl::encoding::ResourceTypeMarker for InputType {
14861        type Borrowed<'a> = &'a mut Self;
14862        fn take_or_borrow<'a>(
14863            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14864        ) -> Self::Borrowed<'a> {
14865            value
14866        }
14867    }
14868
14869    unsafe impl fidl::encoding::TypeMarker for InputType {
14870        type Owned = Self;
14871
14872        #[inline(always)]
14873        fn inline_align(_context: fidl::encoding::Context) -> usize {
14874            8
14875        }
14876
14877        #[inline(always)]
14878        fn inline_size(_context: fidl::encoding::Context) -> usize {
14879            16
14880        }
14881    }
14882
14883    unsafe impl fidl::encoding::Encode<InputType, fidl::encoding::DefaultFuchsiaResourceDialect>
14884        for &mut InputType
14885    {
14886        #[inline]
14887        unsafe fn encode(
14888            self,
14889            encoder: &mut fidl::encoding::Encoder<
14890                '_,
14891                fidl::encoding::DefaultFuchsiaResourceDialect,
14892            >,
14893            offset: usize,
14894            _depth: fidl::encoding::Depth,
14895        ) -> fidl::Result<()> {
14896            encoder.debug_check_bounds::<InputType>(offset);
14897            encoder.write_num::<u64>(self.ordinal(), offset);
14898            match self {
14899                InputType::Keyboard(ref mut val) => fidl::encoding::encode_in_envelope::<
14900                    fidl::encoding::Endpoint<
14901                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
14902                    >,
14903                    fidl::encoding::DefaultFuchsiaResourceDialect,
14904                >(
14905                    <fidl::encoding::Endpoint<
14906                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
14907                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14908                        val
14909                    ),
14910                    encoder,
14911                    offset + 8,
14912                    _depth,
14913                ),
14914                InputType::Mouse(ref mut val) => fidl::encoding::encode_in_envelope::<
14915                    fidl::encoding::Endpoint<
14916                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14917                    >,
14918                    fidl::encoding::DefaultFuchsiaResourceDialect,
14919                >(
14920                    <fidl::encoding::Endpoint<
14921                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14922                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14923                        val
14924                    ),
14925                    encoder,
14926                    offset + 8,
14927                    _depth,
14928                ),
14929            }
14930        }
14931    }
14932
14933    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for InputType {
14934        #[inline(always)]
14935        fn new_empty() -> Self {
14936            Self::Keyboard(fidl::new_empty!(
14937                fidl::encoding::Endpoint<
14938                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
14939                >,
14940                fidl::encoding::DefaultFuchsiaResourceDialect
14941            ))
14942        }
14943
14944        #[inline]
14945        unsafe fn decode(
14946            &mut self,
14947            decoder: &mut fidl::encoding::Decoder<
14948                '_,
14949                fidl::encoding::DefaultFuchsiaResourceDialect,
14950            >,
14951            offset: usize,
14952            mut depth: fidl::encoding::Depth,
14953        ) -> fidl::Result<()> {
14954            decoder.debug_check_bounds::<Self>(offset);
14955            #[allow(unused_variables)]
14956            let next_out_of_line = decoder.next_out_of_line();
14957            let handles_before = decoder.remaining_handles();
14958            let (ordinal, inlined, num_bytes, num_handles) =
14959                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
14960
14961            let member_inline_size = match ordinal {
14962                1 => <fidl::encoding::Endpoint<
14963                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
14964                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
14965                2 => <fidl::encoding::Endpoint<
14966                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14967                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
14968                _ => return Err(fidl::Error::UnknownUnionTag),
14969            };
14970
14971            if inlined != (member_inline_size <= 4) {
14972                return Err(fidl::Error::InvalidInlineBitInEnvelope);
14973            }
14974            let _inner_offset;
14975            if inlined {
14976                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
14977                _inner_offset = offset + 8;
14978            } else {
14979                depth.increment()?;
14980                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14981            }
14982            match ordinal {
14983                1 => {
14984                    #[allow(irrefutable_let_patterns)]
14985                    if let InputType::Keyboard(_) = self {
14986                        // Do nothing, read the value into the object
14987                    } else {
14988                        // Initialize `self` to the right variant
14989                        *self = InputType::Keyboard(fidl::new_empty!(
14990                            fidl::encoding::Endpoint<
14991                                fidl::endpoints::ServerEnd<
14992                                    fidl_fuchsia_ui_input3::KeyboardListenerMarker,
14993                                >,
14994                            >,
14995                            fidl::encoding::DefaultFuchsiaResourceDialect
14996                        ));
14997                    }
14998                    #[allow(irrefutable_let_patterns)]
14999                    if let InputType::Keyboard(ref mut val) = self {
15000                        fidl::decode!(
15001                            fidl::encoding::Endpoint<
15002                                fidl::endpoints::ServerEnd<
15003                                    fidl_fuchsia_ui_input3::KeyboardListenerMarker,
15004                                >,
15005                            >,
15006                            fidl::encoding::DefaultFuchsiaResourceDialect,
15007                            val,
15008                            decoder,
15009                            _inner_offset,
15010                            depth
15011                        )?;
15012                    } else {
15013                        unreachable!()
15014                    }
15015                }
15016                2 => {
15017                    #[allow(irrefutable_let_patterns)]
15018                    if let InputType::Mouse(_) = self {
15019                        // Do nothing, read the value into the object
15020                    } else {
15021                        // Initialize `self` to the right variant
15022                        *self = InputType::Mouse(fidl::new_empty!(
15023                            fidl::encoding::Endpoint<
15024                                fidl::endpoints::ClientEnd<
15025                                    fidl_fuchsia_ui_pointer::MouseSourceMarker,
15026                                >,
15027                            >,
15028                            fidl::encoding::DefaultFuchsiaResourceDialect
15029                        ));
15030                    }
15031                    #[allow(irrefutable_let_patterns)]
15032                    if let InputType::Mouse(ref mut val) = self {
15033                        fidl::decode!(
15034                            fidl::encoding::Endpoint<
15035                                fidl::endpoints::ClientEnd<
15036                                    fidl_fuchsia_ui_pointer::MouseSourceMarker,
15037                                >,
15038                            >,
15039                            fidl::encoding::DefaultFuchsiaResourceDialect,
15040                            val,
15041                            decoder,
15042                            _inner_offset,
15043                            depth
15044                        )?;
15045                    } else {
15046                        unreachable!()
15047                    }
15048                }
15049                ordinal => panic!("unexpected ordinal {:?}", ordinal),
15050            }
15051            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
15052                return Err(fidl::Error::InvalidNumBytesInEnvelope);
15053            }
15054            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15055                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15056            }
15057            Ok(())
15058        }
15059    }
15060}